Required Libraries

Required Libraries cindyhg Tue, 04/23/2019 - 15:16

Some external libraries are required for compiling/building MET and should be downloaded and installed before attempting to install MET. Many users may already have one or more of the required libraries on their system. In particular, WRF users will likely already have NetCDF built for use with WRF. However, users must ensure that the following libraries are built on their machines using the *same* family of compilers that will be used to build MET:

  • Unidata's NetCDF4 library.

  • Both NetCDF-C and NetCDF-CXX are required:
wget https://github.com/Unidata/netcdf-c/archive/v4.4.1.1.zip
wget https://github.com/Unidata/netcdf-cxx4/archive/v4.3.0.tar.gz
  • The GNU Scientific Library (GSL)
  • NCEP's BUFRLIB
  • NCEP's GRIB2 C-Library (optional)
  • The HDF5 library is required to support NetCDF 4 (which is also required). HDF5 should be built with zlib.
  • The HDF and HDF-EOS libraries for using the MODIS-Regrid tool (optional)
  • The Cairo and FreeType libraries for using the MODE-Graphics tool (optional)
  • Python 2.7 for allowing MET to read gridded data by calling a Python script (numpy or xarray required; netCDF4 is useful when using this functionality) (optional)

MET now requires NetCDF version 4. See section on Compiling NetCDF below.

MET is not yet compatible with BUFRLIB version 11.0.0, released 04/27/2015. Please use BUFRLIB v10.2.3

Compiling BUFRLIB

NCEP's BUFRLIB is used by the pb2nc MET tool to decode point-based observation datasets in PrepBufr format. Compilation of pb2nc is enabled by default but may be disabled using the --disable-pb2nc option for configure. Once you have downloaded and unpacked the BUFRLIB tarball, refer to the README_BUFRLIB file. Users should use the compilation options listed below for each compiler. Once built, MET expects the BUFRLIB archive file to be named libbufr.a.

Unpacking the BUFRLIB tarball consists of the following 3 steps:

  • Make a new directory to contain the BUFRLIB code (e.g. mkdir /home/user/BUFRLIB).
  • Move the BUFRLIB tarball to the new directory (e.g. mv BUFRLIB.tar /home/user/BUFRLIB/.).
  • Unpack the tarball (e.g. cd /home/user/BUFRLIB; tar -xvf BUFRLIB.tar).

Next, compile BUFRLIB using a C and a FORTRAN compiler.

Compiling BUFRLIB using the GNU gcc and gfortran compilers consists of the following 3 steps:

gcc -c -DUNDERSCORE *.c
gfortran -c -DUNDERSCORE -fno-second-underscore *.f *.F
ar crv libbufr.a *.o

Compiling BUFRLIB using the PGI pgcc and pgf90 compilers consists of the following 3 steps:

pgc++ -c -DUNDERSCORE *.c
pgf90 -c -DUNDERSCORE -Mnosecond_underscore *.f *.F
ar crv libbufr.a *.o

Compiling BUFRLIB using the Intel icc and ifort compilers consists of the following 3 steps:

icc -c -DUNDERSCORE *.c
ifort -c -DUNDERSCORE *.f *.F
ar crv libbufr.a *.o

Warnings may be encountered when compiling a few of the BUFRLIB files but they may be ignored.

Compiling zlib

zlib is used by MET when producing postscript output files. If zlib not already available on your system, download and unpack the tarball.

The following is a summary of the steps for building zlib using the C-shell:

cd /path/to/zlib
./configure --prefix=/zlib/install/path
make test
make install

Compiling HDF5

The HDF5 library is required to support NetCDF4. Compile HDF5 prior to compiling NetCDF4. If the HDF5 library is not already available on your system, download and unpack the tarball.

The following is a summary of the steps for building HDF5.

