Skip to content

Commit 4852b22

Browse files
authored
Merge pull request #10201 from NREL/6919-FixBlankNameOutTabSumRep
Fix 6919 when blanks are present in some tabular output reports
2 parents 993f569 + 504183d commit 4852b22

File tree

4 files changed

+113
-6
lines changed

4 files changed

+113
-6
lines changed

src/EnergyPlus/OutputReportTabular.cc

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,10 @@ void GetInputTabularMonthly(EnergyPlusData &state)
366366
int const curTable = AddMonthlyReport(state, AlphArray(1), int(NumArray(1)));
367367
for (int jField = 2; jField <= NumAlphas; jField += 2) {
368368
if (AlphArray(jField).empty()) {
369-
ShowFatalError(state, "Blank report name in Output:Table:Monthly");
369+
ShowWarningError(state,
370+
format("{}: Blank column specified in '{}', need to provide a variable or meter name ",
371+
CurrentModuleObject,
372+
ort->MonthlyInput(TabNum).name));
370373
}
371374
std::string const curAggString = AlphArray(jField + 1);
372375
AggType curAggType; // kind of aggregation identified (see AggType parameters)
@@ -402,7 +405,9 @@ void GetInputTabularMonthly(EnergyPlusData &state)
402405
ShowWarningError(state, format("{}={}, Variable name={}", CurrentModuleObject, ort->MonthlyInput(TabNum).name, AlphArray(jField)));
403406
ShowContinueError(state, format("Invalid aggregation type=\"{}\" Defaulting to SumOrAverage.", curAggString));
404407
}
405-
AddMonthlyFieldSetInput(state, curTable, AlphArray(jField), "", curAggType);
408+
if (!AlphArray(jField).empty()) {
409+
AddMonthlyFieldSetInput(state, curTable, AlphArray(jField), "", curAggType);
410+
}
406411
}
407412
}
408413
}
@@ -1492,7 +1497,7 @@ void GetInputOutputTableSummaryReports(EnergyPlusData &state)
14921497
for (int iReport = 1; iReport <= NumAlphas; ++iReport) {
14931498
bool nameFound = false;
14941499
if (AlphArray(iReport).empty()) {
1495-
ShowFatalError(state, "Blank report name in Output:Table:SummaryReports");
1500+
ShowWarningError(state, "Blank report name in Output:Table:SummaryReports");
14961501
} else if (Util::SameString(AlphArray(iReport), "AnnualBuildingUtilityPerformanceSummary")) {
14971502
ort->displayTabularBEPS = true;
14981503
ort->WriteTabularFiles = true;

src/EnergyPlus/OutputReportTabularAnnual.cc

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,10 @@ void GetInputTabularAnnual(EnergyPlusData &state)
130130
for (jAlpha = 4; jAlpha <= numAlphas; jAlpha += 2) {
131131
curVarMtr = alphArray(jAlpha);
132132
if (curVarMtr.empty()) {
133-
ShowFatalError(state, "Blank report name in Output:Table:Annual");
133+
ShowWarningError(state,
134+
format("{}: Blank column specified in '{}', need to provide a variable or meter or EMS variable name ",
135+
currentModuleObject,
136+
alphArray(1)));
134137
}
135138
if (jAlpha <= numAlphas) {
136139
std::string aggregationString = alphArray(jAlpha + 1);
@@ -144,7 +147,9 @@ void GetInputTabularAnnual(EnergyPlusData &state)
144147
} else {
145148
curNumDgts = 2;
146149
}
147-
annualTables.back().addFieldSet(curVarMtr, curAgg, curNumDgts);
150+
if (!curVarMtr.empty()) {
151+
annualTables.back().addFieldSet(curVarMtr, curAgg, curNumDgts);
152+
}
148153
}
149154
annualTables.back().setupGathering(state);
150155
} else {
@@ -1353,7 +1358,9 @@ std::vector<Real64> AnnualTable::calculateBins(int const numberOfBins,
13531358
} else {
13541359
// determine which bin the results are in
13551360
binNum = int((*valueIt - bottomOfBins) / intervalSize);
1356-
returnBins[binNum] += *elapsedTimeIt;
1361+
if (binNum < numberOfBins && binNum >= 0) {
1362+
returnBins[binNum] += *elapsedTimeIt;
1363+
}
13571364
}
13581365
++elapsedTimeIt;
13591366
}

tst/EnergyPlus/unit/OutputReportTabular.unit.cc

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12772,6 +12772,64 @@ TEST_F(EnergyPlusFixture, OutputReportTabularMonthly_WarnMonthlyDisplayExtraWarn
1277212772
compare_err_stream(expected_error);
1277312773
}
1277412774

12775+
TEST_F(EnergyPlusFixture, OutputReportTabularMonthly_WarnMonthlyBlankVariable)
12776+
{
12777+
// #6919 - Warn instead of fatal on blank monthly table
12778+
std::string const idf_objects = delimited_string({
12779+
"Output:Table:Monthly,",
12780+
" Space Gains Annual Report, !- Name",
12781+
" 2, !- Digits After Decimal",
12782+
" , !- Variable or Meter 1 Name",
12783+
" SumOrAverage; !- Aggregation Type for Variable or Meter 1",
12784+
12785+
"Output:Table:SummaryReports,",
12786+
" AllSummaryAndMonthly; !- Report 1 Name",
12787+
});
12788+
12789+
ASSERT_TRUE(process_idf(idf_objects));
12790+
12791+
Real64 extLitUse;
12792+
12793+
SetupOutputVariable(*state,
12794+
"Exterior Lights Electricity Energy",
12795+
Constant::Units::J,
12796+
extLitUse,
12797+
OutputProcessor::SOVTimeStepType::Zone,
12798+
OutputProcessor::SOVStoreType::Summed,
12799+
"Lite1",
12800+
Constant::eResource::Electricity,
12801+
OutputProcessor::SOVEndUseCat::ExteriorLights,
12802+
"General");
12803+
12804+
SetupOutputVariable(*state,
12805+
"Exterior Lights Electricity Energy",
12806+
Constant::Units::J,
12807+
extLitUse,
12808+
OutputProcessor::SOVTimeStepType::Zone,
12809+
OutputProcessor::SOVStoreType::Summed,
12810+
"Lite2",
12811+
Constant::eResource::Electricity,
12812+
OutputProcessor::SOVEndUseCat::ExteriorLights,
12813+
"General");
12814+
12815+
state->dataGlobal->DoWeathSim = true;
12816+
state->dataGlobal->KindOfSim = Constant::KindOfSim::RunPeriodWeather; // Trigger the extra warning
12817+
state->dataGlobal->TimeStepZone = 0.25;
12818+
state->dataGlobal->TimeStepZoneSec = state->dataGlobal->TimeStepZone * 60.0;
12819+
state->dataGlobal->DisplayExtraWarnings = true;
12820+
12821+
GetInputTabularMonthly(*state);
12822+
EXPECT_EQ(state->dataOutRptTab->MonthlyInputCount, 1);
12823+
GetInputOutputTableSummaryReports(*state);
12824+
EXPECT_EQ(state->dataOutRptTab->MonthlyInputCount, numNamedMonthly + 1);
12825+
12826+
InitializeTabularMonthly(*state);
12827+
12828+
std::string const expected_error = delimited_string(
12829+
{" ** Warning ** Output:Table:Monthly: Blank column specified in 'SPACE GAINS ANNUAL REPORT', need to provide a variable or meter name "});
12830+
compare_err_stream(expected_error);
12831+
}
12832+
1277512833
TEST_F(EnergyPlusFixture, OutputReportTabularMonthly_NoWarnMonthlIfNoWeatherFileRun)
1277612834
{
1277712835
// #9621 - Only warn if a bad variable is defined in a Monthly table user requested, not on the AllSummaryAndMonthly ones

tst/EnergyPlus/unit/OutputReportTabularAnnual.unit.cc

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -566,3 +566,40 @@ TEST_F(SQLiteFixture, OutputReportTabularAnnual_CurlyBraces)
566566
EXPECT_TRUE(false) << "Missing braces in monthly table for : " << colHeader;
567567
}
568568
}
569+
570+
TEST_F(EnergyPlusFixture, OutputReportTabularAnnual_WarnBlankVariable)
571+
{
572+
std::string const idf_objects = delimited_string({
573+
"Output:Table:Annual,",
574+
"Space Gains Annual Report, !- Name",
575+
"Filter1, !- Filter",
576+
"Schedule2, !- Schedule Name",
577+
"Zone People Total Heating Energy, !- Variable or Meter 1 Name",
578+
"SumOrAverage, !- Aggregation Type for Variable or Meter 1",
579+
"4, !- field Digits After Decimal 1",
580+
", !- Variable or Meter 2 Name",
581+
"hoursNonZero, !- Aggregation Type for Variable or Meter 2",
582+
", !- field Digits After Decimal 2",
583+
"Zone Electric Equipment Total Heating Energy; !- Variable or Meter 3 Name",
584+
});
585+
586+
ASSERT_TRUE(process_idf(idf_objects));
587+
588+
state->dataGlobal->DoWeathSim = true;
589+
590+
EXPECT_FALSE(state->dataOutRptTab->WriteTabularFiles);
591+
GetInputTabularAnnual(*state);
592+
EXPECT_TRUE(state->dataOutRptTab->WriteTabularFiles);
593+
594+
EXPECT_EQ(state->dataOutputReportTabularAnnual->annualTables.size(), 1u);
595+
596+
std::vector<AnnualTable>::iterator firstTable = state->dataOutputReportTabularAnnual->annualTables.begin();
597+
598+
std::vector<std::string> tableParams = firstTable->inspectTable();
599+
600+
std::string const expected_error = delimited_string({" ** Warning ** Output:Table:Annual: Blank column specified in 'SPACE GAINS ANNUAL "
601+
"REPORT', need to provide a variable or meter or EMS variable name ",
602+
" ** Warning ** Invalid aggregation type=\"\" Defaulting to SumOrAverage."});
603+
604+
compare_err_stream(expected_error);
605+
}

0 commit comments

Comments
 (0)