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.
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
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
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
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
unzip OpenBLAS-0.2.18.zip
and go to the folder
cd OpenBLAS-0.2.18
and compile the library with
make USE_THREAD=0
and install it
make PREFIX=/Users/<username>/vaspbuild/openblas-0.2.18 install
More information about compiling and installing OpenBLAS can be found here.
$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
BLAS_Accelerate_LIBRARY:FILEPATH=/System/Library/Frameworks/Accelerate.framework
with
BLAS_Accelerate_LIBRARY:FILEPATH=/Users//vaspbuild/openblas-0.2.18/lib/libopenblas.dylib
and as well around line 253 we have to replace,
LAPACK_Accelerate_LIBRARY:FILEPATH=/System/Library/Frameworks/Accelerate.framework
with
LAPACK_Accelerate_LIBRARY:FILEPATH=/Users//vaspbuild-openblas/0.2.18/lib/libopenblas.dylib
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
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
$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 \
/Users//vaspbuild/fftw/3.3.4/lib/libfftw3.a
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
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