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

Re: Problem with datatype UNLIMITED



Hi Tim,

> I have a problem with the UNLIMITED datatype.

UNLIMITED is not really a datatype like NC_FLOAT, NC_LONG, etc.

It identifies the "unlimited dimension", also known as the "record
dimension", which is the only dimension along which variables can grow.  It
permits data to be appended to variables that use it as the first
dimension.

The length of the unlimited dimension is the number of records currently in
the netCDF file.  When no records have been written, this length is zero.

> If I create a new netCDF file with this datatype, it looks like this:
> 
> netcdf test.cdf {
> dimensions:
>         dim1 = 1 ;
>         dim5 = 5 ;
>         dim12 = 12 ;
>         dim30 = 30 ;
>         dim50 = 50 ;
>         dim2 = 2 ;
>         dim8 = 8 ;
>         dimUL = UNLIMITED ; // (0 currently)
> variables:
>         ....
> 
> }
> 
> Why is it '0 currently'?

Because no data has yet been written for any record variables, the
variables that have the unlimited dimension as their first dimension.

> Everything works fine, if I do not use the datatype. But if I try to work
> with variables of this type, I got several error messages, e.g. edge
> length 0.
> 
> I think I make something wrong creating this datatype. So, what is the
> right way.

If you have something like:

    variables:
       float var(dimUL, dim50);

you can write values into this variable just as if dimUL were an ordinary
dimension, but the size of the dimension is unbounded, and will grow as
needed.

______________________________________________________________________________

Russ Rew                                           UCAR Unidata Program
address@hidden                              http://www.unidata.ucar.edu