[Numpy-discussion] f2py: Can anyone tell me why this simple call-back example fails?
Wed Nov 12 18:06:44 CST 2008
Ubuntu v8.0.4; Gnu gcc v4.0.3; g95 v0.92
Python v2.5.2; Numpy v1.2.1; f2py v2.5972
Hope someone can see what's wrong here?
..............Here is the F90 code...........
! PROGRAM TO DEMONSTRATE PYTHON-->F90 AND F90-->PYTHON INTERFACE
SUBROUTINE CBSET(N, call_back)
!f2py intent(in) N
!f2py intent(callback) call_back
INTEGER N, m
! IDENTIFY THAT FORTRAN IS EXECUTING & WHO CALLED CBSET
PRINT *,'Enter CBSET.F, N=',N
IF(N .EQ. 1) THEN
PRINT *,' in CBSET: This Call originated to test call-back'
PRINT *,' in CBSET: Make callback to PYTHON...EXPECT reply'
PRINT *,' in CBSET: Returned from call-back to PYTHON'
IF(N .EQ. 2) THEN
PRINT *,' in CBSET: Call came from Python to test Py->For'
..............Here is the f2py created Signature code...........
! -*- f90 -*-
! Note: the context of this file is case sensitive.
python module cbset__user__routines
subroutine call_back(m) ! in :foo:CBSET.F90:cbset:unknown_interface
integer :: m
end subroutine call_back
end interface cbset_user_interface
end python module cbset__user__routines
python module foo ! in
interface ! in :foo
subroutine cbset(n) ! in :foo:CBSET.F90
integer intent(in) :: n
end subroutine cbset
end python module foo
! This file was auto-generated with f2py (version:2_5972).
! See http://cens.ioc.ee/projects/f2py2e/
..............Here is the Python Main Program code...........
# Main Python program to test nominal "wrap" and "call back"
print 'HELLO, pymain is about to call CBSET to test f2py operation'
print 'BUT, 1st test call_back subr from within python itself'
#test "Python --> FORTRAN" (nominal wrap) from Python
print 'NOW, call CBSET to test Python --> FORTRAN wrap'
n = 2
#test "FORTRAN --> Python" (call-back) scheme as seen from Python
print 'NOW, call CBSET to test FORTRAN --> Python call-back'
n = 1
# define call-back routine
print '..Confirming call_back, Python is entered from Fortran'
print '..in call_back: m = ', m
# end of call-back defn
if __name__ =='__main__':
..............Here is the execution result...........
david@david-desktop:~/Pyth/ACB$ python pymain.py
HELLO, pymain is about to call CBSET to test f2py operation
BUT, 1st test call_back subr from within python itself
..Confirming call_back, Python is entered from Fortran
..in call_back: m = 999
NOW, call CBSET to test Python --> FORTRAN wrap
Enter CBSET.F, N= 2
in CBSET: Call came from Python to test Py->For
NOW, call CBSET to test FORTRAN --> Python call-back
Enter CBSET.F, N= 1
in CBSET: this Call originated to test call-back
in CBSET: Make callback to PYTHON...EXPECT reply
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Numpy-discussion