Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Section


Column

Introduction

The ECMWF grib_api ecCodes software library provides a set of functions/subroutines and command line tools for encoding and decoding WMO FM-92 GRIB edition 1 and edition 2 messages. The OpenIFS models use GRIB for its their input and output files.

The grib_api ecCodes software library must be built and installed before compiling any OpenIFS model that needs it.

To download and install please visit the ecCodes website.

If you have a version of ecCodes or the older (no longer supported) ECMWF grib_api library on your system already that would most likely work, though check the minimum grib-api version required for each model.  It is recommended that you build and install grib-api ecCodes as described below to ensure the correct configuration is used. Also, we We also recommend compiling your own to ensure the same compiler and compiler version is used for the model, as otherwise, error messages about conflicting module versions when compiling can arise.For more information about

Info

The older ECMWF grib_api

, to download and install it please visit the grib_api website

library can be used with OpenIFS, but as it's no longer developed by ECMWF, ecCodes is recommended. Versions of OpenIFS before 40r1v2 may need a small code change to work with ecCodes.

Before you start

Decide where you will put the grib_api packageecCodes software.

For a single user, grib_api ecCodes might be installed in your home directory. For a multi-user environment, say a cluster or High Performance Computing Facility (HPCF), installing the grib_api package ecCodes centrally once only is probably best and pointing point your build configuration to this location.

In the walk-through example that followsbelow, a single-user download and install is assumed.

Info

OpenIFS does not need the 'jasper' library in grib-apiecCodes. To avoid linking against the jasper library it can be disabled (see below).



Column
width50px

 


Column
width280px


Panel
bgColorwhite
titleBGColorlightlightgrey
titleOn this page

Table of Contents
maxLevel2
printablefalse



...

Create a directory called $HOME/ecmwf in which grib-api ecCodes will be downloaded and compiled.

If you haven't already obtained the grib_api package, ecCodes, get it from the grib-api web site ecCodes Releases page.. We recommend downloading the latest version. Some of the instructions for options below may differ with the very latest versions.

Unpacking

...

ecCodes

To unpack the software:

Code Block
languagebash
titleCreate directory and unpack source
mkdir -p ecmwf/src
cd ecmwf/src
tar zxf grib_apieccodes-12.149.0-Source.tar.gz

or if your version of tar doesn't support the 'z' option, do:

Code Block
gunzip grib_api_1.14.0.tar.gz
tar xf grib_api-1.14.0.tar

Configuring using CMake

Configure ecCodes for OpenIFS using CMake

ecCodes uses the CMake command Grib_api uses the CMake command for configuration and compilation. CMake is available for usually installed by default on modern Linux systems but may have to be installed .

Alternately grib_api supports installation via a 'configure' script, though this option is deprecated.

if not.

CMake compilation CMake compilation must be done in a separate build directory to both the source and the install directory. More information on configuring and building ecCodes is available on the ecCodes page.

Code Block
languagebash
titleSteps to configure grib-api with CMake assuming gnu compilers
mkdir bld
mkdir grib-apieccodes
cd bld
cmake ../grib_apieccodes-12.149.0-Source   \
      -DCMAKE_C_COMPILER=gcc      \
      -DCMAKE_Fortran_COMPILER=gfortran \
      -DCMAKE_INSTALL_PREFIX="../grib-apieccodes"   \
      -DENABLE_NETCDF=ON              \
      -DENABLE_JPG=OFF                \
      -DENABLE_PNG=OFF                \
      -DENABLE_PYTHON=ON              \
      -DENABLE_FORTRAN=ON             \
      -DENABLEDBUILD_GRIBSHARED_OMP_THREADS=ON    \
      -DBUILD_SHARED_LIBS=OFFLIBS=BOTH

Explanation Explanation of lines. Note that all options are prefixed by '-D':

CMAKE_C_COMPILER=gcc
CMAKE_Fortran_COMPILER=gfortran

These lines set the choice of compiler. CMake is often able to determine the available compilers for itself.
However, in cases where multiple compilers are available, or where compiler wrappers are used (as on HPC systems), it's preferable to set these explicitly.

These lines can often be omitted.

Note the CMake variables are preferred rather than set environment variables CC and FC.

CMAKE_INSTALL_PREFIX="../grib_apieccodes"

This specifies the location where the 'make install' command will place the grib-api eccodes installation.

ENABLE_NETCDF=ONEnabling netcdf this option ensures the grib_to_netcdf command can be used. Note: a netCDF library must be available on the system.
ENABLE_JPG=OFF
ENABLE_PNG=OFF

As OpenIFS models do not deal with any image based GRIB data these options can be disabled, unless you have other

grib

GRIB data containing images that you need to work with.

Setting this removes the need for the Jasper or OpenJPG libraries.

ENABLE_PYTHON=ONSome of the ENABLE_PYTHON=ONSome of the utilities that come with the OpenIFS model make use of the python interface to grib_api, ecCodes e.g. the tools to create and manipulate the model data.
For this option to work, ensure that a python installation is available. This option is not needed for the single column nor offline surface models currently.
ENABLE_FORTRAN=ONThis enables the Fortran interface to grib_api ecCodes and should always be on as OpenIFS uses this.
ENABLEBUILD_GRIBSHARED_OMP_THREADSLIBS=ONNot essential but recommended. This ensures grib_api supports OpenMP threads. Note this is not the same as the option ENABLE_GRIB_THREADS which is for Posix threading and not used by the OpenIFS model. Although OpenIFS models do not currently use multiple threaded calls to grib-api, future versions may do so this option is recommended.
BUILD_SHARED_LIBS=OFFgrib_api can be built with both 'shared' and 'static' libraries for linking. Normally static libraries are sufficient. Note that some IBM users may experience problems if shared libraries are built.

Available options

To get additional help on the available options (similar to the 'configure --help' command) run the command:

Code Block
cmake -LH grib_api-1.14.0-Source
Info

This command will cause cmake to run its system discovery if this is the first time the command has been used. On some systems, this may take time to complete.

Configuring using autotools

Grib_api compilation can be made using the GNU configure tool. This will be familiar to many who have previously installed software.

The configure command is probably the easiest method as it does not rely on having the CMake package installed, though note it is deprecated in favour of using cmake (see above).

The configure command is contained in the grib_api directory. A few options are needed to suit the OpenIFS models and gcc & gfortran compilers are assumed in the example below. If you use different compilers, see below.

Code Block
titlegcc/gfortran compilers
cd grib_api_1.14.0-Source
CC=gcc FC=gfortran ./configure --prefix=$HOME/ecmwf/grib_api --enable-pthread --enable-python --disable-jpeg

A description of what these options are for:

...

Available options

--help option to configure can be used to see what other options are possible, also see the grib_api website for more detailed documentation.

...

BOTHThe ecCodes library can be built with both 'shared' and 'static' libraries for linking, by default only shared libraries are built. Note some IBM users may experience problems if shared libraries are built.

Available options

To get additional help on the available options run the command:

Code Block
cmake -LH eccodes-2.9.0-Source


Info

This command will cause cmake to run its system discovery if this is the first time the command has been used. This may take time to complete.

Configuring using autotools

...


Shared and static libraries

...