fortran是否可以在subroutine 中调用function?
答案是可以的:
real function add(a,b)
implicit none
real::a,b
add=a+b
return
end
subroutine total(c)
implicit none
real::a,b,c
real,external::add !声时add是一个函数而不是变量
a=1.0
b=2.0
c=add(a,b) !直接调用add就可以返回了
return
end

我的微信公众号
分享科研软件、科研方法,为你的科研助力。
评论