Difference between revisions of "Building on Mac High Sierra"

From GridPACK
Jump to: navigation, search
 
(12 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 11: Line 11:
 
used, the one here happened to work for the author.  If you choose
 
used, the one here happened to work for the author.  If you choose
 
some other combination, you're on your own.
 
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".
  
 
== MacPorts ==
 
== MacPorts ==
Line 23: 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 43: Line 45:
 
  sudo port select --set mpi mpich-clang60-fortran
 
  sudo port select --set mpi mpich-clang60-fortran
  
That way the compiler commands, <code>clang</code> and <code>clang++</code>, and MPI compiler
+
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 69: Line 71:
  
 
  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>
 +
 +
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]
 
Change into the PETSc source directory and configure and build [http://www.mcs.anl.gov/petsc/ PETSc]
Line 103: Line 107:
 
  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=<span style="color:red">$HOME/gridpack/petsc-3.8.4</span> 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 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 ===
Line 145: Line 148:
 
  setenv CXX /opt/local/bin/clang++
 
  setenv CXX /opt/local/bin/clang++
  
In a convenient directory, like <code><span style="color:red">$HOME/gridpack/src</span></code>, either download the GridPACK source from the [https://github.com/GridOPTICS/GridPACK/releases GridPACK release page] and unpack it in a convenient location, or clone the [https://github.com/GridOPTICS/GridPACK GridPACK GitHub repository]. Change into the GridPACK source directory and make a place to build GridPACK. Then, change into that directory, e.g.:
+
[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>.  
  
cd <span style="color:red">$HOME/gridpack/src/GridPACK</span>
+
In the build directory (<tt>src/build</tt> here), configure, build, and test GridPACK with
mkdir src/build
 
cd src/build
 
 
 
Configure, build, and test GridPACK with
 
  
 
  rm -rf CMake*
 
  rm -rf CMake*
Line 169: Line 168:
 
     ..
 
     ..
 
  make
 
  make
  make test
+
 
 +
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".

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.