Compilation
Compilation cindyhg Tue, 04/23/2019 - 14:53Getting Started
Please refer to Chapter 2 of the MET Users Guide for more detailed information on installing MET and the libraries on which it depends.
MET has been developed and tested on a single architecture, Debian Linux. However, many users have had success compiling MET on other platforms, including Red Hat Linux Enterprise.
Supported Architectures
The MET package was developed and tested on Debian Linux using GNU compilers. Other machines will be added to this list in future releases as they are tested. In particular, the goal is to support those architectures supported by the WRF model itself. Unfortunately, the NCAR-JNT and DTC group, which supports MET development, and the NCAR-MMM group, which supports WRF development, no longer have access to an IBM on which to test out our software. We will no longer be able to support the MET software on IBM platforms unless we regain access to an IBM for testing.
Vendor | Hardware | OS | Compiler |
---|---|---|---|
DELL | XEON | Linux | GNU / PGI / Intel |
Get MET Source Code
The source code for MET is available from the MET download page:
Download the MET version 8.0 tarball named met-8.0.tar.gz rather than the bugfix tarball. Place the tarball in the installation directory and execute the following commands:
tar -xvf met-8.0.20180927.tar
These commands create the met-8.0 directory.
Examine the MET Source Code
Move into the met-8.0 directory you created:
Inside this directory, you will find the following files and subdirectories:
- aclocal.m4 used by the autoconf build process
- compile used by the autoconf build process
- config.guess used by the autoconf build process
- config.h.in used by the autoconf build process
- config.sub used by the autoconf build process
- configure used by the autoconf build process
- configure.ac used by the autoconf build process
- data/ subdirectory contains map data, colortables, sample input data, and default configuration files.
- depcomp used by the autoconf build process
- doc/ subdirectory contains the MET Users Guide.
- install-sh used by the autoconf build process
- Makefile.am used by the autoconf build process
- Makefile.in used by the autoconf build process
- Make-include used by the autoconf build process
- missing used by the autoconf build process
- out/ subdirectory is where the output from the test scripts is written.
- README contains useful information about setting up and running MET.
- scripts/ subdirectory contains the test scripts that users are strongly encouraged to run after building MET.
- src/ subdirectory contains all the source code for MET tools and libraries.
Get the Latest MET Patches
The latest set of patches for MET is available from the MET known issues page:
Place the latest set of patches in the top-level met-8.0 directory, and execute the following commands:
tar -xvf met-8.0*patches*.tar
Required Libraries
Required Libraries cindyhg Tue, 04/23/2019 - 15:16Some 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:
- 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:
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:
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:
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:
./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.
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:
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':
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.
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:
./configure --prefix=/cairo/install/path
make
make install
The following is a summary of the steps for building FreeType using the C-shell:
./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.
Recommended Software
Recommended Software cindyhg Wed, 04/24/2019 - 11:59While not required to build MET, the following utilities are strongly recommended for use with MET:
Unified Post-Processor
The Unified Post-Processor is recommended for post-processing the raw WRF model output prior to verifying the data with MET. MET can easily read gridded data in GRIB1 or GRIB2 format on a standard, de-staggered grid and on pressure levels. These requirements match the Unified Post-Processor output format. The Unified Post-Processor may be used on output from both the ARW and NMM cores. It is available for download via the UPP page.
WRF-ARW wrf_interp Tool
MET can also read the NetCDF output of the wrf_interp tool for WRF-ARW output. However, support for wrf_interp data is limited to those variables defined on non-staggered dimensions. MET cannot read wind data from wrf_interp files since they are staggered.
copygb Utility
The MET software includes support for automated regridding on the fly. However, users may still find it convenient to regrid their data prior to passing it to the MET tools. The copygb utility is recommended for re-gridding model and observation datasets in GRIB1 format to a common verification grid. The copygb utility is distributed as part of the Unified Post-Processor and is also available from the NOAA Climate Predication Center.
wgrib2 Utility
The wgrib2 utility is recommended for re-gridding model and observation datasets in GRIB2 format to a common verification grid. The wgrib2 utility is distributed by the NOAA Climate Predication Center.
Configure MET
Configure MET cindyhg Wed, 04/24/2019 - 12:01The build and installation process performed using autoconf, a package that produces shell scripts to automatically configure software source code packages. Autoconf checks the system for available compilers and sets the flags accordingly.
Compilers
The autoconf package checks the system for which compilers are available and sets the flags accordingly, unless you explicitly tell it the ones to use. When compiling MET and all the dependent libraries, we need to use the same family of compilers. Set the following variables to specify which compilers should be used:
- Set CC to the full path for your C compiler.
- Set CXX to the full path for your C++ compiler (recommend GNU g++, PGI pgc++, or Intel icc).
- Set FC77 to the full path for your Fortran 90 compiler (recommend GNU gfortran, PGI pgf90, or Intel ifort).
Run the following command to see the full set of compiler and linker options available:
Set Environment Variables
The MET build process uses environment variables to specify the locations of the needed external libraries. For each library, there is a set of three environment variables to describe the locations: $MET_<lib>, $MET_<inc>INC, and $MET_<lib>LIB.
The $MET_<lib> environment variable can be used if the external library is installed such that there is a main directory which has a subdirectory called "lib" containing the library files and another subdirectory called "include" containing the include files. For example, if the NetCDF library files are installed in /opt/netcdf/lib and the include files are in /opt/netcdf/include, you can just define the $MET_NETCDF environment variable to be "/opt/netcdf".
The $MET_<inc>INC and $MET_<lib>LIB environment variables are used if the library and include files for an external library are installed in separate locations. In this case, both environment variables must be specified and the associated $MET_<lib>variable will be ignored. For example, if the NetCDF include files are installed in /opt/include/netcdf and the library files are in /opt/lib/netcdf, then you would set $MET_NETCDFINC to "/opt/include/netcdf" and $MET_NETCDFLIB to "/opt/lib/netcdf".
The following environment variables should also be set:
For ease of use, you should define these in your .cshrc or equivalent file.
- Set $MET_NETCDF to point to the main NetCDF directory (e.g. /usr/local/netcdf-4.3.0), or set $MET_NETCDFINC to point to the directory with the NetCDF include files (e.g. /usr/local/netcdf-4.3.0/include) and set $MET_NETCDFLIB to point to the directory with the NetCDF library files (e.g. /usr/local/netcdf-4.3.0/lib).
- Set $MET_HDF5 to point to the main HDF5 directory.
- Set $MET_BUFR to point to the main BUFR directory, or set $MET_BUFRLIB to point to the directory with the BUFR library files. Because MET doesn't use any BUFR library include files, you don't need to specify $MET_BUFRINC.
- Set $MET_GSL to point to the main GSL directory, or set $MET_GSLINC to point to the directory with the GSL include files and set $MET_GSLLIB to point to the directory with the GSL library files.
- If compiling support for GRIB2, set $MET_GRIB2CINC and $MET_GRIB2CLIB to point to the main GRIB2C directory which contains both the include and library files. These are used instead of $MET_GRIB2C since the main GRIB2C directory does not contain include and lib subdirectories.
- If compiling MODIS-Regrid, set $MET_HDF to point to the main HDF directory, or set $MET_HDFINC to point to the directory with the HDF include files and set $MET_HDFLIB to point to the directory with the HDF library files. Also, set $MET_HDFEOSINC to point to the directory with the HDF EOS include files and set $MET_HDFEOSLIB to point to the directory with the HDF EOS library files.
- If compiling MODE-Graphics, set $MET_CAIRO to point to the main Cairo directory, or set $MET_CAIROINC to point to the directory with the Cairo include files and set $MET_CAIROLIB to point to the directory with the Cairo library files. Also, set $MET_FREETYPE to point to the main FreeType directory, or set $MET_FREETYPEINC to point to the directory with the FreeType include files and set $MET_FREETYPELIB to point to the directory with the FreeType library files. If ft2build.h and freetype.h are not in $MET_FREETYPE/include directory, please set $MET_FREETYPEINC and $MET_FREETYPELIB (In case of FreeType 2.6 and 2.7, the header files are at $MET_FREETYPE/include/freetype2 directory).
- When running MODE-Graphics, set $MET_FONT_DIR to the directory containing font data required at runtime. Download and unpack the tarball and set $MET_FONT_DIR to the full path of the fonts directory.
- If compiling support for Python embedding, set $MET_PYTHON_CC and $MET_PYTHON_LD to specify the compiler (-I) and the linker (-L) flags required for Python. Set $MET_PYTHON_CC to the directory containing the "Python.h" header file. Set $MET_PYTHON_LD to the directory containing the Python library file and indicate the name of that file. For example:
Configuration
Configure the installation for your system using the configure script. The configure script has command line options to specify where to install MET and which MET utilities to install. Include any of the following options that apply to your system:
The remainder of this tutorial assumes that you have installed MET in the top-level met-8.0 directory. To configure MET to install all of the available tools in the bin subdirectory of your current directory, use the following command:
- MET_PYTHON_CC= '-I/usr/include/python2.7'
- MET_PYTHON_LD='-L/usr/lib/python2.7/config-x86_64-linux-gnu -lpython2.7'
- These values can often be found by running "python-config --cflags" to get the value for MET_PYTHON_CC and by running "python-config --ldflags" to get the value for MET_PYTHON_LD.
- --prefix=PREFIX By default, MET will install all the executables in /usr/local/bin. You can specify an installation prefix other than /usr/local using --prefix. For example, --prefix=$HOME to install to your home directory or --prefix=`pwd` to install to the current directory.
- --enable-grib2 Enable compilation of utilities using GRIB2.
- --enable-lidar2nc Enable compilation of utilities using lidar2nc.
- --enable-modis Enable compilation of modis_regrid.
- --enable-mode_graphics Enable compilation of mode_graphics.
- --enable-python Enable Python embedding.
- --disable-ascii2nc Disable compilation of ascii2nc.
- --disable-ensemble_stat Disable compilation of ensemble_stat.
- --disable-gen_poly_mask Disable compilation of gen_poly_mask.
- --disable-gen_circle_mask Disable compilation of gen_circle_mask.
- --disable-grid_stat Disable compilation of grid_stat.
- --disable-madis2nc Disable compilation of madis2nc.
- --disable-mode Disable compilation of mode.
- --disable-mode_analysis Disable compilation of mode_analysis.
- --disable-pb2nc Disable compilation of pb2nc.
- --disable-pcp_combine Disable compilation of pcp_combine.
- --disable-plot_data_plane Disable compilation of plot_data_plane.
- --disable-plot_point_obs Disable compilation of plot_point_obs.
- --disable-point_stat Disable compilation of point_stat.
- --disable-stat_analysis Disable compilation of stat_analysis.
- --disable-wavelet_stat Disable compilation of wavelet_stat.
- --disable-series_analysis Disable compilation of series_analysis.
- --disable-wwmca Disable compilation of wwmca_plot and wwmca_regrid.
- --disable-tc_utils Disable compilation of the tropical cyclone tools: tc_dland, tc_pairs, and tc_stat.
- --disable-block4 Disable use of BLOCK4 in the compilation. Use this if you have trouble using PrepBufr files.
Compile MET
Compile MET cindyhg Wed, 04/24/2019 - 12:04Make MET
After running the configure command, do the following to build MET:
tail -f make_install.log
To exit the tail command, type CNTL-C.
The GNU make is required to build MET.
Examine the contents of the make_install.log file to verify the build was successful and there were no errors.
Built Executables
The bin subdirectory of the installation directory should now contain up to 31 MET executables:
- ascii2nc
- ensemble_stat
- gen_vx_mask
- gis_dump_dbf
- gis_dump_shp
- gis_dump_shx
- grid_stat
- gsid2mpr
- gsidens2orank
- madis2nc
- lidar2nc
- mode
- mode_analysis
- modis_regrid
- mtd
- pb2nc
- pcp_combine
- plot_data_plane
- plot_mode_field
- plot_point_obs
- point_stat
- regrid_data_plane
- series_analysis
- shift_data_plane
- stat_analysis
- tc_dland
- tc_pairs
- tc_stat
- wavelet_stat
- wwmca_plot
- wwmca_regrid
Now add the full path to the installation bin directory to your PATH environment variable. For example, if you installed MET at /usr/local/met, add /usr/local/met/bin to your PATH.
Dynamic Libraries
Some of the applications use dynamic libraries to run. You may receive the following type of undefined reference errors from the MET tools at runtime:
- error while loading shared libraries: libnetcdf_c++.so.4: cannot open shared object file: No such file or directory
If you receive this type of error you will need to update the LD_LIBRARY_PATH environment variable to point to the locations of these libraries so the applications know where to find them
Known Issues and MET_Help
If you encounter problems building METv8.0, please:
- Refer to the MET User Support page.
- Refer to the METv8.0 known issues page.
- Send email to met_help@ucar.edu.
Test Scripts
Test Scripts cindyhg Wed, 04/24/2019 - 12:07Running Test Scripts
Once the MET package has been built successfully, users are strongly encouraged to run the make test command:
tail -f make_test.log
To exit the tail command, type CNTL-C.
Most of the steps in the test scripts will only take a couple of minutes each to run. However, the PB2NC step will likely take several minutes.
Checking for Errors
Examine the contents of the make_test.log file. Some users may experience a runtime error for pb2nc due to a compiler dependent compilation setting. Check the make_test.log file for the following error:
**************BUFR ARCHIVE LIBRARY ABORT*****************
BUFRLIB: OPENBF - FIRST 4 BYTES READ FROM RECORD IN INPUT FILE
FILE CONNECTED TO UNIT 11 NOT 'BUFR', DOES NOT CONTAIN DATA
**************BUFR ARCHIVE LIBRARY ABORT*****************
If you see there was an error, run make clean, then rerun your configure command adding --disable-block4 to your configure command line and rebuild MET, checking again to make sure the runtime error no longer occurs.
Test Script Output
In the make_test.log file, look for the following message which indicates that the test script completed:
*** Finished Testing the Model Evaluation Tools Project ***
The output from this test script is written to the out subdirectory (e.g. met-8.0/out), organized by the names of the MET tools. List the output directories with the following command:
Congratulations!
You have now successfully compiled and run MET!