[f2py] Re: Callback help

Marek Wojciechowski mwojc at p.lodz.pl
Wed May 9 01:36:21 EEST 2007


> I'd like to amend my previous question: all I really need is a working
> example of a callback that either returns an array or overwrites one
> in-place. Does anyone have one laying around?

in fortran...
      subroutine callback(n, fun)
        integer i, n
        double precision arr(n)
        external fun

        i = 10
        call fun(i, arr, n)
        print *, arr

      return
      end

in python...
def fun(i, arr):
    arr[:] = float(i)
callback(5, fun)

I hope this solve your problem.

Greetings
-- 
Marek Wojciechowski




More information about the f2py-users mailing list