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

2015-11-03

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 make gfortran libopenmpi-dev libfftw3-dev libblas-dev liblapack-dev libscalapack-openmpi1

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
CPP_OPTIONS= -DMPI -DHOST=\"IFC91_ompi\" -DIFC \
             -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
OFLAG_IN   = $(OFLAG)
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 \
             /usr/lib/x86_64-linux-gnu/libfftw3.a
INCS       =-I/usr/include

LLIBS      = $(SCALAPACK) $(LAPACK) $(BLAS)

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
CFLAGS_LIB = -O
FFLAGS_LIB = -O1
FREE_LIB   = $(FREE)

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

Troubleshooting

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


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. 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:


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

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.

Comments

Question:
What is the answer to Two + Eight?
Please answer with a whole number, i.e. 2, 3, 5, 8,...
b_dot_zijlstra_at_tue_dot_nl
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/libscalapack-openmpi.so.1 /usr/lib/libscalapack-openmpi.so
sudo ln -s /usr/lib/libblacs-openmpi.so.1 /usr/lib/libblacs-openmpi.so
sudo ln -s /usr/lib/libblacsCinit-openmpi.so.1 /usr/lib/libblacsCinit-openmpi.so
Question:
What is the answer to Ten + One?
Please answer with a whole number, i.e. 2, 3, 5, 8,...
dimov_at_cm_dot_kyushu-u_dot_ac_dot_jp
2016-12-14 10:19:04
You saved my life! Thanks a lot!
Looks like these links resolve the difference between debian and ubuntu.
Question:
What is the answer to Ten + Three?
Please answer with a whole number, i.e. 2, 3, 5, 8,...