Pre-requisite Software for building NCL

Since NCL requires many external software packages make sure that all the packages are compiled with the same set of compilers and use the same compiler options (This makes life easier). For tcsh build scripts assuming that you are using GNU compilers use,

setenv CC gcc
setenv CXX g++
setenv FC gfortran

Don't use g77 fortran compiler for building any of the packages. The compiler is old and replaced by the newer gfortran compiler.

The following external packages are required before building NCL.

  • JPEG
  • ZLIB
  • NetCDF
    • szip
    • HDF-5
    • libcurl
  • HDF-4

JPEG

All versions of the JPEG image compression library are not compatible with NCL (and other packages like HDF4).

  • Download version 6b from  HDF4 website.
  • Build and install the software
#!/bin/tcsh
setenv CC gcc
setenv CXX g++
setenv FC gfortran
./configure --prefix=$HOME/utils/jpeg-6b/install |& tee configure.log
make |& tee make.log
make install |& tee install.log

ZLIB

  • Download ZLIB version 1.2.5 from  ZLIB website.
  • I had to comment out line 171 in the Makefile.in that assumed the existence of shared libs.
            cp $(STATICLIB) $(DESTDIR)$(libdir)
    #       cp $(SHAREDLIBV) $(DESTDIR)$(sharedlibdir)
            cd $(DESTDIR)$(libdir); chmod u=rw,go=r $(STATICLIB)
    
  • Configure ZLIB to generate static libraries
  • Build and install the source
#!/bin/tcsh
setenv CC gcc
setenv CXX g++
setenv FC gfortran
./configure --prefix=$HOME/utils/zlib-1.2.5/install --static |& tee configure.log
make |& tee make.log
make install |& tee install.log

SZIP

  • Download szip version 2.1 from  HDF4 website.
  • Configure szip to generate static libraries.
  • Build and install SZIP.
#!/bin/tcsh
setenv CC gcc
setenv CXX g++
setenv FC gfortran
./configure --prefix=$HOME/utils/szip-2.1/install --disable-shared --enable-static |& tee configure.log
make |& tee make.log
make install |& tee install.log

HDF5

  • Download HDF5 version 1.8.5-patch 1 from the  HDF5 ftp site. Note that I haven't tested versions > 1.8.5-patch1 and versions < 1.8.5patch1 have known issues with NetCDF.
  • Configure HDF5 to generate static libraries
#!/bin/tcsh
setenv CC gcc
setenv CXX g++
setenv FC gfortran
./configure --prefix=$HOME/utils/hdf5-1.8.5-patch1/install --disable-shared --enable-static --with-zlib=$HOME/utils/zlib-1.2.5/install |& tee configure.log
make |& tee make.log
make install |& tee install.log

NetCDF

  • Download NetCDF version 4.1.1 from  NetCDF website.
  • Eventhough I specified the paths to hdf5 to the NetCDF configure script with the "--with-hdf5" option I had to set the compiler flags for NetCDF to pick the correct libraries. This needs to be investigated further.
  • Configure NetCDF to disable shared libraries, enable NetCDF 4 and use the hdf5, zlib and szip libraries installed.
#!/bin/tcsh
setenv CC gcc
setenv CXX g++
setenv FC gfortran
setenv CFLAGS '-I$HOME/utils/hdf5-1.8.5-patch1/install/include -I$HOME/utils/zlib-1.2.5/install/include -I$HOME/utils/szip-2.1/install/include'
setenv LDFLAGS '-no-undefined -L$HOME/utils/hdf5-1.8.5-patch1/install/lib -L$HOME/utils/zlib-1.2.5/install/lib -L$HOME/utils/szip-2.1/install/lib'
setenv CXXFLAGS '-I$HOME/utils/hdf5-1.8.5-patch1/install/include -I$HOME/utils/zlib-1.2.5/install/include -I$HOME/utils/szip-2.1/install/include'
./configure --prefix=$HOME/utils/netcdf-4.1.1/install --enable-netcdf4 --disable-shared --with-hdf5=$HOME/utils/hdf5-1.8.5-patch1/install --with-zlib=$HOME/utils/zlib-1.2.5/install --with-szip=$HOME/utils/szip-2.1/install |& tee configure.log
make |& tee make.log
make install |& tee install.log

HDF-4

  • NCL requires HDF4 to be installed eventhough we have already installed HDF5.
  • Download HDF 4.2.5 from the  HDF4 website.
  • Configure HDF to disable netcdf, disable shared libraries, use the installed zlib and jpeg libs and install headers in "<INSTALL-DIR>/include/hdf"
  • Build and install HDF4.
#!/bin/tcsh
setenv CC gcc
setenv CXX g++
setenv F77 gfortran
setenv FC gfortran

./configure --prefix=$HOME/utils/hdf-4.2.5/install --includedir=$HOME/utils/hdf-4.2.5/install/include/hdf --disable-shared --enable-static --with-zlib=$HOME/utils/zlib-1.2.5 --with-jpeg=$HOME/utils/jpeg-6b --disable-netcdf |& tee configure.log
make |& tee make.log
make install |& tee install.log