I can not get f2py to refer to the parameter from the module in a separate routine, where it is used to determine the size of the input array. That is, the parameter is damaged in the module:
! File: testmod.f90 MODULE testmod INTEGER, PARAMETER :: dimsize = 20 END MODULE testmod
and the dimsize parameter should be specified in the subroutine (NOT contained in the module) in another file, which will be the entry point for my python module:
! File testsub.f90 SUBROUTINE testsub(arg) USE testmod REAL, INTENT(IN) :: arg(dimsize) END SUBROUTINE testsub
I compile like this:
f2py -m testmod -h testmod.pyf testsub.f90 pgf90 -g -Mbounds -Mchkptr -c -fPIC testmod.f90 -o testmod.o pgf90 -g -Mbounds -Mchkptr -c -fPIC testsub.f90 -o testsub.o f2py -c testmod.pyf testmod.o testsub.o
but get this error:
testmodmodule.c: In function 'f2py_rout_testmod_testsub': testmodmodule.c:180: error: 'dimsize' undeclared (first use in this function)
I tried modifying testub.g90 to include the following directive as suggested by ni other posts:
SUBROUTINE testsub(arg) USE testmod !f2py integer, parameter :: dimsize REAL, INTENT(IN) :: arg(dimsize) END SUBROUTINE testsub
but to no avail. I need to leave the subroutine separate from the module.
How can I get f2py to correctly enable the dimsize variable?
TIA
python fortran f2py
ccbunney
source share