# -*- 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.14.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  51b2a5bc3f7dc19ce17d152b4059e00a0e492127 \
                        sha256  575f189fb01c53f93b3d6ae0e506f46e19694807c81af0b9548e947995acf704 \
                        size    2419346

if {${os.arch} eq "powerpc"} {
   mpi.setup            require -clang -gfortran
} else {
   mpi.setup            require -gcc12 -gfortran
}

#compilers.choose       fc f77 f90 cc cxx

depends_build-append    port:perl5 \
                        port:autoconf \
                        port:automake \
                        port:libtool \
                        port:m4

configure.args-append   --disable-silent-rules

# 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}

default_variants        +gcc12 +mpich

use_parallel_build      yes

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         {New version \(([^)]+)\)}
