Building and Testing MAPL as a standalone - GEOS-ESM/MAPL GitHub Wiki

Introduction

MAPL can be built by itself as long as you have the dependencies. If you are inside the NASA HPC ecosystem on NAS or NCCS computer clusters it is really simple since the SI Team maintains the dependencies needed.

Building at NAS or NCCS

If you have an account as NAS or NCCS it is really, really simple to build MAPL (we promise) since we maintain all the dependencies. There is no need to read beyond this section. You will need "mepo" in your path, ask the SI team if you don't know what that means. Once you have mepo in your path, it is as simple as this.

# Note that this command, up to and including the mepo clone must be done on a login node. 
# The compute nodes can't see the internet
# Note by default the clone will be to a directory named MAPL.
git clone [email protected]:GEOS-ESM/MAPL.git
# If you want the checkout in a different directory, in this example I'll call it MAPL_v2.44.2 you can do this
git clone [email protected]:GEOS-ESM/MAPL.git MAPL_v2.44.2
# Either way cd to the cloned directory, either "MAPL" or some other name if you did that.
cd MAPL
# checkout the version of MAPL you want. I'll use v2.44.2 as an example
git checkout v2.44.2
mepo clone
# From here you would probably want a compute node to do the build
# If you do more than -j2 on a login node NCCS/NAS will get mad
# and it will take longer
source ESMA_env/g5_modules
mkdir build
cd build
cmake ../ -DBASEDIR=$BASEDIR/Linux -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=../install
make -j4 install

Once you do this, you will have an install directory with libraries and executables created by MAPL. The instructions above will build the "Release" build which enables optimization flags and turns off some error checking like going past array bounds. We highly recommend for any development work to use the "Debug" built which turns off optimization flags and turns on error checking such as making sure arrays do not go out of bounds and uninitialized variables will be set to signaling NANs. To turn on the "Debug" built you simple replace -DCMAKE_BUILD_TYPE=Release with -DCMAKE_BUILD_TYPE=Debug in the cmake command when you build. Note you can even have multiple installations. Just build twice and point to a different installation directory in each!

As a side note, if you can do the above you can build the full GEOSgcm or GEOSadas in the same manner, you just clone a different repo to start. We would recommend that you do that rather than use the parallel_build scripts in those repos. As you can see, building by hand is not hard and you will actually understand what is going on!

Building Outside of NASA HPC systems

If you are not inside a NASA HPC system, it is more exciting, as you will have to build the dependencies yourself. If you are on a Linux system with a C and Fortran compiler with MPI, you could try build our GMAO baselibs. Assuming you have the compiler/mpi stack, in theory baselibs should build easily and that is detailed below. On macOS, you can also build baselibs but it may be a little more exciting.

Dependencies

MAPL has the following dependencies (really the easiest way to get the dependencies is to build our Baselibs):

  • MPI with Fortran interfaces
  • ESMF
    • NetCDF
      • HDF
  • NetCDF-Fortran
    • NetCDF
      • HDF
  • FLAP
  • ESMA_cmake
  • ecbuild
  • GFE (Goddard Fortran Ecosystem, omnibus repo for a collection of managed version of Fortran libraries written mostly by Tom Clune)

Testing

  • GFE

Note 1: The one dependency that could be eliminated here is FLAP. It is only used in drivers for MAPL, and not in the unit tests. We also expect to replace FLAP with fArgParse (part of GFE) in the future, which adds no complexity as it is already being used by the testing framework.

Note 2: We are assuming that MPI is available in the desired computing environment and offer no instructions for building and installing MPI.

Baselibs

Baselibs can be obtained here:

https://github.com/GEOS-ESM/ESMA-Baselibs

Before building make sure you have these environment variables set for you chosen compilers:

Compilers:

$ export FC=...
$ export CC=...
$ export CXX=...

Then, be certain that the MPI wrappers (mpif90/mpifort/..., mpicc, mpicxx) are in your path.

Building Baselibs with GNUmake

In theory if the above is true you can build baselibs like so with GNUmake. For the sake of this example I will assume you want to build Baselibs v7.8.1 and note that I am assuming it is Intel MPI you are using if you have a different flavour of MPI you will need specify that.

mkdir ESMA-Baselibs-7.8.1
cd ESMA-Baselibs-7.8.1
wget https://github.com/GEOS-ESM/ESMA-Baselibs/releases/download/v7.8.1/ESMA-Baselibs-v7.8.1.COMPLETE.tar.xz
cd ESMA-Baselibs-v7.8.1
make download
make -j10 install ESMF_COMM=intelmpi BUILD=ESSENTIALS CONFIG_SETUP=ifort_2021.6.0-intelmpi_2021.6.0

Once Baselibs is built, you would need to point the g5_modules in your MAPL clone to the correct baselibs and make sure any modules you need are loaded on your system. From there you would build as detailed in the beginning of the document.


Anything beyond this point is not for the faint of heart..., it's really much easier if you just build our baselibs. You have been warned and the following instructions have not been tested or may be incomplete.

Build MAPL

Obtaining MAPL

Git + Mepo

If you want to clone MAPL via Git, you'll also need to get mepo:

https://github.com/GEOS-ESM/mepo/

which is our tool to handle our subrepositories. mepo is a Python3 script that needs PyYAML, and all you need to do is add the repo to your path.

Once you have mepo:

git clone -b v3.25.2 https://github.com/GEOS-ESM/MAPL.git
cd MAPL
mepo clone

Note that git clone is the only way to get non-tags of MAPL.

Complete Tarfile

The other easier way to get MAPL is via a "complete" tarfile. You can find these in the Assets for a version, such as here:

https://github.com/GEOS-ESM/MAPL/releases/tag/v2.35.2

where you will see:

MAPL-v2.27.0.COMPLETE.tar.xz

This tarfile has had mepo run on it and is "complete".

Building MAPL

  1. Create a build directory
    $ mkdir <build-dir>
    $ cd <build-dir>
    
  2. Configure cmake
    $ cmake -DCMAKE_PREFIX_PATH=<install-dir> -DESMF= -DNETCDF=
    
  3. Build and run unit tests
    $ make -j 
    $ make -j tests
    $ ctest -V
    
    

Note: The make tests step must be done after the regular make step. This is because some dependencies are not correctly captured in the pFUnit macro used to define the tests.

⚠️ **GitHub.com Fallback** ⚠️