How to compile VASP 5.4.1 on a MacBook running OS X El Capitan


This tutorial will explain how to install VASP 5.4.1 on a MacBook. As a small warning, note that this procedure will take quite some time, so make sure you do not need your MacBook for a couple of hours.

Step 0: Directories and settings

We are going to compile the source in the /Users/<username>/Downloads folder and install everything in /Users/<username>/vaspbuild. Note that you need to change with your current login (i.e. the name of your user account). Feel free to change any of these paths to suit your needs. Furthermore, in this tutorial, I will embed the ScaLAPACK, OpenBLAS and FFTW libraries in the executable.

Step 1: Installing the tool-chain

To install VASP, we are going to use MacPorts for our tool-chain. First, install MacPorts. On their website, they provide a set of instructions. Thereafter, run the following command to install GCC 4.9 with gfortran.

sudo port install gcc49 +gfortran

and install cmake as well as we are going to use it for building ScaLAPACK.

sudo port install cmake

Step 2: OpenMPI

Next, we are going to install OpenMPI. Go to their website and pick the latest version. At the time of this writing, this is version 1.10.3 and can be downloaded using this link.

Extract the archive

tar -xvjf openmpi-1.10.3.tar.bz2

go to the folder and configure it

cd openpmi-1.10.3

./configure --prefix=/Users/<username>/vaspbuild/openmpi-1.10.3

and compile and install it

make -j5 && make -j5 install

To use this version of OpenMPI for the compilation of VASP and ScaLAPACK, execute the following two commands

export PATH=/Users/<username>/vaspbuild/openmpi-1.10.3/bin:$PATH

export LD_LIBRARY_PATH=/Users/<username>/vaspbuild/openmpi-1.10.3/lib:$LD_LIBRARY_PATH

Step 3: OpenBLAS

Go to the website of OpenBLAS and download the latest version. At the time of this writing, this is version 0.2.18. Unzip the archive


and go to the folder

cd OpenBLAS-0.2.18

and compile the library with


and install it

make PREFIX=/Users/<username>/vaspbuild/openblas-0.2.18 install

More information about compiling and installing OpenBLAS can be found here.

Step 4: ScaLAPACK

Note: Make sure you have adjusted your $PATH and $LD_LIBRARY_PATH to use the version of OpenMPI we just built.

Download the latest version of ScaLAPACK from their website and extract the tarball.

tar -xvzf scalapack.tgz

Create a seperate build folder

mkdir spbuild && cd spbuild

and execute cmake

cmake ../scalapack-2.0.2

We need to make a few adjustments to CMakeCache.txt:

On line 18, replace




and as well around line 253 we have to replace,




Now we are ready to compile

make -j5

We are manually installing the library by copying it to an installation folder

mkdir -pv /Users/<username>/vaspbuild/scalapack-2.0.2/lib

cp -v lib/libscalapack.a /Users/<username>/vaspbuild/scalapack-2.0.2/lib

Step 5: FFTW

The last library we need to compile is FFTW. The procedure is fairly similar to how we compiled OpenMPI.

As usual, go to the website of FFTW and download the latest version.

Extract the archive

tar -xvzf fftw-3.3.4.tar.gz

and go to the folder. Therein, configure, build and install the library

./configure --prefix=/Users/<username>/vaspbuild/fftw-3.3.4

make -j5 && make -j5 install

Step 6: VASP

Note: Make sure you have adjusted your $PATH and $LD_LIBRARY_PATH to use the version of OpenMPI we just built.

Extract the VASP tarball, go to the source folder and copy the makefile.include for gfortran

cp arch/makefile.include.linux_gfortran makefile.include

We need to adjust part of the makefile.include so that it looks as follows:

BLAS       = 
LAPACK     = /Users//vaspbuild/openblas-0.2.18/lib/libopenblas.a
BLACS      = 
SCALAPACK  = /Users//vaspbuild/scalapack-2.0.2/lib/libscalapack.a

OBJECTS    = fftmpiw.o fftmpi_map.o  fftw3d.o  fft3dlib.o \
INCS       =-I/Users//vaspbuild/fftw/3.3.4/include

The first two references ensure that our recently built versions of OpenBLAS and ScaLAPACK are used to build VASP and the last few lines grab the header and library files from FFTW.

To compile the standard version (non-gamma-point version, run)

make std

For the gamma point version, you need to run

make gam

The binary files are written in the bin folder.

To check that our VASP executable only depend on OpenMPI, run otool -L bin/vasp_std and/or otool -L bin/vasp_gam.

For me, the result looks like this:

My-MacBook-Air:vasp.5.4.1 ivofilot$ otool -L bin/vasp_std 
    /Users/ivofilot/vaspbuild/openmpi-1.10.3/lib/libmpi_usempif08.11.dylib (compatibility version 13.0.0, current version 13.1.0)
    /Users/ivofilot/vaspbuild/openmpi-1.10.3/lib/libmpi_mpifh.12.dylib (compatibility version 13.0.0, current version 13.1.0)
    /Users/ivofilot/vaspbuild/openmpi-1.10.3/lib/libmpi.12.dylib (compatibility version 13.0.0, current version 13.3.0)
    /opt/local/lib/libgcc/libgfortran.3.dylib (compatibility version 4.0.0, current version 4.0.0)
    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1226.10.1)
    /opt/local/lib/libgcc/libgcc_s.1.dylib (compatibility version 1.0.0, current version 1.0.0)
    /opt/local/lib/libgcc/libquadmath.0.dylib (compatibility version 1.0.0, current version 1.0.0)

Let's place the VASP executable in the vaspbuild folder as well

cp -v bin/vasp_* /Users/<username>/vaspbuild/

In order to run and test VASP, create a seperate folder wherein your place the INCAR, POTCAR, POSCAR and KPOINTS files. From within that folder you run VASP (in this example using four threads) like so

mpirun -np 4 /Users/<username>/vaspbuild/vasp_std

If you have questions or comments, feel free to drop a line! Like what you read? Share this page with your friends and colleagues.


What is the answer to Three + Six?
Please answer with a whole number, i.e. 2, 3, 5, 8,...