Add --debug-log logs for internal model state - #352
Conversation
--debug-output logs for internal model state
|
Addressed in |
|
@copilot Please remove the |
Addressed in |
|
@copilot please rename |
Addressed in |
|
@copilot Please change all new names such as |
Addressed in |
|
Addressed in |
--debug-output logs for internal model state--debug-log logs for internal model state
There was a problem hiding this comment.
Pull request overview
Adds an optional per-timestep “debug state” logging facility to SIPNET, wiring a new CLI flag through context handling and the model loop to emit additional structured outputs for internal state.
Changes:
- Adds
--debug-log <prefix>CLI support plusDEBUG_LOG_PREFIXcontext/config plumbing. - Introduces
src/sipnet/debug_log.{c,h}and integrates header/state row emission intorunModelOutput(). - Adds an infrastructure test and updates smoke expected config dumps/docs to reflect the new context key.
Reviewed changes
Copilot reviewed 18 out of 18 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/smoke/russell_3/sipnet.config | Updates expected config dump to include DEBUG_LOG_PREFIX. |
| tests/smoke/russell_2/sipnet.config | Updates expected config dump to include DEBUG_LOG_PREFIX. |
| tests/smoke/russell_1/sipnet.config | Updates expected config dump to include DEBUG_LOG_PREFIX. |
| tests/smoke/niwot/sipnet.config | Updates expected config dump to include DEBUG_LOG_PREFIX. |
| tests/sipnet/test_sipnet_infrastructure/testDebugLogFiles.c | Adds infrastructure test verifying debug log creation/headers/row counts. |
| tests/sipnet/test_sipnet_infrastructure/Makefile | Registers the new infrastructure test and cleans its artifacts. |
| src/sipnet/sipnet.h | Extends runModelOutput() API to accept debug log file handles. |
| src/sipnet/sipnet.c | Emits debug headers/rows and initializes/frees debug field arrays. |
| src/sipnet/frontend.c | Initializes/opens/closes debug log files and passes them into the model run. |
| src/sipnet/debug_log.h | Declares debug logging API and DebugLogFiles handles. |
| src/sipnet/debug_log.c | Implements debug logging (headers + per-timestep rows). |
| src/sipnet/cli.c | Adds --debug-log argument parsing and help text. |
| src/common/context.h | Adds debugLogPrefix to the global context struct. |
| src/common/context.c | Registers DEBUG_LOG_PREFIX in context initialization. |
| Makefile | Adds debug_log.c to the build. |
| docs/user-guide/running-sipnet.md | Documents the new debug log feature (but needs key-name correction). |
| docs/user-guide/model-inputs.md | Documents the new option (but had inconsistent formatting). |
| CMakeLists.txt | Adds debug_log.c and the new test to the CLion/IDE build config. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Note: copilot review comments above are valid, will fix tomorrow |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Adds a new CLI option to emit per-timestep debug logs for SIPNET internal state. When enabled, the run produces structured
envi,fluxes, andtrackerslogs with headers derived from the current global state structs.CLI and output lifecycle
--debug-log <prefix>to configure debug log output with an arbitrary prefix/path.<prefix>_envi.log<prefix>_fluxes.log<prefix>_trackers.logPer-timestep debug logging
year day time, matchingsipnet.out.Structured field coverage
*_envi.log: one column perenvifield, using the field name directly.*_fluxes.log: one column perfluxesfield, using the field name directly.*_trackers.log: one column pertrackersfield witht.prefix, plusphenologyTrackersfields withpt.prefix.Config and documentation
Focused coverage
--debug-output, verifies all three files are created, checks representative headers, and confirms row counts matchsipnet.out.Example:
Outputs: