안녕하세요. 아래에 나와있는 오류 메시지 중 하나를 강조하기 위해 최소한의 완전하고 검증 가능한 예제 코드를 만들려고했습니다. "(1)에서 인수 'func0'에 유형 불일치가 발생하여 REAL (4)에서 COMPLEX (4)로 전달됨오류가 발생했습니다.
(1)의 오류 메시지가 표시된 코드에 표시됩니다. 또 다른 서브 루틴 내에서 서브 루틴을 호출하려고합니다. 제가 원래 Sub2라는으로 암시 아무것도 추가하지하려고
그러나 그때 func0, FUNC1 암시 적 유형이없는 없다는 오류 메시지가 표시됩니다.
내가 논리를 따라 시도 이 게시물의 내용 : How to call and use a subroutine inside another subroutine in fortran?
Module Sample
integer :: n,m
contains
subroutine Sub1(func0,func1)
implicit none
complex, dimension(-10:10, -10:10), intent(inout) :: func0,func1
complex, dimension(-10:10, -10:10) :: Deriv0,Deriv1
do while (100 > 0.000001)
Deriv0 = Deriv(func0)
Deriv1 = Deriv(func1)
end do
end subroutine Sub1
subroutine Sub2(func3)
!implicit none : if this line is not commented out, I still get error messages saying func0,func1 do not have implicit types
real,dimension(0:20), intent(inout) :: Func3
call Sub1(func0,func1) !error message from here, this is line (1)
end subroutine Sub2
function Deriv(func)
implicit none
complex, dimension(-10:10, -10:10) :: func, Deriv
do n=-9,9
do m=-9,9
Deriv(n,m) = func(n+1,m)-2*func(n,m)
end do
end do
end function Deriv
End Module Sample
어떻게이 오류를 해결할 수 있습니까? 감사.
이것은 나를 위해 매우 도움이됩니다. 나는 당신이 제안한 것처럼 sub2에서 func0, func1을 선언함으로써 오류를 수정할 수 있었다. 또한 암시적인 none을 모듈에 추가했습니다. 다른 모든 설명에도 많은 감사를드립니다. 내가 궁금한 점이 있으면 알려 드리 겠지만 지금은 그렇지 않다. 아주 분명하다. 감사! –