# How to build VASP 5.3.5 using the GNU compiler on Linux Ubuntu 14.04 LTS

2015-06-29

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:

# Step 1: Installing the necessary packages


sudo apt-get install build-essential gfortran libopenmpi-dev libopenmpi1.6 openmpi1.6 libfftw3-double3 libfftw3-single3 libfftw3-dev git



# Step 2: Building OpenBLAS

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.

# Step 3: Building ScaLAPACK


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


make



This will generate a library file called libscalapack.a.

Now, we have everything to build VASP.

# Step 4: Building 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:


FC=mpif90
FCL=$(FC)   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



Upon typing 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 make clean)

Now, everything should compile perfectly. Type make again and the vasp executable will be generated.

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

#### Drop a line

Question:
What is the answer to Three + Two?
Please answer with a whole number, i.e. 2, 3, 5, 8,...
road309_at_naver_dot_com
2015-08-19 13:06:13
Dear Ivo,
Thanks for your kind instructions.
Unfortunately, I encountered error message as below,
although I followed all the procedures.
Would you please give me some solution?
- from Yong
======
Error: Syntax error in argument list at (1)
bse_te.f90:510.102:

ECTORELEMENTS(1,IDIR), MATDIM_NODE(NODE_ME), MPI_COMPLEX, VECTOR_D(1,IDIR),&1

Error: Syntax error in argument list at (1)
Makefile:324: recipe for target 'bse_te.o' failed
make: *** [bse_te.o] Error 1
====

#### Reply to road309_at_naver_dot_com

Question:
What is the answer to Five + Seven?
Please answer with a whole number, i.e. 2, 3, 5, 8,...
mudra_dot_msu_at_gmail_dot_com
2016-07-11 15:20:15
Hi, i am having same problem, can you please help and share how did you resolved it?

#### Reply to mudra_dot_msu_at_gmail_dot_com

Question:
What is the answer to One + Eight?
Please answer with a whole number, i.e. 2, 3, 5, 8,...
ivo_at_ivofilot_dot_nl
2016-07-11 15:46:18
Like I said below, it is very hard to give an answer to such questions with so little to go on. I never encountered this problem and it is very hard to reproduce without having some more details. My best guess is that you look into the GCC compilers and make sure you use a recent version. (> 4.9)

#### Reply to ivo_at_ivofilot_dot_nl

Question:
What is the answer to Five + Eight?
Please answer with a whole number, i.e. 2, 3, 5, 8,...
swangi_at_outlook_dot_com
2016-09-29 19:51:30
Change GCC to 4.9 didn't change the error. I found one solution is to delete '&' symbols in the lines (for instance, bse_te.f90:510.102), and make sure all values in the function in one line.

#### Reply to swangi_at_outlook_dot_com

Question:
What is the answer to Three + Six?
Please answer with a whole number, i.e. 2, 3, 5, 8,...
xuwenwu1115_at_hotmail_dot_com
2016-02-24 07:17:57
I had exactly the same problem about bse_te.f90 error...

#### Reply to xuwenwu1115_at_hotmail_dot_com

Question:
What is the answer to Eight + Six?
Please answer with a whole number, i.e. 2, 3, 5, 8,...
ivo_at_ivofilot_dot_nl
2016-02-25 12:41:09
It's hard to find out what went wrong with so little details to go on. Furthermore, this version of VASP is outdated and VASP 5.4.x has a completely new build system. Better try that out. (more information can be found in my other blog post)

#### Reply to ivo_at_ivofilot_dot_nl

Question:
What is the answer to Ten + Four?
Please answer with a whole number, i.e. 2, 3, 5, 8,...
khanhbinh183_at_yahoo_dot_com
2016-05-01 10:23:58
Thank you very much for your guidance. I've installed VASP successfully. But when I run VASP, the percentage of 1 cpu can increase up to 400% and it slows down all of my system. I think that is the OpenMPI problem but I don't know how to fix it. Do you have any suggestion. Thank you very much!

#### Reply to khanhbinh183_at_yahoo_dot_com

Question:
What is the answer to Two + Seven?
Please answer with a whole number, i.e. 2, 3, 5, 8,...
ivo_at_ivofilot_dot_nl
2016-05-03 08:03:16
This is indeed most likely caused by a problem with how you use OpenMPI. Regrettably, I cannot give a straight answer how to resolve it as I cannot reproduce the problem you have. Relevant questions for you are: How do you run VASP? (e.g. mpirun -np 4 ./vasp) How did you obtain OpenMPI? My suggestion is to look into the manual pages of OpenMPI and especially the mpirun command. Alternatively, you could try to manually compile OpenMPI yourself and see if that resolves your problem.

#### Reply to ivo_at_ivofilot_dot_nl

Question:
What is the answer to Five + Eight?
Please answer with a whole number, i.e. 2, 3, 5, 8,...
khanhbinh183_at_yahoo_dot_com
2016-05-04 07:59:37
Thank you for your response. I've already fixed the problem. I'm not sure about the it. This is probably because that the hyper-threading is enable in my cluster. By adding the flag "-x OMP_NUM_THREADS=1" (or 2), the problem is fixed.

#### Reply to khanhbinh183_at_yahoo_dot_com

Question:
What is the answer to Two + Three?
Please answer with a whole number, i.e. 2, 3, 5, 8,...
jyothigsit26_at_gmail_dot_com
2016-12-28 16:46:18
Hi, I have one problem like AS you mention above

Error: 'setdij' of module 'us', imported at (1), is also the name of the current program unit

i tried to attach patch file but it showing

can't find file to patch at input line 3
Perhaps you used the wrong -p or --strip option?
The text leading up to this was:
--------------------------
|--- us.F
|+++ us.F
--------------------------
File to patch:

Would you please give me some solution?

from Jyothi

#### Reply to jyothigsit26_at_gmail_dot_com

Question:
What is the answer to Two + Eight?
Please answer with a whole number, i.e. 2, 3, 5, 8,...
ngoctri2990_at_gmail_dot_com
2017-04-12 02:59:04
Dear Ivo,
Thank you very much for your instruction.
Could you please help me to fix this problem:

mpif90 -ffree-form -ffree-line-length-0 -O3 -c symmetry.f90
symmetry.f90:1567:10:
USE spinsym
1
Fatal Error: Can't open module file ‘spinsym.mod’ for reading at (1): No such file or directory
compilation terminated.
makefile:320: recipe for target 'symmetry.o' failed
make: *** [symmetry.o] Error 1

Thanks so much!

#### Reply to ngoctri2990_at_gmail_dot_com

Question:
What is the answer to Two + Four?
Please answer with a whole number, i.e. 2, 3, 5, 8,...
bafekry_dot_asad_at_gmail_dot_com
2017-08-23 06:23:58
Hi dears
please help me to fix this problem:

mpif90 -ffree-form -ffree-line-length-0 -O3 -c symmetry.f90
symmetry.f90:1567:10:
USE spinsym
1
Fatal Error: Can't open module file ‘spinsym.mod’ for reading at (1): No such file or directory
compilation terminated.
makefile:320: recipe for target 'symmetry.o' failed
make: *** [symmetry.o] Error 1

Thanks

#### Reply to bafekry_dot_asad_at_gmail_dot_com

Question:
What is the answer to Ten + Eight?
Please answer with a whole number, i.e. 2, 3, 5, 8,...

44046
9
28-07-2014
3034
1
22-03-2015
46
0
29-12-2017
40
0
27-12-2017