netCDF
Guidance last updated: 20 October 2026
NetCDF provides libraries and portable file formats for storing and sharing array-oriented scientific data.
Usage
After connecting to Stanage (see Establishing a SSH connection), start an interactive session:
salloc
Load one of the following modules. This also loads the matching gompi or iimpi toolchain, HDF5 and other dependencies. Choose a build matching your application’s compiler and MPI.
module load netCDF/4.9.3-gompi-2025b
module load netCDF/4.9.3-iimpi-2025b
module load netCDF/4.9.2-gompi-2024a
module load netCDF/4.9.2-gompi-2023a
module load netCDF/4.9.2-gompi-2023b
module load netCDF/4.9.0-gompi-2022b
module load netCDF/4.9.3-gompi-2025a
module load netCDF/4.9.3-gompi-2025b
module load netCDF/4.9.2-gompi-2023b
nc-config --all reports the C library’s build settings and supported
features. It does not check that your application can compile or run.
Fortran bindings
For Fortran applications, load a netCDF-Fortran module; its package page lists versions, installation details and dependencies. The module also loads the matching netCDF C library and toolchain.
Use nf-config --all to inspect the Fortran build. Keep the Fortran module
and its dependencies together rather than loading a newer C library over them.
Creating and inspecting a file
Save the following Common Data Language (CDL) description as example.cdl:
netcdf example {
dimensions:
sample = 3;
variables:
int values(sample);
data:
values = 10, 20, 30;
}
The following example batch submission script creates a netCDF-4 file and prints its contents:
#!/bin/bash
#SBATCH --partition=sheffield
#SBATCH --nodes=1
#SBATCH --ntasks=1
#SBATCH --cpus-per-task=1
#SBATCH --mem-per-cpu=2000
#SBATCH --time=00:05:00
set -euo pipefail
cd "$SLURM_SUBMIT_DIR"
module load netCDF/4.9.3-gompi-2025b
ncgen -4 -o example.nc example.cdl
ncdump example.nc
Save the script as netcdf.slurm and submit with sbatch netcdf.slurm.
The output should contain values = 10, 20, 30.
Compiling a C program
Within a CPU allocation, ncgen can also generate a C program from the
same CDL input. With netCDF/4.9.3-gompi-2025b loaded, run:
ncgen -4 -lc -o compiled.nc example.cdl > generated.c
"$(nc-config --cc)" $(nc-config --cflags) generated.c -o generated $(nc-config --libs)
./generated
ncdump compiled.nc
nc-config supplies the compiler and the include and library flags for the
loaded build. The resulting file should contain the same 10, 20, 30 values.
For netCDF/4.9.3-iimpi-2025b, use the same commands but replace the
compilation line with:
I_MPI_CC=icx "$(nc-config --cc)" $(nc-config --cflags) generated.c -o generated $(nc-config --libs)
I_MPI_CC=icx selects Intel’s current C compiler; the compiler recorded by
this netCDF build otherwise requests the unavailable icc compiler.
Installation notes
netCDF was installed using Easybuild, build details can be found in $EBROOTNETCDF/easybuild with a given module loaded.