# IT4Innovations
# LK 2021

easyblock = 'CMakeMake'
name = 'OpenMolcas'
version = '21.06'
versionsuffix = '-Python-3.8.6'

homepage = "https://gitlab.com/Molcas/OpenMolcas"
description = "OpenMolcas is a quantum chemistry software package"

toolchain = {'name': 'intel', 'version': '2020b'}
import os
if os.environ.get("CLUSTERNAME") in ["KAROLINA"]:
  toolchainopts = {'usempi': True, 'optarch': 'march=core-avx2', 'opt': '03'}
else:
  toolchainopts = {'usempi': True}

source_urls = ['https://gitlab.com/Molcas/OpenMolcas/-/archive/v%(version)s/']
sources = ["OpenMolcas-v%(version)s.tar.gz"]

patches = ['OpenMolcas-21.06_mcpdft_deps.patch']
checksums = [
    '54cf989c1e0fcb7e8927f0c64fe356b300bf3537e4868356eea47105a8a06e3a',  # OpenMolcas-v21.06.tar.gz
    '708763e060aa0174bbe9c0cc336b509fbf492066465908dd919452836a7a793a',  # OpenMolcas-21.06_mcpdft_deps.patch
]

dependencies = [
    ('GlobalArrays', '5.8'),
    ('HDF5', '1.10.6', '-parallel'),
    ('Python', '3.8.6', ''),
    ('CheMPS2', '1.8.9'),
]

builddependencies = [('CMake', '3.18.4', '', True)]

separate_build_dir = True

preconfigopts = 'GAROOT=$EBROOTGLOBALARRAYS'
configopts = '-DLINALG=MKL -DMKLROOT=$EBROOTIMKL/mkl -DMPI=ON -DGA=ON -DBUILD_SHARED_LIBS=ON -DTOOLS=ON -DFDE=ON '
configopts += '-DCHEMPS2=ON -DCHEMPS2_DIR=$EBROOTCHEMPS2/bin'

modextravars = {
    'MOLCAS': '%(installdir)s',
    'MOLCAS_DRIVER': '%(installdir)s/sbin/pymolcas',
    'MOLCAS_SOURCE': '%(installdir)s',
}

sanity_check_paths = {
    'files': ['lib/libmolcas.so', 'bin/alaska.exe', 'bin/casvb.exe', 'bin/cht3.exe', 'bin/espf.exe', 'bin/gateway.exe',
              'bin/gugaci.exe', 'bin/last_energy.exe', 'bin/mbpt2.exe', 'bin/mcpdft.exe', 'bin/mrci.exe',
              'bin/qmstat.exe', 'bin/rassi.exe', 'bin/seward.exe', 'bin/vibrot.exe', 'bin/averd.exe', 'bin/ccsdt.exe',
              'bin/cpf.exe', 'bin/expbas.exe', 'bin/genano.exe', 'bin/gugadrt.exe', 'bin/localisation.exe',
              'bin/mckinley.exe', 'bin/motra.exe', 'bin/numerical_gradient.exe', 'bin/quater.exe', 'bin/rpa.exe',
              'bin/slapaf.exe', 'bin/caspt2.exe', 'bin/chcc.exe', 'bin/dynamix.exe', 'bin/ffpt.exe', 'bin/guessorb.exe',
              'bin/guga.exe', 'bin/loprop.exe', 'bin/mclr.exe', 'bin/mpprop.exe', 'bin/parnell.exe', 'bin/rasscf.exe',
              'bin/scf.exe', 'bin/surfacehop.exe', 'sbin/help_basis'],
    'dirs': ['data/', 'basis_library/'],
}

moduleclass = 'chem'
