2008 Unidata NetCDF Workshop for Developers and Data Providers > Introduction to NetCDF-4
11.8 Variable-Length Types
Variable-Length types provide support for ragged arrays.
Simple example: ragged array
types:
float(*) row_of_floats;
dimensions:
m = 50;
variables:
row_of_floats ragged_array(m);
- Has a name and a base type
- Multiple variables may use same type
- May be nested to create multidimensional variable-length types
- Access to a variable-length value is atomic
- Length and values written or read together
- Can't know length until value is read
- In C/Fortran, library allocates memory for value
Nested example: in situ observations
types:
compound obs_t { // type for a single observation
float pressure ;
float temperature ;
float salinity ;
}
obs_t some_obs_t(*) ; // type for some observations
compound profile_t { // type for a single profile
float latitude ;
float longitude ;
int time ;
some_obs_t obs ;
}
profile_t some_profiles_t(*) ; // type for some profiles
compound track_t { // type for a single track
string id ;
string description ;
some_profiles_t profiles;
}
dimensions:
tracks = 42;
variables:
track_t cruise(tracks); // this cruise has 42 tracks
Notes on netCDF-4 Variable-Length Types
- Any base type may be used (including compound types and other
variable-length types)
- No associated shared dimension, unlike unlimited dimensions
2008 Unidata NetCDF Workshop for Developers and Data Providers > Introduction to NetCDF-4