Skip to content

Compiling NetCDF

NetCDF is a C library. It also provides Fortran and C++ interfaces, which are distributed separately. These Fortran and C++ interfaces rely on the C version, and the version numbers do not track. E.g. NetCDF Fortran 4.4.4 can be compiled against both NetCDF C 4.4.1 and NetCDF C 4.5.0.

Installed Versions

If you just need to use NetCDF see the article on NetCDF.

Documentation

  • Official build documentation is online[1]

Prerequisites

  • Intel Composer XE - modulefile intel/composerxe/2015.1.133
  • HDF5 - modulefile hdf5/intel/2015/1.10.1-serial
  • CMake - modulefile cmake/gcc/3.9.4
  • Doxygen - modulefile doxygen/1.8.12

Notes

  • NetCDF C 4.5.0 compiles and tests successfully using the cmake build
  • NetCDF Fortran 4.4.0 does not build correctly with the cmake build, but builds and tests correctly using configure

NetCDF C 4.5.0

  • Use Cmake
$ cd netcdf-c-4.5.0
$ mkdir BUILD
$ cd BUILD
$ ccmake ..
set the right things, including paths to HDF5, installation prefix, compiler options

NetCDF Fortran 4.4.4

  • Must have already built and installed NetCDF C 4.5.0, and then loaded the modulefile for NetCDF C 4.5.0
  • Use configure
  • Set these environment variables:
CPPFLAGS=${NETCDFDIR}/include
CFLAGS="-O3 -xHost -ip"
FCFLAGS="-O3 -xHost -ip"
LDFLAGS="-L${NETCDFDIR}/lib64 -Wl,-rpath,${NETCDFDIR}/lib64"
  • Configure
    ./configure --prefix=${NETCDF} \
        --disable-parallel-tests \
        --enable-large-file-tests --enable-largefile \
        --with-temp-large=/tmp > & Configure.out &
  • Make, check, install
     $ make -j 20
     $ make check
     $ make install

References

[1] NetCDF - Getting and Building NetCDF