Hi all, I'm trying to hide the actual python callback function on the fortran side as well as on the python side. See the example: I want f1 to be the wrapper of my callback, f2 is a second level where the user has no arg to pass. But if I call f2, for example in f3, the callback is 'propagated' and I have to declare it the same way as in f2. Is there a trick to stop this propagation? subroutine f1(p,t) cf2py intent(callback) push_back_path cf2py optional push_back_path cf2py external push_back_path character(len=*) p character(len=*) t call push_back_path(p,t) return end subroutine f2() cf2py intent(callback) push_back_path cf2py optional push_back_path cf2py external push_back_path cf2py use f1__user__routines character(len=96) p character(len=32) t p='/usr' t='local' call f1(p,t) t='lib' call f1(p,t) return end subroutine f3() call f2() end The python test: # ----------------------------------------------- # f2py -c pathutils.for -m pathutils # python pathtest.py import pathutils import string def push_back_path(p,t): p=p.strip() t=t.strip() p=string.ljust(p+'/'+t,96) print 'PUSH_BACK_PATH [%s]'%p pathutils.push_back_path=push_back_path print 'F1' pathutils.f1('/usr','bin') print 'F2' # Hiding on python side is ok pathutils.f2() # Hiding on fortran side fails print 'F3' pathutils.f3() Which leads to: $ python pathtest.py F1 PUSH_BACK_PATH [/usr/bin ] F2 PUSH_BACK_PATH [/usr/local ] PUSH_BACK_PATH [/usr/lib ] F3 capi_return is NULL Call-back cb_push_back_path_in_f1__user__routines failed. capi_return is NULL Call-back cb_push_back_path_in_f1__user__routines failed. Traceback (most recent call last): File "pathtest.py", line 20, in <module> pathutils.f3() TypeError: push_back_path() takes exactly 2 arguments (0 given) TIA -MP- ----------------------------------------------------------------------- Marc POINOT [ONERA/DSNA] Tel:+33.1.46.73.42.84 Fax:+33.1.46.73.41.66 Avertissement/disclaimer http://www.onera.fr/onera-en/emails-terms
participants (1)
-
Marc Poinot