Difference between revisions of "Building on Mac High Sierra"
Line 64: | Line 64: | ||
Download the [http://ftp.mcs.anl.gov/pub/petsc/release-snapshots/petsc-3.8.4.tar.gz PETSc source]. It is recommended to unpack this in the | Download the [http://ftp.mcs.anl.gov/pub/petsc/release-snapshots/petsc-3.8.4.tar.gz PETSc source]. It is recommended to unpack this in the | ||
− | installation directory (<code><span style="color:red">$HOME/gridpack</span></code>). PETSc configuration requires that the <code>PETSC_DIR</code> environment variable be set before configuration. If using a Bourne-based shell, like the Mac OS X default <code>/bin/bash</code>, | + | installation directory (<code><span style="color:red">$HOME/gridpack</span></code>). PETSc configuration requires that the <code>PETSC_DIR</code> environment variable be set before configuration. Set the <code>PETSC_DIR</code> to the directory it which the PETSc source was unpacked. If using a Bourne-based shell, like the Mac OS X default <code>/bin/bash</code>, do something like |
PETSC_DIR=<span style="color:red">$HOME/gridpack/petsc-3.8.4</span> | PETSC_DIR=<span style="color:red">$HOME/gridpack/petsc-3.8.4</span> | ||
export PETSC_DIR | export PETSC_DIR | ||
− | Or, if using a C-shell | + | Or, if using a C-shell, |
setenv PETSC_DIR <span style="color:red">$HOME/gridpack/petsc-3.8.4</span> | setenv PETSC_DIR <span style="color:red">$HOME/gridpack/petsc-3.8.4</span> |
Revision as of 15:29, 20 September 2018
This page is currently under development. Please excuse inconsistencies.
This details the building of GridPACK on a Macbook Pro running Mac OS X High Sierra (10.13.6). The build was aided by the use of MacPorts to install some prerequisite software. Super user permissions are required to install and manage MacPorts.
These instructions use a specific combination of compilers, MPI implementation, and MacPorts packages. Other combinations can be used, the one here happened to work for the author. If you choose some other combination, you're on your own.
The author uses the C-shell. These instructions will need to be
slightly modified to adapt to another shell, like bash
.
Contents
MacPorts
The easiest way to get GridPACK going on Mac OS X is to use MacPorts to install (some of) the needed prerequisite software. MacPorts is free, open source system whereby various software packages can be installed and maintained on a Mac OS X system. Homebrew provides a similar capability, but the author has no experience with it.
The MacPorts project provides very good
installation instructions. They will not be repeated here. It is
assumed here that MacPorts was installed in /opt/local
, which is the
default.
After MacPorts installation, /opt/local/bin
needs to be in shell
search path. The easiest way to do this is to add /opt/local/bin
to
the top of /etc/paths
(superuser privileges required). Afterward, a reboot or
starting a new shell should make the port
command available on the
command line.
Packages from MacPorts
Install the CLang 6.0 compiler set, mpich MPI implementation, and Boost with Boost.MPI using the following:
sudo port install boost +clang60+mpich
Make the installed compilers and MPI wrappers the default.
sudo port select --set clang mp-clang-6.0 sudo port select --set mpi mpich-clang60-fortran
That way the compiler commands, clang
and clang++
, and MPI compiler
wrappers, like mpicc
, will be available at the command line.
Install CMake and the GNU linear programming kit:
sudo port install cmake sudo port install glpk
Build Packages from Source
PETSc and Global Arrays need to be built from source. You need to
choose a path in which packages will be installed. Here the author
decided to use a single installation directory, $HOME/gridpack
. Directories or architecture variables that should be set to reflect local user environments are colored red.
PETSc, version 3.8.4
Download the PETSc source. It is recommended to unpack this in the
installation directory ($HOME/gridpack
). PETSc configuration requires that the PETSC_DIR
environment variable be set before configuration. Set the PETSC_DIR
to the directory it which the PETSc source was unpacked. If using a Bourne-based shell, like the Mac OS X default /bin/bash
, do something like
PETSC_DIR=$HOME/gridpack/petsc-3.8.4
export PETSC_DIR
Or, if using a C-shell,
setenv PETSC_DIR $HOME/gridpack/petsc-3.8.4
Change into the PETSc source directory and configure and build PETSc using
cd $PETSC_DIR ./configure \ PETSC_ARCH=arch-macosx-clang-real-opt \ COPTFLAGS="-g -O2" \ CXXOPTFLAGS="-g -O2" \ FOPTFLAGS="-g -O2" \ --with-prefix="$HOME/gridpack" \ --with-mpi=1 \ --with-gnu-compilers=0 \ --with-cc=/opt/local/bin/mpicc \ --with-fc=/opt/local/bin/mpif90 \ --with-cxx=/opt/local/bin/mpicxx \ --with-clanguage=c++ \ --with-fortran-bindings=0 \ --with-scalar-type=real \ --with-precision=double \ --download-suitesparse=1 \ --download-superlu_dist=1 \ --download-parmetis=1 \ --download-metis=1 \ --download-f2cblaslapack=1 \ --download-mumps=0 \ --download-scalapack=1 \ --with-shared-libraries=0 \ --with-x=0 \ --with-valgrind=0 \ --with-mpiexec=mpiexec \ --with-debugging=0 make PETSC_DIR=$HOME/gridpack/petsc-3.8.4 PETSC_ARCH=arch-macosx-clang-real-opt all make PETSC_DIR=$HOME/gridpack/petsc-3.8.4 PETSC_ARCH=arch-macosx-clang-real-opt test
Global Arrays, version 5.7
Download the source from here and unpack in a convenient location. Change into the unpacked directory and configure, build, and install Global Arrays like this
mkdir build
cd build
../configure \
--enable-cxx \
--disable-f77 \
--enable-i4 \
--with-mpi \
--with-mpi-ts \
--enable-autodetect=yes \
--prefix="$HOME/gridpack" \
--without-blas \
--without-lapack \
--without-scalapack \
--enable-shared=no \
--enable-static=yes \
MPICC=mpicc MPICXX=mpicxx MPIF77=mpif90 \
MPIEXEC=mpiexec MPIRUN=mpirun \
LDFLAGS="-L/opt/local/lib"
make
make install
GridPACK
CMake will work very hard to choose the wrong compiler. Make sure it uses the correct compiler by setting environment variables as follows, in a Bourne-like shell,
CC=/opt/local/bin/clang CXX=/opt/local/bin/clang++ export CC CXX
Or it a C-shell,
setenv CC /opt/local/bin/clang setenv CXX /opt/local/bin/clang++
Either download the GridPACK source from the GridPACK release page and unpack it in a convenient location or clone the GridPACK GitHub repository. Change into the GridPACK source directory and make a place to build GridPACK. Then, change into that directory, e.g.:
cd $HOME/gridpack/src/GridPACK
mkdir src/build
cd src/build
Configure, build, and test GridPACK with
rm -rf CMake* cmake \ -D GA_DIR:STRING="$HOME/gridpack" \ -D BOOST_ROOT:STRING="/opt/local" \ -D PETSC_DIR:PATH="$HOME/gridpack/petsc-3.8.4" \ -D PETSC_ARCH:STRING="arch-macosx-clang-real-opt" \ -D MPI_CXX_COMPILER:STRING='/opt/local/bin/mpicxx' \ -D MPI_C_COMPILER:STRING='/opt/local/bin/mpicc' \ -D MPIEXEC:STRING='/opt/local/bin/mpiexec' \ -D MPIEXEC_MAX_NUMPROCS:STRING="2" \ -D GRIDPACK_TEST_TIMEOUT:STRING=30 \ -D USE_GLPK:BOOL=ON \ -D GLPK_ROOT_DIR:PATH="/opt/local" \ -D CMAKE_INSTALL_PREFIX:PATH="$HOME/gridpack" \ .. make make test
Observations
It appears that at the time of writing the OpenMPI ports are not Boost or PETSc compatible. Stick with mpich.
Boost.MPI compiled with the stock XCode C++ compiler seems to have trouble with serialization needed in the GridPACK code. This may or may not be a real issue. Little effort was expended to track it down, since Boost.MPI appears to work fine on Mac OS X if compiled with another CLang-based compiler.
MacPorts does have a PETSc package, but it will not work for GridPACK because it does not have the required C++ support built in.
PETSc must be later than 3.8. Versions 3.7.x do not configure properly with up to date XCode. This is a known issue that was fixed in 3.8.x.