...
| Section | |||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
...
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 is probably best and pointing your build configuration to this location.
In the walk-through example that follows, we assume a single-user download and install is assumed.
Download and unpack
In this example, we assume you have created create a directory called $HOME/ecmwf in which you will download and compile grib_apigrib-api will be downloaded and compiled.
If you haven't already obtained the grib_api package, get it from the grib-api web site.
...
| Code Block | ||||
|---|---|---|---|---|
| ||||
mkdir bld
mkdir grib-api
cd bld
export CC=gcc
export FC=gfortran
cmake ../grib_api-1.14.0-Source \
-DCMAKE_BUILD_TYPE=Bit \
-DCMAKE_INSTALL_PREFIX="../grib-api" \
-DENABLE_NETCDF=ON \
-DENABLE_JPG=OFF \
-DENABLE_PNG=OFF \
-DENABLE_PYTHON=ON \
-DENABLE_FORTRAN=ON \
-DENABLE_GRIB_THREADS=ON |
...
| 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. |
CMAKECMAKE_BUILD_TYPE=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. |
CMAKE_INSTALL_PREFIX="../grib_api" | This specifies the location where the 'make install' command will place the grib-api installation. |
ENABLE_NETCDF=ON | Enabling netcdf ensures the grib_to_netcdf command can be used. |
ENABLE_JPG=OFFENABLE_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=ON | Some 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=ON | This enables the Fortran interface to grib_api and should always be on. |
ENABLE_GRIB_THREADS=ON | This 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. |
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 configure
Grib_api compilation can also be made using 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.
Other build types
CMake supports several standard 'build types'. These are:
| Release | Release mode - the binary package does not include debug symbols and some of the source code is ignored; this mode is the default for users. |
| Debug | Debug 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. |
| RelWithDebInfo | Release mode, but the binary package includes debug symbols this mode is for developers and users and is often the default build type. |
| Bit | Bit-reproducibility mode - This is non-standard and will not be found on other cmake enabled packages. It is used at ECMWF to set compiler options that have been tested to provide bit-reproducibility. |
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 configure
Grib_api compilation can also be made using the GNU configure tool.
The configure The configure command is contained in the grib_api directory you have just unpacked. We will use the command with a . A few options are needed to suit OpenIFS and assume we'll use the gcc & gfortran compilers are assumed in the example below. If you use different compilers, see below.
| Code Block | ||
|---|---|---|
| ||
cd grib_api_1.914.180-Source ./configure --prefix=$HOME/ecmwf/grib_api --enable-pthread --enable-python --disable-jpeg |
...
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.14.0-Source and we will put the compiled grib_api libraries will go 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-jpeg | OpenIFS 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-pthread | This option ensures that grib_api is thread-safe and is a recommended option. |
--enable-python | This enables the python interface and is required as some OpenIFS utilities make use of the grib-api python interface. If the make fails because of a missing numpy header file you should add the --disable-numpy option. |
...
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.
...
By default, cmake and configure will use the preferred compiler and set appropriate compiler options accordingly (for cmake, this depends on the build type).
(by searching your PATH environment variable). This may not be what you need if you have multiple compilers available . As in 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 (as this is the default compiler for OpenIFS). 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 chooses choose a sensible set of optimized compiler flags for the choice of supported compiler .for the 'Bit' build type.
Although it is not normally necessary to specify them, the The following examples show the recommended compiler options and how to set them for the cmake and configure commands.
| Section | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Code Block | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| title | Portland compiler:
| IBM
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Note | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Compiling, checks and installing
...
| Excerpt Include | ||||||
|---|---|---|---|---|---|---|
|