現在f2py
、Fortran コードから Python 関数を呼び出すために を使用しています。非常に簡単な例を試しましたが、うまくいきませんでした。
Fortran90 コード:
subroutine foo(fun,r)
external fun
integer ( kind = 4 ) i
real ( kind = 8 ) r
r=0.0D+00
do i= 1,5
r=r+fun(i)
enddo
end
コマンドラインを使用:
f2py -c -m コールバック callback.f90
Python コード:
import callback
def f(i):
return i * i
print callback.foo(f)
エラー:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: `Required argument 'r' (pos 2) not found`