v0.14.0 |
Spack.pm is "A flexible package manager supporting multiple versions, configurations, platforms, and compilers."
A community of Spack.pm users and developers contributes to development of package configurations for a range of platforms, including macOS and Linux. This creates a consistent build setup for supported scientific packages.
MoFEM can be deployed and developed using Spack.pm, which is the recommended way of installation. It should be noted that Spack.pm compiles packages from sources, pre-compiled binaries are not available. If you have any problems, feedback or would like to suggest corrections, please email to mofem-group@googlegroups.com.
The remainder of this article presents a step-by-step guidance with comments/explanations on how to install MoFEM using Spack on different platforms (Linux, macOS, HPC). However, those who prefer to automate the process of the installation can use the following scripts for different purposes:
install_mofem_user.sh
install_mofem_developer.sh
You should copy the script to the directory where MoFEM will be installed and run it from the terminal, for example:
The installation of MoFEM requires git.
Install the following packages:
Xcode contains required compilers for macOS. The latest known working version of Xcode is 13.3 with clang 13.1.6; there may be issues with future/different versions.
You can install the latest version of Xcode for your macOS through App Store, or, alternatively, you can see Apple's Xcode download page (Apple login required) for other versions.
Ensure that Xcode command-line tools are installed by running:
Additional packages may be required - install homebrew package manager:
Recent releases of macOS stopped shipping a Fortran compiler and therefore require Mixed Toolchains. The installation of gfortran
through homebrew
is one way of solving this:
Note that gfortran
if part of GCC
.
Create mofem_install
directory:
Retrieve Spack for MoFEM:
Initialise Spack's environment variables:
Spack's environment variables will be lost when the terminal session is closed. Consider adding the previous command to your .bash_profile
or .bashrc
, e.g.:
If you are using a newer macOS, you might need to add config to .zshrc
, e.g.:
Finally, find already installed compilers and external packages:
Note that there are further instructions on Spack usage and configuration.
The first time installation of MoFEM takes considerable time (hours). Spack fetches and compiles MoFEM's dependencies from source and this includes several large packages.
Those seeking to develop MoFEM should see developer's instructions.
MoFEM's basic users module consist of tools for solving a range of common problems, from elasticity to the Poisson equation. To install them run the following command:
To access the installed users modules, create an um_view
directory. This should be created in an appropriate directory. Then you can run:
This filesystem view is a single directory tree that is the union of the directory hierarchies of a number of installed packages; it is similar to the directory hierarchy that might exist under /usr/local
. The files of the view's installed MoFEM packages are brought into the view by symbolic or hard links, referencing the original Spack installation. Different 'views' can be created depending on the MoFEM version you wish to access. To make the new 'view' visible from any directory, add its bin
directory to your PATH
, e.g.:
Consider also adding this command to your .bash_profile
or .bashrc
, or .zshrc
, e.g.:
MoFEM can be extended by adding user modules. More modules are available as extensions in Spack. This will show available extensions:
The extensions can be installed using spack install <extension>
. For example, the fracture module can be installed by:
or the minimal surface equation tutorial module:
You can automatically run tests after installing a package, for example:
MoFEM can be developed in several different ways, here you can find step-by-step installation instructions for core and user modules developers:
The developer installation requires knowing more about how Spack works. See Spack usage and configuration before proceeding with the installation. In particular, the instructions below will use so-called specs to obtain the desired build configuration, see Spack manual page for more details. For example, the default Spack specifier for the build type is RelWithDebInfo
, however keep in mind that two other build types can be specified as build_type=Release
or build_type=Debug
, see also Change the build_type.
You can skip the first installation step and jump to second if you are not going to be the core MoFEM developer. However, to avoid having multiple installation paths, and potential bugs which are difficult to reproduce, we recommend following installation step 1 and step 2.
If you are going to develop MoFEM's core library, it means that you are a core developer and you can install MoFEM directly from the source.
Create mofem_install
folder in the home directory and clone MoFEM repository:
and kick-start installation of the core library. First install all dependencies:
and then core MoFEM library:
Note that here another specification of the build configuration (spec) was set as ~copy_user_modules
which is equivalent to copy_user_modules=False
.
If installation is successfully, by executing
you should see something similar to
Furthermore, in the directory $HOME/mofem_install/mofem-cephas
you will find build directory core-build-WithDebugInfo-vhv7opa
. Note that the hash in the name of the directory is matching the one in first column in the list printed by executing spack find -lv mofem-cephas
.
You can now start to develop code in the MoFEM core library. If you change directory to
you can compile, test and install:
i.e. do typical developer work.
Moreover, you can install simultaneously debugging version of code, as follows:
spack dev-build
will try to use all available processor slots to run make
in parallel. To set a desired number of parallel jobs, you can use the parameter -j NP
, where NP
is number of parallel processes to be used. Alternatively, you can edit Spack settings as discussed below in the section Basic settings in config.yaml-b BEFORE
or -u UNTIL
. For example, if you would like to investigate build issues, you can do Note that installation at that point is partial.
Clone users modules repository:
For example, if you want to install users modules against core library which was built with the specification build_type=RelWithDebInfo
, pick the corresponding row and copy to clipboard the hash (pa3httg
). Next, change the directory:
and install users modules:
In the spack dev-build
command of the snippet above ^
is a dependency spec, i.e. a descriptor defining the dependency of the package that we are currently installing on another package (in this case, a particular version of the core library).
Once installation is successfully, you can execute
and as result you will get something similar to:
Also, you will find new directory $HOME/mofem_install/mofem-cephas/mofem/users_modules/um-build-WithDebugInfo-c6ts56b
, which is the build directory for a particular version of mofem-users-modules
. There you can do typical developer work:
Later you can add other modules to that directory if needed.
-b BEFORE
or -u UNTIL
, for example if you like to investigate build issues, you can doBuckethead is a Linux cluster running CentOS 7. More information about Buckethead you will find here.
Load cluster modules:
It is a good idea to put the above lines into your .bash_profile
or .bashrc
file.
Clone spack:
and initialise Spack's environment variables (should also be placed into .bash_profile
or .bashrc
):
First, find available compilers:
Edit file $HOME/.spack/linux/compilers.yaml
and ensure it includes the following:
Note that most of the file was created by the command
however you have to put the line
which enables linking std lib c++ libraries.
Second, find the locally compiled openmpi
library:
Open the file $HOME/.spack/packages.yaml
and ensure that it has information only about the openmpi
library, i.e. the file should look as follows:
At this point, we can follow the standard installation procedure (with a few adjustments). To install dependencies run the following:
Once completed, check the installed packages by running
Note that the path for the openmpi
library should differ from all other packages: /software/mpi/openmpi/3.1.6/gcc-9.3.0
If you would like to have user installation, run the following command:
Now you can create a symlink to the install directory including dependent libraries using commands below:
Alternatively, you may want to follow the developer installation, which will have a few differences from the Developer installation discussed above.
Create mofem_install
folder in the $HOME
directory and clone MoFEM repository:
Kick-start installation of the core library:
If installation is successful, by executing
you should see something similar to
Next, change the directory:
and install users modules specifying the dependency on the previously installed core library using the:
Once installation is successfully, you will find a new directory, e.g. $HOME/mofem_install/mofem-cephas/mofem/users_modules/um-build-RelWithDebInfo-646hxk7
, which is the build directory for a particular version of mofem-users-modules
. There you can do typical developer work:
Later you can add other modules to that directory if needed.
Create a script file with content as below and name it, for example, job_spack
and run it as follows:
Results of the analysis are located in $HOME/um_view/elasticity.
The build type affects performance and the availability of debugging symbols. Select an appropriate type. With spack you can set the build_type
during installation:
Release
Debug
RelWithDebInfo
By default Spack will use RelWithDebInfo
.
For example:
Or when using spack dev-build
for developers:
An example compiler flag:
Spack is capable of managing multiple versions of MoFEM. It stores each version under a unique ID. The following command displays installed MoFEM packages with their unique ID, build type and other info:
An example output:
Preceding the name of the package is its ID. e.g. yk45ivx
. This is important when specifying which package version you wish to use.
Look at Spack creation tutorial and Spack Package Build Systems. You can look how we have created packages for fracture module or minimal-surface-equation, located in $HOME/spack/var/spack/repos/builtin/packages/mofem-fracture-module
and $HOME/spack/var/spack/repos/builtin/packages/mofem-minimal-surface-equation
. You can open package file:
To create your package for the user module, you have to
Spack's basic configuration options are set in config.yaml. You can see the default settings in $HOME/.spack/config.yaml
, for example, you can set the default number of jobs to use when running make
in parallel. If set to 4, for example, spack install
will run make -j4
. This can be done by adding line to config.yaml
. Configuration file should look like this:
For more details see here.
You can download mirror with all necessary packages from MoFEM repository and untar or unzip to directory:
Note that packages are expanded to directory mofem_mirror
, and mirror is made for MoFEM version v0.16.0.
Once mirror is downloaded, you can add it to your spack:
Some sites may not have access to the internet for fetching packages. These sites will need a local repository of tarballs from which they can get their files. Spack has support for this with mirrors. Look to Spack documentation to learn more about mirrors here. If you run
as a result a directory is created with are prerequisites needed for Spack installation of mofem-fracture-module. You can now move that directory to your secure server with the spack package.
On a secure server, you add mirror directory to Spack, for example:
and with that at hand kick-start installation process described above.
Not all packages can be installed with spack currentlt. Temprorary solution utill bigs are fixed in other packages is installation following packages with homebrew
Then spack command has to be called
Command abouve will find homebrew installation for openmpi. Installation for openblas has to be added by editing file $HOME/.spack/packages.yaml, and adding at the end
Run command:
and you will get:
Run command:
If you are experiencing any problems with this installation, please contact us by mofem-group@googlegroups.com.