HowTo: Use Spack to install MFEM.

MFEM can be built with make or CMake. But MFEM has also been packaged to be built with Spack.

What does it mean to use Spack, and why use it?

Packaging vs. Build-System

In concrete terms, packaging with Spack here means that:

(Note that so far, the MFEM Spack package interfaces with MFEM makefile build system, not CMake.)

The first takeaway is that using Spack may not allow as much configuration as possible manually but will manage the installation of dependencies.

When to use Spack?

Spack is a from source package manager. So Spack will allow you to build mfem from source using the underlying makefile build system.

To manage your libraries for development

Spack is typically used to deploy software. You may use it to install MFEM among other libraries in a shared location for developers using MFEM as a dependency: all will have access to the same configuration and you will be able to reproduce this installation at will.

But you will be limited to a predefined set of versions. Typically the releases and the latest state of master branch. In that sense Spack is not meant to be use to develop in MFEM a priori.

(For those looking to use Spack to develop in MFEM, see Spack workflow feature)

To install dependencies automatically

Spack will automatically build the dependencies, which can be especially valuable to get started quickly with an advanced configuration of MFEM.

This is a great way to get students started quickly with a configuration that would require much too many steps otherwise.

To reproduce a vetted configuration

Spack is used in GitLab CI context to automate the build on dependencies, easily update those, and improve reproducibility.

For more details about this, explore MFEM Uberenv configuration, and the documentation mentioned in the README.

How to use Spack to install MFEM.

Using Spack is easy to start with, complex when it comes to getting exactly what you want, and can be tedious to maintain on the long term.

Best practices for a long-term sane relationship with Spack

Unless you want to develop in Spack, those rules will help keeping things under control:

Using Spack to install MFEM on LLNL's Lassen and Quartz systems

Those machines are used to test MFEM. The tests running in GitLab CI use Spack to manage MFEM dependencies. The configuration used for those tests can be reproduced exactly. This guarantees to get a working installation through Spack.

Unfortunately, only a handful of configurations are being tested. But this is a good starting point to explore further. See MFEM Uberenv configuration for more details.