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.
> Date: Thu, 13 May 1999 11:17:38 -0400 > To: Russ Rew <address@hidden> > From: address@hidden (Chuck Denham) > Subject: Renaming netCDF item with longer name Hi Chuck, > We make big netCDF files of oceanographic data. Depending on our > customer, we sometimes have to rename our variables using longer names. To > avoid automatically rewriting the netCDF file in such cases, I want to > provide some name padding right up front. However, when I do "vardef" with > a long fake name, and then rename it immediately with the correct shorter > name, the file doesn't seem to preserve any of the padding I intended. Do > I need to go through an "endef/redef" cycle to make the padding stick? Do > you know of a reliable strategy? I think before renaming with a short name, you need to make sure nc_enddef or nc_close gets called, which actually computes the space needed on the disk and commits it. Then nc_rename_var with the short name(s), and nc_close will store the variable with padding. I just verified that you can then call nc_open, nc_rename_var to a longer name, and nc_close, without calling nc_redef or nc_enddef, to rename to a longer name. I was surprised by this, since I thought nc_redef/nc_enddef was necessary in this case to extend the name, but it's not. There is also another way, though it's currently only documented in the netcdf man page reference documentation, and not the User's Guides. That's to use the "underbar underbar" function nc__enddef after the nc_create (or nc__create) to set the tuning parameter h_minfree on the dataset, which reserves extra space in the header for subsequent expansion. (By the way, the man page documentation in the netCDF 3.4 release misspells this function as "nc__endef", but I've just fixed it for the upcoming netCDF 3.5 release to be "nc__enddef"). I haven't tested this, but that's what the h_minfree parameter is intended for, as well as adding new dimensions, variables, and attributes later without copying data. --Russ _____________________________________________________________________ Russ Rew UCAR Unidata Program address@hidden http://www.unidata.ucar.edu