我有一个子例程(最小示例)
subroutine treatfunction(f,input,output)
external, real::f
real, intent(in):: input
real, intent(out):: output
output = f(input) + f(1.0) ! i.e. f has only one argument
end subroutine
Run Code Online (Sandbox Code Playgroud)
和带有两个参数的函数
real function fun(x,a)
real,intent(in)::x,a
Run Code Online (Sandbox Code Playgroud)
现在,对于a运行时的给定值,我想传递fun给treatfunction。所以理想情况下,我想称呼类似
call treatfunction(fun(:,a=a0), input=myinput, output=myoutput)
Run Code Online (Sandbox Code Playgroud)
使用Fortran2003功能gfortran-5支持进行此操作的最优雅的方法是什么?
当然,我可以在其中插入一个可选的哑元参数a,treatfunction并在子例程的主体中f使用f(x)或f(x,a)视情况present(a)而定。但是更改子例程并不理想。
在 strptime 和 as.POSIXct 的帮助下,POSIXlt 和 POSIXct 类似乎只记录整秒。
(我需要毫秒将它们作为种子传递给共享对象中的随机数生成器。)