子程序能作为参数传递吗?
本帖最后由 shrine 于 2017-7-8 10:40 编辑最近在看最小二乘法minpack,简洁起见,过多参数用省略号表示,fcn是需要自己提供的
subroutine lmder(fcn,......wa4)
integer ....
double .....
call fcn(m,n,x,fvec,fjac,ldfjac,iflag)
end
既然要call fcn,那肯定是subroutine,而不是function,但是subroutine怎么能作为参数传递呢?
方法1(假设 fcn 返回 real 类型):
Subroutine Imder( fcn , ... )
Real , external :: fcn
y = fcn(x)
方法2:
Subroutine Imder( fcn , ... )
Interface
real function fcn( x )
real :: x
end function fcn
End Interface
y = fcn(x)
蒐集來的資料, 敬請參考:
页:
[1]