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, > I have just installed netcdf successfully. Now I am trying to compile > the simple_xy_wr.f90, I am getting some problems. I am using following > command to compile the program: > > gfortran -L/home/libs/lib -lnetcdf -L/home/libs/lib -lhdf5_hl -lhdf5 > -L/home/libs/lib -lz -lm -I/home/libs/include simple_xy_wr.f90 > > this gives following errors: > > /tmp/ccdPaqW7.o:simple_xy_wr.f90:(.text+0xe5): undefined reference to > `___netcdf > _MOD_nf90_create' > /tmp/ccdPaqW7.o:simple_xy_wr.f90:(.text+0x11d): undefined reference to > `___netcd > f_MOD_nf90_def_dim' > /tmp/ccdPaqW7.o:simple_xy_wr.f90:(.text+0x155): undefined reference to > `___netcd > f_MOD_nf90_def_dim' > /tmp/ccdPaqW7.o:simple_xy_wr.f90:(.text+0x277): undefined reference to > `___netcd > f_MOD_nf90_def_var_manydims' > /tmp/ccdPaqW7.o:simple_xy_wr.f90:(.text+0x2b0): undefined reference to > `___netcd > f_MOD_nf90_enddef' > /tmp/ccdPaqW7.o:simple_xy_wr.f90:(.text+0x356): undefined reference to > `___netcd > f_MOD_nf90_put_var_2d_fourbyteint' > /tmp/ccdPaqW7.o:simple_xy_wr.f90:(.text+0x36f): undefined reference to > `___netcd > f_MOD_nf90_close' > /tmp/ccdPaqW7.o:simple_xy_wr.f90:(.text+0x447): undefined reference to > `___netcd > f_MOD_nf90_strerror' > collect2: ld returned 1 exit status I think you only need to reorder the arguments to gfortran so that the the source file name comes before all the libraries, as in: gfortran -I/home/libs/include simple_xy_wr.f90 -L/home/libs/lib -lnetcdf -L/home/libs/lib -lhdf5_hl -lhdf5 -L/home/libs/lib -lz -lm --Russ Russ Rew UCAR Unidata Program address@hidden http://www.unidata.ucar.edu Ticket Details =================== Ticket ID: TMW-190074 Department: Support netCDF Priority: Normal Status: Closed