我已经使用 Fortran 90 一段时间了,最近决定使用 f2py 封装一些模块,以使用 Python 作为前端来简化原型设计。
\n\n但是,在尝试编译传递外部函数(来自 Python)的子例程时,我遇到了错误。这是复制错误的代码:
\n\n! file: callback.f90\nsubroutine callback(f,x,y)\n implicit none\n ! - args -\n ! in\n external :: f\n real(kind=kind(0.0d0)), intent(in) :: x\n ! out\n real(kind=kind(0.0d0)), intent(inout) :: y\n\n y = f(x)\nend subroutine\nRun Code Online (Sandbox Code Playgroud)\n\n现在,如果我使用 f2py 生成签名文件 (.pyf),我将获得以下结果:
\n\n! -*- f90 -*- \n! Note: the context of this file is case sensitive.\npython module callback__user__routines \ninterface callback_user_interface \n function f(x) result (y) ! in :callback:callback.f90\n intent(inout) f\n real(kind=kind(0.0d0)) intent(in) :: x\n real(kind=kind(0.0d0)) …Run Code Online (Sandbox Code Playgroud)