# IT4Innovations
# PH 2024

easyblock = 'CMakeMake'

name = 'ScalapackFx'
version = '1.2'

homepage = 'https://github.com/dftbplus/ScalapackFx'
description = "Modern Fortran Interface for ScaLAPACK, providing convenient wrappers for diagonalization-related routines."

toolchain = {'name': 'foss', 'version': '2023a'}

# https://github.com/dftbplus/scalapackfx/archive/refs/tags/1.2.tar.gz
source_urls = ['https://github.com/dftbplus/scalapackfx/archive/refs/tags/']
sources = [f'{version}.tar.gz']

checksums = ['277fd170cfe6b6c67242a2c179494ec48d0daae94eac26f8361ca30aafe71b98']

builddependencies = [
    ('CMake', '3.26.3'),
    ('fypp', '3.2')       
]

dependencies = [
    ('ScaLAPACK', '2.2.0', '-fb'),
    ('FlexiBLAS', '3.3.1'),
]

configopts = '-DSCALAPACK_LIBRARY="-L$EBROOTSCALAPACK/lib -lscalapack" '
configopts += '-DLAPACK_LIBRARY="-L$EBROOTFLEXIBLAS/lib -lflexiblas" '


sanity_check_paths = {
    'files': [
        'lib/libscalapackfx.a',
        '%(builddir)s/easybuild_obj/test/test_cpg2l',
        '%(builddir)s/easybuild_obj/test/test_desc',
        '%(builddir)s/easybuild_obj/test/test_det',
        '%(builddir)s/easybuild_obj/test/test_diag',
        '%(builddir)s/easybuild_obj/test/test_gemr2d',
        '%(builddir)s/easybuild_obj/test/test_linecomm',
        '%(builddir)s/easybuild_obj/test/test_psyr_pher',
        '%(builddir)s/easybuild_obj/test/test_subgrids',
        '%(builddir)s/easybuild_obj/test/test_svd',
        '%(builddir)s/easybuild_obj/test/test_tran',
    ],
    'dirs': ['include', 'lib']
}

sanity_check_commands = [
    'cd %(builddir)s/scalapackfx-1.2/test && mpirun -n 2 ../../easybuild_obj/test/test_cpg2l',
    'cd %(builddir)s/scalapackfx-1.2/test && mpirun -n 2 ../../easybuild_obj/test/test_desc',
    'cd %(builddir)s/scalapackfx-1.2/test && mpirun -n 2 ../../easybuild_obj/test/test_det',
    'cd %(builddir)s/scalapackfx-1.2/test && mpirun -n 2 ../../easybuild_obj/test/test_diag',
    #'cd %(builddir)s/scalapackfx-1.2/test && mpirun -n 2 ../../easybuild_obj/test/test_gemr2d',
    'cd %(builddir)s/scalapackfx-1.2/test && mpirun -n 2 ../../easybuild_obj/test/test_linecomm',
    'cd %(builddir)s/scalapackfx-1.2/test && mpirun -n 2 ../../easybuild_obj/test/test_psyr_pher',
    'cd %(builddir)s/scalapackfx-1.2/test && mpirun -n 2 ../../easybuild_obj/test/test_subgrids',
    'cd %(builddir)s/scalapackfx-1.2/test && mpirun -n 2 ../../easybuild_obj/test/test_svd',
    'cd %(builddir)s/scalapackfx-1.2/test && mpirun -n 2 ../../easybuild_obj/test/test_tran',
]

moduleclass = 'math'