NEP 4.0.0
NetCDF Expansion Pack
Loading...
Searching...
No Matches
NEP Example Programs

NEP includes over 55 C and Fortran example programs covering classic NetCDF, NetCDF-4, NcZarr, OPeNDAP remote access, performance tuning, and parallel I/O.

They are companion code for The NetCDF Developer's Handbook: The Authoritative Guide to Writing High-Performance Programs for Scientific Data Management, Second Edition.

See examples/README.md for build instructions and usage details.

Classic NetCDF (examples/classic/, examples/f_classic/)

Both C and Fortran versions provided for all programs.

NetCDF-4 (examples/netcdf-4/, examples/f_netcdf-4/)

Both C and Fortran versions provided for all programs.

NcZarr (examples/nczarr/)

Both C and Fortran versions provided for all programs.

OPeNDAP Remote Access (examples/opendap/)

Both C and Fortran versions provided for all programs.

Visualization Examples (examples/viz/)

Python visualization examples open NEP UDF files directly with netCDF4.Dataset and write static Matplotlib PNGs. They are optional and disabled by default. The examples cover FITS images, CDF temperature data, GeoTIFF rasters, GRIB2 wind grids, and PDS4 MESSENGER, Perseverance, MAVEN, and New Horizons products.

Enable visualizations with -DNEP_ENABLE_VIZ_EXAMPLES=ON for CMake or --enable-viz-examples for Autotools. Normal examples and at least one UDF reader must also be enabled. A source-root .venv must provide NumPy, Matplotlib, and netCDF4 built from source against the exact NetCDF-C installation used by NEP; wheels or system packages using another libnetcdf cannot load NEP UDF handlers.

Tests use the generated build-tree .ncrc: NCRCENV_RC selects the file, NETCDF_RC points to its directory, and LD_LIBRARY_PATH includes the NEP UDF libraries. Generated PNGs and <basename>_metadata.txt files remain in the visualization build directory and are neither installed nor written to the source tree. Each plot is grayscale, no caption appears inside its PNG, figures are limited to 8.0 by 6.1 inches at 150 DPI, and metadata contains ordered non-empty title, caption, and alt_text fields; captions are limited to 75 words.

See examples/viz/README.md for setup, build, test, and direct-execution instructions.

Performance and Compression Benchmarking (examples/performance/)

C only. Built with -DENABLE_BENCHMARKS=ON (CMake) or --enable-benchmarks (Autotools).

  • cache_tuning.c — Chunk cache size and slots effect on read performance
  • chunking.c — Row-optimized, column-optimized, and balanced chunk shape comparison
  • deflate.c — Deflate compression levels 1–9 speed and ratio benchmarking
  • lz4.c — LZ4 compression performance vs deflate
  • bzip2.c — BZIP2 compression performance vs deflate
  • zstandard.c — Zstandard (ZSTD) compression benchmarking
  • szip.c — SZIP compression benchmarking
  • lossless.c — Lossless compression algorithm comparison
  • quantize.c — Quantization for lossy compression and storage reduction
  • endianness.c — Byte order effects on I/O performance
  • fill_values.c — Fill value storage and read performance

Parallel I/O (examples/parallelIO/)

Built only when parallel tests are enabled (--enable-parallel-tests / -DENABLE_PARALLEL_TESTS=ON).