Compiling octopus in OS X
- 1 Installation of octopus package from MacPorts
- 2 Installing the GNU compilers and tools
- 3 Installing required libraries
- 4 Installing optional libraries
- 5 Build serial version of octopus
- 6 Build parallel version of octopus
- 7 Build mpich2 (optional)
- 8 Build fftw
Installation of octopus package from MacPorts
You can now simply install an octopus package from MacPorts (). See info in the next section about installing MacPorts, and then you can just do
sudo port install fftw-3 +gfortran octopus
You can specify various variants for octopus as well, which specify some optional supporting libraries and the compilers used.
sudo port install octopus +gcc7 +openmpi +etsf_io +netcdf +sparskit +gdlib
Alternately, you can proceed with the full instructions to build by hand. This is probably not necessary unless you want to do development or install a pre-release version from svn.
Installing the GNU compilers and tools
Although OS X installs part of the GNU compiler tools automatically, it lacks a Fortran compiler. To install it one should use either macports, fink, or homebrew. These instructions always assume that you are using macports.
Install Macports according to these instructions: https://www.macports.org/install.php
Install gcc7 (or a different version of gcc if you prefer). To install the packages you just need to do
port selfupdate to get the most recent package database and then
port install gcc7. You'll have to login as root or use sudo to install packages. Leave your computer running and go for a looong coffee.
Installing required libraries
FFTW3 is available in the "fftw-3" port, which must have the Fortan interface enabled by selecting a Fortran variant (as below). GSL is available in the "gsl" port; the
+optimize variant may give you faster performance. libxc is available in the "libxc" port. Install as below. (If you like, you can first run
sudo port test ... for each, to run its testsuite; then do
install afterward if it succeeds.)
sudo port install fftw-3 +gfortran sudo port install gsl +optimize sudo port install libxc
For BLAS and LAPACK, the easiest is to install the very small port veclibfort, which is an interface to the built-in optimized Accelerate framework. If you like, you can also try the ports atlas, openBLAS, or openBLAS-devel, which possibly will give better performance, but can take a long time to install. For development, the automake, autoconf, and libtool (for libxc) ports are needed too.
Installing optional libraries
You may optionally install ports gd2, netcdf-fortran, sparskit, etsf_io, and an MPI implementation (mpich or openmpi).
If you want to build them by hand for some reason, you could continue as below. Set these environment variables before building the libraries:
export FC="gfortran-mp-7" export F77="gfortran-mp-7" export F90="gfortran-mp-7" export CC="gcc-mp-7" export CXX="g++-mp-7" export CPP="cpp-mp-7 -ansi" export FCCPP="cpp-mp-7 -ansi" export FCFLAGS="-O3 -I$HOME/include -L$HOME/lib" export FFLAGS="-O3 -I$HOME/include -L$HOME/lib" export F90FLAGS="-O3 -I$HOME/include -L$HOME/lib"
All these variables might be overkill, as most of the libraries read only one or two of them, but it's better to be safe than sorry ;-) Now, in order to build the other libraries you just need to follow the standard configure, make, make install sequence, as below.
Get etsf_io, untar it and cd to the directory where you untared it. Then type:
./configure --prefix=$HOME --with-netcdf-module-path=$HOME/include --with-netcdf-ldflags="-L$HOME/lib -lnetcdf" --with-moduledir=$HOME/include make install make check
Get SPARSKIT2, untar it and cd to the directory where you untared it. Then edit makefile and set F77=gfortran-mp-7. Save the makefile and type make. When compilation finishes just copy libskit.a to $HOME/lib.
Get netcdf, untar it and cd to the directory where you untared it. Then type:
./configure CPPFLAGS='-DpgiFortran' --disable-cxx --prefix=$HOME make make install
You can make check just to confirm that everything went OK.
Build serial version of octopus
Now you need to tell octopus' configure script about all the libraries you have just compiled:
./configure --prefix=$HOME --enable-gdlib --disable-mpi --with-netcdf-prefix=$HOME --with-sparskit=$HOME/lib/libskit.a --with-etsf-io-prefix=$HOME --with-blas=-lveclibfort --with-fft-lib="-L$HOME/lib -lfftw3" make install
For ATLAS, you would use "
Build parallel version of octopus
If you want to use all of your cores/cpus when running octopus, then you need to compile a parallel version of it. It is relatively straightforward. Install port
openmpi-default. Start by exporting the same environment variables as in the serial case. Then remember that you need to use the 'MPI' compilers, e.g
export CC=`which mpicc-mpich-mp` export FC=`which mpif90-mpich-mp`
You need to specify the full path to these compiler wrappers, otherwise octopus will use the system
mpif90, which will not work. Configure as above with the addition of
If you want to build your own versions of these libraries instead of using macports, see instructions below.
Build mpich2 (optional)
Get mpich2, untar it and cd to the directory where you untared it. Then type:
./configure --prefix=$HOME --enable-smpcoll --enable-f77 --enable-f90 --enable-cxx --enable-mpe --enable-sharedlibs=osx-gcc --enable-fast make make install
Get fftw, untar it and cd to the directory where you untared it. Then type:
./configure --prefix=$HOME --enable-shared --enable-sse2 --enable-static --enable-threads --with-combined-threads make make install
If you want to build fftw with MPI, add --enable-mpi to the configure line after changing these environment variables:
export FC="$HOME/bin/mpif90" export CC="$HOME/bin/mpicc"
Don't forget to change these variables back to their original values after compiling fftw.