[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Deleting dimensions in NetCDF files



> Date: Fri, 30 Aug 1996 11:46:25 -0600 (MDT)
> From: Doug Hunt <address@hidden>
> To: Russ Rew <address@hidden>
> Subject: Deleting dimensions in NetCDF files
> Organization: UCAR - GPS/MET 

Hi Doug,

>               ... Can one write a netCDF file and then reopen it, go into 
> define mode and delete (or change the size of) a dimension?
> 
> It appears from the manual that this can't be done, but I'd like to make
> sure before I scrap some plans I've been making for a neat use of netCDF 
> files.

You can't delete a netCDF dimension.  We didn't include this capability
because it would require also deleting all the variables that used that
dimension.

Changing the size of dimension is useful, but currently only the
unlimited dimension can change size, and then only by increasing.

If you changed the size of a dimension to be smaller, all the variables
that used that dimension would have to have their data truncated along
that dimension.

A problem with this sort of thing is that the current netCDF
implementation uses no "garbage collection", so when you delete
something, the space it uses is not recovered or available for anything
else (except that there is a limited kind of garbage collection for
deleted attributes).  And if you increased the size of a dimension, data
would have to be moved around in the file, to keep data for each
variable contiguous.

One could write a layer on top of netCDF that permitted changing the
size of a dimension, and that implemented this by creating a new netCDF
dataset, defining the changed dimension with the new size, and copying
everything else over to the new dataset, before renaming it to the
original.  We already do something like this for adding new variables
and dimensions, so I suppose it could be done similarly to permit
deleting or shrinking dimensions.

--Russ