Re: character dimensions, attribute lengths

Nan Galbraith <ngalbraith@xxxxxxxx> writes:

> Sorry if this has been covered repeatedly, I have searched the unidata site
> and the netcdf users guide and just don't see the issue addressed directly.
> It's a "best practices" question, but is not actually answered in that
> document either.
> I'm working on an implementation of NetCDF with a very varied group,
> and the issue of string lengths is a real problem for some of them. All our
> data is numeric;  attributes are often char though.
> Some participants use software that requires them to specify string
> lengths for char variables, I assume it's fortran but am not sure. Their
> work-around is to declare these as dimensions in the netcdf file:
> STRING256,
> STRING64, STRING32,  etc.

I believe this is the way to go for defining char arrays in netCDF-3.

Of course, you don't need to define dimensions for attributes, so if
you can put your string in an attribute, that may be easier.

> This seems like a misuse of the concept of dimensions in netcdf, but I'd
> like to know if it's a widely accepted way to deal with the fact that
> strings
> don't exist in netcdf.  I'd prefer to deal with the issue in software,
> and leave
> this out of our specification. It seems ... messy to me, but if it's
> commonly
> done then I guess I'll stop arguing.

NetCDF-4, which is expected to come out in beta this Summer, offers
the NC_STRING type, which addresses this problem. 

Ed Hartnett  -- edh@xxxxxxxx

To unsubscribe netcdfgroup, visit: