NetCDF format


(Difference between revisions)
Jump to: navigation, search
(Installation of the NetCDF library)
(Co=mpilation with Intel Compilers =)
Line 37: Line 37:
  tar -xvf netcdf.tar.gz
  tar -xvf netcdf.tar.gz
=== Co=mpilation with Intel Compilers ====
==== Compilation with Intel Compilers ====
Intel compilers are available for free non-commercial download at
Intel compilers are available for free non-commercial download at

Revision as of 20:37, 5 November 2013

NetCDF stands for Network Common Data Form. It is self-describing, machine-independent data format, frequently used in ocean and atmospheric sciences.



Visualization of NetCDF files

There are several ways to have a quick view of the content of a NetCDF file:

  • ncBrowse (very easy to install on any platform)
  • Ncview (easy on Linux, tricky on Windows), installation detailed here
  • Ferret: an interactive computer visualization and analysis environment.
  • ODV: lets you explore and visualize CF, COARDS, GDT and CDC compliant netCDF datasets.
  • Panoply: the NASA data viewer for netCDF, HDF and GRIB data.

Installation of the NetCDF library

Use a package manager to download libraries

This approach is generally the easiest one provided you find a library which was compiled with the same compile you plan to use (gnu gfortran for example). Make sure you install development libraries and Fortran interface libraries. If this approach does not work you will need to compile netCDF yourself as explained in the following

Download the sources if you do not find libraries

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 NetCDF sources from Unidata webpage:
  • Extract the archive:
tar -xvf netcdf.tar.gz

Compilation with Intel Compilers

Intel compilers are available for free non-commercial download at

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

Compilation 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

Operations on NetCDF files


The command ncdump allows the user to examine the content of a NetCDF file.

Examples are available here:

Display header information

ncdump -h time

Display a given variable

ncdump -v time

netCDF Operator (NCO)

NetCDF Operator (NCO) is a set of command-line programs that take netCDF files as input and perform operations on their content.


ncclamp is another command-line tool for the replacement of values in files.

Note that you may have to modify the makefile before compilation of the code.

ncclamp TSM nan -999 eq

replaces all the NaN's by -999


CDO stands for Climate Data Operator. A collection of command line Operators to manipulate and analyse Climate and NWP model Data.

Personal tools