# IT4Innovations 2022
# JK

easyblock = 'CMakeMake'

name = 'OpenMolcas'
version = '22.06'

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

toolchain = {'name': 'intel', 'version': '2021a'}

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 = [
    '45daca1e6465d59a43479d5509315bca9c19dedbb0a2d4bb4f26f0b443b7670d',  # OpenMolcas-v22.06.tar.gz
    '708763e060aa0174bbe9c0cc336b509fbf492066465908dd919452836a7a793a',  # OpenMolcas-21.06_mcpdft_deps.patch
]

dependencies = [
    ('GlobalArrays', '5.8'),
    ('HDF5', '1.10.7'),
    ('Python', '3.9.5'),
    ('CheMPS2', '1.8.9'),
]

builddependencies = [('CMake', '3.20.1')]

separate_build_dir = True

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

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

sanity_check_paths = {
    'files': ['bin/dynamix.exe', 'bin/mpprop.exe', 'lib/libmolcas.%s' % SHLIB_EXT,
              'sbin/help_basis', 'pymolcas'],
    'dirs': ['data/', 'basis_library/'],
}

moduleclass = 'chem'
