I have a Fortran shared library specified by:
C FILE: OTHER.F
SUBROUTINE OTHER(FUN)
EXTERNAL FUN
INTEGER I
DO I=0,5
PRINT *, FUN(I)
ENDDO
END SUBROUTINE
C END OF FILE OTHER.F
Which I compiled as follows: gfortran -shared -O2 other.f -o libother.so -fPIC
I have now another module:
C FILE: CALLBACK.F
SUBROUTINE FOO(FUN,R)
EXTERNAL FUN
INTEGER I
REAL*8 R
R = 0D0
DO I=-5,5
PRINT *, FUN(I)
R = R + FUN(I)
ENDDO
CALL OTHER(FUN)
END SUBROUTINE
C END OF FILE CALLBACK.F
And I wish to compile this module as a python module, using f2py. To achieve this, I have entered:
f2py -m callback -h callback.pyf callback.f
followed by:
f2py -c callback.pyf callback.f -L. -lother
I then use the Python interpreter to run:
import callback
callback.foo(lambda x: 1)
The expected behaviour is:
- print "1" eleven times (b/c of
foo
) - print "1" six times (b/c of the call to
other
insidefoo
) - return "11"
The observed behaviour is instead:
ImportError: libother.so: cannot open shared object file: No such file or directory
If I do nm callfun.so
, I can see that other
is undefined