从 C 调用 Fortran 77
我在 fortran 77 中有一个 ema 函数。我如何从 C 调用 fortran 函数。我知道在 fortran 2003 中有一个 iso_c_bindings 但我需要一些针对旧 77 标准的解决方案。
subroutine ema(inarray,leninarray,n,outarray,lenoutarray)
integer leninarray, lenoutarray, n, i
double precision inarray(leninarray), outarray(lenoutarray)
do 10 i = n+1, leninarray
outarray = inarray(i) * (1/n) + outarray(i-1) * (1-(1/n))
continue
end
感谢您的帮助 问候
I have an ema function in fortran 77. How can I call to fortran function from C. I know that in fortran 2003 there is a iso_c_bindings but I need some solution for old 77 standard.
subroutine ema(inarray,leninarray,n,outarray,lenoutarray)
integer leninarray, lenoutarray, n, i
double precision inarray(leninarray), outarray(lenoutarray)
do 10 i = n+1, leninarray
outarray = inarray(i) * (1/n) + outarray(i-1) * (1-(1/n))
continue
end
Thanks for any help
regards
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Fortran 的调用约定与 C 几乎相同,但有以下差异:
例如,如果您有一个 Fortran 例程,
它会变成
或
取决于您的机器。在 C++ 中,
您希望或不要忘记 fortran 数组从 1 开始。
当您将索引传递给例程时,
Fortran has pretty much the same calling convention as C, but with the following differences:
E.g. if you have a fortran routine
it turns into
or
depending on your machine. In C++ you want
or
Don't forget that fortran arrays start as 1 when you pass indices to the routines.