# -*- 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           github 1.0
PortGroup           mpi 1.0

github.setup        sourceryinstitute OpenCoarrays 2.10.2
github.tarball_from releases
revision            0
categories          science parallel devel fortran
license             BSD
maintainers         {@barracuda156 gmail.com:vital.had} openmaintainer

description         Library for multi-image coarray Fortran suppport
long_description    OpenCoarrays is an open-source software project \
                    that produces an application binary interface (ABI) \
                    to support coarrays and other Fortran 2018 parallel \
                    programming features for gfortran in the GNU Compiler \
                    Collection (GCC). Gfortran has used OpenCoarrays \
                    since the GCC 5.1.0 release.
homepage            http://www.opencoarrays.org

mpi.setup           require require_fortran \
                    -gcc44 -gcc45 -gcc46 -gcc47 -gcc48 -gcc49 -gcc5 \
                    -clang -fortran

universal_variant   no

checksums           rmd160  ea47f5b51795d60fa282dc5a753e0f46fb43fc0c \
                    sha256  e13f0dc54b966b0113deed7f407514d131990982ad0fe4dea6b986911d26890c \
                    size    339400

pre-patch   {
    move ${worksrcpath}/src/tests/integration/pde_solvers/coarrayHeatSimplified/main.f90 \
        ${worksrcpath}/src/tests/integration/pde_solvers/coarrayHeatSimplified/main.F90
}

patchfiles          patch-isnan.diff

post-patch {
    reinplace "s|mpicc|${prefix}/bin/${mpi.cc}|g" \
        src/tests/unit/simple/CMakeLists.txt
}

# Required to run the test phase.
pre-configure {
    configure.args-append \
        -DMPIEXEC_EXECUTABLE=${prefix}/bin/${mpi.exec} \
        -DMPI_C_COMPILER=${prefix}/bin/${mpi.cc} \
        -DMPI_Fortran_COMPILER=${prefix}/bin/${mpi.f90}
}

configure.args-append \
        -DMPI_C_COMPILE_OPTIONS="-lpthread" \
        -DMPI_Fortran_COMPILE_OPTIONS="-lpthread"

if {[string match *gcc* ${configure.compiler}]} {
    configure.ldflags-append \
        -latomic
}

# This can be used generally, since no universal variant, but Rosetta needs it:
platform darwin 10 powerpc {
    patchfiles-append patch-rosetta.diff
}

variant events description {enable support for the Fortran 2015 events feature} {
    configure.args-append \
        -DCOMPILER_SUPPORTS_ATOMICS:BOOL=ON
}

# Do not make this default: known to trigger some bugs on Intel, broken on PPC.
variant ULFM description {enable experimental ULFM support} {
    configure.args-append \
        -DCAF_ENABLE_FAILED_IMAGES:BOOL=ON
}

test.run            yes
test.target         check
