Skip to content
Jon Grumer edited this page May 25, 2022 · 1 revision

To install GRASP you will need at least a Fortran and MPI compiler, and either Make or CMake. For this tutorial, we shall stick to the open-source and freely available gfortran and open-mpi compilers.

Mac [work in progress]

Before you do anything, make sure everything is up to date with brew update.

  1. Install gfortran with e.g. the Homebrew package manager.
    brew install gfortran
    Check version with gfortran --version and optionally define an alias as you see fit e.g. with alias gfortran=gfortran-11 in ~/bashrc.

  2. Install lapack and blas [optional, Mac OS typically comes with its own implementation].
    brew install lapack, openblas

  3. Before installing OpenMPI, set the following environment variables in e.g. ~/.bashrc to match your gfortran version above

    export HOMEBREW_CC=gcc-11
    export HOMEBREW_CXX=g++-11
    export HOMEBREW_FC=gfortran-11

    Then run source ~/.bashrc or restart your terminal.

  4. Install open-mpi (-build-from-source is optional, takes up to an hour to compile).
    brew install openmpi --build-from-source

    If you have a previous installation of open-mpi with brew, then rebuild and reinstall openmpi and its dependencies from source,
    brew reinstall openmpi --build-from-source

  5. Define which Fortran compiler/version mpifort should link to in /usr/local/Cellar/open-mpi/X.X.X/share/openmpi/mpifort-wrapper-data.txt. Edit the compiler line to compiler=gfortran-11.

Issue with gfortran-10/11

Note that the code won't compile with gfortran-10 or 11 with the default flags due to some stricter rules concerning rank mismatches.

For Make, as a temporary fix if you're using gfortran-10 or 11 (and only then), using the regular non-cmake build system, append the FC_FLAG variable with this flag (directly in the terminal before making or in a new file Make.user, automatically read by the Makefile):

export FC_FLAGS="$FC_FLAGS -fallow-argument-mismatch"

For CMake you can try to add

set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fallow-argument-mismatch")

in the CMakeLists.user.