src/sipnet/frontend.cis the only production entrypoint (main): init context, parse CLI, readsipnet.in, validate options, derive file names, then run model.- Runtime core is in
src/sipnet/sipnet.c; each timestep followsupdateState():calculateFluxes()+processEvents()-> 2)updatePoolsAndBalance()-> 3) tracker updates.
- Keep flux math pure: mutate pools only in pool-update functions (
updateMainPools,updatePoolsForSoil,updatePoolsForEvents) as documented indocs/developer-guide/code-structure.md. - Events are translated into
fluxes.event*insrc/sipnet/events.c; they do not directly mutate pools (except tillage tracker decay path). - Global state lives in
src/sipnet/state.c(envi,trackers,fluxes,climatelinked list), so side effects are process-global.
- Authoritative build is GNU Make, not CMake:
make(default targetsipnet)make helpfor all targets
CMakeLists.txtis CLion assistance only (explicitly non-buildable for full project).- Unit tests:
make testbuildthenmake unit(wrappertools/run_unit_tests.shwalkstests/sipnet/*). - Smoke tests:
make smoke(scripttests/smoke/run_smoke.shruns each subdir, compares tracked outputs withgit diff, andgit restoressipnet.configtimestamp-only diffs). - Full local verification path used by CI intent:
make test. - Docs build path:
make document(docs/api/via Doxygen +site/via MkDocs).
- Logging: prefer
logInfo/logWarning/logError/logTestfromsrc/common/logging.h; avoid introducing rawprintfin runtime code. - Config naming is forgiving by design:
src/common/context.cnormalizes keys by stripping non-alphanumerics and lowercasing; keep new keys unique after normalization. - Context precedence is strict: default < input file < CLI < calculated (
ContextSourceinsrc/common/context.h). - Feature coupling is enforced in
validateContext():nitrogen-cyclerequires bothlitter-poolandanaerobic;anaerobicrequireswater-hresp;soil-phenolandgddare mutually exclusive. - When adding model flags, update both
NUM_CONTEXT_MODEL_FLAGS(src/common/context.h) and restart serialization checks (src/sipnet/restart.c).
- Restart checkpoints are strict schema contracts in
src/sipnet/restart.c; schema/layout drift requires coordinated updates to code, tests, and docs (docs/developer-guide/restart-checkpoint.md). - Event I/O contract (
events.in/events.out) is part of smoke and restart tests; changing event output formatting breaks regression checks. - Test pattern: each suite under
tests/sipnet/*has its ownMakefilewithTEST_CFILES; shared helpers intests/utils/tUtils.hand exit stubbing intests/utils/exitHandler.c. - Existing docs worth trusting first:
docs/README.md,docs/developer-guide/*.md;src/README.mdis marked TODO/stale.