Difference between revisions of "Building on Mac High Sierra"
(16 intermediate revisions by 2 users not shown) | |||
Line 4: | Line 4: | ||
This details the building of GridPACK on a Macbook Pro running Mac OS | 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 [https://www.macports.org/ MacPorts] | X High Sierra (10.13.6). The build was aided by the use of [https://www.macports.org/ MacPorts] | ||
− | to install some prerequisite software. Super user permissions are | + | to install some prerequisite software. Super user or sudo permissions are |
− | required to install and manage [https://www.macports.org/ MacPorts]. | + | required to install and manage [https://www.macports.org/ MacPorts], but should not be required for any other task. |
These instructions use a specific combination of compilers, MPI | These instructions use a specific combination of compilers, MPI | ||
Line 12: | Line 12: | ||
some other combination, you're on your own. | some other combination, you're on your own. | ||
− | The | + | The instructions below can be executed in a terminal. To bring one up, go under the "Utilities" folder in the application tray at the bottom of the screen and click on "Terminal". |
− | |||
== MacPorts == | == MacPorts == | ||
Line 26: | Line 25: | ||
[https://www.macports.org/install.php installation instructions]. They will not be repeated here. It is | [https://www.macports.org/install.php installation instructions]. They will not be repeated here. It is | ||
assumed here that [https://www.macports.org/ MacPorts] was installed in <code>/opt/local</code>, which is the | assumed here that [https://www.macports.org/ MacPorts] was installed in <code>/opt/local</code>, which is the | ||
− | default. | + | default. Most systems support <code>rsync</code>, but if yours doesn't because of firewall issues, additional information and some workarounds can be found [https://trac.macports.org/wiki/FAQ#selfupdatefails here]. |
After [https://www.macports.org/ MacPorts] installation, <code>/opt/local/bin</code> needs to be in shell | After [https://www.macports.org/ MacPorts] installation, <code>/opt/local/bin</code> needs to be in shell | ||
Line 46: | Line 45: | ||
sudo port select --set mpi mpich-clang60-fortran | sudo port select --set mpi mpich-clang60-fortran | ||
− | + | At this point, the compiler commands, <code>clang</code> and <code>clang++</code>, and MPI compiler | |
wrappers, like <code>mpicc</code>, will be available at the command line. | wrappers, like <code>mpicc</code>, will be available at the command line. | ||
Line 58: | Line 57: | ||
[http://www.mcs.anl.gov/petsc/ PETSc] and [http://www.emsl.pnl.gov/docs/global/ Global Arrays] need to be built from source. You need to | [http://www.mcs.anl.gov/petsc/ PETSc] and [http://www.emsl.pnl.gov/docs/global/ Global Arrays] need to be built from source. You need to | ||
choose a path in which packages will be installed. Here the author | choose a path in which packages will be installed. Here the author | ||
− | decided to use <code>$HOME/gridpack</code> | + | decided to use a single installation directory, <span style="color:red"><code>$HOME/gridpack</code></span>. Directories or architecture variables that should be set to reflect local user environments are colored <span style="color:red">red</span>. |
+ | |||
=== PETSc, version 3.8.4 === | === PETSc, version 3.8.4 === | ||
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>$HOME/gridpack</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> | ||
+ | export PETSC_DIR | ||
+ | |||
+ | Or, if using a C-shell, | ||
+ | |||
+ | setenv PETSC_DIR <span style="color:red">$HOME/gridpack/petsc-3.8.4</span> | ||
+ | |||
+ | Some users encountered significant problems building PETSc, which seems to be related to using a newer version of Xcode. If you have problems configuring or compiling PETSc, you may be able to fix them by making the modifications described on our [[Troubleshooting_GridPACK_Builds#PETSc | troubleshooting page]]. | ||
+ | |||
+ | Change into the PETSc source directory and configure and build [http://www.mcs.anl.gov/petsc/ PETSc] | ||
using | using | ||
− | + | cd $PETSC_DIR | |
− | |||
./configure \ | ./configure \ | ||
PETSC_ARCH=arch-macosx-clang-real-opt \ | PETSC_ARCH=arch-macosx-clang-real-opt \ | ||
Line 73: | Line 83: | ||
CXXOPTFLAGS="-g -O2" \ | CXXOPTFLAGS="-g -O2" \ | ||
FOPTFLAGS="-g -O2" \ | FOPTFLAGS="-g -O2" \ | ||
− | --with-prefix="/ | + | --with-prefix="<span style="color:red">$HOME/gridpack</span>" \ |
--with-mpi=1 \ | --with-mpi=1 \ | ||
--with-gnu-compilers=0 \ | --with-gnu-compilers=0 \ | ||
Line 95: | Line 105: | ||
--with-mpiexec=mpiexec \ | --with-mpiexec=mpiexec \ | ||
--with-debugging=0 | --with-debugging=0 | ||
− | make PETSC_DIR=$HOME/gridpack/petsc-3.8.4 PETSC_ARCH=arch-macosx-clang-real-opt all | + | make PETSC_DIR=<span style="color:red">$HOME/gridpack/petsc-3.8.4</span> 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 | + | make PETSC_DIR=<span style="color:red">$HOME/gridpack/petsc-3.8.4</span> PETSC_ARCH=arch-macosx-clang-real-opt test |
− | |||
=== Global Arrays, version 5.7 === | === Global Arrays, version 5.7 === | ||
− | Download the source from [https://github.com/GlobalArrays/ga/releases/download/v5.7/ga-5.7.tar.gz here] and unpack in a convenient location. | + | Download the source from [https://github.com/GlobalArrays/ga/releases/download/v5.7/ga-5.7.tar.gz here] and unpack in a convenient location. Change into |
− | the unpacked directory | + | the unpacked directory and configure, build, and install [http://www.emsl.pnl.gov/docs/global/ Global Arrays] like this |
mkdir build | mkdir build | ||
Line 113: | Line 122: | ||
--with-mpi-ts \ | --with-mpi-ts \ | ||
--enable-autodetect=yes \ | --enable-autodetect=yes \ | ||
− | --prefix="$HOME/gridpack" \ | + | --prefix="<span style="color:red">$HOME/gridpack</span>" \ |
--without-blas \ | --without-blas \ | ||
--without-lapack \ | --without-lapack \ | ||
Line 128: | Line 137: | ||
CMake will work very hard to choose the wrong compiler. Make sure it | CMake will work very hard to choose the wrong compiler. Make sure it | ||
− | uses the correct compiler by setting environment variables as follows | + | 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 in a C-shell, | ||
setenv CC /opt/local/bin/clang | setenv CC /opt/local/bin/clang | ||
setenv CXX /opt/local/bin/clang++ | setenv CXX /opt/local/bin/clang++ | ||
− | + | [https://www.gridpack.org/wiki/index.php/Download_GridPACK Obtain the GridPACK release or development code] and put it in a convenient directory, like <code><span style="color:red">$HOME/gridpack/src</span></code>. | |
+ | In the build directory (<tt>src/build</tt> here), configure, build, and test GridPACK with | ||
rm -rf CMake* | rm -rf CMake* | ||
Line 140: | Line 156: | ||
-D GA_DIR:STRING="$HOME/gridpack" \ | -D GA_DIR:STRING="$HOME/gridpack" \ | ||
-D BOOST_ROOT:STRING="/opt/local" \ | -D BOOST_ROOT:STRING="/opt/local" \ | ||
− | -D PETSC_DIR:PATH="$HOME/gridpack/petsc-3.8.4" \ | + | -D PETSC_DIR:PATH="<span style="color:red">$HOME/gridpack/petsc-3.8.4</span>" \ |
-D PETSC_ARCH:STRING="arch-macosx-clang-real-opt" \ | -D PETSC_ARCH:STRING="arch-macosx-clang-real-opt" \ | ||
-D MPI_CXX_COMPILER:STRING='/opt/local/bin/mpicxx' \ | -D MPI_CXX_COMPILER:STRING='/opt/local/bin/mpicxx' \ | ||
Line 149: | Line 165: | ||
-D USE_GLPK:BOOL=ON \ | -D USE_GLPK:BOOL=ON \ | ||
-D GLPK_ROOT_DIR:PATH="/opt/local" \ | -D GLPK_ROOT_DIR:PATH="/opt/local" \ | ||
− | -D CMAKE_INSTALL_PREFIX:PATH="$HOME/gridpack" \ | + | -D CMAKE_INSTALL_PREFIX:PATH="<span style="color:red">$HOME/gridpack</span>" \ |
.. | .. | ||
make | make | ||
− | + | ||
+ | If compilation is successful, the [[How to Build GridPACK#Running Tests|unit tests]] and/or [[How to Build GridPACK#Running_the_Powerflow_Example.28s.29|example applications]] can be run. | ||
Latest revision as of 15:17, 9 May 2019
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 or sudo permissions are required to install and manage MacPorts, but should not be required for any other task.
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 instructions below can be executed in a terminal. To bring one up, go under the "Utilities" folder in the application tray at the bottom of the screen and click on "Terminal".
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. Most systems support rsync
, but if yours doesn't because of firewall issues, additional information and some workarounds can be found here.
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
At this point, 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
Some users encountered significant problems building PETSc, which seems to be related to using a newer version of Xcode. If you have problems configuring or compiling PETSc, you may be able to fix them by making the modifications described on our troubleshooting page.
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 in a C-shell,
setenv CC /opt/local/bin/clang setenv CXX /opt/local/bin/clang++
Obtain the GridPACK release or development code and put it in a convenient directory, like $HOME/gridpack/src
.
In the build directory (src/build here), 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
If compilation is successful, the unit tests and/or example applications can be run.
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.