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.
Jeff, > Russ/Dennis: I've filed two tickets on support-netcdf, I think they > both represent bugs in 4.2rc1. I hope you can find the time to take a > look at them before 4.2 is released. One (netCDF #VKP-631083) has to do > with changing an existing attribute in a netcdf4 file, and the other > (netCDF #XHX-254015) is a regression from 4.1.3 that occurs when trying > to read opendap aggregation datasets. Thanks, Jeff, I've reproduced the bug in a C program. You can monitor this Jira issue to see when it's fixed: https://www.unidata.ucar.edu/jira/browse/NCF-156 Thanks for reporting the bug and providing a reproducible example program. --Russ > If I open a NETCDF4 file in "append" mode and immediately try to modify > an existing attribute, I get this error > > NetCDF: Operation not allowed in data mode > > However, if I first create a new attribute, before trying to modify an > existing one, all is well. Here is a python script that triggers the > error with netcdf 4.1.3/hdf5 1.8.8 > > from netCDF4 import Dataset > f = Dataset('pv.nc','w') > lat = f.createDimension('lat',181) > lon = f.createDimension('lon',360) > lev = f.createDimension('lev',60) > pv = f.createVariable('PV','f',('lev','lat','lon'),fill_value=-999) > pv.units="K m**2 kg**-1 s**-1" > pv.longname = 'Potential Vorticity' > f.close() > f = Dataset('pv.nc','a') > pv = f.variables['PV'] > pv.longname = 'Ertel Potential Vorticity' ==> error occurs here > f.close() > > Here is the workaround: > > pv.testatt = 'test' > pv.longname = 'Ertel Potential Vorticity' > del pv.testatt > f.close() > > I can create a C program to trigger the error if you like. > > Regards, > > Jeff > > > Russ Rew UCAR Unidata Program address@hidden http://www.unidata.ucar.edu Ticket Details =================== Ticket ID: VKP-631083 Department: Support netCDF Priority: Urgent Status: Closed