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.
Paul, > To: address@hidden > From: Paul Van Delst <address@hidden> > Subject: Using netCDF v3.5 (f90 interface) and HDF4 together. > Organization: CIMSS@NOAA/NCEP/EMC > Keywords: 200205082122.g48LMCa15014 netCDF 3.5 HDF4.1r3 The above message contained the following: > I looked through the support email archive but couldn't find an answer > (after about 30 minutes of looking) so I hope you don't mind this email > if this is in a FAQ. > > I need to read HDF4 data files, play with the data, and output netCDF > files. I use the netCDF v3.5 fortran-90 interface and the HDF 4.1r3 > install. When I get to the link stage I get a humungous pile of > warnings such as: > > /usr2/wd20pd/local/hdf4/lib/libmfhdf.a(error.o): In function `NCadvise': > error.o(.text+0x134): multiple definition of `NCadvise' > /usr2/wd20pd/local/netcdf/lib/libnetcdf.a(v2i.o)(.text+0xa8): first defined > here > /usr/bin/ld: Warning: size of symbol `NCadvise' changed from 26 to 144 in > error.o > /usr2/wd20pd/local/hdf4/lib/libmfhdf.a(array.o): In function `nctypelen': > array.o(.text+0x190): multiple definition of `nctypelen' > /usr2/wd20pd/local/netcdf/lib/libnetcdf.a(v2i.o)(.text+0x9ac): first defined > here > /usr/bin/ld: Warning: size of symbol `nctypelen' changed from 77 to 120 in > array.o > /usr2/wd20pd/local/hdf4/lib/libmfhdf.a(attr.o): In function `NC_findattr': > attr.o(.text+0x200): multiple definition of `NC_findattr' > /usr2/wd20pd/local/netcdf/lib/libnetcdf.a(attr.o)(.text+0x364): first defined > here > /usr/bin/ld: Warning: size of symbol `NC_findattr' changed from 137 to 148 in > attr.o > /usr2/wd20pd/local/hdf4/lib/libmfhdf.a(attr.o): In function `ncattput': > attr.o(.text+0x5f0): multiple definition of `ncattput' > /usr2/wd20pd/local/netcdf/lib/libnetcdf.a(v2i.o)(.text+0x7d0): first defined > here > /usr/bin/ld: Warning: size of symbol `ncattput' changed from 66 to 156 in > attr.o > /usr2/wd20pd/local/hdf4/lib/libmfhdf.a(attr.o): In function `ncattname': > ......etc.... I would expect the above because HDF 4 supplies a netCD interface for reading HDF 4 files and the functions in that interface would clash with the functions of the same name in the netCDF library. > Can I "strip out" parts of the libnetcdf.a library (via ar) and create > the "Fortran-90 only" version so that only the stuff that is not > already defined in the HDF libraries remains? I doubt it because the netCDF-3 Fortran-90 implementation uses the netCDF-3 Fortran-77 implementation, and that implementation uses the netCDF-3 C implementation. So you'd still have name classes amonst the netCDF-3 C functions. > I tried removing just the > netcdf.o and typeSizes.o members and put them in their own library but > then I got a bunch of undefined reference link errors (which didn't > surprise me - I was just trying it to see if it would work). > > Or can I do the opposite? E.g. strip out the netCDF bits of the HDF libraries? That might be a better way to go -- assuming that you can do without accessing an HDF 4 file via the netCDF interface. > If neither is possible (or a bad idea generally), do you have any > suggestions on how to make netcdf v3.5 and hdf v4.1r3 play nice > together when I link into the libraries? I've never attempted this so I'm afraid I don't have any good ideas. I did find a couple of emails on this topic in our support-email archive: http://www.unidata.ucar.edu/glimpse/netcdf/2947 http://www.unidata.ucar.edu/glimpse/netcdf/2883 You might look at them for some ideas. I found them by searching the netCDF archive using the string "HDF 4". Another possibility is posting a query to the netcdfgroup mailing-list. > thanks, > > paulv > > -- > Paul van Delst Religious and cultural > CIMSS @ NOAA/NCEP/EMC purity is a fundamentalist > Ph: (301)763-8000 x7274 fantasy > Fax:(301)763-8545 V.S.Naipaul Goood luck. Regards, Steve Emmerson <http://www.unidata.ucar.edu>