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 Klaus, > I just started working with the new C++ API to NetCDF, the current > stable release: > > netcdf-cxx4-4.2.1 > > I want to write classic NetCDF files, therefore I call the NcFile > constructor with: > > NcFile test(FILE_NAME, NcFile::replace, NcFile::classic); > > But as soon as I start to write data (via ...putVar(...)) to the file, > an exception is raised with the text: > ----- > NcInDefineMode: Operation not allowed in define mode > file: ncVar.cpp line:720 > ----- > > I checked this behaviour also with the NetCDF example code > ("pres_temp_4D_wr.cpp"), where I only added "NcFile::classic" to the > NcFile constructor, with the same result (after also adding > 'cout << e.what() << endl' to the example code). > > Therefore I think, for the 'classic' mode, the switch from define to > data mode is broken. > Could you check this behaviour? Yes, thanks for the error report. I was able to duplicate the problem, and now there's a fix on GitHub: https://github.com/Unidata/netcdf-cxx4 as well as a test in the examples/simple_xy_wr_formats.cpp that verifies that files of all formats can now be created. This fix will be in the next release, along with a lot of other fixes recently contributed by another generous developer. If you want to try the latest version, you can clone the current GitHub release, run "autoreconf -if" in the top-level directory to generate a "configure" script, and then build it in the usual way. > P.S. Merry Christmas and a Happy New Year! Thanks, same to you and yours ... --Russ Russ Rew UCAR Unidata Program address@hidden http://www.unidata.ucar.edu Ticket Details =================== Ticket ID: FVM-642365 Department: Support netCDF Priority: Normal Status: Closed