[f2py] callback error
段丞博
lilyphysik at gmail.com
Thu Apr 8 04:58:53 EEST 2010
hi,
I have trouble with the callback usage in f2py. I rewrote the example in the
f2py usersguide
in the f90 format. But it can't work in the right way. In fortran code,I
output the return value
of the function defined in python side and found the external function
always return zero. I
paste the related files. Please assist. Thanks in advance!
Duan
test1.f90
subroutine foo(fun,r)
external fun
integer:: i,fun
real(8)::r
!f2py intent(out) r
r=0.0d0
do i=-5,5
r=r+fun(i)
write(*,*) r,fun(i)
end do
end subroutine foo
test1.pyf
! -*- f90 -*-
! Note: the context of this file is case sensitive.
python module foo__user__routines
interface foo_user_interface
function fun(i) result (r) ! in
:test1:test1.f90:foo:unknown_interface
integer :: i
real(kind=8) :: r
end function fun
end interface foo_user_interface
end python module foo__user__routines
python module test1 ! in
interface ! in :test1
subroutine foo(fun,r) ! in :test1:test1.f90
use foo__user__routines
external fun
real(kind=8) intent(out) :: r
end subroutine foo
end interface
end python module test1
! This file was auto-generated with f2py (version:2).
! See http://cens.ioc.ee/projects/f2py2e/
test1.py
#!/home/dcb/python/bin/python
from test1 import *
def f(i):
print i
return i*i
a=foo(f)
--
段丞博
--------------------------------------------
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://cens.ioc.ee/pipermail/f2py-users/attachments/20100408/906ac008/attachment.htm
More information about the f2py-users
mailing list