Versions Compared

Key

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

...

 

Section


Column

Introduction

The ECMWF 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 their input and output files.

The 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 ecCodes as described below to ensure the correct configuration is used. 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.

Info

The older ECMWF grib_api 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 ecCodes software.

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

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

Info

OpenIFS does not need the 'jasper' library in ecCodes. 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



Download and unpack

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

If you haven't already obtained ecCodes, get it from the ecCodes Releases page.. We recommend downloading the latest version.

Unpacking ecCodes

To unpack the software:

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

Configure ecCodes

...

using CMake

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

...

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.

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

CMAKE_INSTALL_PREFIX="../eccodes"

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

ENABLE_NETCDF=ONEnabling 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 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 utilities that come with the OpenIFS model make use of the python interface to ecCodes e.g. the tools to create and manipulate the model data.
For this option to work, ensure that a python installation is available.
ENABLE_FORTRAN=ONThis enables the Fortran interface to ecCodes and should always be on as OpenIFS uses this.
BUILD_SHARED_LIBS=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

Shared libraries may be needed for the python interface depending on your installation. Some compilers will link to the shared version by default if both shared and static are found (e.g. the GNU compiler). Disabling shared libraries from being generated is not recommended as it may prevents the ecCodes command line tools from working. Note some IBM users may experience problems if shared libraries are built.

Available options

To get additional help on the available options and build configuration run the commandTo 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

grib_api will build both shared and static libraries by default. Shared libraries may need to be built if the python interface is used, depending on your installation.

Some compilers will link to the shared version by default if both are found (e.g. the GNU compiler). Alternately, the option  --disable-shared stops the shared libraries from being generated, only the static libraries are built and will be linked. However, this may prevent other grib api tools working and is not generally recommended.

IBM users may find that the grib-api fortran tests will fail unless --disable-shared is used.

Preferred compiler options

By default, cmake and configure will use the preferred compiler and set appropriate compiler options accordingly (for cmake, this depends on the build type).

This may not be what you need if you have multiple compilers available and want to direct cmake/configure to the most appropriate one to use.

Recommended options given below are conservative to ensure stability and bit-reproducibility.

Changing compiler options is not normally necessary. However, the following examples show the recommended compiler options and how to set them for the cmake and configure commands.

 

...

bgColorlightlightgrey
borderStyledashed

Compiler options if using cmake

...

titleclick here to expand...

With cmake, it is better to use the cmake variables to define the compilers rather than rely on environment variables FC and CC.

Code Block
titlegcc/gfortran compilers
cmake .... -DCMAKE_C_COMPILER=gcc -DCMAKE_Fortran_COMPILER=gfortran -DCMAKE_C_FLAGS="-g -O2" -DCMAKE_Fortran_FLAGS="-g -O2"
Code Block
titleIntel compiler:
cmake ... -DCMAKE_C_COMPILER=icc -DCMAKE_Fortran_COMPILER=ifort -DCMAKE_C_FLAGS="-g -O1 -fp-model precise"   \
          -DCMAKE_Fortran_FLAGS="-g -O1 -fp-model precise"
Code Block
languagebash
titleCray compiler (cce)
cmake ... -DCMAKE_C_COMPILER=cc -DCMAKE_Fortran_COMPILER=ftn -DCMAKE_C_FLAGS="-O1 -G2 -hflex_mp=conservative -hadd_paren -hfp1"  \
          -DCMAKE_Fortran_FLAGS="-O1 -G2 -hflex_mp=conservative -hadd_paren -hfp1"

...

titleIBM compiler:

...

Preferred compiler options

By default, cmake will use the preferred compiler and set appropriate compiler options accordingly (for cmake, this depends on the build type).

This may not be what you need if you have multiple compilers available and want to direct cmake to the most appropriate one to use.

Recommended options given below are conservative to ensure stability and bit-reproducibility.

Changing compiler options is not normally necessary. However, the following examples show the recommended compiler options and how to set them for the cmake commands.

 

Panel
bgColorlightlightgrey
borderStyledashed

Compiler options if using configurecmake

click here to expand..
Expand
titleclick here to expand...

With cmake, it is better to use the cmake variables to define the compilers rather than rely on environment variables FC and CC

title

.

Code Block
titlegcc/gfortran compilers
export CCcmake .... -DCMAKE_C_COMPILER=gcc
export FC -DCMAKE_Fortran_COMPILER=gfortran
export CCFLAGS -DCMAKE_C_FLAGS="-g -O2"
export FCFLAGS -DCMAKE_Fortran_FLAGS="-g -O2"
./configure ...


