Hi all-

   I've run into what I think might be a bug in f2py and callbacks to
python.  Or, maybe I'm not using things correctly.  I have created a
very minimal example which illustrates my problem at:

https://github.com/soylentdeen/fluffy-kumquat

The issue seems to affect call backs with variables, but only when they
are called indirectly (i.e. from other fortran routines).  For example,
if I have a python function

def show_number(n):
    print("%d" % n)

and I setup a callback in a fortran routine:

      subroutine cb
cf2py intent(callback, hide) blah
      external blah
      call blah(5)
      end

and connect it to the python routine
fortranObject.blah = show_number

I can successfully call the cb routine from python:

>fortranObject.cb
5

However, if I call the cb routine from within another fortran routine,
it seems to lose its marbles

      subroutine no_cb
      call cb
      end

capi_return is NULL
Call-back cb_blah_in_cb__user__routines failed.

For more information, please have a look at the github repository.  I've
reproduced the behavior on both linux and mac.  I'm not sure if this is
an error in the way I'm using the code, or if it is an actual bug.  Any
and all help would be very much appreciated.

Cheers,
Casey


-- 
Dr. Casey Deen
Post-doctoral Researcher
d...@mpia.de                       +49-6221-528-375
Max Planck Institut für Astronomie (MPIA)
Königstuhl 17  D-69117 Heidelberg, Germany
_______________________________________________
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion

Reply via email to