-
Notifications
You must be signed in to change notification settings - Fork 7
NetCDF
NetCDF (Network Common Data Form) is a set of software libraries and self-describing, machine-independent data formats that support the creation, access, and sharing of array-oriented scientific data[1].
The source codes for netCDF-C, netCDF-Fortran & netCDF-C++ can be downloaded from https://www.unidata.ucar.edu/downloads/netcdf/index.jsp. The netCDF-C library and utilities require the following third-party libraries for full functionality[2]:
- HDF5 1.8.9 or later (for netCDF-4 support)
- zlib 1.2.5 or later (for netCDF-4 compression)
- curl 7.18.0 or later (for DAP remote access client support)
netCDF-C 4.3.0:
$ cd /scratch $ tar xvfz netcdf-4.3.0.tar.gz $ cd netcdf-4.3.0 $ ./configure --prefix=/pfs/sw/serial/gcc/netcdf-4.3.0 $ make $ make install
netCDF-Fortran 4.2:
$ cd /scratch $ tar xvfz netcdf-fortran-4.2.tar.gz $ cd netcdf-fortran-4.2 $ export LD_LIBRARY_PATH=/pfs/sw/serial/gcc/netcdf-4.3.0/lib:$LD_LIBRARY_PATH $ CPPFLAGS=-I/pfs/sw/serial/gcc/netcdf-4.3.0/include \ LDFLAGS=-L/pfs/sw/serial/gcc/netcdf-4.3.0/lib \ ./configure --prefix=/pfs/sw/serial/gcc/netcdf-4.3.0 $ make $ make install
netCDF-C 4.3.1.1:
$ cd /scratch $ rm -rf netcdf-4.3.1.1 $ tar xvfz netcdf-4.3.1.1.tar.gz $ cd netcdf-4.3.1.1 $ CC=icc ./configure --prefix=/pfs/sw/serial/gcc/netcdf-4.3.0 $ make $ make install
netCDF-Fortran 4.2:
$ cd /scratch $ rm -rf netcdf-fortran-4.2 $ tar xvfz netcdf-fortran-4.2.tar.gz $ cd netcdf-fortran-4.2 $ export LD_LIBRARY_PATH=/pfs/sw/serial/intel/netcdf-4.3.1.1/lib:$LD_LIBRARY_PATH $ CC=icc FC=ifort F77=ifort \ CPPFLAGS=-I/pfs/sw/serial/intel/netcdf-4.3.1.1/include \ LDFLAGS=-L/pfs/sw/serial/intel/netcdf-4.3.1.1/lib \ ./configure --prefix=/pfs/sw/serial/intel/netcdf-4.3.1.1 $ make $ make install
We must first load the pgi module:
$ module load pgi
netCDF-C 4.3.1.1:
$ cd /scratch $ rm -rf netcdf-4.3.1.1 $ tar xvfz netcdf-4.3.1.1.tar.gz $ cd netcdf-4.3.1.1
The command
$ CC=pgcc ./configure --prefix=/pfs/sw/serial/pgi/netcdf-4.3.1.1will fail with the following error:
checking how to run the C preprocessor... /opt/pgi/linux86-64/14.10/bin/pgprepro configure: error: in `/scratch/netcdf-4.3.1.1': configure: error: C preprocessor "/opt/pgi/linux86-64/14.10/bin/pgprepro" fails sanity check
We must specify CPP:
$ CC=pgcc CPP="pgcc -E" \ ./configure --prefix=/pfs/sw/serial/pgi/netcdf-4.3.1.1 $ make $ make install
netCDF-Fortran 4.2:
$ cd /scratch $ rm -rf netcdf-fortran-4.2 $ tar xvfz netcdf-fortran-4.2.tar.gz $ cd netcdf-fortran-4.2
Instead of specifying CPPFLAGS and LDFLAGS as when using GCC or Intel compilers[3], here we just load the netcdf/s_pgi_4.3.1.1:
$ module load netcdf/s_pgi_4.3.1.1 $ CC=pgcc CPP="pgcc -E" \ FC=pgf90 F77=pgf77 \ ./configure --prefix=/pfs/sw/serial/pgi/netcdf-4.3.1.1 $ make $ make install
netCDF C++ 4.2.1:
$ cd /scratch $ wget https://github.com/Unidata/netcdf-cxx4/archive/v4.2.1.tar.gz $ mv v4.2.1 netcdf-cxx4-4.2.1.tar.gz $ tar xvfz netcdf-cxx4-4.2.1.tar.gz $ cd netcdf-cxx4-4.2.1 $ module load netcdf/s_pgi_4.3.1.1
The command
$ CC=pgcc CPP="pgcc -E" CXX=pgCC \ ./configure --prefix=/pfs/sw/serial/pgi/netcdf-4.3.1.1will fail with the following error:
configure: error: NetCDF must be built with netCDF-4 enabled.
The error, however, is misleading; because NetCDF is built with netCDF-4 enabled:
$ nc-config --has-nc4 yes
A quick Google search will turn up many similar errors, dating at least back to 2012[4]. The solution offered by the netCDF support team doesn't work! A quick inspection of the configuration log suggests that there is a bug in the Autoconf[5] test, which fails to correctly determine whether netCDF-4 is enabled or not. My workaround is to replace the following line in configure:
nc_build_v4=$ac_cv_func_nc_def_opaquewith
nc_build_v4=yesthen I can successfully build netcdf-cxx4-4.2.1:
$ CC=pgcc CPP="pgcc -E" CXX=pgCC \ ./configure --prefix=/pfs/sw/serial/pgi/netcdf-4.3.1.1 $ make $ make install
We've also installed netcdf4-python[6][7], the Python interface to the netCDF C library, on Hyades.
$ module load python $ export NETCDF4_DIR=/pfs/sw/serial/intel/netcdf-4.3.1.1 $ pip install netCDF4
To facilitate the usage of netCDF libraries, we've create a few module files for them.
To list all available netCDF modules, run:
$ module avail netcdf netcdf/s_gcc_4.3.0 netcdf/s_intel_4.3.1.1(default) netcdf/s_pgi_4.3.1.1
To display information about, e.g., the netcdf/s_pgi_4.3.1.1 module and list the environment changes it makes, run:
$ module display netcdf/s_pgi_4.3.1.1 ------------------------------------------------------------------- /pfs/sw/modulefiles/netcdf/s_pgi_4.3.1.1: module-whatis Set up environment for netcdf compiled with PGI compilers prepend-path PATH /pfs/sw/serial/pgi/netcdf-4.3.1.1/bin prepend-path CPATH /pfs/sw/serial/pgi/netcdf-4.3.1.1/include prepend-path LIBRARY_PATH /pfs/sw/serial/pgi/netcdf-4.3.1.1/lib prepend-path LD_LIBRARY_PATH /pfs/sw/serial/pgi/netcdf-4.3.1.1/lib prepend-path MANPATH /pfs/sw/serial/pgi/netcdf-4.3.1.1/share/man -------------------------------------------------------------------
To load the netcdf/s_pgi_4.3.1.1 module, run:
$ module load netcdf/s_pgi_4.3.1.1Then you can simply use the option -lnetcdf to link with the netCDF-C library built with the PGI compilers. You don't need specify the include path with -I/pfs/sw/serial/pgi/netcdf-4.3.1.1/include, nor the library path with -L/pfs/sw/serial/pgi/netcdf-4.3.1.1/lib.
Ncview is a visual browser for netCDF format files.
To install Ncview, first build udunits (a C-based package for the programatic handling of units of physical quantities) 2.1.24; then build Ncview 2.1.4:
$ cd /scratch $ tar xvfz ncview-2.1.4.tar.gz $ ./configure \ --prefix=/pfs/sw/serial/gcc/ncview-2.1.4 \ --with-nc-config=/pfs/sw/serial/gcc/netcdf-4.3.0/bin/nc-config \ --with-udunits2_incdir=/pfs/sw/serial/gcc/udunits-2.1.24/include \ --with-udunits2_libdir=/pfs/sw/serial/gcc/udunits-2.1.24/lib $ make $ make install
To use Ncview, first load its module:
$ module load ncview