Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bug with alarms after clock direction change. #29

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/Infrastructure/TimeMgr/src/ESMCI_Clock.C
Original file line number Diff line number Diff line change
Expand Up @@ -566,6 +566,7 @@ int Clock::count=0;
#define ESMC_METHOD "ESMCI::Clock::advance()"

int rc = ESMF_SUCCESS;
bool userChangedDirLocal;

if (this == ESMC_NULL_POINTER) {
ESMC_LogDefault.MsgFoundError(ESMC_RC_PTR_NULL,
Expand Down Expand Up @@ -638,11 +639,21 @@ int Clock::count=0;
ringingAlarmList1stElementPtr);
}

// Each alarm sets userChangedDirection to false in checkRingTime,
// so only the first alarm knows if the user changed direction.
// To remedy this, we'll save userChangedDirection and reset
// the clock's userChangedDirection before each alarm. After
// the last alarm::checkRingTime, this->userChangedDirection
// will be false. This is not the most efficient fix, but
// requires the least code changing to achieve it.
userChangedDirLocal = this->userChangedDirection;

// traverse alarm list (i) for ringing alarms (j)
for(int i=0, j=0; i<alarmCount; i++) {
int rc;
bool ringing;

this->userChangedDirection = userChangedDirLocal;
// check each alarm to see if it's time to ring
ringing = alarmList[i]->Alarm::checkRingTime(&rc);

Expand Down