Spack is a flexible package manager designed to support multiple versions, configurations, platforms, and compilers.
It is actively developed by a vibrant open-source community of users and contributors who maintain package configurations across a wide range of platforms, including macOS and Linux. This enables a consistent and reproducible build environment for many scientific software packages.
MoFEM is best deployed and developed using Spack, which is the recommended installation method. Please note that Spack builds all packages from source; precompiled binaries are not provided.
If you encounter issues, have feedback, or would like to suggest improvements, feel free to contact us at
mofem-group@googlegroups.com.
Installation instructions besides Oak are not valid. We changed patterns how we work
with Spack, and change MoFEM infrastructure. Documentation is not yet updated.
Installing MoFEM with Spack on Ubuntu Noble
This guide walks you through setting up MoFEM using Spack on Ubuntu Noble, based on the official Docker build.
๐งฐ Prerequisites
Ensure you're running Ubuntu 24.04 (Noble Numbat) and have sudo privileges.
๐ฆ Step 1: Install System Dependencies
sudo apt update && sudo apt install -y \
file \
zlib1g-dev \
openssh-server \
wget \
valgrind \
curl \
git \
g++ \
gfortran \
gdb \
m4 \
automake \
build-essential \
libtool \
libsigsegv2 \
libjpeg-dev \
graphviz \
doxygen \
cmake \
pkg-config \
gnuplot \
ca-certificates \
python3-setuptools \
python3-dev \
python3-numpy \
python3-scipy \
libx11-dev \
xauth \
xterm \
unzip \
mesa-common-dev \
libglu1-mesa-dev \
libxmu-dev \
libxi-dev \
libssl-dev \
gawk \
gettext \
libboost-all-dev \
libboost-python-dev \
openmpi-bin \
libopenmpi-dev
๐ Step 2: Set Up Directories
export MOFEM_INSTALL_DIR=$HOME/mofem_install
export SPACK_ROOT=$MOFEM_INSTALL_DIR/spack
mkdir -p $SPACK_ROOT
๐ฅ Step 3: Download and Unpack Spack
curl -L https://github.com/spack/spack/archive/refs/tags/v0.23.1.tar.gz | \
tar -xz -C $SPACK_ROOT --strip-components=1
๐ง Step 4: Initialise Spack
Add to your .bashrc or .bash_profile:
export MOFEM_INSTALL_DIR=$HOME/mofem_install
export SPACK_ROOT=$MOFEM_INSTALL_DIR/spack
. $SPACK_ROOT/share/spack/setup-env.sh
Then apply:
๐ง Step 5: Configure Spack
spack compiler find
spack external find
spack config add "packages:all:target:[x86_64]"
spack config add "packages:all:variants:build_type=Release"
Then, update ~/.spack/packages.yaml (or use sed) to mark some packages as external:
openmpi:
externals:
- spec: openmpi@4.1.6
prefix: /usr
buildable: false
python:
externals:
- spec: python@3.12.3
prefix: /usr
buildable: false
py-numpy:
externals:
- spec: py-numpy@1.26.4 ^python@3.12.13
prefix: /usr
buildable: false
boost:
externals:
- spec: boost@1.83.0
prefix: /usr
buildable: false
icu4c:
externals:
- spec: icu4c@74.2
prefix: /usr
buildable: false
๐งฉ Step 6: Add Clone and Custom MoFEM Package Repository
If you have a custom MoFEM Spack repo:
# Clone the MoFEM repository
cd $MOFEM_INSTALL_DIR
git clone -b $MOFEM_BRANCH https://bitbucket.org/mofem/mofem-cephas.git
spack repo add $MOFEM_INSTALL_DIR/mofem_cephas
Ensure:
- `$MOFEM_INSTALL_DIR/mofem_cephas/repo.yaml`
- `$MOFEM_INSTALL_DIR/mofem_cephas/packages/...`
## ๐ Step 7: Install MoFEM Dependencies
bash spack repo add $MOFEM_INSTALL_DIR/mofem_cephas spack install –only dependencies mofem.nosp@m.-cep.nosp@m.has@0.nosp@m..15.0+mgis ^petsc+X
## ๐งน Step 8: Clean Build Cache
bash spack clean -a
## ๐ฅ Step 9: Build MoFEM
bash
Set the MoFEM source directory
export MOFEM_SRC_DIR=$MOFEM_INSTALL_DIR/mofem-cephas export MOFEM_BRANCH=Version0.15.0
๐๏ธ Step 10: Build MoFEM Core Library
. $SPACK_ROOT/share/spack/setup-env.sh
# Create and activate environment
spack env create mofem
spack env activate mofem
# Configure and build
spack config add "packages:all:target:[x86_64]"
spack config add "packages:all:variants:build_type=Release"
spack add mofem-cephas@0.15.0+adol-c+med+mgis~shared+slepc+tetgen install_id=0 ^petsc+X
spack develop -p $MOFEM_SRC_DIR mofem-cephas@0.15.0
spack concretize -f
spack install -v
# Clean build cache
spack clean -a
โ
Done!
MoFEM is now installed using Spack and ready to use.
To persist environment setup across sessions, you may add:
echo ". $SPACK_ROOT/share/spack/setup-env.sh" | sudo tee /etc/profile.d/mofem.sh
๐ง MoFEM Installation on Oak Development Server
These instructions describe how to install MoFEM using Spack on the Oak development server.
๐ ๏ธ 1. Set Up Environment in <tt>~/.bashrc</tt>
If you have an account on Oak, configure your shell environment by adding the following lines:
echo "export TMPDIR=$HOME/tmp" >> ~/.bashrc
echo ". /mofem_install/vanilla_spack/share/spack/setup-env.sh" >> ~/.bashrc
Then restart your terminal, or run the above lines in your current shell to apply them immediately.
๐ 2. Prepare Installation Directory
mkdir -p $HOME/mofem_install
cd $HOME/mofem_install
and copy packages list
cp /mofem_install/packages.yaml $HOME/.spack
๐ฆ 3. Clone the MoFEM Repository
git clone git@bitbucket.org:mofem/mofem-cephas.git
๐งช 4. Create and Configure the Release Environment
mkdir -p $HOME/mofem_install/release_env
cd $HOME/mofem_install/release_env
Add the MoFEM repository to Spack:
spack repo add $HOME/mofem_install/mofem-cephas
Create a new Spack environment and configure it:
spack env create -d .
spacktivate .
spack config add "packages:all:variants:build_type=RelWithDebInfo"
Add MoFEM and its dependencies:
spack add mofem-cephas@0.15.0 +adol-c +med +mgis ~shared +slepc +tetgen +build_tutorials install_id=$USER ^petsc+X
spack develop -p $HOME/mofem_install/mofem-cephas
Build the environment:
spack concretize -f
spack install -v --test=root mofem-cephas@0.15.0
To activate the environment in future sessions:
spack env activate -d $HOME/mofem_install/release_env
๐ 5. (Optional) Create a Debugging Environment
Use this to build with debug flags and work on source-level changes to PETSc or MOAB.
โ๏ธ Create and Configure the Debug Environment
mkdir -p $HOME/mofem_install/debug_env
cd $HOME/mofem_install/debug_env
spack env create -d .
spacktivate .
spack config add "packages:all:variants:build_type=Debug"
spack add mofem-cephas@0.15.0 +adol-c +med +mgis ~shared +slepc +tetgen +build_tutorials install_id=$USER ^petsc+X
spack develop -p $HOME/mofem_install/mofem-cephas
spack concretize -f
spack install -v --test=root mofem-cephas@0.15.0
Activate the environment:
spack env activate -d $HOME/mofem_install/debug_env
๐ฌ Work on PETSc and MOAB Code (Optional)
If you plan to modify PETSc or MOAB, you can clone and develop them directly:
cd $HOME/mofem_install/debug_env
# Add source-controlled PETSc and MOAB
spack add moab@5.5.1
spack add petsc@3.22.1
# Mark them for local development
spack develop -p $PWD/moab moab@5.5.1
spack develop -p $PWD/petsc petsc@3.22.1
# Re-concretise and install
spack concretize -f
spack install -v
โ
Done!
MoFEM is now installed and ready for use. To make development smoother:
- Use
spack env activate -d <path> to switch environments.
- Add common commands to your
.bashrc or .bash_aliases.
- Use
spack develop to link your changes into the build.
๐ง MoFEM Installation on Buckedhead (SLURM System)
This guide assumes you're using modules and installing into your user space, without admin privileges.
๐ฆ 1. Load Required Modules
module purge
module load gcc/14.2.0
module load mpi/openmpi/4.1.7/gcc-14.2.0
module load python/3.12.8
Check that they are loaded correctly:
which gcc
which mpicc
python3 --version
๐ 2. Create Directory Layout
export MOFEM_INSTALL_DIR=$HOME/mofem_install
export SPACK_ROOT=$MOFEM_INSTALL_DIR/spack
mkdir -p $SPACK_ROOT
mkdir -p $MOFEM_INSTALL_DIR
cd $MOFEM_INSTALL_DIR
๐ฅ 3. Download and Unpack Spack
curl -L https://github.com/spack/spack/archive/refs/tags/v0.23.1.tar.gz | \
tar -xz -C $SPACK_ROOT --strip-components=1
๐ง 4. Initialise Spack
Add to your .bashrc or run interactively:
export SPACK_ROOT=$HOME/mofem_install/spack
. $SPACK_ROOT/share/spack/setup-env.sh
Apply changes:
๐ง 5. Configure Spack with External Packages
spack compiler find
spack external find
Edit ~/.spack/packages.yaml and add:
packages:
all:
target: [x86_64]
variants: +mpi build_type=Release
python:
externals:
- spec: python@3.12.8
prefix: /software/python/3.12.8
buildable: false
openmpi:
externals:
- spec: openmpi@4.1.7
prefix: /software/mpi/openmpi/4.1.7/gcc-14.2.0
buildable: false
boost:
externals:
- spec: boost@1.83.0
prefix: /usr
buildable: false
๐งฉ 6. Clone and Register MoFEM Repo
cd $MOFEM_INSTALL_DIR
git clone --branch Version0.15.0 https://bitbucket.org/mofem/mofem-cephas.git
spack repo add $MOFEM_INSTALL_DIR/mofem-cephas
๐ฑ 7. Create and Configure Spack Environment
mkdir -p $MOFEM_INSTALL_DIR/release_env
cd $MOFEM_INSTALL_DIR/release_env
spack env create -d .
spack env activate .
spack config add "packages:all:target:[x86_64]"
spack config add "packages:all:variants:build_type=RelWithDebInfo"
๐ 8. Add and Build MoFEM
spack add mofem-cephas@0.15.0 +adol-c +med +mgis ~shared +slepc +tetgen ~build_tutorials install_id=$USER ^petsc+X
spack develop -p $MOFEM_INSTALL_DIR/mofem-cephas
spack concretize -f
spack install -v
๐งช 9. (Optional) Create Debug Environment
mkdir -p $MOFEM_INSTALL_DIR/debug_env
cd $MOFEM_INSTALL_DIR/debug_env
spack env create -d .
spack env activate .
spack config add "packages:all:variants:build_type=Debug"
spack add mofem-cephas@0.15.0 +adol-c +med +mgis ~shared +slepc +tetgen ~build_tutorials install_id=$USER ^petsc+X
spack develop -p $MOFEM_INSTALL_DIR/mofem-cephas
spack concretize -f
spack install -v
โ
10. Run MoFEM in SLURM Job
Example SLURM script:
#!/bin/bash
#SBATCH --job-name=mofem_test
#SBATCH --ntasks=4
#SBATCH --time=01:00:00
module purge
module load gcc/14.2.0
module load mpi/openmpi/4.1.7/gcc-14.2.0
module load python/3.12.8
source $HOME/mofem_install/spack/share/spack/setup-env.sh
spack env activate $HOME/mofem_install/release_env
mpirun ./my_mofem_app
FAQ
How to get packages installed today?
Run command:
spack find -p -L --start-date `date +%F`
and you will get:
-- darwin-elcapitan-x86_64 / clang@7.3.0-apple ------------------
ugi2gm7 mofem-cephas@develop /spack/opt/spack/darwin-elcapitan-x86_64/clang-7.3.0-apple/mofem-cephas-develop-ugi2gm7lydyjwmiwneefhxq7ahvpnuzc
gu4uheh mofem-users-modules@develop /spack/opt/spack/darwin-elcapitan-x86_64/clang-7.3.0-apple/mofem-users-modules-develop-gu4uhehai3edtqow7kivuxgpw5lmvbxz
How to find packages that were only installed today?
Run command:
ls -lhd `spack find -lp | grep mofem | awk '\''{print $3}'\''`
Contact
If you are experiencing any problems with this installation, please contact us by mofem-group@googlegroups.com.