This tutorial will explain how to install VASP 5.3.5 on a Linux Ubuntu system. I used the latest version at hand (14.04 LTS) and started with a fresh install (in a Virtualbox environment). This tutorial is to a large extend based on the previous work of Peter Larsson.
This tutorial also works for Debian 8. For Debian 7, you need to use different packages in step 1, but the same procedure holds.
For installing VASP 4.6.38, you can refer to my previous blogpost. In that post, I got some comments regarding how to install VASP 5, this post is therefore also (more-or-less) an answer to these questions.
This tutorial proceeds in 4 steps:
sudo apt-get install build-essential gfortran libopenmpi-dev libopenmpi1.6 openmpi1.6 libfftw3-double3 libfftw3-single3 libfftw3-dev git
From here on, I will assume that everything is compiled in its own build directory. For convenience, let's declare a variable to hold this path.
export BUILDPATH=$HOME/vaspbuild mkdir $BUILDPATH cd $BUILDPATH
The latest version of OpenBLAS can be readily obtained via the command below:
git clone https://github.com/xianyi/OpenBLAS.git --depth 1
To compile OpenBLAS run:
cd $BUILDPATH/OpenBLAS make FC=gfortran CC=gcc USE_THREAD=0
This will generate a file called libopenblas.a. We will use this file for the compilation of scaLAPACK as well as VASP.
cd $BUILDPATH wget http://www.netlib.org/scalapack/scalapack-2.0.2.tgz tar -xvzf scalapack-2.0.2.tgz cd $BUILDPATH/scalapack-2.0.2 cp SLmake.inc.example SLmake.inc
We are going to make a few modifications to SLmake.inc in order to properly link everything to our version of OpenBLAS. To do so, let BLASLIB refer to our OpenBLAS library. Because OpenBLAS also contains LAPACK routines, refer LAPACKLIB to BLASLIB.
BLASLIB = -L/home/$USER/vaspbuild/OpenBLAS -lopenblas LAPACKLIB = $(BLASLIB) LIBS = $(LAPACKLIB) $(BLASLIB)
Then, in order to compile everything, simply type
This will generate a library file called libscalapack.a.
Now, we have everything to build VASP.
I assume you have extracted the two VASP packages (vasp5.lib.tar.gz and vasp5.tar.gz) in the build folder. Compiling the library part of VASP is easy.
cd $BUILDPATH/vasp.5.lib cp Makefile.linux_gfortran Makefile make
Building the other part is somewhat more difficult and requires a bit of tweaking and fixing some things. Start by copying the template makefile.
cd $BUILDPATH/vasp.5.3 cp Makefile.linux_gfortran Makefile
Next, we are going to change some directives in the makefile. Open the Makefile with your favorite text editor.
First, remove the -C part from the CPP line, like so:
CPP_ = ./preprocess <$*.F | /usr/bin/cpp -P -traditional >$*$(SUFFIX)
Next, we are going to comment the last line of the FPP block.
# this release should be fpp clean # we now recommend fpp as preprocessor # if this fails go back to cpp # CPP_=fpp -f_com=no -free -w0 $*.F $*$(SUFFIX)
Scroll down to the FFLAGS directive and change it to:
FFLAGS =-ffree-form -ffree-line-length-0
Note that there has to be a space after the 0!!
Now scroll further down to the part mentioning MPI section.
Uncomment the FC and FCL line and change mpif77 to mpif90, like so:
Uncomment the whole block for CPP and add -DMPI and -DscaLAPACK to the block, like so:
CPP = $(CPP_) -DHOST=\"gfortran\" \ -DCACHE_SIZE=4096 -DMINLOOP=1 -DNGZhalf \ -DMPI_BLOCK=8000 -DMPI -DscaLAPACK
Add our version of scaLAPACK to the SCA variable and create a reference to our version of BLAS and LAPACK:
SCA=/home/$USER/vaspbuild/scalapack-2.0.2/libscalapack.a BLAS=/home/$USER/vaspbuild/OpenBLAS/libopenblas.a LAPACK=/home/$USER/vaspbuild/OpenBLAS/libopenblas.a
Uncomment the lines for the LIB and the (second!) FFT3D variables in the libraries for MPI block. Refer to the fftw3 library of the OS. (last part of the FFT3D line)
LIB = -fall-intrinsics \ -L../vasp.5.lib -ldmy \ ../vasp.5.lib/linpack_double.o $(LAPACK) \ $(SCA) $(BLAS) # FFT: fftmpi.o with fft3dlib of Juergen Furthmueller # FFT3D = fftmpi.o fftmpi_map.o fft3dfurth.o fft3dlib.o # alternatively: fftw.3.1.X is slighly faster and should be used if available FFT3D = fftmpiw.o fftmpi_map.o fftw3d.o fft3dlib.o /usr/lib/x86_64-linux-gnu/libfftw3.a
When you would now start to compile VASP by typing
make, you would encounter an error like the following:
us.f90:1403.10: USE us 1 Error: 'setdij' of module 'us', imported at (1), is also the name of the current program unit
The way to resolve this error, is by changing the names. The way we are going to do that, is by applying a patch to this file. You can download the patch file here. Just place it in the same directory as where the VASP sources reside and apply the patch by typing:
wget http://www.ivofilot.nl/downloads/vasp535.patch patch -p0 < vasp535.patch
This will change the names automatically. You will receive a message such as
patching file us.F
make, the compilation will resume. The next error we are going to encounter is
fftmpiw.f90:70: Error: Can't open included file 'fftw3.f'
The way to resolve this error is by copying our system's version of fftw3.h to the source folder like so
cp /usr/include/fftw3.f .
(note that all .f files get removed after a
Now, everything should compile perfectly. Type
make again and the
vasp executable will be generated.