Skip to content

SIP256 Leaf on/off events#326

Draft
Alomir wants to merge 6 commits intomasterfrom
SIP256-Leaf-on-off-events
Draft

SIP256 Leaf on/off events#326
Alomir wants to merge 6 commits intomasterfrom
SIP256-Leaf-on-off-events

Conversation

@Alomir
Copy link
Copy Markdown
Collaborator

@Alomir Alomir commented Apr 23, 2026

Summary

  • What: Add leaf-on/leaf-off events
  • Motivation: Needed by PEcAn

How was this change tested?

List steps taken to test this change, with appropriate outputs if applicable

If changes are needed for any sipnet.out files in the test/smoke subdirectories, then include output from
tools/smoke_check.py by running the commands below and pasting the output at the end of this PR. Note that
this must be run BEFORE submitting changes to any sipnet.out files.

make smoke
python tools/smoke_check.py run verbose <list tests/smoke subdirectories with changed outputs>

Run python tools/smoke_check.py help for more info.

TBD

Related issues

Checklist

  • Related issues are listed above. PRs without an approved, related issue may not get reviewed.
  • PR title has the issue number in it ("[#] <concise description of proposed change>")
  • Tests added/updated for new features (if applicable)
  • Documentation updated (if applicable)
  • docs/CHANGELOG.md updated with noteworthy changes
  • Code formatted with clang-format (run git clang-format if needed)

Note: See CONTRIBUTING.md for additional guidance. This repository uses automated formatting checks; if the pre-commit hook blocks your commit, run git clang-format to format staged changes.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 23, 2026

Cpp-Linter Report ⚠️

Some files did not pass the configured checks!

clang-format (v19.1.1) reports: 4 file(s) not formatted
  • src/sipnet/events.c
  • src/sipnet/sipnet.c
  • tests/sipnet/test_events_types/testEventLeafOnOff.c
  • tests/sipnet/test_modeling/testBalance.c

Have any feedback or feature suggestions? Share it here.

@Alomir
Copy link
Copy Markdown
Collaborator Author

Alomir commented Apr 23, 2026

@copilot Please update unit tests for these changes by:

  1. Update tests/sipnet/test_modeling.c to include the relevant changes
  2. Create a new test in tests/sipnet/test_event_types/testEventLeafOnOff.c in the style of the other tests in that directory

Copilot AI and others added 3 commits April 23, 2026 20:34
Agent-Logs-Url: https://github.com/PecanProject/sipnet/sessions/3491dabf-5167-435f-b694-ee10c5d4ca0e

Co-authored-by: Alomir <1099935+Alomir@users.noreply.github.com>
- Fix resetFluxes() placement in sipnet.c: move from calculateFluxes() to
  updateState() before processEvents(), so event fluxes are visible during N
  limitation calculations
- Fix LEAFON/LEAFOFF param parsing in events.c: use numRead > 0 instead of
  != 0 to handle empty/whitespace-only param strings (sscanf returns EOF=-1
  for empty input, not 0)
- Fix LEAFOFF event bug: use plantLeafC instead of plantWoodC when computing
  how much leaf C falls
- Update russell_2 smoke test reference output to use correct fert event
  field names (eventLitterN instead of eventOrgN)
- Update russell_1/2/3 smoke test reference outputs to reflect correct model
  behavior with working irrigation events
- Add tests/sipnet/test_events_types/testEventLeafOnOff.c
- Add event input files for leaf on/off tests
- Add tests/sipnet/test_modeling/events_leaf.in
- Update tests/sipnet/test_modeling/testBalance.c with testBalanceLeafEvents()"

Agent-Logs-Url: https://github.com/PecanProject/sipnet/sessions/3491dabf-5167-435f-b694-ee10c5d4ca0e

Co-authored-by: Alomir <1099935+Alomir@users.noreply.github.com>
Agent-Logs-Url: https://github.com/PecanProject/sipnet/sessions/3491dabf-5167-435f-b694-ee10c5d4ca0e

Co-authored-by: Alomir <1099935+Alomir@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 23, 2026

@copilot Please update unit tests for these changes by:

  1. Update tests/sipnet/test_modeling.c to include the relevant changes
    ...

Done in commit 73a7611. Here's what was added:

  1. tests/sipnet/test_events_types/testEventLeafOnOff.c — tests 5 scenarios: one leaf-on event, two leaf-on events, one leaf-off event (no N cycle), one leaf-off event (with N cycle, verifying N goes to litter), and one leaf-off event without litter pool (verifying C goes to soilC). New event input files events_one_leafon.in, events_two_leafon.in, events_one_leafoff.in, events_two_leafoff.in were also added.

  2. tests/sipnet/test_modeling/testBalance.c — added testBalanceLeafEvents() which runs the model with event-based leaf-on (day 46) and leaf-off (day 50) and verifies carbon/nitrogen balance is maintained at each time step.

Three bugs were also fixed in the process:

  • resetFluxes() was inside calculateFluxes() which zeroed event fluxes before pool updates — moved to updateState() before processEvents()
  • LEAFON/LEAFOFF param parsing used numRead != 0 which incorrectly triggered an error on empty strings (sscanf returns EOF=-1, not 0, for empty input) — changed to numRead > 0
  • LEAFOFF event used plantWoodC instead of plantLeafC to compute how much leaf C falls

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.

Allow leaf on/leaf off to be specified as actual events

2 participants