chengcli / canoe

Comprehensive Atmosphere N' Ocean Engine
14 stars 16 forks source link

Canoe: Comprehensive Atmosphere N' Ocean Engine

build build DocStatus License codecov

Install system libraries and toolchain

Canoe can be installed on either a Linux distribution or on MacOS. Open a Linux or Mac terminal, you can clone this repo using the following command:

git clone https://github.com/chengcli/canoe

This will copy all source files into your local computer. You will need to install a few system libraries before installing canoe. All following instructions are executed under the canoe/ directory, which is referred to as the root.

MacOS Installation Guide

We assume that homebrew is already installed on your Mac and we will use brew to install required system libraries. The system libraries are listed in Brewfile at the root. To install them all, execute

brew bundle

Ubuntu Linux Installation Guide

On a Ubuntu linux system, use apt to install

sudo apt install $(cat packages_debian.txt)

Redhat Linux Installation Guide

On a Redhat linux system, use yum to install

sudo yum -y install $(cat packages_centos.txt)

Multi-core execution

If multi-core parallelization is needed, these extra pacakges should be install

Ubuntu linux:

sudo apt install libmpich-dev

Redhat linux:

sudo yum install mpich-devel
source ~/.bash_profile

Redhat linux does not support pnetcdf natively. So it should be downloaded and install. The default installation directory is $HOME/opt/

cd external
./fetch_pnetcdf.sh
./install_pnetcdf.sh
cd ..

Notes on using openmpi

Some system, especially conda, uses openmpi by default. It is know that openmpi sometimes causes trouble in the simulation and mpich works better with canoe. If you have to use openmpi and the run fails immediately after execution, try to run with a single core first and then multi-core.

Install python libraries

The minimum python version is 3.8. All needed python libraries are collected in requirements.txt. We suggest using a python virtual environment to install these packages. If you are already using a virtual enviroment, install python packages by

pip3 install -r requirements.txt

Otherwise, to create a python virtual environment:

python -m venv pyenv

This command will create an environment named pyenv in your current directory. Then, you can use the previous command to install the python packages.

Install pre-commit

Register your pre-commit hooks using

pre-commit install

The contributor's guide explains the meaning of pre-commit.

Environment variables

These following environment variables are important for the system to find the appropriate MPI:

export PATH=$PATH:/usr/lib64/mpich/bin
export LD_LIBRARY_PATH=/usr/lib64/mpich/lib:$LD_LIBRARY_PATH
export MPICC=/usr/lib64/mpich/bin/mpicc
export MPICXX=/usr/lib64/mpich/bin/mpicxx

How to build and test

After you completed the installation steps, you can build the canoe library. The easiest way is to build it in-place, meaning that the build (binary files) are located under root. To do so, make a new directory named build

mkdir build

All build files will be generated and placed under this directory. It is completely safe to delete the whole directory if you want another build. cd to build and cmake

cd build
cmake ..

This command tells the cmake command to look for CMakeFiles.txt in the parent directory, and start configuring the compile environment. Then compile the code by

make -j4

This comman will use 4 cores to compile the code in parallel. Once complete, all executable files will be placed in build/bin.

Optional packages