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 issue #514: Output correct block averages first time after restart #517

Merged
merged 1 commit into from
Sep 13, 2023
Merged
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
20 changes: 7 additions & 13 deletions src/BlockOutput.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,21 +110,15 @@ struct BlockAverages : OutputableBase {
void InitVals(config_setup::EventSettings const &event) {
stepsPerOut = event.frequency;
invSteps = 1.0 / stepsPerOut;
if (startStep != 0) {
firstInvSteps = invSteps;
//Handle the case where we are restarting from a checkpoint and the first
//interval is smaller than expected because we create a checkpoint more
//often than the Block output frequency.
if (startStep != 0 && (startStep % stepsPerOut) != 0) {
ulong diff;
if (stepsPerOut >= startStep) {
diff = stepsPerOut - startStep;
} else {
diff = startStep - stepsPerOut;
}
firstInvSteps = 1.0 / diff;
} else {
firstInvSteps = invSteps;
diff = stepsPerOut - (startStep % stepsPerOut);
firstInvSteps = 1.0/diff;
}
// We only subtract the firstInvSteps on
// the first print with startStep != 0
// invSteps - firstInvSteps = 1/(stepsPerOut-startStep)
// After the first print
enableOut = event.enable;
}
void AllocBlocks(void);
Expand Down