Versions Compared

Key

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

...


Introduction

The ECMWF

...

...

package provides a set of functions/subroutines and command line tools for

...

working with WMO FM-92 GRIB edition 1 and edition 2 messages. The OpenIFS

...

models use GRIB for

...

their input and output files.

The

...

ecCodes software

...

package must be

...

built and installed before

...

compiling any OpenIFS model that needs it.

To download the software 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

...

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, then point your build configuration to this location.

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

Info
titleJPEG and PNG image data

OpenIFS does not need the 'JPEG' or 'PNG' facility in ecCodes as the model does not use any image based data. They can be disabled to remove the dependency on libjpeg and libpng (see below).


Info
titleecCodes and python

ecCodes can be build and linked against python2. However, users are recommended to turn this option off and use the Python3 interface to eccodes that can be installed from PyPI after eccodes is installed (see below).

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.

To unpack the software (2.21.0 is given as an example, please use the latest version number):

Code Block
languagebash
titleCreate directory and unpack source
% mkdir -p ecmwf
% cd ecmwf
% tar zxf eccodes-2.21.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.  Note that a cmake version 3.6 and above is required. Some older linux systems may have earlier versions.

CMake compilation is 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.

First create a new directory, "eccodes" in this example, go into it and then run the cmake command to install the build files into that directory. In this example we'll also install the compiled ecCodes into the same directory, but you can change it to by altering the -DCMAKE_INSTALL_PREFIX (e.g. /usr/local/eccodes).

Code Block
languagebash
titleSteps to configure ecCodes with CMake assuming gnu compilers
% mkdir eccodes
% cd eccodes
% cmake ../eccodes-2.21.0-Source   \
      -DCMAKE_C_COMPILER=gcc      \
      -DCMAKE_Fortran_COMPILER=gfortran \
      -DCMAKE_INSTALL_PREFIX="$HOME/ecmwf/eccodes"   \
      -DENABLE_NETCDF=ON              \
      -DENABLE_JPG=OFF                \
      -DENABLE_PNG=OFF                \
      -DENABLE_FORTRAN=ON             \
      -DBUILD_SHARED_LIBS=BOTH

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

CMAKE_C_COMPILER=gcc
CMAKE_Fortran_COMPILER=gfortran

This sets 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="$HOME/ecmwf/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

Setting these removes the need for the Jasper, OpenJPG or PNG system libraries, which can simplify ecCodes installation. The use of ecCodes in OpenIFS does not need these options, though other GRIB data encoded using JPEG and PNG will not be supported.

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. 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.


Info

Please note that the python interface to ecCodes can be installed from PyPi for python3. For users who need a python2 interface, please include the option 'ENABLE_PYTHON2=ON'.

For more information about using ecCodes with python3, please see: ecCodes installation.


Available options

To get additional help on the available options and build configuration run the command:

Code Block
% cmake -LH eccodes-2.21.0-Source

Change the version number to your installation.

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 and generate additional files.

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 cmake

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.

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"


Code Block
titleIBM compiler:
% cmake ... -DCMAKE_C_COMPILER=xlc_r -DCMAKE_Fortran_COMPILER=xlf90_r -DCMAKE_C_FLAGS="-g -O2 -qstrict -qarch=auto -qtune=auto"  \
          -DCMAKE_Fortran_FLAGS="-g -O2 -qstrict -qarch=auto -qtune=auto"



Compiling, checks and installing

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

Code Block
% make -j2 2>&1 | tee make.out

which will send all the standard and error output from the make command to the file 'make.out' as well as the terminal. This is recommended as the output is lengthy.

The -j2 option will use 2 threads (cores) for a faster compilation.

Info
titleSeeing command output with cmake

If using cmake, it will normally hide all the output from the compile commands. If you want to see the compile command (to check the compile options), do:

make VERBOSE=1


Info
titleParallel make

If your computer has multiple processors (cores), we recommend using more cores for faster compilation (specifying more cores than the computer has will slow the compilation down) e.g.

Code Block
% make -j4 2>&1 | tee make.out


Next, to verify ecCodes works correctly run (this will likely download some test data from the ECMWF test-data server):

Code Block
% ctest -j2 | tee ctest.out

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

