NEP 4.3.0
NetCDF Expansion Pack
Loading...
Searching...
No Matches
examples Directory Reference

Directories

 
dicom
 
expected_output
 
nxcdf
 
pdb
 
performance
 
viz

Files

 
perf_disk.h
 Helpers that make example benchmarks measure disk-bound I/O.

Detailed Description

This directory contains example programs exercising NEP features: the nxCDF backend, the UDF format readers, and disk-bound performance benchmarks.

The generic NetCDF teaching examples (classic NetCDF, NetCDF-4, NcZarr, OPeNDAP, parallel I/O, and all Fortran versions) moved to the NetCDF Developer's Handbook repository in v4.3.0. The mission examples moved to Earth Observation in Practice in v4.1.0.

Example Categories

nxCDF Examples (C)

Located in nxcdf/ (built when -DNEP_ENABLE_NXCDF=ON):

Typed bfloat16 benchmark rows were bfloat16_hdf5 with internal conversion OFF and bfloat16_internal with ON; the internal engine is now permanent, so new runs are labeled bfloat16_internal. The legacy plot scripts describe historical OFF results; use the comparison plotter for paired runs:

python3 examples/nxcdf/plot_conversion_compare.py OFF.csv ON.csv OFF_IO.csv ON_IO.csv PREFIX
python3 examples/nxcdf/plot_conversion_compare.py --numeric OFF_NUMERIC.csv ON_NUMERIC.csv PREFIX

The first form writes PREFIX_typed.png and PREFIX_io.png; the second writes PREFIX_numeric.png. The synthetic CSV columns are engine,case,storage,copies,nvalues,memory_bytes,file_bytes,write_s,read_s,write_MBps,read_MBps. Its throughput counts memory bytes per case; the GDAS programs count float32-equivalent bytes. Raw-I/O rows are controls, not converting-path measurements.

Build with -DNEP_ENABLE_NXCDF=ON -DNEP_BUILD_EXAMPLES=ON -DNEP_ZSTD_PLUGIN_DIR=<dir>; add -DNEP_ENABLE_BENCHMARKS=ON to register the benchmark tests. Benchmarks should be built with -DCMAKE_BUILD_TYPE=RelWithDebInfo for representative timings; the benchmark programs warn when built without optimization. The bfloat16, float16 and performance/ benchmarks use examples/perf_disk.h to fsync() each file inside the write time and drop it from the page cache before each read, so their times are disk-bound.

Performance Benchmarks (C)

Located in performance/:

Benchmarks run as tests only with -DNEP_ENABLE_BENCHMARKS=ON. LZ4/BZIP2 benchmarks are maintained by nep-compress.

Format Reader Examples (C)

Visualization Examples (Python)

Located in viz/ (built when -DNEP_ENABLE_VIZ_EXAMPLES=ON): open enabled NEP UDF files through netCDF4.Dataset and write static grayscale PNG plots with companion metadata files. See viz/README.md.

Building Examples

CMake

# Build with examples enabled
cmake -B build -DNEP_BUILD_EXAMPLES=ON
cmake --build build
# Disable examples
cmake -B build -DNEP_BUILD_EXAMPLES=OFF
cmake --build build

Running Examples

Examples are automatically run as tests when built:

ctest --test-dir build

Each example creates NetCDF output files demonstrating the features being illustrated.

Output Validation

The cache_tuning and chunking_performance tests are validated against expected CDL (Common Data Language) files stored in expected_output/ using validate_cdl.sh (generated from validate_cdl.sh.in). This ensures examples continue producing correct output across code changes.

Documentation

All examples are documented with Doxygen comments explaining:

Viewing Documentation

The examples are integrated into the main NEP Doxygen documentation. After building the documentation:

# Build documentation
cmake -B build -DNEP_BUILD_DOCUMENTATION=ON
cmake --build build --target docs
# View in browser
open build/docs/html/examples.html

Or view the online documentation at: https://intelligent-data-design-inc.github.io/NEP/

Dependencies