Skip to content

module_sf_sfclay sfclay1d: (g/tgdsa*pblh*fluxc)**.33 with zero base raises FP invalid on timestep 1; aborts under -Ktrap #1509

Description

@mordisdevone

Summary

sfclay1d in src/core_atmosphere/physics/physics_wrf/module_sf_sfclay.F computes

fluxc = max(hfx(i)/rhox(i)/cp + ep1*tskv*qfx(i)/rhox(i), 0.)
VCONV = vconvc*(g/tgdsa(i)*pblh(i)*fluxc)**.33          ! line 510

On the first timestep (pblh not yet diagnosed, and/or fluxc clamped to 0) the base of the real-exponent power is exactly zero. The result (0) is correct, but the power raises the FP invalid-operation flag inside the math library, so with trapping enabled (-Ktrap=fp,inv,ovf, NVHPC 25.11) the run aborts at timestep 1.

Observed (MPAS-A 8.4.1 at 91c5eac, sf_monin_obukhov + YSU, 240 km x1.10242, NVHPC 25.11)

Caught signal 8 (Floating point exception: floating-point invalid operation)
 2 0x... module_sf_sfclay_sfclay1d_()  .../physics_wrf/module_sf_sfclay.F:510

Without trapping the model runs normally and produces finite output.

Why it matters

It prevents using FP trapping as a whole-model check on MPAS physics, and the correct-by-accident result relies on the library's tolerant pow(0, y) path. A guard (if (pblh(i)*fluxc > 0.) then ... else VCONV = 0.) or a max(..., tiny) base would make the statement well-defined at the endpoint with no change for nonzero inputs. Happy to open a PR if wanted. (The same pattern exists in MYNN's psi_init; reported separately to NCAR/MMM-physics.)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions