Code Monkey home page Code Monkey logo

forces's Introduction

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.

[TOC]

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

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/[email protected]")

# 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

forces's People

Contributors

gitporst avatar mishde2 avatar muellerseb avatar pallavhydro avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.