Unidata - To provide the data services, tools, and cyberinfrastructure leadership that advance Earth system science, enhance educational opportunities, and broaden participation. Unidata
         
  advanced  
 

Re: deleting dimensions and variables

Hi James,

> Is there no way to delete a dimension, a variable or a data element from
> a netCDF database?

There are no netCDF functions for deleting variables, dimensions (which
may be shared by multiple variables), or data.  Deleting dimensions,
variables, or data can only be accomplished by copying everything except
what you want deleted to a new dataset.

Permitting deletion of dimensions or variables, which are specified in
the C and Fortran interfaces by small integer handles in a consecutive
range of integers, would complicate the interfaces.  For example, after
deletion of a variable either subsequent variable IDs would have to
change (to preserve the ability to iterate through all the variables
using consecutive IDs) or the interfaces would have to be changed to
handle "holes" in the range of variable IDs.

Deletion of dimensions or variables also brings up garbage collection
issues.  It would only make sense to delete a dimension after all the
variables that use that dimension had been deleted.  If a variable was
deleted, making the space allocated for that variable's data available
might require work equivalent to copying the whole file anyway.

These issues don't arise for attributes, which are accessed by name
rather than by integer handles, and for which space is not considered
significant enough to warrant recovery.  Thus deletion of attributes is
supported (though apparently rarely used).

--Russ

_____________________________________________________________________

Russ Rew                                         UCAR Unidata Program
russ@xxxxxxxxxxxxxxxx                     http://www.unidata.ucar.edu


 
 
  Contact Us     Site Map     Search     Terms and Conditions     Privacy Policy     Participation Policy
 
National Science Foundation (NSF) UCAR Community Programs   Unidata is a member of the UCAR Community Programs, is managed by the University Corporation for Atmospheric Research, and is sponsored by the National Science Foundation.
P.O. Box 3000     Boulder, CO 80307-3000 USA     Tel: 303-497-8643     Fax: 303-497-8690