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.
>To: address@hidden >From: "Krzysztof Markowicz" <address@hidden> >Subject: netCDF Fortran (77 + 90) - linux - How to read NetCDF and HDF files >in one Fortran code? >Organization: Warsaw Uniwersity >Keywords: 200402281720.i1SHKvqL014997 netCDF HDF Hi Krzysztof, > I've written code which read NetCDF files but also HDF in fortran pgf90. > I use 3.5.1 NetCDF and 5.1 HDF . > > Unfortunatelly during complilation I have errors due to mix NetCDF > and HDF library. > When I run separatelly rutines which read NetCDF and HDF files > everytjhing works fine. > > Could you tell is it possible to fixed this problem. I spend a lot > of time on my code but when I try build main program this problems > appeared. ... > pgf90 -O0 readhdf.o -I/usr/local/include -L/usr/local/lib -lmfhdf -ldf > -ljpeg -lz -lnetcdf aerosol_kmark.o readnogaps.o readnaaps.o albedo_emiss.o > timesub.o -o readhdf > /usr/local/lib/libnetcdf.a(attr.o): In function `NC_findattr': > attr.o(.text+0x388): multiple definition of `NC_findattr' > /usr/local/lib/libmfhdf.a(attr.o)(.text+0x0): first defined here > /usr/bin/ld: Warning: size of symbol `NC_findattr' changed from 105 to 131 in > attr.o > /usr/local/lib/libnetcdf.a(nc.o): In function `NC_check_id': > nc.o(.text+0x6c): multiple definition of `NC_check_id' > /usr/local/lib/libmfhdf.a(file.o)(.text+0x1204): first defined here > /usr/bin/ld: Warning: size of symbol `NC_check_id' changed from 57 to 60 in > nc.o > /usr/local/lib/libnetcdf.a(var.o): In function `NC_var_shape': > var.o(.text+0x4f8): multiple definition of `NC_var_shape' > /usr/local/lib/libmfhdf.a(var.o)(.text+0x0): first defined here > /usr/bin/ld: Warning: size of symbol `NC_var_shape' changed from 483 to 267 > in var.o > make: *** [readhdf] Error 2 I think you should not include "-lmfhdf" in the flags for pgf90. That library is for HDF4, not HDF5, and provides an emulation of the netCDF API in terms of HDF4 functions. If you omit that library, the duplicate definitions should go away. --Russ _____________________________________________________________________ Russ Rew UCAR Unidata Program address@hidden http://www.unidata.ucar.edu/staff/russ