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.
> Subject: 1995124 netCDF-2.4-beta4 comments > Organization: CSIRO Division of Oceanography > Keywords: 199512032150.AA10339 Hi Stephen, > We are developing a complex ecological model, with many variables, > using netCDF for data input and output. Last week we ran into trouble, > exceeding the maximum number of attributes allowed in a cdl file. > This became apparent when we added a few new variables to our model - each > variable has about 10 attributes. We got up to abut 520 attributes, > and ncgen fell over. > > I down-loaded and installed NetCDF 2.4 Beta4, in an attempt to fix this, > as I had noticed that the release notes state that: > > "We increased the sizes of MAX_NC_DIMS (from 32 to 100), MAX_NC_ATTRS > (from > 512 to 2000), and MAX_NC_VARS (from 512 to 2000) to accommodate users who > are finding the old limits constraining." > > Well, you almost did. The trouble is that the ncgen code sets its own idea > of the maximum number of attributes, in the following line from > ncgen/ncgen.h: > > #define MAX_NC_ATTS 500 /* max number of attributes in a netCDF */ Thanks for pointing out this inconsistency. > I don't understand why it doesn't use the library-wide definition, > as stated in the following line from libsrc/netcdf.h: > > #define MAX_NC_ATTRS 2000 /* max global or per variable attributes > */ The MAX_NC_ATTS macro used by ncgen was originally a temporary implementation that I intended to replace with dynamic allocation of attributes so that ncgen would have no limit. If it's statically allocated, it really should be more than MAX_NC_ATTRS in netcdf.h, since the latter is *per variable*, whereas the ncgen limit is for the total of all attributes of all variables. Also, dynamic allocation of space for attributes would keep the ncgen executable smaller. > Could this minor inconsistency be cleaned up, or is there some reason for > it which I am not aware of. In the meantime, I have edited ncgen.h for > our purposes. The only reason it hasn't been cleaned up yet is I forgot to put it on a list of ncgen fixes. I'll try to get it fixed before the final release of netCDF 2.4, and increase MAX_NC_ATTS now to make it consistent with MAX_NC_ATTRS. Your fix to ncgen.h should be fine. > Thanks for a very useful package (our model would be a nightmare without > something like netCDF!). You're welcome. Thanks for the positive feedback. ______________________________________________________________________________ Russ Rew UCAR Unidata Program address@hidden http://www.unidata.ucar.edu