This package contains a Fortran wrapper for some of the functionality of the glacier flow modeling library icepack. The purpose of this package is to enable coupling of icepack, which is written in Python, to ocean circulation models, which are typically written in Fortran. This is all possible thanks to the wonderful work of Elias Rabel on forpy.
This package consists of two parts.
The Python module at python/icepack_fortran.py
defines some simple helper functions for initializing a simulation from a set of input data, accessing the current state of the simulation, and running the diagnostic and prognostic solvers.
The Fortran module at fortran/src/icepack_fortran.F90
contains a set of subroutines that call these Python functions.
The routines defined in this Fortran module are what an ocean model would call to access the functionality in icepack.
This wrapper does not expose the complete functionality of icepack. Instead, it provides access to a limited set of routines under fairly stringent assumptions on what the input data are. The input files are:
- a mesh, generated by gmsh
- the numeric IDs of boundary segments of the mesh where Dirichlet and friction boundary conditions are to be applied
- the initial thickness, accumulation rate, melt rate, and velocity, stored in Arc ASCII grid format
These are all stored in a JSON file.
The path to this config file is passed to the simulation_init
routine in the Fortran wrapper which then passes it to the Python layer.
This package requires a working installation of icepack. See these instructions for how to install icepack and firedrake, the finite element modeling library that icepack is built on. To use the Fortran wrapper for icepack, you will need to have the firedrake virtual environment activated in your current terminal session first.
First, make sure to clone this repository with the --recursive
option to also fetch forpy:
git clone --recursive https://github.com/icepack/icepack-fortran.git
Both the thin Python layer and the Fortran wrapper are built at the same time using CMake:
cd icepack-fortran
mkdir build
cd build
cmake ..
make
To test that everything is working correctly, run
make test
from the build directory.
The following resources were helpful:
- forpy: a complete Fortran wrapper for the CPython API.
- CMake and distutils: How to build a Python project using CMake.
- Modern CMake: Minimize agony from the build system.