A NetCDF-4 file is an HDF5 file written by the NetCDF library under the conventions in the “NetCDF-4 format” part of Unidata’s file format specification, read 2026-11-12. This page lists how each NetCDF object is stored.
Objects
| NetCDF | HDF5 |
|---|---|
| Group | Group. The root group is /. Global attributes become attributes of each group. |
| Variable | Dataset with the same name. If a variable has a dimension’s name but is not its coordinate variable, the dataset name gets the prefix _nc4_non_coord_. |
| Attribute | Attribute on the group or dataset. |
| Dimension with a coordinate variable | The variable’s dataset, made an HDF5 dimension scale of the same type, holding the coordinate data. |
| Dimension without a variable | An empty dimension scale of type char; only its name and length matter. Its NAME attribute is This is a netCDF dimension but not a netCDF variable. |
| Variable’s dimensions | HDF5 dimension scales, with the attributes the HDF5 dimension scale API keeps: CLASS, NAME, REFERENCE_LIST, DIMENSION_LIST. When NetCDF writes, every dimension has a scale. |
Types and values
- The atomic types map to HDF5 native types:
NC_BYTEsigned char,NC_UBYTEunsigned char,NC_SHORT/NC_USHORT,NC_INT/NC_UINT,NC_INT64/NC_UINT64(long long),NC_FLOAT,NC_DOUBLE;NC_CHARisH5T_C_S1andNC_STRINGa variable-length array ofH5T_C_S1. - Data is written in the writing machine’s byte order unless the user sets one for a variable; HDF5 swaps on reading as needed.
- Each user-defined type corresponds exactly to an HDF5 user-defined type; only base types that NetCDF-4 has may be used (no HDF5 reference types).
- Compression: NetCDF-4 writes only zlib (deflate levels 1 to 9; asking for 0 turns deflation off). It can read szip data if its HDF5 library supports it, but cannot write it.
- The library writes variables in creation order.