Open GeneralDuke9 opened 6 years ago
Any luck with this?
did you do "-lnetcdf -lnetcdff"
I don't know the particulars for the original poster, but the quoted error can be reproduced with a command something like (i.e., not using -lnetcdff):
gfortran simple_xy_wr.f90 -o simple_xy_wr.exe -I/opt/local/include -L/opt/local/lib -lnetcdf
To get the code to compile correctly, one needs to use -lnetcdff:
gfortran simple_xy_wr.f90 -o simple_xy_wr.exe -I/opt/local/include -L/opt/local/lib -lnetcdff
or
gfortran simple_xy_wr.f90 -o simple_xy_wr.exe -I/opt/local/include -L/opt/local/lib -lnetcdf -lnetcdff
For completeness, the other errors associated with not specifying either the -I or -L (when using the macports default install locations) are:
> gfortran simple_xy_wr.f90 -o simple_xy_wr.exe -I/opt/local/include -lnetcdff
ld: library not found for -lnetcdff
collect2: error: ld returned 1 exit status
and:
> gfortran simple_xy_wr.f90 -o simple_xy_wr.exe -L/opt/local/lib -lnetcdf -lnetcdff
simple_xy_wr.f90:19:6:
use netcdf
1
Fatal Error: Can't open module file 'netcdf.mod' for reading at (1): No such file or directory
I tried to compile the "simple_wr_xy.f90" example fortran program that I found on the Unidata website (https://www.unidata.ucar.edu/software/netcdf/examples/programs/). However, it produces the following error:
I use the ncarg suite provided by MacPorts, built with the gcc7 option. I have also installed the netcdf-cxx, netcdf-cxx4 and netcdf-fortran ports (installed in that order) and I included the -I/opt/local/include flag in the compilation command.