Follow these instructions to build a basic Framework stack built with the GNU Compiler Suite on Intel Based Macs running Macintosh OS X.

0. Pre-Reqs

  • CMake. CMake is required to build PETSc. A quick Internet search for "CMake" and "DMG" will bring you to Kitware's site with a Mac OS X 64/32-bit Universal double-click installer. If you haven't already, download and install the CMake package. Once install, open CMake, click 'Tools', and then click 'How to Install For Command Line Use' and follow those instructions.

To verify you currently, or correctly have installed CMake, perform the following:

which cmake

If a path returns, you have CMake.

1. Environment Setup

Next we need to have a complete and sane environment. Copy the following to the end of your ~/.bash_profile:

# Compiler Variables
export CC=mpicc
export CXX=mpicxx
export F77=mpif77
export FC=mpif90

# Library location
export PACKAGES_DIR=/opt/moose

# Helper variables
export GCC_HOME=$PACKAGES_DIR/gcc_6.2.0
export CLANG_HOME=$PACKAGES_DIR/clang_3.9.0
export MPI_HOME=$PACKAGES_DIR/mpich/mpich_3.2
export PETSC_DIR=$PACKAGES_DIR/petsc/mpich_petsc-3.7.5/clang-opt


# JOB Count (the number of cores available on this machine)
export MOOSE_JOBS=4

# Peacock specific (optional)
if [ -d $PACKAGES_DIR/miniconda ]; then
  export PATH=$PACKAGES_DIR/miniconda/bin:$PATH
  export QT_API='pyside'

Now close all of your open terminals and re-open them. This will allow the above information to be present in your environment.

Next make sure you have an area setup to download packages and a place to build packages that need to be built. We recommend using the normal Mac ~/Downloads folder for your downloads and ~/projects/src, for your build directory. Create the build directory now:

mkdir -p ~/projects/src

Xcode Command Line Tools

Be sure you have an up to date version of Xcode Command Line tools installed. Having Xcode alone is not enough. To install (or verify) the latest version of Command Line Tools, open a terminal and run the following command:

xcode-select --install

Either a window will prompt you allowing to install command line tools, or the above command will error, explaining that you already have command line tools.

2. GCC 6.2.0

Because Apple does not include a Fortran compiler, it will be necessary to build the GNU compiler suite. This step can be avoided if you already have a working GNU compiler suite from MacPorts, Homebrew etc...

Download the following tarball: gcc-6.2.0.tar.gz. Please note, Safari may decompress the tarball and strip the '.gz' from it automatically. So you may need to strip the '.gz' in the following instructions as well. Also note, this is a modified version of GCC. Basically, its GCC with the prereqs included in the tarball. If that is a concern to you (that this tarball is not a true GNU GCC tarball), then please proceed to the web site and obtain a true copy of the gcc 6.2 tarball and perform the prereq steps as listed in their HOWTO. Again, the only difference with our tarball copy, is that we have performed the 'prereqs' steps, and then re-packaged the tarball. This is the same tarball that is used when building GCC in our redistributable package.

Build GCC

Extract the tarball, configure and build GCC

cd ~/projects/src
tar -xf ~/Downloads/gcc-6.2.0.tar.gz -C .
mkdir ~/projects/src/gcc-build
cd ~/projects/src/gcc-build

unset CC
unset CXX
unset FC
unset F90
unset F77

../gcc-6.2.0/configure --prefix=$GCC_HOME --disable-multilib --enable-languages=c,c++,fortran --enable-lto
make -j $MOOSE_JOBS
sudo -E make install

Verify you have correctly built/installed GCC by performing the following command:

which g++

If the above command does not return /opt/moose/gcc_6.2.0/bin/g++ then something went wrong and you should not proceed until this is fixed. Otherwise it will be a wast of time...

3. Clang 3.9

Clang is our preferred compiler. It was necessary to build GCC so we have a Fortran compiler. There are many components that go into the building of the LLVM compiler suite. It is important the following be completed in a very specific order.

cd ~/projects/src

tar -xf ~/Downloads/llvm-3.9.0.src.tar.xz -C .
tar -xf ~/Downloads/cfe-3.9.0.src.tar.xz -C .; mv cfe-3.9.0.src llvm-3.9.0.src/tools/clang
tar -xf ~/Downloads/clang-tools-extra-3.9.0.src.tar.xz -C .; mv clang-tools-extra-3.9.0.src llvm-3.9.0.src/tools/clang/tools/extra
tar -xf ~/Downloads/compiler-rt-3.9.0.src.tar.xz -C .; mv compiler-rt-3.9.0.src llvm-3.9.0.src/projects/compiler-rt
tar -xf ~/Downloads/libcxx-3.9.0.src.tar.xz -C .; mv libcxx-3.9.0.src llvm-3.9.0.src/projects/libcxx
tar -xf ~/Downloads/libcxxabi-3.9.0.src.tar.xz -C .; mv libcxxabi-3.9.0.src llvm-3.9.0.src/projects/libcxxabi
tar -xf ~/Downloads/openmp-3.9.0.src.tar.xz -C .; mv openmp-3.9.0.src llvm-3.9.0.src/projects/openmp

