How to compile VASP 5.4.1 for Linux Debian using the GNU compiler


This tutorial will explain how to install VASP 5.4.1 on a Linux Debian system. The developers of VASP have completely remade the compilation procedure. Personally, I believe they have done a marvelous job and the new compilation system will make compiling VASP significantly easier.

For installing VASP 4.6.38, you can refer to my previous blogpost.

If you are interested in compiling VASP 5.3.5 using the old procedure, have a look at this tutorial.

Step 1: Acquiring the necessary packages

sudo apt-get install build-essential libopenmpi-dev libfftw3-dev libblas-dev liblapack-dev libscalapack-mpi-dev libblacs-mpi-dev

Step 2: Extracting the VASP source tarball

Extract the VASP sources and go to the root directory of the VASP package.

tar -xvzf vasp.5.4.1.tar.gz
cd vasp.5.4.1

Step 3: Setting the build procedure

You need to copy the makefile corresponding to your build architecture. Here, I assume we are going to use the GNU compiler, so you need to copy the makefile for gfortran:

cp -v arch/makefile.include.linux_gfortran makefile.include

Step 4: Configuring the makefile

You need to tweak some directives in the Makefile to point the compiler to the right libraries and header files. For my Linux Debian system, I have used the following directives:

# Precompiler options
             -DCACHE_SIZE=4000 -Davoidalloc \
             -DMPI_BLOCK=8000 -DscaLAPACK -Duse_collective \
             -DnoAugXCmeta -Duse_bse_te \
             -Duse_shmem -Dtbdyn

CPP        = gcc -E -P -C $*$(FUFFIX) >$*$(SUFFIX) $(CPP_OPTIONS)

FC         = mpif90
FCL        = mpif90

FREE       = -ffree-form -ffree-line-length-none

FFLAGS     =
OFLAG      = -O2
DEBUG      = -O0

LIBDIR     = /usr/lib/x86_64-linux-gnu
BLAS       = -L$(LIBDIR) -lblas
LAPACK     = -L$(LIBDIR) -llapack
BLACS      = -L$(LIBDIR) -lblacs-openmpi -lblacsCinit-openmpi
SCALAPACK  = -L$(LIBDIR) -lscalapack-openmpi $(BLACS)

OBJECTS    = fftmpiw.o fftmpi_map.o  fftw3d.o  fft3dlib.o \
INCS       =-I/usr/include


OBJECTS_O1 += fft3dfurth.o fftw3d.o fftmpi.o fftmpiw.o chi.o
OBJECTS_O2 += fft3dlib.o

# For what used to be vasp.5.lib
CPP_LIB    = $(CPP)
FC_LIB     = $(FC)
CC_LIB     = gcc

OBJECTS_LIB= linpack_double.o getshmem.o

# Normally no need to change this
SRCDIR     = ../../src
BINDIR     = ../../bin

Step 5: Compiling

You are now ready to compile VASP!

make std


When compiling, I encountered the same error as for VASP 5.3.5 relating to the us.f90.


       USE us
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. The patch was created for VASP 5.3.5, but works fine for VASP 5.4.1. Just place it in the same directory as where the VASP sources reside (src) and apply the patch by typing:

patch -p0 < vasp535.patch

This will change the names automatically. You will receive a message such as

patching file us.F

Upon typing make, the compilation will resume.

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 Ten + Four?
Please answer with a whole number, i.e. 2, 3, 5, 8,...
2016-07-19 11:30:35
This is a significant improvement compared to the compilation of previous versions.
I did have some trouble linking the libraries, but I worked around that by running:
sudo ln -s /usr/lib/ /usr/lib/
sudo ln -s /usr/lib/ /usr/lib/
sudo ln -s /usr/lib/ /usr/lib/
What is the answer to Seven + Nine?
Please answer with a whole number, i.e. 2, 3, 5, 8,...
2016-12-14 10:19:04
You saved my life! Thanks a lot!
Looks like these links resolve the difference between debian and ubuntu.
What is the answer to Five + Nine?
Please answer with a whole number, i.e. 2, 3, 5, 8,...
2018-01-08 18:15:27
I found out that you need to install libblacs-mpi-dev and libscalapack-mpi-dev as well to have those symbolic links. I have changed this in the blog post for convenience.
What is the answer to Nine + Six?
Please answer with a whole number, i.e. 2, 3, 5, 8,...