How to build OpenFOAM with Arm Compiler for HPC.


OpenFOAM is a free, open source CFD software used to solve a variety of problems, such as complex fluid flows, chemical reactions, acoustics, solid mechanics, and electromagnetics

For more information on OpenFOAM, visit the official OpenFOAM website.

Version information

For the purposes of this build, the following components are used:

OpenFOAM Version 1812
Arm Compiler for HPC
Version 19.0
Arm Performance Libraries Version 19.0
Open MPI Version 4.0.0
Operating System
RHEL 7.5
Hardware Cavium ThunderX2


Choose a location for the OpenFOAM build using $BUILD_DIR, and download and unpack the OpenFOAM and ThirdParty source.



mkdir $BUILD_DIR
tar -xzf OpenFOAM-v1812.tgz -C $BUILD_DIR
tar -xzf ThirdParty-v1812.tgz -C $BUILD_DIR

User configuration

To configure your environment:

  1. Set the compiler type to Arm in etc/

    $ echo "WM_COMPILER=Arm" > $BUILD_DIR/OpenFOAM-v1812/etc/
  2. Ensure that your desired optimisation and library flags are set in OpenFOAM‑v1812/wmake/rules/linuxARM64Arm/.
    For example:

    • In the c file, set the following flags:
    • LINKLIBSO = $(cc) -shared -mcpu=native -armpl
      LINKEXE   = $(cc) -Xlinker --add-needed -Xlinker -z -Xlinker nodefs ‑mcpu=native ‑armpl
    • In the cOpt file, set the following flags:
    • cOPT = -mcpu=native -ffp-contract=fast -O3 -fsimdmath -armpl
    • In the c++ file, set the following flags:
    • LINKLIBSO = $(CC) $(c++FLAGS) -shared -mcpu=native -armpl
      LINKEXE = $(CC) $(c++FLAGS) -Xlinker --add-needed -mcpu=native -armpl
    • In the c++Opt file, set the following flags:
    • c++OPT = -mcpu=native -ffp-contract=fast -O3 -fsimdmath -armpl
  3. Source the OpenFOAM build environment:

    $ source $BUILD_DIR/OpenFOAM-v1812/etc/bashrc

Build OpenFoam

To preconfigure your environment for building OpenFOAM with Arm Compiler for HPC:

  1. To use a pre-built Boost library, set boost_version and BOOST_ARCH_PATH in $BUILD_DIR/OpenFOAM-v1812/etc/
    For example:

    export CGAL_ARCH_PATH=$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER/$cgal_version

    $BOOST_ROOT is the location of the Boost installation.

    For details on building Boost with the Arm toolchain, see the Arm Boost porting guide.

  2. Optionally, check the system readiness.

    $ foamSystemCheck
  3. Change to the main OpenFOAM directory with cd $WM_PROJECT_DIR, using the foam alias:

    $ foam
    This only works if the Build environment is set correctly.
  4. Compile OpenFOAM using all available processors (-j), with reduced output (-s), and log the output (-l) to a file so that you can examine compilation issues later.

    $ ./Allwmake -j -s -l

Run a test case

To run a test case, use the following:

$ tut
$ cd incompressible/simpleFoam/motorBike
$ ./Allclean
$ ./Allrun

More resources