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

Re: character dimensions, attribute lengths

Nan Galbraith <ngalbraith@xxxxxxxx> writes:

> My apologies, I didn't make this clear enough, or else I don't
> exactly understand the answer. They are specifying dimensions
> as a way to define the length of character attributes, not for data
> parameters.
>
> Dimensions: time, dept, lat, long, string256, ... string4
> Attributes:  Name      Definition               Example
>   DataType  char DataType(STRING32); Real-time PLATFORM  char
> PLATFORM (STRING8); "PIRATA"
>
> Do you think it is reasonable to include these string dimensions in
> the standard specification, when they are not dimensions of data
> parameters?

I'm a bit confused. (Nothing new, certainly!)

In netCDF you don't need dimensions for attributes. Every attribute is
a scalar or a one-dimensional array.

Here is the function prototype for writing an attribute which is an
array of integers, and may be written as any netCDF type:

EXTERNL int
nc_put_att_int(int ncid, int varid, const char *name, nc_type xtype,
        size_t len, const int *op);

As you can see, there is no need (and no place) for any dimension IDs
in this function call. You provide an array of int as "op", it's
length in "len", and the type of the attribute in "xtype". (For
example, the most straightforward choice would be NC_INT, to write the
attributes as an array of ints.)

The same thing works for attributes which are arrays of NC_CHAR. They
don't need dimensions, just a length, which can be different for each
attribute.

Dimensions are only needed when defining (non-scalar) variables.

Ed
-- 
Ed Hartnett  -- ed@xxxxxxxxxxxxxxxx

==============================================================================
To unsubscribe netcdfgroup, visit:
http://www.unidata.ucar.edu/mailing-list-delete-form.html
==============================================================================


 
 
  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