This archive contains answers to questions sent to Unidata support through mid-2025. Note that the archive is no longer being updated. We provide the archive for reference; many of the answers presented here remain technically correct, even if somewhat outdated. For the most up-to-date information on the use of NSF Unidata software and data services, please consult the Software Documentation first.
Steve, > gfortran -o nc nc.f95 -L/Users/Stefan/cool/lib -I/Users/Stefan/local/include > -I/Users/Stefan/cool/include -lhdf5 -lhdf5_hl -lz -lnetcdf I should have noticed that the order in which the libraries are linked above is wrong. Since netCDF Fortran depends on netCDF C, which depends on HDF5, the above should be: gfortran -o nc nc.f95 -L/Users/Stefan/cool/lib -I/Users/Stefan/local/include -I/Users/Stefan/cool/include -lnetcdff -lnetcdf -lhdf5_hl -lhdf5 -lz But if hdf5 and the netCDF-C library are available as shared libraries (appearing with .so extension in your /Users/Stefan/cool/lib directory), then you should be able to link more simply, with just gfortran -o nc nc.f95 -L/Users/Stefan/cool/lib -I/Users/Stefan/local/include -I/Users/Stefan/cool/include -lnetcdff Note that to run the resulting "nc" program when it's linked to shared libraries, you have to either set the LD_LIBRARY_PATH environment variable (or DYLD_LIBRARY_PATH for OSX) to include your lib directory, or use another method such as setting RPATH at link time. --Russ Russ Rew UCAR Unidata Program address@hidden http://www.unidata.ucar.edu Ticket Details =================== Ticket ID: HBB-707489 Department: Support netCDF Priority: Normal Status: Closed