I'm trying to use f2py to compile some fortran code that makes use of netcdf libraries. The compilation appears to work but when I try to import the module in python I get the error message:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: ./cdfio_simple.so: undefined symbol: netcdf_mp_nf90_get_var_2d_fourbytereal_
There is also the following output during compilation:
In: :cdfio_simple:cdfio_simple.f90:cdfio_simple get_useparameters: no module netcdf info used by cdfio_simple
The code I am trying to use is (note this is simplified code to demonstrate the problem):
MODULE cdfio_simple USE netcdf PRIVATE PUBLIC getvar CONTAINS FUNCTION getvar (cdfile,cdvar) CHARACTER(LEN=*), INTENT(in) :: cdfile, & ! file name & cdvar ! variable REAL(KIND=4), DIMENSION(1442,1021) :: getvar ! 2D REAL !! * Local variables INTEGER :: ncid, id_var INTEGER :: istatus CHARACTER(LEN=300) :: clvar !f2py INTENT(in):: cdfile, cdvar clvar=cdvar istatus=NF90_OPEN(cdfile,NF90_NOWRITE,ncid) istatus=NF90_INQUIRE(ncid,unlimitedDimId=id_dimunlim) istatus=NF90_INQ_VARID ( ncid,clvar,id_var) istatus=NF90_GET_VAR(ncid,id_var,getvar) istatus=NF90_CLOSE(ncid) getvar(:,:)=1 END FUNCTION getvar END MODULE cdfio_simple
To compile it I use the command:
f2py --fcompiler=intelem -c -I/usr/local/netcdf/include/ -L/usr/local/netcdf/lib -lnetcdff --f90flags=-fPIC -m cdfio_simple cdfio_simple.f90
Does anyone have an idea how I can get this to work correctly? Thanks in advance for any suggestions.
Tim
-lnetcdf
too? – Timothy Brown-lnetcdf
,-lnetcdff
and both together. I still get the same error. – TGrahamnc-config --fflags --flibs
say? – Timothy Brown-g -I/path/to/netcdf4/ifort/include
-L/path/to/netcdf4/ifort_composerxe/lib -lnetcdff -lnetcdf
– TGraham