[f2py] extcallback arguments problem

Marek Wojciechowski mwojc at p.lodz.pl
Fri May 4 20:47:28 EEST 2007


Hi!
I'd like to present a problem with modified extcallback.f extension (from
f2py userguide):
ccccccccccccccccccccccccccccccccccccccccccccccccccccccc
      subroutine f1()
         print *, "in f1, calling f2 twice.."
         call f2()
         call f2()
         return
      end
      
      subroutine f2()
cf2py    intent(callback, hide) fpy
         external fpy
         integer a, b
         print *, "in f2, calling f2py.."
         a = 1
         b = 2
         call fpy(a, b)  
         !modification above - callback function fpy has 
         !some arguments now
         return
      end
ccccccccccccccccccccccccccccccccccccccccccccccccccccccc

Compiling the modified extension and calling f1 routine
in python gives the exception (f2 however goes nicely):
#######################################################
import extcallback
def fpy(a, b): print a+b
extcallback.fpy = fpy
extcallback.f2()
 in f2, calling f2py..
3
extcallback.f2()
 in f1, calling f2 twice..
 in f2, calling f2py..
capi_return is NULL
Call-back cb_fpy_in_f2__user__routines failed.
 in f2, calling f2py..
capi_return is NULL
Call-back cb_fpy_in_f2__user__routines failed
TypeError: fpy() takes exactly 2 arguments (0 given)
#######################################################

I suppose this error should not occure. Any solutions (workarounds)?

Regards
-- 
Marek Wojciechowski




More information about the f2py-users mailing list