-
-
Notifications
You must be signed in to change notification settings - Fork 12.2k
f2py: assumed shape array arguments break callback functionality #17797
Copy link
Copy link
Closed
Description
Using f2py on subroutines that take both, a callback (external) routine argument and an assumed shape array argument fails. For some reason the "use __user__routines" line is passed on to the ...-f2pywrappers.f or f90 file and not removed, as it should be. For some reason, replacing dimension(:) by dimension(*) in the .pyf file passes the compilation. I have not checked yet if this introduces problems in the interface.
For more details, see https://stackoverflow.com/questions/45219663/f2py-with-subroutine-having-a-call-back-argument-and-an-assumed-shape-array-argu?noredirect=1&lq=1
Reproducing code example:
assumed.f90:
subroutine caller(f, y)
external f
real(8), dimension(:) :: y
real(8) :: x
x = 3d0
call f(x)
end subroutine callerassumed.pyf:
python module caller__user__routines
interface caller_user_interface
subroutine f(x) ! in :assumed:assumed.f90:caller:unknown_interface
real(kind=8) :: x
end subroutine f
end interface caller_user_interface
end python module caller__user__routines
python module assumed ! in
interface ! in :assumed
subroutine caller(f,y) ! in :assumed:assumed.f90
use caller__user__routines
external f
real(kind=8) dimension(:) :: y
end subroutine caller
end interface
end python module assumedError message:
gfortran:f77: /var/folders/xj/rwxkg6fn5hdgmr82rdj35h3c0000gn/T/tmpg9mr1yky/src.macosx-10.15-x86_64-3.9/assumed-f2pywrappers.f
/var/folders/xj/rwxkg6fn5hdgmr82rdj35h3c0000gn/T/tmpg9mr1yky/src.macosx-10.15-x86_64-3.9/assumed-f2pywrappers.f:6:20:
6 | use caller__user__routines
| 1
Fatal Error: Cannot open module file 'caller__user__routines.mod' for reading at (1): No such file or directory
compilation terminated.
error: Command "/usr/local/bin/gfortran -Wall -g -ffixed-form -fno-second-underscore -fPIC -O3 -funroll-loops -I/var/folders/xj/rwxkg6fn5hdgmr82rdj35h3c0000gn/T/tmpg9mr1yky/src.macosx-10.15-x86_64-3.9 -I/usr/local/lib/python3.9/site-packages/numpy/core/include -I/usr/local/include -I/usr/local/opt/openssl@1.1/include -I/usr/local/opt/sqlite/include -I/usr/local/Cellar/python@3.9/3.9.0_1/Frameworks/Python.framework/Versions/3.9/include/python3.9 -c -c /var/folders/xj/rwxkg6fn5hdgmr82rdj35h3c0000gn/T/tmpg9mr1yky/src.macosx-10.15-x86_64-3.9/assumed-f2pywrappers.f -o /var/folders/xj/rwxkg6fn5hdgmr82rdj35h3c0000gn/T/tmpg9mr1yky/var/folders/xj/rwxkg6fn5hdgmr82rdj35h3c0000gn/T/tmpg9mr1yky/src.macosx-10.15-x86_64-3.9/assumed-f2pywrappers.o" failed with exit status 1
NumPy/Python version information:
1.19.4 3.9.0 (default, Oct 27 2020, 14:15:17)
[Clang 12.0.0 (clang-1200.0.32.21)]
Reactions are currently unavailable