Demonstrate NcZarr with the NetCDF-4 enhanced data model (Fortran).
Creates a local NcZarr store with: Root group: time (unlimited) and x dimensions, temperature(time,x) and pressure(time,x) variables. Child group obs/: station (unlimited), obs_value(station) and obs_time(station) variables.
Note: NcZarr supports groups and unlimited dims from the enhanced model; user-defined types (enum, compound) require HDF5 storage.
Reopens the store and validates all metadata and data values.
Learning Objectives:
- Use NcZarr with the NetCDF-4 enhanced data model features from Fortran
- Create groups in a Zarr store with nf90_def_grp()
- Use unlimited dimensions in NcZarr datasets
- Combine root-level and child-group variables in one store
- Verify round-trip correctness for multi-group NcZarr datasets
Key Concepts:
- Enhanced Data Model: NcZarr supports groups and unlimited dimensions from the NetCDF-4 enhanced model (but not user-defined types)
- Groups in Zarr: nf90_def_grp() creates sub-groups stored as nested directories in the Zarr store
- Unlimited Dimensions: NF90_UNLIMITED works in NcZarr just like NetCDF-4/HDF5
- Mixed Variables: Root and child groups can have independent variables with different dimensions
- Column-Major Ordering: Fortran arrays have reversed dimension order compared to C (x varies fastest in Fortran)
Prerequisites:
Related Examples:
Compilation:
program f_nczarr_enhanced
Definition f_nczarr_enhanced.f90:70
Usage:
ncdump 'file://f_nczarr_enhanced.zarr#mode=nczarr'
Expected Output: Creates the directory f_nczarr_enhanced.zarr containing:
- Root group with dimensions time(unlimited), x(5) and variables temperature(x, time), pressure(x, time)
- Child group obs/ with dimension station(unlimited) and variables obs_value(station), obs_time(station)
- Note
- Companion code for "The NetCDF Developer's Handbook: The Authoritative Guide to Writing
High-Performance Programs for Scientific Data Management, Second Edition" (https://www.amazon.com/dp/B0H7Q1Z75L)
- Author
- Edward Hartnett, Intelligent Data Design, Inc.
- Date
- 2026-06-27