![]() |
FORCES
FORtran lib for Comp. Env. Sys.
|
This is the FORTRAN library for Computational Environmental Systems of the
Department Computational Hydrosystems
Helmholtz Centre for Environmental Research - UFZ
Permoserstr. 15
04318 Leipzig, Germany
It is a lightweight fork of the jams_fortran library maintained by Matthias Cuntz et al: https://github.com/mcuntz/jams_fortran
The jams_fortran library was formerly developed at the CHS department at the UFZ and is now released under the MIT license.
Let's assume, you want to write a fortran program using forces, like this example test.f90:
You should create a minimal CMakeLists.txt file next to the test.f90 file like this:
There, CPM (the cmake package manager) is downloaded on the fly and used to get FORCES to be able to link against it.
Afterwards you only need to do the following to configure, compile and execute your program:
And it will happily write:
If you have the FORCES sources downloaded and you want to link a local executable against it, you can specify a path to CMake with FORCES_EXE:
You can use this with the examples provided in the examples/ directory, e.g. FORCES_EXE=examples/01_grids/01_regridding.f90. The executable will be always called main.
FORCES uses standard CMake inputs such as CMAKE_BUILD_TYPE and a small set of project-specific cache options:
FORCES_BUILD_TESTING: build the FORCES pfUnit tests. Defaults to OFF.FORCES_WITH_COVERAGE: enable GNU coverage instrumentation for FORCES test builds.FORCES_WITH_OpenMP: enable OpenMP support.FORCES_OpenMP_LINK_PUBLIC: propagate OpenMP usage requirements to targets linking against FORCES. Requires FORCES_WITH_OpenMP=ON and defaults to OFF.FORCES_WITH_MPI: enable MPI support.FORCES_WITH_NETCDF: enable NetCDF support.FORCES_WITH_OPTIMIZATION: include optimization routines.FORCES_ENABLE_NATIVE: enable host-native tuning for Release and RelWithDebInfo builds.FORCES_ENABLE_HEAP_ARRAYS: place compiler-generated Fortran arrays on the heap with Intel Fortran or LLVM Flang. Defaults to OFF.FORCES_EXE: build a local executable linked against forces.Typical configure commands:
FORCES_WITH_COVERAGE is only meaningful for test builds and requires GNU Fortran.
It is recommended to have a clean installation at a custom location for a C compiler, a Fortran compiler and the NetCDF C library with consistent compilers.
We recommend to use a conda environment by using Miniconda to get all dependencies easily:
With this you could now proceed with the example given above.
FORCES uses pFUnit for its unit tests. When FORCES_BUILD_TESTING=ON, CMake will look for PFUNIT. If pFUnit is not available, configuration still succeeds, but no FORCES tests are added.
You need to provide pFUnit to run the tests. It is unfortunately not available on conda yet. To compile it by hand in the current conda environment, you can do the following:
Then you can compile and run the tests and/or calculate coverage in the same environment:
Run all configured tests with:
Run a single pFUnit suite with ctest -R, for example:
If you only want to configure a subset of the pFUnit files, use FORCES_TEST_GLOB:
This is useful when iterating on one module or when you want to avoid configuring optional suites such as NetCDF- or optimization-related tests.
The coverage target additionally requires lcov to be available on PATH.
For a more complex project, prepared for unit-tests, documentation and modules, have a look at the Fortran Template.
LGPLv3 (c) 2005-2026 CHS-Developers