echo "Compiling HDF5"
wget https://support.hdfgroup.org/ftp/HDF5/releases/hdf5-1.8/hdf5-1.8.18/src/hdf5-1.8.18.tar.gz
tar -xvzf hdf5-1.8.18.tar.gz 
cd hdf5-1.8.18
setenv ZDIR /path/to/zlib/lib
setenv H5DIR /path/with/location/to/install/hdf5
./configure --with-zlib=${ZDIR} --prefix=${H5DIR}
make
make check
make install

Note: you might encounter a cyclical dependency between NetCDF4 and HDF5 if you attempt to configure HDF5 before configuring NetCDF4 and you have an existing installation of HDF5. Two solutions to this issue:

  • Recompile with the proper HDF5 or indicate the correct HDF5 path with LD_LIBRARY_PATH
  • Disable the HDF version checking by setting the environment variable 'HDF5_DISABLE_VERSION_CHECK' to the value of '1'

Compiling NetCDF

Unidata's NetCDF libraries are used by several tools within MET for writing output NetCDF files. Users may also find some utilities built for NetCDF such as ncdump and ncview useful for viewing the contents of NetCDF files. Detailed installation instructions are available from Unidata.

Prior to running the NetCDF configure script, users are encouraged to explicitly specify the compilers to be used by setting the following variables:

  • Set CC to the C compiler to be used: setenv CC /path/to/c/compiler
  • Set CXX to the C++ compiler to be used:setenv CXX /path/to/c++/compiler
  • Set FC to the Fortran compiler to be used (not used by MET) or set to an empty string ("") to disable:setenv FC ''
  • Set F90 to the Fortran90 to be used (not used by MET) or set to an empty string ("") to disable:setenv F90 ''
  • Set MET_LIB_DIR to your installation directory.

Checklist for NetCDF4 C++ installation Files for NetCDF4 C:

  • $MET_NETCDF/include/netcdf.h
  • $MET_NETCDF/lib/libnetcdf.a
  • $MET_NETCDF/lib/libnetcdf.so

Files for NetCDF4 C++:

  • $MET_NETCDF/include/netcdf
  • $MET_NETCDF/lib/libnetcdf_c++4.a
  • $MET_NETCDF/lib/libnetcdf_c++4.so

Files to check if netcdf4 was disabled (not correct):

  • $MET_NETCDF/include/netcdf.hh
  • $MET_NETCDF/lib/libnetcdf_c++.a
  • $MET_NETCDF/lib/libnetcdf_c++.so

NetCDF-C

  • wget https://github.com/Unidata/netcdf-c/archive/v4.4.1.1.zip
  • unzip v4.4.1.1.zip
  • cd netcdf-c-4.4.1.1
  • ./configure --prefix=${MET_LIB_DIR}/external_libs LDFLAGS=-L${MET_LIB_DIR}/external_libs/lib CPPFLAGS=-I${MET_LIB_DIR}/external_libs/include
  • make install

NetCDF-CXX

  • wget https://github.com/Unidata/netcdf-cxx4/archive/v4.3.0.tar.gz
  • tar -xvzf v4.3.0.tar.gz
  • cd netcdf-cxx4-4.3.0
  • ./configure --prefix=${MET_LIB_DIR}/external_libs LDFLAGS=-L${MET_LIB_DIR}/external_libs/lib CPPFLAGS=-I${MET_LIB_DIR}/external_libs/include
  • make install

When running the NetCDF configure script, users may want to pass in the --prefix=/netcdf/install/path command line argument to specify where the NetCDF library should be installed.

Compiling GNU Scientific Library

The GNU Scientific Library (GSL) is used by MET when computing confidence intervals. Precompiled binary packages are available for most GNU/Linux distributions and may be installed with root access. When installing GSL from a precompiled package on Debian Linux, the developer's version of GSL must be used. MET requires access to the GSL source headers and library archive file at build time.

For those who have downloaded and are building the GSL source code locally:

  • In the top-level GSL directory, refer to the README and INSTALL files for instructions.
  • Set CC to the C compiler to be used.
  • Run the configure script.
  • Type make to build the GSL library.

When running the GSL configure script, users may want to pass in the --prefix=/GSL/install/directory command line argument to specify where the GSL library should be installed.

