Skip to content

Tips and tricks

jornbr edited this page Nov 12, 2020 · 26 revisions

Speed up compilation by including only a subset of biogeochemical models

By default FABM includes biogeochemical models from all "institute directories" under src/models. You can restrict this to a subset of directories by providing -DFABM_INSTITUTES=<INSTITUTES> as argument to cmake. Here, <INSTITUTES> is a semi-colon separated list of institute names.

Efficient debugging by compiling in "debug mode"

While you are developing new biogeochemical models or couplers that link FABM with a new host, it is highly recommended to compile FABM in debug mode. This is done by providing -DCMAKE_BUILD_TYPE=debug as argument to cmake. In debug mode, FABM performs many more runtime checks. For instance, it verifies whether biogeochemical models actually provide values for the diagnostics they have registered, and it checks the extent of arrays provided by the host model. This comes at the expense of computational performance and is therefore not recommended for production runs. It is very useful for debugging though.

Setting compiler flags

By default, cmake will choose determine the flags that will be provided to the Fortran compiler. These flags are based on the value of the FFLAGS environment variable, the detected Fortran compiler and the selected build configurations (debug, release, etc). They are internally stored as one general set (CMAKE_Fortran_FLAGS) and one set of additional flags per build configuration (e.g., CMAKE_Fortran_FLAGS_RELEASE, CMAKE_Fortran_FLAGS_DEBUG). When you compile, the general and configuration-specific flags are combined. You can control the flags in several different ways:

  • You can run cmake withg default settings first, and then in the build directory run ccmake .. This allows you to see and edit all active cmake options, including the compiler flags (after you press T to make advanced options visible).
  • You can provide -DCMAKE_Fortran_FLAGS=<FLAGS> to cmake to override the general set of compiler flags. This can also be achieved by setting the FFLAGS environment variable before the first call to cmake.
  • You can provide flags per build configuration by providing -DCMAKE_Fortran_FLAGS_DEBUG=<FLAGS> or -DCMAKE_Fortran_FLAGS_RELEASE=<FLAGS> to cmake. Remember that these will be added to the general set.