Conversation
|
When I asked Chad to "just make it work, please" (referring to the entire MAGic pipeline) Chad did this (among other things): master...dlebauer:sipnet:fix/zero-carbon-nitrogen-transfer And now that this is up he said:
|
|
@dlebauer I like that! Go Chad! |
|
I'm going to go ahead and make a PR for Chad's changes, rather than make this one bigger |
|
Moving to ready for review - I suspect copilot will point out some doc updates I missed. |
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Harvest deltas remain absent from pool look-ahead checks, and leaf-off logs can report pre-limitation values.
Review effort: Balanced
Findings: 2
Open (2)
What changed in this PR
Fixes harvest and leaf-off mass conservation by restructuring event processing, adding harvest termination handling, and expanding regression coverage.
Changes:
- Splits event processing into carbon and nitrogen passes.
- Tracks harvest routing and leaf-off fluxes more precisely.
- Adds comprehensive harvest, balance, restart, and event-output tests.
| File | Description |
|---|---|
src/common/exitCodes.h |
Adds allocation-failure exit code. |
src/common/util.c |
Implements dynamic strings. |
src/common/util.h |
Declares dynamic-string API. |
src/sipnet/balance.c |
Improves imbalance diagnostics. |
src/sipnet/debug_log.c |
Logs new flux and event fields. |
src/sipnet/events.c |
Splits event passes and revises harvest handling. |
src/sipnet/events.h |
Adds event logs and harvest trackers. |
src/sipnet/limitations.c |
Extends negative-pool limitation logic. |
src/sipnet/nitrogen.c |
Separates leaf-off nitrogen effects. |
src/sipnet/nitrogen.h |
Exposes leaf-off nitrogen helper. |
src/sipnet/restart.c |
Serializes expanded event trackers. |
src/sipnet/sipnet.c |
Integrates event passes and mortality correction. |
src/sipnet/state.c |
Adds combined leaf-litter accessor. |
src/sipnet/state.h |
Adds new event and leaf-off fluxes. |
tests/sipnet/test_events_infrastructure/events_output_header.out |
Updates expected event output. |
tests/sipnet/test_events_infrastructure/events_output_no_header.out |
Updates headerless event output. |
tests/sipnet/test_events_types/testEventHarvest.c |
Tests accounting-carbon harvests. |
tests/sipnet/test_modeling/Makefile |
Registers the harvest regression suite. |
tests/sipnet/test_modeling/termination.clim |
Adds regression climate fixture. |
tests/sipnet/test_modeling/termination.param |
Adds regression parameter fixture. |
tests/sipnet/test_modeling/testCompleteHarvest.c |
Adds comprehensive harvest regressions. |
tests/sipnet/test_modeling/testNitrogenCycle.c |
Updates event/N-cycle sequencing tests. |
tests/sipnet/test_modeling/testPlantMortality.c |
Uses expanded harvest trackers. |
tests/sipnet/test_sipnet_infrastructure/testDebugLogFiles.c |
Validates expanded debug output. |
tests/smoke/russell_2/events.out |
Updates smoke-test field ordering. |
tests/utils/helpers.c |
Updates test event processing flow. |
docs/CHANGELOG.md |
Documents harvest and leaf-off fixes. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| double leafOff = envi.plantLeafC * params.fracLeafFall; | ||
| fluxes.eventLeafOffLitterC += leafOff / climLen; | ||
|
|
||
| appendLog(event, 1, "eventLeafOffLitter", leafOff); |
There was a problem hiding this comment.
Yeah, fine, I was clearly ignoring this as these outputs are really just for debugging. However, we're in a decent place for doing this in a centralized/extendable way, so why not...
| double deficit = fluxes.leafOffLitter + fluxes.eventLeafOffLitterC - | ||
| fluxes.leafCreation - availableLeafRate; |
There was a problem hiding this comment.
This one is harder, as I don't think this is the best place to handle eventLeafC overdraws.
Hmm, maybe as a step between leaf-off litter and transfer to woodC... that might work. This will mess up the test, so more work there.

Summary
How was this change tested?
Related issues
Checklist
docs/CHANGELOG.mdupdated with noteworthy changesclang-format(rungit clang-formatif needed)