The following is a summary of these steps for building GSL using the C-shell:

cd /path/to/gsl
setenv CC /path/to/c/compiler
./configure --prefix=/gsl/install/path
make
make install

PGI users should download and compile GSL-1.11 since later versions do not build correctly with PGI.

Compiling GRIB2 C-Library

The GRIB2 C-Library is used by the MET library code to read GRIB2 data files. Support for GRIB2 is optional and can be enabled with the --enable-grib2 option for configure. If the grib2c library is not already available on your system, download and unpack the tarball and refer to the README file.

Unfortunately, there are hard coded values in the "makefile", which need to be modified:

  • If using a compiler other than "gcc" please edit the value of CC in "makefile".
  • Because the GRIB2 C-Library requires the libraries zlib, jasper and png to be present on your system, please edit the value of "INC" to be the location of the include directory for the header files of those libraries.
  • Compiling the GRIB2C library with the -D__64BIT__ option requires that MET also be configured with CXXFLAGS="-D__64BIT__". Compiling MET and the GRIB2C library inconsistently may result in a segmentation fault when reading GRIB2 files. Either remove the -D__64BIT__ flag from the g2clib library or set the CXXFLAG. The __64BIT__ option should either be used for both or neither.
  • Once built, MET expects the GRIB2 C-Library to be named libgrib2c.a. Please either edit the value of LIB in "makefile" to be libgrib2c.a or rename the .a file after it is created.

If you'd like to have a different installation location instead of working in the default g2clib directory, please copy over the library .a file to your lib dir and the .h header files to your include directory. When configuring the MET build, set the MET_GRIB2C (or MET_GRIB2CINC and MET_GRIB2CLIB) environment variables to indicate the location of this library.

Compiling HDF4 and HDF-EOS

The HDF4 and HDF-EOS2 libraries are required for building the MODIS-Regrid tool. This support is optional and can be enabled with the --enable-modis option for configure. If the HDF4 library is not already available on your system, download and unpack the HDF4 tarball . If the HDF-EOS2 library is not already available on your system, download and unpack the HDF-EOS2 tarball.

The following is a summary of the steps for building HDF4 using the C-shell. Please note the need to edit one of the HDF4 makefiles (mfhdf/hdiff/Makefile) changing 'LIBS = -ljpeg -lz' to 'LIBS = -ljpeg -lz -lm':

echo "Compiling HDF4" 
cd hdf 
tar -xzf HDF4.2r3.tar.gz
cd HDF4.2r3
./configure --prefix=${INSTALL_DIR} --disable-netcdf >& /dev/null
cat mfhdf/hdiff/Makefile | sed 's/LIBS = -ljpeg -lz/LIBS = -ljpeg -lz -lm/g' > Makefile_NEW
mv Makefile_NEW mfhdf/hdiff/Makefile
make >& /dev/null
make install >& /dev/null

The following is a summary of the step for building HDF-EOS2 using the C-shell.

echo "Compiling HDF-EOS"
cd hdfeos
tar -xf HDF-EOS2.16v1.00.tar
cd hdfeos
./configure --prefix=${INSTALL_DIR} \
--with-hdf4=${INSTALL_DIR} CC=${INSTALL_DIR}/bin/h4cc \
--enable-install_include >& /dev/null

make >& /dev/null
make install >& /dev/null

Compiling Cairo and FreeType

The Cairo and FreeType libraries are needed for building the MODE-Graphics tool. This support is optional and can be enabled with the --enable-mode_graphic option for configure. If the Cairo and FreeType libraries are not already available on your system, download and unpack the tarball.

The following is a summary of the steps for building Cairo using the C-shell:

cd /path/to/cairo
./configure --prefix=/cairo/install/path
make
make install

The following is a summary of the steps for building FreeType using the C-shell:

cd /path/to/freetype
./configure --prefix=/freetype/install/path
make
make install

 

Note: the "make install" fails if the install directory is the same with the build directory for freetype 2.7.