Skip to content

Commit

Permalink
Fix issue #514: Output correct block average values first time after …
Browse files Browse the repository at this point in the history
…restart
  • Loading branch information
LSchwiebert committed Sep 12, 2023
1 parent ead59f2 commit ef9494b
Showing 1 changed file with 7 additions and 13 deletions.
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

0 comments on commit ef9494b

Please sign in to comment.