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 Mike, > We are some questions about how to build the legacy C++ library for > netCDF-4 support. > > We are using netcdf-cxx-4.2. > > Previously, when we built version 4.1.3 (all in one), we ran configure > as follows: > > ./configure --prefix=/tmp/ncf --enable-netcdf-4 --disable-dap > > For building netcdf-cxx-4.2, --enable-netcdf-4 does not seem to apply. > The only way I have been able to get it to support netCDF-4 and > compression is to use: > > setenv CPPFLAGS "-g -I/tmp/ncf/include -DUSE_NETCDF4" > ./configure --prefix=/tmp/ncf > > Is this the correct way to do this, or do you have a cleaner option? Even doing it that way won't support compression, unless you are actually calling C functions to set variable deflation levels. The legacy C++ API provides almost no support for netCDF-4, beyond specifying a mode for creating a netCDF-4 file in the NcFile constructor. If you need the per-variable compression supported by the netCDF-4 C or Fortran interfaces with real C++, you'll have to switch to the contributed C++ netCDF-4 API. It's methods for specifying deflation are documented here: http://www.unidata.ucar.edu/software/netcdf/docs/cxx4/classnetCDF_1_1NcVar.html under the NcVar::setCompression and NcVar::getCompression methods. However, as you probably know, the contributed C++ netCDF-4 is not backward compatible with the old legacy C++ API, so it may require quite a bit of rewriting. As far as building the legacy C++ library, this worked for me, after installing the netCDF-4 C library under /usr/local: LD_LIBRARY_PATH=/usr/local/lib CPPFLAGS="-I/usr/local/include -DUSE_NETCDF4" ./configure --enable-netcdf-4 make -j check In particular, I didn't have to disable DAP. --Russ Russ Rew UCAR Unidata Program address@hidden http://www.unidata.ucar.edu Ticket Details =================== Ticket ID: FCH-479977 Department: Support netCDF Priority: Normal Status: Closed