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: Michael Dixon <address@hidden> >Subject: netCDF C++ interface >Organization: NCAR/RAP >Keywords: 200112312242.fBVMg3N20826 netCDF C++ Hi Mike, > I recently started using the C++ interface for netCDF. I think the > docs are pretty good and the interface is pretty easy to use. > > I have a couple of comments, as feedback: > > 1. Deleting NcValues objects: > ----------------------------- > > In the docs you do mention that the caller must delete the NcAtt > pointers after use. However, you do not mention that the caller must > also delete the NcValues pointers, retrieved with the values() method, > after use. This leads to memory leaks. > > I'd suggest an addition to the docs. Thanks, I've made the suggested change and updated the HTML and PostScript docs at: http://www.unidata.ucar.edu/packages/netcdf/cxxdoc_toc.html and http://www.unidata.ucar.edu/packages/netcdf/cxxdoc.ps > 2. NcError. > ----------- > > Perhaps it would be worth adding a strerror() type function to > the error class? Or do you have suggestions on how best to use > the NcError class? Yes, it might be worth adding a strerror() method to the NcError class. I think you can just use strerror() from the C interface directly on the int returned by NcError::get_err() to get a char* error message. You may have guessed this C++ interface was written before the Java interface (and in fact before the netCDF 3.x interfaces), and has languished lately for lack of development. In particular, the current C++ interface doesn't make any use of C++ templates, exceptions, String, or other parts of the standard C++ library. It would probably benefit by being rewritten to use standard C++ facilities. Charlie Zender (who used to work at NCAR) has developed a new C++ interface to the netCDF C library that you may want to look at, as it represents an advance from the current C++ interface: http://www.unidata.ucar.edu/glimpse/netcdf/4427 If you have the time to look at it, I'd be interested in your evaluation ... --Russ _____________________________________________________________________ Russ Rew UCAR Unidata Program address@hidden http://www.unidata.ucar.edu