Code Block
titleIntel compiler:
export CCcmake ... -DCMAKE_C_COMPILER=icc
export FC -DCMAKE_Fortran_COMPILER=ifort
export CFLAGS -DCMAKE_C_FLAGS="-g -O1 -fp-model precise"
export FCFLAGS   \
          -DCMAKE_Fortran_FLAGS="-g -O1 -fp-model precise"
./configure ...


Code Block
languagebash
titleCray compiler (cce)
export CCcmake ... -DCMAKE_C_COMPILER=cc
export FC -DCMAKE_Fortran_COMPILER=ftn
export CFLAGS -DCMAKE_C_FLAGS="-O1 -G2 -hflex_mp=conservative -hadd_paren -hfp1"
export FCFLAGS  \
          -DCMAKE_Fortran_FLAGS="-O1 -G2 -hflex_mp=conservative -hadd_paren -hfp1"
./configure ...


Code Block
titleIBM compiler:
export CCcmake ... -DCMAKE_C_COMPILER=xlc_r
export FC -DCMAKE_Fortran_COMPILER=xlf90_r
export CFLAGS -DCMAKE_C_FLAGS="-g -O2 -qstrict -qarch=auto -qtune=auto"
export FCFLAGS  \
          -DCMAKE_Fortran_FLAGS="-g -O2 -qstrict -qarch=auto -qtune=auto"
./configure ..



Compiling, checks and installing

After configuration the next steps are to compile grib-api ecCodes and install it. To compile grib_api ecCodes do:

Code Block
make | tee make.out

...

Info
titleParallel make

If your computer has multiple cores as many, use the -j flag to make to build grib_api ecCodes faster. e.g.

Code Block
make -j 32 | tee make.out


Next, to verify grib_api ecCodes works correctly run:

Code Block
make check | tee check.out

Verify that all the grib_api ecCodes tests have passed. If not, go back and check your configure configuration options. In case of difficulty, contact Software.Support@ecmwf.int.

Finally, to install grib_api ecCodes do:

Code Block
make install | tee install.out

At the end of this step, in the directory $HOME/ecmwf/ that we are using use in this example, you should now have a directory called grib_api eccodes (or some other compiler suffix) which contains the following:

Code Block
% ls grib_apieccodes
bin  include  lib  share
% ls grib_apieccodes/lib
libgrib_api.a  libgrib_api.la  libgrib_api_f77.a  libgrib_api_f77.la  libgrib_api_f90.a  libgrib_api_f90.la  pkgconfig

After this stage, next steps are to download and install FCM and then download the OpenIFS code and accompanying files.

Possible problems

Info
titleFor help contact...

 OpenIFS support: openifs-support@ecmwf.int.

Cray

Possible issues with the Cray systems (using cce or gnu compilers) are related to building shared libraries and linking with supporting netcdf and python libraries.

...

LIBRARY_PATH is only used at compile/link time. It may also be necessary to add this directory to the LD_LIBRARY_PATH environment variable which is searched for libraries at runtime.

Intel compiler

We currently recommend not using a higher optimization level than -O1 with the Intel compiler. Failures have been seen with grib_api and the Intel compiler when compiled with -O2.

Some versions of the Intel compiler (v14.0.x) can produce an error "unknown option -soname" when using 'configure. If this occurs try using "--disable-shared" or try the cmake command instead.

IBM compiler

For the IBM xlc compiler we recommend disabling the creation of 'shared libraries' which is known to cause problems with some versions of grib_api.

In this example, note the use of the '_r' form of the IBM compiler to ensure grib_api is compiled 'thread-safe'.

Building on High Performance Computer Systems

Some HPC batch systems have a different hardware architecture for their login (or frontend node) to the batch node, but the frontend compilation system is targeted at the batch nodes. This is known as cross-compilation. If this is the case you may see failures in the 'make check' stage because the checks, although compiled for the backend batch nodes, are being run on the frontend nodes and therefore may not work correctly. If this is the case on your system, we recommend using a batch job to do the 'configure; make; make check; make install' steps.

...

If you have any questions installing grib_api in this type of environment, please contact: openifs-support@ecmwf.int for assistance.

Verify the installation

To verify that the installation was successful, first ensure that the grib_api bin directory is added to your PATH environment variable and then run the grib_info command e.g.

...