[f2py] Callback help
Anand Patil
anand at soe.ucsc.edu
Fri May 4 20:30:53 EEST 2007
Hi all,
I'm having a very hard time figuring out why this is crashing, any help
is greatly appreciated. My intent is to have col_fun(i), where i is an
integer, return a double precision array. It would also be acceptable to
have col_fun overwrite a double-precision array in-place, if that's easier.
Fortran:
SUBROUTINE incomplete_chol(diag,col_fun,N,ndmax,sig,nd)
cf2py integer intent(hide), depend(diag):: N = len(diag)
cf2py double precision intent(out),dimension(ndmax,N)::sig
cf2py integer intent(in)::ndmax
cf2py integer intent(out)::nd
cf2py double precision dimension(N), intent(in)::diag
cf2py intent(callback) col_fun
EXTERNAL col_fun
cf2py integer p
cf2py double precision new_col(N)
cf2py new_col=col_fun(p)
double precision sig(N,ndmax), diag(N), col(N)
integer ndmax, nd, N, i, j
i=0
col = col_fun(i)
print *, col
return
end
Python:
diag = ones(10)
def col_fun(i):
return i*ones(10)
ndmax = 3
print incomplete_chol(diag,col_fun,ndmax)
Many thanks in advance,
Anand Patil
More information about the f2py-users
mailing list