I am trying to wrap some Fortran code using f2py, but running into the following problem. Let's say that I have a minimum working example in Fortran as,
MODULE Circle
!---------------------------------------------------------------------
!
! Module containing definitions of variables needed to
! compute the area of a circle of radius r
!
!---------------------------------------------------------------------
REAL, PARAMETER :: Pi = 3.1415927
REAL :: radius
END MODULE Circle
I save this file as circlemodule.F90 and run,
python -m numpy.f2py -c circlemodule.F90 -m circlemodule
Then f2py runs without errors and I obtain a file circlemodule.cp37-win_amd64.pyd
. If I now run the simple script
import circlemodule
print(circlemodule.__doc__)
in the same directory I get the expected output and everything seems fine. However here is my issue, if I take the above example and add an extra line:
MODULE Circle
!---------------------------------------------------------------------
!
! Module containing definitions of variables needed to
! compute the area of a circle of radius r
!
!---------------------------------------------------------------------
REAL, ALLOCATABLE, DIMENSION(:,:) :: B
REAL, PARAMETER :: Pi = 3.1415927
REAL :: radius
END MODULE Circle
The code that I actually want to wrap contains a lot of allocatable definitions like this one, and if I am reading this correctly f2py should be able to handle these according to the example at the bottom of this webpage: https://numpy.org/doc/stable/f2py/python-usage.html However when I try to wrap this code using the exact same steps as before, and run the python script to import, I get the following,
ImportError: DLL load failed: The specified module could not be found.
Does anyone have any idea why this happens? Somehow the module f2py creates is now no longer recognized by python. I am using python 3.7.9 and my fortran compiler is ifort 2021. Thanks!
EDIT: It might be interesting to note that in the output of f2py the following line is present
getarrdims:warning: assumed shape array, using 0 instead of ':'
Perhaps this is a clue to the problem?