Skip to content

[278] Reject negative NPP allocation inputs - #405

Open
Nitir4 wants to merge 2 commits into
PecanProject:masterfrom
Nitir4:278-reject-negative-allocations
Open

Nitir4 wants to merge 2 commits into
PecanProject:masterfrom
Nitir4:278-reject-negative-allocations

Conversation

@Nitir4

@Nitir4 Nitir4 commented Oct 12, 2026 •

Copy link
Copy Markdown

Summary

Reject negative leafAllocation, woodAllocation, and fineRootAllocation during model setup. For example, (-0.125, 0.25, 0.25) previously passed ensureAllocation() because the derived coarse-root fraction was positive (0.625). It now reports the supplied values through logError() and exits with EXIT_CODE_BAD_PARAMETER_VALUE (3).

Keep the existing individual upper bounds and coarse-root remainder check. Add a focused allocation regression, document the input constraints, and update the changelog.

This addresses the allocation lower-bound subtask of #278. The broader parameter, climate, and event validation work remains outside this PR. No nonfinite-input or rounding-tolerance changes are included.

How was this change tested?

  • make test: all 26 registered test executables passed, including 17 allocation cases. Four active smoke scenarios (niwot, russell_1, russell_2, russell_3) matched model, event, and configuration references. The smoke summary reports 5/5 with one forced pass because russell_4 is skipped.
  • make testrun: passed. The unit wrapper's PASS/FAIL table was also inspected rather than relying only on its shell exit status.
  • clang-format 19.1.7: changed-line check reported no changes; the new regression file passed --dry-run --Werror.
  • git diff --check: passed.

No smoke reference outputs were changed. Local clang-tidy was unavailable.

Reproduction steps

The new testAllocation.c exercises negative values in each supplied allocation, a small negative value, valid zero/interior/exact-boundary cases, individual values at or above one, and a sum above one. It checks error code 3 and preserves the supplied fractions.

make
make -C tests/sipnet/test_sipnet_infrastructure testAllocation
cd tests/sipnet/test_sipnet_infrastructure
./testAllocation

Expected final line: PASSED testAllocation (17 cases).

Related issues

Checklist

  • Related issue and scope are listed above.
  • Maintainer assignment/approval received under the contribution workflow.
  • PR title includes the issue number.
  • Regression tests added and registered.
  • Parameter documentation updated.
  • docs/CHANGELOG.md updated.
  • Code checked with clang-format.

Copilot AI balanced review requested due to automatic review settings October 12, 2026 10:59

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants