I am having difficulty with getting a f2py compiled module work in Python.
I have a piece of software written in Fortran that compiles well on a Linux 64bit machine.
Further on F2Py compiles a Python module that uses Fortran bits as well.
Here is how the Python module is compiled:
f2py --fcompiler=gfortran -I"path-to-dir-with-mod-files" -c -m mod_landems mod_landem.f90
But once I want to import that module I get an error (in Ipython):
----> 1 import mod_landems
ImportError: ./mod_landems.so: undefined symbol: __nesdis_landem_module_MOD_nesdis_landem
To be honest I am confused with this error. Search did not help much so I need to ask you here: how can I possibly make it work? If I put the python module code in the same directory as where the mod files are it produces same error message.
Here is a piece of my (primitive) code:
module n_landem
implicit none
! INPUT VARIABLES
real(8) Angle
real(8) Sm_Content
real(8) Veg_Frac
real(8) Soil_Temp
real(8) Land_Temp
real(8) Snow_Depth
real(8) Frequency
! OUTPUT VARIABLES
real(8) Emis_H
real(8) Emis_V
contains
subroutine landem
USE NESDIS_LANDEM_MODULE
USE TYPE_KINDS, ONLY : fp
call NESDIS_LandEM(Angle,Frequency,Sm_Content,Veg_Frac,Soil_Temp,Land_Temp,Snow_Depth,Emis_H,Emis_V)
end subroutine landem
end module n_landem
If I recall correctly some time ago this module was importable, but can’t seem to make it work on either debian64 installation or debian32bit computer.
in your f2py call, you have to pass the libraries you are linking explicitly with ‘-l’, the same you would pass it to your Fortran compiler (i.e. gfortran). Therefore, does
work for you ?
Best,
Max.