NetCDF library


Jump to: navigation, search

The following instructions describe the installation of the NetCDF 4 library, with the HDF5 storage format.

The installation of the packages and libraries was performed on nic3 in the directory /u/mc and on the computer gher01 in the directory /usr/local


Download the sources

  • Download the NetCDF sources from Unidata webpage:
  • Extract the archive:
tar -xvf netcdf.tar.gz

NetCDF with Intel Compilers

Install HDF5 and zlib packages

  • Download:
  • Extract the archives:
tar -xvf hdf5-1.8.2.tar.gz
tar -xvf zlib-1.2.3.tar.gz
  • Install zlib first
cd /u/mc/zlib-1.2.3
./configure --prefix=/u/mc
make install
  • Install HDF5
cd /u/mc/hdf5-1.8.2
./configure --prefix=/u/mc
make check
make install


  1. if you want to be sure to have the last version of zlib and hdf5, check
  2. that the make operation can take quite a long time.
  3. replace /u/mc by /usr/local (or something else) for an installation on you machine


  • Specify the compilation options you want:
export CC=icc
export FC=ifort
  • Launch the configuration
./configure --enable-netcdf-4 --with-hdf5=/u/mc/ --with-zlib=/u/mc/ --prefix=/u/mc/

where /u/mc can be replaced by the location you want.

  • Run the tests
make check

Note that some of the tests may fail, but usually that is not a problem.

  • Perform the installation
make install

Once the installation is performed, new directories will appear in /u/mc:

  • bin/
  • include/
  • lib/
  • share/

In particular, the netcdf library is located in lib:

nick3:/u/mc$ ls lib/
libhdf5.a      libnetcdf_c++.a   libz.a
libhdf5_hl.a      libhdf5.settings  pkgconfig        libnetcdf.a

NetCDF with gcc

sudo aptitude install libhdf4-dev libhdf5-serial-dev 
./configure --enable-hdf4  --enable-cxx-4  --with-udunits --with-pic
sudo make install

Failed options

*** No rule to make target `../../libsrc/', needed by `cfcheck'.  Stop.
*** Testing HDF4/NetCDF-4 interoperability...
/bin/bash: line 5: 28738 Segmentation fault      ${dir}$tst
FAIL: tst_interops2
1 of 60 tests failed
Personal tools