Third-party licences for the code in this directory
==================================================

Some of the CUDA translation units here are hand transcriptions of
third-party work.  ArWen distributes them under the Apache License 2.0; the
notices below belong to the transcribed parts and are reproduced because the
licences those parts carry require it.  The same notices, with the fuller
provenance account, are in the repository's root NOTICE, and the complete
licence texts are in the repository's licenses/ directory, which ships in
the wheel under gpuwm-<version>.dist-info/licenses/.

WHY THIS FILE EXISTS RATHER THAN A HEADER IN EACH .cu
-----------------------------------------------------
Every .cu in this directory is pinned by SHA-256 -- by
tests/test_mp8_frozen.py::FROZEN_MODULE_DIGESTS, which pins the file AND the
assembled compile string the loader hands nvrtc, and by
tests/test_kernel_source_freeze_per_module.py::BASELINE_PINNED, which pins
the rest.  A comment prepended to any of them would move a frozen digest and
turn a numerics gate red for a reason that has nothing to do with numerics.
So the notice sits beside the code instead of inside it, and it ships with
the code: pyproject.toml's package-data glob for gpuwm.core.kernels names
this file explicitly.  The existing headers here are NOT digest-pinned and were
checked against every _EXTRA_HEADERS consumer -- glibc_flt32.cuh and
thompson_aerosol_common.cuh -- and those two do carry their notice inline.
The new glibc_trig_flt32.cuh also carries its notice inline.

WHAT IS COVERED, AND WHERE
--------------------------
1. Arm optimized-routines (MIT)        -- logf, expf, exp2f, powf, sinf, cosf
2. FDLIBM / Sun Microsystems           -- expm1f, tanhf, atanf, log10f, log1pf
3. AER RRTMG (BSD 3-Clause)            -- the legacy RRTMG radiation kernels
4. RTE+RRTMGP (BSD 3-Clause)           -- the default radiation kernels
5. Numerical Recipes Software          -- the GAMMLN log-gamma coefficients
6. CORE-MATH (MIT)                     -- tanf, asinf, acosf, atanf, log10f

Sections 1, 2 and 6 state their scope; section 7 states what none of
the six grants covers.

The FP32 libm transcriptions exist because ArWen grades several physics
schemes bitwise against a gfortran/glibc reference, so it carries hand
transcriptions of the standard single-precision libm routines rather than
calling CUDA's, whose expf, powf and tgammaf are different functions.

Scope in this directory: the logf / expf / exp2f / powf cores and their data
tables (Arm, MIT) appear in glibc_flt32.cuh, mynn_dmp_sibling.cu, mynn_pbl.cu,
noahmp_bareflux.cu, noahmp_fluxprep.cu, noahmp_leaves.cu, noahmp_radiation.cu,
noahmp_snow.cu, noahmp_soilwater.cu, noahmp_vegeflux.cu, noahmp_vegprecip.cu,
noahmp_water.cu, rrtmg_lw.cu, rrtmg_sw.cu and vert_interp.cu.  The expm1f / tanhf / atanf /
log10f reductions (FDLIBM, Sun Microsystems) appear in mynn_dmp_sibling.cu,
mynn_pbl.cu, noahmp_bareflux.cu, noahmp_energy.cu, noahmp_fluxprep.cu,
noahmp_glacier.cu, noahmp_leaves.cu, noahmp_vegeflux.cu and ruc.cu.
glibc_flt32.cuh is NOT on that second list: it carried FDLIBM's expm1f and
lgammaf through 2.6.5 as helpers of ArWen's earlier gamma, and both were
removed at 2.6.6 when that gamma was replaced and nothing called them any
more.  lgammaf is not on the first list either: that removal took out the
only transcription of e_lgammaf_r.c anywhere in this repository.  Their Python counterparts are in
gpuwm/core/noahmp_libm.py, gpuwm/core/mynn_pbl.py and gpuwm/core/ruc.py, each
of which carries this notice in its own header.
tests/test_cuda_libm_table_copies.py enumerates the table copies and keeps
them in step, so this list is machine-checkable rather than prose.


1. Arm optimized-routines -- logf, expf, exp2f, powf, sinf, cosf
----------------------------------------------------

