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

name                    pnetcdf
version                 1.15.0
revision                0
maintainers             {@thiagoveloso gmail.com:thiagoveloso} openmaintainer
categories              science devel
license                 Permissive

description             A Parallel I/O Library for NetCDF File Access.

long_description        PnetCDF is a high-performance parallel I/O library \
                        for accessing files in format compatibility with Unidata's \
                        NetCDF, specifically the formats of CDF-1, 2 and 5. The \
                        CDF-5 file format, an extension of CDF-2, supports unsigned \
                        data types and uses 64-bit integers to allow users to define \
                        large dimensions, attributes and variables (> 2B array elements).

homepage                https://parallel-netcdf.github.io

master_sites            ${homepage}/Release/

checksums               rmd160  a468332733d7d8400a83b4eec393183656510665 \
                        sha256  39813fe91ec901c7cfca3212731edbb5201029ebf55caeaaaa08d9e33c6bad65 \
                        size    3146725

# Xcode clang of 10.7 fails with error: invalid instruction mnemonic 'cvtsi2ssl'
# Copied from https://github.com/macports/macports-ports/pull/17269
# Also see https://github.com/william-dawson/NTPoly/issues/192
compiler.blacklist-append \
                        {clang < 500} {*gcc-[34].*} {macports-gcc-[56]}

mpi.setup               require default

depends_build-append    port:autoconf \
                        port:automake \
                        port:libtool \
                        port:m4 \
                        path:bin/perl:perl5

configure.args-append   --disable-silent-rules \
                        --with-mpi=${prefix}

# M4 was accidentally left out of Xcode 15.3. Affects some Sonoma builds.
# Use MacPorts M4. For background, see:
# https://github.com/macports/macports-ports/pull/22985 and related tickets.
configure.env-append    M4=${prefix}/bin/gm4

configure.env-append    MPICC=${mpi.cc} \
                        MPICXX=${mpi.cxx} \
                        MPIF77=${mpi.f77} \
                        MPIF90=${mpi.f90}

use_parallel_build      yes

if {![variant_isset openmpi]} {
    default_variants-append \
                        +mpich
}

post-destroot {
    reinplace "s|${destroot}||g" ${destroot}${prefix}/lib/pkgconfig/pnetcdf.pc
    reinplace "s|${destroot}||g" ${destroot}${prefix}/bin/pnetcdf-config
}

livecheck.type          regex
livecheck.url           ${homepage}
livecheck.regex         PnetCDF \(\[0-9.\]+\)
