NetCDF
NetCDF (Network Common Data Form) is an interface for array-oriented data access and a freely-distributed collection of software libraries for C, Fortran, C++, Perl and Java that provide implementations of the interface. The netCDF software was developed by Glenn Davis, Russ Rew, Steve Emmerson and Harvey Davies at the Unidata Program Center in Boulder, Colorado, and augmented by contributions from other netCDF users. The netCDF libraries define a machine-independent format for representing scientific data. Together, the interface, libraries, and format support the creation, access, and sharing of scientific data.
Which versions of netCDF are installed at LRZ?
On all Linux HPC Systems the C, C++, Fortran and Parallel netCDF APIs of netCDF are installed. We provide all libraries for both INTEL and GCC compilers.
Depending on the system, the APIs are organized in different ways as explained in the following two paragraphs.
Software Stack/24.5.0 and newer stack versions
Beginning from stack/24.5.0 and newer the netcdf packages are provided as seperate modules. For example on stack/24.6.0:
:~> module av netcdf --------------------------------------------------------------- /lrz/sys/spack/release/sles15.7/24.6.0/modules/skylake_avx512 ---------------------------------------------------------------- netcdf-c/4.9.2-gcc14 netcdf-c/4.9.2-intel25 netcdf-cxx4/4.3.1-gcc14-impi netcdf-fortran/4.6.1-gcc14-impi netcdf-c/4.9.2-gcc14-impi netcdf-c/4.9.2-intel25-impi netcdf-cxx4/4.3.1-intel25-impi netcdf-fortran/4.6.1-intel25-impi
For easier usage, each module sets several environment variables, which can be shown bymodule show MODULENAME
For Parallel netCDF, please see here: PnetCDF
Software Stack/24.4.0 and earlier stack versions
The different APIs (C, C++, C++ legacy, Fortran and parallel-netCDF) together with HDF5 have been combined into bundle-packages called "netcdf-hdf5-all".
You can get a list of all available environment modules for netcdf with:
module av netcdf-hdf5-all
For a specific module, you can check the provided API and HDF5 versions via
~> module show netcdf-hdf5-all/MODULE_VERSION | grep VERSION
So e.g.:
module show netcdf-hdf5-all/4.6_hdf5-1.10-intel21-impi | grep VERSION setenv NETCDF_C_VERSION 4.6.3 setenv NETCDF_FORTRAN_VERSION 4.4.5 setenv NETCDF_CXX4_VERSION 4.3.1 setenv NETCDF_LEGACY_CXX_VERSION 4.2 setenv HDF5_VERSION 1.10.7 setenv PNETCDF_VERSION 1.11.2
The parallel modules also include pnetcdf/parallel-netcdf and all packages are configured to use INTEL MPI.
For easier usage, each module sets several environment variables, which can be shown by
module show netcdf-hdf5-all
Here netcdf-hdf5-all reverts to the default module. The corresponding module ist loaded via:
module load netcdf-hdf5-all
Compilation for Serial Use
Make sure you load the appropriate module(s) (see above) first. For example, if you plan to use the C-API of netCDF together with GCC:
module load netcdf-c/4.9.2-gcc14
or on older stacks
module load netcdf-hdf5-all/4.6_hdf5-1.10-gcc8-serial
If you do not have a build system that autodetects the corresponding libraries, you can compile your code with [Intel|GCC] as follows for the C, C++ and the Fortran API:
[icx|gcc] -c $NETCDF_INC foo.c [icpx|g++] -c $NETCDF_CXX4_INC foo.cpp [ifx|gfortran] -c $NETCDF_FORTRAN_INC foo.f90
Link your code with:
[icx|gcc] -o myprog.exe mainC.o foo.o $NETCDF_SHLIB [icpx|g++] -o myprog.exe mainCPP.o foo.o $NETCDF_CXX_SHLIB [ifx|gfortran] -o myprog.exe mainF.o foo.o $NETCDF_F90_SHLIB
Compilation for Parallel Use
Make sure you load the appropriate module first. For example, if you plan to use netCDF together with INTEL:
module load netcdf-c/4.9.2-intel25-impi
or for older stacks
module load netcdf-hdf5-all/4.6_hdf5-1.10-intel19-impi
Of course, you only need to load the modules for the APIs that you plan to use.
For compilation then use the MPI compiler wrappers for [INTEL|GCC]:
[mpiicx|mpigcc] -c $NETCDF_INC foo.c [mpiicpx|mpigxx] -c $NETCDF_CXX4_INC foo.cpp [mpiifx|mpifc] -c $NETCDF_FORTRAN_INC foo.f90
You can check with "MPICOMPILERWRAPPER --version" if the wrapper uses to the correct compiler.
Linking is analogue:
[mpiicx|mpigcc] -o myprog.exe mainC.o foo.o $NETCDF_SHLIB [mpiicpx|mpigxx] -o myprog.exe mainCPP.o foo.o $NETCDF_CXX_SHLIB [mpiifx|mpifc] -o myprog.exe mainF.o foo.o $NETCDF_F90_SHLIB
NetCDF Operators (NCO)
To make use of the NetCDF operators (NCO), please load the appropriate environment module. The available versions can be shown by:
module av nco
The default module is loaded by:
module load nco
Documentation
- Please refer to the netCDF Web Site for documentation of the interface. The manuals include a description of the integrated parallel facilities.
- Please refer to the PNetCDF Web Site for documentation of the pnetcdf interface.
- Documentation on the netCDF operators may be found on the NCO Web Site.