Skip to content

Commit

Permalink
Fix #10899
Browse files Browse the repository at this point in the history
The issue was that an if else ladder inside a loop was incorrectly refactored to a switch case:

This was the original thing
```c++
for (int i = ....) {
  SELECT_CASE_var = XXXX
  if (SELECT_CASE_var == blabla) {
    break; // THIS BREAKS THE FOR LOOP
   } else ...
}
```

The refactor:

```c++
for (int i = ....) {
  switch (XXX) {
  case blabla:
    break; // THIS DO NOT BREAK THE FOR LOOP, it just prevents other `case`s to be processed (fallthrough)
  }
  ...
 }
```

255e7e939fc?w=1#diff-79e778e07bedf79acf027aa76c1235badd89a6f3014b6f0cdadc4ada74402ae3R3817-R3827
  • Loading branch information
jmarrec committed Jan 21, 2025
1 parent ca35498 commit 78f9058
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/EnergyPlus/OutputReportTabular.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3767,7 +3767,11 @@ void GatherMonthlyResultsForTimestep(EnergyPlusData &state, OutputProcessor::Tim
// If the hours variable is active then scan through the rest of the variables
// and accumulate
if (activeHoursShown) {
bool exit_loop = false;
for (int kOtherColumn = jColumn + 1; kOtherColumn <= ort->MonthlyTables(iTable).numColumns; ++kOtherColumn) {
if (exit_loop) {
break;
}
int const scanColumn = kOtherColumn + ort->MonthlyTables(iTable).firstColumn - 1;
OutputProcessor::VariableType const scanTypeOfVar = ort->MonthlyColumns(scanColumn).typeOfVar;
int const scanVarNum = ort->MonthlyColumns(scanColumn).varNum;
Expand All @@ -3781,6 +3785,7 @@ void GatherMonthlyResultsForTimestep(EnergyPlusData &state, OutputProcessor::Tim
case AggType::HoursNegative:
case AggType::HoursNonNegative:
// end scanning since these might reset
exit_loop = true;
break; // do
case AggType::SumOrAverageHoursShown: {
// this case is when the value should be set
Expand Down

3 comments on commit 78f9058

@nrel-bot-2
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

10899_OutputTableMonthly_DuringHours (jmarrec) - x86_64-Linux-Ubuntu-24.04-gcc-13.3: OK (2921 of 2921 tests passed, 0 test warnings)

Build Badge Test Badge

@nrel-bot-2
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

10899_OutputTableMonthly_DuringHours (jmarrec) - x86_64-Linux-Ubuntu-24.04-gcc-13.3-UnitTestsCoverage-RelWithDebInfo: OK (2103 of 2103 tests passed, 0 test warnings)

Build Badge Test Badge Coverage Badge

@nrel-bot-2
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

10899_OutputTableMonthly_DuringHours (jmarrec) - x86_64-Linux-Ubuntu-24.04-gcc-13.3-IntegrationCoverage-RelWithDebInfo: OK (801 of 801 tests passed, 0 test warnings)

Build Badge Test Badge Coverage Badge

Please sign in to comment.