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.
Hi Pat, > I have problems in compiling a fortran code by using netcdf libraries: > > My Fortran compiler is: intel64-10.0.026 > I do the following: > > 1. Compiling netcdf-4.1.3 version: > setenv F77 ifort > setenv F90 ifort > > ./configure --prefix=/home/laux-p/netcdf413_ifort --disable-netcdf-4 > --disable-dap-remote-tests > > make check install > > >> everything works well. Then I tried to compile and link a fortran code as > >> follows: > > ifort simple_xy_rd1.f90 -I${NETCDF_IFORT_PATH}/include > -L${NETCDF_IFORT_PATH}/lib -lnetcdf -o simple_xy_rd1 > > >> the warning is: > > /tmp/ifortt75E58.o: In function `MAIN__': > simple_xy_rd1.f90:(.text+0x146): undefined reference to `netcdf_mp_nf90_open_' > simple_xy_rd1.f90:(.text+0x1d1): undefined reference to > `netcdf_mp_nf90_inquire_' > simple_xy_rd1.f90:(.text+0x24b): undefined reference to > `netcdf_mp_nf90_inq_varid_' > simple_xy_rd1.f90:(.text+0x27b): undefined reference to > `netcdf_mp_nf90_inq_varid_' > simple_xy_rd1.f90:(.text+0x365): undefined reference to > `netcdf_mp_nf90_get_var_1d_fourbytereal_' > simple_xy_rd1.f90:(.text+0x405): undefined reference to > `netcdf_mp_nf90_get_var_1d_fourbytereal_' > simple_xy_rd1.f90:(.text+0x4c9): undefined reference to > `netcdf_mp_nf90_inq_varid_' > simple_xy_rd1.f90:(.text+0x504): undefined reference to > `netcdf_mp_nf90_get_var_2d_fourbytereal_' > simple_xy_rd1.f90:(.text+0x62c): undefined reference to > `netcdf_mp_nf90_get_att_text_' > simple_xy_rd1.f90:(.text+0x66c): undefined reference to > `netcdf_mp_nf90_inquire_attribute_' > simple_xy_rd1.f90:(.text+0x6a8): undefined reference to > `netcdf_mp_nf90_get_att_text_' > simple_xy_rd1.f90:(.text+0x6e8): undefined reference to > `netcdf_mp_nf90_inquire_attribute_' > simple_xy_rd1.f90:(.text+0x706): undefined reference to > `netcdf_mp_nf90_close_' > simple_xy_rd1.f90:(.text+0x784): undefined reference to > `netcdf_mp_nf90_strerror_' > simple_xy_rd1.f90:(.text+0x834): undefined reference to > `netcdf_mp_nf90_strerror_' > simple_xy_rd1.f90:(.text+0x8e4): undefined reference to > `netcdf_mp_nf90_strerror_' > simple_xy_rd1.f90:(.text+0x994): undefined reference to > `netcdf_mp_nf90_strerror_' > simple_xy_rd1.f90:(.text+0xa41): undefined reference to > `netcdf_mp_nf90_strerror_' > /tmp/ifortt75E58.o:simple_xy_rd1.f90:(.text+0xb1a): more undefined references > to `netcdf_mp_nf90_strerror_' follow With version 4.1.3 and later releases, the Fortran library is no longer combined with the C library, so you need to specify both when linking, as in ifort simple_xy_rd1.f90 -I${NETCDF_IFORT_PATH}/include -L${NETCDF_IFORT_PATH}/lib -lnetcdff -lnetcdf -o simple_xy_rd1 You can tell if you need this extra "-lnetcdff" argument by looking in the ${NETCDF_IFORT_PATH}/lib directory to see if there are extra libraries there for fortran, all of which contain the string "libnetcdff". --Russ Russ Rew UCAR Unidata Program address@hidden http://www.unidata.ucar.edu Ticket Details =================== Ticket ID: KWT-441277 Department: Support netCDF Priority: Normal Status: Closed