Versions Compared

Key

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

...

Alternately grib_api supports installation via a 'configure' script, though this option is deprecated. See instructions below and GRIB API Installation for more details.

CMake compilation must be done is a separate build directory to both the source and the install directory.

Code Block
languagebash
titleSteps to configure grib-api with CMake assuming gnu compilers
mkdir bld
mkdir grib-api
cd bld
export CC=gcc
export FC=gfortran
cmake ../grib_api-1.14.0-Source   \
      -DCMAKE_INSTALL_PREFIX="../grib-api"   \
      -DENABLE_NETCDF=ON              \
      -DENABLE_JPG=OFF                \
      -DENABLE_PNG=OFF                \
      -DENABLE_PYTHON=ON              \
      -DENABLE_FORTRAN=ON             \
      -DENABLE_GRIB_THREADS=ON        \
      -DBUILD_SHARED_LIBS=OFF

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

export CC=gcc
export FC=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 by use of environment variables.
These lines can often be omitted.
CMAKE_BUILDINSTALL_TYPEPREFIX=Bit"Bit" here means 'bit-reproducible'. It instructs CMake to use conservative compiler options that are known to ensure bit-reproducibility in separate runs of OpenIFS."../grib_api"

This specifies the location where the 'make install' command will

CMAKE_INSTALL_PREFIX="../grib_api"

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

ENABLE_NETCDF=ONEnabling netcdf ensures the grib_to_netcdf command can be used.
ENABLE_JPG=OFF
ENABLE_PNG=OFF
As OpenIFS does 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.
ENABLE_PYTHON=ONSome of the utilities that come with OpenIFS make use of the python interface to grib_api, 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 grib_api and should always be on.
ENABLE_GRIB_THREADS=ONThis ensures grib_api is compiled to be 'thread-safe'. Although OpenIFS does not currently use multiple threaded calls to grib-api, future versions may do so this option is recommended.

Other build types

CMake supports several standard 'build types'. These are:

ReleaseRelease mode - the binary package does not include debug symbols and some of the source code is ignored; this mode is the default for users.
DebugDebug mode - the binary package includes debug symbols in the source code are not ignored; this mode is the default for developers and typically uses low or no optimisation.
RelWithDebInfoRelease mode, but the binary package includes debug symbols this mode is for developers and users and is often the default build type.

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.

Choice of compiler and options

it is not usually necessary to override the compiler options chosen by cmake or configure. 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. In the above example, we enforce the use of the GNU C and Fortran compilers. If you intend to use other compilers with OpenIFS you will need to set these appropriately.

Recommended options are conservative to ensure stability and bit-reproducibility. The cmake and configure commands usually choose a sensible set of optimized compiler flags for the choice of supported compiler for the 'Bit' build type.

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.

BUILD_SHARED_LIBS=OFFgrib_api can be built with both 'shared' and 'static' libraries for linking. Normally static libraries are sufficient.

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.

Choice of compiler and options

it is not usually necessary to override the compiler options chosen by cmake or configure. 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. In the above example, we enforce the use of the GNU C and Fortran compilers. If you intend to use other compilers with OpenIFS you will need to set these appropriately.

Recommended options are conservative to ensure stability and bit-reproducibility. The cmake and configure commands usually choose a sensible set of optimized compiler flags for the choice of supported compiler for the 'Bit' build type.

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.

Section
Column
Panel
borderColorwhite
bgColorwhite
titleBGColorwhite
borderStyledotted
titleIf using 'cmake' command
Code Block
titlegcc/gfortran compilers
export CC=gcc
export FC=gfortran
cmake .... -DCMAKE_C_FLAGS="-g -O2" -DCMAKE_Fortran_FLAGS="-g -O2"
Code Block
titleIntel compiler:
export CC=icc
export FC=ifort
cmake 
Section
Column
Panel
borderColorwhite
bgColorwhite
titleBGColorwhite
borderStyledotted
titleIf using 'cmake' command
Code Block
titlegcc/gfortran compilers
export CC=gcc
export FC=gfortran
cmake .... -DCMAKE_C_FLAGS="-g -O1 -fp-O2"model precise"   \
          -DCMAKE_Fortran_FLAGS="-g -O2"O1 -fp-model precise"
