Versions Compared

Key

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

...

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

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

For versions of grib_api before 1.9.18 you will also need to download and install the oifs_samples.tar.gz file in the src/grib_api directory on the ftp server, because some of the GRIB templates that OpenIFS requires are not present in the 1.9.16 (or previous) distribution. Please see the README file in the grib_api directory for more information.

Unpacking grib_api

To unpack the software:

...

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

In order to make the build configuration generic and make it easier to swap to later versions of grib_api, we recommend creating a link to the version of grib_api:

Code Block
ln -s grib_api-1.9.18 grib_api

so all future references to this directory will refer to 'oifs/grib_api'.

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: Software.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
CC=gcc FC=gfortran  \
CCFLAGS="-g -O2 -m64 -march=native" FCFLAGS="-g -O2 -m64 -march=native"  \
 ./configure --prefix=$(pwd)/myinstall../grib_api_gcc --enable-pthread --disable-jpeg --disable-omp-packing --disable-vector

...

A quick description of what these options are for:

--prefix=$(pwd)/myinstall../grib_api_gccThis 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 oifs$HOME/ecmwf/grib_api/myinstall. If you are on _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 you specify 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).
--disable-omp-packingOpenMP enabled packing is removed as the model needs to have control over OpenMP multithreading. This is usually disabled by default but it's best to enforce it in case the default changes for future releases.
--disable-vectorLikewise, on vector computer hardware (e.g. NEC), you can enable this option and grib_api will use a more efficient packing/unpacking method suitable for vector machines.
--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.
Info
titleOther 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.

Info
title--disable-sharedShared and static libraries

grib_api will build both shared and static libraries by defaultOmitting --disable-shared means that the gnu linker will use the shared library by default. The user must then ensure that their LD_LIBRARY_PATH is correct and points to the grib_api directory. Shared libraries need to be built if the python interface is used.

Otherwise, explicitly specify libgrib_api.a on the compile line to force static linking. Could also use -Bstatic -Bdynamic but this depends on the underlying linker, which may not be compatible.

...

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

...

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
titleIntel compiler:

...

code
CC=icc FC=ifort  \
CFLAGS="-O-g -O2 -m64 -fp-model precise" FCFLAGS="-g -O2 -fp-model precise"  \
./configure --prefix=$(pwd)/myinstall../grib_api_icc --enable-pthread --disable-jpeg --disable-omp-packing --disable-vector
Code Block
title

...

Portland compiler:
CC=pgcc FC=pgf90  \
CFLAGS="-g -O2 -m64" FCFLAGS="-g -O2 -m64"  \
./configure --prefix=../grib_api_pgcc --enable-pthread --disable-jpeg --disable-omp-packing --disable-vector
Code Block
titleIBM compiler:
CC=xlc_r FC=xlf90_r  \
CFLAGS="-O-g -O2 -qstrict -qarch=auto -qtune=auto" FCFLAGS="-g -O3O2 -qstrict -qarch=auto -qtune=auto" \
./configure --prefix=$(pwd)/myinstall../grib_api_xlc --enable-pthread --disable-jpeg --disable-omp-packing --disable-vector

...

Compiling, checks and installing

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

...

Info
titleParallel make

If your computer has multiple cores as many do these days, you can exploit this by using 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.

...

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

Code Block
% ls myinstallgrib_api_gcc
bin  include  lib  share
% ls myinstallgrib_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, proceed to downloading the OpenIFS model itselfnext steps are to download and install FCM and then download the OpenIFS code and accompanying files.

 

Panel

Table of Contents
maxLevel2
typeflat
separatorpipe