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

github.setup        nco nco 5.3.9
github.tarball_from archive
revision            0
maintainers         {takeshi @tenomoto} \
                    {me.com:remko.scharroo @remkos} \
                    openmaintainer
license             GPL-3
categories          science
description         The netCDF Operators

compilers.choose    cc cxx
if {${os.major} > 12} {
    compilers.setup -clang33 -clang34 -gcc
} else {
    compilers.setup -clang33 -clang34
}

checksums           rmd160  47c90836b07a3190f46513d271a46ea6013911e2 \
                    sha256  705ffa98a78d468cdfaa5858f09213142265120fc26a78249a442ae2fa92ae96 \
                    size    6895863

homepage            http://nco.sourceforge.net/
long_description \
    Each NCO operator (e.g., ncks) takes netCDF or HDF input file(s), \
    performs an operation (e.g., averaging, hyperslabbing, or renaming), \
    and outputs a processed netCDF file. Although most users of netCDF \
    and HDF data are involved in scientific research, these data formats, \
    and thus NCO, are generic and are equally useful in fields like finance. \
    This version is OPeNDAP/DODS enabled, so it can be given \
    URLs to read remote datasets as if they were local netCDF files.

depends_lib         port:curl \
                    port:gettext \
                    port:netcdf \
                    port:udunits2 \
                    port:gsl
depends_build       port:antlr \
                    port:bison \
                    port:m4 \
                    port:texinfo
depends_run         port:wget

configure.env       HAVE_ANTLR=yes ANTLR_ROOT=${prefix} \
                    PATH_TO_NCGEN=${prefix}/bin/ncgen
configure.cppflags-append   -I${prefix}/include/udunits2 \
                            -I${prefix}/include \
                            -DENABLE_NETCDF4
configure.args      --disable-dependency-tracking \
                    --mandir=${prefix}/share/man  \
                    --disable-shared              \
                    --disable-openmp

if {[gcc_variant_isset] || [clang_variant_isset]} {
    default_variants-append +openmp
}

post-destroot {
    xinstall -m 0755 -d ${destroot}${prefix}/share/doc/${name}
    foreach f {ANNOUNCE ChangeLog LICENSE TODO VERSION *.txt *.pdf} {
        xinstall -m 0644 {*}[glob ${worksrcpath}/doc/${f}] \
            ${destroot}${prefix}/share/doc/${name}
    }
}

variant openmp description {enable support for OpenMP} {
    configure.args-delete   --disable-openmp
    configure.args-append   --enable-openmp --disable-ncoxx
    compiler.whitelist      macports-clang-7.0 macports-clang-6.0 macports-clang-5.0 \
                            macports-clang-3.7 \
                            macports-gcc-8 macports-gcc-7 macports-gcc-6 macports-gcc-5 \
                            macports-gcc-4.8 macports-gcc-4.7 macports-gcc-4.6 macports-gcc-4.5 \
                            macports-gcc-4.4 macports-gcc-4.3
    compiler.fallback       macports-clang-7.0
}

# Note 2025 Nov 10:  Do not ever use "--enable_esmf".
# ESMF features are used through executables only, not library.
# Direct ESMF linkage in code is unstable, developer only,
# not for public builds.
# https://github.com/nco/nco/issues/42#issuecomment-271440737

variant esmf description {enable ESMF regridding} {
    depends_run-append      port:esmf
}

github.livecheck.regex      {([^"rba]+)}
