To create HDF5 files that can be read by netCDF-4, use the latest in the HDF5 1.8.x series.
HDF5 has some features that will not be supported by netCDF-4, and will cause problems for interoperability:
- HDF5 allows a Group to be both an ancestor and a descendant of another Group, creating cycles in the subgroup graph. HDF5 also permits multiple parents for a Group. In the netCDF-4 data model, Groups form a tree with no cycles, so each Group (except the top-level unnamed Group) has a unique parent.
- HDF5 supports "references" which are like pointers to objects and data regions within a file. The netCDF-4 data model omits references.
- HDF5 supports some primitive types that are not included in the netCDF-4 data model, including H5T_TIME and H5T_BITFIELD.
- HDF5 supports multiple names for data objects like Datasets (netCDF-4 variables) with no distinguished name. The netCDF-4 data model requires that each variable, attribute, dimension, and group have a single distinguished name.
- HDF5 (like netCDF) supports scalar attributes, but netCDF-4 cannot read scalar HDF5 attributes (unless it is a string attribute). This limitation will be removed in a future release of netCDF.
These are fairly easy requirements to meet, but there is one relating to shared dimensions which is a little more challenging. Every HDF5 dataset must have a dimension scale attached to each dimension.
Dimension scales are a new feature for HF 1.8, which allow specification of shared dimensions.
Without creation order in the HDF5 file, the files will still be readable to netCDF-4, it's just that netCDF-4 will number the variables in alphabetical, rather than creation, order.
Interoperability is a complex task, and all of this is in the alpha release stage. It is tested in libsrc4/tst_interops.c, which contains some examples of how to create HDF5 files, modify them in netCDF-4, and then verify them in HDF5. (And vice versa).