How to compile the SWMF model

Pre-requisites

sudo apt update
sudo apt install build-essential

The command installs a bunch of new packages including gcc, g++ and make.

gcc --version

Then we need an MPI support. We choose OpenMPI:

sudo apt-get update && sudo apt-get install infiniband-diags ibverbs-utils \
     libibverbs-dev libfabric1 libfabric-dev libpsm2-dev -y
sudo apt-get install openmpi-bin openmpi-common libopenmpi-dev libgtk2.0-dev
sudo apt-get install librdmacm-dev libpsm2-dev

The command installs a bunch of new programs including mpiexec, mpif90, and mpicxx.

Downloading

The source code locates at: https://github.com/SWMFsoftware/SWMF

To download the code, we choose to clone through SSH:

git clone git@github.com:SWMFsoftware/SWMF.git

If you use HTTPS, you will encounter errors during installation. SSH connection requires setup in the terminal. Checkout this GitHub post.

Compilation

./Config.pl
./Config.pl -install

Checkout the usage of Config.pl for switching compilers etc.

On Perlmutter, we need to manually add -pthread to the linking stage. Identify the following line in Makefile.conf:

LINK.f90         = ${CUSTOMPATH_MPI}mpif90

Append -pthread to the end:

LINK.f90         = ${CUSTOMPATH_MPI}mpif90 -pthread

Testing

make -j test16_2d