# IT4Innovations 2019
#
# NOT WORKING!


name = 'Trilinos'
version = '12.14.1'
versionsuffix = '-Py-2.7'

homepage = 'https://trilinos.org'
description = """The Trilinos Project is an effort to develop algorithms and enabling technologies
 within an object-oriented software framework for the solution of large-scale, complex multi-physics
 engineering and scientific problems. A unique design feature of Trilinos is its focus on packages."""

toolchain = {'name': 'intel', 'version': '2017c'}
toolchainopts = {'usempi': True, 'pic': True, 'strict': True}

source_urls = ['https://github.com/trilinos/Trilinos/archive/']
sources = ['%(namelower)s-release-12-14-1.tar.gz']
patches = [
     ('Trilinos-12.14.1-epetra_hdf5.patch'),
     ('Trilinos-12.14.1-thyra_test.patch'),
#    ('Trilinos-12.12.1_fix-CEpetra-LAPACK.patch', 'packages/CTrilinos'),
#    'Trilinos-12.12.1_muelu-fix-function-signature.patch',
#    'Trilinos-12.12.1_fix-Sundance.patch',
]

configopts =  '-DThyraEpetraAdapters_THYRADEBUGHANG_ENABLE=OFF '
configopts += '-DEpetraExt_ENABLE_HDF5=OFF '
configopts += '-DMueLu_ENABLE_Epetra:BOOL=OFF '
configopts += '-DTpetra_INST_SERIAL:BOOL=ON. '

builddependencies = [
    ('CMake', '3.13.1', '', True),
    ('SWIG', '3.0.12', versionsuffix, True),
]

dependencies = [
    ('Py', '2.7', '', True),
    ('Boost', '1.68.0', versionsuffix),
    ('SCOTCH', '6.0.6'),
    ('SuiteSparse', '5.4.0', '-METIS-5.1.0'),
    ('ParMETIS', '4.0.3'),
    ('netCDF', '4.6.1'),
    ('MATIO', '1.5.12', '', ('GCCcore', '6.3.0')),
    ('GLM', '0.9.9.0', '', ('GCCcore', '6.3.0')),
    ('X11', '20180604', '', True),
]

# disable TrilinosCouplings package, doesn't build correctly (examples fail to compile)
skip_exts = ['TrilinosCouplings']


#prebuildopts =  "find packages/amesos2 -type f -exec sed -i.bak 's/-lifcoremt_pic/-lifcoremt_pic -lcamd -lccolamd/g' {} + && "
#prebuildopts += "find packages/amesos -type f -exec sed -i.bak 's/-lifcoremt_pic/-lifcoremt_pic -lcamd -lccolamd -lmetis/g' {} + && "
#prebuildopts += "find packages/ifpack -type f -exec sed -i.bak 's/-lifcoremt_pic/-lifcoremt_pic -lcamd -lccolamd -lmetis/g' {} + && "
#prebuildopts += "find packages/ml -type f -exec sed -i.bak 's/-lifcoremt_pic/-lifcoremt_pic -lcamd -lccolamd/g' {} + && "
#prebuildopts += "find packages/belos -type f -exec sed -i.bak 's/-lifcoremt_pic/-lifcoremt_pic -lcamd -lccolamd/g' {} + && "
#prebuildopts += "find packages/moertel -type f -exec sed -i.bak 's/-lifcoremt_pic/-lifcoremt_pic -lcamd -lccolamd/g' {} + && "
#prebuildopts += "find packages/anasazi -type f -exec sed -i.bak 's/-lifcoremt_pic/-lifcoremt_pic -lcamd -lccolamd -lmetis/g' {} + && "

prebuildopts = "find packages -type f -name link.txt -exec sed -i.bak 's/libcholmod.a/libcholmod.a -lcamd -lccolamd -lmetis/g' {} + && "

# workaround for Teuchos.pyc not being found during "make install"
# see https://github.com/trilinos/Trilinos/issues/1749
preinstallopts = "cd %(builddir)s/trilinos-%(version)s-Source/packages/PyTrilinos/src/PyTrilinos && "
preinstallopts += "python -m compileall -l -f . && cd - && "

# too parallel is too slow because of memory requirements (results in swapping), and may cause build/tests to fail
# building with 20 cores seems to require about 100GB of memory (peak usage)
maxparallel = 10

moduleclass = 'numlib'
