[Numpy-discussion] f2py : callbacks without callback function as an argument

Daniel Creveling dancrev@yahoo....
Wed Mar 12 01:38:12 CDT 2008


Is there a way to code a callback to python from
fortran in a way such that the calling routine does
not need the callback function as an input argument? 
I'm using the Intel fortran compiler for linux with
numpy 1.0.4 and f2py gives version 2_4422.  My modules
crash on loading because the external callback
function is not set.  I noticed in the release notes
for f2py 2.46.243 that it was a resolved issue, but I
don't know how that development compares to version
2_4422 that comes with numpy.

The example that I was trying to follow is from some
documentation off of the web:

      subroutine f1()
        print *, "in f1, calling f2 twice.."
        call f2()
        call f2()

      subroutine f2()
cf2py intent(callback, hide) fpy
        external fpy
        print *, "in f2, calling fpy.."
        call fpy()

f2py -c -m pfromf extcallback.f

I'm supposed to be able to define the callback
function from Python like:
>>> import pfromf
>>> def f(): print "This is Python"
>>> pfromf.fpy = f

but I am unable to even load the module:
>>> import pfromf
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: ./pfromf.so: undefined symbol: fpy_

Any ideas?
Thank you-

Looking for last minute shopping deals?  
Find them fast with Yahoo! Search.  http://tools.search.yahoo.com/newsearch/category.php?category=shopping

More information about the Numpy-discussion mailing list