From 78f9058ae5c23f31042f2b91d9bf85ecfcf1dc69 Mon Sep 17 00:00:00 2001 From: Julien Marrec Date: Mon, 20 Jan 2025 19:24:46 +0100 Subject: [PATCH] Fix #10899 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) } ... } ``` https://github.com/NREL/EnergyPlus/commit/255e7e939fc?w=1#diff-79e778e07bedf79acf027aa76c1235badd89a6f3014b6f0cdadc4ada74402ae3R3817-R3827 --- src/EnergyPlus/OutputReportTabular.cc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/EnergyPlus/OutputReportTabular.cc b/src/EnergyPlus/OutputReportTabular.cc index e18c3cffa7b..0ebe7b60b38 100644 --- a/src/EnergyPlus/OutputReportTabular.cc +++ b/src/EnergyPlus/OutputReportTabular.cc @@ -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; @@ -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