Written by Szabolcs Nagy and published at
https://github.com/ARM-software/optimized-routines (math/logf.c, math/expf.c,
math/exp2f.c, math/powf.c and the corresponding math/*_data.c) in August 2017,
and imported into glibc for 2.27/2.28 by their own author.  ArWen transcribed
them from glibc's copy at sysdeps/ieee754/flt-32/, which reproduces Arm's text
unchanged apart from symbol renaming, branch-hint and cast macro spellings and
symbol-versioning declarations -- none of which ArWen reproduces.  ArWen takes
this material under the MIT branch of Arm's grant.

The sinf / cosf cores and their tables in
gpuwm/core/kernels/glibc_trig_flt32.cuh are also Arm's work. Their sources
are math/sinf.c, math/cosf.c, math/sincosf.h and math/sincosf_data.c.
The 2018 Arm revision 5e8389113b47a48622d1de8beb9a4adc2b332694
predates glibc's imports ea5c662c623125ad39fc43d5b9224150256407a9
(shared data and helpers, 2018-08-10) and
599cf3976679e1b345307d9c02057f02aa95528f (sinf/cosf, 2018-08-14).
Arm's MIT relicensing at 11253b0b9d6b covers the same algorithms and
constants; current Arm fe09d4e7ed62aa24c81b5791c810bc9de70006e9
still offers MIT. Its source notices read:

    Copyright (c) 2018-2024, Arm Limited.
    Copyright (c) 2018-2019, Arm Limited.

The transcription follows glibc 2.43 sysdeps/ieee754/flt-32/s_sinf.c,
s_cosf.c, s_sincosf.h, sincosf_poly.h and s_sincosf_data.c, selected
as the x86 FMA IFUNC variant. The generic sine/cosine bodies, both range
reductions, polynomials and tables reproduce Arm's code apart from
renamings, qualifiers, macro spellings and splitting polynomial helpers
into sincosf_poly.h. Integration aliases and IFUNC wrappers are not copied.
The MIT branch is elected for these parts too; the full Arm permission
notice below and licenses/LICENSE-Arm-optimized-routines-MIT.txt apply.
This adds one trig header to the fourteen log/exp/pow kernel files above;
the Python log/exp/pow copy remains separate.

At the vintage glibc imported -- Arm 86067a740541, 2017-08-11, taken into
glibc at 4ea49f4c08ee on 2017-09-04 -- those files read "Copyright (C) 2017,
ARM Limited" under Apache-2.0.  Arm relicensed the same work to MIT fifteen
months later, at 11253b0b9d6b on 2018-11-12, and each file has carried

    Copyright (c) 2017-2018, Arm Limited.
    SPDX-License-Identifier: MIT

ever since.  A copyright holder may licence its own work on any terms it
chooses; Arm's MIT offer is public, current and made by the retained
copyright holder, and it is the offer ArWen takes.  The project LICENSE at
that relicensing (identical at every tag through v21.02, md5
c7e74e8165fadb7dd9ee169534fe99ef) reads:

    MIT License

    Copyright (c) 1999-2019, Arm Limited.

    Permission is hereby granted, free of charge, to any person obtaining a copy
    of this software and associated documentation files (the "Software"), to deal
    in the Software without restriction, including without limitation the rights
    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    copies of the Software, and to permit persons to whom the Software is
    furnished to do so, subject to the following conditions:

    The above copyright notice and this permission notice shall be included in all
    copies or substantial portions of the Software.

    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
    AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
    SOFTWARE.


2. FDLIBM -- expm1f, tanhf, atanf, log10f, log1pf
--------------------------------------------------

These reductions descend from FDLIBM, developed at SunPro, a Sun Microsystems,
Inc. business, and converted to single precision at Cygnus Support.  glibc
carries them substantially unmodified and presents them, in its own LICENSES
file, as Sun's code.  The notice below is the whole of the licence: its single
condition is that the notice be preserved, and this is that preservation.

    /*
     * ====================================================
     * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
     *
     * Developed at SunPro, a Sun Microsystems, Inc. business.
     * Permission to use, copy, modify, and distribute this
     * software is freely granted, provided that this notice
     * is preserved.
     * ====================================================
     */

Where ArWen must match a glibc 2.39 reference bit for bit, these
transcriptions follow glibc's versions of these files, which differ from other
FDLIBM descendants at a small number of points.  Through 2.6.5 there were
three: atanf's 2**25 large-argument threshold, the fabsf spelling in log10f's
zero path, and a redundant zero guard in tanhf.  Two of the three are gone at
2.6.6 because neither did any work -- tanhf's guard is unreachable behind the
|x| < 2**-55 branch, and log10f's zero path divided -2**25 by |x| only to
reach -inf -- and the two forms were compared on all 4,294,967,296 float32 bit
patterns with zero differing.  noahmp_energy.cu and noahmp_leaves.cu carry the
argument at the point of the edit.  lgammaf's 2**26 and 2**-30 thresholds were
on that list until 2.6.6 too; the lgammaf transcription is deleted, so nothing
here reproduces them any more.  atanf's threshold stays: it is a fact a
black-box measurement recovers rather than a spelling read from a source, and
the root NOTICE records that it was measured from the running library.


