# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4

PortSystem          1.0
PortGroup           cmake 1.1
PortGroup           compiler_blacklist_versions 1.0
PortGroup           linear_algebra 1.0
PortGroup           github 1.0
PortGroup           mpi 1.0
PortGroup           muniversal 1.0

github.setup        Reference-ScaLAPACK scalapack 2.2.2 v
revision            0
categories          math
maintainers         nomaintainer
license             BSD
description         A package for solving linear equations
long_description    The ScaLAPACK (or Scalable LAPACK) library includes \
                    a subset of LAPACK routines redesigned for distributed \
                    memory MIMD parallel computers. Since version 2.0.0, \
                    ScaLAPACK includes BLACS.

homepage            https://www.netlib.org/scalapack

checksums           rmd160  91015da6f02b4185c644c4567b2679852966e824 \
                    sha256  a2f0c9180a210bf7ffe126c9cb81099cf337da1a7120ddb4cbe4894eb7b7d022 \
                    size    4769347
github.tarball_from archive

mpi.setup           require require_fortran

compiler.blacklist-append   {clang < 500}

# remove when issue https://trac.macports.org/ticket/62567 is closed
configure.cflags-append -Wno-implicit-function-declaration
configure.args      -DCMAKE_INSTALL_NAME_DIR=${prefix}/lib \
                    -DBUILD_SHARED_LIBS=ON \
                    -DBUILD_TESTING=ON
# BUILD_TESTING only affects BLACS directory anyway

test.run            yes

pre-test {
    # test infrastructure uses /bin/ps (I think for checking on job timeout), which is forbidden by sandboxing
    append portsandbox_profile " (allow process-exec (literal \"/bin/ps\") (with no-profile))"
}

pre-configure {
    configure.args-append \
        -DMPI_C_COMPILER=${mpi.cc} \
        -DMPI_Fortran_COMPILER=${mpi.fc} \
        -DMPIEXEC_EXECUTABLE=${prefix}/bin/${mpi.exec} \
        -DLAPACK_LIBRARIES="-L${prefix}/lib ${linalglib}"
}

# see https://github.com/Reference-ScaLAPACK/scalapack/issues/21
compilers.allow_arguments_mismatch \
                    yes
