I am trying to use F2PY to wrap a fortran subroutine which takes a function and an assumed-shape array as arguments. This results in an error. I am using GNU Fortran (GCC) 4.8.5 20150623 (Red Hat 4.8.5-11) and F2PY version 2 with Scientific Linux 7.3.
A minimal example would be a file 'callback.f90' :
!file callback.f90
subroutine sub(arr,func)
implicit none
integer,intent(in),dimension(:) :: arr
external func
integer :: func
integer :: i
i = arr(1)
print *, func(i)
end subroutine sub
I wrap it in the Terminal with
f2py -m pymod -h sign.pyf callback.f90
f2py -c sign.pyf callback.f90
This results in the following error (translated from German):
gfortran:f77: /usr/tmp/tmpsADmTS/src.linux-x86_64-2.7/pymod-f2pywrappers.f
/usr/tmp/tmpsADmTS/src.linux-x86_64-2.7/pymod-f2pywrappers.f:6.19:
use sub__user__routines
1
Error: Module file »sub__user__routines.mod« at (1) can't be opened
for reading: File not found
However, this works perfectly fine, if arr is not assumed shape, but fixed size. F2PY with assumed shape arrays is also working fine for me, as long as no Call-back arguments are involved, thus the problem seems to be some kind of interaction between these two, which I can't figure out.