3. AER RRTMG -- the legacy RRTMG radiation kernels
--------------------------------------------------

rrtmg_lw.cu, rrtmg_sw.cu, rrtmg_lw_chain.cu, rrtmg_lw_taugb02_10_11_12.cu,
rrtmg_lw_taugb03_05.cu, rrtmg_lw_taugb06_09.cu, rrtmg_lw_taugb13_16.cu and
rrtmg_mcica_wrf.cu transcribe WRF v4.6.1's phys/module_ra_rrtmg_lw.F and
phys/module_ra_rrtmg_sw.F.  That code is the work of Atmospheric and
Environmental Research, Inc., not of UCAR, and WRF says so by preserving
AER's notice -- seven times in the longwave file, nine in the shortwave:

    Copyright 2002-2008, Atmospheric & Environmental Research, Inc. (AER).
    This software may be used, copied, or redistributed as long as it is
    not sold and this copyright notice is reproduced on each copy made.
    This model is provided as is without any express or implied warranties.
                          (http://www.rtweb.aer.com/)

All three copyright-year spans in which that notice appears are reproduced
in licenses/NOTICE-AER-RRTMG-as-distributed-with-WRF.txt.

ArWen takes this material under AER's own current grant instead: BSD
3-Clause, "Copyright (c) 2020, Atmospheric and Environmental Research",
published by AER at https://github.com/AER-RC/RRTMG_LW and .../RRTMG_SW.  A
copyright holder may licence its own work on any terms it chooses, and that
offer is public, current and unconditional.  The BSD-3-Clause text is in
licenses/LICENSE-AER-RRTMG-BSD-3-Clause.txt and beside the packaged
coefficients in gpuwm/data/wrf_radiation/.


4. RTE+RRTMGP -- the default radiation kernels
----------------------------------------------

rrtmgp_gas.cu, rrtmgp_cloud.cu, rrtmgp_mcica.cu, rrtmgp_rte.cu,
rrtmgp_validation.cu and rrtmgp_planck_common.cuh transcribe
earth-system-radiation/rte-rrtmgp at commit
fa107a16120051c4124305c6b3d4c87059119f58, which each file's own header
cites.  That project is BSD 3-Clause:

    Copyright (c) 2015-2025, Atmospheric and Environmental Research,
      Regents of the University of Colorado,
      Trustees of Columbia University in the City of New York.
    All rights reserved.

Clause 1 requires a source redistribution to retain that notice, the list of
conditions and the disclaimer.  The full text is in
licenses/LICENSE-RTE-RRTMGP-BSD-3-Clause.txt.  It is a DIFFERENT work from
the rrtmgp-data k-distribution files, which carry their own, earlier
copyright line and ship beside the data in the companion gpuwm-data
distribution.


5. Numerical Recipes Software -- the GAMMLN log-gamma coefficients
------------------------------------------------------------------

nssl2_fused_gs.cu's wrf_gamma_dp, and the THOMPSON_AA_CC* tables in
thompson_aerosol_common.cuh that were produced with it, carry the Lanczos
g=5, n=6 coefficient set and evaluation that WRF v4.6.1 takes from Numerical
Recipes.  WRF preserves the notice immediately above and below REAL FUNCTION
GAMMLN(XX) at phys/module_mp_thompson.F:5325-5347:

    (C) Copr. 1986-92 Numerical Recipes Software 2.02

It is preserved here for the same reason.  ArWen's position on this material
-- taken from WRF, reproduced in order to match WRF bit for bit, and the
standard published Lanczos coefficient set -- is set out in full, including
the argument against it, in licenses/NOTICE-Numerical-Recipes.txt.


6. CORE-MATH -- tanf, asinf, acosf, atanf, log10f
------------------------------------------------

The glibc_tanf, glibc_asinf, glibc_acosf and glibc_atanf functions in
gpuwm/core/kernels/glibc_trig_flt32.cuh transcribe the CORE-MATH
correctly-rounded binary32 implementations distributed in glibc 2.43.
Their sources under glibc's sysdeps/ieee754/flt-32/ record these upstream
CORE-MATH paths and revisions:

    s_tanf.c: src/binary32/tan/tanf.c, 59d21d7
    e_asinf.c: src/binary32/asin/asinf.c, bc385c2
    e_acosf.c: src/binary32/acos/acosf.c, 56dd347
    s_atanf.c: src/binary32/atan/atanf.c, a8066a5
    s_asincosf_data.c: src/binary32/asin/asinf.c, bc385c2

The common asinf/acosf coefficient tables are included in that scope.
These files carry MIT permission directly, including in glibc's copies.
The atanf here is CORE-MATH; the older FDLIBM atanf transcriptions in
other files remain covered by the separate Sun notice. No FDLIBM code
is transcribed in glibc_trig_flt32.cuh.

The ubm_log10f and ubm_log10f_special functions in
gpuwm/core/kernels/urban_bem.cuh transcribe CORE-MATH's correctly-rounded
binary32 log10f as glibc 2.43 carries it (sysdeps/ieee754/flt-32/
e_log10f.c: src/binary32/log10/log10f.c, bc385c2), Copyright (c)
2022-2023 Alexei Sibidanov, under the same MIT permission. That file
carries the copyright line and the permission notice beside the code.
ubm_atanf there is a call to glibc_atanf above, not a transcription.

The noah_log10 and noah_log10_special functions in
gpuwm/core/kernels/noah_mosaic.cu transcribe the same CORE-MATH log10f
(bc385c2, Copyright (c) 2022-2023 Alexei Sibidanov, the same MIT
permission) for the Noah mosaic column, whose TDFCND takes LOG10 of the
soil saturation ratio; that file too carries the copyright line and the
permission notice beside the code.

Both upstream copyright-year lines and the exact common permission text
are reproduced in licenses/LICENSE-CORE-MATH-MIT.txt, in the header and
beside the code in gpuwm/core/kernels/LICENSE-third-party.txt. MIT
requires the copyright and permission notice in copies or substantial
portions of this work:

    Copyright (c) 2022-2024 Alexei Sibidanov.
    Copyright (c) 2023-2024 Alexei Sibidanov.

    Permission is hereby granted, free of charge, to any person obtaining a copy
    of this software and associated documentation files (the "Software"), to deal
    in the Software without restriction, including without limitation the rights
    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    copies of the Software, and to permit persons to whom the Software is
    furnished to do so, subject to the following conditions:

    The above copyright notice and this permission notice shall be included in all
    copies or substantial portions of the Software.

    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
    AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
    SOFTWARE.


7. The scope of the six grants above
-------------------------------------

Each is stated by routine or by file on purpose.  They cover what sections 1
to 6 name and nothing else.  Other code in this directory -- including other
transcriptions, and including gfk_tgamma in glibc_flt32.cuh, which is
ArWen's own work -- takes nothing from Arm, Sun, AER, the RTE+RRTMGP
copyright holders, Numerical Recipes or CORE-MATH, and is not offered to a reader on
the strength of these notices.  Its provenance is recorded where it lives:
in the repository NOTICE, in PROVENANCE.md, and in each file's own header.


ADDENDUM. The binary64 libm of the UW boundary layer (glibc_flt64.cuh)
-----------------------------------------------------------------------

glibc_flt64.cuh is prepended to uwpbl.cu (bl_pbl_physics = 9) and carries
its notice inline.  It transcribes, by routine:

a. Arm optimized-routines (MIT) -- binary64 exp, log and pow and their data
   tables (math/exp.c, exp_data.c, log.c, log_data.c, pow.c,
   pow_log_data.c).  Source notices: "Copyright (c) 2018-2026, Arm
   Limited.", SPDX-License-Identifier: MIT.  The permission text is
   section 1's.

b. CORE-MATH (MIT) -- binary64 cos and acos, correctly rounded.  glibc's own
   binary64 cos and acos (IBM, LGPL) are not transcribed anywhere in this
   repository.

The upstream files are kept verbatim, sha256-pinned, at
tools/uwpbl_wrf471_oracle/libm64/upstream/.  These two grants cover the
routines named here and nothing else, on the terms section 6 states for the
others.  CORE-MATH's copyright lines and permission notice, reproduced as
MIT requires (also at licenses/LICENSE-CORE-MATH-binary64-MIT.txt):

    Copyright (c) 2022-2025 Paul Zimmermann and Tom Hubrecht
    Copyright (c) 2024-2025 Alexei Sibidanov.

    These files are part of the CORE-MATH project
    (https://core-math.gitlabpages.inria.fr/).

    Permission is hereby granted, free of charge, to any person obtaining a copy
    of this software and associated documentation files (the "Software"), to deal
    in the Software without restriction, including without limitation the rights
    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    copies of the Software, and to permit persons to whom the Software is
    furnished to do so, subject to the following conditions:

    The above copyright notice and this permission notice shall be included in all
    copies or substantial portions of the Software.

    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
    AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
    SOFTWARE.
