2007 Unidata NetCDF Workshop for Developers and Data Providers > Using NetCDF-4 Features, Part 2
13.2 Using User Defined Types
User-defined types can be used to store N-dimensional arrays structs,
variable length arrays, enumerations, and opaque data ojects of known
size.
- Datasets and attributes may be of user-defined type.
- A user defined type must be defined before it is used to store
data.
- When defined, a user type is assigned a typeid (which may not be
the same between different openings of the same file).
- The typeid is then used when defining a variable or writing an
attribute.
- The functions nc_put_var/nc_get_var and nc_put_att/nc_get_att are
used to write and read data of user-defined type. For example:
/* Write an attribute of any type. */
EXTERNL int
nc_put_att(int ncid, int varid, const char *name, nc_type xtype,
size_t len, const void *op);
/* Read an attribute of any type. */
EXTERNL int
nc_get_att(int ncid, int varid, const char *name, void *ip);
- User defined types may be nested (in some ways), so that one may
define a compound type, holding a variable length array of
enumerations.
2007 Unidata NetCDF Workshop for Developers and Data Providers > Using NetCDF-4 Features, Part 2