传递函数时Fortran错误

Bil*_* TP 0 fortran function

我正在尝试编写一个简单的Fortran代码来计算h = g(f(x)).x是长度= 2的向量.

module m1
implicit none
contains

function f(x)
implicit none
real::f(2),x(2)
f(1)=x(1)-x(2)
f(2)=exp(x(1))-x(2)**2
end function f

function g(ff)
implicit none
real::g(2),x1(2),ffreslt(2)
interface
    function ff(x)
    implicit none
    real::x(2),ff(2)
    end function ff
end interface
ffreslt=ff(x1)
g(1)=1-ffreslt(1)
g(2)=2*ffreslt(1)**2-3*ffreslt(2)+4.2
end function g

end module m1

program hgf
use m1
implicit none
real::x1(2),h(2)
x1 = (/0.55,2.47/)
h = g(f(x1))

write(*,*) h

end program hgf
Run Code Online (Sandbox Code Playgroud)

但是,我收到此错误消息:

h = g(f(x1))
      1
Error: Actual parameter 'ff' at <1> is not a PROCEDURE
Run Code Online (Sandbox Code Playgroud)

我错过了什么吗?谢谢.

Ric*_*ers 5

在对g()的调用中,您没有传递函数f(),而是使用值x1调用函数f()的结果.

检查这从F77转换成F90注意事项,并期待在第24页,第3.2.7节.

另请将此问题作为参数检查.