0.6.2-dev0
FORCES
FORtran lib for Comp. Env. Sys.
Loading...
Searching...
No Matches
FORCES library

Forces-LOGO

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.

Using FORCES with your Fortran program

Let's assume, you want to write a fortran program using forces, like this example test.f90:

program test
use mo_message, only : message
implicit none
call message("This is working!")
end program test
Write out concatenated strings.
subroutine, public message(t01, t02, t03, t04, t05, t06, t07, t08, t09, t10, t11, t12, t13, t14, t15, t16, uni, advance, show, reset_format)
Write out an error message to stdout.

You should create a minimal CMakeLists.txt file next to the test.f90 file like this:

cmake_minimum_required(VERSION 3.14 FATAL_ERROR)
# get CPM (package manager)
set(CPM_DOWNLOAD_LOCATION "${CMAKE_BINARY_DIR}/cmake/CPM_0.35.0.cmake")
file(DOWNLOAD https://github.com/cpm-cmake/CPM.cmake/releases/download/v0.35.0/CPM.cmake ${CPM_DOWNLOAD_LOCATION})
include(${CPM_DOWNLOAD_LOCATION})
# create project
project(MyProject LANGUAGES Fortran)
# add executable
add_executable(test test.f90)
# add FORCES dependency
CPMAddPackage("https://git.ufz.de/chs/forces.git@0.3.1")
# link dependencies
target_link_libraries(test forces)

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:

cmake -B build
cmake --build build --parallel
./build/test

And it will happily write:

This is working!

For a more complex project, prepared for unit-tests, documentation and modules, have a look at the Fortran Template.

Dependencies and Requirements

It is recommended to have a clean installation at a custom location for a C compiler, a Fortran compiler, the NetCDF C library and the NetCDF Fortran library with consistent compilers.

We recommend to use a conda environment by using Miniconda to get all dependencies easily:

conda create -y --prefix ./forces_env
conda activate ./forces_env
conda config --add channels conda-forge
conda config --set channel_priority strict
conda install -y cmake make fortran-compiler netcdf-fortran fypp

With this you could now proceed with the example given above.

License

LGPLv3 (c) 2005-2024 CHS-Developers