Missed event across a year boundary silently blocks later events

Open
#421 4 comments 0 reactions 1 assignee View on GitHub

Maintainers usually reply within 2 days

@ANAMASGARD is already working on this.

Since Oct 27, 2026.

  • #428 by @ANAMASGARD — open

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
73/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
c
Domain
backend

Research direction

Start with processEventsForCarbon() and trace the date checks in nitrogen processing and event output, as the issue proposes. Build SIPNET with make and reproduce using the supplied climate and event records; add regression coverage for cross-year misses, same-year misses, and valid schedules. Done when an overdue event reports the missing climate record and exits with an error, while valid events still run.

Written by the indexing model from the issue text.

Description

Description:

An event without a matching climate record can block later events across a year boundary while SIPNET exits successfully.

Reproduced on master at 6c2193470f48076206eeea74b3a20c0753a55d9e.

Relationship to #74 / #77

This is a follow-up to #74 and #77. That PR fixed event ordering checks in the reader, but left the runtime date comparison unchanged. This reproducer uses correctly ordered events; the failure occurs when a climate date passes an unmatched event.

Steps to reproduce

From the repository root, build SIPNET and create an isolated run:

make

repo_dir="$(pwd)"
run_dir="$(mktemp -d)"
cp tests/sipnet/test_restart_infrastructure/restart.param \
  "$run_dir/run.param"

cat > "$run_dir/run.in" <<'EOF'
FILE_NAME run
EVENTS 1
EOF

cat > "$run_dir/run.clim" <<'EOF'
2016 100 0.00 1.0 20.0 15.0 0.0 0.0 1000.0 500.0 1000.0 2.0
2017 10 0.00 1.0 20.0 15.0 0.0 0.0 1000.0 500.0 1000.0 2.0
EOF

cat > "$run_dir/events.in" <<'EOF'
2016 200 till 0.2
2017 10 till 0.3
EOF

(
  cd "$run_dir" || exit 1
  "$repo_dir/sipnet" -i run.in --no-do-main-output
  printf 'Exit status: %s\n' "$?"
  cat events.out
)

Actual: Exit status is 0. events.out contains only its header; neither tillage is applied.

Expected: SIPNET should report the missing climate record for the event on 2016/200 and exit with an error when climate advances to 2017/10.

For comparison, removing the 2016/200 event allows the 2017/10 tillage to run successfully.

Cause and impact

processEventsForCarbon() uses:

event->year <= climYear && event->day <= climDay

For event 2016/200 and climate 2017/10, the day comparison is false, so the existing missing-climate error is never reached. The stale event remains at the front of the queue and blocks later events.

This can let automated runs accept results with missing management actions. If a later climate record reaches the blocked event’s day-of-year, the error is reported late instead.

Proposed approach

I propose comparing the complete (year, day) date so an overdue event triggers the existing error immediately. I will also review the matching predicates in nitrogen processing and event output for consistency, and add regression tests for missed events across year boundaries, same-year misses, and valid event schedules.

I would like to work on this issue and submit a fix PR.

Dominant language
C
Stars
42
Forks
38
Avg merge
3d 21h
Merged PRs (30d)
10

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from PecanProject/sipnet

All issues in PecanProject/sipnet

Similar issues

More C issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.