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

20031203: How to create an array of string?



David,

> To: address@hidden
> cc: address@hidden
> From: David Han <address@hidden>
> Subject: How to create an array of string?
> Organization: NASA
> Keywords: netCDF array of strings

The above message contained the following:

> Is it possible to create an array of string in netCDF?  If so, can 
> you tell me how to do that.  Thanks.
> 
> Here's what I'm trying to do:
> 
> record #1 : array of string (str1, str2, str3)
> record #2 : array of string (str4, str5, str6)
>   .
>   .
> record #n : array of string

It's possible to create a netCDF variable that is a multi-dimensional 
array of characters.  For example, in CDL notation one could have the 
following:

    netcdf test {
        dimensions:
            len=15;
            n1=2;

        variables:
            char strings(n1, len);

        data:
            strings =
                "a string\000\000\000\000\000\000\000",
                "another string\000";
    }

This would result in a netCDF variables named "strings" that could be
interpreted as a 2-element array of the strings "a string" and "another
string".  Note the padding to a fixed string length.

More information can be found in the "NetCDF User's Guide".

Regards,
Steve Emmerson