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: Jacob Bensabat <address@hidden> >Subject: Re: 20000425: a persistence problem >Organization: >Keywords: C++ persistence STL Hi Jacob, > I have been using the NetCDF lib for a while and I have encountered a > problem, that I will try to describe. > I have built a c++ class that wraps the Netcdf functionality. One of its > members is a netcdf file, others are access and write functions. > Since I want to open more than one Netcdf file at a time, I store each > instance of the class in an stl vector. The problem > is that once I stored the class instance in the vector I loose the > ability to retrive data from the file (I get a -33 error codes which > means: invalid cdf file). I solved the problem by open and closing the > netcdf file each time I retrieve a member from the stl vector. My > question is wheter there is a better way to overcome this problem. From the description above, I can't tell whether the problem is with the netCDF library or your wrapper. It's intended to be possible to have multiple netCDF files open simultaneously with the netCDF C++ interface, and no one else has reported a problem with opening multiple netCDF files at the same time from C++. If you are declaring an NcFile object that goes out of scope, its destructor will get called, which closes that file. Perhaps you just need to make sure the ~NcFile(void) destructor doesn't get called. Otherwise, if you could construct a small example that demonstrates the problem, we could reproduce it here and diagnose where the problem lies. Also, it would be better to send netCDF problem reports to "address@hidden" rather than my email address. That way the problem will get routed to someone who can deal with it even if I happen to be on vacation or away from my email. --Russ _____________________________________________________________________ Russ Rew UCAR Unidata Program address@hidden http://www.unidata.ucar.edu