This archive contains answers to questions sent to Unidata support through mid-2025. Note that the archive is no longer being updated. We provide the archive for reference; many of the answers presented here remain technically correct, even if somewhat outdated. For the most up-to-date information on the use of NSF Unidata software and data services, please consult the Software Documentation first.
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