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.
>From: address@hidden (Vivian Chao)
>Organization: NOAA
>Keywords: 199507172124.AA11095 netCDF C++
Hi Vivian,
> Question: How does one append data to an existing netcdf file using the c++
> interface? We get data periodically, so it must be stored periodically.
> I have tried to use set_cur() to move to the end of the file, but
> this causes the last existing record to be overwritten. Is there another
> function that will put the cursor beyond the last record? We have considered
> various hacks around this problem: 1) write one extra dummy record at the
> end of the file 2) Reading the last record (hopefully, this advances the
> cursor)and writing the new records
> 3) Reading and rewriting the last record plus the new ones and
> 4) Reading and rewriting all the old records
> plus the new ones. All of these seem to be fairly ugly solutions.
This bug in the C++ interface was fixed by the patch number 4 for netCDF
2.3.2. You can obtain this patch from
ftp://ftp.unidata.ucar.edu/pub/netcdf/2.3.2-patch4
or you can get an already-patched version of the whole source distribution
from
ftp://ftp.unidata.ucar.edu/pub/netcdf/netcdf-232pl4.tar.Z
______________________________________________________________________________
Russ Rew UCAR Unidata Program
address@hidden http://www.unidata.ucar.edu