# IT4Innovations 2021
# LK

easyblock = 'MakeCp'

name = 'VASP'
version = '6.2.0'
versionsuffix = '-mkl=sequential'

homepage = 'http://www.vasp.at'
description = """The Vienna Ab initio Simulation Package (VASP) is a local_computer program for atomic scale
materials modelling, e.g. electronic structure calculations and quantum-mechanical molecular dynamics,
from first principles.

To use VASP, You need academic licenses from University of Wiena. Follow the instructions https://www.vasp.at/index.php/faqs.

Then send us please a list of authorized users and their ID for which you need this access. Please use only http://support.it4i.cz/rt. We are responsible to verify your licenses. After succesfull verification You will be granted to use VASP in our enviroment."""

toolchain = {'name': 'intel', 'version': '2020b'}
toolchainopts = {'usempi': True}

# Vasp is proprietary software, see http://www.vasp.at/index.php/faqs on
# how to get access to the code
sources = ['%(namelower)s.%(version)s.tgz']

prebuildopts = 'cp arch/makefile.include.linux_intel ./makefile.include && '

# DFTD4
prebuildopts += 'echo "#DFTD4"'
prebuildopts += 'echo "CPP_OPTIONS += -DDFTD4 " >> makefile.include && '
prebuildopts += 'echo "DFTD4_ROOT  ?= /path/to/your/dft4/installation" >> makefile.include && '
prebuildopts += 'echo "LLIBS       += -L$(DFTD4_ROOT)/build -ldftd4" >> makefile.include && '
prebuildopts += 'echo "INCS        += -I$(DFTD4_ROOT)/libdftd4.a.p" >> makefile.include && '


# Makefile uses LIBS as a list of folders
prebuildopts += 'unset LIBS && '

_targets = ['std', 'gam', 'ncl']

buildopts = '%s ' % ' '.join(_targets)
buildopts += 'FCL="$MPIF90" DEBUG="$FFLAGS" OFLAG="$FFLAGS" OFLAG_1="${FFLAGS/O2/O1}" OFLAG_2="$FFLAGS" '
buildopts += 'OFLAG_3="${FFLAGS/O2/O3}" CFLAGS_LIB="$CFLAGS" FFLAGS_LIB="$FFLAGS" BLAS="$LIBBLAS" '
buildopts += 'LAPACK="$LIBLAPACK" BLACS="$LIBBLACS" SCALAPACK="$LIBSCALAPACK"'

# https://www.vasp.at/wiki/index.php/Validation_tests
runtest = 'test'

parallel = 1

files_to_copy = [(['bin/vasp_' + x for x in _targets], 'bin')]

sanity_check_paths = {
    'files': ['bin/vasp_' + x for x in _targets],
    'dirs': []
}

modluafooter = 'add_property("state","license")'

moduleclass = 'chem'
