Compiling Kynema-SGF

Kynema-SGF is primarily written in C++ and requires a modern C++ compiler (that supports C++14 standard) to build. This section describes the dependencies of Kynema-SGF as well as the general procedure to compile and execute Kynema-SGF on your system. The main dependencies are listed below:

  1. Operating system – Kynema-SGF has been tested on Linux and MacOS operating systems.

  2. C++ compiler – Kynema-SGF requires a C++ compiler that supports the C++14 standard. The code has been tested on GCC v5.x and higher, LLVM Clang v7.x, and Intel 2019 compiler suites.

  3. MPI – OpenMPI, MPICH, or Intel-MPI.

  4. CMake – Configure and build the code

  5. Python A recent version of python

Optional dependencies

  1. NVIDIA CUDA version 10 or higher required to run on GPUs.

  2. Intel OneAPI for building with SyCL.

  3. AMD GPU for building with ROCM.

Building from source

  1. If you are on an HPC system that provides Modules Environment, load the necessary compiler, MPI, and CMake modules. If targeting GPUs, load CUDA modules.

  2. Clone a local copy of the git repository

    git clone --recursive https://github.com/kynema/kynema-sgf.git
    
  3. Configure and build

    mkdir kynema-sgf/build && cd kynema-sgf/build
    cmake -DKYNEMA_SGF_ENABLE_TESTS:BOOL=ON ../
    make
    

    Upon successful build, you will end up with an executable kynema_sgf in your build directory.

  4. (Optional) Test your build

    ctest --output-on-failure
    

CMake configuration reference

Architecture options

KYNEMA_SGF_ENABLE_MPI

Enable MPI support for parallel executions. Default: OFF

KYNEMA_SGF_ENABLE_OPENMP

Enable OpenMP threading support for CPU builds. It is not recommended to combine this with GPU builds. Default: OFF

KYNEMA_SGF_ENABLE_CUDA

Enable NVIDIA CUDA GPU builds. Default: OFF

KYNEMA_SGF_ENABLE_SYCL

Enable Intel OneAPI SyCL builds. Default: OFF

KYNEMA_SGF_ENABLE_ROCM

Enable AMD ROCM GPU builds. Default: OFF

Dependencies

KYNEMA_SGF_ENABLE_MASA

Enable MASA library. Default: OFF

KYNEMA_SGF_ENABLE_NETCDF

Enable NetCDF outputs. Default: OFF

KYNEMA_SGF_ENABLE_OPENFAST

Enable OpenFAST coupling. Default: OFF

KYNEMA_SGF_OPENFAST_VERSION

OpenFAST version. Default: 3

Other Kynema-SGF specific options

KYNEMA_SGF_ENABLE_DOCUMENTATION

Enable documentation. Default: OFF

KYNEMA_SGF_ENABLE_TESTS

Enable CTest testing. Default: OFF

KYNEMA_SGF_TEST_WITH_FCOMPARE

Enable checking test results against gold files using fcompare. Default: OFF

KYNEMA_SGF_REFERENCE_GOLDS_DIRECTORY

Directory for reference gold files when using fcompare. Default: “”

KYNEMA_SGF_SAVE_GOLDS

Enable saving of the gold files. Default: OFF

KYNEMA_SGF_SAVED_GOLDS_DIRECTORY

Directory for saving gold files when using fcompare. Default: “”

KYNEMA_SGF_TEST_WITH_PYTHON

Enable performing tests that rely on python, primarily consists of checks for post-processing scripts in tools directory. Default: OFF

General CMake options

CMAKE_INSTALL_PREFIX

The directory where the compiled executables and libraries as well as headers are installed. For example, passing -DCMAKE_INSTALL_PREFIX=${HOME}/software will install the executables in ${HOME}/software/bin when the user executes the make install command.

CMAKE_BUILD_TYPE

Controls the optimization levels for compilation. This variable can take the following values:

Value

Typical flags

RELEASE

-O2 -DNDEBUG

DEBUG

-g

RelWithDebInfo

-O2 -g

Example: -DCMAKE_BUILD_TYPE:STRING=RELEASE

CMAKE_CXX_COMPILER

Set the C++ compiler used for compiling the code.

For Intel SyCL builds (see KYNEMA_SGF_ENABLE_SYCL) this should be set to icpx.

CMAKE_C_COMPILER

Set the C compiler used for compiling the code

CMAKE_Fortran_COMPILER

Set the Fortran compiler used for compiling the code

CMAKE_CXX_FLAGS

Additional flags to be passed to the C++ compiler during compilation.

CMAKE_C_FLAGS

Additional flags to be passed to the C compiler during compilation.

CMAKE_Fortran_FLAGS

Additional flags to be passed to the Fortran compiler during compilation.