Finally, to install ecCodes do (the installation directory is specified in the -DCMAKE_INSTALL_PREFIX option (see above):

Code Block
% make install | tee install.out

At the end of this step, in the directory $HOME/ecmwf/ that we use in this example, you should now have a directory called eccodes which contains the following:

Code Block
% ls eccodes
bin  include  lib  share
% ls eccodes/lib
libeccodes.a  libeccodes_f90.a  pkgconfig  python2.7

Verify the installation

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

Code Block
% export PATH=$PATH:$HOME/ecmwf/eccodes/bin
% codes_info

ecCodes Version 2.21.0

Default definition files path is used: /home/myname/ecmwf/eccodes/share/eccodes/definitions
Definition files path can be changed setting ECCODES_DEFINITION_PATH environment variable

Default SAMPLES path is used: /home/myname/ecmwf/eccodes/share/eccodes/samples
SAMPLES path can be changed setting ECCODES_SAMPLES_PATH environment variable

Your output may differ for different ecCodes versions. If the installation was successful, codes_info will report the installation directories.


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.

1.   If problems occur, first try using the option "-DBUILD_SHARED_LIBS=OFF" to only build statically linked libraries.

2.   If linking problems still occur, try unloading the Cray ATP module which has been known to cause problems.

Code Block
module unload atp

3.   -llibm link error.

If the following occurs:

Code Block
languagebash
/usr/bin/ld: attempted static link of dynamic object `/usr/lib64/libm.so'

set the environment variable CRAYPE_LINK_TYPE=dynamic (or add the compiler option '-dynamic').

4.   Missing python library.

Although it's recommended not to compile with python enabled, if you need this and If this error occurs when compiling _gribapi_swig.so:

Code Block
/usr/bin/ld: cannot find -lpython

it means the directory path of the python library is not on the linkers list of directories to search.

Make sure the python module is loaded. Then check any PYTHON environment variables set by the module and confirm the location of the libpython (or other version) library.

Set the environment variable LIBRARY_PATH to the correct directory so that the linker can find it:

Code Block
titlee.g.
export LIBRARY_PATH=/home/anaconda/2.2.0-python2/lib64

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.

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 'cmake; make; make check; make install' steps.

Note if you plan on using the eccodes software in your own software that runs on the frontend nodes you may need to compile and install eccodes twice; one for the batch system and again for the frontend system.

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




Excerpt Include
Credits
Credits
nopaneltrue



Panel
borderColorgrey

On this page ...

Table of Contents
indent12px


Panel
titleIn this section...

Children Display
depth1
page5. OpenIFS Installation


Panel
titleOpenIFS User Guide ...

Children Display
depth1
pageOpenIFS 43r3 User Guide

For more information about grib_api, please visit the grib_api website.

Column
width50px

 

Column
width280px

 

 

Panel
bgColorwhite
titleBGColorlightlightgrey
titleOn this page

Table of Contents
maxLevel2
stylesquare
printablefalse

Before you start

Decide where you will put the grib_api package.

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

In the walk-through example that follows, we assume a single-user download and install.

Download grib_api

In this example, assume you have created a directory called $HOME/ecmwf in which you will download and compile grib_api.

If you haven't already obtained the grib_api package, get it from the OpenIFS ftp site. The userid for ftp is 'openifs'. If you need the password, please email: openifs-support@ecmwf.int. Please note that currently we require a signed license before password access can be granted to the ftp site, though grib_api is freely available from the ECMWF website.

Code Block
% mkdir $HOME/ecmwf
% cd $HOME/ecmwf
ftp ftp.ecmwf.int
Connected to ftp-int.ecmwf.int.
Name (ftp.ecmwf.int:user): openifs
331 User openifs OK. Password required
Password:
ftp> cd src/grib_api
ftp> get grib_api-1.9.18.tar.gz
ftp> quit

Unpacking grib_api

To unpack the software:

Code Block
tar zxf grib_api-1.9.18.tar.gz

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

Code Block
gunzip grib_api_1.9.18.tar.gz
tar xf grib_api-1.9.18.tar

Configuring grib_api

If you are familiar with compiling and installing software on linux systems, you will be used to the following steps. Grib_api uses the GNU configure tool to ease building and compilation. It is tested on different platforms and compilers and should not cause any problems. If however, you do have a problem installing grib_api, please email: openifs-support@ecmwf.int.

The configure command is contained in the grib_api directory you have just unpacked. We will use the command with a few options to suit OpenIFS and assume we'll use the gcc & gfortran compilers. If you use different compilers, see below.

Code Block
titlegcc/gfortran compilers
cd grib_api_1.9.18
./configure --prefix=$HOME/ecmwf/grib_api_gcc --enable-pthread --disable-jpeg

Note the use of the backslash '\' to allow the command to use two lines.

A quick description of what these options are for:

--prefix        
This specifies where you want the grib_api files to be installed. In our example here, the source code is in $HOME/ecmwf/grib_api_1.9.18 and we will put the compiled grib_api libraries in our example directory $HOME/ecmwf/grib_api_gcc. You are free to choose any installation directory but it's recommended to keep the installed binaries & libraries in a separate directory to the source code in case different compiler versions are needed. On a shared high performance computer facility, the install path would most likely be somewhere central. If nothing is specified for --prefix, by default grib_api will install in /usr/local.
--disable-jpegOpenIFS does not need to support JPEG and PNG for data compression. This removes the need to link OpenIFS against the Jasper library (libjasper.a).
--enable-pthreadThis option ensures that grib_api is thread-safe. Again, this is normally the default but we enforce it here as OpenIFS will call grib_api from parallel threads.
Warning
title--disable bug in 1.9.18

There is a known bug with 1.9.18 grib_api that when some of the --disable-<feature> (e.g. --disable-vector) or --enable-<feature> options are used, it has the reverse effect and actually enables the option. In most cases the default option is the preferred one. The options used above are known to be safe to use. Any issues or questions can be sent to openifs-suppport@ecmwf.int.

Other options

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

The --enable-python option enables the python interface and is optional but might be useful if you intend to use/write software to access the GRIB output files. If the make fails because of a missing numpy header file you should add the --disable-numpy option.

The --enable-vector option should be used on vector based computers (e.g. NEC). Grib_api will then use a more efficient packing/unpacking method suitable for vector hardware. n.b. there is a bug in the 1.9.18 release that if the --disable-vector option is used, this has the reverse effect of enabling the vector code. See grib_api issue GRIB-269 for more details.

Shared and static libraries

grib_api will build both shared and static libraries by default. Shared libraries need to be built if the python interface is used.

Some compilers will link to the shared version by default if both are found (e.g. the GNU compiler). To ensure the correct version of grib_api is found (in case several are available on your system), OpenIFS explicitly lists the static library in the FCM configuration files. Alternately, if you prefer to use the shared library, you must ensure that your LD_LIBRARY_PATH variable is set so that 1.9.18 version compiled here is found first. 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.

 

Choice of compiler and options

By default, grib_api will use the first known compiler it finds (by searching your PATH environment variable). This may not be what you need if you have multiple compilers available. As in the above example, we enforce the use of the GNU C and Fortran compilers (as this is the default compiler for OpenIFS). If you intend to use other compilers with OpenIFS you will need to set these appropriately.

The configure script usually chooses a sensible set of optimized compiler flags for the choice of supported compiler. If you need to override the compiler flags you can do so as shown in the following example. Note also the use of '\' to extend the command over multiple lines.

Code Block
titlegcc/gfortran compilers
CC=gcc FC=gfortran CCFLAGS="-g -O2" FCFLAGS="-g -O2"  \
 ./configure --prefix=$HOME/ecmwf/grib_api_gcc --enable-pthread --disable-jpeg
Code Block
titleIntel compiler:
CC=icc FC=ifort CFLAGS="-g -O1 -fp-model precise" FCFLAGS="-g -O1 -fp-model precise"  \
./configure --prefix=$HOME/ecmwf/grib_api_icc --enable-pthread --disable-jpeg
Note

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.

Code Block
titlePortland compiler:
CC=pgcc FC=pgf90 CFLAGS="-g -O2" FCFLAGS="-g -O2"  \
./configure --prefix=$HOME/ecmwf/grib_api_pgcc --enable-pthread --disable-jpeg
Code Block
titleIBM compiler:
CC=xlc_r FC=xlf90_r  \
CFLAGS="-g -O2 -qstrict -qarch=auto -qtune=auto" FCFLAGS="-g -O2 -qstrict -qarch=auto -qtune=auto" \
./configure --prefix=$HOME/ecmwf/grib_api_xlc --enable-pthread --disable-jpeg --disable-shared
Note

For the IBM xlc compiler we recommend disabling the creation of 'shared libraries' which is known to cause problems with this version 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'. This is important as grib_api will be called by multiple threads with OpenIFS.

Compiling, checks and installing

The 'configure' command creates a 'Makefile' in the directory where it resides. To compile grib_api do:

Code Block
make | tee make.out

which will send all the output from the make command to the file 'make.out' as well as the terminal. This is recommended as the output is lengthy.

Info
titleParallel make

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

Code Block
make -j 3 | tee make.out

would allow make to compile 3 files at once - appropriate on a 4 core machine.

Next, to verify grib_api works correctly run:

Code Block
make check | tee check.out

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

Info
titleBuilding 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.

In some cases, the batch system cannot be used for compilation at all. In this case, you have to compile on the frontend but without extra flags 'configure' will assume the build is for the frontend. You can make use of the --host option to ensure the build is correct for the architecture of the batch system. Again though, the tests will fail, a small serial batch job is recommended to make sure grib_api is installed correctly.

Note if you plan on using the grib_api software in your own software that runs on the frontend nodes you will need to install grib_api twice; one for the batch system and again for the frontend system.

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

Finally, to install grib_api do:

Code Block
make install | tee install.out

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

Code Block
% ls grib_api_gcc
bin  include  lib  share
% ls grib_api_gcc/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.

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.

Code Block
% export PATH=$PATH:$HOME/ecmwf/grib_api_gcc/bin
% grib_info

grib_api Version 1.9.18
Default definition files path is used: ..../grib_api_gcc/share/definitions
Definition files path can be changed setting GRIB_DEFINITION_PATH environment variable
Default SAMPLES path is used: ..../grib_api_gcc/share/samples
SAMPLES path can be changed setting GRIB_SAMPLES_PATH environment variable

If the installation was successful, grib_info will report the installation directories. Any problems, please contact openifs-support@ecmwf.int.

 

HTML
<script type="text/javascript" src="https://software.ecmwf.int/issues/s/en_UKet2vtj/787/12/1.2.5/_/download/batch/com.atlassian.jira.collector.plugin.jira-issue-collector-plugin:issuecollector/com.atlassian.jira.collector.plugin.jira-issue-collector-plugin:issuecollector.js?collectorId=047f74ec"></script>

...

 

...