...
Code Block |
---|
gunzip grib_api_1.14.0.tar.gz tar xf grib_api-1.14.0.tar |
Configuring compilation using
...
autotools
Grib_api uses the CMake command for configuration and compilation. CMake is available for modern Linux systems but may have to be installed.
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.
compilation can be made using the GNU configure tool. This will be familiar to many who have previously installed software.
The configure command is probably the easiest method though note it is deprecated in favour of using cmake (see below).
The configure command is contained in the grib_api directory. A few options are needed to suit OpenIFS and gcc & gfortran compilers are assumed in the example below. If you use different compilers, see below.
Code Block | ||||
---|---|---|---|---|
| ||||
cd grib_api_ | ||||
Code Block | ||||
| ||||
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 |
Explanation of lines:
| 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_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=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=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. |
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. |
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 command is contained in the grib_api directory. A few options are needed to suit OpenIFS and gcc & gfortran compilers are assumed in the example below. If you use different compilers, see below.
Code Block | ||
---|---|---|
| ||
cd grib_api_1.14.0-Source
./configure --prefix=$HOME/ecmwf/grib_api --enable-pthread --enable-python --disable-jpeg |
A description of what these options are for:
--prefix | This specifies where you want the grib_api files to be installed. In example here, the source code is in $HOME/ecmwf/grib_api_1.14.0-Source and the compiled grib_api libraries will go in directory $HOME/ecmwf/grib_api . 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. |
Other options
--help
option to configure can be used to see what other options are possible, also see the grib_api website for more detailed documentation.
--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.
--disable-numpy
option should be used if python is enabled but configure can't find the NumPy package.
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.
...
./configure --prefix=$HOME/ecmwf/grib_api --enable-pthread --enable-python --disable-jpeg |
A description of what these options are for:
--prefix | This specifies where you want the grib_api files to be installed. In example here, the source code is in $HOME/ecmwf/grib_api_1.14.0-Source and the compiled grib_api libraries will go in directory $HOME/ecmwf/grib_api . 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. |
Other options
--help
option to configure can be used to see what other options are possible, also see the grib_api website for more detailed documentation.
--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.
--disable-numpy
option should be used if python is enabled but configure can't find the NumPy package.
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.
Configuring using CMake
Grib_api uses the CMake command for configuration and compilation. CMake is available for modern Linux systems but may have to be installed.
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 | ||||
---|---|---|---|---|
| ||||
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 |
Explanation of lines:
| 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_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=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=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. |
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. |
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
...