Skip to content

Compiling on Mac OS X

Tim Greaves edited this page Jun 18, 2014 · 3 revisions

WARNING: This is a new page and currently untested! Use at your own risk.

Compiling Fluidity on Mac OS X/Darwin

Darwin, the underlying POSIX-compilant base of the Mac operating system is itself built round BSD, which makes it possible (though not trivial) to build and run the fluidity binary on a mac. Unfortunately the default apple compilers that Macs ship with aren't supported by fluidity and aren't sufficiently modern to compile the the fluidity source code and supporting software. As such, it is necessary to install elements of the GNU toolchain onto the machine to build fluidity successfully. Multiple package managers exist which make this task much easier. Two of the more popular package managers are MacPorts and Fink

For MacPorts Users

Core requirements are GCC 4.6 and openmpi. Both of these can be obtained by running the following command in a terminal window (as a user with suitable authority)

 port install openmpi +gcc46

Once installed, it is useful to set a few additional Environment variables so that the correct compilers are always used:

 export OMPI_CXX=/opt/local/bin/g++-mp-4.6
 export OMPI_CC=/opt/local/bin/gcc-mp-4.6
 export OMPI_F77=/opt/local/bin/gfortran-mp-4.6
 export OMPI_FC=/opt/local/bin/gfortran-mp-4.6

These commands can be included in ~/.profile or ~/.bash_rc etc. to ensure the variables are always set correctly. Users who have Macport package installed in a location other than /opt/local will need to make the obvious changes.

Other necessary supporting software under macports includes:

  • gmsh 2.5.1 (meshing program):

port install gmsh-devel

  • VTK 5.8:

port install vtk-5

  • BZR:

port install bzr

Other useful supporting software under macports includes:

  • Valgrind:

port install valgrind

  • various python pacakges including Numpy (python numerical support package):

port install py27-numpy py27-tkinter py27-dateutil py27-sympy

  • UDUnits:

port install udunits

  • CGAL:

port install cgal

  • NetCDF:

port install netcdf netcdf-cxx netcdf-fortran

Unfortunately the default petsc build that is included in Macports doesn't have the full support that fluidity requires to build successfully. The commands to compile by hand are set below:

For Fink Users

== Building petsc ==

First download and unpack the latest petsc-3.3 patch from the website, then, in the root directory of the unpacked files run configure with

./configure --with-python --with-debugging=1
            --with-c-support=1 --with-c++-support=1
            --with-shared-libraries=0 --with-pic=fpic
            --with-mpi=1 --prefix=/usr/amcg
            --with-mpi-dir=/opt/local/lib/openmpi
            --with-lapack-lib=/usr/lib/liblapack.dylib
             --with-blas-lib=/usr/lib/libblas.dylib
             --download-umfpack=1 --download-ml --download-blacs
             --download-scalapack --download-mumps
             --download-ptscotch --download-hypre
             --with-fortran-interfaces=1 --download-prometheus
             --download-parmetis --download-metis

Replace /usr/amcg with an alternative location if you have a preference.

then follow the instructions given by the configure program to make, install and test. Finally set

export PETSC_DIR=/usr/amcg

changing the path as necesary.

== Building zoltan ==

First apply the patch given in on the Fluidity support page, then run configure with:

 ./configure x86_64-darwin-gnu --prefix=/usr/amcg --enable-mpi --with-mpi-compilers  --with-gnumake\
                                  --enable-zoltan --with-parmetis --enable-f90interface\
                                  --enable-zoltan-cppdriver --disable-examples --with-parmetis-libdir=/usr/amcg

Finally run

 make 
 make install

== Building Fluidity ==

First download the mac-modified branch via bzr with

bzr branch lp:~j-percival/fluidity/fluidty-darwin-port

now change to that directory and run

 ./configure F77=mpif90 FC=mpif90 CXX=mpicxx CC=mpicc\
         CXXFLAGS="-I$PETSC_DIR/include I/opt/local/include/vtk-5.10"\
         LIBS="-L$PETSC_DIR/lib -L/opt/local/lib/vtk-5.10" --enable-2d-adaptivity\
         --with-blas-dir=$PETSC_DIR --with-lapack-dir=$PETSC_DIR\
         --with-ParMetis=$PETSC_DIR LDFLAGS="-L$PETSC_DIR -lprometheus -lpromfei"
Clone this wiki locally