Linux 컴퓨터에서 사용하고 gfortran을 사용하여 컴파일 한 fortran 90 프로그램을 만들었습니다. 그것은 gfortran와 리눅스 시스템에서 잘 작동하지만, 플라톤 컴파일러 (FTN95)를 사용할 때 오류인터페이스를 사용하는 서브 루틴에 인수로 함수를 전달하는 기능이 Plato Fortran 90에서 작동하지 않습니다.
error 327 - In the INTERFACE to SECANTMETHOD (from MODULE SECMETH), the ninth dummy argument (F) was of type REAL(KIND=2) FUNCTION, whereas the actual argument is of type REAL(KIND=2)
을 제공합니다. 누구든지 내 코드를 Plato에서 작동하도록 변경해야하는 방법을 알고 있습니까? 이 오류에 대해 읽으려고했지만 포인터에 대한 언급이 있지만 작동하지 않는 부분에서 언급했습니다. 몇 가지 해결 방법을 알아 냈지만 서브 루틴이 더 이상 인수로 함수를 받아들이지 못하게 만듭니다. 이는 거의 쓸모가 없습니다. 어떤 도움이라도 대단히 감사하겠습니다. 내 코드는 아래와 같습니다.
!--! A module to define a real number precision.
module types
integer, parameter :: dp=selected_real_kind(15)
end module types
module secFuncs
contains
function colebrookWhite(T)
use types
real(dp) :: colebrookWhite
real(dp), intent(in) :: T
colebrookwhite=25-T**2
return
end function colebrookWhite
end module secFuncs
module secMeth
contains
subroutine secantMethod(xolder,xold,xnew,epsi1,epsi2,maxit,exitFlag,numit,f)
use types
use secFuncs
implicit none
interface
function f(T)
use types
real(dp) :: f
real(dp), intent(in) :: T
end function f
end interface
real(dp), intent(in) :: epsi1, epsi2
real(dp), intent(inout) :: xolder, xold
real(dp), intent(out) :: xnew
integer, intent(in) :: maxit
integer, intent(out) :: numit, exitFlag
real(dp) :: fxold, fxolder, fxnew
integer :: i
fxolder = f(xolder)
fxold = f(xold)
i = 0
do
i = i + 1
xnew = xold - fxold*(xold-xolder)/(fxold-fxolder)
fxnew = f(xnew)
if (i == maxit) then
exitFlag = 1
numit = i
return
else if (abs(fxnew) < epsi1) then
exitFlag = 2
numit = i
return
else if (abs(xnew - xold) < epsi2) then
exitFlag = 3
numit = i
return
end if
xolder = xold
xold = xnew
fxolder = fxold
fxold = fxnew
end do
end subroutine secantMethod
end module secMeth
program secantRoots
use types
use secMeth
use secFuncs
implicit none
real(dp) :: x1, x2, xfinal, epsi1, epsi2
integer :: ioerror, maxit, numit, exitFlag
do
write(*,'(A)',advance="no")"Please enter two initial root estimates, 2epsi's, and maxit: "
read(*,*,iostat=ioerror) x1, x2, epsi1, epsi2, maxit
if (ioerror /= 0) then
write(*,*)"Invalid input."
else
exit
end if
end do
call secantMethod(x1,x2,xfinal,epsi1,epsi2,maxit,exitFlag,numit,colebrookWhite)
if (exitFlag == 1) then
write(*,*)"The maximum number of iterations was reached."
else if (exitFlag == 2) then
write(*,'(a,f5.3,a,i3,a)')"The root is ", xfinal, ", which was reached in ", numit, " iterations."
else if (exitFlag == 3) then
write(*,'(a,i3,a)')"There is slow or no progress at ", numit, " iterations."
end if
end program secantRoots
죄송합니다. 포함 시키려고하지 않았습니다. 실제로 디버깅하려고 할 때 추가했습니다. (원래의 게시물에서 삭제했습니다.) 괄호가 없으면 프로그램이 실행되고 입력 사항을 묻습니다. 입력을 입력 할 때 "프로 시저가 필요할 때 인수가 9 인 실제 (kind = 2) 루틴을 호출하려고 시도합니다"라는 오류가 발생하면 오류의 세부 정보는 "SECMETH! SECANTMETHOD - 파일 secantnew .f90 라인 19 [+ 00a4] SECANTROOTS - 파일 secantnew.f90의 100 행 [+0274] "에 있습니다. 이 오류가 발생하는 이유와 플라톤에서 작동하도록 수정하는 방법에 대한 아이디어가 있습니까? 도와 주셔서 감사합니다! – ryanDavid