Code Block
languagebash
titleIntel Cray compiler :(cce)
export CC=icccc
export FC=ifortftn
cmake ... -DCMAKE_C_FLAGS="-gO1 -O1G2 -fp-model precise" hflex_mp=conservative -hadd_paren -hfp1"  \
          -DCMAKE_Fortran_FLAGS="-gO1 -O1G2 -fp-model precisehflex_mp=conservative -hadd_paren -hfp1"
bash
Code Block
language
titleCray IBM compiler (cce):
export CC=ccxlc_r
export FC=ftnxlf90_r
cmake ... -DCMAKE_C_FLAGS="-O1g -G2O2 -hflex_mp=conservativeqstrict -hadd_parenqarch=auto -hfp1qtune=auto"  \
          -DCMAKE_Fortran_FLAGS="-O1g -G2O2 -hflex_mp=conservativeqstrict -hadd_parenqarch=auto -hfp1qtune=auto"
Column
codetitle
Panel
borderColorwhite
bgColorwhite
titleBGColorwhite
borderStyledotted
titleIf using 'configure' command
Code Block
titlegcc/gfortran compilers
export CC=gcc
IBM compiler:
export CC=xlc_r
export FC=xlf90_rgfortran
cmake ... -DCMAKE_C_FLAGSexport CCFLAGS="-g -O2"
export FCFLAGS="-qstrict -qarch=auto -qtune=auto"  \
          -DCMAKE_Fortran_FLAGSg -O2"
./configure ...
Code Block
titleIntel compiler:
export CC=icc
export FC=ifort
export CFLAGS="-g -O1 -fp-model precise"
export FCFLAGS="-g -O2O1 -qstrict -qarch=auto -qtune=auto"
Column
fp-model precise"
./configure ...
Code Block
languagebash
titleCray compiler (cce)
Panel
borderColorwhite
bgColorwhite
titleBGColorwhite
borderStyledotted
titleIf using 'configure' command
Code Block
titlegcc/gfortran compilers
export CC=gcccc
export FC=gfortranftn
export CCFLAGSCFLAGS="-gO1 -O2G2 -hflex_mp=conservative -hadd_paren -hfp1"
export FCFLAGS="-gO1 -G2 -hflex_mp=conservative -hadd_paren -O2hfp1"
./configure ...
Code Block
titleIntel IBM compiler:
export CC=iccxlc_r
export FC=ifortxlf90_r
export CFLAGS="-g -O1O2 -fp-model preciseqstrict -qarch=auto -qtune=auto"
export FCFLAGS="-g -O1O2 -fp-model preciseqstrict -qarch=auto -qtune=auto"
./configure ...
Code Block
languagebash
titleCray compiler (cce)
export CC=cc
export FC=ftn
export CFLAGS="-O1 -G2 -hflex_mp=conservative -hadd_paren -hfp1"
export FCFLAGS="-O1 -G2 -hflex_mp=conservative -hadd_paren -hfp1"
./configure ...
Code Block
titleIBM compiler:
export CC=xlc_r
export FC=xlf90_r
export CFLAGS="-g -O2 -qstrict -qarch=auto -qtune=auto"
export FCFLAGS="-g -O2 -qstrict -qarch=auto -qtune=auto"
./configure ...
Info
titleFor help contact...

 OpenIFS support: openifs-support@ecmwf.int.

 

Possible problems

Info
titleFor help contact...

 OpenIFS support: openifs-support@ecmwf.int.

Note
titleCray

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 "--disable-shared" (configure) or "-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

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

Note
titleCray compiler

Possible issues with the Cray compiler are related to building shared libraries. If problems occur try using the option "--disable-shared" to only build statically linked libraries. It may be necessary to set the environment variable CRAYPE_LINK_TYPE=dynamic. For assistance, please contact OpenIFS support.

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

...