I cannot get f2py to reference a parameter from a module in a separate subroutine where it is used to defined an input array dimension. I.e. the paramter is defeind in a module:
! File: testmod.f90
MODULE testmod
INTEGER, PARAMETER :: dimsize = 20
END MODULE testmod
and the parameter dimsize needs to be referenced in a 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 have tried modifying testsub.g90 to include the following directive, as suggested 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 keep the subroutine separate from the module.
How can I get f2py to correctly resolve the variable dimsize
?
TIA