With all the packages downloaded and moved to their proper locations, we can configure LLVM:

mkdir ~/projects/src/llvm-build
cd ~/projects/src/llvm-build


As long as no problems were detected during configure, proceed to building LLVM:

cd ~/projects/src/llvm-build
make -j $MOOSE_JOBS

Sill no problems? Then proceed to installing LLVM:

cd ~/projects/src/llvm-build
sudo -E make install

Verify you have correctly built/installed Clang by performing the following command:

which clang

If the above command does not return /opt/moose/clang_3.9.0/bin/clang then something went wrong and you should not proceed until this is fixed. Otherwise it will be a wast of time...

There is one final step that needs to take place now that Clang has been installed properly. Due to Mac OSX Yosemite (and later) removing the ability for us to set DYLD_LIBRARY_PATHs, we need to create a symbolic link to the OpenMP library that was built:

sudo mkdir -p /usr/local/lib
cd /usr/local/lib
sudo ln -s $CLANG_HOME/lib/libomp.dylib .

4. MPICH 3.2

We recommend compiling and using MPICH for your MPI needs.
Download mpich-3.2. Once downloaded, perform the following:

cd ~/projects/src
tar -xf ~/Downloads/mpich-3.2.tar.gz -C .
mkdir ~/projects/src/mpich-3.2/clang-opt
cd ~/projects/src/mpich-3.2/clang-opt

../configure --prefix=$MPI_HOME --enable-shared --enable-sharedlibs=clang --enable-fast=03 \
--enable-debuginfo --enable-totalview --enable-two-level-namespace CC=clang CXX=clang++ \
FC=gfortran F77=gfortran F90='' CFLAGS='' CXXFLAGS='' FFLAGS='' FCFLAGS='' F90FLAGS='' F77FLAGS=''

make -j $MOOSE_JOBS
sudo -E make install

Verify you have correctly built/installed MPICH by performing the following command:

which mpicc

If the above command does not return /opt/moose/mpich/mpich_3.2/bin/mpicc then something went wrong and you should not proceed until this is fixed. Otherwise it will be a wast of time...

5. PETSc

PETSc is our preferred linear and nonlinear solver package for MOOSE. If you are on a Linux system avoid getting a package distribution of PETSc because it may not come configured the way we want. Specifically it will most likely NOT be compiled with HYPRE support and will likely be tied to a different MPI installation.

Download petsc-3.7.5.tar.gz. Once downloaded, perform the following:

tar -xf ~/Downloads/petsc-3.7.5.tar.gz -C ~/projects/src
cd ~/projects/src/petsc-3.7.5

Note: If you downloaded PETSc via Safari, it is possible Safari extracted the petsc-3.7.5.tar file within it. If you receive a 'file not found error', try the same command above again, but with out the '.gz' suffix.

./configure \
--prefix=$PETSC_DIR \
--download-hypre=1 \
--with-ssl=0 \
--with-debugging=no \
--with-pic=1 \
--with-shared-libraries=1 \
--with-cc=mpicc \
--with-cxx=mpicxx \
--with-fc=mpif90 \
--download-fblaslapack=1 \
--download-metis=1 \
--download-parmetis=1 \
--download-superlu_dist=1 \
--download-mumps=1 \
--download-scalapack=1 \
CC=mpicc CXX=mpicxx FC=mpif90 F77=mpif77 F90=mpif90 \
CFLAGS='-fPIC -fopenmp' \
CXXFLAGS='-fPIC -fopenmp' \
FFLAGS='-fPIC -fopenmp' \
FCFLAGS='-fPIC -fopenmp' \
F90FLAGS='-fPIC -fopenmp' \
F77FLAGS='-fPIC -fopenmp' \
  • You may be asked for your password during configure. This is because the above configure command is downloading and installing additional components needed (blas, lapack, etc).
  • Once configure has completed, follow the on-screen 'make' instructions, which will be specific to your machine.
  • Once make has completed, follow the on-screen 'make install' instructions, which will be specific to your machine. Be ready needing to use 'sudo' for the final step.

6. Peacock

Note: If you follow these instructions, know that your Python environment will change. Only follow step 6, if you would like to use Peacock, the MOOSE GUI.

Download the Miniconda installer and install it:

cd ~/projects/src
curl -L -O
sudo -E bash -b -p $PACKAGES_DIR/miniconda
export PATH=$PACKAGES_DIR/miniconda/bin:$PATH

Install the following conda applications:

sudo -E conda update conda
sudo -E conda install -c idaholab python=2.7 matplotlib pandas numpy scikit-image mock scipy coverage yaml pyyaml pyqt pyflakes vtk=7.1.0 --yes

7. Finalizing

Close any running terminals (really just the one you were performing all of the above instructions from) and re-open them. This allow everything we just did, do be available for use.

That's it! We recommend that you browse your $PACKAGE_DIR directory and make sure that you see each of the library directories in there (GCC, clang, mpich, PETSc and miniconda if you choose to do Step 6). If not then you've probably done something wrong. Take a look back at the directions above and see what steps you may have missed. Otherwise you are set to continue on with Step #2 in the Getting Started Instructions