The installation of openfoam with spack will generally require the
latest (development version) of spack. If this is available, you can
install openfoam in various configurations and dependencies, but
typically can simply install directly:
$ spack install openfoam
Depending on how your packaging system has handled things, an openfoam
session command may be available as an alternative to the
On the openSUSE installation, for example:
Although the OpenFOAM environment is sourced after your home
~/.bashrc, it is advisable to ensure that there are no circular
references from within your ~/.bashrc file.
Different compiler versions
By default, OpenFOAM handles newer/older non-system compilers as
ThirdParty installations and uses the combination of WM_COMPILER
and WM_COMPILER_TYPE to select them. In some cases, however, it can
be much more convenient for the user to install prebuilt compiler
binaries as system compilers (eg, using deb or rpm packages).
This poses a slight problem since the OpenFOAM build rules normally
use the main compiler name (gcc, clang etc) without any additional
version information, but the various system compilers are frequently
installed with versioned names such as gcc-8, clang-9 etc.
Here is a simple way to solve this, using clang-9 on openSUSE for the
Or if this shall be restricted to system compilers only:
# Override compiler calls for llvm-9ifeq ($(WM_COMPILER_TYPE),system) cc = clang-9 CC = clang++-9 -std=c++11endif
The final step is to select this compiler definition with the following
# Preferences for system Clang90export WM_COMPILER=Clang90export WM_COMPILER_TYPE=system
If this change represents your standard default compiler definition,
then place the information into the etc/prefs.sh file (see the
etc/bashrc file for some details) and re-source your OpenFOAM
If you would like to selectively enable this compiler definition, a
common means is to place the same definition information into a user
configuration file (for example, ~/.OpenFOAM/clang90) and then
specify that configuration when sourcing your OpenFOAM environment.