In ncdigest V1 #497, Patrice Cousineau asked the following questions:
I'm wondering what is the best way to deal with character string
data in
NetCDF (mainly metadata). It seems very clumsy to have to
declare a
string as an array of characters and need to declare a dimension
for
string length. Furthermore, the processing of these arrays
becomes very
tedious and not very useful to other NetCDF tools.
My suggestion is to use attributes rather than variables. The
advantages of attributes are:
* no dimension
* they can be expanded (although this may be inefficient unless
you are careful)
An example is the standard global attribute ':history' created by FAN
function put_history in fanlib/put_history.c.
This creates ':history' with size 1000 bytes, then expands it by another
1000 whenever it fills.
A better method would be to use our late friend Glenn Davis's "double
underbar tuning functions nc__create and
nc__open" to create some space for expansion in the header. Note that
these are still not documented in the
User Guides, but are documented in the man pages. The relevant online
man pages are at:
http://www.unidata.ucar.edu/cgi-bin/man-cgi?netcdf+-s3
The only solution I have found is to assign an integer ID to
these
strings (assuming there are a limited number of possibilities)
and
creating a lookup table for them. But then, where and how would
i store
the lookup tables?
And what to do with an infinite list of strings???
I really don't understand your problem. Perhaps an example would help.
You seem to want some kind of variable
list of variable-length strings (sometimes called 'ragged arrays').
This is not the sort of thing netCDF is intended for.
There are many other tools (e.g. database software) which would be much
more suitable.
Harvey Davies, CSIRO Atmospheric Research,
Private Bag No. 1, Aspendale 3195
E-mail: harvey.davies@xxxxxxxxxxxx
Phone: +61 3 9239 4556
Fax: +61 3 9239 4444