Step-by-Step Compilation of VASP (CPU) Incorporating Grand-Canonical Methods on NSCC

Instruction for compiling vasp cpu with grand-canonical approach on NSCC

Download packages

Assume the vasp source code was downloaded in extracted in $HOME/vasp.6.4.0_cp_cpu

You need the patch VASPSOL for VASP.6.3.0 and VASP-CP. Those patches can be found in the links below.

solvation.F
VASPsol_VASP630.patch
cp-vaspsol.patch

Patch VASPSOL

Copy solvation.F and VASPsol_VASP630.patch to src folder of vasp source code

cp solvation.F $HOME/vasp.6.4.0_cp_cpu/src
cp VASPsol_VASP630.patch $HOME/vasp.6.4.0_cp_cpu/src

Then execute the patch.

patch -p0 < VASPsol_VASP630.patch

Patch VASP-CP

Copy cp-vaspsol.patch to src folder of vasp source code

cp cp-vaspsol.patch $HOME/vasp.6.4.0_cp_cpu/src

Then execute the patch.

patch -p0 < cp-vaspsol++.patch

Load libs

Clean all loaded modules and load intel oneapi packages.

module purge
source /app/apps/oneapi/2022.1.2/setvars.sh

Modify the makefile

Modify the makefile.include as follow.

# Default precompiler options
CPP_OPTIONS = -DHOST=\"LinuxIFC\" \
              -DMPI -DMPI_BLOCK=8000 -Duse_collective \
              -DscaLAPACK \
              -DCACHE_SIZE=4000 \
              -Davoidalloc \
              -Dvasp6 \
              -Duse_bse_te \
              -Dtbdyn \
              -Dfock_dblbuf \
              -D_OPENMP \
              -Dsol_compat

CPP         = fpp -f_com=no -free -w0  $*$(FUFFIX) $*$(SUFFIX) $(CPP_OPTIONS)

FC          = mpiifort -qopenmp
FCL         = mpiifort

FREE        = -free -names lowercase

FFLAGS      = -assume byterecl -w

OFLAG       = -O2
OFLAG_IN    = $(OFLAG)
DEBUG       = -O0

OBJECTS     = fftmpiw.o fftmpi_map.o fftw3d.o fft3dlib.o
OBJECTS_O1 += fftw3d.o fftmpi.o fftmpiw.o
OBJECTS_O2 += fft3dlib.o

# For what used to be vasp.5.lib
CPP_LIB     = $(CPP)
FC_LIB      = $(FC)
CC_LIB      = icc
CFLAGS_LIB  = -O
FFLAGS_LIB  = -O1
FREE_LIB    = $(FREE)

OBJECTS_LIB = linpack_double.o

# For the parser library
CXX_PARS    = icpc
LLIBS       = -lstdc++

##
## Customize as of this point! Of course you may change the preceding
## part of this file as well if you like, but it should rarely be
## necessary ...
##

# When compiling on the target machine itself, change this to the
# relevant target when cross-compiling for another architecture
VASP_TARGET_CPU ?= -march=core-avx2
FFLAGS     += $(VASP_TARGET_CPU)

# Intel MKL (FFTW, BLAS, LAPACK, and scaLAPACK)
# (Note: for Intel Parallel Studio's MKL use -mkl instead of -qmkl)
FCL        += -qmkl
MKLROOT    ?= /path/to/your/mkl/installation
LLIBS      += -L$(MKLROOT)/lib/intel64 -lmkl_scalapack_lp64 -lmkl_blacs_intelmpi_lp64
INCS        =-I$(MKLROOT)/include/fftw

Installtion

Then install the vasp package with the command below. Remember to change N in the command.

make DEPS=1 -jN all

Vasp script

The bash script to run vasp can be set as follow.

#!/bin/bash

#PBS -N CPU-vasp
#PBS -q normal
#PBS -P personal-vannamtr
#PBS -l select=1:ncpus=128:mpiprocs=64:mem=420G
#PBS -l walltime=1:00:00
#PBS -j oe

# Change directory to the one where the job was submitted
idir=${PBS_O_WORKDIR}
cd $idir
# Set scratch environment

module purge
source /app/apps/oneapi/2022.1.2/setvars.sh

EXECROOT=/home/users/ntu/vannamtr/vasp.6.4.0_cp_cpu/intel_omp

MPIFLAGS='-genv I_MPI_PIN_DOMAIN=omp -genv I_MPI_PIN=yes -genv OMP_NUM_THREADS=4 -genv OMP_STACKSIZE=512m -genv OMP_PLACES=cores -genv OMP_PROC_BIND=close'

time mpirun $MPIFLAGS $EXECROOT/vasp_std > print-out

echo $(date) $PBS_JOBNAME ${PBS_O_WORKDIR} >> ~/LOG