netcdf-c/ncdump/ref_tst_enum_undef.cdl
Dennis Heimbigner 65fd9fe1a5 Provide a default enum const when fill value does not match any enum const.
re: https://github.com/Unidata/netcdf-c/issues/982

It is possible to define an enum type that has no enum constant
with value zero. However, HDF5 has a default fill value of zero
that it used to fill all chunks. In the event that this situation
occurs, ncdump, say, will fail because there is no enum const
to print for the value zero.

The solution is to create a special enum constant called "_UNDEFINED"
that has the value zero. It is only used in the case that there is
no constant in the enum that already covers zero.

A test case is added in netcdf-c/ncdump to validate this solution.

Note: the changes occur primarily in libsrc4, so they also work for NCZarr.
2022-07-17 14:32:31 -06:00

14 lines
415 B
Plaintext

netcdf tst_enum_undef {
types:
ubyte enum cloud_class_t {Cumulonimbus = 1, Stratus = 2, Stratocumulus = 3,
Cumulus = 4, Altostratus = 5, Nimbostratus = 6, Altocumulus = 7,
Cirrostratus = 8, Cirrocumulus = 9, Cirrus = 10, Missing = 255} ;
dimensions:
station = 5 ;
variables:
cloud_class_t primary_cloud(station) ;
data:
primary_cloud = _UNDEFINED, Stratus, _UNDEFINED, Cumulonimbus, Missing ;
}