# Updated to version 3.17.0 with significantly more modules added
# J. Sassmannshausen ICL/UK 

easyblock = 'ConfigureMake'

name = 'PETSc'
version = '3.17.4'

homepage = 'https://www.mcs.anl.gov/petsc'
description = """PETSc, pronounced PET-see (the S is silent), is a suite of data structures and routines for the
 scalable (parallel) solution of scientific applications modeled by partial differential equations.

This installation is build with significant amounts of modules in it compared to previous versions."""

toolchain = {'name': 'foss', 'version': '2021a'}
toolchainopts = {'openmp': True, 'usempi': True, 'pic': True}

source_urls = [
    'https://ftp.mcs.anl.gov/pub/petsc/release-snapshots/',
    'ftp://ftp.mcs.anl.gov/pub/petsc/release-snapshots/',
]
sources = [SOURCELOWER_TAR_GZ]
patches = [
    'webclient-3.17.0.patch',
]
checksums = [
    '99c127486722a3ffd95a268b4ceb0976cbf217926c681a9631bd7246eab8cb2a',  # petsc-3.17.4.tar.gz
    '2ba253df42853385e2683dbc87dfcb66d4ce4bcd84e054efa8f466274f49bc81',  # webclient-3.17.0.patch
]

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

dependencies = [
    ('Python', '3.9.5'),
    ('SciPy-bundle', '2021.05'),
    ('Boost', '1.76.0'),
    ('METIS', '5.1.0'),
    ('SCOTCH', '6.1.0'),
    ('MUMPS', '5.4.0', '-metis'),
    ('SuiteSparse', '5.10.1', '-METIS-5.1.0'),
    ('Hypre', '2.21.0'),
    ('zlib', '1.2.11'),
    ('BLIS', '0.8.1'),
    ('Szip', '2.1.1'),
    ('HDF5', '1.12.1'),
    ('GMP', '6.2.1'),
    ('GSL', '2.7'),
    ('libjpeg-turbo', '2.0.6'),
    ('libpng', '1.6.37'),
    ('giflib', '5.2.1'),
    ('OpenSSL', '1.1', '', True),
    ('libyaml', '0.2.5'),
    ('zstd', '1.4.9'),
    ('Mmg', '5.6.0'),
    ('MPFR', '4.1.0'),
    ('googletest', '1.11.0'),
    ('muParser', '2.3.3'),
    ('ParMETIS', '4.0.3'),
]

# enabling --with-mpi4py seems to be totally broken, leads to make errors like:
# No rule to make target 'mpi4py-build'
configopts = '--configModules=PETSc.Configure --optionsModule=config.compilerOptions '
configopts += '--LIBS="$LIBS -lrt" --download-mpi4py --with-mpi4py=1 --download-petsc4py --CXXFLAGS="$CXXFLAGS '
configopts += '-DOMPI_SKIP_MPICXX -DMPICH_SKIP_MPICXX" --with-mpi=1 --with-build-step-np=4 '
configopts += '--CPPFLAGS="$CPPFLAGS" --F90FLAGS="$F90FLAGS" --FFLAGS="$FFLAGS" --FCFLAGS="$FCFLAGS" '
configopts += '--with-blaslapack-lib=" -lflexiblas -lgfortran" '
configopts += '--with-shared-libraries=1 --with-debugging=0 --with-pic=1 --with-x=0 '
configopts += '--with-windows-graphics=0 --with-numpy=1 --with-fftw=1 --with-scalapack=1 '
configopts += '--with-python=1 --with-boost=1 --with-metis=1 -with-ptscotch=1 --with-mumps=1 '
configopts += '--with-hypre=1  --with-suitesparse=1 --with-hwloc=1 --with-openmp=1 --with-zlib=1 --with-blis=1 '
configopts += '--with-hdf5=1 --with-eigen=1 --with-parmetis=1 --with-gmp=1 --with-gsl=1 --with-libjpeg=1 '
configopts += '--with-libpng=1 --with-yaml=1 --with-zstd=1 --with-ssl=1 --with-triangle=0 --with-giflib=1 '

sanity_check_paths = {
    'files': ['lib/libpetsc.%s' % SHLIB_EXT],
    'dirs': ['include', 'share']
}

modextrapaths = {'PYTHONPATH': 'lib'}

moduleclass = 'numlib'

