Prerequisites

OPM uses various third-party libraries and frameworks, these include:

  • BLAS and LAPACK
  • Boost (1.58 or later)
  • SuiteSparse with UMFPACK
  • The Dune core modules dune-common, dune-geometry, dune-grid and dune-istl. We currently support Dune 2.7, 2.8 and 2.9.  Dune can be installed from binary packages (see the “Ubuntu binary” section below) or from source (see the Dune documentation).
  • The Zoltan library from Trilinos (for grid partitioning and load balancing)

Note that some parts of OPM (opm-common) can be built without Dune. No part of OPM requires any optional Dune prerequisites, such as Alberta, ALUGrid, UG or psurface. Also, some libraries that used to be prerequisites (libecl, SuperLU and Eigen) are no longer needed.

Required tools

In addition, you need some tools:

  • git (for cloning the repo)
  • a C++ compiler (must support C++17) and cmake (for building the software),
  • doxygen and latex (for building the docs).

The easiest way to satisfy prerequisites is to install them from binary packages, we provide instructions for Ubuntu, OpenSUSE and Mac OS X. The developers use either the g++ (version 7 or later required) or clang++ (version 5 or later required) compiler. 

Ubuntu binaries (for Ubuntu 20.04 or 22.04)

To install binary packages of the OPM prerequisites you can follow the recipe below. Note that for some of these packages we provide our own versions, which is why you must add the OPM PPA repository even if you want to build OPM yourself. In particular, note that the Dune packages in Ubuntu 20.04 are Dune version 2.6, which is not supported with OPM, but if you install it from the OPM PPA you get version 2.8.

# Make sure we have updated URLs to packages etc.
sudo apt-get update -y

# For server edition of Ubuntu add-apt-repository depends on
sudo apt-get install -y software-properties-common

# Add PPA for OPM packages
sudo add-apt-repository -y ppa:opm/ppa
sudo apt-get update -y

# Packages necessary for building
sudo apt-get install -y build-essential \
  gfortran pkg-config cmake

# Packages necessary for documentation
sudo apt-get install -y doxygen ghostscript \
  texlive-latex-recommended gnuplot

# Packages necessary for version control
sudo apt-get install -y git-core

# MPI for parallel programs
sudo apt-get install -y mpi-default-dev
# Prerequisite libraries
sudo apt-get install -y libblas-dev \
  libboost-all-dev libsuitesparse-dev \
  libtrilinos-zoltan-dev libfmt-dev libcjson-dev 

# Parts of Dune needed
sudo apt-get install libdune-common-dev \
  libdune-geometry-dev libdune-istl-dev \
  libdune-grid-dev

OpenSUSE

# libraries
sudo zypper in blas libblas3 lapack liblapack3 libboost umfpack

# tools
sudo zypper in gcc automake autoconf git doxygen

# DUNE libraries
sudo zypper ar \
http://download.opensuse.org/repositories/science/openSUSE_12.2/science.repo
sudo zypper in dune-common dune-istl

macOS

There are only some binary packages available for macOS for the prerequisites. The following steps should  install all needed utilities and libraries. The steps have been tested on macOS 10.15 (Catalina).

  • Install XCode, make sure that you can run clang and git from the Terminal.
  • Install Homebrew. You can visit their home page for simple (one-line) install instructions and information.
  • Install various tools and libraries:
brew install cmake pkg-config doxygen
brew install boost suite-sparse
  • Optional: install OpenMPI. For some reason this seems to install gcc, and therefore takes a long time. Can be skipped, but then you will not be able to build a parallel version of the OPM programs.
brew install open-mpi
  • Optional: install Zoltan (requires that you have installed MPI). The Zoltan library is used for partitioning the grid for load balancing in parallel runs. Without Zoltan, it is possible to run in parallel but the partitioning will be bad and the gain very limited. To install Zoltan, you must clone the Trilinos repository containing Zoltan and build it, which can be done with this script:
#!/bin/bash

# Edit the next two variables to match your wishes and system.
install_prefix="/Users/YOURUSERNAME/duneinstall"
parallel_build_tasks=4

git clone https://github.com/trilinos/Trilinos.git
git checkout trilinos-release-12-8-1
mkdir build
(
  cd build
  cmake \
    -D CMAKE_INSTALL_PREFIX=$install_prefix \
    -D TPL_ENABLE_MPI:BOOL=ON \
    -D MPI_BASE_DIR:PATH=/usr/local \
    -D Trilinos_ENABLE_ALL_PACKAGES:BOOL=OFF \
    -D Trilinos_ENABLE_Zoltan:BOOL=ON \
    ../
  make -j $parallel_build_tasks
)
  • Install Dune. This is documented on the Dune webpage, but you can use the following shell-script. To run the script, copy it into a file (buildDune.bash for example) and run it with “bash buildDune.bash“. The lines are broken below, but selecting the text and copying to a text editor should show the script in a readable way.
#!/bin/bash

# Edit the next two variables to match your wishes and system.
install_prefix="/Users/YOURUSERNAME/duneinstall"
parallel_build_tasks=4

# Set of modules to build
modules="dune-common dune-geometry dune-grid dune-istl"

# Clone modules, check out the 2.6 release.
for m in $modules; do
    echo "==================================================="
    echo "=        Cloning module: $m"
    echo "==================================================="
    (
        if [ ! -d "$m" ]; then
            git clone -b releases/2.6 https://gitlab.dune-project.org/core/$m.git
        else
            echo "******** Skipping $m, module already cloned."
        fi
    )
done

# Build the modules, and install them to the chosen directory
for m in $modules; do
    echo "==================================================="
    echo "=        Building module: $m"
    echo "==================================================="
    (
        cd $m
        builddir="build-cmake"
        if [ ! -d "$builddir" ]; then
            mkdir "$builddir"
            cd "$builddir"
            cmake -DCMAKE_INSTALL_PREFIX=$install_prefix ".."
            make -j $parallel_build_tasks
            make install
        else
            echo "******** Skipping $m, build dir $builddir already exists."
        fi
    )
done
  • Note that unless you choose to install Dune to a standard location (not recommended since you may want to install and experiment with newer versions while keeping the old one), you must tell cmake where to find Dune when building OPM! This is done by passing the option
    -DCMAKE_PREFIX_PATH="/Users/foo/bar" to cmake when you build OPM (replacing /Users/foo/bar with the location where you installed Dune). The same applies to Zoltan, if you need to specify two different paths you can do so with -DCMAKE_PREFIX_PATH="/first/dir;/second/dir".