LCOV - code coverage report
Current view: top level - EnergyPlus - OutputReportTabular.cc (source / functions) Coverage Total Hit
Test: lcov.output.filtered Lines: 77.9 % 11731 9138
Test Date: 2025-05-22 16:09:37 Functions: 83.7 % 141 118

            Line data    Source code
       1              : // EnergyPlus, Copyright (c) 1996-2025, The Board of Trustees of the University of Illinois,
       2              : // The Regents of the University of California, through Lawrence Berkeley National Laboratory
       3              : // (subject to receipt of any required approvals from the U.S. Dept. of Energy), Oak Ridge
       4              : // National Laboratory, managed by UT-Battelle, Alliance for Sustainable Energy, LLC, and other
       5              : // contributors. All rights reserved.
       6              : //
       7              : // NOTICE: This Software was developed under funding from the U.S. Department of Energy and the
       8              : // U.S. Government consequently retains certain rights. As such, the U.S. Government has been
       9              : // granted for itself and others acting on its behalf a paid-up, nonexclusive, irrevocable,
      10              : // worldwide license in the Software to reproduce, distribute copies to the public, prepare
      11              : // derivative works, and perform publicly and display publicly, and to permit others to do so.
      12              : //
      13              : // Redistribution and use in source and binary forms, with or without modification, are permitted
      14              : // provided that the following conditions are met:
      15              : //
      16              : // (1) Redistributions of source code must retain the above copyright notice, this list of
      17              : //     conditions and the following disclaimer.
      18              : //
      19              : // (2) Redistributions in binary form must reproduce the above copyright notice, this list of
      20              : //     conditions and the following disclaimer in the documentation and/or other materials
      21              : //     provided with the distribution.
      22              : //
      23              : // (3) Neither the name of the University of California, Lawrence Berkeley National Laboratory,
      24              : //     the University of Illinois, U.S. Dept. of Energy nor the names of its contributors may be
      25              : //     used to endorse or promote products derived from this software without specific prior
      26              : //     written permission.
      27              : //
      28              : // (4) Use of EnergyPlus(TM) Name. If Licensee (i) distributes the software in stand-alone form
      29              : //     without changes from the version obtained under this License, or (ii) Licensee makes a
      30              : //     reference solely to the software portion of its product, Licensee must refer to the
      31              : //     software as "EnergyPlus version X" software, where "X" is the version number Licensee
      32              : //     obtained under this License and may not use a different name for the software. Except as
      33              : //     specifically required in this Section (4), Licensee shall not use in a company name, a
      34              : //     product name, in advertising, publicity, or other promotional activities any name, trade
      35              : //     name, trademark, logo, or other designation of "EnergyPlus", "E+", "e+" or confusingly
      36              : //     similar designation, without the U.S. Department of Energy's prior written consent.
      37              : //
      38              : // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
      39              : // IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
      40              : // AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
      41              : // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
      42              : // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
      43              : // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
      44              : // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
      45              : // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
      46              : // POSSIBILITY OF SUCH DAMAGE.
      47              : 
      48              : // C++ Headers
      49              : #include <algorithm>
      50              : #include <array>
      51              : #include <cassert>
      52              : #include <cmath>
      53              : #include <iomanip>
      54              : #include <map>
      55              : #include <string_view>
      56              : #include <unordered_map>
      57              : #include <utility>
      58              : #include <vector>
      59              : 
      60              : // ObjexxFCL Headers
      61              : #include <ObjexxFCL/Array.functions.hh>
      62              : #include <ObjexxFCL/ArrayS.functions.hh>
      63              : #include <ObjexxFCL/Fmath.hh>
      64              : #include <ObjexxFCL/member.functions.hh>
      65              : #include <ObjexxFCL/numeric.hh>
      66              : #include <ObjexxFCL/string.functions.hh>
      67              : #include <ObjexxFCL/time.hh>
      68              : 
      69              : // Third-party Headers
      70              : #include <fast_float/fast_float.h>
      71              : #include <fmt/format.h>
      72              : 
      73              : // EnergyPlus Headers
      74              : #include <AirflowNetwork/Solver.hpp>
      75              : #include <EnergyPlus/Boilers.hh>
      76              : #include <EnergyPlus/ChillerElectricEIR.hh>
      77              : #include <EnergyPlus/ChillerReformulatedEIR.hh>
      78              : #include <EnergyPlus/CondenserLoopTowers.hh>
      79              : #include <EnergyPlus/CostEstimateManager.hh>
      80              : #include <EnergyPlus/DXCoils.hh>
      81              : #include <EnergyPlus/Data/EnergyPlusData.hh>
      82              : #include <EnergyPlus/DataAirLoop.hh>
      83              : #include <EnergyPlus/DataAirSystems.hh>
      84              : #include <EnergyPlus/DataDefineEquip.hh>
      85              : #include <EnergyPlus/DataGlobalConstants.hh>
      86              : #include <EnergyPlus/DataHVACGlobals.hh>
      87              : #include <EnergyPlus/DataHeatBalFanSys.hh>
      88              : #include <EnergyPlus/DataHeatBalSurface.hh>
      89              : #include <EnergyPlus/DataHeatBalance.hh>
      90              : #include <EnergyPlus/DataIPShortCuts.hh>
      91              : #include <EnergyPlus/DataOutputs.hh>
      92              : #include <EnergyPlus/DataShadowingCombinations.hh>
      93              : #include <EnergyPlus/DataSizing.hh>
      94              : #include <EnergyPlus/DataStringGlobals.hh>
      95              : #include <EnergyPlus/DataSurfaces.hh>
      96              : #include <EnergyPlus/DataViewFactorInformation.hh>
      97              : #include <EnergyPlus/DataWater.hh>
      98              : #include <EnergyPlus/DaylightingManager.hh>
      99              : #include <EnergyPlus/DisplayRoutines.hh>
     100              : #include <EnergyPlus/EconomicLifeCycleCost.hh>
     101              : #include <EnergyPlus/ElectricPowerServiceManager.hh>
     102              : #include <EnergyPlus/EvaporativeCoolers.hh>
     103              : #include <EnergyPlus/EvaporativeFluidCoolers.hh>
     104              : #include <EnergyPlus/FileSystem.hh>
     105              : #include <EnergyPlus/FluidCoolers.hh>
     106              : #include <EnergyPlus/General.hh>
     107              : #include <EnergyPlus/HVACVariableRefrigerantFlow.hh>
     108              : #include <EnergyPlus/HeatingCoils.hh>
     109              : #include <EnergyPlus/HybridModel.hh>
     110              : #include <EnergyPlus/InputProcessing/InputProcessor.hh>
     111              : #include <EnergyPlus/InternalHeatGains.hh>
     112              : #include <EnergyPlus/LowTempRadiantSystem.hh>
     113              : #include <EnergyPlus/MixedAir.hh>
     114              : #include <EnergyPlus/OutputProcessor.hh>
     115              : #include <EnergyPlus/OutputReportPredefined.hh>
     116              : #include <EnergyPlus/OutputReportTabular.hh>
     117              : #include <EnergyPlus/OutputReportTabularAnnual.hh>
     118              : #include <EnergyPlus/PackagedThermalStorageCoil.hh>
     119              : #include <EnergyPlus/PlantChillers.hh>
     120              : #include <EnergyPlus/PollutionModule.hh>
     121              : #include <EnergyPlus/Psychrometrics.hh>
     122              : #include <EnergyPlus/RefrigeratedCase.hh>
     123              : #include <EnergyPlus/ReportCoilSelection.hh>
     124              : #include <EnergyPlus/ResultsFramework.hh>
     125              : #include <EnergyPlus/SQLiteProcedures.hh>
     126              : #include <EnergyPlus/ScheduleManager.hh>
     127              : #include <EnergyPlus/ThermalComfort.hh>
     128              : #include <EnergyPlus/UtilityRoutines.hh>
     129              : #include <EnergyPlus/VentilatedSlab.hh>
     130              : #include <EnergyPlus/WaterManager.hh>
     131              : #include <EnergyPlus/WaterThermalTanks.hh>
     132              : #include <EnergyPlus/WeatherManager.hh>
     133              : #include <EnergyPlus/ZonePlenum.hh>
     134              : #include <EnergyPlus/ZoneTempPredictorCorrector.hh>
     135              : 
     136              : namespace EnergyPlus::OutputReportTabular {
     137              : 
     138              : // MODULE INFORMATION:
     139              : //    AUTHOR         Jason Glazer of GARD Analytics, Inc.
     140              : //    DATE WRITTEN   July 2003
     141              : //    MODIFIED       na
     142              : //    RE-ENGINEERED  na
     143              : // PURPOSE OF THIS MODULE:
     144              : //    This module allows the user to define several different tabular
     145              : //    report that have a specific format.
     146              : // METHODOLOGY EMPLOYED:
     147              : //    Generally aggregation. Specifically, the IDF objects are read into data
     148              : //    structures on the first call to update the data.  The data structures
     149              : //    include not only ones to hold the IDF data but also that initialize
     150              : //    the structure used to gather data each iteration. The report:table:binned
     151              : //    object is stored in OutputTableBinned.
     152              : //    During initialization the TableResults data structure is created which contains
     153              : //    all the information needed to perform the aggregation on a timestep basis.
     154              : //    After the end of the simulation the original Output data structures
     155              : //    are scanned and actual tables are created doing any scaling as necessary
     156              : //    and placing all the results into an output table.  The output table
     157              : //    is written in the selected format for each of the tables defined.
     158              : // REFERENCES:
     159              : //    None.
     160              : // OTHER NOTES:.
     161              : //                                      |--> BinResults
     162              : //                                      |
     163              : //                                      |--> BinResultsAbove
     164              : //   OutputTableBinned ---------------->|
     165              : //                                      |--> BinResultsBelow
     166              : //                                      |
     167              : //                                      |--> BinObjVarID
     168              : //
     169              : //                                      |--> MonthlyFieldSetInput
     170              : //   MonthlyInput --------------------->|
     171              : //                                      |--> MonthlyTable --> MonthlyColumns
     172              : 
     173              : // Using/Aliasing
     174              : using namespace OutputReportPredefined;
     175              : using namespace DataHeatBalance;
     176              : using namespace HybridModel;
     177              : 
     178              : constexpr std::array<std::string_view, (int)AggType::Num> AggTypeNamesUC{
     179              :     "SUMORAVERAGE",
     180              :     "MAXIMUM",
     181              :     "MINIMUM",
     182              :     "VALUEWHENMAXIMUMORMINIMUM",
     183              :     "HOURSZERO",
     184              :     "HOURSNONZERO",
     185              :     "HOURSPOSITIVE",
     186              :     "HOURSNONPOSITIVE",
     187              :     "HOURSNEGATIVE",
     188              :     "HOURSNONNEGATIVE",
     189              :     "SUMORAVERAGEDURINGHOURSSHOWN",
     190              :     "MAXIMUMDURINGHOURSSHOWN",
     191              :     "MINIMUMDURINGHOURSSHOWN",
     192              : };
     193              : 
     194          128 : std::ofstream &open_tbl_stream(EnergyPlusData &state, int const iStyle, fs::path const &filePath, bool output_to_file)
     195              : {
     196          128 :     std::ofstream &tbl_stream(*state.dataOutRptTab->TabularOutputFile(iStyle));
     197          128 :     if (output_to_file) {
     198          128 :         tbl_stream.open(filePath);
     199          128 :         if (!tbl_stream) {
     200            0 :             ShowFatalError(state, format("OpenOutputTabularFile: Could not open file \"{}\" for output (write).", filePath));
     201              :         }
     202              :     } else {
     203            0 :         tbl_stream.setstate(std::ios_base::badbit);
     204              :     }
     205          128 :     return tbl_stream;
     206              : }
     207              : 
     208        41142 : void UpdateTabularReports(EnergyPlusData &state, OutputProcessor::TimeStepType t_timeStepType) // What kind of data to update (Zone, HVAC)
     209              : {
     210              :     // SUBROUTINE INFORMATION:
     211              :     //       AUTHOR         Jason Glazer
     212              :     //       DATE WRITTEN   July 2003
     213              :     //       MODIFIED       na
     214              :     //       RE-ENGINEERED  na
     215              : 
     216              :     // PURPOSE OF THIS SUBROUTINE:
     217              :     // This is the routine that is called at the end of the time step
     218              :     // loop and updates the arrays of data that will later being put
     219              :     // into the tabular reports.
     220              : 
     221        41142 :     auto &ort = state.dataOutRptTab;
     222              : 
     223        41142 :     if (t_timeStepType != OutputProcessor::TimeStepType::Zone && t_timeStepType != OutputProcessor::TimeStepType::System) {
     224            0 :         ShowFatalError(state, "Invalid reporting requested -- UpdateTabularReports");
     225              :     }
     226              : 
     227        41142 :     if (ort->UpdateTabularReportsGetInput) {
     228           74 :         GetInputTabularMonthly(state);
     229           74 :         OutputReportTabularAnnual::GetInputTabularAnnual(state);
     230           74 :         OutputReportTabularAnnual::checkAggregationOrderForAnnual(state);
     231           74 :         GetInputTabularTimeBins(state);
     232           74 :         GetInputTabularStyle(state);
     233           74 :         GetInputOutputTableSummaryReports(state);
     234           74 :         if (state.dataOutRptTab->displayThermalResilienceSummary) {
     235              :             // check whether multiple people have different threshold for a zone
     236           39 :             Real64 valueNotInit = -999.0;
     237           39 :             Real64 nearThreshold = 1.0;
     238           84 :             for (int ZoneNum = 1; ZoneNum <= state.dataGlobal->NumOfZones; ++ZoneNum) {
     239           45 :                 state.dataHeatBal->Resilience(ZoneNum).ColdStressTempThresh = valueNotInit;
     240           45 :                 state.dataHeatBal->Resilience(ZoneNum).HeatStressTempThresh = valueNotInit;
     241              :             }
     242           53 :             for (int iPeople = 1; iPeople <= state.dataHeatBal->TotPeople; ++iPeople) {
     243           14 :                 int ZoneNum = state.dataHeatBal->People(iPeople).ZonePtr;
     244              : 
     245           14 :                 Real64 ColdTempThresh = state.dataHeatBal->People(iPeople).ColdStressTempThresh;
     246           14 :                 if (state.dataHeatBal->Resilience(ZoneNum).ColdStressTempThresh < valueNotInit + nearThreshold) {
     247           13 :                     state.dataHeatBal->Resilience(ZoneNum).ColdStressTempThresh = ColdTempThresh;
     248              :                 } else {
     249            1 :                     if (state.dataHeatBal->Resilience(ZoneNum).ColdStressTempThresh != ColdTempThresh) {
     250            1 :                         ShowWarningMessage(
     251            1 :                             state, fmt::format("Zone {} has multiple people objects with different Cold Stress Temperature Threshold.", ZoneNum));
     252              :                     }
     253              :                 }
     254              : 
     255           14 :                 Real64 HeatTempThresh = state.dataHeatBal->People(iPeople).HeatStressTempThresh;
     256           14 :                 if (state.dataHeatBal->Resilience(ZoneNum).HeatStressTempThresh < valueNotInit + nearThreshold) {
     257           13 :                     state.dataHeatBal->Resilience(ZoneNum).HeatStressTempThresh = HeatTempThresh;
     258              :                 } else {
     259            1 :                     if (state.dataHeatBal->Resilience(ZoneNum).HeatStressTempThresh != HeatTempThresh) {
     260            1 :                         ShowWarningMessage(
     261            1 :                             state, fmt::format("Zone {} has multiple people objects with different Heat Stress Temperature Threshold.", ZoneNum));
     262              :                     }
     263              :                 }
     264              :             }
     265              :         }
     266              :         // noel -- noticed this was called once and very slow -- sped up a little by caching keys
     267           74 :         InitializeTabularMonthly(state);
     268           74 :         if (isInvalidAggregationOrder(state)) {
     269            0 :             ShowFatalError(state, "OutputReportTabular: Invalid aggregations detected, no simulation performed.");
     270              :         }
     271           74 :         GetInputFuelAndPollutionFactors(state);
     272           74 :         SetupUnitConversions(state);
     273           74 :         AddTOCLoadComponentTableSummaries(state);
     274           74 :         ort->UpdateTabularReportsGetInput = false;
     275           74 :         date_and_time(_, _, _, ort->td);
     276              :     }
     277        41142 :     if (state.dataGlobal->DoOutputReporting && ort->WriteTabularFiles && (state.dataGlobal->KindOfSim == Constant::KindOfSim::RunPeriodWeather)) {
     278            2 :         if (t_timeStepType == OutputProcessor::TimeStepType::Zone) {
     279            0 :             ort->gatherElapsedTimeBEPS += state.dataGlobal->TimeStepZone;
     280              :         }
     281            2 :         if (state.dataGlobal->DoWeathSim) {
     282            2 :             GatherMonthlyResultsForTimestep(state, t_timeStepType);
     283            2 :             OutputReportTabularAnnual::GatherAnnualResultsForTimeStep(state, t_timeStepType);
     284            2 :             GatherBinResultsForTimestep(state, t_timeStepType);
     285            2 :             GatherBEPSResultsForTimestep(state, t_timeStepType);
     286            2 :             GatherSourceEnergyEndUseResultsForTimestep(state, t_timeStepType);
     287            2 :             GatherPeakDemandForTimestep(state, t_timeStepType);
     288            2 :             GatherHeatGainReport(state, t_timeStepType);
     289            2 :             GatherHeatEmissionReport(state, t_timeStepType);
     290              :         }
     291              :     }
     292        41142 : }
     293              : 
     294              : //======================================================================================================================
     295              : //======================================================================================================================
     296              : 
     297              : //    GET INPUT ROUTINES
     298              : 
     299              : //======================================================================================================================
     300              : //======================================================================================================================
     301              : 
     302           88 : void GetInputTabularMonthly(EnergyPlusData &state)
     303              : {
     304              :     // SUBROUTINE INFORMATION:
     305              :     //       AUTHOR         Jason Glazer
     306              :     //       DATE WRITTEN   July 2003
     307              :     //       MODIFIED       na
     308              :     //       RE-ENGINEERED  na
     309              : 
     310              :     // PURPOSE OF THIS SUBROUTINE:
     311              :     //   The routine assigns the input information for
     312              :     //   REPORT:TABLE:MONTHLY also known as tabular monthly
     313              :     //   reports that are defined by the user. The input
     314              :     //   information is assigned to a data structure that
     315              :     //   is used for both user defined monthly reports and
     316              :     //   predefined monthly reports.
     317              : 
     318              :     // METHODOLOGY EMPLOYED:
     319              :     //   Uses get input structure and call to build up
     320              :     //   data on monthly reports.
     321              : 
     322              :     // REFERENCES:
     323              :     // na
     324              : 
     325              :     // USE STATEMENTS:
     326              :     // na
     327              : 
     328              :     // Locals
     329              :     // SUBROUTINE ARGUMENT DEFINITIONS:
     330              :     // na
     331              : 
     332              :     // SUBROUTINE PARAMETER DEFINITIONS:
     333          248 :     static std::string const CurrentModuleObject("Output:Table:Monthly");
     334              : 
     335              :     // INTERFACE BLOCK SPECIFICATIONS:
     336              :     // na
     337              : 
     338              :     // DERIVED TYPE DEFINITIONS:
     339              :     // na
     340              : 
     341              :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
     342           88 :     auto &ort = state.dataOutRptTab;
     343              : 
     344           88 :     if (!state.files.outputControl.writeTabular(state)) {
     345            0 :         ort->WriteTabularFiles = false;
     346            1 :         return;
     347              :     }
     348              : 
     349           88 :     ort->MonthlyInputCount = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, CurrentModuleObject);
     350           88 :     if (ort->MonthlyInputCount > 0) {
     351           12 :         ort->WriteTabularFiles = true;
     352              :         // if not a run period using weather do not create reports
     353           12 :         if (!state.dataGlobal->DoWeathSim) {
     354            2 :             ShowWarningError(
     355              :                 state,
     356            2 :                 format("{} requested with SimulationControl Run Simulation for Weather File Run Periods set to No so {} will not be generated",
     357              :                        CurrentModuleObject,
     358              :                        CurrentModuleObject));
     359            1 :             return;
     360              :         }
     361              :     }
     362              : 
     363           87 :     int NumParams = 0;        // Number of elements combined
     364           87 :     int NumAlphas = 0;        // Number of elements in the alpha array
     365           87 :     int NumNums = 0;          // Number of elements in the numeric array
     366           87 :     Array1D_string AlphArray; // character string data
     367           87 :     Array1D<Real64> NumArray; // numeric data
     368           87 :     int IOStat = -1;          // IO Status when calling get input subroutine
     369           87 :     bool ErrorsFound = false;
     370              : 
     371           87 :     state.dataInputProcessing->inputProcessor->getObjectDefMaxArgs(state, CurrentModuleObject, NumParams, NumAlphas, NumNums);
     372           87 :     AlphArray.allocate(NumAlphas);
     373           87 :     NumArray.dimension(NumNums, 0.0);
     374           98 :     for (int TabNum = 1, TabNum_end = ort->MonthlyInputCount; TabNum <= TabNum_end; ++TabNum) { // MonthlyInputCount is modified in the loop
     375           11 :         state.dataInputProcessing->inputProcessor->getObjectItem(state, CurrentModuleObject, TabNum, AlphArray, NumAlphas, NumArray, NumNums, IOStat);
     376              : 
     377           11 :         if (TabNum - 1 > 0) {
     378            0 :             Util::IsNameEmpty(state, AlphArray(1), CurrentModuleObject, ErrorsFound);
     379              :         }
     380           11 :         if (NumAlphas < 2) {
     381            0 :             ShowSevereError(state, format("{}: No fields specified.", CurrentModuleObject));
     382              :         }
     383              :         // add to the data structure
     384           11 :         int const curTable = AddMonthlyReport(state, AlphArray(1), int(NumArray(1)));
     385           50 :         for (int jField = 2; jField <= NumAlphas; jField += 2) {
     386           39 :             if (AlphArray(jField).empty()) {
     387            2 :                 ShowWarningError(state,
     388            2 :                                  format("{}: Blank column specified in '{}', need to provide a variable or meter name ",
     389              :                                         CurrentModuleObject,
     390            1 :                                         ort->MonthlyInput(TabNum).name));
     391            1 :                 continue;
     392              :             }
     393           38 :             std::string const curAggString = AlphArray(jField + 1);
     394              :             // kind of aggregation identified (see AggType parameters)
     395           38 :             AggType curAggType = static_cast<AggType>(getEnumValue(AggTypeNamesUC, Util::makeUPPER(curAggString)));
     396              :             // set accumulator values to default as appropriate for aggregation type
     397           38 :             if (curAggType == AggType::Invalid) {
     398            0 :                 ShowWarningError(state, format("{}={}, Variable name={}", CurrentModuleObject, ort->MonthlyInput(TabNum).name, AlphArray(jField)));
     399            0 :                 ShowContinueError(state, format("Invalid aggregation type=\"{}\"  Defaulting to SumOrAverage.", curAggString));
     400            0 :                 curAggType = AggType::SumOrAvg;
     401              :             }
     402           38 :             AddMonthlyFieldSetInput(state, curTable, AlphArray(jField), "", curAggType);
     403           38 :         }
     404              :     }
     405           87 : }
     406              : 
     407          390 : int AddMonthlyReport(EnergyPlusData &state, std::string const &inReportName, int const inNumDigitsShown, bool isNamedMonthly)
     408              : {
     409              :     // SUBROUTINE INFORMATION:
     410              :     //       AUTHOR         Jason Glazer
     411              :     //       DATE WRITTEN   August 2008
     412              :     //       MODIFIED
     413              :     //       RE-ENGINEERED  na
     414              : 
     415              :     // PURPOSE OF THIS SUBROUTINE:
     416              :     //   Creates a monthly report
     417              : 
     418              :     // METHODOLOGY EMPLOYED:
     419              :     // na
     420              : 
     421              :     // REFERENCES:
     422              :     // na
     423              : 
     424              :     // USE STATEMENTS:
     425              : 
     426              :     // Return value
     427              : 
     428              :     // Locals
     429              :     // SUBROUTINE ARGUMENT DEFINITIONS:
     430              :     // na
     431              : 
     432              :     // SUBROUTINE PARAMETER DEFINITIONS:
     433              : 
     434              :     // INTERFACE BLOCK SPECIFICATIONS:
     435              :     // na
     436              : 
     437              :     // DERIVED TYPE DEFINITIONS:
     438              :     // na
     439              : 
     440              :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
     441          390 :     int constexpr SizeAdder(25);
     442          390 :     auto &ort = state.dataOutRptTab;
     443              : 
     444          390 :     if (!allocated(ort->MonthlyInput)) {
     445           14 :         ort->MonthlyInput.allocate(SizeAdder);
     446           14 :         ort->sizeMonthlyInput = SizeAdder;
     447           14 :         ort->MonthlyInputCount = 1;
     448              :     } else {
     449          376 :         ++ort->MonthlyInputCount;
     450              :         // if larger than current size grow the array
     451          376 :         if (ort->MonthlyInputCount > ort->sizeMonthlyInput) {
     452           12 :             ort->MonthlyInput.redimension(ort->sizeMonthlyInput += SizeAdder);
     453              :         }
     454              :     }
     455              :     // initialize new record
     456          390 :     ort->MonthlyInput(ort->MonthlyInputCount).name = inReportName;
     457          390 :     ort->MonthlyInput(ort->MonthlyInputCount).showDigits = inNumDigitsShown;
     458          390 :     ort->MonthlyInput(ort->MonthlyInputCount).isNamedMonthly = isNamedMonthly;
     459          390 :     return ort->MonthlyInputCount;
     460              : }
     461              : 
     462         2680 : void AddMonthlyFieldSetInput(
     463              :     EnergyPlusData &state, int const inMonthReport, std::string const &inVariMeter, std::string const &inColHead, AggType const inAggregate)
     464              : {
     465              :     // SUBROUTINE INFORMATION:
     466              :     //       AUTHOR         Jason Glazer
     467              :     //       DATE WRITTEN   August 2008
     468              :     //       MODIFIED
     469              :     //       RE-ENGINEERED  na
     470              : 
     471              :     // PURPOSE OF THIS SUBROUTINE:
     472              :     //   Assigns the column information for predefined
     473              :     //   monthly reports
     474              : 
     475              :     // METHODOLOGY EMPLOYED:
     476              :     //   Simple assignments to public variables.
     477              : 
     478              :     // REFERENCES:
     479              :     // na
     480              : 
     481              :     // USE STATEMENTS:
     482              : 
     483              :     // Locals
     484              :     // SUBROUTINE ARGUMENT DEFINITIONS:
     485              : 
     486              :     // SUBROUTINE PARAMETER DEFINITIONS:
     487         2680 :     int constexpr sizeIncrement(50);
     488         2680 :     auto &ort = state.dataOutRptTab;
     489              : 
     490              :     // INTERFACE BLOCK SPECIFICATIONS:
     491              :     // na
     492              : 
     493              :     // DERIVED TYPE DEFINITIONS:
     494              :     // na
     495              : 
     496              :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
     497              :     // na
     498              : 
     499         2680 :     if (!allocated(ort->MonthlyFieldSetInput)) {
     500           14 :         ort->MonthlyFieldSetInput.allocate(sizeIncrement);
     501           14 :         ort->sizeMonthlyFieldSetInput = sizeIncrement;
     502           14 :         ort->MonthlyFieldSetInputCount = 1;
     503              :     } else {
     504         2666 :         ++ort->MonthlyFieldSetInputCount;
     505              :         // if larger than current size grow the array
     506         2666 :         if (ort->MonthlyFieldSetInputCount > ort->sizeMonthlyFieldSetInput) {
     507           24 :             ort->MonthlyFieldSetInput.redimension(ort->sizeMonthlyFieldSetInput *=
     508              :                                                   2); // Tuned Changed += sizeIncrement to *= 2 for reduced heap allocations (at some space cost)
     509              :         }
     510              :     }
     511              :     // initialize new record)
     512         2680 :     ort->MonthlyFieldSetInput(ort->MonthlyFieldSetInputCount).variMeter = inVariMeter;
     513         2680 :     ort->MonthlyFieldSetInput(ort->MonthlyFieldSetInputCount).colHead = inColHead;
     514         2680 :     ort->MonthlyFieldSetInput(ort->MonthlyFieldSetInputCount).aggregate = inAggregate;
     515              :     // update the references from the MonthlyInput array
     516         2680 :     if ((inMonthReport > 0) && (inMonthReport <= ort->MonthlyInputCount)) {
     517         2680 :         if (ort->MonthlyInput(inMonthReport).firstFieldSet == 0) {
     518          389 :             ort->MonthlyInput(inMonthReport).firstFieldSet = ort->MonthlyFieldSetInputCount;
     519          389 :             ort->MonthlyInput(inMonthReport).numFieldSet = 1;
     520              :         } else {
     521         2291 :             ++ort->MonthlyInput(inMonthReport).numFieldSet;
     522              :         }
     523              :     }
     524         2680 : }
     525              : 
     526           89 : void InitializeTabularMonthly(EnergyPlusData &state)
     527              : {
     528              :     // SUBROUTINE INFORMATION:
     529              :     //       AUTHOR         Jason Glazer
     530              :     //       DATE WRITTEN   July 2008
     531              :     //       MODIFIED       na
     532              :     //       RE-ENGINEERED  na
     533              : 
     534              :     // PURPOSE OF THIS SUBROUTINE:
     535              :     //   This routine initializes the data structures based
     536              :     //   on input from either the IDF file or from the predefined
     537              :     //   monthly reports.  The data structures follow the IDD
     538              :     //   closely.  The routine initializes many of the arrays
     539              :     //   for monthly tables.
     540              : 
     541              :     // METHODOLOGY EMPLOYED:
     542              :     //   Process the data structures that define monthly tabular
     543              :     //   reports
     544              : 
     545              :     // NOTE:
     546              :     //   The bulk of this routine used to be part of the the
     547              :     //   GetInputTabularMonthly routine but when predefined
     548              :     //   monthly reports were added this routine was separated
     549              :     //   from input.
     550              : 
     551              :     // REFERENCES:
     552              :     // na
     553              : 
     554              :     // USE STATEMENTS:
     555              :     // na
     556              : 
     557              :     // Locals
     558              :     // SUBROUTINE ARGUMENT DEFINITIONS:
     559              :     // na
     560              : 
     561              :     // SUBROUTINE PARAMETER DEFINITIONS:
     562              :     // na
     563              : 
     564              :     // INTERFACE BLOCK SPECIFICATIONS:
     565              :     // na
     566              : 
     567              :     // DERIVED TYPE DEFINITIONS:
     568              :     // na
     569              : 
     570              :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
     571              :     OutputProcessor::VariableType TypeVar;
     572              :     OutputProcessor::StoreType AvgSumVar;
     573              :     OutputProcessor::TimeStepType StepTypeVar;
     574           89 :     Constant::Units UnitsVar = Constant::Units::None; // Units enum
     575           89 :     Array1D_string UniqueKeyNames;
     576              :     int found;
     577           89 :     auto &ort = state.dataOutRptTab;
     578              : 
     579              :     // if not a running a weather simulation do not create reports
     580           89 :     if (!state.dataGlobal->DoWeathSim) {
     581           74 :         return;
     582              :     }
     583           15 :     ort->maxUniqueKeyCount = 1500;
     584           15 :     UniqueKeyNames.allocate(ort->maxUniqueKeyCount);
     585              :     // First pass through the input objects is to put the name of the report
     586              :     // into the array and count the number of unique keys found to allocate
     587              :     // the monthlyTables and monthlyColumns
     588              :     // This approach seems inefficient but I know of no other way to size
     589              :     // the arrays prior to filling them and to size the arrays basically
     590              :     // the same steps must be gone through as with filling the arrays.
     591              : 
     592              :     // #ifdef ITM_KEYCACHE
     593              :     //  Noel comment:  How about allocating these variables once for the whole routine?
     594              :     //     Again, if a max value for key count can be agreed upon, we could use it here --
     595              :     //     otherwise, will have to have re-allocate logic.
     596              :     //  maxKeyCount=1500 ! ?
     597              :     //  ALLOCATE(NamesOfKeys(maxKeyCount))
     598              :     //  ALLOCATE(IndexesForKeyVar(maxKeyCount))
     599              :     // #endif
     600              : 
     601           15 :     ort->MonthlyColumnsCount = 0;
     602           15 :     ort->MonthlyTablesCount = 0;
     603          342 :     for (int TabNum = 1; TabNum <= ort->MonthlyInputCount; ++TabNum) {
     604              :         // the number of columns based on number of alpha fields
     605          327 :         int const NumColumns = ort->MonthlyInput(TabNum).numFieldSet;
     606          327 :         int const FirstColumn = ort->MonthlyInput(TabNum).firstFieldSet;
     607          327 :         bool environmentKeyFound = false;
     608          327 :         int UniqueKeyCount = 0;
     609         2568 :         for (int colNum = 1; colNum <= NumColumns; ++colNum) {
     610              : 
     611              :             // #ifdef ITM_KEYCACHE
     612              :             //  Noel comment:  First time in this TabNum/ColNum loop, let's save the results
     613              :             //   of GetVariableKeyCountandType & GetVariableKeys.
     614         2241 :             std::string const curVariMeter = Util::makeUPPER(ort->MonthlyFieldSetInput(FirstColumn + colNum - 1).variMeter);
     615              :             // call the key count function but only need count during this pass
     616         2241 :             int KeyCount = 0;
     617         2241 :             GetVariableKeyCountandType(state, curVariMeter, KeyCount, TypeVar, AvgSumVar, StepTypeVar, UnitsVar);
     618         2241 :             if (TypeVar == OutputProcessor::VariableType::Invalid) { // TODO: This NotFound thing has to go
     619         2176 :                 if (!ort->MonthlyInput(TabNum).isNamedMonthly) {
     620           11 :                     ++state.dataOutRptTab->ErrCount1;
     621              :                 }
     622              :             }
     623              :             //    IF (KeyCount > maxKeyCount) THEN
     624              :             //      DEALLOCATE(NamesOfKeys)
     625              :             //      DEALLOCATE(IndexesForKeyVar)
     626              :             //      maxKeyCount=KeyCount
     627              :             //      ALLOCATE(NamesOfKeys(maxKeyCount))
     628              :             //      ALLOCATE(IndexesForKeyVar(maxKeyCount))
     629              :             //    ENDIF
     630              : 
     631              :             // save these values to use later -- noel
     632         2241 :             ort->MonthlyFieldSetInput(FirstColumn + colNum - 1).variMeterUpper = curVariMeter;
     633         2241 :             ort->MonthlyFieldSetInput(FirstColumn + colNum - 1).typeOfVar = TypeVar;
     634         2241 :             ort->MonthlyFieldSetInput(FirstColumn + colNum - 1).keyCount = KeyCount;
     635         2241 :             ort->MonthlyFieldSetInput(FirstColumn + colNum - 1).varAvgSum = AvgSumVar;
     636         2241 :             ort->MonthlyFieldSetInput(FirstColumn + colNum - 1).varStepType = StepTypeVar;
     637         2241 :             ort->MonthlyFieldSetInput(FirstColumn + colNum - 1).varUnits = UnitsVar;
     638              : 
     639         2241 :             if (TypeVar == OutputProcessor::VariableType::Invalid) {
     640         2176 :                 continue;
     641              :             }
     642              : 
     643           65 :             ort->MonthlyFieldSetInput(FirstColumn + colNum - 1).NamesOfKeys.allocate(KeyCount);
     644           65 :             ort->MonthlyFieldSetInput(FirstColumn + colNum - 1).IndexesForKeyVar.allocate(KeyCount);
     645              : 
     646              :             // fill keys?
     647           65 :             GetVariableKeys(state,
     648              :                             curVariMeter,
     649              :                             TypeVar,
     650           65 :                             ort->MonthlyFieldSetInput(FirstColumn + colNum - 1).NamesOfKeys,
     651           65 :                             ort->MonthlyFieldSetInput(FirstColumn + colNum - 1).IndexesForKeyVar);
     652              : 
     653              :             //    DO iKey = 1, KeyCount
     654              :             //      MonthlyFieldSetInput(FirstColumn + ColNum - 1)%NamesOfKeys(iKey) = NamesOfKeys(iKey)  !noel
     655              :             //      MonthlyFieldSetInput(FirstColumn + ColNum - 1)%IndexesForKeyVar(iKey) = IndexesForKeyVar(iKey)  !noel
     656              :             //    ENDDO
     657              :             // #else
     658              :             //    curVariMeter = Util::makeUPPER(MonthlyFieldSetInput(FirstColumn + ColNum - 1)%variMeter)
     659              :             //    ! call the key count function but only need count during this pass
     660              :             //    CALL GetVariableKeyCountandType(state, curVariMeter,KeyCount,TypeVar,AvgSumVar,StepTypeVar,UnitsVar)
     661              :             //    ALLOCATE(NamesOfKeys(KeyCount))
     662              :             //    ALLOCATE(IndexesForKeyVar(KeyCount))
     663              :             //    CALL GetVariableKeys(state, curVariMeter,TypeVar,NamesOfKeys,IndexesForKeyVar)
     664              :             // #endif
     665              : 
     666          146 :             for (int iKey = 1; iKey <= KeyCount; ++iKey) {
     667           81 :                 found = 0;
     668              :                 // set a flag if environment variables are found
     669           81 :                 if (Util::SameString(ort->MonthlyFieldSetInput(FirstColumn + colNum - 1).NamesOfKeys(iKey), "ENVIRONMENT")) {
     670            1 :                     environmentKeyFound = true;
     671            1 :                     found = -1; // so not counted in list of unique keys
     672              :                 }
     673          103 :                 for (int jUnique = 1; jUnique <= UniqueKeyCount; ++jUnique) {
     674           62 :                     if (Util::SameString(UniqueKeyNames(jUnique), ort->MonthlyFieldSetInput(FirstColumn + colNum - 1).NamesOfKeys(iKey))) {
     675           40 :                         found = jUnique;
     676           40 :                         break;
     677              :                     }
     678              :                 }
     679           81 :                 if (found == 0) {
     680           40 :                     ++UniqueKeyCount;
     681           40 :                     if (UniqueKeyCount > ort->maxUniqueKeyCount) {
     682            0 :                         UniqueKeyNames.redimension(ort->maxUniqueKeyCount += 500);
     683              :                     }
     684           40 :                     UniqueKeyNames(UniqueKeyCount) = ort->MonthlyFieldSetInput(FirstColumn + colNum - 1).NamesOfKeys(iKey);
     685              :                 }
     686              :             }
     687              :             // #ifdef ITM_KEYCACHE
     688              :             //     ! Don't deallocate here, only allocating/deallocating once for the whole routine
     689              :             // #else
     690              :             //     DEALLOCATE(NamesOfKeys)
     691              :             //     DEALLOCATE(IndexesForKeyVar)
     692              :             // #endif
     693         2241 :         } // colNum
     694              :         // fix for CR8285 - when monthly report is only environmental variables
     695          327 :         if (environmentKeyFound && UniqueKeyCount == 0) {
     696            0 :             UniqueKeyCount = 1;
     697              :         }
     698              :         // increment the number of tables based on the number of unique keys
     699          327 :         ort->MonthlyTablesCount += UniqueKeyCount;
     700          327 :         ort->MonthlyColumnsCount += UniqueKeyCount * NumColumns;
     701              :     } // TabNum the end of the loop through the inputs objects
     702              :     // Now that we have the maximum size of the number of tables (each table is
     703              :     // repeated for the number of keys found) and the number of total columns
     704              :     // of all of the tables, allocate the arrays to store this information.
     705           15 :     ort->MonthlyTables.allocate(ort->MonthlyTablesCount);
     706           15 :     ort->MonthlyColumns.allocate(ort->MonthlyColumnsCount);
     707              :     // Initialize tables and results
     708           55 :     for (auto &e : ort->MonthlyTables) {
     709           40 :         e.keyValue.clear();
     710           40 :         e.firstColumn = 0;
     711           40 :         e.numColumns = 0;
     712              :     }
     713              : 
     714          259 :     for (auto &e : ort->MonthlyColumns) {
     715          244 :         e.varName.clear();
     716          244 :         e.varNum = 0;
     717          244 :         e.typeOfVar = OutputProcessor::VariableType::Invalid;
     718          244 :         e.avgSum = OutputProcessor::StoreType::Average;
     719          244 :         e.stepType = OutputProcessor::TimeStepType::Zone;
     720          244 :         e.units = Constant::Units::None;
     721          244 :         e.aggType = AggType::Invalid;
     722              :     }
     723          259 :     for (int colNum = 1; colNum <= ort->MonthlyColumnsCount; ++colNum) {
     724          244 :         ort->MonthlyColumns(colNum).reslt = 0.0;
     725          244 :         ort->MonthlyColumns(colNum).timeStamp = 0;
     726          244 :         ort->MonthlyColumns(colNum).duration = 0.0;
     727              :     }
     728              : 
     729              :     // If no weather file run requested, don't bother issuing a warning
     730           15 :     bool issueWarnings = false;
     731           15 :     if (state.dataGlobal->DoWeathSim && (state.dataOutRptTab->ErrCount1 > 0)) {
     732           12 :         ShowWarningError(state, "Processing Monthly Tabular Reports: Variable names not valid for this simulation");
     733              : 
     734            6 :         if (!state.dataGlobal->DisplayExtraWarnings) {
     735           15 :             ShowContinueError(state, "...use Output:Diagnostics,DisplayExtraWarnings; to show more details on individual variables.");
     736              :         } else {
     737            2 :             ShowContinueError(state,
     738              :                               "..Variables not valid for this simulation will have \"[Invalid/Undefined]\" in the Units Column of "
     739              :                               "the Table Report.");
     740            1 :             issueWarnings = true;
     741              :         }
     742              :     }
     743              : 
     744           15 :     int ColumnsRecount = 0;
     745           15 :     int TablesRecount = 0;
     746          342 :     for (int TabNum = 1; TabNum <= ort->MonthlyInputCount; ++TabNum) {
     747              :         // the number of columns based on number of alpha fields
     748          327 :         int const NumColumns = ort->MonthlyInput(TabNum).numFieldSet;
     749          327 :         int FirstColumn = ort->MonthlyInput(TabNum).firstFieldSet;
     750          327 :         int UniqueKeyCount = 0;
     751          327 :         bool environmentKeyFound = false;
     752         2568 :         for (int colNum = 1; colNum <= NumColumns; ++colNum) {
     753         2241 :             std::string const &curVariMeter = ort->MonthlyFieldSetInput(FirstColumn + colNum - 1).variMeterUpper;
     754         2241 :             const int KeyCount = ort->MonthlyFieldSetInput(FirstColumn + colNum - 1).keyCount;
     755         2241 :             TypeVar = ort->MonthlyFieldSetInput(FirstColumn + colNum - 1).typeOfVar;
     756         2241 :             AvgSumVar = ort->MonthlyFieldSetInput(FirstColumn + colNum - 1).varAvgSum;
     757         2241 :             StepTypeVar = ort->MonthlyFieldSetInput(FirstColumn + colNum - 1).varStepType;
     758         2241 :             UnitsVar = ort->MonthlyFieldSetInput(FirstColumn + colNum - 1).varUnits;
     759              : 
     760         2241 :             if (KeyCount == 0 && issueWarnings && !ort->MonthlyInput(TabNum).isNamedMonthly) {
     761            4 :                 ShowWarningError(
     762            4 :                     state, format("In Output:Table:Monthly '{}' invalid Variable or Meter Name '{}'", ort->MonthlyInput(TabNum).name, curVariMeter));
     763              :             }
     764         2322 :             for (int iKey = 1; iKey <= KeyCount; ++iKey) {
     765           81 :                 found = 0;
     766              :                 // set a flag if environment variables are found
     767           81 :                 if (Util::SameString(ort->MonthlyFieldSetInput(FirstColumn + colNum - 1).NamesOfKeys(iKey), "ENVIRONMENT")) {
     768            1 :                     environmentKeyFound = true;
     769            1 :                     found = -1; // so not counted in list of unique keys
     770              :                 }
     771          103 :                 for (int jUnique = 1; jUnique <= UniqueKeyCount; ++jUnique) {
     772           62 :                     if (Util::SameString(UniqueKeyNames(jUnique), ort->MonthlyFieldSetInput(FirstColumn + colNum - 1).NamesOfKeys(iKey))) {
     773           40 :                         found = jUnique;
     774           40 :                         break;
     775              :                     }
     776              :                 }
     777           81 :                 if (found == 0) {
     778           40 :                     ++UniqueKeyCount;
     779           40 :                     UniqueKeyNames(UniqueKeyCount) = ort->MonthlyFieldSetInput(FirstColumn + colNum - 1).NamesOfKeys(iKey);
     780              :                 }
     781              :             }
     782              :             // #ifdef ITM_KEYCACHE
     783              :             //     ! Don't deallocate here, only allocating/deallocating once for the whole routine
     784              :             // #else
     785              :             //     DEALLOCATE(NamesOfKeys)
     786              :             //     DEALLOCATE(IndexesForKeyVar)
     787              :             // #endif
     788              :         }
     789              :         // fix for CR8285 - when monthly report is only environmental variables
     790          327 :         if (environmentKeyFound && UniqueKeyCount == 0) {
     791            0 :             UniqueKeyCount = 1;
     792              :         }
     793              :         // increment the number of tables based on the number of unique keys
     794          327 :         ort->MonthlyInput(TabNum).firstTable = TablesRecount + 1;
     795          327 :         ort->MonthlyInput(TabNum).numTables = UniqueKeyCount;
     796          327 :         TablesRecount += UniqueKeyCount;
     797              :         // loop through the different unique keys since each user defined table
     798              :         // has that many instances - one for each unique key.
     799              :         // It is unusual that this loop is about 'keys' and an inner loop is also
     800              :         // about 'keys' but for this loop the keys are really instances of tables.
     801          367 :         for (int kUniqueKey = 1; kUniqueKey <= UniqueKeyCount; ++kUniqueKey) {
     802           40 :             int const lTable = kUniqueKey + ort->MonthlyInput(TabNum).firstTable - 1;
     803              :             // use the term 'environment' for identifying the report if
     804           40 :             if (environmentKeyFound && UniqueKeyCount == 1) {
     805            0 :                 ort->MonthlyTables(lTable).keyValue = "Environment";
     806              :             } else { // this is the most common case is to use the unique key for the report
     807           40 :                 ort->MonthlyTables(lTable).keyValue = UniqueKeyNames(kUniqueKey);
     808              :             }
     809           40 :             ort->MonthlyTables(lTable).firstColumn = ColumnsRecount + 1;
     810           40 :             ort->MonthlyTables(lTable).numColumns = NumColumns;
     811           40 :             ColumnsRecount += NumColumns;
     812           40 :             FirstColumn = ort->MonthlyInput(TabNum).firstFieldSet;
     813          284 :             for (int colNum = 1; colNum <= NumColumns; ++colNum) {
     814          244 :                 environmentKeyFound = false;
     815          244 :                 int const mColumn = colNum + ort->MonthlyTables(lTable).firstColumn - 1;
     816              :                 // when going through the columns this time, not all columns may have
     817              :                 // a EP variable that corresponds to it.  In no variable is found
     818              :                 // then set it to 0 to be skipped during data gathering
     819              : 
     820              :                 // #ifdef ITM_KEYCACHE
     821              :                 //  Noel comment:  Here is where we could use the saved values
     822          244 :                 std::string const &curVariMeter = ort->MonthlyFieldSetInput(FirstColumn + colNum - 1).variMeterUpper;
     823          244 :                 int const KeyCount = ort->MonthlyFieldSetInput(FirstColumn + colNum - 1).keyCount;
     824          244 :                 TypeVar = ort->MonthlyFieldSetInput(FirstColumn + colNum - 1).typeOfVar;
     825          244 :                 AvgSumVar = ort->MonthlyFieldSetInput(FirstColumn + colNum - 1).varAvgSum;
     826          244 :                 StepTypeVar = ort->MonthlyFieldSetInput(FirstColumn + colNum - 1).varStepType;
     827          244 :                 UnitsVar = ort->MonthlyFieldSetInput(FirstColumn + colNum - 1).varUnits;
     828              :                 //    DO iKey = 1, KeyCount  !noel
     829              :                 //       NamesOfKeys(iKey) = MonthlyFieldSetInput(FirstColumn + ColNum - 1)%NamesOfKeys(iKey)  !noel
     830              :                 //       IndexesForKeyVar(iKey) = MonthlyFieldSetInput(FirstColumn + ColNum - 1)%IndexesForKeyVar(iKey) !noel
     831              :                 //    ENDDO
     832              :                 // #else
     833              :                 //    curVariMeter = Util::makeUPPER(MonthlyFieldSetInput(FirstColumn + ColNum - 1)%variMeter)
     834              :                 //    ! call the key count function but only need count during this pass
     835              :                 //    CALL GetVariableKeyCountandType(state, curVariMeter,KeyCount,TypeVar,AvgSumVar,StepTypeVar,UnitsVar)
     836              :                 //    ALLOCATE(NamesOfKeys(KeyCount))
     837              :                 //    ALLOCATE(IndexesForKeyVar(KeyCount))
     838              :                 //    CALL GetVariableKeys(state, curVariMeter,TypeVar,NamesOfKeys,IndexesForKeyVar)
     839              :                 // #endif
     840              : 
     841          244 :                 if (KeyCount == 1) { // first test if KeyCount is one to avoid referencing a zero element array
     842           56 :                     if (Util::SameString(ort->MonthlyFieldSetInput(FirstColumn + colNum - 1).NamesOfKeys(1), "ENVIRONMENT")) {
     843            2 :                         environmentKeyFound = true;
     844              :                     }
     845              :                 }
     846              :                 // if this is an environment variable - don't bother searching
     847          244 :                 if (environmentKeyFound) {
     848            2 :                     found = 1; // only one instance of environment variables so use it.
     849              :                 } else {
     850              :                     // search through the keys for the currently active key "UniqueKeyNames(kUniqueKey)"
     851          242 :                     found = 0;
     852          264 :                     for (int iKey = 1; iKey <= KeyCount; ++iKey) {
     853          102 :                         if (Util::SameString(ort->MonthlyFieldSetInput(FirstColumn + colNum - 1).NamesOfKeys(iKey), UniqueKeyNames(kUniqueKey))) {
     854           80 :                             found = iKey;
     855           80 :                             break;
     856              :                         }
     857              :                     }
     858              :                 }
     859          244 :                 if ((found > 0) && (KeyCount >= 1)) {
     860           82 :                     ort->MonthlyColumns(mColumn).varName = curVariMeter;
     861           82 :                     ort->MonthlyColumns(mColumn).varNum = ort->MonthlyFieldSetInput(FirstColumn + colNum - 1).IndexesForKeyVar(found);
     862           82 :                     ort->MonthlyColumns(mColumn).typeOfVar = TypeVar;
     863           82 :                     ort->MonthlyColumns(mColumn).avgSum = AvgSumVar;
     864           82 :                     ort->MonthlyColumns(mColumn).stepType = StepTypeVar;
     865           82 :                     ort->MonthlyColumns(mColumn).units = UnitsVar;
     866           82 :                     ort->MonthlyColumns(mColumn).aggType = ort->MonthlyFieldSetInput(FirstColumn + colNum - 1).aggregate;
     867              :                     // set accumulator values to default as appropriate for aggregation type
     868          164 :                     switch (ort->MonthlyColumns(mColumn).aggType) {
     869           24 :                     case AggType::SumOrAvg: {
     870           24 :                         ort->MonthlyColumns(mColumn).reslt = 0.0;
     871           24 :                         ort->MonthlyColumns(mColumn).duration = 0.0;
     872           24 :                     } break;
     873           16 :                     case AggType::Maximum: {
     874           16 :                         ort->MonthlyColumns(mColumn).reslt = -HUGE_(state.dataOutRptTab->BigNum);
     875           16 :                         ort->MonthlyColumns(mColumn).timeStamp = 0;
     876           16 :                     } break;
     877            4 :                     case AggType::Minimum: {
     878            4 :                         ort->MonthlyColumns(mColumn).reslt = HUGE_(state.dataOutRptTab->BigNum);
     879            4 :                         ort->MonthlyColumns(mColumn).timeStamp = 0;
     880            4 :                     } break;
     881            6 :                     case AggType::ValueWhenMaxMin: {
     882            6 :                         ort->MonthlyColumns(mColumn).reslt = 0.0;
     883            6 :                     } break;
     884            1 :                     case AggType::HoursZero: {
     885            1 :                         ort->MonthlyColumns(mColumn).reslt = 0.0;
     886            1 :                     } break;
     887           11 :                     case AggType::HoursNonZero: {
     888           11 :                         ort->MonthlyColumns(mColumn).reslt = 0.0;
     889           11 :                     } break;
     890            1 :                     case AggType::HoursPositive: {
     891            1 :                         ort->MonthlyColumns(mColumn).reslt = 0.0;
     892            1 :                     } break;
     893            1 :                     case AggType::HoursNonPositive: {
     894            1 :                         ort->MonthlyColumns(mColumn).reslt = 0.0;
     895            1 :                     } break;
     896            1 :                     case AggType::HoursNegative: {
     897            1 :                         ort->MonthlyColumns(mColumn).reslt = 0.0;
     898            1 :                     } break;
     899            1 :                     case AggType::HoursNonNegative: {
     900            1 :                         ort->MonthlyColumns(mColumn).reslt = 0.0;
     901            1 :                     } break;
     902           14 :                     case AggType::SumOrAverageHoursShown: {
     903           14 :                         ort->MonthlyColumns(mColumn).reslt = 0.0;
     904           14 :                         ort->MonthlyColumns(mColumn).duration = 0.0;
     905           14 :                     } break;
     906            1 :                     case AggType::MaximumDuringHoursShown: {
     907            1 :                         ort->MonthlyColumns(mColumn).reslt = -HUGE_(state.dataOutRptTab->BigNum);
     908            1 :                         ort->MonthlyColumns(mColumn).timeStamp = 0;
     909            1 :                     } break;
     910            1 :                     case AggType::MinimumDuringHoursShown: {
     911            1 :                         ort->MonthlyColumns(mColumn).reslt = HUGE_(state.dataOutRptTab->BigNum);
     912            1 :                         ort->MonthlyColumns(mColumn).timeStamp = 0;
     913            1 :                     } break;
     914            0 :                     default:
     915            0 :                         break;
     916              :                     }
     917              :                 } else { // if no key corresponds to this instance of the report
     918              :                     // fixing CR5878 removed the showing of the warning once about a specific variable.
     919          162 :                     if (issueWarnings && !ort->MonthlyInput(TabNum).isNamedMonthly) {
     920            0 :                         ShowWarningError(
     921              :                             state,
     922            0 :                             format("In Output:Table:Monthly '{}' invalid Variable or Meter Name '{}'", ort->MonthlyInput(TabNum).name, curVariMeter));
     923            0 :                         ShowContinueError(
     924            0 :                             state, format("..i.e., Variable name={}:{} not valid for this simulation.", UniqueKeyNames(kUniqueKey), curVariMeter));
     925              :                     }
     926          162 :                     ort->MonthlyColumns(mColumn).varName = curVariMeter;
     927          162 :                     ort->MonthlyColumns(mColumn).varNum = 0;
     928          162 :                     ort->MonthlyColumns(mColumn).typeOfVar = OutputProcessor::VariableType::Invalid;
     929          162 :                     ort->MonthlyColumns(mColumn).avgSum = OutputProcessor::StoreType::Average;
     930          162 :                     ort->MonthlyColumns(mColumn).stepType = OutputProcessor::TimeStepType::Zone;
     931          162 :                     ort->MonthlyColumns(mColumn).units = Constant::Units::None;
     932          162 :                     ort->MonthlyColumns(mColumn).aggType = AggType::SumOrAvg;
     933              :                 }
     934              :                 // #ifdef ITM_KEYCACHE
     935              :                 // #else
     936              :                 //     DEALLOCATE(NamesOfKeys)
     937              :                 //     DEALLOCATE(IndexesForKeyVar)
     938              :                 // #endif
     939              :             } // ColNum
     940              :         }     // kUniqueKey
     941              :     }         // TabNum the end of the loop through the inputs objects
     942              : 
     943              :     // #ifdef ITM_KEYCACHE
     944              :     //  DEALLOCATE(NamesOfKeys)
     945              :     //  DEALLOCATE(IndexesForKeyVar)
     946              :     // #endif
     947           89 : }
     948              : 
     949           75 : bool isInvalidAggregationOrder(EnergyPlusData &state)
     950              : {
     951           75 :     auto &ort = state.dataOutRptTab;
     952           75 :     bool foundError = false;
     953           75 :     if (!state.dataGlobal->DoWeathSim) { // if no weather simulation than no reading of MonthlyInput array
     954           73 :         return foundError;
     955              :     }
     956            3 :     for (int iInput = 1; iInput <= ort->MonthlyInputCount; ++iInput) {
     957            1 :         bool foundMinOrMax = false;
     958            1 :         bool foundHourAgg = false;
     959            1 :         bool missingMaxOrMinError = false;
     960            1 :         bool missingHourAggError = false;
     961            4 :         for (int jTable = 1; jTable <= ort->MonthlyInput(iInput).numTables; ++jTable) {
     962            3 :             int curTable = jTable + ort->MonthlyInput(iInput).firstTable - 1;
     963              :             // test if the aggregation types are in the correct order
     964            5 :             for (int kColumn = 1; kColumn <= ort->MonthlyTables(curTable).numColumns; ++kColumn) {
     965            5 :                 int curCol = kColumn + ort->MonthlyTables(curTable).firstColumn - 1;
     966            5 :                 if (ort->MonthlyColumns(curCol).varNum == 0) break; // if no variable was ever found than stop checking
     967            2 :                 AggType curAggType = ort->MonthlyColumns(curCol).aggType;
     968            2 :                 if ((curAggType == AggType::Maximum) || (curAggType == AggType::Minimum)) {
     969            0 :                     foundMinOrMax = true;
     970            2 :                 } else if ((curAggType == AggType::HoursNonZero) || (curAggType == AggType::HoursZero) || (curAggType == AggType::HoursPositive) ||
     971            2 :                            (curAggType == AggType::HoursNonPositive) || (curAggType == AggType::HoursNegative) ||
     972              :                            (curAggType == AggType::HoursNonNegative)) {
     973            0 :                     foundHourAgg = true;
     974            2 :                 } else if (curAggType == AggType::ValueWhenMaxMin) {
     975            0 :                     if (!foundMinOrMax) {
     976            0 :                         missingMaxOrMinError = true;
     977              :                     }
     978            2 :                 } else if ((curAggType == AggType::SumOrAverageHoursShown) || (curAggType == AggType::MaximumDuringHoursShown) ||
     979              :                            (curAggType == AggType::MinimumDuringHoursShown)) {
     980            2 :                     if (!foundHourAgg) {
     981            2 :                         missingHourAggError = true;
     982              :                     }
     983              :                 }
     984              :             }
     985              :         }
     986            1 :         if (missingMaxOrMinError) {
     987            0 :             ShowSevereError(state,
     988            0 :                             format("The Output:Table:Monthly report named=\"{}\" has a valueWhenMaxMin aggregation type for a column without a "
     989              :                                    "previous column that uses either the minimum or maximum aggregation types. The report will not be generated.",
     990            0 :                                    ort->MonthlyInput(iInput).name));
     991            0 :             foundError = true;
     992              :         }
     993            1 :         if (missingHourAggError) {
     994            2 :             ShowSevereError(state,
     995            2 :                             format("The Output:Table:Monthly report named=\"{}\" has a --DuringHoursShown aggregation type for a column without a "
     996              :                                    "previous field that uses one of the Hour-- aggregation types. The report will not be generated.",
     997            1 :                                    ort->MonthlyInput(iInput).name));
     998            1 :             foundError = true;
     999              :         }
    1000              :     }
    1001            2 :     return foundError;
    1002              : }
    1003              : 
    1004           75 : void GetInputTabularTimeBins(EnergyPlusData &state)
    1005              : {
    1006              :     // SUBROUTINE INFORMATION:
    1007              :     //       AUTHOR         Jason Glazer
    1008              :     //       DATE WRITTEN   July 2003
    1009              :     //       MODIFIED       na
    1010              :     //       RE-ENGINEERED  na
    1011              : 
    1012              :     // PURPOSE OF THIS SUBROUTINE:
    1013              :     //   This routine initializes the data structures based
    1014              :     //   on input from in the IDF file.  The data structures
    1015              :     //   follow the IDD closely.
    1016              : 
    1017              :     // METHODOLOGY EMPLOYED:
    1018              :     //   Uses get input structure similar to other objects
    1019              : 
    1020              :     // REFERENCES:
    1021              :     // na
    1022              : 
    1023              :     // Locals
    1024              :     // SUBROUTINE ARGUMENT DEFINITIONS:
    1025              :     // na
    1026              : 
    1027              :     // SUBROUTINE PARAMETER DEFINITIONS:
    1028          209 :     static std::string const CurrentModuleObject("Output:Table:TimeBins");
    1029              : 
    1030              :     // INTERFACE BLOCK SPECIFICATIONS:
    1031              :     // na
    1032              : 
    1033              :     // DERIVED TYPE DEFINITIONS:
    1034              :     // na
    1035              : 
    1036              :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
    1037           75 :     int NumParams = 0;            // Number of elements combined
    1038           75 :     int NumAlphas = 0;            // Number of elements in the alpha array
    1039           75 :     int NumNums = 0;              // Number of elements in the numeric array
    1040           75 :     Array1D_string AlphArray;     // character string data
    1041           75 :     Array1D<Real64> NumArray;     // numeric data
    1042           75 :     int IOStat = -1;              // IO Status when calling get input subroutine
    1043           75 :     Real64 constexpr bigVal(0.0); // used with HUGE: Value doesn't matter, only type: Initialize so compiler doesn't warn about use uninitialized
    1044              : 
    1045           75 :     Array1D_int objVarIDs;
    1046           75 :     Array1D_string objNames;
    1047              : 
    1048              :     static constexpr std::string_view routineName = "GetInputTabularTimeBins";
    1049              : 
    1050           75 :     auto &ort = state.dataOutRptTab;
    1051              : 
    1052           75 :     if (!state.files.outputControl.writeTabular(state)) {
    1053            0 :         ort->WriteTabularFiles = false;
    1054            0 :         return;
    1055              :     }
    1056              : 
    1057           75 :     state.dataInputProcessing->inputProcessor->getObjectDefMaxArgs(state, CurrentModuleObject, NumParams, NumAlphas, NumNums);
    1058           75 :     AlphArray.allocate(NumAlphas);
    1059           75 :     NumArray.dimension(NumNums, 0.0);
    1060              : 
    1061           75 :     ort->timeInYear = 0.0; // initialize the time in year counter
    1062              :     // determine size of array that holds the IDF description
    1063           75 :     ort->OutputTableBinnedCount = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, CurrentModuleObject);
    1064           75 :     ort->OutputTableBinned.allocate(ort->OutputTableBinnedCount);
    1065           75 :     if (ort->OutputTableBinnedCount > 0) {
    1066            1 :         ort->WriteTabularFiles = true;
    1067              :         // if not a run period using weather do not create reports
    1068            1 :         if (!state.dataGlobal->DoWeathSim) {
    1069            0 :             ShowWarningError(
    1070              :                 state,
    1071            0 :                 format("{} requested with SimulationControl Run Simulation for Weather File Run Periods set to No so {} will not be generated",
    1072              :                        CurrentModuleObject,
    1073              :                        CurrentModuleObject));
    1074            0 :             return;
    1075              :         }
    1076              :     }
    1077              :     // looking for maximum number of intervals for sizing
    1078           75 :     ort->BinResultsIntervalCount = 0;
    1079           75 :     ort->BinResultsTableCount = 0;
    1080           76 :     for (int iInObj = 1; iInObj <= ort->OutputTableBinnedCount; ++iInObj) {
    1081            2 :         state.dataInputProcessing->inputProcessor->getObjectItem(state,
    1082              :                                                                  CurrentModuleObject,
    1083              :                                                                  iInObj,
    1084              :                                                                  AlphArray,
    1085              :                                                                  NumAlphas,
    1086              :                                                                  NumArray,
    1087              :                                                                  NumNums,
    1088              :                                                                  IOStat,
    1089            1 :                                                                  state.dataIPShortCut->lNumericFieldBlanks,
    1090            1 :                                                                  state.dataIPShortCut->lAlphaFieldBlanks,
    1091            1 :                                                                  state.dataIPShortCut->cAlphaFieldNames,
    1092            1 :                                                                  state.dataIPShortCut->cNumericFieldNames);
    1093              : 
    1094            1 :         ErrorObjectHeader eoh{routineName, CurrentModuleObject, AlphArray(1)};
    1095              : 
    1096            1 :         ort->OutputTableBinned(iInObj).keyValue = AlphArray(1);
    1097            1 :         ort->OutputTableBinned(iInObj).varOrMeter = AlphArray(2);
    1098              :         // if a schedule has been specified assign
    1099            1 :         if (state.dataIPShortCut->lAlphaFieldBlanks(3)) {
    1100            1 :         } else if ((ort->OutputTableBinned(iInObj).sched = Sched::GetSchedule(state, AlphArray(3))) == nullptr) {
    1101            0 :             ShowWarningItemNotFound(state, eoh, state.dataIPShortCut->cAlphaFieldNames(3), AlphArray(3), "");
    1102              :         }
    1103              : 
    1104              :         // validate the kind of variable - not used internally except for validation
    1105            1 :         if (len(AlphArray(4)) > 0) {
    1106            0 :             if (!(Util::SameString(AlphArray(4), "ENERGY") || Util::SameString(AlphArray(4), "DEMAND") ||
    1107            0 :                   Util::SameString(AlphArray(4), "TEMPERATURE") || Util::SameString(AlphArray(4), "FLOWRATE"))) {
    1108            0 :                 ShowWarningError(
    1109              :                     state,
    1110            0 :                     format("In {} named {} the Variable Type was not energy, demand, temperature, or flowrate.", CurrentModuleObject, AlphArray(1)));
    1111              :             }
    1112              :         }
    1113            1 :         ort->OutputTableBinned(iInObj).intervalStart = NumArray(1);
    1114            1 :         ort->OutputTableBinned(iInObj).intervalSize = NumArray(2);
    1115            1 :         ort->OutputTableBinned(iInObj).intervalCount = int(NumArray(3));
    1116              :         // valid range checking on inputs
    1117            1 :         if (ort->OutputTableBinned(iInObj).intervalCount < 1) {
    1118            0 :             ort->OutputTableBinned(iInObj).intervalCount = 1;
    1119              :         }
    1120            1 :         if (ort->OutputTableBinned(iInObj).intervalCount > 20) {
    1121            0 :             ort->OutputTableBinned(iInObj).intervalCount = 20;
    1122              :         }
    1123            1 :         if (ort->OutputTableBinned(iInObj).intervalSize < 0) {
    1124            0 :             ort->OutputTableBinned(iInObj).intervalSize = 1000.0;
    1125              :         }
    1126            1 :         ort->OutputTableBinned(iInObj).resIndex = ort->BinResultsTableCount + 1; // the next results report
    1127              :         // find maximum number of intervals
    1128            1 :         if (ort->OutputTableBinned(iInObj).intervalCount > ort->BinResultsIntervalCount) {
    1129            1 :             ort->BinResultsIntervalCount = ort->OutputTableBinned(iInObj).intervalCount;
    1130              :         }
    1131            1 :         GetVariableKeyCountandType(state,
    1132            1 :                                    ort->OutputTableBinned(iInObj).varOrMeter,
    1133            1 :                                    ort->OutputTableBinned(iInObj).numTables,
    1134            1 :                                    ort->OutputTableBinned(iInObj).typeOfVar,
    1135            1 :                                    ort->OutputTableBinned(iInObj).avgSum,
    1136            1 :                                    ort->OutputTableBinned(iInObj).stepType,
    1137            1 :                                    ort->OutputTableBinned(iInObj).units);
    1138            1 :         if (ort->OutputTableBinned(iInObj).typeOfVar == OutputProcessor::VariableType::Invalid) {
    1139            2 :             ShowWarningError(
    1140            2 :                 state, format("{}: User specified meter or variable not found: {}", CurrentModuleObject, ort->OutputTableBinned(iInObj).varOrMeter));
    1141              :         }
    1142              :         // If only a single table key is requested than only one should be counted
    1143              :         // later will reset the numTables array pointer but for now use it to know
    1144              :         // how many items to scan through
    1145            1 :         if (ort->OutputTableBinned(iInObj).keyValue == "*") {
    1146            0 :             ort->BinResultsTableCount += ort->OutputTableBinned(iInObj).numTables;
    1147              :         } else {
    1148            1 :             ++ort->BinResultsTableCount; // if a particular key is requested then only one more report
    1149              :         }
    1150              :     }
    1151              :     // size the arrays that holds the bin results
    1152           75 :     ort->BinResults.allocate(ort->BinResultsIntervalCount, ort->BinResultsTableCount);
    1153           75 :     ort->BinResultsBelow.allocate(ort->BinResultsTableCount);
    1154           75 :     ort->BinResultsAbove.allocate(ort->BinResultsTableCount);
    1155           75 :     ort->BinStatistics.allocate(ort->BinResultsTableCount);
    1156           75 :     ort->BinObjVarID.allocate(ort->BinResultsTableCount);
    1157              :     // now that the arrays are sized go back and fill in
    1158              :     // what ID numbers are used for each table
    1159           76 :     for (int iInObj = 1; iInObj <= ort->OutputTableBinnedCount; ++iInObj) {
    1160            1 :         int firstReport = ort->OutputTableBinned(iInObj).resIndex;
    1161              :         // allocate the arrays to the number of objects
    1162            1 :         objVarIDs.allocate(ort->OutputTableBinned(iInObj).numTables);
    1163            1 :         objNames.allocate(ort->OutputTableBinned(iInObj).numTables);
    1164            1 :         GetVariableKeys(state, ort->OutputTableBinned(iInObj).varOrMeter, ort->OutputTableBinned(iInObj).typeOfVar, objNames, objVarIDs);
    1165              : 
    1166            1 :         if (ort->OutputTableBinned(iInObj).keyValue == "*") {
    1167            0 :             for (int iTable = 1; iTable <= ort->OutputTableBinned(iInObj).numTables; ++iTable) {
    1168            0 :                 int repIndex = firstReport + (iTable - 1);
    1169            0 :                 ort->BinObjVarID(repIndex).namesOfObj = objNames(iTable);
    1170            0 :                 ort->BinObjVarID(repIndex).varMeterNum = objVarIDs(iTable);
    1171              :                 // check if valid meter or number
    1172              :                 // Why is this here?
    1173            0 :                 if (objVarIDs(iTable) == -1) {
    1174            0 :                     ShowWarningError(state, format("{}: Specified variable or meter not found: {}", CurrentModuleObject, objNames(iTable)));
    1175              :                 }
    1176              :             }
    1177              :         } else {
    1178              :             // scan through the keys and look for the user specified key
    1179            1 :             int found = 0;
    1180            1 :             for (int iTable = 1; iTable <= ort->OutputTableBinned(iInObj).numTables; ++iTable) {
    1181            0 :                 if (Util::SameString(objNames(iTable), ort->OutputTableBinned(iInObj).keyValue)) {
    1182            0 :                     found = iTable;
    1183            0 :                     break;
    1184              :                 }
    1185              :             }
    1186              :             // the first and only report is assigned to the found object name
    1187            1 :             if (!warningAboutKeyNotFound(state, found, iInObj, CurrentModuleObject)) {
    1188            0 :                 ort->BinObjVarID(firstReport).namesOfObj = objNames(found);
    1189            0 :                 ort->BinObjVarID(firstReport).varMeterNum = objVarIDs(found);
    1190              :             }
    1191              :             // reset the number of tables to one
    1192            1 :             ort->OutputTableBinned(iInObj).numTables = 1;
    1193              :         }
    1194              :     }
    1195              :     // clear the binning arrays to zeros
    1196           80 :     for (auto &e : ort->BinResults) {
    1197            5 :         e.mnth = 0.0;
    1198            5 :         e.hrly = 0.0;
    1199              :     }
    1200           76 :     for (auto &e : ort->BinResultsBelow) {
    1201            1 :         e.mnth = 0.0;
    1202            1 :         e.hrly = 0.0;
    1203              :     }
    1204           76 :     for (auto &e : ort->BinResultsAbove) {
    1205            1 :         e.mnth = 0.0;
    1206            1 :         e.hrly = 0.0;
    1207              :     }
    1208              : 
    1209              :     // initialize statistics counters
    1210           76 :     for (auto &e : ort->BinStatistics) {
    1211            1 :         e.minimum = HUGE_(bigVal);
    1212            1 :         e.maximum = -HUGE_(bigVal);
    1213            1 :         e.n = 0;
    1214            1 :         e.sum = 0.0;
    1215            1 :         e.sum2 = 0.0;
    1216              :     }
    1217           75 : }
    1218              : 
    1219            3 : bool warningAboutKeyNotFound(EnergyPlusData &state, int foundIndex, int inObjIndex, std::string const &moduleName)
    1220              : {
    1221            3 :     if (foundIndex == 0) {
    1222            4 :         ShowWarningError(state,
    1223            4 :                          format("{}: Specified key not found: {} for variable: {}",
    1224              :                                 moduleName,
    1225            2 :                                 state.dataOutRptTab->OutputTableBinned(inObjIndex).keyValue,
    1226            2 :                                 state.dataOutRptTab->OutputTableBinned(inObjIndex).varOrMeter));
    1227            2 :         return true;
    1228              :     } else {
    1229            1 :         return false;
    1230              :     }
    1231              : }
    1232              : 
    1233           74 : void GetInputTabularStyle(EnergyPlusData &state)
    1234              : {
    1235              :     // SUBROUTINE INFORMATION:
    1236              :     //       AUTHOR         Jason Glazer
    1237              :     //       DATE WRITTEN   July 2003
    1238              :     //       MODIFIED       na
    1239              :     //       RE-ENGINEERED  na
    1240              : 
    1241              :     // PURPOSE OF THIS SUBROUTINE:
    1242              :     //   This routine set a flag for the output format for
    1243              :     //   all tabular reports. This is a "unique" object.
    1244              : 
    1245              :     // METHODOLOGY EMPLOYED:
    1246              :     //   Uses get input structure similar to other objects
    1247              : 
    1248              :     // REFERENCES:
    1249              :     // na
    1250              : 
    1251              :     // Using/Aliasing
    1252              :     using DataStringGlobals::CharComma;
    1253              :     using DataStringGlobals::CharSpace;
    1254              :     using DataStringGlobals::CharTab;
    1255              : 
    1256              :     // Locals
    1257              :     // SUBROUTINE ARGUMENT DEFINITIONS:
    1258              :     // na
    1259              : 
    1260              :     // SUBROUTINE PARAMETER DEFINITIONS:
    1261          206 :     static std::string const CurrentModuleObject("OutputControl:Table:Style");
    1262              : 
    1263              :     // INTERFACE BLOCK SPECIFICATIONS:
    1264              :     // na
    1265              : 
    1266              :     // DERIVED TYPE DEFINITIONS:
    1267              :     // na
    1268              : 
    1269              :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
    1270           74 :     int NumParams = 0;        // Number of elements combined
    1271           74 :     int NumAlphas = 0;        // Number of elements in the alpha array
    1272           74 :     int NumNums = 0;          // Number of elements in the numeric array
    1273           74 :     Array1D_string AlphArray; // character string data
    1274           74 :     Array1D<Real64> NumArray; // numeric data
    1275           74 :     int IOStat = -1;          // IO Status when calling get input subroutine
    1276           74 :     auto &ort = state.dataOutRptTab;
    1277              : 
    1278           74 :     state.dataInputProcessing->inputProcessor->getObjectDefMaxArgs(state, CurrentModuleObject, NumParams, NumAlphas, NumNums);
    1279           74 :     AlphArray.allocate(NumAlphas);
    1280           74 :     NumArray.dimension(NumNums, 0.0);
    1281              : 
    1282           74 :     int NumTabularStyle = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, CurrentModuleObject);
    1283              : 
    1284           74 :     if (NumTabularStyle == 0) {
    1285           46 :         AlphArray(1) = "COMMA";
    1286           46 :         ort->numStyles = 1;
    1287           46 :         ort->TableStyle(1) = TableStyle::Comma;
    1288           46 :         ort->del(1) = CharComma; // comma
    1289           46 :         ort->unitsStyle = UnitsStyle::None;
    1290           28 :     } else if (NumTabularStyle == 1) {
    1291           56 :         state.dataInputProcessing->inputProcessor->getObjectItem(state,
    1292              :                                                                  CurrentModuleObject,
    1293              :                                                                  1,
    1294              :                                                                  AlphArray,
    1295              :                                                                  NumAlphas,
    1296              :                                                                  NumArray,
    1297              :                                                                  NumNums,
    1298              :                                                                  IOStat,
    1299           28 :                                                                  state.dataIPShortCut->lNumericFieldBlanks,
    1300           28 :                                                                  state.dataIPShortCut->lAlphaFieldBlanks,
    1301           28 :                                                                  state.dataIPShortCut->cAlphaFieldNames,
    1302           28 :                                                                  state.dataIPShortCut->cNumericFieldNames);
    1303              :         // ColumnSeparator
    1304           28 :         if (Util::SameString(AlphArray(1), "Comma")) {
    1305            0 :             ort->numStyles = 1;
    1306            0 :             ort->TableStyle(1) = TableStyle::Comma;
    1307            0 :             ort->del(1) = CharComma; // comma
    1308           28 :         } else if (Util::SameString(AlphArray(1), "Tab")) {
    1309            0 :             ort->numStyles = 1;
    1310            0 :             ort->TableStyle(1) = TableStyle::Tab;
    1311            0 :             ort->del(1) = CharTab; // tab
    1312           28 :         } else if (Util::SameString(AlphArray(1), "Fixed")) {
    1313            0 :             ort->numStyles = 1;
    1314            0 :             ort->TableStyle(1) = TableStyle::Fixed;
    1315            0 :             ort->del(1) = CharSpace; // space
    1316           28 :         } else if (Util::SameString(AlphArray(1), "HTML")) {
    1317            4 :             ort->numStyles = 1;
    1318            4 :             ort->TableStyle(1) = TableStyle::HTML;
    1319            4 :             ort->del(1) = CharSpace; // space - this is not used much for HTML output
    1320           24 :         } else if (Util::SameString(AlphArray(1), "XML")) {
    1321            0 :             ort->numStyles = 1;
    1322            0 :             ort->TableStyle(1) = TableStyle::XML;
    1323            0 :             ort->del(1) = CharSpace; // space - this is not used much for XML output
    1324           24 :         } else if (Util::SameString(AlphArray(1), "CommaAndHTML")) {
    1325            1 :             ort->numStyles = 2;
    1326            1 :             ort->TableStyle(1) = TableStyle::Comma;
    1327            1 :             ort->del(1) = CharComma; // comma
    1328            1 :             ort->TableStyle(2) = TableStyle::HTML;
    1329            1 :             ort->del(2) = CharSpace; // space - this is not used much for HTML output
    1330           23 :         } else if (Util::SameString(AlphArray(1), "CommaAndXML")) {
    1331            0 :             ort->numStyles = 2;
    1332            0 :             ort->TableStyle(1) = TableStyle::Comma;
    1333            0 :             ort->del(1) = CharComma; // comma
    1334            0 :             ort->TableStyle(2) = TableStyle::XML;
    1335            0 :             ort->del(2) = CharSpace; // space - this is not used much for XML output
    1336           23 :         } else if (Util::SameString(AlphArray(1), "TabAndHTML")) {
    1337            1 :             ort->numStyles = 2;
    1338            1 :             ort->TableStyle(1) = TableStyle::Tab;
    1339            1 :             ort->del(1) = CharTab; // tab
    1340            1 :             ort->TableStyle(2) = TableStyle::HTML;
    1341            1 :             ort->del(2) = CharSpace; // space - this is not used much for HTML output
    1342           22 :         } else if (Util::SameString(AlphArray(1), "XMLandHTML")) {
    1343            0 :             ort->numStyles = 2;
    1344            0 :             ort->TableStyle(1) = TableStyle::XML;
    1345            0 :             ort->del(1) = CharSpace; // space - this is not used much for XML output
    1346            0 :             ort->TableStyle(2) = TableStyle::HTML;
    1347            0 :             ort->del(2) = CharSpace; // space - this is not used much for HTML output
    1348           22 :         } else if (Util::SameString(AlphArray(1), "All")) {
    1349           22 :             ort->numStyles = 5;
    1350           22 :             ort->TableStyle(1) = TableStyle::Comma;
    1351           22 :             ort->del(1) = CharComma; // comma
    1352           22 :             ort->TableStyle(2) = TableStyle::Tab;
    1353           22 :             ort->del(2) = CharTab; // tab
    1354           22 :             ort->TableStyle(3) = TableStyle::Fixed;
    1355           22 :             ort->del(3) = CharSpace; // space
    1356           22 :             ort->TableStyle(4) = TableStyle::HTML;
    1357           22 :             ort->del(4) = CharSpace; // space - this is not used much for HTML output
    1358           22 :             ort->TableStyle(5) = TableStyle::XML;
    1359           22 :             ort->del(5) = CharSpace; // space - this is not used much for XML output
    1360              :         } else {
    1361            0 :             ShowWarningError(
    1362              :                 state,
    1363            0 :                 format("{}: Invalid {}=\"{}\". Commas will be used.", CurrentModuleObject, state.dataIPShortCut->cAlphaFieldNames(1), AlphArray(1)));
    1364            0 :             ort->numStyles = 1;
    1365            0 :             ort->TableStyle(1) = TableStyle::Comma;
    1366            0 :             ort->del(1) = CharComma; // comma
    1367            0 :             AlphArray(1) = "COMMA";
    1368              :         }
    1369              :         // MonthlyUnitConversion
    1370           28 :         if (NumAlphas >= 2) {
    1371            2 :             ort->unitsStyle = SetUnitsStyleFromString(AlphArray(2));
    1372            2 :             if (ort->unitsStyle == UnitsStyle::NotFound) {
    1373            0 :                 ShowWarningError(state,
    1374            0 :                                  format("{}: Invalid {}=\"{}\". No unit conversion will be performed. Normal SI units will be shown.",
    1375              :                                         CurrentModuleObject,
    1376            0 :                                         state.dataIPShortCut->cAlphaFieldNames(2),
    1377              :                                         AlphArray(2)));
    1378              :             }
    1379              :         } else {
    1380           26 :             ort->unitsStyle = UnitsStyle::None;
    1381           26 :             AlphArray(2) = "None";
    1382              :         }
    1383            0 :     } else if (NumTabularStyle > 1) {
    1384            0 :         ShowWarningError(state, format("{}: Only one instance of this object is allowed. Commas will be used.", CurrentModuleObject));
    1385            0 :         ort->TableStyle = TableStyle::Comma;
    1386            0 :         ort->del = std::string(1, CharComma); // comma
    1387            0 :         AlphArray(1) = "COMMA";
    1388            0 :         ort->unitsStyle = UnitsStyle::None;
    1389            0 :         AlphArray(2) = "None";
    1390              :     }
    1391              : 
    1392           74 :     if (ort->WriteTabularFiles) {
    1393            0 :         print(state.files.eio, "! <Tabular Report>,Style,Unit Conversion\n");
    1394            0 :         if (AlphArray(1) != "HTML") {
    1395            0 :             ConvertCaseToLower(AlphArray(1), AlphArray(2));
    1396            0 :             AlphArray(1).erase(1);
    1397            0 :             AlphArray(1) += AlphArray(2).substr(1);
    1398              :         }
    1399            0 :         print(state.files.eio, "Tabular Report,{},{}\n", AlphArray(1), AlphArray(2));
    1400              :     }
    1401           74 : }
    1402              : 
    1403            8 : UnitsStyle SetUnitsStyleFromString(std::string const &unitStringIn)
    1404              : {
    1405            8 :     UnitsStyle unitsStyleReturn = static_cast<UnitsStyle>(getEnumValue(UnitsStyleNamesUC, Util::makeUPPER(unitStringIn)));
    1406            8 :     if (unitsStyleReturn == UnitsStyle::Invalid) {
    1407            1 :         unitsStyleReturn = UnitsStyle::NotFound;
    1408              :     }
    1409              : 
    1410            8 :     return unitsStyleReturn;
    1411              : }
    1412              : 
    1413           88 : void GetInputOutputTableSummaryReports(EnergyPlusData &state)
    1414              : {
    1415              :     // SUBROUTINE INFORMATION:
    1416              :     //       AUTHOR         Jason Glazer
    1417              :     //       DATE WRITTEN   November 2003
    1418              :     //       MODIFIED       na
    1419              :     //       RE-ENGINEERED  na
    1420              : 
    1421              :     // PURPOSE OF THIS SUBROUTINE:
    1422              :     //   This routine flags if any of the predefined reports
    1423              :     //   are requested by the user
    1424              : 
    1425              :     // METHODOLOGY EMPLOYED:
    1426              :     //   Uses get input structure similar to other objects
    1427              : 
    1428              :     // REFERENCES:
    1429              :     // na
    1430              : 
    1431              :     // Using/Aliasing
    1432              :     using DataStringGlobals::CharComma;
    1433              :     using DataStringGlobals::CharSpace;
    1434              :     using DataStringGlobals::CharTab;
    1435              : 
    1436              :     // SUBROUTINE PARAMETER DEFINITIONS:
    1437          248 :     static std::string const CurrentModuleObject("Output:Table:SummaryReports");
    1438              : 
    1439              :     // INTERFACE BLOCK SPECIFICATIONS:
    1440              :     // na
    1441              : 
    1442              :     // DERIVED TYPE DEFINITIONS:
    1443              : 
    1444              :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
    1445           88 :     auto &ort = state.dataOutRptTab;
    1446           88 :     bool ErrorsFound = false;
    1447              : 
    1448           88 :     if (!state.files.outputControl.writeTabular(state)) {
    1449            0 :         ort->WriteTabularFiles = false;
    1450            0 :         return;
    1451              :     }
    1452              : 
    1453           88 :     int NumTabularPredefined = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, CurrentModuleObject);
    1454           88 :     if (NumTabularPredefined == 1) {
    1455              : 
    1456           47 :         int NumParams = 0;
    1457           47 :         int NumAlphas = 0; // Number of elements in the alpha array
    1458           47 :         int NumNums = 0;   // Number of elements in the numeric array
    1459           47 :         Array1D_string AlphArray;
    1460           47 :         Array1D<Real64> NumArray;
    1461           47 :         int IOStat = -1; // IO Status when calling get input subroutine
    1462              : 
    1463              :         // find out how many fields since the object is extensible
    1464           47 :         state.dataInputProcessing->inputProcessor->getObjectDefMaxArgs(state, CurrentModuleObject, NumParams, NumAlphas, NumNums);
    1465              :         // allocate the temporary arrays for the call to get the filed
    1466           47 :         AlphArray.allocate(NumAlphas);
    1467              :         // don't really need the NumArray since not expecting any numbers but the call requires it
    1468           47 :         NumArray.dimension(NumNums, 0.0);
    1469              :         // get the object
    1470           47 :         state.dataInputProcessing->inputProcessor->getObjectItem(state, CurrentModuleObject, 1, AlphArray, NumAlphas, NumArray, NumNums, IOStat);
    1471              :         // default all report flags to false (do not get produced)
    1472           47 :         ort->displayTabularBEPS = false;
    1473              :         // initialize the names of the predefined monthly report titles
    1474           47 :         InitializePredefinedMonthlyTitles(state);
    1475              :         // loop through the fields looking for matching report titles
    1476           97 :         for (int iReport = 1; iReport <= NumAlphas; ++iReport) {
    1477           50 :             bool nameFound = false;
    1478           50 :             if (AlphArray(iReport).empty()) {
    1479            0 :                 ShowWarningError(state, "Blank report name in Output:Table:SummaryReports");
    1480           50 :             } else if (Util::SameString(AlphArray(iReport), "AnnualBuildingUtilityPerformanceSummary")) {
    1481            0 :                 ort->displayTabularBEPS = true;
    1482            0 :                 ort->WriteTabularFiles = true;
    1483            0 :                 nameFound = true;
    1484           50 :             } else if (Util::SameString(AlphArray(iReport), "ComponentCostEconomicsSummary")) {
    1485            0 :                 ort->displayTabularCompCosts = true;
    1486            0 :                 ort->WriteTabularFiles = true;
    1487            0 :                 nameFound = true;
    1488           50 :             } else if (Util::SameString(AlphArray(iReport), "InputVerificationandResultsSummary")) {
    1489            0 :                 ort->displayTabularVeriSum = true;
    1490            0 :                 ort->WriteTabularFiles = true;
    1491            0 :                 nameFound = true;
    1492           50 :             } else if (Util::SameString(AlphArray(iReport), "ComponentSizingSummary")) {
    1493            0 :                 ort->displayComponentSizing = true;
    1494            0 :                 ort->WriteTabularFiles = true;
    1495            0 :                 nameFound = true;
    1496           50 :             } else if (Util::SameString(AlphArray(iReport), "SurfaceShadowingSummary")) {
    1497            0 :                 ort->displaySurfaceShadowing = true;
    1498            0 :                 ort->WriteTabularFiles = true;
    1499            0 :                 nameFound = true;
    1500           50 :             } else if (Util::SameString(AlphArray(iReport), "DemandEndUseComponentsSummary")) {
    1501            0 :                 ort->displayDemandEndUse = true;
    1502            0 :                 ort->WriteTabularFiles = true;
    1503            0 :                 nameFound = true;
    1504           50 :             } else if (Util::SameString(AlphArray(iReport), "AdaptiveComfortSummary")) {
    1505            0 :                 ort->displayAdaptiveComfort = true;
    1506            0 :                 ort->WriteTabularFiles = true;
    1507            0 :                 nameFound = true;
    1508           50 :             } else if (Util::SameString(AlphArray(iReport), "SourceEnergyEndUseComponentsSummary")) {
    1509            0 :                 ort->displaySourceEnergyEndUseSummary = true;
    1510            0 :                 ort->WriteTabularFiles = true;
    1511            0 :                 nameFound = true;
    1512           50 :             } else if (Util::SameString(AlphArray(iReport), "ZoneComponentLoadSummary")) {
    1513            0 :                 ort->displayZoneComponentLoadSummary = true;
    1514            0 :                 ort->WriteTabularFiles = true;
    1515            0 :                 nameFound = true;
    1516           50 :             } else if (Util::SameString(AlphArray(iReport), "AirLoopComponentLoadSummary")) {
    1517            0 :                 ort->displayAirLoopComponentLoadSummary = true;
    1518            0 :                 ort->WriteTabularFiles = true;
    1519            0 :                 nameFound = true;
    1520           50 :             } else if (Util::SameString(AlphArray(iReport), "FacilityComponentLoadSummary")) {
    1521            0 :                 ort->displayFacilityComponentLoadSummary = true;
    1522            0 :                 ort->WriteTabularFiles = true;
    1523            0 :                 nameFound = true;
    1524           50 :             } else if (Util::SameString(AlphArray(iReport), "LEEDSummary")) {
    1525            0 :                 ort->displayLEEDSummary = true;
    1526            0 :                 ort->WriteTabularFiles = true;
    1527            0 :                 nameFound = true;
    1528           50 :             } else if (Util::SameString(AlphArray(iReport), "LifeCycleCostReport")) {
    1529            0 :                 ort->displayLifeCycleCostReport = true;
    1530            0 :                 ort->WriteTabularFiles = true;
    1531            0 :                 nameFound = true;
    1532           50 :             } else if (Util::SameString(AlphArray(iReport), "TariffReport")) {
    1533            0 :                 ort->displayTariffReport = true;
    1534            0 :                 ort->WriteTabularFiles = true;
    1535            0 :                 nameFound = true;
    1536           50 :             } else if (Util::SameString(AlphArray(iReport), "EconomicResultSummary")) {
    1537            0 :                 ort->displayEconomicResultSummary = true;
    1538            0 :                 ort->WriteTabularFiles = true;
    1539            0 :                 nameFound = true;
    1540           50 :             } else if (Util::SameString(AlphArray(iReport), "HeatEmissionsSummary")) {
    1541            0 :                 ort->displayHeatEmissionsSummary = true;
    1542            0 :                 ort->WriteTabularFiles = true;
    1543            0 :                 nameFound = true;
    1544           50 :             } else if (Util::SameString(AlphArray(iReport), "ThermalResilienceSummary")) {
    1545            0 :                 ort->displayThermalResilienceSummary = true;
    1546            0 :                 ort->displayThermalResilienceSummaryExplicitly = true;
    1547            0 :                 ort->WriteTabularFiles = true;
    1548            0 :                 nameFound = true;
    1549           50 :             } else if (Util::SameString(AlphArray(iReport), "CO2ResilienceSummary")) {
    1550            0 :                 ort->displayCO2ResilienceSummary = true;
    1551            0 :                 ort->displayCO2ResilienceSummaryExplicitly = true;
    1552            0 :                 ort->WriteTabularFiles = true;
    1553            0 :                 nameFound = true;
    1554           50 :             } else if (Util::SameString(AlphArray(iReport), "VisualResilienceSummary")) {
    1555            0 :                 ort->displayVisualResilienceSummary = true;
    1556            0 :                 ort->displayVisualResilienceSummaryExplicitly = true;
    1557            0 :                 ort->WriteTabularFiles = true;
    1558            0 :                 nameFound = true;
    1559           50 :             } else if (Util::SameString(AlphArray(iReport), "EnergyMeters")) {
    1560            0 :                 ort->WriteTabularFiles = true;
    1561            0 :                 nameFound = true;
    1562           50 :             } else if (Util::SameString(AlphArray(iReport), "InitializationSummary")) {
    1563            0 :                 ort->WriteTabularFiles = true;
    1564            0 :                 ort->displayEioSummary = true;
    1565            0 :                 nameFound = true;
    1566           50 :             } else if (Util::SameString(AlphArray(iReport), "AllSummary")) {
    1567           37 :                 ort->WriteTabularFiles = true;
    1568           37 :                 ort->displayTabularBEPS = true;
    1569           37 :                 ort->displayTabularVeriSum = true;
    1570           37 :                 ort->displayTabularCompCosts = true;
    1571           37 :                 ort->displaySurfaceShadowing = true;
    1572           37 :                 ort->displayComponentSizing = true;
    1573           37 :                 ort->displayDemandEndUse = true;
    1574           37 :                 ort->displayAdaptiveComfort = true;
    1575           37 :                 ort->displaySourceEnergyEndUseSummary = true;
    1576           37 :                 ort->displayLifeCycleCostReport = true;
    1577           37 :                 ort->displayTariffReport = true;
    1578           37 :                 ort->displayEconomicResultSummary = true;
    1579           37 :                 ort->displayEioSummary = true;
    1580           37 :                 ort->displayLEEDSummary = true;
    1581           37 :                 ort->displayHeatEmissionsSummary = true;
    1582           37 :                 ort->displayThermalResilienceSummary = true;
    1583           37 :                 ort->displayCO2ResilienceSummary = true;
    1584           37 :                 ort->displayVisualResilienceSummary = true;
    1585           37 :                 nameFound = true;
    1586          679 :                 for (int jReport = 1; jReport <= state.dataOutRptPredefined->numReportName; ++jReport) {
    1587          642 :                     state.dataOutRptPredefined->reportName(jReport).show = true;
    1588              :                 }
    1589           13 :             } else if (Util::SameString(AlphArray(iReport), "AllSummaryAndSizingPeriod")) {
    1590            4 :                 ort->WriteTabularFiles = true;
    1591            4 :                 ort->displayTabularBEPS = true;
    1592            4 :                 ort->displayTabularVeriSum = true;
    1593            4 :                 ort->displayTabularCompCosts = true;
    1594            4 :                 ort->displaySurfaceShadowing = true;
    1595            4 :                 ort->displayComponentSizing = true;
    1596            4 :                 ort->displayDemandEndUse = true;
    1597            4 :                 ort->displayAdaptiveComfort = true;
    1598            4 :                 ort->displaySourceEnergyEndUseSummary = true;
    1599            4 :                 ort->displayLifeCycleCostReport = true;
    1600            4 :                 ort->displayTariffReport = true;
    1601            4 :                 ort->displayEconomicResultSummary = true;
    1602            4 :                 ort->displayEioSummary = true;
    1603            4 :                 ort->displayLEEDSummary = true;
    1604            4 :                 ort->displayHeatEmissionsSummary = true;
    1605            4 :                 ort->displayThermalResilienceSummary = true;
    1606            4 :                 ort->displayCO2ResilienceSummary = true;
    1607            4 :                 ort->displayVisualResilienceSummary = true;
    1608            4 :                 nameFound = true;
    1609           76 :                 for (int jReport = 1; jReport <= state.dataOutRptPredefined->numReportName; ++jReport) {
    1610           72 :                     state.dataOutRptPredefined->reportName(jReport).show = true;
    1611              :                 }
    1612              :                 // the sizing period reports
    1613            4 :                 ort->displayZoneComponentLoadSummary = true;
    1614            4 :                 ort->displayAirLoopComponentLoadSummary = true;
    1615            4 :                 ort->displayFacilityComponentLoadSummary = true;
    1616            9 :             } else if (Util::SameString(AlphArray(iReport), "AllMonthly")) {
    1617            0 :                 ort->WriteTabularFiles = true;
    1618            0 :                 for (int jReport = 1; jReport <= numNamedMonthly; ++jReport) {
    1619            0 :                     ort->namedMonthly(jReport).show = true;
    1620              :                 }
    1621            0 :                 nameFound = true;
    1622            9 :             } else if (Util::SameString(AlphArray(iReport), "AllSummaryAndMonthly")) {
    1623            6 :                 ort->WriteTabularFiles = true;
    1624            6 :                 ort->displayTabularBEPS = true;
    1625            6 :                 ort->displayTabularVeriSum = true;
    1626            6 :                 ort->displayTabularCompCosts = true;
    1627            6 :                 ort->displaySurfaceShadowing = true;
    1628            6 :                 ort->displayComponentSizing = true;
    1629            6 :                 ort->displayDemandEndUse = true;
    1630            6 :                 ort->displayAdaptiveComfort = true;
    1631            6 :                 ort->displaySourceEnergyEndUseSummary = true;
    1632            6 :                 ort->displayLifeCycleCostReport = true;
    1633            6 :                 ort->displayTariffReport = true;
    1634            6 :                 ort->displayEconomicResultSummary = true;
    1635            6 :                 ort->displayEioSummary = true;
    1636            6 :                 ort->displayLEEDSummary = true;
    1637            6 :                 ort->displayHeatEmissionsSummary = true;
    1638            6 :                 ort->displayThermalResilienceSummary = true;
    1639            6 :                 ort->displayCO2ResilienceSummary = true;
    1640            6 :                 ort->displayVisualResilienceSummary = true;
    1641            6 :                 nameFound = true;
    1642            6 :                 for (int jReport = 1; jReport <= state.dataOutRptPredefined->numReportName; ++jReport) {
    1643            0 :                     state.dataOutRptPredefined->reportName(jReport).show = true;
    1644              :                 }
    1645          384 :                 for (int jReport = 1; jReport <= numNamedMonthly; ++jReport) {
    1646          378 :                     ort->namedMonthly(jReport).show = true;
    1647              :                 }
    1648            3 :             } else if (Util::SameString(AlphArray(iReport), "AllSummaryMonthlyAndSizingPeriod")) {
    1649            0 :                 ort->WriteTabularFiles = true;
    1650            0 :                 ort->displayTabularBEPS = true;
    1651            0 :                 ort->displayTabularVeriSum = true;
    1652            0 :                 ort->displayTabularCompCosts = true;
    1653            0 :                 ort->displaySurfaceShadowing = true;
    1654            0 :                 ort->displayComponentSizing = true;
    1655            0 :                 ort->displayDemandEndUse = true;
    1656            0 :                 ort->displayAdaptiveComfort = true;
    1657            0 :                 ort->displaySourceEnergyEndUseSummary = true;
    1658            0 :                 ort->displayLifeCycleCostReport = true;
    1659            0 :                 ort->displayTariffReport = true;
    1660            0 :                 ort->displayEconomicResultSummary = true;
    1661            0 :                 ort->displayEioSummary = true;
    1662            0 :                 ort->displayLEEDSummary = true;
    1663            0 :                 ort->displayHeatEmissionsSummary = true;
    1664            0 :                 ort->displayThermalResilienceSummary = true;
    1665            0 :                 ort->displayCO2ResilienceSummary = true;
    1666            0 :                 ort->displayVisualResilienceSummary = true;
    1667            0 :                 nameFound = true;
    1668            0 :                 for (int jReport = 1; jReport <= state.dataOutRptPredefined->numReportName; ++jReport) {
    1669            0 :                     state.dataOutRptPredefined->reportName(jReport).show = true;
    1670              :                 }
    1671            0 :                 for (int jReport = 1; jReport <= numNamedMonthly; ++jReport) {
    1672            0 :                     ort->namedMonthly(jReport).show = true;
    1673              :                 }
    1674              :                 // the sizing period reports
    1675            0 :                 ort->displayZoneComponentLoadSummary = true;
    1676            0 :                 ort->displayAirLoopComponentLoadSummary = true;
    1677            0 :                 ort->displayFacilityComponentLoadSummary = true;
    1678              :             }
    1679              :             // check the reports that are predefined and are created by OutputReportPredefined
    1680          799 :             for (int jReport = 1; jReport <= state.dataOutRptPredefined->numReportName; ++jReport) {
    1681          749 :                 if (Util::SameString(AlphArray(iReport), state.dataOutRptPredefined->reportName(jReport).name)) {
    1682            1 :                     ort->WriteTabularFiles = true;
    1683            1 :                     state.dataOutRptPredefined->reportName(jReport).show = true;
    1684            1 :                     nameFound = true;
    1685              :                 }
    1686          749 :                 if (Util::SameString(AlphArray(iReport), state.dataOutRptPredefined->reportName(jReport).abrev)) {
    1687            0 :                     ort->WriteTabularFiles = true;
    1688            0 :                     state.dataOutRptPredefined->reportName(jReport).show = true;
    1689            0 :                     nameFound = true;
    1690              :                 }
    1691              :             }
    1692              :             // check if the predefined monthly reports are used
    1693         3200 :             for (int jReport = 1; jReport <= numNamedMonthly; ++jReport) {
    1694         3150 :                 if (Util::SameString(AlphArray(iReport), ort->namedMonthly(jReport).title)) {
    1695            1 :                     ort->namedMonthly(jReport).show = true;
    1696            1 :                     ort->WriteTabularFiles = true;
    1697            1 :                     nameFound = true;
    1698              :                 }
    1699              :             }
    1700           50 :             if (!nameFound) {
    1701            1 :                 if (Util::SameString(AlphArray(iReport), "Standard62.1Summary")) {
    1702            1 :                     ShowWarningError(state, format("{} Field[{}]=\"Standard62.1Summary\", Report is not enabled.", CurrentModuleObject, iReport));
    1703            3 :                     ShowContinueError(state, "Do Zone Sizing or Do System Sizing must be enabled in SimulationControl.");
    1704              : 
    1705              :                 } else {
    1706            0 :                     ShowSevereError(
    1707              :                         state,
    1708            0 :                         format(
    1709              :                             "{} Field[{}]=\"{}\", invalid report name -- will not be reported.", CurrentModuleObject, iReport, AlphArray(iReport)));
    1710              :                     //      ErrorsFound=.TRUE.
    1711              :                 }
    1712              :             }
    1713              :         }
    1714           47 :         CreatePredefinedMonthlyReports(state);
    1715           88 :     } else if (NumTabularPredefined > 1) {
    1716            0 :         ShowSevereError(state, format("{}: Only one instance of this object is allowed.", CurrentModuleObject));
    1717            0 :         ErrorsFound = true;
    1718              :     }
    1719           88 :     if (ErrorsFound) {
    1720            0 :         ShowFatalError(state, format("{}: Preceding errors cause termination.", CurrentModuleObject));
    1721              :     }
    1722              :     // if the BEPS report has been called for than initialize its arrays
    1723           88 :     if (ort->displayTabularBEPS || ort->displayDemandEndUse || ort->displaySourceEnergyEndUseSummary || ort->displayLEEDSummary) {
    1724              :         // initialize the resource type names
    1725           49 :         ort->resourceTypeNames(1) = Constant::eResourceNames[static_cast<int>(Constant::eResource::Electricity)];
    1726           49 :         ort->resourceTypeNames(2) = Constant::eResourceNames[static_cast<int>(Constant::eResource::NaturalGas)];
    1727           49 :         ort->resourceTypeNames(3) = Constant::eResourceNames[static_cast<int>(Constant::eResource::DistrictCooling)];
    1728           49 :         ort->resourceTypeNames(4) = Constant::eResourceNames[static_cast<int>(Constant::eResource::DistrictHeatingWater)];
    1729           49 :         ort->resourceTypeNames(5) = Constant::eResourceNames[static_cast<int>(Constant::eResource::DistrictHeatingSteam)];
    1730           49 :         ort->resourceTypeNames(6) = Constant::eResourceNames[static_cast<int>(Constant::eResource::Gasoline)];
    1731           49 :         ort->resourceTypeNames(7) = Constant::eResourceNames[static_cast<int>(Constant::eResource::Water)];
    1732           49 :         ort->resourceTypeNames(8) = Constant::eResourceNames[static_cast<int>(Constant::eResource::Diesel)];
    1733           49 :         ort->resourceTypeNames(9) = Constant::eResourceNames[static_cast<int>(Constant::eResource::Coal)];
    1734           49 :         ort->resourceTypeNames(10) = Constant::eResourceNames[static_cast<int>(Constant::eResource::FuelOilNo1)];
    1735           49 :         ort->resourceTypeNames(11) = Constant::eResourceNames[static_cast<int>(Constant::eResource::FuelOilNo2)];
    1736           49 :         ort->resourceTypeNames(12) = Constant::eResourceNames[static_cast<int>(Constant::eResource::Propane)];
    1737           49 :         ort->resourceTypeNames(13) = Constant::eResourceNames[static_cast<int>(Constant::eResource::OtherFuel1)];
    1738           49 :         ort->resourceTypeNames(14) = Constant::eResourceNames[static_cast<int>(Constant::eResource::OtherFuel2)];
    1739              : 
    1740           49 :         ort->sourceTypeNames(1) = "Electricity";
    1741           49 :         ort->sourceTypeNames(2) = "NaturalGas";
    1742           49 :         ort->sourceTypeNames(3) = "Gasoline";
    1743           49 :         ort->sourceTypeNames(4) = "Diesel";
    1744           49 :         ort->sourceTypeNames(5) = "Coal";
    1745           49 :         ort->sourceTypeNames(6) = "FuelOilNo1";
    1746           49 :         ort->sourceTypeNames(7) = "FuelOilNo2";
    1747           49 :         ort->sourceTypeNames(8) = "Propane";
    1748           49 :         ort->sourceTypeNames(9) = "PurchasedElectricity";
    1749           49 :         ort->sourceTypeNames(10) = "SoldElectricity";
    1750           49 :         ort->sourceTypeNames(11) = "OtherFuel1";
    1751           49 :         ort->sourceTypeNames(12) = "OtherFuel2";
    1752              : 
    1753              :         // initialize the end use names
    1754           49 :         ort->endUseNames(static_cast<int>(Constant::EndUse::Heating) + 1) = "Heating";
    1755           49 :         ort->endUseNames(static_cast<int>(Constant::EndUse::Cooling) + 1) = "Cooling";
    1756           49 :         ort->endUseNames(static_cast<int>(Constant::EndUse::InteriorLights) + 1) = "InteriorLights";
    1757           49 :         ort->endUseNames(static_cast<int>(Constant::EndUse::ExteriorLights) + 1) = "ExteriorLights";
    1758           49 :         ort->endUseNames(static_cast<int>(Constant::EndUse::InteriorEquipment) + 1) = "InteriorEquipment";
    1759           49 :         ort->endUseNames(static_cast<int>(Constant::EndUse::ExteriorEquipment) + 1) = "ExteriorEquipment";
    1760           49 :         ort->endUseNames(static_cast<int>(Constant::EndUse::Fans) + 1) = "Fans";
    1761           49 :         ort->endUseNames(static_cast<int>(Constant::EndUse::Pumps) + 1) = "Pumps";
    1762           49 :         ort->endUseNames(static_cast<int>(Constant::EndUse::HeatRejection) + 1) = "HeatRejection";
    1763           49 :         ort->endUseNames(static_cast<int>(Constant::EndUse::Humidification) + 1) = "Humidifier";
    1764           49 :         ort->endUseNames(static_cast<int>(Constant::EndUse::HeatRecovery) + 1) = "HeatRecovery";
    1765           49 :         ort->endUseNames(static_cast<int>(Constant::EndUse::WaterSystem) + 1) = "WaterSystems";
    1766           49 :         ort->endUseNames(static_cast<int>(Constant::EndUse::Refrigeration) + 1) = "Refrigeration";
    1767           49 :         ort->endUseNames(static_cast<int>(Constant::EndUse::Cogeneration) + 1) = "Cogeneration";
    1768              : 
    1769           49 :         auto &op = state.dataOutputProcessor;
    1770              :         // End use subs must be dynamically allocated to accommodate the end use with the most subcategories
    1771           49 :         ort->meterNumEndUseSubBEPS.allocate(op->MaxNumSubcategories, static_cast<int>(Constant::EndUse::Num), numResourceTypes);
    1772           49 :         ort->meterNumEndUseSpTypeBEPS.allocate(op->maxNumEndUseSpaceTypes, static_cast<int>(Constant::EndUse::Num), numResourceTypes);
    1773          735 :         for (int endUse = 1; endUse <= static_cast<int>(Constant::EndUse::Num); ++endUse) {
    1774        10290 :             for (int resType = 1; resType <= numResourceTypes; ++resType) {
    1775        19992 :                 for (int subCat = 1; subCat <= op->MaxNumSubcategories; ++subCat) {
    1776        10388 :                     ort->meterNumEndUseSubBEPS(subCat, endUse, resType) = -1;
    1777              :                 }
    1778        19208 :                 for (int spType = 1; spType <= op->maxNumEndUseSpaceTypes; ++spType) {
    1779         9604 :                     ort->meterNumEndUseSpTypeBEPS(spType, endUse, resType) = -1;
    1780              :                 }
    1781              :             }
    1782              :         }
    1783              : 
    1784              :         // loop through all of the resources and end uses and sub end uses for the entire facility
    1785          735 :         for (int iResource = 1; iResource <= numResourceTypes; ++iResource) {
    1786          686 :             std::string meterName = format("{}:FACILITY", ort->resourceTypeNames(iResource));
    1787          686 :             int meterNumber = GetMeterIndex(state, Util::makeUPPER(meterName));
    1788          686 :             ort->meterNumTotalsBEPS(iResource) = meterNumber;
    1789              : 
    1790        10290 :             for (int jEndUse = 1; jEndUse <= static_cast<int>(Constant::EndUse::Num); ++jEndUse) {
    1791         9604 :                 meterName = format("{}:{}", ort->endUseNames(jEndUse), ort->resourceTypeNames(iResource)); //// ':FACILITY'
    1792         9604 :                 meterNumber = GetMeterIndex(state, Util::makeUPPER(meterName));
    1793         9604 :                 ort->meterNumEndUseBEPS(iResource, jEndUse) = meterNumber;
    1794              : 
    1795        12152 :                 for (int kEndUseSub = 1; kEndUseSub <= op->EndUseCategory(jEndUse).NumSubcategories; ++kEndUseSub) {
    1796        10192 :                     meterName = format("{}:{}:{}",
    1797         2548 :                                        op->EndUseCategory(jEndUse).SubcategoryName(kEndUseSub),
    1798         2548 :                                        ort->endUseNames(jEndUse),
    1799         5096 :                                        ort->resourceTypeNames(iResource));
    1800         2548 :                     meterNumber = GetMeterIndex(state, Util::makeUPPER(meterName));
    1801         2548 :                     ort->meterNumEndUseSubBEPS(kEndUseSub, jEndUse, iResource) = meterNumber;
    1802              :                 }
    1803         9940 :                 for (int kEndUseSpType = 1; kEndUseSpType <= op->EndUseCategory(jEndUse).numSpaceTypes; ++kEndUseSpType) {
    1804         1008 :                     meterName = format("{}:{}:SpaceType:{}",
    1805          336 :                                        ort->endUseNames(jEndUse),
    1806          336 :                                        ort->resourceTypeNames(iResource),
    1807          672 :                                        op->EndUseCategory(jEndUse).spaceTypeName(kEndUseSpType));
    1808          336 :                     meterNumber = GetMeterIndex(state, Util::makeUPPER(meterName));
    1809          336 :                     ort->meterNumEndUseSpTypeBEPS(kEndUseSpType, jEndUse, iResource) = meterNumber;
    1810              :                 }
    1811              :             }
    1812          686 :         }
    1813              : 
    1814          637 :         for (int iResource = 1; iResource <= numSourceTypes; ++iResource) {
    1815          588 :             int const meterNumber = GetMeterIndex(state, Util::makeUPPER(format("{}Emissions:Source", ort->sourceTypeNames(iResource))));
    1816          588 :             ort->meterNumTotalsSource(iResource) = meterNumber;
    1817              :         }
    1818              : 
    1819              :         // initialize the gathering arrays to zero
    1820           49 :         ort->gatherTotalsBEPS = 0.0;
    1821           49 :         ort->gatherTotalsBySourceBEPS = 0.0;
    1822           49 :         ort->gatherTotalsSource = 0.0;
    1823           49 :         ort->gatherTotalsBySource = 0.0;
    1824           49 :         ort->gatherEndUseBEPS = 0.0;
    1825           49 :         ort->gatherEndUseBySourceBEPS = 0.0;
    1826              :         // End use subs must be dynamically allocated to accommodate the end use with the most subcategories
    1827           49 :         ort->gatherEndUseSubBEPS.allocate(op->MaxNumSubcategories, static_cast<int>(Constant::EndUse::Num), numResourceTypes);
    1828           49 :         ort->gatherEndUseSubBEPS = 0.0;
    1829           49 :         ort->gatherEndUseSpTypeBEPS.allocate(op->maxNumEndUseSpaceTypes, static_cast<int>(Constant::EndUse::Num), numResourceTypes);
    1830           49 :         ort->gatherEndUseSpTypeBEPS = 0.0;
    1831           49 :         ort->gatherDemandEndUseSub.allocate(op->MaxNumSubcategories, static_cast<int>(Constant::EndUse::Num), numResourceTypes);
    1832           49 :         ort->gatherDemandEndUseSub = 0.0;
    1833           49 :         ort->gatherDemandIndEndUseSub.allocate(op->MaxNumSubcategories, static_cast<int>(Constant::EndUse::Num), numResourceTypes);
    1834           49 :         ort->gatherDemandIndEndUseSub = 0.0;
    1835              : 
    1836              :         // get meter numbers for other meters relating to electric load components
    1837           98 :         ort->meterNumPowerFuelFireGen = GetMeterIndex(state, "COGENERATION:ELECTRICITYPRODUCED");
    1838           98 :         ort->meterNumPowerPV = GetMeterIndex(state, "PHOTOVOLTAIC:ELECTRICITYPRODUCED");
    1839           98 :         ort->meterNumPowerWind = GetMeterIndex(state, "WINDTURBINE:ELECTRICITYPRODUCED");
    1840           98 :         ort->meterNumPowerHTGeothermal = GetMeterIndex(state, "HTGEOTHERMAL:ELECTRICITYPRODUCED");
    1841           98 :         ort->meterNumElecStorage = GetMeterIndex(state, "ELECTRICSTORAGE:ELECTRICITYPRODUCED");
    1842           98 :         ort->meterNumPowerConversion = GetMeterIndex(state, "POWERCONVERSION:ELECTRICITYPRODUCED");
    1843           98 :         ort->meterNumElecProduced = GetMeterIndex(state, "ELECTRICITYPRODUCED:FACILITY");
    1844           98 :         ort->meterNumElecPurchased = GetMeterIndex(state, "ELECTRICITYPURCHASED:FACILITY");
    1845           49 :         ort->meterNumElecSurplusSold = GetMeterIndex(state, "ELECTRICITYSURPLUSSOLD:FACILITY");
    1846              :         // if no ElectricityPurchased:Facility meter is defined then no electric load center
    1847              :         // was created by the user and no power generation will occur in the plant. The amount
    1848              :         // purchased would be the total end use.
    1849           49 :         if (ort->meterNumElecPurchased == 0) {
    1850            0 :             ort->meterNumElecPurchased = GetMeterIndex(state, "ELECTRICITY:FACILITY");
    1851              :         }
    1852              : 
    1853              :         // initialize the gathering variables for the electric load components
    1854           49 :         ort->gatherPowerFuelFireGen = 0.0;
    1855           49 :         ort->gatherPowerPV = 0.0;
    1856           49 :         ort->gatherPowerWind = 0.0;
    1857           49 :         ort->gatherPowerHTGeothermal = 0.0;
    1858           49 :         ort->gatherElecProduced = 0.0;
    1859           49 :         ort->gatherElecPurchased = 0.0;
    1860           49 :         ort->gatherElecSurplusSold = 0.0;
    1861           49 :         ort->gatherElecStorage = 0.0;
    1862           49 :         ort->gatherPowerConversion = 0.0;
    1863              : 
    1864              :         // get meter numbers for onsite thermal components on BEPS report
    1865           98 :         ort->meterNumWaterHeatRecovery = GetMeterIndex(state, "HEATRECOVERY:ENERGYTRANSFER");
    1866           98 :         ort->meterNumAirHeatRecoveryCool = GetMeterIndex(state, "HEATRECOVERYFORCOOLING:ENERGYTRANSFER");
    1867           98 :         ort->meterNumAirHeatRecoveryHeat = GetMeterIndex(state, "HEATRECOVERYFORHEATING:ENERGYTRANSFER");
    1868           98 :         ort->meterNumHeatHTGeothermal = GetMeterIndex(state, "HTGEOTHERMAL:HEATPRODUCED");
    1869           98 :         ort->meterNumHeatSolarWater = GetMeterIndex(state, "SOLARWATER:FACILITY");
    1870           49 :         ort->meterNumHeatSolarAir = GetMeterIndex(state, "HEATPRODUCED:SOLARAIR");
    1871              :         // initialize the gathering variables for onsite thermal components on BEPS report
    1872           49 :         ort->gatherWaterHeatRecovery = 0.0;
    1873           49 :         ort->gatherAirHeatRecoveryCool = 0.0;
    1874           49 :         ort->gatherAirHeatRecoveryHeat = 0.0;
    1875           49 :         ort->gatherHeatHTGeothermal = 0.0;
    1876           49 :         ort->gatherHeatSolarWater = 0.0;
    1877           49 :         ort->gatherHeatSolarAir = 0.0;
    1878              : 
    1879              :         // get meter numbers for water components on BEPS report
    1880           98 :         ort->meterNumRainWater = GetMeterIndex(state, "RAINWATER:ONSITEWATER");
    1881           98 :         ort->meterNumCondensate = GetMeterIndex(state, "CONDENSATE:ONSITEWATER");
    1882           98 :         ort->meterNumGroundwater = GetMeterIndex(state, "WELLWATER:ONSITEWATER");
    1883           98 :         ort->meterNumMains = GetMeterIndex(state, "MAINSWATER:FACILITY");
    1884           49 :         ort->meterNumWaterEndUseTotal = GetMeterIndex(state, "WATER:FACILITY");
    1885              : 
    1886              :         // initialize the gathering variables for water components on BEPS report
    1887           49 :         ort->gatherRainWater = 0.0;
    1888           49 :         ort->gatherCondensate = 0.0;
    1889           49 :         ort->gatherWellwater = 0.0;
    1890           49 :         ort->gatherMains = 0.0;
    1891           49 :         ort->gatherWaterEndUseTotal = 0.0;
    1892              :     }
    1893              : }
    1894              : 
    1895           91 : bool isCompLoadRepReq(EnergyPlusData &state)
    1896              : {
    1897              :     // SUBROUTINE INFORMATION:
    1898              :     //       AUTHOR         Jason Glazer
    1899              :     //       DATE WRITTEN   November 2003
    1900              :     //       MODIFIED       na
    1901              :     //       RE-ENGINEERED  na
    1902              : 
    1903              :     // PURPOSE OF THIS SUBROUTINE:
    1904              :     //   Determine if the ZoneComponentLoadSummary or
    1905              :     //   ZoneComponentLoadDetail reports are requested.
    1906              : 
    1907              :     // METHODOLOGY EMPLOYED:
    1908              :     //   Uses get input structure similar to other objects
    1909              : 
    1910              :     // REFERENCES:
    1911              :     // na
    1912              : 
    1913              :     // USE STATEMENTS:
    1914              :     // na
    1915              : 
    1916              :     // Return value
    1917              :     bool isCompLoadRepReq;
    1918              : 
    1919              :     // Locals
    1920              :     // SUBROUTINE ARGUMENT DEFINITIONS:
    1921              :     // na
    1922              : 
    1923              :     // SUBROUTINE PARAMETER DEFINITIONS:
    1924          253 :     static std::string const CurrentModuleObject("Output:Table:SummaryReports");
    1925              : 
    1926              :     // INTERFACE BLOCK SPECIFICATIONS:
    1927              :     // na
    1928              : 
    1929              :     // DERIVED TYPE DEFINITIONS:
    1930              : 
    1931              :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
    1932              : 
    1933           91 :     bool isFound = false;
    1934              : 
    1935           91 :     int const NumTabularPredefined = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, CurrentModuleObject);
    1936           91 :     if (NumTabularPredefined == 1) {
    1937              : 
    1938           42 :         int NumParams = 0;
    1939           42 :         int NumAlphas = 0; // Number of elements in the alpha array
    1940           42 :         int NumNums = 0;   // Number of elements in the numeric array
    1941           42 :         Array1D_string AlphArray;
    1942           42 :         Array1D<Real64> NumArray;
    1943           42 :         int IOStat = -1; // IO Status when calling get input subroutine
    1944              : 
    1945              :         // find out how many fields since the object is extensible
    1946           42 :         state.dataInputProcessing->inputProcessor->getObjectDefMaxArgs(state, CurrentModuleObject, NumParams, NumAlphas, NumNums);
    1947              :         // allocate the temporary arrays for the call to get the filed
    1948           42 :         AlphArray.allocate(NumAlphas);
    1949              :         // don't really need the NumArray since not expecting any numbers but the call requires it
    1950           42 :         NumArray.dimension(NumNums, 0.0);
    1951              :         // get the object
    1952           42 :         state.dataInputProcessing->inputProcessor->getObjectItem(state, CurrentModuleObject, 1, AlphArray, NumAlphas, NumArray, NumNums, IOStat);
    1953              :         // loop through the fields looking for matching report titles
    1954           87 :         for (int iReport = 1; iReport <= NumAlphas; ++iReport) {
    1955           45 :             if (Util::SameString(AlphArray(iReport), "ZoneComponentLoadSummary")) {
    1956            0 :                 isFound = true;
    1957              :             }
    1958           45 :             if (Util::SameString(AlphArray(iReport), "AirLoopComponentLoadSummary")) {
    1959            0 :                 isFound = true;
    1960              :             }
    1961           45 :             if (Util::SameString(AlphArray(iReport), "FacilityComponentLoadSummary")) {
    1962            0 :                 isFound = true;
    1963              :             }
    1964           45 :             if (Util::SameString(AlphArray(iReport), "AllSummaryAndSizingPeriod")) {
    1965            6 :                 isFound = true;
    1966              :             }
    1967           45 :             if (Util::SameString(AlphArray(iReport), "AllSummaryMonthlyAndSizingPeriod")) {
    1968            0 :                 isFound = true;
    1969              :             }
    1970              :         }
    1971           42 :     }
    1972           91 :     isCompLoadRepReq = isFound; // return true if either report was found
    1973           91 :     return isCompLoadRepReq;
    1974              : }
    1975              : 
    1976           94 : bool hasSizingPeriodsDays(EnergyPlusData &state)
    1977              : {
    1978           94 :     int const sizePerDesDays = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "SizingPeriod:DesignDay");
    1979           94 :     int const sizePerWeathFileDays = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "SizingPeriod:WeatherFileDays");
    1980           94 :     return ((sizePerDesDays + sizePerWeathFileDays) > 0);
    1981              : }
    1982              : 
    1983           47 : void InitializePredefinedMonthlyTitles(EnergyPlusData &state)
    1984              : {
    1985              :     // SUBROUTINE INFORMATION:
    1986              :     //       AUTHOR         Jason Glazer
    1987              :     //       DATE WRITTEN   September 2008
    1988              :     //       MODIFIED       na
    1989              :     //       RE-ENGINEERED  na
    1990              : 
    1991              :     // PURPOSE OF THIS SUBROUTINE:
    1992              :     //   Initialize the NamedMonthly array for the titles
    1993              :     //   of the monthly predefined reports
    1994              : 
    1995              :     // METHODOLOGY EMPLOYED:
    1996              :     // REFERENCES:
    1997              :     // na
    1998              : 
    1999              :     // Using/Aliasing
    2000              :     using namespace DataOutputs;
    2001              : 
    2002              :     // Locals
    2003              :     // SUBROUTINE ARGUMENT DEFINITIONS:
    2004              :     // na
    2005              : 
    2006              :     // SUBROUTINE PARAMETER DEFINITIONS:
    2007              :     // na
    2008              : 
    2009              :     // INTERFACE BLOCK SPECIFICATIONS:
    2010              :     // na
    2011              : 
    2012              :     // DERIVED TYPE DEFINITIONS:
    2013              :     // na
    2014              : 
    2015              :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
    2016           47 :     auto &ort = state.dataOutRptTab;
    2017              : 
    2018           47 :     ort->namedMonthly.allocate(numNamedMonthly);
    2019           47 :     ort->namedMonthly(1).title = "ZoneCoolingSummaryMonthly";
    2020           47 :     ort->namedMonthly(2).title = "ZoneHeatingSummaryMonthly";
    2021           47 :     ort->namedMonthly(3).title = "ZoneElectricSummaryMonthly";
    2022           47 :     ort->namedMonthly(4).title = "SpaceGainsMonthly";
    2023           47 :     ort->namedMonthly(5).title = "PeakSpaceGainsMonthly";
    2024           47 :     ort->namedMonthly(6).title = "SpaceGainComponentsAtCoolingPeakMonthly";
    2025           47 :     ort->namedMonthly(7).title = "EnergyConsumptionElectricityNaturalGasMonthly";
    2026           47 :     ort->namedMonthly(8).title = "EnergyConsumptionElectricityGeneratedPropaneMonthly";
    2027           47 :     ort->namedMonthly(9).title = "EnergyConsumptionDieselFuelOilMonthly";
    2028           47 :     ort->namedMonthly(10).title = "EnergyConsumptionDistrictHeatingCoolingMonthly";
    2029           47 :     ort->namedMonthly(11).title = "EnergyConsumptionCoalGasolineMonthly";
    2030           47 :     ort->namedMonthly(12).title = "EnergyConsumptionOtherFuelsMonthly";
    2031           47 :     ort->namedMonthly(13).title = "EndUseEnergyConsumptionElectricityMonthly";
    2032           47 :     ort->namedMonthly(14).title = "EndUseEnergyConsumptionNaturalGasMonthly";
    2033           47 :     ort->namedMonthly(15).title = "EndUseEnergyConsumptionDieselMonthly";
    2034           47 :     ort->namedMonthly(16).title = "EndUseEnergyConsumptionFuelOilMonthly";
    2035           47 :     ort->namedMonthly(17).title = "EndUseEnergyConsumptionCoalMonthly";
    2036           47 :     ort->namedMonthly(18).title = "EndUseEnergyConsumptionPropaneMonthly";
    2037           47 :     ort->namedMonthly(19).title = "EndUseEnergyConsumptionGasolineMonthly";
    2038           47 :     ort->namedMonthly(20).title = "EndUseEnergyConsumptionOtherFuelsMonthly";
    2039           47 :     ort->namedMonthly(21).title = "PeakEnergyEndUseElectricityPart1Monthly";
    2040           47 :     ort->namedMonthly(22).title = "PeakEnergyEndUseElectricityPart2Monthly";
    2041           47 :     ort->namedMonthly(23).title = "ElectricComponentsOfPeakDemandMonthly";
    2042           47 :     ort->namedMonthly(24).title = "PeakEnergyEndUseNaturalGasMonthly";
    2043           47 :     ort->namedMonthly(25).title = "PeakEnergyEndUseDieselMonthly";
    2044           47 :     ort->namedMonthly(26).title = "PeakEnergyEndUseFuelOilMonthly";
    2045           47 :     ort->namedMonthly(27).title = "PeakEnergyEndUseCoalMonthly";
    2046           47 :     ort->namedMonthly(28).title = "PeakEnergyEndUsePropaneMonthly";
    2047           47 :     ort->namedMonthly(29).title = "PeakEnergyEndUseGasolineMonthly";
    2048           47 :     ort->namedMonthly(30).title = "PeakEnergyEndUseOtherFuelsMonthly";
    2049           47 :     ort->namedMonthly(31).title = "SetpointsNotMetWithTemperaturesMonthly";
    2050           47 :     ort->namedMonthly(32).title = "ComfortReportSimple55Monthly";
    2051           47 :     ort->namedMonthly(33).title = "UnglazedTranspiredSolarCollectorSummaryMonthly";
    2052           47 :     ort->namedMonthly(34).title = "OccupantComfortDataSummaryMonthly";
    2053           47 :     ort->namedMonthly(35).title = "ChillerReportMonthly";
    2054           47 :     ort->namedMonthly(36).title = "TowerReportMonthly";
    2055           47 :     ort->namedMonthly(37).title = "BoilerReportMonthly";
    2056           47 :     ort->namedMonthly(38).title = "DXReportMonthly";
    2057           47 :     ort->namedMonthly(39).title = "WindowReportMonthly";
    2058           47 :     ort->namedMonthly(40).title = "WindowEnergyReportMonthly";
    2059           47 :     ort->namedMonthly(41).title = "WindowZoneSummaryMonthly";
    2060           47 :     ort->namedMonthly(42).title = "WindowEnergyZoneSummaryMonthly";
    2061           47 :     ort->namedMonthly(43).title = "AverageOutdoorConditionsMonthly";
    2062           47 :     ort->namedMonthly(44).title = "OutdoorConditionsMaximumDryBulbMonthly";
    2063           47 :     ort->namedMonthly(45).title = "OutdoorConditionsMinimumDryBulbMonthly";
    2064           47 :     ort->namedMonthly(46).title = "OutdoorConditionsMaximumWetBulbMonthly";
    2065           47 :     ort->namedMonthly(47).title = "OutdoorConditionsMaximumDewPointMonthly";
    2066           47 :     ort->namedMonthly(48).title = "OutdoorGroundConditionsMonthly";
    2067           47 :     ort->namedMonthly(49).title = "WindowACReportMonthly";
    2068           47 :     ort->namedMonthly(50).title = "WaterHeaterReportMonthly";
    2069           47 :     ort->namedMonthly(51).title = "GeneratorReportMonthly";
    2070           47 :     ort->namedMonthly(52).title = "DaylightingReportMonthly";
    2071           47 :     ort->namedMonthly(53).title = "CoilReportMonthly";
    2072           47 :     ort->namedMonthly(54).title = "PlantLoopDemandReportMonthly";
    2073           47 :     ort->namedMonthly(55).title = "FanReportMonthly";
    2074           47 :     ort->namedMonthly(56).title = "PumpReportMonthly";
    2075           47 :     ort->namedMonthly(57).title = "CondLoopDemandReportMonthly";
    2076           47 :     ort->namedMonthly(58).title = "ZoneTemperatureOscillationReportMonthly";
    2077           47 :     ort->namedMonthly(59).title = "AirLoopSystemEnergyAndWaterUseMonthly";
    2078           47 :     ort->namedMonthly(60).title = "AirLoopSystemComponentLoadsMonthly";
    2079           47 :     ort->namedMonthly(61).title = "AirLoopSystemComponentEnergyUseMonthly";
    2080           47 :     ort->namedMonthly(62).title = "MechanicalVentilationLoadsMonthly";
    2081           47 :     ort->namedMonthly(63).title = "HeatEmissionsReportMonthly";
    2082              : 
    2083              :     if (numNamedMonthly != NumMonthlyReports) {
    2084              :         ShowFatalError(state,
    2085              :                        format("InitializePredefinedMonthlyTitles: Number of Monthly Reports in OutputReportTabular=[{}] does not match number in "
    2086              :                               "DataOutputs=[{}].",
    2087              :                               numNamedMonthly,
    2088              :                               NumMonthlyReports));
    2089              :     } else {
    2090         3008 :         for (int xcount = 1; xcount <= numNamedMonthly; ++xcount) {
    2091         2961 :             if (!Util::SameString(MonthlyNamedReports(xcount), ort->namedMonthly(xcount).title)) {
    2092            0 :                 ShowSevereError(state,
    2093              :                                 "InitializePredefinedMonthlyTitles: Monthly Report Titles in OutputReportTabular do not match titles in DataOutput.");
    2094            0 :                 ShowContinueError(state, format("first mismatch at ORT [{}] =\"{}\".", numNamedMonthly, ort->namedMonthly(xcount).title));
    2095            0 :                 ShowContinueError(state, format("same location in DO =\"{}\".", MonthlyNamedReports(xcount)));
    2096            0 :                 ShowFatalError(state, "Preceding condition causes termination.");
    2097              :             }
    2098              :         }
    2099              :     }
    2100           47 : }
    2101              : 
    2102           47 : void CreatePredefinedMonthlyReports(EnergyPlusData &state)
    2103              : {
    2104              :     // SUBROUTINE INFORMATION:
    2105              :     //       AUTHOR         Jason Glazer
    2106              :     //       DATE WRITTEN   September 2008
    2107              :     //       MODIFIED       na
    2108              :     //       RE-ENGINEERED  na
    2109              : 
    2110              :     // PURPOSE OF THIS SUBROUTINE:
    2111              :     //   For any predefined monthly reports that have been
    2112              :     //   called out, define the individual columns.
    2113              : 
    2114              :     // METHODOLOGY EMPLOYED:
    2115              :     // REFERENCES:
    2116              :     // na
    2117              : 
    2118              :     // USE STATEMENTS:
    2119              : 
    2120              :     // Locals
    2121              :     // SUBROUTINE ARGUMENT DEFINITIONS:
    2122              :     // na
    2123              : 
    2124              :     // SUBROUTINE PARAMETER DEFINITIONS:
    2125              :     // na
    2126              : 
    2127              :     // INTERFACE BLOCK SPECIFICATIONS:
    2128              :     // na
    2129              : 
    2130              :     // DERIVED TYPE DEFINITIONS:
    2131              :     // na
    2132              : 
    2133              :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
    2134              :     int curReport;
    2135           47 :     auto &ort = state.dataOutRptTab;
    2136              : 
    2137              :     // ----------------------------------------------------------------------------------------
    2138              :     // If any variable are added to these reports they also need to be added to the
    2139              :     // AddVariablesForMonthlyReport routine in InputProcessor.
    2140              :     // ----------------------------------------------------------------------------------------
    2141              : 
    2142           47 :     if (ort->namedMonthly(1).show) {
    2143           12 :         curReport = AddMonthlyReport(state, "ZoneCoolingSummaryMonthly", 2, true);
    2144           24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Air System Sensible Cooling Energy", "", AggType::SumOrAvg);
    2145           24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Air System Sensible Cooling Rate", "", AggType::Maximum);
    2146           24 :         AddMonthlyFieldSetInput(state, curReport, "Site Outdoor Air Drybulb Temperature", "", AggType::ValueWhenMaxMin);
    2147           24 :         AddMonthlyFieldSetInput(state, curReport, "Site Outdoor Air Wetbulb Temperature", "", AggType::ValueWhenMaxMin);
    2148           24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Total Internal Latent Gain Energy", "", AggType::SumOrAvg);
    2149           24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Total Internal Latent Gain Rate", "", AggType::Maximum);
    2150           24 :         AddMonthlyFieldSetInput(state, curReport, "Site Outdoor Air Drybulb Temperature", "", AggType::ValueWhenMaxMin);
    2151           24 :         AddMonthlyFieldSetInput(state, curReport, "Site Outdoor Air Wetbulb Temperature", "", AggType::ValueWhenMaxMin);
    2152              :     }
    2153           47 :     if (ort->namedMonthly(2).show) {
    2154           12 :         curReport = AddMonthlyReport(state, "ZoneHeatingSummaryMonthly", 2, true);
    2155           24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Air System Sensible Heating Energy", "", AggType::SumOrAvg);
    2156           24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Air System Sensible Heating Rate", "", AggType::Maximum);
    2157           24 :         AddMonthlyFieldSetInput(state, curReport, "Site Outdoor Air Drybulb Temperature", "", AggType::ValueWhenMaxMin);
    2158              :     }
    2159           47 :     if (ort->namedMonthly(3).show) {
    2160           12 :         curReport = AddMonthlyReport(state, "ZoneElectricSummaryMonthly", 2, true);
    2161           24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Lights Electricity Energy", "", AggType::SumOrAvg);
    2162           24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Lights Electricity Energy", "", AggType::Maximum);
    2163           24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Electric Equipment Electricity Energy", "", AggType::SumOrAvg);
    2164           24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Electric Equipment Electricity Energy", "", AggType::Maximum);
    2165              :     }
    2166           47 :     if (ort->namedMonthly(4).show) {
    2167           12 :         curReport = AddMonthlyReport(state, "SpaceGainsMonthly", 2, true);
    2168           24 :         AddMonthlyFieldSetInput(state, curReport, "Zone People Total Heating Energy", "", AggType::SumOrAvg);
    2169           24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Lights Total Heating Energy", "", AggType::SumOrAvg);
    2170           24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Electric Equipment Total Heating Energy", "", AggType::SumOrAvg);
    2171           24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Gas Equipment Total Heating Energy", "", AggType::SumOrAvg);
    2172           24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Hot Water Equipment Total Heating Energy", "", AggType::SumOrAvg);
    2173           24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Steam Equipment Total Heating Energy", "", AggType::SumOrAvg);
    2174           24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Other Equipment Total Heating Energy", "", AggType::SumOrAvg);
    2175           24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Infiltration Sensible Heat Gain Energy", "", AggType::SumOrAvg);
    2176           24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Infiltration Sensible Heat Loss Energy", "", AggType::SumOrAvg);
    2177              :     }
    2178           47 :     if (ort->namedMonthly(5).show) {
    2179           12 :         curReport = AddMonthlyReport(state, "PeakSpaceGainsMonthly", 2, true);
    2180           24 :         AddMonthlyFieldSetInput(state, curReport, "Zone People Total Heating Energy", "", AggType::Maximum);
    2181           24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Lights Total Heating Energy", "", AggType::Maximum);
    2182           24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Electric Equipment Total Heating Energy", "", AggType::Maximum);
    2183           24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Gas Equipment Total Heating Energy", "", AggType::Maximum);
    2184           24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Hot Water Equipment Total Heating Energy", "", AggType::Maximum);
    2185           24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Steam Equipment Total Heating Energy", "", AggType::Maximum);
    2186           24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Other Equipment Total Heating Energy", "", AggType::Maximum);
    2187           24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Infiltration Sensible Heat Gain Energy", "", AggType::Maximum);
    2188           24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Infiltration Sensible Heat Loss Energy", "", AggType::Maximum);
    2189              :     }
    2190           47 :     if (ort->namedMonthly(6).show) {
    2191           12 :         curReport = AddMonthlyReport(state, "SpaceGainComponentsAtCoolingPeakMonthly", 2, true);
    2192           24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Air System Sensible Cooling Rate", "", AggType::Maximum);
    2193           24 :         AddMonthlyFieldSetInput(state, curReport, "Zone People Total Heating Energy", "", AggType::ValueWhenMaxMin);
    2194           24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Lights Total Heating Energy", "", AggType::ValueWhenMaxMin);
    2195           24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Electric Equipment Total Heating Energy", "", AggType::ValueWhenMaxMin);
    2196           24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Gas Equipment Total Heating Energy", "", AggType::ValueWhenMaxMin);
    2197           24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Hot Water Equipment Total Heating Energy", "", AggType::ValueWhenMaxMin);
    2198           24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Steam Equipment Total Heating Energy", "", AggType::ValueWhenMaxMin);
    2199           24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Other Equipment Total Heating Energy", "", AggType::ValueWhenMaxMin);
    2200           24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Infiltration Sensible Heat Gain Energy", "", AggType::ValueWhenMaxMin);
    2201           24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Infiltration Sensible Heat Loss Energy", "", AggType::ValueWhenMaxMin);
    2202              :     }
    2203           47 :     if (ort->namedMonthly(7).show) {
    2204           12 :         curReport = AddMonthlyReport(state, "EnergyConsumptionElectricityNaturalGasMonthly", 2, true);
    2205           24 :         AddMonthlyFieldSetInput(state, curReport, "Electricity:Facility", "", AggType::SumOrAvg);
    2206           24 :         AddMonthlyFieldSetInput(state, curReport, "Electricity:Facility", "", AggType::Maximum);
    2207           24 :         AddMonthlyFieldSetInput(state, curReport, "NaturalGas:Facility", "", AggType::SumOrAvg);
    2208           24 :         AddMonthlyFieldSetInput(state, curReport, "NaturalGas:Facility", "", AggType::Maximum);
    2209              :     }
    2210           47 :     if (ort->namedMonthly(8).show) {
    2211           12 :         curReport = AddMonthlyReport(state, "EnergyConsumptionElectricityGeneratedPropaneMonthly", 2, true);
    2212           24 :         AddMonthlyFieldSetInput(state, curReport, "ElectricityProduced:Facility", "", AggType::SumOrAvg);
    2213           24 :         AddMonthlyFieldSetInput(state, curReport, "ElectricityProduced:Facility", "", AggType::Maximum);
    2214           24 :         AddMonthlyFieldSetInput(state, curReport, "Propane:Facility", "", AggType::SumOrAvg);
    2215           24 :         AddMonthlyFieldSetInput(state, curReport, "Propane:Facility", "", AggType::Maximum);
    2216              :     }
    2217           47 :     if (ort->namedMonthly(9).show) {
    2218           12 :         curReport = AddMonthlyReport(state, "EnergyConsumptionDieselFuelOilMonthly", 2, true);
    2219           24 :         AddMonthlyFieldSetInput(state, curReport, "Diesel:Facility", "", AggType::SumOrAvg);
    2220           24 :         AddMonthlyFieldSetInput(state, curReport, "Diesel:Facility", "", AggType::Maximum);
    2221           24 :         AddMonthlyFieldSetInput(state, curReport, "FuelOilNo1:Facility", "", AggType::SumOrAvg);
    2222           24 :         AddMonthlyFieldSetInput(state, curReport, "FuelOilNo1:Facility", "", AggType::Maximum);
    2223           24 :         AddMonthlyFieldSetInput(state, curReport, "FuelOilNo2:Facility", "", AggType::SumOrAvg);
    2224           24 :         AddMonthlyFieldSetInput(state, curReport, "FuelOilNo2:Facility", "", AggType::Maximum);
    2225              :     }
    2226           47 :     if (ort->namedMonthly(10).show) {
    2227           12 :         curReport = AddMonthlyReport(state, "EnergyConsumptionDistrictHeatingCoolingMonthly", 2, true);
    2228           24 :         AddMonthlyFieldSetInput(state, curReport, "DistrictCooling:Facility", "", AggType::SumOrAvg);
    2229           24 :         AddMonthlyFieldSetInput(state, curReport, "DistrictCooling:Facility", "", AggType::Maximum);
    2230           24 :         AddMonthlyFieldSetInput(state, curReport, "DistrictHeatingWater:Facility", "", AggType::SumOrAvg);
    2231           24 :         AddMonthlyFieldSetInput(state, curReport, "DistrictHeatingWater:Facility", "", AggType::Maximum);
    2232           24 :         AddMonthlyFieldSetInput(state, curReport, "DistrictHeatingSteam:Facility", "", AggType::SumOrAvg);
    2233           24 :         AddMonthlyFieldSetInput(state, curReport, "DistrictHeatingSteam:Facility", "", AggType::Maximum);
    2234              :     }
    2235           47 :     if (ort->namedMonthly(11).show) {
    2236           12 :         curReport = AddMonthlyReport(state, "EnergyConsumptionCoalGasolineMonthly", 2, true);
    2237           24 :         AddMonthlyFieldSetInput(state, curReport, "Coal:Facility", "", AggType::SumOrAvg);
    2238           24 :         AddMonthlyFieldSetInput(state, curReport, "Coal:Facility", "", AggType::Maximum);
    2239           24 :         AddMonthlyFieldSetInput(state, curReport, "Gasoline:Facility", "", AggType::SumOrAvg);
    2240           24 :         AddMonthlyFieldSetInput(state, curReport, "Gasoline:Facility", "", AggType::Maximum);
    2241              :     }
    2242           47 :     if (ort->namedMonthly(12).show) {
    2243           12 :         curReport = AddMonthlyReport(state, "EnergyConsumptionOtherFuelsMonthly", 2, true);
    2244           24 :         AddMonthlyFieldSetInput(state, curReport, "OtherFuel1:Facility", "", AggType::SumOrAvg);
    2245           24 :         AddMonthlyFieldSetInput(state, curReport, "OtherFuel1:Facility", "", AggType::Maximum);
    2246           24 :         AddMonthlyFieldSetInput(state, curReport, "OtherFuel2:Facility", "", AggType::SumOrAvg);
    2247           24 :         AddMonthlyFieldSetInput(state, curReport, "OtherFuel2:Facility", "", AggType::Maximum);
    2248              :     }
    2249           47 :     if (ort->namedMonthly(13).show) {
    2250           12 :         curReport = AddMonthlyReport(state, "EndUseEnergyConsumptionElectricityMonthly", 2, true);
    2251           24 :         AddMonthlyFieldSetInput(state, curReport, "InteriorLights:Electricity", "", AggType::SumOrAvg);
    2252           24 :         AddMonthlyFieldSetInput(state, curReport, "ExteriorLights:Electricity", "", AggType::SumOrAvg);
    2253           24 :         AddMonthlyFieldSetInput(state, curReport, "InteriorEquipment:Electricity", "", AggType::SumOrAvg);
    2254           24 :         AddMonthlyFieldSetInput(state, curReport, "ExteriorEquipment:Electricity", "", AggType::SumOrAvg);
    2255           24 :         AddMonthlyFieldSetInput(state, curReport, "Fans:Electricity", "", AggType::SumOrAvg);
    2256           24 :         AddMonthlyFieldSetInput(state, curReport, "Pumps:Electricity", "", AggType::SumOrAvg);
    2257           24 :         AddMonthlyFieldSetInput(state, curReport, "Heating:Electricity", "", AggType::SumOrAvg);
    2258           24 :         AddMonthlyFieldSetInput(state, curReport, "Cooling:Electricity", "", AggType::SumOrAvg);
    2259           24 :         AddMonthlyFieldSetInput(state, curReport, "HeatRejection:Electricity", "", AggType::SumOrAvg);
    2260           24 :         AddMonthlyFieldSetInput(state, curReport, "Humidifier:Electricity", "", AggType::SumOrAvg);
    2261           24 :         AddMonthlyFieldSetInput(state, curReport, "HeatRecovery:Electricity", "", AggType::SumOrAvg);
    2262           24 :         AddMonthlyFieldSetInput(state, curReport, "WaterSystems:Electricity", "", AggType::SumOrAvg);
    2263           24 :         AddMonthlyFieldSetInput(state, curReport, "Cogeneration:Electricity", "", AggType::SumOrAvg);
    2264              :     }
    2265           47 :     if (ort->namedMonthly(14).show) {
    2266           12 :         curReport = AddMonthlyReport(state, "EndUseEnergyConsumptionNaturalGasMonthly", 2, true);
    2267           24 :         AddMonthlyFieldSetInput(state, curReport, "InteriorEquipment:NaturalGas", "", AggType::SumOrAvg);
    2268           24 :         AddMonthlyFieldSetInput(state, curReport, "ExteriorEquipment:NaturalGas", "", AggType::SumOrAvg);
    2269           24 :         AddMonthlyFieldSetInput(state, curReport, "Heating:NaturalGas", "", AggType::SumOrAvg);
    2270           24 :         AddMonthlyFieldSetInput(state, curReport, "Cooling:NaturalGas", "", AggType::SumOrAvg);
    2271           24 :         AddMonthlyFieldSetInput(state, curReport, "WaterSystems:NaturalGas", "", AggType::SumOrAvg);
    2272           24 :         AddMonthlyFieldSetInput(state, curReport, "Cogeneration:NaturalGas", "", AggType::SumOrAvg);
    2273           24 :         AddMonthlyFieldSetInput(state, curReport, "Humidifier:NaturalGas", "", AggType::SumOrAvg);
    2274              :     }
    2275           47 :     if (ort->namedMonthly(15).show) {
    2276           12 :         curReport = AddMonthlyReport(state, "EndUseEnergyConsumptionDieselMonthly", 2, true);
    2277           24 :         AddMonthlyFieldSetInput(state, curReport, "ExteriorEquipment:Diesel", "", AggType::SumOrAvg);
    2278           24 :         AddMonthlyFieldSetInput(state, curReport, "Cooling:Diesel", "", AggType::SumOrAvg);
    2279           24 :         AddMonthlyFieldSetInput(state, curReport, "Heating:Diesel", "", AggType::SumOrAvg);
    2280           24 :         AddMonthlyFieldSetInput(state, curReport, "WaterSystems:Diesel", "", AggType::SumOrAvg);
    2281           24 :         AddMonthlyFieldSetInput(state, curReport, "Cogeneration:Diesel", "", AggType::SumOrAvg);
    2282              :     }
    2283           47 :     if (ort->namedMonthly(16).show) {
    2284           12 :         curReport = AddMonthlyReport(state, "EndUseEnergyConsumptionFuelOilMonthly", 2, true);
    2285           24 :         AddMonthlyFieldSetInput(state, curReport, "ExteriorEquipment:FuelOilNo1", "", AggType::SumOrAvg);
    2286           24 :         AddMonthlyFieldSetInput(state, curReport, "Cooling:FuelOilNo1", "", AggType::SumOrAvg);
    2287           24 :         AddMonthlyFieldSetInput(state, curReport, "Heating:FuelOilNo1", "", AggType::SumOrAvg);
    2288           24 :         AddMonthlyFieldSetInput(state, curReport, "WaterSystems:FuelOilNo1", "", AggType::SumOrAvg);
    2289           24 :         AddMonthlyFieldSetInput(state, curReport, "Cogeneration:FuelOilNo1", "", AggType::SumOrAvg);
    2290           24 :         AddMonthlyFieldSetInput(state, curReport, "ExteriorEquipment:FuelOilNo2", "", AggType::SumOrAvg);
    2291           24 :         AddMonthlyFieldSetInput(state, curReport, "Cooling:FuelOilNo2", "", AggType::SumOrAvg);
    2292           24 :         AddMonthlyFieldSetInput(state, curReport, "Heating:FuelOilNo2", "", AggType::SumOrAvg);
    2293           24 :         AddMonthlyFieldSetInput(state, curReport, "WaterSystems:FuelOilNo2", "", AggType::SumOrAvg);
    2294           24 :         AddMonthlyFieldSetInput(state, curReport, "Cogeneration:FuelOilNo2", "", AggType::SumOrAvg);
    2295              :     }
    2296           47 :     if (ort->namedMonthly(17).show) {
    2297           12 :         curReport = AddMonthlyReport(state, "EndUseEnergyConsumptionCoalMonthly", 2, true);
    2298           24 :         AddMonthlyFieldSetInput(state, curReport, "ExteriorEquipment:Coal", "", AggType::SumOrAvg);
    2299           24 :         AddMonthlyFieldSetInput(state, curReport, "Heating:Coal", "", AggType::SumOrAvg);
    2300           24 :         AddMonthlyFieldSetInput(state, curReport, "WaterSystems:Coal", "", AggType::SumOrAvg);
    2301              :     }
    2302           47 :     if (ort->namedMonthly(18).show) {
    2303           12 :         curReport = AddMonthlyReport(state, "EndUseEnergyConsumptionPropaneMonthly", 2, true);
    2304           24 :         AddMonthlyFieldSetInput(state, curReport, "ExteriorEquipment:Propane", "", AggType::SumOrAvg);
    2305           24 :         AddMonthlyFieldSetInput(state, curReport, "Cooling:Propane", "", AggType::SumOrAvg);
    2306           24 :         AddMonthlyFieldSetInput(state, curReport, "Heating:Propane", "", AggType::SumOrAvg);
    2307           24 :         AddMonthlyFieldSetInput(state, curReport, "WaterSystems:Propane", "", AggType::SumOrAvg);
    2308           24 :         AddMonthlyFieldSetInput(state, curReport, "Cogeneration:Propane", "", AggType::SumOrAvg);
    2309           24 :         AddMonthlyFieldSetInput(state, curReport, "Humidifier:Propane", "", AggType::SumOrAvg);
    2310              :     }
    2311           47 :     if (ort->namedMonthly(19).show) {
    2312           12 :         curReport = AddMonthlyReport(state, "EndUseEnergyConsumptionGasolineMonthly", 2, true);
    2313           24 :         AddMonthlyFieldSetInput(state, curReport, "ExteriorEquipment:Gasoline", "", AggType::SumOrAvg);
    2314           24 :         AddMonthlyFieldSetInput(state, curReport, "Cooling:Gasoline", "", AggType::SumOrAvg);
    2315           24 :         AddMonthlyFieldSetInput(state, curReport, "Heating:Gasoline", "", AggType::SumOrAvg);
    2316           24 :         AddMonthlyFieldSetInput(state, curReport, "WaterSystems:Gasoline", "", AggType::SumOrAvg);
    2317           24 :         AddMonthlyFieldSetInput(state, curReport, "Cogeneration:Gasoline", "", AggType::SumOrAvg);
    2318              :     }
    2319           47 :     if (ort->namedMonthly(20).show) {
    2320           12 :         curReport = AddMonthlyReport(state, "EndUseEnergyConsumptionOtherFuelsMonthly", 2, true);
    2321           24 :         AddMonthlyFieldSetInput(state, curReport, "ExteriorEquipment:OtherFuel1", "", AggType::SumOrAvg);
    2322           24 :         AddMonthlyFieldSetInput(state, curReport, "Cooling:OtherFuel1", "", AggType::SumOrAvg);
    2323           24 :         AddMonthlyFieldSetInput(state, curReport, "Heating:OtherFuel1", "", AggType::SumOrAvg);
    2324           24 :         AddMonthlyFieldSetInput(state, curReport, "WaterSystems:OtherFuel1", "", AggType::SumOrAvg);
    2325           24 :         AddMonthlyFieldSetInput(state, curReport, "Cogeneration:OtherFuel1", "", AggType::SumOrAvg);
    2326           24 :         AddMonthlyFieldSetInput(state, curReport, "ExteriorEquipment:OtherFuel2", "", AggType::SumOrAvg);
    2327           24 :         AddMonthlyFieldSetInput(state, curReport, "Cooling:OtherFuel2", "", AggType::SumOrAvg);
    2328           24 :         AddMonthlyFieldSetInput(state, curReport, "Heating:OtherFuel2", "", AggType::SumOrAvg);
    2329           24 :         AddMonthlyFieldSetInput(state, curReport, "WaterSystems:OtherFuel2", "", AggType::SumOrAvg);
    2330           24 :         AddMonthlyFieldSetInput(state, curReport, "Cogeneration:OtherFuel2", "", AggType::SumOrAvg);
    2331              :     }
    2332           47 :     if (ort->namedMonthly(21).show) {
    2333           12 :         curReport = AddMonthlyReport(state, "PeakEnergyEndUseElectricityPart1Monthly", 2, true);
    2334           24 :         AddMonthlyFieldSetInput(state, curReport, "InteriorLights:Electricity", "", AggType::Maximum);
    2335           24 :         AddMonthlyFieldSetInput(state, curReport, "ExteriorLights:Electricity", "", AggType::Maximum);
    2336           24 :         AddMonthlyFieldSetInput(state, curReport, "InteriorEquipment:Electricity", "", AggType::Maximum);
    2337           24 :         AddMonthlyFieldSetInput(state, curReport, "ExteriorEquipment:Electricity", "", AggType::Maximum);
    2338           24 :         AddMonthlyFieldSetInput(state, curReport, "Fans:Electricity", "", AggType::Maximum);
    2339           24 :         AddMonthlyFieldSetInput(state, curReport, "Pumps:Electricity", "", AggType::Maximum);
    2340           24 :         AddMonthlyFieldSetInput(state, curReport, "Heating:Electricity", "", AggType::Maximum);
    2341              :     }
    2342           47 :     if (ort->namedMonthly(22).show) {
    2343           12 :         curReport = AddMonthlyReport(state, "PeakEnergyEndUseElectricityPart2Monthly", 2, true);
    2344           24 :         AddMonthlyFieldSetInput(state, curReport, "Cooling:Electricity", "", AggType::Maximum);
    2345           24 :         AddMonthlyFieldSetInput(state, curReport, "HeatRejection:Electricity", "", AggType::Maximum);
    2346           24 :         AddMonthlyFieldSetInput(state, curReport, "Humidifier:Electricity", "", AggType::Maximum);
    2347           24 :         AddMonthlyFieldSetInput(state, curReport, "HeatRecovery:Electricity", "", AggType::Maximum);
    2348           24 :         AddMonthlyFieldSetInput(state, curReport, "WaterSystems:Electricity", "", AggType::Maximum);
    2349           24 :         AddMonthlyFieldSetInput(state, curReport, "Cogeneration:Electricity", "", AggType::Maximum);
    2350              :     }
    2351           47 :     if (ort->namedMonthly(23).show) {
    2352           12 :         curReport = AddMonthlyReport(state, "ElectricComponentsOfPeakDemandMonthly", 2, true);
    2353           24 :         AddMonthlyFieldSetInput(state, curReport, "Electricity:Facility", "", AggType::Maximum);
    2354           24 :         AddMonthlyFieldSetInput(state, curReport, "InteriorLights:Electricity", "", AggType::ValueWhenMaxMin);
    2355           24 :         AddMonthlyFieldSetInput(state, curReport, "InteriorEquipment:Electricity", "", AggType::ValueWhenMaxMin);
    2356           24 :         AddMonthlyFieldSetInput(state, curReport, "ExteriorLights:Electricity", "", AggType::ValueWhenMaxMin);
    2357           24 :         AddMonthlyFieldSetInput(state, curReport, "ExteriorEquipment:Electricity", "", AggType::ValueWhenMaxMin);
    2358           24 :         AddMonthlyFieldSetInput(state, curReport, "Fans:Electricity", "", AggType::ValueWhenMaxMin);
    2359           24 :         AddMonthlyFieldSetInput(state, curReport, "Pumps:Electricity", "", AggType::ValueWhenMaxMin);
    2360           24 :         AddMonthlyFieldSetInput(state, curReport, "Heating:Electricity", "", AggType::ValueWhenMaxMin);
    2361           24 :         AddMonthlyFieldSetInput(state, curReport, "Cooling:Electricity", "", AggType::ValueWhenMaxMin);
    2362           24 :         AddMonthlyFieldSetInput(state, curReport, "HeatRejection:Electricity", "", AggType::ValueWhenMaxMin);
    2363              :     }
    2364           47 :     if (ort->namedMonthly(24).show) {
    2365           12 :         curReport = AddMonthlyReport(state, "PeakEnergyEndUseNaturalGasMonthly", 2, true);
    2366           24 :         AddMonthlyFieldSetInput(state, curReport, "InteriorEquipment:NaturalGas", "", AggType::Maximum);
    2367           24 :         AddMonthlyFieldSetInput(state, curReport, "ExteriorEquipment:NaturalGas", "", AggType::Maximum);
    2368           24 :         AddMonthlyFieldSetInput(state, curReport, "Heating:NaturalGas", "", AggType::Maximum);
    2369           24 :         AddMonthlyFieldSetInput(state, curReport, "Cooling:NaturalGas", "", AggType::Maximum);
    2370           24 :         AddMonthlyFieldSetInput(state, curReport, "WaterSystems:NaturalGas", "", AggType::Maximum);
    2371           24 :         AddMonthlyFieldSetInput(state, curReport, "Cogeneration:NaturalGas", "", AggType::Maximum);
    2372              :     }
    2373           47 :     if (ort->namedMonthly(25).show) {
    2374           12 :         curReport = AddMonthlyReport(state, "PeakEnergyEndUseDieselMonthly", 2, true);
    2375           24 :         AddMonthlyFieldSetInput(state, curReport, "ExteriorEquipment:Diesel", "", AggType::Maximum);
    2376           24 :         AddMonthlyFieldSetInput(state, curReport, "Cooling:Diesel", "", AggType::Maximum);
    2377           24 :         AddMonthlyFieldSetInput(state, curReport, "Heating:Diesel", "", AggType::Maximum);
    2378           24 :         AddMonthlyFieldSetInput(state, curReport, "WaterSystems:Diesel", "", AggType::Maximum);
    2379           24 :         AddMonthlyFieldSetInput(state, curReport, "Cogeneration:Diesel", "", AggType::Maximum);
    2380              :     }
    2381           47 :     if (ort->namedMonthly(26).show) {
    2382           12 :         curReport = AddMonthlyReport(state, "PeakEnergyEndUseFuelOilMonthly", 2, true);
    2383           24 :         AddMonthlyFieldSetInput(state, curReport, "ExteriorEquipment:FuelOilNo1", "", AggType::Maximum);
    2384           24 :         AddMonthlyFieldSetInput(state, curReport, "Cooling:FuelOilNo1", "", AggType::Maximum);
    2385           24 :         AddMonthlyFieldSetInput(state, curReport, "Heating:FuelOilNo1", "", AggType::Maximum);
    2386           24 :         AddMonthlyFieldSetInput(state, curReport, "WaterSystems:FuelOilNo1", "", AggType::Maximum);
    2387           24 :         AddMonthlyFieldSetInput(state, curReport, "Cogeneration:FuelOilNo1", "", AggType::Maximum);
    2388           24 :         AddMonthlyFieldSetInput(state, curReport, "ExteriorEquipment:FuelOilNo2", "", AggType::Maximum);
    2389           24 :         AddMonthlyFieldSetInput(state, curReport, "Cooling:FuelOilNo2", "", AggType::Maximum);
    2390           24 :         AddMonthlyFieldSetInput(state, curReport, "Heating:FuelOilNo2", "", AggType::Maximum);
    2391           24 :         AddMonthlyFieldSetInput(state, curReport, "WaterSystems:FuelOilNo2", "", AggType::Maximum);
    2392           24 :         AddMonthlyFieldSetInput(state, curReport, "Cogeneration:FuelOilNo2", "", AggType::Maximum);
    2393              :     }
    2394           47 :     if (ort->namedMonthly(27).show) {
    2395           12 :         curReport = AddMonthlyReport(state, "PeakEnergyEndUseCoalMonthly", 2, true);
    2396           24 :         AddMonthlyFieldSetInput(state, curReport, "ExteriorEquipment:Coal", "", AggType::Maximum);
    2397           24 :         AddMonthlyFieldSetInput(state, curReport, "Heating:Coal", "", AggType::Maximum);
    2398           24 :         AddMonthlyFieldSetInput(state, curReport, "WaterSystems:Coal", "", AggType::Maximum);
    2399              :     }
    2400           47 :     if (ort->namedMonthly(28).show) {
    2401           12 :         curReport = AddMonthlyReport(state, "PeakEnergyEndUsePropaneMonthly", 2, true);
    2402           24 :         AddMonthlyFieldSetInput(state, curReport, "ExteriorEquipment:Propane", "", AggType::Maximum);
    2403           24 :         AddMonthlyFieldSetInput(state, curReport, "Cooling:Propane", "", AggType::Maximum);
    2404           24 :         AddMonthlyFieldSetInput(state, curReport, "Heating:Propane", "", AggType::Maximum);
    2405           24 :         AddMonthlyFieldSetInput(state, curReport, "WaterSystems:Propane", "", AggType::Maximum);
    2406           24 :         AddMonthlyFieldSetInput(state, curReport, "Cogeneration:Propane", "", AggType::Maximum);
    2407              :     }
    2408           47 :     if (ort->namedMonthly(29).show) {
    2409           12 :         curReport = AddMonthlyReport(state, "PeakEnergyEndUseGasolineMonthly", 2, true);
    2410           24 :         AddMonthlyFieldSetInput(state, curReport, "ExteriorEquipment:Gasoline", "", AggType::Maximum);
    2411           24 :         AddMonthlyFieldSetInput(state, curReport, "Cooling:Gasoline", "", AggType::Maximum);
    2412           24 :         AddMonthlyFieldSetInput(state, curReport, "Heating:Gasoline", "", AggType::Maximum);
    2413           24 :         AddMonthlyFieldSetInput(state, curReport, "WaterSystems:Gasoline", "", AggType::Maximum);
    2414           24 :         AddMonthlyFieldSetInput(state, curReport, "Cogeneration:Gasoline", "", AggType::Maximum);
    2415              :     }
    2416           47 :     if (ort->namedMonthly(30).show) {
    2417           12 :         curReport = AddMonthlyReport(state, "PeakEnergyEndUseOtherFuelsMonthly", 2, true);
    2418           24 :         AddMonthlyFieldSetInput(state, curReport, "ExteriorEquipment:OtherFuel1", "", AggType::Maximum);
    2419           24 :         AddMonthlyFieldSetInput(state, curReport, "Cooling:OtherFuel1", "", AggType::Maximum);
    2420           24 :         AddMonthlyFieldSetInput(state, curReport, "Heating:OtherFuel1", "", AggType::Maximum);
    2421           24 :         AddMonthlyFieldSetInput(state, curReport, "WaterSystems:OtherFuel1", "", AggType::Maximum);
    2422           24 :         AddMonthlyFieldSetInput(state, curReport, "Cogeneration:OtherFuel1", "", AggType::Maximum);
    2423           24 :         AddMonthlyFieldSetInput(state, curReport, "ExteriorEquipment:OtherFuel2", "", AggType::Maximum);
    2424           24 :         AddMonthlyFieldSetInput(state, curReport, "Cooling:OtherFuel2", "", AggType::Maximum);
    2425           24 :         AddMonthlyFieldSetInput(state, curReport, "Heating:OtherFuel2", "", AggType::Maximum);
    2426           24 :         AddMonthlyFieldSetInput(state, curReport, "WaterSystems:OtherFuel2", "", AggType::Maximum);
    2427           24 :         AddMonthlyFieldSetInput(state, curReport, "Cogeneration:OtherFuel2", "", AggType::Maximum);
    2428              :     }
    2429           47 :     if (ort->namedMonthly(31).show) {
    2430           14 :         curReport = AddMonthlyReport(state, "SetpointsNotMetWithTemperaturesMonthly", 2, true);
    2431           28 :         AddMonthlyFieldSetInput(state, curReport, "Zone Heating Setpoint Not Met Time", "", AggType::HoursNonZero);
    2432           28 :         AddMonthlyFieldSetInput(state, curReport, "Zone Mean Air Temperature", "", AggType::SumOrAverageHoursShown);
    2433           28 :         AddMonthlyFieldSetInput(state, curReport, "Zone Heating Setpoint Not Met While Occupied Time", "", AggType::HoursNonZero);
    2434           28 :         AddMonthlyFieldSetInput(state, curReport, "Zone Mean Air Temperature", "", AggType::SumOrAverageHoursShown);
    2435           28 :         AddMonthlyFieldSetInput(state, curReport, "Zone Cooling Setpoint Not Met Time", "", AggType::HoursNonZero);
    2436           28 :         AddMonthlyFieldSetInput(state, curReport, "Zone Mean Air Temperature", "", AggType::SumOrAverageHoursShown);
    2437           28 :         AddMonthlyFieldSetInput(state, curReport, "Zone Cooling Setpoint Not Met While Occupied Time", "", AggType::HoursNonZero);
    2438           28 :         AddMonthlyFieldSetInput(state, curReport, "Zone Mean Air Temperature", "", AggType::SumOrAverageHoursShown);
    2439              :     }
    2440           47 :     if (ort->namedMonthly(32).show) {
    2441           12 :         curReport = AddMonthlyReport(state, "ComfortReportSimple55Monthly", 2, true);
    2442           24 :         AddMonthlyFieldSetInput(
    2443              :             state, curReport, "Zone Thermal Comfort ASHRAE 55 Simple Model Summer Clothes Not Comfortable Time", "", AggType::HoursNonZero);
    2444           24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Mean Air Temperature", "", AggType::SumOrAverageHoursShown);
    2445           24 :         AddMonthlyFieldSetInput(
    2446              :             state, curReport, "Zone Thermal Comfort ASHRAE 55 Simple Model Winter Clothes Not Comfortable Time", "", AggType::HoursNonZero);
    2447           24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Mean Air Temperature", "", AggType::SumOrAverageHoursShown);
    2448           24 :         AddMonthlyFieldSetInput(
    2449              :             state, curReport, "Zone Thermal Comfort ASHRAE 55 Simple Model Summer or Winter Clothes Not Comfortable Time", "", AggType::HoursNonZero);
    2450           24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Mean Air Temperature", "", AggType::SumOrAverageHoursShown);
    2451              :     }
    2452           47 :     if (ort->namedMonthly(33).show) {
    2453           12 :         curReport = AddMonthlyReport(state, "UnglazedTranspiredSolarCollectorSummaryMonthly", 5, true);
    2454           24 :         AddMonthlyFieldSetInput(state, curReport, "Solar Collector System Efficiency", "", AggType::HoursNonZero);
    2455           24 :         AddMonthlyFieldSetInput(state, curReport, "Solar Collector System Efficiency", "", AggType::SumOrAverageHoursShown);
    2456           24 :         AddMonthlyFieldSetInput(state, curReport, "Solar Collector Outside Face Suction Velocity", "", AggType::SumOrAverageHoursShown);
    2457           24 :         AddMonthlyFieldSetInput(state, curReport, "Solar Collector Sensible Heating Rate", "", AggType::SumOrAverageHoursShown);
    2458              :     }
    2459           47 :     if (ort->namedMonthly(34).show) {
    2460           12 :         curReport = AddMonthlyReport(state, "OccupantComfortDataSummaryMonthly", 5, true);
    2461           24 :         AddMonthlyFieldSetInput(state, curReport, "People Occupant Count", "", AggType::HoursNonZero);
    2462           24 :         AddMonthlyFieldSetInput(state, curReport, "People Air Temperature", "", AggType::SumOrAverageHoursShown);
    2463           24 :         AddMonthlyFieldSetInput(state, curReport, "People Air Relative Humidity", "", AggType::SumOrAverageHoursShown);
    2464           24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Thermal Comfort Fanger Model PMV", "", AggType::SumOrAverageHoursShown);
    2465           24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Thermal Comfort Fanger Model PPD", "", AggType::SumOrAverageHoursShown);
    2466              :     }
    2467           47 :     if (ort->namedMonthly(35).show) {
    2468           12 :         curReport = AddMonthlyReport(state, "ChillerReportMonthly", 2, true);
    2469           24 :         AddMonthlyFieldSetInput(state, curReport, "Chiller Electricity Energy", "", AggType::SumOrAvg);
    2470           24 :         AddMonthlyFieldSetInput(state, curReport, "Chiller Electricity Rate", "", AggType::Maximum);
    2471           24 :         AddMonthlyFieldSetInput(state, curReport, "Chiller Electricity Energy", "", AggType::HoursNonZero);
    2472           24 :         AddMonthlyFieldSetInput(state, curReport, "Chiller Evaporator Cooling Energy", "", AggType::SumOrAvg);
    2473           24 :         AddMonthlyFieldSetInput(state, curReport, "Chiller Evaporator Cooling Rate", "", AggType::Maximum);
    2474           24 :         AddMonthlyFieldSetInput(state, curReport, "Chiller Condenser Heat Transfer Energy", "", AggType::SumOrAvg);
    2475           24 :         AddMonthlyFieldSetInput(state, curReport, "Chiller COP", "", AggType::SumOrAvg);
    2476           24 :         AddMonthlyFieldSetInput(state, curReport, "Chiller COP", "", AggType::Maximum);
    2477           24 :         AddMonthlyFieldSetInput(state, curReport, "Chiller Part Load Ratio", "", AggType::SumOrAvg);
    2478           24 :         AddMonthlyFieldSetInput(state, curReport, "Chiller Part Load Ratio", "", AggType::Maximum);
    2479              :     }
    2480           47 :     if (ort->namedMonthly(36).show) {
    2481           12 :         curReport = AddMonthlyReport(state, "TowerReportMonthly", 2, true);
    2482           24 :         AddMonthlyFieldSetInput(state, curReport, "Cooling Tower Fan Electricity Energy", "", AggType::SumOrAvg);
    2483           24 :         AddMonthlyFieldSetInput(state, curReport, "Cooling Tower Fan Electricity Energy", "", AggType::HoursNonZero);
    2484           24 :         AddMonthlyFieldSetInput(state, curReport, "Cooling Tower Fan Electricity Rate", "", AggType::Maximum);
    2485           24 :         AddMonthlyFieldSetInput(state, curReport, "Cooling Tower Heat Transfer Rate", "", AggType::Maximum);
    2486           24 :         AddMonthlyFieldSetInput(state, curReport, "Cooling Tower Inlet Temperature", "", AggType::SumOrAvg);
    2487           24 :         AddMonthlyFieldSetInput(state, curReport, "Cooling Tower Outlet Temperature", "", AggType::SumOrAvg);
    2488           24 :         AddMonthlyFieldSetInput(state, curReport, "Cooling Tower Mass Flow Rate", "", AggType::SumOrAvg);
    2489              :     }
    2490           47 :     if (ort->namedMonthly(37).show) {
    2491           12 :         curReport = AddMonthlyReport(state, "BoilerReportMonthly", 2, true);
    2492           24 :         AddMonthlyFieldSetInput(state, curReport, "Boiler Heating Energy", "", AggType::SumOrAvg);
    2493           24 :         AddMonthlyFieldSetInput(state, curReport, "Boiler Gas Consumption", "", AggType::SumOrAvg);
    2494           24 :         AddMonthlyFieldSetInput(state, curReport, "Boiler Heating Energy", "", AggType::HoursNonZero);
    2495           24 :         AddMonthlyFieldSetInput(state, curReport, "Boiler Heating Rate", "", AggType::Maximum);
    2496           24 :         AddMonthlyFieldSetInput(state, curReport, "Boiler Gas Consumption Rate", "", AggType::Maximum);
    2497           24 :         AddMonthlyFieldSetInput(state, curReport, "Boiler Inlet Temperature", "", AggType::SumOrAvg);
    2498           24 :         AddMonthlyFieldSetInput(state, curReport, "Boiler Outlet Temperature", "", AggType::SumOrAvg);
    2499           24 :         AddMonthlyFieldSetInput(state, curReport, "Boiler Mass Flow Rate", "", AggType::SumOrAvg);
    2500           24 :         AddMonthlyFieldSetInput(state, curReport, "Boiler Ancillary Electricity Rate", "", AggType::SumOrAvg);
    2501           24 :         AddMonthlyFieldSetInput(state, curReport, "Boiler Part Load Ratio", "", AggType::SumOrAvg);
    2502           24 :         AddMonthlyFieldSetInput(state, curReport, "Boiler Part Load Ratio", "", AggType::Maximum);
    2503              :     }
    2504           47 :     if (ort->namedMonthly(38).show) {
    2505           12 :         curReport = AddMonthlyReport(state, "DXReportMonthly", 2, true);
    2506           24 :         AddMonthlyFieldSetInput(state, curReport, "Cooling Coil Total Cooling Energy", "", AggType::SumOrAvg);
    2507           24 :         AddMonthlyFieldSetInput(state, curReport, "Cooling Coil Electricity Energy", "", AggType::SumOrAvg);
    2508           24 :         AddMonthlyFieldSetInput(state, curReport, "Cooling Coil Total Cooling Energy", "", AggType::HoursNonZero);
    2509           24 :         AddMonthlyFieldSetInput(state, curReport, "Cooling Coil Sensible Cooling Energy", "", AggType::SumOrAvg);
    2510           24 :         AddMonthlyFieldSetInput(state, curReport, "Cooling Coil Latent Cooling Energy", "", AggType::SumOrAvg);
    2511           24 :         AddMonthlyFieldSetInput(state, curReport, "Cooling Coil Crankcase Heater Electricity Energy", "", AggType::SumOrAvg);
    2512           24 :         AddMonthlyFieldSetInput(state, curReport, "Cooling Coil Runtime Fraction", "", AggType::Maximum);
    2513           24 :         AddMonthlyFieldSetInput(state, curReport, "Cooling Coil Runtime Fraction", "", AggType::Minimum);
    2514           24 :         AddMonthlyFieldSetInput(state, curReport, "Cooling Coil Total Cooling Rate", "", AggType::Maximum);
    2515           24 :         AddMonthlyFieldSetInput(state, curReport, "Cooling Coil Sensible Cooling Rate", "", AggType::Maximum);
    2516           24 :         AddMonthlyFieldSetInput(state, curReport, "Cooling Coil Latent Cooling Rate", "", AggType::Maximum);
    2517           24 :         AddMonthlyFieldSetInput(state, curReport, "Cooling Coil Electricity Rate", "", AggType::Maximum);
    2518           24 :         AddMonthlyFieldSetInput(state, curReport, "Cooling Coil Crankcase Heater Electricity Rate", "", AggType::Maximum);
    2519              :     }
    2520           47 :     if (ort->namedMonthly(39).show) {
    2521           12 :         curReport = AddMonthlyReport(state, "WindowReportMonthly", 2, true);
    2522           24 :         AddMonthlyFieldSetInput(state, curReport, "Surface Window Transmitted Solar Radiation Rate", "", AggType::SumOrAvg);
    2523           24 :         AddMonthlyFieldSetInput(state, curReport, "Surface Window Transmitted Beam Solar Radiation Rate", "", AggType::SumOrAvg);
    2524           24 :         AddMonthlyFieldSetInput(state, curReport, "Surface Window Transmitted Diffuse Solar Radiation Rate", "", AggType::SumOrAvg);
    2525           24 :         AddMonthlyFieldSetInput(state, curReport, "Surface Window Heat Gain Rate", "", AggType::SumOrAvg);
    2526           24 :         AddMonthlyFieldSetInput(state, curReport, "Surface Window Heat Loss Rate", "", AggType::SumOrAvg);
    2527           24 :         AddMonthlyFieldSetInput(state, curReport, "Surface Window Inside Face Glazing Condensation Status", "", AggType::HoursNonZero);
    2528           24 :         AddMonthlyFieldSetInput(state, curReport, "Surface Shading Device Is On Time Fraction", "", AggType::HoursNonZero);
    2529           24 :         AddMonthlyFieldSetInput(state, curReport, "Surface Storm Window On Off Status", "", AggType::HoursNonZero);
    2530              :     }
    2531           47 :     if (ort->namedMonthly(40).show) {
    2532           12 :         curReport = AddMonthlyReport(state, "WindowEnergyReportMonthly", 2, true);
    2533           24 :         AddMonthlyFieldSetInput(state, curReport, "Surface Window Transmitted Solar Radiation Energy", "", AggType::SumOrAvg);
    2534           24 :         AddMonthlyFieldSetInput(state, curReport, "Surface Window Transmitted Beam Solar Radiation Energy", "", AggType::SumOrAvg);
    2535           24 :         AddMonthlyFieldSetInput(state, curReport, "Surface Window Transmitted Diffuse Solar Radiation Energy", "", AggType::SumOrAvg);
    2536           24 :         AddMonthlyFieldSetInput(state, curReport, "Surface Window Heat Gain Energy", "", AggType::SumOrAvg);
    2537           24 :         AddMonthlyFieldSetInput(state, curReport, "Surface Window Heat Loss Energy", "", AggType::SumOrAvg);
    2538              :     }
    2539           47 :     if (ort->namedMonthly(41).show) {
    2540           12 :         curReport = AddMonthlyReport(state, "WindowZoneSummaryMonthly", 2, true);
    2541           24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Windows Total Heat Gain Rate", "", AggType::SumOrAvg);
    2542           24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Windows Total Heat Loss Rate", "", AggType::SumOrAvg);
    2543           24 :         AddMonthlyFieldSetInput(state, curReport, "Enclosure Windows Total Transmitted Solar Radiation Rate", "", AggType::SumOrAvg);
    2544           24 :         AddMonthlyFieldSetInput(state, curReport, "Enclosure Exterior Windows Total Transmitted Beam Solar Radiation Rate", "", AggType::SumOrAvg);
    2545           24 :         AddMonthlyFieldSetInput(state, curReport, "Enclosure Exterior Windows Total Transmitted Diffuse Solar Radiation Rate", "", AggType::SumOrAvg);
    2546           24 :         AddMonthlyFieldSetInput(state, curReport, "Enclosure Interior Windows Total Transmitted Diffuse Solar Radiation Rate", "", AggType::SumOrAvg);
    2547           24 :         AddMonthlyFieldSetInput(state, curReport, "Enclosure Interior Windows Total Transmitted Beam Solar Radiation Rate", "", AggType::SumOrAvg);
    2548              :     }
    2549           47 :     if (ort->namedMonthly(42).show) {
    2550           12 :         curReport = AddMonthlyReport(state, "WindowEnergyZoneSummaryMonthly", 2, true);
    2551           24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Windows Total Heat Gain Energy", "", AggType::SumOrAvg);
    2552           24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Windows Total Heat Loss Energy", "", AggType::SumOrAvg);
    2553           24 :         AddMonthlyFieldSetInput(state, curReport, "Enclosure Windows Total Transmitted Solar Radiation Energy", "", AggType::SumOrAvg);
    2554           24 :         AddMonthlyFieldSetInput(state, curReport, "Enclosure Exterior Windows Total Transmitted Beam Solar Radiation Energy", "", AggType::SumOrAvg);
    2555           24 :         AddMonthlyFieldSetInput(
    2556              :             state, curReport, "Enclosure Exterior Windows Total Transmitted Diffuse Solar Radiation Energy", "", AggType::SumOrAvg);
    2557           24 :         AddMonthlyFieldSetInput(
    2558              :             state, curReport, "Enclosure Interior Windows Total Transmitted Diffuse Solar Radiation Energy", "", AggType::SumOrAvg);
    2559           24 :         AddMonthlyFieldSetInput(state, curReport, "Enclosure Interior Windows Total Transmitted Beam Solar Radiation Energy", "", AggType::SumOrAvg);
    2560              :     }
    2561           47 :     if (ort->namedMonthly(43).show) {
    2562           12 :         curReport = AddMonthlyReport(state, "AverageOutdoorConditionsMonthly", 2, true);
    2563           24 :         AddMonthlyFieldSetInput(state, curReport, "Site Outdoor Air Drybulb Temperature", "", AggType::SumOrAvg);
    2564           24 :         AddMonthlyFieldSetInput(state, curReport, "Site Outdoor Air Wetbulb Temperature", "", AggType::SumOrAvg);
    2565           24 :         AddMonthlyFieldSetInput(state, curReport, "Site Outdoor Air Dewpoint Temperature", "", AggType::SumOrAvg);
    2566           24 :         AddMonthlyFieldSetInput(state, curReport, "Site Wind Speed", "", AggType::SumOrAvg);
    2567           24 :         AddMonthlyFieldSetInput(state, curReport, "Site Sky Temperature", "", AggType::SumOrAvg);
    2568           24 :         AddMonthlyFieldSetInput(state, curReport, "Site Diffuse Solar Radiation Rate per Area", "", AggType::SumOrAvg);
    2569           24 :         AddMonthlyFieldSetInput(state, curReport, "Site Direct Solar Radiation Rate per Area", "", AggType::SumOrAvg);
    2570           24 :         AddMonthlyFieldSetInput(state, curReport, "Site Rain Status", "", AggType::SumOrAvg);
    2571              :     }
    2572           47 :     if (ort->namedMonthly(44).show) {
    2573           12 :         curReport = AddMonthlyReport(state, "OutdoorConditionsMaximumDryBulbMonthly", 2, true);
    2574           24 :         AddMonthlyFieldSetInput(state, curReport, "Site Outdoor Air Drybulb Temperature", "", AggType::Maximum);
    2575           24 :         AddMonthlyFieldSetInput(state, curReport, "Site Outdoor Air Wetbulb Temperature", "", AggType::ValueWhenMaxMin);
    2576           24 :         AddMonthlyFieldSetInput(state, curReport, "Site Outdoor Air Dewpoint Temperature", "", AggType::ValueWhenMaxMin);
    2577           24 :         AddMonthlyFieldSetInput(state, curReport, "Site Wind Speed", "", AggType::ValueWhenMaxMin);
    2578           24 :         AddMonthlyFieldSetInput(state, curReport, "Site Sky Temperature", "", AggType::ValueWhenMaxMin);
    2579           24 :         AddMonthlyFieldSetInput(state, curReport, "Site Diffuse Solar Radiation Rate per Area", "", AggType::ValueWhenMaxMin);
    2580           24 :         AddMonthlyFieldSetInput(state, curReport, "Site Direct Solar Radiation Rate per Area", "", AggType::ValueWhenMaxMin);
    2581              :     }
    2582           47 :     if (ort->namedMonthly(45).show) {
    2583           12 :         curReport = AddMonthlyReport(state, "OutdoorConditionsMinimumDryBulbMonthly", 2, true);
    2584           24 :         AddMonthlyFieldSetInput(state, curReport, "Site Outdoor Air Drybulb Temperature", "", AggType::Minimum);
    2585           24 :         AddMonthlyFieldSetInput(state, curReport, "Site Outdoor Air Wetbulb Temperature", "", AggType::ValueWhenMaxMin);
    2586           24 :         AddMonthlyFieldSetInput(state, curReport, "Site Outdoor Air Dewpoint Temperature", "", AggType::ValueWhenMaxMin);
    2587           24 :         AddMonthlyFieldSetInput(state, curReport, "Site Wind Speed", "", AggType::ValueWhenMaxMin);
    2588           24 :         AddMonthlyFieldSetInput(state, curReport, "Site Sky Temperature", "", AggType::ValueWhenMaxMin);
    2589           24 :         AddMonthlyFieldSetInput(state, curReport, "Site Diffuse Solar Radiation Rate per Area", "", AggType::ValueWhenMaxMin);
    2590           24 :         AddMonthlyFieldSetInput(state, curReport, "Site Direct Solar Radiation Rate per Area", "", AggType::ValueWhenMaxMin);
    2591              :     }
    2592           47 :     if (ort->namedMonthly(46).show) {
    2593           12 :         curReport = AddMonthlyReport(state, "OutdoorConditionsMaximumWetBulbMonthly", 2, true);
    2594           24 :         AddMonthlyFieldSetInput(state, curReport, "Site Outdoor Air Wetbulb Temperature", "", AggType::Maximum);
    2595           24 :         AddMonthlyFieldSetInput(state, curReport, "Site Outdoor Air Drybulb Temperature", "", AggType::ValueWhenMaxMin);
    2596           24 :         AddMonthlyFieldSetInput(state, curReport, "Site Outdoor Air Dewpoint Temperature", "", AggType::ValueWhenMaxMin);
    2597           24 :         AddMonthlyFieldSetInput(state, curReport, "Site Wind Speed", "", AggType::ValueWhenMaxMin);
    2598           24 :         AddMonthlyFieldSetInput(state, curReport, "Site Sky Temperature", "", AggType::ValueWhenMaxMin);
    2599           24 :         AddMonthlyFieldSetInput(state, curReport, "Site Diffuse Solar Radiation Rate per Area", "", AggType::ValueWhenMaxMin);
    2600           24 :         AddMonthlyFieldSetInput(state, curReport, "Site Direct Solar Radiation Rate per Area", "", AggType::ValueWhenMaxMin);
    2601              :     }
    2602           47 :     if (ort->namedMonthly(47).show) {
    2603           12 :         curReport = AddMonthlyReport(state, "OutdoorConditionsMaximumDewPointMonthly", 2, true);
    2604           24 :         AddMonthlyFieldSetInput(state, curReport, "Site Outdoor Air Dewpoint Temperature", "", AggType::Maximum);
    2605           24 :         AddMonthlyFieldSetInput(state, curReport, "Site Outdoor Air Drybulb Temperature", "", AggType::ValueWhenMaxMin);
    2606           24 :         AddMonthlyFieldSetInput(state, curReport, "Site Outdoor Air Wetbulb Temperature", "", AggType::ValueWhenMaxMin);
    2607           24 :         AddMonthlyFieldSetInput(state, curReport, "Site Wind Speed", "", AggType::ValueWhenMaxMin);
    2608           24 :         AddMonthlyFieldSetInput(state, curReport, "Site Sky Temperature", "", AggType::ValueWhenMaxMin);
    2609           24 :         AddMonthlyFieldSetInput(state, curReport, "Site Diffuse Solar Radiation Rate per Area", "", AggType::ValueWhenMaxMin);
    2610           24 :         AddMonthlyFieldSetInput(state, curReport, "Site Direct Solar Radiation Rate per Area", "", AggType::ValueWhenMaxMin);
    2611              :     }
    2612           47 :     if (ort->namedMonthly(48).show) {
    2613           12 :         curReport = AddMonthlyReport(state, "OutdoorGroundConditionsMonthly", 2, true);
    2614           24 :         AddMonthlyFieldSetInput(state, curReport, "Site Ground Temperature", "", AggType::SumOrAvg);
    2615           24 :         AddMonthlyFieldSetInput(state, curReport, "Site Surface Ground Temperature", "", AggType::SumOrAvg);
    2616           24 :         AddMonthlyFieldSetInput(state, curReport, "Site Deep Ground Temperature", "", AggType::SumOrAvg);
    2617           24 :         AddMonthlyFieldSetInput(state, curReport, "Site Mains Water Temperature", "", AggType::SumOrAvg);
    2618           24 :         AddMonthlyFieldSetInput(state, curReport, "Site Ground Reflected Solar Radiation Rate per Area", "", AggType::SumOrAvg);
    2619           24 :         AddMonthlyFieldSetInput(state, curReport, "Site Snow on Ground Status", "", AggType::SumOrAvg);
    2620              :     }
    2621           47 :     if (ort->namedMonthly(49).show) {
    2622           12 :         curReport = AddMonthlyReport(state, "WindowACReportMonthly", 2, true);
    2623           24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Window Air Conditioner Total Cooling Energy", "", AggType::SumOrAvg);
    2624           24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Window Air Conditioner Electricity Energy", "", AggType::SumOrAvg);
    2625           24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Window Air Conditioner Total Cooling Energy", "", AggType::HoursNonZero);
    2626           24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Window Air Conditioner Sensible Cooling Energy", "", AggType::SumOrAvg);
    2627           24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Window Air Conditioner Latent Cooling Energy", "", AggType::SumOrAvg);
    2628           24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Window Air Conditioner Total Cooling Rate", "", AggType::Maximum);
    2629           24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Window Air Conditioner Sensible Cooling Rate", "", AggType::ValueWhenMaxMin);
    2630           24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Window Air Conditioner Latent Cooling Rate", "", AggType::ValueWhenMaxMin);
    2631           24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Window Air Conditioner Electricity Rate", "", AggType::ValueWhenMaxMin);
    2632              :     }
    2633           47 :     if (ort->namedMonthly(50).show) {
    2634           12 :         curReport = AddMonthlyReport(state, "WaterHeaterReportMonthly", 2, true);
    2635           24 :         AddMonthlyFieldSetInput(state, curReport, "Water Heater Total Demand Heat Transfer Energy", "", AggType::SumOrAvg);
    2636           24 :         AddMonthlyFieldSetInput(state, curReport, "Water Heater Use Side Heat Transfer Energy", "", AggType::SumOrAvg);
    2637           24 :         AddMonthlyFieldSetInput(state, curReport, "Water Heater Burner Heating Energy", "", AggType::SumOrAvg);
    2638           24 :         AddMonthlyFieldSetInput(state, curReport, "Water Heater Gas Consumption", "", AggType::SumOrAvg);
    2639           24 :         AddMonthlyFieldSetInput(state, curReport, "Water Heater Total Demand Heat Transfer Energy", "", AggType::HoursNonZero);
    2640           24 :         AddMonthlyFieldSetInput(state, curReport, "Water Heater Loss Demand Energy", "", AggType::SumOrAvg);
    2641           24 :         AddMonthlyFieldSetInput(state, curReport, "Water Heater Heat Loss Energy", "", AggType::SumOrAvg);
    2642           24 :         AddMonthlyFieldSetInput(state, curReport, "Water Heater Tank Temperature", "", AggType::SumOrAvg);
    2643           24 :         AddMonthlyFieldSetInput(state, curReport, "Water Heater Heat Recovery Supply Energy", "", AggType::SumOrAvg);
    2644           24 :         AddMonthlyFieldSetInput(state, curReport, "Water Heater Source Side Heat Transfer Energy", "", AggType::SumOrAvg);
    2645              :     }
    2646           47 :     if (ort->namedMonthly(51).show) {
    2647           12 :         curReport = AddMonthlyReport(state, "GeneratorReportMonthly", 2, true);
    2648           24 :         AddMonthlyFieldSetInput(state, curReport, "Generator Produced AC Electricity Energy", "", AggType::SumOrAvg);
    2649           24 :         AddMonthlyFieldSetInput(state, curReport, "Generator Diesel Consumption", "", AggType::SumOrAvg);
    2650           24 :         AddMonthlyFieldSetInput(state, curReport, "Generator Gas Consumption", "", AggType::SumOrAvg);
    2651           24 :         AddMonthlyFieldSetInput(state, curReport, "Generator Produced AC Electricity Energy", "", AggType::HoursNonZero);
    2652           24 :         AddMonthlyFieldSetInput(state, curReport, "Generator Total Heat Recovery", "", AggType::SumOrAvg);
    2653           24 :         AddMonthlyFieldSetInput(state, curReport, "Generator Jacket Heat Recovery Energy", "", AggType::SumOrAvg);
    2654           24 :         AddMonthlyFieldSetInput(state, curReport, "Generator Lube Heat Recovery", "", AggType::SumOrAvg);
    2655           24 :         AddMonthlyFieldSetInput(state, curReport, "Generator Exhaust Heat Recovery Energy", "", AggType::SumOrAvg);
    2656           24 :         AddMonthlyFieldSetInput(state, curReport, "Generator Exhaust Air Temperature", "", AggType::SumOrAvg);
    2657              :     }
    2658           47 :     if (ort->namedMonthly(52).show) {
    2659           12 :         curReport = AddMonthlyReport(state, "DaylightingReportMonthly", 2, true);
    2660           24 :         AddMonthlyFieldSetInput(state, curReport, "Site Exterior Beam Normal Illuminance", "", AggType::HoursNonZero);
    2661           24 :         AddMonthlyFieldSetInput(state, curReport, "Daylighting Lighting Power Multiplier", "", AggType::SumOrAverageHoursShown);
    2662           24 :         AddMonthlyFieldSetInput(state, curReport, "Daylighting Lighting Power Multiplier", "", AggType::MinimumDuringHoursShown);
    2663           24 :         AddMonthlyFieldSetInput(state, curReport, "Daylighting Reference Point 1 Illuminance", "", AggType::SumOrAverageHoursShown);
    2664           24 :         AddMonthlyFieldSetInput(state, curReport, "Daylighting Reference Point 1 Glare Index", "", AggType::SumOrAverageHoursShown);
    2665           24 :         AddMonthlyFieldSetInput(state, curReport, "Daylighting Reference Point 1 Glare Index Setpoint Exceeded Time", "", AggType::SumOrAvg);
    2666           24 :         AddMonthlyFieldSetInput(state, curReport, "Daylighting Reference Point 1 Daylight Illuminance Setpoint Exceeded Time", "", AggType::SumOrAvg);
    2667           24 :         AddMonthlyFieldSetInput(state, curReport, "Daylighting Reference Point 2 Illuminance", "", AggType::SumOrAverageHoursShown);
    2668           24 :         AddMonthlyFieldSetInput(state, curReport, "Daylighting Reference Point 2 Glare Index", "", AggType::SumOrAverageHoursShown);
    2669           24 :         AddMonthlyFieldSetInput(state, curReport, "Daylighting Reference Point 2 Glare Index Setpoint Exceeded Time", "", AggType::SumOrAvg);
    2670           24 :         AddMonthlyFieldSetInput(state, curReport, "Daylighting Reference Point 2 Daylight Illuminance Setpoint Exceeded Time", "", AggType::SumOrAvg);
    2671              :     }
    2672           47 :     if (ort->namedMonthly(53).show) {
    2673           12 :         curReport = AddMonthlyReport(state, "CoilReportMonthly", 2, true);
    2674           24 :         AddMonthlyFieldSetInput(state, curReport, "Heating Coil Heating Energy", "", AggType::SumOrAvg);
    2675           24 :         AddMonthlyFieldSetInput(state, curReport, "Heating Coil Heating Rate", "", AggType::Maximum);
    2676           24 :         AddMonthlyFieldSetInput(state, curReport, "Cooling Coil Total Cooling Energy", "", AggType::SumOrAvg);
    2677           24 :         AddMonthlyFieldSetInput(state, curReport, "Cooling Coil Sensible Cooling Energy", "", AggType::SumOrAvg);
    2678           24 :         AddMonthlyFieldSetInput(state, curReport, "Cooling Coil Total Cooling Rate", "", AggType::Maximum);
    2679           24 :         AddMonthlyFieldSetInput(state, curReport, "Cooling Coil Sensible Cooling Rate", "", AggType::ValueWhenMaxMin);
    2680           24 :         AddMonthlyFieldSetInput(state, curReport, "Cooling Coil Wetted Area Fraction", "", AggType::SumOrAvg);
    2681              :     }
    2682           47 :     if (ort->namedMonthly(54).show) {
    2683           12 :         curReport = AddMonthlyReport(state, "PlantLoopDemandReportMonthly", 2, true);
    2684           24 :         AddMonthlyFieldSetInput(state, curReport, "Plant Supply Side Cooling Demand Rate", "", AggType::SumOrAvg);
    2685           24 :         AddMonthlyFieldSetInput(state, curReport, "Plant Supply Side Cooling Demand Rate", "", AggType::Maximum);
    2686           24 :         AddMonthlyFieldSetInput(state, curReport, "Plant Supply Side Heating Demand Rate", "", AggType::SumOrAvg);
    2687           24 :         AddMonthlyFieldSetInput(state, curReport, "Plant Supply Side Heating Demand Rate", "", AggType::Maximum);
    2688              :     }
    2689           47 :     if (ort->namedMonthly(55).show) {
    2690           12 :         curReport = AddMonthlyReport(state, "FanReportMonthly", 2, true);
    2691           24 :         AddMonthlyFieldSetInput(state, curReport, "Fan Electricity Energy", "", AggType::SumOrAvg);
    2692           24 :         AddMonthlyFieldSetInput(state, curReport, "Fan Rise in Air Temperature", "", AggType::SumOrAvg);
    2693           24 :         AddMonthlyFieldSetInput(state, curReport, "Fan Electricity Rate", "", AggType::Maximum);
    2694           24 :         AddMonthlyFieldSetInput(state, curReport, "Fan Rise in Air Temperature", "", AggType::ValueWhenMaxMin);
    2695              :     }
    2696           47 :     if (ort->namedMonthly(56).show) {
    2697           12 :         curReport = AddMonthlyReport(state, "PumpReportMonthly", 2, true);
    2698           24 :         AddMonthlyFieldSetInput(state, curReport, "Pump Electricity Energy", "", AggType::SumOrAvg);
    2699           24 :         AddMonthlyFieldSetInput(state, curReport, "Pump Fluid Heat Gain Energy", "", AggType::SumOrAvg);
    2700           24 :         AddMonthlyFieldSetInput(state, curReport, "Pump Electricity Rate", "", AggType::Maximum);
    2701           24 :         AddMonthlyFieldSetInput(state, curReport, "Pump Shaft Power", "", AggType::ValueWhenMaxMin);
    2702           24 :         AddMonthlyFieldSetInput(state, curReport, "Pump Fluid Heat Gain Rate", "", AggType::ValueWhenMaxMin);
    2703           24 :         AddMonthlyFieldSetInput(state, curReport, "Pump Outlet Temperature", "", AggType::ValueWhenMaxMin);
    2704           24 :         AddMonthlyFieldSetInput(state, curReport, "Pump Mass Flow Rate", "", AggType::ValueWhenMaxMin);
    2705              :     }
    2706           47 :     if (ort->namedMonthly(57).show) {
    2707           12 :         curReport = AddMonthlyReport(state, "CondLoopDemandReportMonthly", 2, true);
    2708           24 :         AddMonthlyFieldSetInput(state, curReport, "Plant Supply Side Cooling Demand Rate", "", AggType::SumOrAvg);
    2709           24 :         AddMonthlyFieldSetInput(state, curReport, "Plant Supply Side Cooling Demand Rate", "", AggType::Maximum);
    2710           24 :         AddMonthlyFieldSetInput(state, curReport, "Plant Supply Side Inlet Temperature", "", AggType::ValueWhenMaxMin);
    2711           24 :         AddMonthlyFieldSetInput(state, curReport, "Plant Supply Side Outlet Temperature", "", AggType::ValueWhenMaxMin);
    2712           24 :         AddMonthlyFieldSetInput(state, curReport, "Plant Supply Side Heating Demand Rate", "", AggType::SumOrAvg);
    2713           24 :         AddMonthlyFieldSetInput(state, curReport, "Plant Supply Side Heating Demand Rate", "", AggType::Maximum);
    2714              :     }
    2715           47 :     if (ort->namedMonthly(58).show) {
    2716           12 :         curReport = AddMonthlyReport(state, "ZoneTemperatureOscillationReportMonthly", 2, true);
    2717           24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Oscillating Temperatures Time", "", AggType::HoursNonZero);
    2718           24 :         AddMonthlyFieldSetInput(state, curReport, "Zone People Occupant Count", "", AggType::SumOrAverageHoursShown);
    2719              :     }
    2720           47 :     if (ort->namedMonthly(59).show) {
    2721           12 :         curReport = AddMonthlyReport(state, "AirLoopSystemEnergyAndWaterUseMonthly", 2, true);
    2722           24 :         AddMonthlyFieldSetInput(state, curReport, "Air System Hot Water Energy", "", AggType::SumOrAvg);
    2723           24 :         AddMonthlyFieldSetInput(state, curReport, "Air System Steam Energy", "", AggType::SumOrAvg);
    2724           24 :         AddMonthlyFieldSetInput(state, curReport, "Air System Chilled Water Energy", "", AggType::SumOrAvg);
    2725           24 :         AddMonthlyFieldSetInput(state, curReport, "Air System Electricity Energy", "", AggType::SumOrAvg);
    2726           24 :         AddMonthlyFieldSetInput(state, curReport, "Air System Natural Gas Energy", "", AggType::SumOrAvg);
    2727           24 :         AddMonthlyFieldSetInput(state, curReport, "Air System Water Volume", "", AggType::SumOrAvg);
    2728              :     }
    2729              : 
    2730           47 :     if (ort->namedMonthly(60).show) {
    2731           12 :         curReport = AddMonthlyReport(state, "AirLoopSystemComponentLoadsMonthly", 2, true);
    2732           24 :         AddMonthlyFieldSetInput(state, curReport, "Air System Fan Air Heating Energy", "", AggType::SumOrAvg);
    2733           24 :         AddMonthlyFieldSetInput(state, curReport, "Air System Cooling Coil Total Cooling Energy", "", AggType::SumOrAvg);
    2734           24 :         AddMonthlyFieldSetInput(state, curReport, "Air System Heating Coil Total Heating Energy", "", AggType::SumOrAvg);
    2735           24 :         AddMonthlyFieldSetInput(state, curReport, "Air System Heat Exchanger Total Heating Energy", "", AggType::SumOrAvg);
    2736           24 :         AddMonthlyFieldSetInput(state, curReport, "Air System Heat Exchanger Total Cooling Energy", "", AggType::SumOrAvg);
    2737           24 :         AddMonthlyFieldSetInput(state, curReport, "Air System Humidifier Total Heating Energy", "", AggType::SumOrAvg);
    2738           24 :         AddMonthlyFieldSetInput(state, curReport, "Air System Evaporative Cooler Total Cooling Energy", "", AggType::SumOrAvg);
    2739           24 :         AddMonthlyFieldSetInput(state, curReport, "Air System Desiccant Dehumidifier Total Cooling Energy", "", AggType::SumOrAvg);
    2740              :     }
    2741           47 :     if (ort->namedMonthly(61).show) {
    2742           12 :         curReport = AddMonthlyReport(state, "AirLoopSystemComponentEnergyUseMonthly", 2, true);
    2743           24 :         AddMonthlyFieldSetInput(state, curReport, "Air System Fan Electricity Energy", "", AggType::SumOrAvg);
    2744           24 :         AddMonthlyFieldSetInput(state, curReport, "Air System Heating Coil Hot Water Energy", "", AggType::SumOrAvg);
    2745           24 :         AddMonthlyFieldSetInput(state, curReport, "Air System Cooling Coil Chilled Water Energy", "", AggType::SumOrAvg);
    2746           24 :         AddMonthlyFieldSetInput(state, curReport, "Air System DX Heating Coil Electricity Energy", "", AggType::SumOrAvg);
    2747           24 :         AddMonthlyFieldSetInput(state, curReport, "Air System DX Cooling Coil Electricity Energy", "", AggType::SumOrAvg);
    2748           24 :         AddMonthlyFieldSetInput(state, curReport, "Air System Heating Coil Electricity Energy", "", AggType::SumOrAvg);
    2749           24 :         AddMonthlyFieldSetInput(state, curReport, "Air System Heating Coil Natural Gas Energy", "", AggType::SumOrAvg);
    2750           24 :         AddMonthlyFieldSetInput(state, curReport, "Air System Heating Coil Steam Energy", "", AggType::SumOrAvg);
    2751           24 :         AddMonthlyFieldSetInput(state, curReport, "Air System Humidifier Electricity Energy", "", AggType::SumOrAvg);
    2752           24 :         AddMonthlyFieldSetInput(state, curReport, "Air System Humidifier Natural Gas Energy", "", AggType::SumOrAvg);
    2753           24 :         AddMonthlyFieldSetInput(state, curReport, "Air System Evaporative Cooler Electricity Energy", "", AggType::SumOrAvg);
    2754           24 :         AddMonthlyFieldSetInput(state, curReport, "Air System Desiccant Dehumidifier Electricity Energy", "", AggType::SumOrAvg);
    2755              :     }
    2756           47 :     if (ort->namedMonthly(62).show) {
    2757           12 :         curReport = AddMonthlyReport(state, "MechanicalVentilationLoadsMonthly", 2, true);
    2758           24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Mechanical Ventilation No Load Heat Removal Energy", "", AggType::SumOrAvg);
    2759           24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Mechanical Ventilation Cooling Load Increase Energy", "", AggType::SumOrAvg);
    2760           24 :         AddMonthlyFieldSetInput(
    2761              :             state, curReport, "Zone Mechanical Ventilation Cooling Load Increase Due to Overheating Energy", "", AggType::SumOrAvg);
    2762           24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Mechanical Ventilation Cooling Load Decrease Energy", "", AggType::SumOrAvg);
    2763           24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Mechanical Ventilation No Load Heat Addition Energy", "", AggType::SumOrAvg);
    2764           24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Mechanical Ventilation Heating Load Increase Energy", "", AggType::SumOrAvg);
    2765           24 :         AddMonthlyFieldSetInput(
    2766              :             state, curReport, "Zone Mechanical Ventilation Heating Load Increase Due to Overcooling Energy", "", AggType::SumOrAvg);
    2767           24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Mechanical Ventilation Heating Load Decrease Energy", "", AggType::SumOrAvg);
    2768           24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Mechanical Ventilation Air Changes per Hour", "", AggType::SumOrAvg);
    2769              :     }
    2770           47 :     if (ort->namedMonthly(63).show) {
    2771           12 :         curReport = AddMonthlyReport(state, "HeatEmissionsReportMonthly", 2, true);
    2772              :         // Place holder
    2773           24 :         AddMonthlyFieldSetInput(state, curReport, "Site Total Surface Heat Emission to Air", "", AggType::SumOrAvg);
    2774           24 :         AddMonthlyFieldSetInput(state, curReport, "Site Total Zone Exfiltration Heat Loss", "", AggType::SumOrAvg);
    2775           24 :         AddMonthlyFieldSetInput(state, curReport, "Site Total Zone Exhaust Air Heat Loss", "", AggType::SumOrAvg);
    2776           24 :         AddMonthlyFieldSetInput(state, curReport, "Air System Relief Air Total Heat Loss Energy", "", AggType::SumOrAvg);
    2777           24 :         AddMonthlyFieldSetInput(state, curReport, "HVAC System Total Heat Rejection Energy", "", AggType::SumOrAvg);
    2778              :     }
    2779           47 : }
    2780              : 
    2781           74 : void GetInputFuelAndPollutionFactors(EnergyPlusData &state)
    2782              : {
    2783              :     // SUBROUTINE INFORMATION:
    2784              :     //       AUTHOR         Jason Glazer
    2785              :     //       DATE WRITTEN   January 2004
    2786              :     //       MODIFIED       na
    2787              :     //       RE-ENGINEERED  na
    2788              : 
    2789              :     // PURPOSE OF THIS SUBROUTINE:
    2790              :     //   Read the Fuel Factor inputs by the user to
    2791              :     //   get the source energy conversion factors
    2792              :     //   Also reads PolutionCalculationFactors to
    2793              :     //   get information on district cooling and heating
    2794              : 
    2795              :     // METHODOLOGY EMPLOYED:
    2796              :     //   Uses get input structure similar to other objects
    2797              : 
    2798              :     // REFERENCES:
    2799              :     // na
    2800              : 
    2801              :     // Using/Aliasing
    2802              :     using Pollution::GetEnvironmentalImpactFactorInfo;
    2803              :     using Pollution::GetFuelFactorInfo;
    2804              : 
    2805              :     // Locals
    2806              :     // SUBROUTINE ARGUMENT DEFINITIONS:
    2807              :     // na
    2808              : 
    2809              :     // SUBROUTINE PARAMETER DEFINITIONS:
    2810              :     // na
    2811              : 
    2812              :     // INTERFACE BLOCK SPECIFICATIONS:
    2813              :     // na
    2814              : 
    2815              :     // DERIVED TYPE DEFINITIONS:
    2816              :     // na
    2817              : 
    2818              :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
    2819              :     Real64 curSourceFactor;
    2820              :     bool fuelFactorUsed;
    2821              :     bool fFScheduleUsed;
    2822           74 :     Sched::Schedule *ffSched = nullptr;
    2823              : 
    2824           74 :     auto &ort = state.dataOutRptTab;
    2825              : 
    2826              :     // set the default factors for source energy - they will be overwritten if the user sets any values
    2827           74 :     ort->sourceFactorElectric = 3.167;
    2828           74 :     ort->sourceFactorNaturalGas = 1.084;
    2829           74 :     ort->sourceFactorDistrictHeatingSteam = 1.20;
    2830           74 :     ort->sourceFactorGasoline = 1.05;
    2831           74 :     ort->sourceFactorDiesel = 1.05;
    2832           74 :     ort->sourceFactorCoal = 1.05;
    2833           74 :     ort->sourceFactorFuelOil1 = 1.05;
    2834           74 :     ort->sourceFactorFuelOil2 = 1.05;
    2835           74 :     ort->sourceFactorPropane = 1.05;
    2836           74 :     ort->sourceFactorOtherFuel1 = 1.0;
    2837           74 :     ort->sourceFactorOtherFuel2 = 1.0;
    2838              :     // the following should be kept consistent with the assumptions in the pollution calculation routines
    2839           74 :     ort->efficiencyDistrictCooling = 3.0;
    2840           74 :     ort->efficiencyDistrictHeatingWater = 0.3;
    2841              : 
    2842              :     //  TotalSourceEnergyUse = (gatherTotalsSource(1) & !total source from electricity
    2843              :     //                  +  gatherTotalsSource(2)   & !natural gas
    2844              :     //                  + gatherTotalsSource(3)    & !gasoline
    2845              :     //                  + gatherTotalsSource(4)    & !diesel
    2846              :     //                  + gatherTotalsSource(5)    & !coal
    2847              :     //                  + gatherTotalsSource(6)    & !Fuel Oil No1
    2848              :     //                  + gatherTotalsSource(7)    & !Fuel Oil No2
    2849              :     //                  + gatherTotalsSource(8)    &  !propane
    2850              :     //                  + gatherTotalsBEPS(3)*sourceFactorElectric/efficiencyDistrictCooling  & !district cooling
    2851              :     //                  + gatherTotalsBEPS(4)*sourceFactorNaturalGas/efficiencyDistrictHeating  & !district heating
    2852              :     //                  + gatherTotalsBEPS(5)*sourceFactorSteam  & !steam
    2853              :     //                                          ) / largeConversionFactor
    2854              : 
    2855           74 :     GetFuelFactorInfo(state, Constant::eFuel::NaturalGas, fuelFactorUsed, curSourceFactor, fFScheduleUsed, &ffSched);
    2856           74 :     if (fuelFactorUsed) {
    2857            0 :         ort->sourceFactorNaturalGas = curSourceFactor;
    2858            0 :         ort->fuelfactorsused(2) = true;
    2859            0 :         ort->ffUsed(2) = true;
    2860              :     }
    2861           74 :     ort->SourceFactors(2) = curSourceFactor;
    2862           74 :     if (fFScheduleUsed) {
    2863            0 :         ort->fuelFactorSchedulesUsed = true;
    2864            0 :         ort->ffSchedUsed(2) = true;
    2865            0 :         ort->ffScheds(2) = ffSched;
    2866              :     }
    2867              : 
    2868           74 :     GetFuelFactorInfo(state, Constant::eFuel::FuelOilNo2, fuelFactorUsed, curSourceFactor, fFScheduleUsed, &ffSched);
    2869           74 :     if (fuelFactorUsed) {
    2870            0 :         ort->sourceFactorFuelOil2 = curSourceFactor;
    2871            0 :         ort->fuelfactorsused(7) = true;
    2872            0 :         ort->ffUsed(11) = true;
    2873              :     }
    2874           74 :     ort->SourceFactors(11) = curSourceFactor;
    2875           74 :     if (fFScheduleUsed) {
    2876            0 :         ort->fuelFactorSchedulesUsed = true;
    2877            0 :         ort->ffSchedUsed(11) = true;
    2878            0 :         ort->ffScheds(11) = ffSched;
    2879              :     }
    2880              : 
    2881           74 :     GetFuelFactorInfo(state, Constant::eFuel::FuelOilNo1, fuelFactorUsed, curSourceFactor, fFScheduleUsed, &ffSched);
    2882           74 :     if (fuelFactorUsed) {
    2883            0 :         ort->sourceFactorFuelOil1 = curSourceFactor;
    2884            0 :         ort->fuelfactorsused(6) = true;
    2885            0 :         ort->ffUsed(10) = true;
    2886              :     }
    2887           74 :     ort->SourceFactors(10) = curSourceFactor;
    2888           74 :     if (fFScheduleUsed) {
    2889            0 :         ort->fuelFactorSchedulesUsed = true;
    2890            0 :         ort->ffSchedUsed(10) = true;
    2891            0 :         ort->ffScheds(10) = ffSched;
    2892              :     }
    2893              : 
    2894           74 :     GetFuelFactorInfo(state, Constant::eFuel::Coal, fuelFactorUsed, curSourceFactor, fFScheduleUsed, &ffSched);
    2895           74 :     if (fuelFactorUsed) {
    2896            0 :         ort->sourceFactorCoal = curSourceFactor;
    2897            0 :         ort->fuelfactorsused(5) = true;
    2898            0 :         ort->ffUsed(9) = true;
    2899              :     }
    2900           74 :     ort->SourceFactors(9) = curSourceFactor;
    2901           74 :     if (fFScheduleUsed) {
    2902            0 :         ort->fuelFactorSchedulesUsed = true;
    2903            0 :         ort->ffSchedUsed(9) = true;
    2904            0 :         ort->ffScheds(9) = ffSched;
    2905              :     }
    2906              : 
    2907           74 :     GetFuelFactorInfo(state, Constant::eFuel::Electricity, fuelFactorUsed, curSourceFactor, fFScheduleUsed, &ffSched);
    2908           74 :     if (fuelFactorUsed) {
    2909            0 :         ort->sourceFactorElectric = curSourceFactor;
    2910            0 :         ort->fuelfactorsused(1) = true;
    2911            0 :         ort->ffUsed(1) = true;
    2912              :     }
    2913           74 :     ort->SourceFactors(1) = curSourceFactor;
    2914           74 :     if (fFScheduleUsed) {
    2915            0 :         ort->fuelFactorSchedulesUsed = true;
    2916            0 :         ort->ffSchedUsed(1) = true;
    2917            0 :         ort->ffScheds(1) = ffSched;
    2918              :     }
    2919              : 
    2920           74 :     GetFuelFactorInfo(state, Constant::eFuel::Gasoline, fuelFactorUsed, curSourceFactor, fFScheduleUsed, &ffSched);
    2921           74 :     if (fuelFactorUsed) {
    2922            0 :         ort->sourceFactorGasoline = curSourceFactor;
    2923            0 :         ort->fuelfactorsused(3) = true;
    2924            0 :         ort->ffUsed(6) = true;
    2925              :     }
    2926           74 :     ort->SourceFactors(6) = curSourceFactor;
    2927           74 :     if (fFScheduleUsed) {
    2928            0 :         ort->fuelFactorSchedulesUsed = true;
    2929            0 :         ort->ffSchedUsed(6) = true;
    2930            0 :         ort->ffScheds(6) = ffSched;
    2931              :     }
    2932              : 
    2933           74 :     GetFuelFactorInfo(state, Constant::eFuel::Propane, fuelFactorUsed, curSourceFactor, fFScheduleUsed, &ffSched);
    2934           74 :     if (fuelFactorUsed) {
    2935            0 :         ort->sourceFactorPropane = curSourceFactor;
    2936            0 :         ort->fuelfactorsused(8) = true;
    2937            0 :         ort->ffUsed(12) = true;
    2938              :     }
    2939           74 :     ort->SourceFactors(12) = curSourceFactor;
    2940           74 :     if (fFScheduleUsed) {
    2941            0 :         ort->fuelFactorSchedulesUsed = true;
    2942            0 :         ort->ffSchedUsed(12) = true;
    2943            0 :         ort->ffScheds(12) = ffSched;
    2944              :     }
    2945              : 
    2946           74 :     GetFuelFactorInfo(state, Constant::eFuel::Diesel, fuelFactorUsed, curSourceFactor, fFScheduleUsed, &ffSched);
    2947           74 :     if (fuelFactorUsed) {
    2948            0 :         ort->sourceFactorDiesel = curSourceFactor;
    2949            0 :         ort->fuelfactorsused(4) = true;
    2950            0 :         ort->ffUsed(8) = true;
    2951              :     }
    2952           74 :     ort->SourceFactors(8) = curSourceFactor;
    2953           74 :     if (fFScheduleUsed) {
    2954            0 :         ort->fuelFactorSchedulesUsed = true;
    2955            0 :         ort->ffSchedUsed(8) = true;
    2956            0 :         ort->ffScheds(8) = ffSched;
    2957              :     }
    2958              : 
    2959           74 :     GetFuelFactorInfo(state, Constant::eFuel::DistrictCooling, fuelFactorUsed, curSourceFactor, fFScheduleUsed, &ffSched);
    2960           74 :     if (fuelFactorUsed) {
    2961            0 :         ort->ffUsed(3) = true;
    2962              :     }
    2963           74 :     ort->SourceFactors(3) = curSourceFactor;
    2964           74 :     if (fFScheduleUsed) {
    2965            0 :         ort->ffSchedUsed(3) = true;
    2966            0 :         ort->ffScheds(3) = ffSched;
    2967              :     }
    2968              : 
    2969           74 :     GetFuelFactorInfo(state, Constant::eFuel::DistrictHeatingWater, fuelFactorUsed, curSourceFactor, fFScheduleUsed, &ffSched);
    2970           74 :     if (fuelFactorUsed) {
    2971            0 :         ort->ffUsed(4) = true;
    2972              :     }
    2973           74 :     ort->SourceFactors(4) = curSourceFactor;
    2974           74 :     if (fFScheduleUsed) {
    2975            0 :         ort->ffSchedUsed(4) = true;
    2976            0 :         ort->ffScheds(4) = ffSched;
    2977              :     }
    2978              : 
    2979           74 :     GetFuelFactorInfo(state, Constant::eFuel::DistrictHeatingSteam, fuelFactorUsed, curSourceFactor, fFScheduleUsed, &ffSched);
    2980           74 :     if (fuelFactorUsed) {
    2981            0 :         ort->ffUsed(5) = true;
    2982              :     }
    2983           74 :     ort->SourceFactors(5) = curSourceFactor;
    2984           74 :     if (fFScheduleUsed) {
    2985            0 :         ort->ffSchedUsed(5) = true;
    2986            0 :         ort->ffScheds(5) = ffSched;
    2987              :     }
    2988              : 
    2989           74 :     GetFuelFactorInfo(state, Constant::eFuel::OtherFuel1, fuelFactorUsed, curSourceFactor, fFScheduleUsed, &ffSched);
    2990           74 :     if (fuelFactorUsed) {
    2991            0 :         ort->sourceFactorOtherFuel1 = curSourceFactor;
    2992            0 :         ort->fuelfactorsused(11) = true; // should be source number
    2993            0 :         ort->ffUsed(13) = true;
    2994              :     }
    2995           74 :     ort->SourceFactors(13) = curSourceFactor;
    2996           74 :     if (fFScheduleUsed) {
    2997            0 :         ort->fuelFactorSchedulesUsed = true;
    2998            0 :         ort->ffSchedUsed(13) = true;
    2999            0 :         ort->ffScheds(13) = ffSched;
    3000              :     }
    3001              : 
    3002           74 :     GetFuelFactorInfo(state, Constant::eFuel::OtherFuel2, fuelFactorUsed, curSourceFactor, fFScheduleUsed, &ffSched);
    3003           74 :     if (fuelFactorUsed) {
    3004            0 :         ort->sourceFactorOtherFuel2 = curSourceFactor;
    3005            0 :         ort->fuelfactorsused(12) = true; // should be source number
    3006            0 :         ort->ffUsed(14) = true;
    3007              :     }
    3008           74 :     ort->SourceFactors(14) = curSourceFactor;
    3009           74 :     if (fFScheduleUsed) {
    3010            0 :         ort->fuelFactorSchedulesUsed = true;
    3011            0 :         ort->ffSchedUsed(14) = true;
    3012            0 :         ort->ffScheds(14) = ffSched;
    3013              :     }
    3014              : 
    3015           74 :     GetEnvironmentalImpactFactorInfo(
    3016           74 :         state, ort->efficiencyDistrictHeatingWater, ort->efficiencyDistrictCooling, ort->sourceFactorDistrictHeatingSteam);
    3017           74 : }
    3018              : 
    3019              : //======================================================================================================================
    3020              : //======================================================================================================================
    3021              : 
    3022              : //    OTHER INITIALIZATION ROUTINES
    3023              : 
    3024              : //======================================================================================================================
    3025              : //======================================================================================================================
    3026              : 
    3027           74 : void OpenOutputTabularFile(EnergyPlusData &state)
    3028              : {
    3029              :     // SUBROUTINE INFORMATION:
    3030              :     //       AUTHOR         Jason Glazer
    3031              :     //       DATE WRITTEN   July 2003
    3032              :     //       MODIFIED       na
    3033              :     //       RE-ENGINEERED  na
    3034              : 
    3035              :     // PURPOSE OF THIS SUBROUTINE:
    3036              :     //   Create a file that holds the output from the tabular reports
    3037              :     //   the output is in a CSV file if it is comma delimited otherwise
    3038              :     //   it is in a TXT file.
    3039              : 
    3040              :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
    3041           74 :     auto &ort = state.dataOutRptTab;
    3042              : 
    3043              :     // get a new file unit number
    3044              :     // create a file to hold the results
    3045              :     // Use a CSV file if comma separated but otherwise use TXT file
    3046              :     // extension.
    3047           74 :     if (ort->WriteTabularFiles && state.files.outputControl.tabular) {
    3048          167 :         for (int iStyle = 1; iStyle <= ort->numStyles; ++iStyle) {
    3049          128 :             std::string const &curDel = ort->del(iStyle);
    3050          128 :             if (ort->TableStyle(iStyle) == TableStyle::Comma) {
    3051           33 :                 DisplayString(state, "Writing tabular output file results using comma format.");
    3052              :                 std::ofstream &tbl_stream =
    3053           33 :                     open_tbl_stream(state, iStyle, state.dataStrGlobals->outputTblCsvFilePath, state.files.outputControl.tabular);
    3054           33 :                 tbl_stream << "Program Version:" << curDel << state.dataStrGlobals->VerStringVar << '\n';
    3055           33 :                 tbl_stream << "Tabular Output Report in Format: " << curDel << "Comma\n";
    3056           33 :                 tbl_stream << '\n';
    3057           33 :                 tbl_stream << "Building:" << curDel << state.dataHeatBal->BuildingName << '\n';
    3058           33 :                 if (state.dataEnvrn->EnvironmentName == state.dataEnvrn->WeatherFileLocationTitle) {
    3059            0 :                     tbl_stream << "Environment:" << curDel << state.dataEnvrn->EnvironmentName << '\n';
    3060              :                 } else {
    3061          132 :                     tbl_stream << "Environment:" << curDel << state.dataEnvrn->EnvironmentName << " ** " << state.dataEnvrn->WeatherFileLocationTitle
    3062           33 :                                << '\n';
    3063              :                 }
    3064           33 :                 tbl_stream << '\n';
    3065           95 :             } else if (ort->TableStyle(iStyle) == TableStyle::Tab) {
    3066           23 :                 DisplayString(state, "Writing tabular output file results using tab format.");
    3067              :                 std::ofstream &tbl_stream =
    3068           23 :                     open_tbl_stream(state, iStyle, state.dataStrGlobals->outputTblTabFilePath, state.files.outputControl.tabular);
    3069           23 :                 tbl_stream << "Program Version" << curDel << state.dataStrGlobals->VerStringVar << '\n';
    3070           23 :                 tbl_stream << "Tabular Output Report in Format: " << curDel << "Tab\n";
    3071           23 :                 tbl_stream << '\n';
    3072           23 :                 tbl_stream << "Building:" << curDel << state.dataHeatBal->BuildingName << '\n';
    3073           23 :                 if (state.dataEnvrn->EnvironmentName == state.dataEnvrn->WeatherFileLocationTitle) {
    3074            0 :                     tbl_stream << "Environment:" << curDel << state.dataEnvrn->EnvironmentName << '\n';
    3075              :                 } else {
    3076           92 :                     tbl_stream << "Environment:" << curDel << state.dataEnvrn->EnvironmentName << " ** " << state.dataEnvrn->WeatherFileLocationTitle
    3077           23 :                                << '\n';
    3078              :                 }
    3079           23 :                 tbl_stream << '\n';
    3080           72 :             } else if (ort->TableStyle(iStyle) == TableStyle::HTML) {
    3081           28 :                 DisplayString(state, "Writing tabular output file results using HTML format.");
    3082              :                 std::ofstream &tbl_stream =
    3083           28 :                     open_tbl_stream(state, iStyle, state.dataStrGlobals->outputTblHtmFilePath, state.files.outputControl.tabular);
    3084           28 :                 tbl_stream << "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"\"http://www.w3.org/TR/html4/loose.dtd\">\n";
    3085           28 :                 tbl_stream << "<html>\n";
    3086           28 :                 tbl_stream << "<head>\n";
    3087           28 :                 if (state.dataEnvrn->EnvironmentName == state.dataEnvrn->WeatherFileLocationTitle) {
    3088            1 :                     tbl_stream << "<title> " << state.dataHeatBal->BuildingName << ' ' << state.dataEnvrn->EnvironmentName << '\n';
    3089              :                 } else {
    3090          108 :                     tbl_stream << "<title> " << state.dataHeatBal->BuildingName << ' ' << state.dataEnvrn->EnvironmentName << " ** "
    3091           27 :                                << state.dataEnvrn->WeatherFileLocationTitle << '\n';
    3092              :                 }
    3093           28 :                 tbl_stream << "  " << std::setw(4) << ort->td(1) << '-' << std::setfill('0') << std::setw(2) << ort->td(2) << '-' << std::setw(2)
    3094           28 :                            << ort->td(3) << '\n';
    3095           28 :                 tbl_stream << "  " << std::setw(2) << ort->td(5) << ':' << std::setw(2) << ort->td(6) << ':' << std::setw(2) << ort->td(7)
    3096           28 :                            << std::setfill(' ') << '\n';
    3097           28 :                 tbl_stream << " - EnergyPlus</title>\n";
    3098           28 :                 tbl_stream << "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">\n";
    3099           28 :                 tbl_stream << "</head>\n";
    3100           28 :                 tbl_stream << "<body>\n";
    3101           28 :                 tbl_stream << "<p><a href=\"#toc\" style=\"float: right\">Table of Contents</a></p>\n";
    3102           28 :                 tbl_stream << "<a name=top></a>\n";
    3103           28 :                 tbl_stream << "<p>Program Version:<b>" << state.dataStrGlobals->VerStringVar << "</b></p>\n";
    3104           28 :                 tbl_stream << "<p>Tabular Output Report in Format: <b>HTML</b></p>\n";
    3105           28 :                 tbl_stream << "<p>Building: <b>" << state.dataHeatBal->BuildingName << "</b></p>\n";
    3106           28 :                 if (state.dataEnvrn->EnvironmentName == state.dataEnvrn->WeatherFileLocationTitle) {
    3107            1 :                     tbl_stream << "<p>Environment: <b>" << ConvertToEscaped(state.dataEnvrn->EnvironmentName, false) << "</b></p>\n";
    3108              :                 } else {
    3109           54 :                     tbl_stream << "<p>Environment: <b>" << ConvertToEscaped(state.dataEnvrn->EnvironmentName, false) << " ** "
    3110           54 :                                << ConvertToEscaped(state.dataEnvrn->WeatherFileLocationTitle, false) << "</b></p>\n";
    3111              :                 }
    3112           28 :                 tbl_stream << "<p>Simulation Timestamp: <b>" << std::setw(4) << ort->td(1) << '-' << std::setfill('0') << std::setw(2) << ort->td(2)
    3113           28 :                            << '-' << std::setw(2) << ort->td(3) << '\n';
    3114           28 :                 tbl_stream << "  " << std::setw(2) << ort->td(5) << ':' << std::setw(2) << ort->td(6) << ':' << std::setw(2) << ort->td(7)
    3115           28 :                            << std::setfill(' ') << "</b></p>\n";
    3116           44 :             } else if (ort->TableStyle(iStyle) == TableStyle::XML) {
    3117           22 :                 DisplayString(state, "Writing tabular output file results using XML format.");
    3118              :                 std::ofstream &tbl_stream =
    3119           22 :                     open_tbl_stream(state, iStyle, state.dataStrGlobals->outputTblXmlFilePath, state.files.outputControl.tabular);
    3120           22 :                 tbl_stream << "<?xml version=\"1.0\"?>\n";
    3121           22 :                 tbl_stream << "<EnergyPlusTabularReports>\n";
    3122           22 :                 tbl_stream << "  <BuildingName>" << ConvertToEscaped(state.dataHeatBal->BuildingName) << "</BuildingName>\n";
    3123           22 :                 tbl_stream << "  <EnvironmentName>" << state.dataEnvrn->EnvironmentName << "</EnvironmentName>\n";
    3124           22 :                 tbl_stream << "  <WeatherFileLocationTitle>" << state.dataEnvrn->WeatherFileLocationTitle << "</WeatherFileLocationTitle>\n";
    3125           22 :                 tbl_stream << "  <ProgramVersion>" << state.dataStrGlobals->VerStringVar << "</ProgramVersion>\n";
    3126           22 :                 tbl_stream << "  <SimulationTimestamp>\n";
    3127           22 :                 tbl_stream << "    <Date>\n";
    3128           22 :                 tbl_stream << "      " << std::setw(4) << ort->td(1) << '-' << std::setfill('0') << std::setw(2) << ort->td(2) << '-' << std::setw(2)
    3129           22 :                            << ort->td(3) << '\n';
    3130           22 :                 tbl_stream << "    </Date>\n";
    3131           22 :                 tbl_stream << "    <Time>\n";
    3132           22 :                 tbl_stream << "      " << std::setw(2) << ort->td(5) << ':' << std::setw(2) << ort->td(6) << ':' << std::setw(2) << ort->td(7)
    3133           22 :                            << std::setfill(' ') << '\n';
    3134           22 :                 tbl_stream << "    </Time>\n";
    3135           22 :                 tbl_stream << "  </SimulationTimestamp>\n";
    3136           22 :                 tbl_stream << '\n';
    3137              :             } else {
    3138           22 :                 DisplayString(state, "Writing tabular output file results using text format.");
    3139              :                 std::ofstream &tbl_stream =
    3140           22 :                     open_tbl_stream(state, iStyle, state.dataStrGlobals->outputTblTxtFilePath, state.files.outputControl.tabular);
    3141           22 :                 tbl_stream << "Program Version: " << state.dataStrGlobals->VerStringVar << '\n';
    3142           22 :                 tbl_stream << "Tabular Output Report in Format: " << curDel << "Fixed\n";
    3143           22 :                 tbl_stream << '\n';
    3144           22 :                 tbl_stream << "Building:        " << state.dataHeatBal->BuildingName << '\n';
    3145           22 :                 if (state.dataEnvrn->EnvironmentName == state.dataEnvrn->WeatherFileLocationTitle) {
    3146            0 :                     tbl_stream << "Environment:     " << state.dataEnvrn->EnvironmentName << '\n';
    3147              :                 } else {
    3148           88 :                     tbl_stream << "Environment:     " << state.dataEnvrn->EnvironmentName << " ** " << state.dataEnvrn->WeatherFileLocationTitle
    3149           22 :                                << '\n';
    3150              :                 }
    3151           22 :                 tbl_stream << '\n';
    3152              :             }
    3153              :         }
    3154              :     }
    3155           74 : }
    3156              : 
    3157           74 : void CloseOutputTabularFile(EnergyPlusData &state)
    3158              : {
    3159              :     // SUBROUTINE INFORMATION:
    3160              :     //       AUTHOR         Jason Glazer
    3161              :     //       DATE WRITTEN   July 2003
    3162              :     //       MODIFIED       na
    3163              :     //       RE-ENGINEERED  na
    3164              : 
    3165              :     // PURPOSE OF THIS SUBROUTINE:
    3166              :     //   Create a file that holds the output from the tabular reports
    3167              :     //   the output is in a CSV file if it is comma delimited otherwise
    3168              :     //   it is in a TXT file.
    3169              : 
    3170              :     // METHODOLOGY EMPLOYED:
    3171              :     //   Uses get input structure similar to other objects
    3172              : 
    3173              :     // REFERENCES:
    3174              :     // na
    3175              : 
    3176              :     // USE STATEMENTS:
    3177              :     // na
    3178              : 
    3179              :     // Locals
    3180              :     // SUBROUTINE ARGUMENT DEFINITIONS:
    3181              :     // na
    3182              : 
    3183              :     // SUBROUTINE PARAMETER DEFINITIONS:
    3184              : 
    3185              :     // INTERFACE BLOCK SPECIFICATIONS:
    3186              :     // na
    3187              : 
    3188              :     // DERIVED TYPE DEFINITIONS:
    3189              :     // na
    3190              : 
    3191              :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
    3192           74 :     auto &ort = state.dataOutRptTab;
    3193              : 
    3194           74 :     if (ort->WriteTabularFiles) {
    3195          167 :         for (int iStyle = 1; iStyle <= ort->numStyles; ++iStyle) {
    3196          128 :             std::ofstream &tbl_stream(*ort->TabularOutputFile(iStyle));
    3197          128 :             if (ort->TableStyle(iStyle) == TableStyle::HTML) { // if HTML file put ending info
    3198           28 :                 tbl_stream << "</body>\n";
    3199           28 :                 tbl_stream << "</html>\n";
    3200          100 :             } else if (ort->TableStyle(iStyle) == TableStyle::XML) {
    3201           22 :                 if (!ort->prevReportName.empty()) {
    3202           22 :                     tbl_stream << "</" << ort->prevReportName << ">\n"; // close the last element if it was used.
    3203              :                 }
    3204           22 :                 tbl_stream << "</EnergyPlusTabularReports>\n";
    3205              :             }
    3206          128 :             tbl_stream.close();
    3207              :         }
    3208              :     }
    3209           74 : }
    3210              : 
    3211           38 : void WriteTableOfContents(EnergyPlusData &state)
    3212              : {
    3213              :     // SUBROUTINE INFORMATION:
    3214              :     //       AUTHOR         Jason Glazer
    3215              :     //       DATE WRITTEN   June 2005
    3216              :     //       MODIFIED       na
    3217              :     //       RE-ENGINEERED  na
    3218              : 
    3219              :     // PURPOSE OF THIS SUBROUTINE:
    3220              :     //   Creates hyperlinks for table of contents
    3221              : 
    3222              :     // METHODOLOGY EMPLOYED:
    3223              :     //   Go through the reports and create links
    3224              : 
    3225              :     // SUBROUTINE PARAMETER DEFINITIONS:
    3226           98 :     static std::string const Entire_Facility("Entire Facility");
    3227           98 :     static std::string const Annual_Building_Utility_Performance_Summary("Annual Building Utility Performance Summary");
    3228           98 :     static std::string const Input_Verification_and_Results_Summary("Input Verification and Results Summary");
    3229           98 :     static std::string const Demand_End_Use_Components_Summary("Demand End Use Components Summary");
    3230           98 :     static std::string const Source_Energy_End_Use_Components_Summary("Source Energy End Use Components Summary");
    3231           98 :     static std::string const Component_Cost_Economics_Summary("Component Cost Economics Summary");
    3232           98 :     static std::string const Component_Sizing_Summary("Component Sizing Summary");
    3233           98 :     static std::string const Surface_Shadowing_Summary("Surface Shadowing Summary");
    3234           98 :     static std::string const Adaptive_Comfort_Summary("Adaptive Comfort Summary");
    3235           98 :     static std::string const Initialization_Summary("Initialization Summary");
    3236           98 :     static std::string const Annual_Heat_Emissions_Summary("Annual Heat Emissions Summary");
    3237           98 :     static std::string const Annual_Thermal_Resilience_Summary("Annual Thermal Resilience Summary");
    3238           98 :     static std::string const Annual_CO2_Resilience_Summary("Annual CO2 Resilience Summary");
    3239           98 :     static std::string const Annual_Visual_Resilience_Summary("Annual Visual Resilience Summary");
    3240              : 
    3241              :     // INTERFACE BLOCK SPECIFICATIONS:
    3242              :     // na
    3243              : 
    3244              :     // DERIVED TYPE DEFINITIONS:
    3245              :     // na
    3246              : 
    3247              :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
    3248           38 :     auto &ort = state.dataOutRptTab;
    3249              : 
    3250              :     // normally do not add to the table of contents here but the order of calls is different for the life-cycle costs
    3251           38 :     if (ort->displayLifeCycleCostReport && state.dataEconLifeCycleCost->LCCparamPresent) {
    3252            0 :         AddTOCEntry(state, "Life-Cycle Cost Report", "Entire Facility");
    3253              :     }
    3254              : 
    3255          165 :     for (int iStyle = 1; iStyle <= ort->numStyles; ++iStyle) {
    3256          127 :         if (ort->TableStyle(iStyle) == TableStyle::HTML) {
    3257           27 :             std::ostream &tbl_stream(*ort->TabularOutputFile(iStyle));
    3258           27 :             tbl_stream << "<hr>\n";
    3259           27 :             tbl_stream << "<a name=toc></a>\n";
    3260           27 :             tbl_stream << "<p><b>Table of Contents</b></p>\n";
    3261           27 :             tbl_stream << "<a href=\"#top\">Top</a>\n";
    3262           27 :             if (ort->displayTabularBEPS) {
    3263           27 :                 tbl_stream << "<br><a href=\"#" << MakeAnchorName(Annual_Building_Utility_Performance_Summary, Entire_Facility)
    3264           27 :                            << "\">Annual Building Utility Performance Summary</a>\n";
    3265              :             }
    3266           27 :             if (ort->displayTabularVeriSum) {
    3267           27 :                 tbl_stream << "<br><a href=\"#" << MakeAnchorName(Input_Verification_and_Results_Summary, Entire_Facility)
    3268           27 :                            << "\">Input Verification and Results Summary</a>\n";
    3269              :             }
    3270           27 :             if (ort->displayDemandEndUse) {
    3271           27 :                 tbl_stream << "<br><a href=\"#" << MakeAnchorName(Demand_End_Use_Components_Summary, Entire_Facility)
    3272           27 :                            << "\">Demand End Use Components Summary</a>\n";
    3273              :             }
    3274           27 :             if (ort->displaySourceEnergyEndUseSummary) {
    3275           27 :                 tbl_stream << "<br><a href=\"#" << MakeAnchorName(Source_Energy_End_Use_Components_Summary, Entire_Facility)
    3276           27 :                            << "\">Source Energy End Use Components Summary</a>\n";
    3277              :             }
    3278           27 :             if (state.dataCostEstimateManager->DoCostEstimate) {
    3279            0 :                 tbl_stream << "<br><a href=\"#" << MakeAnchorName(Component_Cost_Economics_Summary, Entire_Facility)
    3280            0 :                            << "\">Component Cost Economics Summary</a>\n";
    3281              :             }
    3282           27 :             if (ort->displayComponentSizing) {
    3283           27 :                 tbl_stream << "<br><a href=\"#" << MakeAnchorName(Component_Sizing_Summary, Entire_Facility) << "\">Component Sizing Summary</a>\n";
    3284              :             }
    3285           27 :             if (ort->displaySurfaceShadowing) {
    3286           27 :                 tbl_stream << "<br><a href=\"#" << MakeAnchorName(Surface_Shadowing_Summary, Entire_Facility) << "\">Surface Shadowing Summary</a>\n";
    3287              :             }
    3288           27 :             if (ort->displayAdaptiveComfort) {
    3289           27 :                 tbl_stream << "<br><a href=\"#" << MakeAnchorName(Adaptive_Comfort_Summary, Entire_Facility) << "\">Adaptive Comfort Summary</a>\n";
    3290              :             }
    3291           27 :             if (ort->displayEioSummary) {
    3292           27 :                 tbl_stream << "<br><a href=\"#" << MakeAnchorName(Initialization_Summary, Entire_Facility) << "\">Initialization Summary</a>\n";
    3293              :             }
    3294           27 :             if (ort->displayHeatEmissionsSummary) {
    3295           27 :                 tbl_stream << "<br><a href=\"#" << MakeAnchorName(Annual_Heat_Emissions_Summary, Entire_Facility)
    3296           27 :                            << "\">Annual Heat Emissions Summary</a>\n";
    3297              :             }
    3298           27 :             if (ort->displayThermalResilienceSummary) {
    3299           27 :                 tbl_stream << "<br><a href=\"#" << MakeAnchorName(Annual_Thermal_Resilience_Summary, Entire_Facility)
    3300           27 :                            << "\">Annual Thermal Resilience Summary</a>\n";
    3301              :             }
    3302              :             //                if (displayCO2ResilienceSummary) {
    3303              :             //                    tbl_stream << "<br><a href=\"#" << MakeAnchorName(Annual_CO2_Resilience_Summary, Entire_Facility)
    3304              :             //                               << "\">Annual CO2 Resilience Summary</a>\n";
    3305              :             //                }
    3306              :             //                if (displayVisualResilienceSummary) {
    3307              :             //                    tbl_stream << "<br><a href=\"#" << MakeAnchorName(Annual_Visual_Resilience_Summary, Entire_Facility)
    3308              :             //                               << "\">Annual Visual Resilience Summary</a>\n";
    3309              :             //                }
    3310          491 :             for (int kReport = 1; kReport <= state.dataOutRptPredefined->numReportName; ++kReport) {
    3311          464 :                 if (state.dataOutRptPredefined->reportName(kReport).show) {
    3312          928 :                     tbl_stream << "<br><a href=\"#" << MakeAnchorName(state.dataOutRptPredefined->reportName(kReport).namewithspaces, Entire_Facility)
    3313          928 :                                << "\">" << state.dataOutRptPredefined->reportName(kReport).namewithspaces << "</a>\n";
    3314              :                 }
    3315              :             }
    3316           27 :             if (state.dataGlobal->DoWeathSim) {
    3317            0 :                 for (int iInput = 1; iInput <= ort->MonthlyInputCount; ++iInput) {
    3318            0 :                     if (ort->MonthlyInput(iInput).numTables > 0) {
    3319            0 :                         tbl_stream << "<p><b>" << ort->MonthlyInput(iInput).name << "</b></p> |\n";
    3320            0 :                         for (int jTable = 1; jTable <= ort->MonthlyInput(iInput).numTables; ++jTable) {
    3321            0 :                             int const curTable = jTable + ort->MonthlyInput(iInput).firstTable - 1;
    3322            0 :                             tbl_stream << "<a href=\"#" << MakeAnchorName(ort->MonthlyInput(iInput).name, ort->MonthlyTables(curTable).keyValue)
    3323            0 :                                        << "\">" << ort->MonthlyTables(curTable).keyValue << "</a>    |   \n";
    3324              :                         }
    3325              :                     }
    3326              :                 }
    3327            0 :                 for (int iInput = 1; iInput <= ort->OutputTableBinnedCount; ++iInput) {
    3328            0 :                     if (ort->OutputTableBinned(iInput).numTables > 0) {
    3329            0 :                         if (ort->OutputTableBinned(iInput).sched == nullptr) {
    3330            0 :                             tbl_stream << "<p><b>" << ort->OutputTableBinned(iInput).varOrMeter << "</b></p> |\n";
    3331              :                         } else {
    3332            0 :                             tbl_stream << "<p><b>" << ort->OutputTableBinned(iInput).varOrMeter << " [" << ort->OutputTableBinned(iInput).sched->Name
    3333            0 :                                        << "]</b></p> |\n";
    3334              :                         }
    3335            0 :                         for (int jTable = 1; jTable <= ort->OutputTableBinned(iInput).numTables; ++jTable) {
    3336            0 :                             int const curTable = ort->OutputTableBinned(iInput).resIndex + (jTable - 1);
    3337            0 :                             std::string curName;
    3338            0 :                             if (ort->ip()) {
    3339            0 :                                 std::string origName = format("{} [{}]",
    3340            0 :                                                               ort->OutputTableBinned(iInput).varOrMeter,
    3341            0 :                                                               Constant::unitNames[(int)ort->OutputTableBinned(iInput).units]);
    3342            0 :                                 [[maybe_unused]] int indexUnitConv = -1;
    3343            0 :                                 LookupSItoIP(state, origName, indexUnitConv, curName);
    3344            0 :                             } else {
    3345            0 :                                 curName = format("{}[{}]",
    3346            0 :                                                  ort->OutputTableBinned(iInput).varOrMeter,
    3347            0 :                                                  Constant::unitNames[(int)ort->OutputTableBinned(iInput).units]);
    3348              :                             }
    3349            0 :                             if (ort->OutputTableBinned(iInput).sched == nullptr) {
    3350            0 :                                 tbl_stream << "<a href=\"#" << MakeAnchorName(curName, ort->BinObjVarID(curTable).namesOfObj) << "\">"
    3351            0 :                                            << ort->BinObjVarID(curTable).namesOfObj << "</a>   |  \n";
    3352              :                             } else {
    3353              :                                 tbl_stream << "<a href=\"#"
    3354            0 :                                            << MakeAnchorName(curName + ort->OutputTableBinned(iInput).sched->Name,
    3355            0 :                                                              ort->BinObjVarID(curTable).namesOfObj)
    3356            0 :                                            << "\">" << ort->BinObjVarID(curTable).namesOfObj << "</a>   |  \n";
    3357              :                             }
    3358            0 :                         }
    3359              :                     }
    3360              :                 }
    3361            0 :                 OutputReportTabularAnnual::AddAnnualTableOfContents(state, tbl_stream);
    3362              :             }
    3363              :             // add entries specifically added using AddTOCEntry
    3364           37 :             for (int iEntry = 1; iEntry <= ort->TOCEntriesCount; ++iEntry) {
    3365           10 :                 if (!ort->TOCEntries(iEntry).isWritten) {
    3366            9 :                     std::string const &curSection = ort->TOCEntries(iEntry).sectionName;
    3367            9 :                     tbl_stream << "<p><b>" << curSection << "</b></p> |\n";
    3368           28 :                     for (int jEntry = iEntry; jEntry <= ort->TOCEntriesCount; ++jEntry) {
    3369           19 :                         if (!ort->TOCEntries(jEntry).isWritten) {
    3370           19 :                             if (ort->TOCEntries(jEntry).sectionName == curSection) {
    3371           20 :                                 tbl_stream << "<a href=\"#" << MakeAnchorName(ort->TOCEntries(jEntry).sectionName, ort->TOCEntries(jEntry).reportName)
    3372           20 :                                            << "\">" << ort->TOCEntries(jEntry).reportName << "</a>   |  \n";
    3373           10 :                                 ort->TOCEntries(jEntry).isWritten = true;
    3374              :                             }
    3375              :                         }
    3376              :                     }
    3377              :                 }
    3378              :             }
    3379              : 
    3380           27 :             if (state.dataWeather->TotReportPers > 0) {
    3381            0 :                 std::string ReportPeriodSummary = "Reporting Period Summary";
    3382            0 :                 tbl_stream << "<br><a href=\"#" << MakeAnchorName(ReportPeriodSummary, Entire_Facility) << "\">"
    3383              :                            << "Reporting Period Summary"
    3384            0 :                            << "</a>\n";
    3385            0 :                 AddTOCReportPeriod(state.dataWeather->TotThermalReportPers, "Thermal", state.dataWeather->ThermalReportPeriodInput, tbl_stream);
    3386            0 :                 AddTOCReportPeriod(state.dataWeather->TotCO2ReportPers, "CO2", state.dataWeather->CO2ReportPeriodInput, tbl_stream);
    3387            0 :                 AddTOCReportPeriod(state.dataWeather->TotVisualReportPers, "Visual", state.dataWeather->VisualReportPeriodInput, tbl_stream);
    3388            0 :             }
    3389              :         }
    3390              :     }
    3391           38 : }
    3392              : 
    3393            0 : void AddTOCReportPeriod(const int nReportPeriods,
    3394              :                         const std::string &kw,
    3395              :                         const Array1D<Weather::ReportPeriodData> &ReportPeriodInputData,
    3396              :                         std::ostream &tbl_stream)
    3397              : {
    3398            0 :     static std::string const Entire_Facility("Entire Facility");
    3399            0 :     for (int i = 1; i <= nReportPeriods; i++) {
    3400              :         std::string ReportPeriod_Resilience_Summary = fmt::format(
    3401            0 :             "{} Resilience Summary for Reporting Period {}: {}", kw, i, ReportPeriodInputData(i).title, ReportPeriodInputData(i).totalElectricityUse);
    3402            0 :         tbl_stream << "<br><a href=\"#" << MakeAnchorName(ReportPeriod_Resilience_Summary, Entire_Facility) << "\">" << kw
    3403            0 :                    << " Resilience Summary for Reporting Period " << i << ": " << ReportPeriodInputData(i).title << "</a>\n";
    3404            0 :     }
    3405            0 : }
    3406              : 
    3407              : //======================================================================================================================
    3408              : //======================================================================================================================
    3409              : 
    3410              : //    GATHER DATA EACH TIME STEP ROUTINES
    3411              : 
    3412              : //======================================================================================================================
    3413              : //======================================================================================================================
    3414              : 
    3415            2 : void GatherBinResultsForTimestep(EnergyPlusData &state, OutputProcessor::TimeStepType t_timeStepType) // What kind of data to update (Zone, HVAC)
    3416              : {
    3417              :     // SUBROUTINE INFORMATION:
    3418              :     //       AUTHOR         Jason Glazer
    3419              :     //       DATE WRITTEN   August 2003
    3420              :     //       MODIFIED       na
    3421              :     //       RE-ENGINEERED  na
    3422              : 
    3423              :     // PURPOSE OF THIS SUBROUTINE:
    3424              :     //   Gathers the data each timestep and adds the length of the
    3425              :     //   timestep to the appropriate bin.
    3426              : 
    3427              :     // Locals
    3428              :     // SUBROUTINE ARGUMENT DEFINITIONS:
    3429              : 
    3430              :     // SUBROUTINE PARAMETER DEFINITIONS:
    3431              :     // na
    3432              : 
    3433              :     // INTERFACE BLOCK SPECIFICATIONS:
    3434              :     // na
    3435              : 
    3436              :     // DERIVED TYPE DEFINITIONS:
    3437              :     // na
    3438              : 
    3439              :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
    3440              :     // values of OutputTableBinned array for current index
    3441            2 :     auto &ort = state.dataOutRptTab;
    3442              : 
    3443            2 :     if (!state.dataGlobal->DoWeathSim) {
    3444            0 :         return;
    3445              :     }
    3446              : 
    3447              :     Real64 const elapsedTime =
    3448            2 :         (t_timeStepType == OutputProcessor::TimeStepType::System) ? state.dataHVACGlobal->TimeStepSys : state.dataGlobal->TimeStepZone;
    3449              : 
    3450            2 :     ort->timeInYear += state.dataHVACGlobal->TimeStepSys;
    3451              : 
    3452            2 :     for (int iInObj = 1; iInObj <= ort->OutputTableBinnedCount; ++iInObj) {
    3453              :         // get values of array for current object being referenced
    3454              : 
    3455            0 :         auto *sched = ort->OutputTableBinned(iInObj).sched;
    3456              :         // if a schedule was used, check if it was non-zero value
    3457            0 :         bool gatherThisTime = (sched == nullptr) || (sched->getCurrentVal() != 0.0);
    3458              : 
    3459            0 :         if (gatherThisTime) {
    3460            0 :             Real64 const &curIntervalStart = ort->OutputTableBinned(iInObj).intervalStart;
    3461            0 :             Real64 const &curIntervalSize = ort->OutputTableBinned(iInObj).intervalSize;
    3462            0 :             int const curIntervalCount = ort->OutputTableBinned(iInObj).intervalCount;
    3463            0 :             Real64 const topValue = curIntervalStart + curIntervalSize * curIntervalCount;
    3464            0 :             OutputProcessor::VariableType const curTypeOfVar = ort->OutputTableBinned(iInObj).typeOfVar;
    3465            0 :             OutputProcessor::TimeStepType const curStepType = ort->OutputTableBinned(iInObj).stepType;
    3466              : 
    3467            0 :             for (int jTable = 1; jTable <= ort->OutputTableBinned(iInObj).numTables; ++jTable) {
    3468            0 :                 int curResIndex = ort->OutputTableBinned(iInObj).resIndex;
    3469            0 :                 int repIndex = curResIndex + (jTable - 1);
    3470            0 :                 if (((curStepType == OutputProcessor::TimeStepType::Zone) && (t_timeStepType == OutputProcessor::TimeStepType::Zone)) ||
    3471            0 :                     ((curStepType == OutputProcessor::TimeStepType::System) && (t_timeStepType == OutputProcessor::TimeStepType::System))) {
    3472              :                     // put actual value from OutputProcesser arrays
    3473            0 :                     Real64 curValue = GetInternalVariableValue(state, curTypeOfVar, ort->BinObjVarID(repIndex).varMeterNum);
    3474              :                     // per MJW when a summed variable is used divide it by the length of the time step
    3475            0 :                     if (ort->OutputTableBinned(iInObj).avgSum == OutputProcessor::StoreType::Sum) { // if it is a summed variable
    3476            0 :                         curValue /= (elapsedTime * Constant::rSecsInHour);
    3477              :                     }
    3478              :                     // round the value to the number of significant digits used in the final output report
    3479            0 :                     if (curIntervalSize < 1) {
    3480            0 :                         curValue = round(curValue * 10000.0) / 10000.0; // four significant digits
    3481            0 :                     } else if (curIntervalSize >= 10) {
    3482            0 :                         curValue = round(curValue); // zero significant digits
    3483              :                     } else {
    3484            0 :                         curValue = round(curValue * 100.0) / 100.0; // two significant digits
    3485              :                     }
    3486              :                     // check if the value is above the maximum or below the minimum value
    3487              :                     // first before binning the value within the range.
    3488            0 :                     if (curValue < curIntervalStart) {
    3489            0 :                         ort->BinResultsBelow(repIndex).mnth(state.dataEnvrn->Month) += elapsedTime;
    3490            0 :                         ort->BinResultsBelow(repIndex).hrly(state.dataGlobal->HourOfDay) += elapsedTime;
    3491            0 :                     } else if (curValue >= topValue) {
    3492            0 :                         ort->BinResultsAbove(repIndex).mnth(state.dataEnvrn->Month) += elapsedTime;
    3493            0 :                         ort->BinResultsAbove(repIndex).hrly(state.dataGlobal->HourOfDay) += elapsedTime;
    3494              :                     } else {
    3495              :                         // determine which bin the results are in
    3496            0 :                         int binNum = static_cast<int>((curValue - curIntervalStart) / curIntervalSize) + 1;
    3497            0 :                         ort->BinResults(binNum, repIndex).mnth(state.dataEnvrn->Month) += elapsedTime;
    3498            0 :                         ort->BinResults(binNum, repIndex).hrly(state.dataGlobal->HourOfDay) += elapsedTime;
    3499              :                     }
    3500              :                     // add to statistics array
    3501            0 :                     ++ort->BinStatistics(repIndex).n;
    3502            0 :                     ort->BinStatistics(repIndex).sum += curValue;
    3503            0 :                     ort->BinStatistics(repIndex).sum2 += curValue * curValue;
    3504            0 :                     if (curValue < ort->BinStatistics(repIndex).minimum) {
    3505            0 :                         ort->BinStatistics(repIndex).minimum = curValue;
    3506              :                     }
    3507            0 :                     if (curValue > ort->BinStatistics(repIndex).maximum) {
    3508            0 :                         ort->BinStatistics(repIndex).maximum = curValue;
    3509              :                     }
    3510              :                 }
    3511              :             }
    3512              :         }
    3513              :     }
    3514              : }
    3515              : 
    3516           11 : void GatherMonthlyResultsForTimestep(EnergyPlusData &state, OutputProcessor::TimeStepType t_timeStepType) // What kind of data to update (Zone, HVAC)
    3517              : {
    3518              :     // SUBROUTINE INFORMATION:
    3519              :     //       AUTHOR         Jason Glazer
    3520              :     //       DATE WRITTEN   September 2003
    3521              :     //       MODIFIED       na
    3522              :     //       RE-ENGINEERED  na
    3523              : 
    3524              :     // PURPOSE OF THIS SUBROUTINE:
    3525              :     //   Gathers the data each timestep and updates the arrays
    3526              :     //   holding the data that will be reported later.
    3527              : 
    3528              :     // Using/Aliasing
    3529           11 :     Real64 const TimeStepSysSec = state.dataHVACGlobal->TimeStepSysSec;
    3530              :     using General::EncodeMonDayHrMin;
    3531              : 
    3532              :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
    3533              : 
    3534           11 :     if (!state.dataGlobal->DoWeathSim) {
    3535            0 :         return;
    3536              :     }
    3537              : 
    3538           11 :     auto &ort = state.dataOutRptTab;
    3539           11 :     assert(state.dataGlobal->TimeStepZoneSec > 0.0);
    3540              : 
    3541              :     // create temporary arrays to speed processing of these arrays
    3542           11 :     if (ort->GatherMonthlyResultsForTimestepRunOnce) {
    3543              :         // MonthlyColumns
    3544            4 :         state.dataOutRptTab->MonthlyColumnsTypeOfVar.allocate(ort->MonthlyColumns.I());
    3545            4 :         state.dataOutRptTab->MonthlyColumnsStepType.allocate(ort->MonthlyColumns.I());
    3546            4 :         state.dataOutRptTab->MonthlyColumnsAggType.allocate(ort->MonthlyColumns.I());
    3547            4 :         state.dataOutRptTab->MonthlyColumnsVarNum.allocate(ort->MonthlyColumns.I());
    3548           18 :         for (int i = ort->MonthlyColumns.l(), e = ort->MonthlyColumns.u(); i <= e; ++i) {
    3549           14 :             auto const &col = ort->MonthlyColumns(i);
    3550           14 :             state.dataOutRptTab->MonthlyColumnsTypeOfVar(i) = col.typeOfVar;
    3551           14 :             state.dataOutRptTab->MonthlyColumnsStepType(i) = col.stepType;
    3552           14 :             state.dataOutRptTab->MonthlyColumnsAggType(i) = col.aggType;
    3553           14 :             state.dataOutRptTab->MonthlyColumnsVarNum(i) = col.varNum;
    3554              :         }
    3555              : 
    3556              :         // MonthlyTables
    3557            4 :         state.dataOutRptTab->MonthlyTablesNumColumns.allocate(ort->MonthlyTables.I());
    3558            8 :         for (int i = ort->MonthlyTables.l(), e = ort->MonthlyTables.u(); i <= e; ++i) {
    3559            4 :             state.dataOutRptTab->MonthlyTablesNumColumns(i) = ort->MonthlyTables(i).numColumns;
    3560              :         }
    3561              : 
    3562              :         // set flag so this block is only executed once
    3563            4 :         ort->GatherMonthlyResultsForTimestepRunOnce = false;
    3564              :     }
    3565              : 
    3566              :     Real64 const elapsedTime =
    3567           11 :         (t_timeStepType == OutputProcessor::TimeStepType::System) ? state.dataHVACGlobal->TimeStepSys : state.dataGlobal->TimeStepZone;
    3568              : 
    3569           11 :     ort->IsMonthGathered(state.dataEnvrn->Month) = true;
    3570           28 :     for (int iTable = 1; iTable <= ort->MonthlyTablesCount; ++iTable) {
    3571           17 :         bool activeMinMax = false;     // at the beginning of the new timestep
    3572           17 :         bool activeHoursShown = false; // fix by JG addressing CR6482
    3573           17 :         state.dataOutRptTab->curFirstColumn = ort->MonthlyTables(iTable).firstColumn;
    3574           78 :         for (int jColumn = 1; jColumn <= state.dataOutRptTab->MonthlyTablesNumColumns(iTable); ++jColumn) {
    3575           61 :             int const curCol = jColumn + state.dataOutRptTab->curFirstColumn - 1;
    3576           61 :             OutputProcessor::VariableType const curTypeOfVar = state.dataOutRptTab->MonthlyColumnsTypeOfVar(curCol);
    3577           61 :             OutputProcessor::TimeStepType const curStepType = state.dataOutRptTab->MonthlyColumnsStepType(curCol);
    3578           61 :             if (((curStepType == OutputProcessor::TimeStepType::Zone) && (t_timeStepType == OutputProcessor::TimeStepType::Zone)) ||
    3579            0 :                 ((curStepType == OutputProcessor::TimeStepType::System) && (t_timeStepType == OutputProcessor::TimeStepType::System))) {
    3580              :                 //  the above condition used to include the following prior to new scan method
    3581              :                 //  (MonthlyColumns(curCol)%aggType .EQ. AggType::ValueWhenMaxMin)
    3582           61 :                 int const curVarNum = state.dataOutRptTab->MonthlyColumnsVarNum(curCol);
    3583           61 :                 Real64 curValue = GetInternalVariableValue(state, curTypeOfVar, curVarNum);
    3584              :                 // Get the value from the result array
    3585           61 :                 Real64 const &oldResultValue = ort->MonthlyColumns(curCol).reslt(state.dataEnvrn->Month);
    3586              :                 // Real64 oldTimeStamp = ort->MonthlyColumns(curCol).timeStamp(state.dataEnvrn->Month);
    3587           61 :                 Real64 const &oldDuration = ort->MonthlyColumns(curCol).duration(state.dataEnvrn->Month);
    3588              :                 // Zero the revised values (as default if not set later in SELECT)
    3589           61 :                 Real64 newResultValue = 0.0;
    3590           61 :                 int newTimeStamp = 0;
    3591           61 :                 Real64 newDuration = 0.0;
    3592           61 :                 bool activeNewValue = false;
    3593              :                 // the current timestamp
    3594           61 :                 int const minuteCalculated = OutputProcessor::DetermineMinuteForReporting(state);
    3595              :                 //      minuteCalculated = (CurrentTime - INT(CurrentTime))*60
    3596              :                 //      IF (t_timeStepType .EQ. OutputProcessor::TimeStepType::TimeStepSystem) minuteCalculated = minuteCalculated +
    3597              :                 //      SysTimeElapsed * 60 minuteCalculated = INT((TimeStep-1) * TimeStepZone * 60) + INT((SysTimeElapsed + TimeStepSys) * 60)
    3598              :                 int timestepTimeStamp;
    3599           61 :                 EncodeMonDayHrMin(
    3600           61 :                     timestepTimeStamp, state.dataEnvrn->Month, state.dataEnvrn->DayOfMonth, state.dataGlobal->HourOfDay, minuteCalculated);
    3601              :                 // perform the selected aggregation type
    3602              :                 // use next lines since it is faster was: SELECT CASE (MonthlyColumns(curCol)%aggType)
    3603           61 :                 switch (state.dataOutRptTab->MonthlyColumnsAggType(curCol)) {
    3604           41 :                 case AggType::SumOrAvg: {
    3605           41 :                     if (ort->MonthlyColumns(curCol).avgSum == OutputProcessor::StoreType::Sum) { // if it is a summed variable
    3606           17 :                         newResultValue = oldResultValue + curValue;
    3607              :                     } else {
    3608           24 :                         newResultValue = oldResultValue + curValue * elapsedTime; // for averaging - weight by elapsed time
    3609              :                     }
    3610           41 :                     newDuration = oldDuration + elapsedTime;
    3611           41 :                     activeNewValue = true;
    3612           41 :                 } break;
    3613            0 :                 case AggType::Maximum: {
    3614              :                     // per MJW when a summed variable is used divide it by the length of the time step
    3615            0 :                     if (ort->MonthlyColumns(curCol).avgSum == OutputProcessor::StoreType::Sum) { // if it is a summed variable
    3616            0 :                         if (t_timeStepType == OutputProcessor::TimeStepType::System) {
    3617            0 :                             curValue /= TimeStepSysSec;
    3618              :                         } else {
    3619            0 :                             curValue /= state.dataGlobal->TimeStepZoneSec;
    3620              :                         }
    3621              :                     }
    3622            0 :                     if (curValue > oldResultValue) {
    3623            0 :                         newResultValue = curValue;
    3624            0 :                         newTimeStamp = timestepTimeStamp;
    3625            0 :                         activeMinMax = true;
    3626            0 :                         activeNewValue = true;
    3627              :                     } else {
    3628            0 :                         activeMinMax = false; // reset this
    3629              :                     }
    3630            0 :                 } break;
    3631            0 :                 case AggType::Minimum: {
    3632              :                     // per MJW when a summed variable is used divide it by the length of the time step
    3633            0 :                     if (ort->MonthlyColumns(curCol).avgSum == OutputProcessor::StoreType::Sum) { // if it is a summed variable
    3634            0 :                         if (t_timeStepType == OutputProcessor::TimeStepType::System) {
    3635            0 :                             curValue /= TimeStepSysSec;
    3636              :                         } else {
    3637            0 :                             curValue /= state.dataGlobal->TimeStepZoneSec;
    3638              :                         }
    3639              :                     }
    3640            0 :                     if (curValue < oldResultValue) {
    3641            0 :                         newResultValue = curValue;
    3642            0 :                         newTimeStamp = timestepTimeStamp;
    3643            0 :                         activeMinMax = true;
    3644            0 :                         activeNewValue = true;
    3645              :                     } else {
    3646            0 :                         activeMinMax = false; // reset this
    3647              :                     }
    3648            0 :                 } break;
    3649            0 :                 case AggType::HoursZero: {
    3650            0 :                     if (curValue == 0) {
    3651            0 :                         newResultValue = oldResultValue + elapsedTime;
    3652            0 :                         activeHoursShown = true;
    3653            0 :                         activeNewValue = true;
    3654              :                     } else {
    3655            0 :                         activeHoursShown = false;
    3656              :                     }
    3657            0 :                 } break;
    3658           10 :                 case AggType::HoursNonZero: {
    3659           10 :                     if (curValue != 0) {
    3660            5 :                         newResultValue = oldResultValue + elapsedTime;
    3661            5 :                         activeHoursShown = true;
    3662            5 :                         activeNewValue = true;
    3663              :                     } else {
    3664            5 :                         activeHoursShown = false;
    3665              :                     }
    3666           10 :                 } break;
    3667            0 :                 case AggType::HoursPositive: {
    3668            0 :                     if (curValue > 0) {
    3669            0 :                         newResultValue = oldResultValue + elapsedTime;
    3670            0 :                         activeHoursShown = true;
    3671            0 :                         activeNewValue = true;
    3672              :                     } else {
    3673            0 :                         activeHoursShown = false;
    3674              :                     }
    3675            0 :                 } break;
    3676            0 :                 case AggType::HoursNonPositive: {
    3677            0 :                     if (curValue <= 0) {
    3678            0 :                         newResultValue = oldResultValue + elapsedTime;
    3679            0 :                         activeHoursShown = true;
    3680            0 :                         activeNewValue = true;
    3681              :                     } else {
    3682            0 :                         activeHoursShown = false;
    3683              :                     }
    3684            0 :                 } break;
    3685            0 :                 case AggType::HoursNegative: {
    3686            0 :                     if (curValue < 0) {
    3687            0 :                         newResultValue = oldResultValue + elapsedTime;
    3688            0 :                         activeHoursShown = true;
    3689            0 :                         activeNewValue = true;
    3690              :                     } else {
    3691            0 :                         activeHoursShown = false;
    3692              :                     }
    3693            0 :                 } break;
    3694            0 :                 case AggType::HoursNonNegative: {
    3695            0 :                     if (curValue >= 0) {
    3696            0 :                         newResultValue = oldResultValue + elapsedTime;
    3697            0 :                         activeHoursShown = true;
    3698            0 :                         activeNewValue = true;
    3699              :                     } else {
    3700            0 :                         activeHoursShown = false;
    3701              :                     }
    3702              :                     // The valueWhenMaxMin is picked up now during the activeMinMax if block below.
    3703              :                     // CASE (iAggType::ValueWhenMaxMin)
    3704              :                     // CASE (iAggType::SumOrAverageHoursShown)
    3705              :                     // CASE (iAggType::MaximumDuringHoursShown)
    3706              :                     // CASE (iAggType::MinimumDuringHoursShown)
    3707            0 :                 } break;
    3708           10 :                 default:
    3709           10 :                     break;
    3710              :                 }
    3711              :                 // if the new value has been set then set the monthly values to the
    3712              :                 // new columns. This skips the aggregation types that don't even get
    3713              :                 // triggered now such as valueWhenMinMax and all the agg*HoursShown
    3714           61 :                 if (activeNewValue) {
    3715           46 :                     ort->MonthlyColumns(curCol).reslt(state.dataEnvrn->Month) = newResultValue;
    3716           46 :                     ort->MonthlyColumns(curCol).timeStamp(state.dataEnvrn->Month) = newTimeStamp;
    3717           46 :                     ort->MonthlyColumns(curCol).duration(state.dataEnvrn->Month) = newDuration;
    3718              :                 }
    3719              :                 // if a minimum or maximum value was set this timeStep then
    3720              :                 // scan the remaining columns of the table looking for values
    3721              :                 // that are aggregation type "ValueWhenMaxMin" and set their values
    3722              :                 // if another minimum or maximum column is found then end
    3723              :                 // the scan (it will be taken care of when that column is done)
    3724           61 :                 if (activeMinMax) {
    3725            0 :                     for (int kOtherColumn = jColumn + 1; kOtherColumn <= ort->MonthlyTables(iTable).numColumns; ++kOtherColumn) {
    3726            0 :                         int const scanColumn = kOtherColumn + ort->MonthlyTables(iTable).firstColumn - 1;
    3727            0 :                         switch (ort->MonthlyColumns(scanColumn).aggType) {
    3728            0 :                         case AggType::Maximum:
    3729              :                         case AggType::Minimum:
    3730              :                             // end scanning since these might reset
    3731            0 :                             break; // do
    3732            0 :                         case AggType::ValueWhenMaxMin: {
    3733              :                             // this case is when the value should be set
    3734            0 :                             OutputProcessor::VariableType const scanTypeOfVar = ort->MonthlyColumns(scanColumn).typeOfVar;
    3735            0 :                             int const scanVarNum = ort->MonthlyColumns(scanColumn).varNum;
    3736            0 :                             Real64 scanValue = GetInternalVariableValue(state, scanTypeOfVar, scanVarNum);
    3737              :                             // When a summed variable is used divide it by the length of the time step
    3738            0 :                             if (ort->MonthlyColumns(scanColumn).avgSum == OutputProcessor::StoreType::Sum) { // if it is a summed variable
    3739            0 :                                 if (t_timeStepType == OutputProcessor::TimeStepType::System) {
    3740            0 :                                     scanValue /= TimeStepSysSec;
    3741              :                                 } else {
    3742            0 :                                     scanValue /= state.dataGlobal->TimeStepZoneSec;
    3743              :                                 }
    3744              :                             }
    3745            0 :                             ort->MonthlyColumns(scanColumn).reslt(state.dataEnvrn->Month) = scanValue;
    3746            0 :                         } break;
    3747            0 :                         default:
    3748            0 :                             break;
    3749              :                         }
    3750              :                     }
    3751              :                 }
    3752              :                 // If the hours variable is active then scan through the rest of the variables
    3753              :                 // and accumulate
    3754           61 :                 if (activeHoursShown) {
    3755            5 :                     bool exit_loop = false;
    3756           15 :                     for (int kOtherColumn = jColumn + 1; kOtherColumn <= ort->MonthlyTables(iTable).numColumns; ++kOtherColumn) {
    3757           13 :                         if (exit_loop) {
    3758            3 :                             break;
    3759              :                         }
    3760           10 :                         int const scanColumn = kOtherColumn + ort->MonthlyTables(iTable).firstColumn - 1;
    3761           10 :                         OutputProcessor::VariableType const scanTypeOfVar = ort->MonthlyColumns(scanColumn).typeOfVar;
    3762           10 :                         int const scanVarNum = ort->MonthlyColumns(scanColumn).varNum;
    3763           10 :                         Real64 scanValue = GetInternalVariableValue(state, scanTypeOfVar, scanVarNum);
    3764           10 :                         Real64 const oldScanValue = ort->MonthlyColumns(scanColumn).reslt(state.dataEnvrn->Month);
    3765           10 :                         switch (ort->MonthlyColumns(scanColumn).aggType) {
    3766            3 :                         case AggType::HoursZero:
    3767              :                         case AggType::HoursNonZero:
    3768              :                         case AggType::HoursPositive:
    3769              :                         case AggType::HoursNonPositive:
    3770              :                         case AggType::HoursNegative:
    3771              :                         case AggType::HoursNonNegative:
    3772              :                             // end scanning since these might reset
    3773            3 :                             exit_loop = true;
    3774            3 :                             break; // do
    3775            5 :                         case AggType::SumOrAverageHoursShown: {
    3776              :                             // this case is when the value should be set
    3777            5 :                             if (ort->MonthlyColumns(scanColumn).avgSum == OutputProcessor::StoreType::Sum) { // if it is a summed variable
    3778            5 :                                 ort->MonthlyColumns(scanColumn).reslt(state.dataEnvrn->Month) = oldScanValue + scanValue;
    3779              :                             } else {
    3780              :                                 // for averaging - weight by elapsed time
    3781            0 :                                 ort->MonthlyColumns(scanColumn).reslt(state.dataEnvrn->Month) = oldScanValue + scanValue * elapsedTime;
    3782              :                             }
    3783            5 :                             ort->MonthlyColumns(scanColumn).duration(state.dataEnvrn->Month) += elapsedTime;
    3784            5 :                         } break;
    3785            0 :                         case AggType::MaximumDuringHoursShown: {
    3786            0 :                             if (ort->MonthlyColumns(scanColumn).avgSum == OutputProcessor::StoreType::Sum) { // if it is a summed variable
    3787            0 :                                 if (t_timeStepType == OutputProcessor::TimeStepType::System) {
    3788            0 :                                     scanValue /= TimeStepSysSec;
    3789              :                                 } else {
    3790            0 :                                     scanValue /= state.dataGlobal->TimeStepZoneSec;
    3791              :                                 }
    3792              :                             }
    3793            0 :                             if (scanValue > oldScanValue) {
    3794            0 :                                 ort->MonthlyColumns(scanColumn).reslt(state.dataEnvrn->Month) = scanValue;
    3795            0 :                                 ort->MonthlyColumns(scanColumn).timeStamp(state.dataEnvrn->Month) = timestepTimeStamp;
    3796              :                             }
    3797            0 :                         } break;
    3798            0 :                         case AggType::MinimumDuringHoursShown: {
    3799            0 :                             if (ort->MonthlyColumns(scanColumn).avgSum == OutputProcessor::StoreType::Sum) { // if it is a summed variable
    3800            0 :                                 if (t_timeStepType == OutputProcessor::TimeStepType::System) {
    3801            0 :                                     scanValue /= TimeStepSysSec;
    3802              :                                 } else {
    3803            0 :                                     scanValue /= state.dataGlobal->TimeStepZoneSec;
    3804              :                                 }
    3805              :                             }
    3806            0 :                             if (scanValue < oldScanValue) {
    3807            0 :                                 ort->MonthlyColumns(scanColumn).reslt(state.dataEnvrn->Month) = scanValue;
    3808            0 :                                 ort->MonthlyColumns(scanColumn).timeStamp(state.dataEnvrn->Month) = timestepTimeStamp;
    3809              :                             }
    3810            0 :                         } break;
    3811            2 :                         default:
    3812            2 :                             break;
    3813              :                         }
    3814           10 :                         activeHoursShown = false; // fixed CR8317
    3815              :                     }
    3816              :                 }
    3817              :             }
    3818              :         }
    3819              :     }
    3820              : }
    3821              : 
    3822           17 : void GatherBEPSResultsForTimestep(EnergyPlusData &state, OutputProcessor::TimeStepType t_timeStepType) // What kind of data to update (Zone, HVAC)
    3823              : {
    3824              :     // SUBROUTINE INFORMATION:
    3825              :     //       AUTHOR         Jason Glazer
    3826              :     //       DATE WRITTEN   November 2003
    3827              :     //       MODIFIED       na
    3828              :     //       RE-ENGINEERED  na
    3829              : 
    3830              :     // PURPOSE OF THIS SUBROUTINE:
    3831              :     //   This routine gathers data for producing the BEPS report
    3832              : 
    3833              :     // METHODOLOGY EMPLOYED:
    3834              :     //   Uses get input structure similar to other objects
    3835              :     //   Meter names are of two forms:
    3836              :     //         <ResourceType>:<name>
    3837              :     //   or
    3838              :     //         <EndUseType>:<ResourceType>
    3839              :     //   For the purposes of this routine, only the facility <name>
    3840              :     //   is used.  Remember that 'Building' is actually the sum of
    3841              :     //   the zones only without system,plant and exterior. The only
    3842              :     //   way to get them all is to use 'facility'
    3843              :     //   The <EndUseType> are:
    3844              :     //          Heating
    3845              :     //          Cooling
    3846              :     //          InteriorLights
    3847              :     //          ExteriorLights
    3848              :     //          InteriorEquipment
    3849              :     //          ExteriorEquipment
    3850              :     //          Fans
    3851              :     //          Pumps
    3852              :     //          HeatRejection
    3853              :     //          Humidifier
    3854              :     //          HeatRecovery
    3855              :     //          Refrigeration
    3856              :     //          Cogeneration
    3857              :     //          WaterSystems
    3858              :     //   The <ResourceType> are:
    3859              :     //          Electricity
    3860              :     //          Gas
    3861              :     //          Gasoline
    3862              :     //          Diesel
    3863              :     //          Coal
    3864              :     //          FuelOilNo1
    3865              :     //          FuelOilNo2
    3866              :     //          Propane
    3867              :     //          Water
    3868              :     //          Steam
    3869              :     //          DistrictCooling
    3870              :     //          DistrictHeatingWater
    3871              :     //          DistrictHeatingSteam
    3872              : 
    3873              :     using DataStringGlobals::CharComma;
    3874              :     using DataStringGlobals::CharSpace;
    3875              :     using DataStringGlobals::CharTab;
    3876              : 
    3877           17 :     auto &ort = state.dataOutRptTab;
    3878              :     // if no beps report is called then skip
    3879              : 
    3880           17 :     if ((ort->displayTabularBEPS || ort->displayLEEDSummary) && (t_timeStepType == OutputProcessor::TimeStepType::Zone)) {
    3881           15 :         auto &op = state.dataOutputProcessor;
    3882              :         // add the current time to the total elapsed time
    3883              :         // FOLLOWING LINE MOVED TO UPDATETABULARREPORTS because used even when beps is not called
    3884              :         // gatherElapsedTimeBEPS = gatherElapsedTimeBEPS + TimeStepZone
    3885              :         // loop through all of the resource types for the entire facility
    3886              :         //  DO iResource = 1, numResourceTypes
    3887              :         //    curMeterNumber = meterNumTotalsBEPS(iResource)
    3888              :         //    IF (curMeterNumber .GT. 0) THEN
    3889              :         //      curMeterValue = GetCurrentMeterValue(curMeterNumber)
    3890              :         //      gatherTotalsBEPS(iResource) = gatherTotalsBEPS(iResource) + curMeterValue
    3891              :         //    END IF
    3892              :         //  END DO
    3893              : 
    3894              :         // loop through all of the resources and end uses for the entire facility
    3895          225 :         for (int iResource = 1; iResource <= numResourceTypes; ++iResource) {
    3896          210 :             int curResMeterNumber = ort->meterNumTotalsBEPS(iResource);
    3897          210 :             if (curResMeterNumber > -1) {
    3898           44 :                 Real64 curResMeterValue = GetCurrentMeterValue(state, curResMeterNumber);
    3899           44 :                 ort->gatherTotalsBEPS(iResource) += curResMeterValue;
    3900              :             }
    3901              : 
    3902         3150 :             for (int jEndUse = 1; jEndUse <= static_cast<int>(Constant::EndUse::Num); ++jEndUse) {
    3903         2940 :                 int curEndUseMeterNumber = ort->meterNumEndUseBEPS(iResource, jEndUse);
    3904         2940 :                 if (curEndUseMeterNumber > -1) {
    3905           44 :                     Real64 curEndUseMeterValue = GetCurrentMeterValue(state, curEndUseMeterNumber);
    3906           44 :                     ort->gatherEndUseBEPS(iResource, jEndUse) += curEndUseMeterValue;
    3907              : 
    3908           97 :                     for (int kEndUseSub = 1; kEndUseSub <= op->EndUseCategory(jEndUse).NumSubcategories; ++kEndUseSub) {
    3909           53 :                         int curSubMeterNumber = ort->meterNumEndUseSubBEPS(kEndUseSub, jEndUse, iResource);
    3910           53 :                         if (curSubMeterNumber > -1) {
    3911           53 :                             Real64 curSubMeterValue = GetCurrentMeterValue(state, curSubMeterNumber);
    3912           53 :                             ort->gatherEndUseSubBEPS(kEndUseSub, jEndUse, iResource) += curSubMeterValue;
    3913              :                         }
    3914              :                     }
    3915           44 :                     for (int kEndUseSpType = 1; kEndUseSpType <= op->EndUseCategory(jEndUse).numSpaceTypes; ++kEndUseSpType) {
    3916            0 :                         int curSpTypeMeterNumber = ort->meterNumEndUseSpTypeBEPS(kEndUseSpType, jEndUse, iResource);
    3917            0 :                         if (curSpTypeMeterNumber > -1) {
    3918            0 :                             Real64 curSpTypeMeterValue = GetCurrentMeterValue(state, curSpTypeMeterNumber);
    3919            0 :                             ort->gatherEndUseSpTypeBEPS(kEndUseSpType, jEndUse, iResource) += curSpTypeMeterValue;
    3920              :                         }
    3921              :                     }
    3922              :                 }
    3923              :             }
    3924              :         }
    3925              : 
    3926          195 :         for (int iResource = 1; iResource <= numSourceTypes; ++iResource) {
    3927          180 :             int curResMeterNumber = ort->meterNumTotalsSource(iResource);
    3928          180 :             if (curResMeterNumber > -1) {
    3929            0 :                 Real64 curResMeterValue = GetCurrentMeterValue(state, curResMeterNumber);
    3930            0 :                 ort->gatherTotalsSource(iResource) += curResMeterValue;
    3931              :             }
    3932              :         }
    3933              : 
    3934              :         // gather the electric load components
    3935           15 :         ort->gatherPowerFuelFireGen += GetCurrentMeterValue(state, ort->meterNumPowerFuelFireGen);
    3936           15 :         ort->gatherPowerPV += GetCurrentMeterValue(state, ort->meterNumPowerPV);
    3937           15 :         ort->gatherPowerWind += GetCurrentMeterValue(state, ort->meterNumPowerWind);
    3938           15 :         ort->gatherPowerHTGeothermal += GetCurrentMeterValue(state, ort->meterNumPowerHTGeothermal);
    3939           15 :         ort->gatherElecProduced += GetCurrentMeterValue(state, ort->meterNumElecProduced);
    3940           15 :         ort->gatherElecPurchased += GetCurrentMeterValue(state, ort->meterNumElecPurchased);
    3941           15 :         ort->gatherElecSurplusSold += GetCurrentMeterValue(state, ort->meterNumElecSurplusSold);
    3942           15 :         ort->gatherElecStorage += GetCurrentMeterValue(state, ort->meterNumElecStorage);
    3943           15 :         ort->gatherPowerConversion += GetCurrentMeterValue(state, ort->meterNumPowerConversion);
    3944              :         // gather the onsite thermal components
    3945           15 :         ort->gatherWaterHeatRecovery += GetCurrentMeterValue(state, ort->meterNumWaterHeatRecovery);
    3946           15 :         ort->gatherAirHeatRecoveryCool += GetCurrentMeterValue(state, ort->meterNumAirHeatRecoveryCool);
    3947           15 :         ort->gatherAirHeatRecoveryHeat += GetCurrentMeterValue(state, ort->meterNumAirHeatRecoveryHeat);
    3948           15 :         ort->gatherHeatHTGeothermal += GetCurrentMeterValue(state, ort->meterNumHeatHTGeothermal);
    3949           15 :         ort->gatherHeatSolarWater += GetCurrentMeterValue(state, ort->meterNumHeatSolarWater);
    3950           15 :         ort->gatherHeatSolarAir += GetCurrentMeterValue(state, ort->meterNumHeatSolarAir);
    3951              :         // gather the water supply components
    3952           15 :         ort->gatherRainWater += GetCurrentMeterValue(state, ort->meterNumRainWater);
    3953           15 :         ort->gatherCondensate += GetCurrentMeterValue(state, ort->meterNumCondensate);
    3954           15 :         ort->gatherWellwater += GetCurrentMeterValue(state, ort->meterNumGroundwater);
    3955           15 :         ort->gatherMains += GetCurrentMeterValue(state, ort->meterNumMains);
    3956           15 :         ort->gatherWaterEndUseTotal += GetCurrentMeterValue(state, ort->meterNumWaterEndUseTotal);
    3957              :     }
    3958           17 : }
    3959              : 
    3960            2 : void GatherSourceEnergyEndUseResultsForTimestep(EnergyPlusData &state,
    3961              :                                                 OutputProcessor::TimeStepType t_timeStepType) // What kind of data to update (Zone, HVAC)
    3962              : {
    3963              :     // SUBROUTINE INFORMATION:
    3964              :     //       AUTHOR         Mangesh Basarkar
    3965              :     //       DATE WRITTEN   September 2011
    3966              :     //       MODIFIED       na
    3967              :     //       RE-ENGINEERED  na
    3968              : 
    3969              :     // PURPOSE OF THIS SUBROUTINE:
    3970              :     //   This routine gathers data for producing the end uses report in source energy
    3971              : 
    3972              :     // METHODOLOGY EMPLOYED:
    3973              :     //   Uses get input structure similar to other objects
    3974              :     //   Meter names are of two forms:
    3975              :     //         <ResourceType>:<name>
    3976              :     //   or
    3977              :     //         <EndUseType>:<ResourceType>
    3978              :     //   The <EndUseType> are:
    3979              :     //          Heating
    3980              :     //          Cooling
    3981              :     //          InteriorLights
    3982              :     //          ExteriorLights
    3983              :     //          InteriorEquipment
    3984              :     //          ExteriorEquipment
    3985              :     //          Fans
    3986              :     //          Pumps
    3987              :     //          HeatRejection
    3988              :     //          Humidifier
    3989              :     //          HeatRecovery
    3990              :     //          Refrigeration
    3991              :     //          Cogeneration
    3992              :     //          WaterSystems
    3993              :     //   The <ResourceType> are:
    3994              :     //          Electricity 1
    3995              :     //          Gas 2
    3996              :     //          Gasoline 6
    3997              :     //          Diesel 8
    3998              :     //          Coal 9
    3999              :     //          FuelOilNo1 10
    4000              :     //          FuelOilNo2 11
    4001              :     //          Propane 12
    4002              :     //          Water 7
    4003              :     //          DistrictCooling 3
    4004              :     //          DistrictHeatingWater 4
    4005              :     //          DistrictHeatingSteam 5
    4006              : 
    4007              :     //          sourceTypeNames(1)='Electric'
    4008              :     //          sourceTypeNames(2)='NaturalGas'
    4009              :     //          sourceTypeNames(3)='Gasoline'
    4010              :     //          sourceTypeNames(4)='Diesel'
    4011              :     //          sourceTypeNames(5)='Coal'
    4012              :     //          sourceTypeNames(6)='FuelOilNo1'
    4013              :     //          sourceTypeNames(7)='FuelOilNo2'
    4014              :     //          sourceTypeNames(8)='Propane'
    4015              :     //          sourceTypeNames(9)='PurchasedElectricity'
    4016              :     //          sourceTypeNames(10)='SoldElectricity'
    4017              :     //          sourceTypeNames(11)='OtherFuel1'
    4018              :     //          sourceTypeNames(12)='OtherFuel2'
    4019              : 
    4020              :     // REFERENCES:
    4021              :     // na
    4022              : 
    4023              :     // Using/Aliasing
    4024              :     using DataStringGlobals::CharComma;
    4025              :     using DataStringGlobals::CharSpace;
    4026              :     using DataStringGlobals::CharTab;
    4027              : 
    4028              :     // Locals
    4029              :     // SUBROUTINE ARGUMENT DEFINITIONS:
    4030              : 
    4031              :     // SUBROUTINE PARAMETER DEFINITIONS:
    4032              :     // na
    4033              : 
    4034              :     // INTERFACE BLOCK SPECIFICATIONS:
    4035              :     // na
    4036              : 
    4037              :     // DERIVED TYPE DEFINITIONS:
    4038              :     // na
    4039              : 
    4040              :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
    4041            2 :     auto &ort = state.dataOutRptTab;
    4042              : 
    4043              :     // if no beps by source report is called then skip
    4044              : 
    4045            2 :     if ((ort->displaySourceEnergyEndUseSummary) && (t_timeStepType == OutputProcessor::TimeStepType::Zone)) {
    4046              :         // loop through all of the resources and end uses for the entire facility
    4047            0 :         for (int iResource = 1; iResource <= numResourceTypes; ++iResource) {
    4048              : 
    4049            0 :             if (ort->ffSchedUsed(iResource)) {
    4050            0 :                 int const curMeterNumber = ort->meterNumTotalsBEPS(iResource);
    4051            0 :                 if (curMeterNumber > -1) {
    4052              :                     Real64 const curMeterValue =
    4053            0 :                         GetCurrentMeterValue(state, curMeterNumber) * ort->ffScheds(iResource)->getCurrentVal() * ort->SourceFactors(iResource);
    4054            0 :                     ort->gatherTotalsBySourceBEPS(iResource) += curMeterValue;
    4055              :                 }
    4056              :             } else {
    4057            0 :                 int const curMeterNumber = ort->meterNumTotalsBEPS(iResource);
    4058            0 :                 if (curMeterNumber > -1) {
    4059            0 :                     Real64 const curMeterValue = GetCurrentMeterValue(state, curMeterNumber) * ort->SourceFactors(iResource);
    4060            0 :                     ort->gatherTotalsBySourceBEPS(iResource) += curMeterValue;
    4061              :                 }
    4062              :             }
    4063              : 
    4064            0 :             for (int jEndUse = 1; jEndUse <= static_cast<int>(Constant::EndUse::Num); ++jEndUse) {
    4065            0 :                 if (ort->ffSchedUsed(iResource)) {
    4066            0 :                     int const curMeterNumber = ort->meterNumEndUseBEPS(iResource, jEndUse);
    4067            0 :                     if (curMeterNumber > -1) {
    4068              :                         Real64 const curMeterValue =
    4069            0 :                             GetCurrentMeterValue(state, curMeterNumber) * ort->ffScheds(iResource)->getCurrentVal() * ort->SourceFactors(iResource);
    4070            0 :                         ort->gatherEndUseBySourceBEPS(iResource, jEndUse) += curMeterValue;
    4071              :                     }
    4072              :                 } else {
    4073            0 :                     int const curMeterNumber = ort->meterNumEndUseBEPS(iResource, jEndUse);
    4074            0 :                     if (curMeterNumber > -1) {
    4075            0 :                         Real64 const curMeterValue = GetCurrentMeterValue(state, curMeterNumber) * ort->SourceFactors(iResource);
    4076            0 :                         ort->gatherEndUseBySourceBEPS(iResource, jEndUse) += curMeterValue;
    4077              :                     }
    4078              :                 }
    4079              :             }
    4080              :         }
    4081              :     }
    4082            2 : }
    4083              : 
    4084           17 : void GatherPeakDemandForTimestep(EnergyPlusData &state, OutputProcessor::TimeStepType t_timeStepType) // What kind of data to update (Zone, HVAC)
    4085              : {
    4086              :     // SUBROUTINE INFORMATION:
    4087              :     //       AUTHOR         Jason Glazer
    4088              :     //       DATE WRITTEN   January 2009
    4089              :     //       MODIFIED       na
    4090              :     //       RE-ENGINEERED  na
    4091              : 
    4092              :     // PURPOSE OF THIS SUBROUTINE:
    4093              :     //   This routine gathers data for producing the Peak Demand
    4094              :     //   by end-use report
    4095              : 
    4096              :     // METHODOLOGY EMPLOYED:
    4097              :     //   Uses get input structure similar to other objects
    4098              :     //   Meter names are of two forms:
    4099              :     //         <ResourceType>:<name>
    4100              :     //   or
    4101              :     //         <EndUseType>:<ResourceType>
    4102              :     //   For the purposes of this routine, only the facility <name>
    4103              :     //   is used.  Remember that 'Building' is actually the sum of
    4104              :     //   the zones only without system,plant and exterior. The only
    4105              :     //   way to get them all is to use 'facility'
    4106              :     //   The <EndUseType> are:
    4107              :     //          Heating
    4108              :     //          Cooling
    4109              :     //          InteriorLights
    4110              :     //          ExteriorLights
    4111              :     //          InteriorEquipment
    4112              :     //          ExteriorEquipment
    4113              :     //          Fans
    4114              :     //          Pumps
    4115              :     //          HeatRejection
    4116              :     //          Humidifier
    4117              :     //          HeatRecovery
    4118              :     //          Refrigeration
    4119              :     //          Cogeneration
    4120              :     //          WaterSystems
    4121              :     //   The <ResourceType> are:
    4122              :     //          Electricity
    4123              :     //          Gas
    4124              :     //          Gasoline
    4125              :     //          Diesel
    4126              :     //          Coal
    4127              :     //          FuelOilNo1
    4128              :     //          FuelOilNo2
    4129              :     //          Propane
    4130              :     //          Water
    4131              :     //          DistrictCooling
    4132              :     //          DistrictHeatingWater
    4133              :     //          DistrictHeatingSteam
    4134              : 
    4135              :     // REFERENCES:
    4136              :     // na
    4137              : 
    4138              :     // Using/Aliasing
    4139              :     using DataStringGlobals::CharComma;
    4140              :     using DataStringGlobals::CharSpace;
    4141              :     using DataStringGlobals::CharTab;
    4142              :     using General::EncodeMonDayHrMin;
    4143              : 
    4144              :     // Locals
    4145              :     // SUBROUTINE ARGUMENT DEFINITIONS:
    4146              : 
    4147              :     // SUBROUTINE PARAMETER DEFINITIONS:
    4148              :     // na
    4149              : 
    4150              :     // INTERFACE BLOCK SPECIFICATIONS:
    4151              :     // na
    4152              : 
    4153              :     // DERIVED TYPE DEFINITIONS:
    4154              :     // na
    4155              : 
    4156              :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
    4157           17 :     assert(state.dataGlobal->TimeStepZoneSec > 0.0);
    4158           17 :     auto &ort = state.dataOutRptTab;
    4159           17 :     auto &op = state.dataOutputProcessor;
    4160              : 
    4161           17 :     if ((ort->displayDemandEndUse) && (t_timeStepType == OutputProcessor::TimeStepType::Zone)) {
    4162              :         // loop through all of the resources and end uses for the entire facility
    4163          225 :         for (int iResource = 1; iResource <= numResourceTypes; ++iResource) {
    4164          210 :             int curMeterNumber = ort->meterNumTotalsBEPS(iResource);
    4165          210 :             if (curMeterNumber > -1) {
    4166           44 :                 Real64 curDemandValue = GetCurrentMeterValue(state, curMeterNumber) / state.dataGlobal->TimeStepZoneSec;
    4167              :                 // check if current value is greater than existing peak demand value
    4168           44 :                 if (curDemandValue > ort->gatherDemandTotal(iResource)) {
    4169           17 :                     ort->gatherDemandTotal(iResource) = curDemandValue;
    4170              :                     // save the time that the peak demand occurred
    4171              :                     //        minuteCalculated = (CurrentTime - INT(CurrentTime))*60
    4172           17 :                     int const minuteCalculated = OutputProcessor::DetermineMinuteForReporting(state);
    4173              :                     int timestepTimeStamp;
    4174           17 :                     EncodeMonDayHrMin(
    4175           17 :                         timestepTimeStamp, state.dataEnvrn->Month, state.dataEnvrn->DayOfMonth, state.dataGlobal->HourOfDay, minuteCalculated);
    4176           17 :                     ort->gatherDemandTimeStamp(iResource) = timestepTimeStamp;
    4177              :                     // if new peak demand is set, then gather all of the end use values at this particular
    4178              :                     // time to find the components of the peak demand
    4179          255 :                     for (int jEndUse = 1; jEndUse <= static_cast<int>(Constant::EndUse::Num); ++jEndUse) {
    4180          238 :                         curMeterNumber = ort->meterNumEndUseBEPS(iResource, jEndUse);
    4181          238 :                         if (curMeterNumber > -1) {
    4182           17 :                             curDemandValue = GetCurrentMeterValue(state, curMeterNumber) / state.dataGlobal->TimeStepZoneSec;
    4183           17 :                             ort->gatherDemandEndUse(iResource, jEndUse) = curDemandValue;
    4184           37 :                             for (int kEndUseSub = 1; kEndUseSub <= op->EndUseCategory(jEndUse).NumSubcategories; ++kEndUseSub) {
    4185           20 :                                 curMeterNumber = ort->meterNumEndUseSubBEPS(kEndUseSub, jEndUse, iResource);
    4186           20 :                                 if (curMeterNumber > -1) {
    4187           20 :                                     curDemandValue = GetCurrentMeterValue(state, curMeterNumber) / state.dataGlobal->TimeStepZoneSec;
    4188           20 :                                     ort->gatherDemandEndUseSub(kEndUseSub, jEndUse, iResource) = curDemandValue;
    4189              :                                 }
    4190              :                             }
    4191              :                         }
    4192              :                     }
    4193              :                 }
    4194              :             }
    4195              :         }
    4196              :     }
    4197              : 
    4198              :     // gather the peak demands of each individual enduse subcategory for the LEED report
    4199           17 :     if ((ort->displayLEEDSummary) && (t_timeStepType == OutputProcessor::TimeStepType::Zone)) {
    4200              :         // loop through all of the resources and end uses for the entire facility
    4201          225 :         for (int iResource = 1; iResource <= numResourceTypes; ++iResource) {
    4202         3150 :             for (int jEndUse = 1; jEndUse <= static_cast<int>(Constant::EndUse::Num); ++jEndUse) {
    4203         2940 :                 int curMeterNumber = ort->meterNumEndUseBEPS(iResource, jEndUse);
    4204         2940 :                 if (curMeterNumber > -1) {
    4205           44 :                     Real64 curDemandValue = GetCurrentMeterValue(state, curMeterNumber) / state.dataGlobal->TimeStepZoneSec;
    4206           44 :                     if (curDemandValue > ort->gatherDemandIndEndUse(iResource, jEndUse)) {
    4207           17 :                         ort->gatherDemandIndEndUse(iResource, jEndUse) = curDemandValue;
    4208              :                     }
    4209           97 :                     for (int kEndUseSub = 1; kEndUseSub <= op->EndUseCategory(jEndUse).NumSubcategories; ++kEndUseSub) {
    4210           53 :                         curMeterNumber = ort->meterNumEndUseSubBEPS(kEndUseSub, jEndUse, iResource);
    4211           53 :                         if (curMeterNumber > -1) {
    4212           53 :                             curDemandValue = GetCurrentMeterValue(state, curMeterNumber) / state.dataGlobal->TimeStepZoneSec;
    4213              :                             // check if current value is greater than existing peak demand value
    4214           53 :                             if (curDemandValue > ort->gatherDemandIndEndUseSub(kEndUseSub, jEndUse, iResource)) {
    4215           20 :                                 ort->gatherDemandIndEndUseSub(kEndUseSub, jEndUse, iResource) = curDemandValue;
    4216              :                             }
    4217              :                         }
    4218              :                     }
    4219              :                 }
    4220              :             }
    4221              :         }
    4222              :     }
    4223           17 : }
    4224              : 
    4225            5 : void GatherHeatEmissionReport(EnergyPlusData &state, OutputProcessor::TimeStepType t_timeStepType)
    4226              : {
    4227              :     // PURPOSE OF THIS SUBROUTINE:
    4228              :     // Gathers the data each zone timestep for the heat gain report.
    4229              :     // The routine generates an annual table with the following columns which correspond to
    4230              :     // the output variables and data structures shown.
    4231              : 
    4232            5 :     state.dataHeatBal->SysTotalHVACReliefHeatLoss = 0;
    4233            5 :     state.dataHeatBal->SysTotalHVACRejectHeatLoss = 0;
    4234            5 :     auto const &ort = state.dataOutRptTab;
    4235              : 
    4236            5 :     if (!ort->displayHeatEmissionsSummary) {
    4237            0 :         return; // don't gather data if report isn't requested
    4238              :     }
    4239              : 
    4240              :     // Only gather zone report at zone time steps
    4241            5 :     if (t_timeStepType == OutputProcessor::TimeStepType::Zone) {
    4242            0 :         state.dataHeatBal->BuildingPreDefRep.emiEnvelopConv += state.dataHeatBalSurf->SumSurfaceHeatEmission * Constant::convertJtoGJ;
    4243            0 :         return;
    4244              :     }
    4245              : 
    4246            5 :     CalcHeatEmissionReport(state);
    4247            5 :     state.dataHeatBal->BuildingPreDefRep.emiZoneExfiltration += state.dataHeatBal->ZoneTotalExfiltrationHeatLoss * Constant::convertJtoGJ;
    4248            5 :     state.dataHeatBal->BuildingPreDefRep.emiZoneExhaust += state.dataHeatBal->ZoneTotalExhaustHeatLoss * Constant::convertJtoGJ;
    4249            5 :     state.dataHeatBal->BuildingPreDefRep.emiHVACRelief += state.dataHeatBal->SysTotalHVACReliefHeatLoss * Constant::convertJtoGJ;
    4250            5 :     state.dataHeatBal->BuildingPreDefRep.emiHVACReject += state.dataHeatBal->SysTotalHVACRejectHeatLoss * Constant::convertJtoGJ;
    4251              : 
    4252            5 :     state.dataHeatBal->BuildingPreDefRep.emiTotHeat =
    4253            5 :         state.dataHeatBal->BuildingPreDefRep.emiEnvelopConv + state.dataHeatBal->BuildingPreDefRep.emiZoneExfiltration +
    4254            5 :         state.dataHeatBal->BuildingPreDefRep.emiZoneExhaust + state.dataHeatBal->BuildingPreDefRep.emiHVACRelief +
    4255            5 :         state.dataHeatBal->BuildingPreDefRep.emiHVACReject;
    4256              : }
    4257              : 
    4258        71337 : void CalcHeatEmissionReport(EnergyPlusData &state)
    4259              : {
    4260              :     // PURPOSE OF THIS SUBROUTINE:
    4261              :     // Gathers the data each zone timestep for the heat gain report.
    4262              :     // The routine generates an annual table with the following columns which correspond to
    4263              :     // the output variables and data structures shown.
    4264              : 
    4265              :     // Using/Aliasing
    4266        71337 :     Real64 const TimeStepSysSec = state.dataHVACGlobal->TimeStepSysSec;
    4267              : 
    4268        71337 :     Real64 H2OHtOfVap_HVAC = Psychrometrics::PsyHgAirFnWTdb(state.dataEnvrn->OutHumRat, state.dataEnvrn->OutDryBulbTemp);
    4269        71337 :     Real64 RhoWater = Psychrometrics::RhoH2O(state.dataEnvrn->OutDryBulbTemp);
    4270              : 
    4271        71337 :     state.dataHeatBal->SysTotalHVACReliefHeatLoss = 0;
    4272        71337 :     state.dataHeatBal->SysTotalHVACRejectHeatLoss = 0;
    4273              : 
    4274              :     // HVAC relief air
    4275        73682 :     for (int iOACtrl = 1; iOACtrl <= state.dataMixedAir->NumOAControllers; ++iOACtrl) {
    4276         2345 :         state.dataHeatBal->SysTotalHVACReliefHeatLoss += state.dataMixedAir->OAController(iOACtrl).RelTotalLossRate * TimeStepSysSec;
    4277              :     }
    4278              : 
    4279              :     // Airloop HVAC Exhaust System
    4280        71337 :     for (int iExhSys = 1; iExhSys < state.dataZoneEquip->NumExhaustAirSystems; ++iExhSys) {
    4281            0 :         state.dataHeatBal->SysTotalHVACReliefHeatLoss += state.dataZoneEquip->ExhaustAirSystem(iExhSys).exhTotalHVACReliefHeatLoss;
    4282              :     }
    4283              : 
    4284              :     // Condenser water loop
    4285        71340 :     for (int iCooler = 1; iCooler <= (int)state.dataCondenserLoopTowers->towers.size(); ++iCooler) {
    4286            6 :         state.dataHeatBal->SysTotalHVACRejectHeatLoss += state.dataCondenserLoopTowers->towers(iCooler).Qactual * TimeStepSysSec +
    4287            3 :                                                          state.dataCondenserLoopTowers->towers(iCooler).FanEnergy +
    4288            3 :                                                          state.dataCondenserLoopTowers->towers(iCooler).BasinHeaterConsumption;
    4289              :     }
    4290        71337 :     for (auto const &thisCooler : state.dataEvapFluidCoolers->SimpleEvapFluidCooler) {
    4291            0 :         state.dataHeatBal->SysTotalHVACRejectHeatLoss += thisCooler.Qactual * TimeStepSysSec + thisCooler.FanEnergy;
    4292              :     }
    4293        71337 :     for (auto const &cooler : state.dataFluidCoolers->SimpleFluidCooler) {
    4294            0 :         state.dataHeatBal->SysTotalHVACRejectHeatLoss += cooler.Qactual * TimeStepSysSec + cooler.FanEnergy;
    4295              :     }
    4296              : 
    4297              :     // Air- and Evap-cooled chiller
    4298        71337 :     for (int iChiller = 1; iChiller <= state.dataPlantChillers->NumElectricChillers; ++iChiller) {
    4299            0 :         auto const &thisChiller = state.dataPlantChillers->ElectricChiller(iChiller);
    4300              : 
    4301            0 :         if (thisChiller.CondenserType != DataPlant::CondenserType::WaterCooled) {
    4302            0 :             state.dataHeatBal->SysTotalHVACRejectHeatLoss += thisChiller.CondenserEnergy;
    4303              :         }
    4304              :     }
    4305        71337 :     for (int iChiller = 1; iChiller <= state.dataPlantChillers->NumEngineDrivenChillers; ++iChiller) {
    4306            0 :         auto const &thisChiller = state.dataPlantChillers->EngineDrivenChiller(iChiller);
    4307              : 
    4308            0 :         if (thisChiller.CondenserType != DataPlant::CondenserType::WaterCooled) {
    4309            0 :             state.dataHeatBal->SysTotalHVACRejectHeatLoss += thisChiller.CondenserEnergy;
    4310              :         }
    4311              :     }
    4312        71337 :     for (int iChiller = 1; iChiller <= state.dataPlantChillers->NumGTChillers; ++iChiller) {
    4313            0 :         auto const &thisChiller = state.dataPlantChillers->GTChiller(iChiller);
    4314              : 
    4315            0 :         if (thisChiller.CondenserType != DataPlant::CondenserType::WaterCooled) {
    4316            0 :             state.dataHeatBal->SysTotalHVACRejectHeatLoss += thisChiller.CondenserEnergy;
    4317              :         }
    4318              :     }
    4319        71337 :     for (int iChiller = 1; iChiller <= state.dataPlantChillers->NumConstCOPChillers; ++iChiller) {
    4320            0 :         auto const &thisChiller = state.dataPlantChillers->ConstCOPChiller(iChiller);
    4321              : 
    4322            0 :         if (thisChiller.CondenserType != DataPlant::CondenserType::WaterCooled) {
    4323            0 :             state.dataHeatBal->SysTotalHVACRejectHeatLoss += thisChiller.CondenserEnergy;
    4324              :         }
    4325              :     }
    4326              : 
    4327        71337 :     for (int iChiller = 1; iChiller <= (int)state.dataChillerElectricEIR->ElectricEIRChiller.size(); ++iChiller) {
    4328            0 :         auto const &thisChiller = state.dataChillerElectricEIR->ElectricEIRChiller(iChiller);
    4329              : 
    4330            0 :         if (thisChiller.CondenserType != DataPlant::CondenserType::WaterCooled) {
    4331            0 :             state.dataHeatBal->SysTotalHVACRejectHeatLoss += thisChiller.CondEnergy;
    4332              :         }
    4333              :     }
    4334        71337 :     for (int iChiller = 1; iChiller <= (int)state.dataChillerReformulatedEIR->ElecReformEIRChiller.size(); ++iChiller) {
    4335            0 :         auto const &thisChiller = state.dataChillerReformulatedEIR->ElecReformEIRChiller(iChiller);
    4336              : 
    4337            0 :         if (thisChiller.CondenserType != DataPlant::CondenserType::WaterCooled) {
    4338            0 :             state.dataHeatBal->SysTotalHVACRejectHeatLoss += thisChiller.CondEnergy;
    4339              :         }
    4340              :     }
    4341              : 
    4342              :     // Water / steam boiler
    4343        71337 :     for (int iBoiler = 1; iBoiler <= (int)state.dataBoilers->Boiler.size(); ++iBoiler) {
    4344            0 :         state.dataHeatBal->SysTotalHVACRejectHeatLoss +=
    4345            0 :             state.dataBoilers->Boiler(iBoiler).FuelConsumed + state.dataBoilers->Boiler(iBoiler).ParasiticFuelConsumption +
    4346            0 :             state.dataBoilers->Boiler(iBoiler).ParasiticElecConsumption - state.dataBoilers->Boiler(iBoiler).BoilerEnergy;
    4347              :     }
    4348              : 
    4349              :     // DX Coils air to air
    4350        75260 :     for (int iCoil = 1; iCoil <= state.dataDXCoils->NumDXCoils; ++iCoil) {
    4351         3923 :         auto const &thisDXCoil = state.dataDXCoils->DXCoil(iCoil);
    4352              : 
    4353         3923 :         if (thisDXCoil.DXCoilType_Num == HVAC::CoilDX_CoolingSingleSpeed || thisDXCoil.DXCoilType_Num == HVAC::CoilDX_CoolingTwoSpeed ||
    4354            4 :             thisDXCoil.DXCoilType_Num == HVAC::CoilDX_MultiSpeedCooling || thisDXCoil.DXCoilType_Num == HVAC::CoilDX_CoolingTwoStageWHumControl) {
    4355         3921 :             if (thisDXCoil.CondenserType(1) == DataHeatBalance::RefrigCondenserType::Air) {
    4356         3147 :                 state.dataHeatBal->SysTotalHVACRejectHeatLoss += thisDXCoil.ElecCoolingConsumption + thisDXCoil.DefrostConsumption +
    4357         3147 :                                                                  thisDXCoil.CrankcaseHeaterConsumption + thisDXCoil.TotalCoolingEnergy;
    4358          774 :             } else if (thisDXCoil.CondenserType(1) == DataHeatBalance::RefrigCondenserType::Evap) {
    4359          774 :                 state.dataHeatBal->SysTotalHVACRejectHeatLoss += thisDXCoil.EvapCondPumpElecConsumption + thisDXCoil.BasinHeaterConsumption +
    4360          774 :                                                                  thisDXCoil.EvapWaterConsump * RhoWater * H2OHtOfVap_HVAC;
    4361              :             }
    4362         3921 :             if (thisDXCoil.FuelType != Constant::eFuel::Electricity) {
    4363         3921 :                 state.dataHeatBal->SysTotalHVACRejectHeatLoss += thisDXCoil.MSFuelWasteHeat * TimeStepSysSec;
    4364              :             }
    4365            2 :         } else if (thisDXCoil.DXCoilType_Num == HVAC::CoilDX_HeatingEmpirical || thisDXCoil.DXCoilType_Num == HVAC::CoilDX_MultiSpeedHeating) {
    4366            2 :             state.dataHeatBal->SysTotalHVACRejectHeatLoss += thisDXCoil.ElecHeatingConsumption + thisDXCoil.DefrostConsumption +
    4367            2 :                                                              thisDXCoil.FuelConsumed + thisDXCoil.CrankcaseHeaterConsumption -
    4368            2 :                                                              thisDXCoil.TotalHeatingEnergy;
    4369              :         }
    4370              :     }
    4371              :     // VAV coils - air to air
    4372        71337 :     for (int iCoil = 1; iCoil <= state.dataVariableSpeedCoils->NumVarSpeedCoils; ++iCoil) {
    4373            0 :         auto const &thisCoil = state.dataVariableSpeedCoils->VarSpeedCoil(iCoil);
    4374              : 
    4375            0 :         if (thisCoil.VSCoilType == HVAC::Coil_CoolingAirToAirVariableSpeed) {
    4376            0 :             if (thisCoil.CondenserType == DataHeatBalance::RefrigCondenserType::Air) {
    4377            0 :                 state.dataHeatBal->SysTotalHVACRejectHeatLoss +=
    4378            0 :                     thisCoil.Energy + thisCoil.CrankcaseHeaterConsumption + thisCoil.DefrostConsumption + thisCoil.EnergyLoadTotal;
    4379            0 :             } else if (thisCoil.CondenserType == DataHeatBalance::RefrigCondenserType::Evap) {
    4380            0 :                 state.dataHeatBal->SysTotalHVACRejectHeatLoss +=
    4381            0 :                     thisCoil.EvapCondPumpElecConsumption + thisCoil.BasinHeaterConsumption + thisCoil.EvapWaterConsump * RhoWater * H2OHtOfVap_HVAC;
    4382              :             }
    4383            0 :         } else if (thisCoil.VSCoilType == HVAC::Coil_HeatingAirToAirVariableSpeed) {
    4384            0 :             state.dataHeatBal->SysTotalHVACRejectHeatLoss +=
    4385            0 :                 thisCoil.Energy + thisCoil.CrankcaseHeaterConsumption + thisCoil.DefrostConsumption - thisCoil.EnergyLoadTotal;
    4386              :         }
    4387              :     }
    4388              : 
    4389              :     // Heating coils - fuel
    4390        73676 :     for (int iCoil = 1; iCoil <= state.dataHeatingCoils->NumHeatingCoils; ++iCoil) {
    4391         2339 :         auto const &thisCoil = state.dataHeatingCoils->HeatingCoil(iCoil);
    4392              : 
    4393         2339 :         if (thisCoil.HCoilType_Num == HVAC::Coil_HeatingGas_MultiStage || thisCoil.HCoilType_Num == HVAC::Coil_HeatingGasOrOtherFuel) {
    4394          774 :             state.dataHeatBal->SysTotalHVACRejectHeatLoss += thisCoil.FuelUseLoad + thisCoil.ParasiticFuelConsumption - thisCoil.HeatingCoilLoad;
    4395              :         }
    4396              :     }
    4397              : 
    4398              :     // Packaged TES
    4399        71337 :     for (int iCoil = 1; iCoil <= state.dataPackagedThermalStorageCoil->NumTESCoils; ++iCoil) {
    4400            0 :         auto const &thisCoil = state.dataPackagedThermalStorageCoil->TESCoil(iCoil);
    4401              : 
    4402            0 :         if (thisCoil.CondenserType == PackagedThermalStorageCoil::TESCondenserType::Air) {
    4403            0 :             state.dataHeatBal->SysTotalHVACRejectHeatLoss +=
    4404            0 :                 thisCoil.EvapTotCoolingEnergy + thisCoil.ElecCoolingEnergy + thisCoil.ElectColdWeatherEnergy - thisCoil.Q_Ambient;
    4405            0 :         } else if (thisCoil.CondenserType == PackagedThermalStorageCoil::TESCondenserType::Evap) {
    4406            0 :             state.dataHeatBal->SysTotalHVACRejectHeatLoss += thisCoil.EvapCondPumpElecConsumption + thisCoil.ElectEvapCondBasinHeaterEnergy +
    4407            0 :                                                              thisCoil.EvapWaterConsump * RhoWater * H2OHtOfVap_HVAC - thisCoil.Q_Ambient;
    4408              :         }
    4409              :     }
    4410              : 
    4411              :     // Water heater and thermal storage
    4412        71337 :     for (int iTank = 1; iTank <= state.dataWaterThermalTanks->numWaterThermalTank; ++iTank) {
    4413            0 :         auto const &thisTank = state.dataWaterThermalTanks->WaterThermalTank(iTank);
    4414              : 
    4415            0 :         if (thisTank.AmbientTempIndicator == WaterThermalTanks::WTTAmbientTemp::OutsideAir) {
    4416            0 :             state.dataHeatBal->SysTotalHVACRejectHeatLoss += thisTank.FuelEnergy - thisTank.TotalDemandEnergy;
    4417              :         }
    4418              :     }
    4419              : 
    4420              :     // Variable Refrigerant Flow
    4421        71337 :     for (int iCoil = 1; iCoil <= state.dataHVACVarRefFlow->NumVRFCond; ++iCoil) {
    4422            0 :         auto const &thisVRF = state.dataHVACVarRefFlow->VRF(iCoil);
    4423              : 
    4424            0 :         if (thisVRF.CondenserType == DataHeatBalance::RefrigCondenserType::Air) {
    4425            0 :             state.dataHeatBal->SysTotalHVACRejectHeatLoss += thisVRF.CoolElecConsumption + thisVRF.HeatElecConsumption +
    4426            0 :                                                              thisVRF.CrankCaseHeaterElecConsumption + thisVRF.DefrostConsumption +
    4427            0 :                                                              (thisVRF.TotalCoolingCapacity - thisVRF.TotalHeatingCapacity) * TimeStepSysSec;
    4428            0 :         } else if (thisVRF.CondenserType == DataHeatBalance::RefrigCondenserType::Evap) {
    4429            0 :             state.dataHeatBal->SysTotalHVACRejectHeatLoss += thisVRF.EvapCondPumpElecConsumption + thisVRF.BasinHeaterConsumption +
    4430            0 :                                                              thisVRF.EvapWaterConsumpRate * TimeStepSysSec * RhoWater * H2OHtOfVap_HVAC;
    4431            0 :         } else if (thisVRF.CondenserType == DataHeatBalance::RefrigCondenserType::Water) {
    4432            0 :             state.dataHeatBal->SysTotalHVACRejectHeatLoss += thisVRF.QCondEnergy;
    4433              :         }
    4434              :     }
    4435              : 
    4436              :     // Refrigerated Rack
    4437        71337 :     for (int iRef = 1; iRef <= state.dataRefrigCase->NumRefrigeratedRacks; ++iRef) {
    4438            0 :         auto const &thisRack = state.dataRefrigCase->RefrigRack(iRef);
    4439              : 
    4440            0 :         if (thisRack.CondenserType == DataHeatBalance::RefrigCondenserType::Air) {
    4441            0 :             state.dataHeatBal->SysTotalHVACRejectHeatLoss += thisRack.RackElecConsumption + thisRack.RackCoolingEnergy;
    4442            0 :         } else if (thisRack.CondenserType == DataHeatBalance::RefrigCondenserType::Evap) {
    4443            0 :             state.dataHeatBal->SysTotalHVACRejectHeatLoss +=
    4444            0 :                 thisRack.EvapPumpConsumption + thisRack.BasinHeaterConsumption + thisRack.EvapWaterConsumption * RhoWater * H2OHtOfVap_HVAC;
    4445            0 :         } else if (thisRack.CondenserType == DataHeatBalance::RefrigCondenserType::Water) {
    4446            0 :             state.dataHeatBal->SysTotalHVACRejectHeatLoss += thisRack.CondEnergy;
    4447              :         }
    4448              :     }
    4449              : 
    4450              :     // Refrigerated Case - Condenser
    4451        71337 :     for (int iRef = 1; iRef <= state.dataRefrigCase->NumRefrigCondensers; ++iRef) {
    4452            0 :         state.dataHeatBal->SysTotalHVACRejectHeatLoss += state.dataRefrigCase->Condenser(iRef).CondEnergy;
    4453              :     }
    4454              : 
    4455              :     // Evaporative coolers
    4456        71337 :     for (int iCooler = 1; iCooler <= state.dataEvapCoolers->NumEvapCool; ++iCooler) {
    4457            0 :         auto const &thisCooler = state.dataEvapCoolers->EvapCond(iCooler);
    4458              : 
    4459            0 :         state.dataHeatBal->SysTotalHVACRejectHeatLoss += thisCooler.EvapWaterConsump * RhoWater * H2OHtOfVap_HVAC + thisCooler.EvapCoolerEnergy;
    4460              :     }
    4461        71337 : }
    4462              : 
    4463            3 : void GatherHeatGainReport(EnergyPlusData &state, OutputProcessor::TimeStepType t_timeStepType) // What kind of data to update (Zone, HVAC)
    4464              : {
    4465              :     // SUBROUTINE INFORMATION:
    4466              :     //       AUTHOR         Jason Glazer
    4467              :     //       DATE WRITTEN   August 2011
    4468              :     //       MODIFIED       na
    4469              :     //       RE-ENGINEERED  na
    4470              : 
    4471              :     // PURPOSE OF THIS SUBROUTINE:
    4472              :     //   Gathers the data each zone timestep for the heat gain report.
    4473              :     // The routine generates an annual table with the following columns which correspond to
    4474              :     // the output variables and data structures shown:
    4475              :     // Column                               Output Variable                                Internal Data Structure      Timestep Type
    4476              :     // ------                               ---------------                                -----------------------      -------- -----
    4477              :     // HVAC Input Sensible Air Heating      Zone Air Heat Balance System Air Transfer Rate ZnAirRpt()%SumMCpDTsystem    HVAC     Rate
    4478              :     //                                   Zone Air Heat Balance System Convective Heat Gain Rate ZnAirRpt()%SumNonAirSystem HVAC   Rate
    4479              :     // HVAC Input Sensible Air Cooling      Zone Air Heat Balance System Air Transfer Rate ZnAirRpt()%SumMCpDTsystem    HVAC     Rate
    4480              :     // HVAC sensible heating by ATU         sensible heating by the air terminal unit                                   HVAC     Rate
    4481              :     // HVAC sensible cooling by ATU         sensible cooling by the air terminal unit                                   HVAC     Rate
    4482              :     //                                    Zone Air Heat Balance System Convective Heat Gain Rate ZnAirRpt()%SumNonAirSystem HVAC  Rate
    4483              :     // HVAC Input Heated Surface Heating    Electric Low Temp Radiant Heating Energy       ElecRadSys()%HeatEnergy      HVAC     Energy
    4484              :     //                                      Zone Ventilated Slab Radiant Heating Energy    VentSlab()%RadHeatingEnergy  HVAC     Energy
    4485              :     //                                      Hydronic Low Temp Radiant Heating Energy       HydrRadSys()%HeatEnergy      HVAC     Energy
    4486              :     //                                      Constant Flow Low Temp Radiant Heating Energy  CFloRadSys()%HeatEnergy      HVAC     Energy
    4487              :     // HVAC Input Cooled Surface Cooling    Zone Ventilated Slab Radiant Cooling Energy    -VentSlab()%RadCoolingEnergy HVAC     Energy
    4488              :     //                                      Hydronic Low Temp Radiant Cooling Energy       -HydrRadSys()%CoolEnergy     HVAC     Energy
    4489              :     //                                      Constant Flow Low Temp Radiant Cooling Energy  -CFloRadSys()%CoolEnergy     HVAC     Energy
    4490              :     // People Sensible Heat Addition        Zone People Sensible Heating Energy            ZoneRpt()%PeopleSenGain        Zone     Energy
    4491              :     // Lights Sensible Heat Addition        Zone Lights Total Heating Energy               ZoneRpt()%LtsTotGain           Zone     Energy
    4492              :     // Equipment Sensible Heat Addition     Zone Electric Equipment Radiant Heating Energy ZoneRpt()%ElecRadGain          Zone     Energy
    4493              :     //                                      Zone Gas Equipment Radiant Heating Energy      ZoneRpt()%GasRadGain           Zone     Energy
    4494              :     //                                      Zone Steam Equipment Radiant Heating Energy    ZoneRpt()%SteamRadGain         Zone     Energy
    4495              :     //                                      Zone Hot Water Equipment Radiant Heating Energy ZoneRpt()%HWRadGain           Zone     Energy
    4496              :     //                                      Zone Other Equipment Radiant Heating Energy    ZoneRpt()%OtherRadGain         Zone     Energy
    4497              :     //                                   Zone Electric Equipment Convective Heating Energy ZoneRpt()%ElecConGain          Zone     Energy
    4498              :     //                                      Zone Gas Equipment Convective Heating Energy   ZoneRpt()%GasConGain           Zone     Energy
    4499              :     //                                      Zone Steam Equipment Convective Heating Energy ZoneRpt()%SteamConGain         Zone     Energy
    4500              :     //                                    Zone Hot Water Equipment Convective Heating Energy ZoneRpt()%HWConGain          Zone     Energy
    4501              :     //                                      Zone Other Equipment Convective Heating Energy ZoneRpt()%OtherConGain         Zone     Energy
    4502              :     // Window Heat Addition                 Zone Windows Total Heat Gain Energy            ZoneWinHeatGainRepEnergy()   Zone     Energy
    4503              :     // Interzone Air Transfer Heat Addition Zone Air Heat Balance Interzone Air Transfer Rate  ZnAirRpt()%SumMCpDTzones HVAC     Rate
    4504              :     // Infiltration Heat Addition           Zone Air Heat Balance Outdoor Air Transfer Rate ZnAirRpt()%SumMCpDtInfil     HVAC     Rate
    4505              :     // Equipment Sensible Heat Removal      Zone Electric Equipment Radiant Heating Energy ZoneRpt()%ElecRadGain          Zone     Energy
    4506              :     //                                      Zone Gas Equipment Radiant Heating Energy      ZoneRpt()%GasRadGain           Zone     Energy
    4507              :     //                                      Zone Steam Equipment Radiant Heating Energy    ZoneRpt()%SteamRadGain         Zone     Energy
    4508              :     //                                      Zone Hot Water Equipment Radiant Heating Energy ZoneRpt()%HWRadGain           Zone     Energy
    4509              :     //                                      Zone Other Equipment Radiant Heating Energy    ZoneRpt()%OtherRadGain         Zone     Energy
    4510              :     //                                   Zone Electric Equipment Convective Heating Energy ZoneRpt()%ElecConGain          Zone     Energy
    4511              :     //                                      Zone Gas Equipment Convective Heating Energy   ZoneRpt()%GasConGain           Zone     Energy
    4512              :     //                                      Zone Steam Equipment Convective Heating Energy ZoneRpt()%SteamConGain         Zone     Energy
    4513              :     //                                     Zone Hot Water Equipment Convective Heating Energy ZoneRpt()%HWConGain         Zone     Energy
    4514              :     //                                      Zone Other Equipment Convective Heating Energy ZoneRpt()%OtherConGain         Zone     Energy
    4515              :     // Window Heat Removal                  Zone Windows Total Heat Loss Energy            -ZoneWinHeatLossRepEnergy()  Zone     Energy
    4516              :     // Interzone Air Transfer Heat Removal  Zone Air Heat Balance Interzone Air Transfer Rate ZnAirRpt()%SumMCpDTzones  HVAC     Rate
    4517              :     // Infiltration Heat Removal            Zone Air Heat Balance Outdoor Air Transfer Rate ZnAirRpt()%SumMCpDtInfil     HVAC     Rate
    4518              :     // The following two columns are derived based on the values of the other columns and need to be computed on every HVAC timestep.
    4519              :     //   Opaque Surface Conduction and Other Heat Addition
    4520              :     //   Opaque Surface Conduction and Other Heat Removal
    4521              :     // For variables that are updated on a zone timestep basis, the values are used on the HVAC timestep but are ratio-ed by the
    4522              :     // timestep lengths.
    4523              :     // The peak reports follow a similar example.
    4524              : 
    4525              :     // Using/Aliasing
    4526            3 :     Real64 const TimeStepSysSec = state.dataHVACGlobal->TimeStepSysSec;
    4527              : 
    4528              :     using General::EncodeMonDayHrMin;
    4529              : 
    4530            3 :     auto &Zone = state.dataHeatBal->Zone;
    4531            3 :     auto &ZonePreDefRep = state.dataHeatBal->ZonePreDefRep;
    4532              : 
    4533            3 :     if (!state.dataGlobal->DoWeathSim) {
    4534            0 :         return;
    4535              :     }
    4536              : 
    4537            3 :     if (!state.dataOutRptPredefined->reportName(state.dataOutRptPredefined->pdrSensibleGain).show)
    4538            0 :         return; // don't gather data if report isn't requested
    4539              : 
    4540            3 :     if (t_timeStepType == OutputProcessor::TimeStepType::Zone) {
    4541            0 :         return; // only add values over the HVAC timestep basis
    4542              :     }
    4543              : 
    4544            3 :     auto &ort = state.dataOutRptTab;
    4545              : 
    4546            3 :     if (ort->GatherHeatGainReportfirstTime) {
    4547            3 :         state.dataOutRptTab->radiantHeat.allocate(state.dataGlobal->NumOfZones);
    4548            3 :         state.dataOutRptTab->radiantCool.allocate(state.dataGlobal->NumOfZones);
    4549            3 :         state.dataOutRptTab->ATUHeat.allocate(state.dataGlobal->NumOfZones);
    4550            3 :         state.dataOutRptTab->ATUCool.allocate(state.dataGlobal->NumOfZones);
    4551            3 :         ort->GatherHeatGainReportfirstTime = false;
    4552              :     }
    4553              :     // clear the radiant surface accumulation variables
    4554            3 :     state.dataOutRptTab->radiantHeat = 0.0;
    4555            3 :     state.dataOutRptTab->radiantCool = 0.0;
    4556              :     // clear the ATU accumulation variables
    4557            3 :     state.dataOutRptTab->ATUHeat = 0.0;
    4558            3 :     state.dataOutRptTab->ATUCool = 0.0;
    4559              :     //--------------------
    4560              :     //     ANNUAL
    4561              :     //--------------------
    4562              :     // HVAC annual heating by ATU
    4563              :     // HVAC annual cooling by ATU
    4564            6 :     for (state.dataOutRptTab->iunitGHGR = 1; state.dataOutRptTab->iunitGHGR <= (int)state.dataDefineEquipment->AirDistUnit.size();
    4565            3 :          ++state.dataOutRptTab->iunitGHGR) {
    4566              :         // HVAC equipment should already have the multipliers included, no "* mult" needed (assumes autosized or multiplied hard-sized air flow).
    4567            3 :         state.dataOutRptTab->curZoneGHGR = state.dataDefineEquipment->AirDistUnit(state.dataOutRptTab->iunitGHGR).ZoneNum;
    4568            3 :         if ((state.dataOutRptTab->curZoneGHGR > 0) && (state.dataOutRptTab->curZoneGHGR <= state.dataGlobal->NumOfZones)) {
    4569            3 :             ZonePreDefRep(state.dataOutRptTab->curZoneGHGR).SHGSAnHvacATUHt +=
    4570            3 :                 state.dataDefineEquipment->AirDistUnit(state.dataOutRptTab->iunitGHGR).HeatGain;
    4571            3 :             ZonePreDefRep(state.dataOutRptTab->curZoneGHGR).SHGSAnHvacATUCl -=
    4572            3 :                 state.dataDefineEquipment->AirDistUnit(state.dataOutRptTab->iunitGHGR).CoolGain;
    4573            3 :             state.dataOutRptTab->ATUHeat(state.dataOutRptTab->curZoneGHGR) +=
    4574            3 :                 state.dataDefineEquipment->AirDistUnit(state.dataOutRptTab->iunitGHGR).HeatRate;
    4575            3 :             state.dataOutRptTab->ATUCool(state.dataOutRptTab->curZoneGHGR) -=
    4576            3 :                 state.dataDefineEquipment->AirDistUnit(state.dataOutRptTab->iunitGHGR).CoolRate;
    4577              :         }
    4578              :     }
    4579              :     // the fraction of the zone time step used by the system timestep
    4580            3 :     state.dataOutRptTab->timeStepRatio = state.dataHVACGlobal->TimeStepSys / state.dataGlobal->TimeStepZone;
    4581            8 :     for (state.dataOutRptTab->iZoneGHGR = 1; state.dataOutRptTab->iZoneGHGR <= state.dataGlobal->NumOfZones; ++state.dataOutRptTab->iZoneGHGR) {
    4582            5 :         Real64 const mult = Zone(state.dataOutRptTab->iZoneGHGR).Multiplier * Zone(state.dataOutRptTab->iZoneGHGR).ListMultiplier;
    4583              :         // People Sensible Heat Addition
    4584            5 :         ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSAnPeoplAdd +=
    4585            5 :             state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).PeopleSenGain * mult * state.dataOutRptTab->timeStepRatio;
    4586              :         // Lights Sensible Heat Addition
    4587            5 :         ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSAnLiteAdd +=
    4588            5 :             state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).LtsTotGain * mult * state.dataOutRptTab->timeStepRatio;
    4589              :         // HVAC Input Sensible Air Heating
    4590              :         // HVAC Input Sensible Air Cooling
    4591            5 :         Real64 ZoneEqHeatorCool = state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDTsystem +
    4592            5 :                                   state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumNonAirSystem * mult -
    4593            5 :                                   state.dataOutRptTab->ATUHeat(state.dataOutRptTab->iZoneGHGR) -
    4594            5 :                                   state.dataOutRptTab->ATUCool(state.dataOutRptTab->iZoneGHGR);
    4595            5 :         if (ZoneEqHeatorCool > 0.0) {
    4596            1 :             ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSAnZoneEqHt += ZoneEqHeatorCool * TimeStepSysSec;
    4597              :         } else {
    4598            4 :             ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSAnZoneEqCl += ZoneEqHeatorCool * TimeStepSysSec;
    4599              :         }
    4600              :         // Interzone Air Transfer Heat Addition
    4601              :         // Interzone Air Transfer Heat Removal
    4602            5 :         if (state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDTzones > 0.0) {
    4603            0 :             ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSAnIzaAdd +=
    4604            0 :                 state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDTzones * mult * TimeStepSysSec;
    4605              :         } else {
    4606            5 :             ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSAnIzaRem +=
    4607            5 :                 state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDTzones * mult * TimeStepSysSec;
    4608              :         }
    4609              :         // Window Heat Addition
    4610              :         // Window Heat Removal
    4611            5 :         ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSAnWindAdd +=
    4612            5 :             state.dataHeatBal->ZoneWinHeatGainRepEnergy(state.dataOutRptTab->iZoneGHGR) * mult * state.dataOutRptTab->timeStepRatio;
    4613            5 :         ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSAnWindRem -=
    4614            5 :             state.dataHeatBal->ZoneWinHeatLossRepEnergy(state.dataOutRptTab->iZoneGHGR) * mult * state.dataOutRptTab->timeStepRatio;
    4615              :         // Infiltration Heat Addition
    4616              :         // Infiltration Heat Removal
    4617            5 :         if (state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDtInfil > 0.0) {
    4618            0 :             ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSAnInfilAdd +=
    4619            0 :                 state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDtInfil * mult * TimeStepSysSec;
    4620              :         } else {
    4621            5 :             ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSAnInfilRem +=
    4622            5 :                 state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDtInfil * mult * TimeStepSysSec;
    4623              :         }
    4624              :         // Equipment Sensible Heat Addition
    4625              :         // Equipment Sensible Heat Removal
    4626              :         // the following variables are already gains so they do not need to be converted by multiplying by time.
    4627            5 :         state.dataOutRptTab->eqpSensGHGR = (state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).ElecRadGain +
    4628            5 :                                             state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).GasRadGain +
    4629            5 :                                             state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).HWRadGain +
    4630            5 :                                             state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).SteamRadGain +
    4631            5 :                                             state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).OtherRadGain +
    4632            5 :                                             state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).ElecConGain +
    4633            5 :                                             state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).GasConGain +
    4634            5 :                                             state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).HWConGain +
    4635            5 :                                             state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).SteamConGain +
    4636            5 :                                             state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).OtherConGain) *
    4637            5 :                                            state.dataOutRptTab->timeStepRatio;
    4638            5 :         if (state.dataOutRptTab->eqpSensGHGR > 0.0) {
    4639            4 :             ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSAnEquipAdd += state.dataOutRptTab->eqpSensGHGR * mult;
    4640              :         } else {
    4641            1 :             ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSAnEquipRem += state.dataOutRptTab->eqpSensGHGR * mult;
    4642              :         }
    4643              :     }
    4644            3 :     state.dataOutRptTab->curZoneGHGR = 0;
    4645              :     // HVAC Input Heated Surface Heating
    4646              :     // HVAC Input Cooled Surface Cooling
    4647            3 :     for (state.dataOutRptTab->iRadiantGHGR = 1; state.dataOutRptTab->iRadiantGHGR <= state.dataVentilatedSlab->NumOfVentSlabs;
    4648            0 :          ++state.dataOutRptTab->iRadiantGHGR) {
    4649            0 :         state.dataOutRptTab->curZoneGHGR = state.dataVentilatedSlab->VentSlab(state.dataOutRptTab->iRadiantGHGR).ZonePtr;
    4650            0 :         Real64 const mult = Zone(state.dataOutRptTab->curZoneGHGR).Multiplier * Zone(state.dataOutRptTab->curZoneGHGR).ListMultiplier;
    4651            0 :         if ((state.dataOutRptTab->curZoneGHGR > 0) && (state.dataOutRptTab->curZoneGHGR <= state.dataGlobal->NumOfZones)) {
    4652            0 :             ZonePreDefRep(state.dataOutRptTab->curZoneGHGR).SHGSAnSurfHt +=
    4653            0 :                 state.dataVentilatedSlab->VentSlab(state.dataOutRptTab->iRadiantGHGR).RadHeatingEnergy * mult;
    4654            0 :             ZonePreDefRep(state.dataOutRptTab->curZoneGHGR).SHGSAnSurfCl -=
    4655            0 :                 state.dataVentilatedSlab->VentSlab(state.dataOutRptTab->iRadiantGHGR).RadCoolingEnergy * mult;
    4656            0 :             state.dataOutRptTab->radiantHeat(state.dataOutRptTab->curZoneGHGR) =
    4657            0 :                 state.dataVentilatedSlab->VentSlab(state.dataOutRptTab->iRadiantGHGR).RadHeatingPower * mult;
    4658            0 :             state.dataOutRptTab->radiantCool(state.dataOutRptTab->curZoneGHGR) =
    4659            0 :                 -state.dataVentilatedSlab->VentSlab(state.dataOutRptTab->iRadiantGHGR).RadCoolingPower * mult;
    4660              :         }
    4661              :     }
    4662            3 :     for (state.dataOutRptTab->iRadiantGHGR = 1; state.dataOutRptTab->iRadiantGHGR <= state.dataLowTempRadSys->NumOfHydrLowTempRadSys;
    4663            0 :          ++state.dataOutRptTab->iRadiantGHGR) {
    4664            0 :         state.dataOutRptTab->curZoneGHGR = state.dataLowTempRadSys->HydrRadSys(state.dataOutRptTab->iRadiantGHGR).ZonePtr;
    4665            0 :         Real64 const mult = Zone(state.dataOutRptTab->curZoneGHGR).Multiplier * Zone(state.dataOutRptTab->curZoneGHGR).ListMultiplier;
    4666            0 :         if ((state.dataOutRptTab->curZoneGHGR > 0) && (state.dataOutRptTab->curZoneGHGR <= state.dataGlobal->NumOfZones)) {
    4667            0 :             ZonePreDefRep(state.dataOutRptTab->curZoneGHGR).SHGSAnSurfHt +=
    4668            0 :                 state.dataLowTempRadSys->HydrRadSys(state.dataOutRptTab->iRadiantGHGR).HeatEnergy * mult;
    4669            0 :             ZonePreDefRep(state.dataOutRptTab->curZoneGHGR).SHGSAnSurfCl -=
    4670            0 :                 state.dataLowTempRadSys->HydrRadSys(state.dataOutRptTab->iRadiantGHGR).CoolEnergy * mult;
    4671            0 :             state.dataOutRptTab->radiantHeat(state.dataOutRptTab->curZoneGHGR) +=
    4672            0 :                 state.dataLowTempRadSys->HydrRadSys(state.dataOutRptTab->iRadiantGHGR).HeatPower * mult;
    4673            0 :             state.dataOutRptTab->radiantCool(state.dataOutRptTab->curZoneGHGR) -=
    4674            0 :                 state.dataLowTempRadSys->HydrRadSys(state.dataOutRptTab->iRadiantGHGR).CoolPower * mult;
    4675              :         }
    4676              :     }
    4677            3 :     for (state.dataOutRptTab->iRadiantGHGR = 1; state.dataOutRptTab->iRadiantGHGR <= state.dataLowTempRadSys->NumOfCFloLowTempRadSys;
    4678            0 :          ++state.dataOutRptTab->iRadiantGHGR) {
    4679            0 :         state.dataOutRptTab->curZoneGHGR = state.dataLowTempRadSys->CFloRadSys(state.dataOutRptTab->iRadiantGHGR).ZonePtr;
    4680            0 :         Real64 const mult = Zone(state.dataOutRptTab->curZoneGHGR).Multiplier * Zone(state.dataOutRptTab->curZoneGHGR).ListMultiplier;
    4681            0 :         if ((state.dataOutRptTab->curZoneGHGR > 0) && (state.dataOutRptTab->curZoneGHGR <= state.dataGlobal->NumOfZones)) {
    4682            0 :             ZonePreDefRep(state.dataOutRptTab->curZoneGHGR).SHGSAnSurfHt +=
    4683            0 :                 state.dataLowTempRadSys->CFloRadSys(state.dataOutRptTab->iRadiantGHGR).HeatEnergy * mult;
    4684            0 :             ZonePreDefRep(state.dataOutRptTab->curZoneGHGR).SHGSAnSurfCl -=
    4685            0 :                 state.dataLowTempRadSys->CFloRadSys(state.dataOutRptTab->iRadiantGHGR).CoolEnergy * mult;
    4686            0 :             state.dataOutRptTab->radiantHeat(state.dataOutRptTab->curZoneGHGR) +=
    4687            0 :                 state.dataLowTempRadSys->CFloRadSys(state.dataOutRptTab->iRadiantGHGR).HeatPower * mult;
    4688            0 :             state.dataOutRptTab->radiantCool(state.dataOutRptTab->curZoneGHGR) -=
    4689            0 :                 state.dataLowTempRadSys->CFloRadSys(state.dataOutRptTab->iRadiantGHGR).CoolPower * mult;
    4690              :         }
    4691              :     }
    4692            3 :     for (state.dataOutRptTab->iRadiantGHGR = 1; state.dataOutRptTab->iRadiantGHGR <= state.dataLowTempRadSys->NumOfElecLowTempRadSys;
    4693            0 :          ++state.dataOutRptTab->iRadiantGHGR) {
    4694            0 :         state.dataOutRptTab->curZoneGHGR = state.dataLowTempRadSys->ElecRadSys(state.dataOutRptTab->iRadiantGHGR).ZonePtr;
    4695            0 :         Real64 const mult = Zone(state.dataOutRptTab->curZoneGHGR).Multiplier * Zone(state.dataOutRptTab->curZoneGHGR).ListMultiplier;
    4696            0 :         if ((state.dataOutRptTab->curZoneGHGR > 0) && (state.dataOutRptTab->curZoneGHGR <= state.dataGlobal->NumOfZones)) {
    4697            0 :             ZonePreDefRep(state.dataOutRptTab->curZoneGHGR).SHGSAnSurfHt +=
    4698            0 :                 state.dataLowTempRadSys->ElecRadSys(state.dataOutRptTab->iRadiantGHGR).HeatEnergy * mult;
    4699            0 :             state.dataOutRptTab->radiantHeat(state.dataOutRptTab->curZoneGHGR) +=
    4700            0 :                 state.dataLowTempRadSys->ElecRadSys(state.dataOutRptTab->iRadiantGHGR).HeatPower * mult;
    4701              :         }
    4702              :     }
    4703              :     // Opaque Surface Conduction and Other Heat Addition
    4704              :     // Opaque Surface Conduction and Other Heat Removal
    4705            8 :     for (state.dataOutRptTab->iZoneGHGR = 1; state.dataOutRptTab->iZoneGHGR <= state.dataGlobal->NumOfZones; ++state.dataOutRptTab->iZoneGHGR) {
    4706              :         // ZonePreDefRep variables above already include zone list and group multipliers
    4707           10 :         state.dataOutRptTab->totalGHGR =
    4708            5 :             ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSAnPeoplAdd + ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSAnLiteAdd +
    4709            5 :             ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSAnZoneEqHt + ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSAnZoneEqCl +
    4710            5 :             ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSAnHvacATUHt + ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSAnHvacATUCl +
    4711            5 :             ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSAnIzaAdd + ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSAnIzaRem +
    4712            5 :             ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSAnWindAdd + ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSAnWindRem +
    4713            5 :             ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSAnInfilAdd + ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSAnInfilRem +
    4714            5 :             ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSAnEquipAdd + ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSAnEquipRem +
    4715            5 :             ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSAnSurfHt + ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSAnSurfCl;
    4716           10 :         state.dataOutRptTab->totalGHGR =
    4717            5 :             -state.dataOutRptTab->totalGHGR; // want to know the negative value of the sum since the row should add up to zero
    4718            5 :         if (state.dataOutRptTab->totalGHGR > 0) {
    4719            0 :             ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSAnOtherAdd = state.dataOutRptTab->totalGHGR;
    4720              :         } else {
    4721            5 :             ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSAnOtherRem = state.dataOutRptTab->totalGHGR;
    4722              :         }
    4723              :     }
    4724              :     //--------------------------------
    4725              :     // ZONE PEAK COOLING AND HEATING
    4726              :     //--------------------------------
    4727            8 :     for (state.dataOutRptTab->iZoneGHGR = 1; state.dataOutRptTab->iZoneGHGR <= state.dataGlobal->NumOfZones; ++state.dataOutRptTab->iZoneGHGR) {
    4728            5 :         Real64 const mult = Zone(state.dataOutRptTab->iZoneGHGR).Multiplier * Zone(state.dataOutRptTab->iZoneGHGR).ListMultiplier;
    4729              :         // RR I can't get the Infiltration Heat Addition/Removal columns to add up.
    4730              :         // THis is the only suspect line, mixing MCpDt terms and a power term looks fishy.
    4731            5 :         if ((state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDTsystem +
    4732            5 :              state.dataOutRptTab->radiantHeat(state.dataOutRptTab->iZoneGHGR) +
    4733            5 :              state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumNonAirSystem * mult) > 0) {
    4734            0 :             if ((state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDTsystem +
    4735            0 :                  state.dataOutRptTab->radiantHeat(state.dataOutRptTab->iZoneGHGR) +
    4736            0 :                  state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumNonAirSystem * mult) >
    4737            0 :                 ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).htPeak) {
    4738            0 :                 ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).htPeak =
    4739            0 :                     state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDTsystem +
    4740            0 :                     state.dataOutRptTab->radiantHeat(state.dataOutRptTab->iZoneGHGR) +
    4741            0 :                     state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumNonAirSystem * mult;
    4742              :                 // determine timestamp
    4743              :                 //      ActualTimeS = CurrentTime-TimeStepZone+SysTimeElapsed
    4744              :                 //      ActualtimeE = ActualTimeS+TimeStepSys
    4745              :                 //      ActualTimeHrS=INT(ActualTimeS)
    4746              :                 //      ActualTimeMin=NINT((ActualtimeE - ActualTimeHrS)*FracToMin)
    4747            0 :                 int const ActualTimeMin = OutputProcessor::DetermineMinuteForReporting(state);
    4748            0 :                 EncodeMonDayHrMin(state.dataOutRptTab->timestepTimeStampGHGR,
    4749            0 :                                   state.dataEnvrn->Month,
    4750            0 :                                   state.dataEnvrn->DayOfMonth,
    4751            0 :                                   state.dataGlobal->HourOfDay,
    4752              :                                   ActualTimeMin);
    4753            0 :                 ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).htPtTimeStamp = state.dataOutRptTab->timestepTimeStampGHGR;
    4754              :                 // HVAC Input Sensible Air Heating
    4755              :                 // HVAC Input Sensible Air Cooling
    4756              :                 // non-HVAC ZnAirRpt variables DO NOT include zone multipliers
    4757            0 :                 ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtHvacHt =
    4758            0 :                     state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDTsystem +
    4759            0 :                     state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumNonAirSystem * mult;
    4760            0 :                 ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtHvacCl = 0.0;
    4761              :                 // HVAC Input Heated Surface Heating
    4762              :                 // HVAC Input Cooled Surface Cooling
    4763            0 :                 ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtSurfHt =
    4764            0 :                     state.dataOutRptTab->radiantHeat(state.dataOutRptTab->iZoneGHGR); // multipliers included above
    4765            0 :                 ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtSurfCl =
    4766            0 :                     state.dataOutRptTab->radiantCool(state.dataOutRptTab->iZoneGHGR); // multipliers included above
    4767              :                 // HVAC ATU Heating at Heat Peak
    4768              :                 // HVAC ATU Cooling at Heat Peak
    4769            0 :                 ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtHvacATUHt =
    4770            0 :                     state.dataOutRptTab->ATUHeat(state.dataOutRptTab->iZoneGHGR); // multipliers included above
    4771            0 :                 ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtHvacATUCl =
    4772            0 :                     state.dataOutRptTab->ATUCool(state.dataOutRptTab->iZoneGHGR); // multipliers included above
    4773              :                 // People Sensible Heat Addition
    4774            0 :                 ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtPeoplAdd =
    4775            0 :                     state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).PeopleSenGainRate * mult;
    4776              :                 // Lights Sensible Heat Addition
    4777            0 :                 ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtLiteAdd =
    4778            0 :                     state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).LtsTotGainRate * mult;
    4779              :                 // Equipment Sensible Heat Addition
    4780              :                 // Equipment Sensible Heat Removal
    4781              :                 // non-HVAC ZnAirRpt variables DO NOT include zone multipliers
    4782            0 :                 state.dataOutRptTab->eqpSensGHGR = state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).ElecRadGainRate +
    4783            0 :                                                    state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).GasRadGainRate +
    4784            0 :                                                    state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).HWRadGainRate +
    4785            0 :                                                    state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).SteamRadGainRate +
    4786            0 :                                                    state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).OtherRadGainRate +
    4787            0 :                                                    state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).ElecConGainRate +
    4788            0 :                                                    state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).GasConGainRate +
    4789            0 :                                                    state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).HWConGainRate +
    4790            0 :                                                    state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).SteamConGainRate +
    4791            0 :                                                    state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).OtherConGainRate;
    4792            0 :                 if (state.dataOutRptTab->eqpSensGHGR > 0.0) {
    4793            0 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtEquipAdd = state.dataOutRptTab->eqpSensGHGR * mult;
    4794            0 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtEquipRem = 0.0;
    4795              :                 } else {
    4796            0 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtEquipAdd = 0.0;
    4797            0 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtEquipRem = state.dataOutRptTab->eqpSensGHGR * mult;
    4798              :                 }
    4799              :                 // Window Heat Addition
    4800              :                 // Window Heat Removal
    4801            0 :                 ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtWindAdd =
    4802            0 :                     state.dataHeatBal->ZoneWinHeatGainRep(state.dataOutRptTab->iZoneGHGR) * mult;
    4803            0 :                 ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtWindRem =
    4804            0 :                     -state.dataHeatBal->ZoneWinHeatLossRep(state.dataOutRptTab->iZoneGHGR) * mult;
    4805              :                 // mixing object heat addition and removal
    4806            0 :                 if (state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDTzones > 0.0) {
    4807            0 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtIzaAdd =
    4808            0 :                         state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDTzones * mult;
    4809            0 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtIzaRem = 0.0;
    4810              :                 } else {
    4811            0 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtIzaAdd = 0.0;
    4812            0 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtIzaRem =
    4813            0 :                         state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDTzones * mult;
    4814              :                 }
    4815              :                 // Infiltration Heat Addition
    4816              :                 // Infiltration Heat Removal
    4817            0 :                 if (state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDtInfil > 0.0) {
    4818            0 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtInfilAdd =
    4819            0 :                         state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDtInfil * mult;
    4820            0 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtInfilRem = 0.0;
    4821              :                 } else {
    4822            0 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtInfilAdd = 0.0;
    4823            0 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtInfilRem =
    4824            0 :                         state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDtInfil * mult;
    4825              :                 }
    4826              :                 // Opaque Surface Conduction and Other Heat Addition
    4827              :                 // Opaque Surface Conduction and Other Heat Removal
    4828            0 :                 state.dataOutRptTab->totalGHGR =
    4829            0 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtPeoplAdd + ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtLiteAdd +
    4830            0 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtHvacHt + ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtHvacCl +
    4831            0 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtIzaAdd + ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtIzaRem +
    4832            0 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtWindAdd + ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtWindRem +
    4833            0 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtInfilAdd + ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtInfilRem +
    4834            0 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtEquipAdd + ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtEquipRem +
    4835            0 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtSurfHt + ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtSurfCl;
    4836            0 :                 state.dataOutRptTab->totalGHGR =
    4837            0 :                     -state.dataOutRptTab->totalGHGR; // want to know the negative value of the sum since the row should add up to zero
    4838            0 :                 if (state.dataOutRptTab->totalGHGR > 0) {
    4839            0 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtOtherAdd = state.dataOutRptTab->totalGHGR;
    4840            0 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtOtherRem = 0.0;
    4841              :                 } else {
    4842            0 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtOtherAdd = 0.0;
    4843            0 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtOtherRem = state.dataOutRptTab->totalGHGR;
    4844              :                 }
    4845              :             }
    4846              :         } else {
    4847            5 :             if ((state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDTsystem +
    4848            5 :                  state.dataOutRptTab->radiantCool(state.dataOutRptTab->iZoneGHGR) +
    4849            5 :                  state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumNonAirSystem * mult) <
    4850            5 :                 ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).clPeak) {
    4851            2 :                 ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).clPeak =
    4852            2 :                     state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDTsystem +
    4853            2 :                     state.dataOutRptTab->radiantCool(state.dataOutRptTab->iZoneGHGR) +
    4854            2 :                     state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumNonAirSystem * mult;
    4855              :                 // determine timestamp
    4856              :                 //      ActualTimeS = CurrentTime-TimeStepZone+SysTimeElapsed
    4857              :                 //      ActualtimeE = ActualTimeS+TimeStepSys
    4858              :                 //      ActualTimeHrS=INT(ActualTimeS)
    4859              :                 //      ActualTimeMin=NINT((ActualtimeE - ActualTimeHrS)*FracToMin)
    4860            2 :                 int const ActualTimeMin = OutputProcessor::DetermineMinuteForReporting(state);
    4861            2 :                 EncodeMonDayHrMin(state.dataOutRptTab->timestepTimeStampGHGR,
    4862            2 :                                   state.dataEnvrn->Month,
    4863            2 :                                   state.dataEnvrn->DayOfMonth,
    4864            2 :                                   state.dataGlobal->HourOfDay,
    4865              :                                   ActualTimeMin);
    4866            2 :                 ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).clPtTimeStamp = state.dataOutRptTab->timestepTimeStampGHGR;
    4867              :                 // HVAC Input Sensible Air Heating
    4868              :                 // HVAC Input Sensible Air Cooling
    4869            2 :                 ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClHvacHt = 0.0;
    4870            2 :                 ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClHvacCl =
    4871            2 :                     state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDTsystem +
    4872            2 :                     state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumNonAirSystem * mult;
    4873              :                 // HVAC Input Heated Surface Heating
    4874              :                 // HVAC Input Cooled Surface Cooling
    4875            2 :                 ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClSurfHt = state.dataOutRptTab->radiantHeat(state.dataOutRptTab->iZoneGHGR);
    4876            2 :                 ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClSurfCl = state.dataOutRptTab->radiantCool(state.dataOutRptTab->iZoneGHGR);
    4877              :                 // HVAC heating by ATU at cool peak
    4878              :                 // HVAC cooling by ATU at cool peak
    4879            2 :                 ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClHvacATUHt = state.dataOutRptTab->ATUHeat(state.dataOutRptTab->iZoneGHGR);
    4880            2 :                 ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClHvacATUCl = state.dataOutRptTab->ATUCool(state.dataOutRptTab->iZoneGHGR);
    4881              :                 // People Sensible Heat Addition
    4882            2 :                 ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClPeoplAdd =
    4883            2 :                     state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).PeopleSenGainRate * mult;
    4884              :                 // Lights Sensible Heat Addition
    4885            2 :                 ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClLiteAdd =
    4886            2 :                     state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).LtsTotGainRate * mult;
    4887              :                 // Equipment Sensible Heat Addition
    4888              :                 // Equipment Sensible Heat Removal
    4889            2 :                 state.dataOutRptTab->eqpSensGHGR = state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).ElecRadGainRate +
    4890            2 :                                                    state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).GasRadGainRate +
    4891            2 :                                                    state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).HWRadGainRate +
    4892            2 :                                                    state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).SteamRadGainRate +
    4893            2 :                                                    state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).OtherRadGainRate +
    4894            2 :                                                    state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).ElecConGainRate +
    4895            2 :                                                    state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).GasConGainRate +
    4896            2 :                                                    state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).HWConGainRate +
    4897            2 :                                                    state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).SteamConGainRate +
    4898            2 :                                                    state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).OtherConGainRate;
    4899            2 :                 if (state.dataOutRptTab->eqpSensGHGR > 0.0) {
    4900            2 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClEquipAdd = state.dataOutRptTab->eqpSensGHGR * mult;
    4901            2 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClEquipRem = 0.0;
    4902              :                 } else {
    4903            0 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClEquipAdd = 0.0;
    4904            0 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClEquipRem = state.dataOutRptTab->eqpSensGHGR * mult;
    4905              :                 }
    4906              :                 // Window Heat Addition
    4907              :                 // Window Heat Removal
    4908            2 :                 ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClWindAdd =
    4909            2 :                     state.dataHeatBal->ZoneWinHeatGainRep(state.dataOutRptTab->iZoneGHGR) * mult;
    4910            2 :                 ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClWindRem =
    4911            2 :                     -state.dataHeatBal->ZoneWinHeatLossRep(state.dataOutRptTab->iZoneGHGR) * mult;
    4912              :                 // mixing object cool addition and removal
    4913            2 :                 if (state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDTzones > 0.0) {
    4914            0 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClIzaAdd =
    4915            0 :                         state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDTzones * mult;
    4916            0 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClIzaRem = 0.0;
    4917              :                 } else {
    4918            2 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClIzaAdd = 0.0;
    4919            2 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClIzaRem =
    4920            2 :                         state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDTzones * mult;
    4921              :                 }
    4922              :                 // Infiltration Heat Addition
    4923              :                 // Infiltration Heat Removal
    4924            2 :                 if (state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDtInfil > 0.0) {
    4925            0 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClInfilAdd =
    4926            0 :                         state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDtInfil * mult;
    4927            0 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClInfilRem = 0.0;
    4928              :                 } else {
    4929            2 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClInfilAdd = 0.0;
    4930            2 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClInfilRem =
    4931            2 :                         state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDtInfil * mult;
    4932              :                 }
    4933              :                 // Opaque Surface Conduction and Other Heat Addition
    4934              :                 // Opaque Surface Conduction and Other Heat Removal
    4935            4 :                 state.dataOutRptTab->totalGHGR =
    4936            2 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClPeoplAdd + ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClLiteAdd +
    4937            2 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClHvacHt + ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClHvacCl +
    4938            2 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClIzaAdd + ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClIzaRem +
    4939            2 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClWindAdd + ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClWindRem +
    4940            2 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClInfilAdd + ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClInfilRem +
    4941            2 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClEquipAdd + ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClEquipRem +
    4942            2 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClSurfHt + ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClSurfCl;
    4943            4 :                 state.dataOutRptTab->totalGHGR =
    4944            2 :                     -state.dataOutRptTab->totalGHGR; // want to know the negative value of the sum since the row should add up to zero
    4945            2 :                 if (state.dataOutRptTab->totalGHGR > 0) {
    4946            0 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClOtherAdd = state.dataOutRptTab->totalGHGR;
    4947            0 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClOtherRem = 0.0;
    4948              :                 } else {
    4949            2 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClOtherAdd = 0.0;
    4950            2 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClOtherRem = state.dataOutRptTab->totalGHGR;
    4951              :                 }
    4952              :             }
    4953              :         }
    4954              :     }
    4955              :     //------------------------------------
    4956              :     // BUILDING PEAK COOLING AND HEATING
    4957              :     //------------------------------------
    4958            3 :     state.dataOutRptTab->bldgHtPk = 0.0;
    4959            3 :     state.dataOutRptTab->bldgClPk = 0.0;
    4960            8 :     for (state.dataOutRptTab->iZoneGHGR = 1; state.dataOutRptTab->iZoneGHGR <= state.dataGlobal->NumOfZones; ++state.dataOutRptTab->iZoneGHGR) {
    4961            5 :         Real64 const mult = Zone(state.dataOutRptTab->iZoneGHGR).Multiplier * Zone(state.dataOutRptTab->iZoneGHGR).ListMultiplier;
    4962            5 :         if ((state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDTsystem +
    4963            5 :              state.dataOutRptTab->radiantHeat(state.dataOutRptTab->iZoneGHGR) +
    4964            5 :              state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumNonAirSystem * mult) > 0) {
    4965            0 :             state.dataOutRptTab->bldgHtPk += state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDTsystem +
    4966            0 :                                              state.dataOutRptTab->radiantHeat(state.dataOutRptTab->iZoneGHGR) +
    4967            0 :                                              state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumNonAirSystem * mult;
    4968              :         } else {
    4969           10 :             state.dataOutRptTab->bldgClPk += state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDTsystem +
    4970            5 :                                              state.dataOutRptTab->radiantCool(state.dataOutRptTab->iZoneGHGR) +
    4971            5 :                                              state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumNonAirSystem * mult;
    4972              :         }
    4973              :     }
    4974            3 :     if (state.dataOutRptTab->bldgHtPk > state.dataHeatBal->BuildingPreDefRep.htPeak) {
    4975            0 :         state.dataHeatBal->BuildingPreDefRep.htPeak = state.dataOutRptTab->bldgHtPk;
    4976              :         // determine timestamp
    4977              :         //  ActualTimeS = CurrentTime-TimeStepZone+SysTimeElapsed
    4978              :         //  ActualtimeE = ActualTimeS+TimeStepSys
    4979              :         //  ActualTimeHrS=INT(ActualTimeS)
    4980              :         //  ActualTimeMin=NINT((ActualtimeE - ActualTimeHrS)*FracToMin)
    4981            0 :         int const ActualTimeMin = OutputProcessor::DetermineMinuteForReporting(state);
    4982            0 :         EncodeMonDayHrMin(state.dataOutRptTab->timestepTimeStampGHGR,
    4983            0 :                           state.dataEnvrn->Month,
    4984            0 :                           state.dataEnvrn->DayOfMonth,
    4985            0 :                           state.dataGlobal->HourOfDay,
    4986              :                           ActualTimeMin);
    4987            0 :         state.dataHeatBal->BuildingPreDefRep.htPtTimeStamp = state.dataOutRptTab->timestepTimeStampGHGR;
    4988              :         // reset building level results to zero prior to accumulating across zones
    4989            0 :         state.dataHeatBal->BuildingPreDefRep.SHGSHtHvacHt = 0.0;
    4990            0 :         state.dataHeatBal->BuildingPreDefRep.SHGSHtHvacCl = 0.0;
    4991            0 :         state.dataHeatBal->BuildingPreDefRep.SHGSHtHvacATUHt = 0.0;
    4992            0 :         state.dataHeatBal->BuildingPreDefRep.SHGSHtHvacATUCl = 0.0;
    4993            0 :         state.dataHeatBal->BuildingPreDefRep.SHGSHtSurfHt = 0.0;
    4994            0 :         state.dataHeatBal->BuildingPreDefRep.SHGSHtSurfCl = 0.0;
    4995            0 :         state.dataHeatBal->BuildingPreDefRep.SHGSHtPeoplAdd = 0.0;
    4996            0 :         state.dataHeatBal->BuildingPreDefRep.SHGSHtLiteAdd = 0.0;
    4997            0 :         state.dataHeatBal->BuildingPreDefRep.SHGSHtEquipAdd = 0.0;
    4998            0 :         state.dataHeatBal->BuildingPreDefRep.SHGSHtWindAdd = 0.0;
    4999            0 :         state.dataHeatBal->BuildingPreDefRep.SHGSHtIzaAdd = 0.0;
    5000            0 :         state.dataHeatBal->BuildingPreDefRep.SHGSHtInfilAdd = 0.0;
    5001            0 :         state.dataHeatBal->BuildingPreDefRep.SHGSHtOtherAdd = 0.0;
    5002            0 :         state.dataHeatBal->BuildingPreDefRep.SHGSHtEquipRem = 0.0;
    5003            0 :         state.dataHeatBal->BuildingPreDefRep.SHGSHtWindRem = 0.0;
    5004            0 :         state.dataHeatBal->BuildingPreDefRep.SHGSHtIzaRem = 0.0;
    5005            0 :         state.dataHeatBal->BuildingPreDefRep.SHGSHtInfilRem = 0.0;
    5006            0 :         state.dataHeatBal->BuildingPreDefRep.SHGSHtOtherRem = 0.0;
    5007            0 :         for (state.dataOutRptTab->iZoneGHGR = 1; state.dataOutRptTab->iZoneGHGR <= state.dataGlobal->NumOfZones; ++state.dataOutRptTab->iZoneGHGR) {
    5008            0 :             Real64 const mult = Zone(state.dataOutRptTab->iZoneGHGR).Multiplier * Zone(state.dataOutRptTab->iZoneGHGR).ListMultiplier;
    5009              :             // HVAC Input Sensible Air Heating
    5010              :             // HVAC Input Sensible Air Cooling
    5011            0 :             state.dataHeatBal->BuildingPreDefRep.SHGSHtHvacHt += state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDTsystem +
    5012            0 :                                                                  state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumNonAirSystem * mult;
    5013              :             // HVAC Input Heated Surface Heating
    5014              :             // HVAC Input Cooled Surface Cooling
    5015            0 :             state.dataHeatBal->BuildingPreDefRep.SHGSHtSurfHt += state.dataOutRptTab->radiantHeat(state.dataOutRptTab->iZoneGHGR);
    5016            0 :             state.dataHeatBal->BuildingPreDefRep.SHGSHtSurfCl += state.dataOutRptTab->radiantCool(state.dataOutRptTab->iZoneGHGR);
    5017              :             // HVAC ATU Heating
    5018              :             // HVAC ATU Cooling
    5019            0 :             state.dataHeatBal->BuildingPreDefRep.SHGSHtHvacATUHt += state.dataOutRptTab->ATUHeat(state.dataOutRptTab->iZoneGHGR);
    5020            0 :             state.dataHeatBal->BuildingPreDefRep.SHGSHtHvacATUCl += state.dataOutRptTab->ATUCool(state.dataOutRptTab->iZoneGHGR);
    5021              :             // People Sensible Heat Addition
    5022            0 :             state.dataHeatBal->BuildingPreDefRep.SHGSHtPeoplAdd +=
    5023            0 :                 state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).PeopleSenGainRate * mult;
    5024              :             // Lights Sensible Heat Addition
    5025            0 :             state.dataHeatBal->BuildingPreDefRep.SHGSHtLiteAdd += state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).LtsTotGainRate * mult;
    5026              :             // Equipment Sensible Heat Addition
    5027              :             // Equipment Sensible Heat Removal
    5028            0 :             state.dataOutRptTab->eqpSensGHGR = state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).ElecRadGainRate +
    5029            0 :                                                state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).GasRadGainRate +
    5030            0 :                                                state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).HWRadGainRate +
    5031            0 :                                                state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).SteamRadGainRate +
    5032            0 :                                                state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).OtherRadGainRate +
    5033            0 :                                                state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).ElecConGainRate +
    5034            0 :                                                state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).GasConGainRate +
    5035            0 :                                                state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).HWConGainRate +
    5036            0 :                                                state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).SteamConGainRate +
    5037            0 :                                                state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).OtherConGainRate;
    5038            0 :             if (state.dataOutRptTab->eqpSensGHGR > 0.0) {
    5039            0 :                 state.dataHeatBal->BuildingPreDefRep.SHGSHtEquipAdd += state.dataOutRptTab->eqpSensGHGR * mult;
    5040              :             } else {
    5041            0 :                 state.dataHeatBal->BuildingPreDefRep.SHGSHtEquipRem += state.dataOutRptTab->eqpSensGHGR * mult;
    5042              :             }
    5043              :             // Window Heat Addition
    5044              :             // Window Heat Removal
    5045            0 :             state.dataHeatBal->BuildingPreDefRep.SHGSHtWindAdd += state.dataHeatBal->ZoneWinHeatGainRep(state.dataOutRptTab->iZoneGHGR) * mult;
    5046            0 :             state.dataHeatBal->BuildingPreDefRep.SHGSHtWindRem -= state.dataHeatBal->ZoneWinHeatLossRep(state.dataOutRptTab->iZoneGHGR) * mult;
    5047              :             // mixing object heat addition and removal
    5048            0 :             if (state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDTzones > 0.0) {
    5049            0 :                 state.dataHeatBal->BuildingPreDefRep.SHGSHtIzaAdd += state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDTzones * mult;
    5050              :             } else {
    5051            0 :                 state.dataHeatBal->BuildingPreDefRep.SHGSHtIzaRem += state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDTzones * mult;
    5052              :             }
    5053              :             // Infiltration Heat Addition
    5054              :             // Infiltration Heat Removal
    5055            0 :             if (state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDtInfil > 00) {
    5056            0 :                 state.dataHeatBal->BuildingPreDefRep.SHGSHtInfilAdd +=
    5057            0 :                     state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDtInfil * mult;
    5058              :             } else {
    5059            0 :                 state.dataHeatBal->BuildingPreDefRep.SHGSHtInfilRem +=
    5060            0 :                     state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDtInfil * mult;
    5061              :             }
    5062              :         }
    5063              :         // Opaque Surface Conduction and Other Heat Addition
    5064              :         // Opaque Surface Conduction and Other Heat Removal
    5065            0 :         state.dataOutRptTab->totalGHGR = state.dataHeatBal->BuildingPreDefRep.SHGSHtPeoplAdd + state.dataHeatBal->BuildingPreDefRep.SHGSHtLiteAdd +
    5066            0 :                                          state.dataHeatBal->BuildingPreDefRep.SHGSHtHvacHt + state.dataHeatBal->BuildingPreDefRep.SHGSHtHvacCl +
    5067            0 :                                          state.dataHeatBal->BuildingPreDefRep.SHGSHtIzaAdd + state.dataHeatBal->BuildingPreDefRep.SHGSHtIzaRem +
    5068            0 :                                          state.dataHeatBal->BuildingPreDefRep.SHGSHtWindAdd + state.dataHeatBal->BuildingPreDefRep.SHGSHtWindRem +
    5069            0 :                                          state.dataHeatBal->BuildingPreDefRep.SHGSHtInfilAdd + state.dataHeatBal->BuildingPreDefRep.SHGSHtInfilRem +
    5070            0 :                                          state.dataHeatBal->BuildingPreDefRep.SHGSHtEquipAdd + state.dataHeatBal->BuildingPreDefRep.SHGSHtEquipRem +
    5071            0 :                                          state.dataHeatBal->BuildingPreDefRep.SHGSHtSurfHt + state.dataHeatBal->BuildingPreDefRep.SHGSHtSurfCl;
    5072            0 :         state.dataOutRptTab->totalGHGR =
    5073            0 :             -state.dataOutRptTab->totalGHGR; // want to know the negative value of the sum since the row should add up to zero
    5074            0 :         if (state.dataOutRptTab->totalGHGR > 0) {
    5075            0 :             state.dataHeatBal->BuildingPreDefRep.SHGSHtOtherAdd += state.dataOutRptTab->totalGHGR;
    5076              :         } else {
    5077            0 :             state.dataHeatBal->BuildingPreDefRep.SHGSHtOtherRem += state.dataOutRptTab->totalGHGR;
    5078              :         }
    5079              :     }
    5080            3 :     if (state.dataOutRptTab->bldgClPk < state.dataHeatBal->BuildingPreDefRep.clPeak) {
    5081            1 :         state.dataHeatBal->BuildingPreDefRep.clPeak = state.dataOutRptTab->bldgClPk;
    5082              :         // determine timestamp
    5083              :         //  ActualTimeS = CurrentTime-TimeStepZone+SysTimeElapsed
    5084              :         //  ActualtimeE = ActualTimeS+TimeStepSys
    5085              :         //  ActualTimeHrS=INT(ActualTimeS)
    5086              :         //  ActualTimeMin=NINT((ActualtimeE - ActualTimeHrS)*FracToMin)
    5087            1 :         int const ActualTimeMin = OutputProcessor::DetermineMinuteForReporting(state);
    5088            1 :         EncodeMonDayHrMin(state.dataOutRptTab->timestepTimeStampGHGR,
    5089            1 :                           state.dataEnvrn->Month,
    5090            1 :                           state.dataEnvrn->DayOfMonth,
    5091            1 :                           state.dataGlobal->HourOfDay,
    5092              :                           ActualTimeMin);
    5093            1 :         state.dataHeatBal->BuildingPreDefRep.clPtTimeStamp = state.dataOutRptTab->timestepTimeStampGHGR;
    5094              :         // reset building level results to zero prior to accumulating across zones
    5095            1 :         state.dataHeatBal->BuildingPreDefRep.SHGSClHvacHt = 0.0;
    5096            1 :         state.dataHeatBal->BuildingPreDefRep.SHGSClHvacCl = 0.0;
    5097            1 :         state.dataHeatBal->BuildingPreDefRep.SHGSClSurfHt = 0.0;
    5098            1 :         state.dataHeatBal->BuildingPreDefRep.SHGSClSurfCl = 0.0;
    5099            1 :         state.dataHeatBal->BuildingPreDefRep.SHGSClHvacATUHt = 0.0;
    5100            1 :         state.dataHeatBal->BuildingPreDefRep.SHGSClHvacATUCl = 0.0;
    5101            1 :         state.dataHeatBal->BuildingPreDefRep.SHGSClPeoplAdd = 0.0;
    5102            1 :         state.dataHeatBal->BuildingPreDefRep.SHGSClLiteAdd = 0.0;
    5103            1 :         state.dataHeatBal->BuildingPreDefRep.SHGSClEquipAdd = 0.0;
    5104            1 :         state.dataHeatBal->BuildingPreDefRep.SHGSClWindAdd = 0.0;
    5105            1 :         state.dataHeatBal->BuildingPreDefRep.SHGSClIzaAdd = 0.0;
    5106            1 :         state.dataHeatBal->BuildingPreDefRep.SHGSClInfilAdd = 0.0;
    5107            1 :         state.dataHeatBal->BuildingPreDefRep.SHGSClOtherAdd = 0.0;
    5108            1 :         state.dataHeatBal->BuildingPreDefRep.SHGSClEquipRem = 0.0;
    5109            1 :         state.dataHeatBal->BuildingPreDefRep.SHGSClWindRem = 0.0;
    5110            1 :         state.dataHeatBal->BuildingPreDefRep.SHGSClIzaRem = 0.0;
    5111            1 :         state.dataHeatBal->BuildingPreDefRep.SHGSClInfilRem = 0.0;
    5112            1 :         state.dataHeatBal->BuildingPreDefRep.SHGSClOtherRem = 0.0;
    5113            3 :         for (state.dataOutRptTab->iZoneGHGR = 1; state.dataOutRptTab->iZoneGHGR <= state.dataGlobal->NumOfZones; ++state.dataOutRptTab->iZoneGHGR) {
    5114            2 :             Real64 const mult = Zone(state.dataOutRptTab->iZoneGHGR).Multiplier * Zone(state.dataOutRptTab->iZoneGHGR).ListMultiplier;
    5115              :             // HVAC Input Sensible Air Heating
    5116              :             // HVAC Input Sensible Air Cooling
    5117            2 :             state.dataHeatBal->BuildingPreDefRep.SHGSClHvacCl += state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDTsystem +
    5118            2 :                                                                  state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumNonAirSystem * mult;
    5119              :             // HVAC Input Heated Surface Heating
    5120              :             // HVAC Input Cooled Surface Cooling
    5121            2 :             state.dataHeatBal->BuildingPreDefRep.SHGSClSurfHt += state.dataOutRptTab->radiantHeat(state.dataOutRptTab->iZoneGHGR);
    5122            2 :             state.dataHeatBal->BuildingPreDefRep.SHGSClSurfCl += state.dataOutRptTab->radiantCool(state.dataOutRptTab->iZoneGHGR);
    5123              :             // HVAC ATU Heating
    5124              :             // HVAC ATU Cooling
    5125            2 :             state.dataHeatBal->BuildingPreDefRep.SHGSClHvacATUHt += state.dataOutRptTab->ATUHeat(state.dataOutRptTab->iZoneGHGR);
    5126            2 :             state.dataHeatBal->BuildingPreDefRep.SHGSClHvacATUCl += state.dataOutRptTab->ATUCool(state.dataOutRptTab->iZoneGHGR);
    5127              :             // People Sensible Heat Addition
    5128            4 :             state.dataHeatBal->BuildingPreDefRep.SHGSClPeoplAdd +=
    5129            2 :                 state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).PeopleSenGainRate * mult;
    5130              :             // Lights Sensible Heat Addition
    5131            2 :             state.dataHeatBal->BuildingPreDefRep.SHGSClLiteAdd += state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).LtsTotGainRate * mult;
    5132              :             // Equipment Sensible Heat Addition
    5133              :             // Equipment Sensible Heat Removal
    5134            2 :             state.dataOutRptTab->eqpSensGHGR = state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).ElecRadGainRate +
    5135            2 :                                                state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).GasRadGainRate +
    5136            2 :                                                state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).HWRadGainRate +
    5137            2 :                                                state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).SteamRadGainRate +
    5138            2 :                                                state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).OtherRadGainRate +
    5139            2 :                                                state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).ElecConGainRate +
    5140            2 :                                                state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).GasConGainRate +
    5141            2 :                                                state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).HWConGainRate +
    5142            2 :                                                state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).SteamConGainRate +
    5143            2 :                                                state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).OtherConGainRate;
    5144            2 :             if (state.dataOutRptTab->eqpSensGHGR > 0.0) {
    5145            2 :                 state.dataHeatBal->BuildingPreDefRep.SHGSClEquipAdd += state.dataOutRptTab->eqpSensGHGR * mult;
    5146              :             } else {
    5147            0 :                 state.dataHeatBal->BuildingPreDefRep.SHGSClEquipRem += state.dataOutRptTab->eqpSensGHGR * mult;
    5148              :             }
    5149              :             // Window Heat Addition
    5150              :             // Window Heat Removal
    5151            2 :             state.dataHeatBal->BuildingPreDefRep.SHGSClWindAdd += state.dataHeatBal->ZoneWinHeatGainRep(state.dataOutRptTab->iZoneGHGR) * mult;
    5152            2 :             state.dataHeatBal->BuildingPreDefRep.SHGSClWindRem -= state.dataHeatBal->ZoneWinHeatLossRep(state.dataOutRptTab->iZoneGHGR) * mult;
    5153              :             // mixing object cool addition and removal
    5154            2 :             if (state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDTzones > 0.0) {
    5155            0 :                 state.dataHeatBal->BuildingPreDefRep.SHGSClIzaAdd += state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDTzones * mult;
    5156              :             } else {
    5157            2 :                 state.dataHeatBal->BuildingPreDefRep.SHGSClIzaRem += state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDTzones * mult;
    5158              :             }
    5159              :             // Infiltration Heat Addition
    5160              :             // Infiltration Heat Removal
    5161            2 :             if (state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDtInfil > 00) {
    5162            0 :                 state.dataHeatBal->BuildingPreDefRep.SHGSClInfilAdd +=
    5163            0 :                     state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDtInfil * mult;
    5164              :             } else {
    5165            2 :                 state.dataHeatBal->BuildingPreDefRep.SHGSClInfilRem +=
    5166            2 :                     state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDtInfil * mult;
    5167              :             }
    5168              :         }
    5169              :         // Opaque Surface Conduction and Other Heat Addition
    5170              :         // Opaque Surface Conduction and Other Heat Removal
    5171            1 :         state.dataOutRptTab->totalGHGR = state.dataHeatBal->BuildingPreDefRep.SHGSClPeoplAdd + state.dataHeatBal->BuildingPreDefRep.SHGSClLiteAdd +
    5172            1 :                                          state.dataHeatBal->BuildingPreDefRep.SHGSClHvacHt + state.dataHeatBal->BuildingPreDefRep.SHGSClHvacCl +
    5173            1 :                                          state.dataHeatBal->BuildingPreDefRep.SHGSClIzaAdd + state.dataHeatBal->BuildingPreDefRep.SHGSClIzaRem +
    5174            1 :                                          state.dataHeatBal->BuildingPreDefRep.SHGSClWindAdd + state.dataHeatBal->BuildingPreDefRep.SHGSClWindRem +
    5175            1 :                                          state.dataHeatBal->BuildingPreDefRep.SHGSClInfilAdd + state.dataHeatBal->BuildingPreDefRep.SHGSClInfilRem +
    5176            1 :                                          state.dataHeatBal->BuildingPreDefRep.SHGSClEquipAdd + state.dataHeatBal->BuildingPreDefRep.SHGSClEquipRem +
    5177            1 :                                          state.dataHeatBal->BuildingPreDefRep.SHGSClSurfHt + state.dataHeatBal->BuildingPreDefRep.SHGSClSurfCl;
    5178            2 :         state.dataOutRptTab->totalGHGR =
    5179            1 :             -state.dataOutRptTab->totalGHGR; // want to know the negative value of the sum since the row should add up to zero
    5180            1 :         if (state.dataOutRptTab->totalGHGR > 0) {
    5181            0 :             state.dataHeatBal->BuildingPreDefRep.SHGSClOtherAdd += state.dataOutRptTab->totalGHGR;
    5182              :         } else {
    5183            1 :             state.dataHeatBal->BuildingPreDefRep.SHGSClOtherRem += state.dataOutRptTab->totalGHGR;
    5184              :         }
    5185              :     }
    5186              : }
    5187              : 
    5188              : //======================================================================================================================
    5189              : //======================================================================================================================
    5190              : 
    5191              : //    WRITE OUTPUT FILE ROUTINES
    5192              : 
    5193              : //======================================================================================================================
    5194              : //======================================================================================================================
    5195              : 
    5196           73 : void WriteTabularReports(EnergyPlusData &state)
    5197              : {
    5198              :     // SUBROUTINE INFORMATION:
    5199              :     //       AUTHOR         Jason Glazer
    5200              :     //       DATE WRITTEN   August 2003
    5201              :     //       MODIFIED       January 2021, J. Yuan
    5202              :     //                      Modified to accommodate dual-unit reporting
    5203              :     //       RE-ENGINEERED  na
    5204              : 
    5205              :     // PURPOSE OF THIS SUBROUTINE:
    5206              :     //   This routine hides from the main simulation that four specific
    5207              :     //   types of tabular reports are each created. If another type of
    5208              :     //   report is added it can be added to the list here.
    5209              : 
    5210           73 :     FillWeatherPredefinedEntries(state);
    5211           73 :     FillRemainingPredefinedEntries(state);
    5212           73 :     WaterManager::ReportRainfall(state);
    5213           73 :     auto &ort = state.dataOutRptTab;
    5214              : 
    5215              :     // Here to it is ready to assign ort->unitStyle_SQLite (not in SQLiteProcedures.cc)
    5216              :     // when ort->unitsStyle inputs should have been concretely processed and assigned.
    5217           73 :     if (ort->unitsStyle_SQLite == UnitsStyle::NotFound) {
    5218           73 :         ort->unitsStyle_SQLite = ort->unitsStyle; // This is the default UseOutputControlTableStyles
    5219              :     }
    5220              : 
    5221           73 :     if (ort->WriteTabularFiles) {
    5222              : 
    5223              :         // call each type of report in turn
    5224           38 :         WriteBEPSTable(state);
    5225           38 :         WriteTableOfContents(state);
    5226           38 :         WriteVeriSumTable(state);
    5227           38 :         WriteDemandEndUseSummary(state);
    5228           38 :         WriteSourceEnergyEndUseSummary(state);
    5229           38 :         WriteComponentSizing(state);
    5230           38 :         WriteSurfaceShadowing(state);
    5231           38 :         WriteCompCostTable(state);
    5232           38 :         WriteAdaptiveComfortTable(state);
    5233           38 :         WriteEioTables(state);
    5234           38 :         WriteLoadComponentSummaryTables(state);
    5235           38 :         WriteHeatEmissionTable(state);
    5236              : 
    5237           38 :         if (ort->displayThermalResilienceSummary && !state.dataGlobal->DoPureLoadCalc) // code will crash if pure load calc
    5238           30 :             WriteThermalResilienceTables(state);                                       // code will crash if pure load calc
    5239           38 :         if (ort->displayCO2ResilienceSummary && !state.dataGlobal->DoPureLoadCalc)     // code will crash if pure load calc
    5240            0 :             WriteCO2ResilienceTables(state);                                           // code will crash if pure load calc
    5241           38 :         if (ort->displayVisualResilienceSummary && !state.dataGlobal->DoPureLoadCalc)  // code will crash if pure load calc
    5242            0 :             WriteVisualResilienceTables(state);                                        // code will crash if pure load calc
    5243           38 :         if (state.dataWeather->TotReportPers > 0) WriteReportPeriodTimeConsumption(state);
    5244           38 :         for (int i = 1; i <= state.dataWeather->TotThermalReportPers; i++) {
    5245            0 :             WriteThermalResilienceTablesRepPeriod(state, i);
    5246              :         }
    5247           38 :         for (int i = 1; i <= state.dataWeather->TotCO2ReportPers; i++) {
    5248            0 :             WriteCO2ResilienceTablesRepPeriod(state, i);
    5249              :         }
    5250           38 :         for (int i = 1; i <= state.dataWeather->TotVisualReportPers; i++) {
    5251            0 :             WriteVisualResilienceTablesRepPeriod(state, i);
    5252              :         }
    5253              : 
    5254           38 :         state.dataRptCoilSelection->coilSelectionReportObj->finishCoilSummaryReportTable(
    5255              :             state);                   // call to write out the coil selection summary table data
    5256           38 :         WritePredefinedTables(state); // moved to come after zone load components is finished
    5257              : 
    5258           38 :         if (state.dataGlobal->DoWeathSim) {
    5259            0 :             WriteMonthlyTables(state);
    5260            0 :             WriteTimeBinTables(state);
    5261            0 :             OutputReportTabularAnnual::WriteAnnualTables(state);
    5262              :         }
    5263              :     }
    5264              : 
    5265              :     constexpr static std::string_view variable_fmt = " {}={:12}\n";
    5266              :     constexpr static auto variable_fmt_syntax = check_syntax(variable_fmt); // (AUTO_OK) not sure what this is
    5267          146 :     state.files.audit.ensure_open(state, "WriteTabularReports", state.files.outputControl.audit);
    5268           73 :     print<variable_fmt_syntax>(state.files.audit, variable_fmt, "MonthlyInputCount", ort->MonthlyInputCount);
    5269           73 :     print<variable_fmt_syntax>(state.files.audit, variable_fmt, "sizeMonthlyInput", ort->sizeMonthlyInput);
    5270           73 :     print<variable_fmt_syntax>(state.files.audit, variable_fmt, "MonthlyFieldSetInputCount", ort->MonthlyFieldSetInputCount);
    5271           73 :     print<variable_fmt_syntax>(state.files.audit, variable_fmt, "sizeMonthlyFieldSetInput", ort->sizeMonthlyFieldSetInput);
    5272           73 :     print<variable_fmt_syntax>(state.files.audit, variable_fmt, "MonthlyTablesCount", ort->MonthlyTablesCount);
    5273           73 :     print<variable_fmt_syntax>(state.files.audit, variable_fmt, "MonthlyColumnsCount", ort->MonthlyColumnsCount);
    5274           73 :     print<variable_fmt_syntax>(state.files.audit, variable_fmt, "sizeReportName", state.dataOutRptPredefined->sizeReportName);
    5275           73 :     print<variable_fmt_syntax>(state.files.audit, variable_fmt, "numReportName", state.dataOutRptPredefined->numReportName);
    5276           73 :     print<variable_fmt_syntax>(state.files.audit, variable_fmt, "sizeSubTable", state.dataOutRptPredefined->sizeSubTable);
    5277           73 :     print<variable_fmt_syntax>(state.files.audit, variable_fmt, "numSubTable", state.dataOutRptPredefined->numSubTable);
    5278           73 :     print<variable_fmt_syntax>(state.files.audit, variable_fmt, "sizeColumnTag", state.dataOutRptPredefined->sizeColumnTag);
    5279           73 :     print<variable_fmt_syntax>(state.files.audit, variable_fmt, "numColumnTag", state.dataOutRptPredefined->numColumnTag);
    5280           73 :     print<variable_fmt_syntax>(state.files.audit, variable_fmt, "sizeTableEntry", state.dataOutRptPredefined->sizeTableEntry);
    5281           73 :     print<variable_fmt_syntax>(state.files.audit, variable_fmt, "numTableEntry", state.dataOutRptPredefined->numTableEntry);
    5282           73 :     print<variable_fmt_syntax>(state.files.audit, variable_fmt, "sizeCompSizeTableEntry", state.dataOutRptPredefined->sizeCompSizeTableEntry);
    5283           73 :     print<variable_fmt_syntax>(state.files.audit, variable_fmt, "numCompSizeTableEntry", state.dataOutRptPredefined->numCompSizeTableEntry);
    5284           73 : }
    5285              : 
    5286          674 : bool produceDualUnitsFlags(const int iUnit_Sys,
    5287              :                            const UnitsStyle unitsStyle_Tab,
    5288              :                            const UnitsStyle unitsStyle_Sql,
    5289              :                            UnitsStyle &unitsStyle_Cur,
    5290              :                            bool &produce_Tab,
    5291              :                            bool &produce_Sql)
    5292              : {
    5293              :     // January 2021:
    5294              :     // PURPOSE OF THIS SUBROUTINE:
    5295              :     // This routine sets the order and flags for tabular data and sqlite writing for a Dual-Unit reporting.
    5296              :     // It will set the unit styles to used, a flag for tabular data writing, and a flag for sqlite writing.
    5297              :     // The function will return a false flag if only a second round of (SQLite) writing is needed
    5298              :     // and will return a true flag if a second round SQLite writing is not needed.
    5299              : 
    5300          674 :     bool brkflag(false);
    5301              : 
    5302          674 :     if (iUnit_Sys == 0) {
    5303          337 :         unitsStyle_Cur = unitsStyle_Tab;
    5304          337 :         produce_Tab = true;
    5305          337 :         if (unitsStyle_Sql == unitsStyle_Tab) {
    5306          321 :             produce_Sql = true;
    5307              :         } else {
    5308           16 :             produce_Sql = false;
    5309              :         }
    5310              :     } else { // iUnit_Sys == 1
    5311          337 :         unitsStyle_Cur = unitsStyle_Sql;
    5312          337 :         produce_Tab = false;
    5313          337 :         produce_Sql = true;
    5314          337 :         if (unitsStyle_Sql == unitsStyle_Tab) {
    5315              :             // flag true if a separate SQLite round writing is not needed
    5316          321 :             brkflag = true;
    5317          321 :             produce_Sql = false;
    5318              :         }
    5319              :     }
    5320              : 
    5321              :     // False if a separate sqlite round is needed;
    5322              :     // true if not
    5323          674 :     return brkflag;
    5324              : }
    5325              : 
    5326        10269 : void parseStatLine(const std::string &lineIn,
    5327              :                    StatLineType &lineType,
    5328              :                    bool &desConditionlinepassed,
    5329              :                    bool &heatingDesignlinepassed,
    5330              :                    bool &coolingDesignlinepassed,
    5331              :                    bool isKoppen,
    5332              :                    bool &insideLiquidPrecipitation)
    5333              : {
    5334              :     // assumes that all the variables are initialized outside of this routine -- it does not re-initialize them
    5335        10269 :     if (has_prefix(lineIn, "Statistics")) {
    5336           18 :         lineType = StatLineType::StatisticsLine;
    5337        10251 :     } else if (has_prefix(lineIn, "Location")) {
    5338           18 :         lineType = StatLineType::LocationLine;
    5339        10233 :     } else if (has_prefix(lineIn, "{")) {
    5340           18 :         lineType = StatLineType::LatLongLine;
    5341        10215 :     } else if (has_prefix(lineIn, "Elevation")) {
    5342           18 :         lineType = StatLineType::ElevationLine;
    5343        10197 :     } else if (has_prefix(lineIn, "Standard Pressure")) {
    5344           18 :         lineType = StatLineType::StdPressureLine;
    5345        10179 :     } else if (has_prefix(lineIn, "Data Source")) {
    5346           18 :         lineType = StatLineType::DataSourceLine;
    5347        10161 :     } else if (has_prefix(lineIn, "WMO Station")) {
    5348           18 :         lineType = StatLineType::WMOStationLine;
    5349        10143 :     } else if (has(lineIn, "Design Conditions")) {
    5350           35 :         if (!desConditionlinepassed) {
    5351           18 :             desConditionlinepassed = true;
    5352           18 :             lineType = StatLineType::DesignConditionsLine;
    5353              :         }
    5354        10108 :     } else if (has_prefix(lineIn, "\tHeating")) {
    5355           18 :         if (!heatingDesignlinepassed) {
    5356           18 :             heatingDesignlinepassed = true;
    5357           18 :             lineType = StatLineType::HeatingConditionsLine;
    5358              :         }
    5359        10090 :     } else if (has_prefix(lineIn, "\tCooling")) {
    5360           18 :         if (!coolingDesignlinepassed) {
    5361           18 :             coolingDesignlinepassed = true;
    5362           18 :             lineType = StatLineType::CoolingConditionsLine;
    5363              :         }
    5364        10072 :     } else if (has(lineIn, "(standard) heating degree-days (18.3")) {
    5365           18 :         lineType = StatLineType::StdHDDLine;
    5366        10054 :     } else if (has(lineIn, "(standard) cooling degree-days (10")) {
    5367           20 :         lineType = StatLineType::StdCDDLine;
    5368              : 
    5369        10034 :     } else if (has(lineIn, "Maximum Dry Bulb")) {
    5370           18 :         lineType = StatLineType::MaxDryBulbLine;
    5371        10016 :     } else if (has(lineIn, "Minimum Dry Bulb")) {
    5372           18 :         lineType = StatLineType::MinDryBulbLine;
    5373         9998 :     } else if (has(lineIn, "Maximum Dew Point")) {
    5374           18 :         lineType = StatLineType::MaxDewPointLine;
    5375         9980 :     } else if (has(lineIn, "Minimum Dew Point")) {
    5376           18 :         lineType = StatLineType::MinDewPointLine;
    5377         9962 :     } else if (has(lineIn, "(wthr file) heating degree-days (18") || has(lineIn, "heating degree-days (18")) {
    5378           18 :         lineType = StatLineType::WithHDDLine;
    5379         9944 :     } else if (has(lineIn, "(wthr file) cooling degree-days (10") || has(lineIn, "cooling degree-days (10")) {
    5380           18 :         lineType = StatLineType::WithCDDLine;
    5381              : 
    5382         9926 :     } else if (has(lineIn, "Statistics for Liquid Precipitation")) {
    5383           18 :         insideLiquidPrecipitation = true;
    5384         9908 :     } else if (insideLiquidPrecipitation && has(lineIn, "Total")) {
    5385           18 :         lineType = StatLineType::MonthlyPrec;
    5386         9890 :     } else if (insideLiquidPrecipitation && has(lineIn, "Max Hourly")) {
    5387           18 :         lineType = StatLineType::MaxHourlyPrec;
    5388           18 :         insideLiquidPrecipitation = false;
    5389              :     }
    5390              : 
    5391              :     // these not part of big if/else because sequential
    5392        10269 :     if (lineType == StatLineType::KoppenDes1Line && isKoppen) lineType = StatLineType::KoppenDes2Line;
    5393        10269 :     if (lineType == StatLineType::KoppenLine && isKoppen) lineType = StatLineType::KoppenDes1Line;
    5394        10269 :     if (has(lineIn, "ppen classification)")) lineType = StatLineType::KoppenLine;
    5395        10269 :     if (lineType == StatLineType::AshStdDes2Line) lineType = StatLineType::AshStdDes3Line;
    5396        10269 :     if (lineType == StatLineType::AshStdDes1Line) lineType = StatLineType::AshStdDes2Line;
    5397        10269 :     if (lineType == StatLineType::AshStdLine) lineType = StatLineType::AshStdDes1Line;
    5398        10269 :     if (has(lineIn, "ASHRAE Standard")) lineType = StatLineType::AshStdLine;
    5399        10269 : }
    5400              : 
    5401           74 : void FillWeatherPredefinedEntries(EnergyPlusData &state)
    5402              : {
    5403              :     // SUBROUTINE INFORMATION:
    5404              :     //       AUTHOR         Jason Glazer
    5405              :     //       DATE WRITTEN   Feb 2008
    5406              :     //       MODIFIED       na
    5407              :     //       RE-ENGINEERED  na
    5408              : 
    5409              :     // PURPOSE OF THIS SUBROUTINE:
    5410              :     //   Read the STAT file for the active weather file and summarize in a predefined report.
    5411              :     //   The stat file that is attached may have several formats -- from evolution of the
    5412              :     //   stat file from the weather converter (or others that produce a similar stat file).
    5413              : 
    5414              :     // Using/Aliasing
    5415              :     using namespace OutputReportPredefined;
    5416              : 
    5417              :     // SUBROUTINE PARAMETER DEFINITIONS:
    5418          204 :     static std::string const degChar("°");
    5419              : 
    5420           74 :     if (!FileSystem::fileExists(state.files.inStatFilePath.filePath)) {
    5421           56 :         return;
    5422              :     }
    5423              : 
    5424           18 :     auto const &ort = state.dataOutRptTab;
    5425              : 
    5426              :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
    5427              : 
    5428           18 :     StatLineType lineTypeinterim = StatLineType::Initialized;
    5429              :     std::string::size_type ashPtr;
    5430              :     std::string::size_type lnPtr;
    5431              :     int col1;
    5432              :     int col2;
    5433              :     int col3;
    5434              :     std::string::size_type sposlt;
    5435              :     std::string::size_type eposlt;
    5436              :     std::string::size_type sposlg;
    5437              :     std::string::size_type eposlg;
    5438              :     std::string::size_type spostz;
    5439              :     std::string::size_type epostz;
    5440           18 :     std::string ashDesYear;
    5441           18 :     std::string ashZone; // ashrae climate zone
    5442           18 :     std::string curNameWithSIUnits;
    5443           18 :     std::string curNameAndUnits;
    5444              :     int indexUnitConv;
    5445              : 
    5446           18 :     bool isASHRAE = false;
    5447           18 :     bool iscalc = false;
    5448           18 :     bool isKoppen = false;
    5449           18 :     bool heatingDesignlinepassed = false;
    5450           18 :     bool coolingDesignlinepassed = false;
    5451           18 :     bool desConditionlinepassed = false;
    5452           18 :     bool insideLiquidPrecipitation = false;
    5453           18 :     std::string storeASHRAEHDD;
    5454           18 :     std::string storeASHRAECDD;
    5455              : 
    5456           36 :     auto statFile = state.files.inStatFilePath.open(state, "FillWeatherPredefinedEntries");
    5457        10283 :     while (statFile.good()) { // end of file, or error
    5458        10265 :         StatLineType lineType = lineTypeinterim;
    5459        10265 :         auto lineIn = statFile.readLine().data;
    5460              :         // reconcile line with different versions of stat file
    5461              :         // v7.1 added version as first line.
    5462        10265 :         strip(lineIn);
    5463        10265 :         parseStatLine(
    5464              :             lineIn, lineType, desConditionlinepassed, heatingDesignlinepassed, coolingDesignlinepassed, isKoppen, insideLiquidPrecipitation);
    5465              : 
    5466        10265 :         switch (lineType) {
    5467           18 :         case StatLineType::StatisticsLine: { // Statistics for USA_CA_San.Francisco_TMY2
    5468           18 :             PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "Reference", lineIn.substr(15));
    5469           18 :         } break;
    5470           18 :         case StatLineType::LocationLine: { // Location -- SAN_FRANCISCO CA USA
    5471           18 :             PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "Site:Location", lineIn.substr(11));
    5472           18 :         } break;
    5473           18 :         case StatLineType::LatLongLine: { //      {N 37° 37'} {W 122° 22'} {GMT -8.0 Hours}
    5474              :             // find the {}
    5475           18 :             sposlt = index(lineIn, '{');
    5476           18 :             eposlt = index(lineIn, '}');
    5477           18 :             if (sposlt != std::string::npos && eposlt != std::string::npos) {
    5478           18 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "Latitude", lineIn.substr(sposlt, eposlt - sposlt + 1));
    5479              :                 // redefine so next scan can go with {}
    5480           18 :                 lineIn[sposlt] = '[';
    5481           18 :                 lineIn[eposlt] = ']';
    5482              :             } else {
    5483            0 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "Latitude", "not found");
    5484              :             }
    5485           18 :             sposlg = index(lineIn, '{');
    5486           18 :             eposlg = index(lineIn, '}');
    5487           18 :             if (sposlg != std::string::npos && eposlg != std::string::npos) {
    5488           18 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "Longitude", lineIn.substr(sposlg, eposlg - sposlg + 1));
    5489              :                 // redefine so next scan can go with {}
    5490           18 :                 lineIn[sposlg] = '[';
    5491           18 :                 lineIn[eposlg] = ']';
    5492              :             } else {
    5493            0 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "Longitude", "not found");
    5494              :             }
    5495           18 :             spostz = index(lineIn, '{');
    5496           18 :             epostz = index(lineIn, '}');
    5497           18 :             if (spostz != std::string::npos && epostz != std::string::npos) {
    5498           18 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "Time Zone", lineIn.substr(spostz, epostz - spostz + 1));
    5499              :                 // redefine so next scan can go with {}
    5500           18 :                 lineIn[spostz] = '[';
    5501           18 :                 lineIn[epostz] = ']';
    5502              :             } else {
    5503            0 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "Time Zone", "not found");
    5504              :             }
    5505           18 :         } break;
    5506           18 :         case StatLineType::ElevationLine: { // Elevation --     5m above sea level
    5507           18 :             lnPtr = index(lineIn.substr(12), 'm');
    5508           18 :             if (lnPtr != std::string::npos) {
    5509           18 :                 curNameWithSIUnits = "Elevation (m) " + lineIn.substr(12 + lnPtr + 2);
    5510           18 :                 if (ort->ip()) {
    5511            1 :                     LookupSItoIP(state, curNameWithSIUnits, indexUnitConv, curNameAndUnits);
    5512            2 :                     PreDefTableEntry(state,
    5513            1 :                                      state.dataOutRptPredefined->pdchWthrVal,
    5514              :                                      curNameAndUnits,
    5515            2 :                                      RealToStr(ConvertIP(state, indexUnitConv, StrToReal(lineIn.substr(12, lnPtr))), 1));
    5516              :                 } else {
    5517           17 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, curNameWithSIUnits, lineIn.substr(12, lnPtr));
    5518              :                 }
    5519              :             } else {
    5520            0 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "Elevation", "not found");
    5521              :             }
    5522           18 :         } break;
    5523           18 :         case StatLineType::StdPressureLine: { // Standard Pressure at Elevation -- 101265Pa
    5524           18 :             PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "Standard Pressure at Elevation", lineIn.substr(34));
    5525           18 :         } break;
    5526           18 :         case StatLineType::DataSourceLine: { // Data Source -- TMY2-23234
    5527           18 :             PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "Data Source", lineIn.substr(15));
    5528           18 :         } break;
    5529           18 :         case StatLineType::WMOStationLine: { // WMO Station 724940
    5530           18 :             PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "WMO Station", lineIn.substr(12));
    5531           18 :         } break;
    5532           18 :         case StatLineType::DesignConditionsLine: { //  - Using Design Conditions from "Climate Design Data 2005 ASHRAE Handbook"
    5533           18 :             ashPtr = index(lineIn, "ASHRAE");
    5534           18 :             if (ashPtr != std::string::npos) {
    5535           18 :                 isASHRAE = true;
    5536           18 :                 iscalc = true;
    5537           18 :                 if (ashPtr > 4u) { // Autodesk:BoundsViolation IF block added to protect against ashPtr<=5
    5538           18 :                     ashDesYear = lineIn.substr(ashPtr - 5, 5);
    5539              :                 } else {
    5540            0 :                     ashDesYear = "";
    5541              :                 }
    5542           36 :                 PreDefTableEntry(state,
    5543           18 :                                  state.dataOutRptPredefined->pdchWthrVal,
    5544              :                                  "Weather File Design Conditions",
    5545           36 :                                  "Climate Design Data " + ashDesYear + "ASHRAE Handbook");
    5546            0 :             } else if (has(lineIn, "not calculated") || lineIn == "") {
    5547            0 :                 iscalc = false;
    5548            0 :                 PreDefTableEntry(
    5549            0 :                     state, state.dataOutRptPredefined->pdchWthrVal, "Weather File Design Conditions", "not calculated, Number of days < 1 year");
    5550              :             } else {
    5551            0 :                 isASHRAE = false;
    5552            0 :                 iscalc = true;
    5553            0 :                 PreDefTableEntry(
    5554            0 :                     state, state.dataOutRptPredefined->pdchWthrVal, "Weather File Design Conditions", "Calculated from the weather file");
    5555              :             }
    5556           18 :         } break;
    5557           18 :         case StatLineType::HeatingConditionsLine: { //  winter/heating design conditions
    5558           18 :             if (iscalc) {
    5559           18 :                 if (isASHRAE) {
    5560           18 :                     if (ashDesYear == "2001") {
    5561            0 :                         if (ort->ip()) {
    5562            0 :                             curNameWithSIUnits = "Heating Design Temperature 99.6% (C)";
    5563            0 :                             LookupSItoIP(state, curNameWithSIUnits, indexUnitConv, curNameAndUnits);
    5564            0 :                             PreDefTableEntry(state,
    5565            0 :                                              state.dataOutRptPredefined->pdchWthrVal,
    5566              :                                              curNameAndUnits,
    5567            0 :                                              RealToStr(ConvertIP(state, indexUnitConv, StrToReal(GetColumnUsingTabs(lineIn, 2))), 1) + degChar);
    5568            0 :                             PreDefTableEntry(state,
    5569            0 :                                              state.dataOutRptPredefined->pdchWthrVal,
    5570              :                                              "Heating Design Temperature 99% (F)",
    5571            0 :                                              RealToStr(ConvertIP(state, indexUnitConv, StrToReal(GetColumnUsingTabs(lineIn, 3))), 1) + degChar);
    5572              :                         } else {
    5573            0 :                             PreDefTableEntry(state,
    5574            0 :                                              state.dataOutRptPredefined->pdchWthrVal,
    5575              :                                              "Heating Design Temperature 99.6% (C)",
    5576            0 :                                              GetColumnUsingTabs(lineIn, 2) + degChar);
    5577            0 :                             PreDefTableEntry(state,
    5578            0 :                                              state.dataOutRptPredefined->pdchWthrVal,
    5579              :                                              "Heating Design Temperature 99% (C)",
    5580            0 :                                              GetColumnUsingTabs(lineIn, 3) + degChar);
    5581              :                         }
    5582              :                     } else { // 2005 and 2009 are the same
    5583           18 :                         if (ort->ip()) {
    5584            1 :                             curNameWithSIUnits = "Heating Design Temperature 99.6% (C)";
    5585            1 :                             LookupSItoIP(state, curNameWithSIUnits, indexUnitConv, curNameAndUnits);
    5586            2 :                             PreDefTableEntry(state,
    5587            1 :                                              state.dataOutRptPredefined->pdchWthrVal,
    5588              :                                              curNameAndUnits,
    5589            2 :                                              RealToStr(ConvertIP(state, indexUnitConv, StrToReal(GetColumnUsingTabs(lineIn, 4))), 1) + degChar);
    5590            2 :                             PreDefTableEntry(state,
    5591            1 :                                              state.dataOutRptPredefined->pdchWthrVal,
    5592              :                                              "Heating Design Temperature 99% (F)",
    5593            2 :                                              RealToStr(ConvertIP(state, indexUnitConv, StrToReal(GetColumnUsingTabs(lineIn, 5))), 1) + degChar);
    5594              :                         } else {
    5595           34 :                             PreDefTableEntry(state,
    5596           17 :                                              state.dataOutRptPredefined->pdchWthrVal,
    5597              :                                              "Heating Design Temperature 99.6% (C)",
    5598           34 :                                              GetColumnUsingTabs(lineIn, 4) + degChar);
    5599           34 :                             PreDefTableEntry(state,
    5600           17 :                                              state.dataOutRptPredefined->pdchWthrVal,
    5601              :                                              "Heating Design Temperature 99% (C)",
    5602           34 :                                              GetColumnUsingTabs(lineIn, 5) + degChar);
    5603              :                         }
    5604              :                     }
    5605              :                 } else { // from weather file
    5606            0 :                     if (is_blank(GetColumnUsingTabs(lineIn, 5))) {
    5607            0 :                         col1 = 3;
    5608            0 :                         col2 = 4;
    5609              :                     } else {
    5610            0 :                         col1 = 4;
    5611            0 :                         col2 = 5;
    5612              :                     }
    5613            0 :                     if (ort->ip()) {
    5614            0 :                         curNameWithSIUnits = "Heating Design Temperature 99.6% (C)";
    5615            0 :                         LookupSItoIP(state, curNameWithSIUnits, indexUnitConv, curNameAndUnits);
    5616            0 :                         PreDefTableEntry(state,
    5617            0 :                                          state.dataOutRptPredefined->pdchWthrVal,
    5618              :                                          curNameAndUnits,
    5619            0 :                                          RealToStr(ConvertIP(state, indexUnitConv, StrToReal(GetColumnUsingTabs(lineIn, col1))), 1) + degChar);
    5620            0 :                         PreDefTableEntry(state,
    5621            0 :                                          state.dataOutRptPredefined->pdchWthrVal,
    5622              :                                          "Heating Design Temperature 99% (F)",
    5623            0 :                                          RealToStr(ConvertIP(state, indexUnitConv, StrToReal(GetColumnUsingTabs(lineIn, col2))), 1) + degChar);
    5624              :                     } else {
    5625            0 :                         PreDefTableEntry(state,
    5626            0 :                                          state.dataOutRptPredefined->pdchWthrVal,
    5627              :                                          "Heating Design Temperature 99.6% (C)",
    5628            0 :                                          GetColumnUsingTabs(lineIn, col1) + degChar);
    5629            0 :                         PreDefTableEntry(state,
    5630            0 :                                          state.dataOutRptPredefined->pdchWthrVal,
    5631              :                                          "Heating Design Temperature 99% (C)",
    5632            0 :                                          GetColumnUsingTabs(lineIn, col2) + degChar);
    5633              :                     }
    5634              :                 }
    5635              :             }
    5636           18 :         } break;
    5637           18 :         case StatLineType::CoolingConditionsLine: { //  summer/cooling design conditions
    5638           18 :             if (iscalc) {
    5639           18 :                 if (isASHRAE) {
    5640           18 :                     if (ashDesYear == "2001") {
    5641            0 :                         if (ort->ip()) {
    5642            0 :                             curNameWithSIUnits = "Cooling Design Temperature 0.4% (C)";
    5643            0 :                             LookupSItoIP(state, curNameWithSIUnits, indexUnitConv, curNameAndUnits);
    5644            0 :                             PreDefTableEntry(state,
    5645            0 :                                              state.dataOutRptPredefined->pdchWthrVal,
    5646              :                                              curNameAndUnits,
    5647            0 :                                              RealToStr(ConvertIP(state, indexUnitConv, StrToReal(GetColumnUsingTabs(lineIn, 2))), 1) + degChar);
    5648            0 :                             PreDefTableEntry(state,
    5649            0 :                                              state.dataOutRptPredefined->pdchWthrVal,
    5650              :                                              "Cooling Design Temperature 1% (F)",
    5651            0 :                                              RealToStr(ConvertIP(state, indexUnitConv, StrToReal(GetColumnUsingTabs(lineIn, 4))), 1) + degChar);
    5652            0 :                             PreDefTableEntry(state,
    5653            0 :                                              state.dataOutRptPredefined->pdchWthrVal,
    5654              :                                              "Cooling Design Temperature 2% (F)",
    5655            0 :                                              RealToStr(ConvertIP(state, indexUnitConv, StrToReal(GetColumnUsingTabs(lineIn, 6))), 1) + degChar);
    5656              :                         } else {
    5657            0 :                             PreDefTableEntry(state,
    5658            0 :                                              state.dataOutRptPredefined->pdchWthrVal,
    5659              :                                              "Cooling Design Temperature 0.4% (C)",
    5660            0 :                                              GetColumnUsingTabs(lineIn, 2) + degChar);
    5661            0 :                             PreDefTableEntry(state,
    5662            0 :                                              state.dataOutRptPredefined->pdchWthrVal,
    5663              :                                              "Cooling Design Temperature 1% (C)",
    5664            0 :                                              GetColumnUsingTabs(lineIn, 4) + degChar);
    5665            0 :                             PreDefTableEntry(state,
    5666            0 :                                              state.dataOutRptPredefined->pdchWthrVal,
    5667              :                                              "Cooling Design Temperature 2% (C)",
    5668            0 :                                              GetColumnUsingTabs(lineIn, 6) + degChar);
    5669              :                         }
    5670              :                     } else { // 2005 and 2009 are the same
    5671           18 :                         if (ort->ip()) {
    5672            1 :                             curNameWithSIUnits = "Cooling Design Temperature 0.4% (C)";
    5673            1 :                             LookupSItoIP(state, curNameWithSIUnits, indexUnitConv, curNameAndUnits);
    5674            2 :                             PreDefTableEntry(state,
    5675            1 :                                              state.dataOutRptPredefined->pdchWthrVal,
    5676              :                                              curNameAndUnits,
    5677            2 :                                              RealToStr(ConvertIP(state, indexUnitConv, StrToReal(GetColumnUsingTabs(lineIn, 5))), 1) + degChar);
    5678            2 :                             PreDefTableEntry(state,
    5679            1 :                                              state.dataOutRptPredefined->pdchWthrVal,
    5680              :                                              "Cooling Design Temperature 1% (F)",
    5681            2 :                                              RealToStr(ConvertIP(state, indexUnitConv, StrToReal(GetColumnUsingTabs(lineIn, 7))), 1) + degChar);
    5682            2 :                             PreDefTableEntry(state,
    5683            1 :                                              state.dataOutRptPredefined->pdchWthrVal,
    5684              :                                              "Cooling Design Temperature 2% (F)",
    5685            2 :                                              RealToStr(ConvertIP(state, indexUnitConv, StrToReal(GetColumnUsingTabs(lineIn, 9))), 1) + degChar);
    5686              :                         } else {
    5687           34 :                             PreDefTableEntry(state,
    5688           17 :                                              state.dataOutRptPredefined->pdchWthrVal,
    5689              :                                              "Cooling Design Temperature 0.4% (C)",
    5690           34 :                                              GetColumnUsingTabs(lineIn, 5) + degChar);
    5691           34 :                             PreDefTableEntry(state,
    5692           17 :                                              state.dataOutRptPredefined->pdchWthrVal,
    5693              :                                              "Cooling Design Temperature 1% (C)",
    5694           34 :                                              GetColumnUsingTabs(lineIn, 7) + degChar);
    5695           34 :                             PreDefTableEntry(state,
    5696           17 :                                              state.dataOutRptPredefined->pdchWthrVal,
    5697              :                                              "Cooling Design Temperature 2% (C)",
    5698           34 :                                              GetColumnUsingTabs(lineIn, 9) + degChar);
    5699              :                         }
    5700              :                     }
    5701              :                 } else { // from weather file
    5702            0 :                     if (is_blank(GetColumnUsingTabs(lineIn, 6))) {
    5703            0 :                         col1 = 3;
    5704            0 :                         col2 = 4;
    5705            0 :                         col3 = 5;
    5706              :                     } else {
    5707            0 :                         col1 = 4;
    5708            0 :                         col2 = 5;
    5709            0 :                         col3 = 6;
    5710              :                     }
    5711            0 :                     if (ort->ip()) {
    5712            0 :                         curNameWithSIUnits = "Cooling Design Temperature 0.4% (C)";
    5713            0 :                         LookupSItoIP(state, curNameWithSIUnits, indexUnitConv, curNameAndUnits);
    5714            0 :                         PreDefTableEntry(state,
    5715            0 :                                          state.dataOutRptPredefined->pdchWthrVal,
    5716              :                                          curNameAndUnits,
    5717            0 :                                          RealToStr(ConvertIP(state, indexUnitConv, StrToReal(GetColumnUsingTabs(lineIn, col1))), 1) + degChar);
    5718            0 :                         PreDefTableEntry(state,
    5719            0 :                                          state.dataOutRptPredefined->pdchWthrVal,
    5720              :                                          "Cooling Design Temperature 1% (F)",
    5721            0 :                                          RealToStr(ConvertIP(state, indexUnitConv, StrToReal(GetColumnUsingTabs(lineIn, col2))), 1) + degChar);
    5722            0 :                         PreDefTableEntry(state,
    5723            0 :                                          state.dataOutRptPredefined->pdchWthrVal,
    5724              :                                          "Cooling Design Temperature 2% (F)",
    5725            0 :                                          RealToStr(ConvertIP(state, indexUnitConv, StrToReal(GetColumnUsingTabs(lineIn, col3))), 1) + degChar);
    5726              :                     } else {
    5727            0 :                         PreDefTableEntry(state,
    5728            0 :                                          state.dataOutRptPredefined->pdchWthrVal,
    5729              :                                          "Cooling Design Temperature 0.4% (C)",
    5730            0 :                                          GetColumnUsingTabs(lineIn, col1) + degChar);
    5731            0 :                         PreDefTableEntry(state,
    5732            0 :                                          state.dataOutRptPredefined->pdchWthrVal,
    5733              :                                          "Cooling Design Temperature 1% (C)",
    5734            0 :                                          GetColumnUsingTabs(lineIn, col2) + degChar);
    5735            0 :                         PreDefTableEntry(state,
    5736            0 :                                          state.dataOutRptPredefined->pdchWthrVal,
    5737              :                                          "Cooling Design Temperature 2% (C)",
    5738            0 :                                          GetColumnUsingTabs(lineIn, col3) + degChar);
    5739              :                     }
    5740              :                 }
    5741              :             }
    5742           18 :         } break;
    5743           18 :         case StatLineType::StdHDDLine: { //  - 1745 annual (standard) heating degree-days (10°C baseline)
    5744           18 :             storeASHRAEHDD = lineIn.substr(2, 4);
    5745           18 :         } break;
    5746           18 :         case StatLineType::StdCDDLine: { //  -  464 annual (standard) cooling degree-days (18.3°C baseline)
    5747           18 :             storeASHRAECDD = lineIn.substr(2, 4);
    5748           18 :         } break;
    5749           18 :         case StatLineType::MaxDryBulbLine: { //   - Maximum Dry Bulb temperature of  35.6°C on Jul  9
    5750           18 :             sposlt = index(lineIn, "of");
    5751           18 :             eposlt = index(lineIn, 'C');
    5752           18 :             sposlt += 2;
    5753           18 :             size_t deg_index = index(lineIn, degChar);
    5754           18 :             if (deg_index != std::string::npos) {
    5755            0 :                 eposlt = deg_index - 1;
    5756              :             } else {
    5757           18 :                 eposlt -= 2;
    5758              :             }
    5759           18 :             if (sposlt != std::string::npos && eposlt != std::string::npos) {
    5760           36 :                 if (ort->ip()) {
    5761            1 :                     curNameWithSIUnits = "Maximum Dry Bulb Temperature (C)";
    5762            1 :                     LookupSItoIP(state, curNameWithSIUnits, indexUnitConv, curNameAndUnits);
    5763            2 :                     PreDefTableEntry(state,
    5764            1 :                                      state.dataOutRptPredefined->pdchWthrVal,
    5765              :                                      curNameAndUnits,
    5766            2 :                                      RealToStr(ConvertIP(state, indexUnitConv, StrToReal(lineIn.substr(sposlt, eposlt - sposlt + 1))), 1) + degChar);
    5767              :                 } else {
    5768           34 :                     PreDefTableEntry(state,
    5769           17 :                                      state.dataOutRptPredefined->pdchWthrVal,
    5770              :                                      "Maximum Dry Bulb Temperature (C)",
    5771           34 :                                      lineIn.substr(sposlt, eposlt - sposlt + 1) + degChar);
    5772              :                 }
    5773              :             } else {
    5774            0 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "Maximum Dry Bulb Temperature", "not found");
    5775              :             }
    5776           18 :             sposlt = index(lineIn, "on");
    5777           18 :             sposlt += 2;
    5778           18 :             if (sposlt != std::string::npos) {
    5779           18 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "Maximum Dry Bulb Occurs on", lineIn.substr(sposlt));
    5780              :             } else {
    5781            0 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "Maximum Dry Bulb Occurs on", "not found");
    5782              :             }
    5783           18 :         } break;
    5784           18 :         case StatLineType::MinDryBulbLine: { //   - Minimum Dry Bulb temperature of -22.8°C on Jan  7
    5785           18 :             sposlt = index(lineIn, "of");
    5786           18 :             eposlt = index(lineIn, 'C');
    5787           18 :             sposlt += 2;
    5788           18 :             size_t deg_index = index(lineIn, degChar);
    5789           18 :             if (deg_index != std::string::npos) {
    5790            0 :                 eposlt = deg_index - 1;
    5791              :             } else {
    5792           18 :                 eposlt -= 2;
    5793              :             }
    5794           18 :             if (sposlt != std::string::npos && eposlt != std::string::npos) {
    5795           36 :                 if (ort->ip()) {
    5796            1 :                     curNameWithSIUnits = "Minimum Dry Bulb Temperature (C)";
    5797            1 :                     LookupSItoIP(state, curNameWithSIUnits, indexUnitConv, curNameAndUnits);
    5798            2 :                     PreDefTableEntry(state,
    5799            1 :                                      state.dataOutRptPredefined->pdchWthrVal,
    5800              :                                      curNameAndUnits,
    5801            2 :                                      RealToStr(ConvertIP(state, indexUnitConv, StrToReal(lineIn.substr(sposlt, eposlt - sposlt + 1))), 1) + degChar);
    5802              :                 } else {
    5803           34 :                     PreDefTableEntry(state,
    5804           17 :                                      state.dataOutRptPredefined->pdchWthrVal,
    5805              :                                      "Minimum Dry Bulb Temperature (C)",
    5806           34 :                                      lineIn.substr(sposlt, eposlt - sposlt + 1) + degChar);
    5807              :                 }
    5808              :             } else {
    5809            0 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "Minimum Dry Bulb Temperature", "not found");
    5810              :             }
    5811           18 :             sposlt = index(lineIn, "on");
    5812           18 :             sposlt += 2;
    5813           18 :             if (sposlt != std::string::npos) {
    5814           18 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "Minimum Dry Bulb Occurs on", lineIn.substr(sposlt));
    5815              :             } else {
    5816            0 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "Minimum Dry Bulb Occurs on", "not found");
    5817              :             }
    5818           18 :         } break;
    5819           18 :         case StatLineType::MaxDewPointLine: { //   - Maximum Dew Point temperature of  25.6°C on Aug  4
    5820           18 :             sposlt = index(lineIn, "of");
    5821           18 :             eposlt = index(lineIn, 'C');
    5822           18 :             sposlt += 2;
    5823           18 :             size_t deg_index = index(lineIn, degChar);
    5824           18 :             if (deg_index != std::string::npos) {
    5825            0 :                 eposlt = deg_index - 1;
    5826              :             } else {
    5827           18 :                 eposlt -= 2;
    5828              :             }
    5829           18 :             if (sposlt != std::string::npos && eposlt != std::string::npos) {
    5830           36 :                 if (ort->ip()) {
    5831            1 :                     curNameWithSIUnits = "Maximum Dew Point Temperature (C)";
    5832            1 :                     LookupSItoIP(state, curNameWithSIUnits, indexUnitConv, curNameAndUnits);
    5833            2 :                     PreDefTableEntry(state,
    5834            1 :                                      state.dataOutRptPredefined->pdchWthrVal,
    5835              :                                      curNameAndUnits,
    5836            2 :                                      RealToStr(ConvertIP(state, indexUnitConv, StrToReal(lineIn.substr(sposlt, eposlt - sposlt + 1))), 1) + degChar);
    5837              :                 } else {
    5838           34 :                     PreDefTableEntry(state,
    5839           17 :                                      state.dataOutRptPredefined->pdchWthrVal,
    5840              :                                      "Maximum Dew Point Temperature (C)",
    5841           34 :                                      lineIn.substr(sposlt, eposlt - sposlt + 1) + degChar);
    5842              :                 }
    5843              :             } else {
    5844            0 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "Maximum Dew Point Temperature", "not found");
    5845              :             }
    5846           18 :             sposlt = index(lineIn, "on");
    5847           18 :             sposlt += 2;
    5848           18 :             if (sposlt != std::string::npos) {
    5849           18 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "Maximum Dew Point Occurs on", lineIn.substr(sposlt));
    5850              :             } else {
    5851            0 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "Maximum Dew Point Occurs on", "not found");
    5852              :             }
    5853           18 :         } break;
    5854           18 :         case StatLineType::MinDewPointLine: { //   - Minimum Dew Point temperature of -28.9°C on Dec 31
    5855           18 :             sposlt = index(lineIn, "of");
    5856           18 :             eposlt = index(lineIn, 'C');
    5857           18 :             sposlt += 2;
    5858           18 :             size_t deg_index = index(lineIn, degChar);
    5859           18 :             if (deg_index != std::string::npos) {
    5860            0 :                 eposlt = deg_index - 1;
    5861              :             } else {
    5862           18 :                 eposlt -= 2;
    5863              :             }
    5864           18 :             if (sposlt != std::string::npos && eposlt != std::string::npos) {
    5865           36 :                 if (ort->ip()) {
    5866            1 :                     curNameWithSIUnits = "Minimum Dew Point Temperature (C)";
    5867            1 :                     LookupSItoIP(state, curNameWithSIUnits, indexUnitConv, curNameAndUnits);
    5868            2 :                     PreDefTableEntry(state,
    5869            1 :                                      state.dataOutRptPredefined->pdchWthrVal,
    5870              :                                      curNameAndUnits,
    5871            2 :                                      RealToStr(ConvertIP(state, indexUnitConv, StrToReal(lineIn.substr(sposlt, eposlt - sposlt + 1))), 1) + degChar);
    5872              :                 } else {
    5873           34 :                     PreDefTableEntry(state,
    5874           17 :                                      state.dataOutRptPredefined->pdchWthrVal,
    5875              :                                      "Minimum Dew Point Temperature (C)",
    5876           34 :                                      lineIn.substr(sposlt, eposlt - sposlt + 1) + degChar);
    5877              :                 }
    5878              :             } else {
    5879            0 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "Minimum Dew Point Temperature", "not found");
    5880              :             }
    5881           18 :             sposlt = index(lineIn, "on");
    5882           18 :             sposlt += 2;
    5883           18 :             if (sposlt != std::string::npos) {
    5884           18 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "Minimum Dew Point Occurs on", lineIn.substr(sposlt));
    5885              :             } else {
    5886            0 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "Minimum Dew Point Occurs on", "not found");
    5887              :             }
    5888           18 :         } break;
    5889           18 :         case StatLineType::MonthlyPrec: { //   - Monthly precipitation mm
    5890           18 :             std::stringstream ss(lineIn);
    5891           18 :             std::vector<std::string> result;
    5892          288 :             while (ss.good()) {
    5893          270 :                 std::string substr;
    5894          270 :                 getline(ss, substr, '\t');
    5895          270 :                 substr.erase(remove_if(substr.begin(), substr.end(), isspace), substr.end());
    5896          270 :                 result.push_back(substr);
    5897          270 :             }
    5898              :             int monthlyTotalPrecFromStat[12];
    5899           18 :             int annualTotalPrecFromStat = 0;
    5900          234 :             for (int i = 0; i < 12; i++) {
    5901          216 :                 monthlyTotalPrecFromStat[i] = std::stoi(result[i + 2]);
    5902              :                 // fixme: add to monthly data structure
    5903          216 :                 annualTotalPrecFromStat += monthlyTotalPrecFromStat[i];
    5904              :             }
    5905           18 :             PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "Annual Total Precipitation [mm]", annualTotalPrecFromStat);
    5906              :             // fixme: store the monthly data in some data structure
    5907           18 :         } break;
    5908           18 :         case StatLineType::MaxHourlyPrec: { //   - Highest hourly precipitation in each month
    5909              :             // Split string by \t into substrings and remove the space in each substring
    5910           18 :             std::stringstream ss(lineIn);
    5911           18 :             std::vector<std::string> result;
    5912          288 :             while (ss.good()) {
    5913          270 :                 std::string substr;
    5914          270 :                 getline(ss, substr, '\t');
    5915          270 :                 substr.erase(remove_if(substr.begin(), substr.end(), isspace), substr.end());
    5916          270 :                 result.push_back(substr);
    5917          270 :             }
    5918              :             int MaxHourlyPrecEachMonth[12];
    5919           18 :             int MaxHourlyPrec = 0;
    5920           18 :             int MaxHourlyPrecIdx = 0;
    5921          234 :             for (int i = 0; i < 12; i++) {
    5922          216 :                 MaxHourlyPrecEachMonth[i] = std::stoi(result[i + 2]);
    5923          216 :                 if (MaxHourlyPrecEachMonth[i] > MaxHourlyPrec) {
    5924           19 :                     MaxHourlyPrec = MaxHourlyPrecEachMonth[i];
    5925           19 :                     MaxHourlyPrecIdx = i;
    5926              :                 }
    5927              :             }
    5928           18 :             constexpr std::array<std::string_view, 12> Months{"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
    5929           18 :             PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "Max Hourly Precipitation [mm]", MaxHourlyPrec);
    5930           18 :             PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "Max Hourly Precipitation Occurs in", Months[MaxHourlyPrecIdx]);
    5931           18 :         } break;
    5932           18 :         case StatLineType::WithHDDLine: { //  - 1745 (wthr file) annual heating degree-days (10°C baseline)
    5933           18 :             if (storeASHRAEHDD != "") {
    5934           18 :                 if (ort->ip()) {
    5935            1 :                     curNameWithSIUnits = "ASHRAE Handbook 2009 Heating Degree-Days - base 65°(C)";
    5936            1 :                     LookupSItoIP(state, curNameWithSIUnits, indexUnitConv, curNameAndUnits);
    5937            2 :                     PreDefTableEntry(state,
    5938            1 :                                      state.dataOutRptPredefined->pdchWthrVal,
    5939              :                                      curNameAndUnits,
    5940            2 :                                      RealToStr(ConvertIPdelta(state, indexUnitConv, StrToReal(storeASHRAEHDD)), 1));
    5941              :                 } else {
    5942           34 :                     PreDefTableEntry(
    5943           17 :                         state, state.dataOutRptPredefined->pdchWthrVal, "ASHRAE Handbook 2009 Heating Degree-Days (base 18.3°C)", storeASHRAEHDD);
    5944              :                 }
    5945              :             } else {
    5946            0 :                 if (ort->ip()) {
    5947            0 :                     PreDefTableEntry(
    5948            0 :                         state, state.dataOutRptPredefined->pdchWthrVal, "ASHRAE Handbook 2009 Heating Degree-Days (base 65°F)", "not found");
    5949              :                 } else {
    5950            0 :                     PreDefTableEntry(
    5951            0 :                         state, state.dataOutRptPredefined->pdchWthrVal, "ASHRAE Handbook 2009 Heating Degree-Days (base 18.3°C)", "not found");
    5952              :                 }
    5953              :             }
    5954           18 :             if (ort->ip()) {
    5955            1 :                 curNameWithSIUnits = "Weather File Heating Degree-Days - base 65°(C)";
    5956            1 :                 LookupSItoIP(state, curNameWithSIUnits, indexUnitConv, curNameAndUnits);
    5957            2 :                 PreDefTableEntry(state,
    5958            1 :                                  state.dataOutRptPredefined->pdchWthrVal,
    5959              :                                  curNameAndUnits,
    5960            2 :                                  RealToStr(ConvertIPdelta(state, indexUnitConv, StrToReal(lineIn.substr(2, 4))), 1));
    5961            2 :                 PreDefTableEntry(state,
    5962            1 :                                  state.dataOutRptPredefined->pdchLeedGenData,
    5963              :                                  "Heating Degree Days",
    5964            2 :                                  RealToStr(ConvertIPdelta(state, indexUnitConv, StrToReal(lineIn.substr(2, 4))), 1));
    5965              :             } else {
    5966           17 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "Weather File Heating Degree-Days (base 18°C)", lineIn.substr(2, 4));
    5967           17 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchLeedGenData, "Heating Degree Days", lineIn.substr(2, 4));
    5968              :             }
    5969           18 :             PreDefTableEntry(state, state.dataOutRptPredefined->pdchLeedGenData, "HDD and CDD data source", "Weather File Stat");
    5970           18 :         } break;
    5971           18 :         case StatLineType::WithCDDLine: { //  -  464 (wthr file) annual cooling degree-days (18°C baseline)
    5972           18 :             if (storeASHRAECDD != "") {
    5973           18 :                 if (ort->ip()) {
    5974            1 :                     curNameWithSIUnits = "ASHRAE Handbook 2009  Cooling Degree-Days - base 50°(C)";
    5975            1 :                     LookupSItoIP(state, curNameWithSIUnits, indexUnitConv, curNameAndUnits);
    5976            2 :                     PreDefTableEntry(state,
    5977            1 :                                      state.dataOutRptPredefined->pdchWthrVal,
    5978              :                                      curNameAndUnits,
    5979            2 :                                      RealToStr(ConvertIPdelta(state, indexUnitConv, StrToReal(storeASHRAECDD)), 1));
    5980              :                 } else {
    5981           34 :                     PreDefTableEntry(
    5982           17 :                         state, state.dataOutRptPredefined->pdchWthrVal, "ASHRAE Handbook 2009  Cooling Degree-Days (base 10°C)", storeASHRAECDD);
    5983              :                 }
    5984              :             } else {
    5985            0 :                 if (ort->ip()) {
    5986            0 :                     PreDefTableEntry(
    5987            0 :                         state, state.dataOutRptPredefined->pdchWthrVal, "ASHRAE Handbook 2009  Cooling Degree-Days (base 50°F)", "not found");
    5988              :                 } else {
    5989            0 :                     PreDefTableEntry(
    5990            0 :                         state, state.dataOutRptPredefined->pdchWthrVal, "ASHRAE Handbook 2009  Cooling Degree-Days (base 10°C)", "not found");
    5991              :                 }
    5992              :             }
    5993           18 :             if (ort->ip()) {
    5994            1 :                 curNameWithSIUnits = "Weather File Cooling Degree-Days - base 50°(C)";
    5995            1 :                 LookupSItoIP(state, curNameWithSIUnits, indexUnitConv, curNameAndUnits);
    5996            2 :                 PreDefTableEntry(state,
    5997            1 :                                  state.dataOutRptPredefined->pdchWthrVal,
    5998              :                                  curNameAndUnits,
    5999            2 :                                  RealToStr(ConvertIPdelta(state, indexUnitConv, StrToReal(lineIn.substr(2, 4))), 1));
    6000            2 :                 PreDefTableEntry(state,
    6001            1 :                                  state.dataOutRptPredefined->pdchLeedGenData,
    6002              :                                  "Cooling Degree Days",
    6003            2 :                                  RealToStr(ConvertIPdelta(state, indexUnitConv, StrToReal(lineIn.substr(2, 4))), 1));
    6004              :             } else {
    6005           17 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "Weather File Cooling Degree-Days (base 10°C)", lineIn.substr(2, 4));
    6006           17 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchLeedGenData, "Cooling Degree Days", lineIn.substr(2, 4));
    6007              :             }
    6008           18 :         } break;
    6009           18 :         case StatLineType::KoppenLine: { // - Climate type "BSk" (Köppen classification)
    6010           18 :             if (!has(lineIn, "not shown")) {
    6011           18 :                 isKoppen = true;
    6012           18 :                 if (lineIn[18] == '"') { // two character classification
    6013            0 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "Köppen Classification", lineIn.substr(16, 2));
    6014              :                 } else {
    6015           18 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "Köppen Classification", lineIn.substr(16, 3));
    6016              :                 }
    6017              :             } else {
    6018            0 :                 isKoppen = false;
    6019            0 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "Köppen Recommendation", lineIn.substr(2));
    6020              :             }
    6021           18 :         } break;
    6022           18 :         case StatLineType::KoppenDes1Line: { // - Tropical monsoonal or tradewind-coastal (short dry season, lat. 5-25°)
    6023           18 :             if (isKoppen) {
    6024           18 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "Köppen Description", lineIn.substr(2));
    6025              :             }
    6026           18 :         } break;
    6027           18 :         case StatLineType::KoppenDes2Line: { // - Unbearably humid periods in summer, but passive cooling is possible
    6028           18 :             if (isKoppen) {
    6029           18 :                 if (len(lineIn) > 3) {                 // avoid blank lines
    6030           17 :                     if (lineIn.substr(2, 2) != "**") { // avoid line with warning
    6031           17 :                         PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "Köppen Recommendation", lineIn.substr(2));
    6032              :                     } else {
    6033            0 :                         PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "Köppen Recommendation", "");
    6034              :                     }
    6035              :                 } else {
    6036            1 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "Köppen Recommendation", "");
    6037              :                 }
    6038              :             }
    6039           18 :         } break;
    6040           72 :         case StatLineType::AshStdLine:
    6041              :         case StatLineType::AshStdDes1Line:
    6042              :         case StatLineType::AshStdDes2Line:
    6043              :         case StatLineType::AshStdDes3Line: {
    6044              :             //  - Climate type "1A" (ASHRAE Standards 90.1-2004 and 90.2-2004 Climate Zone)**
    6045           72 :             if (has(lineIn, "Standard")) {
    6046           18 :                 ashZone = lineIn.substr(16, 2);
    6047           18 :                 if (ashZone[1] == '"') ashZone[1] = ' ';
    6048           18 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "ASHRAE Climate Zone", ashZone);
    6049           18 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchLeedGenData, "Climate Zone", ashZone);
    6050           18 :                 if (ashZone == "1A") {
    6051            0 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "ASHRAE Description", "Very Hot-Humid");
    6052           18 :                 } else if (ashZone == "1B") {
    6053            0 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "ASHRAE Description", "Very Hot-Dry");
    6054           18 :                 } else if (ashZone == "2A") {
    6055            0 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "ASHRAE Description", "Hot-Humid");
    6056           18 :                 } else if (ashZone == "2B") {
    6057            0 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "ASHRAE Description", "Hot-Dry");
    6058           18 :                 } else if (ashZone == "3A") {
    6059            0 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "ASHRAE Description", "Warm-Humid");
    6060           18 :                 } else if (ashZone == "3B") {
    6061            0 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "ASHRAE Description", "Warm-Dry");
    6062           18 :                 } else if (ashZone == "3C") {
    6063            0 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "ASHRAE Description", "Warm-Marine");
    6064           18 :                 } else if (ashZone == "4A") {
    6065            0 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "ASHRAE Description", "Mixed-Humid");
    6066           18 :                 } else if (ashZone == "4B") {
    6067            0 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "ASHRAE Description", "Mixed-Dry");
    6068           18 :                 } else if (ashZone == "4C") {
    6069            0 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "ASHRAE Description", "Mixed-Marine");
    6070           18 :                 } else if (ashZone == "5A") {
    6071           18 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "ASHRAE Description", "Cool-Humid");
    6072            0 :                 } else if (ashZone == "5B") {
    6073            0 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "ASHRAE Description", "Cool-Dry");
    6074            0 :                 } else if (ashZone == "5C") {
    6075            0 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "ASHRAE Description", "Cool-Marine");
    6076            0 :                 } else if (ashZone == "6A") {
    6077            0 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "ASHRAE Description", "Cold-Humid");
    6078            0 :                 } else if (ashZone == "6B") {
    6079            0 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "ASHRAE Description", "Cold-Dry");
    6080            0 :                 } else if (ashZone == "7 ") {
    6081            0 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "ASHRAE Description", "Very Cold");
    6082            0 :                 } else if (ashZone == "8 ") {
    6083            0 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "ASHRAE Description", "Subarctic");
    6084              :                 }
    6085              :             }
    6086           72 :         } break;
    6087         9779 :         default:
    6088         9779 :             break;
    6089              :         }
    6090        10265 :         lineIn = "";
    6091        10265 :         lineTypeinterim = StatLineType::Initialized;
    6092        10265 :         if (lineType == StatLineType::AshStdDes3Line) lineTypeinterim = StatLineType::Initialized;
    6093        10265 :         if (lineType == StatLineType::AshStdDes2Line) lineTypeinterim = StatLineType::AshStdDes2Line;
    6094        10265 :         if (lineType == StatLineType::AshStdDes1Line) lineTypeinterim = StatLineType::AshStdDes1Line;
    6095        10265 :         if (lineType == StatLineType::AshStdLine) lineTypeinterim = StatLineType::AshStdLine;
    6096        10265 :         if (lineType == StatLineType::KoppenDes2Line) lineTypeinterim = StatLineType::Initialized;
    6097        10265 :         if (lineType == StatLineType::KoppenDes1Line) lineTypeinterim = StatLineType::KoppenDes1Line;
    6098        10265 :         if (lineType == StatLineType::KoppenLine) lineTypeinterim = StatLineType::KoppenLine;
    6099        10265 :     }
    6100           18 : }
    6101              : 
    6102          136 : std::string GetColumnUsingTabs(std::string const &inString, // Input String
    6103              :                                int const colNum             // Column number
    6104              : )
    6105              : {
    6106              :     // SUBROUTINE INFORMATION:
    6107              :     //       AUTHOR         Jason Glazer
    6108              :     //       DATE WRITTEN   March 2008
    6109              :     //       MODIFIED       na
    6110              :     //       RE-ENGINEERED  na
    6111              : 
    6112              :     // PURPOSE OF THIS SUBROUTINE:
    6113              :     //   Assumes that the input string contains tabs that mark the
    6114              :     //   separation between columns. Returns the string that appears
    6115              :     //   in the column specified.
    6116              : 
    6117              :     // SUBROUTINE PARAMETER DEFINITIONS:
    6118              :     static char const tb('\t'); // tab character
    6119              : 
    6120              :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
    6121          136 :     std::string::size_type startPos = 0;
    6122              : 
    6123          136 :     size_t endPos = inString.find_first_of(tb);
    6124          136 :     if (colNum == 1) {
    6125            9 :         if (endPos == std::string::npos) return inString;
    6126            7 :         return inString.substr(startPos, endPos - startPos);
    6127              :     }
    6128          131 :     if (endPos == std::string::npos) return "";
    6129              : 
    6130          125 :     int numCols = 1;
    6131          700 :     while (numCols < colNum) {
    6132          588 :         startPos = endPos + 1;
    6133          588 :         endPos = inString.find_first_of(tb, startPos);
    6134          588 :         ++numCols;
    6135          588 :         if (endPos == std::string::npos) break;
    6136              :     }
    6137          137 :     if (colNum > numCols) return "";
    6138          119 :     if (endPos == std::string::npos) endPos = inString.size();
    6139          119 :     return inString.substr(startPos, endPos - startPos);
    6140              : }
    6141              : 
    6142           73 : void FillRemainingPredefinedEntries(EnergyPlusData &state)
    6143              : {
    6144              :     // SUBROUTINE INFORMATION:
    6145              :     //       AUTHOR         Jason Glazer
    6146              :     //       DATE WRITTEN   May 2007
    6147              :     //       MODIFIED       na
    6148              :     //       RE-ENGINEERED  na
    6149              : 
    6150              :     // PURPOSE OF THIS SUBROUTINE:
    6151              :     //   Just before writing the output reports, will gather up
    6152              :     //   any additional report entries for the predefined reports.
    6153              : 
    6154              :     // Using/Aliasing
    6155           73 :     int NumPrimaryAirSys = state.dataHVACGlobal->NumPrimaryAirSys;
    6156           73 :     int iNumberOfAutoCalcedFields = state.dataOutput->iNumberOfAutoCalcedFields;
    6157           73 :     int iNumberOfAutoSizedFields = state.dataOutput->iNumberOfAutoSizedFields;
    6158           73 :     int iNumberOfDefaultedFields = state.dataOutput->iNumberOfDefaultedFields;
    6159           73 :     int iNumberOfRecords = state.dataOutput->iNumberOfRecords;
    6160           73 :     int iTotalAutoCalculatableFields = state.dataOutput->iTotalAutoCalculatableFields;
    6161           73 :     int iTotalAutoSizableFields = state.dataOutput->iTotalAutoSizableFields;
    6162           73 :     int iTotalFieldsWithDefaults = state.dataOutput->iTotalFieldsWithDefaults;
    6163              : 
    6164              :     Real64 consumptionTotal;
    6165              : 
    6166           73 :     auto const &ort = state.dataOutRptTab;
    6167              : 
    6168           73 :     int StartOfWeek = state.dataEnvrn->RunPeriodStartDayOfWeek;
    6169           73 :     if (StartOfWeek == 0) {
    6170           73 :         StartOfWeek = 2; // if the first day of the week has not been set yet, assume monday
    6171              :     }
    6172              : 
    6173              :     // Interior Connected Lighting Power
    6174           73 :     consumptionTotal = 0.0;
    6175          111 :     for (int iLight = 1; iLight <= state.dataHeatBal->TotLights; ++iLight) {
    6176           38 :         auto const &thisLight = state.dataHeatBal->Lights(iLight);
    6177           38 :         int const iZone = state.dataHeatBal->Lights(iLight).ZonePtr;
    6178           38 :         auto const &thisZone = state.dataHeatBal->Zone(iZone);
    6179              : 
    6180           38 :         Real64 const mult = thisZone.Multiplier * thisZone.ListMultiplier;
    6181           38 :         if (thisZone.SystemZoneNodeNumber > 0) { // conditioned y/n
    6182           33 :             PreDefTableEntry(state, state.dataOutRptPredefined->pdchInLtCond, thisLight.Name, "Y");
    6183              :         } else {
    6184            5 :             PreDefTableEntry(state, state.dataOutRptPredefined->pdchInLtCond, thisLight.Name, "N");
    6185              :         }
    6186          114 :         PreDefTableEntry(state,
    6187           38 :                          state.dataOutRptPredefined->pdchInLtAvgHrSchd,
    6188              :                          thisLight.Name,
    6189           38 :                          thisLight.sched->getAverageWeeklyHoursFullLoad(state, StartOfWeek, state.dataEnvrn->CurrentYearIsLeapYear));
    6190              :         // average operating hours per week
    6191           38 :         if (ort->gatherElapsedTimeBEPS > 0) {
    6192            0 :             state.dataOutRptTab->HrsPerWeek = 24 * 7 * thisLight.SumTimeNotZeroCons / ort->gatherElapsedTimeBEPS;
    6193            0 :             PreDefTableEntry(state, state.dataOutRptPredefined->pdchInLtAvgHrOper, thisLight.Name, state.dataOutRptTab->HrsPerWeek);
    6194              :         }
    6195              :         // full load hours per week
    6196           38 :         if ((thisLight.DesignLevel * ort->gatherElapsedTimeBEPS) > 0) {
    6197            0 :             state.dataOutRptTab->HrsPerWeek =
    6198            0 :                 24 * 7 * thisLight.SumConsumption / (thisLight.DesignLevel * ort->gatherElapsedTimeBEPS * Constant::rSecsInHour);
    6199            0 :             PreDefTableEntry(state, state.dataOutRptPredefined->pdchInLtFullLoadHrs, thisLight.Name, state.dataOutRptTab->HrsPerWeek);
    6200              :         }
    6201           38 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchInLtConsump, thisLight.Name, thisLight.SumConsumption * mult / 1000000000.0);
    6202           38 :         consumptionTotal += thisLight.SumConsumption / 1000000000.0;
    6203              :     }
    6204           73 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchInLtConsump, "Interior Lighting Total", consumptionTotal);
    6205              : 
    6206              :     // Exterior Lighting
    6207           73 :     consumptionTotal = 0.0;
    6208           97 :     for (int iLight = 1; iLight <= state.dataExteriorEnergyUse->NumExteriorLights; ++iLight) {
    6209           24 :         auto const &thisLight = state.dataExteriorEnergyUse->ExteriorLights(iLight);
    6210              : 
    6211           24 :         if (thisLight.ControlMode == ExteriorEnergyUse::LightControlType::ScheduleOnly) { // photocell/schedule
    6212            3 :             PreDefTableEntry(state,
    6213            1 :                              state.dataOutRptPredefined->pdchExLtAvgHrSchd,
    6214              :                              thisLight.Name,
    6215            1 :                              thisLight.sched->getAverageWeeklyHoursFullLoad(state, StartOfWeek, state.dataEnvrn->CurrentYearIsLeapYear));
    6216              :         }
    6217              :         // average operating hours per week
    6218           24 :         if (ort->gatherElapsedTimeBEPS > 0) {
    6219            0 :             state.dataOutRptTab->HrsPerWeek = 24 * 7 * thisLight.SumTimeNotZeroCons / ort->gatherElapsedTimeBEPS;
    6220            0 :             PreDefTableEntry(state, state.dataOutRptPredefined->pdchExLtAvgHrOper, thisLight.Name, state.dataOutRptTab->HrsPerWeek);
    6221              :         }
    6222              :         // full load hours per week
    6223           24 :         if ((thisLight.DesignLevel * ort->gatherElapsedTimeBEPS) > 0) {
    6224            0 :             state.dataOutRptTab->HrsPerWeek =
    6225            0 :                 24 * 7 * thisLight.SumConsumption / (thisLight.DesignLevel * ort->gatherElapsedTimeBEPS * Constant::rSecsInHour);
    6226            0 :             PreDefTableEntry(state, state.dataOutRptPredefined->pdchExLtFullLoadHrs, thisLight.Name, state.dataOutRptTab->HrsPerWeek);
    6227              :         }
    6228           24 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchExLtConsump, thisLight.Name, thisLight.SumConsumption / 1000000000.0);
    6229           24 :         consumptionTotal += thisLight.SumConsumption / 1000000000.0;
    6230              :     }
    6231           73 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchExLtConsump, "Exterior Lighting Total", consumptionTotal);
    6232              : 
    6233              :     // outside air ventilation
    6234           73 :     Real64 totalOccupants = 0.;
    6235           73 :     Real64 totalAverageOccupants = 0.;
    6236           73 :     Real64 totalArea = 0.;
    6237           73 :     Real64 totalVozMin = 0;
    6238           73 :     Real64 totalMechVentVol = 0;
    6239           73 :     Real64 totalNatVentVol = 0;
    6240           73 :     Real64 totalInfilVol = 0;
    6241           73 :     Real64 totalVozDyn = 0;
    6242           73 :     Real64 totalMechVentRateOcc = 0;
    6243           73 :     Real64 totalNatVentRateOcc = 0;
    6244           73 :     Real64 totalInfilRateOcc = 0;
    6245           73 :     Real64 totalVozDynOcc = 0;
    6246              : 
    6247              :     // Outdoor Air Summary and Outdoor Air Details
    6248          167 :     for (int iZone = 1; iZone <= state.dataGlobal->NumOfZones; ++iZone) {
    6249              : 
    6250           94 :         auto const &thisZone = state.dataHeatBal->Zone(iZone);
    6251              : 
    6252           94 :         int const zoneMult = thisZone.Multiplier * thisZone.ListMultiplier;
    6253           94 :         if (thisZone.SystemZoneNodeNumber >= 0) { // conditioned zones only
    6254              : 
    6255           94 :             auto &thisZonePreDefRep = state.dataHeatBal->ZonePreDefRep(iZone);
    6256              : 
    6257              :             // AFN infiltration -- check that afn sim is being done.
    6258           94 :             if (!state.afn->multizone_always_simulated) {
    6259           91 :                 thisZonePreDefRep.AFNInfilVolTotalStdDen = 0.0;
    6260           91 :                 thisZonePreDefRep.AFNVentVolTotalStdDen = 0.0;
    6261           91 :                 thisZonePreDefRep.AFNInfilVolTotalOccStdDen = 0.0;
    6262           91 :                 thisZonePreDefRep.AFNVentVolTotalOccStdDen = 0.0;
    6263           91 :                 thisZonePreDefRep.AFNInfilVolMin = 0.0;
    6264           91 :                 thisZonePreDefRep.AFNInfilVolTotalOcc = 0.0;
    6265              :             }
    6266              : 
    6267              :             // air loop name
    6268           94 :             if (thisZone.IsControlled) {
    6269           52 :                 std::string airLoopName = "";
    6270          107 :                 for (int zoneInNode = 1; zoneInNode <= state.dataZoneEquip->ZoneEquipConfig(iZone).NumInletNodes; ++zoneInNode) {
    6271           55 :                     int airLoopNumber = state.dataZoneEquip->ZoneEquipConfig(iZone).InletNodeAirLoopNum(zoneInNode);
    6272           55 :                     if (airLoopNumber > 0) {
    6273           35 :                         if (airLoopName.empty()) {
    6274           35 :                             airLoopName = state.dataAirSystemsData->PrimaryAirSystems(airLoopNumber).Name;
    6275              :                         } else {
    6276            0 :                             airLoopName += "; " + state.dataAirSystemsData->PrimaryAirSystems(airLoopNumber).Name;
    6277              :                         }
    6278              :                     }
    6279              :                 }
    6280           52 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaMvAirLpNm, thisZone.Name, airLoopName);
    6281              : 
    6282              :                 // occupants
    6283           52 :                 if (thisZone.isNominalOccupied) {
    6284           31 :                     if (thisZonePreDefRep.NumOccAccumTime > 0) {
    6285           30 :                         Real64 const avgOcc = thisZonePreDefRep.NumOccAccum / thisZonePreDefRep.NumOccAccumTime;
    6286           30 :                         PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaoAvgNumOcc1, thisZone.Name, avgOcc);
    6287           30 :                         PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaoAvgNumOcc2, thisZone.Name, avgOcc);
    6288           30 :                         PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaMvAvgNumOcc, thisZone.Name, avgOcc);
    6289           30 :                         totalAverageOccupants += avgOcc * zoneMult;
    6290              :                     }
    6291              :                 }
    6292           52 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaMvNomNumOcc, thisZone.Name, thisZone.TotOccupants);
    6293           52 :                 totalOccupants += thisZone.TotOccupants * zoneMult;
    6294              : 
    6295              :                 // Zone volume and area
    6296              : 
    6297           52 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaoZoneVol1, thisZone.Name, thisZone.Volume);
    6298           52 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaoZoneVol2, thisZone.Name, thisZone.Volume);
    6299           52 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaMvZoneVol, thisZone.Name, thisZone.Volume);
    6300           52 :                 state.dataOutRptTab->totalVolume += thisZone.Volume * zoneMult;
    6301           52 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaMvZoneArea, thisZone.Name, thisZone.FloorArea);
    6302           52 :                 totalArea += thisZone.FloorArea * zoneMult;
    6303              : 
    6304              :                 // minimum dynamic target ventilation Voz-dyn-min
    6305           52 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaMvMinDynTrgVent, thisZone.Name, thisZonePreDefRep.VozMin / zoneMult, 3);
    6306           52 :                 totalVozMin += thisZonePreDefRep.VozMin;
    6307              : 
    6308              :                 // Mechanical ventilation
    6309           52 :                 if (thisZone.Volume > 0 && thisZonePreDefRep.TotTimeOcc > 0) {
    6310           30 :                     PreDefTableEntry(state,
    6311           30 :                                      state.dataOutRptPredefined->pdchOaoAvgMechVent,
    6312              :                                      thisZone.Name,
    6313           30 :                                      thisZonePreDefRep.MechVentVolTotalOcc / (thisZonePreDefRep.TotTimeOcc * thisZone.Volume * zoneMult),
    6314           30 :                                      3);
    6315           30 :                     PreDefTableEntry(state,
    6316           30 :                                      state.dataOutRptPredefined->pdchOaoMinMechVent,
    6317              :                                      thisZone.Name,
    6318           30 :                                      thisZonePreDefRep.MechVentVolMin / (thisZone.Volume * zoneMult),
    6319           60 :                                      3);
    6320              :                 }
    6321          104 :                 PreDefTableEntry(
    6322           52 :                     state, state.dataOutRptPredefined->pdchOaTaBzMechVent, thisZone.Name, thisZonePreDefRep.MechVentVolTotalStdDen / zoneMult);
    6323           52 :                 totalMechVentVol += thisZonePreDefRep.MechVentVolTotalStdDen;
    6324              : 
    6325              :                 // Natural ventilation
    6326          104 :                 PreDefTableEntry(state,
    6327           52 :                                  state.dataOutRptPredefined->pdchOaTaBzNatVent,
    6328              :                                  thisZone.Name,
    6329           52 :                                  thisZonePreDefRep.SimpVentVolTotalStdDen + thisZonePreDefRep.AFNVentVolTotalStdDen);
    6330           52 :                 totalNatVentVol += (thisZonePreDefRep.SimpVentVolTotalStdDen + thisZonePreDefRep.AFNVentVolTotalStdDen) * zoneMult;
    6331              : 
    6332              :                 // Total ventilation
    6333          104 :                 PreDefTableEntry(state,
    6334           52 :                                  state.dataOutRptPredefined->pdchOaTaBzTotVent,
    6335              :                                  thisZone.Name,
    6336           52 :                                  thisZonePreDefRep.MechVentVolTotalStdDen / zoneMult + thisZonePreDefRep.SimpVentVolTotalStdDen +
    6337           52 :                                      thisZonePreDefRep.AFNVentVolTotalStdDen);
    6338              : 
    6339              :                 // infiltration
    6340           52 :                 if (thisZone.Volume > 0 && thisZonePreDefRep.TotTimeOcc > 0) {
    6341           30 :                     PreDefTableEntry(state,
    6342           30 :                                      state.dataOutRptPredefined->pdchOaoAvgInfil,
    6343              :                                      thisZone.Name,
    6344           30 :                                      thisZonePreDefRep.InfilVolTotalOcc / (thisZonePreDefRep.TotTimeOcc * thisZone.Volume),
    6345           30 :                                      3);
    6346           30 :                     PreDefTableEntry(
    6347           30 :                         state, state.dataOutRptPredefined->pdchOaoMinInfil, thisZone.Name, thisZonePreDefRep.InfilVolMin / (thisZone.Volume), 3);
    6348              : 
    6349           30 :                     PreDefTableEntry(state,
    6350           30 :                                      state.dataOutRptPredefined->pdchOaoAvgAFNInfil,
    6351              :                                      thisZone.Name,
    6352           30 :                                      thisZonePreDefRep.AFNInfilVolTotalOcc / (thisZonePreDefRep.TotTimeOcc * thisZone.Volume),
    6353           30 :                                      3);
    6354              : 
    6355           30 :                     PreDefTableEntry(state,
    6356           30 :                                      state.dataOutRptPredefined->pdchOaoMinAFNInfil,
    6357              :                                      thisZone.Name,
    6358           30 :                                      thisZonePreDefRep.AFNInfilVolMin / (thisZone.Volume),
    6359           30 :                                      3);
    6360              : 
    6361              :                     // simple 'ZoneVentilation'
    6362           30 :                     PreDefTableEntry(state,
    6363           30 :                                      state.dataOutRptPredefined->pdchOaoAvgSimpVent,
    6364              :                                      thisZone.Name,
    6365           30 :                                      thisZonePreDefRep.SimpVentVolTotalOcc / (thisZonePreDefRep.TotTimeOcc * thisZone.Volume),
    6366           30 :                                      3);
    6367              : 
    6368           30 :                     PreDefTableEntry(state,
    6369           30 :                                      state.dataOutRptPredefined->pdchOaoMinSimpVent,
    6370              :                                      thisZone.Name,
    6371           30 :                                      thisZonePreDefRep.SimpVentVolMin / (thisZone.Volume),
    6372           60 :                                      3);
    6373              :                 }
    6374              : 
    6375              :                 // Infiltration
    6376          104 :                 PreDefTableEntry(state,
    6377           52 :                                  state.dataOutRptPredefined->pdchOaTaBzInfil,
    6378              :                                  thisZone.Name,
    6379           52 :                                  thisZonePreDefRep.InfilVolTotalStdDen + thisZonePreDefRep.AFNInfilVolTotalStdDen);
    6380           52 :                 totalInfilVol += (thisZonePreDefRep.InfilVolTotalStdDen + thisZonePreDefRep.AFNInfilVolTotalStdDen) * zoneMult;
    6381              : 
    6382              :                 // Total ventilation and infiltration
    6383          104 :                 PreDefTableEntry(state,
    6384           52 :                                  state.dataOutRptPredefined->pdchOaTaBzTotVentInfil,
    6385              :                                  thisZone.Name,
    6386           52 :                                  thisZonePreDefRep.MechVentVolTotalStdDen / zoneMult + thisZonePreDefRep.SimpVentVolTotalStdDen +
    6387           52 :                                      thisZonePreDefRep.AFNVentVolTotalStdDen + thisZonePreDefRep.AFNInfilVolTotalStdDen +
    6388           52 :                                      thisZonePreDefRep.InfilVolTotalStdDen);
    6389              : 
    6390              :                 // Dynamic target ventilation Voz-dyn
    6391           52 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaTaBzDynTrgVent, thisZone.Name, thisZonePreDefRep.VozTargetTotal / zoneMult);
    6392           52 :                 totalVozDyn += thisZonePreDefRep.VozTargetTotal;
    6393           52 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaTaBzTmBelow, thisZone.Name, thisZonePreDefRep.VozTargetTimeBelow);
    6394           52 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaTaBzTmAt, thisZone.Name, thisZonePreDefRep.VozTargetTimeAt);
    6395           52 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaTaBzTmAbove, thisZone.Name, thisZonePreDefRep.VozTargetTimeAbove);
    6396           52 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaTaBzTmAboveUnocc, thisZone.Name, thisZonePreDefRep.TotVentTimeNonZeroUnocc);
    6397              : 
    6398           52 :                 if (thisZone.isNominalOccupied && (thisZonePreDefRep.TotTimeOcc > 0.0)) {
    6399           30 :                     Real64 totTimeOccSec = thisZonePreDefRep.TotTimeOcc * Constant::rSecsInHour;
    6400              :                     // Mechanical ventilation
    6401           30 :                     Real64 mechVent = thisZonePreDefRep.MechVentVolTotalOccStdDen / totTimeOccSec;
    6402           30 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaOccBzMechVent, thisZone.Name, mechVent / zoneMult, 4);
    6403           30 :                     totalMechVentRateOcc += mechVent;
    6404              : 
    6405              :                     // Natural ventilation
    6406           30 :                     Real64 natVent = (thisZonePreDefRep.SimpVentVolTotalOccStdDen + thisZonePreDefRep.AFNVentVolTotalOccStdDen) / totTimeOccSec;
    6407           30 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaOccBzNatVent, thisZone.Name, natVent, 4);
    6408           30 :                     totalNatVentRateOcc += natVent * zoneMult;
    6409              : 
    6410              :                     // Total ventilation
    6411           30 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaOccBzTotVent, thisZone.Name, mechVent / zoneMult + natVent, 4);
    6412              : 
    6413              :                     // infiltration
    6414           30 :                     Real64 infil = (thisZonePreDefRep.InfilVolTotalOccStdDen + thisZonePreDefRep.AFNInfilVolTotalOccStdDen) / totTimeOccSec;
    6415           30 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaOccBzInfil, thisZone.Name, infil, 4);
    6416           30 :                     totalInfilRateOcc += infil * zoneMult;
    6417              : 
    6418              :                     // Total ventilation and infiltration
    6419           30 :                     PreDefTableEntry(
    6420           30 :                         state, state.dataOutRptPredefined->pdchOaOccBzTotVentInfil, thisZone.Name, mechVent / zoneMult + natVent + infil, 4);
    6421              : 
    6422              :                     // Dynamic target ventilation Voz-dyn
    6423           30 :                     Real64 avgVoz = thisZonePreDefRep.VozTargetTotalOcc / totTimeOccSec;
    6424           30 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaOccBzDynTrgVent, thisZone.Name, avgVoz / zoneMult, 4);
    6425           30 :                     totalVozDynOcc += avgVoz;
    6426           30 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaOccBzTmBelow, thisZone.Name, thisZonePreDefRep.VozTargetTimeBelowOcc);
    6427           30 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaOccBzTmAt, thisZone.Name, thisZonePreDefRep.VozTargetTimeAtOcc);
    6428           30 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaOccBzTmAbove, thisZone.Name, thisZonePreDefRep.VozTargetTimeAboveOcc);
    6429              :                 }
    6430           52 :             }
    6431              :         }
    6432              :     }
    6433              : 
    6434           95 :     for (int iSys = 1; iSys <= state.dataHVACGlobal->NumPrimaryAirSys; ++iSys) {
    6435           22 :         auto const &thisPrimaryAirSys = state.dataAirSystemsData->PrimaryAirSystems(iSys);
    6436           22 :         auto const &thisSysPreDefRep = state.dataSysRpts->SysPreDefRep(iSys);
    6437              : 
    6438              :         // Total Outdoor Air by Airloop
    6439           22 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaTaAlMechVent, thisPrimaryAirSys.Name, thisSysPreDefRep.MechVentTotal);
    6440           22 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaTaAlNatVent, thisPrimaryAirSys.Name, thisSysPreDefRep.NatVentTotal);
    6441           44 :         PreDefTableEntry(state,
    6442           22 :                          state.dataOutRptPredefined->pdchOaTaAlTotVent,
    6443              :                          thisPrimaryAirSys.Name,
    6444           22 :                          thisSysPreDefRep.MechVentTotal + thisSysPreDefRep.NatVentTotal);
    6445           22 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaTaAlSumDynTrgVent, thisPrimaryAirSys.Name, thisSysPreDefRep.TargetVentTotalVoz);
    6446           22 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaTaAlTmBelow, thisPrimaryAirSys.Name, thisSysPreDefRep.TimeBelowVozDynTotal);
    6447           22 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaTaAlTmAt, thisPrimaryAirSys.Name, thisSysPreDefRep.TimeAtVozDynTotal);
    6448           22 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaTaAlTmAbove, thisPrimaryAirSys.Name, thisSysPreDefRep.TimeAboveVozDynTotal);
    6449           22 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaTaAlTmAboveUnocc, thisPrimaryAirSys.Name, thisSysPreDefRep.TimeVentUnoccTotal);
    6450              : 
    6451              :         // Air loop times at OA limiting factors
    6452           66 :         PreDefTableEntry(state,
    6453           22 :                          state.dataOutRptPredefined->pdchOaTmFctNoLimit,
    6454              :                          thisPrimaryAirSys.Name,
    6455           22 :                          thisSysPreDefRep.TimeAtOALimit[static_cast<int>(MixedAir::OALimitFactor::None)]);
    6456           66 :         PreDefTableEntry(state,
    6457           22 :                          state.dataOutRptPredefined->pdchOaTmFctLimit,
    6458              :                          thisPrimaryAirSys.Name,
    6459           22 :                          thisSysPreDefRep.TimeAtOALimit[static_cast<int>(MixedAir::OALimitFactor::Limits)]);
    6460           66 :         PreDefTableEntry(state,
    6461           22 :                          state.dataOutRptPredefined->pdchOaTmFctEcono,
    6462              :                          thisPrimaryAirSys.Name,
    6463           22 :                          thisSysPreDefRep.TimeAtOALimit[static_cast<int>(MixedAir::OALimitFactor::Economizer)]);
    6464           66 :         PreDefTableEntry(state,
    6465           22 :                          state.dataOutRptPredefined->pdchOaTmFctExhaust,
    6466              :                          thisPrimaryAirSys.Name,
    6467           22 :                          thisSysPreDefRep.TimeAtOALimit[static_cast<int>(MixedAir::OALimitFactor::Exhaust)]);
    6468           66 :         PreDefTableEntry(state,
    6469           22 :                          state.dataOutRptPredefined->pdchOaTmFctMixedLimit,
    6470              :                          thisPrimaryAirSys.Name,
    6471           22 :                          thisSysPreDefRep.TimeAtOALimit[static_cast<int>(MixedAir::OALimitFactor::MixedAir)]);
    6472           66 :         PreDefTableEntry(state,
    6473           22 :                          state.dataOutRptPredefined->pdchOaTmFctHiHumid,
    6474              :                          thisPrimaryAirSys.Name,
    6475           22 :                          thisSysPreDefRep.TimeAtOALimit[static_cast<int>(MixedAir::OALimitFactor::HighHum)]);
    6476           66 :         PreDefTableEntry(state,
    6477           22 :                          state.dataOutRptPredefined->pdchOaTmFctDCV,
    6478              :                          thisPrimaryAirSys.Name,
    6479           22 :                          thisSysPreDefRep.TimeAtOALimit[static_cast<int>(MixedAir::OALimitFactor::DCV)]);
    6480           66 :         PreDefTableEntry(state,
    6481           22 :                          state.dataOutRptPredefined->pdchOaTmFctNiteVent,
    6482              :                          thisPrimaryAirSys.Name,
    6483           22 :                          thisSysPreDefRep.TimeAtOALimit[static_cast<int>(MixedAir::OALimitFactor::NightVent)]);
    6484           66 :         PreDefTableEntry(state,
    6485           22 :                          state.dataOutRptPredefined->pdchOaTmFctDemand,
    6486              :                          thisPrimaryAirSys.Name,
    6487           22 :                          thisSysPreDefRep.TimeAtOALimit[static_cast<int>(MixedAir::OALimitFactor::DemandLimit)]);
    6488           66 :         PreDefTableEntry(state,
    6489           22 :                          state.dataOutRptPredefined->pdchOaTmFctEMS,
    6490              :                          thisPrimaryAirSys.Name,
    6491           22 :                          thisSysPreDefRep.TimeAtOALimit[static_cast<int>(MixedAir::OALimitFactor::EMS)]);
    6492              : 
    6493           22 :         if (thisSysPreDefRep.TimeOccupiedTotal > 0.0) {
    6494              :             // Average Outdoor Air During Occupancy by Airloop
    6495           13 :             Real64 totTimeOccSec = thisSysPreDefRep.TimeOccupiedTotal * Constant::rSecsInHour;
    6496           13 :             PreDefTableEntry(
    6497           13 :                 state, state.dataOutRptPredefined->pdchOaOccAlMechVent, thisPrimaryAirSys.Name, thisSysPreDefRep.MechVentTotalOcc / totTimeOccSec, 4);
    6498           13 :             PreDefTableEntry(
    6499           13 :                 state, state.dataOutRptPredefined->pdchOaOccAlNatVent, thisPrimaryAirSys.Name, thisSysPreDefRep.NatVentTotalOcc / totTimeOccSec, 4);
    6500           13 :             PreDefTableEntry(state,
    6501           13 :                              state.dataOutRptPredefined->pdchOaOccAlTotVent,
    6502              :                              thisPrimaryAirSys.Name,
    6503           13 :                              (thisSysPreDefRep.MechVentTotalOcc + thisSysPreDefRep.NatVentTotalOcc) / totTimeOccSec,
    6504           13 :                              4);
    6505           13 :             PreDefTableEntry(state,
    6506           13 :                              state.dataOutRptPredefined->pdchOaOccAlSumDynTrgVent,
    6507              :                              thisPrimaryAirSys.Name,
    6508           13 :                              thisSysPreDefRep.TargetVentTotalVozOcc / totTimeOccSec,
    6509           13 :                              4);
    6510           13 :             PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaOccAlTmBelow, thisPrimaryAirSys.Name, thisSysPreDefRep.TimeBelowVozDynTotalOcc);
    6511           13 :             PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaOccAlTmAt, thisPrimaryAirSys.Name, thisSysPreDefRep.TimeAtVozDynTotalOcc);
    6512           13 :             PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaOccAlTmAbove, thisPrimaryAirSys.Name, thisSysPreDefRep.TimeAboveVozDynTotalOcc);
    6513              : 
    6514              :             // Average Outdoor Air at OA Limiting Factors During Occupancy by Airloop
    6515              :             // lambda to set avgFlow during occupancy for a given airloop and limiting factor type
    6516          130 :             auto avgFlowRate = [&state](int sysNum, MixedAir::OALimitFactor limitingFactorType) {
    6517          130 :                 int time = state.dataSysRpts->SysPreDefRep(sysNum).TimeAtOALimitOcc[static_cast<int>(limitingFactorType)];
    6518          130 :                 if (time > 0) {
    6519           11 :                     return state.dataSysRpts->SysPreDefRep(sysNum).MechVentTotAtLimitOcc[static_cast<int>(limitingFactorType)] /
    6520           11 :                            (time * Constant::rSecsInHour);
    6521              :                 } else {
    6522          119 :                     return 0.0;
    6523              :                 }
    6524           13 :             };
    6525           26 :             PreDefTableEntry(
    6526           26 :                 state, state.dataOutRptPredefined->pdchOaAvFctNoLimit, thisPrimaryAirSys.Name, avgFlowRate(iSys, MixedAir::OALimitFactor::None), 4);
    6527           26 :             PreDefTableEntry(
    6528           26 :                 state, state.dataOutRptPredefined->pdchOaAvFctLimit, thisPrimaryAirSys.Name, avgFlowRate(iSys, MixedAir::OALimitFactor::Limits), 4);
    6529           26 :             PreDefTableEntry(state,
    6530           13 :                              state.dataOutRptPredefined->pdchOaAvFctEcono,
    6531              :                              thisPrimaryAirSys.Name,
    6532              :                              avgFlowRate(iSys, MixedAir::OALimitFactor::Economizer),
    6533           13 :                              4);
    6534           26 :             PreDefTableEntry(state,
    6535           13 :                              state.dataOutRptPredefined->pdchOaAvFctExhaust,
    6536              :                              thisPrimaryAirSys.Name,
    6537              :                              avgFlowRate(iSys, MixedAir::OALimitFactor::Exhaust),
    6538           13 :                              4);
    6539           26 :             PreDefTableEntry(state,
    6540           13 :                              state.dataOutRptPredefined->pdchOaAvFctMixedLimit,
    6541              :                              thisPrimaryAirSys.Name,
    6542              :                              avgFlowRate(iSys, MixedAir::OALimitFactor::MixedAir),
    6543           13 :                              4);
    6544           26 :             PreDefTableEntry(state,
    6545           13 :                              state.dataOutRptPredefined->pdchOaAvFctHiHumid,
    6546              :                              thisPrimaryAirSys.Name,
    6547              :                              avgFlowRate(iSys, MixedAir::OALimitFactor::HighHum),
    6548           13 :                              4);
    6549           26 :             PreDefTableEntry(
    6550           26 :                 state, state.dataOutRptPredefined->pdchOaAvFctDCV, thisPrimaryAirSys.Name, avgFlowRate(iSys, MixedAir::OALimitFactor::DCV), 4);
    6551           26 :             PreDefTableEntry(state,
    6552           13 :                              state.dataOutRptPredefined->pdchOaAvFctNiteVent,
    6553              :                              thisPrimaryAirSys.Name,
    6554              :                              avgFlowRate(iSys, MixedAir::OALimitFactor::NightVent),
    6555           13 :                              4);
    6556           26 :             PreDefTableEntry(state,
    6557           13 :                              state.dataOutRptPredefined->pdchOaAvFctDemand,
    6558              :                              thisPrimaryAirSys.Name,
    6559              :                              avgFlowRate(iSys, MixedAir::OALimitFactor::DemandLimit),
    6560           13 :                              4);
    6561           26 :             PreDefTableEntry(
    6562           39 :                 state, state.dataOutRptPredefined->pdchOaAvFctEMS, thisPrimaryAirSys.Name, avgFlowRate(iSys, MixedAir::OALimitFactor::EMS), 4);
    6563              :         }
    6564              :     }
    6565              :     // add total rows for outdoor air details
    6566          146 :     OutputReportPredefined::PreDefTableEntry(
    6567          146 :         state, state.dataOutRptPredefined->pdchOaMvDesZnOa, "Total Facility", state.dataOutRptPredefined->TotalVozMax, 4);
    6568              : 
    6569           73 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaMvZoneVol, "Total Facility", state.dataOutRptTab->totalVolume);
    6570           73 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaMvZoneArea, "Total Facility", totalArea);
    6571           73 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaMvNomNumOcc, "Total Facility", totalOccupants);
    6572           73 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaMvAvgNumOcc, "Total Facility", totalAverageOccupants);
    6573           73 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaMvMinDynTrgVent, "Total Facility", totalVozMin, 3);
    6574              : 
    6575           73 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaTaBzMechVent, "Total Facility", totalMechVentVol);
    6576           73 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaTaBzNatVent, "Total Facility", totalNatVentVol);
    6577           73 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaTaBzTotVent, "Total Facility", totalMechVentVol + totalNatVentVol);
    6578           73 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaTaBzInfil, "Total Facility", totalInfilVol);
    6579           73 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaTaBzTotVentInfil, "Total Facility", totalMechVentVol + totalNatVentVol + totalInfilVol);
    6580           73 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaTaBzDynTrgVent, "Total Facility", totalVozDyn);
    6581          219 :     PreDefTableEntry(
    6582          146 :         state, state.dataOutRptPredefined->pdchOaTaBzTmBelow, "Total Facility", state.dataOutRptPredefined->TotalAnyZoneBelowVozDynForOA);
    6583           73 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaTaBzTmAt, "Total Facility", state.dataOutRptPredefined->TotalAllZonesAtVozDynForOA);
    6584          219 :     PreDefTableEntry(
    6585          146 :         state, state.dataOutRptPredefined->pdchOaTaBzTmAbove, "Total Facility", state.dataOutRptPredefined->TotalAnyZoneAboveVozDynForOA);
    6586          219 :     PreDefTableEntry(
    6587          146 :         state, state.dataOutRptPredefined->pdchOaTaBzTmAboveUnocc, "Total Facility", state.dataOutRptPredefined->TotalAnyZoneVentUnoccForOA);
    6588              : 
    6589           73 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaOccBzMechVent, "Total Facility", totalMechVentRateOcc, 4);
    6590           73 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaOccBzNatVent, "Total Facility", totalNatVentRateOcc, 4);
    6591           73 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaOccBzTotVent, "Total Facility", totalMechVentRateOcc + totalNatVentRateOcc, 4);
    6592           73 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaOccBzInfil, "Total Facility", totalInfilRateOcc, 4);
    6593           73 :     PreDefTableEntry(state,
    6594           73 :                      state.dataOutRptPredefined->pdchOaOccBzTotVentInfil,
    6595              :                      "Total Facility",
    6596           73 :                      totalMechVentRateOcc + totalNatVentRateOcc + totalInfilRateOcc,
    6597           73 :                      4);
    6598           73 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaOccBzDynTrgVent, "Total Facility", totalVozDynOcc, 4);
    6599          219 :     PreDefTableEntry(
    6600          146 :         state, state.dataOutRptPredefined->pdchOaOccBzTmBelow, "Total Facility", state.dataOutRptPredefined->TotalAnyZoneBelowVozDynOccForOA);
    6601           73 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaOccBzTmAt, "Total Facility", state.dataOutRptPredefined->TotalAllZonesAtVozDynOccForOA);
    6602          219 :     PreDefTableEntry(
    6603          146 :         state, state.dataOutRptPredefined->pdchOaOccBzTmAbove, "Total Facility", state.dataOutRptPredefined->TotalAnyZoneAboveVozDynOccForOA);
    6604              : 
    6605              :     // Add the number of central air distributions system to the count report
    6606           73 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchHVACcntVal, "HVAC Air Loops", NumPrimaryAirSys);
    6607              :     // Add the number of conditioned and unconditioned zones to the count report
    6608          167 :     for (int iZone = 1; iZone <= state.dataGlobal->NumOfZones; ++iZone) {
    6609              : 
    6610           94 :         if (state.dataHeatBal->Zone(iZone).SystemZoneNodeNumber > 0) { // conditioned zones only
    6611           52 :             ++state.dataOutRptTab->numCondZones;
    6612              :         } else {
    6613           42 :             ++state.dataOutRptTab->numUncondZones;
    6614              :         }
    6615              :     }
    6616           73 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchHVACcntVal, "Conditioned Zones", state.dataOutRptTab->numCondZones);
    6617           73 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchHVACcntVal, "Unconditioned Zones", state.dataOutRptTab->numUncondZones);
    6618              :     // add the number of plenums to the count report
    6619           73 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchHVACcntVal, "Supply Plenums", state.dataZonePlenum->NumZoneSupplyPlenums);
    6620           73 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchHVACcntVal, "Return Plenums", state.dataZonePlenum->NumZoneReturnPlenums);
    6621              : 
    6622              :     // Add footnote saying if it is a design day or other kind of environment
    6623              : 
    6624              :     // Field counts
    6625           73 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchFieldCntVal, "IDF Objects", iNumberOfRecords);
    6626           73 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchFieldCntVal, "Defaulted Fields", iNumberOfDefaultedFields);
    6627           73 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchFieldCntVal, "Fields with Defaults", iTotalFieldsWithDefaults);
    6628           73 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchFieldCntVal, "Autosized Fields", iNumberOfAutoSizedFields);
    6629           73 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchFieldCntVal, "Autosizable Fields", iTotalAutoSizableFields);
    6630           73 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchFieldCntVal, "Autocalculated Fields", iNumberOfAutoCalcedFields);
    6631           73 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchFieldCntVal, "Autocalculatable Fields", iTotalAutoCalculatableFields);
    6632              : 
    6633          167 :     for (int iZone = 1; iZone <= state.dataGlobal->NumOfZones; ++iZone) {
    6634              : 
    6635           94 :         auto const &thisZone = state.dataHeatBal->Zone(iZone);
    6636           94 :         auto const &thisZonePreDefRep = state.dataHeatBal->ZonePreDefRep(iZone);
    6637              : 
    6638              :         // annual
    6639              :         // PreDefTableEntry(state,  pdchSHGSAnHvacHt, Zone( iZone ).Name, ZonePreDefRep( iZone ).SHGSAnHvacHt * convertJtoGJ, 3 );
    6640              :         // PreDefTableEntry(state,  pdchSHGSAnHvacCl, Zone( iZone ).Name, ZonePreDefRep( iZone ).SHGSAnHvacCl * convertJtoGJ, 3 );
    6641           94 :         PreDefTableEntry(
    6642           94 :             state, state.dataOutRptPredefined->pdchSHGSAnZoneEqHt, thisZone.Name, thisZonePreDefRep.SHGSAnZoneEqHt * Constant::convertJtoGJ, 3);
    6643           94 :         PreDefTableEntry(
    6644           94 :             state, state.dataOutRptPredefined->pdchSHGSAnZoneEqCl, thisZone.Name, thisZonePreDefRep.SHGSAnZoneEqCl * Constant::convertJtoGJ, 3);
    6645           94 :         PreDefTableEntry(
    6646           94 :             state, state.dataOutRptPredefined->pdchSHGSAnHvacATUHt, thisZone.Name, thisZonePreDefRep.SHGSAnHvacATUHt * Constant::convertJtoGJ, 3);
    6647           94 :         PreDefTableEntry(
    6648           94 :             state, state.dataOutRptPredefined->pdchSHGSAnHvacATUCl, thisZone.Name, thisZonePreDefRep.SHGSAnHvacATUCl * Constant::convertJtoGJ, 3);
    6649           94 :         PreDefTableEntry(
    6650           94 :             state, state.dataOutRptPredefined->pdchSHGSAnSurfHt, thisZone.Name, thisZonePreDefRep.SHGSAnSurfHt * Constant::convertJtoGJ, 3);
    6651           94 :         PreDefTableEntry(
    6652           94 :             state, state.dataOutRptPredefined->pdchSHGSAnSurfCl, thisZone.Name, thisZonePreDefRep.SHGSAnSurfCl * Constant::convertJtoGJ, 3);
    6653           94 :         PreDefTableEntry(
    6654           94 :             state, state.dataOutRptPredefined->pdchSHGSAnPeoplAdd, thisZone.Name, thisZonePreDefRep.SHGSAnPeoplAdd * Constant::convertJtoGJ, 3);
    6655           94 :         PreDefTableEntry(
    6656           94 :             state, state.dataOutRptPredefined->pdchSHGSAnLiteAdd, thisZone.Name, thisZonePreDefRep.SHGSAnLiteAdd * Constant::convertJtoGJ, 3);
    6657           94 :         PreDefTableEntry(
    6658           94 :             state, state.dataOutRptPredefined->pdchSHGSAnEquipAdd, thisZone.Name, thisZonePreDefRep.SHGSAnEquipAdd * Constant::convertJtoGJ, 3);
    6659           94 :         PreDefTableEntry(
    6660           94 :             state, state.dataOutRptPredefined->pdchSHGSAnWindAdd, thisZone.Name, thisZonePreDefRep.SHGSAnWindAdd * Constant::convertJtoGJ, 3);
    6661           94 :         PreDefTableEntry(
    6662           94 :             state, state.dataOutRptPredefined->pdchSHGSAnIzaAdd, thisZone.Name, thisZonePreDefRep.SHGSAnIzaAdd * Constant::convertJtoGJ, 3);
    6663           94 :         PreDefTableEntry(
    6664           94 :             state, state.dataOutRptPredefined->pdchSHGSAnInfilAdd, thisZone.Name, thisZonePreDefRep.SHGSAnInfilAdd * Constant::convertJtoGJ, 3);
    6665           94 :         PreDefTableEntry(
    6666           94 :             state, state.dataOutRptPredefined->pdchSHGSAnOtherAdd, thisZone.Name, thisZonePreDefRep.SHGSAnOtherAdd * Constant::convertJtoGJ, 3);
    6667           94 :         PreDefTableEntry(
    6668           94 :             state, state.dataOutRptPredefined->pdchSHGSAnEquipRem, thisZone.Name, thisZonePreDefRep.SHGSAnEquipRem * Constant::convertJtoGJ, 3);
    6669           94 :         PreDefTableEntry(
    6670           94 :             state, state.dataOutRptPredefined->pdchSHGSAnWindRem, thisZone.Name, thisZonePreDefRep.SHGSAnWindRem * Constant::convertJtoGJ, 3);
    6671           94 :         PreDefTableEntry(
    6672           94 :             state, state.dataOutRptPredefined->pdchSHGSAnIzaRem, thisZone.Name, thisZonePreDefRep.SHGSAnIzaRem * Constant::convertJtoGJ, 3);
    6673           94 :         PreDefTableEntry(
    6674           94 :             state, state.dataOutRptPredefined->pdchSHGSAnInfilRem, thisZone.Name, thisZonePreDefRep.SHGSAnInfilRem * Constant::convertJtoGJ, 3);
    6675           94 :         PreDefTableEntry(
    6676           94 :             state, state.dataOutRptPredefined->pdchSHGSAnOtherRem, thisZone.Name, thisZonePreDefRep.SHGSAnOtherRem * Constant::convertJtoGJ, 3);
    6677              :         // peak cooling
    6678           94 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSClTimePeak, thisZone.Name, DateToString(thisZonePreDefRep.clPtTimeStamp));
    6679              :         // PreDefTableEntry(state,  pdchSHGSClHvacHt, Zone( iZone ).Name, ZonePreDefRep( iZone ).SHGSClHvacHt );
    6680              :         // PreDefTableEntry(state,  pdchSHGSClHvacCl, Zone( iZone ).Name, ZonePreDefRep( iZone ).SHGSClHvacCl );
    6681          188 :         PreDefTableEntry(
    6682           94 :             state, state.dataOutRptPredefined->pdchSHGSClHvacHt, thisZone.Name, (thisZonePreDefRep.SHGSClHvacHt - thisZonePreDefRep.SHGSClHvacATUHt));
    6683          188 :         PreDefTableEntry(
    6684           94 :             state, state.dataOutRptPredefined->pdchSHGSClHvacCl, thisZone.Name, (thisZonePreDefRep.SHGSClHvacCl - thisZonePreDefRep.SHGSClHvacATUCl));
    6685           94 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSClHvacATUHt, thisZone.Name, thisZonePreDefRep.SHGSClHvacATUHt);
    6686           94 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSClHvacATUCl, thisZone.Name, thisZonePreDefRep.SHGSClHvacATUCl);
    6687           94 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSClSurfHt, thisZone.Name, thisZonePreDefRep.SHGSClSurfHt);
    6688           94 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSClSurfCl, thisZone.Name, thisZonePreDefRep.SHGSClSurfCl);
    6689           94 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSClPeoplAdd, thisZone.Name, thisZonePreDefRep.SHGSClPeoplAdd);
    6690           94 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSClLiteAdd, thisZone.Name, thisZonePreDefRep.SHGSClLiteAdd);
    6691           94 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSClEquipAdd, thisZone.Name, thisZonePreDefRep.SHGSClEquipAdd);
    6692           94 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSClWindAdd, thisZone.Name, thisZonePreDefRep.SHGSClWindAdd);
    6693           94 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSClIzaAdd, thisZone.Name, thisZonePreDefRep.SHGSClIzaAdd);
    6694           94 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSClInfilAdd, thisZone.Name, thisZonePreDefRep.SHGSClInfilAdd);
    6695           94 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSClOtherAdd, thisZone.Name, thisZonePreDefRep.SHGSClOtherAdd);
    6696           94 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSClEquipRem, thisZone.Name, thisZonePreDefRep.SHGSClEquipRem);
    6697           94 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSClWindRem, thisZone.Name, thisZonePreDefRep.SHGSClWindRem);
    6698           94 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSClIzaRem, thisZone.Name, thisZonePreDefRep.SHGSClIzaRem);
    6699           94 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSClInfilRem, thisZone.Name, thisZonePreDefRep.SHGSClInfilRem);
    6700           94 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSClOtherRem, thisZone.Name, thisZonePreDefRep.SHGSClOtherRem);
    6701              :         // peak heating
    6702           94 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSHtTimePeak, thisZone.Name, DateToString(thisZonePreDefRep.htPtTimeStamp));
    6703              :         // PreDefTableEntry(state,  pdchSHGSHtHvacHt, Zone( iZone ).Name, ZonePreDefRep( iZone ).SHGSHtHvacHt );
    6704              :         // PreDefTableEntry(state,  pdchSHGSHtHvacCl, Zone( iZone ).Name, ZonePreDefRep( iZone ).SHGSHtHvacCl );
    6705          188 :         PreDefTableEntry(
    6706           94 :             state, state.dataOutRptPredefined->pdchSHGSHtHvacHt, thisZone.Name, (thisZonePreDefRep.SHGSHtHvacHt - thisZonePreDefRep.SHGSHtHvacATUHt));
    6707          188 :         PreDefTableEntry(
    6708           94 :             state, state.dataOutRptPredefined->pdchSHGSHtHvacCl, thisZone.Name, (thisZonePreDefRep.SHGSHtHvacCl - thisZonePreDefRep.SHGSHtHvacATUCl));
    6709           94 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSHtHvacATUHt, thisZone.Name, thisZonePreDefRep.SHGSHtHvacATUHt);
    6710           94 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSHtHvacATUCl, thisZone.Name, thisZonePreDefRep.SHGSHtHvacATUCl);
    6711           94 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSHtSurfHt, thisZone.Name, thisZonePreDefRep.SHGSHtSurfHt);
    6712           94 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSHtSurfCl, thisZone.Name, thisZonePreDefRep.SHGSHtSurfCl);
    6713           94 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSHtPeoplAdd, thisZone.Name, thisZonePreDefRep.SHGSHtPeoplAdd);
    6714           94 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSHtLiteAdd, thisZone.Name, thisZonePreDefRep.SHGSHtLiteAdd);
    6715           94 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSHtEquipAdd, thisZone.Name, thisZonePreDefRep.SHGSHtEquipAdd);
    6716           94 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSHtWindAdd, thisZone.Name, thisZonePreDefRep.SHGSHtWindAdd);
    6717           94 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSHtIzaAdd, thisZone.Name, thisZonePreDefRep.SHGSHtIzaAdd);
    6718           94 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSHtInfilAdd, thisZone.Name, thisZonePreDefRep.SHGSHtInfilAdd);
    6719           94 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSHtOtherAdd, thisZone.Name, thisZonePreDefRep.SHGSHtOtherAdd);
    6720           94 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSHtEquipRem, thisZone.Name, thisZonePreDefRep.SHGSHtEquipRem);
    6721           94 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSHtWindRem, thisZone.Name, thisZonePreDefRep.SHGSHtWindRem);
    6722           94 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSHtIzaRem, thisZone.Name, thisZonePreDefRep.SHGSHtIzaRem);
    6723           94 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSHtInfilRem, thisZone.Name, thisZonePreDefRep.SHGSHtInfilRem);
    6724           94 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSHtOtherRem, thisZone.Name, thisZonePreDefRep.SHGSHtOtherRem);
    6725              :     }
    6726              :     // totals for annual report
    6727          167 :     for (int iZone = 1; iZone <= state.dataGlobal->NumOfZones; ++iZone) {
    6728           94 :         auto const &thisZonePreDefRep = state.dataHeatBal->ZonePreDefRep(iZone);
    6729              : 
    6730           94 :         state.dataOutRptTab->totalZoneEqHt += thisZonePreDefRep.SHGSAnZoneEqHt;
    6731           94 :         state.dataOutRptTab->totalZoneEqCl += thisZonePreDefRep.SHGSAnZoneEqCl;
    6732           94 :         state.dataOutRptTab->totalHvacATUHt += thisZonePreDefRep.SHGSAnHvacATUHt;
    6733           94 :         state.dataOutRptTab->totalHvacATUCl += thisZonePreDefRep.SHGSAnHvacATUCl;
    6734           94 :         state.dataOutRptTab->totalSurfHt += thisZonePreDefRep.SHGSAnSurfHt;
    6735           94 :         state.dataOutRptTab->totalSurfCl += thisZonePreDefRep.SHGSAnSurfCl;
    6736           94 :         state.dataOutRptTab->totalPeoplAdd += thisZonePreDefRep.SHGSAnPeoplAdd;
    6737           94 :         state.dataOutRptTab->totalLiteAdd += thisZonePreDefRep.SHGSAnLiteAdd;
    6738           94 :         state.dataOutRptTab->totalEquipAdd += thisZonePreDefRep.SHGSAnEquipAdd;
    6739           94 :         state.dataOutRptTab->totalWindAdd += thisZonePreDefRep.SHGSAnWindAdd;
    6740           94 :         state.dataOutRptTab->totalIzaAdd += thisZonePreDefRep.SHGSAnIzaAdd;
    6741           94 :         state.dataOutRptTab->totalInfilAdd += thisZonePreDefRep.SHGSAnInfilAdd;
    6742           94 :         state.dataOutRptTab->totalOtherAdd += thisZonePreDefRep.SHGSAnOtherAdd;
    6743           94 :         state.dataOutRptTab->totalEquipRem += thisZonePreDefRep.SHGSAnEquipRem;
    6744           94 :         state.dataOutRptTab->totalWindRem += thisZonePreDefRep.SHGSAnWindRem;
    6745           94 :         state.dataOutRptTab->totalIzaRem += thisZonePreDefRep.SHGSAnIzaRem;
    6746           94 :         state.dataOutRptTab->totalInfilRem += thisZonePreDefRep.SHGSAnInfilRem;
    6747           94 :         state.dataOutRptTab->totalOtherRem += thisZonePreDefRep.SHGSAnOtherRem;
    6748              :     }
    6749              :     // PreDefTableEntry(state,  pdchSHGSAnHvacHt, "Total Facility", totalHvacHt * convertJtoGJ, 3 );
    6750              :     // PreDefTableEntry(state,  pdchSHGSAnHvacCl, "Total Facility", totalHvacCl * convertJtoGJ, 3 );
    6751           73 :     PreDefTableEntry(
    6752           73 :         state, state.dataOutRptPredefined->pdchSHGSAnZoneEqHt, "Total Facility", state.dataOutRptTab->totalZoneEqHt * Constant::convertJtoGJ, 3);
    6753           73 :     PreDefTableEntry(
    6754           73 :         state, state.dataOutRptPredefined->pdchSHGSAnZoneEqCl, "Total Facility", state.dataOutRptTab->totalZoneEqCl * Constant::convertJtoGJ, 3);
    6755           73 :     PreDefTableEntry(
    6756           73 :         state, state.dataOutRptPredefined->pdchSHGSAnHvacATUHt, "Total Facility", state.dataOutRptTab->totalHvacATUHt * Constant::convertJtoGJ, 3);
    6757           73 :     PreDefTableEntry(
    6758           73 :         state, state.dataOutRptPredefined->pdchSHGSAnHvacATUCl, "Total Facility", state.dataOutRptTab->totalHvacATUCl * Constant::convertJtoGJ, 3);
    6759           73 :     PreDefTableEntry(
    6760           73 :         state, state.dataOutRptPredefined->pdchSHGSAnSurfHt, "Total Facility", state.dataOutRptTab->totalSurfHt * Constant::convertJtoGJ, 3);
    6761           73 :     PreDefTableEntry(
    6762           73 :         state, state.dataOutRptPredefined->pdchSHGSAnSurfCl, "Total Facility", state.dataOutRptTab->totalSurfCl * Constant::convertJtoGJ, 3);
    6763           73 :     PreDefTableEntry(
    6764           73 :         state, state.dataOutRptPredefined->pdchSHGSAnPeoplAdd, "Total Facility", state.dataOutRptTab->totalPeoplAdd * Constant::convertJtoGJ, 3);
    6765           73 :     PreDefTableEntry(
    6766           73 :         state, state.dataOutRptPredefined->pdchSHGSAnLiteAdd, "Total Facility", state.dataOutRptTab->totalLiteAdd * Constant::convertJtoGJ, 3);
    6767           73 :     PreDefTableEntry(
    6768           73 :         state, state.dataOutRptPredefined->pdchSHGSAnEquipAdd, "Total Facility", state.dataOutRptTab->totalEquipAdd * Constant::convertJtoGJ, 3);
    6769           73 :     PreDefTableEntry(
    6770           73 :         state, state.dataOutRptPredefined->pdchSHGSAnWindAdd, "Total Facility", state.dataOutRptTab->totalWindAdd * Constant::convertJtoGJ, 3);
    6771           73 :     PreDefTableEntry(
    6772           73 :         state, state.dataOutRptPredefined->pdchSHGSAnIzaAdd, "Total Facility", state.dataOutRptTab->totalIzaAdd * Constant::convertJtoGJ, 3);
    6773           73 :     PreDefTableEntry(
    6774           73 :         state, state.dataOutRptPredefined->pdchSHGSAnInfilAdd, "Total Facility", state.dataOutRptTab->totalInfilAdd * Constant::convertJtoGJ, 3);
    6775           73 :     PreDefTableEntry(
    6776           73 :         state, state.dataOutRptPredefined->pdchSHGSAnOtherAdd, "Total Facility", state.dataOutRptTab->totalOtherAdd * Constant::convertJtoGJ, 3);
    6777           73 :     PreDefTableEntry(
    6778           73 :         state, state.dataOutRptPredefined->pdchSHGSAnEquipRem, "Total Facility", state.dataOutRptTab->totalEquipRem * Constant::convertJtoGJ, 3);
    6779           73 :     PreDefTableEntry(
    6780           73 :         state, state.dataOutRptPredefined->pdchSHGSAnWindRem, "Total Facility", state.dataOutRptTab->totalWindRem * Constant::convertJtoGJ, 3);
    6781           73 :     PreDefTableEntry(
    6782           73 :         state, state.dataOutRptPredefined->pdchSHGSAnIzaRem, "Total Facility", state.dataOutRptTab->totalIzaRem * Constant::convertJtoGJ, 3);
    6783           73 :     PreDefTableEntry(
    6784           73 :         state, state.dataOutRptPredefined->pdchSHGSAnInfilRem, "Total Facility", state.dataOutRptTab->totalInfilRem * Constant::convertJtoGJ, 3);
    6785           73 :     PreDefTableEntry(
    6786           73 :         state, state.dataOutRptPredefined->pdchSHGSAnOtherRem, "Total Facility", state.dataOutRptTab->totalOtherRem * Constant::convertJtoGJ, 3);
    6787              :     // building level results for peak cooling
    6788          146 :     PreDefTableEntry(
    6789          219 :         state, state.dataOutRptPredefined->pdchSHGSClTimePeak, "Total Facility", DateToString(state.dataHeatBal->BuildingPreDefRep.clPtTimeStamp));
    6790              :     // PreDefTableEntry(state,  pdchSHGSClHvacHt, "Total Facility", BuildingPreDefRep.SHGSClHvacHt );
    6791              :     // PreDefTableEntry(state,  pdchSHGSClHvacCl, "Total Facility", BuildingPreDefRep.SHGSClHvacCl );
    6792          146 :     PreDefTableEntry(state,
    6793           73 :                      state.dataOutRptPredefined->pdchSHGSClHvacHt,
    6794              :                      "Total Facility",
    6795           73 :                      (state.dataHeatBal->BuildingPreDefRep.SHGSClHvacHt - state.dataHeatBal->BuildingPreDefRep.SHGSClHvacATUHt));
    6796          146 :     PreDefTableEntry(state,
    6797           73 :                      state.dataOutRptPredefined->pdchSHGSClHvacCl,
    6798              :                      "Total Facility",
    6799           73 :                      (state.dataHeatBal->BuildingPreDefRep.SHGSClHvacCl - state.dataHeatBal->BuildingPreDefRep.SHGSClHvacATUCl));
    6800           73 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSClHvacATUHt, "Total Facility", state.dataHeatBal->BuildingPreDefRep.SHGSClHvacATUHt);
    6801           73 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSClHvacATUCl, "Total Facility", state.dataHeatBal->BuildingPreDefRep.SHGSClHvacATUCl);
    6802           73 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSClSurfHt, "Total Facility", state.dataHeatBal->BuildingPreDefRep.SHGSClSurfHt);
    6803           73 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSClSurfCl, "Total Facility", state.dataHeatBal->BuildingPreDefRep.SHGSClSurfCl);
    6804           73 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSClPeoplAdd, "Total Facility", state.dataHeatBal->BuildingPreDefRep.SHGSClPeoplAdd);
    6805           73 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSClLiteAdd, "Total Facility", state.dataHeatBal->BuildingPreDefRep.SHGSClLiteAdd);
    6806           73 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSClEquipAdd, "Total Facility", state.dataHeatBal->BuildingPreDefRep.SHGSClEquipAdd);
    6807           73 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSClWindAdd, "Total Facility", state.dataHeatBal->BuildingPreDefRep.SHGSClWindAdd);
    6808           73 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSClIzaAdd, "Total Facility", state.dataHeatBal->BuildingPreDefRep.SHGSClIzaAdd);
    6809           73 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSClInfilAdd, "Total Facility", state.dataHeatBal->BuildingPreDefRep.SHGSClInfilAdd);
    6810           73 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSClOtherAdd, "Total Facility", state.dataHeatBal->BuildingPreDefRep.SHGSClOtherAdd);
    6811           73 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSClEquipRem, "Total Facility", state.dataHeatBal->BuildingPreDefRep.SHGSClEquipRem);
    6812           73 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSClWindRem, "Total Facility", state.dataHeatBal->BuildingPreDefRep.SHGSClWindRem);
    6813           73 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSClIzaRem, "Total Facility", state.dataHeatBal->BuildingPreDefRep.SHGSClIzaRem);
    6814           73 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSClInfilRem, "Total Facility", state.dataHeatBal->BuildingPreDefRep.SHGSClInfilRem);
    6815           73 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSClOtherRem, "Total Facility", state.dataHeatBal->BuildingPreDefRep.SHGSClOtherRem);
    6816              :     // building level results for peak heating
    6817          146 :     PreDefTableEntry(
    6818          219 :         state, state.dataOutRptPredefined->pdchSHGSHtTimePeak, "Total Facility", DateToString(state.dataHeatBal->BuildingPreDefRep.htPtTimeStamp));
    6819              :     // PreDefTableEntry(state,  pdchSHGSHtHvacHt, "Total Facility", BuildingPreDefRep.SHGSHtHvacHt );
    6820              :     // PreDefTableEntry(state,  pdchSHGSHtHvacCl, "Total Facility", BuildingPreDefRep.SHGSHtHvacCl );
    6821          146 :     PreDefTableEntry(state,
    6822           73 :                      state.dataOutRptPredefined->pdchSHGSHtHvacHt,
    6823              :                      "Total Facility",
    6824           73 :                      (state.dataHeatBal->BuildingPreDefRep.SHGSHtHvacHt - state.dataHeatBal->BuildingPreDefRep.SHGSHtHvacATUHt));
    6825          146 :     PreDefTableEntry(state,
    6826           73 :                      state.dataOutRptPredefined->pdchSHGSHtHvacCl,
    6827              :                      "Total Facility",
    6828           73 :                      (state.dataHeatBal->BuildingPreDefRep.SHGSHtHvacCl - state.dataHeatBal->BuildingPreDefRep.SHGSHtHvacATUCl));
    6829           73 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSHtHvacATUHt, "Total Facility", state.dataHeatBal->BuildingPreDefRep.SHGSHtHvacATUHt);
    6830           73 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSHtHvacATUCl, "Total Facility", state.dataHeatBal->BuildingPreDefRep.SHGSHtHvacATUCl);
    6831           73 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSHtSurfHt, "Total Facility", state.dataHeatBal->BuildingPreDefRep.SHGSHtSurfHt);
    6832           73 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSHtSurfCl, "Total Facility", state.dataHeatBal->BuildingPreDefRep.SHGSHtSurfCl);
    6833           73 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSHtPeoplAdd, "Total Facility", state.dataHeatBal->BuildingPreDefRep.SHGSHtPeoplAdd);
    6834           73 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSHtLiteAdd, "Total Facility", state.dataHeatBal->BuildingPreDefRep.SHGSHtLiteAdd);
    6835           73 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSHtEquipAdd, "Total Facility", state.dataHeatBal->BuildingPreDefRep.SHGSHtEquipAdd);
    6836           73 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSHtWindAdd, "Total Facility", state.dataHeatBal->BuildingPreDefRep.SHGSHtWindAdd);
    6837           73 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSHtIzaAdd, "Total Facility", state.dataHeatBal->BuildingPreDefRep.SHGSHtIzaAdd);
    6838           73 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSHtInfilAdd, "Total Facility", state.dataHeatBal->BuildingPreDefRep.SHGSHtInfilAdd);
    6839           73 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSHtOtherAdd, "Total Facility", state.dataHeatBal->BuildingPreDefRep.SHGSHtOtherAdd);
    6840           73 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSHtEquipRem, "Total Facility", state.dataHeatBal->BuildingPreDefRep.SHGSHtEquipRem);
    6841           73 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSHtWindRem, "Total Facility", state.dataHeatBal->BuildingPreDefRep.SHGSHtWindRem);
    6842           73 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSHtIzaRem, "Total Facility", state.dataHeatBal->BuildingPreDefRep.SHGSHtIzaRem);
    6843           73 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSHtInfilRem, "Total Facility", state.dataHeatBal->BuildingPreDefRep.SHGSHtInfilRem);
    6844           73 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSHtOtherRem, "Total Facility", state.dataHeatBal->BuildingPreDefRep.SHGSHtOtherRem);
    6845              : 
    6846              :     // LEED Report
    6847              :     // 1.1A-General Information
    6848           73 :     if (state.dataEnvrn->EnvironmentName == state.dataEnvrn->WeatherFileLocationTitle) {
    6849            0 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchLeedGenData, "Weather File", state.dataEnvrn->EnvironmentName);
    6850              :     } else {
    6851          146 :         PreDefTableEntry(state,
    6852           73 :                          state.dataOutRptPredefined->pdchLeedGenData,
    6853              :                          "Weather File",
    6854          146 :                          state.dataEnvrn->EnvironmentName + " ** " + state.dataEnvrn->WeatherFileLocationTitle);
    6855              :     }
    6856              : 
    6857           73 :     if (ort->ip()) {
    6858            2 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchLeedGenData, "Total gross floor area [ft2]", "-");
    6859              :     } else {
    6860           71 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchLeedGenData, "Total gross floor area [m2]", "-");
    6861              :     }
    6862              :     // LEED schedule sub table
    6863          607 :     for (auto *sched : state.dataSched->schedules) {
    6864          534 :         if (sched->schedTypeNum == -1) continue;
    6865          338 :         if (!Util::SameString(state.dataSched->scheduleTypes[sched->schedTypeNum]->Name, "FRACTION")) continue;
    6866              : 
    6867          172 :         PreDefTableEntry(state,
    6868           86 :                          state.dataOutRptPredefined->pdchLeedEflhEflh,
    6869              :                          sched->Name,
    6870           86 :                          sched->getAnnualHoursFullLoad(state, StartOfWeek, state.dataEnvrn->CurrentYearIsLeapYear),
    6871           86 :                          0);
    6872          172 :         PreDefTableEntry(state,
    6873           86 :                          state.dataOutRptPredefined->pdchLeedEflhNonZerHrs,
    6874              :                          sched->Name,
    6875           86 :                          sched->getAnnualHoursGreaterThan1Percent(state, StartOfWeek, state.dataEnvrn->CurrentYearIsLeapYear),
    6876          172 :                          0);
    6877              :     }
    6878              : 
    6879              :     // fill the LEED setpoint table
    6880           73 :     ZoneTempPredictorCorrector::FillPredefinedTableOnThermostatSetpoints(state);
    6881           73 :     ZoneTempPredictorCorrector::FillPredefinedTableOnThermostatSchedules(state);
    6882           73 : }
    6883              : 
    6884            1 : void WriteMonthlyTables(EnergyPlusData &state)
    6885              : {
    6886              :     // SUBROUTINE INFORMATION:
    6887              :     //       AUTHOR         Jason Glazer
    6888              :     //       DATE WRITTEN   August 2003
    6889              :     //       MODIFIED       January 2010, Kyle Benne
    6890              :     //                      Added SQLite output
    6891              :     //                      January 2021, J. Yuan
    6892              :     //                      Modified to accommodate dual-unit reporting
    6893              :     //       RE-ENGINEERED  na
    6894              : 
    6895              :     // PURPOSE OF THIS SUBROUTINE:
    6896              :     //   Set up the monthly tabular report results
    6897              : 
    6898              :     // METHODOLOGY EMPLOYED:
    6899              :     //   Creates several arrays that are passed to the WriteTable
    6900              :     //   routine.  All arrays are strings so numbers need to be
    6901              :     //   converted prior to calling WriteTable.
    6902              : 
    6903              :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
    6904            1 :     Array1D_string columnHead;
    6905            1 :     Array1D_int columnWidth;
    6906            1 :     Array1D_string rowHead(16);
    6907            1 :     Array2D_string tableBody;
    6908            1 :     std::string curAggString;
    6909              :     int iInput;
    6910              :     int jTable;
    6911              :     int kColumn;
    6912              :     int lMonth;
    6913              :     int curTable;
    6914              :     int curCol;
    6915              :     Real64 curVal;
    6916              :     Real64 curConversionFactor;
    6917              :     int columnUsedCount;
    6918              :     int columnRecount;
    6919              :     int digitsShown;
    6920              :     Real64 minVal;
    6921              :     Real64 maxVal;
    6922              :     Real64 sumVal;
    6923              :     Real64 sumDuration;
    6924            1 :     std::string curUnits;
    6925            1 :     std::string energyUnitsString;
    6926              :     Real64 energyUnitsConversionFactor;
    6927              :     int indexUnitConv;
    6928            1 :     std::string varNameWithUnits;
    6929              :     Real64 veryLarge;
    6930              :     Real64 verySmall;
    6931              : 
    6932              :     static Real64 const storedMaxVal(std::numeric_limits<Real64>::max());
    6933              :     static Real64 const storedMinVal(std::numeric_limits<Real64>::lowest());
    6934              : 
    6935            1 :     rowHead(1) = "January";
    6936            1 :     rowHead(2) = "February";
    6937            1 :     rowHead(3) = "March";
    6938            1 :     rowHead(4) = "April";
    6939            1 :     rowHead(5) = "May";
    6940            1 :     rowHead(6) = "June";
    6941            1 :     rowHead(7) = "July";
    6942            1 :     rowHead(8) = "August";
    6943            1 :     rowHead(9) = "September";
    6944            1 :     rowHead(10) = "October";
    6945            1 :     rowHead(11) = "November";
    6946            1 :     rowHead(12) = "December";
    6947            1 :     rowHead(13) = "";
    6948            1 :     rowHead(14) = "Annual Sum or Average";
    6949            1 :     rowHead(15) = "Minimum of Months";
    6950            1 :     rowHead(16) = "Maximum of Months";
    6951              : 
    6952              :     // Why is this a map? If the enum/integer is the independent variable/index, it should be a std::array.
    6953              :     std::unordered_map<AggType, std::string> aggString = {
    6954            0 :         {AggType::SumOrAvg, ""},
    6955            0 :         {AggType::Maximum, " Maximum "},
    6956            0 :         {AggType::Minimum, " MINIMUM "},
    6957            0 :         {AggType::ValueWhenMaxMin, " AT MAX/MIN "},
    6958            0 :         {AggType::HoursZero, " HOURS ZERO "},
    6959            0 :         {AggType::HoursNonZero, " HOURS NON-ZERO "},
    6960            0 :         {AggType::HoursPositive, " HOURS POSITIVE "},
    6961            0 :         {AggType::HoursNonPositive, " HOURS NON-POSITIVE "},
    6962            0 :         {AggType::HoursNegative, " HOURS NEGATIVE "},
    6963            0 :         {AggType::HoursNonNegative, " HOURS NON-NEGATIVE "},
    6964            0 :         {AggType::SumOrAverageHoursShown, " FOR HOURS SHOWN "},
    6965            0 :         {AggType::MaximumDuringHoursShown, " MAX FOR HOURS SHOWN "},
    6966            0 :         {AggType::MinimumDuringHoursShown, " MIN FOR HOURS SHOWN "},
    6967           15 :     };
    6968              : 
    6969            1 :     veryLarge = 1.0E280;
    6970            1 :     verySmall = -1.0E280;
    6971              : 
    6972            1 :     auto &ort = state.dataOutRptTab;
    6973              : 
    6974            3 :     for (int iUnitSystem = 0; iUnitSystem <= 1; iUnitSystem++) {
    6975            2 :         UnitsStyle unitsStyle_cur = ort->unitsStyle;
    6976            2 :         bool produceTabular = true;
    6977            2 :         bool produceSQLite = false;
    6978            2 :         if (produceDualUnitsFlags(iUnitSystem, ort->unitsStyle, ort->unitsStyle_SQLite, unitsStyle_cur, produceTabular, produceSQLite)) break;
    6979              : 
    6980              :         // set the unit conversion
    6981            2 :         if (unitsStyle_cur == UnitsStyle::None) {
    6982            1 :             energyUnitsString = "J";
    6983            1 :             energyUnitsConversionFactor = 1.0;
    6984            1 :         } else if (unitsStyle_cur == UnitsStyle::JtoKWH) {
    6985            0 :             energyUnitsString = "kWh";
    6986            0 :             energyUnitsConversionFactor = 1.0 / 3600000.0;
    6987            1 :         } else if (unitsStyle_cur == UnitsStyle::JtoMJ) {
    6988            0 :             energyUnitsString = "MJ";
    6989            0 :             energyUnitsConversionFactor = 1.0 / 1000000.0;
    6990            1 :         } else if (unitsStyle_cur == UnitsStyle::JtoGJ) {
    6991            0 :             energyUnitsString = "GJ";
    6992            0 :             energyUnitsConversionFactor = 1.0 / 1000000000.0;
    6993              :         } else { // Should never happen but assures compilers of initialization
    6994            1 :             energyUnitsString = "J";
    6995            1 :             energyUnitsConversionFactor = 1.0;
    6996              :         }
    6997              : 
    6998              :         // loop through each input to get the name of the tables
    6999            4 :         for (iInput = 1; iInput <= ort->MonthlyInputCount; ++iInput) {
    7000              :             // loop through each report and
    7001            2 :             digitsShown = ort->MonthlyInput(iInput).showDigits;
    7002            4 :             for (jTable = 1; jTable <= ort->MonthlyInput(iInput).numTables; ++jTable) {
    7003            2 :                 curTable = jTable + ort->MonthlyInput(iInput).firstTable - 1;
    7004              :                 // first loop through and count how many 'columns' are defined
    7005              :                 // since max and min actually define two columns (the value
    7006              :                 // and the timestamp).
    7007            2 :                 columnUsedCount = 0;
    7008           28 :                 for (kColumn = 1; kColumn <= ort->MonthlyTables(curTable).numColumns; ++kColumn) {
    7009           26 :                     curCol = kColumn + ort->MonthlyTables(curTable).firstColumn - 1;
    7010           26 :                     switch (ort->MonthlyColumns(curCol).aggType) {
    7011           18 :                     case AggType::SumOrAvg:
    7012              :                     case AggType::ValueWhenMaxMin:
    7013              :                     case AggType::HoursZero:
    7014              :                     case AggType::HoursNonZero:
    7015              :                     case AggType::HoursPositive:
    7016              :                     case AggType::HoursNonPositive:
    7017              :                     case AggType::HoursNegative:
    7018              :                     case AggType::HoursNonNegative:
    7019              :                     case AggType::SumOrAverageHoursShown: {
    7020           18 :                         ++columnUsedCount;
    7021           18 :                     } break;
    7022            8 :                     case AggType::Maximum:
    7023              :                     case AggType::Minimum:
    7024              :                     case AggType::MaximumDuringHoursShown:
    7025              :                     case AggType::MinimumDuringHoursShown: {
    7026            8 :                         columnUsedCount += 2;
    7027            8 :                     } break;
    7028            0 :                     default:
    7029            0 :                         break;
    7030              :                     }
    7031              :                 } // jColumn
    7032            2 :                 columnHead.allocate(columnUsedCount);
    7033            2 :                 columnWidth.dimension(columnUsedCount, 14); // array assignment - same for all columns
    7034            2 :                 tableBody.allocate(columnUsedCount, 16);
    7035            2 :                 tableBody = ""; // set entire table to blank as default
    7036            2 :                 columnRecount = 0;
    7037           28 :                 for (kColumn = 1; kColumn <= ort->MonthlyTables(curTable).numColumns; ++kColumn) {
    7038           26 :                     curCol = kColumn + ort->MonthlyTables(curTable).firstColumn - 1;
    7039           26 :                     curAggString = aggString.at(ort->MonthlyColumns(curCol).aggType);
    7040           26 :                     if (len(curAggString) > 0) {
    7041           24 :                         curAggString = " {" + stripped(curAggString) + '}';
    7042              :                     }
    7043              :                     // do the unit conversions
    7044           26 :                     if (unitsStyle_cur == OutputReportTabular::UnitsStyle::InchPound ||
    7045           26 :                         unitsStyle_cur == OutputReportTabular::UnitsStyle::InchPoundExceptElectricity) {
    7046              :                         varNameWithUnits =
    7047            0 :                             format("{} [{}]", ort->MonthlyColumns(curCol).varName, Constant::unitNames[(int)ort->MonthlyColumns(curCol).units]);
    7048            0 :                         LookupSItoIP(state, varNameWithUnits, indexUnitConv, curUnits);
    7049            0 :                         GetUnitConversion(state, indexUnitConv, curConversionFactor, state.dataOutRptTab->curConversionOffset, curUnits);
    7050           26 :                     } else if (Util::SameString(Constant::unitNames[(int)ort->MonthlyColumns(curCol).units], "J")) {
    7051           26 :                         curUnits = energyUnitsString;
    7052           26 :                         curConversionFactor = energyUnitsConversionFactor;
    7053           26 :                         state.dataOutRptTab->curConversionOffset = 0.0;
    7054              :                     } else { // if not joules don't perform conversion
    7055            0 :                         curUnits = Constant::unitNames[(int)ort->MonthlyColumns(curCol).units];
    7056            0 :                         curConversionFactor = 1.0;
    7057            0 :                         state.dataOutRptTab->curConversionOffset = 0.0;
    7058              :                     }
    7059           26 :                     switch (ort->MonthlyColumns(curCol).aggType) {
    7060            4 :                     case AggType::SumOrAvg:
    7061              :                     case AggType::SumOrAverageHoursShown: {
    7062            4 :                         ++columnRecount;
    7063              :                         // put in the name of the variable for the column
    7064            4 :                         columnHead(columnRecount) = ort->MonthlyColumns(curCol).varName + curAggString + " [" + curUnits + ']';
    7065            4 :                         sumVal = 0.0;
    7066            4 :                         sumDuration = 0.0;
    7067            4 :                         minVal = storedMaxVal;
    7068            4 :                         maxVal = storedMinVal;
    7069           52 :                         for (lMonth = 1; lMonth <= 12; ++lMonth) {
    7070           48 :                             if (ort->MonthlyColumns(curCol).avgSum ==
    7071              :                                 OutputProcessor::StoreType::Average) { // if it is a average variable divide by duration
    7072            0 :                                 if (ort->MonthlyColumns(curCol).duration(lMonth) != 0) {
    7073            0 :                                     curVal = ((ort->MonthlyColumns(curCol).reslt(lMonth) / ort->MonthlyColumns(curCol).duration(lMonth)) *
    7074              :                                               curConversionFactor) +
    7075            0 :                                              state.dataOutRptTab->curConversionOffset;
    7076              :                                 } else {
    7077            0 :                                     curVal = 0.0;
    7078              :                                 }
    7079            0 :                                 sumVal +=
    7080            0 :                                     (ort->MonthlyColumns(curCol).reslt(lMonth) * curConversionFactor) + state.dataOutRptTab->curConversionOffset;
    7081            0 :                                 sumDuration += ort->MonthlyColumns(curCol).duration(lMonth);
    7082              :                             } else {
    7083           48 :                                 curVal = (ort->MonthlyColumns(curCol).reslt(lMonth) * curConversionFactor) + state.dataOutRptTab->curConversionOffset;
    7084           48 :                                 sumVal += curVal;
    7085              :                             }
    7086           48 :                             if (ort->IsMonthGathered(lMonth)) {
    7087            0 :                                 tableBody(columnRecount, lMonth) = RealToStr(curVal, digitsShown);
    7088            0 :                                 if (curVal > maxVal) maxVal = curVal;
    7089            0 :                                 if (curVal < minVal) minVal = curVal;
    7090              :                             } else {
    7091           48 :                                 tableBody(columnRecount, lMonth) = "-";
    7092              :                             }
    7093              :                         } // lMonth
    7094              :                         // add the summary to bottom
    7095            4 :                         if (ort->MonthlyColumns(curCol).avgSum ==
    7096              :                             OutputProcessor::StoreType::Average) { // if it is a average variable divide by duration
    7097            0 :                             if (sumDuration > 0) {
    7098            0 :                                 tableBody(columnRecount, 14) = RealToStr(sumVal / sumDuration, digitsShown);
    7099              :                             } else {
    7100            0 :                                 tableBody(columnRecount, 14) = "";
    7101              :                             }
    7102              :                         } else {
    7103            4 :                             tableBody(columnRecount, 14) = RealToStr(sumVal, digitsShown);
    7104              :                         }
    7105            4 :                         if (minVal != storedMaxVal) {
    7106            0 :                             tableBody(columnRecount, 15) = RealToStr(minVal, digitsShown);
    7107              :                         }
    7108            4 :                         if (maxVal != storedMinVal) {
    7109            0 :                             tableBody(columnRecount, 16) = RealToStr(maxVal, digitsShown);
    7110              :                         }
    7111            4 :                     } break;
    7112           12 :                     case AggType::HoursZero:
    7113              :                     case AggType::HoursNonZero:
    7114              :                     case AggType::HoursPositive:
    7115              :                     case AggType::HoursNonPositive:
    7116              :                     case AggType::HoursNegative:
    7117              :                     case AggType::HoursNonNegative: {
    7118           12 :                         ++columnRecount;
    7119              :                         // put in the name of the variable for the column
    7120           12 :                         columnHead(columnRecount) = ort->MonthlyColumns(curCol).varName + curAggString + " [HOURS]";
    7121           12 :                         sumVal = 0.0;
    7122           12 :                         minVal = storedMaxVal;
    7123           12 :                         maxVal = storedMinVal;
    7124          156 :                         for (lMonth = 1; lMonth <= 12; ++lMonth) {
    7125          144 :                             curVal = ort->MonthlyColumns(curCol).reslt(lMonth);
    7126          144 :                             if (ort->IsMonthGathered(lMonth)) {
    7127            0 :                                 tableBody(columnRecount, lMonth) = RealToStr(curVal, digitsShown);
    7128            0 :                                 sumVal += curVal;
    7129            0 :                                 if (curVal > maxVal) maxVal = curVal;
    7130            0 :                                 if (curVal < minVal) minVal = curVal;
    7131              :                             } else {
    7132          144 :                                 tableBody(columnRecount, lMonth) = "-";
    7133              :                             }
    7134              :                         } // lMonth
    7135              :                         // add the summary to bottom
    7136           12 :                         tableBody(columnRecount, 14) = RealToStr(sumVal, digitsShown);
    7137           12 :                         if (minVal != storedMaxVal) {
    7138            0 :                             tableBody(columnRecount, 15) = RealToStr(minVal, digitsShown);
    7139              :                         }
    7140           12 :                         if (maxVal != storedMinVal) {
    7141            0 :                             tableBody(columnRecount, 16) = RealToStr(maxVal, digitsShown);
    7142              :                         }
    7143           12 :                     } break;
    7144            2 :                     case AggType::ValueWhenMaxMin: {
    7145            2 :                         ++columnRecount;
    7146            2 :                         if (ort->MonthlyColumns(curCol).avgSum == OutputProcessor::StoreType::Sum) {
    7147            2 :                             curUnits += "/s";
    7148              :                         }
    7149            2 :                         if (Util::SameString(curUnits, "J/s")) {
    7150            2 :                             curUnits = "W";
    7151              :                         }
    7152              :                         // CR7783 fix
    7153            2 :                         if (Util::SameString(curUnits, "kWh/s")) {
    7154            0 :                             curUnits = "W";
    7155            0 :                             curConversionFactor *= 3600000.0;
    7156              :                         }
    7157            2 :                         if (Util::SameString(curUnits, "GJ/s")) {
    7158            0 :                             curUnits = "kW";
    7159            0 :                             curConversionFactor *= 1000000.0;
    7160              :                         }
    7161            2 :                         if (Util::SameString(curUnits, "MJ/s")) {
    7162            0 :                             curUnits = "kW";
    7163            0 :                             curConversionFactor *= 1000.0;
    7164              :                         }
    7165            2 :                         if (Util::SameString(curUnits, "therm/s")) {
    7166            0 :                             curUnits = "kBtu/h";
    7167            0 :                             curConversionFactor *= 360000.0;
    7168              :                         }
    7169            2 :                         if (Util::SameString(curUnits, "kBtu/s")) {
    7170            0 :                             curUnits = "kBtu/h";
    7171            0 :                             curConversionFactor *= 3600.0;
    7172              :                         }
    7173            2 :                         if (Util::SameString(curUnits, "ton-hrs/s")) {
    7174            0 :                             curUnits = "ton";
    7175            0 :                             curConversionFactor *= 3600.0;
    7176              :                         }
    7177            2 :                         columnHead(columnRecount) = ort->MonthlyColumns(curCol).varName + curAggString + " [" + curUnits + ']';
    7178            2 :                         minVal = storedMaxVal;
    7179            2 :                         maxVal = storedMinVal;
    7180           26 :                         for (lMonth = 1; lMonth <= 12; ++lMonth) {
    7181           24 :                             curVal = ort->MonthlyColumns(curCol).reslt(lMonth) * curConversionFactor + state.dataOutRptTab->curConversionOffset;
    7182           24 :                             if (ort->IsMonthGathered(lMonth)) {
    7183            0 :                                 tableBody(columnRecount, lMonth) = RealToStr(curVal, digitsShown);
    7184            0 :                                 if (curVal > maxVal) maxVal = curVal;
    7185            0 :                                 if (curVal < minVal) minVal = curVal;
    7186              :                             } else {
    7187           24 :                                 tableBody(columnRecount, lMonth) = "-";
    7188              :                             }
    7189              :                         } // lMonth
    7190              :                         // add the summary to bottom
    7191            2 :                         if (minVal != storedMaxVal) {
    7192            0 :                             tableBody(columnRecount, 15) = RealToStr(minVal, digitsShown);
    7193              :                         }
    7194            2 :                         if (maxVal != storedMinVal) {
    7195            0 :                             tableBody(columnRecount, 16) = RealToStr(maxVal, digitsShown);
    7196              :                         }
    7197            2 :                     } break;
    7198            8 :                     case AggType::Maximum:
    7199              :                     case AggType::Minimum:
    7200              :                     case AggType::MaximumDuringHoursShown:
    7201              :                     case AggType::MinimumDuringHoursShown: {
    7202            8 :                         columnRecount += 2;
    7203              :                         // put in the name of the variable for the column
    7204            8 :                         if (ort->MonthlyColumns(curCol).avgSum == OutputProcessor::StoreType::Sum) { // if it is a summed variable
    7205            8 :                             curUnits += "/s";
    7206              :                         }
    7207            8 :                         if (Util::SameString(curUnits, "J/s")) {
    7208            8 :                             curUnits = "W";
    7209              :                         }
    7210              :                         // CR7783 fix
    7211            8 :                         if (Util::SameString(curUnits, "kWh/s")) {
    7212            0 :                             curUnits = "W";
    7213            0 :                             curConversionFactor *= 3600000.0;
    7214              :                         }
    7215            8 :                         if (Util::SameString(curUnits, "GJ/s")) {
    7216            0 :                             curUnits = "kW";
    7217            0 :                             curConversionFactor *= 1000000.0;
    7218              :                         }
    7219            8 :                         if (Util::SameString(curUnits, "MJ/s")) {
    7220            0 :                             curUnits = "kW";
    7221            0 :                             curConversionFactor *= 1000.0;
    7222              :                         }
    7223            8 :                         if (Util::SameString(curUnits, "therm/s")) {
    7224            0 :                             curUnits = "kBtu/h";
    7225            0 :                             curConversionFactor *= 360000.0;
    7226              :                         }
    7227            8 :                         if (Util::SameString(curUnits, "kBtu/s")) {
    7228            0 :                             curUnits = "kBtu/h";
    7229            0 :                             curConversionFactor *= 3600.0;
    7230              :                         }
    7231            8 :                         if (Util::SameString(curUnits, "ton-hrs/s")) {
    7232            0 :                             curUnits = "ton";
    7233            0 :                             curConversionFactor *= 3600.0;
    7234              :                         }
    7235            8 :                         columnHead(columnRecount - 1) = ort->MonthlyColumns(curCol).varName + curAggString + " [" + curUnits + ']';
    7236            8 :                         columnHead(columnRecount) = ort->MonthlyColumns(curCol).varName + " {TIMESTAMP}";
    7237            8 :                         minVal = storedMaxVal;
    7238            8 :                         maxVal = storedMinVal;
    7239          104 :                         for (lMonth = 1; lMonth <= 12; ++lMonth) {
    7240           96 :                             if (ort->IsMonthGathered(lMonth)) {
    7241            0 :                                 curVal = ort->MonthlyColumns(curCol).reslt(lMonth);
    7242              :                                 // CR7788 the conversion factors were causing an overflow for the InchPound case since the
    7243              :                                 // value was very small
    7244              :                                 // restructured the following lines to hide showing HUGE and -HUGE values in output table CR8154 Glazer
    7245            0 :                                 if ((curVal < veryLarge) && (curVal > verySmall)) {
    7246            0 :                                     curVal = curVal * curConversionFactor + state.dataOutRptTab->curConversionOffset;
    7247            0 :                                     if (curVal > maxVal) maxVal = curVal;
    7248            0 :                                     if (curVal < minVal) minVal = curVal;
    7249            0 :                                     if (curVal < veryLarge && curVal > verySmall) {
    7250            0 :                                         tableBody(columnRecount - 1, lMonth) = RealToStr(curVal, digitsShown);
    7251              :                                     } else {
    7252            0 :                                         tableBody(columnRecount - 1, lMonth) = "-";
    7253              :                                     }
    7254            0 :                                     tableBody(columnRecount, lMonth) = DateToString(ort->MonthlyColumns(curCol).timeStamp(lMonth));
    7255              :                                 } else {
    7256            0 :                                     tableBody(columnRecount - 1, lMonth) = "-";
    7257            0 :                                     tableBody(columnRecount, lMonth) = "-";
    7258              :                                 }
    7259              :                             } else {
    7260           96 :                                 tableBody(columnRecount - 1, lMonth) = "-";
    7261           96 :                                 tableBody(columnRecount, lMonth) = "-";
    7262              :                             }
    7263              :                         } // lMonth
    7264              :                         // add the summary to bottom
    7265              :                         // Don't include if the original min and max values are still present
    7266            8 :                         if (minVal < veryLarge) {
    7267            0 :                             tableBody(columnRecount - 1, 15) = RealToStr(minVal, digitsShown);
    7268              :                         } else {
    7269            8 :                             tableBody(columnRecount - 1, 15) = "-";
    7270              :                         }
    7271            8 :                         if (maxVal > verySmall) {
    7272            0 :                             tableBody(columnRecount - 1, 16) = RealToStr(maxVal, digitsShown);
    7273              :                         } else {
    7274            8 :                             tableBody(columnRecount - 1, 15) = "-";
    7275              :                         }
    7276            8 :                     } break;
    7277            0 :                     default:
    7278            0 :                         break;
    7279              :                     }
    7280              :                 } // KColumn
    7281            2 :                 if (produceTabular) {
    7282            1 :                     WriteReportHeaders(
    7283            1 :                         state, ort->MonthlyInput(iInput).name, ort->MonthlyTables(curTable).keyValue, OutputProcessor::StoreType::Average);
    7284            1 :                     WriteSubtitle(state, "Custom Monthly Report");
    7285            1 :                     WriteTable(state, tableBody, rowHead, columnHead, columnWidth, true); // transpose monthly XML tables.
    7286              :                 }
    7287            2 :                 if (produceSQLite) {
    7288            1 :                     if (state.dataSQLiteProcedures->sqlite) {
    7289            2 :                         state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(tableBody,
    7290              :                                                                                            rowHead,
    7291              :                                                                                            columnHead,
    7292            1 :                                                                                            ort->MonthlyInput(iInput).name,
    7293            1 :                                                                                            ort->MonthlyTables(curTable).keyValue,
    7294              :                                                                                            "Custom Monthly Report");
    7295              :                     }
    7296              :                 }
    7297            2 :                 if (produceTabular) {
    7298            1 :                     if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
    7299            0 :                         state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(tableBody,
    7300              :                                                                                                               rowHead,
    7301              :                                                                                                               columnHead,
    7302            0 :                                                                                                               ort->MonthlyInput(iInput).name,
    7303            0 :                                                                                                               ort->MonthlyTables(curTable).keyValue,
    7304              :                                                                                                               "Custom Monthly Report");
    7305              :                     }
    7306              :                 }
    7307              :             } // jTables
    7308              :         }     // iInput
    7309              :     }
    7310            2 : }
    7311              : 
    7312            0 : void WriteTimeBinTables(EnergyPlusData &state)
    7313              : {
    7314              :     // SUBROUTINE INFORMATION:
    7315              :     //       AUTHOR         Jason Glazer
    7316              :     //       DATE WRITTEN   August 2003
    7317              :     //       MODIFIED       January 2010, Kyle Benne
    7318              :     //                      Added SQLite output
    7319              :     //       RE-ENGINEERED  na
    7320              : 
    7321              :     // PURPOSE OF THIS SUBROUTINE:
    7322              :     //   Set up the time bin tabular report results
    7323              : 
    7324              :     // METHODOLOGY EMPLOYED:
    7325              :     //   Creates several arrays that are passed to the WriteTable
    7326              :     //   routine.  All arrays are strings so numbers need to be
    7327              :     //   converted prior to calling WriteTable.
    7328              : 
    7329              :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
    7330              :     // main table
    7331            0 :     Array1D_string columnHead;
    7332            0 :     Array1D_int columnWidth;
    7333            0 :     Array1D_string rowHead(39);
    7334            0 :     Array2D_string tableBody;
    7335              :     // stat table
    7336            0 :     Array1D_string columnHeadStat(1);
    7337            0 :     Array1D_int columnWidthStat(1);
    7338            0 :     Array1D_string rowHeadStat(6);
    7339            0 :     Array2D_string tableBodyStat(1, 6);
    7340              : 
    7341            0 :     std::string repNameWithUnitsandscheduleName;
    7342            0 :     std::string curNameWithSIUnits;
    7343            0 :     std::string curNameAndUnits;
    7344              : 
    7345            0 :     auto &ort = state.dataOutRptTab;
    7346              : 
    7347            0 :     for (int iUnitSystem = 0; iUnitSystem <= 1; iUnitSystem++) {
    7348            0 :         UnitsStyle unitsStyle_cur = ort->unitsStyle;
    7349            0 :         bool produceTabular = true;
    7350            0 :         bool produceSQLite = false;
    7351            0 :         if (produceDualUnitsFlags(iUnitSystem, ort->unitsStyle, ort->unitsStyle_SQLite, unitsStyle_cur, produceTabular, produceSQLite)) break;
    7352              : 
    7353            0 :         rowHead(1) = "Interval Start";
    7354            0 :         rowHead(2) = "Interval End";
    7355            0 :         rowHead(3) = "January";
    7356            0 :         rowHead(4) = "February";
    7357            0 :         rowHead(5) = "March";
    7358            0 :         rowHead(6) = "April";
    7359            0 :         rowHead(7) = "May";
    7360            0 :         rowHead(8) = "June";
    7361            0 :         rowHead(9) = "July";
    7362            0 :         rowHead(10) = "August";
    7363            0 :         rowHead(11) = "September";
    7364            0 :         rowHead(12) = "October";
    7365            0 :         rowHead(13) = "November";
    7366            0 :         rowHead(14) = "December";
    7367            0 :         rowHead(15) = "12:01 to  1:00 am";
    7368            0 :         rowHead(16) = " 1:01 to  2:00 am";
    7369            0 :         rowHead(17) = " 2:01 to  3:00 am";
    7370            0 :         rowHead(18) = " 3:01 to  4:00 am";
    7371            0 :         rowHead(19) = " 4:01 to  5:00 am";
    7372            0 :         rowHead(20) = " 5:01 to  6:00 am";
    7373            0 :         rowHead(21) = " 6:01 to  7:00 am";
    7374            0 :         rowHead(22) = " 7:01 to  8:00 am";
    7375            0 :         rowHead(23) = " 8:01 to  9:00 am";
    7376            0 :         rowHead(24) = " 9:01 to 10:00 am";
    7377            0 :         rowHead(25) = "10:01 to 11:00 am";
    7378            0 :         rowHead(26) = "11:01 to 12:00 pm";
    7379            0 :         rowHead(27) = "12:01 to  1:00 pm";
    7380            0 :         rowHead(28) = " 1:01 to  2:00 pm";
    7381            0 :         rowHead(29) = " 2:01 to  3:00 pm";
    7382            0 :         rowHead(30) = " 3:01 to  4:00 pm";
    7383            0 :         rowHead(31) = " 4:01 to  5:00 pm";
    7384            0 :         rowHead(32) = " 5:01 to  6:00 pm";
    7385            0 :         rowHead(33) = " 6:01 to  7:00 pm";
    7386            0 :         rowHead(34) = " 7:01 to  8:00 pm";
    7387            0 :         rowHead(35) = " 8:01 to  9:00 pm";
    7388            0 :         rowHead(36) = " 9:01 to 10:00 pm";
    7389            0 :         rowHead(37) = "10:01 to 11:00 pm";
    7390            0 :         rowHead(38) = "11:01 to 12:00 am";
    7391            0 :         rowHead(39) = "Total";
    7392              : 
    7393            0 :         for (int iInObj = 1; iInObj <= ort->OutputTableBinnedCount; ++iInObj) {
    7394            0 :             int const firstReport = ort->OutputTableBinned(iInObj).resIndex;
    7395              :             curNameWithSIUnits =
    7396            0 :                 format("{} [{}]", ort->OutputTableBinned(iInObj).varOrMeter, Constant::unitNames[(int)ort->OutputTableBinned(iInObj).units]);
    7397              :             Real64 curIntervalStart;
    7398              :             Real64 curIntervalSize;
    7399            0 :             int indexUnitConv = -1;
    7400            0 :             if (unitsStyle_cur == UnitsStyle::InchPound) {
    7401            0 :                 LookupSItoIP(state, curNameWithSIUnits, indexUnitConv, curNameAndUnits);
    7402            0 :                 curIntervalStart = ConvertIP(state, indexUnitConv, ort->OutputTableBinned(iInObj).intervalStart);
    7403            0 :                 curIntervalSize = ConvertIPdelta(state, indexUnitConv, ort->OutputTableBinned(iInObj).intervalSize);
    7404            0 :             } else if (unitsStyle_cur == UnitsStyle::InchPoundExceptElectricity) {
    7405            0 :                 LookupSItoIP(state, curNameWithSIUnits, indexUnitConv, curNameAndUnits);
    7406            0 :                 curIntervalStart = ConvertIP(state, indexUnitConv, ort->OutputTableBinned(iInObj).intervalStart);
    7407            0 :                 curIntervalSize = ConvertIPdelta(state, indexUnitConv, ort->OutputTableBinned(iInObj).intervalSize);
    7408              :             } else {
    7409            0 :                 curNameAndUnits = curNameWithSIUnits;
    7410            0 :                 curIntervalStart = ort->OutputTableBinned(iInObj).intervalStart;
    7411            0 :                 curIntervalSize = ort->OutputTableBinned(iInObj).intervalSize;
    7412              :             }
    7413            0 :             int const curIntervalCount = ort->OutputTableBinned(iInObj).intervalCount;
    7414            0 :             int const curNumTables = ort->OutputTableBinned(iInObj).numTables;
    7415            0 :             Real64 const topValue = curIntervalStart + curIntervalSize * curIntervalCount;
    7416            0 :             int numIntervalDigits = 2;
    7417            0 :             if (curIntervalSize < 1) {
    7418            0 :                 numIntervalDigits = 4;
    7419            0 :             } else if (curIntervalSize >= 10) {
    7420            0 :                 numIntervalDigits = 0;
    7421              :             }
    7422            0 :             int const numCols = curIntervalCount + 3;
    7423              :             // make arrays two columns wider for below and above bin range
    7424            0 :             columnHead.allocate(numCols);
    7425            0 :             columnWidth.allocate(numCols);
    7426            0 :             columnWidth = 14; // array assignment - same for all columns
    7427            0 :             tableBody.allocate(numCols, 39);
    7428            0 :             tableBody = "";
    7429            0 :             columnHead = "- [hr]";
    7430            0 :             tableBody(1, 1) = "less than";
    7431            0 :             tableBody(1, 2) = RealToStr(curIntervalStart, numIntervalDigits);
    7432            0 :             for (int nCol = 1; nCol <= curIntervalCount; ++nCol) {
    7433            0 :                 columnHead(nCol + 1) = fmt::format("{} [hr]", nCol);
    7434              :                 // beginning of interval
    7435            0 :                 tableBody(nCol + 1, 1) = RealToStr(curIntervalStart + (nCol - 1) * curIntervalSize, numIntervalDigits) + "<=";
    7436              :                 // end of interval
    7437            0 :                 tableBody(nCol + 1, 2) = RealToStr(curIntervalStart + nCol * curIntervalSize, numIntervalDigits) + '>';
    7438              :             }
    7439            0 :             tableBody(curIntervalCount + 2, 1) = "equal to or more than";
    7440            0 :             tableBody(curIntervalCount + 2, 2) = RealToStr(topValue, numIntervalDigits);
    7441            0 :             tableBody(numCols, 1) = "Row";
    7442            0 :             tableBody(numCols, 2) = "Total";
    7443            0 :             for (int iTable = 1; iTable <= curNumTables; ++iTable) {
    7444            0 :                 int const repIndex = firstReport + (iTable - 1);
    7445            0 :                 if (ort->OutputTableBinned(iInObj).sched == nullptr) {
    7446            0 :                     repNameWithUnitsandscheduleName = curNameAndUnits;
    7447              :                 } else {
    7448            0 :                     repNameWithUnitsandscheduleName = curNameAndUnits + " [" + ort->OutputTableBinned(iInObj).sched->Name + ']';
    7449              :                 }
    7450            0 :                 if (produceTabular) {
    7451            0 :                     WriteReportHeaders(
    7452            0 :                         state, repNameWithUnitsandscheduleName, ort->BinObjVarID(repIndex).namesOfObj, ort->OutputTableBinned(iInObj).avgSum);
    7453              :                 }
    7454            0 :                 for (int kHour = 1; kHour <= 24; ++kHour) {
    7455            0 :                     tableBody(1, 14 + kHour) = RealToStr(ort->BinResultsBelow(repIndex).hrly(kHour), 2);
    7456            0 :                     tableBody(curIntervalCount + 2, 14 + kHour) = RealToStr(ort->BinResultsAbove(repIndex).hrly(kHour), 2);
    7457            0 :                     Real64 rowTotal = ort->BinResultsBelow(repIndex).hrly(kHour) + ort->BinResultsAbove(repIndex).hrly(kHour);
    7458            0 :                     for (int nCol = 1; nCol <= curIntervalCount; ++nCol) {
    7459            0 :                         tableBody(nCol + 1, 14 + kHour) = RealToStr(ort->BinResults(nCol, repIndex).hrly(kHour), 2);
    7460              :                         // sum the total for all columns
    7461            0 :                         rowTotal += ort->BinResults(nCol, repIndex).hrly(kHour);
    7462              :                     }
    7463            0 :                     tableBody(numCols, 14 + kHour) = RealToStr(rowTotal, 2);
    7464              :                 }
    7465            0 :                 Real64 tableTotal = 0.0;
    7466            0 :                 for (int kMonth = 1; kMonth <= 12; ++kMonth) {
    7467            0 :                     tableBody(1, 2 + kMonth) = RealToStr(ort->BinResultsBelow(repIndex).mnth(kMonth), 2);
    7468            0 :                     tableBody(curIntervalCount + 2, 2 + kMonth) = RealToStr(ort->BinResultsAbove(repIndex).mnth(kMonth), 2);
    7469            0 :                     Real64 rowTotal = ort->BinResultsBelow(repIndex).mnth(kMonth) + ort->BinResultsAbove(repIndex).mnth(kMonth);
    7470            0 :                     for (int nCol = 1; nCol <= curIntervalCount; ++nCol) {
    7471            0 :                         tableBody(nCol + 1, 2 + kMonth) = RealToStr(ort->BinResults(nCol, repIndex).mnth(kMonth), 2);
    7472              :                         // sum the total for all columns
    7473            0 :                         rowTotal += ort->BinResults(nCol, repIndex).mnth(kMonth);
    7474              :                     }
    7475            0 :                     tableBody(numCols, 2 + kMonth) = RealToStr(rowTotal, 2);
    7476            0 :                     tableTotal += rowTotal;
    7477              :                 }
    7478              :                 // compute total row
    7479            0 :                 for (int nCol = 1; nCol <= curIntervalCount; ++nCol) {
    7480            0 :                     Real64 colTotal = 0.0;
    7481            0 :                     for (int kMonth = 1; kMonth <= 12; ++kMonth) {
    7482            0 :                         colTotal += ort->BinResults(nCol, repIndex).mnth(kMonth);
    7483              :                     }
    7484            0 :                     tableBody(nCol + 1, 39) = RealToStr(colTotal, 2);
    7485              :                 }
    7486            0 :                 Real64 aboveTotal = 0.0;
    7487            0 :                 Real64 belowTotal = 0.0;
    7488            0 :                 for (int kMonth = 1; kMonth <= 12; ++kMonth) {
    7489            0 :                     aboveTotal += ort->BinResultsAbove(repIndex).mnth(kMonth);
    7490            0 :                     belowTotal += ort->BinResultsBelow(repIndex).mnth(kMonth);
    7491              :                 }
    7492            0 :                 tableBody(1, 39) = RealToStr(belowTotal, 2);
    7493            0 :                 tableBody(curIntervalCount + 2, 39) = RealToStr(aboveTotal, 2);
    7494            0 :                 tableBody(numCols, 39) = RealToStr(tableTotal, 2);
    7495            0 :                 if (produceTabular) {
    7496            0 :                     WriteTextLine(state, "Values in table are in hours.");
    7497            0 :                     WriteTextLine(state, "");
    7498            0 :                     WriteSubtitle(state, "Time Bin Results");
    7499            0 :                     WriteTable(state, tableBody, rowHead, columnHead, columnWidth, true); // transpose XML tables
    7500              :                 }
    7501            0 :                 if (produceSQLite) {
    7502            0 :                     if (state.dataSQLiteProcedures->sqlite) {
    7503            0 :                         state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(tableBody,
    7504              :                                                                                            rowHead,
    7505              :                                                                                            columnHead,
    7506              :                                                                                            repNameWithUnitsandscheduleName,
    7507            0 :                                                                                            ort->BinObjVarID(repIndex).namesOfObj,
    7508              :                                                                                            "Time Bin Results");
    7509              :                     }
    7510              :                 }
    7511            0 :                 if (produceTabular) {
    7512            0 :                     if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
    7513            0 :                         state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(tableBody,
    7514              :                                                                                                               rowHead,
    7515              :                                                                                                               columnHead,
    7516              :                                                                                                               repNameWithUnitsandscheduleName,
    7517            0 :                                                                                                               ort->BinObjVarID(repIndex).namesOfObj,
    7518              :                                                                                                               "Time Bin Results");
    7519              :                     }
    7520              :                 }
    7521              :                 // create statistics table
    7522            0 :                 rowHeadStat(1) = "Minimum";
    7523            0 :                 rowHeadStat(2) = "Mean minus two standard deviations";
    7524            0 :                 rowHeadStat(3) = "Mean";
    7525            0 :                 rowHeadStat(4) = "Mean plus two standard deviations";
    7526            0 :                 rowHeadStat(5) = "Maximum";
    7527            0 :                 rowHeadStat(6) = "Standard deviation";
    7528            0 :                 columnHeadStat(1) = "Statistic";
    7529            0 :                 columnWidthStat(1) = 14;
    7530              :                 // per Applied Regression Analysis and Other Multivariate Methods, Kleinburger/Kupper, 1978
    7531              :                 // first check if very large constant number has caused the second part to be larger than the first
    7532            0 :                 Real64 repStDev = 0.0;
    7533            0 :                 Real64 repMean = 0.0;
    7534              : 
    7535            0 :                 if (ort->BinStatistics(repIndex).n > 1) {
    7536            0 :                     if (ort->BinStatistics(repIndex).sum2 > (pow_2(ort->BinStatistics(repIndex).sum) / ort->BinStatistics(repIndex).n)) {
    7537            0 :                         repStDev = std::sqrt(
    7538            0 :                             (ort->BinStatistics(repIndex).sum2 - (pow_2(ort->BinStatistics(repIndex).sum) / ort->BinStatistics(repIndex).n)) /
    7539            0 :                             (ort->BinStatistics(repIndex).n - 1));
    7540              :                     } else {
    7541            0 :                         repStDev = 0.0;
    7542              :                     }
    7543            0 :                     repMean = ort->BinStatistics(repIndex).sum / ort->BinStatistics(repIndex).n;
    7544              :                 }
    7545              : 
    7546            0 :                 if (unitsStyle_cur == OutputReportTabular::UnitsStyle::InchPound ||
    7547            0 :                     unitsStyle_cur == OutputReportTabular::UnitsStyle::InchPoundExceptElectricity) {
    7548            0 :                     tableBodyStat(1, 1) = RealToStr(ConvertIP(state, indexUnitConv, ort->BinStatistics(repIndex).minimum), 2);
    7549            0 :                     tableBodyStat(1, 2) = RealToStr(ConvertIP(state, indexUnitConv, repMean - 2 * repStDev), 2);
    7550            0 :                     tableBodyStat(1, 3) = RealToStr(ConvertIP(state, indexUnitConv, repMean), 2);
    7551            0 :                     tableBodyStat(1, 4) = RealToStr(ConvertIP(state, indexUnitConv, repMean + 2 * repStDev), 2);
    7552            0 :                     tableBodyStat(1, 5) = RealToStr(ConvertIP(state, indexUnitConv, ort->BinStatistics(repIndex).maximum), 2);
    7553            0 :                     tableBodyStat(1, 6) = RealToStr(ConvertIPdelta(state, indexUnitConv, repStDev), 2);
    7554              :                 } else {
    7555            0 :                     tableBodyStat(1, 1) = RealToStr(ort->BinStatistics(repIndex).minimum, 2);
    7556            0 :                     tableBodyStat(1, 2) = RealToStr(repMean - 2 * repStDev, 2);
    7557            0 :                     tableBodyStat(1, 3) = RealToStr(repMean, 2);
    7558            0 :                     tableBodyStat(1, 4) = RealToStr(repMean + 2 * repStDev, 2);
    7559            0 :                     tableBodyStat(1, 5) = RealToStr(ort->BinStatistics(repIndex).maximum, 2);
    7560            0 :                     tableBodyStat(1, 6) = RealToStr(repStDev, 2);
    7561              :                 }
    7562            0 :                 if (produceTabular) {
    7563            0 :                     WriteSubtitle(state, "Statistics");
    7564            0 :                     WriteTable(state, tableBodyStat, rowHeadStat, columnHeadStat, columnWidthStat, true); // transpose XML table
    7565              :                 }
    7566            0 :                 if (produceSQLite) {
    7567            0 :                     if (state.dataSQLiteProcedures->sqlite) {
    7568            0 :                         state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
    7569            0 :                             tableBody, rowHead, columnHead, repNameWithUnitsandscheduleName, ort->BinObjVarID(repIndex).namesOfObj, "Statistics");
    7570              :                     }
    7571              :                 }
    7572            0 :                 if (produceTabular) {
    7573            0 :                     if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
    7574            0 :                         state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(
    7575            0 :                             tableBody, rowHead, columnHead, repNameWithUnitsandscheduleName, ort->BinObjVarID(repIndex).namesOfObj, "Statistics");
    7576              :                     }
    7577              :                 }
    7578              :             }
    7579              :         }
    7580              :     }
    7581            0 : }
    7582              : 
    7583           42 : void WriteBEPSTable(EnergyPlusData &state)
    7584              : {
    7585              :     // SUBROUTINE INFORMATION:
    7586              :     //       AUTHOR         Jason Glazer
    7587              :     //       DATE WRITTEN   November 2003
    7588              :     //       MODIFIED       January 2010, Kyle Benne; Added SQLite output
    7589              :     //                      March 2020, Dareum Nam; Disaggregated "Additional Fuel"
    7590              : 
    7591              :     // PURPOSE OF THIS SUBROUTINE:
    7592              :     //   Take the gathered total and enduse meter data and structure
    7593              :     //   the results into a tabular report for output.
    7594              : 
    7595              :     // METHODOLOGY EMPLOYED:
    7596              :     //   Create arrays for the call to WriteTable and then call it.
    7597              :     //   This report actually consists of many sub-tables each with
    7598              :     //   its own call to WriteTable.  Anytime that column headings are
    7599              :     //   desired they are done in a new table because the only place
    7600              :     //   that will split up very long header lines for the fixed width
    7601              :     //   table is the header rows.
    7602              : 
    7603           42 :     int constexpr colElectricity(1);
    7604           42 :     int constexpr colGas(2);
    7605           42 :     int constexpr colGasoline(3);
    7606           42 :     int constexpr colDiesel(4);
    7607           42 :     int constexpr colCoal(5);
    7608           42 :     int constexpr colFuelOilNo1(6);
    7609           42 :     int constexpr colFuelOilNo2(7);
    7610           42 :     int constexpr colPropane(8);
    7611           42 :     int constexpr colOtherFuel1(9);
    7612           42 :     int constexpr colOtherFuel2(10);
    7613           42 :     int constexpr colPurchCool(11);
    7614           42 :     int constexpr colPurchHeatWtr(12);
    7615           42 :     int constexpr colPurchHeatSt(13);
    7616              : 
    7617           42 :     Real64 constexpr SmallValue(1.e-14);
    7618           42 :     auto &ort = state.dataOutRptTab;
    7619           42 :     auto &op = state.dataOutputProcessor;
    7620              : 
    7621           42 :     if (!ort->displayTabularBEPS && !ort->displayLEEDSummary) {
    7622            0 :         return;
    7623              :     }
    7624              : 
    7625              :     // all arrays are in the format: (row, column)
    7626           42 :     Array1D_string columnHead;
    7627           42 :     Array1D_int columnWidth;
    7628           42 :     Array1D_string rowHead;
    7629           42 :     Array2D_string tableBody;
    7630              : 
    7631           42 :     Array2D<Real64> useVal(14, 15);
    7632           42 :     Array2D<Real64> normalVal(14, 4);
    7633           42 :     Array1D<Real64> collapsedTotal(14);
    7634           42 :     Array2D<Real64> collapsedEndUse(14, static_cast<int>(Constant::EndUse::Num));
    7635           42 :     Array3D<Real64> collapsedEndUseSub(state.dataOutputProcessor->MaxNumSubcategories, static_cast<int>(Constant::EndUse::Num), 14);
    7636           42 :     Array2D<Real64> endUseSubOther(14, static_cast<int>(Constant::EndUse::Num));
    7637           42 :     Array3D<Real64> collapsedEndUseSpType(state.dataOutputProcessor->maxNumEndUseSpaceTypes, static_cast<int>(Constant::EndUse::Num), 14);
    7638              : 
    7639              :     // Jan 2021: Added temp storage
    7640           42 :     Real64 gtPowerFuelFireGen = ort->gatherPowerFuelFireGen;
    7641           42 :     Real64 gtPowerPV = ort->gatherPowerPV;
    7642           42 :     Real64 gtPowerWind = ort->gatherPowerWind;
    7643           42 :     Real64 gtPowerHTGeothermal = ort->gatherPowerHTGeothermal;
    7644           42 :     Real64 gtPowerConversion = ort->gatherPowerConversion;
    7645           42 :     Real64 gtElecProduced = ort->gatherElecProduced;
    7646           42 :     Real64 gtElecPUrchased = ort->gatherElecPurchased;
    7647           42 :     Real64 gtElecSurplusSold = ort->gatherElecSurplusSold;
    7648              : 
    7649           42 :     Real64 gtWaterHeatRecovery = ort->gatherWaterHeatRecovery;
    7650           42 :     Real64 gtAirHeatRecoveryCool = ort->gatherAirHeatRecoveryCool;
    7651           42 :     Real64 gtAirHeatRecoveryHeat = ort->gatherAirHeatRecoveryHeat;
    7652           42 :     Real64 gtHeatHTGeothermal = ort->gatherHeatHTGeothermal;
    7653           42 :     Real64 gtHeatSolarWater = ort->gatherHeatSolarWater;
    7654           42 :     Real64 gtHeatSolarAir = ort->gatherHeatSolarAir;
    7655              : 
    7656              :     // show the headers of the report
    7657           42 :     if (ort->displayTabularBEPS) {
    7658          126 :         WriteReportHeaders(state, "Annual Building Utility Performance Summary", "Entire Facility", OutputProcessor::StoreType::Average);
    7659              :         // show the number of hours that the table applies to
    7660           42 :         WriteTextLine(state, "Values gathered over " + RealToStr(ort->gatherElapsedTimeBEPS, 2) + " hours", true);
    7661           42 :         if (ort->gatherElapsedTimeBEPS < 8759.0) { // might not add up to 8760 exactly but can't be more than 1 hour diff.
    7662           84 :             WriteTextLine(state, "WARNING: THE REPORT DOES NOT REPRESENT A FULL ANNUAL SIMULATION.", true);
    7663              :         }
    7664           84 :         WriteTextLine(state, "", true);
    7665              :     }
    7666              : 
    7667           86 :     for (int iUnitSystem = 0; iUnitSystem <= 1; iUnitSystem++) {
    7668           84 :         UnitsStyle unitsStyle_cur = ort->unitsStyle;
    7669           84 :         bool produceTabular = true;
    7670           84 :         bool produceSQLite = false;
    7671           84 :         if (produceDualUnitsFlags(iUnitSystem, ort->unitsStyle, ort->unitsStyle_SQLite, unitsStyle_cur, produceTabular, produceSQLite)) break;
    7672              : 
    7673              :         // determine building floor areas
    7674           44 :         DetermineBuildingFloorArea(state);
    7675              :         // collapse the gatherEndUseBEPS array to the resource groups displayed
    7676          660 :         for (int jEndUse = 1; jEndUse <= static_cast<int>(Constant::EndUse::Num); ++jEndUse) {
    7677          616 :             collapsedEndUse(1, jEndUse) = ort->gatherEndUseBEPS(1, jEndUse);   // electricity
    7678          616 :             collapsedEndUse(2, jEndUse) = ort->gatherEndUseBEPS(2, jEndUse);   // natural gas
    7679          616 :             collapsedEndUse(3, jEndUse) = ort->gatherEndUseBEPS(6, jEndUse);   // gasoline
    7680          616 :             collapsedEndUse(4, jEndUse) = ort->gatherEndUseBEPS(8, jEndUse);   // diesel
    7681          616 :             collapsedEndUse(5, jEndUse) = ort->gatherEndUseBEPS(9, jEndUse);   // coal
    7682          616 :             collapsedEndUse(6, jEndUse) = ort->gatherEndUseBEPS(10, jEndUse);  // Fuel Oil No1
    7683          616 :             collapsedEndUse(7, jEndUse) = ort->gatherEndUseBEPS(11, jEndUse);  // Fuel Oil No2
    7684          616 :             collapsedEndUse(8, jEndUse) = ort->gatherEndUseBEPS(12, jEndUse);  // propane
    7685          616 :             collapsedEndUse(9, jEndUse) = ort->gatherEndUseBEPS(13, jEndUse);  // otherfuel1
    7686          616 :             collapsedEndUse(10, jEndUse) = ort->gatherEndUseBEPS(14, jEndUse); // otherfuel2
    7687          616 :             collapsedEndUse(11, jEndUse) = ort->gatherEndUseBEPS(3, jEndUse);  // district cooling <- purchased cooling
    7688          616 :             collapsedEndUse(12, jEndUse) = ort->gatherEndUseBEPS(4, jEndUse);  // district heating water <- purchased heating
    7689          616 :             collapsedEndUse(13, jEndUse) = ort->gatherEndUseBEPS(5, jEndUse);  // district heating steam  <- purchased heating
    7690          616 :             collapsedEndUse(14, jEndUse) = ort->gatherEndUseBEPS(7, jEndUse);  // water
    7691              :         }
    7692              :         // repeat with totals
    7693           44 :         collapsedTotal(1) = ort->gatherTotalsBEPS(1);   // electricity
    7694           44 :         collapsedTotal(2) = ort->gatherTotalsBEPS(2);   // natural gas
    7695           44 :         collapsedTotal(3) = ort->gatherTotalsBEPS(6);   // gasoline
    7696           44 :         collapsedTotal(4) = ort->gatherTotalsBEPS(8);   // diesel
    7697           44 :         collapsedTotal(5) = ort->gatherTotalsBEPS(9);   // coal
    7698           44 :         collapsedTotal(6) = ort->gatherTotalsBEPS(10);  // Fuel Oil No1
    7699           44 :         collapsedTotal(7) = ort->gatherTotalsBEPS(11);  // Fuel Oil No2
    7700           44 :         collapsedTotal(8) = ort->gatherTotalsBEPS(12);  // propane
    7701           44 :         collapsedTotal(9) = ort->gatherTotalsBEPS(13);  // other fuel 1
    7702           44 :         collapsedTotal(10) = ort->gatherTotalsBEPS(14); // other fuel 2
    7703           44 :         collapsedTotal(11) = ort->gatherTotalsBEPS(3);  // district cooling <- purchased cooling
    7704           44 :         collapsedTotal(12) = ort->gatherTotalsBEPS(4);  // district heating water <- purchased heating
    7705           44 :         collapsedTotal(13) = ort->gatherTotalsBEPS(5);  // district heating steam  <- purchased heating
    7706           44 :         collapsedTotal(14) = ort->gatherTotalsBEPS(7);  // water
    7707              : 
    7708           44 :         if (produceTabular) {
    7709           42 :             if (state.dataGlobal->createPerfLog) {
    7710            0 :                 Util::appendPerfLog(state, "Electricity ABUPS Total [J]", format("{:.3R}", collapsedTotal(1)));
    7711            0 :                 Util::appendPerfLog(state, "Natural Gas ABUPS Total [J]", format("{:.3R}", collapsedTotal(2)));
    7712            0 :                 Util::appendPerfLog(state, "Gasoline ABUPS Total [J]", format("{:.3R}", collapsedTotal(3)));
    7713            0 :                 Util::appendPerfLog(state, "Diesel ABUPS Total [J]", format("{:.3R}", collapsedTotal(4)));
    7714            0 :                 Util::appendPerfLog(state, "Coal ABUPS Total [J]", format("{:.3R}", collapsedTotal(5)));
    7715            0 :                 Util::appendPerfLog(state, "Fuel Oil No 1 ABUPS Total [J]", format("{:.3R}", collapsedTotal(6)));
    7716            0 :                 Util::appendPerfLog(state, "Fuel Oil No 2 ABUPS Total [J]", format("{:.3R}", collapsedTotal(7)));
    7717            0 :                 Util::appendPerfLog(state, "Propane ABUPS Total [J]", format("{:.3R}", collapsedTotal(8)));
    7718            0 :                 Util::appendPerfLog(state, "Other Fuel 1 ABUPS Total [J]", format("{:.3R}", collapsedTotal(9)));
    7719            0 :                 Util::appendPerfLog(state, "Other Fuel 2 ABUPS Total [J]", format("{:.3R}", collapsedTotal(10)));
    7720            0 :                 Util::appendPerfLog(state, "District Cooling ABUPS Total [J]", format("{:.3R}", collapsedTotal(11)));
    7721            0 :                 Util::appendPerfLog(state, "District Heating Water ABUPS Total [J]", format("{:.3R}", collapsedTotal(12)));
    7722            0 :                 Util::appendPerfLog(state, "District Heating Steam ABUPS Total [J]", format("{:.3R}", collapsedTotal(13)));
    7723            0 :                 Util::appendPerfLog(state, "Water ABUPS Total [m3]", format("{:.3R}", collapsedTotal(14)));
    7724            0 :                 Util::appendPerfLog(state, "Values Gathered Over [hours]", format("{:.2R}", ort->gatherElapsedTimeBEPS));
    7725            0 :                 Util::appendPerfLog(state,
    7726              :                                     "Facility Any Zone Oscillating Temperatures Time [hours]",
    7727            0 :                                     format("{:.2R}", state.dataZoneTempPredictorCorrector->AnnualAnyZoneTempOscillate));
    7728            0 :                 Util::appendPerfLog(state,
    7729              :                                     "Facility Any Zone Oscillating Temperatures During Occupancy Time [hours]",
    7730            0 :                                     format("{:.2R}", state.dataZoneTempPredictorCorrector->AnnualAnyZoneTempOscillateDuringOccupancy));
    7731            0 :                 Util::appendPerfLog(state,
    7732              :                                     "Facility Any Zone Oscillating Temperatures in Deadband Time [hours]",
    7733            0 :                                     format("{:.2R}", state.dataZoneTempPredictorCorrector->AnnualAnyZoneTempOscillateInDeadband));
    7734              :             }
    7735              :         }
    7736          660 :         for (int jEndUse = 1; jEndUse <= static_cast<int>(Constant::EndUse::Num); ++jEndUse) {
    7737          797 :             for (int kEndUseSub = 1; kEndUseSub <= op->EndUseCategory(jEndUse).NumSubcategories; ++kEndUseSub) {
    7738          181 :                 collapsedEndUseSub(kEndUseSub, jEndUse, 1) = ort->gatherEndUseSubBEPS(kEndUseSub, jEndUse, 1);   // electricity
    7739          181 :                 collapsedEndUseSub(kEndUseSub, jEndUse, 2) = ort->gatherEndUseSubBEPS(kEndUseSub, jEndUse, 2);   // natural gas
    7740          181 :                 collapsedEndUseSub(kEndUseSub, jEndUse, 3) = ort->gatherEndUseSubBEPS(kEndUseSub, jEndUse, 6);   // gasoline
    7741          181 :                 collapsedEndUseSub(kEndUseSub, jEndUse, 4) = ort->gatherEndUseSubBEPS(kEndUseSub, jEndUse, 8);   // diesel
    7742          181 :                 collapsedEndUseSub(kEndUseSub, jEndUse, 5) = ort->gatherEndUseSubBEPS(kEndUseSub, jEndUse, 9);   // coal
    7743          181 :                 collapsedEndUseSub(kEndUseSub, jEndUse, 6) = ort->gatherEndUseSubBEPS(kEndUseSub, jEndUse, 10);  // Fuel Oil No1
    7744          181 :                 collapsedEndUseSub(kEndUseSub, jEndUse, 7) = ort->gatherEndUseSubBEPS(kEndUseSub, jEndUse, 11);  // Fuel Oil No2
    7745          181 :                 collapsedEndUseSub(kEndUseSub, jEndUse, 8) = ort->gatherEndUseSubBEPS(kEndUseSub, jEndUse, 12);  // propane
    7746          181 :                 collapsedEndUseSub(kEndUseSub, jEndUse, 9) = ort->gatherEndUseSubBEPS(kEndUseSub, jEndUse, 13);  // otherfuel1
    7747          181 :                 collapsedEndUseSub(kEndUseSub, jEndUse, 10) = ort->gatherEndUseSubBEPS(kEndUseSub, jEndUse, 14); // otherfuel2
    7748          181 :                 collapsedEndUseSub(kEndUseSub, jEndUse, 11) = ort->gatherEndUseSubBEPS(kEndUseSub, jEndUse, 3);  // district cooling <- purch cooling
    7749          362 :                 collapsedEndUseSub(kEndUseSub, jEndUse, 12) =
    7750          181 :                     ort->gatherEndUseSubBEPS(kEndUseSub, jEndUse, 4); // district heating water <- purch heating
    7751          362 :                 collapsedEndUseSub(kEndUseSub, jEndUse, 13) =
    7752          181 :                     ort->gatherEndUseSubBEPS(kEndUseSub, jEndUse, 5); // district heating steam <- purch heating
    7753          181 :                 collapsedEndUseSub(kEndUseSub, jEndUse, 14) = ort->gatherEndUseSubBEPS(kEndUseSub, jEndUse, 7); // water
    7754              :             }
    7755              : 
    7756          640 :             for (int kEndUseSpType = 1; kEndUseSpType <= op->EndUseCategory(jEndUse).numSpaceTypes; ++kEndUseSpType) {
    7757           24 :                 collapsedEndUseSpType(kEndUseSpType, jEndUse, 1) = ort->gatherEndUseSpTypeBEPS(kEndUseSpType, jEndUse, 1);   // electricity
    7758           24 :                 collapsedEndUseSpType(kEndUseSpType, jEndUse, 2) = ort->gatherEndUseSpTypeBEPS(kEndUseSpType, jEndUse, 2);   // natural gas
    7759           24 :                 collapsedEndUseSpType(kEndUseSpType, jEndUse, 3) = ort->gatherEndUseSpTypeBEPS(kEndUseSpType, jEndUse, 6);   // gasoline
    7760           24 :                 collapsedEndUseSpType(kEndUseSpType, jEndUse, 4) = ort->gatherEndUseSpTypeBEPS(kEndUseSpType, jEndUse, 8);   // diesel
    7761           24 :                 collapsedEndUseSpType(kEndUseSpType, jEndUse, 5) = ort->gatherEndUseSpTypeBEPS(kEndUseSpType, jEndUse, 9);   // coal
    7762           24 :                 collapsedEndUseSpType(kEndUseSpType, jEndUse, 6) = ort->gatherEndUseSpTypeBEPS(kEndUseSpType, jEndUse, 10);  // Fuel Oil No1
    7763           24 :                 collapsedEndUseSpType(kEndUseSpType, jEndUse, 7) = ort->gatherEndUseSpTypeBEPS(kEndUseSpType, jEndUse, 11);  // Fuel Oil No2
    7764           24 :                 collapsedEndUseSpType(kEndUseSpType, jEndUse, 8) = ort->gatherEndUseSpTypeBEPS(kEndUseSpType, jEndUse, 12);  // propane
    7765           24 :                 collapsedEndUseSpType(kEndUseSpType, jEndUse, 9) = ort->gatherEndUseSpTypeBEPS(kEndUseSpType, jEndUse, 13);  // otherfuel1
    7766           24 :                 collapsedEndUseSpType(kEndUseSpType, jEndUse, 10) = ort->gatherEndUseSpTypeBEPS(kEndUseSpType, jEndUse, 14); // otherfuel2
    7767           48 :                 collapsedEndUseSpType(kEndUseSpType, jEndUse, 11) =
    7768           24 :                     ort->gatherEndUseSpTypeBEPS(kEndUseSpType, jEndUse, 3); // district cooling <- purch cooling
    7769           48 :                 collapsedEndUseSpType(kEndUseSpType, jEndUse, 12) =
    7770           24 :                     ort->gatherEndUseSpTypeBEPS(kEndUseSpType, jEndUse, 4); // district heating water <- purch heating
    7771           48 :                 collapsedEndUseSpType(kEndUseSpType, jEndUse, 13) =
    7772           24 :                     ort->gatherEndUseSpTypeBEPS(kEndUseSpType, jEndUse, 5); // district heating steam <- purch heating
    7773           24 :                 collapsedEndUseSpType(kEndUseSpType, jEndUse, 14) = ort->gatherEndUseSpTypeBEPS(kEndUseSpType, jEndUse, 7); // water
    7774              :             }
    7775              :         }
    7776              :         // unit conversion - all values are used as divisors
    7777              :         Real64 largeConversionFactor;
    7778              :         Real64 kConversionFactor;
    7779              :         Real64 waterConversionFactor;
    7780              :         Real64 areaConversionFactor;
    7781           44 :         Real64 ipElectricityConversionFactor = 1.0;
    7782           44 :         switch (unitsStyle_cur) {
    7783            4 :         case UnitsStyle::JtoKWH: {
    7784            4 :             largeConversionFactor = 3600000.0;
    7785            4 :             kConversionFactor = 1.0;
    7786            4 :             waterConversionFactor = 1.0;
    7787            4 :             areaConversionFactor = 1.0;
    7788            4 :         } break;
    7789            2 :         case UnitsStyle::InchPound: {
    7790            6 :             largeConversionFactor = getSpecificUnitDivider(state, "J", "kBtu"); // 1054351.84 J to kBtu
    7791            2 :             kConversionFactor = 1.0;
    7792            8 :             waterConversionFactor = getSpecificUnitDivider(state, "m3", "gal"); // 0.003785413 m3 to gal
    7793            6 :             areaConversionFactor = getSpecificUnitDivider(state, "m2", "ft2");  // 0.092893973 m2 to ft2
    7794            2 :         } break;
    7795            1 :         case UnitsStyle::InchPoundExceptElectricity: {
    7796            3 :             largeConversionFactor = getSpecificUnitDivider(state, "J", "kBtu"); // 1054351.84 J to kBtu
    7797            1 :             kConversionFactor = 1.0;
    7798            4 :             waterConversionFactor = getSpecificUnitDivider(state, "m3", "gal"); // 0.003785413 m3 to gal
    7799            3 :             areaConversionFactor = getSpecificUnitDivider(state, "m2", "ft2");  // 0.092893973 m2 to ft2
    7800            1 :             ipElectricityConversionFactor = largeConversionFactor / (1000.0 * 3600.0);
    7801            1 :         } break;
    7802           37 :         default: {
    7803           37 :             largeConversionFactor = 1000000000.0;
    7804           37 :             kConversionFactor = 1000.0;
    7805           37 :             waterConversionFactor = 1.0;
    7806           37 :             areaConversionFactor = 1.0;
    7807           37 :         } break;
    7808              :         }
    7809              : 
    7810              :         // convert units into GJ (divide by 1,000,000,000) if J otherwise kWh
    7811          616 :         for (int iResource = 1; iResource <= 13; ++iResource) { // don't do water
    7812          572 :             Real64 ipElectricityAdjust = (iResource == 1) ? ipElectricityConversionFactor : 1.0;
    7813         8580 :             for (int jEndUse = 1; jEndUse <= static_cast<int>(Constant::EndUse::Num); ++jEndUse) {
    7814         8008 :                 collapsedEndUse(iResource, jEndUse) /= (largeConversionFactor / ipElectricityAdjust);
    7815        10361 :                 for (int kEndUseSub = 1; kEndUseSub <= op->EndUseCategory(jEndUse).NumSubcategories; ++kEndUseSub) {
    7816         2353 :                     collapsedEndUseSub(kEndUseSub, jEndUse, iResource) /= (largeConversionFactor / ipElectricityAdjust);
    7817              :                 }
    7818         8320 :                 for (int kEndUseSpType = 1; kEndUseSpType <= op->EndUseCategory(jEndUse).numSpaceTypes; ++kEndUseSpType) {
    7819          312 :                     collapsedEndUseSpType(kEndUseSpType, jEndUse, iResource) /= (largeConversionFactor / ipElectricityAdjust);
    7820              :                 }
    7821              :             }
    7822          572 :             collapsedTotal(iResource) /= (largeConversionFactor / ipElectricityAdjust);
    7823              :         }
    7824              :         // do water
    7825          660 :         for (int jEndUse = 1; jEndUse <= static_cast<int>(Constant::EndUse::Num); ++jEndUse) {
    7826          616 :             collapsedEndUse(14, jEndUse) /= waterConversionFactor;
    7827          797 :             for (int kEndUseSub = 1; kEndUseSub <= state.dataOutputProcessor->EndUseCategory(jEndUse).NumSubcategories; ++kEndUseSub) {
    7828          181 :                 collapsedEndUseSub(kEndUseSub, jEndUse, 14) /= waterConversionFactor;
    7829              :             }
    7830          640 :             for (int kEndUseSpType = 1; kEndUseSpType <= state.dataOutputProcessor->EndUseCategory(jEndUse).numSpaceTypes; ++kEndUseSpType) {
    7831           24 :                 collapsedEndUseSpType(kEndUseSpType, jEndUse, 14) /= waterConversionFactor;
    7832              :             }
    7833              :         }
    7834              : 
    7835           44 :         collapsedTotal(14) = WaterConversionFunct(collapsedTotal(14), waterConversionFactor);
    7836              : 
    7837           44 :         if (iUnitSystem == 0) {
    7838           42 :             gtPowerFuelFireGen = ort->gatherPowerFuelFireGen;
    7839           42 :             gtPowerPV = ort->gatherPowerPV;
    7840           42 :             gtPowerWind = ort->gatherPowerWind;
    7841           42 :             gtPowerHTGeothermal = ort->gatherPowerHTGeothermal;
    7842           42 :             gtPowerConversion = ort->gatherPowerConversion;
    7843           42 :             gtElecProduced = ort->gatherElecProduced;
    7844           42 :             gtElecPUrchased = ort->gatherElecPurchased;
    7845           42 :             gtElecSurplusSold = ort->gatherElecSurplusSold;
    7846              :         } else { // if(iUnitSystem == 1)
    7847            2 :             ort->gatherPowerFuelFireGen = gtPowerFuelFireGen;
    7848            2 :             ort->gatherPowerPV = gtPowerPV;
    7849            2 :             ort->gatherPowerWind = gtPowerWind;
    7850            2 :             ort->gatherPowerHTGeothermal = gtPowerHTGeothermal;
    7851            2 :             ort->gatherPowerConversion = gtPowerConversion;
    7852            2 :             ort->gatherElecProduced = gtElecProduced;
    7853            2 :             ort->gatherElecPurchased = gtElecPUrchased;
    7854            2 :             ort->gatherElecSurplusSold = gtElecSurplusSold;
    7855              :         }
    7856              :         // convert to GJ
    7857           44 :         Real64 convFactorMulti = ipElectricityConversionFactor / largeConversionFactor;
    7858           44 :         ort->gatherPowerFuelFireGen *= convFactorMulti;
    7859           44 :         ort->gatherPowerPV *= convFactorMulti;
    7860           44 :         ort->gatherPowerWind *= convFactorMulti;
    7861           44 :         ort->gatherPowerHTGeothermal *= convFactorMulti;
    7862           44 :         ort->gatherPowerConversion *= convFactorMulti;
    7863           44 :         ort->gatherElecProduced *= convFactorMulti;
    7864           44 :         ort->gatherElecPurchased *= convFactorMulti;
    7865           44 :         ort->gatherElecSurplusSold *= convFactorMulti;
    7866              : 
    7867              :         // get change in overall state of charge for electrical storage devices.
    7868           44 :         if (state.dataElectPwrSvcMgr->facilityElectricServiceObj->numElecStorageDevices > 0) {
    7869              :             // All flow in/out of storage is accounted for in gatherElecStorage, so separate calculation of change in state of charge is not
    7870              :             // necessary OverallNetEnergyFromStorage = ( sum( ElecStorage.StartingEnergyStored() ) - sum(
    7871              :             // ElecStorage.ThisTimeStepStateOfCharge() ) ) + gatherElecStorage;
    7872            0 :             ort->OverallNetEnergyFromStorage = ort->gatherElecStorage;
    7873            0 :             ort->OverallNetEnergyFromStorage *= convFactorMulti;
    7874              :         } else {
    7875           44 :             ort->OverallNetEnergyFromStorage = 0.0;
    7876              :         }
    7877              :         // determine which resource is the primary heating resource
    7878           44 :         int resourcePrimaryHeating = 0;
    7879           44 :         Real64 heatingMaximum = 0.0;
    7880          616 :         for (int iResource = 1; iResource <= 13; ++iResource) { // don't do water
    7881          572 :             if (collapsedEndUse(iResource, static_cast<int>(Constant::EndUse::Heating) + 1) > heatingMaximum) {
    7882           10 :                 heatingMaximum = collapsedEndUse(iResource, static_cast<int>(Constant::EndUse::Heating) + 1); // +1 because enum is 0-based
    7883           10 :                 resourcePrimaryHeating = iResource;
    7884              :             }
    7885              :         }
    7886              : 
    7887              :         //---- Source and Site Energy Sub-Table
    7888           44 :         rowHead.allocate(4);
    7889           44 :         columnHead.allocate(3);
    7890           44 :         columnWidth.allocate(3);
    7891           44 :         columnWidth = 14; // array assignment - same for all columns
    7892           44 :         tableBody.allocate(3, 4);
    7893              : 
    7894           44 :         switch (unitsStyle_cur) {
    7895            4 :         case UnitsStyle::JtoKWH: {
    7896            4 :             columnHead(1) = "Total Energy [kWh]";
    7897            4 :             columnHead(2) = "Energy Per Total Building Area [kWh/m2]";
    7898            4 :             columnHead(3) = "Energy Per Conditioned Building Area [kWh/m2]";
    7899            4 :         } break;
    7900            2 :         case UnitsStyle::InchPound: {
    7901            2 :             columnHead(1) = "Total Energy [kBtu]";
    7902            2 :             columnHead(2) = "Energy Per Total Building Area [kBtu/ft2]";
    7903            2 :             columnHead(3) = "Energy Per Conditioned Building Area [kBtu/ft2]";
    7904            2 :         } break;
    7905            1 :         case UnitsStyle::InchPoundExceptElectricity: {
    7906            1 :             columnHead(1) = "Total Energy [kBtu]";
    7907            1 :             columnHead(2) = "Energy Per Total Building Area [kBtu/ft2]";
    7908            1 :             columnHead(3) = "Energy Per Conditioned Building Area [kBtu/ft2]";
    7909            1 :         } break;
    7910           37 :         default: {
    7911           37 :             columnHead(1) = "Total Energy [GJ]";
    7912           37 :             columnHead(2) = "Energy Per Total Building Area [MJ/m2]";
    7913           37 :             columnHead(3) = "Energy Per Conditioned Building Area [MJ/m2]";
    7914           37 :         } break;
    7915              :         }
    7916              : 
    7917           44 :         rowHead(1) = "Total Site Energy";
    7918           44 :         rowHead(2) = "Net Site Energy";
    7919           44 :         rowHead(3) = "Total Source Energy";
    7920           44 :         rowHead(4) = "Net Source Energy";
    7921              : 
    7922           44 :         tableBody = "";
    7923              : 
    7924              :         // compute the net amount of electricity received from the utility which
    7925              :         // is the amount purchased less the amount sold to the utility. Note that
    7926              :         // previously these variables were converted into GJ so now we don't need
    7927              :         // to do any conversion
    7928              :         // water is not included   gatherTotalsBEPS(7)    !water
    7929              :         Real64 const totalSiteEnergyUse =
    7930           44 :             (ort->gatherTotalsBEPS(1) + ort->gatherTotalsBEPS(2) + ort->gatherTotalsBEPS(3) + ort->gatherTotalsBEPS(4) + ort->gatherTotalsBEPS(5) +
    7931           44 :              ort->gatherTotalsBEPS(6) + ort->gatherTotalsBEPS(8) + ort->gatherTotalsBEPS(9) + ort->gatherTotalsBEPS(10) + ort->gatherTotalsBEPS(11) +
    7932           44 :              ort->gatherTotalsBEPS(12) + ort->gatherTotalsBEPS(13) + ort->gatherTotalsBEPS(14)) /
    7933           44 :             largeConversionFactor; // electricity | natural gas | district cooling | district heating water | district heating steam | gasoline |
    7934              :                                    // diesel | coal | Fuel Oil No1 | Fuel Oil No2 | propane | otherfuel1 | otherfuel2
    7935              : 
    7936           44 :         Real64 const netElecPurchasedSold = ort->gatherElecPurchased - ort->gatherElecSurplusSold;
    7937              : 
    7938              :         // water is not included   gatherTotalsBEPS(7)    !water
    7939              :         Real64 const netSiteEnergyUse =
    7940           44 :             netElecPurchasedSold + (ort->gatherTotalsBEPS(2) + ort->gatherTotalsBEPS(3) + ort->gatherTotalsBEPS(4) + ort->gatherTotalsBEPS(5) +
    7941           44 :                                     ort->gatherTotalsBEPS(6) + ort->gatherTotalsBEPS(8) + ort->gatherTotalsBEPS(9) + ort->gatherTotalsBEPS(10) +
    7942           44 :                                     ort->gatherTotalsBEPS(11) + ort->gatherTotalsBEPS(12) + ort->gatherTotalsBEPS(13) + ort->gatherTotalsBEPS(14)) /
    7943           44 :                                        largeConversionFactor; // electricity (already in GJ) | natural gas | district cooling |
    7944              :                                                               // district heating water | district heating steam | gasoline | diesel | coal | Fuel Oil
    7945              :                                                               // No1 | Fuel Oil No2 | propane | otherfuel1 | otherfuel2
    7946              : 
    7947           44 :         if (ort->efficiencyDistrictCooling == 0) ort->efficiencyDistrictCooling = 1.0;
    7948           44 :         if (ort->efficiencyDistrictHeatingWater == 0) ort->efficiencyDistrictHeatingWater = 1.0;
    7949              : 
    7950              :         // source emissions already have the source factors included in the calcs.
    7951           44 :         Real64 totalSourceEnergyUse = 0.0;
    7952              :         //  electricity
    7953           44 :         if (ort->fuelfactorsused(1)) {
    7954            0 :             totalSourceEnergyUse += ort->gatherTotalsSource(1);
    7955              :         } else {
    7956           44 :             totalSourceEnergyUse += ort->gatherTotalsBEPS(1) * ort->sourceFactorElectric;
    7957              :         }
    7958              :         //  natural gas
    7959           44 :         if (ort->fuelfactorsused(2)) {
    7960            0 :             totalSourceEnergyUse += ort->gatherTotalsSource(2);
    7961              :         } else {
    7962           44 :             totalSourceEnergyUse += ort->gatherTotalsBEPS(2) * ort->sourceFactorNaturalGas;
    7963              :         }
    7964              :         // gasoline
    7965           44 :         if (ort->fuelfactorsused(3)) {
    7966            0 :             totalSourceEnergyUse += ort->gatherTotalsSource(3);
    7967              :         } else {
    7968           44 :             totalSourceEnergyUse += ort->gatherTotalsBEPS(6) * ort->sourceFactorGasoline;
    7969              :         }
    7970              :         // diesel
    7971           44 :         if (ort->fuelfactorsused(4)) {
    7972            0 :             totalSourceEnergyUse += ort->gatherTotalsSource(4);
    7973              :         } else {
    7974           44 :             totalSourceEnergyUse += ort->gatherTotalsBEPS(8) * ort->sourceFactorDiesel;
    7975              :         }
    7976              :         // coal
    7977           44 :         if (ort->fuelfactorsused(5)) {
    7978            0 :             totalSourceEnergyUse += ort->gatherTotalsSource(5);
    7979              :         } else {
    7980           44 :             totalSourceEnergyUse += ort->gatherTotalsBEPS(9) * ort->sourceFactorCoal;
    7981              :         }
    7982              :         // Fuel Oil No1
    7983           44 :         if (ort->fuelfactorsused(6)) {
    7984            0 :             totalSourceEnergyUse += ort->gatherTotalsSource(6);
    7985              :         } else {
    7986           44 :             totalSourceEnergyUse += ort->gatherTotalsBEPS(10) * ort->sourceFactorFuelOil1;
    7987              :         }
    7988              :         // Fuel Oil No2
    7989           44 :         if (ort->fuelfactorsused(7)) {
    7990            0 :             totalSourceEnergyUse += ort->gatherTotalsSource(7);
    7991              :         } else {
    7992           44 :             totalSourceEnergyUse += ort->gatherTotalsBEPS(11) * ort->sourceFactorFuelOil2;
    7993              :         }
    7994              :         // propane
    7995           44 :         if (ort->fuelfactorsused(8)) {
    7996            0 :             totalSourceEnergyUse += ort->gatherTotalsSource(8);
    7997              :         } else {
    7998           44 :             totalSourceEnergyUse += ort->gatherTotalsBEPS(12) * ort->sourceFactorPropane;
    7999              :         }
    8000              :         // otherfuel1
    8001           44 :         if (ort->fuelfactorsused(11)) {
    8002            0 :             totalSourceEnergyUse += ort->gatherTotalsSource(11);
    8003              :         } else {
    8004           44 :             totalSourceEnergyUse += ort->gatherTotalsBEPS(13) * ort->sourceFactorOtherFuel1;
    8005              :         }
    8006              :         // otherfuel2
    8007           44 :         if (ort->fuelfactorsused(12)) {
    8008            0 :             totalSourceEnergyUse += ort->gatherTotalsSource(12);
    8009              :         } else {
    8010           44 :             totalSourceEnergyUse += ort->gatherTotalsBEPS(14) * ort->sourceFactorOtherFuel2;
    8011              :         }
    8012              : 
    8013           44 :         totalSourceEnergyUse = (totalSourceEnergyUse + ort->gatherTotalsBEPS(3) * ort->sourceFactorElectric / ort->efficiencyDistrictCooling +
    8014           44 :                                 ort->gatherTotalsBEPS(4) * ort->sourceFactorNaturalGas / ort->efficiencyDistrictHeatingWater +
    8015           44 :                                 ort->gatherTotalsBEPS(5) * ort->sourceFactorDistrictHeatingSteam) /
    8016              :                                largeConversionFactor; // district cooling | district heating water | district heating steam
    8017              : 
    8018              :         // now determine "net" source from purchased and surplus sold (still in J)
    8019              : 
    8020              :         Real64 netSourceElecPurchasedSold;
    8021           44 :         if (ort->fuelfactorsused(1)) {
    8022            0 :             netSourceElecPurchasedSold = ort->gatherTotalsSource(9) - ort->gatherTotalsSource(10);
    8023              :         } else {
    8024           44 :             netSourceElecPurchasedSold = netElecPurchasedSold * ort->sourceFactorElectric * largeConversionFactor; // back to J
    8025              :         }
    8026              : 
    8027           44 :         Real64 netSourceEnergyUse = 0.0;
    8028              :         //  natural gas
    8029           44 :         if (ort->fuelfactorsused(2)) {
    8030            0 :             netSourceEnergyUse += ort->gatherTotalsSource(2);
    8031              :         } else {
    8032           44 :             netSourceEnergyUse += ort->gatherTotalsBEPS(2) * ort->sourceFactorNaturalGas;
    8033              :         }
    8034              :         // gasoline
    8035           44 :         if (ort->fuelfactorsused(3)) {
    8036            0 :             netSourceEnergyUse += ort->gatherTotalsSource(3);
    8037              :         } else {
    8038           44 :             netSourceEnergyUse += ort->gatherTotalsBEPS(6) * ort->sourceFactorGasoline;
    8039              :         }
    8040              :         // diesel
    8041           44 :         if (ort->fuelfactorsused(4)) {
    8042            0 :             netSourceEnergyUse += ort->gatherTotalsSource(4);
    8043              :         } else {
    8044           44 :             netSourceEnergyUse += ort->gatherTotalsBEPS(8) * ort->sourceFactorDiesel;
    8045              :         }
    8046              :         // coal
    8047           44 :         if (ort->fuelfactorsused(5)) {
    8048            0 :             netSourceEnergyUse += ort->gatherTotalsSource(5);
    8049              :         } else {
    8050           44 :             netSourceEnergyUse += ort->gatherTotalsBEPS(9) * ort->sourceFactorCoal;
    8051              :         }
    8052              :         // Fuel Oil No1
    8053           44 :         if (ort->fuelfactorsused(6)) {
    8054            0 :             netSourceEnergyUse += ort->gatherTotalsSource(6);
    8055              :         } else {
    8056           44 :             netSourceEnergyUse += ort->gatherTotalsBEPS(10) * ort->sourceFactorFuelOil1;
    8057              :         }
    8058              :         // Fuel Oil No2
    8059           44 :         if (ort->fuelfactorsused(7)) {
    8060            0 :             netSourceEnergyUse += ort->gatherTotalsSource(7);
    8061              :         } else {
    8062           44 :             netSourceEnergyUse += ort->gatherTotalsBEPS(11) * ort->sourceFactorFuelOil2;
    8063              :         }
    8064              :         // propane
    8065           44 :         if (ort->fuelfactorsused(8)) {
    8066            0 :             netSourceEnergyUse += ort->gatherTotalsSource(8);
    8067              :         } else {
    8068           44 :             netSourceEnergyUse += ort->gatherTotalsBEPS(12) * ort->sourceFactorPropane;
    8069              :         }
    8070              :         // otherfuel1
    8071           44 :         if (ort->fuelfactorsused(11)) {
    8072            0 :             netSourceEnergyUse += ort->gatherTotalsSource(11);
    8073              :         } else {
    8074           44 :             netSourceEnergyUse += ort->gatherTotalsBEPS(13) * ort->sourceFactorOtherFuel1;
    8075              :         }
    8076              :         // otherfuel2
    8077           44 :         if (ort->fuelfactorsused(12)) {
    8078            0 :             netSourceEnergyUse += ort->gatherTotalsSource(12);
    8079              :         } else {
    8080           44 :             netSourceEnergyUse += ort->gatherTotalsBEPS(14) * ort->sourceFactorOtherFuel2;
    8081              :         }
    8082              : 
    8083           44 :         netSourceEnergyUse =
    8084           44 :             (netSourceEnergyUse + netSourceElecPurchasedSold + ort->gatherTotalsBEPS(3) * ort->sourceFactorElectric / ort->efficiencyDistrictCooling +
    8085           44 :              ort->gatherTotalsBEPS(4) * ort->sourceFactorNaturalGas / ort->efficiencyDistrictHeatingWater +
    8086           44 :              ort->gatherTotalsBEPS(5) * ort->sourceFactorDistrictHeatingSteam) /
    8087              :             largeConversionFactor; // from other fuels | net source from electricity | district cooling | district heating water | district heating
    8088              :                                    // steam
    8089              : 
    8090              :         // show annual values
    8091           44 :         tableBody(1, 1) = RealToStr(totalSiteEnergyUse, 2);
    8092           44 :         tableBody(1, 2) = RealToStr(netSiteEnergyUse, 2);
    8093           44 :         tableBody(1, 3) = RealToStr(totalSourceEnergyUse, 2);
    8094           44 :         tableBody(1, 4) = RealToStr(netSourceEnergyUse, 2);
    8095              : 
    8096              :         // convert floor areas
    8097           44 :         Real64 const convBldgGrossFloorArea = ort->buildingGrossFloorArea / areaConversionFactor;
    8098           44 :         Real64 const convBldgCondFloorArea = ort->buildingConditionedFloorArea / areaConversionFactor;
    8099              : 
    8100              :         // show  per building area
    8101           44 :         if (convBldgGrossFloorArea > 0) {
    8102           38 :             tableBody(2, 1) = RealToStr(totalSiteEnergyUse * kConversionFactor / convBldgGrossFloorArea, 2);
    8103           38 :             tableBody(2, 2) = RealToStr(netSiteEnergyUse * kConversionFactor / convBldgGrossFloorArea, 2);
    8104           38 :             tableBody(2, 3) = RealToStr(totalSourceEnergyUse * kConversionFactor / convBldgGrossFloorArea, 2);
    8105           38 :             tableBody(2, 4) = RealToStr(netSourceEnergyUse * kConversionFactor / convBldgGrossFloorArea, 2);
    8106              :         }
    8107              :         // show  per conditioned building area
    8108           44 :         if (convBldgCondFloorArea > 0) {
    8109           14 :             tableBody(3, 1) = RealToStr(totalSiteEnergyUse * kConversionFactor / convBldgCondFloorArea, 2);
    8110           14 :             tableBody(3, 2) = RealToStr(netSiteEnergyUse * kConversionFactor / convBldgCondFloorArea, 2);
    8111           14 :             tableBody(3, 3) = RealToStr(totalSourceEnergyUse * kConversionFactor / convBldgCondFloorArea, 2);
    8112           14 :             tableBody(3, 4) = RealToStr(netSourceEnergyUse * kConversionFactor / convBldgCondFloorArea, 2);
    8113              :         }
    8114              : 
    8115              :         // heading for the entire sub-table
    8116           44 :         if (ort->displayTabularBEPS) {
    8117           44 :             if (produceTabular) {
    8118           42 :                 WriteSubtitle(state, "Site and Source Energy");
    8119           42 :                 WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
    8120              :             }
    8121           44 :             if (produceSQLite) {
    8122           42 :                 if (state.dataSQLiteProcedures->sqlite) {
    8123            7 :                     state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
    8124              :                         tableBody, rowHead, columnHead, "AnnualBuildingUtilityPerformanceSummary", "Entire Facility", "Site and Source Energy");
    8125              :                 }
    8126              :             }
    8127           44 :             if (produceTabular) {
    8128           42 :                 if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
    8129            0 :                     state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(
    8130              :                         tableBody, rowHead, columnHead, "AnnualBuildingUtilityPerformanceSummary", "Entire Facility", "Site and Source Energy");
    8131              :                 }
    8132              :             }
    8133              :         }
    8134              : 
    8135              :         //---- Source and Site Energy Sub-Table
    8136           44 :         rowHead.allocate(13);
    8137           44 :         columnHead.allocate(1);
    8138           44 :         columnWidth.allocate(1);
    8139           44 :         columnWidth = 50; // array assignment
    8140           44 :         tableBody.allocate(1, 13);
    8141              : 
    8142           44 :         columnHead(1) = "Site=>Source Conversion Factor";
    8143              : 
    8144           44 :         rowHead(1) = "Electricity";
    8145           44 :         rowHead(2) = "Natural Gas";
    8146           44 :         rowHead(3) = "District Cooling";
    8147           44 :         rowHead(4) = "District Heating Water";
    8148           44 :         rowHead(5) = "District Heating Steam";
    8149           44 :         rowHead(6) = "Gasoline";
    8150           44 :         rowHead(7) = "Diesel";
    8151           44 :         rowHead(8) = "Coal";
    8152           44 :         rowHead(9) = "Fuel Oil No 1";
    8153           44 :         rowHead(10) = "Fuel Oil No 2";
    8154           44 :         rowHead(11) = "Propane";
    8155           44 :         rowHead(12) = "Other Fuel 1";
    8156           44 :         rowHead(13) = "Other Fuel 2";
    8157              : 
    8158           44 :         tableBody = "";
    8159              : 
    8160              :         // set columns to conversion factors
    8161              :         // show values
    8162              :         //  tableBody(1,1)  = TRIM(RealToStr(sourceFactorElectric,3))
    8163              :         //  tableBody(2,1)  = TRIM(RealToStr(sourceFactorNaturalGas, 3))
    8164              :         //  tableBody(3,1)  = TRIM(RealToStr(sourceFactorElectric/ efficiencyDistrictCooling,3))
    8165              :         //  tableBody(4,1)  = TRIM(RealToStr(sourceFactorNaturalGas/ efficiencyDistrictHeating ,3))
    8166              :         //  tableBody(5,1)  = TRIM(RealToStr(sourceFactorSteam ,3))
    8167              :         //  tableBody(6,1)  = TRIM(RealToStr(sourceFactorGasoline ,3))
    8168              :         //  tableBody(7,1)  = TRIM(RealToStr(sourceFactorDiesel ,3))
    8169              :         //  tableBody(8,1)  = TRIM(RealToStr(sourceFactorCoal ,3))
    8170              :         //  tableBody(9,1)  = TRIM(RealToStr(sourceFactorFuelOil1 ,3))
    8171              :         //  tableBody(10,1) = TRIM(RealToStr(sourceFactorFuelOil2 ,3))
    8172              :         //  tableBody(11,1) = TRIM(RealToStr(sourceFactorPropane ,3))
    8173              : 
    8174           44 :         if (!ort->ffSchedUsed(1)) {
    8175           44 :             tableBody(1, 1) = RealToStr(ort->sourceFactorElectric, 3);
    8176            0 :         } else if (ort->gatherTotalsBEPS(1) > SmallValue) {
    8177            0 :             tableBody(1, 1) = "Effective Factor = " + RealToStr(ort->gatherTotalsBySourceBEPS(1) / ort->gatherTotalsBEPS(1), 3) +
    8178            0 :                               " (calculated using schedule \"" + ort->ffScheds(1)->Name + "\")";
    8179              :         } else {
    8180            0 :             tableBody(1, 1) = "N/A";
    8181              :         }
    8182              : 
    8183           44 :         if (!ort->ffSchedUsed(2)) {
    8184           44 :             tableBody(1, 2) = RealToStr(ort->sourceFactorNaturalGas, 3);
    8185            0 :         } else if (ort->gatherTotalsBEPS(2) > SmallValue) {
    8186            0 :             tableBody(1, 2) = "Effective Factor = " + RealToStr(ort->gatherTotalsBySourceBEPS(2) / ort->gatherTotalsBEPS(2), 3) +
    8187            0 :                               " (calculated using schedule \"" + ort->ffScheds(2)->Name + "\")";
    8188              :         } else {
    8189            0 :             tableBody(1, 2) = "N/A";
    8190              :         }
    8191              : 
    8192           44 :         tableBody(1, 3) = RealToStr(ort->sourceFactorElectric / ort->efficiencyDistrictCooling, 3); // District Cooling
    8193              : 
    8194           44 :         tableBody(1, 4) = RealToStr(ort->sourceFactorNaturalGas / ort->efficiencyDistrictHeatingWater, 3); // District Heating Water
    8195              : 
    8196           44 :         tableBody(1, 5) = RealToStr(ort->sourceFactorDistrictHeatingSteam, 3); // District Heating Steam
    8197              : 
    8198           44 :         if (!ort->ffSchedUsed(6)) {
    8199           44 :             tableBody(1, 6) = RealToStr(ort->sourceFactorGasoline, 3);
    8200            0 :         } else if (ort->gatherTotalsBEPS(6) > SmallValue) {
    8201            0 :             tableBody(1, 6) = "Effective Factor = " + RealToStr(ort->gatherTotalsBySourceBEPS(6) / ort->gatherTotalsBEPS(6), 3) +
    8202            0 :                               " (calculated using schedule \"" + ort->ffScheds(6)->Name + "\")";
    8203              :         } else {
    8204            0 :             tableBody(1, 6) = "N/A";
    8205              :         }
    8206              : 
    8207           44 :         if (!ort->ffSchedUsed(8)) {
    8208           44 :             tableBody(1, 7) = RealToStr(ort->sourceFactorDiesel, 3);
    8209            0 :         } else if (ort->gatherTotalsBEPS(8) > SmallValue) {
    8210            0 :             tableBody(1, 7) = "Effective Factor = " + RealToStr(ort->gatherTotalsBySourceBEPS(8) / ort->gatherTotalsBEPS(8), 3) +
    8211            0 :                               " (calculated using schedule \"" + ort->ffScheds(8)->Name + "\")";
    8212              :         } else {
    8213            0 :             tableBody(1, 7) = "N/A";
    8214              :         }
    8215              : 
    8216           44 :         if (!ort->ffSchedUsed(9)) {
    8217           44 :             tableBody(1, 8) = RealToStr(ort->sourceFactorCoal, 3);
    8218            0 :         } else if (ort->gatherTotalsBEPS(9) > SmallValue) {
    8219            0 :             tableBody(1, 8) = "Effective Factor = " + RealToStr(ort->gatherTotalsBySourceBEPS(9) / ort->gatherTotalsBEPS(9), 3) +
    8220            0 :                               " (calculated using schedule \"" + ort->ffScheds(9)->Name + "\")";
    8221              :         } else {
    8222            0 :             tableBody(1, 8) = "N/A";
    8223              :         }
    8224              : 
    8225           44 :         if (!ort->ffSchedUsed(10)) {
    8226           44 :             tableBody(1, 9) = RealToStr(ort->sourceFactorFuelOil1, 3);
    8227            0 :         } else if (ort->gatherTotalsBEPS(10) > SmallValue) {
    8228            0 :             tableBody(1, 9) = "Effective Factor = " + RealToStr(ort->gatherTotalsBySourceBEPS(10) / ort->gatherTotalsBEPS(10), 3) +
    8229            0 :                               " (calculated using schedule \"" + ort->ffScheds(10)->Name + "\")";
    8230              :         } else {
    8231            0 :             tableBody(1, 9) = "N/A";
    8232              :         }
    8233              : 
    8234           44 :         if (!ort->ffSchedUsed(11)) {
    8235           44 :             tableBody(1, 10) = RealToStr(ort->sourceFactorFuelOil2, 3);
    8236            0 :         } else if (ort->gatherTotalsBEPS(11) > SmallValue) {
    8237            0 :             tableBody(1, 10) = "Effective Factor = " + RealToStr(ort->gatherTotalsBySourceBEPS(11) / ort->gatherTotalsBEPS(11), 3) +
    8238            0 :                                " (calculated using schedule \"" + ort->ffScheds(11)->Name + "\")";
    8239              :         } else {
    8240            0 :             tableBody(1, 10) = "N/A";
    8241              :         }
    8242              : 
    8243           44 :         if (!ort->ffSchedUsed(12)) {
    8244           44 :             tableBody(1, 11) = RealToStr(ort->sourceFactorPropane, 3);
    8245            0 :         } else if (ort->gatherTotalsBEPS(12) > SmallValue) {
    8246            0 :             tableBody(1, 11) = "Effective Factor = " + RealToStr(ort->gatherTotalsBySourceBEPS(12) / ort->gatherTotalsBEPS(12), 3) +
    8247            0 :                                " (calculated using schedule \"" + ort->ffScheds(12)->Name + "\")";
    8248              :         } else {
    8249            0 :             tableBody(1, 11) = "N/A";
    8250              :         }
    8251              : 
    8252           44 :         if (!ort->ffSchedUsed(13)) {
    8253           44 :             tableBody(1, 12) = RealToStr(ort->sourceFactorOtherFuel1, 3);
    8254            0 :         } else if (ort->gatherTotalsBEPS(13) > SmallValue) {
    8255            0 :             tableBody(1, 12) = "Effective Factor = " + RealToStr(ort->gatherTotalsBySourceBEPS(13) / ort->gatherTotalsBEPS(13), 3) +
    8256            0 :                                " (calculated using schedule \"" + ort->ffScheds(13)->Name + "\")";
    8257              :         } else {
    8258            0 :             tableBody(1, 12) = "N/A";
    8259              :         }
    8260              : 
    8261           44 :         if (!ort->ffSchedUsed(14)) {
    8262           44 :             tableBody(1, 13) = RealToStr(ort->sourceFactorOtherFuel2, 3);
    8263            0 :         } else if (ort->gatherTotalsBEPS(14) > SmallValue) {
    8264            0 :             tableBody(1, 13) = "Effective Factor = " + RealToStr(ort->gatherTotalsBySourceBEPS(14) / ort->gatherTotalsBEPS(14), 3) +
    8265            0 :                                " (calculated using schedule \"" + ort->ffScheds(14)->Name + "\")";
    8266              :         } else {
    8267            0 :             tableBody(1, 13) = "N/A";
    8268              :         }
    8269              : 
    8270              :         // heading for the entire sub-table
    8271           44 :         if (ort->displayTabularBEPS) {
    8272           44 :             if (produceTabular) {
    8273           42 :                 WriteSubtitle(state, "Site to Source Energy Conversion Factors");
    8274           42 :                 WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
    8275              :             }
    8276           44 :             if (produceSQLite) {
    8277           42 :                 if (state.dataSQLiteProcedures->sqlite) {
    8278            7 :                     state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(tableBody,
    8279              :                                                                                        rowHead,
    8280              :                                                                                        columnHead,
    8281              :                                                                                        "AnnualBuildingUtilityPerformanceSummary",
    8282              :                                                                                        "Entire Facility",
    8283              :                                                                                        "Site to Source Energy Conversion Factors");
    8284              :                 }
    8285              :             }
    8286           44 :             if (produceTabular) {
    8287           42 :                 if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
    8288            0 :                     state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(tableBody,
    8289              :                                                                                                           rowHead,
    8290              :                                                                                                           columnHead,
    8291              :                                                                                                           "AnnualBuildingUtilityPerformanceSummary",
    8292              :                                                                                                           "Entire Facility",
    8293              :                                                                                                           "Site to Source Energy Conversion Factors");
    8294              :                 }
    8295              :             }
    8296              :         }
    8297              : 
    8298              :         //---- Building Area Sub-Table
    8299           44 :         rowHead.allocate(3);
    8300           44 :         columnHead.allocate(1);
    8301           44 :         columnWidth.allocate(1);
    8302           44 :         columnWidth = 14; // array assignment - same for all columns
    8303           44 :         tableBody.allocate(1, 3);
    8304              : 
    8305           44 :         switch (unitsStyle_cur) {
    8306            4 :         case UnitsStyle::JtoKWH: {
    8307            4 :             columnHead(1) = "Area [m2]";
    8308            4 :         } break;
    8309            2 :         case UnitsStyle::InchPound: {
    8310            2 :             columnHead(1) = "Area [ft2]";
    8311            2 :         } break;
    8312            1 :         case UnitsStyle::InchPoundExceptElectricity: {
    8313            1 :             columnHead(1) = "Area [ft2]";
    8314            1 :         } break;
    8315           37 :         default: {
    8316           37 :             columnHead(1) = "Area [m2]";
    8317           37 :         } break;
    8318              :         }
    8319              : 
    8320           44 :         rowHead(1) = "Total Building Area";
    8321           44 :         rowHead(2) = "Net Conditioned Building Area";
    8322           44 :         rowHead(3) = "Unconditioned Building Area";
    8323              : 
    8324           44 :         tableBody = "";
    8325           44 :         tableBody(1, 1) = RealToStr(convBldgGrossFloorArea, 2);
    8326              : 
    8327           44 :         if (unitsStyle_cur == OutputReportTabular::UnitsStyle::InchPound ||
    8328           42 :             unitsStyle_cur == OutputReportTabular::UnitsStyle::InchPoundExceptElectricity) {
    8329            3 :             if (produceTabular) {
    8330            2 :                 PreDefTableEntry(
    8331            3 :                     state, state.dataOutRptPredefined->pdchLeedGenData, "Total gross floor area [ft2]", RealToStr(convBldgGrossFloorArea, 2));
    8332              :             }
    8333              :         } else {
    8334           41 :             if (produceTabular) {
    8335           82 :                 PreDefTableEntry(
    8336          123 :                     state, state.dataOutRptPredefined->pdchLeedGenData, "Total gross floor area [m2]", RealToStr(convBldgGrossFloorArea, 2));
    8337              :             }
    8338              :         }
    8339              : 
    8340           44 :         tableBody(1, 2) = RealToStr(convBldgCondFloorArea, 2);
    8341           44 :         tableBody(1, 3) = RealToStr(convBldgGrossFloorArea - convBldgCondFloorArea, 2);
    8342              : 
    8343              :         // heading for the entire sub-table
    8344           44 :         if (ort->displayTabularBEPS) {
    8345           44 :             if (produceTabular) {
    8346           42 :                 WriteSubtitle(state, "Building Area");
    8347           42 :                 WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
    8348              :             }
    8349           44 :             if (produceSQLite) {
    8350           42 :                 if (state.dataSQLiteProcedures->sqlite) {
    8351            7 :                     state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
    8352              :                         tableBody, rowHead, columnHead, "AnnualBuildingUtilityPerformanceSummary", "Entire Facility", "Building Area");
    8353              :                 }
    8354              :             }
    8355           44 :             if (produceTabular) {
    8356           42 :                 if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
    8357            0 :                     state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(
    8358              :                         tableBody, rowHead, columnHead, "AnnualBuildingUtilityPerformanceSummary", "Entire Facility", "Building Area");
    8359              :                 }
    8360              :             }
    8361              :         }
    8362              : 
    8363              :         //---- End Use Sub-Table
    8364           44 :         rowHead.allocate(16);
    8365           44 :         columnHead.allocate(14);
    8366           44 :         columnWidth.allocate(14);
    8367           44 :         columnWidth = 10; // array assignment - same for all columns
    8368           44 :         tableBody.allocate(14, 16);
    8369          660 :         for (int iResource = 1; iResource <= 14; ++iResource) {
    8370         9240 :             for (int iEndUse = 0; iEndUse < static_cast<int>(Constant::EndUse::Num); ++iEndUse) {
    8371         8624 :                 useVal(iResource, iEndUse + 1) = collapsedEndUse(iResource, iEndUse + 1);
    8372              :             }
    8373          616 :             useVal(iResource, 15) = collapsedTotal(iResource); // totals
    8374              :         }
    8375              : 
    8376           44 :         rowHead(static_cast<int>(Constant::EndUse::Heating) + 1) = "Heating";
    8377           44 :         rowHead(static_cast<int>(Constant::EndUse::Cooling) + 1) = "Cooling";
    8378           44 :         rowHead(static_cast<int>(Constant::EndUse::InteriorLights) + 1) = "Interior Lighting";
    8379           44 :         rowHead(static_cast<int>(Constant::EndUse::ExteriorLights) + 1) = "Exterior Lighting";
    8380           44 :         rowHead(static_cast<int>(Constant::EndUse::InteriorEquipment) + 1) = "Interior Equipment";
    8381           44 :         rowHead(static_cast<int>(Constant::EndUse::ExteriorEquipment) + 1) = "Exterior Equipment";
    8382           44 :         rowHead(static_cast<int>(Constant::EndUse::Fans) + 1) = "Fans";
    8383           44 :         rowHead(static_cast<int>(Constant::EndUse::Pumps) + 1) = "Pumps";
    8384           44 :         rowHead(static_cast<int>(Constant::EndUse::HeatRejection) + 1) = "Heat Rejection";
    8385           44 :         rowHead(static_cast<int>(Constant::EndUse::Humidification) + 1) = "Humidification";
    8386           44 :         rowHead(static_cast<int>(Constant::EndUse::HeatRecovery) + 1) = "Heat Recovery";
    8387           44 :         rowHead(static_cast<int>(Constant::EndUse::WaterSystem) + 1) = "Water Systems";
    8388           44 :         rowHead(static_cast<int>(Constant::EndUse::Refrigeration) + 1) = "Refrigeration";
    8389           44 :         rowHead(static_cast<int>(Constant::EndUse::Cogeneration) + 1) = "Generators";
    8390           44 :         rowHead(15) = "";
    8391           44 :         rowHead(16) = "Total End Uses";
    8392              : 
    8393           44 :         switch (unitsStyle_cur) {
    8394            4 :         case UnitsStyle::JtoKWH: {
    8395            4 :             columnHead(1) = "Electricity [kWh]";
    8396            4 :             columnHead(2) = "Natural Gas [kWh]";
    8397            4 :             columnHead(3) = "Gasoline [kWh]";
    8398            4 :             columnHead(4) = "Diesel [kWh]";
    8399            4 :             columnHead(5) = "Coal [kWh]";
    8400            4 :             columnHead(6) = "Fuel Oil No 1 [kWh]";
    8401            4 :             columnHead(7) = "Fuel Oil No 2 [kWh]";
    8402            4 :             columnHead(8) = "Propane [kWh]";
    8403            4 :             columnHead(9) = "Other Fuel 1 [kWh]";
    8404            4 :             columnHead(10) = "Other Fuel 2 [kWh]";
    8405            4 :             columnHead(11) = "District Cooling [kWh]";
    8406            4 :             columnHead(12) = "District Heating Water [kWh]";
    8407            4 :             columnHead(13) = "District Heating Steam [kWh]";
    8408            4 :             columnHead(14) = "Water [m3]";
    8409            4 :         } break;
    8410            2 :         case UnitsStyle::InchPound: {
    8411            2 :             columnHead(1) = "Electricity [kBtu]";
    8412            2 :             columnHead(2) = "Natural Gas [kBtu]";
    8413            2 :             columnHead(3) = "Gasoline [kBtu]";
    8414            2 :             columnHead(4) = "Diesel [kBtu]";
    8415            2 :             columnHead(5) = "Coal [kBtu]";
    8416            2 :             columnHead(6) = "Fuel Oil No 1 [kBtu]";
    8417            2 :             columnHead(7) = "Fuel Oil No 2 [kBtu]";
    8418            2 :             columnHead(8) = "Propane [kBtu]";
    8419            2 :             columnHead(9) = "Other Fuel 1 [kBtu]";
    8420            2 :             columnHead(10) = "Other Fuel 2 [kBtu]";
    8421            2 :             columnHead(11) = "District Cooling [kBtu]";
    8422            2 :             columnHead(12) = "District Heating Water [kBtu]";
    8423            2 :             columnHead(13) = "District Heating Steam [kBtu]";
    8424            2 :             columnHead(14) = "Water [gal]";
    8425            2 :         } break;
    8426            1 :         case UnitsStyle::InchPoundExceptElectricity: {
    8427            1 :             columnHead(1) = "Electricity [kWh]";
    8428            1 :             columnHead(2) = "Natural Gas [kBtu]";
    8429            1 :             columnHead(3) = "Gasoline [kBtu]";
    8430            1 :             columnHead(4) = "Diesel [kBtu]";
    8431            1 :             columnHead(5) = "Coal [kBtu]";
    8432            1 :             columnHead(6) = "Fuel Oil No 1 [kBtu]";
    8433            1 :             columnHead(7) = "Fuel Oil No 2 [kBtu]";
    8434            1 :             columnHead(8) = "Propane [kBtu]";
    8435            1 :             columnHead(9) = "Other Fuel 1 [kBtu]";
    8436            1 :             columnHead(10) = "Other Fuel 2 [kBtu]";
    8437            1 :             columnHead(11) = "District Cooling [kBtu]";
    8438            1 :             columnHead(12) = "District Heating Water [kBtu]";
    8439            1 :             columnHead(13) = "District Heating Steam [kBtu]";
    8440            1 :             columnHead(14) = "Water [gal]";
    8441            1 :         } break;
    8442           37 :         default: {
    8443           37 :             columnHead(1) = "Electricity [GJ]";
    8444           37 :             columnHead(2) = "Natural Gas [GJ]";
    8445           37 :             columnHead(3) = "Gasoline [GJ]";
    8446           37 :             columnHead(4) = "Diesel [GJ]";
    8447           37 :             columnHead(5) = "Coal [GJ]";
    8448           37 :             columnHead(6) = "Fuel Oil No 1 [GJ]";
    8449           37 :             columnHead(7) = "Fuel Oil No 2 [GJ]";
    8450           37 :             columnHead(8) = "Propane [GJ]";
    8451           37 :             columnHead(9) = "Other Fuel 1 [GJ]";
    8452           37 :             columnHead(10) = "Other Fuel 2 [GJ]";
    8453           37 :             columnHead(11) = "District Cooling [GJ]";
    8454           37 :             columnHead(12) = "District Heating Water [GJ]";
    8455           37 :             columnHead(13) = "District Heating Steam [GJ]";
    8456           37 :             columnHead(14) = "Water [m3]";
    8457           37 :         } break;
    8458              :         }
    8459              : 
    8460           44 :         tableBody = "";
    8461          660 :         for (int iResource = 1; iResource <= 14; ++iResource) {
    8462         9240 :             for (int jEndUse = 1; jEndUse <= 14; ++jEndUse) {
    8463         8624 :                 tableBody(iResource, jEndUse) = RealToStr(useVal(iResource, jEndUse), 2);
    8464              :             }
    8465          616 :             tableBody(iResource, 16) = RealToStr(useVal(iResource, 15), 2);
    8466              :         }
    8467              :         // add warning message if end use values do not add up to total
    8468          660 :         for (int iResource = 1; iResource <= 14; ++iResource) {
    8469          616 :             Real64 curTotal = 0.0;
    8470         9240 :             for (int jUse = 1; jUse <= 14; ++jUse) {
    8471         8624 :                 curTotal += useVal(iResource, jUse);
    8472              :             }
    8473          616 :             if (std::abs(curTotal - collapsedTotal(iResource)) > (collapsedTotal(iResource) * 0.001)) {
    8474            0 :                 ShowWarningError(state, ResourceWarningMessage(columnHead(iResource)));
    8475              :             }
    8476              :         }
    8477              : 
    8478           44 :         Real64 const unconvert = largeConversionFactor / 1000000000.0; // to avoid double converting, the values for the LEED report should be in GJ
    8479           44 :         Real64 const unconvert_ipExceptElec = (largeConversionFactor / ipElectricityConversionFactor) /
    8480              :                                               1000000000.0; // to avoid double converting, the values for the LEED report should be in GJ
    8481              : 
    8482              :         //  Energy Use Intensities - Electricity
    8483           44 :         if (ort->buildingGrossFloorArea > 0) {
    8484           38 :             if (produceTabular) {
    8485           38 :                 PreDefTableEntry(state,
    8486           38 :                                  state.dataOutRptPredefined->pdchLeedEuiElec,
    8487              :                                  "Interior Lighting (All)",
    8488           38 :                                  unconvert_ipExceptElec * 1000 * useVal(colElectricity, 3) / ort->buildingGrossFloorArea,
    8489           38 :                                  2);
    8490           38 :                 PreDefTableEntry(state,
    8491           38 :                                  state.dataOutRptPredefined->pdchLeedEuiElec,
    8492              :                                  "Space Heating",
    8493           38 :                                  unconvert_ipExceptElec * 1000 * useVal(colElectricity, 1) / ort->buildingGrossFloorArea,
    8494           38 :                                  2);
    8495           38 :                 PreDefTableEntry(state,
    8496           38 :                                  state.dataOutRptPredefined->pdchLeedEuiElec,
    8497              :                                  "Space Cooling",
    8498           38 :                                  unconvert_ipExceptElec * 1000 * useVal(colElectricity, 2) / ort->buildingGrossFloorArea,
    8499           38 :                                  2);
    8500           38 :                 PreDefTableEntry(state,
    8501           38 :                                  state.dataOutRptPredefined->pdchLeedEuiElec,
    8502              :                                  "Fans (All)",
    8503           38 :                                  unconvert_ipExceptElec * 1000 * useVal(colElectricity, 7) / ort->buildingGrossFloorArea,
    8504           38 :                                  2);
    8505           38 :                 PreDefTableEntry(state,
    8506           38 :                                  state.dataOutRptPredefined->pdchLeedEuiElec,
    8507              :                                  "Service Water Heating",
    8508           38 :                                  unconvert_ipExceptElec * 1000 * useVal(colElectricity, 12) / ort->buildingGrossFloorArea,
    8509           38 :                                  2);
    8510           38 :                 PreDefTableEntry(state,
    8511           38 :                                  state.dataOutRptPredefined->pdchLeedEuiElec,
    8512              :                                  "Receptacle Equipment",
    8513           38 :                                  unconvert_ipExceptElec * 1000 * useVal(colElectricity, 5) / ort->buildingGrossFloorArea,
    8514           38 :                                  2);
    8515           38 :                 PreDefTableEntry(state,
    8516           38 :                                  state.dataOutRptPredefined->pdchLeedEuiElec,
    8517              :                                  "Miscellaneous (All)",
    8518           38 :                                  unconvert_ipExceptElec * 1000 * (useVal(colElectricity, 15)) / ort->buildingGrossFloorArea,
    8519           38 :                                  2);
    8520           38 :                 PreDefTableEntry(state,
    8521           38 :                                  state.dataOutRptPredefined->pdchLeedEuiElec,
    8522              :                                  "Subtotal",
    8523           38 :                                  unconvert_ipExceptElec * 1000 * useVal(colElectricity, 15) / ort->buildingGrossFloorArea,
    8524           76 :                                  2);
    8525              :             }
    8526              :         }
    8527              : 
    8528           44 :         if (produceTabular) {
    8529           42 :             PreDefTableEntry(
    8530           42 :                 state, state.dataOutRptPredefined->pdchLeedEusTotal, "Electricity", unconvert_ipExceptElec * useVal(colElectricity, 15), 2);
    8531           42 :             PreDefTableEntry(state,
    8532           42 :                              state.dataOutRptPredefined->pdchLeedEusProc,
    8533              :                              "Electricity",
    8534           42 :                              unconvert_ipExceptElec * (useVal(colElectricity, 5) + useVal(colElectricity, 13)),
    8535           84 :                              2);
    8536              :         }
    8537              : 
    8538           44 :         Real64 processElecCost = 0.0;
    8539           44 :         if (useVal(colElectricity, 15) != 0) {
    8540            5 :             Real64 const processFraction = (useVal(colElectricity, 5) + useVal(colElectricity, 13)) / useVal(colElectricity, 15);
    8541            5 :             processElecCost = state.dataOutRptPredefined->LEEDelecCostTotal * processFraction;
    8542              :         }
    8543           44 :         if (produceTabular) {
    8544           42 :             PreDefTableEntry(state, state.dataOutRptPredefined->pdchLeedEcsProc, "Electricity", processElecCost, 2);
    8545           84 :             addFootNoteSubTable(
    8546           42 :                 state, state.dataOutRptPredefined->pdstLeedEneCostSum, "Process energy cost based on ratio of process to total energy.");
    8547              :         }
    8548              : 
    8549              :         //  Energy Use Intensities- Natural Gas
    8550           44 :         if (ort->buildingGrossFloorArea > 0) {
    8551           38 :             if (produceTabular) {
    8552           38 :                 PreDefTableEntry(state,
    8553           38 :                                  state.dataOutRptPredefined->pdchLeedEuiNatG,
    8554              :                                  "Space Heating",
    8555           38 :                                  unconvert * 1000 * useVal(colGas, 1) / ort->buildingGrossFloorArea,
    8556           38 :                                  2);
    8557           38 :                 PreDefTableEntry(state,
    8558           38 :                                  state.dataOutRptPredefined->pdchLeedEuiNatG,
    8559              :                                  "Service Water Heating",
    8560           38 :                                  unconvert * 1000 * useVal(colGas, 12) / ort->buildingGrossFloorArea,
    8561           38 :                                  2);
    8562           38 :                 PreDefTableEntry(state,
    8563           38 :                                  state.dataOutRptPredefined->pdchLeedEuiNatG,
    8564              :                                  "Miscellaneous (All)",
    8565           38 :                                  unconvert * 1000 * useVal(colGas, 15) / ort->buildingGrossFloorArea,
    8566           38 :                                  2);
    8567           38 :                 PreDefTableEntry(state,
    8568           38 :                                  state.dataOutRptPredefined->pdchLeedEuiNatG,
    8569              :                                  "Subtotal",
    8570           38 :                                  unconvert * 1000 * useVal(colGas, 15) / ort->buildingGrossFloorArea,
    8571           76 :                                  2);
    8572              :             }
    8573              :         }
    8574           44 :         if (produceTabular) {
    8575           42 :             PreDefTableEntry(state, state.dataOutRptPredefined->pdchLeedEusTotal, "Natural Gas", unconvert * useVal(colGas, 15), 2);
    8576           42 :             PreDefTableEntry(
    8577           84 :                 state, state.dataOutRptPredefined->pdchLeedEusProc, "Natural Gas", unconvert * (useVal(colGas, 5) + useVal(colGas, 13)), 2);
    8578              :         }
    8579              : 
    8580           44 :         Real64 processGasCost = 0.0;
    8581           44 :         if (useVal(colGas, 15) != 0) {
    8582            0 :             Real64 const processFraction = (useVal(colGas, 5) + useVal(colGas, 13)) / useVal(colGas, 15);
    8583            0 :             processGasCost = state.dataOutRptPredefined->LEEDgasCostTotal * processFraction;
    8584              :         }
    8585           44 :         if (produceTabular) {
    8586           42 :             PreDefTableEntry(state, state.dataOutRptPredefined->pdchLeedEcsProc, "Natural Gas", processGasCost, 2);
    8587              :         }
    8588              :         //  Energy Use Intensities  - Additional Fuel
    8589              :         Real64 const useValColAddFuel15 =
    8590           44 :             useVal(3, 15) + useVal(4, 15) + useVal(5, 15) + useVal(6, 15) + useVal(7, 15) + useVal(8, 15) + useVal(9, 15) + useVal(10, 15);
    8591              :         Real64 const useValColAddFuel5 =
    8592           44 :             useVal(3, 5) + useVal(4, 5) + useVal(5, 5) + useVal(6, 5) + useVal(7, 5) + useVal(8, 5) + useVal(9, 5) + useVal(10, 5);
    8593              :         Real64 const useValColAddFuel13 =
    8594           44 :             useVal(3, 13) + useVal(4, 13) + useVal(5, 13) + useVal(6, 13) + useVal(7, 13) + useVal(8, 13) + useVal(9, 13) + useVal(10, 13);
    8595           44 :         if (ort->buildingGrossFloorArea > 0) {
    8596           38 :             if (produceTabular) {
    8597           38 :                 PreDefTableEntry(state,
    8598           38 :                                  state.dataOutRptPredefined->pdchLeedEuiOthr,
    8599              :                                  "Miscellaneous",
    8600           38 :                                  unconvert * 1000 * useValColAddFuel15 / ort->buildingGrossFloorArea,
    8601           38 :                                  2);
    8602           38 :                 PreDefTableEntry(state,
    8603           38 :                                  state.dataOutRptPredefined->pdchLeedEuiOthr,
    8604              :                                  "Subtotal",
    8605           38 :                                  unconvert * 1000 * useValColAddFuel15 / ort->buildingGrossFloorArea,
    8606           76 :                                  2);
    8607              :             }
    8608              :         }
    8609           44 :         if (produceTabular) {
    8610           42 :             PreDefTableEntry(state,
    8611           42 :                              state.dataOutRptPredefined->pdchLeedEusTotal,
    8612              :                              "Additional",
    8613           42 :                              (useValColAddFuel15 + useVal(colPurchCool, 15) + useVal(colPurchHeatWtr, 15) + useVal(colPurchHeatSt, 15)),
    8614           42 :                              2);
    8615           42 :             PreDefTableEntry(state,
    8616           42 :                              state.dataOutRptPredefined->pdchLeedEusProc,
    8617              :                              "Additional",
    8618              :                              unconvert *
    8619           42 :                                  (useValColAddFuel5 + useValColAddFuel13 + useVal(colPurchCool, 5) + useVal(colPurchCool, 13) +
    8620           42 :                                   useVal(colPurchHeatWtr, 5) + useVal(colPurchHeatWtr, 13) + useVal(colPurchHeatSt, 5) + useVal(colPurchHeatSt, 13)),
    8621           84 :                              2);
    8622              :         }
    8623              : 
    8624           44 :         Real64 processOthrCost = 0.0;
    8625           44 :         if ((useValColAddFuel15 + useVal(colPurchCool, 15) + useVal(colPurchHeatWtr, 15) + useVal(colPurchHeatSt, 15)) > 0.001) {
    8626              :             Real64 const processFraction =
    8627            6 :                 (useValColAddFuel5 + useValColAddFuel13 + useVal(colPurchCool, 5) + useVal(colPurchCool, 13) + useVal(colPurchHeatWtr, 5) +
    8628            6 :                  useVal(colPurchHeatWtr, 13) + useVal(colPurchHeatSt, 5) + useVal(colPurchHeatSt, 13)) /
    8629            6 :                 (useValColAddFuel15 + useVal(colPurchCool, 15) + useVal(colPurchHeatWtr, 15) + useVal(colPurchHeatSt, 15));
    8630            6 :             processOthrCost = state.dataOutRptPredefined->LEEDothrCostTotal * processFraction;
    8631              :         }
    8632           44 :         if (produceTabular) {
    8633           42 :             PreDefTableEntry(state, state.dataOutRptPredefined->pdchLeedEcsProc, "Additional", processOthrCost, 2);
    8634           42 :             PreDefTableEntry(state, state.dataOutRptPredefined->pdchLeedEcsProc, "Total", processElecCost + processGasCost + processOthrCost, 2);
    8635              :         }
    8636              :         // accumulate for percentage table
    8637           44 :         state.dataOutRptTab->leedSiteIntLite = 0.0;
    8638           44 :         state.dataOutRptTab->leedSiteSpHeat = 0.0;
    8639           44 :         state.dataOutRptTab->leedSiteSpCool = 0.0;
    8640           44 :         state.dataOutRptTab->leedSiteFanInt = 0.0;
    8641           44 :         state.dataOutRptTab->leedSiteSrvWatr = 0.0;
    8642           44 :         state.dataOutRptTab->leedSiteRecept = 0.0;
    8643           44 :         state.dataOutRptTab->leedSiteTotal = 0.0;
    8644          616 :         for (int iResource = 1; iResource <= 13; ++iResource) { // don't bother with water
    8645          572 :             state.dataOutRptTab->leedSiteIntLite += useVal(iResource, 3);
    8646          572 :             state.dataOutRptTab->leedSiteSpHeat += useVal(iResource, 1);
    8647          572 :             state.dataOutRptTab->leedSiteSpCool += useVal(iResource, 2);
    8648          572 :             state.dataOutRptTab->leedSiteFanInt += useVal(iResource, 7);
    8649          572 :             state.dataOutRptTab->leedSiteSrvWatr += useVal(iResource, 12);
    8650          572 :             state.dataOutRptTab->leedSiteRecept += useVal(iResource, 5);
    8651          572 :             state.dataOutRptTab->leedSiteTotal += useVal(iResource, 15);
    8652              :         }
    8653           44 :         if (state.dataOutRptTab->leedSiteTotal != 0) {
    8654            6 :             if (produceTabular) {
    8655            4 :                 PreDefTableEntry(state,
    8656            4 :                                  state.dataOutRptPredefined->pdchLeedEupPerc,
    8657              :                                  "Interior Lighting (All)",
    8658            4 :                                  100 * state.dataOutRptTab->leedSiteIntLite / state.dataOutRptTab->leedSiteTotal,
    8659            4 :                                  2);
    8660            4 :                 PreDefTableEntry(state,
    8661            4 :                                  state.dataOutRptPredefined->pdchLeedEupPerc,
    8662              :                                  "Space Heating",
    8663            4 :                                  100 * state.dataOutRptTab->leedSiteSpHeat / state.dataOutRptTab->leedSiteTotal,
    8664            4 :                                  2);
    8665            4 :                 PreDefTableEntry(state,
    8666            4 :                                  state.dataOutRptPredefined->pdchLeedEupPerc,
    8667              :                                  "Space Cooling",
    8668            4 :                                  100 * state.dataOutRptTab->leedSiteSpCool / state.dataOutRptTab->leedSiteTotal,
    8669            4 :                                  2);
    8670            4 :                 PreDefTableEntry(state,
    8671            4 :                                  state.dataOutRptPredefined->pdchLeedEupPerc,
    8672              :                                  "Fans (All)",
    8673            4 :                                  100 * state.dataOutRptTab->leedSiteFanInt / state.dataOutRptTab->leedSiteTotal,
    8674            4 :                                  2);
    8675            4 :                 PreDefTableEntry(state,
    8676            4 :                                  state.dataOutRptPredefined->pdchLeedEupPerc,
    8677              :                                  "Service Water Heating",
    8678            4 :                                  100 * state.dataOutRptTab->leedSiteSrvWatr / state.dataOutRptTab->leedSiteTotal,
    8679            4 :                                  2);
    8680            4 :                 PreDefTableEntry(state,
    8681            4 :                                  state.dataOutRptPredefined->pdchLeedEupPerc,
    8682              :                                  "Receptacle Equipment",
    8683            4 :                                  100 * state.dataOutRptTab->leedSiteRecept / state.dataOutRptTab->leedSiteTotal,
    8684            4 :                                  2);
    8685            4 :                 PreDefTableEntry(
    8686              :                     state,
    8687            4 :                     state.dataOutRptPredefined->pdchLeedEupPerc,
    8688              :                     "Miscellaneous",
    8689            4 :                     100 *
    8690            4 :                         (state.dataOutRptTab->leedSiteTotal -
    8691            4 :                          (state.dataOutRptTab->leedSiteIntLite + state.dataOutRptTab->leedSiteSpHeat + state.dataOutRptTab->leedSiteSpCool +
    8692            4 :                           state.dataOutRptTab->leedSiteFanInt + state.dataOutRptTab->leedSiteSrvWatr + state.dataOutRptTab->leedSiteRecept)) /
    8693            4 :                         state.dataOutRptTab->leedSiteTotal,
    8694            8 :                     2);
    8695              :             }
    8696              :         }
    8697              :         // totals across energy source
    8698           44 :         if (produceTabular) {
    8699           42 :             PreDefTableEntry(state,
    8700           42 :                              state.dataOutRptPredefined->pdchLeedEusTotal,
    8701              :                              "Total",
    8702           42 :                              unconvert_ipExceptElec * useVal(colElectricity, 15) +
    8703           42 :                                  unconvert * (useValColAddFuel15 + useVal(colPurchCool, 15) + useVal(colPurchHeatWtr, 15) +
    8704           42 :                                               useVal(colPurchHeatSt, 15) + +useVal(colGas, 15)),
    8705           42 :                              2);
    8706           42 :             PreDefTableEntry(state,
    8707           42 :                              state.dataOutRptPredefined->pdchLeedEusProc,
    8708              :                              "Total",
    8709           42 :                              unconvert_ipExceptElec * (useVal(colElectricity, 5) + useVal(colElectricity, 13)) +
    8710           42 :                                  unconvert * (useValColAddFuel5 + useValColAddFuel13 + useVal(colPurchCool, 5) + useVal(colPurchCool, 13) +
    8711           42 :                                               useVal(colPurchHeatWtr, 5) + useVal(colPurchHeatWtr, 13) + useVal(colPurchHeatSt, 5) +
    8712           42 :                                               useVal(colPurchHeatSt, 13) + +useVal(colGas, 5) + useVal(colGas, 13)),
    8713           84 :                              2);
    8714              :         }
    8715              : 
    8716           88 :         std::string footnote;
    8717           44 :         switch (resourcePrimaryHeating) {
    8718            0 :         case colElectricity: {
    8719            0 :             if (produceTabular) {
    8720            0 :                 footnote = "Note: Electricity appears to be the principal heating source based on energy usage.";
    8721            0 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchLeedGenData, "Principal Heating Source", "Electricity");
    8722              :             }
    8723            0 :         } break;
    8724            0 :         case colGas: {
    8725            0 :             if (produceTabular) {
    8726            0 :                 footnote = "Note: Natural gas appears to be the principal heating source based on energy usage.";
    8727            0 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchLeedGenData, "Principal Heating Source", "Natural Gas");
    8728              :             }
    8729            0 :         } break;
    8730            5 :         case colGasoline:
    8731              :         case colDiesel:
    8732              :         case colCoal:
    8733              :         case colFuelOilNo1:
    8734              :         case colFuelOilNo2:
    8735              :         case colPropane:
    8736              :         case colOtherFuel1:
    8737              :         case colOtherFuel2: {
    8738            5 :             if (produceTabular) {
    8739            3 :                 footnote = "Note: Additional fuel appears to be the principal heating source based on energy usage.";
    8740            3 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchLeedGenData, "Principal Heating Source", "Additional Fuel");
    8741              :             }
    8742            5 :         } break;
    8743            0 :         case colPurchHeatWtr: {
    8744            0 :             if (produceTabular) {
    8745            0 :                 footnote = "Note: District heating water appears to be the principal heating source based on energy usage.";
    8746            0 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchLeedGenData, "Principal Heating Source", "District Heating Water");
    8747              :             }
    8748            0 :         } break;
    8749            0 :         case colPurchHeatSt: {
    8750            0 :             if (produceTabular) {
    8751            0 :                 footnote = "Note: District heating steam appears to be the principal heating source based on energy usage.";
    8752            0 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchLeedGenData, "Principal Heating Source", "District Heating steam");
    8753              :             }
    8754            0 :         } break;
    8755              :         }
    8756              :         // heading for the entire sub-table
    8757           44 :         if (ort->displayTabularBEPS) {
    8758           44 :             if (produceTabular) {
    8759           42 :                 WriteSubtitle(state, "End Uses");
    8760           42 :                 WriteTable(state, tableBody, rowHead, columnHead, columnWidth, false, footnote);
    8761              :             }
    8762           44 :             if (produceSQLite) {
    8763           42 :                 if (state.dataSQLiteProcedures->sqlite) {
    8764            7 :                     state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
    8765              :                         tableBody, rowHead, columnHead, "AnnualBuildingUtilityPerformanceSummary", "Entire Facility", "End Uses");
    8766              :                 }
    8767              :             }
    8768           44 :             if (produceTabular) {
    8769           42 :                 if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
    8770            0 :                     state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(
    8771              :                         tableBody, rowHead, columnHead, "AnnualBuildingUtilityPerformanceSummary", "Entire Facility", "End Uses");
    8772              :                 }
    8773              :             }
    8774              :         }
    8775              : 
    8776              :         //---- End Uses By Subcategory Sub-Table
    8777           88 :         writeBEPSEndUseBySubCatOrSpaceType(state,
    8778              :                                            EndUseSubTableType::BySubCategory,
    8779              :                                            endUseSubOther,
    8780              :                                            collapsedEndUse,
    8781              :                                            collapsedEndUseSub,
    8782           44 :                                            ort->needOtherRowLEED45,
    8783              :                                            unitsStyle_cur,
    8784              :                                            produceTabular,
    8785              :                                            produceSQLite);
    8786              : 
    8787           88 :         writeBEPSEndUseBySubCatOrSpaceType(state,
    8788              :                                            EndUseSubTableType::BySpaceType,
    8789              :                                            endUseSubOther,
    8790              :                                            collapsedEndUse,
    8791              :                                            collapsedEndUseSpType,
    8792           44 :                                            ort->needOtherRowEndUse,
    8793              :                                            unitsStyle_cur,
    8794              :                                            produceTabular,
    8795              :                                            produceSQLite);
    8796              : 
    8797              :         // EAp2-4/5. Performance Rating Method Compliance
    8798              :         // repeat some of the code for the end use subcategory table but only looping over the energy resources and not including water
    8799              : 
    8800           88 :         Array1D_int resource_entry_map;
    8801           44 :         resource_entry_map.allocate(13);
    8802           44 :         resource_entry_map(1) = state.dataOutRptPredefined->pdchLeedPerfElEneUse;          // electricity
    8803           44 :         resource_entry_map(2) = state.dataOutRptPredefined->pdchLeedPerfGasEneUse;         // natural gas
    8804           44 :         resource_entry_map(3) = state.dataOutRptPredefined->pdchLeedPerfGasolineEneUse;    // gasoline
    8805           44 :         resource_entry_map(4) = state.dataOutRptPredefined->pdchLeedPerfDieselEneUse;      // diesel
    8806           44 :         resource_entry_map(5) = state.dataOutRptPredefined->pdchLeedPerfCoalEneUse;        // coal
    8807           44 :         resource_entry_map(6) = state.dataOutRptPredefined->pdchLeedPerfFuelOil1EneUse;    // fuel oil no 1
    8808           44 :         resource_entry_map(7) = state.dataOutRptPredefined->pdchLeedPerfFuelOil2EneUse;    // fuel oil no 2
    8809           44 :         resource_entry_map(8) = state.dataOutRptPredefined->pdchLeedPerfPropaneEneUse;     // propane
    8810           44 :         resource_entry_map(9) = state.dataOutRptPredefined->pdchLeedPerfOtherFuel1EneUse;  // other fuel 1
    8811           44 :         resource_entry_map(10) = state.dataOutRptPredefined->pdchLeedPerfOtherFuel2EneUse; // other fuel 2
    8812           44 :         resource_entry_map(11) = state.dataOutRptPredefined->pdchLeedPerfDisClEneUse;      // district cooling
    8813           44 :         resource_entry_map(12) = state.dataOutRptPredefined->pdchLeedPerfDisHtWtrEneUse;   // district heating Water
    8814           44 :         resource_entry_map(13) = state.dataOutRptPredefined->pdchLeedPerfDisHtStEneUse;    // district heating Steam
    8815              : 
    8816          616 :         for (int iResource = 1; iResource <= 13; ++iResource) {
    8817          572 :             int i = 1;
    8818          572 :             Real64 localUnconvert = (iResource == 1) ? unconvert_ipExceptElec : unconvert;
    8819         8580 :             for (int jEndUse = 1; jEndUse <= static_cast<int>(Constant::EndUse::Num); ++jEndUse) {
    8820         8008 :                 if (op->EndUseCategory(jEndUse).NumSubcategories > 0) {
    8821         4628 :                     for (int kEndUseSub = 1; kEndUseSub <= op->EndUseCategory(jEndUse).NumSubcategories; ++kEndUseSub) {
    8822         2353 :                         if (produceTabular) {
    8823         6825 :                             PreDefTableEntry(state,
    8824         2275 :                                              resource_entry_map(iResource),
    8825         4550 :                                              op->EndUseCategory(jEndUse).DisplayName + " -- " +
    8826         2275 :                                                  op->EndUseCategory(jEndUse).SubcategoryName(kEndUseSub),
    8827         2275 :                                              localUnconvert * collapsedEndUseSub(kEndUseSub, jEndUse, iResource));
    8828              :                         }
    8829         2353 :                         ++i;
    8830              :                     }
    8831              :                     // put other
    8832         2275 :                     if (ort->needOtherRowLEED45(jEndUse)) {
    8833            0 :                         if (produceTabular) {
    8834            0 :                             PreDefTableEntry(state,
    8835            0 :                                              resource_entry_map(iResource),
    8836            0 :                                              op->EndUseCategory(jEndUse).DisplayName + " -- Other",
    8837            0 :                                              localUnconvert * endUseSubOther(iResource, jEndUse));
    8838              :                         }
    8839            0 :                         ++i;
    8840              :                     }
    8841              :                 } else {
    8842         5733 :                     if (produceTabular) {
    8843        16263 :                         PreDefTableEntry(state,
    8844         5421 :                                          resource_entry_map(iResource),
    8845        10842 :                                          op->EndUseCategory(jEndUse).DisplayName + " -- Not Subdivided",
    8846         5421 :                                          localUnconvert * collapsedEndUse(iResource, jEndUse));
    8847              :                     }
    8848         5733 :                     ++i;
    8849              :                 }
    8850              :             }
    8851              :         }
    8852              : 
    8853              :         //---- Normalized by Conditioned Area Sub-Table
    8854              :         // Calculations for both normalized tables are first
    8855           44 :         rowHead.allocate(4);
    8856           44 :         columnHead.allocate(14);
    8857           44 :         columnWidth.allocate(14);
    8858           44 :         columnWidth = 7; // array assignment - same for all columns
    8859           44 :         tableBody.allocate(14, 4);
    8860          660 :         for (int iResource = 1; iResource <= 14; ++iResource) {
    8861              :             // Lights     <- InteriorLights | <- ExteriorLights
    8862          616 :             normalVal(iResource, 1) = collapsedEndUse(iResource, static_cast<int>(Constant::EndUse::InteriorLights) + 1) +
    8863          616 :                                       collapsedEndUse(iResource, static_cast<int>(Constant::EndUse::ExteriorLights) + 1);
    8864              : 
    8865              :             // HVAC       <- fans | <- pumps | <- heating | <- cooling | <- heat rejection | <- humidification | <- water system | <- domestic hot
    8866              :             // water
    8867          616 :             normalVal(iResource, 2) = collapsedEndUse(iResource, static_cast<int>(Constant::EndUse::Fans) + 1) +
    8868          616 :                                       collapsedEndUse(iResource, static_cast<int>(Constant::EndUse::Pumps) + 1) +
    8869          616 :                                       collapsedEndUse(iResource, static_cast<int>(Constant::EndUse::Heating) + 1) +
    8870          616 :                                       collapsedEndUse(iResource, static_cast<int>(Constant::EndUse::Cooling) + 1) +
    8871          616 :                                       collapsedEndUse(iResource, static_cast<int>(Constant::EndUse::HeatRejection) + 1) +
    8872          616 :                                       collapsedEndUse(iResource, static_cast<int>(Constant::EndUse::Humidification) + 1) +
    8873          616 :                                       collapsedEndUse(iResource, static_cast<int>(Constant::EndUse::WaterSystem) + 1);
    8874              : 
    8875              :             // Other <- InteriorEquipment | <- ExteriorEquipment | <- generator fuel | <- Heat Recovery (parasitics) | <- Refrigeration
    8876          616 :             normalVal(iResource, 3) = collapsedEndUse(iResource, static_cast<int>(Constant::EndUse::InteriorEquipment) + 1) +
    8877          616 :                                       collapsedEndUse(iResource, static_cast<int>(Constant::EndUse::ExteriorEquipment) + 1) +
    8878          616 :                                       collapsedEndUse(iResource, static_cast<int>(Constant::EndUse::Cogeneration) + 1) +
    8879          616 :                                       collapsedEndUse(iResource, static_cast<int>(Constant::EndUse::HeatRecovery) + 1) +
    8880          616 :                                       collapsedEndUse(iResource, static_cast<int>(Constant::EndUse::Refrigeration) + 1);
    8881              : 
    8882          616 :             normalVal(iResource, 4) = collapsedTotal(iResource); // totals
    8883              :         }
    8884              :         // convert the normalized end use values to MJ from GJ if using J
    8885          616 :         for (int iResource = 1; iResource <= 13; ++iResource) { // not including resource=14 water
    8886         2860 :             for (int jEndUse = 1; jEndUse <= 4; ++jEndUse) {
    8887         2288 :                 normalVal(iResource, jEndUse) *= kConversionFactor;
    8888              :             }
    8889              :         }
    8890              : 
    8891           44 :         rowHead(1) = "Lighting"; // typo fixed 5-17-04 BTG
    8892           44 :         rowHead(2) = "HVAC";
    8893           44 :         rowHead(3) = "Other";
    8894           44 :         rowHead(4) = "Total";
    8895              : 
    8896           44 :         switch (unitsStyle_cur) {
    8897            4 :         case UnitsStyle::JtoKWH: {
    8898            4 :             columnHead(1) = "Electricity Intensity [kWh/m2]";
    8899            4 :             columnHead(2) = "Natural Gas Intensity [kWh/m2]";
    8900            4 :             columnHead(3) = "Gasoline Intensity [kWh/m2]";
    8901            4 :             columnHead(4) = "Diesel Intensity [kWh/m2]";
    8902            4 :             columnHead(5) = "Coal Intensity [kWh/m2]";
    8903            4 :             columnHead(6) = "Fuel Oil No 1 Intensity [kWh/m2]";
    8904            4 :             columnHead(7) = "Fuel Oil No 2 Intensity [kWh/m2]";
    8905            4 :             columnHead(8) = "Propane Intensity [kWh/m2]";
    8906            4 :             columnHead(9) = "Other Fuel 1 Intensity [kWh/m2]";
    8907            4 :             columnHead(10) = "Other Fuel 2 Intensity [kWh/m2]";
    8908            4 :             columnHead(11) = "District Cooling Intensity [kWh/m2]";
    8909            4 :             columnHead(12) = "District Heating Water Intensity [kWh/m2]";
    8910            4 :             columnHead(13) = "District Heating Steam Intensity [kWh/m2]";
    8911            4 :             columnHead(14) = "Water Intensity [m3/m2]";
    8912            4 :         } break;
    8913            2 :         case UnitsStyle::InchPound: {
    8914            2 :             columnHead(1) = "Electricity Intensity [kBtu/ft2]";
    8915            2 :             columnHead(2) = "Natural Gas Intensity [kBtu/ft2]";
    8916            2 :             columnHead(3) = "Gasoline Intensity [kBtu/ft2]";
    8917            2 :             columnHead(4) = "Diesel Intensity [kBtu/ft2]";
    8918            2 :             columnHead(5) = "Coal Intensity [kBtu/ft2]";
    8919            2 :             columnHead(6) = "Fuel Oil No 1 Intensity [kBtu/ft2]";
    8920            2 :             columnHead(7) = "Fuel Oil No 2 Intensity [kBtu/ft2]";
    8921            2 :             columnHead(8) = "Propane Intensity [kBtu/ft2]";
    8922            2 :             columnHead(9) = "Other Fuel 1 Intensity [kBtu/ft2]";
    8923            2 :             columnHead(10) = "Other Fuel 2 Intensity [kBtu/ft2]";
    8924            2 :             columnHead(11) = "District Cooling Intensity [kBtu/ft2]";
    8925            2 :             columnHead(12) = "District Heating Water Intensity [kBtu/ft2]";
    8926            2 :             columnHead(13) = "District Heating Steam Intensity [kBtu/ft2]";
    8927            2 :             columnHead(14) = "Water Intensity [gal/ft2]";
    8928            2 :         } break;
    8929            1 :         case UnitsStyle::InchPoundExceptElectricity: {
    8930            1 :             columnHead(1) = "Electricity Intensity [kWh/ft2]";
    8931            1 :             columnHead(2) = "Natural Gas Intensity [kBtu/ft2]";
    8932            1 :             columnHead(3) = "Gasoline Intensity [kBtu/ft2]";
    8933            1 :             columnHead(4) = "Diesel Intensity [kBtu/ft2]";
    8934            1 :             columnHead(5) = "Coal Intensity [kBtu/ft2]";
    8935            1 :             columnHead(6) = "Fuel Oil No 1 Intensity [kBtu/ft2]";
    8936            1 :             columnHead(7) = "Fuel Oil No 2 Intensity [kBtu/ft2]";
    8937            1 :             columnHead(8) = "Propane Intensity [kBtu/ft2]";
    8938            1 :             columnHead(9) = "Other Fuel 1 Intensity [kBtu/ft2]";
    8939            1 :             columnHead(10) = "Other Fuel 2 Intensity [kBtu/ft2]";
    8940            1 :             columnHead(11) = "District Cooling Intensity [kBtu/ft2]";
    8941            1 :             columnHead(12) = "District Heating Water Intensity [kBtu/ft2]";
    8942            1 :             columnHead(13) = "District Heating Steam Intensity [kBtu/ft2]";
    8943            1 :             columnHead(14) = "Water Intensity [gal/ft2]";
    8944            1 :         } break;
    8945           37 :         default: {
    8946           37 :             columnHead(1) = "Electricity Intensity [MJ/m2]";
    8947           37 :             columnHead(2) = "Natural Gas Intensity [MJ/m2]";
    8948           37 :             columnHead(3) = "Gasoline Intensity [MJ/m2]";
    8949           37 :             columnHead(4) = "Diesel Intensity [MJ/m2]";
    8950           37 :             columnHead(5) = "Coal Intensity [MJ/m2]";
    8951           37 :             columnHead(6) = "Fuel Oil No 1 Intensity [MJ/m2]";
    8952           37 :             columnHead(7) = "Fuel Oil No 2 Intensity [MJ/m2]";
    8953           37 :             columnHead(8) = "Propane Intensity [MJ/m2]";
    8954           37 :             columnHead(9) = "Other Fuel 1 Intensity [MJ/m2]";
    8955           37 :             columnHead(10) = "Other Fuel 2 Intensity [MJ/m2]";
    8956           37 :             columnHead(11) = "District Cooling Intensity [MJ/m2]";
    8957           37 :             columnHead(12) = "District Heating Water Intensity [MJ/m2]";
    8958           37 :             columnHead(13) = "District Heating Steam Intensity [MJ/m2]";
    8959           37 :             columnHead(14) = "Water Intensity [m3/m2]";
    8960           37 :         } break;
    8961              :         }
    8962              : 
    8963           44 :         if (produceTabular) {
    8964           84 :             WriteTextLine(state, "Normalized Metrics", true);
    8965              :         }
    8966              : 
    8967              :         // write the conditioned area based table
    8968           44 :         tableBody = "";
    8969           44 :         if (convBldgCondFloorArea > 0) {
    8970          210 :             for (int iResource = 1; iResource <= 14; ++iResource) {
    8971          980 :                 for (int jEndUse = 1; jEndUse <= 4; ++jEndUse) {
    8972          784 :                     tableBody(iResource, jEndUse) = RealToStr(normalVal(iResource, jEndUse) / convBldgCondFloorArea, 2);
    8973              :                 }
    8974              :             }
    8975              :         }
    8976              :         // heading for the entire sub-table
    8977           44 :         if (ort->displayTabularBEPS) {
    8978           44 :             if (produceTabular) {
    8979           42 :                 WriteSubtitle(state, "Utility Use Per Conditioned Floor Area");
    8980           42 :                 WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
    8981              :             }
    8982           44 :             if (produceSQLite) {
    8983           42 :                 if (state.dataSQLiteProcedures->sqlite) {
    8984            7 :                     state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(tableBody,
    8985              :                                                                                        rowHead,
    8986              :                                                                                        columnHead,
    8987              :                                                                                        "AnnualBuildingUtilityPerformanceSummary",
    8988              :                                                                                        "Entire Facility",
    8989              :                                                                                        "Utility Use Per Conditioned Floor Area");
    8990              :                 }
    8991              :             }
    8992           44 :             if (produceTabular) {
    8993           42 :                 if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
    8994            0 :                     state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(tableBody,
    8995              :                                                                                                           rowHead,
    8996              :                                                                                                           columnHead,
    8997              :                                                                                                           "AnnualBuildingUtilityPerformanceSummary",
    8998              :                                                                                                           "Entire Facility",
    8999              :                                                                                                           "Utility Use Per Conditioned Floor Area");
    9000              :                 }
    9001              :             }
    9002              :         }
    9003              :         //---- Normalized by Total Area Sub-Table
    9004           44 :         tableBody = "";
    9005           44 :         if (convBldgGrossFloorArea > 0) {
    9006          532 :             for (int iResource = 1; iResource <= 13; ++iResource) {
    9007         2470 :                 for (int jEndUse = 1; jEndUse <= 4; ++jEndUse) {
    9008         1976 :                     tableBody(iResource, jEndUse) = RealToStr(normalVal(iResource, jEndUse) / convBldgGrossFloorArea, 2);
    9009              :                 }
    9010              :             }
    9011              :         }
    9012              :         // heading for the entire sub-table
    9013           44 :         if (ort->displayTabularBEPS) {
    9014           44 :             if (produceTabular) {
    9015           42 :                 WriteSubtitle(state, "Utility Use Per Total Floor Area");
    9016           42 :                 WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
    9017              :             }
    9018           44 :             if (produceSQLite) {
    9019           42 :                 if (state.dataSQLiteProcedures->sqlite) {
    9020            7 :                     state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(tableBody,
    9021              :                                                                                        rowHead,
    9022              :                                                                                        columnHead,
    9023              :                                                                                        "AnnualBuildingUtilityPerformanceSummary",
    9024              :                                                                                        "Entire Facility",
    9025              :                                                                                        "Utility Use Per Total Floor Area");
    9026              :                 }
    9027              :             }
    9028           44 :             if (produceTabular) {
    9029           42 :                 if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
    9030            0 :                     state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(tableBody,
    9031              :                                                                                                           rowHead,
    9032              :                                                                                                           columnHead,
    9033              :                                                                                                           "AnnualBuildingUtilityPerformanceSummary",
    9034              :                                                                                                           "Entire Facility",
    9035              :                                                                                                           "Utility Use Per Total Floor Area");
    9036              :                 }
    9037              :             }
    9038              :         }
    9039              : 
    9040              :         //---- Electric Loads Satisfied Sub-Table
    9041           44 :         rowHead.allocate(14);
    9042           44 :         columnHead.allocate(2);
    9043           44 :         columnWidth.allocate(2);
    9044           44 :         columnWidth = 14; // array assignment - same for all columns
    9045           44 :         tableBody.allocate(2, 14);
    9046              : 
    9047           44 :         switch (unitsStyle_cur) {
    9048            4 :         case UnitsStyle::JtoKWH: {
    9049            4 :             columnHead(1) = "Electricity [kWh]";
    9050            4 :         } break;
    9051            2 :         case UnitsStyle::InchPound: {
    9052            2 :             columnHead(1) = "Electricity [kBtu]";
    9053            2 :         } break;
    9054            1 :         case UnitsStyle::InchPoundExceptElectricity: {
    9055            1 :             columnHead(1) = "Electricity [kWh]";
    9056            1 :         } break;
    9057           37 :         default: {
    9058           37 :             columnHead(1) = "Electricity [GJ]";
    9059           37 :         } break;
    9060              :         }
    9061           44 :         columnHead(2) = "Percent Electricity [%]";
    9062              : 
    9063           44 :         rowHead(1) = "Fuel-Fired Power Generation";
    9064           44 :         rowHead(2) = "High Temperature Geothermal*";
    9065           44 :         rowHead(3) = "Photovoltaic Power";
    9066           44 :         rowHead(4) = "Wind Power";
    9067           44 :         rowHead(5) = "Power Conversion";
    9068           44 :         rowHead(6) = "Net Decrease in On-Site Storage";
    9069           44 :         rowHead(7) = "Total On-Site Electric Sources";
    9070           44 :         rowHead(8) = "";
    9071           44 :         rowHead(9) = "Electricity Coming From Utility";
    9072           44 :         rowHead(10) = "Surplus Electricity Going To Utility";
    9073           44 :         rowHead(11) = "Net Electricity From Utility";
    9074           44 :         rowHead(12) = "";
    9075           44 :         rowHead(13) = "Total On-Site and Utility Electric Sources";
    9076           44 :         rowHead(14) = "Total Electricity End Uses";
    9077              : 
    9078           44 :         tableBody = "";
    9079              : 
    9080              :         // show annual values
    9081           44 :         tableBody(1, 1) = RealToStr(ort->gatherPowerFuelFireGen, 3);
    9082           44 :         tableBody(1, 2) = RealToStr(ort->gatherPowerHTGeothermal, 3);
    9083           44 :         tableBody(1, 3) = RealToStr(ort->gatherPowerPV, 3);
    9084           44 :         if (produceTabular) {
    9085           42 :             PreDefTableEntry(state, state.dataOutRptPredefined->pdchLeedRenAnGen, "Photovoltaic", unconvert_ipExceptElec * ort->gatherPowerPV, 2);
    9086              :         }
    9087           44 :         tableBody(1, 4) = RealToStr(ort->gatherPowerWind, 3);
    9088           44 :         if (produceTabular) {
    9089           42 :             PreDefTableEntry(state, state.dataOutRptPredefined->pdchLeedRenAnGen, "Wind", unconvert_ipExceptElec * ort->gatherPowerWind, 2);
    9090              :         }
    9091           44 :         tableBody(1, 5) = RealToStr(ort->gatherPowerConversion, 3);
    9092           44 :         tableBody(1, 6) = RealToStr(ort->OverallNetEnergyFromStorage, 3);
    9093           44 :         tableBody(1, 7) = RealToStr(ort->gatherElecProduced, 3);
    9094           44 :         tableBody(1, 9) = RealToStr(ort->gatherElecPurchased, 3);
    9095           44 :         tableBody(1, 10) = RealToStr(ort->gatherElecSurplusSold, 3);
    9096           44 :         tableBody(1, 11) = RealToStr(ort->gatherElecPurchased - ort->gatherElecSurplusSold, 3);
    9097           44 :         tableBody(1, 13) = RealToStr(ort->gatherElecProduced + (ort->gatherElecPurchased - ort->gatherElecSurplusSold), 3);
    9098           44 :         tableBody(1, 14) = RealToStr(collapsedTotal(1), 3);
    9099              : 
    9100              :         // show annual percentages
    9101           44 :         if (collapsedTotal(1) > 0) {
    9102            5 :             tableBody(2, 1) = RealToStr(100.0 * ort->gatherPowerFuelFireGen / collapsedTotal(1), 2);
    9103            5 :             tableBody(2, 2) = RealToStr(100.0 * ort->gatherPowerHTGeothermal / collapsedTotal(1), 2);
    9104            5 :             tableBody(2, 3) = RealToStr(100.0 * ort->gatherPowerPV / collapsedTotal(1), 2);
    9105            5 :             tableBody(2, 4) = RealToStr(100.0 * ort->gatherPowerWind / collapsedTotal(1), 2);
    9106            5 :             tableBody(2, 5) = RealToStr(100.0 * ort->gatherPowerConversion / collapsedTotal(1), 2);
    9107            5 :             tableBody(2, 6) = RealToStr(100.0 * ort->OverallNetEnergyFromStorage / collapsedTotal(1), 2);
    9108            5 :             tableBody(2, 7) = RealToStr(100.0 * ort->gatherElecProduced / collapsedTotal(1), 2);
    9109            5 :             tableBody(2, 9) = RealToStr(100.0 * ort->gatherElecPurchased / collapsedTotal(1), 2);
    9110            5 :             tableBody(2, 10) = RealToStr(100.0 * ort->gatherElecSurplusSold / collapsedTotal(1), 2);
    9111            5 :             tableBody(2, 11) = RealToStr(100.0 * (ort->gatherElecPurchased - ort->gatherElecSurplusSold) / collapsedTotal(1), 2);
    9112            5 :             tableBody(2, 13) =
    9113           10 :                 RealToStr(100.0 * (ort->gatherElecProduced + (ort->gatherElecPurchased - ort->gatherElecSurplusSold)) / collapsedTotal(1), 2);
    9114            5 :             tableBody(2, 14) = RealToStr(100.0, 2);
    9115              :         }
    9116              : 
    9117              :         // heading for the entire sub-table
    9118           44 :         if (ort->displayTabularBEPS) {
    9119           44 :             if (produceTabular) {
    9120           42 :                 WriteSubtitle(state, "Electric Loads Satisfied");
    9121           42 :                 WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
    9122              :             }
    9123           44 :             if (produceSQLite) {
    9124           42 :                 if (state.dataSQLiteProcedures->sqlite) {
    9125            7 :                     state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
    9126              :                         tableBody, rowHead, columnHead, "AnnualBuildingUtilityPerformanceSummary", "Entire Facility", "Electric Loads Satisfied");
    9127              :                 }
    9128              :             }
    9129           44 :             if (produceTabular) {
    9130           42 :                 if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
    9131            0 :                     state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(
    9132              :                         tableBody, rowHead, columnHead, "AnnualBuildingUtilityPerformanceSummary", "Entire Facility", "Electric Loads Satisfied");
    9133              :                 }
    9134              :             }
    9135              :         }
    9136              : 
    9137              :         //---- On-Site Thermal Sources Sub-Table
    9138           44 :         rowHead.allocate(7);
    9139           44 :         columnHead.allocate(2);
    9140           44 :         columnWidth.allocate(2);
    9141           44 :         columnWidth = 14; // array assignment - same for all columns
    9142           44 :         tableBody.allocate(2, 7);
    9143              : 
    9144           44 :         switch (unitsStyle_cur) {
    9145            4 :         case UnitsStyle::JtoKWH: {
    9146            4 :             columnHead(1) = "Heat [kWh]";
    9147            4 :         } break;
    9148            2 :         case UnitsStyle::InchPound: {
    9149            2 :             columnHead(1) = "Heat [kBtu]";
    9150            2 :         } break;
    9151            1 :         case UnitsStyle::InchPoundExceptElectricity: {
    9152            1 :             columnHead(1) = "Heat [kBtu]";
    9153            1 :         } break;
    9154           37 :         default: {
    9155           37 :             columnHead(1) = "Heat [GJ]";
    9156           37 :         } break;
    9157              :         }
    9158              : 
    9159           44 :         columnHead(2) = "Percent Heat [%]";
    9160              : 
    9161           44 :         rowHead(1) = "Water-Side Heat Recovery";
    9162           44 :         rowHead(2) = "Air to Air Heat Recovery for Cooling";
    9163           44 :         rowHead(3) = "Air to Air Heat Recovery for Heating";
    9164           44 :         rowHead(4) = "High-Temperature Geothermal*";
    9165           44 :         rowHead(5) = "Solar Water Thermal";
    9166           44 :         rowHead(6) = "Solar Air Thermal";
    9167           44 :         rowHead(7) = "Total On-Site Thermal Sources";
    9168              : 
    9169           44 :         tableBody = "";
    9170              : 
    9171           44 :         if (iUnitSystem == 0) {
    9172           42 :             gtWaterHeatRecovery = ort->gatherWaterHeatRecovery;
    9173           42 :             gtAirHeatRecoveryCool = ort->gatherAirHeatRecoveryCool;
    9174           42 :             gtAirHeatRecoveryHeat = ort->gatherAirHeatRecoveryHeat;
    9175           42 :             gtHeatHTGeothermal = ort->gatherHeatHTGeothermal;
    9176           42 :             gtHeatSolarWater = ort->gatherHeatSolarWater;
    9177           42 :             gtHeatSolarAir = ort->gatherHeatSolarAir;
    9178              :         } else {
    9179            2 :             ort->gatherWaterHeatRecovery = gtWaterHeatRecovery;
    9180            2 :             ort->gatherAirHeatRecoveryCool = gtAirHeatRecoveryCool;
    9181            2 :             ort->gatherAirHeatRecoveryHeat = gtAirHeatRecoveryHeat;
    9182            2 :             ort->gatherHeatHTGeothermal = gtHeatHTGeothermal;
    9183            2 :             ort->gatherHeatSolarWater = gtHeatSolarWater;
    9184            2 :             ort->gatherHeatSolarAir = gtHeatSolarAir;
    9185              :         }
    9186              : 
    9187              :         // convert to GJ
    9188           44 :         ort->gatherWaterHeatRecovery /= largeConversionFactor;
    9189           44 :         ort->gatherAirHeatRecoveryCool /= largeConversionFactor;
    9190           44 :         ort->gatherAirHeatRecoveryHeat /= largeConversionFactor;
    9191           44 :         ort->gatherHeatHTGeothermal /= largeConversionFactor;
    9192           44 :         ort->gatherHeatSolarWater /= largeConversionFactor;
    9193           44 :         ort->gatherHeatSolarAir /= largeConversionFactor;
    9194              : 
    9195              :         // determine total on site heat
    9196           44 :         Real64 const totalOnsiteHeat = ort->gatherWaterHeatRecovery + ort->gatherAirHeatRecoveryCool + ort->gatherAirHeatRecoveryHeat +
    9197           44 :                                        ort->gatherHeatHTGeothermal + ort->gatherHeatSolarWater + ort->gatherHeatSolarAir;
    9198              : 
    9199              :         // show annual values
    9200           44 :         tableBody(1, 1) = RealToStr(ort->gatherWaterHeatRecovery, 2);
    9201           44 :         tableBody(1, 2) = RealToStr(ort->gatherAirHeatRecoveryCool, 2);
    9202           44 :         tableBody(1, 3) = RealToStr(ort->gatherAirHeatRecoveryHeat, 2);
    9203           44 :         tableBody(1, 4) = RealToStr(ort->gatherHeatHTGeothermal, 2);
    9204           44 :         tableBody(1, 5) = RealToStr(ort->gatherHeatSolarWater, 2);
    9205           44 :         tableBody(1, 6) = RealToStr(ort->gatherHeatSolarAir, 2);
    9206           44 :         tableBody(1, 7) = RealToStr(totalOnsiteHeat, 2);
    9207              : 
    9208           44 :         if (totalOnsiteHeat > 0) {
    9209            0 :             tableBody(2, 1) = RealToStr(100.0 * ort->gatherWaterHeatRecovery / totalOnsiteHeat, 2);
    9210            0 :             tableBody(2, 2) = RealToStr(100.0 * ort->gatherAirHeatRecoveryCool / totalOnsiteHeat, 2);
    9211            0 :             tableBody(2, 3) = RealToStr(100.0 * ort->gatherAirHeatRecoveryHeat / totalOnsiteHeat, 2);
    9212            0 :             tableBody(2, 4) = RealToStr(100.0 * ort->gatherHeatHTGeothermal / totalOnsiteHeat, 2);
    9213            0 :             tableBody(2, 5) = RealToStr(100.0 * ort->gatherHeatSolarWater / totalOnsiteHeat, 2);
    9214            0 :             tableBody(2, 6) = RealToStr(100.0 * ort->gatherHeatSolarAir / totalOnsiteHeat, 2);
    9215            0 :             tableBody(2, 7) = RealToStr(100.0, 2);
    9216              :         }
    9217              : 
    9218              :         // heading for the entire sub-table
    9219           44 :         if (ort->displayTabularBEPS) {
    9220           44 :             if (produceTabular) {
    9221           42 :                 WriteSubtitle(state, "On-Site Thermal Sources");
    9222           42 :                 WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
    9223              :             }
    9224           44 :             if (produceSQLite) {
    9225           42 :                 if (state.dataSQLiteProcedures->sqlite) {
    9226            7 :                     state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
    9227              :                         tableBody, rowHead, columnHead, "AnnualBuildingUtilityPerformanceSummary", "Entire Facility", "On-Site Thermal Sources");
    9228              :                 }
    9229              :             }
    9230           44 :             if (produceTabular) {
    9231           42 :                 if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
    9232            0 :                     state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(
    9233              :                         tableBody, rowHead, columnHead, "AnnualBuildingUtilityPerformanceSummary", "Entire Facility", "On-Site Thermal Sources");
    9234              :                 }
    9235              :             }
    9236              :         }
    9237              : 
    9238              :         //---- Water Loads Sub-Table
    9239              :         // As of 12/8/2003 decided to not include this sub-table to wait
    9240              :         // until water use is implemented in EnergyPlus before displaying
    9241              :         // the table. Implementing water end-uses makes sense for EnergyPlus
    9242              :         // but since they are not really implemented as of December 2003 the
    9243              :         // table would be all zeros.  Recommendation to exclude this table
    9244              :         // for now made by Glazer and Crawley.
    9245              :         // Aug 2006, adding table in with implementation of water system, BGriffith
    9246           44 :         rowHead.allocate(13);
    9247           44 :         columnHead.allocate(2);
    9248           44 :         columnWidth.allocate(2);
    9249           44 :         columnWidth = 14; // array assignment - same for all columns
    9250           44 :         tableBody.allocate(2, 13);
    9251           44 :         switch (unitsStyle_cur) {
    9252            4 :         case UnitsStyle::JtoKWH: {
    9253            4 :             columnHead(1) = "Water [m3]";
    9254            4 :         } break;
    9255            2 :         case UnitsStyle::InchPound: {
    9256            2 :             columnHead(1) = "Water [gal]";
    9257            2 :         } break;
    9258            1 :         case UnitsStyle::InchPoundExceptElectricity: {
    9259            1 :             columnHead(1) = "Water [gal]";
    9260            1 :         } break;
    9261           37 :         default: {
    9262           37 :             columnHead(1) = "Water [m3]";
    9263           37 :         } break;
    9264              :         }
    9265              : 
    9266           44 :         columnHead(2) = "Percent Water [%]";
    9267           44 :         rowHead(1) = "Rainwater Collection";
    9268           44 :         rowHead(2) = "Condensate Collection";
    9269           44 :         rowHead(3) = "Groundwater Well";
    9270           44 :         rowHead(4) = "Total On Site Water Sources";
    9271           44 :         rowHead(5) = "-";
    9272           44 :         rowHead(6) = "Initial Storage";
    9273           44 :         rowHead(7) = "Final Storage";
    9274           44 :         rowHead(8) = "Change in Storage";
    9275           44 :         rowHead(9) = "-";
    9276           44 :         rowHead(10) = "Water Supplied by Utility";
    9277           44 :         rowHead(11) = "-";
    9278           44 :         rowHead(12) = "Total On Site, Change in Storage, and Utility Water Sources";
    9279           44 :         rowHead(13) = "Total Water End Uses";
    9280           44 :         tableBody = "-";
    9281              : 
    9282           44 :         Real64 const totalOnsiteWater = ort->gatherRainWater + ort->gatherCondensate + ort->gatherWellwater;
    9283              : 
    9284              :         //  ! show annual values
    9285           44 :         tableBody(1, 1) = RealToStr(ort->gatherRainWater / waterConversionFactor, 2);
    9286           44 :         tableBody(1, 2) = RealToStr(ort->gatherCondensate / waterConversionFactor, 2);
    9287           44 :         tableBody(1, 3) = RealToStr(ort->gatherWellwater / waterConversionFactor, 2);
    9288           44 :         tableBody(1, 4) = RealToStr(totalOnsiteWater / waterConversionFactor, 2);
    9289              : 
    9290           44 :         Real64 initialStorage = 0.0;
    9291           44 :         Real64 finalStorage = 0.0;
    9292           44 :         Real64 StorageChange = 0.0;
    9293           44 :         if (allocated(state.dataWaterData->WaterStorage)) {
    9294            0 :             initialStorage = sum(state.dataWaterData->WaterStorage, &DataWater::StorageTankDataStruct::InitialVolume);
    9295            0 :             finalStorage = sum(state.dataWaterData->WaterStorage, &DataWater::StorageTankDataStruct::ThisTimeStepVolume);
    9296            0 :             StorageChange = initialStorage - finalStorage;
    9297              :         }
    9298           44 :         tableBody(1, 6) = RealToStr(initialStorage / waterConversionFactor, 2);
    9299           44 :         tableBody(1, 7) = RealToStr(finalStorage / waterConversionFactor, 2);
    9300           44 :         tableBody(1, 8) = RealToStr(StorageChange / waterConversionFactor, 2);
    9301              : 
    9302           44 :         Real64 const totalWater = totalOnsiteWater + ort->gatherMains + StorageChange;
    9303              : 
    9304           44 :         tableBody(1, 10) = RealToStr(ort->gatherMains / waterConversionFactor, 2);
    9305           44 :         tableBody(1, 12) = RealToStr(totalWater / waterConversionFactor, 2);
    9306           44 :         tableBody(1, 13) = RealToStr(ort->gatherWaterEndUseTotal / waterConversionFactor, 2);
    9307              : 
    9308           44 :         if (ort->gatherWaterEndUseTotal > 0) {
    9309            0 :             tableBody(2, 1) = RealToStr(100.0 * ort->gatherRainWater / ort->gatherWaterEndUseTotal, 2);
    9310            0 :             tableBody(2, 2) = RealToStr(100.0 * ort->gatherCondensate / ort->gatherWaterEndUseTotal, 2);
    9311            0 :             tableBody(2, 3) = RealToStr(100.0 * ort->gatherWellwater / ort->gatherWaterEndUseTotal, 2);
    9312            0 :             tableBody(2, 4) = RealToStr(100.0 * totalOnsiteWater / ort->gatherWaterEndUseTotal, 2);
    9313            0 :             tableBody(2, 6) = RealToStr(100.0 * initialStorage / ort->gatherWaterEndUseTotal, 2);
    9314            0 :             tableBody(2, 7) = RealToStr(100.0 * finalStorage / ort->gatherWaterEndUseTotal, 2);
    9315            0 :             tableBody(2, 8) = RealToStr(100.0 * StorageChange / ort->gatherWaterEndUseTotal, 2);
    9316              : 
    9317            0 :             tableBody(2, 10) = RealToStr(100.0 * ort->gatherMains / ort->gatherWaterEndUseTotal, 2);
    9318              : 
    9319            0 :             tableBody(2, 12) = RealToStr(100.0 * totalWater / ort->gatherWaterEndUseTotal, 2);
    9320            0 :             tableBody(2, 13) = RealToStr(100.0, 2);
    9321              :         }
    9322              : 
    9323              :         //  ! heading for the entire sub-table
    9324           44 :         if (ort->displayTabularBEPS) {
    9325           44 :             if (produceTabular) {
    9326           42 :                 WriteSubtitle(state, "Water Source Summary");
    9327           42 :                 WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
    9328              :             }
    9329           44 :             if (produceSQLite) {
    9330           42 :                 if (state.dataSQLiteProcedures->sqlite) {
    9331            7 :                     state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
    9332              :                         tableBody, rowHead, columnHead, "AnnualBuildingUtilityPerformanceSummary", "Entire Facility", "Water Source Summary");
    9333              :                 }
    9334              :             }
    9335           44 :             if (produceTabular) {
    9336           42 :                 if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
    9337            0 :                     state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(
    9338              :                         tableBody, rowHead, columnHead, "AnnualBuildingUtilityPerformanceSummary", "Entire Facility", "Water Source Summary");
    9339              :                 }
    9340              :             }
    9341              : 
    9342              :             //---- Comfort and Setpoint Not Met Sub-Table
    9343           44 :             rowHead.allocate(2);
    9344           44 :             columnHead.allocate(1);
    9345           44 :             columnWidth.allocate(1);
    9346           44 :             columnWidth = 14; // array assignment - same for all columns
    9347           44 :             tableBody.allocate(1, 2);
    9348              : 
    9349           44 :             if (produceTabular) {
    9350           84 :                 WriteSubtitle(state, "Setpoint Not Met Criteria");
    9351              :             }
    9352              : 
    9353           44 :             std::string const curNameWithSIUnits = "Degrees [deltaC]";
    9354           44 :             if (unitsStyle_cur == OutputReportTabular::UnitsStyle::InchPound ||
    9355           42 :                 unitsStyle_cur == OutputReportTabular::UnitsStyle::InchPoundExceptElectricity) {
    9356            3 :                 int indexUnitConv = -1;
    9357            3 :                 std::string curNameAndUnits;
    9358            3 :                 LookupSItoIP(state, curNameWithSIUnits, indexUnitConv, curNameAndUnits);
    9359            3 :                 columnHead(1) = curNameAndUnits;
    9360            3 :             } else {
    9361           41 :                 columnHead(1) = curNameWithSIUnits;
    9362              :             }
    9363              : 
    9364           44 :             rowHead(1) = "Tolerance for Zone Heating Setpoint Not Met Time";
    9365           44 :             rowHead(2) = "Tolerance for Zone Cooling Setpoint Not Met Time";
    9366              : 
    9367           44 :             if (!(unitsStyle_cur == OutputReportTabular::UnitsStyle::InchPound ||
    9368           42 :                   unitsStyle_cur == OutputReportTabular::UnitsStyle::InchPoundExceptElectricity)) {
    9369           41 :                 tableBody(1, 1) = RealToStr(std::abs(state.dataHVACGlobal->deviationFromSetPtThresholdHtg), 2);
    9370           41 :                 tableBody(1, 2) = RealToStr(state.dataHVACGlobal->deviationFromSetPtThresholdClg, 2);
    9371              :             } else {
    9372            3 :                 int indexUnitConv = -1;
    9373            3 :                 std::string curNameAndUnits;
    9374            3 :                 LookupSItoIP(state, curNameWithSIUnits, indexUnitConv, curNameAndUnits);
    9375            3 :                 tableBody(1, 1) = RealToStr(ConvertIPdelta(state, indexUnitConv, std::abs(state.dataHVACGlobal->deviationFromSetPtThresholdHtg)), 2);
    9376            3 :                 tableBody(1, 2) = RealToStr(ConvertIPdelta(state, indexUnitConv, state.dataHVACGlobal->deviationFromSetPtThresholdClg), 2);
    9377            3 :             }
    9378              : 
    9379           44 :             if (produceTabular) {
    9380           42 :                 WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
    9381              :             }
    9382           44 :             if (produceSQLite) {
    9383           42 :                 if (state.dataSQLiteProcedures->sqlite) {
    9384            7 :                     state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
    9385              :                         tableBody, rowHead, columnHead, "AnnualBuildingUtilityPerformanceSummary", "Entire Facility", "Setpoint Not Met Criteria");
    9386              :                 }
    9387              :             }
    9388           44 :             if (produceTabular) {
    9389           42 :                 if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
    9390            0 :                     state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(
    9391              :                         tableBody, rowHead, columnHead, "AnnualBuildingUtilityPerformanceSummary", "Entire Facility", "Setpoint Not Met Criteria");
    9392              :                 }
    9393              :             }
    9394           44 :         }
    9395              : 
    9396           44 :         rowHead.allocate(3);
    9397           44 :         columnHead.allocate(1);
    9398           44 :         columnWidth.allocate(1);
    9399           44 :         columnWidth = 14; // array assignment - same for all columns
    9400           44 :         tableBody.allocate(1, 3);
    9401              : 
    9402           44 :         if (ort->displayTabularBEPS) {
    9403           44 :             if (produceTabular) {
    9404           84 :                 WriteSubtitle(state, "Comfort and Setpoint Not Met Summary");
    9405              :             }
    9406              :         }
    9407              : 
    9408           44 :         columnHead(1) = "Facility [Hours]";
    9409              : 
    9410           44 :         rowHead(1) = "Time Setpoint Not Met During Occupied Heating";
    9411           44 :         rowHead(2) = "Time Setpoint Not Met During Occupied Cooling";
    9412           44 :         rowHead(3) = "Time Not Comfortable Based on Simple ASHRAE 55-2004";
    9413              : 
    9414           44 :         tableBody(1, 1) = RealToStr(state.dataOutRptPredefined->TotalNotMetHeatingOccupiedForABUPS, 2);
    9415           44 :         tableBody(1, 2) = RealToStr(state.dataOutRptPredefined->TotalNotMetCoolingOccupiedForABUPS, 2);
    9416           44 :         if (produceTabular) {
    9417           84 :             PreDefTableEntry(state,
    9418           42 :                              state.dataOutRptPredefined->pdchLeedAmData,
    9419              :                              "Number of hours heating loads not met",
    9420           84 :                              RealToStr(state.dataOutRptPredefined->TotalNotMetHeatingOccupiedForABUPS, 2));
    9421           84 :             PreDefTableEntry(state,
    9422           42 :                              state.dataOutRptPredefined->pdchLeedAmData,
    9423              :                              "Number of hours cooling loads not met",
    9424           84 :                              RealToStr(state.dataOutRptPredefined->TotalNotMetCoolingOccupiedForABUPS, 2));
    9425           84 :             PreDefTableEntry(state,
    9426           42 :                              state.dataOutRptPredefined->pdchLeedAmData,
    9427              :                              "Number of hours not met",
    9428           84 :                              RealToStr(state.dataOutRptPredefined->TotalNotMetOccupiedForABUPS, 2));
    9429              :         }
    9430           44 :         tableBody(1, 3) = RealToStr(state.dataOutRptPredefined->TotalTimeNotSimpleASH55EitherForABUPS, 2);
    9431              : 
    9432           44 :         if (ort->displayTabularBEPS) {
    9433           44 :             if (produceTabular) {
    9434           42 :                 WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
    9435              :             }
    9436           44 :             if (produceSQLite) {
    9437           42 :                 if (state.dataSQLiteProcedures->sqlite) {
    9438            7 :                     state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(tableBody,
    9439              :                                                                                        rowHead,
    9440              :                                                                                        columnHead,
    9441              :                                                                                        "AnnualBuildingUtilityPerformanceSummary",
    9442              :                                                                                        "Entire Facility",
    9443              :                                                                                        "Comfort and Setpoint Not Met Summary");
    9444              :                 }
    9445              :             }
    9446           44 :             if (produceTabular) {
    9447           42 :                 if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
    9448            0 :                     state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(tableBody,
    9449              :                                                                                                           rowHead,
    9450              :                                                                                                           columnHead,
    9451              :                                                                                                           "AnnualBuildingUtilityPerformanceSummary",
    9452              :                                                                                                           "Entire Facility",
    9453              :                                                                                                           "Comfort and Setpoint Not Met Summary");
    9454              :                 }
    9455              :             }
    9456              :         }
    9457              :     }
    9458              :     //---- Control Summary Sub-Table
    9459              : 
    9460              :     //---- End Notes
    9461           42 :     if (ort->displayTabularBEPS) {
    9462           84 :         WriteTextLine(state, "Note 1: An asterisk (*) indicates that the feature is not yet implemented.");
    9463              :     }
    9464           42 : }
    9465              : 
    9466            8 : std::string ResourceWarningMessage(std::string const &resource)
    9467              : {
    9468            8 :     return "In the Annual Building Utility Performance Summary Report the total row does not match the sum of the column for: " + resource;
    9469              : }
    9470              : 
    9471           49 : Real64 WaterConversionFunct(Real64 WaterTotal, Real64 ConversionFactor)
    9472              : {
    9473           49 :     return WaterTotal / ConversionFactor;
    9474              : }
    9475              : 
    9476           88 : void writeBEPSEndUseBySubCatOrSpaceType(EnergyPlusData &state,
    9477              :                                         EndUseSubTableType tableType,
    9478              :                                         Array2D<Real64> &endUseSubOther,
    9479              :                                         Array2D<Real64> &collapsedEndUse,
    9480              :                                         Array3D<Real64> &collapsedEndUseSubTable,
    9481              :                                         Array1D_bool &needOtherRow,
    9482              :                                         const UnitsStyle unitsStyle_cur,
    9483              :                                         const bool produceTabular,
    9484              :                                         const bool produceSQLite)
    9485              : {
    9486           88 :     auto const &ort = state.dataOutRptTab;
    9487           88 :     auto &op = state.dataOutputProcessor;
    9488           88 :     constexpr int numCol = 15;
    9489           88 :     Array1D_string columnHead;
    9490           88 :     Array1D_int columnWidth;
    9491           88 :     columnHead.allocate(numCol);
    9492           88 :     columnWidth.allocate(numCol);
    9493         1408 :     for (int col = 1; col <= numCol; ++col) {
    9494         1320 :         columnWidth(col) = 10; // array assignment - same for all columns
    9495              :     }
    9496           88 :     switch (unitsStyle_cur) {
    9497            8 :     case UnitsStyle::JtoKWH: {
    9498            8 :         columnHead(2) = "Electricity [kWh]";
    9499            8 :         columnHead(3) = "Natural Gas [kWh]";
    9500            8 :         columnHead(4) = "Gasoline [kWh]";
    9501            8 :         columnHead(5) = "Diesel [kWh]";
    9502            8 :         columnHead(6) = "Coal [kWh]";
    9503            8 :         columnHead(7) = "Fuel Oil No 1 [kWh]";
    9504            8 :         columnHead(8) = "Fuel Oil No 2 [kWh]";
    9505            8 :         columnHead(9) = "Propane [kWh]";
    9506            8 :         columnHead(10) = "Other Fuel 1 [kWh]";
    9507            8 :         columnHead(11) = "Other Fuel 2 [kWh]";
    9508            8 :         columnHead(12) = "District Cooling [kWh]";
    9509            8 :         columnHead(13) = "District Heating Water [kWh]";
    9510            8 :         columnHead(14) = "District Heating Steam [kWh]";
    9511            8 :         columnHead(15) = "Water [m3]";
    9512            8 :     } break;
    9513            4 :     case UnitsStyle::InchPound: {
    9514            4 :         columnHead(2) = "Electricity [kBtu]";
    9515            4 :         columnHead(3) = "Natural Gas [kBtu]";
    9516            4 :         columnHead(4) = "Gasoline [kBtu]";
    9517            4 :         columnHead(5) = "Diesel [kBtu]";
    9518            4 :         columnHead(6) = "Coal [kBtu]";
    9519            4 :         columnHead(7) = "Fuel Oil No 1 [kBtu]";
    9520            4 :         columnHead(8) = "Fuel Oil No 2 [kBtu]";
    9521            4 :         columnHead(9) = "Propane [kBtu]";
    9522            4 :         columnHead(10) = "Other Fuel 1 [kBtu]";
    9523            4 :         columnHead(11) = "Other Fuel 2 [kBtu]";
    9524            4 :         columnHead(12) = "District Cooling [kBtu]";
    9525            4 :         columnHead(13) = "District Heating Water [kBtu]";
    9526            4 :         columnHead(14) = "District Heating Steam [kBtu]";
    9527            4 :         columnHead(15) = "Water [gal]";
    9528            4 :     } break;
    9529            2 :     case UnitsStyle::InchPoundExceptElectricity: {
    9530            2 :         columnHead(2) = "Electricity [kWh]";
    9531            2 :         columnHead(3) = "Natural Gas [kBtu]";
    9532            2 :         columnHead(4) = "Gasoline [kBtu]";
    9533            2 :         columnHead(5) = "Diesel [kBtu]";
    9534            2 :         columnHead(6) = "Coal [kBtu]";
    9535            2 :         columnHead(7) = "Fuel Oil No 1 [kBtu]";
    9536            2 :         columnHead(8) = "Fuel Oil No 2 [kBtu]";
    9537            2 :         columnHead(9) = "Propane [kBtu]";
    9538            2 :         columnHead(10) = "Other Fuel 1 [kBtu]";
    9539            2 :         columnHead(11) = "Other Fuel 2 [kBtu]";
    9540            2 :         columnHead(12) = "District Cooling [kBtu]";
    9541            2 :         columnHead(13) = "District Heating Water [kBtu]";
    9542            2 :         columnHead(14) = "District Heating Steam [kBtu]";
    9543            2 :         columnHead(15) = "Water [gal]";
    9544            2 :     } break;
    9545           74 :     default: {
    9546           74 :         columnHead(2) = "Electricity [GJ]";
    9547           74 :         columnHead(3) = "Natural Gas [GJ]";
    9548           74 :         columnHead(4) = "Gasoline [GJ]";
    9549           74 :         columnHead(5) = "Diesel [GJ]";
    9550           74 :         columnHead(6) = "Coal [GJ]";
    9551           74 :         columnHead(7) = "Fuel Oil No 1 [GJ]";
    9552           74 :         columnHead(8) = "Fuel Oil No 2 [GJ]";
    9553           74 :         columnHead(9) = "Propane [GJ]";
    9554           74 :         columnHead(10) = "Other Fuel 1 [GJ]";
    9555           74 :         columnHead(11) = "Other Fuel 2 [GJ]";
    9556           74 :         columnHead(12) = "District Cooling [GJ]";
    9557           74 :         columnHead(13) = "District Heating Water [GJ]";
    9558           74 :         columnHead(14) = "District Heating Steam [GJ]";
    9559           74 :         columnHead(15) = "Water [m3]";
    9560           74 :     } break;
    9561              :     }
    9562              : 
    9563           88 :     int numSubCatOrTypes = 0;
    9564           88 :     int numRows = 0;
    9565           88 :     if (tableType == EndUseSubTableType::BySubCategory) {
    9566           44 :         columnHead(1) = "Subcategory";
    9567           44 :     } else if (tableType == EndUseSubTableType::BySpaceType) {
    9568           44 :         columnHead(1) = "Space Type";
    9569              :     }
    9570              : 
    9571              :     // determine number of rows and if subcategories add up to the total
    9572              :     // if not, determine the difference for the 'other' row
    9573         1320 :     for (int i = 1; i <= static_cast<int>(Constant::EndUse::Num); ++i) {
    9574         1232 :         needOtherRow(i) = false; // set array to all false assuming no other rows are needed
    9575              :     }
    9576         1320 :     for (int iResource = 1; iResource <= 14; ++iResource) {
    9577        18480 :         for (int jEndUse = 1; jEndUse <= static_cast<int>(Constant::EndUse::Num); ++jEndUse) {
    9578        17248 :             if (tableType == EndUseSubTableType::BySubCategory) {
    9579         8624 :                 numSubCatOrTypes = op->EndUseCategory(jEndUse).NumSubcategories;
    9580         8624 :             } else if (tableType == EndUseSubTableType::BySpaceType) {
    9581         8624 :                 numSubCatOrTypes = op->EndUseCategory(jEndUse).numSpaceTypes;
    9582              :             }
    9583        17248 :             if (numSubCatOrTypes > 0) {
    9584              :                 // set the value to the total for the end use
    9585         2786 :                 endUseSubOther(iResource, jEndUse) = collapsedEndUse(iResource, jEndUse);
    9586              :                 // subtract off each sub end use category value
    9587         5656 :                 for (int kEndUseSub = 1; kEndUseSub <= numSubCatOrTypes; ++kEndUseSub) {
    9588         2870 :                     endUseSubOther(iResource, jEndUse) -= collapsedEndUseSubTable(kEndUseSub, jEndUse, iResource);
    9589              :                 }
    9590              :                 // if just a small value remains set it to zero
    9591         2786 :                 if (std::abs(endUseSubOther(iResource, jEndUse)) > 0.01) {
    9592            0 :                     needOtherRow(jEndUse) = true;
    9593              :                 } else {
    9594         2786 :                     endUseSubOther(iResource, jEndUse) = 0.0;
    9595              :                 }
    9596              :             } else {
    9597        14462 :                 endUseSubOther(iResource, jEndUse) = 0.0;
    9598              :             }
    9599              :         }
    9600              :     }
    9601              : 
    9602         1320 :     for (int jEndUse = 1; jEndUse <= static_cast<int>(Constant::EndUse::Num); ++jEndUse) {
    9603         1232 :         if (tableType == EndUseSubTableType::BySubCategory) {
    9604          616 :             numSubCatOrTypes = op->EndUseCategory(jEndUse).NumSubcategories;
    9605          616 :         } else if (tableType == EndUseSubTableType::BySpaceType) {
    9606          616 :             numSubCatOrTypes = op->EndUseCategory(jEndUse).numSpaceTypes;
    9607              :         }
    9608         1232 :         if (numSubCatOrTypes > 0) {
    9609          404 :             for (int kEndUseSub = 1; kEndUseSub <= numSubCatOrTypes; ++kEndUseSub) {
    9610          205 :                 ++numRows;
    9611              :             }
    9612          199 :             if (needOtherRow(jEndUse)) {
    9613            0 :                 ++numRows;
    9614              :             }
    9615              :         } else {
    9616         1033 :             ++numRows;
    9617              :         }
    9618              :     }
    9619              :     // all arrays are in the format: (row, column)
    9620          176 :     Array1D_string rowHead;
    9621          176 :     Array2D_string tableBody;
    9622           88 :     rowHead.allocate(numRows);
    9623           88 :     tableBody.allocate(numCol, numRows); // TODO: this appears to be (column, row)...
    9624         1408 :     for (int col = 1; col <= numCol; ++col) {
    9625        19890 :         for (int row = 1; row <= numRows; ++row) {
    9626        18570 :             rowHead(row) = "";
    9627        18570 :             tableBody(col, row) = "";
    9628              :         }
    9629              :     }
    9630              : 
    9631              :     // Build row head and subcategories columns
    9632              :     {
    9633           88 :         int i = 1;
    9634         1320 :         for (int jEndUse = 1; jEndUse <= static_cast<int>(Constant::EndUse::Num); ++jEndUse) {
    9635         1232 :             if (tableType == EndUseSubTableType::BySubCategory) {
    9636          616 :                 numSubCatOrTypes = op->EndUseCategory(jEndUse).NumSubcategories;
    9637          616 :             } else if (tableType == EndUseSubTableType::BySpaceType) {
    9638          616 :                 numSubCatOrTypes = op->EndUseCategory(jEndUse).numSpaceTypes;
    9639              :             }
    9640         1232 :             rowHead(i) = op->EndUseCategory(jEndUse).DisplayName;
    9641         1232 :             if (numSubCatOrTypes > 0) {
    9642          404 :                 for (int kEndUseSub = 1; kEndUseSub <= numSubCatOrTypes; ++kEndUseSub) {
    9643          205 :                     if (tableType == EndUseSubTableType::BySubCategory) {
    9644          181 :                         tableBody(1, i) = op->EndUseCategory(jEndUse).SubcategoryName(kEndUseSub);
    9645           24 :                     } else if (tableType == EndUseSubTableType::BySpaceType) {
    9646           24 :                         tableBody(1, i) = op->EndUseCategory(jEndUse).spaceTypeName(kEndUseSub);
    9647              :                     }
    9648          205 :                     ++i;
    9649              :                 }
    9650              :                 // check if an 'other' row is needed
    9651          199 :                 if (needOtherRow(jEndUse)) {
    9652            0 :                     tableBody(1, i) = "Other";
    9653            0 :                     ++i;
    9654              :                 }
    9655              :             } else {
    9656         1033 :                 if (tableType == EndUseSubTableType::BySubCategory) {
    9657          441 :                     tableBody(1, i) = "General";
    9658          592 :                 } else if (tableType == EndUseSubTableType::BySpaceType) {
    9659          592 :                     tableBody(1, i) = "Unassigned";
    9660              :                 }
    9661         1033 :                 ++i;
    9662              :             }
    9663              :         }
    9664              :     }
    9665              : 
    9666         1320 :     for (int iResource = 1; iResource <= 14; ++iResource) {
    9667         1232 :         int i = 1;
    9668        18480 :         for (int jEndUse = 1; jEndUse <= static_cast<int>(Constant::EndUse::Num); ++jEndUse) {
    9669        17248 :             if (tableType == EndUseSubTableType::BySubCategory) {
    9670         8624 :                 numSubCatOrTypes = op->EndUseCategory(jEndUse).NumSubcategories;
    9671         8624 :             } else if (tableType == EndUseSubTableType::BySpaceType) {
    9672         8624 :                 numSubCatOrTypes = op->EndUseCategory(jEndUse).numSpaceTypes;
    9673              :             }
    9674        17248 :             if (numSubCatOrTypes > 0) {
    9675         5656 :                 for (int kEndUseSub = 1; kEndUseSub <= numSubCatOrTypes; ++kEndUseSub) {
    9676         2870 :                     tableBody(iResource + 1, i) = RealToStr(collapsedEndUseSubTable(kEndUseSub, jEndUse, iResource), 2);
    9677         2870 :                     ++i;
    9678              :                 }
    9679              :                 // put other
    9680         2786 :                 if (needOtherRow(jEndUse)) {
    9681            0 :                     tableBody(iResource + 1, i) = RealToStr(endUseSubOther(iResource, jEndUse), 2);
    9682            0 :                     ++i;
    9683              :                 }
    9684              :             } else {
    9685        14462 :                 tableBody(iResource + 1, i) = RealToStr(collapsedEndUse(iResource, jEndUse), 2);
    9686        14462 :                 ++i;
    9687              :             }
    9688              :         }
    9689              :     }
    9690              : 
    9691              :     // heading for the entire sub-table
    9692           88 :     if (ort->displayTabularBEPS) {
    9693           88 :         std::string subTableTitle;
    9694           88 :         if (tableType == EndUseSubTableType::BySubCategory) {
    9695           44 :             subTableTitle = "End Uses By Subcategory";
    9696           44 :         } else if (tableType == EndUseSubTableType::BySpaceType) {
    9697           44 :             subTableTitle = "End Uses By Space Type";
    9698              :         }
    9699           88 :         if (produceTabular) {
    9700           84 :             WriteSubtitle(state, subTableTitle);
    9701           84 :             WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
    9702              :         }
    9703           88 :         Array1D_string rowHeadTemp(rowHead);
    9704              :         // Before outputting to SQL, we forward fill the End use column (rowHead)
    9705              :         // for better sql queries
    9706           88 :         FillRowHead(rowHeadTemp);
    9707              : 
    9708         1326 :         for (int i = 1; i <= numRows; ++i) {
    9709         1238 :             rowHeadTemp(i) = rowHeadTemp(i) + ":" + tableBody(1, i);
    9710              :         }
    9711              : 
    9712              :         // Erase the SubCategory (first column), using slicing
    9713          616 :         Array2D_string tableBodyTemp(tableBody({2, _, _}, {_, _, _}));
    9714          352 :         Array1D_string columnHeadTemp(columnHead({2, _, _}));
    9715           88 :         if (produceSQLite) {
    9716           84 :             if (state.dataSQLiteProcedures->sqlite) {
    9717           14 :                 state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
    9718              :                     tableBodyTemp, rowHeadTemp, columnHeadTemp, "AnnualBuildingUtilityPerformanceSummary", "Entire Facility", subTableTitle);
    9719              :             }
    9720              :         }
    9721           88 :         if (produceTabular) {
    9722           84 :             if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
    9723            0 :                 state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(
    9724              :                     tableBodyTemp, rowHeadTemp, columnHeadTemp, "AnnualBuildingUtilityPerformanceSummary", "Entire Facility", subTableTitle);
    9725              :             }
    9726              :         }
    9727           88 :         rowHeadTemp.deallocate();
    9728           88 :         tableBodyTemp.deallocate();
    9729           88 :         columnHeadTemp.deallocate();
    9730           88 :     }
    9731          264 : }
    9732           41 : void WriteSourceEnergyEndUseSummary(EnergyPlusData &state)
    9733              : {
    9734              :     // SUBROUTINE INFORMATION:
    9735              :     //       AUTHOR         Mangesh Basarkar
    9736              :     //       DATE WRITTEN   September 2011
    9737              :     //       MODIFIED       March 2020, Dareum Nam; Disaggregated "Additional Fuel"
    9738              :     //       RE-ENGINEERED  na
    9739              : 
    9740              :     // PURPOSE OF THIS SUBROUTINE:
    9741              :     //   Take the gathered total and end use source energy meter data and structure
    9742              :     //   the results into a tabular report for output.
    9743              : 
    9744              :     // METHODOLOGY EMPLOYED:
    9745              :     //   Create arrays for the call to WriteTable and then call it.
    9746              : 
    9747           41 :     auto &ort = state.dataOutRptTab;
    9748              : 
    9749           41 :     if (!ort->displaySourceEnergyEndUseSummary) {
    9750            0 :         return;
    9751              :     }
    9752              : 
    9753              :     // all arrays are in the format: (row, column)
    9754           41 :     Array1D_string columnHead;
    9755           41 :     Array1D_int columnWidth;
    9756           41 :     Array1D_string rowHead;
    9757           41 :     Array2D_string tableBody;
    9758              : 
    9759              :     // all arrays are in the format: (row, columnm)
    9760           41 :     Array2D<Real64> useVal(14, 15);
    9761           41 :     Array1D<Real64> collapsedTotal(14);
    9762           41 :     Array2D<Real64> collapsedEndUse(14, static_cast<int>(Constant::EndUse::Num));
    9763           41 :     Array3D<Real64> collapsedEndUseSub(state.dataOutputProcessor->MaxNumSubcategories, static_cast<int>(Constant::EndUse::Num), 14);
    9764              : 
    9765              :     // show the headers of the report
    9766          123 :     WriteReportHeaders(state, "Source Energy End Use Components Summary", "Entire Facility", OutputProcessor::StoreType::Average);
    9767              :     // show the number of hours that the table applies to
    9768           41 :     WriteTextLine(state, "Values gathered over " + RealToStr(ort->gatherElapsedTimeBEPS, 2) + " hours", true);
    9769           41 :     if (ort->gatherElapsedTimeBEPS < 8759.0) { // might not add up to 8760 exactly but can't be more than 1 hour diff.
    9770           82 :         WriteTextLine(state, "WARNING: THE REPORT DOES NOT REPRESENT A FULL ANNUAL SIMULATION.", true);
    9771              :     }
    9772           41 :     WriteTextLine(state, "", true);
    9773              : 
    9774              :     // determine building floor areas
    9775           41 :     DetermineBuildingFloorArea(state);
    9776              : 
    9777           83 :     for (int iUnitSystem = 0; iUnitSystem <= 1; iUnitSystem++) {
    9778           82 :         UnitsStyle unitsStyle_cur = ort->unitsStyle;
    9779           82 :         bool produceTabular = true;
    9780           82 :         bool produceSQLite = false;
    9781           82 :         if (produceDualUnitsFlags(iUnitSystem, ort->unitsStyle, ort->unitsStyle_SQLite, unitsStyle_cur, produceTabular, produceSQLite)) break;
    9782              : 
    9783              :         // collapse the gatherEndUseBEPS array to the resource groups displayed
    9784          630 :         for (int jEndUse = 1; jEndUse <= static_cast<int>(Constant::EndUse::Num); ++jEndUse) {
    9785          588 :             collapsedEndUse(1, jEndUse) = ort->gatherEndUseBySourceBEPS(1, jEndUse);   // electricity
    9786          588 :             collapsedEndUse(2, jEndUse) = ort->gatherEndUseBySourceBEPS(2, jEndUse);   // natural gas
    9787          588 :             collapsedEndUse(3, jEndUse) = ort->gatherEndUseBySourceBEPS(6, jEndUse);   // gasoline
    9788          588 :             collapsedEndUse(4, jEndUse) = ort->gatherEndUseBySourceBEPS(8, jEndUse);   // diesel
    9789          588 :             collapsedEndUse(5, jEndUse) = ort->gatherEndUseBySourceBEPS(9, jEndUse);   // coal
    9790          588 :             collapsedEndUse(6, jEndUse) = ort->gatherEndUseBySourceBEPS(10, jEndUse);  // Fuel Oil No1
    9791          588 :             collapsedEndUse(7, jEndUse) = ort->gatherEndUseBySourceBEPS(11, jEndUse);  // Fuel Oil No2
    9792          588 :             collapsedEndUse(8, jEndUse) = ort->gatherEndUseBySourceBEPS(12, jEndUse);  // propane
    9793          588 :             collapsedEndUse(9, jEndUse) = ort->gatherEndUseBySourceBEPS(13, jEndUse);  // otherfuel1
    9794          588 :             collapsedEndUse(10, jEndUse) = ort->gatherEndUseBySourceBEPS(14, jEndUse); // otherfuel2
    9795          588 :             collapsedEndUse(11, jEndUse) = ort->gatherEndUseBySourceBEPS(3, jEndUse);  // district cooling <- purchased cooling
    9796          588 :             collapsedEndUse(12, jEndUse) = ort->gatherEndUseBySourceBEPS(4, jEndUse);  // district heating water <- purchased heating
    9797          588 :             collapsedEndUse(13, jEndUse) = ort->gatherEndUseBySourceBEPS(5, jEndUse);  // district heating steam <- purchased heating
    9798          588 :             collapsedEndUse(14, jEndUse) = ort->gatherEndUseBySourceBEPS(7, jEndUse);  // water
    9799              :         }
    9800              :         // repeat with totals
    9801           42 :         collapsedTotal(1) = ort->gatherTotalsBySourceBEPS(1);   // electricity
    9802           42 :         collapsedTotal(2) = ort->gatherTotalsBySourceBEPS(2);   // natural gas
    9803           42 :         collapsedTotal(3) = ort->gatherTotalsBySourceBEPS(6);   // gasoline
    9804           42 :         collapsedTotal(4) = ort->gatherTotalsBySourceBEPS(8);   // diesel
    9805           42 :         collapsedTotal(5) = ort->gatherTotalsBySourceBEPS(9);   // coal
    9806           42 :         collapsedTotal(6) = ort->gatherTotalsBySourceBEPS(10);  // Fuel Oil No1
    9807           42 :         collapsedTotal(7) = ort->gatherTotalsBySourceBEPS(11);  // Fuel Oil No2
    9808           42 :         collapsedTotal(8) = ort->gatherTotalsBySourceBEPS(12);  // propane
    9809           42 :         collapsedTotal(9) = ort->gatherTotalsBySourceBEPS(13);  // otherfuel1
    9810           42 :         collapsedTotal(10) = ort->gatherTotalsBySourceBEPS(14); // otherfuel2
    9811           42 :         collapsedTotal(11) = ort->gatherTotalsBySourceBEPS(3);  // district cooling <- purchased cooling
    9812           42 :         collapsedTotal(12) = ort->gatherTotalsBySourceBEPS(4);  // district heating water <- purchased heating
    9813           42 :         collapsedTotal(13) = ort->gatherTotalsBySourceBEPS(5);  // district heating steam <- purchased heating
    9814           42 :         collapsedTotal(14) = ort->gatherTotalsBySourceBEPS(7);  // water
    9815              : 
    9816              :         // unit conversion - all values are used as divisors
    9817              :         Real64 largeConversionFactor;
    9818              :         Real64 areaConversionFactor;
    9819           42 :         Real64 ipElectricityConversionFactor = 1.0;
    9820           42 :         switch (unitsStyle_cur) {
    9821            2 :         case UnitsStyle::JtoKWH: {
    9822            2 :             largeConversionFactor = 3600000.0;
    9823            2 :             areaConversionFactor = 1.0;
    9824            2 :         } break;
    9825            2 :         case UnitsStyle::InchPound: {
    9826            8 :             largeConversionFactor = getSpecificUnitDivider(state, "J", "kBtu"); // 1054351.84 J to kBtu
    9827            6 :             areaConversionFactor = getSpecificUnitDivider(state, "m2", "ft2");  // 0.092893973 m2 to ft2
    9828            2 :         } break;
    9829            1 :         case UnitsStyle::InchPoundExceptElectricity: {
    9830            4 :             largeConversionFactor = getSpecificUnitDivider(state, "J", "kBtu"); // 1054351.84 J to kBtu
    9831            3 :             areaConversionFactor = getSpecificUnitDivider(state, "m2", "ft2");  // 0.092893973 m2 to ft2
    9832            1 :             ipElectricityConversionFactor = largeConversionFactor / (1000.0 * 3600.0);
    9833            1 :         } break;
    9834           37 :         default: {
    9835           37 :             largeConversionFactor = 1000000.0; // to MJ
    9836           37 :             areaConversionFactor = 1.0;
    9837           37 :         } break;
    9838              :         }
    9839              : 
    9840              :         // convert units into MJ (divide by 1,000,000) if J otherwise kWh
    9841          588 :         for (int iResource = 1; iResource <= 13; ++iResource) { // don't do water
    9842          546 :             Real64 ipElectricityAdjust = (iResource == 1) ? ipElectricityConversionFactor : 1.0;
    9843         8190 :             for (int jEndUse = 1; jEndUse <= static_cast<int>(Constant::EndUse::Num); ++jEndUse) {
    9844         7644 :                 collapsedEndUse(iResource, jEndUse) /= (largeConversionFactor / ipElectricityAdjust);
    9845              :             }
    9846          546 :             collapsedTotal(iResource) /= (largeConversionFactor / ipElectricityAdjust);
    9847              :         }
    9848              : 
    9849           42 :         rowHead.allocate(16);
    9850           42 :         columnHead.allocate(13);
    9851           42 :         columnWidth.allocate(13);
    9852           42 :         columnWidth = 10; // array assignment - same for all columns
    9853           42 :         tableBody.allocate(13, 16);
    9854          630 :         for (int iResource = 1; iResource <= 14; ++iResource) {
    9855         8820 :             for (int iEndUse = 0; iEndUse < static_cast<int>(Constant::EndUse::Num); ++iEndUse) {
    9856         8232 :                 useVal(iResource, iEndUse + 1) = collapsedEndUse(iResource, iEndUse + 1);
    9857              :             }
    9858          588 :             useVal(iResource, 15) = collapsedTotal(iResource); // totals
    9859              :         }
    9860              : 
    9861           42 :         rowHead(static_cast<int>(Constant::EndUse::Heating) + 1) = "Heating";
    9862           42 :         rowHead(static_cast<int>(Constant::EndUse::Cooling) + 1) = "Cooling";
    9863           42 :         rowHead(static_cast<int>(Constant::EndUse::InteriorLights) + 1) = "Interior Lighting";
    9864           42 :         rowHead(static_cast<int>(Constant::EndUse::ExteriorLights) + 1) = "Exterior Lighting";
    9865           42 :         rowHead(static_cast<int>(Constant::EndUse::InteriorEquipment) + 1) = "Interior Equipment";
    9866           42 :         rowHead(static_cast<int>(Constant::EndUse::ExteriorEquipment) + 1) = "Exterior Equipment";
    9867           42 :         rowHead(static_cast<int>(Constant::EndUse::Fans) + 1) = "Fans";
    9868           42 :         rowHead(static_cast<int>(Constant::EndUse::Pumps) + 1) = "Pumps";
    9869           42 :         rowHead(static_cast<int>(Constant::EndUse::HeatRejection) + 1) = "Heat Rejection";
    9870           42 :         rowHead(static_cast<int>(Constant::EndUse::Humidification) + 1) = "Humidification";
    9871           42 :         rowHead(static_cast<int>(Constant::EndUse::HeatRecovery) + 1) = "Heat Recovery";
    9872           42 :         rowHead(static_cast<int>(Constant::EndUse::WaterSystem) + 1) = "Water Systems";
    9873           42 :         rowHead(static_cast<int>(Constant::EndUse::Refrigeration) + 1) = "Refrigeration";
    9874           42 :         rowHead(static_cast<int>(Constant::EndUse::Cogeneration) + 1) = "Generators";
    9875           42 :         rowHead(15) = "";
    9876           42 :         rowHead(16) = "Total Source Energy End Use Components";
    9877              : 
    9878           42 :         largeConversionFactor = 1.0;
    9879              : 
    9880           42 :         switch (unitsStyle_cur) {
    9881            2 :         case UnitsStyle::JtoKWH: {
    9882            2 :             columnHead(1) = "Source Electricity [kWh]";
    9883            2 :             columnHead(2) = "Source Natural Gas [kWh]";
    9884            2 :             columnHead(3) = "Source Gasoline [kWh]";
    9885            2 :             columnHead(4) = "Source Diesel [kWh]";
    9886            2 :             columnHead(5) = "Source Coal [kWh]";
    9887            2 :             columnHead(6) = "Source Fuel Oil No 1 [kWh]";
    9888            2 :             columnHead(7) = "Source Fuel Oil No 2 [kWh]";
    9889            2 :             columnHead(8) = "Source Propane [kWh]";
    9890            2 :             columnHead(9) = "Source Other Fuel 1 [kWh]";
    9891            2 :             columnHead(10) = "Source Other Fuel 2 [kWh]";
    9892            2 :             columnHead(11) = "Source District Cooling [kWh]";
    9893            2 :             columnHead(12) = "Source District Heating Water [kWh]";
    9894            2 :             columnHead(13) = "Source District Heating Steam [kWh]";
    9895            2 :         } break;
    9896            2 :         case UnitsStyle::InchPound: {
    9897            2 :             columnHead(1) = "Source Electricity [kBtu]";
    9898            2 :             columnHead(2) = "Source Natural Gas [kBtu]";
    9899            2 :             columnHead(3) = "Source Gasoline [kBtu]";
    9900            2 :             columnHead(4) = "Source Diesel [kBtu]";
    9901            2 :             columnHead(5) = "Source Coal [kBtu]";
    9902            2 :             columnHead(6) = "Source Fuel Oil No 1 [kBtu]";
    9903            2 :             columnHead(7) = "Source Fuel Oil No 2 [kBtu]";
    9904            2 :             columnHead(8) = "Source Propane [kBtu]";
    9905            2 :             columnHead(9) = "Source Other Fuel 1 [kBtu]";
    9906            2 :             columnHead(10) = "Source Other Fuel 2 [kBtu]";
    9907            2 :             columnHead(11) = "Source District Cooling [kBtu]";
    9908            2 :             columnHead(12) = "Source District Heating Water [kBtu]";
    9909            2 :             columnHead(13) = "Source District Heating Steam [kBtu]";
    9910            2 :         } break;
    9911            1 :         case UnitsStyle::InchPoundExceptElectricity: {
    9912            1 :             columnHead(1) = "Source Electricity [kWh]";
    9913            1 :             columnHead(2) = "Source Natural Gas [kBtu]";
    9914            1 :             columnHead(3) = "Source Gasoline [kBtu]";
    9915            1 :             columnHead(4) = "Source Diesel [kBtu]";
    9916            1 :             columnHead(5) = "Source Coal [kBtu]";
    9917            1 :             columnHead(6) = "Source Fuel Oil No 1 [kBtu]";
    9918            1 :             columnHead(7) = "Source Fuel Oil No 2 [kBtu]";
    9919            1 :             columnHead(8) = "Source Propane [kBtu]";
    9920            1 :             columnHead(9) = "Source Other Fuel 1 [kBtu]";
    9921            1 :             columnHead(10) = "Source Other Fuel 2 [kBtu]";
    9922            1 :             columnHead(11) = "Source District Cooling [kBtu]";
    9923            1 :             columnHead(12) = "Source District Heating Water [kBtu]";
    9924            1 :             columnHead(13) = "Source District Heating Steam [kBtu]";
    9925            1 :         } break;
    9926           37 :         default: {
    9927           37 :             columnHead(1) = "Source Electricity [GJ]";
    9928           37 :             columnHead(2) = "Source Natural Gas [GJ]";
    9929           37 :             columnHead(3) = "Source Gasoline [GJ]";
    9930           37 :             columnHead(4) = "Source Diesel [GJ]";
    9931           37 :             columnHead(5) = "Source Coal [GJ]";
    9932           37 :             columnHead(6) = "Source Fuel Oil No 1 [GJ]";
    9933           37 :             columnHead(7) = "Source Fuel Oil No 2 [GJ]";
    9934           37 :             columnHead(8) = "Source Propane [GJ]";
    9935           37 :             columnHead(9) = "Source Other Fuel 1 [GJ]";
    9936           37 :             columnHead(10) = "Source Other Fuel 2 [GJ]";
    9937           37 :             columnHead(11) = "Source District Cooling [GJ]";
    9938           37 :             columnHead(12) = "Source District Heating Water [GJ]";
    9939           37 :             columnHead(13) = "Source District Heating Steam [GJ]";
    9940           37 :             largeConversionFactor = 1000.0; // for converting MJ to GJ
    9941           37 :         } break;
    9942              :         }
    9943              : 
    9944              :         //---- End Uses by Source Energy Sub-Table
    9945              : 
    9946           42 :         tableBody = "";
    9947          588 :         for (int iResource = 1; iResource <= 13; ++iResource) {
    9948         8190 :             for (int jEndUse = 1; jEndUse <= static_cast<int>(Constant::EndUse::Num); ++jEndUse) {
    9949         7644 :                 tableBody(iResource, jEndUse) = RealToStr(useVal(iResource, jEndUse) / largeConversionFactor, 2);
    9950              :             }
    9951          546 :             tableBody(iResource, 16) = RealToStr(useVal(iResource, 15) / largeConversionFactor, 2);
    9952              :         }
    9953              : 
    9954              :         // heading for the entire sub-table
    9955           42 :         if (produceTabular) {
    9956           41 :             WriteSubtitle(state, "Source Energy End Use Components Summary");
    9957           41 :             WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
    9958              :         }
    9959           42 :         if (produceSQLite) {
    9960           41 :             if (state.dataSQLiteProcedures->sqlite) {
    9961            6 :                 state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(tableBody,
    9962              :                                                                                    rowHead,
    9963              :                                                                                    columnHead,
    9964              :                                                                                    "SourceEnergyEndUseComponentsSummary",
    9965              :                                                                                    "Entire Facility",
    9966              :                                                                                    "Source Energy End Use Components Summary");
    9967              :             }
    9968              :         }
    9969           42 :         if (produceTabular) {
    9970           41 :             if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
    9971            0 :                 state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(tableBody,
    9972              :                                                                                                       rowHead,
    9973              :                                                                                                       columnHead,
    9974              :                                                                                                       "SourceEnergyEndUseComponentsSummary",
    9975              :                                                                                                       "Entire Facility",
    9976              :                                                                                                       "Source Energy End Use Components Summary");
    9977              :             }
    9978              :         }
    9979              : 
    9980              :         // Normalized by Area tables
    9981              : 
    9982           42 :         switch (unitsStyle_cur) {
    9983            2 :         case UnitsStyle::JtoKWH: {
    9984            2 :             columnHead(1) = "Source Electricity [kWh/m2]";
    9985            2 :             columnHead(2) = "Source Natural Gas [kWh/m2]";
    9986            2 :             columnHead(3) = "Source Gasoline [kWh/m2]";
    9987            2 :             columnHead(4) = "Source Diesel [kWh/m2]";
    9988            2 :             columnHead(5) = "Source Coal [kWh/m2]";
    9989            2 :             columnHead(6) = "Source Fuel Oil No 1 [kWh/m2]";
    9990            2 :             columnHead(7) = "Source Fuel Oil No 2 [kWh/m2]";
    9991            2 :             columnHead(8) = "Source Propane [kWh/m2]";
    9992            2 :             columnHead(9) = "Source Other Fuel 1 [kWh/m2]";
    9993            2 :             columnHead(10) = "Source Other Fuel 2 [kWh/m2]";
    9994            2 :             columnHead(11) = "Source District Cooling [kWh/m2]";
    9995            2 :             columnHead(12) = "Source District Heating Water [kWh/m2]";
    9996            2 :             columnHead(13) = "Source District Heating Steam [kWh/m2]";
    9997            2 :         } break;
    9998            2 :         case UnitsStyle::InchPound: {
    9999            2 :             columnHead(1) = "Source Electricity [kBtu/ft2]";
   10000            2 :             columnHead(2) = "Source Natural Gas [kBtu/ft2]";
   10001            2 :             columnHead(3) = "Source Gasoline [kBtu/ft2]";
   10002            2 :             columnHead(4) = "Source Diesel [kBtu/ft2]";
   10003            2 :             columnHead(5) = "Source Coal [kBtu/ft2]";
   10004            2 :             columnHead(6) = "Source Fuel Oil No 1 [kBtu/ft2]";
   10005            2 :             columnHead(7) = "Source Fuel Oil No 2 [kBtu/ft2]";
   10006            2 :             columnHead(8) = "Source Propane [kBtu/ft2]";
   10007            2 :             columnHead(9) = "Source Other Fuel 1 [kBtu/ft2]";
   10008            2 :             columnHead(10) = "Source Other Fuel 2 [kBtu/ft2]";
   10009            2 :             columnHead(11) = "Source District Cooling [kBtu/ft2]";
   10010            2 :             columnHead(12) = "Source District Heating Water [kBtu/ft2]";
   10011            2 :             columnHead(13) = "Source District Heating Steam [kBtu/ft2]";
   10012            2 :         } break;
   10013            1 :         case UnitsStyle::InchPoundExceptElectricity: {
   10014            1 :             columnHead(1) = "Source Electricity [kWh/ft2]";
   10015            1 :             columnHead(2) = "Source Natural Gas [kBtu/ft2]";
   10016            1 :             columnHead(3) = "Source Gasoline [kBtu/ft2]";
   10017            1 :             columnHead(4) = "Source Diesel [kBtu/ft2]";
   10018            1 :             columnHead(5) = "Source Coal [kBtu/ft2]";
   10019            1 :             columnHead(6) = "Source Fuel Oil No 1 [kBtu/ft2]";
   10020            1 :             columnHead(7) = "Source Fuel Oil No 2 [kBtu/ft2]";
   10021            1 :             columnHead(8) = "Source Propane [kBtu/ft2]";
   10022            1 :             columnHead(9) = "Source Other Fuel 1 [kBtu/ft2]";
   10023            1 :             columnHead(10) = "Source Other Fuel 2 [kBtu/ft2]";
   10024            1 :             columnHead(11) = "Source District Cooling [kBtu/ft2]";
   10025            1 :             columnHead(12) = "Source District Heating Water [kBtu/ft2]";
   10026            1 :             columnHead(13) = "Source District Heating Steam [kBtu/ft2]";
   10027            1 :         } break;
   10028           37 :         default: {
   10029           37 :             columnHead(1) = "Source Electricity [MJ/m2]";
   10030           37 :             columnHead(2) = "Source Natural Gas [MJ/m2]";
   10031           37 :             columnHead(3) = "Source Gasoline [MJ/m2]";
   10032           37 :             columnHead(4) = "Source Diesel [MJ/m2]";
   10033           37 :             columnHead(5) = "Source Coal [MJ/m2]";
   10034           37 :             columnHead(6) = "Source Fuel Oil No 1 [MJ/m2]";
   10035           37 :             columnHead(7) = "Source Fuel Oil No 2 [MJ/m2]";
   10036           37 :             columnHead(8) = "Source Propane [MJ/m2]";
   10037           37 :             columnHead(9) = "Source Other Fuel 1 [MJ/m2]";
   10038           37 :             columnHead(10) = "Source Other Fuel 2 [MJ/m2]";
   10039           37 :             columnHead(11) = "Source District Cooling [MJ/m2]";
   10040           37 :             columnHead(12) = "Source District Heating Water [MJ/m2]";
   10041           37 :             columnHead(13) = "Source District Heating Steam [MJ/m2]";
   10042           37 :         } break;
   10043              :         }
   10044              : 
   10045              :         //---- Normalized by Conditioned Area Sub-Table
   10046              :         {
   10047           42 :             tableBody = "";
   10048              :             // convert floor area
   10049           42 :             Real64 convBldgCondFloorArea = ort->buildingConditionedFloorArea / areaConversionFactor;
   10050           42 :             if (convBldgCondFloorArea > 0) {
   10051          252 :                 for (int iResource = 1; iResource <= 13; ++iResource) {
   10052         3510 :                     for (int jEndUse = 1; jEndUse <= static_cast<int>(Constant::EndUse::Num); ++jEndUse) {
   10053         3276 :                         tableBody(iResource, jEndUse) = RealToStr(useVal(iResource, jEndUse) / convBldgCondFloorArea, 2);
   10054              :                     }
   10055          234 :                     tableBody(iResource, 16) = RealToStr(useVal(iResource, 15) / convBldgCondFloorArea, 2);
   10056              :                 }
   10057              :             }
   10058              : 
   10059           42 :             if (produceTabular) {
   10060           82 :                 WriteTextLine(state, "Normalized Metrics", true);
   10061              : 
   10062              :                 // heading for the entire sub-table
   10063           41 :                 WriteSubtitle(state, "Source Energy End Use Components Per Conditioned Floor Area");
   10064           41 :                 WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
   10065              :             }
   10066           42 :             if (produceSQLite) {
   10067           41 :                 if (state.dataSQLiteProcedures->sqlite) {
   10068            6 :                     state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(tableBody,
   10069              :                                                                                        rowHead,
   10070              :                                                                                        columnHead,
   10071              :                                                                                        "SourceEnergyEndUseComponentsSummary",
   10072              :                                                                                        "Entire Facility",
   10073              :                                                                                        "Source Energy End Use Components Per Conditioned Floor Area");
   10074              :                 }
   10075              :             }
   10076           42 :             if (produceTabular) {
   10077           41 :                 if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
   10078            0 :                     state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(
   10079              :                         tableBody,
   10080              :                         rowHead,
   10081              :                         columnHead,
   10082              :                         "SourceEnergyEndUseComponentsSummary",
   10083              :                         "Entire Facility",
   10084              :                         "Source Energy End Use Components Per Conditioned Floor Area");
   10085              :                 }
   10086              :             }
   10087              :         } // End of Normalized by Conditioned Area
   10088              : 
   10089              :         //---- Normalized by Total Area Sub-Table
   10090              :         {
   10091           42 :             tableBody = "";
   10092           42 :             Real64 convBldgGrossFloorArea = ort->buildingGrossFloorArea / areaConversionFactor;
   10093              : 
   10094           42 :             if (convBldgGrossFloorArea > 0) {
   10095          588 :                 for (int iResource = 1; iResource <= 13; ++iResource) {
   10096         8190 :                     for (int jEndUse = 1; jEndUse <= static_cast<int>(Constant::EndUse::Num); ++jEndUse) {
   10097         7644 :                         tableBody(iResource, jEndUse) = RealToStr(useVal(iResource, jEndUse) / convBldgGrossFloorArea, 2);
   10098              :                     }
   10099          546 :                     tableBody(iResource, 16) = RealToStr(useVal(iResource, 15) / convBldgGrossFloorArea, 2);
   10100              :                 }
   10101              :             }
   10102              : 
   10103              :             // heading for the entire sub-table
   10104           42 :             if (produceTabular) {
   10105           41 :                 WriteSubtitle(state, "Source Energy End Use Components Per Total Floor Area");
   10106           41 :                 WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
   10107              :             }
   10108           42 :             if (produceSQLite) {
   10109           41 :                 if (state.dataSQLiteProcedures->sqlite) {
   10110            6 :                     state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(tableBody,
   10111              :                                                                                        rowHead,
   10112              :                                                                                        columnHead,
   10113              :                                                                                        "SourceEnergyEndUseComponentsSummary",
   10114              :                                                                                        "Entire Facility",
   10115              :                                                                                        "Source Energy End Use Components Per Total Floor Area");
   10116              :                 }
   10117              :             }
   10118           42 :             if (produceTabular) {
   10119           41 :                 if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
   10120            0 :                     state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(
   10121              :                         tableBody,
   10122              :                         rowHead,
   10123              :                         columnHead,
   10124              :                         "SourceEnergyEndUseComponentsSummary",
   10125              :                         "Entire Facility",
   10126              :                         "Source Energy End Use Components Per Total Floor Area");
   10127              :                 }
   10128              :             }
   10129              :         } // End of Normalized by Total Area
   10130              :     }     // End of Dual Units reporting
   10131           41 : }
   10132              : 
   10133           42 : void WriteDemandEndUseSummary(EnergyPlusData &state)
   10134              : {
   10135              :     // SUBROUTINE INFORMATION:
   10136              :     //       AUTHOR         Jason Glazer
   10137              :     //       DATE WRITTEN   January 2009
   10138              :     //       MODIFIED       January 2010, Kyle Benne; Added SQLite output
   10139              :     //                      March 2020, Dareum Nam; Disaggregated "Additional Fuel"
   10140              :     //       RE-ENGINEERED  na
   10141              : 
   10142              :     // PURPOSE OF THIS SUBROUTINE:
   10143              :     //   Take the gathered total and enduse meter data and structure
   10144              :     //   the results into a tabular report for output.
   10145              : 
   10146              :     // METHODOLOGY EMPLOYED:
   10147              :     //   Create arrays for the call to WriteTable and then call it.
   10148              :     //   This report actually consists of many sub-tables each with
   10149              :     //   its own call to WriteTable.
   10150              : 
   10151           42 :     auto &ort = state.dataOutRptTab;
   10152           42 :     auto &op = state.dataOutputProcessor;
   10153              : 
   10154           42 :     if (!ort->displayDemandEndUse) {
   10155            0 :         return;
   10156              :     }
   10157              : 
   10158              :     // all arrays are in the format: (row, column)
   10159           42 :     Array1D_string columnHead;
   10160           42 :     Array1D_int columnWidth;
   10161           42 :     Array1D_string rowHead;
   10162           42 :     Array2D_string tableBody;
   10163              : 
   10164              :     // all arrays are in the format: (row, column)
   10165           42 :     Array2D<Real64> useVal(14, 15);
   10166           42 :     Array1D<Real64> collapsedTotal(14);
   10167           42 :     Array2D<Real64> collapsedEndUse(14, static_cast<int>(Constant::EndUse::Num));
   10168           42 :     Array2D<Real64> collapsedIndEndUse(14, static_cast<int>(Constant::EndUse::Num));
   10169           42 :     Array1D_int collapsedTimeStep(14);
   10170           42 :     Array3D<Real64> collapsedEndUseSub(state.dataOutputProcessor->MaxNumSubcategories, static_cast<int>(Constant::EndUse::Num), 14);
   10171           42 :     Array3D<Real64> collapsedIndEndUseSub(state.dataOutputProcessor->MaxNumSubcategories, static_cast<int>(Constant::EndUse::Num), 14);
   10172           42 :     Array2D<Real64> endUseSubOther(14, static_cast<int>(Constant::EndUse::Num));
   10173              : 
   10174              :     // show the headers of the report
   10175          126 :     WriteReportHeaders(state, "Demand End Use Components Summary", "Entire Facility", OutputProcessor::StoreType::Average);
   10176              : 
   10177           42 :     Real64 ipElectricityConversion = 1.0; // declare here so that last one used is correct for LEED section
   10178           86 :     for (int iUnitSystem = 0; iUnitSystem <= 1; iUnitSystem++) {
   10179           84 :         UnitsStyle unitsStyle_cur = ort->unitsStyle;
   10180           84 :         bool produceTabular = true;
   10181           84 :         bool produceSQLite = false;
   10182           84 :         if (produceDualUnitsFlags(iUnitSystem, ort->unitsStyle, ort->unitsStyle_SQLite, unitsStyle_cur, produceTabular, produceSQLite)) break;
   10183              : 
   10184              :         // totals - select which additional fuel to display
   10185           44 :         collapsedTotal = 0.0;
   10186           44 :         collapsedTotal(1) = ort->gatherDemandTotal(1); // electricity
   10187           44 :         collapsedTimeStep(1) = ort->gatherDemandTimeStamp(1);
   10188           44 :         collapsedTotal(2) = ort->gatherDemandTotal(2); // natural gas
   10189           44 :         collapsedTimeStep(2) = ort->gatherDemandTimeStamp(2);
   10190           44 :         collapsedTotal(3) = ort->gatherDemandTotal(6); // gasoline
   10191           44 :         collapsedTimeStep(3) = ort->gatherDemandTimeStamp(6);
   10192           44 :         collapsedTotal(4) = ort->gatherDemandTotal(8); // diesel
   10193           44 :         collapsedTimeStep(4) = ort->gatherDemandTimeStamp(8);
   10194           44 :         collapsedTotal(5) = ort->gatherDemandTotal(9); // coal
   10195           44 :         collapsedTimeStep(5) = ort->gatherDemandTimeStamp(9);
   10196           44 :         collapsedTotal(6) = ort->gatherDemandTotal(10); // fuel oil no 1
   10197           44 :         collapsedTimeStep(6) = ort->gatherDemandTimeStamp(10);
   10198           44 :         collapsedTotal(7) = ort->gatherDemandTotal(11); // fuel oil no 2
   10199           44 :         collapsedTimeStep(7) = ort->gatherDemandTimeStamp(11);
   10200           44 :         collapsedTotal(8) = ort->gatherDemandTotal(12); // propane
   10201           44 :         collapsedTimeStep(8) = ort->gatherDemandTimeStamp(12);
   10202           44 :         collapsedTotal(9) = ort->gatherDemandTotal(13); // other fuel 1
   10203           44 :         collapsedTimeStep(9) = ort->gatherDemandTimeStamp(13);
   10204           44 :         collapsedTotal(10) = ort->gatherDemandTotal(14); // other fuel 2
   10205           44 :         collapsedTimeStep(10) = ort->gatherDemandTimeStamp(14);
   10206           44 :         collapsedTotal(11) = ort->gatherDemandTotal(3); // district cooling <- purchased cooling
   10207           44 :         collapsedTimeStep(11) = ort->gatherDemandTimeStamp(3);
   10208           44 :         collapsedTotal(12) = ort->gatherDemandTotal(4); // district heating water <- purchased heating
   10209           44 :         collapsedTimeStep(12) = ort->gatherDemandTimeStamp(4);
   10210           44 :         collapsedTotal(13) = ort->gatherDemandTotal(5); // district heating steam <- purchased heating
   10211           44 :         collapsedTimeStep(13) = ort->gatherDemandTimeStamp(5);
   10212           44 :         collapsedTotal(14) = ort->gatherDemandTotal(7); // water
   10213           44 :         collapsedTimeStep(14) = ort->gatherDemandTimeStamp(7);
   10214              : 
   10215           44 :         Real64 powerConversion = 1.0;
   10216           44 :         Real64 flowConversion = 1.0;
   10217           44 :         ipElectricityConversion = 1.0;
   10218              : 
   10219              :         // establish unit conversion factors
   10220           44 :         if (unitsStyle_cur == UnitsStyle::InchPound) {
   10221            8 :             powerConversion = getSpecificUnitMultiplier(state, "W", "kBtuh");
   10222            8 :             flowConversion = getSpecificUnitMultiplier(state, "m3/s", "gal/min");
   10223           42 :         } else if (unitsStyle_cur == UnitsStyle::InchPoundExceptElectricity) {
   10224            4 :             powerConversion = getSpecificUnitMultiplier(state, "W", "kBtuh");
   10225            3 :             flowConversion = getSpecificUnitMultiplier(state, "m3/s", "gal/min");
   10226            1 :             ipElectricityConversion = powerConversion * 1000.0; // W to kW adjustment
   10227              :         }
   10228              : 
   10229              :         // collapse the gatherEndUseBEPS array to the resource groups displayed
   10230           44 :         collapsedEndUse = 0.0;
   10231          660 :         for (int jEndUse = 1; jEndUse <= static_cast<int>(Constant::EndUse::Num); ++jEndUse) {
   10232          616 :             collapsedEndUse(1, jEndUse) = ort->gatherDemandEndUse(1, jEndUse) * (powerConversion / ipElectricityConversion); // electricity
   10233          616 :             collapsedEndUse(2, jEndUse) = ort->gatherDemandEndUse(2, jEndUse) * powerConversion;                             // natural gas
   10234          616 :             collapsedEndUse(3, jEndUse) = ort->gatherDemandEndUse(6, jEndUse) * powerConversion;                             // gasoline
   10235          616 :             collapsedEndUse(4, jEndUse) = ort->gatherDemandEndUse(8, jEndUse) * powerConversion;                             // diesel
   10236          616 :             collapsedEndUse(5, jEndUse) = ort->gatherDemandEndUse(9, jEndUse) * powerConversion;                             // coal
   10237          616 :             collapsedEndUse(6, jEndUse) = ort->gatherDemandEndUse(10, jEndUse) * powerConversion;                            // fuel oil no 1
   10238          616 :             collapsedEndUse(7, jEndUse) = ort->gatherDemandEndUse(11, jEndUse) * powerConversion;                            // fuel oil no 2
   10239          616 :             collapsedEndUse(8, jEndUse) = ort->gatherDemandEndUse(12, jEndUse) * powerConversion;                            // propane
   10240          616 :             collapsedEndUse(9, jEndUse) = ort->gatherDemandEndUse(13, jEndUse) * powerConversion;                            // otherfuel1
   10241          616 :             collapsedEndUse(10, jEndUse) = ort->gatherDemandEndUse(14, jEndUse) * powerConversion;                           // otherfuel2
   10242          616 :             collapsedEndUse(11, jEndUse) = ort->gatherDemandEndUse(3, jEndUse) * powerConversion;                            // purchased cooling
   10243          616 :             collapsedEndUse(12, jEndUse) = ort->gatherDemandEndUse(4, jEndUse) * powerConversion;                            // district heating water
   10244          616 :             collapsedEndUse(13, jEndUse) = ort->gatherDemandEndUse(5, jEndUse) * powerConversion;                            // district heating steam
   10245          616 :             collapsedEndUse(14, jEndUse) = ort->gatherDemandEndUse(7, jEndUse) * flowConversion;                             // water
   10246              :         }
   10247          660 :         for (int jEndUse = 1; jEndUse <= static_cast<int>(Constant::EndUse::Num); ++jEndUse) {
   10248          797 :             for (int kEndUseSub = 1; kEndUseSub <= op->EndUseCategory(jEndUse).NumSubcategories; ++kEndUseSub) {
   10249          362 :                 collapsedEndUseSub(kEndUseSub, jEndUse, 1) =
   10250          181 :                     ort->gatherDemandEndUseSub(kEndUseSub, jEndUse, 1) * (powerConversion / ipElectricityConversion);                // electricity
   10251          181 :                 collapsedEndUseSub(kEndUseSub, jEndUse, 2) = ort->gatherDemandEndUseSub(kEndUseSub, jEndUse, 2) * powerConversion;   // natural gas
   10252          181 :                 collapsedEndUseSub(kEndUseSub, jEndUse, 3) = ort->gatherDemandEndUseSub(kEndUseSub, jEndUse, 6) * powerConversion;   // gasoline
   10253          181 :                 collapsedEndUseSub(kEndUseSub, jEndUse, 4) = ort->gatherDemandEndUseSub(kEndUseSub, jEndUse, 8) * powerConversion;   // diesel
   10254          181 :                 collapsedEndUseSub(kEndUseSub, jEndUse, 5) = ort->gatherDemandEndUseSub(kEndUseSub, jEndUse, 9) * powerConversion;   // coal
   10255          181 :                 collapsedEndUseSub(kEndUseSub, jEndUse, 6) = ort->gatherDemandEndUseSub(kEndUseSub, jEndUse, 10) * powerConversion;  // fuel oil no 1
   10256          181 :                 collapsedEndUseSub(kEndUseSub, jEndUse, 7) = ort->gatherDemandEndUseSub(kEndUseSub, jEndUse, 11) * powerConversion;  // fuel oil no 2
   10257          181 :                 collapsedEndUseSub(kEndUseSub, jEndUse, 8) = ort->gatherDemandEndUseSub(kEndUseSub, jEndUse, 12) * powerConversion;  // propane
   10258          181 :                 collapsedEndUseSub(kEndUseSub, jEndUse, 9) = ort->gatherDemandEndUseSub(kEndUseSub, jEndUse, 13) * powerConversion;  // otherfuel1
   10259          181 :                 collapsedEndUseSub(kEndUseSub, jEndUse, 10) = ort->gatherDemandEndUseSub(kEndUseSub, jEndUse, 14) * powerConversion; // otherfuel2
   10260          181 :                 collapsedEndUseSub(kEndUseSub, jEndUse, 11) = ort->gatherDemandEndUseSub(kEndUseSub, jEndUse, 3) * powerConversion;  // purch cooling
   10261          362 :                 collapsedEndUseSub(kEndUseSub, jEndUse, 12) =
   10262          181 :                     ort->gatherDemandEndUseSub(kEndUseSub, jEndUse, 4) * powerConversion; // district heating water
   10263          362 :                 collapsedEndUseSub(kEndUseSub, jEndUse, 13) =
   10264          181 :                     ort->gatherDemandEndUseSub(kEndUseSub, jEndUse, 5) * powerConversion; // district heating steam
   10265          181 :                 collapsedEndUseSub(kEndUseSub, jEndUse, 14) = ort->gatherDemandEndUseSub(kEndUseSub, jEndUse, 7) * flowConversion; // water
   10266              :             }
   10267              :         }
   10268              :         // collapse the individual peaks for the end use subcategories for the LEED report
   10269              :         // collapse the gatherEndUseBEPS array to the resource groups displayed
   10270              :         // no unit conversion, it is done at the reporting stage if necessary
   10271           44 :         collapsedIndEndUse = 0.0;
   10272          660 :         for (int jEndUse = 1; jEndUse <= static_cast<int>(Constant::EndUse::Num); ++jEndUse) {
   10273          616 :             collapsedIndEndUse(1, jEndUse) = ort->gatherDemandIndEndUse(1, jEndUse) * (1.0 / ipElectricityConversion); // electricity
   10274          616 :             collapsedIndEndUse(2, jEndUse) = ort->gatherDemandIndEndUse(2, jEndUse);                                   // natural gas
   10275          616 :             collapsedIndEndUse(3, jEndUse) = ort->gatherDemandIndEndUse(6, jEndUse);                                   // gasoline
   10276          616 :             collapsedIndEndUse(4, jEndUse) = ort->gatherDemandIndEndUse(8, jEndUse);                                   // diesel
   10277          616 :             collapsedIndEndUse(5, jEndUse) = ort->gatherDemandIndEndUse(9, jEndUse);                                   // coal
   10278          616 :             collapsedIndEndUse(6, jEndUse) = ort->gatherDemandIndEndUse(10, jEndUse);                                  // fuel oil no 1
   10279          616 :             collapsedIndEndUse(7, jEndUse) = ort->gatherDemandIndEndUse(11, jEndUse);                                  // fuel oil no 2
   10280          616 :             collapsedIndEndUse(8, jEndUse) = ort->gatherDemandIndEndUse(12, jEndUse);                                  // propane
   10281          616 :             collapsedIndEndUse(9, jEndUse) = ort->gatherDemandIndEndUse(13, jEndUse);                                  // otherfuel1
   10282          616 :             collapsedIndEndUse(10, jEndUse) = ort->gatherDemandIndEndUse(14, jEndUse);                                 // otherfuel2
   10283          616 :             collapsedIndEndUse(11, jEndUse) = ort->gatherDemandIndEndUse(3, jEndUse);                                  // purchased cooling
   10284          616 :             collapsedIndEndUse(12, jEndUse) = ort->gatherDemandIndEndUse(4, jEndUse);                                  // district heating water
   10285          616 :             collapsedIndEndUse(13, jEndUse) = ort->gatherDemandIndEndUse(5, jEndUse);                                  // district heating steam
   10286          616 :             collapsedIndEndUse(14, jEndUse) = ort->gatherDemandIndEndUse(7, jEndUse);                                  // water
   10287              :         }
   10288          660 :         for (int jEndUse = 1; jEndUse <= static_cast<int>(Constant::EndUse::Num); ++jEndUse) {
   10289          797 :             for (int kEndUseSub = 1; kEndUseSub <= op->EndUseCategory(jEndUse).NumSubcategories; ++kEndUseSub) {
   10290          362 :                 collapsedIndEndUseSub(kEndUseSub, jEndUse, 1) =
   10291          181 :                     ort->gatherDemandIndEndUseSub(kEndUseSub, jEndUse, 1) * (1.0 / ipElectricityConversion);             // electricity
   10292          181 :                 collapsedIndEndUseSub(kEndUseSub, jEndUse, 2) = ort->gatherDemandIndEndUseSub(kEndUseSub, jEndUse, 2);   // natural gas
   10293          181 :                 collapsedIndEndUseSub(kEndUseSub, jEndUse, 3) = ort->gatherDemandIndEndUseSub(kEndUseSub, jEndUse, 6);   // gasoline
   10294          181 :                 collapsedIndEndUseSub(kEndUseSub, jEndUse, 4) = ort->gatherDemandIndEndUseSub(kEndUseSub, jEndUse, 8);   // diesel
   10295          181 :                 collapsedIndEndUseSub(kEndUseSub, jEndUse, 5) = ort->gatherDemandIndEndUseSub(kEndUseSub, jEndUse, 9);   // coal
   10296          181 :                 collapsedIndEndUseSub(kEndUseSub, jEndUse, 6) = ort->gatherDemandIndEndUseSub(kEndUseSub, jEndUse, 10);  // fuel oil no 1
   10297          181 :                 collapsedIndEndUseSub(kEndUseSub, jEndUse, 7) = ort->gatherDemandIndEndUseSub(kEndUseSub, jEndUse, 11);  // fuel oil no 2
   10298          181 :                 collapsedIndEndUseSub(kEndUseSub, jEndUse, 8) = ort->gatherDemandIndEndUseSub(kEndUseSub, jEndUse, 12);  // propane
   10299          181 :                 collapsedIndEndUseSub(kEndUseSub, jEndUse, 9) = ort->gatherDemandIndEndUseSub(kEndUseSub, jEndUse, 13);  // otherfuel1
   10300          181 :                 collapsedIndEndUseSub(kEndUseSub, jEndUse, 10) = ort->gatherDemandIndEndUseSub(kEndUseSub, jEndUse, 14); // otherfuel2
   10301          181 :                 collapsedIndEndUseSub(kEndUseSub, jEndUse, 11) = ort->gatherDemandIndEndUseSub(kEndUseSub, jEndUse, 3);  // purch cooling
   10302          181 :                 collapsedIndEndUseSub(kEndUseSub, jEndUse, 12) = ort->gatherDemandIndEndUseSub(kEndUseSub, jEndUse, 4);  // district heating water
   10303          181 :                 collapsedIndEndUseSub(kEndUseSub, jEndUse, 13) = ort->gatherDemandIndEndUseSub(kEndUseSub, jEndUse, 5);  // district heating steam
   10304          181 :                 collapsedIndEndUseSub(kEndUseSub, jEndUse, 14) = ort->gatherDemandIndEndUseSub(kEndUseSub, jEndUse, 7);  // water
   10305              :             }
   10306              :         }
   10307              : 
   10308              :         // convert totals
   10309           44 :         collapsedTotal(1) *= (powerConversion / ipElectricityConversion); // electricity
   10310           44 :         collapsedTotal(2) *= powerConversion;                             // natural gas
   10311           44 :         collapsedTotal(3) *= powerConversion;                             // gasoline
   10312           44 :         collapsedTotal(4) *= powerConversion;                             // diesel
   10313           44 :         collapsedTotal(5) *= powerConversion;                             // coal
   10314           44 :         collapsedTotal(6) *= powerConversion;                             // fuel oil no 1
   10315           44 :         collapsedTotal(7) *= powerConversion;                             // fuel oil no 2
   10316           44 :         collapsedTotal(8) *= powerConversion;                             // propane
   10317           44 :         collapsedTotal(9) *= powerConversion;                             // otherfuel1
   10318           44 :         collapsedTotal(10) *= powerConversion;                            // otherfuel2
   10319           44 :         collapsedTotal(11) *= powerConversion;                            // purchased cooling
   10320           44 :         collapsedTotal(12) *= powerConversion;                            // district heating water
   10321           44 :         collapsedTotal(13) *= powerConversion;                            // district heating steam
   10322           44 :         collapsedTotal(14) *= flowConversion;                             // water
   10323              :         //---- End Use Sub-Table
   10324           44 :         rowHead.allocate(17);
   10325           44 :         columnHead.allocate(14);
   10326           44 :         columnWidth.allocate(14);
   10327           44 :         columnWidth = 10; // array assignment - same for all columns
   10328           44 :         tableBody.allocate(14, 17);
   10329          660 :         for (int iResource = 1; iResource <= 14; ++iResource) {
   10330         9240 :             for (int iEndUse = 0; iEndUse < static_cast<int>(Constant::EndUse::Num); ++iEndUse) {
   10331         8624 :                 useVal(iResource, iEndUse + 1) = collapsedEndUse(iResource, iEndUse + 1);
   10332              :             }
   10333          616 :             useVal(iResource, 15) = collapsedTotal(iResource); // totals
   10334              :         }
   10335              : 
   10336           44 :         rowHead(1) = "Time of Peak";
   10337           44 :         rowHead(static_cast<int>(Constant::EndUse::Heating) + 2) = "Heating";
   10338           44 :         rowHead(static_cast<int>(Constant::EndUse::Cooling) + 2) = "Cooling";
   10339           44 :         rowHead(static_cast<int>(Constant::EndUse::InteriorLights) + 2) = "Interior Lighting";
   10340           44 :         rowHead(static_cast<int>(Constant::EndUse::ExteriorLights) + 2) = "Exterior Lighting";
   10341           44 :         rowHead(static_cast<int>(Constant::EndUse::InteriorEquipment) + 2) = "Interior Equipment";
   10342           44 :         rowHead(static_cast<int>(Constant::EndUse::ExteriorEquipment) + 2) = "Exterior Equipment";
   10343           44 :         rowHead(static_cast<int>(Constant::EndUse::Fans) + 2) = "Fans";
   10344           44 :         rowHead(static_cast<int>(Constant::EndUse::Pumps) + 2) = "Pumps";
   10345           44 :         rowHead(static_cast<int>(Constant::EndUse::HeatRejection) + 2) = "Heat Rejection";
   10346           44 :         rowHead(static_cast<int>(Constant::EndUse::Humidification) + 2) = "Humidification";
   10347           44 :         rowHead(static_cast<int>(Constant::EndUse::HeatRecovery) + 2) = "Heat Recovery";
   10348           44 :         rowHead(static_cast<int>(Constant::EndUse::WaterSystem) + 2) = "Water Systems";
   10349           44 :         rowHead(static_cast<int>(Constant::EndUse::Refrigeration) + 2) = "Refrigeration";
   10350           44 :         rowHead(static_cast<int>(Constant::EndUse::Cogeneration) + 2) = "Generators";
   10351           44 :         rowHead(16) = "";
   10352           44 :         rowHead(17) = "Total End Uses";
   10353              : 
   10354           44 :         if (unitsStyle_cur == UnitsStyle::InchPound) {
   10355            2 :             columnHead(1) = "Electricity [kBtuh]";
   10356            2 :             columnHead(2) = "Natural Gas [kBtuh]";
   10357            2 :             columnHead(3) = "Gasoline [kBtuh]";
   10358            2 :             columnHead(4) = "Diesel [kBtuh]";
   10359            2 :             columnHead(5) = "Coal [kBtuh]";
   10360            2 :             columnHead(6) = "Fuel Oil No 1 [kBtuh]";
   10361            2 :             columnHead(7) = "Fuel Oil No 2 [kBtuh]";
   10362            2 :             columnHead(8) = "Propane [kBtuh]";
   10363            2 :             columnHead(9) = "Other Fuel 1 [kBtuh]";
   10364            2 :             columnHead(10) = "Other Fuel 2 [kBtuh]";
   10365            2 :             columnHead(11) = "District Cooling [kBtuh]";
   10366            2 :             columnHead(12) = "District Heating Water [kBtuh]";
   10367            2 :             columnHead(13) = "District Heating Steam [kBtuh]";
   10368            2 :             columnHead(14) = "Water [gal/min]";
   10369           42 :         } else if (unitsStyle_cur == UnitsStyle::InchPoundExceptElectricity) {
   10370            1 :             columnHead(1) = "Electricity [kW]";
   10371            1 :             columnHead(2) = "Natural Gas [kBtuh]";
   10372            1 :             columnHead(3) = "Gasoline [kBtuh]";
   10373            1 :             columnHead(4) = "Diesel [kBtuh]";
   10374            1 :             columnHead(5) = "Coal [kBtuh]";
   10375            1 :             columnHead(6) = "Fuel Oil No 1 [kBtuh]";
   10376            1 :             columnHead(7) = "Fuel Oil No 2 [kBtuh]";
   10377            1 :             columnHead(8) = "Propane [kBtuh]";
   10378            1 :             columnHead(9) = "Other Fuel 1 [kBtuh]";
   10379            1 :             columnHead(10) = "Other Fuel 2 [kBtuh]";
   10380            1 :             columnHead(11) = "District Cooling [kBtuh]";
   10381            1 :             columnHead(12) = "District Heating Water [kBtuh]";
   10382            1 :             columnHead(13) = "District Heating Steam [kBtuh]";
   10383            1 :             columnHead(14) = "Water [gal/min]";
   10384              :         } else {
   10385           41 :             columnHead(1) = "Electricity [W]";
   10386           41 :             columnHead(2) = "Natural Gas [W]";
   10387           41 :             columnHead(3) = "Gasoline [W]";
   10388           41 :             columnHead(4) = "Diesel [W]";
   10389           41 :             columnHead(5) = "Coal [W]";
   10390           41 :             columnHead(6) = "Fuel Oil No 1 [W]";
   10391           41 :             columnHead(7) = "Fuel Oil No 2 [W]";
   10392           41 :             columnHead(8) = "Propane [W]";
   10393           41 :             columnHead(9) = "Other Fuel 1 [W]";
   10394           41 :             columnHead(10) = "Other Fuel 2 [W]";
   10395           41 :             columnHead(11) = "District Cooling [W]";
   10396           41 :             columnHead(12) = "District Heating Water [W]";
   10397           41 :             columnHead(13) = "District Heating Steam [W]";
   10398           41 :             columnHead(14) = "Water [m3/s]";
   10399              :         }
   10400              : 
   10401           44 :         tableBody = "";
   10402          660 :         for (int iResource = 1; iResource <= 14; ++iResource) {
   10403         9240 :             for (int jEndUse = 1; jEndUse <= static_cast<int>(Constant::EndUse::Num); ++jEndUse) {
   10404         8624 :                 tableBody(iResource, 1 + jEndUse) = RealToStr(useVal(iResource, jEndUse), 2);
   10405              :             }
   10406          616 :             tableBody(iResource, 1) = DateToString(collapsedTimeStep(iResource));
   10407          616 :             tableBody(iResource, 17) = RealToStr(collapsedTotal(iResource), 2);
   10408              :         }
   10409              : 
   10410              :         // complete the LEED end use table using the same values
   10411              : 
   10412           44 :         if (produceTabular) {
   10413           42 :             WriteSubtitle(state, "End Uses");
   10414           42 :             WriteTable(state, tableBody, rowHead, columnHead, columnWidth, false, state.dataOutRptTab->footnote);
   10415              :         }
   10416           44 :         if (produceSQLite) {
   10417           42 :             if (state.dataSQLiteProcedures->sqlite) {
   10418            7 :                 state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
   10419              :                     tableBody, rowHead, columnHead, "DemandEndUseComponentsSummary", "Entire Facility", "End Uses");
   10420              :             }
   10421              :         }
   10422           44 :         if (produceTabular) {
   10423           42 :             if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
   10424            0 :                 state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(
   10425              :                     tableBody, rowHead, columnHead, "DemandEndUseComponentsSummary", "Entire Facility", "End Uses");
   10426              :             }
   10427              :         }
   10428              : 
   10429              :         //---- End Uses By Subcategory Sub-Table
   10430           44 :         int numRows = 0;
   10431          660 :         for (int jEndUse = 1; jEndUse <= static_cast<int>(Constant::EndUse::Num); ++jEndUse) {
   10432          616 :             if (op->EndUseCategory(jEndUse).NumSubcategories > 0) {
   10433          356 :                 for (int kEndUseSub = 1; kEndUseSub <= op->EndUseCategory(jEndUse).NumSubcategories; ++kEndUseSub) {
   10434          181 :                     ++numRows;
   10435              :                 }
   10436              :             } else {
   10437          441 :                 ++numRows;
   10438              :             }
   10439              :         }
   10440              : 
   10441           44 :         rowHead.allocate(numRows);
   10442           44 :         columnHead.allocate(15);
   10443           44 :         columnWidth.allocate(15);
   10444           44 :         columnWidth = 10; // array assignment - same for all columns
   10445           44 :         tableBody.allocate(15, numRows);
   10446              : 
   10447           88 :         rowHead = "";
   10448           44 :         tableBody = "";
   10449              : 
   10450              :         // Build row head and subcategories columns
   10451              :         {
   10452           44 :             int i = 1;
   10453          660 :             for (int jEndUse = 1; jEndUse <= static_cast<int>(Constant::EndUse::Num); ++jEndUse) {
   10454          616 :                 rowHead(i) = op->EndUseCategory(jEndUse).DisplayName;
   10455          616 :                 if (op->EndUseCategory(jEndUse).NumSubcategories > 0) {
   10456          356 :                     for (int kEndUseSub = 1; kEndUseSub <= op->EndUseCategory(jEndUse).NumSubcategories; ++kEndUseSub) {
   10457          181 :                         tableBody(1, i) = op->EndUseCategory(jEndUse).SubcategoryName(kEndUseSub);
   10458          181 :                         ++i;
   10459              :                     }
   10460              :                 } else {
   10461          441 :                     tableBody(1, i) = "General";
   10462          441 :                     ++i;
   10463              :                 }
   10464              :             }
   10465              :         }
   10466              : 
   10467           44 :         if (unitsStyle_cur == UnitsStyle::InchPound) {
   10468            2 :             columnHead(1) = "Subcategory";
   10469            2 :             columnHead(2) = "Electricity [kBtuh]";
   10470            2 :             columnHead(3) = "Natural Gas [kBtuh]";
   10471            2 :             columnHead(4) = "Gasoline [kBtuh]";
   10472            2 :             columnHead(5) = "Diesel [kBtuh]";
   10473            2 :             columnHead(6) = "Coal [kBtuh]";
   10474            2 :             columnHead(7) = "Fuel Oil No 1 [kBtuh]";
   10475            2 :             columnHead(8) = "Fuel Oil No 2 [kBtuh]";
   10476            2 :             columnHead(9) = "Propane [kBtuh]";
   10477            2 :             columnHead(10) = "Other Fuel 1 [kBtuh]";
   10478            2 :             columnHead(11) = "Other Fuel 2 [kBtuh]";
   10479            2 :             columnHead(12) = "District Cooling [kBtuh]";
   10480            2 :             columnHead(13) = "District Heating Water [kBtuh]";
   10481            2 :             columnHead(14) = "District Heating Steam [kBtuh]";
   10482            2 :             columnHead(15) = "Water [gal/min]";
   10483           42 :         } else if (unitsStyle_cur == UnitsStyle::InchPoundExceptElectricity) {
   10484            1 :             columnHead(1) = "Subcategory";
   10485            1 :             columnHead(2) = "Electricity [kW]";
   10486            1 :             columnHead(3) = "Natural Gas [kBtuh]";
   10487            1 :             columnHead(4) = "Gasoline [kBtuh]";
   10488            1 :             columnHead(5) = "Diesel [kBtuh]";
   10489            1 :             columnHead(6) = "Coal [kBtuh]";
   10490            1 :             columnHead(7) = "Fuel Oil No 1 [kBtuh]";
   10491            1 :             columnHead(8) = "Fuel Oil No 2 [kBtuh]";
   10492            1 :             columnHead(9) = "Propane [kBtuh]";
   10493            1 :             columnHead(10) = "Other Fuel 1 [kBtuh]";
   10494            1 :             columnHead(11) = "Other Fuel 2 [kBtuh]";
   10495            1 :             columnHead(12) = "District Cooling [kBtuh]";
   10496            1 :             columnHead(13) = "District Heating Water [kBtuh]";
   10497            1 :             columnHead(14) = "District Heating Steam [kBtuh]";
   10498            1 :             columnHead(15) = "Water [gal/min]";
   10499              :         } else {
   10500           41 :             columnHead(1) = "Subcategory";
   10501           41 :             columnHead(2) = "Electricity [W]";
   10502           41 :             columnHead(3) = "Natural Gas [W]";
   10503           41 :             columnHead(4) = "Gasoline [W]";
   10504           41 :             columnHead(5) = "Diesel [W]";
   10505           41 :             columnHead(6) = "Coal [W]";
   10506           41 :             columnHead(7) = "Fuel Oil No 1 [W]";
   10507           41 :             columnHead(8) = "Fuel Oil No 2 [W]";
   10508           41 :             columnHead(9) = "Propane [W]";
   10509           41 :             columnHead(10) = "Other Fuel 1 [W]";
   10510           41 :             columnHead(11) = "Other Fuel 2 [W]";
   10511           41 :             columnHead(12) = "District Cooling [W]";
   10512           41 :             columnHead(13) = "District Heating Water [W]";
   10513           41 :             columnHead(14) = "District Heating Steam [W]";
   10514           41 :             columnHead(15) = "Water [m3/s]";
   10515              :         }
   10516              : 
   10517          660 :         for (int iResource = 1; iResource <= 14; ++iResource) {
   10518          616 :             int i = 1;
   10519         9240 :             for (int jEndUse = 1; jEndUse <= static_cast<int>(Constant::EndUse::Num); ++jEndUse) {
   10520         8624 :                 if (op->EndUseCategory(jEndUse).NumSubcategories > 0) {
   10521         4984 :                     for (int kEndUseSub = 1; kEndUseSub <= op->EndUseCategory(jEndUse).NumSubcategories; ++kEndUseSub) {
   10522         2534 :                         tableBody(iResource + 1, i) = RealToStr(collapsedEndUseSub(kEndUseSub, jEndUse, iResource), 2);
   10523         2534 :                         ++i;
   10524              :                     }
   10525              :                 } else {
   10526         6174 :                     tableBody(iResource + 1, i) = RealToStr(collapsedEndUse(iResource, jEndUse), 2);
   10527         6174 :                     ++i;
   10528              :                 }
   10529              :             }
   10530              :         }
   10531              : 
   10532              :         // heading for the entire sub-table
   10533           44 :         if (produceTabular) {
   10534           42 :             WriteSubtitle(state, "End Uses By Subcategory");
   10535           42 :             WriteTable(state, tableBody, rowHead, columnHead, columnWidth, false, state.dataOutRptTab->footnote);
   10536              :         }
   10537              : 
   10538           44 :         Array1D_string rowHeadTemp(rowHead);
   10539              :         // Before outputting to SQL, we forward fill the End use column (rowHead) (cf #7481)
   10540              :         // for better sql queries
   10541           44 :         FillRowHead(rowHeadTemp);
   10542              : 
   10543          666 :         for (int i = 1; i <= numRows; ++i) {
   10544          622 :             rowHeadTemp(i) = rowHeadTemp(i) + ":" + tableBody(1, i);
   10545              :         }
   10546              : 
   10547              :         // Erase the SubCategory (first column), using slicing
   10548          308 :         Array2D_string tableBodyTemp(tableBody({2, _, _}, {_, _, _}));
   10549          176 :         Array1D_string columnHeadTemp(columnHead({2, _, _}));
   10550              : 
   10551           44 :         if (produceSQLite) {
   10552           42 :             if (state.dataSQLiteProcedures->sqlite) {
   10553            7 :                 state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
   10554              :                     tableBodyTemp, rowHeadTemp, columnHeadTemp, "DemandEndUseComponentsSummary", "Entire Facility", "End Uses By Subcategory");
   10555              :             }
   10556              :         }
   10557              : 
   10558           44 :         if (produceTabular) {
   10559           42 :             if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
   10560            0 :                 state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(
   10561              :                     tableBodyTemp, rowHeadTemp, columnHeadTemp, "DemandEndUseComponentsSummary", "Entire Facility", "End Uses By Subcategory");
   10562              :             }
   10563              :         }
   10564           44 :         rowHeadTemp.deallocate();
   10565           44 :         tableBodyTemp.deallocate();
   10566           44 :         columnHeadTemp.deallocate();
   10567           44 :     }
   10568              : 
   10569              :     // EAp2-4/5. Performance Rating Method Compliance
   10570          630 :     for (int iResource = 1; iResource <= 14; ++iResource) {
   10571         8820 :         for (int jEndUse = 1; jEndUse <= static_cast<int>(Constant::EndUse::Num); ++jEndUse) {
   10572         8232 :             if (ort->needOtherRowLEED45(jEndUse)) {
   10573            0 :                 if (op->EndUseCategory(jEndUse).NumSubcategories == 0) {
   10574            0 :                     endUseSubOther(iResource, jEndUse) = collapsedIndEndUse(iResource, jEndUse); // often the case that no subcategories are defined
   10575              :                 } else {
   10576            0 :                     Real64 sumOfSubcategories = 0.;
   10577            0 :                     for (int kEndUseSub = 1; kEndUseSub <= op->EndUseCategory(jEndUse).NumSubcategories; ++kEndUseSub) {
   10578            0 :                         sumOfSubcategories += collapsedIndEndUseSub(kEndUseSub, jEndUse, iResource);
   10579              :                     }
   10580            0 :                     endUseSubOther(iResource, jEndUse) = collapsedIndEndUse(iResource, jEndUse) - sumOfSubcategories;
   10581            0 :                     if (endUseSubOther(iResource, jEndUse) < 0.) {
   10582            0 :                         endUseSubOther(iResource, jEndUse) = 0.;
   10583              :                     }
   10584              :                 }
   10585              :             }
   10586              :         }
   10587              :     }
   10588              : 
   10589           42 :     Array1D_int resource_entry_map;
   10590           42 :     resource_entry_map.allocate(13);
   10591           42 :     resource_entry_map(1) = state.dataOutRptPredefined->pdchLeedPerfElDem;          // electricity
   10592           42 :     resource_entry_map(2) = state.dataOutRptPredefined->pdchLeedPerfGasDem;         // natural gas
   10593           42 :     resource_entry_map(3) = state.dataOutRptPredefined->pdchLeedPerfGasolineDem;    // gasoline
   10594           42 :     resource_entry_map(4) = state.dataOutRptPredefined->pdchLeedPerfDieselDem;      // diesel
   10595           42 :     resource_entry_map(5) = state.dataOutRptPredefined->pdchLeedPerfCoalDem;        // coal
   10596           42 :     resource_entry_map(6) = state.dataOutRptPredefined->pdchLeedPerfFuelOil1Dem;    // fuel oil no 1
   10597           42 :     resource_entry_map(7) = state.dataOutRptPredefined->pdchLeedPerfFuelOil2Dem;    // fuel oil no 2
   10598           42 :     resource_entry_map(8) = state.dataOutRptPredefined->pdchLeedPerfPropaneDem;     // propane
   10599           42 :     resource_entry_map(9) = state.dataOutRptPredefined->pdchLeedPerfOtherFuel1Dem;  // other fuel 1
   10600           42 :     resource_entry_map(10) = state.dataOutRptPredefined->pdchLeedPerfOtherFuel2Dem; // other fuel 2
   10601           42 :     resource_entry_map(11) = state.dataOutRptPredefined->pdchLeedPerfDisClDem;      // district cooling
   10602           42 :     resource_entry_map(12) = state.dataOutRptPredefined->pdchLeedPerfDisHtWtrDem;   // district heating water
   10603           42 :     resource_entry_map(13) = state.dataOutRptPredefined->pdchLeedPerfDisHtStDem;    // district heating steam
   10604              : 
   10605          588 :     for (int iResource = 1; iResource <= 13; ++iResource) {
   10606          546 :         int i = 1;
   10607          546 :         Real64 localUnconvert = (iResource == 1) ? ipElectricityConversion : 1.0;
   10608         8190 :         for (int jEndUse = 1; jEndUse <= static_cast<int>(Constant::EndUse::Num); ++jEndUse) {
   10609         7644 :             if (op->EndUseCategory(jEndUse).NumSubcategories > 0) {
   10610         4498 :                 for (int kEndUseSub = 1; kEndUseSub <= op->EndUseCategory(jEndUse).NumSubcategories; ++kEndUseSub) {
   10611         4550 :                     PreDefTableEntry(state,
   10612         2275 :                                      resource_entry_map(iResource),
   10613         4550 :                                      op->EndUseCategory(jEndUse).DisplayName + " -- " + op->EndUseCategory(jEndUse).SubcategoryName(kEndUseSub),
   10614         2275 :                                      localUnconvert * collapsedIndEndUseSub(kEndUseSub, jEndUse, iResource));
   10615         2275 :                     ++i;
   10616              :                 }
   10617              :                 // put other
   10618         2223 :                 if (ort->needOtherRowLEED45(jEndUse)) {
   10619            0 :                     PreDefTableEntry(state,
   10620            0 :                                      resource_entry_map(iResource),
   10621            0 :                                      op->EndUseCategory(jEndUse).DisplayName + " -- Other",
   10622            0 :                                      localUnconvert * endUseSubOther(iResource, jEndUse));
   10623            0 :                     ++i;
   10624              :                 }
   10625              :             } else {
   10626        10842 :                 PreDefTableEntry(state,
   10627         5421 :                                  resource_entry_map(iResource),
   10628        10842 :                                  op->EndUseCategory(jEndUse).DisplayName + " -- Not Subdivided",
   10629         5421 :                                  localUnconvert * collapsedIndEndUse(iResource, jEndUse));
   10630         5421 :                 ++i;
   10631              :             }
   10632              :         }
   10633              :     }
   10634          130 : }
   10635              : 
   10636           38 : void WriteCompCostTable(EnergyPlusData &state)
   10637              : {
   10638              : 
   10639              :     // SUBROUTINE INFORMATION:
   10640              :     //       AUTHOR         BGriffith
   10641              :     //       DATE WRITTEN   April/May 2004
   10642              :     //       MODIFIED       January 2010, Kyle Benne
   10643              :     //                      Added SQLite output
   10644              :     //       RE-ENGINEERED  na
   10645              : 
   10646              :     // PURPOSE OF THIS SUBROUTINE:
   10647              :     // produce a results table from Cost Estimate Calculations
   10648              : 
   10649              :     // METHODOLOGY EMPLOYED:
   10650              :     // USE data from CostEstimateManager, call JGlazer's subroutines
   10651              : 
   10652              :     // REFERENCES:
   10653              :     // na
   10654              : 
   10655              :     // Using/Aliasing
   10656              : 
   10657              :     // Locals
   10658              :     // SUBROUTINE ARGUMENT DEFINITIONS:
   10659              :     // na
   10660              : 
   10661              :     // SUBROUTINE PARAMETER DEFINITIONS:
   10662              :     // na
   10663              : 
   10664              :     // INTERFACE BLOCK SPECIFICATIONS:
   10665              :     // na
   10666              : 
   10667              :     // DERIVED TYPE DEFINITIONS:
   10668              :     // na
   10669              : 
   10670              :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
   10671           38 :     auto const &ort = state.dataOutRptTab;
   10672              : 
   10673           38 :     if (!state.dataCostEstimateManager->DoCostEstimate) {
   10674           38 :         return;
   10675              :     }
   10676              : 
   10677            0 :     Array2D<Real64> TableBodyData(3, 10);
   10678            0 :     Array1D_string columnHead;
   10679            0 :     Array1D_int columnWidth;
   10680            0 :     Array1D_string rowHead;
   10681            0 :     Array2D_string tableBody;
   10682              : 
   10683            0 :     WriteReportHeaders(state, "Component Cost Economics Summary", "Entire Facility", OutputProcessor::StoreType::Average);
   10684              : 
   10685              :     // compute floor area if no ABUPS
   10686            0 :     if (ort->buildingConditionedFloorArea == 0.0) {
   10687            0 :         DetermineBuildingFloorArea(state);
   10688              :     }
   10689              : 
   10690            0 :     for (int iUnitSystem = 0; iUnitSystem <= 1; iUnitSystem++) {
   10691            0 :         UnitsStyle unitsStyle_cur = ort->unitsStyle;
   10692            0 :         bool produceTabular = true;
   10693            0 :         bool produceSQLite = false;
   10694            0 :         if (produceDualUnitsFlags(iUnitSystem, ort->unitsStyle, ort->unitsStyle_SQLite, unitsStyle_cur, produceTabular, produceSQLite)) break;
   10695              : 
   10696              :         // 1st sub-table with total Costs and normalized with area
   10697            0 :         rowHead.allocate(10);
   10698            0 :         columnHead.allocate(3);
   10699            0 :         columnWidth.allocate(3);
   10700            0 :         columnWidth = 14; // array assignment - same for all columns
   10701            0 :         tableBody.allocate(3, 10);
   10702              : 
   10703            0 :         columnHead(1) = "Reference Bldg.";
   10704            0 :         columnHead(2) = "Current Bldg. Model";
   10705            0 :         columnHead(3) = "Difference";
   10706              : 
   10707            0 :         rowHead(1) = "Line Item SubTotal (~~$~~)";
   10708            0 :         rowHead(2) = "Misc. Costs (~~$~~)";
   10709            0 :         rowHead(3) = "Regional Adjustment (~~$~~)";
   10710            0 :         rowHead(4) = "Design Fee (~~$~~)";
   10711            0 :         rowHead(5) = "Contractor Fee (~~$~~)";
   10712            0 :         rowHead(6) = "Contingency (~~$~~)";
   10713            0 :         rowHead(7) = "Permits, Bonds, Insurance (~~$~~)";
   10714            0 :         rowHead(8) = "Commissioning (~~$~~)";
   10715            0 :         rowHead(9) = "Cost Estimate Total (~~$~~)";
   10716            0 :         if (unitsStyle_cur == OutputReportTabular::UnitsStyle::InchPound ||
   10717            0 :             unitsStyle_cur == OutputReportTabular::UnitsStyle::InchPoundExceptElectricity) {
   10718            0 :             std::string const SIunit = "[m2]";
   10719            0 :             std::string m2_unitName;
   10720            0 :             LookupSItoIP(state, SIunit, state.dataOutRptTab->unitConvIndexWCCT, m2_unitName);
   10721            0 :             state.dataOutRptTab->m2_unitConv = ConvertIP(state, state.dataOutRptTab->unitConvIndexWCCT, 1.0);
   10722            0 :             rowHead(10) = "Cost Per Conditioned Building Area (~~$~~/ft2)";
   10723            0 :         } else {
   10724            0 :             rowHead(10) = "Cost Per Conditioned Building Area (~~$~~/m2)";
   10725            0 :             state.dataOutRptTab->m2_unitConv = 1.0;
   10726              :         }
   10727            0 :         TableBodyData = 0.0;
   10728            0 :         tableBody = "";
   10729              : 
   10730            0 :         TableBodyData(1, 1) = state.dataCostEstimateManager->RefrncBldg.LineItemTot;
   10731            0 :         tableBody(1, 1) = RealToStr(TableBodyData(1, 1), 2);
   10732            0 :         TableBodyData(1, 2) = state.dataCostEstimateManager->RefrncBldg.MiscCostperSqMeter * ort->buildingConditionedFloorArea;
   10733            0 :         tableBody(1, 2) = RealToStr(TableBodyData(1, 2), 2);
   10734              : 
   10735            0 :         if (state.dataCostEstimateManager->RefrncBldg.RegionalModifier != 1.0) {
   10736            0 :             TableBodyData(1, 3) = (state.dataCostEstimateManager->RefrncBldg.LineItemTot +
   10737            0 :                                    state.dataCostEstimateManager->RefrncBldg.MiscCostperSqMeter * ort->buildingConditionedFloorArea) *
   10738            0 :                                   (state.dataCostEstimateManager->RefrncBldg.RegionalModifier - 1.0);
   10739              :         } else {
   10740            0 :             TableBodyData(1, 3) = 0.0;
   10741              :         }
   10742              : 
   10743              :         // holds interim value for construction component costs: reference bldg.
   10744            0 :         Real64 const RefBldgConstCost = sum(TableBodyData(1, {1, 3}));
   10745              : 
   10746            0 :         tableBody(1, 3) = RealToStr(TableBodyData(1, 3), 2);
   10747            0 :         TableBodyData(1, 4) = RefBldgConstCost * state.dataCostEstimateManager->RefrncBldg.DesignFeeFrac;
   10748            0 :         tableBody(1, 4) = RealToStr(TableBodyData(1, 4), 2);
   10749            0 :         TableBodyData(1, 5) = RefBldgConstCost * state.dataCostEstimateManager->RefrncBldg.ContractorFeeFrac;
   10750            0 :         tableBody(1, 5) = RealToStr(TableBodyData(1, 5), 2);
   10751            0 :         TableBodyData(1, 6) = RefBldgConstCost * state.dataCostEstimateManager->RefrncBldg.ContingencyFrac;
   10752            0 :         tableBody(1, 6) = RealToStr(TableBodyData(1, 6), 2);
   10753            0 :         TableBodyData(1, 7) = RefBldgConstCost * state.dataCostEstimateManager->RefrncBldg.BondCostFrac;
   10754            0 :         tableBody(1, 7) = RealToStr(TableBodyData(1, 7), 2);
   10755            0 :         TableBodyData(1, 8) = RefBldgConstCost * state.dataCostEstimateManager->RefrncBldg.CommissioningFrac;
   10756            0 :         tableBody(1, 8) = RealToStr(TableBodyData(1, 8), 2);
   10757            0 :         state.dataCostEstimateManager->RefrncBldg.GrandTotal = sum(TableBodyData(1, {1, 8}));
   10758            0 :         TableBodyData(1, 9) = state.dataCostEstimateManager->RefrncBldg.GrandTotal;
   10759            0 :         tableBody(1, 9) = RealToStr(TableBodyData(1, 9), 2);
   10760            0 :         if (ort->buildingConditionedFloorArea > 0.0) {
   10761            0 :             TableBodyData(1, 10) = TableBodyData(1, 9) / (ort->buildingConditionedFloorArea * state.dataOutRptTab->m2_unitConv);
   10762              :         }
   10763            0 :         tableBody(1, 10) = RealToStr(TableBodyData(1, 10), 2);
   10764              : 
   10765            0 :         TableBodyData(2, 1) = state.dataCostEstimateManager->CurntBldg.LineItemTot;
   10766            0 :         tableBody(2, 1) = RealToStr(TableBodyData(2, 1), 2);
   10767            0 :         TableBodyData(2, 2) = state.dataCostEstimateManager->CurntBldg.MiscCostperSqMeter * ort->buildingConditionedFloorArea;
   10768            0 :         tableBody(2, 2) = RealToStr(TableBodyData(2, 2), 2);
   10769            0 :         if (state.dataCostEstimateManager->CurntBldg.RegionalModifier != 1.0) {
   10770            0 :             TableBodyData(2, 3) = (state.dataCostEstimateManager->CurntBldg.LineItemTot +
   10771            0 :                                    state.dataCostEstimateManager->CurntBldg.MiscCostperSqMeter * ort->buildingConditionedFloorArea) *
   10772            0 :                                   (state.dataCostEstimateManager->CurntBldg.RegionalModifier - 1.0);
   10773              :         } else {
   10774            0 :             TableBodyData(2, 3) = 0.0;
   10775              :         }
   10776            0 :         tableBody(2, 3) = RealToStr(TableBodyData(2, 3), 2);
   10777              : 
   10778              :         // holds interim value for construction component costs: current bldg.
   10779            0 :         Real64 const CurntBldgConstCost = sum(TableBodyData(2, {1, 3}));
   10780              : 
   10781            0 :         TableBodyData(2, 4) = CurntBldgConstCost * state.dataCostEstimateManager->CurntBldg.DesignFeeFrac;
   10782            0 :         tableBody(2, 4) = RealToStr(TableBodyData(2, 4), 2);
   10783              : 
   10784            0 :         TableBodyData(2, 5) = CurntBldgConstCost * state.dataCostEstimateManager->CurntBldg.ContractorFeeFrac;
   10785            0 :         tableBody(2, 5) = RealToStr(TableBodyData(2, 5), 2);
   10786            0 :         TableBodyData(2, 6) = CurntBldgConstCost * state.dataCostEstimateManager->CurntBldg.ContingencyFrac;
   10787            0 :         tableBody(2, 6) = RealToStr(TableBodyData(2, 6), 2);
   10788            0 :         TableBodyData(2, 7) = CurntBldgConstCost * state.dataCostEstimateManager->CurntBldg.BondCostFrac;
   10789            0 :         tableBody(2, 7) = RealToStr(TableBodyData(2, 7), 2);
   10790            0 :         TableBodyData(2, 8) = CurntBldgConstCost * state.dataCostEstimateManager->CurntBldg.CommissioningFrac;
   10791            0 :         tableBody(2, 8) = RealToStr(TableBodyData(2, 8), 2);
   10792              : 
   10793            0 :         state.dataCostEstimateManager->CurntBldg.GrandTotal = sum(TableBodyData(2, {1, 8}));
   10794            0 :         TableBodyData(2, 9) = state.dataCostEstimateManager->CurntBldg.GrandTotal;
   10795            0 :         tableBody(2, 9) = RealToStr(TableBodyData(2, 9), 2);
   10796            0 :         if (ort->buildingConditionedFloorArea > 0) {
   10797            0 :             TableBodyData(2, 10) = TableBodyData(2, 9) / (ort->buildingConditionedFloorArea * state.dataOutRptTab->m2_unitConv);
   10798              :         }
   10799            0 :         tableBody(2, 10) = RealToStr(TableBodyData(2, 10), 2);
   10800              : 
   10801            0 :         TableBodyData(3, {1, 10}) = TableBodyData(2, {1, 10}) - TableBodyData(1, {1, 10});
   10802            0 :         tableBody(3, 1) = RealToStr(TableBodyData(3, 1), 2);
   10803            0 :         tableBody(3, 2) = RealToStr(TableBodyData(3, 2), 2);
   10804            0 :         tableBody(3, 3) = RealToStr(TableBodyData(3, 3), 2);
   10805            0 :         tableBody(3, 4) = RealToStr(TableBodyData(3, 4), 2);
   10806            0 :         tableBody(3, 5) = RealToStr(TableBodyData(3, 5), 2);
   10807            0 :         tableBody(3, 6) = RealToStr(TableBodyData(3, 6), 2);
   10808            0 :         tableBody(3, 7) = RealToStr(TableBodyData(3, 7), 2);
   10809            0 :         tableBody(3, 8) = RealToStr(TableBodyData(3, 8), 2);
   10810            0 :         tableBody(3, 9) = RealToStr(TableBodyData(3, 9), 2);
   10811            0 :         tableBody(3, 10) = RealToStr(TableBodyData(3, 10), 2);
   10812              : 
   10813            0 :         if (produceTabular) {
   10814            0 :             WriteSubtitle(state, "Construction Cost Estimate Summary");
   10815            0 :             WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
   10816              :         }
   10817            0 :         if (produceSQLite) {
   10818            0 :             if (state.dataSQLiteProcedures->sqlite) {
   10819            0 :                 state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
   10820              :                     tableBody, rowHead, columnHead, "Construction Cost Estimate Summary", "Entire Facility", "Construction Cost Estimate Summary");
   10821              :             }
   10822              :         }
   10823            0 :         if (produceTabular) {
   10824            0 :             if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
   10825            0 :                 state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(
   10826              :                     tableBody, rowHead, columnHead, "Construction Cost Estimate Summary", "Entire Facility", "Construction Cost Estimate Summary");
   10827              :             }
   10828              :         }
   10829              : 
   10830            0 :         int const NumRows = static_cast<int>(state.dataCostEstimateManager->CostLineItem.size()) + 1; // body will have the total and line items
   10831            0 :         int const NumCols = 6; // Line no., Line name, Qty, Units, ValperQty, Subtotal
   10832            0 :         rowHead.allocate(NumRows);
   10833            0 :         columnHead.allocate(NumCols);
   10834            0 :         columnWidth.dimension(NumCols, 14); // array assignment - same for all columns
   10835            0 :         tableBody.allocate(NumCols, NumRows);
   10836            0 :         tableBody = "--";                        // array init
   10837            0 :         rowHead = "--";                          // array init
   10838            0 :         rowHead(NumRows) = "Line Item SubTotal"; // last line in table will be a total
   10839              :         // setup up column headers
   10840            0 :         columnHead(1) = "Line No.";
   10841            0 :         columnHead(2) = "Item Name";
   10842            0 :         columnHead(3) = "Quantity.";
   10843            0 :         columnHead(4) = "Units";
   10844            0 :         columnHead(5) = "~~$~~ per Qty.";
   10845            0 :         columnHead(6) = "SubTotal ~~$~~";
   10846              : 
   10847            0 :         columnWidth = {7, 30, 16, 10, 16, 16}; // array assignment - for all columns
   10848              : 
   10849            0 :         for (int item = 1; item <= (int)state.dataCostEstimateManager->CostLineItem.size(); ++item) {
   10850            0 :             tableBody(1, item) = fmt::to_string(state.dataCostEstimateManager->CostLineItem(item).LineNumber);
   10851            0 :             tableBody(2, item) = state.dataCostEstimateManager->CostLineItem(item).LineName;
   10852            0 :             if (unitsStyle_cur == OutputReportTabular::UnitsStyle::InchPound ||
   10853            0 :                 unitsStyle_cur == OutputReportTabular::UnitsStyle::InchPoundExceptElectricity) {
   10854            0 :                 std::string IPunitName;
   10855            0 :                 LookupSItoIP(state, state.dataCostEstimateManager->CostLineItem(item).Units, state.dataOutRptTab->unitConvIndexWCCT, IPunitName);
   10856            0 :                 if (state.dataOutRptTab->unitConvIndexWCCT != 0) {
   10857              :                     Real64 const IPqty =
   10858            0 :                         ConvertIP(state, state.dataOutRptTab->unitConvIndexWCCT, state.dataCostEstimateManager->CostLineItem(item).Qty);
   10859            0 :                     tableBody(3, item) = RealToStr(IPqty, 2);
   10860            0 :                     tableBody(4, item) = IPunitName;
   10861            0 :                     Real64 const IPsingleValue = ConvertIP(state, state.dataOutRptTab->unitConvIndexWCCT, 1.0);
   10862            0 :                     if (IPsingleValue != 0.0) {
   10863            0 :                         Real64 const IPvaluePer = state.dataCostEstimateManager->CostLineItem(item).ValuePer / IPsingleValue;
   10864            0 :                         tableBody(5, item) = RealToStr(IPvaluePer, 2);
   10865              :                     }
   10866              :                 } else {
   10867            0 :                     tableBody(3, item) = RealToStr(state.dataCostEstimateManager->CostLineItem(item).Qty, 2);
   10868            0 :                     tableBody(4, item) = state.dataCostEstimateManager->CostLineItem(item).Units;
   10869            0 :                     tableBody(5, item) = RealToStr(state.dataCostEstimateManager->CostLineItem(item).ValuePer, 2);
   10870              :                 }
   10871            0 :             } else {
   10872            0 :                 tableBody(3, item) = RealToStr(state.dataCostEstimateManager->CostLineItem(item).Qty, 2);
   10873            0 :                 tableBody(4, item) = state.dataCostEstimateManager->CostLineItem(item).Units;
   10874            0 :                 tableBody(5, item) = RealToStr(state.dataCostEstimateManager->CostLineItem(item).ValuePer, 2);
   10875              :             }
   10876            0 :             tableBody(6, item) = RealToStr(state.dataCostEstimateManager->CostLineItem(item).LineSubTotal, 2);
   10877              :         }
   10878            0 :         tableBody(6, NumRows) = RealToStr(state.dataCostEstimateManager->CurntBldg.LineItemTot, 2);
   10879            0 :         if (produceTabular) {
   10880            0 :             WriteSubtitle(state, "Cost Line Item Details"); //: '//TRIM(RealToStr(CostEstimateTotal, 2)))
   10881            0 :             WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
   10882              :         }
   10883            0 :         if (produceSQLite) {
   10884            0 :             if (state.dataSQLiteProcedures->sqlite) {
   10885            0 :                 state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
   10886              :                     tableBody, rowHead, columnHead, "Construction Cost Estimate Summary", "Entire Facility", "Cost Line Item Details");
   10887              :             }
   10888              :         }
   10889            0 :         if (produceTabular) {
   10890            0 :             if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
   10891            0 :                 state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(
   10892              :                     tableBody, rowHead, columnHead, "Construction Cost Estimate Summary", "Entire Facility", "Cost Line Item Details");
   10893              :             }
   10894              :         }
   10895              :     }
   10896            0 : }
   10897              : 
   10898              : // modify the ith row in the reportingperiod input verification table
   10899            0 : void writeRowReportPeriodInputVeri(const std::string &reportType,
   10900              :                                    Array2D_string &tableBody,
   10901              :                                    const int rowid,
   10902              :                                    const int periodIdx,
   10903              :                                    const Array1D<Weather::ReportPeriodData> &ReportPeriodInputData)
   10904              : {
   10905            0 :     tableBody(1, rowid) = reportType;
   10906            0 :     tableBody(2, rowid) = std::to_string(periodIdx);
   10907            0 :     tableBody(3, rowid) = ReportPeriodInputData(periodIdx).title;
   10908            0 :     tableBody(4, rowid) = formatReportPeriodTimestamp(ReportPeriodInputData(periodIdx).startYear,
   10909            0 :                                                       ReportPeriodInputData(periodIdx).startMonth,
   10910            0 :                                                       ReportPeriodInputData(periodIdx).startDay,
   10911            0 :                                                       ReportPeriodInputData(periodIdx).startHour);
   10912            0 :     tableBody(5, rowid) = formatReportPeriodTimestamp(ReportPeriodInputData(periodIdx).endYear,
   10913            0 :                                                       ReportPeriodInputData(periodIdx).endMonth,
   10914            0 :                                                       ReportPeriodInputData(periodIdx).endDay,
   10915            0 :                                                       ReportPeriodInputData(periodIdx).endHour);
   10916            0 :     tableBody(6, rowid) = RealToStr(ReportPeriodInputData(periodIdx).totalElectricityUse / 3600000.0, 2);
   10917            0 : }
   10918              : 
   10919           42 : void WriteVeriSumTable(EnergyPlusData &state)
   10920              : {
   10921              :     // SUBROUTINE INFORMATION:
   10922              :     //       AUTHOR         Jason Glazer
   10923              :     //       DATE WRITTEN   June 2006
   10924              :     //       MODIFIED       Jan. 2010, Kyle Benne. Added SQLite output
   10925              :     //                      Aug. 2015, Sang Hoon Lee. Added a new table for hybrid modeling multiplier output.
   10926              :     //       RE-ENGINEERED  na
   10927              : 
   10928              :     // PURPOSE OF THIS SUBROUTINE:
   10929              :     //   Summarize inputs and results for use with code and beyond-code
   10930              :     //   compliance into a tabular report for output.
   10931              : 
   10932              :     // METHODOLOGY EMPLOYED:
   10933              :     //   Create arrays for the call to WriteTable and then call it.
   10934              :     //   This report actually consists of many sub-tables each with
   10935              :     //   its own call to WriteTable.
   10936              : 
   10937              :     // Using/Aliasing
   10938              :     using DataHeatBalance::ZoneData;
   10939              :     using DataSurfaces::ExternalEnvironment;
   10940              :     using DataSurfaces::Ground;
   10941              :     using DataSurfaces::GroundFCfactorMethod;
   10942              :     using DataSurfaces::KivaFoundation;
   10943              :     using DataSurfaces::OtherSideCondModeledExt;
   10944              :     using DataSurfaces::SurfaceClass;
   10945              :     using General::SafeDivide;
   10946              : 
   10947           42 :     auto const &ort = state.dataOutRptTab;
   10948              : 
   10949              :     // all arrays are in the format: (row, column)
   10950           42 :     if (!ort->displayTabularVeriSum) {
   10951            0 :         return;
   10952              :     }
   10953              : 
   10954              :     // SUBROUTINE PARAMETER DEFINITIONS:
   10955           42 :     int constexpr wwrcTotal(1);
   10956           42 :     int constexpr wwrcNorth(2);
   10957           42 :     int constexpr wwrcEast(3);
   10958           42 :     int constexpr wwrcSouth(4);
   10959           42 :     int constexpr wwrcWest(5);
   10960           42 :     int constexpr wwrrWall(1);
   10961           42 :     int constexpr wwrrAbvGndWall(2);
   10962           42 :     int constexpr wwrrWindow(3);
   10963           42 :     int constexpr wwrrWWR(4);
   10964           42 :     int constexpr wwrrAbvGndWWR(5);
   10965              : 
   10966              :     // all arrays are in the format: (row, column)
   10967           42 :     Array1D_string columnHead;
   10968           42 :     Array1D_int columnWidth;
   10969           42 :     Array1D_string rowHead;
   10970           42 :     Array2D_string tableBody;
   10971              : 
   10972           42 :     Array1D<Real64> zoneOpeningArea;
   10973           42 :     zoneOpeningArea.allocate(state.dataGlobal->NumOfZones);
   10974              :     // zoneOpeningArea = 0.0;
   10975              : 
   10976           42 :     Array1D<Real64> zoneGlassArea;
   10977           42 :     zoneGlassArea.allocate(state.dataGlobal->NumOfZones);
   10978              :     // zoneGlassArea = 0.0;
   10979              : 
   10980           88 :     for (int iUnitSystem = 0; iUnitSystem <= 1; iUnitSystem++) {
   10981           84 :         UnitsStyle unitsStyle_cur = ort->unitsStyle;
   10982           84 :         bool produceTabular = true;
   10983           84 :         bool produceSQLite = false;
   10984           84 :         if (produceDualUnitsFlags(iUnitSystem, ort->unitsStyle, ort->unitsStyle_SQLite, unitsStyle_cur, produceTabular, produceSQLite)) break;
   10985              : 
   10986              :         // show the headers of the report
   10987           46 :         if (produceTabular) {
   10988          168 :             WriteReportHeaders(state, "Input Verification and Results Summary", "Entire Facility", OutputProcessor::StoreType::Average);
   10989              :         }
   10990              : 
   10991              :         // Moved these initializations into the loop
   10992           46 :         state.dataOutRptTab->zstArea = 0.0;
   10993           46 :         state.dataOutRptTab->zstVolume = 0.0;
   10994           46 :         state.dataOutRptTab->zstWallArea = 0.0;
   10995           46 :         state.dataOutRptTab->zstUndWallArea = 0.0;
   10996           46 :         state.dataOutRptTab->zstWindowArea = 0.0;
   10997           46 :         state.dataOutRptTab->zstOpeningArea = 0.0;
   10998           46 :         state.dataOutRptTab->zstLight = 0.0;
   10999           46 :         state.dataOutRptTab->zstPeople = 0.0;
   11000           46 :         state.dataOutRptTab->zstPlug = 0.0;
   11001              : 
   11002           46 :         zoneOpeningArea = 0.0;
   11003           46 :         zoneGlassArea = 0.0;
   11004              : 
   11005              :         // do unit conversions if necessary
   11006           46 :         if (unitsStyle_cur == UnitsStyle::InchPound) {
   11007            3 :             std::string SIunit;
   11008            3 :             SIunit = "[m]";
   11009            3 :             LookupSItoIP(state, SIunit, state.dataOutRptTab->unitConvIndexWVST, state.dataOutRptTab->m_unitName);
   11010            3 :             state.dataOutRptTab->m_unitConv = ConvertIP(state, state.dataOutRptTab->unitConvIndexWVST, 1.0);
   11011            3 :             SIunit = "[m2]";
   11012            3 :             LookupSItoIP(state, SIunit, state.dataOutRptTab->unitConvIndexWVST, state.dataOutRptTab->m2_unitName);
   11013            3 :             state.dataOutRptTab->m2_unitConvWVST = ConvertIP(state, state.dataOutRptTab->unitConvIndexWVST, 1.0);
   11014            3 :             SIunit = "[m3]";
   11015            3 :             LookupSItoIP(state, SIunit, state.dataOutRptTab->unitConvIndexWVST, state.dataOutRptTab->m3_unitName);
   11016            3 :             state.dataOutRptTab->m3_unitConv = ConvertIP(state, state.dataOutRptTab->unitConvIndexWVST, 1.0);
   11017            3 :             SIunit = "[W/m2]";
   11018            3 :             LookupSItoIP(state, SIunit, state.dataOutRptTab->unitConvIndexWVST, state.dataOutRptTab->Wm2_unitName);
   11019            3 :             state.dataOutRptTab->Wm2_unitConv = ConvertIP(state, state.dataOutRptTab->unitConvIndexWVST, 1.0);
   11020           46 :         } else if (unitsStyle_cur == UnitsStyle::InchPoundExceptElectricity) {
   11021            0 :             std::string SIunit;
   11022            0 :             SIunit = "[m]";
   11023            0 :             LookupSItoIP(state, SIunit, state.dataOutRptTab->unitConvIndexWVST, state.dataOutRptTab->m_unitName);
   11024            0 :             state.dataOutRptTab->m_unitConv = ConvertIP(state, state.dataOutRptTab->unitConvIndexWVST, 1.0);
   11025            0 :             SIunit = "[m2]";
   11026            0 :             LookupSItoIP(state, SIunit, state.dataOutRptTab->unitConvIndexWVST, state.dataOutRptTab->m2_unitName);
   11027            0 :             state.dataOutRptTab->m2_unitConvWVST = ConvertIP(state, state.dataOutRptTab->unitConvIndexWVST, 1.0);
   11028            0 :             SIunit = "[m3]";
   11029            0 :             LookupSItoIP(state, SIunit, state.dataOutRptTab->unitConvIndexWVST, state.dataOutRptTab->m3_unitName);
   11030            0 :             state.dataOutRptTab->m3_unitConv = ConvertIP(state, state.dataOutRptTab->unitConvIndexWVST, 1.0);
   11031              :             // SIunit = "[W/m2]";
   11032              :             // LookupSItoIP(state, SIunit, state.dataOutRptTab->unitConvIndexWVST, state.dataOutRptTab->Wm2_unitName);
   11033            0 :             state.dataOutRptTab->Wm2_unitName = "[W/ft2]";
   11034            0 :             state.dataOutRptTab->Wm2_unitConv = 0.3048 * 0.3048; // ConvertIP(state, state.dataOutRptTab->unitConvIndexWVST, 1.0);
   11035            0 :         } else {
   11036           43 :             state.dataOutRptTab->m_unitName = "[m]";
   11037           43 :             state.dataOutRptTab->m_unitConv = 1.0;
   11038           43 :             state.dataOutRptTab->m2_unitName = "[m2]";
   11039           43 :             state.dataOutRptTab->m2_unitConvWVST = 1.0;
   11040           43 :             state.dataOutRptTab->m3_unitName = "[m3]";
   11041           43 :             state.dataOutRptTab->m3_unitConv = 1.0;
   11042           43 :             state.dataOutRptTab->Wm2_unitName = "[W/m2]";
   11043           43 :             state.dataOutRptTab->Wm2_unitConv = 1.0;
   11044              :         }
   11045              :         //---- General Sub-Table
   11046              : 
   11047              :         // since a variable number of design days is possible, first read them before sizing the arrays
   11048           46 :         rowHead.allocate(10);
   11049           46 :         columnHead.allocate(1);
   11050           46 :         columnWidth.allocate(1);
   11051           46 :         columnWidth = 14; // array assignment - same for all columns
   11052           46 :         tableBody.allocate(1, 10);
   11053              : 
   11054           46 :         columnHead(1) = "Value";
   11055           46 :         rowHead(1) = "Program Version and Build";
   11056           46 :         rowHead(2) = "RunPeriod";
   11057           46 :         rowHead(3) = "Weather File";
   11058           46 :         rowHead(4) = "Latitude [deg]";
   11059           46 :         rowHead(5) = "Longitude [deg]";
   11060              : 
   11061           46 :         rowHead(6) = "Elevation " + state.dataOutRptTab->m_unitName;
   11062           46 :         rowHead(7) = "Time Zone";
   11063           46 :         rowHead(8) = "North Axis Angle [deg]";
   11064           46 :         rowHead(9) = "Rotation for Appendix G [deg]";
   11065           46 :         rowHead(10) = "Hours Simulated [hrs]";
   11066              :         //  rowHead(9)  = 'Num Table Entries' !used for debugging
   11067              : 
   11068           46 :         tableBody = "";
   11069              : 
   11070           46 :         tableBody(1, 1) = state.dataStrGlobals->VerStringVar;                                         // program
   11071           46 :         tableBody(1, 2) = state.dataEnvrn->EnvironmentName;                                           // runperiod name
   11072           46 :         tableBody(1, 3) = state.dataEnvrn->WeatherFileLocationTitle;                                  // weather
   11073           46 :         tableBody(1, 4) = RealToStr(state.dataEnvrn->Latitude, 2);                                    // latitude
   11074           46 :         tableBody(1, 5) = RealToStr(state.dataEnvrn->Longitude, 2);                                   // longitude
   11075           46 :         tableBody(1, 6) = RealToStr(state.dataEnvrn->Elevation * state.dataOutRptTab->m_unitConv, 2); // Elevation
   11076           46 :         tableBody(1, 7) = RealToStr(state.dataEnvrn->TimeZoneNumber, 2);                              // Time Zone
   11077           46 :         tableBody(1, 8) = RealToStr(state.dataHeatBal->BuildingAzimuth, 2);                           // north axis angle
   11078           46 :         tableBody(1, 9) = RealToStr(state.dataHeatBal->BuildingRotationAppendixG, 2);                 // Rotation for Appendix G
   11079           46 :         tableBody(1, 10) = RealToStr(ort->gatherElapsedTimeBEPS, 2);                                  // hours simulated
   11080              :         //  tableBody(9,1) = TRIM(fmt::to_string(numTableEntry)) !number of table entries for predefined tables
   11081              : 
   11082           46 :         if (produceTabular) {
   11083           42 :             WriteSubtitle(state, "General");
   11084           42 :             WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
   11085              :         }
   11086           46 :         if (produceSQLite) {
   11087           42 :             if (state.dataSQLiteProcedures->sqlite) {
   11088            7 :                 state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
   11089              :                     tableBody, rowHead, columnHead, "InputVerificationandResultsSummary", "Entire Facility", "General");
   11090              :             }
   11091              :         }
   11092           46 :         if (produceTabular) {
   11093           42 :             if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
   11094            0 :                 state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(
   11095              :                     tableBody, rowHead, columnHead, "InputVerificationandResultsSummary", "Entire Facility", "General");
   11096              :             }
   11097              : 
   11098              :             //---- Window Wall Ratio Sub-Table
   11099           84 :             WriteTextLine(state, "ENVELOPE", true);
   11100              :         }
   11101              : 
   11102           46 :         rowHead.allocate(5);
   11103           46 :         columnHead.allocate(5);
   11104           46 :         columnWidth.allocate(5);
   11105           46 :         columnWidth = 14; // array assignment - same for all columns
   11106           46 :         tableBody.allocate(5, 5);
   11107              : 
   11108           46 :         columnHead(wwrcTotal) = "Total";
   11109           46 :         columnHead(wwrcNorth) = "North (315 to 45 deg)";
   11110           46 :         columnHead(wwrcEast) = "East (45 to 135 deg)";
   11111           46 :         columnHead(wwrcSouth) = "South (135 to 225 deg)";
   11112           46 :         columnHead(wwrcWest) = "West (225 to 315 deg)";
   11113              : 
   11114           46 :         rowHead(wwrrWall) = "Gross Wall Area " + state.dataOutRptTab->m2_unitName;
   11115           46 :         rowHead(wwrrAbvGndWall) = "Above Ground Wall Area " + state.dataOutRptTab->m2_unitName;
   11116           46 :         rowHead(wwrrWindow) = "Window Opening Area " + state.dataOutRptTab->m2_unitName;
   11117           46 :         rowHead(wwrrWWR) = "Gross Window-Wall Ratio [%]";
   11118           46 :         rowHead(wwrrAbvGndWWR) = "Above Ground Window-Wall Ratio [%]";
   11119              : 
   11120           46 :         Real64 wallAreaN = 0.0;
   11121           46 :         Real64 wallAreaS = 0.0;
   11122           46 :         Real64 wallAreaE = 0.0;
   11123           46 :         Real64 wallAreaW = 0.0;
   11124           46 :         Real64 aboveGroundWallAreaN = 0.0;
   11125           46 :         Real64 aboveGroundWallAreaS = 0.0;
   11126           46 :         Real64 aboveGroundWallAreaE = 0.0;
   11127           46 :         Real64 aboveGroundWallAreaW = 0.0;
   11128           46 :         Real64 windowAreaN = 0.0;
   11129           46 :         Real64 windowAreaS = 0.0;
   11130           46 :         Real64 windowAreaE = 0.0;
   11131           46 :         Real64 windowAreaW = 0.0;
   11132              :         // wall and window areas attached to conditioned zones
   11133           46 :         Real64 wallAreaNcond = 0.0;
   11134           46 :         Real64 wallAreaScond = 0.0;
   11135           46 :         Real64 wallAreaEcond = 0.0;
   11136           46 :         Real64 wallAreaWcond = 0.0;
   11137           46 :         Real64 aboveGroundWallAreaNcond = 0.0;
   11138           46 :         Real64 aboveGroundWallAreaScond = 0.0;
   11139           46 :         Real64 aboveGroundWallAreaEcond = 0.0;
   11140           46 :         Real64 aboveGroundWallAreaWcond = 0.0;
   11141           46 :         Real64 windowAreaNcond = 0.0;
   11142           46 :         Real64 windowAreaScond = 0.0;
   11143           46 :         Real64 windowAreaEcond = 0.0;
   11144           46 :         Real64 windowAreaWcond = 0.0;
   11145              : 
   11146           46 :         Real64 roofArea = 0.0;
   11147           46 :         Real64 skylightArea = 0.0;
   11148              : 
   11149           92 :         bool DetailedWWR = (state.dataInputProcessing->inputProcessor->getNumSectionsFound("DETAILEDWWR_DEBUG") > 0);
   11150           46 :         if (DetailedWWR) {
   11151            0 :             if (produceTabular) {
   11152            0 :                 print(state.files.debug, "{}\n", "======90.1 Classification [>=60 & <=120] tilt = wall==================");
   11153            0 :                 print(state.files.debug, "{}\n", "SurfName,Class,Area,Tilt");
   11154              :             }
   11155              :         }
   11156              : 
   11157          332 :         for (int iSurf = 1; iSurf <= state.dataSurface->TotSurfaces; ++iSurf) {
   11158              :             // only exterior surfaces including underground
   11159          286 :             auto const &thisSurf = state.dataSurface->Surface(iSurf);
   11160          286 :             if (!thisSurf.HeatTransSurf) continue;
   11161          286 :             bool const isAboveGround = (thisSurf.ExtBoundCond == ExternalEnvironment) || (thisSurf.ExtBoundCond == OtherSideCondModeledExt);
   11162          286 :             if (isAboveGround || (thisSurf.ExtBoundCond == Ground) || (thisSurf.ExtBoundCond == GroundFCfactorMethod) ||
   11163           58 :                 (thisSurf.ExtBoundCond == KivaFoundation)) {
   11164          228 :                 Real64 curAzimuth = thisSurf.Azimuth;
   11165              :                 // Round to two decimals, like the display in tables
   11166          228 :                 curAzimuth = round(curAzimuth * 100.0) / 100.0;
   11167          228 :                 Real64 curArea = thisSurf.GrossArea;
   11168          228 :                 if (thisSurf.FrameDivider != 0) {
   11169            8 :                     Real64 const frameWidth = state.dataSurface->FrameDivider(thisSurf.FrameDivider).FrameWidth;
   11170            8 :                     Real64 const frameArea =
   11171            8 :                         (thisSurf.Height + 2.0 * frameWidth) * (thisSurf.Width + 2.0 * frameWidth) - (thisSurf.Height * thisSurf.Width);
   11172            8 :                     curArea += frameArea;
   11173              :                 }
   11174          228 :                 int const zonePt = thisSurf.Zone;
   11175              : 
   11176          228 :                 bool const isConditioned = (zonePt > 0) && (state.dataHeatBal->Zone(zonePt).SystemZoneNodeNumber > 0);
   11177          228 :                 if ((thisSurf.Tilt >= 60.0) && (thisSurf.Tilt <= 120.0)) {
   11178              :                     // vertical walls and windows
   11179          160 :                     switch (thisSurf.Class) {
   11180          140 :                     case SurfaceClass::Wall:
   11181              :                     case SurfaceClass::Floor:
   11182              :                     case SurfaceClass::Roof: {
   11183          140 :                         auto const &thisZone = state.dataHeatBal->Zone(zonePt);
   11184          140 :                         Real64 const mult = thisZone.Multiplier * thisZone.ListMultiplier;
   11185          140 :                         if ((curAzimuth >= 315.0) || (curAzimuth < 45.0)) {
   11186           35 :                             wallAreaN += curArea * mult;
   11187           35 :                             if (isConditioned) wallAreaNcond += curArea * mult;
   11188           35 :                             if (isAboveGround) {
   11189           35 :                                 aboveGroundWallAreaN += curArea * mult;
   11190           35 :                                 if (isConditioned) aboveGroundWallAreaNcond += curArea * mult;
   11191              :                             }
   11192          105 :                         } else if ((curAzimuth >= 45.0) && (curAzimuth < 135.0)) {
   11193           35 :                             wallAreaE += curArea * mult;
   11194           35 :                             if (isConditioned) wallAreaEcond += curArea * mult;
   11195           35 :                             if (isAboveGround) {
   11196           35 :                                 aboveGroundWallAreaE += curArea * mult;
   11197           35 :                                 if (isConditioned) aboveGroundWallAreaEcond += curArea * mult;
   11198              :                             }
   11199           70 :                         } else if ((curAzimuth >= 135.0) && (curAzimuth < 225.0)) {
   11200           43 :                             wallAreaS += curArea * mult;
   11201           43 :                             if (isConditioned) wallAreaScond += curArea * mult;
   11202           43 :                             if (isAboveGround) {
   11203           43 :                                 aboveGroundWallAreaS += curArea * mult;
   11204           43 :                                 if (isConditioned) aboveGroundWallAreaScond += curArea * mult;
   11205              :                             }
   11206           27 :                         } else if ((curAzimuth >= 225.0) && (curAzimuth < 315.0)) {
   11207           27 :                             wallAreaW += curArea * mult;
   11208           27 :                             if (isConditioned) wallAreaWcond += curArea * mult;
   11209           27 :                             if (isAboveGround) {
   11210           27 :                                 aboveGroundWallAreaW += curArea * mult;
   11211           27 :                                 if (isConditioned) aboveGroundWallAreaWcond += curArea * mult;
   11212              :                             }
   11213              :                         }
   11214          140 :                         if (DetailedWWR) {
   11215            0 :                             if (produceTabular) {
   11216            0 :                                 print(state.files.debug, "{},Wall,{:.1R},{:.1R}\n", thisSurf.Name, curArea * mult, thisSurf.Tilt);
   11217              :                             }
   11218              :                         }
   11219          140 :                     } break;
   11220           20 :                     case SurfaceClass::Window:
   11221              :                     case SurfaceClass::TDD_Dome: {
   11222           20 :                         auto const &thisZone = state.dataHeatBal->Zone(zonePt);
   11223           20 :                         Real64 const mult = thisZone.Multiplier * thisZone.ListMultiplier * thisSurf.Multiplier;
   11224           20 :                         if ((curAzimuth >= 315.0) || (curAzimuth < 45.0)) {
   11225            8 :                             windowAreaN += curArea * mult;
   11226            8 :                             if (isConditioned) windowAreaNcond += curArea * mult;
   11227           12 :                         } else if ((curAzimuth >= 45.0) && (curAzimuth < 135.0)) {
   11228            8 :                             windowAreaE += curArea * mult;
   11229            8 :                             if (isConditioned) windowAreaEcond += curArea * mult;
   11230            4 :                         } else if ((curAzimuth >= 135.0) && (curAzimuth < 225.0)) {
   11231            4 :                             windowAreaS += curArea * mult;
   11232            4 :                             if (isConditioned) windowAreaScond += curArea * mult;
   11233            0 :                         } else if ((curAzimuth >= 225.0) && (curAzimuth < 315.0)) {
   11234            0 :                             windowAreaW += curArea * mult;
   11235            0 :                             if (isConditioned) windowAreaWcond += curArea * mult;
   11236              :                         }
   11237           20 :                         zoneOpeningArea(zonePt) += curArea * thisSurf.Multiplier; // total window opening area for each zone (glass plus frame area)
   11238           20 :                         zoneGlassArea(zonePt) += thisSurf.GrossArea * thisSurf.Multiplier;
   11239           20 :                         if (DetailedWWR) {
   11240            0 :                             if (produceTabular) {
   11241            0 :                                 print(state.files.debug, "{},Window,{:.1R},{:.1R}\n", thisSurf.Name, curArea * mult, thisSurf.Tilt);
   11242              :                             }
   11243              :                         }
   11244           20 :                     } break;
   11245            0 :                     default:
   11246            0 :                         break;
   11247              :                     }
   11248          228 :                 } else if (thisSurf.Tilt < 60.0) { // roof and skylights
   11249           36 :                     switch (thisSurf.Class) {
   11250           36 :                     case SurfaceClass::Wall:
   11251              :                     case SurfaceClass::Floor:
   11252              :                     case SurfaceClass::Roof: {
   11253           36 :                         auto const &thisZone = state.dataHeatBal->Zone(zonePt);
   11254           36 :                         Real64 const mult = thisZone.Multiplier * thisZone.ListMultiplier;
   11255           36 :                         roofArea += curArea * mult;
   11256           36 :                         if (DetailedWWR) {
   11257            0 :                             if (produceTabular) {
   11258            0 :                                 print(state.files.debug, "{},Roof,{:.1R},{:.1R}\n", thisSurf.Name, curArea * mult, thisSurf.Tilt);
   11259              :                             }
   11260              :                         }
   11261           36 :                     } break;
   11262            0 :                     case SurfaceClass::Window:
   11263              :                     case SurfaceClass::TDD_Dome: {
   11264            0 :                         auto const &thisZone = state.dataHeatBal->Zone(zonePt);
   11265            0 :                         Real64 const mult = thisZone.Multiplier * thisZone.ListMultiplier * thisSurf.Multiplier;
   11266            0 :                         skylightArea += curArea * mult;
   11267            0 :                         if (DetailedWWR) {
   11268            0 :                             if (produceTabular) {
   11269            0 :                                 print(state.files.debug, "{},Skylight,{:.1R},{:.1R}\n", thisSurf.Name, curArea * mult, thisSurf.Tilt);
   11270              :                             }
   11271              :                         }
   11272            0 :                     } break;
   11273            0 :                     default:
   11274            0 :                         break;
   11275              :                     }
   11276              :                 } else { // floors
   11277              :                          // ignored
   11278              :                 }
   11279              :             }
   11280              :         }
   11281              : 
   11282           46 :         Real64 TotalWallArea = wallAreaN + wallAreaS + wallAreaE + wallAreaW;
   11283           46 :         Real64 TotalAboveGroundWallArea = aboveGroundWallAreaN + aboveGroundWallAreaS + aboveGroundWallAreaE + aboveGroundWallAreaW;
   11284           46 :         Real64 TotalWindowArea = windowAreaN + windowAreaS + windowAreaE + windowAreaW;
   11285           46 :         if (DetailedWWR) {
   11286            0 :             if (produceTabular) {
   11287            0 :                 print(state.files.debug, "{}\n", "========================");
   11288            0 :                 print(state.files.debug, "{}\n", "TotalWallArea,WallAreaN,WallAreaS,WallAreaE,WallAreaW");
   11289            0 :                 print(state.files.debug, "{}\n", "TotalWindowArea,WindowAreaN,WindowAreaS,WindowAreaE,WindowAreaW");
   11290            0 :                 print(state.files.debug, "{:.2R},{:.2R},{:.2R},{:.2R},{:.2R}\n", TotalWallArea, wallAreaN, wallAreaS, wallAreaE, wallAreaW);
   11291            0 :                 print(state.files.debug, "{:.2R},{:.2R},{:.2R},{:.2R},{:.2R}\n", TotalWindowArea, windowAreaN, windowAreaS, windowAreaE, windowAreaW);
   11292              :             }
   11293              :         }
   11294              : 
   11295           46 :         tableBody = "";
   11296              : 
   11297           46 :         tableBody(wwrcNorth, wwrrWall) = RealToStr(wallAreaN * state.dataOutRptTab->m2_unitConvWVST, 2);
   11298           46 :         tableBody(wwrcSouth, wwrrWall) = RealToStr(wallAreaS * state.dataOutRptTab->m2_unitConvWVST, 2);
   11299           46 :         tableBody(wwrcEast, wwrrWall) = RealToStr(wallAreaE * state.dataOutRptTab->m2_unitConvWVST, 2);
   11300           46 :         tableBody(wwrcWest, wwrrWall) = RealToStr(wallAreaW * state.dataOutRptTab->m2_unitConvWVST, 2);
   11301           46 :         tableBody(wwrcTotal, wwrrWall) = RealToStr(TotalWallArea * state.dataOutRptTab->m2_unitConvWVST, 2);
   11302              : 
   11303           46 :         tableBody(wwrcNorth, wwrrAbvGndWall) = RealToStr(aboveGroundWallAreaN * state.dataOutRptTab->m2_unitConvWVST, 2);
   11304           46 :         tableBody(wwrcSouth, wwrrAbvGndWall) = RealToStr(aboveGroundWallAreaS * state.dataOutRptTab->m2_unitConvWVST, 2);
   11305           46 :         tableBody(wwrcEast, wwrrAbvGndWall) = RealToStr(aboveGroundWallAreaE * state.dataOutRptTab->m2_unitConvWVST, 2);
   11306           46 :         tableBody(wwrcWest, wwrrAbvGndWall) = RealToStr(aboveGroundWallAreaW * state.dataOutRptTab->m2_unitConvWVST, 2);
   11307           46 :         tableBody(wwrcTotal, wwrrAbvGndWall) = RealToStr(TotalAboveGroundWallArea * state.dataOutRptTab->m2_unitConvWVST, 2);
   11308              : 
   11309           46 :         tableBody(wwrcNorth, wwrrWindow) = RealToStr(windowAreaN * state.dataOutRptTab->m2_unitConvWVST, 2);
   11310           46 :         tableBody(wwrcSouth, wwrrWindow) = RealToStr(windowAreaS * state.dataOutRptTab->m2_unitConvWVST, 2);
   11311           46 :         tableBody(wwrcEast, wwrrWindow) = RealToStr(windowAreaE * state.dataOutRptTab->m2_unitConvWVST, 2);
   11312           46 :         tableBody(wwrcWest, wwrrWindow) = RealToStr(windowAreaW * state.dataOutRptTab->m2_unitConvWVST, 2);
   11313           46 :         tableBody(wwrcTotal, wwrrWindow) = RealToStr(TotalWindowArea * state.dataOutRptTab->m2_unitConvWVST, 2);
   11314              : 
   11315           46 :         tableBody(wwrcNorth, wwrrWWR) = RealToStr(100.0 * SafeDivide(windowAreaN, wallAreaN), 2);
   11316           46 :         tableBody(wwrcSouth, wwrrWWR) = RealToStr(100.0 * SafeDivide(windowAreaS, wallAreaS), 2);
   11317           46 :         tableBody(wwrcEast, wwrrWWR) = RealToStr(100.0 * SafeDivide(windowAreaE, wallAreaE), 2);
   11318           46 :         tableBody(wwrcWest, wwrrWWR) = RealToStr(100.0 * SafeDivide(windowAreaW, wallAreaW), 2);
   11319           46 :         tableBody(wwrcTotal, wwrrWWR) = RealToStr(100.0 * SafeDivide(TotalWindowArea, TotalWallArea), 2);
   11320              : 
   11321           46 :         tableBody(wwrcNorth, wwrrAbvGndWWR) = RealToStr(100.0 * SafeDivide(windowAreaN, aboveGroundWallAreaN), 2);
   11322           46 :         tableBody(wwrcSouth, wwrrAbvGndWWR) = RealToStr(100.0 * SafeDivide(windowAreaS, aboveGroundWallAreaS), 2);
   11323           46 :         tableBody(wwrcEast, wwrrAbvGndWWR) = RealToStr(100.0 * SafeDivide(windowAreaE, aboveGroundWallAreaE), 2);
   11324           46 :         tableBody(wwrcWest, wwrrAbvGndWWR) = RealToStr(100.0 * SafeDivide(windowAreaW, aboveGroundWallAreaW), 2);
   11325           46 :         tableBody(wwrcTotal, wwrrAbvGndWWR) = RealToStr(100.0 * SafeDivide(TotalWindowArea, TotalAboveGroundWallArea), 2);
   11326              : 
   11327           46 :         if (produceTabular) {
   11328           42 :             WriteSubtitle(state, "Window-Wall Ratio");
   11329           42 :             WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
   11330              :         }
   11331           46 :         if (produceSQLite) {
   11332           42 :             if (state.dataSQLiteProcedures->sqlite) {
   11333            7 :                 state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
   11334              :                     tableBody, rowHead, columnHead, "InputVerificationandResultsSummary", "Entire Facility", "Window-Wall Ratio");
   11335              :             }
   11336              :         }
   11337           46 :         if (produceTabular) {
   11338           42 :             if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
   11339            0 :                 state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(
   11340              :                     tableBody, rowHead, columnHead, "InputVerificationandResultsSummary", "Entire Facility", "Window-Wall Ratio");
   11341              :             }
   11342              :         }
   11343              : 
   11344              :         //---- Conditioned Window Wall Ratio Sub-Table
   11345           46 :         rowHead.allocate(5);
   11346           46 :         columnHead.allocate(5);
   11347           46 :         columnWidth.allocate(5);
   11348           46 :         columnWidth = 14; // array assignment - same for all columns
   11349           46 :         tableBody.allocate(5, 5);
   11350              : 
   11351           46 :         columnHead(wwrcTotal) = "Total";
   11352           46 :         columnHead(wwrcNorth) = "North (315 to 45 deg)";
   11353           46 :         columnHead(wwrcEast) = "East (45 to 135 deg)";
   11354           46 :         columnHead(wwrcSouth) = "South (135 to 225 deg)";
   11355           46 :         columnHead(wwrcWest) = "West (225 to 315 deg)";
   11356              : 
   11357           46 :         rowHead(wwrrWall) = "Gross Wall Area " + state.dataOutRptTab->m2_unitName;
   11358           46 :         rowHead(wwrrAbvGndWall) = "Above Ground Wall Area " + state.dataOutRptTab->m2_unitName;
   11359           46 :         rowHead(wwrrWindow) = "Window Opening Area " + state.dataOutRptTab->m2_unitName;
   11360           46 :         rowHead(wwrrWWR) = "Gross Window-Wall Ratio [%]";
   11361           46 :         rowHead(wwrrAbvGndWWR) = "Above Ground Window-Wall Ratio [%]";
   11362              : 
   11363              :         // calculations appear in last block with normal window-wall ratio table
   11364              : 
   11365           46 :         TotalWallArea = wallAreaNcond + wallAreaScond + wallAreaEcond + wallAreaWcond;
   11366           46 :         TotalAboveGroundWallArea = aboveGroundWallAreaNcond + aboveGroundWallAreaScond + aboveGroundWallAreaEcond + aboveGroundWallAreaWcond;
   11367           46 :         TotalWindowArea = windowAreaNcond + windowAreaScond + windowAreaEcond + windowAreaWcond;
   11368              : 
   11369           46 :         tableBody = "";
   11370              : 
   11371           46 :         tableBody(wwrcNorth, wwrrWall) = RealToStr(wallAreaNcond * state.dataOutRptTab->m2_unitConvWVST, 2);
   11372           46 :         tableBody(wwrcSouth, wwrrWall) = RealToStr(wallAreaScond * state.dataOutRptTab->m2_unitConvWVST, 2);
   11373           46 :         tableBody(wwrcEast, wwrrWall) = RealToStr(wallAreaEcond * state.dataOutRptTab->m2_unitConvWVST, 2);
   11374           46 :         tableBody(wwrcWest, wwrrWall) = RealToStr(wallAreaWcond * state.dataOutRptTab->m2_unitConvWVST, 2);
   11375           46 :         tableBody(wwrcTotal, wwrrWall) = RealToStr(TotalWallArea * state.dataOutRptTab->m2_unitConvWVST, 2);
   11376              : 
   11377           46 :         tableBody(wwrcNorth, wwrrAbvGndWall) = RealToStr(aboveGroundWallAreaNcond * state.dataOutRptTab->m2_unitConvWVST, 2);
   11378           46 :         tableBody(wwrcSouth, wwrrAbvGndWall) = RealToStr(aboveGroundWallAreaScond * state.dataOutRptTab->m2_unitConvWVST, 2);
   11379           46 :         tableBody(wwrcEast, wwrrAbvGndWall) = RealToStr(aboveGroundWallAreaEcond * state.dataOutRptTab->m2_unitConvWVST, 2);
   11380           46 :         tableBody(wwrcWest, wwrrAbvGndWall) = RealToStr(aboveGroundWallAreaWcond * state.dataOutRptTab->m2_unitConvWVST, 2);
   11381           46 :         tableBody(wwrcTotal, wwrrAbvGndWall) = RealToStr(TotalAboveGroundWallArea * state.dataOutRptTab->m2_unitConvWVST, 2);
   11382              : 
   11383           46 :         tableBody(wwrcNorth, wwrrWindow) = RealToStr(windowAreaNcond * state.dataOutRptTab->m2_unitConvWVST, 2);
   11384           46 :         tableBody(wwrcSouth, wwrrWindow) = RealToStr(windowAreaScond * state.dataOutRptTab->m2_unitConvWVST, 2);
   11385           46 :         tableBody(wwrcEast, wwrrWindow) = RealToStr(windowAreaEcond * state.dataOutRptTab->m2_unitConvWVST, 2);
   11386           46 :         tableBody(wwrcWest, wwrrWindow) = RealToStr(windowAreaWcond * state.dataOutRptTab->m2_unitConvWVST, 2);
   11387           46 :         tableBody(wwrcTotal, wwrrWindow) = RealToStr(TotalWindowArea * state.dataOutRptTab->m2_unitConvWVST, 2);
   11388              : 
   11389           46 :         tableBody(wwrcNorth, wwrrWWR) = RealToStr(100.0 * SafeDivide(windowAreaNcond, wallAreaNcond), 2);
   11390           46 :         tableBody(wwrcSouth, wwrrWWR) = RealToStr(100.0 * SafeDivide(windowAreaScond, wallAreaScond), 2);
   11391           46 :         tableBody(wwrcEast, wwrrWWR) = RealToStr(100.0 * SafeDivide(windowAreaEcond, wallAreaEcond), 2);
   11392           46 :         tableBody(wwrcWest, wwrrWWR) = RealToStr(100.0 * SafeDivide(windowAreaWcond, wallAreaWcond), 2);
   11393           46 :         tableBody(wwrcTotal, wwrrWWR) = RealToStr(100.0 * SafeDivide(TotalWindowArea, TotalWallArea), 2);
   11394              : 
   11395           46 :         tableBody(wwrcNorth, wwrrAbvGndWWR) = RealToStr(100.0 * SafeDivide(windowAreaNcond, aboveGroundWallAreaNcond), 2);
   11396           46 :         tableBody(wwrcSouth, wwrrAbvGndWWR) = RealToStr(100.0 * SafeDivide(windowAreaScond, aboveGroundWallAreaScond), 2);
   11397           46 :         tableBody(wwrcEast, wwrrAbvGndWWR) = RealToStr(100.0 * SafeDivide(windowAreaEcond, aboveGroundWallAreaEcond), 2);
   11398           46 :         tableBody(wwrcWest, wwrrAbvGndWWR) = RealToStr(100.0 * SafeDivide(windowAreaWcond, aboveGroundWallAreaWcond), 2);
   11399           46 :         tableBody(wwrcTotal, wwrrAbvGndWWR) = RealToStr(100.0 * SafeDivide(TotalWindowArea, TotalAboveGroundWallArea), 2);
   11400              : 
   11401           46 :         if (produceTabular) {
   11402           42 :             WriteSubtitle(state, "Conditioned Window-Wall Ratio");
   11403           42 :             WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
   11404              :         }
   11405           46 :         if (produceSQLite) {
   11406           42 :             if (state.dataSQLiteProcedures->sqlite) {
   11407            7 :                 state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
   11408              :                     tableBody, rowHead, columnHead, "InputVerificationandResultsSummary", "Entire Facility", "Conditioned Window-Wall Ratio");
   11409              :             }
   11410              :         }
   11411           46 :         if (produceTabular) {
   11412           42 :             if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
   11413            0 :                 state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(
   11414              :                     tableBody, rowHead, columnHead, "InputVerificationandResultsSummary", "Entire Facility", "Conditioned Window-Wall Ratio");
   11415              :             }
   11416              :         }
   11417              : 
   11418              :         //---- Skylight Roof Ratio Sub-Table
   11419           46 :         rowHead.allocate(3);
   11420           46 :         columnHead.allocate(1);
   11421           46 :         columnWidth.allocate(1);
   11422           46 :         columnWidth = 14; // array assignment - same for all columns
   11423           46 :         tableBody.allocate(1, 3);
   11424              : 
   11425           46 :         columnHead(1) = "Total";
   11426              : 
   11427           46 :         rowHead(1) = "Gross Roof Area " + state.dataOutRptTab->m2_unitName;
   11428           46 :         rowHead(2) = "Skylight Area " + state.dataOutRptTab->m2_unitName;
   11429           46 :         rowHead(3) = "Skylight-Roof Ratio [%]";
   11430              : 
   11431           46 :         if (DetailedWWR) {
   11432            0 :             if (produceTabular) {
   11433            0 :                 print(state.files.debug, "{}\n", "========================");
   11434            0 :                 print(state.files.debug, "{}\n", "TotalRoofArea,SkylightArea");
   11435            0 :                 print(state.files.debug, "{:.2R},{:.2R}\n", roofArea, skylightArea);
   11436              :             }
   11437              :         }
   11438              : 
   11439           46 :         tableBody(1, 1) = RealToStr(roofArea * state.dataOutRptTab->m2_unitConvWVST, 2);
   11440           46 :         tableBody(1, 2) = RealToStr(skylightArea * state.dataOutRptTab->m2_unitConvWVST, 2);
   11441           46 :         tableBody(1, 3) = RealToStr(100.0 * SafeDivide(skylightArea, roofArea), 2);
   11442              : 
   11443           46 :         if (produceTabular) {
   11444           42 :             WriteSubtitle(state, "Skylight-Roof Ratio");
   11445           42 :             WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
   11446              :         }
   11447           46 :         if (produceSQLite) {
   11448           42 :             if (state.dataSQLiteProcedures->sqlite) {
   11449            7 :                 state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
   11450              :                     tableBody, rowHead, columnHead, "InputVerificationandResultsSummary", "Entire Facility", "Skylight-Roof Ratio");
   11451              :             }
   11452              :         }
   11453           46 :         if (produceTabular) {
   11454           42 :             if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
   11455            0 :                 state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(
   11456              :                     tableBody, rowHead, columnHead, "InputVerificationandResultsSummary", "Entire Facility", "Skylight-Roof Ratio");
   11457              :             }
   11458              :         }
   11459              : 
   11460              :         //---- Hybrid Model: Internal Thermal Mass Sub-Table
   11461           46 :         if (state.dataHybridModel->FlagHybridModel_TM) {
   11462            0 :             rowHead.allocate(state.dataGlobal->NumOfZones);
   11463            0 :             int const NumOfCol = 2;
   11464            0 :             columnHead.allocate(NumOfCol);
   11465            0 :             columnWidth.allocate(NumOfCol);
   11466            0 :             columnWidth = 14; // array assignment - same for all columns
   11467            0 :             tableBody.allocate(NumOfCol, state.dataGlobal->NumOfZones);
   11468              : 
   11469            0 :             columnHead(1) = "Hybrid Modeling (Y/N)";
   11470            0 :             columnHead(2) = "Temperature Capacitance Multiplier ";
   11471              : 
   11472            0 :             rowHead = "";
   11473            0 :             tableBody = "";
   11474              : 
   11475            0 :             for (int iZone = 1; iZone <= state.dataGlobal->NumOfZones; ++iZone) {
   11476            0 :                 auto const &thisZone = state.dataHeatBal->Zone(iZone);
   11477              : 
   11478            0 :                 rowHead(iZone) = thisZone.Name;
   11479            0 :                 if (state.dataHybridModel->hybridModelZones(iZone).InternalThermalMassCalc_T) {
   11480            0 :                     tableBody(1, iZone) = "Yes";
   11481              :                 } else {
   11482            0 :                     tableBody(1, iZone) = "No";
   11483              :                 }
   11484            0 :                 tableBody(2, iZone) = RealToStr(thisZone.ZoneVolCapMultpSensHMAverage, 2);
   11485              :             }
   11486              : 
   11487            0 :             if (produceTabular) {
   11488            0 :                 WriteSubtitle(state, "Hybrid Model: Internal Thermal Mass");
   11489            0 :                 WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
   11490              :             }
   11491            0 :             if (produceSQLite) {
   11492            0 :                 if (state.dataSQLiteProcedures->sqlite) {
   11493            0 :                     state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(tableBody,
   11494              :                                                                                        rowHead,
   11495              :                                                                                        columnHead,
   11496              :                                                                                        "InputVerificationandResultsSummary",
   11497              :                                                                                        "Entire Facility",
   11498              :                                                                                        "Hybrid Model: Internal Thermal Mass");
   11499              :                 }
   11500              :             }
   11501              :         }
   11502              : 
   11503           46 :         Real64 const totExtGrossWallArea_Multiplied = sum(state.dataHeatBal->Zone, &ZoneData::ExtGrossWallArea_Multiplied);
   11504           46 :         Real64 const totExtGrossGroundWallArea_Multiplied = sum(state.dataHeatBal->Zone, &ZoneData::ExtGrossGroundWallArea_Multiplied);
   11505           46 :         if (totExtGrossWallArea_Multiplied > 0.0 || totExtGrossGroundWallArea_Multiplied > 0.0) {
   11506              :             Real64 const pdiff =
   11507           38 :                 std::abs((wallAreaN + wallAreaS + wallAreaE + wallAreaW) - (totExtGrossWallArea_Multiplied + totExtGrossGroundWallArea_Multiplied)) /
   11508           38 :                 (totExtGrossWallArea_Multiplied + totExtGrossGroundWallArea_Multiplied);
   11509           38 :             if (pdiff > 0.019) {
   11510            0 :                 if (produceTabular) {
   11511            0 :                     ShowWarningError(
   11512              :                         state, "WriteVeriSumTable: InputVerificationsAndResultsSummary: Wall area based on [>=60,<=120] degrees (tilt) as walls");
   11513            0 :                     ShowContinueError(state,
   11514            0 :                                       format("differs ~{:.1R}% from user entered Wall class surfaces. Degree calculation based on ASHRAE "
   11515              :                                              "90.1 wall definitions.",
   11516            0 :                                              pdiff * 100.0));
   11517              :                     //      CALL ShowContinueError(state, format("Calculated based on degrees=[{}{}{}{}{}{}] m2, Calculated from user entered Wall
   11518              :                     //      class surfaces=[{}{}{}{}{}{}", //, &, //, TRIM(ADJUSTL(RealToStr((wallAreaN + wallAreaS + wallAreaE +
   11519              :                     //      wallAreaW),3)))//, &, //, //, &, //,
   11520              :                     //      TRIM(ADJUSTL(RealToStr(SUM(Zone(1:NumOfZones)%ExtGrossWallArea_Multiplied),3)))//', m2.'), ShowContinueError(state,
   11521              :                     //      "Check classes of surfaces and tilts for discrepancies."));
   11522            0 :                     ShowContinueError(state,
   11523            0 :                                       format("Total wall area by ASHRAE 90.1 definition={} m2.",
   11524            0 :                                              stripped(RealToStr((wallAreaN + wallAreaS + wallAreaE + wallAreaW), 3))));
   11525            0 :                     ShowContinueError(
   11526              :                         state,
   11527            0 :                         format("Total exterior wall area from user entered classes={} m2.", stripped(RealToStr(totExtGrossWallArea_Multiplied, 3))));
   11528            0 :                     ShowContinueError(state,
   11529            0 :                                       format("Total ground contact wall area from user entered classes={} m2.",
   11530            0 :                                              stripped(RealToStr(totExtGrossGroundWallArea_Multiplied, 3))));
   11531              :                 }
   11532              :             }
   11533              :         }
   11534              :         //---- Space Summary Sub-Table
   11535           46 :         if (produceTabular) {
   11536           84 :             WriteTextLine(state, "PERFORMANCE", true);
   11537              :         }
   11538              : 
   11539           46 :         rowHead.allocate(state.dataGlobal->NumOfZones + 4);
   11540              : 
   11541           46 :         int const NumOfCol = 12;
   11542           46 :         columnHead.allocate(NumOfCol);
   11543           46 :         columnWidth.allocate(NumOfCol);
   11544           46 :         columnWidth = 14; // array assignment - same for all columns
   11545           46 :         tableBody.allocate(NumOfCol, state.dataGlobal->NumOfZones + 4);
   11546              : 
   11547           46 :         columnHead(1) = "Area " + state.dataOutRptTab->m2_unitName;
   11548           46 :         columnHead(2) = "Conditioned (Y/N)";
   11549           46 :         columnHead(3) = "Part of Total Floor Area (Y/N)";
   11550           46 :         columnHead(4) = "Volume " + state.dataOutRptTab->m3_unitName;
   11551           46 :         columnHead(5) = "Multipliers";
   11552           46 :         columnHead(6) = "Above Ground Gross Wall Area " + state.dataOutRptTab->m2_unitName;
   11553           46 :         columnHead(7) = "Underground Gross Wall Area " + state.dataOutRptTab->m2_unitName;
   11554           46 :         columnHead(8) = "Window Glass Area " + state.dataOutRptTab->m2_unitName;
   11555           46 :         columnHead(9) = "Opening Area " + state.dataOutRptTab->m2_unitName;
   11556           46 :         columnHead(10) = "Lighting " + state.dataOutRptTab->Wm2_unitName;
   11557           92 :         columnHead(11) = "People " + state.dataOutRptTab->m2_unitName.substr(0, len(state.dataOutRptTab->m2_unitName) - 1) + " per person" +
   11558           92 :                          state.dataOutRptTab->m2_unitName[len(state.dataOutRptTab->m2_unitName) - 1];
   11559           46 :         columnHead(12) = "Plug and Process " + state.dataOutRptTab->Wm2_unitName;
   11560              : 
   11561           46 :         rowHead = "";
   11562           46 :         rowHead(state.dataGlobal->NumOfZones + state.dataOutRptTab->grandTotal) = "Total";
   11563           46 :         rowHead(state.dataGlobal->NumOfZones + state.dataOutRptTab->condTotal) = "Conditioned Total";
   11564           46 :         rowHead(state.dataGlobal->NumOfZones + state.dataOutRptTab->uncondTotal) = "Unconditioned Total";
   11565           46 :         rowHead(state.dataGlobal->NumOfZones + state.dataOutRptTab->notpartTotal) = "Not Part of Total";
   11566              : 
   11567           46 :         tableBody = "";
   11568              : 
   11569          106 :         for (int iZone = 1; iZone <= state.dataGlobal->NumOfZones; ++iZone) {
   11570           60 :             auto const &thisZone = state.dataHeatBal->Zone(iZone);
   11571              : 
   11572           60 :             Real64 const mult = thisZone.Multiplier * thisZone.ListMultiplier;
   11573           60 :             rowHead(iZone) = thisZone.Name;
   11574              :             // Conditioned or not
   11575           60 :             bool zoneIsCond = false;
   11576           60 :             if (thisZone.SystemZoneNodeNumber > 0) {
   11577           30 :                 tableBody(2, iZone) = "Yes";
   11578           30 :                 zoneIsCond = true;
   11579              :             } else {
   11580           30 :                 tableBody(2, iZone) = "No";
   11581           30 :                 zoneIsCond = false;
   11582              :             }
   11583              :             // Part of Total Floor Area or not
   11584           60 :             bool usezoneFloorArea = false;
   11585           60 :             if (thisZone.isPartOfTotalArea) {
   11586           56 :                 tableBody(3, iZone) = "Yes";
   11587           56 :                 usezoneFloorArea = true;
   11588              :             } else {
   11589            4 :                 tableBody(3, iZone) = "No";
   11590            4 :                 usezoneFloorArea = false;
   11591              :             }
   11592           60 :             tableBody(1, iZone) = RealToStr(thisZone.FloorArea * state.dataOutRptTab->m2_unitConvWVST, 2);
   11593           60 :             tableBody(4, iZone) = RealToStr(thisZone.Volume * state.dataOutRptTab->m3_unitConv, 2);
   11594              :             // no unit conversion necessary since done automatically
   11595           60 :             if (produceTabular) {
   11596           52 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchLeedSutSpArea, thisZone.Name, thisZone.FloorArea, 2);
   11597              :             }
   11598           60 :             if (zoneIsCond) {
   11599           30 :                 if (produceTabular) {
   11600           24 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchLeedSutOcArea, thisZone.Name, thisZone.FloorArea, 2);
   11601           24 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchLeedSutUnArea, thisZone.Name, "0.00");
   11602              :                 }
   11603              :             } else {
   11604           30 :                 if (produceTabular) {
   11605           28 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchLeedSutOcArea, thisZone.Name, "0.00");
   11606           28 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchLeedSutUnArea, thisZone.Name, thisZone.FloorArea, 2);
   11607              :                 }
   11608              :             }
   11609           60 :             tableBody(5, iZone) = RealToStr(mult, 2);
   11610           60 :             tableBody(6, iZone) = RealToStr(thisZone.ExtGrossWallArea * state.dataOutRptTab->m2_unitConvWVST, 2);
   11611           60 :             tableBody(7, iZone) = RealToStr(thisZone.ExtGrossGroundWallArea * state.dataOutRptTab->m2_unitConvWVST, 2);
   11612           60 :             tableBody(8, iZone) = RealToStr(zoneGlassArea(iZone) * state.dataOutRptTab->m2_unitConvWVST, 2);
   11613           60 :             tableBody(9, iZone) = RealToStr(zoneOpeningArea(iZone) * state.dataOutRptTab->m2_unitConvWVST, 2);
   11614              :             // lighting density
   11615           60 :             Real64 totLightPower = 0.0;
   11616          121 :             for (int iLight = 1; iLight <= state.dataHeatBal->TotLights; ++iLight) {
   11617           61 :                 if (iZone == state.dataHeatBal->Lights(iLight).ZonePtr) {
   11618           25 :                     totLightPower += state.dataHeatBal->Lights(iLight).DesignLevel;
   11619              :                 }
   11620              :             }
   11621           60 :             if (thisZone.FloorArea > 0) {
   11622           60 :                 tableBody(10, iZone) = RealToStr(state.dataOutRptTab->Wm2_unitConv * totLightPower / thisZone.FloorArea, 4);
   11623              :             }
   11624              :             // people density
   11625           60 :             Real64 totNumPeople = 0.0;
   11626          122 :             for (int iPeople = 1; iPeople <= state.dataHeatBal->TotPeople; ++iPeople) {
   11627           62 :                 if (iZone == state.dataHeatBal->People(iPeople).ZonePtr) {
   11628           24 :                     totNumPeople += state.dataHeatBal->People(iPeople).NumberOfPeople;
   11629              :                 }
   11630              :             }
   11631           60 :             if (totNumPeople > 0) {
   11632           24 :                 tableBody(11, iZone) = RealToStr(thisZone.FloorArea * state.dataOutRptTab->m2_unitConvWVST / totNumPeople, 2);
   11633              :             }
   11634              :             // plug and process density
   11635           60 :             Real64 totPlugProcess = 0.0;
   11636          152 :             for (int iPlugProc = 1; iPlugProc <= state.dataHeatBal->TotElecEquip; ++iPlugProc) {
   11637           92 :                 if (iZone == state.dataHeatBal->ZoneElectric(iPlugProc).ZonePtr) {
   11638           54 :                     totPlugProcess += state.dataHeatBal->ZoneElectric(iPlugProc).DesignLevel;
   11639              :                 }
   11640              :             }
   11641           60 :             for (int iPlugProc = 1; iPlugProc <= state.dataHeatBal->TotGasEquip; ++iPlugProc) {
   11642            0 :                 if (iZone == state.dataHeatBal->ZoneGas(iPlugProc).ZonePtr) {
   11643            0 :                     totPlugProcess += state.dataHeatBal->ZoneGas(iPlugProc).DesignLevel;
   11644              :                 }
   11645              :             }
   11646          104 :             for (int iPlugProc = 1; iPlugProc <= state.dataHeatBal->TotOthEquip; ++iPlugProc) {
   11647           44 :                 if (iZone == state.dataHeatBal->ZoneOtherEq(iPlugProc).ZonePtr) {
   11648           44 :                     totPlugProcess += state.dataHeatBal->ZoneOtherEq(iPlugProc).DesignLevel;
   11649              :                 }
   11650              :             }
   11651           60 :             for (int iPlugProc = 1; iPlugProc <= state.dataHeatBal->TotHWEquip; ++iPlugProc) {
   11652            0 :                 if (iZone == state.dataHeatBal->ZoneHWEq(iPlugProc).ZonePtr) {
   11653            0 :                     totPlugProcess += state.dataHeatBal->ZoneHWEq(iPlugProc).DesignLevel;
   11654              :                 }
   11655              :             }
   11656           78 :             for (int iPlugProc = 1; iPlugProc <= state.dataHeatBal->TotITEquip; ++iPlugProc) {
   11657           18 :                 if (iZone == state.dataHeatBal->ZoneITEq(iPlugProc).ZonePtr) {
   11658            6 :                     totPlugProcess += state.dataHeatBal->ZoneITEq(iPlugProc).DesignTotalPower;
   11659              :                 }
   11660              :             }
   11661           60 :             if (thisZone.FloorArea > 0) {
   11662           60 :                 tableBody(12, iZone) = RealToStr(totPlugProcess * state.dataOutRptTab->Wm2_unitConv / thisZone.FloorArea, 4);
   11663              :             }
   11664              : 
   11665              :             // total rows for Total / Not Part of Total
   11666              :             // In "Total": break between conditioned/unconditioned
   11667              : 
   11668              :             // If not part of total, goes directly to this row
   11669           60 :             if (!usezoneFloorArea) {
   11670            4 :                 state.dataOutRptTab->zstArea(state.dataOutRptTab->notpartTotal) += mult * thisZone.FloorArea;
   11671            4 :                 state.dataOutRptTab->zstVolume(state.dataOutRptTab->notpartTotal) += mult * thisZone.Volume;
   11672            4 :                 state.dataOutRptTab->zstWallArea(state.dataOutRptTab->notpartTotal) += mult * thisZone.ExtGrossWallArea;
   11673            4 :                 state.dataOutRptTab->zstUndWallArea(state.dataOutRptTab->notpartTotal) += mult * thisZone.ExtGrossGroundWallArea;
   11674            4 :                 state.dataOutRptTab->zstWindowArea(state.dataOutRptTab->notpartTotal) += mult * zoneGlassArea(iZone);
   11675            4 :                 state.dataOutRptTab->zstOpeningArea(state.dataOutRptTab->notpartTotal) += mult * zoneOpeningArea(iZone);
   11676            4 :                 state.dataOutRptTab->zstLight(state.dataOutRptTab->notpartTotal) += mult * totLightPower;
   11677            4 :                 state.dataOutRptTab->zstPeople(state.dataOutRptTab->notpartTotal) += mult * totNumPeople;
   11678            4 :                 state.dataOutRptTab->zstPlug(state.dataOutRptTab->notpartTotal) += mult * totPlugProcess;
   11679              :             } else {
   11680              :                 // Add it to the 'Total'
   11681           56 :                 state.dataOutRptTab->zstArea(state.dataOutRptTab->grandTotal) += mult * thisZone.FloorArea;
   11682           56 :                 state.dataOutRptTab->zstVolume(state.dataOutRptTab->grandTotal) += mult * thisZone.Volume;
   11683           56 :                 state.dataOutRptTab->zstWallArea(state.dataOutRptTab->grandTotal) += mult * thisZone.ExtGrossWallArea;
   11684           56 :                 state.dataOutRptTab->zstUndWallArea(state.dataOutRptTab->grandTotal) += mult * thisZone.ExtGrossGroundWallArea;
   11685           56 :                 state.dataOutRptTab->zstWindowArea(state.dataOutRptTab->grandTotal) += mult * zoneGlassArea(iZone);
   11686           56 :                 state.dataOutRptTab->zstOpeningArea(state.dataOutRptTab->grandTotal) += mult * zoneOpeningArea(iZone);
   11687           56 :                 state.dataOutRptTab->zstLight(state.dataOutRptTab->grandTotal) += mult * totLightPower;
   11688           56 :                 state.dataOutRptTab->zstPeople(state.dataOutRptTab->grandTotal) += mult * totNumPeople;
   11689           56 :                 state.dataOutRptTab->zstPlug(state.dataOutRptTab->grandTotal) += mult * totPlugProcess;
   11690              : 
   11691              :                 // Subtotal between cond/unconditioned
   11692           56 :                 int const condUncondTotal = zoneIsCond ? state.dataOutRptTab->condTotal : state.dataOutRptTab->uncondTotal;
   11693           56 :                 state.dataOutRptTab->zstArea(condUncondTotal) += mult * thisZone.FloorArea;
   11694           56 :                 state.dataOutRptTab->zstVolume(condUncondTotal) += mult * thisZone.Volume;
   11695           56 :                 state.dataOutRptTab->zstWallArea(condUncondTotal) += mult * thisZone.ExtGrossWallArea;
   11696           56 :                 state.dataOutRptTab->zstUndWallArea(condUncondTotal) += mult * thisZone.ExtGrossGroundWallArea;
   11697           56 :                 state.dataOutRptTab->zstWindowArea(condUncondTotal) += mult * zoneGlassArea(iZone);
   11698           56 :                 state.dataOutRptTab->zstOpeningArea(condUncondTotal) += mult * zoneOpeningArea(iZone);
   11699           56 :                 state.dataOutRptTab->zstLight(condUncondTotal) += mult * totLightPower;
   11700           56 :                 state.dataOutRptTab->zstPeople(condUncondTotal) += mult * totNumPeople;
   11701           56 :                 state.dataOutRptTab->zstPlug(condUncondTotal) += mult * totPlugProcess;
   11702              :             }
   11703              :         }
   11704          230 :         for (int iTotal = 1; iTotal <= 4; ++iTotal) {
   11705          184 :             tableBody(1, state.dataGlobal->NumOfZones + iTotal) =
   11706          368 :                 RealToStr(state.dataOutRptTab->zstArea(iTotal) * state.dataOutRptTab->m2_unitConvWVST, 2);
   11707          184 :             tableBody(4, state.dataGlobal->NumOfZones + iTotal) =
   11708          368 :                 RealToStr(state.dataOutRptTab->zstVolume(iTotal) * state.dataOutRptTab->m3_unitConv, 2);
   11709          184 :             tableBody(6, state.dataGlobal->NumOfZones + iTotal) =
   11710          368 :                 RealToStr(state.dataOutRptTab->zstWallArea(iTotal) * state.dataOutRptTab->m2_unitConvWVST, 2);
   11711          184 :             tableBody(7, state.dataGlobal->NumOfZones + iTotal) =
   11712          368 :                 RealToStr(state.dataOutRptTab->zstUndWallArea(iTotal) * state.dataOutRptTab->m2_unitConvWVST, 2);
   11713          184 :             tableBody(8, state.dataGlobal->NumOfZones + iTotal) =
   11714          368 :                 RealToStr(state.dataOutRptTab->zstWindowArea(iTotal) * state.dataOutRptTab->m2_unitConvWVST, 2);
   11715          184 :             tableBody(9, state.dataGlobal->NumOfZones + iTotal) =
   11716          368 :                 RealToStr(state.dataOutRptTab->zstOpeningArea(iTotal) * state.dataOutRptTab->m2_unitConvWVST, 2);
   11717          184 :             if (state.dataOutRptTab->zstArea(iTotal) != 0) {
   11718          100 :                 tableBody(10, state.dataGlobal->NumOfZones + iTotal) =
   11719          200 :                     RealToStr(state.dataOutRptTab->zstLight(iTotal) * state.dataOutRptTab->Wm2_unitConv / state.dataOutRptTab->zstArea(iTotal), 4);
   11720          100 :                 tableBody(12, state.dataGlobal->NumOfZones + iTotal) =
   11721          200 :                     RealToStr(state.dataOutRptTab->zstPlug(iTotal) * state.dataOutRptTab->Wm2_unitConv / state.dataOutRptTab->zstArea(iTotal), 4);
   11722              :             }
   11723          184 :             if (state.dataOutRptTab->zstPeople(iTotal) != 0) {
   11724           56 :                 tableBody(11, state.dataGlobal->NumOfZones + iTotal) = RealToStr(
   11725           56 :                     state.dataOutRptTab->zstArea(iTotal) * state.dataOutRptTab->m2_unitConvWVST / state.dataOutRptTab->zstPeople(iTotal), 2);
   11726              :             }
   11727              :         }
   11728           46 :         if (produceTabular) {
   11729           42 :             PreDefTableEntry(
   11730           42 :                 state, state.dataOutRptPredefined->pdchLeedSutSpArea, "Totals", state.dataOutRptTab->zstArea(state.dataOutRptTab->grandTotal), 2);
   11731           42 :             PreDefTableEntry(
   11732           42 :                 state, state.dataOutRptPredefined->pdchLeedSutOcArea, "Totals", state.dataOutRptTab->zstArea(state.dataOutRptTab->condTotal), 2);
   11733           42 :             PreDefTableEntry(
   11734           84 :                 state, state.dataOutRptPredefined->pdchLeedSutUnArea, "Totals", state.dataOutRptTab->zstArea(state.dataOutRptTab->uncondTotal), 2);
   11735              : 
   11736           42 :             WriteSubtitle(state, "Zone Summary");
   11737           42 :             WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
   11738              :         }
   11739           46 :         if (produceSQLite) {
   11740           42 :             if (state.dataSQLiteProcedures->sqlite) {
   11741            7 :                 state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
   11742              :                     tableBody, rowHead, columnHead, "InputVerificationandResultsSummary", "Entire Facility", "Zone Summary");
   11743              :             }
   11744              :         }
   11745           46 :         if (produceTabular) {
   11746           42 :             if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
   11747            0 :                 state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(
   11748              :                     tableBody, rowHead, columnHead, "InputVerificationandResultsSummary", "Entire Facility", "Zone Summary");
   11749              :             }
   11750              :         }
   11751              : 
   11752           46 :         writeVeriSumSpaceTables(state, produceTabular, produceSQLite);
   11753              :     }
   11754           42 : }
   11755              : 
   11756           47 : void writeVeriSumSpaceTables(EnergyPlusData &state, bool produceTabular, bool produceSQLite)
   11757              : {
   11758              : 
   11759              :     // Write Space and SpaceType sub-tables for Input Verification and Results Summary
   11760           47 :     Array1D_string spaceRowHead;
   11761           47 :     Array1D_string spaceColumnHead;
   11762           47 :     Array1D_int spaceColumnWidth;
   11763           47 :     Array2D_string spaceTableBody;
   11764           47 :     int spaceNumCol = 11;
   11765           47 :     spaceRowHead.allocate(state.dataGlobal->numSpaces + 4); // Extra rows for totals
   11766           47 :     spaceColumnHead.allocate(spaceNumCol);
   11767           47 :     spaceColumnWidth.allocate(spaceNumCol);
   11768           47 :     spaceTableBody.allocate(spaceNumCol, state.dataGlobal->numSpaces + 4); // Extra rows for totals
   11769          564 :     for (int iCol = 1; iCol <= spaceNumCol; ++iCol) {
   11770          517 :         spaceColumnWidth(iCol) = 14;
   11771              :     }
   11772              : 
   11773           47 :     spaceColumnHead(1) = "Area " + state.dataOutRptTab->m2_unitName;
   11774           47 :     spaceColumnHead(2) = "Conditioned (Y/N)";
   11775           47 :     spaceColumnHead(3) = "Part of Total Floor Area (Y/N)";
   11776           47 :     spaceColumnHead(4) = "Multipliers";
   11777           47 :     spaceColumnHead(5) = "Zone Name";
   11778           47 :     spaceColumnHead(6) = "Space Type";
   11779           47 :     spaceColumnHead(7) = "Radiant/Solar Enclosure Name";
   11780           47 :     spaceColumnHead(8) = "Lighting " + state.dataOutRptTab->Wm2_unitName;
   11781           94 :     spaceColumnHead(9) = "People " + state.dataOutRptTab->m2_unitName.substr(0, len(state.dataOutRptTab->m2_unitName) - 1) + " per person" +
   11782           94 :                          state.dataOutRptTab->m2_unitName[len(state.dataOutRptTab->m2_unitName) - 1];
   11783           47 :     spaceColumnHead(10) = "Plug and Process " + state.dataOutRptTab->Wm2_unitName;
   11784           47 :     spaceColumnHead(11) = "Tags";
   11785              : 
   11786           47 :     int constexpr colSpaceArea(1);
   11787           47 :     int constexpr colConditioned(2);
   11788           47 :     int constexpr colPartOfTotal(3);
   11789           47 :     int constexpr colMultipliers(4);
   11790           47 :     int constexpr colZoneName(5);
   11791           47 :     int constexpr colSpaceType(6);
   11792           47 :     int constexpr colEnclName(7);
   11793           47 :     int constexpr colSpaceLighting(8);
   11794           47 :     int constexpr colSpacePeople(9);
   11795           47 :     int constexpr colSpacePlugProcess(10);
   11796           47 :     int constexpr colSpaceTags(11);
   11797              : 
   11798           47 :     spaceRowHead(state.dataGlobal->numSpaces + state.dataOutRptTab->grandTotal) = "Total";
   11799           47 :     spaceRowHead(state.dataGlobal->numSpaces + state.dataOutRptTab->condTotal) = "Conditioned Total";
   11800           47 :     spaceRowHead(state.dataGlobal->numSpaces + state.dataOutRptTab->uncondTotal) = "Unconditioned Total";
   11801           47 :     spaceRowHead(state.dataGlobal->numSpaces + state.dataOutRptTab->notpartTotal) = "Not Part of Total";
   11802              : 
   11803           47 :     EPVector<Real64> spaceTotLighting;
   11804           47 :     EPVector<Real64> spaceTotPeople;
   11805           47 :     EPVector<Real64> spaceTotPlugProcess;
   11806           47 :     spaceTotLighting.allocate(state.dataGlobal->numSpaces);
   11807           47 :     spaceTotPeople.allocate(state.dataGlobal->numSpaces);
   11808           47 :     spaceTotPlugProcess.allocate(state.dataGlobal->numSpaces);
   11809          121 :     for (int iSpace = 1; iSpace <= state.dataGlobal->numSpaces; ++iSpace) {
   11810           74 :         spaceTotLighting(iSpace) = 0.0;
   11811           74 :         spaceTotPeople(iSpace) = 0.0;
   11812           74 :         spaceTotPlugProcess(iSpace) = 0.0;
   11813              :     }
   11814              : 
   11815           47 :     Array1D_string spaceTypeRowHead;
   11816           47 :     Array1D_string spaceTypeColumnHead;
   11817           47 :     Array1D_int spaceTypeColumnWidth;
   11818           47 :     Array2D_string spaceTypeTableBody;
   11819           47 :     int spaceTypeNumCol = 7;
   11820           47 :     spaceTypeRowHead.allocate(state.dataGlobal->numSpaceTypes + 1); // Extra row for total
   11821           47 :     spaceTypeColumnHead.allocate(spaceTypeNumCol);
   11822           47 :     spaceTypeColumnWidth.allocate(spaceTypeNumCol);
   11823           47 :     spaceTypeTableBody.allocate(spaceTypeNumCol, state.dataGlobal->numSpaceTypes + 1); // Extra row for total
   11824          376 :     for (int iCol = 1; iCol <= spaceTypeNumCol; ++iCol) {
   11825          329 :         spaceTypeColumnWidth(iCol) = 14;
   11826              :     }
   11827           47 :     spaceTypeColumnHead(1) = "Total Area " + state.dataOutRptTab->m2_unitName;
   11828           47 :     spaceTypeColumnHead(2) = "Conditioned Area " + state.dataOutRptTab->m2_unitName;
   11829           47 :     spaceTypeColumnHead(3) = "Unconditioned Area " + state.dataOutRptTab->m2_unitName;
   11830           47 :     spaceTypeColumnHead(4) = "Not Part of Total Area " + state.dataOutRptTab->m2_unitName;
   11831           47 :     spaceTypeColumnHead(5) = "Lighting " + state.dataOutRptTab->Wm2_unitName;
   11832           94 :     spaceTypeColumnHead(6) = "People " + state.dataOutRptTab->m2_unitName.substr(0, len(state.dataOutRptTab->m2_unitName) - 1) + " per person" +
   11833           94 :                              state.dataOutRptTab->m2_unitName[len(state.dataOutRptTab->m2_unitName) - 1];
   11834           47 :     spaceTypeColumnHead(7) = "Plug and Process " + state.dataOutRptTab->Wm2_unitName;
   11835              : 
   11836           47 :     int constexpr colSpaceTypeTotArea(1);
   11837           47 :     int constexpr colSpaceTypeCondArea(2);
   11838           47 :     int constexpr colSpaceTypeUncondArea(3);
   11839           47 :     int constexpr colSpaceTypeNotTotArea(4);
   11840           47 :     int constexpr colSpaceTypeLighting(5);
   11841           47 :     int constexpr colSpaceTypePeople(6);
   11842           47 :     int constexpr colSpaceTypePlugProcess(7);
   11843              : 
   11844           47 :     spaceTypeRowHead(state.dataGlobal->numSpaceTypes + state.dataOutRptTab->grandTotal) = "Total";
   11845              : 
   11846           47 :     EPVector<Real64> spaceTypeTotArea;
   11847           47 :     EPVector<Real64> spaceTypeCondArea;
   11848           47 :     EPVector<Real64> spaceTypeUncondArea;
   11849           47 :     EPVector<Real64> spaceTypeNotTotArea;
   11850           47 :     EPVector<Real64> spaceTypeTotLighting;
   11851           47 :     EPVector<Real64> spaceTypeTotPeople;
   11852           47 :     EPVector<Real64> spaceTypeTotPlugProcess;
   11853           47 :     spaceTypeTotArea.allocate(state.dataGlobal->numSpaceTypes);
   11854           47 :     spaceTypeCondArea.allocate(state.dataGlobal->numSpaceTypes);
   11855           47 :     spaceTypeUncondArea.allocate(state.dataGlobal->numSpaceTypes);
   11856           47 :     spaceTypeNotTotArea.allocate(state.dataGlobal->numSpaceTypes);
   11857           47 :     spaceTypeTotLighting.allocate(state.dataGlobal->numSpaceTypes);
   11858           47 :     spaceTypeTotPeople.allocate(state.dataGlobal->numSpaceTypes);
   11859           47 :     spaceTypeTotPlugProcess.allocate(state.dataGlobal->numSpaceTypes);
   11860           90 :     for (int iSpaceType = 1; iSpaceType <= state.dataGlobal->numSpaceTypes; ++iSpaceType) {
   11861           43 :         spaceTypeTotArea(iSpaceType) = 0.0;
   11862           43 :         spaceTypeCondArea(iSpaceType) = 0.0;
   11863           43 :         spaceTypeUncondArea(iSpaceType) = 0.0;
   11864           43 :         spaceTypeNotTotArea(iSpaceType) = 0.0;
   11865           43 :         spaceTypeTotLighting(iSpaceType) = 0.0;
   11866           43 :         spaceTypeTotPeople(iSpaceType) = 0.0;
   11867           43 :         spaceTypeTotPlugProcess(iSpaceType) = 0.0;
   11868              :     }
   11869              : 
   11870              :     // Accumulate internal gain totals by space and space type
   11871           72 :     for (int iPeople = 1; iPeople <= state.dataHeatBal->TotPeople; ++iPeople) {
   11872           25 :         auto const &curPeople = state.dataHeatBal->People(iPeople);
   11873           25 :         int const spaceNum = curPeople.spaceIndex;
   11874           25 :         Real64 const people = curPeople.NumberOfPeople;
   11875           25 :         spaceTotPeople(spaceNum) += people;
   11876           25 :         spaceTypeTotPeople(state.dataHeatBal->space(spaceNum).spaceTypeNum) += people;
   11877              :     }
   11878           73 :     for (int iLights = 1; iLights <= state.dataHeatBal->TotLights; ++iLights) {
   11879           26 :         auto const &curLighting = state.dataHeatBal->Lights(iLights);
   11880           26 :         int const spaceNum = curLighting.spaceIndex;
   11881           26 :         Real64 const lighting = curLighting.DesignLevel;
   11882           26 :         spaceTotLighting(spaceNum) += lighting;
   11883           26 :         spaceTypeTotLighting(state.dataHeatBal->space(spaceNum).spaceTypeNum) += lighting;
   11884              :     }
   11885          101 :     for (int iElecEquip = 1; iElecEquip <= state.dataHeatBal->TotElecEquip; ++iElecEquip) {
   11886           54 :         auto const &curElecEquip = state.dataHeatBal->ZoneElectric(iElecEquip);
   11887           54 :         int const spaceNum = curElecEquip.spaceIndex;
   11888           54 :         Real64 const elecEquip = curElecEquip.DesignLevel;
   11889           54 :         spaceTotPlugProcess(spaceNum) += elecEquip;
   11890           54 :         spaceTypeTotPlugProcess(state.dataHeatBal->space(spaceNum).spaceTypeNum) += elecEquip;
   11891              :     }
   11892           47 :     for (int iGasEquip = 1; iGasEquip <= state.dataHeatBal->TotGasEquip; ++iGasEquip) {
   11893            0 :         auto const &curGasEquip = state.dataHeatBal->ZoneGas(iGasEquip);
   11894            0 :         int const spaceNum = curGasEquip.spaceIndex;
   11895            0 :         Real64 const gasEquip = curGasEquip.DesignLevel;
   11896            0 :         spaceTotPlugProcess(spaceNum) += gasEquip;
   11897            0 :         spaceTypeTotPlugProcess(state.dataHeatBal->space(spaceNum).spaceTypeNum) += gasEquip;
   11898              :     }
   11899           91 :     for (int iOthEquip = 1; iOthEquip <= state.dataHeatBal->TotOthEquip; ++iOthEquip) {
   11900           44 :         auto const &curOthEquip = state.dataHeatBal->ZoneOtherEq(iOthEquip);
   11901           44 :         int const spaceNum = curOthEquip.spaceIndex;
   11902           44 :         Real64 const othEquip = curOthEquip.DesignLevel;
   11903           44 :         spaceTotPlugProcess(spaceNum) += othEquip;
   11904           44 :         spaceTypeTotPlugProcess(state.dataHeatBal->space(spaceNum).spaceTypeNum) += othEquip;
   11905              :     }
   11906           47 :     for (int iHWEquip = 1; iHWEquip <= state.dataHeatBal->TotHWEquip; ++iHWEquip) {
   11907            0 :         auto const &curHWEquip = state.dataHeatBal->ZoneHWEq(iHWEquip);
   11908            0 :         int const spaceNum = curHWEquip.spaceIndex;
   11909            0 :         Real64 const hwEquip = curHWEquip.DesignLevel;
   11910            0 :         spaceTotPlugProcess(spaceNum) += hwEquip;
   11911            0 :         spaceTypeTotPlugProcess(state.dataHeatBal->space(spaceNum).spaceTypeNum) += hwEquip;
   11912              :     }
   11913           47 :     for (int iSteamEquip = 1; iSteamEquip <= state.dataHeatBal->TotStmEquip; ++iSteamEquip) {
   11914            0 :         auto const &curSteamEquip = state.dataHeatBal->ZoneSteamEq(iSteamEquip);
   11915            0 :         int const spaceNum = curSteamEquip.spaceIndex;
   11916            0 :         Real64 const steamEquip = curSteamEquip.DesignLevel;
   11917            0 :         spaceTotPlugProcess(spaceNum) += steamEquip;
   11918            0 :         spaceTypeTotPlugProcess(state.dataHeatBal->space(spaceNum).spaceTypeNum) += steamEquip;
   11919              :     }
   11920           54 :     for (int iITEquip = 1; iITEquip <= state.dataHeatBal->TotITEquip; ++iITEquip) {
   11921            7 :         auto const &curITEquip = state.dataHeatBal->ZoneITEq(iITEquip);
   11922            7 :         int const spaceNum = curITEquip.spaceIndex;
   11923            7 :         Real64 const itEquip = curITEquip.DesignTotalPower;
   11924            7 :         spaceTotPlugProcess(spaceNum) += itEquip;
   11925            7 :         spaceTypeTotPlugProcess(state.dataHeatBal->space(spaceNum).spaceTypeNum) += itEquip;
   11926              :     }
   11927              : 
   11928              :     // re-use existing zone total variables
   11929          235 :     for (int iTotal = 1; iTotal <= 4; ++iTotal) {
   11930          188 :         state.dataOutRptTab->zstArea(iTotal) = 0.0;
   11931          188 :         state.dataOutRptTab->zstLight(iTotal) = 0.0;
   11932          188 :         state.dataOutRptTab->zstPlug(iTotal) = 0.0;
   11933          188 :         state.dataOutRptTab->zstPeople(iTotal) = 0.0;
   11934              :     }
   11935              : 
   11936           47 :     int spaceTableRowNum = 0;
   11937          109 :     for (int iZone = 1; iZone <= state.dataGlobal->NumOfZones; ++iZone) {
   11938           62 :         auto const &curZone = state.dataHeatBal->Zone(iZone);
   11939           62 :         Real64 const mult = Real64(curZone.Multiplier) * Real64(curZone.ListMultiplier);
   11940          136 :         for (int const spaceNum : curZone.spaceIndexes) {
   11941           74 :             auto &curSpace = state.dataHeatBal->space(spaceNum);
   11942           74 :             bool spaceIsCond = false;
   11943           74 :             bool useSpaceFloorArea = false;
   11944           74 :             ++spaceTableRowNum;
   11945           74 :             spaceRowHead(spaceTableRowNum) = curSpace.Name;
   11946           74 :             spaceTableBody(colZoneName, spaceTableRowNum) = curZone.Name;
   11947           74 :             spaceTableBody(colSpaceType, spaceTableRowNum) = curSpace.spaceType;
   11948           74 :             spaceTableBody(colEnclName, spaceTableRowNum) = state.dataViewFactor->EnclSolInfo(curSpace.solarEnclosureNum).Name;
   11949           74 :             spaceTableBody(colSpaceArea, spaceTableRowNum) = RealToStr(curSpace.FloorArea * state.dataOutRptTab->m2_unitConvWVST, 2);
   11950              :             // Conditioned or not
   11951           74 :             if (curZone.SystemZoneNodeNumber > 0) {
   11952           44 :                 spaceTableBody(colConditioned, spaceTableRowNum) = "Yes";
   11953           44 :                 spaceIsCond = true;
   11954              :             } else {
   11955           30 :                 spaceTableBody(colConditioned, spaceTableRowNum) = "No";
   11956           30 :                 spaceIsCond = false;
   11957              :             }
   11958              :             // Part of Total Floor Area or not
   11959           74 :             if (curZone.isPartOfTotalArea) {
   11960           70 :                 spaceTableBody(colPartOfTotal, spaceTableRowNum) = "Yes";
   11961           70 :                 useSpaceFloorArea = true;
   11962              :             } else {
   11963            4 :                 spaceTableBody(colPartOfTotal, spaceTableRowNum) = "No";
   11964            4 :                 useSpaceFloorArea = false;
   11965              :             }
   11966              :             // lighting density
   11967           74 :             spaceTableBody(colMultipliers, spaceTableRowNum) = RealToStr(mult, 2);
   11968           74 :             if (curSpace.FloorArea > 0) {
   11969           62 :                 spaceTableBody(colSpaceLighting, spaceTableRowNum) =
   11970          124 :                     RealToStr(state.dataOutRptTab->Wm2_unitConv * spaceTotLighting(spaceNum) / curSpace.FloorArea, 4);
   11971              :             } else {
   11972           12 :                 spaceTableBody(colSpaceLighting, spaceTableRowNum) = RealToStr(0.0, 4);
   11973              :             }
   11974              :             // people density
   11975           74 :             if (spaceTotPeople(spaceNum) > 0) {
   11976           25 :                 spaceTableBody(colSpacePeople, spaceTableRowNum) =
   11977           50 :                     RealToStr(curSpace.FloorArea * state.dataOutRptTab->m2_unitConvWVST / spaceTotPeople(spaceNum), 2);
   11978              :             } else {
   11979           49 :                 spaceTableBody(colSpacePeople, spaceTableRowNum) = RealToStr(0.0, 2);
   11980              :             }
   11981              :             // plug and process density
   11982           74 :             if (curSpace.FloorArea > 0) {
   11983           62 :                 spaceTableBody(colSpacePlugProcess, spaceTableRowNum) =
   11984          124 :                     RealToStr(spaceTotPlugProcess(spaceNum) * state.dataOutRptTab->Wm2_unitConv / curSpace.FloorArea, 4);
   11985              :             } else {
   11986           12 :                 spaceTableBody(colSpacePlugProcess, spaceTableRowNum) = RealToStr(0.0, 4);
   11987              :             }
   11988              : 
   11989          148 :             spaceTableBody(colSpaceTags, spaceTableRowNum) = fmt::format("{}", fmt::join(curSpace.tags, ", "));
   11990              : 
   11991              :             // If not part of total, goes directly to this row
   11992           74 :             if (!useSpaceFloorArea) {
   11993            4 :                 spaceTypeNotTotArea(curSpace.spaceTypeNum) += curSpace.FloorArea * mult;
   11994            4 :                 state.dataOutRptTab->zstArea(state.dataOutRptTab->notpartTotal) += mult * curSpace.FloorArea;
   11995            4 :                 state.dataOutRptTab->zstLight(state.dataOutRptTab->notpartTotal) += mult * spaceTotLighting(spaceNum);
   11996            4 :                 state.dataOutRptTab->zstPeople(state.dataOutRptTab->notpartTotal) += mult * spaceTotPeople(spaceNum);
   11997            4 :                 state.dataOutRptTab->zstPlug(state.dataOutRptTab->notpartTotal) += mult * spaceTotPlugProcess(spaceNum);
   11998              :             } else {
   11999              :                 // Add it to the 'Total'
   12000           70 :                 spaceTypeTotArea(curSpace.spaceTypeNum) += curSpace.FloorArea * mult;
   12001           70 :                 state.dataOutRptTab->zstArea(state.dataOutRptTab->grandTotal) += mult * curSpace.FloorArea;
   12002           70 :                 state.dataOutRptTab->zstLight(state.dataOutRptTab->grandTotal) += mult * spaceTotLighting(spaceNum);
   12003           70 :                 state.dataOutRptTab->zstPeople(state.dataOutRptTab->grandTotal) += mult * spaceTotPeople(spaceNum);
   12004           70 :                 state.dataOutRptTab->zstPlug(state.dataOutRptTab->grandTotal) += mult * spaceTotPlugProcess(spaceNum);
   12005              : 
   12006              :                 // Subtotal between cond/unconditioned
   12007              :                 int condUncondTotalIndex;
   12008           70 :                 if (spaceIsCond) {
   12009           40 :                     spaceTypeCondArea(curSpace.spaceTypeNum) += curSpace.FloorArea * mult;
   12010           40 :                     condUncondTotalIndex = state.dataOutRptTab->condTotal;
   12011              : 
   12012              :                 } else {
   12013           30 :                     spaceTypeUncondArea(curSpace.spaceTypeNum) += curSpace.FloorArea * mult;
   12014           30 :                     condUncondTotalIndex = state.dataOutRptTab->uncondTotal;
   12015              :                 }
   12016           70 :                 state.dataOutRptTab->zstArea(condUncondTotalIndex) += mult * curSpace.FloorArea;
   12017           70 :                 state.dataOutRptTab->zstLight(condUncondTotalIndex) += mult * spaceTotLighting(spaceNum);
   12018           70 :                 state.dataOutRptTab->zstPeople(condUncondTotalIndex) += mult * spaceTotPeople(spaceNum);
   12019           70 :                 state.dataOutRptTab->zstPlug(condUncondTotalIndex) += mult * spaceTotPlugProcess(spaceNum);
   12020              :             }
   12021              :         }
   12022              :     }
   12023              :     // total rows for Total / Not Part of Total
   12024              :     // In "Total": break between conditioned/unconditioned
   12025          235 :     for (int iTotal = 1; iTotal <= 4; ++iTotal) {
   12026          188 :         spaceTableBody(colSpaceArea, state.dataGlobal->numSpaces + iTotal) =
   12027          376 :             RealToStr(state.dataOutRptTab->zstArea(iTotal) * state.dataOutRptTab->m2_unitConvWVST, 2);
   12028          188 :         if (state.dataOutRptTab->zstArea(iTotal) != 0) {
   12029           78 :             spaceTableBody(colSpaceLighting, state.dataGlobal->numSpaces + iTotal) =
   12030          156 :                 RealToStr(state.dataOutRptTab->zstLight(iTotal) * state.dataOutRptTab->Wm2_unitConv / state.dataOutRptTab->zstArea(iTotal), 4);
   12031           78 :             spaceTableBody(colSpacePlugProcess, state.dataGlobal->numSpaces + iTotal) =
   12032          156 :                 RealToStr(state.dataOutRptTab->zstPlug(iTotal) * state.dataOutRptTab->Wm2_unitConv / state.dataOutRptTab->zstArea(iTotal), 4);
   12033              :         } else {
   12034          110 :             spaceTableBody(colSpaceLighting, state.dataGlobal->numSpaces + iTotal) = RealToStr(0.0, 4);
   12035          110 :             spaceTableBody(colSpacePlugProcess, state.dataGlobal->numSpaces + iTotal) = RealToStr(0.0, 4);
   12036              :         }
   12037          188 :         if (state.dataOutRptTab->zstPeople(iTotal) != 0) {
   12038           30 :             spaceTableBody(colSpacePeople, state.dataGlobal->numSpaces + iTotal) =
   12039           60 :                 RealToStr(state.dataOutRptTab->zstArea(iTotal) * state.dataOutRptTab->m2_unitConvWVST / state.dataOutRptTab->zstPeople(iTotal), 2);
   12040              :         } else {
   12041          158 :             spaceTableBody(colSpacePeople, state.dataGlobal->numSpaces + iTotal) = RealToStr(0.0, 2);
   12042              :         }
   12043              :     }
   12044              : 
   12045           47 :     Real64 totalArea = 0.0;
   12046           47 :     Real64 condArea = 0.0;
   12047           47 :     Real64 uncondArea = 0.0;
   12048           47 :     Real64 notTotalArea = 0.0;
   12049           90 :     for (int iSpaceType = 1; iSpaceType <= state.dataGlobal->numSpaceTypes; ++iSpaceType) {
   12050           43 :         spaceTypeRowHead(iSpaceType) = state.dataHeatBal->spaceTypes(iSpaceType);
   12051           43 :         spaceTypeTableBody(colSpaceTypeTotArea, iSpaceType) = RealToStr(spaceTypeTotArea(iSpaceType) * state.dataOutRptTab->m2_unitConvWVST, 2);
   12052           43 :         spaceTypeTableBody(colSpaceTypeCondArea, iSpaceType) = RealToStr(spaceTypeCondArea(iSpaceType) * state.dataOutRptTab->m2_unitConvWVST, 2);
   12053           43 :         spaceTypeTableBody(colSpaceTypeUncondArea, iSpaceType) = RealToStr(spaceTypeUncondArea(iSpaceType) * state.dataOutRptTab->m2_unitConvWVST, 2);
   12054           43 :         spaceTypeTableBody(colSpaceTypeNotTotArea, iSpaceType) = RealToStr(spaceTypeNotTotArea(iSpaceType) * state.dataOutRptTab->m2_unitConvWVST, 2);
   12055           43 :         totalArea += spaceTypeTotArea(iSpaceType);
   12056           43 :         condArea += spaceTypeCondArea(iSpaceType);
   12057           43 :         uncondArea += spaceTypeUncondArea(iSpaceType);
   12058           43 :         notTotalArea += spaceTypeNotTotArea(iSpaceType);
   12059              :         // lighting density
   12060           43 :         if (spaceTypeTotArea(iSpaceType) > 0) {
   12061           39 :             spaceTypeTableBody(colSpaceTypeLighting, iSpaceType) =
   12062           78 :                 RealToStr(state.dataOutRptTab->Wm2_unitConv * spaceTypeTotLighting(iSpaceType) / spaceTypeTotArea(iSpaceType), 4);
   12063              :         } else {
   12064            4 :             spaceTypeTableBody(colSpaceTypeLighting, iSpaceType) = RealToStr(0.0, 4);
   12065              :         }
   12066              :         // people density
   12067           43 :         if (spaceTypeTotPeople(iSpaceType) > 0) {
   12068           11 :             spaceTypeTableBody(colSpaceTypePeople, iSpaceType) =
   12069           22 :                 RealToStr(spaceTypeTotArea(iSpaceType) * state.dataOutRptTab->m2_unitConvWVST / spaceTypeTotPeople(iSpaceType), 2);
   12070              :         } else {
   12071           32 :             spaceTypeTableBody(colSpaceTypePeople, iSpaceType) = RealToStr(0.0, 2);
   12072              :         }
   12073              :         // plug and process density
   12074           43 :         if (spaceTypeTotArea(iSpaceType) > 0) {
   12075           39 :             spaceTypeTableBody(colSpaceTypePlugProcess, iSpaceType) =
   12076           78 :                 RealToStr(spaceTypeTotPlugProcess(iSpaceType) * state.dataOutRptTab->Wm2_unitConv / spaceTypeTotArea(iSpaceType), 4);
   12077              :         } else {
   12078            4 :             spaceTypeTableBody(colSpaceTypePlugProcess, iSpaceType) = RealToStr(0.0, 4);
   12079              :         }
   12080              :     }
   12081              :     // Total Area
   12082           47 :     spaceTypeTableBody(colSpaceTypeTotArea, state.dataGlobal->numSpaceTypes + 1) = RealToStr(totalArea * state.dataOutRptTab->m2_unitConvWVST, 2);
   12083           47 :     spaceTypeTableBody(colSpaceTypeCondArea, state.dataGlobal->numSpaceTypes + 1) = RealToStr(condArea * state.dataOutRptTab->m2_unitConvWVST, 2);
   12084           47 :     spaceTypeTableBody(colSpaceTypeUncondArea, state.dataGlobal->numSpaceTypes + 1) = RealToStr(uncondArea * state.dataOutRptTab->m2_unitConvWVST, 2);
   12085           47 :     spaceTypeTableBody(colSpaceTypeNotTotArea, state.dataGlobal->numSpaceTypes + 1) =
   12086           94 :         RealToStr(notTotalArea * state.dataOutRptTab->m2_unitConvWVST, 2);
   12087              : 
   12088           47 :     if (produceTabular) {
   12089           43 :         WriteSubtitle(state, "Space Summary");
   12090           43 :         WriteTable(state, spaceTableBody, spaceRowHead, spaceColumnHead, spaceColumnWidth);
   12091              : 
   12092           43 :         WriteSubtitle(state, "Space Type Summary");
   12093           43 :         WriteTable(state, spaceTypeTableBody, spaceTypeRowHead, spaceTypeColumnHead, spaceTypeColumnWidth);
   12094              : 
   12095           43 :         if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
   12096            0 :             state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(
   12097              :                 spaceTableBody, spaceRowHead, spaceColumnHead, "InputVerificationandResultsSummary", "Entire Facility", "Space Summary");
   12098              : 
   12099            0 :             state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(spaceTypeTableBody,
   12100              :                                                                                                   spaceTypeRowHead,
   12101              :                                                                                                   spaceTypeColumnHead,
   12102              :                                                                                                   "InputVerificationandResultsSummary",
   12103              :                                                                                                   "Entire Facility",
   12104              :                                                                                                   "Space Type Summary");
   12105              :         }
   12106              :     }
   12107              : 
   12108           47 :     if (produceSQLite) {
   12109           43 :         if (state.dataSQLiteProcedures->sqlite) {
   12110            8 :             state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
   12111              :                 spaceTableBody, spaceRowHead, spaceColumnHead, "InputVerificationandResultsSummary", "Entire Facility", "Space Summary");
   12112              : 
   12113            8 :             state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(spaceTypeTableBody,
   12114              :                                                                                spaceTypeRowHead,
   12115              :                                                                                spaceTypeColumnHead,
   12116              :                                                                                "InputVerificationandResultsSummary",
   12117              :                                                                                "Entire Facility",
   12118              :                                                                                "Space Type Summary");
   12119              :         }
   12120              :     }
   12121           47 : }
   12122              : 
   12123           38 : void WriteAdaptiveComfortTable(EnergyPlusData &state)
   12124              : {
   12125              : 
   12126              :     // SUBROUTINE INFORMATION:
   12127              :     //       AUTHOR         Tyler Hoyt
   12128              :     //       DATE WRITTEN   August 2011
   12129              :     //       MODIFIED       na
   12130              :     //       RE-ENGINEERED  na
   12131              : 
   12132              :     // PURPOSE OF THIS SUBROUTINE:
   12133              :     // Writes summary table for adaptive comfort models. Tabulates
   12134              :     // occupied hours not meeting comfort bounds for ASHRAE-55 and
   12135              :     // CEN-15251 adaptive models.
   12136           38 :     auto &ort = state.dataOutRptTab;
   12137           38 :     if (!ort->displayAdaptiveComfort || state.dataHeatBal->TotPeople <= 0) {
   12138           32 :         return;
   12139              :     }
   12140              : 
   12141            6 :     Array1D_int peopleInd; // Index the relevant people
   12142            6 :     peopleInd.allocate(state.dataHeatBal->TotPeople);
   12143              : 
   12144              :     // Should deallocate after writing table. - LKL
   12145              : 
   12146           18 :     for (int i = 1; i <= state.dataHeatBal->TotPeople; ++i) {
   12147           12 :         if (state.dataHeatBal->People(i).AdaptiveASH55 || state.dataHeatBal->People(i).AdaptiveCEN15251) {
   12148            0 :             ++ort->numPeopleAdaptive;
   12149            0 :             peopleInd(ort->numPeopleAdaptive) = i;
   12150              :         }
   12151              :     }
   12152              : 
   12153            6 :     Array1D_string rowHead;
   12154            6 :     Array2D_string tableBody;
   12155            6 :     rowHead.allocate(ort->numPeopleAdaptive);
   12156            6 :     tableBody.allocate(5, ort->numPeopleAdaptive);
   12157              : 
   12158           24 :     WriteReportHeaders(state, "Adaptive Comfort Summary", "Entire Facility", OutputProcessor::StoreType::Average);
   12159            6 :     WriteSubtitle(state, "Time Not Meeting the Adaptive Comfort Models during Occupied Hours");
   12160              : 
   12161            6 :     Array1D_int columnWidth;
   12162            6 :     columnWidth.allocate(5);
   12163            6 :     columnWidth = 10;
   12164              : 
   12165            6 :     Array1D_string columnHead(5);
   12166            6 :     columnHead(1) = "ASHRAE55 90% Acceptability Limits [Hours]";
   12167            6 :     columnHead(2) = "ASHRAE55 80% Acceptability Limits  [Hours]";
   12168            6 :     columnHead(3) = "CEN15251 Category I Acceptability Limits [Hours]";
   12169            6 :     columnHead(4) = "CEN15251 Category II Acceptability Limits [Hours]";
   12170            6 :     columnHead(5) = "CEN15251 Category III Acceptability Limits [Hours]";
   12171              : 
   12172            6 :     tableBody = "";
   12173            6 :     for (int i = 1; i <= ort->numPeopleAdaptive; ++i) {
   12174            0 :         rowHead(i) = state.dataHeatBal->People(i).Name;
   12175            0 :         if (state.dataHeatBal->People(i).AdaptiveASH55) {
   12176            0 :             tableBody(1, i) = RealToStr(state.dataHeatBal->People(peopleInd(i)).TimeNotMetASH5590, 2);
   12177            0 :             tableBody(2, i) = RealToStr(state.dataHeatBal->People(peopleInd(i)).TimeNotMetASH5580, 2);
   12178              :         }
   12179            0 :         if (state.dataHeatBal->People(i).AdaptiveCEN15251) {
   12180            0 :             tableBody(3, i) = RealToStr(state.dataHeatBal->People(peopleInd(i)).TimeNotMetCEN15251CatI, 2);
   12181            0 :             tableBody(4, i) = RealToStr(state.dataHeatBal->People(peopleInd(i)).TimeNotMetCEN15251CatII, 2);
   12182            0 :             tableBody(5, i) = RealToStr(state.dataHeatBal->People(peopleInd(i)).TimeNotMetCEN15251CatIII, 2);
   12183              :         }
   12184              :     }
   12185              : 
   12186            6 :     WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
   12187            6 :     if (state.dataSQLiteProcedures->sqlite) {
   12188            1 :         state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(tableBody,
   12189              :                                                                            rowHead,
   12190              :                                                                            columnHead,
   12191              :                                                                            "AdaptiveComfortSummary",
   12192              :                                                                            "Entire Facility",
   12193              :                                                                            "Time Not Meeting the Adaptive Comfort Models during Occupied Hours");
   12194              :     }
   12195            6 :     if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
   12196            0 :         state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(
   12197              :             tableBody,
   12198              :             rowHead,
   12199              :             columnHead,
   12200              :             "AdaptiveComfortSummary",
   12201              :             "Entire Facility",
   12202              :             "Time Not Meeting the Adaptive Comfort Models during Occupied Hours");
   12203              :     }
   12204            6 : }
   12205              : 
   12206            0 : std::string formatReportPeriodTimestamp(const int year, const int month, const int day, const int hour)
   12207              : {
   12208            0 :     if (year != 0) {
   12209            0 :         return fmt::format("{}/{}/{} {}:00", year, month, day, hour);
   12210              :     } else {
   12211            0 :         return fmt::format("{}/{} {}:00", month, day, hour);
   12212              :     }
   12213              : }
   12214              : 
   12215            0 : void WriteReportHeaderReportingPeriod(EnergyPlusData &state,
   12216              :                                       const std::string &reportKeyWord,
   12217              :                                       const int periodIdx,
   12218              :                                       const Array1D<Weather::ReportPeriodData> &ReportPeriodInputData)
   12219              : {
   12220            0 :     WriteReportHeaders(
   12221              :         state,
   12222            0 :         fmt::format("{} Resilience Summary for Reporting Period {}: {}", reportKeyWord, periodIdx, ReportPeriodInputData(periodIdx).title),
   12223              :         "Entire Facility",
   12224              :         OutputProcessor::StoreType::Average);
   12225              : 
   12226            0 :     WriteSubtitle(state,
   12227            0 :                   format("Reporting period: {} -- {}, Total Electricity Usage: {:.2R} kWh",
   12228            0 :                          formatReportPeriodTimestamp(ReportPeriodInputData(periodIdx).startYear,
   12229            0 :                                                      ReportPeriodInputData(periodIdx).startMonth,
   12230            0 :                                                      ReportPeriodInputData(periodIdx).startDay,
   12231            0 :                                                      ReportPeriodInputData(periodIdx).startHour),
   12232            0 :                          formatReportPeriodTimestamp(ReportPeriodInputData(periodIdx).endYear,
   12233            0 :                                                      ReportPeriodInputData(periodIdx).endMonth,
   12234            0 :                                                      ReportPeriodInputData(periodIdx).endDay,
   12235            0 :                                                      ReportPeriodInputData(periodIdx).endHour),
   12236            0 :                          ReportPeriodInputData(periodIdx).totalElectricityUse / 3600000.0));
   12237            0 : }
   12238              : 
   12239            0 : void WriteReportPeriodTimeConsumption(EnergyPlusData &state)
   12240              : {
   12241              :     // Reporting Period Time and Consumption Table
   12242              :     // It has the following columns: report type (thermal, co2, visual), period, start, end, total electricity
   12243            0 :     Array1D_string columnHead;
   12244            0 :     Array1D_int columnWidth;
   12245            0 :     Array1D_string rowHead;
   12246            0 :     Array2D_string tableBody;
   12247            0 :     int numRowsReportPeriod = state.dataWeather->TotThermalReportPers + state.dataWeather->TotCO2ReportPers + state.dataWeather->TotVisualReportPers;
   12248            0 :     rowHead.allocate(numRowsReportPeriod);
   12249            0 :     columnHead.allocate(6);
   12250            0 :     columnWidth.allocate(6);
   12251            0 :     columnWidth = 14; // array assignment - same for all columns
   12252            0 :     tableBody.allocate(6, numRowsReportPeriod);
   12253              : 
   12254            0 :     int constexpr reportperiodType(1);
   12255            0 :     int constexpr reportperiodId(2);
   12256            0 :     int constexpr reportperiodTitle(3);
   12257            0 :     int constexpr reportperiodStart(4);
   12258            0 :     int constexpr reportperiodEnd(5);
   12259            0 :     int constexpr reportperiodElectricity(6);
   12260              : 
   12261            0 :     WriteReportHeaders(state, "Reporting Period Summary", "Entire Facility", OutputProcessor::StoreType::Average);
   12262              : 
   12263            0 :     columnHead(reportperiodType) = "Report Type";
   12264            0 :     columnHead(reportperiodId) = "Report Index";
   12265            0 :     columnHead(reportperiodTitle) = "Title";
   12266            0 :     columnHead(reportperiodStart) = "Start Time";
   12267            0 :     columnHead(reportperiodEnd) = "End Time";
   12268            0 :     columnHead(reportperiodElectricity) = "Total Electricity (kWh)";
   12269            0 :     for (int i = 1; i <= numRowsReportPeriod; i++) {
   12270            0 :         rowHead(i) = std::to_string(i);
   12271              :     }
   12272              :     // loop through rows
   12273            0 :     int rowid = 1;
   12274            0 :     for (int periodIdx = 1; periodIdx <= state.dataWeather->TotThermalReportPers; periodIdx++) {
   12275            0 :         writeRowReportPeriodInputVeri("Thermal", tableBody, rowid, periodIdx, state.dataWeather->ThermalReportPeriodInput);
   12276            0 :         rowid += 1;
   12277              :     }
   12278            0 :     for (int periodIdx = 1; periodIdx <= state.dataWeather->TotCO2ReportPers; periodIdx++) {
   12279            0 :         writeRowReportPeriodInputVeri("CO2", tableBody, rowid, periodIdx, state.dataWeather->CO2ReportPeriodInput);
   12280            0 :         rowid += 1;
   12281              :     }
   12282            0 :     for (int periodIdx = 1; periodIdx <= state.dataWeather->TotVisualReportPers; periodIdx++) {
   12283            0 :         writeRowReportPeriodInputVeri("Visual", tableBody, rowid, periodIdx, state.dataWeather->VisualReportPeriodInput);
   12284            0 :         rowid += 1;
   12285              :     }
   12286              : 
   12287            0 :     std::string tableName = "Reporting Period Time and Consumption";
   12288            0 :     WriteSubtitle(state, tableName);
   12289            0 :     WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
   12290            0 :     if (state.dataSQLiteProcedures->sqlite) {
   12291            0 :         state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
   12292              :             tableBody, rowHead, columnHead, "ReportingPeriodSummary", "Entire Facility", tableName);
   12293              :     }
   12294            0 :     if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
   12295            0 :         state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(
   12296              :             tableBody, rowHead, columnHead, "Reporting Period Summary", "Entire Facility", tableName);
   12297              :     }
   12298            0 : }
   12299              : 
   12300            0 : void WriteThermalResilienceTablesRepPeriod(EnergyPlusData &state, int const periodIdx)
   12301              : {
   12302              : 
   12303            0 :     auto const &ort = state.dataOutRptTab;
   12304            0 :     if (!ort->WriteTabularFiles) {
   12305            0 :         return;
   12306              :     }
   12307              : 
   12308              :     Real64 degreeHourConversion;
   12309            0 :     UnitsStyle unitsStyle_cur = ort->unitsStyle;
   12310              : 
   12311            0 :     if (unitsStyle_cur == OutputReportTabular::UnitsStyle::InchPound ||
   12312              :         unitsStyle_cur == OutputReportTabular::UnitsStyle::InchPoundExceptElectricity) {
   12313            0 :         degreeHourConversion = getSpecificUnitMultiplier(state, "°C·hr", "°F·hr");
   12314              :     } else {
   12315            0 :         degreeHourConversion = 1.0;
   12316              :     }
   12317              : 
   12318            0 :     std::string tableType = "Thermal";
   12319            0 :     WriteReportHeaderReportingPeriod(state, tableType, periodIdx, state.dataWeather->ThermalReportPeriodInput);
   12320            0 :     std::string periodTitle = state.dataWeather->ThermalReportPeriodInput(periodIdx).title;
   12321              : 
   12322            0 :     int columnNum = 5;
   12323            0 :     Array1D_int columnWidth;
   12324            0 :     columnWidth.allocate(columnNum);
   12325            0 :     columnWidth = 10;
   12326            0 :     Array1D_string columnHead(5);
   12327            0 :     if (unitsStyle_cur == OutputReportTabular::UnitsStyle::InchPound ||
   12328              :         unitsStyle_cur == OutputReportTabular::UnitsStyle::InchPoundExceptElectricity) {
   12329            0 :         columnHead(1) = "Safe (≤ 80.1°F) [hr]";
   12330            0 :         columnHead(2) = "Caution (> 80.1°F, ≤ 90.0°F) [hr]";
   12331            0 :         columnHead(3) = "Extreme Caution (> 90.0°F, ≤ 102.9°F) [hr]";
   12332            0 :         columnHead(4) = "Danger (> 102.9, ≤ 125.1°F) [hr]";
   12333            0 :         columnHead(5) = "Extreme Danger (> 125.1°F) [hr]";
   12334              :     } else {
   12335            0 :         columnHead(1) = "Safe (≤ 26.7°C) [hr]";
   12336            0 :         columnHead(2) = "Caution (> 26.7°C, ≤ 32.2°C) [hr]";
   12337            0 :         columnHead(3) = "Extreme Caution (> 32.2°C, ≤ 39.4°C) [hr]";
   12338            0 :         columnHead(4) = "Danger (> 39.4°C, ≤ 51.7°C) [hr]";
   12339            0 :         columnHead(5) = "Extreme Danger (> 51.7°C) [hr]";
   12340              :     }
   12341              : 
   12342            0 :     Array1D_string rowHead;
   12343            0 :     Array2D_string tableBody;
   12344            0 :     rowHead.allocate(state.dataGlobal->NumOfZones + 4);
   12345            0 :     tableBody.allocate(columnNum, state.dataGlobal->NumOfZones + 4);
   12346              : 
   12347            0 :     std::string tableName = "Heat Index Hours";
   12348            0 :     WriteResilienceBinsTableReportingPeriod(state,
   12349              :                                             tableType,
   12350              :                                             columnNum,
   12351              :                                             periodIdx,
   12352              :                                             periodTitle,
   12353              :                                             tableName,
   12354              :                                             columnHead,
   12355              :                                             columnWidth,
   12356            0 :                                             state.dataHeatBalFanSys->ZoneHeatIndexHourBinsRepPeriod,
   12357              :                                             rowHead,
   12358              :                                             tableBody);
   12359              : 
   12360            0 :     tableName = "Heat Index OccupantHours";
   12361            0 :     WriteResilienceBinsTableReportingPeriod(state,
   12362              :                                             tableType,
   12363              :                                             columnNum,
   12364              :                                             periodIdx,
   12365              :                                             periodTitle,
   12366              :                                             tableName,
   12367              :                                             columnHead,
   12368              :                                             columnWidth,
   12369            0 :                                             state.dataHeatBalFanSys->ZoneHeatIndexOccuHourBinsRepPeriod,
   12370              :                                             rowHead,
   12371              :                                             tableBody);
   12372              : 
   12373            0 :     tableName = "Heat Index OccupiedHours";
   12374            0 :     WriteResilienceBinsTableReportingPeriod(state,
   12375              :                                             tableType,
   12376              :                                             columnNum,
   12377              :                                             periodIdx,
   12378              :                                             periodTitle,
   12379              :                                             tableName,
   12380              :                                             columnHead,
   12381              :                                             columnWidth,
   12382            0 :                                             state.dataHeatBalFanSys->ZoneHeatIndexOccupiedHourBinsRepPeriod,
   12383              :                                             rowHead,
   12384              :                                             tableBody);
   12385              : 
   12386            0 :     columnHead(1) = "Little to no Discomfort (≤ 29) [hr]";
   12387            0 :     columnHead(2) = "Some Discomfort (> 29, ≤ 40) [hr]";
   12388            0 :     columnHead(3) = "Great Discomfort; Avoid Exertion (> 40, ≤ 45) [hr]";
   12389            0 :     columnHead(4) = "Dangerous (> 45, ≤ 50) [hr]";
   12390            0 :     columnHead(5) = "Heat Stroke Quite Possible (> 50) [hr]";
   12391            0 :     tableName = "Humidex Hours";
   12392            0 :     WriteResilienceBinsTableReportingPeriod(state,
   12393              :                                             tableType,
   12394              :                                             columnNum,
   12395              :                                             periodIdx,
   12396              :                                             periodTitle,
   12397              :                                             tableName,
   12398              :                                             columnHead,
   12399              :                                             columnWidth,
   12400            0 :                                             state.dataHeatBalFanSys->ZoneHumidexHourBinsRepPeriod,
   12401              :                                             rowHead,
   12402              :                                             tableBody);
   12403              : 
   12404            0 :     tableName = "Humidex OccupantHours";
   12405            0 :     WriteResilienceBinsTableReportingPeriod(state,
   12406              :                                             tableType,
   12407              :                                             columnNum,
   12408              :                                             periodIdx,
   12409              :                                             periodTitle,
   12410              :                                             tableName,
   12411              :                                             columnHead,
   12412              :                                             columnWidth,
   12413            0 :                                             state.dataHeatBalFanSys->ZoneHumidexOccuHourBinsRepPeriod,
   12414              :                                             rowHead,
   12415              :                                             tableBody);
   12416              : 
   12417            0 :     tableName = "Humidex OccupiedHours";
   12418            0 :     WriteResilienceBinsTableReportingPeriod(state,
   12419              :                                             tableType,
   12420              :                                             columnNum,
   12421              :                                             periodIdx,
   12422              :                                             periodTitle,
   12423              :                                             tableName,
   12424              :                                             columnHead,
   12425              :                                             columnWidth,
   12426            0 :                                             state.dataHeatBalFanSys->ZoneHumidexOccupiedHourBinsRepPeriod,
   12427              :                                             rowHead,
   12428              :                                             tableBody);
   12429              : 
   12430            0 :     bool hasPierceSET = true;
   12431            0 :     if (state.dataHeatBal->TotPeople == 0) {
   12432            0 :         hasPierceSET = false;
   12433            0 :         if (ort->displayThermalResilienceSummaryExplicitly) {
   12434            0 :             ShowWarningError(state,
   12435              :                              "Writing Reporting Period Thermal Resilience Summary - SET Degree-Hours reports: "
   12436              :                              "Zone Thermal Comfort Pierce Model Standard Effective Temperature is required, "
   12437              :                              "but no People object is defined.");
   12438              :         }
   12439              :     }
   12440            0 :     for (int iPeople = 1; iPeople <= state.dataHeatBal->TotPeople; ++iPeople) {
   12441            0 :         if (!state.dataHeatBal->People(iPeople).Pierce) {
   12442            0 :             hasPierceSET = false;
   12443            0 :             if (ort->displayThermalResilienceSummaryExplicitly) {
   12444            0 :                 ShowWarningError(state,
   12445            0 :                                  format("Writing Reporting Period Thermal Resilience Summary - SET Degree-Hours reports: Zone Thermal Comfort "
   12446              :                                         "Pierce Model Standard Effective Temperature is required, but no Pierce model is defined in {} object.",
   12447            0 :                                         state.dataHeatBal->People(iPeople).Name));
   12448              :             }
   12449              :         }
   12450              :     }
   12451              : 
   12452            0 :     if (hasPierceSET) {
   12453            0 :         columnHead(1) = "SET ≤ 12.2°C Degree-Hours [°C·hr]";
   12454            0 :         columnHead(2) = "SET ≤ 12.2°C Occupant-Weighted Degree-Hours [°C·hr]";
   12455            0 :         columnHead(3) = "SET ≤ 12.2°C Occupied Degree-Hours [°C·hr]";
   12456            0 :         columnHead(4) = "Longest SET ≤ 12.2°C Duration for Occupied Period [hr]";
   12457            0 :         columnHead(5) = "Start Time of the Longest SET ≤ 12.2°C Duration for Occupied Period ";
   12458              : 
   12459            0 :         if (unitsStyle_cur == OutputReportTabular::UnitsStyle::InchPound ||
   12460              :             unitsStyle_cur == OutputReportTabular::UnitsStyle::InchPoundExceptElectricity) {
   12461            0 :             columnHead(1) = "SET ≤ 54.0°F Degree-Hours [°F·hr]";
   12462            0 :             columnHead(2) = "SET ≤ 54.0°F Occupant-Weighted Degree-Hours [°F·hr]";
   12463            0 :             columnHead(3) = "SET ≤ 54.0°F Occupied Degree-Hours [°F·hr]";
   12464            0 :             columnHead(4) = "Longest SET ≤ 54.0°F Duration for Occupied Period [hr]";
   12465            0 :             columnHead(5) = "Start Time of the Longest SET ≤ 54.0°F Duration for Occupied Period ";
   12466              :         } else {
   12467            0 :             columnHead(1) = "SET ≤ 12.2°C Degree-Hours [°C·hr]";
   12468            0 :             columnHead(2) = "SET ≤ 12.2°C Occupant-Weighted Degree-Hours [°C·hr]";
   12469            0 :             columnHead(3) = "SET ≤ 12.2°C Occupied Degree-Hours [°C·hr]";
   12470            0 :             columnHead(4) = "Longest SET ≤ 12.2°C Duration for Occupied Period [hr]";
   12471            0 :             columnHead(5) = "Start Time of the Longest SET ≤ 12.2°C Duration for Occupied Period ";
   12472              :         }
   12473              : 
   12474            0 :         tableName = "Heating SET Degree-Hours";
   12475            0 :         Array1D_string rowHeadSET;
   12476            0 :         Array2D_string tableBodySET;
   12477            0 :         rowHeadSET.allocate(state.dataGlobal->NumOfZones + 3);
   12478            0 :         tableBodySET.allocate(columnNum, state.dataGlobal->NumOfZones + 3);
   12479            0 :         WriteSETHoursTableReportingPeriod(state,
   12480              :                                           columnNum,
   12481              :                                           periodIdx,
   12482              :                                           periodTitle,
   12483              :                                           tableName,
   12484              :                                           columnHead,
   12485              :                                           columnWidth,
   12486            0 :                                           state.dataHeatBalFanSys->ZoneLowSETHoursRepPeriod,
   12487              :                                           rowHeadSET,
   12488              :                                           tableBodySET,
   12489              :                                           degreeHourConversion);
   12490              : 
   12491            0 :         if (unitsStyle_cur == OutputReportTabular::UnitsStyle::InchPound ||
   12492              :             unitsStyle_cur == OutputReportTabular::UnitsStyle::InchPoundExceptElectricity) {
   12493            0 :             columnHead(1) = "SET > 86°F Degree-Hours [°F·hr]";
   12494            0 :             columnHead(2) = "SET > 86°F Occupant-Weighted Degree-Hours [°F·hr]";
   12495            0 :             columnHead(3) = "SET > 86°F Occupied Degree-Hours [°F·hr]";
   12496            0 :             columnHead(4) = "Longest SET > 86°F Duration for Occupied Period [hr]";
   12497            0 :             columnHead(5) = "Start Time of the Longest SET > 86°F Duration for Occupied Period";
   12498              :         } else {
   12499            0 :             columnHead(1) = "SET > 30°C Degree-Hours [°C·hr]";
   12500            0 :             columnHead(2) = "SET > 30°C Occupant-Weighted Degree-Hours [°C·hr]";
   12501            0 :             columnHead(3) = "SET > 30°C Occupied Degree-Hours [°C·hr]";
   12502            0 :             columnHead(4) = "Longest SET > 30°C Duration for Occupied Period [hr]";
   12503            0 :             columnHead(5) = "Start Time of the Longest SET > 30°C Duration for Occupied Period";
   12504              :         }
   12505              : 
   12506            0 :         tableName = "Cooling SET Degree-Hours";
   12507            0 :         WriteSETHoursTableReportingPeriod(state,
   12508              :                                           columnNum,
   12509              :                                           periodIdx,
   12510              :                                           periodTitle,
   12511              :                                           tableName,
   12512              :                                           columnHead,
   12513              :                                           columnWidth,
   12514            0 :                                           state.dataHeatBalFanSys->ZoneHighSETHoursRepPeriod,
   12515              :                                           rowHeadSET,
   12516              :                                           tableBodySET,
   12517              :                                           degreeHourConversion);
   12518            0 :     }
   12519              : 
   12520            0 :     columnHead(1) = "Hours of Safety [hr]";
   12521            0 :     columnHead(2) = "End Time of the Safety Duration";
   12522            0 :     columnHead(3) = "Safe Temperature Exceedance Hours [hr]";
   12523            0 :     columnHead(4) = "Safe Temperature Exceedance OccupantHours [hr]";
   12524            0 :     columnHead(5) = "Safe Temperature Exceedance OccupiedHours [hr]";
   12525            0 :     tableName = "Hours of Safety for Cold Events";
   12526            0 :     WriteHourOfSafetyTableReportingPeriod(state,
   12527              :                                           columnNum,
   12528              :                                           periodIdx,
   12529              :                                           periodTitle,
   12530              :                                           tableName,
   12531              :                                           columnHead,
   12532              :                                           columnWidth,
   12533            0 :                                           state.dataHeatBalFanSys->ZoneColdHourOfSafetyBinsRepPeriod,
   12534              :                                           rowHead,
   12535              :                                           tableBody,
   12536              :                                           2);
   12537              : 
   12538            0 :     tableName = "Hours of Safety for Heat Events";
   12539            0 :     WriteHourOfSafetyTableReportingPeriod(state,
   12540              :                                           columnNum,
   12541              :                                           periodIdx,
   12542              :                                           periodTitle,
   12543              :                                           tableName,
   12544              :                                           columnHead,
   12545              :                                           columnWidth,
   12546            0 :                                           state.dataHeatBalFanSys->ZoneHeatHourOfSafetyBinsRepPeriod,
   12547              :                                           rowHead,
   12548              :                                           tableBody,
   12549              :                                           2);
   12550              : 
   12551            0 :     int columnNumUnmetDegHr = 6;
   12552            0 :     Array1D_string columnHeadUnmetDegHr(6);
   12553              :     // must initialize this otherwise it will only output 5 columns
   12554            0 :     Array1D_int columnWidthUnmetDegHr;
   12555            0 :     columnWidthUnmetDegHr.allocate(columnNumUnmetDegHr);
   12556            0 :     columnWidthUnmetDegHr = 10;
   12557            0 :     columnHeadUnmetDegHr(1) = "Cooling Setpoint Unmet Degree-Hours [°C·hr]";
   12558            0 :     columnHeadUnmetDegHr(2) = "Cooling Setpoint Unmet Occupant-Weighted Degree-Hours [°C·hr]";
   12559            0 :     columnHeadUnmetDegHr(3) = "Cooling Setpoint Unmet Occupied Degree-Hours [°C·hr]";
   12560            0 :     columnHeadUnmetDegHr(4) = "Heating Setpoint Unmet Degree-Hours [°C·hr]";
   12561            0 :     columnHeadUnmetDegHr(5) = "Heating Setpoint Unmet Occupant-Weighted Degree-Hours [°C·hr]";
   12562            0 :     columnHeadUnmetDegHr(6) = "Heating Setpoint Unmet Occupied Degree-Hours [°C·hr]";
   12563            0 :     tableName = "Unmet Degree-Hours";
   12564              : 
   12565            0 :     if (unitsStyle_cur == OutputReportTabular::UnitsStyle::InchPound ||
   12566              :         unitsStyle_cur == OutputReportTabular::UnitsStyle::InchPoundExceptElectricity) {
   12567              :         int indexUnitConv;
   12568            0 :         std::string curUnits;
   12569            0 :         for (int i = 1; i < columnNumUnmetDegHr; i++) {
   12570            0 :             LookupSItoIP(state, columnHeadUnmetDegHr(i), indexUnitConv, curUnits);
   12571            0 :             columnHeadUnmetDegHr(i) = curUnits;
   12572              :         }
   12573            0 :     }
   12574              : 
   12575            0 :     Array2D_string tableBodyUnmetDegHr;
   12576            0 :     tableBodyUnmetDegHr.allocate(columnNumUnmetDegHr, state.dataGlobal->NumOfZones + 4);
   12577            0 :     WriteResilienceBinsTableReportingPeriod(state,
   12578              :                                             tableType,
   12579              :                                             columnNumUnmetDegHr,
   12580              :                                             periodIdx,
   12581              :                                             periodTitle,
   12582              :                                             tableName,
   12583              :                                             columnHeadUnmetDegHr,
   12584              :                                             columnWidthUnmetDegHr,
   12585            0 :                                             state.dataHeatBalFanSys->ZoneUnmetDegreeHourBinsRepPeriod,
   12586              :                                             rowHead,
   12587              :                                             tableBodyUnmetDegHr,
   12588              :                                             degreeHourConversion);
   12589              : 
   12590            0 :     int columnNumDiscomfortWt = 4;
   12591            0 :     Array1D_string columnHeadDiscomfortWt(columnNumDiscomfortWt);
   12592            0 :     columnHeadDiscomfortWt(1) = "Very-cold Exceedance OccupiedHours [hr]";
   12593            0 :     columnHeadDiscomfortWt(2) = "Cool Exceedance OccupiedHours [hr]";
   12594            0 :     columnHeadDiscomfortWt(3) = "Warm Exceedance OccupiedHours [hr]";
   12595            0 :     columnHeadDiscomfortWt(4) = "Very-hot Exceedance OccupiedHours [hr]";
   12596            0 :     tableName = "Discomfort-weighted Exceedance OccupantHours";
   12597            0 :     Array1D_int columnWidthDiscomfortWt;
   12598            0 :     columnWidthDiscomfortWt.allocate(columnNumDiscomfortWt);
   12599            0 :     columnWidth = 10;
   12600            0 :     Array2D_string tableBodyDiscomfortWt;
   12601            0 :     tableBodyDiscomfortWt.allocate(columnNumDiscomfortWt, state.dataGlobal->NumOfZones + 4);
   12602            0 :     WriteResilienceBinsTableReportingPeriod(state,
   12603              :                                             tableType,
   12604              :                                             columnNumDiscomfortWt,
   12605              :                                             periodIdx,
   12606              :                                             periodTitle,
   12607              :                                             tableName,
   12608              :                                             columnHeadDiscomfortWt,
   12609              :                                             columnWidthDiscomfortWt,
   12610            0 :                                             state.dataHeatBalFanSys->ZoneDiscomfortWtExceedOccuHourBinsRepPeriod,
   12611              :                                             rowHead,
   12612              :                                             tableBodyDiscomfortWt);
   12613            0 :     tableName = "Discomfort-weighted Exceedance OccupiedHours";
   12614            0 :     WriteResilienceBinsTableReportingPeriod(state,
   12615              :                                             tableType,
   12616              :                                             columnNumDiscomfortWt,
   12617              :                                             periodIdx,
   12618              :                                             periodTitle,
   12619              :                                             tableName,
   12620              :                                             columnHeadDiscomfortWt,
   12621              :                                             columnWidthDiscomfortWt,
   12622            0 :                                             state.dataHeatBalFanSys->ZoneDiscomfortWtExceedOccupiedHourBinsRepPeriod,
   12623              :                                             rowHead,
   12624              :                                             tableBodyDiscomfortWt);
   12625            0 :     columnHead.deallocate();
   12626            0 :     columnWidth.deallocate();
   12627            0 :     tableBody.deallocate();
   12628            0 :     columnHeadUnmetDegHr.deallocate();
   12629            0 :     columnWidthUnmetDegHr.deallocate();
   12630            0 :     tableBodyUnmetDegHr.deallocate();
   12631            0 :     columnHeadDiscomfortWt.deallocate();
   12632            0 :     columnWidthDiscomfortWt.deallocate();
   12633            0 :     tableBodyDiscomfortWt.deallocate();
   12634            0 : }
   12635              : 
   12636              : template <int columnNum>
   12637            0 : void WriteResilienceBinsTable(EnergyPlusData &state,
   12638              :                               std::array<int, columnNum> const &columnHead,
   12639              :                               const std::array<Real64, columnNum> DataHeatBalance::ZoneResilience::*memberPtr,
   12640              :                               Real64 const unitConvMultiplier)
   12641              : {
   12642            0 :     std::array<Real64, columnNum> columnMax = {0.0};
   12643            0 :     std::array<Real64, columnNum> columnMin = {0.0};
   12644            0 :     std::array<Real64, columnNum> columnSum = {0.0};
   12645            0 :     for (int j = 0; j < columnNum; j++) {
   12646            0 :         columnMin[j] = (state.dataHeatBal->Resilience(1).*memberPtr)[j] * unitConvMultiplier;
   12647              :     }
   12648            0 :     for (int i = 1; i <= state.dataGlobal->NumOfZones; ++i) {
   12649            0 :         const std::string &ZoneName = state.dataHeatBal->Zone(i).Name;
   12650            0 :         for (int j = 0; j < columnNum; j++) {
   12651            0 :             Real64 curValue = (state.dataHeatBal->Resilience(i).*memberPtr)[j] * unitConvMultiplier;
   12652            0 :             if (curValue > columnMax[j]) columnMax[j] = curValue;
   12653            0 :             if (curValue < columnMin[j]) columnMin[j] = curValue;
   12654            0 :             columnSum[j] += curValue;
   12655            0 :             PreDefTableEntry(state, columnHead[j], ZoneName, RealToStr(curValue, 2));
   12656              :         }
   12657              :     }
   12658            0 :     for (int j = 0; j < columnNum; j++) {
   12659            0 :         PreDefTableEntry(state, columnHead[j], "Min", RealToStr(columnMin[j], 2));
   12660            0 :         PreDefTableEntry(state, columnHead[j], "Max", RealToStr(columnMax[j], 2));
   12661            0 :         PreDefTableEntry(state, columnHead[j], "Average", RealToStr(columnSum[j] / state.dataGlobal->NumOfZones, 2));
   12662            0 :         PreDefTableEntry(state, columnHead[j], "Sum", RealToStr(columnSum[j], 2));
   12663              :     }
   12664            0 : }
   12665              : 
   12666              : template <int columnNum>
   12667          271 : void WriteResilienceBinsTableNonPreDefUseZoneData(EnergyPlusData &state,
   12668              :                                                   const std::string &tableName,
   12669              :                                                   Array1D_string const &columnHead,
   12670              :                                                   Array1D_int &columnWidth,
   12671              :                                                   const std::array<Real64, columnNum> DataHeatBalance::ZoneResilience::*memberPtr,
   12672              :                                                   Array1D_string &rowHead,
   12673              :                                                   Array2D_string &tableBody,
   12674              :                                                   Real64 const unitConvMultiplier)
   12675              : {
   12676          271 :     WriteSubtitle(state, tableName);
   12677              : 
   12678          271 :     std::array<Real64, columnNum> columnMax = {0.0};
   12679          271 :     std::array<Real64, columnNum> columnMin = {0.0};
   12680          271 :     std::array<Real64, columnNum> columnSum = {0.0};
   12681              : 
   12682         1596 :     for (int j = 0; j < columnNum; j++) {
   12683         1325 :         columnMin.at(j) = (state.dataHeatBal->Resilience(1).*memberPtr).at(j) * unitConvMultiplier;
   12684              :     }
   12685          597 :     for (int ZoneNum = 1; ZoneNum <= state.dataGlobal->NumOfZones; ZoneNum++) {
   12686          326 :         std::string const &ZoneName = state.dataHeatBal->Zone(ZoneNum).Name;
   12687          326 :         rowHead(ZoneNum) = ZoneName;
   12688         1920 :         for (int j = 0; j < columnNum; j++) {
   12689         1594 :             Real64 curValue = (state.dataHeatBal->Resilience(ZoneNum).*memberPtr).at(j) * unitConvMultiplier;
   12690         1594 :             if (curValue > columnMax.at(j)) columnMax.at(j) = curValue;
   12691         1594 :             if (curValue < columnMin.at(j)) columnMin.at(j) = curValue;
   12692         1594 :             columnSum.at(j) += curValue;
   12693         1594 :             tableBody(j + 1, ZoneNum) = RealToStr(curValue, 2);
   12694              :         }
   12695              :     }
   12696              : 
   12697          271 :     rowHead(state.dataGlobal->NumOfZones + 1) = "Min";
   12698          271 :     rowHead(state.dataGlobal->NumOfZones + 2) = "Max";
   12699          271 :     rowHead(state.dataGlobal->NumOfZones + 3) = "Average";
   12700          271 :     rowHead(state.dataGlobal->NumOfZones + 4) = "Sum";
   12701              : 
   12702         1596 :     for (int j = 0; j < columnNum; j++) {
   12703         1325 :         tableBody(j + 1, state.dataGlobal->NumOfZones + 1) = RealToStr(columnMin.at(j), 2);
   12704         1325 :         tableBody(j + 1, state.dataGlobal->NumOfZones + 2) = RealToStr(columnMax.at(j), 2);
   12705         1325 :         tableBody(j + 1, state.dataGlobal->NumOfZones + 3) = RealToStr(columnSum.at(j) / state.dataGlobal->NumOfZones, 2);
   12706         1325 :         tableBody(j + 1, state.dataGlobal->NumOfZones + 4) = RealToStr(columnSum.at(j), 2);
   12707              :     }
   12708              : 
   12709          271 :     WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
   12710          271 :     if (state.dataSQLiteProcedures->sqlite) {
   12711           27 :         state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
   12712              :             tableBody, rowHead, columnHead, "AnnualThermalResilienceSummary", "Entire Facility", tableName);
   12713              :     }
   12714          271 :     if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
   12715            0 :         state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(
   12716              :             tableBody, rowHead, columnHead, "AnnualThermalResilienceSummary", "Entire Facility", tableName);
   12717              :     }
   12718          271 : }
   12719              : 
   12720            2 : void WriteResilienceBinsTableReportingPeriod(EnergyPlusData &state,
   12721              :                                              const std::string &tableType,
   12722              :                                              int const columnNum,
   12723              :                                              int const periodIdx,
   12724              :                                              const std::string &periodTitle,
   12725              :                                              const std::string &tableName,
   12726              :                                              Array1D_string const &columnHead,
   12727              :                                              Array1D_int &columnWidth,
   12728              :                                              Array2D<std::vector<Real64>> const &ZoneBins,
   12729              :                                              Array1D_string &rowHead,
   12730              :                                              Array2D_string &tableBody,
   12731              :                                              Real64 const unitConvMultiplier)
   12732              : {
   12733            2 :     WriteSubtitle(state, tableName);
   12734              : 
   12735            2 :     std::vector<Real64> columnMax(columnNum, 0);
   12736            2 :     std::vector<Real64> columnMin(columnNum, 0);
   12737            2 :     std::vector<Real64> columnSum(columnNum, 0);
   12738              : 
   12739           14 :     for (int j = 0; j < columnNum; j++) {
   12740           12 :         columnMin.at(j) = ZoneBins(1, periodIdx).at(j) * unitConvMultiplier;
   12741              :     }
   12742            4 :     for (int ZoneNum = 1; ZoneNum <= state.dataGlobal->NumOfZones; ZoneNum++) {
   12743            2 :         std::string const &ZoneName = state.dataHeatBal->Zone(ZoneNum).Name;
   12744            2 :         rowHead(ZoneNum) = ZoneName;
   12745           14 :         for (int j = 0; j < columnNum; j++) {
   12746           12 :             Real64 curValue = ZoneBins(ZoneNum, periodIdx).at(j) * unitConvMultiplier;
   12747           12 :             if (curValue > columnMax.at(j)) columnMax.at(j) = curValue;
   12748           12 :             if (curValue < columnMin.at(j)) columnMin.at(j) = curValue;
   12749           12 :             columnSum.at(j) += curValue;
   12750           12 :             tableBody(j + 1, ZoneNum) = RealToStr(curValue, 2);
   12751              :         }
   12752              :     }
   12753              : 
   12754            2 :     rowHead(state.dataGlobal->NumOfZones + 1) = "Min";
   12755            2 :     rowHead(state.dataGlobal->NumOfZones + 2) = "Max";
   12756            2 :     rowHead(state.dataGlobal->NumOfZones + 3) = "Average";
   12757            2 :     rowHead(state.dataGlobal->NumOfZones + 4) = "Sum";
   12758              : 
   12759           14 :     for (int j = 0; j < columnNum; j++) {
   12760           12 :         tableBody(j + 1, state.dataGlobal->NumOfZones + 1) = RealToStr(columnMin.at(j), 2);
   12761           12 :         tableBody(j + 1, state.dataGlobal->NumOfZones + 2) = RealToStr(columnMax.at(j), 2);
   12762           12 :         tableBody(j + 1, state.dataGlobal->NumOfZones + 3) = RealToStr(columnSum.at(j) / state.dataGlobal->NumOfZones, 2);
   12763           12 :         tableBody(j + 1, state.dataGlobal->NumOfZones + 4) = RealToStr(columnSum.at(j), 2);
   12764              :     }
   12765              : 
   12766            2 :     WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
   12767            2 :     if (state.dataSQLiteProcedures->sqlite) {
   12768            0 :         state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
   12769            0 :             tableBody, rowHead, columnHead, "ReportingPeriod-" + periodTitle + "-" + tableType + "ResilienceSummary", "Entire Facility", tableName);
   12770              :     }
   12771            2 :     if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
   12772            0 :         state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(
   12773            0 :             tableBody, rowHead, columnHead, "ReportingPeriod-" + periodTitle + "-" + tableType + "ResilienceSummary", "Entire Facility", tableName);
   12774              :     }
   12775            2 : }
   12776              : 
   12777            2 : void WriteSETHoursTableNonPreDefUseZoneData(EnergyPlusData &state,
   12778              :                                             int const columnNum,
   12779              :                                             const std::string &tableName,
   12780              :                                             Array1D_string const &columnHead,
   12781              :                                             Array1D_int &columnWidth,
   12782              :                                             const std::array<Real64, 5> DataHeatBalance::ZoneResilience::*memberPtr,
   12783              :                                             Array1D_string &rowHead,
   12784              :                                             Array2D_string &tableBody,
   12785              :                                             Real64 const unitConvMultiplier)
   12786              : {
   12787              : 
   12788            2 :     WriteSubtitle(state, tableName);
   12789              : 
   12790            2 :     std::vector<Real64> columnMax(columnNum - 1, 0);
   12791            2 :     std::vector<Real64> columnMin(columnNum - 1, 0);
   12792            2 :     std::vector<Real64> columnSum(columnNum - 1, 0);
   12793            2 :     std::vector<Real64> multiplier(columnNum - 1, unitConvMultiplier);
   12794            2 :     multiplier[columnNum - 2] = 1.0;
   12795              : 
   12796           10 :     for (int j = 0; j < columnNum - 1; j++) {
   12797            8 :         columnMin.at(j) = (state.dataHeatBal->Resilience(1).*memberPtr).at(j) * multiplier.at(j);
   12798              :     }
   12799            6 :     for (int ZoneNum = 1; ZoneNum <= state.dataGlobal->NumOfZones; ZoneNum++) {
   12800            4 :         std::string const &ZoneName = state.dataHeatBal->Zone(ZoneNum).Name;
   12801            4 :         rowHead(ZoneNum) = ZoneName;
   12802           20 :         for (int j = 0; j < columnNum - 1; j++) {
   12803           16 :             Real64 curValue = (state.dataHeatBal->Resilience(ZoneNum).*memberPtr).at(j) * multiplier.at(j);
   12804           16 :             if (curValue > columnMax.at(j)) columnMax.at(j) = curValue;
   12805           16 :             if (curValue < columnMin.at(j)) columnMin.at(j) = curValue;
   12806           16 :             columnSum.at(j) += curValue;
   12807           16 :             tableBody(j + 1, ZoneNum) = RealToStr(curValue, 2);
   12808              :         }
   12809            4 :         tableBody(columnNum, ZoneNum) = DateToString((state.dataHeatBal->Resilience(ZoneNum).*memberPtr).at(columnNum - 1));
   12810              :     }
   12811              : 
   12812            2 :     rowHead(state.dataGlobal->NumOfZones + 1) = "Min";
   12813            2 :     rowHead(state.dataGlobal->NumOfZones + 2) = "Max";
   12814            2 :     rowHead(state.dataGlobal->NumOfZones + 3) = "Average";
   12815              : 
   12816           10 :     for (int j = 0; j < columnNum - 1; j++) {
   12817            8 :         tableBody(j + 1, state.dataGlobal->NumOfZones + 1) = RealToStr(columnMin.at(j), 2);
   12818            8 :         tableBody(j + 1, state.dataGlobal->NumOfZones + 2) = RealToStr(columnMax.at(j), 2);
   12819            8 :         tableBody(j + 1, state.dataGlobal->NumOfZones + 3) = RealToStr(columnSum.at(j) / state.dataGlobal->NumOfZones, 2);
   12820              :     }
   12821            2 :     tableBody(columnNum, state.dataGlobal->NumOfZones + 1) = "-";
   12822            2 :     tableBody(columnNum, state.dataGlobal->NumOfZones + 2) = "-";
   12823            2 :     tableBody(columnNum, state.dataGlobal->NumOfZones + 3) = "-";
   12824              : 
   12825            2 :     WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
   12826            2 :     if (state.dataSQLiteProcedures->sqlite) {
   12827            0 :         state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
   12828              :             tableBody, rowHead, columnHead, "AnnualThermalResilienceSummary", "Entire Facility", tableName);
   12829              :     }
   12830            2 :     if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
   12831            0 :         state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(
   12832              :             tableBody, rowHead, columnHead, "AnnualThermalResilienceSummary", "Entire Facility", tableName);
   12833              :     }
   12834            2 : }
   12835              : 
   12836            2 : void WriteSETHoursTableReportingPeriod(EnergyPlusData &state,
   12837              :                                        int const columnNum,
   12838              :                                        int const periodIdx,
   12839              :                                        const std::string &periodTitle,
   12840              :                                        const std::string &tableName,
   12841              :                                        Array1D_string const &columnHead,
   12842              :                                        Array1D_int &columnWidth,
   12843              :                                        Array2D<std::vector<Real64>> const &ZoneBins,
   12844              :                                        Array1D_string &rowHead,
   12845              :                                        Array2D_string &tableBody,
   12846              :                                        Real64 const unitConvMultiplier)
   12847              : {
   12848              : 
   12849            2 :     WriteSubtitle(state, tableName);
   12850              : 
   12851            2 :     std::vector<Real64> columnMax(columnNum - 1, 0);
   12852            2 :     std::vector<Real64> columnMin(columnNum - 1, 0);
   12853            2 :     std::vector<Real64> columnSum(columnNum - 1, 0);
   12854            2 :     std::vector<Real64> multiplier(columnNum - 1, unitConvMultiplier);
   12855            2 :     multiplier[columnNum - 2] = 1.0;
   12856              : 
   12857           10 :     for (int j = 0; j < columnNum - 1; j++) {
   12858            8 :         columnMin.at(j) = ZoneBins(1, periodIdx).at(j) * multiplier.at(j);
   12859              :     }
   12860            4 :     for (int ZoneNum = 1; ZoneNum <= state.dataGlobal->NumOfZones; ZoneNum++) {
   12861            2 :         std::string const &ZoneName = state.dataHeatBal->Zone(ZoneNum).Name;
   12862            2 :         rowHead(ZoneNum) = ZoneName;
   12863           10 :         for (int j = 0; j < columnNum - 1; j++) {
   12864            8 :             Real64 curValue = ZoneBins(ZoneNum, periodIdx).at(j) * multiplier.at(j);
   12865            8 :             if (curValue > columnMax.at(j)) columnMax.at(j) = curValue;
   12866            8 :             if (curValue < columnMin.at(j)) columnMin.at(j) = curValue;
   12867            8 :             columnSum.at(j) += curValue;
   12868            8 :             tableBody(j + 1, ZoneNum) = RealToStr(curValue, 2);
   12869              :         }
   12870            2 :         tableBody(columnNum, ZoneNum) = DateToString(ZoneBins(ZoneNum, periodIdx)[columnNum - 1]);
   12871              :     }
   12872              : 
   12873            2 :     rowHead(state.dataGlobal->NumOfZones + 1) = "Min";
   12874            2 :     rowHead(state.dataGlobal->NumOfZones + 2) = "Max";
   12875            2 :     rowHead(state.dataGlobal->NumOfZones + 3) = "Average";
   12876              : 
   12877           10 :     for (int j = 0; j < columnNum - 1; j++) {
   12878            8 :         tableBody(j + 1, state.dataGlobal->NumOfZones + 1) = RealToStr(columnMin.at(j), 2);
   12879            8 :         tableBody(j + 1, state.dataGlobal->NumOfZones + 2) = RealToStr(columnMax.at(j), 2);
   12880            8 :         tableBody(j + 1, state.dataGlobal->NumOfZones + 3) = RealToStr(columnSum.at(j) / state.dataGlobal->NumOfZones, 2);
   12881              :     }
   12882            2 :     tableBody(columnNum, state.dataGlobal->NumOfZones + 1) = "-";
   12883            2 :     tableBody(columnNum, state.dataGlobal->NumOfZones + 2) = "-";
   12884            2 :     tableBody(columnNum, state.dataGlobal->NumOfZones + 3) = "-";
   12885              : 
   12886            2 :     WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
   12887            2 :     if (state.dataSQLiteProcedures->sqlite) {
   12888            0 :         state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
   12889            0 :             tableBody, rowHead, columnHead, "ReportingPeriod-" + periodTitle + "-ThermalResilienceSummary", "Entire Facility", tableName);
   12890              :     }
   12891            2 :     if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
   12892            0 :         state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(
   12893            0 :             tableBody, rowHead, columnHead, "ReportingPeriod-" + periodTitle + "-ThermalResilienceSummary", "Entire Facility", tableName);
   12894              :     }
   12895            2 : }
   12896              : 
   12897           55 : std::string RetrieveEntryFromTableBody(Array2D_string const &tableBody, int const rowIndex, int const columnIndex)
   12898              : {
   12899           55 :     return trimmed(ljustified(tableBody(columnIndex, rowIndex)));
   12900              : }
   12901              : 
   12902           61 : void WriteHourOfSafetyTableNonPreDefUseZoneData(EnergyPlusData &state,
   12903              :                                                 int const columnNum,
   12904              :                                                 const std::string &tableName,
   12905              :                                                 Array1D_string const &columnHead,
   12906              :                                                 Array1D_int &columnWidth,
   12907              :                                                 const std::array<Real64, 5> DataHeatBalance::ZoneResilience::*memberPtr,
   12908              :                                                 Array1D_string &rowHead,
   12909              :                                                 Array2D_string &tableBody,
   12910              :                                                 int const dateColIdx)
   12911              : {
   12912              : 
   12913           61 :     WriteSubtitle(state, tableName);
   12914          135 :     for (int ZoneNum = 1; ZoneNum <= state.dataGlobal->NumOfZones; ++ZoneNum) {
   12915           74 :         rowHead(ZoneNum) = state.dataHeatBal->Zone(ZoneNum).Name;
   12916          444 :         for (int j = 1; j <= columnNum; j++) {
   12917          370 :             tableBody(j, ZoneNum) = RealToStr((state.dataHeatBal->Resilience(ZoneNum).*memberPtr).at(j - 1), 2);
   12918              :         }
   12919           74 :         tableBody(dateColIdx, ZoneNum) = DateToString((state.dataHeatBal->Resilience(ZoneNum).*memberPtr).at(dateColIdx - 1));
   12920              :     }
   12921              : 
   12922           61 :     std::vector<Real64> columnMax(columnNum, 0);
   12923           61 :     std::vector<Real64> columnMin(columnNum, 0);
   12924           61 :     std::vector<Real64> columnSum(columnNum, 0);
   12925              : 
   12926          366 :     for (int j = 0; j < columnNum; j++) {
   12927          305 :         columnMin.at(j) = (state.dataHeatBal->Resilience(1).*memberPtr).at(j);
   12928              :     }
   12929          135 :     for (int ZoneNum = 1; ZoneNum <= state.dataGlobal->NumOfZones; ++ZoneNum) {
   12930          444 :         for (int j = 0; j < columnNum; j++) {
   12931          370 :             Real64 curValue = (state.dataHeatBal->Resilience(ZoneNum).*memberPtr).at(j);
   12932          370 :             if (curValue > columnMax.at(j)) columnMax.at(j) = curValue;
   12933          370 :             if (curValue < columnMin.at(j)) columnMin.at(j) = curValue;
   12934          370 :             columnSum.at(j) += curValue;
   12935              :         }
   12936              :     }
   12937              : 
   12938           61 :     rowHead(state.dataGlobal->NumOfZones + 1) = "Min";
   12939           61 :     rowHead(state.dataGlobal->NumOfZones + 2) = "Max";
   12940           61 :     rowHead(state.dataGlobal->NumOfZones + 3) = "Average";
   12941           61 :     rowHead(state.dataGlobal->NumOfZones + 4) = "Sum";
   12942              : 
   12943          366 :     for (int j = 0; j < columnNum; j++) {
   12944          305 :         tableBody(j + 1, state.dataGlobal->NumOfZones + 1) = RealToStr(columnMin.at(j), 2);
   12945          305 :         tableBody(j + 1, state.dataGlobal->NumOfZones + 2) = RealToStr(columnMax.at(j), 2);
   12946          305 :         tableBody(j + 1, state.dataGlobal->NumOfZones + 3) = RealToStr(columnSum.at(j) / state.dataGlobal->NumOfZones, 2);
   12947          305 :         tableBody(j + 1, state.dataGlobal->NumOfZones + 4) = RealToStr(columnSum.at(j), 2);
   12948              :     }
   12949              : 
   12950          305 :     for (int i = 1; i < 5; i++) {
   12951          244 :         tableBody(dateColIdx, state.dataGlobal->NumOfZones + i) = "-";
   12952              :     }
   12953              : 
   12954           61 :     WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
   12955           61 :     if (state.dataSQLiteProcedures->sqlite) {
   12956            6 :         state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
   12957              :             tableBody, rowHead, columnHead, "AnnualThermalResilienceSummary", "Entire Facility", tableName);
   12958              :     }
   12959           61 :     if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
   12960            0 :         state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(
   12961              :             tableBody, rowHead, columnHead, "AnnualThermalResilienceSummary", "Entire Facility", tableName);
   12962              :     }
   12963           61 : }
   12964              : 
   12965            0 : void WriteHourOfSafetyTableReportingPeriod(EnergyPlusData &state,
   12966              :                                            int const columnNum,
   12967              :                                            int const periodIdx,
   12968              :                                            const std::string &periodTitle,
   12969              :                                            const std::string &tableName,
   12970              :                                            Array1D_string const &columnHead,
   12971              :                                            Array1D_int &columnWidth,
   12972              :                                            Array2D<std::vector<Real64>> const &ZoneBins,
   12973              :                                            Array1D_string &rowHead,
   12974              :                                            Array2D_string &tableBody,
   12975              :                                            int const dateColIdx)
   12976              : {
   12977              : 
   12978            0 :     WriteSubtitle(state, tableName);
   12979            0 :     for (int ZoneNum = 1; ZoneNum <= state.dataGlobal->NumOfZones; ++ZoneNum) {
   12980            0 :         rowHead(ZoneNum) = state.dataHeatBal->Zone(ZoneNum).Name;
   12981            0 :         for (int j = 1; j <= columnNum; j++) {
   12982            0 :             tableBody(j, ZoneNum) = RealToStr(ZoneBins(ZoneNum, periodIdx).at(j - 1), 2);
   12983              :         }
   12984            0 :         tableBody(dateColIdx, ZoneNum) = DateToString(ZoneBins(ZoneNum, periodIdx).at(dateColIdx - 1));
   12985              :     }
   12986              : 
   12987            0 :     std::vector<Real64> columnMax(columnNum, 0);
   12988            0 :     std::vector<Real64> columnMin(columnNum, 0);
   12989            0 :     std::vector<Real64> columnSum(columnNum, 0);
   12990              : 
   12991            0 :     for (int j = 0; j < columnNum; j++) {
   12992            0 :         columnMin.at(j) = ZoneBins(1, periodIdx).at(j);
   12993              :     }
   12994            0 :     for (int i = 1; i <= state.dataGlobal->NumOfZones; ++i) {
   12995            0 :         for (int j = 0; j < columnNum; j++) {
   12996            0 :             Real64 curValue = ZoneBins(i, periodIdx).at(j);
   12997            0 :             if (curValue > columnMax.at(j)) columnMax.at(j) = curValue;
   12998            0 :             if (curValue < columnMin.at(j)) columnMin.at(j) = curValue;
   12999            0 :             columnSum.at(j) += curValue;
   13000              :         }
   13001              :     }
   13002              : 
   13003            0 :     rowHead(state.dataGlobal->NumOfZones + 1) = "Min";
   13004            0 :     rowHead(state.dataGlobal->NumOfZones + 2) = "Max";
   13005            0 :     rowHead(state.dataGlobal->NumOfZones + 3) = "Average";
   13006            0 :     rowHead(state.dataGlobal->NumOfZones + 4) = "Sum";
   13007              : 
   13008            0 :     for (int j = 0; j < columnNum; j++) {
   13009            0 :         tableBody(j + 1, state.dataGlobal->NumOfZones + 1) = RealToStr(columnMin.at(j), 2);
   13010            0 :         tableBody(j + 1, state.dataGlobal->NumOfZones + 2) = RealToStr(columnMax.at(j), 2);
   13011            0 :         tableBody(j + 1, state.dataGlobal->NumOfZones + 3) = RealToStr(columnSum.at(j) / state.dataGlobal->NumOfZones, 2);
   13012            0 :         tableBody(j + 1, state.dataGlobal->NumOfZones + 4) = RealToStr(columnSum.at(j), 2);
   13013              :     }
   13014              : 
   13015            0 :     for (int i = 1; i < 5; i++) {
   13016            0 :         tableBody(dateColIdx, state.dataGlobal->NumOfZones + i) = "-";
   13017              :     }
   13018              : 
   13019            0 :     WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
   13020            0 :     if (state.dataSQLiteProcedures->sqlite) {
   13021            0 :         state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
   13022            0 :             tableBody, rowHead, columnHead, "ReportingPeriod-" + periodTitle + "-ThermalResilienceSummary", "Entire Facility", tableName);
   13023              :     }
   13024            0 :     if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
   13025            0 :         state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(
   13026            0 :             tableBody, rowHead, columnHead, "ReportingPeriod-" + periodTitle + "-ThermalResilienceSummary", "Entire Facility", tableName);
   13027              :     }
   13028            0 : }
   13029              : 
   13030            0 : void WriteHourOfSafetyTable(EnergyPlusData &state,
   13031              :                             int const columnNum,
   13032              :                             std::vector<int> const &columnHead,
   13033              :                             Array1D<std::vector<Real64>> const &ZoneBins,
   13034              :                             int const dateColIdx)
   13035              : {
   13036            0 :     std::vector<Real64> columnMax(columnNum, 0);
   13037            0 :     std::vector<Real64> columnMin(columnNum, 0);
   13038            0 :     std::vector<Real64> columnSum(columnNum, 0);
   13039            0 :     for (int j = 0; j < columnNum; j++) {
   13040            0 :         columnMin[j] = ZoneBins(1)[j];
   13041              :     }
   13042            0 :     for (int i = 1; i <= state.dataGlobal->NumOfZones; ++i) {
   13043            0 :         auto const &thisZone = state.dataHeatBal->Zone(i);
   13044            0 :         for (int j = 0; j < columnNum; j++) {
   13045            0 :             if (j == dateColIdx) {
   13046            0 :                 std::string startDateTime = DateToString(int(ZoneBins(i)[dateColIdx]));
   13047            0 :                 PreDefTableEntry(state, columnHead[dateColIdx], thisZone.Name, startDateTime);
   13048            0 :             } else {
   13049            0 :                 Real64 curValue = ZoneBins(i)[j];
   13050            0 :                 if (curValue > columnMax[j]) columnMax[j] = curValue;
   13051            0 :                 if (curValue < columnMin[j]) columnMin[j] = curValue;
   13052            0 :                 columnSum[j] += curValue;
   13053            0 :                 PreDefTableEntry(state, columnHead[j], thisZone.Name, RealToStr(curValue, 2));
   13054              :             }
   13055              :         }
   13056              :     }
   13057            0 :     for (int j = 0; j < columnNum; j++) {
   13058            0 :         if (j == dateColIdx) {
   13059            0 :             PreDefTableEntry(state, columnHead[j], "Min", "-");
   13060            0 :             PreDefTableEntry(state, columnHead[j], "Max", "-");
   13061            0 :             PreDefTableEntry(state, columnHead[j], "Average", "-");
   13062            0 :             PreDefTableEntry(state, columnHead[j], "Sum", "-");
   13063              :         } else {
   13064            0 :             PreDefTableEntry(state, columnHead[j], "Min", RealToStr(columnMin[j], 2));
   13065            0 :             PreDefTableEntry(state, columnHead[j], "Max", RealToStr(columnMax[j], 2));
   13066            0 :             PreDefTableEntry(state, columnHead[j], "Average", RealToStr(columnSum[j] / state.dataGlobal->NumOfZones, 2));
   13067            0 :             PreDefTableEntry(state, columnHead[j], "Sum", RealToStr(columnSum[j], 2));
   13068              :         }
   13069              :     }
   13070            0 : }
   13071              : 
   13072           30 : void WriteThermalResilienceTables(EnergyPlusData &state)
   13073              : {
   13074              : 
   13075              :     // Using/Aliasing
   13076           30 :     auto const &ort = state.dataOutRptTab;
   13077              : 
   13078           30 :     if (state.dataGlobal->NumOfZones <= 0) {
   13079            0 :         return;
   13080              :     }
   13081              : 
   13082              :     Real64 degreeHourConversion;
   13083           30 :     UnitsStyle unitsStyle_cur = ort->unitsStyle;
   13084           30 :     if (unitsStyle_cur == OutputReportTabular::UnitsStyle::InchPound ||
   13085              :         unitsStyle_cur == OutputReportTabular::UnitsStyle::InchPoundExceptElectricity) {
   13086            4 :         degreeHourConversion = getSpecificUnitMultiplier(state, "°C·hr", "°F·hr");
   13087              :     } else {
   13088           29 :         degreeHourConversion = 1.0;
   13089              :     }
   13090              : 
   13091           90 :     WriteReportHeaders(state, "Annual Thermal Resilience Summary", "Entire Facility", OutputProcessor::StoreType::Average);
   13092              : 
   13093           30 :     Array1D_int columnWidth;
   13094           30 :     columnWidth.allocate(numColumnThermalTbl);
   13095           30 :     columnWidth = 10;
   13096           30 :     Array1D_string rowHead;
   13097           30 :     Array2D_string tableBody;
   13098           30 :     rowHead.allocate(state.dataGlobal->NumOfZones + 4);
   13099           30 :     tableBody.allocate(numColumnThermalTbl, state.dataGlobal->NumOfZones + 4);
   13100           30 :     Array1D_string columnHeadStr(numColumnThermalTbl);
   13101              : 
   13102           30 :     if (unitsStyle_cur == OutputReportTabular::UnitsStyle::InchPound ||
   13103              :         unitsStyle_cur == OutputReportTabular::UnitsStyle::InchPoundExceptElectricity) {
   13104            1 :         columnHeadStr(1) = "Safe (≤ 80.1°F) [hr]";
   13105            1 :         columnHeadStr(2) = "Caution (> 80.1°F, ≤ 90.0°F) [hr]";
   13106            1 :         columnHeadStr(3) = "Extreme Caution (> 90.0°F, ≤ 102.9°F) [hr]";
   13107            1 :         columnHeadStr(4) = "Danger (> 102.9, ≤ 125.1°F) [hr]";
   13108            1 :         columnHeadStr(5) = "Extreme Danger (> 125.1°F) [hr]";
   13109              :     } else {
   13110           29 :         columnHeadStr(1) = "Safe (≤ 26.7°C) [hr]";
   13111           29 :         columnHeadStr(2) = "Caution (> 26.7°C, ≤ 32.2°C) [hr]";
   13112           29 :         columnHeadStr(3) = "Extreme Caution (> 32.2°C, ≤ 39.4°C) [hr]";
   13113           29 :         columnHeadStr(4) = "Danger (> 39.4°C, ≤ 51.7°C) [hr]";
   13114           29 :         columnHeadStr(5) = "Extreme Danger (> 51.7°C) [hr]";
   13115              :     }
   13116              : 
   13117           30 :     std::array<Real64, numColumnThermalTbl> DataHeatBalance::ZoneResilience::*ptrHeatIndex = &DataHeatBalance::ZoneResilience::ZoneHeatIndexHourBins;
   13118           30 :     std::array<Real64, numColumnThermalTbl> DataHeatBalance::ZoneResilience::*ptrHeatIndexOccuHour =
   13119              :         &DataHeatBalance::ZoneResilience::ZoneHeatIndexOccuHourBins;
   13120           30 :     std::array<Real64, numColumnThermalTbl> DataHeatBalance::ZoneResilience::*ptrHeatIndexOccupiedHour =
   13121              :         &DataHeatBalance::ZoneResilience::ZoneHeatIndexOccupiedHourBins;
   13122           30 :     std::string tableName = "Heat Index Hours";
   13123           30 :     WriteResilienceBinsTableNonPreDefUseZoneData<numColumnThermalTbl>(state, tableName, columnHeadStr, columnWidth, ptrHeatIndex, rowHead, tableBody);
   13124           30 :     tableName = "Heat Index OccupantHours";
   13125           30 :     WriteResilienceBinsTableNonPreDefUseZoneData<numColumnThermalTbl>(
   13126              :         state, tableName, columnHeadStr, columnWidth, ptrHeatIndexOccuHour, rowHead, tableBody);
   13127           30 :     tableName = "Heat Index OccupiedHours";
   13128           30 :     WriteResilienceBinsTableNonPreDefUseZoneData<numColumnThermalTbl>(
   13129              :         state, tableName, columnHeadStr, columnWidth, ptrHeatIndexOccupiedHour, rowHead, tableBody);
   13130              : 
   13131           30 :     columnHeadStr(1) = "Little to no Discomfort (≤ 29) [hr]";
   13132           30 :     columnHeadStr(2) = "Some Discomfort (> 29, ≤ 40) [hr]";
   13133           30 :     columnHeadStr(3) = "Great Discomfort; Avoid Exertion (> 40, ≤ 45) [hr]";
   13134           30 :     columnHeadStr(4) = "Dangerous (> 45, ≤ 50) [hr]";
   13135           30 :     columnHeadStr(5) = "Heat Stroke Quite Possible (> 50) [hr]";
   13136              : 
   13137           30 :     std::array<Real64, numColumnThermalTbl> DataHeatBalance::ZoneResilience::*ptrHumidex = &DataHeatBalance::ZoneResilience::ZoneHumidexHourBins;
   13138           30 :     std::array<Real64, numColumnThermalTbl> DataHeatBalance::ZoneResilience::*ptrHumidexOccuHour =
   13139              :         &DataHeatBalance::ZoneResilience::ZoneHumidexOccuHourBins;
   13140           30 :     std::array<Real64, numColumnThermalTbl> DataHeatBalance::ZoneResilience::*ptrHumidexOccupiedHour =
   13141              :         &DataHeatBalance::ZoneResilience::ZoneHumidexOccupiedHourBins;
   13142           30 :     tableName = "Humidex Hours";
   13143           30 :     WriteResilienceBinsTableNonPreDefUseZoneData<numColumnThermalTbl>(state, tableName, columnHeadStr, columnWidth, ptrHumidex, rowHead, tableBody);
   13144           30 :     tableName = "Humidex OccupantHours";
   13145           30 :     WriteResilienceBinsTableNonPreDefUseZoneData<numColumnThermalTbl>(
   13146              :         state, tableName, columnHeadStr, columnWidth, ptrHumidexOccuHour, rowHead, tableBody);
   13147           30 :     tableName = "Humidex OccupiedHours";
   13148           30 :     WriteResilienceBinsTableNonPreDefUseZoneData<numColumnThermalTbl>(
   13149              :         state, tableName, columnHeadStr, columnWidth, ptrHumidexOccupiedHour, rowHead, tableBody);
   13150              : 
   13151           30 :     bool hasPierceSET = true;
   13152           30 :     if (state.dataHeatBal->TotPeople == 0) {
   13153           24 :         hasPierceSET = false;
   13154           24 :         if (ort->displayThermalResilienceSummaryExplicitly) {
   13155            0 :             ShowWarningError(state,
   13156              :                              "Writing Annual Thermal Resilience Summary - SET Degree-Hours reports: "
   13157              :                              "Zone Thermal Comfort Pierce Model Standard Effective Temperature is required, "
   13158              :                              "but no People object is defined.");
   13159              :         }
   13160              :     }
   13161           42 :     for (int iPeople = 1; iPeople <= state.dataHeatBal->TotPeople; ++iPeople) {
   13162           12 :         if (!state.dataHeatBal->People(iPeople).Pierce) {
   13163           12 :             hasPierceSET = false;
   13164           12 :             if (ort->displayThermalResilienceSummaryExplicitly) {
   13165            0 :                 ShowWarningError(state,
   13166            0 :                                  format("Writing Annual Thermal Resilience Summary - SET Degree-Hours reports: Zone Thermal Comfort Pierce Model "
   13167              :                                         "Standard Effective Temperature is required, but no Pierce model is defined in {} object.",
   13168            0 :                                         state.dataHeatBal->People(iPeople).Name));
   13169              :             }
   13170              :         }
   13171              :     }
   13172              : 
   13173           30 :     if (hasPierceSET) {
   13174            0 :         if (unitsStyle_cur == OutputReportTabular::UnitsStyle::InchPound ||
   13175              :             unitsStyle_cur == OutputReportTabular::UnitsStyle::InchPoundExceptElectricity) {
   13176            0 :             columnHeadStr(1) = "SET > 86°F Degree-Hours [°F·hr]";
   13177            0 :             columnHeadStr(2) = "SET > 86°F Occupant-Weighted Degree-Hours [°F·hr]";
   13178            0 :             columnHeadStr(3) = "SET > 86°F Occupied Degree-Hours [°F·hr]";
   13179            0 :             columnHeadStr(4) = "Longest SET > 86°F Duration for Occupied Period [hr]";
   13180            0 :             columnHeadStr(5) = "Start Time of the Longest SET > 86°F Duration for Occupied Period";
   13181              :         } else {
   13182            0 :             columnHeadStr(1) = "SET > 30°C Degree-Hours [°C·hr]";
   13183            0 :             columnHeadStr(2) = "SET > 30°C Occupant-Weighted Degree-Hours [°C·hr]";
   13184            0 :             columnHeadStr(3) = "SET > 30°C Occupied Degree-Hours [°C·hr]";
   13185            0 :             columnHeadStr(4) = "Longest SET > 30°C Duration for Occupied Period [hr]";
   13186            0 :             columnHeadStr(5) = "Start Time of the Longest SET > 30°C Duration for Occupied Period";
   13187              :         }
   13188              : 
   13189            0 :         std::array<Real64, numColumnThermalTbl> DataHeatBalance::ZoneResilience::*ptrLowSETHours = &DataHeatBalance::ZoneResilience::ZoneLowSETHours;
   13190            0 :         std::array<Real64, numColumnThermalTbl> DataHeatBalance::ZoneResilience::*ptrHighSETHours =
   13191              :             &DataHeatBalance::ZoneResilience::ZoneHighSETHours;
   13192            0 :         Array1D_string rowHeadSET;
   13193            0 :         Array2D_string tableBodySET;
   13194            0 :         rowHeadSET.allocate(state.dataGlobal->NumOfZones + 3);
   13195            0 :         tableBodySET.allocate(numColumnThermalTbl, state.dataGlobal->NumOfZones + 3);
   13196            0 :         tableName = "Heating SET Degree-Hours";
   13197            0 :         WriteSETHoursTableNonPreDefUseZoneData(
   13198              :             state, numColumnThermalTbl, tableName, columnHeadStr, columnWidth, ptrLowSETHours, rowHeadSET, tableBodySET, degreeHourConversion);
   13199            0 :         tableName = "Cooling SET Degree-Hours";
   13200            0 :         WriteSETHoursTableNonPreDefUseZoneData(
   13201              :             state, numColumnThermalTbl, tableName, columnHeadStr, columnWidth, ptrHighSETHours, rowHeadSET, tableBodySET, degreeHourConversion);
   13202            0 :     }
   13203              : 
   13204           30 :     std::array<Real64, numColumnThermalTbl> DataHeatBalance::ZoneResilience::*ptrColdHourOfSafetyBins =
   13205              :         &DataHeatBalance::ZoneResilience::ZoneColdHourOfSafetyBins;
   13206           30 :     std::array<Real64, numColumnThermalTbl> DataHeatBalance::ZoneResilience::*ptrHeatHourOfSafetyBins =
   13207              :         &DataHeatBalance::ZoneResilience::ZoneHeatHourOfSafetyBins;
   13208           30 :     tableName = "Hours of Safety for Cold Events";
   13209           30 :     columnHeadStr(1) = "Hours of Safety [hr]";
   13210           30 :     columnHeadStr(2) = "End Time of the Safety Duration";
   13211           30 :     columnHeadStr(3) = "Safe Temperature Exceedance Hours [hr]";
   13212           30 :     columnHeadStr(4) = "Safe Temperature Exceedance OccupantHours [hr]";
   13213           30 :     columnHeadStr(5) = "Safe Temperature Exceedance OccupiedHours [hr]";
   13214           30 :     WriteHourOfSafetyTableNonPreDefUseZoneData(
   13215              :         state, numColumnThermalTbl, tableName, columnHeadStr, columnWidth, ptrColdHourOfSafetyBins, rowHead, tableBody, 2);
   13216           30 :     tableName = "Hours of Safety for Heat Events";
   13217           30 :     WriteHourOfSafetyTableNonPreDefUseZoneData(
   13218              :         state, numColumnThermalTbl, tableName, columnHeadStr, columnWidth, ptrHeatHourOfSafetyBins, rowHead, tableBody, 2);
   13219              : 
   13220           30 :     Array1D_int columnWidthUnmetDegHr;
   13221           30 :     columnWidthUnmetDegHr.allocate(numColumnUnmetDegreeHourTbl);
   13222           30 :     columnWidthUnmetDegHr = 10;
   13223           30 :     Array1D_string columnHeadUnmetDegHr;
   13224           30 :     columnHeadUnmetDegHr.allocate(numColumnUnmetDegreeHourTbl);
   13225           30 :     Array2D_string tableBodyUnmetDegHr;
   13226           30 :     tableBodyUnmetDegHr.allocate(numColumnUnmetDegreeHourTbl, state.dataGlobal->NumOfZones + 4);
   13227           30 :     tableName = "Unmet Degree-Hours";
   13228           30 :     columnHeadUnmetDegHr(1) = "Cooling Setpoint Unmet Degree-Hours [°C·hr]";
   13229           30 :     columnHeadUnmetDegHr(2) = "Cooling Setpoint Unmet Occupant-Weighted Degree-Hours [°C·hr]";
   13230           30 :     columnHeadUnmetDegHr(3) = "Cooling Setpoint Unmet Occupied Degree-Hours [°C·hr]";
   13231           30 :     columnHeadUnmetDegHr(4) = "Heating Setpoint Unmet Degree-Hours [°C·hr]";
   13232           30 :     columnHeadUnmetDegHr(5) = "Heating Setpoint Unmet Occupant-Weighted Degree-Hours [°C·hr]";
   13233           30 :     columnHeadUnmetDegHr(6) = "Heating Setpoint Unmet Occupied Degree-Hours [°C·hr]";
   13234              : 
   13235           30 :     if (unitsStyle_cur == UnitsStyle::InchPound) {
   13236              :         int indexUnitConv;
   13237            1 :         std::string curUnits;
   13238            6 :         for (int i = 1; i < numColumnUnmetDegreeHourTbl; i++) {
   13239            5 :             LookupSItoIP(state, columnHeadUnmetDegHr(i), indexUnitConv, curUnits);
   13240            5 :             columnHeadUnmetDegHr(i) = curUnits;
   13241              :         }
   13242           30 :     } else if (unitsStyle_cur == UnitsStyle::InchPoundExceptElectricity) {
   13243              :         int indexUnitConv;
   13244            0 :         std::string curUnits;
   13245            0 :         for (int i = 1; i < numColumnUnmetDegreeHourTbl; i++) {
   13246            0 :             LookupSItoIP(state, columnHeadUnmetDegHr(i), indexUnitConv, curUnits);
   13247            0 :             columnHeadUnmetDegHr(i) = curUnits;
   13248              :         }
   13249            0 :     }
   13250              : 
   13251           30 :     std::array<Real64, numColumnUnmetDegreeHourTbl> DataHeatBalance::ZoneResilience::*ptrUnmetDegreeHourBins =
   13252              :         &DataHeatBalance::ZoneResilience::ZoneUnmetDegreeHourBins;
   13253           30 :     WriteResilienceBinsTableNonPreDefUseZoneData<numColumnUnmetDegreeHourTbl>(
   13254              :         state, tableName, columnHeadUnmetDegHr, columnWidthUnmetDegHr, ptrUnmetDegreeHourBins, rowHead, tableBodyUnmetDegHr, degreeHourConversion);
   13255              : 
   13256           30 :     columnHeadStr.allocate(numColumnDiscomfortWtExceedHourTbl);
   13257           30 :     columnWidth.allocate(numColumnDiscomfortWtExceedHourTbl);
   13258           30 :     columnWidth = 10;
   13259           30 :     tableBody.allocate(numColumnDiscomfortWtExceedHourTbl, state.dataGlobal->NumOfZones + 4);
   13260           30 :     columnHeadStr(1) = "Very-cold Exceedance OccupantHours [hr]";
   13261           30 :     columnHeadStr(2) = "Cool Exceedance OccupantHours [hr]";
   13262           30 :     columnHeadStr(3) = "Warm Exceedance OccupantHours [hr]";
   13263           30 :     columnHeadStr(4) = "Very-hot Exceedance OccupantHours [hr]";
   13264              : 
   13265           30 :     std::array<Real64, numColumnDiscomfortWtExceedHourTbl> DataHeatBalance::ZoneResilience::*ptrDiscomfortWtExceedOccuHourBins =
   13266              :         &DataHeatBalance::ZoneResilience::ZoneDiscomfortWtExceedOccuHourBins;
   13267           30 :     std::array<Real64, numColumnDiscomfortWtExceedHourTbl> DataHeatBalance::ZoneResilience::*ptrDiscomfortWtExceedOccupiedHourBins =
   13268              :         &DataHeatBalance::ZoneResilience::ZoneDiscomfortWtExceedOccupiedHourBins;
   13269           30 :     tableName = "Discomfort-weighted Exceedance OccupantHours";
   13270           30 :     WriteResilienceBinsTableNonPreDefUseZoneData<numColumnDiscomfortWtExceedHourTbl>(
   13271              :         state, tableName, columnHeadStr, columnWidth, ptrDiscomfortWtExceedOccuHourBins, rowHead, tableBody);
   13272           30 :     tableName = "Discomfort-weighted Exceedance OccupiedHours";
   13273           30 :     WriteResilienceBinsTableNonPreDefUseZoneData<numColumnDiscomfortWtExceedHourTbl>(
   13274              :         state, tableName, columnHeadStr, columnWidth, ptrDiscomfortWtExceedOccupiedHourBins, rowHead, tableBody);
   13275           30 :     rowHead.deallocate();
   13276           30 :     columnHeadStr.deallocate();
   13277           30 :     tableBody.deallocate();
   13278           30 :     tableBodyUnmetDegHr.deallocate();
   13279           30 :     columnWidth.deallocate();
   13280           30 :     columnHeadUnmetDegHr.deallocate();
   13281           30 :     columnWidthUnmetDegHr.deallocate();
   13282           30 : }
   13283              : 
   13284            0 : void WriteCO2ResilienceTables(EnergyPlusData &state)
   13285              : {
   13286              : 
   13287            0 :     if (state.dataGlobal->NumOfZones <= 0) {
   13288            0 :         return;
   13289              :     }
   13290              :     std::array<int, numColumnCO2Tbl> columnHead = {
   13291            0 :         state.dataOutRptPredefined->pdchCO2HourSafe, state.dataOutRptPredefined->pdchCO2HourCaution, state.dataOutRptPredefined->pdchCO2HourHazard};
   13292              : 
   13293            0 :     std::array<Real64, numColumnCO2Tbl> DataHeatBalance::ZoneResilience::*ptrCO2LevelHourBins =
   13294              :         &DataHeatBalance::ZoneResilience::ZoneCO2LevelHourBins;
   13295            0 :     std::array<Real64, numColumnCO2Tbl> DataHeatBalance::ZoneResilience::*ptrCO2LevelOccuHourBins =
   13296              :         &DataHeatBalance::ZoneResilience::ZoneCO2LevelOccuHourBins;
   13297            0 :     std::array<Real64, numColumnCO2Tbl> DataHeatBalance::ZoneResilience::*ptrCO2LevelOccupiedHourBins =
   13298              :         &DataHeatBalance::ZoneResilience::ZoneCO2LevelOccupiedHourBins;
   13299            0 :     WriteResilienceBinsTable<numColumnCO2Tbl>(state, columnHead, ptrCO2LevelHourBins);
   13300              : 
   13301            0 :     columnHead = {state.dataOutRptPredefined->pdchCO2OccuHourSafe,
   13302            0 :                   state.dataOutRptPredefined->pdchCO2OccuHourCaution,
   13303            0 :                   state.dataOutRptPredefined->pdchCO2OccuHourHazard};
   13304            0 :     WriteResilienceBinsTable<numColumnCO2Tbl>(state, columnHead, ptrCO2LevelOccuHourBins);
   13305              : 
   13306            0 :     columnHead = {state.dataOutRptPredefined->pdchCO2OccupiedHourSafe,
   13307            0 :                   state.dataOutRptPredefined->pdchCO2OccupiedHourCaution,
   13308            0 :                   state.dataOutRptPredefined->pdchCO2OccupiedHourHazard};
   13309            0 :     WriteResilienceBinsTable<numColumnCO2Tbl>(state, columnHead, ptrCO2LevelOccupiedHourBins);
   13310              : }
   13311              : 
   13312            0 : void WriteCO2ResilienceTablesRepPeriod(EnergyPlusData &state, const int periodIdx)
   13313              : {
   13314            0 :     auto const &ort = state.dataOutRptTab;
   13315              :     // TODO: this is wrong. This function is called only when ort->WriteTabularFiles is true already. Missing a '!'
   13316            0 :     if (ort->WriteTabularFiles) {
   13317            0 :         return;
   13318              :     }
   13319            0 :     WriteReportHeaderReportingPeriod(state, "CO2", periodIdx, state.dataWeather->CO2ReportPeriodInput);
   13320            0 :     std::string periodTitle = state.dataWeather->CO2ReportPeriodInput(periodIdx).title;
   13321              : 
   13322            0 :     Array1D_int columnWidth;
   13323            0 :     columnWidth.allocate(numColumnCO2Tbl);
   13324            0 :     columnWidth = 10;
   13325            0 :     Array1D_string columnHead(numColumnCO2Tbl);
   13326            0 :     columnHead(1) = "Safe (<= 1000 ppm) [hr]";
   13327            0 :     columnHead(2) = "Caution (> 1000, <= 5000 ppm) [hr]";
   13328            0 :     columnHead(3) = "Hazard (> 5000 ppm) [hr]";
   13329              : 
   13330            0 :     Array1D_string rowHead;
   13331            0 :     Array2D_string tableBody;
   13332            0 :     rowHead.allocate(state.dataGlobal->NumOfZones + 4);
   13333            0 :     tableBody.allocate(numColumnCO2Tbl, state.dataGlobal->NumOfZones + 4);
   13334              : 
   13335            0 :     std::string tableName = "CO2 Level Hours";
   13336            0 :     std::string tableType = "CO2";
   13337            0 :     WriteResilienceBinsTableReportingPeriod(state,
   13338              :                                             tableType,
   13339              :                                             numColumnCO2Tbl,
   13340              :                                             periodIdx,
   13341              :                                             periodTitle,
   13342              :                                             tableName,
   13343              :                                             columnHead,
   13344              :                                             columnWidth,
   13345            0 :                                             state.dataHeatBalFanSys->ZoneCO2LevelHourBinsRepPeriod,
   13346              :                                             rowHead,
   13347              :                                             tableBody);
   13348              : 
   13349            0 :     tableName = "CO2 Level OccupantHours";
   13350            0 :     WriteResilienceBinsTableReportingPeriod(state,
   13351              :                                             tableType,
   13352              :                                             numColumnCO2Tbl,
   13353              :                                             periodIdx,
   13354              :                                             periodTitle,
   13355              :                                             tableName,
   13356              :                                             columnHead,
   13357              :                                             columnWidth,
   13358            0 :                                             state.dataHeatBalFanSys->ZoneCO2LevelOccuHourBinsRepPeriod,
   13359              :                                             rowHead,
   13360              :                                             tableBody);
   13361              : 
   13362            0 :     tableName = "CO2 Level OccupiedHours";
   13363            0 :     WriteResilienceBinsTableReportingPeriod(state,
   13364              :                                             tableType,
   13365              :                                             numColumnCO2Tbl,
   13366              :                                             periodIdx,
   13367              :                                             periodTitle,
   13368              :                                             tableName,
   13369              :                                             columnHead,
   13370              :                                             columnWidth,
   13371            0 :                                             state.dataHeatBalFanSys->ZoneCO2LevelOccupiedHourBinsRepPeriod,
   13372              :                                             rowHead,
   13373              :                                             tableBody);
   13374            0 : }
   13375              : 
   13376            0 : void WriteVisualResilienceTables(EnergyPlusData &state)
   13377              : {
   13378            0 :     for (int ZoneNum = 1; ZoneNum <= state.dataGlobal->NumOfZones; ++ZoneNum) {
   13379            0 :         if (state.dataDayltg->ZoneDaylight(ZoneNum).totRefPts == 0) {
   13380            0 :             if (state.dataOutRptTab->displayVisualResilienceSummaryExplicitly) {
   13381            0 :                 ShowWarningError(state,
   13382            0 :                                  format("Writing Annual Visual Resilience Summary - Lighting Level Hours reports: Zone Average Daylighting Reference "
   13383              :                                         "Point Illuminance output is required, but no Daylighting Controls are defined in Zone:{}",
   13384            0 :                                         state.dataHeatBal->Zone(ZoneNum).Name));
   13385              :             }
   13386              :         }
   13387              :     }
   13388              : 
   13389            0 :     if (state.dataGlobal->NumOfZones <= 0) return;
   13390            0 :     std::array<int, numColumnVisualTbl> columnHead = {state.dataOutRptPredefined->pdchIllumHourDark,
   13391            0 :                                                       state.dataOutRptPredefined->pdchIllumHourDim,
   13392            0 :                                                       state.dataOutRptPredefined->pdchIllumHourAdequate,
   13393            0 :                                                       state.dataOutRptPredefined->pdchIllumHourBright};
   13394              : 
   13395            0 :     std::array<Real64, numColumnVisualTbl> DataHeatBalance::ZoneResilience::*ptrLightingLevelHourBins =
   13396              :         &DataHeatBalance::ZoneResilience::ZoneLightingLevelHourBins;
   13397            0 :     std::array<Real64, numColumnVisualTbl> DataHeatBalance::ZoneResilience::*ptrLightingLevelOccuHourBins =
   13398              :         &DataHeatBalance::ZoneResilience::ZoneLightingLevelOccuHourBins;
   13399            0 :     std::array<Real64, numColumnVisualTbl> DataHeatBalance::ZoneResilience::*ptrLightingLevelOccupiedHourBins =
   13400              :         &DataHeatBalance::ZoneResilience::ZoneLightingLevelOccupiedHourBins;
   13401            0 :     WriteResilienceBinsTable<numColumnVisualTbl>(state, columnHead, ptrLightingLevelHourBins);
   13402              : 
   13403            0 :     columnHead = {state.dataOutRptPredefined->pdchIllumOccuHourDark,
   13404            0 :                   state.dataOutRptPredefined->pdchIllumOccuHourDim,
   13405            0 :                   state.dataOutRptPredefined->pdchIllumOccuHourAdequate,
   13406            0 :                   state.dataOutRptPredefined->pdchIllumOccuHourBright};
   13407            0 :     WriteResilienceBinsTable<numColumnVisualTbl>(state, columnHead, ptrLightingLevelOccuHourBins);
   13408              : 
   13409            0 :     columnHead = {state.dataOutRptPredefined->pdchIllumOccupiedHourDark,
   13410            0 :                   state.dataOutRptPredefined->pdchIllumOccupiedHourDim,
   13411            0 :                   state.dataOutRptPredefined->pdchIllumOccupiedHourAdequate,
   13412            0 :                   state.dataOutRptPredefined->pdchIllumOccupiedHourBright};
   13413            0 :     WriteResilienceBinsTable<numColumnVisualTbl>(state, columnHead, ptrLightingLevelOccupiedHourBins);
   13414              : }
   13415              : 
   13416            0 : void WriteVisualResilienceTablesRepPeriod(EnergyPlusData &state, const int periodIdx)
   13417              : {
   13418            0 :     auto const &ort = state.dataOutRptTab;
   13419            0 :     if (!ort->WriteTabularFiles) {
   13420            0 :         return;
   13421              :     }
   13422              : 
   13423            0 :     WriteReportHeaderReportingPeriod(state, "Visual", periodIdx, state.dataWeather->VisualReportPeriodInput);
   13424            0 :     std::string periodTitle = state.dataWeather->VisualReportPeriodInput(periodIdx).title;
   13425              : 
   13426            0 :     Array1D_int columnWidth;
   13427            0 :     columnWidth.allocate(numColumnVisualTbl);
   13428            0 :     columnWidth = 10;
   13429            0 :     Array1D_string columnHead(numColumnVisualTbl);
   13430            0 :     columnHead(1) = "A Bit Dark (<= 100 lux) [hr]";
   13431            0 :     columnHead(2) = "Dim (> 100, <= 300 lux) [hr]";
   13432            0 :     columnHead(3) = "Adequate (> 300, <= 500 lux) [hr]";
   13433            0 :     columnHead(4) = "Bright (>500 lux) [hr]";
   13434              : 
   13435            0 :     Array1D_string rowHead;
   13436            0 :     Array2D_string tableBody;
   13437            0 :     rowHead.allocate(state.dataGlobal->NumOfZones + 4);
   13438            0 :     tableBody.allocate(numColumnVisualTbl, state.dataGlobal->NumOfZones + 4);
   13439              : 
   13440            0 :     std::string tableName = "Illuminance Level Hours";
   13441            0 :     std::string tableType = "Visual";
   13442            0 :     WriteResilienceBinsTableReportingPeriod(state,
   13443              :                                             tableType,
   13444              :                                             numColumnVisualTbl,
   13445              :                                             periodIdx,
   13446              :                                             periodTitle,
   13447              :                                             tableName,
   13448              :                                             columnHead,
   13449              :                                             columnWidth,
   13450            0 :                                             state.dataHeatBalFanSys->ZoneLightingLevelHourBinsRepPeriod,
   13451              :                                             rowHead,
   13452              :                                             tableBody);
   13453              : 
   13454            0 :     tableName = "Illuminance Level OccupantHours";
   13455            0 :     WriteResilienceBinsTableReportingPeriod(state,
   13456              :                                             tableType,
   13457              :                                             numColumnVisualTbl,
   13458              :                                             periodIdx,
   13459              :                                             periodTitle,
   13460              :                                             tableName,
   13461              :                                             columnHead,
   13462              :                                             columnWidth,
   13463            0 :                                             state.dataHeatBalFanSys->ZoneLightingLevelOccuHourBinsRepPeriod,
   13464              :                                             rowHead,
   13465              :                                             tableBody);
   13466              : 
   13467            0 :     tableName = "Illuminance Level OccupiedHours";
   13468            0 :     WriteResilienceBinsTableReportingPeriod(state,
   13469              :                                             tableType,
   13470              :                                             numColumnVisualTbl,
   13471              :                                             periodIdx,
   13472              :                                             periodTitle,
   13473              :                                             tableName,
   13474              :                                             columnHead,
   13475              :                                             columnWidth,
   13476            0 :                                             state.dataHeatBalFanSys->ZoneLightingLevelOccupiedHourBinsRepPeriod,
   13477              :                                             rowHead,
   13478              :                                             tableBody);
   13479            0 : }
   13480              : 
   13481           41 : void WriteHeatEmissionTable(EnergyPlusData &state)
   13482              : {
   13483              : 
   13484           41 :     Array1D_string columnHead(6);
   13485           41 :     Array1D_int columnWidth;
   13486           41 :     Array1D_string rowHead;
   13487           41 :     Array2D_string tableBody;
   13488           41 :     auto const &ort = state.dataOutRptTab;
   13489              : 
   13490           41 :     if (state.dataOutRptTab->displayHeatEmissionsSummary) {
   13491              : 
   13492           83 :         for (int iUnitSystem = 0; iUnitSystem <= 1; iUnitSystem++) {
   13493           82 :             UnitsStyle unitsStyle_cur = ort->unitsStyle;
   13494           82 :             bool produceTabular = true;
   13495           82 :             bool produceSQLite = false;
   13496           82 :             if (produceDualUnitsFlags(iUnitSystem, ort->unitsStyle, ort->unitsStyle_SQLite, unitsStyle_cur, produceTabular, produceSQLite)) break;
   13497              : 
   13498           42 :             if (produceTabular) {
   13499          164 :                 WriteReportHeaders(state, "Annual Heat Emissions Report", "Entire Facility", OutputProcessor::StoreType::Average);
   13500           82 :                 WriteSubtitle(state, "Annual Heat Emissions Summary");
   13501              :             }
   13502              : 
   13503           42 :             columnWidth.allocate(6);
   13504           42 :             columnWidth = 10;
   13505              : 
   13506           42 :             rowHead.allocate(1);
   13507           42 :             tableBody.allocate(6, 1);
   13508              : 
   13509           42 :             Real64 energyconversion = 1.0;
   13510           42 :             if (unitsStyle_cur == OutputReportTabular::UnitsStyle::InchPound ||
   13511           40 :                 unitsStyle_cur == OutputReportTabular::UnitsStyle::InchPoundExceptElectricity) {
   13512            2 :                 rowHead(1) = "Heat Emissions [kBtu]";
   13513            8 :                 energyconversion = 1.0 / getSpecificUnitDivider(state, "GJ", "kBtu"); // 1054351.84 J to kBtu
   13514           40 :             } else if (unitsStyle_cur == UnitsStyle::JtoGJ) {
   13515            1 :                 rowHead(1) = "Heat Emissions [GJ]";
   13516            1 :                 energyconversion = 1.0;
   13517           39 :             } else if (unitsStyle_cur == UnitsStyle::JtoKWH) {
   13518            1 :                 rowHead(1) = "Heat Emissions [kWh]";
   13519            1 :                 energyconversion = 1.0e3 / 3.6;
   13520           38 :             } else if (unitsStyle_cur == UnitsStyle::JtoMJ) {
   13521            0 :                 rowHead(1) = "Heat Emissions [MJ]";
   13522            0 :                 energyconversion = 1.0e3;
   13523           38 :             } else if (unitsStyle_cur == UnitsStyle::None) {
   13524           38 :                 rowHead(1) = "Heat Emissions [GJ]";
   13525           38 :                 energyconversion = 1.0;
   13526              :             } else {
   13527            0 :                 rowHead(1) = "Heat Emissions [GJ]";
   13528            0 :                 energyconversion = 1.0;
   13529              :             }
   13530              : 
   13531           42 :             columnHead(1) = "Envelope Convection";
   13532           42 :             columnHead(2) = "Zone Exfiltration";
   13533           42 :             columnHead(3) = "Zone Exhaust Air";
   13534           42 :             columnHead(4) = "HVAC Relief Air";
   13535           42 :             columnHead(5) = "HVAC Reject Heat";
   13536           42 :             columnHead(6) = "Total";
   13537              : 
   13538           42 :             tableBody = "";
   13539           42 :             tableBody(1, 1) = RealToStr(state.dataHeatBal->BuildingPreDefRep.emiEnvelopConv * energyconversion, 2);
   13540           42 :             tableBody(2, 1) = RealToStr(state.dataHeatBal->BuildingPreDefRep.emiZoneExfiltration * energyconversion, 2);
   13541           42 :             tableBody(3, 1) = RealToStr(state.dataHeatBal->BuildingPreDefRep.emiZoneExhaust * energyconversion, 2);
   13542           42 :             tableBody(4, 1) = RealToStr(state.dataHeatBal->BuildingPreDefRep.emiHVACRelief * energyconversion, 2);
   13543           42 :             tableBody(5, 1) = RealToStr(state.dataHeatBal->BuildingPreDefRep.emiHVACReject * energyconversion, 2);
   13544           42 :             tableBody(6, 1) = RealToStr(state.dataHeatBal->BuildingPreDefRep.emiTotHeat * energyconversion, 2);
   13545              : 
   13546           42 :             if (produceTabular) {
   13547           41 :                 WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
   13548           41 :                 if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
   13549            0 :                     state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(
   13550              :                         tableBody, rowHead, columnHead, "AnnualHeatEmissionsReport", "Entire Facility", "Annual Heat Emissions Summary");
   13551              :                 }
   13552              :             }
   13553           42 :             if (produceSQLite) {
   13554           41 :                 if (state.dataSQLiteProcedures->sqlite) {
   13555            6 :                     state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
   13556              :                         tableBody, rowHead, columnHead, "AnnualHeatEmissionsReport", "Entire Facility", "Annual Heat Emissions Summary");
   13557              :                 }
   13558              :             }
   13559              :         }
   13560              :     }
   13561           41 : }
   13562              : 
   13563           42 : void WritePredefinedTables(EnergyPlusData &state)
   13564              : {
   13565              :     // SUBROUTINE INFORMATION:
   13566              :     //       AUTHOR         Jason Glazer
   13567              :     //       DATE WRITTEN   August 2006
   13568              :     //       MODIFIED       January 2010, Kyle Benne; Added SQLite output
   13569              :     //                      March 2010, Linda Lawrie; Modify SizingPeriod:DesignDay to convert column/humidity types
   13570              :     //       RE-ENGINEERED  na
   13571              : 
   13572              :     // PURPOSE OF THIS SUBROUTINE:
   13573              :     //   Write out tables that have been predefined with data gathered
   13574              :     //   throughout the program code.
   13575              : 
   13576              :     // METHODOLOGY EMPLOYED:
   13577              :     //   Create arrays for the call to WriteTable and then call it.
   13578              :     //   This is a generic routine to write a report with multiple
   13579              :     //   subtables. The structure of the report are created in
   13580              :     //   OutputReportPredefined which also includes a routine that
   13581              :     //   builds up a tableEntry array which holds the data for the
   13582              :     //   predefined reports.
   13583              : 
   13584              :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
   13585              : 
   13586              :     // all arrays are in the format: (row, column)
   13587           42 :     Array1D_string columnHead;
   13588           42 :     Array1D_int columnWidth;
   13589           42 :     Array1D_string rowHead;
   13590           42 :     Array2D_string tableBody;
   13591           42 :     Array1D_int rowToUnqObjName;
   13592           42 :     Array1D_int colHeadToColTag;
   13593           42 :     Array1D_string uniqueObjectName;
   13594           42 :     Array1D_bool useUniqueObjectName;
   13595           42 :     int colCurrent(0);
   13596           42 :     int rowCurrent(0);
   13597           42 :     Array1D_int colUnitConv;
   13598           42 :     auto const &ort = state.dataOutRptTab;
   13599              : 
   13600           85 :     for (int iUnitSystem = 0; iUnitSystem <= 1; iUnitSystem++) {
   13601           84 :         UnitsStyle unitsStyle_cur = ort->unitsStyle;
   13602           84 :         bool produceTabular = true;
   13603           84 :         bool produceSQLite = false;
   13604           84 :         if (produceDualUnitsFlags(iUnitSystem, ort->unitsStyle, ort->unitsStyle_SQLite, unitsStyle_cur, produceTabular, produceSQLite)) {
   13605           41 :             break;
   13606              :         }
   13607              : 
   13608              :         // loop through the entries and associate them with the subtable and create
   13609              :         // list of unique object names
   13610              :         // Much of this code is to allow for integer compares instead of string
   13611              :         // compares that are nested three levels in a loop.
   13612           43 :         uniqueObjectName.allocate(state.dataOutRptPredefined->numTableEntry);
   13613           43 :         useUniqueObjectName.allocate(state.dataOutRptPredefined->numTableEntry);
   13614           43 :         int numUnqObjName = 0;
   13615        40142 :         for (int lTableEntry = 1; lTableEntry <= state.dataOutRptPredefined->numTableEntry; ++lTableEntry) {
   13616              :             // associate the subtable with each column
   13617        40099 :             int const curColumn = state.dataOutRptPredefined->tableEntry(lTableEntry).indexColumn;
   13618        40099 :             if ((curColumn >= 1) && (curColumn <= state.dataOutRptPredefined->numColumnTag)) {
   13619        40099 :                 state.dataOutRptPredefined->tableEntry(lTableEntry).subTableIndex = state.dataOutRptPredefined->columnTag(curColumn).indexSubTable;
   13620              :             }
   13621              :             // make a list of unique object names
   13622        40099 :             std::string const &curObjectName = state.dataOutRptPredefined->tableEntry(lTableEntry).objectName;
   13623        40099 :             int found = 0;
   13624      3348117 :             for (int mUnqObjNames = 1; mUnqObjNames <= numUnqObjName; ++mUnqObjNames) {
   13625      3342362 :                 if (curObjectName == uniqueObjectName(mUnqObjNames)) {
   13626        34344 :                     found = mUnqObjNames;
   13627        34344 :                     break;
   13628              :                 }
   13629              :             }
   13630              :             // if found then point to the unique object
   13631        40099 :             if (found > 0) {
   13632        34344 :                 state.dataOutRptPredefined->tableEntry(lTableEntry).uniqueObjName = found;
   13633              :                 // if not found add to the unique object list
   13634              :             } else {
   13635         5755 :                 ++numUnqObjName;
   13636         5755 :                 uniqueObjectName(numUnqObjName) = curObjectName;
   13637         5755 :                 state.dataOutRptPredefined->tableEntry(lTableEntry).uniqueObjName = numUnqObjName;
   13638              :             }
   13639              :         }
   13640              :         // loop through all reports and include those that have been flagged as 'show'
   13641          788 :         for (int iReportName = 1; iReportName <= state.dataOutRptPredefined->numReportName; ++iReportName) {
   13642          745 :             if (state.dataOutRptPredefined->reportName(iReportName).show) {
   13643          666 :                 if (produceTabular) {
   13644         1995 :                     WriteReportHeaders(state,
   13645          665 :                                        state.dataOutRptPredefined->reportName(iReportName).namewithspaces,
   13646              :                                        "Entire Facility",
   13647              :                                        OutputProcessor::StoreType::Average);
   13648              :                 }
   13649              :                 // loop through the subtables and include those that are associated with this report
   13650        65970 :                 for (int jSubTable = 1, jSubTable_end = state.dataOutRptPredefined->numSubTable; jSubTable <= jSubTable_end; ++jSubTable) {
   13651        65304 :                     if (state.dataOutRptPredefined->subTable(jSubTable).indexReportName == iReportName) {
   13652              :                         // determine how many columns
   13653         3767 :                         int curNumColumns = 0;
   13654      3281065 :                         for (int kColumnTag = 1; kColumnTag <= state.dataOutRptPredefined->numColumnTag; ++kColumnTag) {
   13655      3277298 :                             if (state.dataOutRptPredefined->columnTag(kColumnTag).indexSubTable == jSubTable) {
   13656        33613 :                                 ++curNumColumns;
   13657              :                             }
   13658              :                         }
   13659              :                         // determine how many rows by going through table entries and setting
   13660              :                         // flag in useUniqueObjectName to true, then count number of true's.
   13661         3767 :                         useUniqueObjectName = false; // array assignment
   13662      3954066 :                         for (int lTableEntry = 1; lTableEntry <= state.dataOutRptPredefined->numTableEntry; ++lTableEntry) {
   13663      3950299 :                             if (state.dataOutRptPredefined->tableEntry(lTableEntry).subTableIndex == jSubTable) {
   13664        40090 :                                 useUniqueObjectName(state.dataOutRptPredefined->tableEntry(lTableEntry).uniqueObjName) = true;
   13665              :                             }
   13666              :                         }
   13667         3767 :                         int curNumRows = 0;
   13668       563580 :                         for (int mUnqObjNames = 1; mUnqObjNames <= numUnqObjName; ++mUnqObjNames) {
   13669       559813 :                             if (useUniqueObjectName(mUnqObjNames)) {
   13670         6817 :                                 ++curNumRows;
   13671              :                             }
   13672              :                         }
   13673         3767 :                         if (curNumRows == 0) curNumRows = 1;
   13674              :                         // now create the arrays that are filled with values
   13675         3767 :                         rowHead.allocate(curNumRows);
   13676         3767 :                         columnHead.allocate(curNumColumns);
   13677         3767 :                         columnWidth.dimension(curNumColumns, 14); // array assignment - same for all columns
   13678         3767 :                         tableBody.allocate(curNumColumns, curNumRows);
   13679         7534 :                         rowHead = "";
   13680         7534 :                         columnHead = "";
   13681         3767 :                         tableBody = "";
   13682              :                         // this array stores the unique object name index for each row
   13683         3767 :                         rowToUnqObjName.allocate(curNumRows);
   13684              :                         // this array stores the columnHead index for each column
   13685         3767 :                         colHeadToColTag.allocate(curNumColumns);
   13686         3767 :                         colUnitConv.allocate(curNumColumns);
   13687              :                         // set row headings
   13688         3767 :                         int countRow = 0;
   13689         3767 :                         rowHead(1) = "None";
   13690       563580 :                         for (int mUnqObjNames = 1; mUnqObjNames <= numUnqObjName; ++mUnqObjNames) {
   13691       559813 :                             if (useUniqueObjectName(mUnqObjNames)) {
   13692         6817 :                                 ++countRow;
   13693         6817 :                                 rowHead(countRow) = uniqueObjectName(mUnqObjNames);
   13694         6817 :                                 rowToUnqObjName(countRow) = mUnqObjNames;
   13695              :                             }
   13696              :                         }
   13697              :                         // set column headings
   13698         3767 :                         int countColumn = 0;
   13699      3281065 :                         for (int kColumnTag = 1; kColumnTag <= state.dataOutRptPredefined->numColumnTag; ++kColumnTag) {
   13700      3277298 :                             if (state.dataOutRptPredefined->columnTag(kColumnTag).indexSubTable == jSubTable) {
   13701        33613 :                                 ++countColumn;
   13702              :                                 // do the unit conversions
   13703        33613 :                                 std::string const &colTagWithSI = state.dataOutRptPredefined->columnTag(kColumnTag).heading;
   13704              :                                 int indexUnitConv;
   13705        33613 :                                 std::string curColTag;
   13706        33613 :                                 if (unitsStyle_cur == UnitsStyle::InchPound) {
   13707         1313 :                                     LookupSItoIP(state, colTagWithSI, indexUnitConv, curColTag);
   13708         1313 :                                     colUnitConv(countColumn) = indexUnitConv;
   13709        32300 :                                 } else if (unitsStyle_cur == UnitsStyle::InchPoundExceptElectricity) {
   13710            0 :                                     LookupSItoIP(state, colTagWithSI, indexUnitConv, curColTag);
   13711            0 :                                     colUnitConv(countColumn) = indexUnitConv;
   13712        32300 :                                 } else if (unitsStyle_cur == UnitsStyle::JtoKWH) {
   13713          105 :                                     LookupJtokWH(state, colTagWithSI, indexUnitConv, curColTag);
   13714          105 :                                     colUnitConv(countColumn) = indexUnitConv;
   13715              :                                 } else {
   13716        32195 :                                     curColTag = colTagWithSI;
   13717        32195 :                                     colUnitConv(countColumn) = 0;
   13718              :                                 }
   13719        33613 :                                 columnHead(countColumn) = curColTag;
   13720        33613 :                                 colHeadToColTag(countColumn) = kColumnTag;
   13721        33613 :                             }
   13722              :                         }
   13723              :                         // fill the body of the table from the entries
   13724              :                         // find the entries associated with the current subtable
   13725      3954066 :                         for (int lTableEntry = 1; lTableEntry <= state.dataOutRptPredefined->numTableEntry; ++lTableEntry) {
   13726      3950299 :                             if (state.dataOutRptPredefined->tableEntry(lTableEntry).subTableIndex == jSubTable) {
   13727              :                                 // determine what column the current entry is in
   13728        40090 :                                 int const curColTagIndex = state.dataOutRptPredefined->tableEntry(lTableEntry).indexColumn;
   13729       344699 :                                 for (int nColHead = 1; nColHead <= curNumColumns; ++nColHead) {
   13730       344699 :                                     if (curColTagIndex == colHeadToColTag(nColHead)) {
   13731        40090 :                                         colCurrent = nColHead;
   13732        40090 :                                         break;
   13733              :                                     }
   13734              :                                 }
   13735              :                                 // determine what row the current entry is in
   13736        40090 :                                 int const curRowUnqObjIndex = state.dataOutRptPredefined->tableEntry(lTableEntry).uniqueObjName;
   13737       233176 :                                 for (int oRowHead = 1; oRowHead <= curNumRows; ++oRowHead) {
   13738       233176 :                                     if (curRowUnqObjIndex == rowToUnqObjName(oRowHead)) {
   13739        40090 :                                         rowCurrent = oRowHead;
   13740        40090 :                                         break;
   13741              :                                     }
   13742              :                                 }
   13743              :                                 // finally assign the entry to the place in the table body
   13744        40090 :                                 if (unitsStyle_cur == OutputReportTabular::UnitsStyle::InchPound ||
   13745        38480 :                                     unitsStyle_cur == OutputReportTabular::UnitsStyle::InchPoundExceptElectricity ||
   13746        38480 :                                     unitsStyle_cur == UnitsStyle::JtoKWH) {
   13747         1611 :                                     int columnUnitConv = colUnitConv(colCurrent);
   13748         1623 :                                     if (Util::SameString(state.dataOutRptPredefined->subTable(jSubTable).name, "SizingPeriod:DesignDay") &&
   13749           12 :                                         (unitsStyle_cur == OutputReportTabular::UnitsStyle::InchPound ||
   13750            0 :                                          unitsStyle_cur == OutputReportTabular::UnitsStyle::InchPoundExceptElectricity)) {
   13751           12 :                                         if (Util::SameString(columnHead(colCurrent), "Humidity Value")) {
   13752            2 :                                             std::string repTableTag;
   13753            2 :                                             LookupSItoIP(state,
   13754            2 :                                                          state.dataOutRptPredefined->tableEntry(lTableEntry + 1).charEntry,
   13755              :                                                          columnUnitConv,
   13756              :                                                          repTableTag);
   13757            2 :                                             state.dataOutRptPredefined->tableEntry(lTableEntry + 1).charEntry = repTableTag;
   13758            2 :                                         }
   13759              :                                     }
   13760         1611 :                                     if (state.dataOutRptPredefined->tableEntry(lTableEntry).origEntryIsReal && (columnUnitConv != 0)) {
   13761              :                                         Real64 const IPvalue =
   13762         1099 :                                             ConvertIP(state, columnUnitConv, state.dataOutRptPredefined->tableEntry(lTableEntry).origRealEntry);
   13763         1099 :                                         tableBody(colCurrent, rowCurrent) =
   13764         2198 :                                             RealToStr(IPvalue, state.dataOutRptPredefined->tableEntry(lTableEntry).significantDigits);
   13765              :                                     } else {
   13766          512 :                                         tableBody(colCurrent, rowCurrent) = state.dataOutRptPredefined->tableEntry(lTableEntry).charEntry;
   13767              :                                     }
   13768         1611 :                                 } else {
   13769        38479 :                                     tableBody(colCurrent, rowCurrent) = state.dataOutRptPredefined->tableEntry(lTableEntry).charEntry;
   13770              :                                 }
   13771              :                             }
   13772              :                         }
   13773              :                         // create the actual output table
   13774         3767 :                         if (produceTabular) {
   13775         3760 :                             WriteSubtitle(state, state.dataOutRptPredefined->subTable(jSubTable).name);
   13776         3760 :                             WriteTable(
   13777         3760 :                                 state, tableBody, rowHead, columnHead, columnWidth, false, state.dataOutRptPredefined->subTable(jSubTable).footnote);
   13778              :                         }
   13779         3767 :                         if (produceSQLite) {
   13780         3760 :                             if (state.dataSQLiteProcedures->sqlite) {
   13781         1041 :                                 state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
   13782              :                                     tableBody,
   13783              :                                     rowHead,
   13784              :                                     columnHead,
   13785          347 :                                     state.dataOutRptPredefined->reportName(iReportName).name,
   13786              :                                     "Entire Facility",
   13787          347 :                                     state.dataOutRptPredefined->subTable(jSubTable).name);
   13788              :                             }
   13789              :                         }
   13790         3767 :                         if (produceTabular) {
   13791         3760 :                             if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
   13792            0 :                                 state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(
   13793              :                                     tableBody,
   13794              :                                     rowHead,
   13795              :                                     columnHead,
   13796            0 :                                     state.dataOutRptPredefined->reportName(iReportName).name,
   13797              :                                     "Entire Facility",
   13798            0 :                                     state.dataOutRptPredefined->subTable(jSubTable).name);
   13799              :                             }
   13800              :                         }
   13801              :                     }
   13802              :                 }
   13803              :             }
   13804              :         }
   13805              :     }
   13806           42 : }
   13807              : 
   13808           38 : void WriteComponentSizing(EnergyPlusData &state)
   13809              : {
   13810              :     // SUBROUTINE INFORMATION:
   13811              :     //       AUTHOR         Jason Glazer
   13812              :     //       DATE WRITTEN   July 2007
   13813              :     //       MODIFIED       January 2010, Kyle Benne
   13814              :     //                      Added SQLite output
   13815              :     //       RE-ENGINEERED  na
   13816              : 
   13817              :     // PURPOSE OF THIS SUBROUTINE:
   13818              :     //   Write out tables based on component sizing data originally
   13819              :     //   found in the EIO report.
   13820              : 
   13821              :     // METHODOLOGY EMPLOYED:
   13822              :     //   Create arrays for the call to WriteTable and then call it.
   13823              :     //   The tables created do not have known headers for rows or
   13824              :     //   columns so those are determined based on what calls have
   13825              :     //   been made to the Sizer routine.  A table
   13826              :     //   is created for each type of component. Columns are created
   13827              :     //   for each description within that table. Rows are created
   13828              :     //   for each named object.
   13829              : 
   13830           38 :     auto const &ort = state.dataOutRptTab;
   13831           38 :     if (!ort->displayComponentSizing) {
   13832            0 :         return;
   13833              :     }
   13834              : 
   13835              :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
   13836              :     // all arrays are in the format: (row, column)
   13837           38 :     Array1D_string columnHead;
   13838           38 :     Array1D_int columnWidth;
   13839           38 :     Array1D_int colUnitConv;
   13840           38 :     Array1D_string rowHead;
   13841           38 :     Array2D_string tableBody;
   13842           38 :     Array1D_string uniqueDesc;
   13843           38 :     Array1D_string uniqueObj;
   13844              :     int numUniqueObj;
   13845           38 :     std::string curDesc;
   13846           38 :     std::string curObj;
   13847              :     int foundEntry;
   13848              :     int foundDesc;
   13849              :     int foundObj;
   13850              :     int iTableEntry;
   13851              :     int jUnique;
   13852              : 
   13853          114 :     WriteReportHeaders(state, "Component Sizing Summary", "Entire Facility", OutputProcessor::StoreType::Average);
   13854              : 
   13855           76 :     for (int iUnitSystem = 0; iUnitSystem <= 1; iUnitSystem++) {
   13856           76 :         UnitsStyle unitsStyle_cur = ort->unitsStyle;
   13857           76 :         bool produceTabular = true;
   13858           76 :         bool produceSQLite = false;
   13859           76 :         if (produceDualUnitsFlags(iUnitSystem, ort->unitsStyle, ort->unitsStyle_SQLite, unitsStyle_cur, produceTabular, produceSQLite)) break;
   13860              : 
   13861              :         // The arrays that look for unique headers are dimensioned in the
   13862              :         // running program since the size of the number of entries is
   13863              :         // not previously known. Use the size of all entries since that
   13864              :         // is the maximum possible.
   13865           38 :         uniqueDesc.allocate(state.dataOutRptPredefined->numCompSizeTableEntry);
   13866           38 :         uniqueObj.allocate(state.dataOutRptPredefined->numCompSizeTableEntry);
   13867              :         // initially clear the written flags for entire array
   13868              :         // The following line is not really necessary and it is possible that the array has
   13869              :         // not been allocated when this is first called.
   13870              :         //  CompSizeTableEntry%written = .FALSE.
   13871              :         // repeat the following loop until everything in array has been
   13872              :         // written into a table
   13873           38 :         int loopLimit = 0;
   13874           72 :         while (loopLimit <= 100) { // put a maximum count since complex loop that could run indefinitely if error
   13875           72 :             foundEntry = 0;
   13876           72 :             ++loopLimit;
   13877          448 :             for (iTableEntry = 1; iTableEntry <= state.dataOutRptPredefined->numCompSizeTableEntry; ++iTableEntry) {
   13878          410 :                 if (!state.dataOutRptPredefined->CompSizeTableEntry(iTableEntry).written) {
   13879           34 :                     foundEntry = iTableEntry;
   13880           34 :                     break;
   13881              :                 }
   13882              :             }
   13883           72 :             if (foundEntry == 0) break; // leave main loop - all items put into tables
   13884              :             // clear active items
   13885         3434 :             for (auto &e : state.dataOutRptPredefined->CompSizeTableEntry)
   13886         3400 :                 e.active = false;
   13887              :             // make an unwritten item that is of the same type active - these will be the
   13888              :             // entries for the particular subtable.
   13889          566 :             for (iTableEntry = 1; iTableEntry <= state.dataOutRptPredefined->numCompSizeTableEntry; ++iTableEntry) {
   13890          532 :                 if (!state.dataOutRptPredefined->CompSizeTableEntry(iTableEntry).written) {
   13891          263 :                     if (Util::SameString(state.dataOutRptPredefined->CompSizeTableEntry(iTableEntry).typeField,
   13892          263 :                                          state.dataOutRptPredefined->CompSizeTableEntry(foundEntry).typeField)) {
   13893          113 :                         state.dataOutRptPredefined->CompSizeTableEntry(iTableEntry).active = true;
   13894              :                     }
   13895              :                 }
   13896              :             }
   13897              :             // identify unique descriptions and objects (columns and rows) in order
   13898              :             // to size the table arrays properly.
   13899              :             // reset the counters for the arrays looking for unique rows and columns
   13900           34 :             int numUniqueDesc = 0;
   13901           34 :             numUniqueObj = 0;
   13902          566 :             for (iTableEntry = 1; iTableEntry <= state.dataOutRptPredefined->numCompSizeTableEntry; ++iTableEntry) {
   13903              :                 // search for descriptions
   13904          532 :                 foundDesc = 0;
   13905          532 :                 if (state.dataOutRptPredefined->CompSizeTableEntry(iTableEntry).active) {
   13906          113 :                     curDesc = state.dataOutRptPredefined->CompSizeTableEntry(iTableEntry).description;
   13907              :                     // look through the list of unique items to see if it matches
   13908          313 :                     for (jUnique = 1; jUnique <= numUniqueDesc; ++jUnique) {
   13909          215 :                         if (Util::SameString(curDesc, uniqueDesc(jUnique))) {
   13910           15 :                             foundDesc = jUnique;
   13911           15 :                             break;
   13912              :                         }
   13913              :                     }
   13914              :                     // if not found add to the list
   13915          113 :                     if (foundDesc == 0) {
   13916           98 :                         ++numUniqueDesc;
   13917           98 :                         uniqueDesc(numUniqueDesc) = curDesc;
   13918              :                     }
   13919              :                     // search for objects
   13920          113 :                     foundObj = 0;
   13921          113 :                     curObj = state.dataOutRptPredefined->CompSizeTableEntry(iTableEntry).nameField;
   13922          130 :                     for (jUnique = 1; jUnique <= numUniqueObj; ++jUnique) {
   13923           90 :                         if (Util::SameString(curObj, uniqueObj(jUnique))) {
   13924           73 :                             foundObj = jUnique;
   13925           73 :                             break;
   13926              :                         }
   13927              :                     }
   13928              :                     // if not found add to the list
   13929          113 :                     if (foundObj == 0) {
   13930           40 :                         ++numUniqueObj;
   13931           40 :                         uniqueObj(numUniqueObj) = curObj;
   13932              :                     }
   13933              :                 }
   13934              :             }
   13935              :             // make sure the table has at least one row and columns
   13936           34 :             if (numUniqueDesc == 0) numUniqueDesc = 1;
   13937           34 :             if (numUniqueObj == 0) numUniqueObj = 1;
   13938              :             // now that the unique row and column headers are known the array
   13939              :             // sizes can be set for the table arrays
   13940           34 :             rowHead.allocate(numUniqueObj);
   13941           34 :             columnHead.allocate(numUniqueDesc);
   13942           34 :             columnWidth.dimension(numUniqueDesc, 14); // array assignment - same for all columns
   13943           34 :             colUnitConv.allocate(numUniqueDesc);
   13944           34 :             tableBody.allocate(numUniqueDesc, numUniqueObj);
   13945              :             // initialize table body to blanks (in case entries are incomplete)
   13946           34 :             tableBody = "";
   13947              :             // transfer the row and column headings first
   13948          132 :             for (jUnique = 1; jUnique <= numUniqueDesc; ++jUnique) {
   13949              :                 // do the unit conversions
   13950           98 :                 state.dataOutRptTab->curColHeadWithSI = uniqueDesc(jUnique);
   13951           98 :                 if (unitsStyle_cur == UnitsStyle::InchPound) {
   13952           20 :                     LookupSItoIP(
   13953           20 :                         state, state.dataOutRptTab->curColHeadWithSI, state.dataOutRptTab->indexUnitConvWCS, state.dataOutRptTab->curColHead);
   13954           20 :                     colUnitConv(jUnique) = state.dataOutRptTab->indexUnitConvWCS;
   13955           78 :                 } else if (unitsStyle_cur == UnitsStyle::InchPoundExceptElectricity) {
   13956            0 :                     LookupSItoIP(
   13957            0 :                         state, state.dataOutRptTab->curColHeadWithSI, state.dataOutRptTab->indexUnitConvWCS, state.dataOutRptTab->curColHead);
   13958            0 :                     colUnitConv(jUnique) = state.dataOutRptTab->indexUnitConvWCS;
   13959              :                 } else {
   13960           78 :                     state.dataOutRptTab->curColHead = state.dataOutRptTab->curColHeadWithSI;
   13961           78 :                     colUnitConv(jUnique) = 0;
   13962              :                 }
   13963           98 :                 columnHead(jUnique) = state.dataOutRptTab->curColHead;
   13964              :             }
   13965           74 :             for (jUnique = 1; jUnique <= numUniqueObj; ++jUnique) {
   13966           40 :                 rowHead(jUnique) = uniqueObj(jUnique);
   13967              :             }
   13968              :             // fill the table
   13969          566 :             for (iTableEntry = 1; iTableEntry <= state.dataOutRptPredefined->numCompSizeTableEntry; ++iTableEntry) {
   13970              :                 // find the row and column for the specific entry
   13971          532 :                 if (state.dataOutRptPredefined->CompSizeTableEntry(iTableEntry).active) {
   13972          113 :                     curDesc = state.dataOutRptPredefined->CompSizeTableEntry(iTableEntry).description;
   13973          113 :                     foundDesc = 0;
   13974          313 :                     for (jUnique = 1; jUnique <= numUniqueDesc; ++jUnique) {
   13975          313 :                         if (Util::SameString(uniqueDesc(jUnique), curDesc)) {
   13976          113 :                             foundDesc = jUnique;
   13977          113 :                             break;
   13978              :                         }
   13979              :                     }
   13980          113 :                     curObj = state.dataOutRptPredefined->CompSizeTableEntry(iTableEntry).nameField;
   13981          113 :                     foundObj = 0;
   13982          130 :                     for (jUnique = 1; jUnique <= numUniqueObj; ++jUnique) {
   13983          130 :                         if (Util::SameString(rowHead(jUnique), curObj)) {
   13984          113 :                             foundObj = jUnique;
   13985          113 :                             break;
   13986              :                         }
   13987              :                     }
   13988          113 :                     if ((foundDesc >= 1) && (foundObj >= 1)) {
   13989          113 :                         state.dataOutRptTab->curValueSIWCS = state.dataOutRptPredefined->CompSizeTableEntry(iTableEntry).valField;
   13990          113 :                         if (unitsStyle_cur == UnitsStyle::InchPound) {
   13991           20 :                             if (colUnitConv(foundDesc) != 0) {
   13992           17 :                                 state.dataOutRptTab->curValueWCS = ConvertIP(state, colUnitConv(foundDesc), state.dataOutRptTab->curValueSIWCS);
   13993              :                             } else {
   13994            3 :                                 state.dataOutRptTab->curValueWCS = state.dataOutRptTab->curValueSIWCS;
   13995              :                             }
   13996           93 :                         } else if (unitsStyle_cur == UnitsStyle::InchPoundExceptElectricity) {
   13997            0 :                             if (colUnitConv(foundDesc) != 0) {
   13998            0 :                                 state.dataOutRptTab->curValueWCS = ConvertIP(state, colUnitConv(foundDesc), state.dataOutRptTab->curValueSIWCS);
   13999              :                             } else {
   14000            0 :                                 state.dataOutRptTab->curValueWCS = state.dataOutRptTab->curValueSIWCS;
   14001              :                             }
   14002              :                         } else {
   14003           93 :                             state.dataOutRptTab->curValueWCS = state.dataOutRptTab->curValueSIWCS;
   14004              :                         }
   14005          113 :                         if (std::abs(state.dataOutRptTab->curValueWCS) >= 1.0) {
   14006           55 :                             tableBody(foundDesc, foundObj) = RealToStr(state.dataOutRptTab->curValueWCS, 2);
   14007              :                         } else {
   14008           58 :                             tableBody(foundDesc, foundObj) = RealToStr(state.dataOutRptTab->curValueWCS, 6);
   14009              :                         }
   14010          113 :                         state.dataOutRptPredefined->CompSizeTableEntry(iTableEntry).written = true;
   14011              :                     }
   14012              :                 }
   14013              :             }
   14014              :             // write the table
   14015           34 :             if (produceTabular) {
   14016           34 :                 WriteSubtitle(state, state.dataOutRptPredefined->CompSizeTableEntry(foundEntry).typeField);
   14017              :             }
   14018              : 
   14019           68 :             if (state.dataOutRptPredefined->CompSizeTableEntry(foundEntry).typeField == "AirTerminal:SingleDuct:VAV:Reheat" ||
   14020           34 :                 state.dataOutRptPredefined->CompSizeTableEntry(foundEntry).typeField == "AirTerminal:SingleDuct:VAV:NoReheat") {
   14021            3 :                 if (produceTabular) {
   14022            3 :                     WriteTable(state,
   14023              :                                tableBody,
   14024              :                                rowHead,
   14025              :                                columnHead,
   14026              :                                columnWidth,
   14027              :                                false,
   14028              :                                "User-Specified values were used. Design Size values were used if no User-Specified values were provided. "
   14029              :                                "Design Size "
   14030              :                                "values may be derived from alternate User-Specified values.");
   14031              :                 }
   14032              :             } else {
   14033           31 :                 if (produceTabular) {
   14034           31 :                     WriteTable(state,
   14035              :                                tableBody,
   14036              :                                rowHead,
   14037              :                                columnHead,
   14038              :                                columnWidth,
   14039              :                                false,
   14040              :                                "User-Specified values were used. Design Size values were used if no User-Specified values were provided.");
   14041              :                 }
   14042              :             }
   14043              : 
   14044           34 :             if (produceSQLite) {
   14045           34 :                 if (state.dataSQLiteProcedures->sqlite) {
   14046           32 :                     state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
   14047              :                         tableBody,
   14048              :                         rowHead,
   14049              :                         columnHead,
   14050              :                         "ComponentSizingSummary",
   14051              :                         "Entire Facility",
   14052           16 :                         state.dataOutRptPredefined->CompSizeTableEntry(foundEntry).typeField);
   14053              :                 }
   14054              :             }
   14055           34 :             if (produceTabular) {
   14056           34 :                 if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
   14057            0 :                     state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(
   14058              :                         tableBody,
   14059              :                         rowHead,
   14060              :                         columnHead,
   14061              :                         "ComponentSizingSummary",
   14062              :                         "Entire Facility",
   14063            0 :                         state.dataOutRptPredefined->CompSizeTableEntry(foundEntry).typeField,
   14064              :                         "User-Specified values were used. Design Size values were used if no User-Specified values were provided.");
   14065              :                 }
   14066              :             }
   14067              :         }
   14068              :     }
   14069           38 : }
   14070              : 
   14071           38 : void WriteSurfaceShadowing(EnergyPlusData &state)
   14072              : {
   14073              :     // SUBROUTINE INFORMATION:
   14074              :     //       AUTHOR         Jason Glazer
   14075              :     //       DATE WRITTEN   July 2007
   14076              :     //       MODIFIED       January 2010, Kyle Benne
   14077              :     //                      Added SQLite output
   14078              :     //       RE-ENGINEERED  June 2014, Stuart Mentzer, Performance tuning
   14079              : 
   14080              :     // PURPOSE OF THIS SUBROUTINE:
   14081              :     //   Write out tables based on which surfaces shade subsurfaces.
   14082              : 
   14083              :     // METHODOLOGY EMPLOYED:
   14084              :     //   Create arrays for the call to WriteTable and then call it.
   14085              :     //   Use <br> tag to put multiple rows into a single cell.
   14086              : 
   14087              :     // Using/Aliasing
   14088              :     using namespace DataShadowingCombinations;
   14089              : 
   14090           38 :     auto const &ort = state.dataOutRptTab;
   14091              : 
   14092              :     // displaySurfaceShadowing = false  for debugging
   14093           38 :     if (!ort->displaySurfaceShadowing) {
   14094            0 :         return;
   14095              :     }
   14096              : 
   14097              :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
   14098              :     // all arrays are in the format: (row, column)
   14099           38 :     Array1D_string columnHead(1);
   14100           38 :     Array1D_int columnWidth(1);
   14101           38 :     Array1D_string rowHead;
   14102           38 :     Array2D_string tableBody;
   14103           38 :     Array1D_int unique;
   14104              : 
   14105           38 :     int numreceivingfields = 0;
   14106          292 :     for (int HTS = 1; HTS <= state.dataSurface->TotSurfaces; ++HTS) {
   14107          254 :         numreceivingfields += state.dataShadowComb->ShadowComb(HTS).NumGenSurf;
   14108          254 :         numreceivingfields += state.dataShadowComb->ShadowComb(HTS).NumSubSurf;
   14109              :     }
   14110              : 
   14111           38 :     state.dataOutRptPredefined->ShadowRelate.allocate(numreceivingfields);
   14112           38 :     state.dataOutRptPredefined->numShadowRelate = 0;
   14113          292 :     for (int HTS = 1; HTS <= state.dataSurface->TotSurfaces; ++HTS) {
   14114          256 :         for (int NGSS = 1; NGSS <= state.dataShadowComb->ShadowComb(HTS).NumGenSurf; ++NGSS) {
   14115            2 :             ++state.dataOutRptPredefined->numShadowRelate;
   14116            2 :             state.dataOutRptPredefined->ShadowRelate(state.dataOutRptPredefined->numShadowRelate).castSurf =
   14117            2 :                 state.dataShadowComb->ShadowComb(HTS).GenSurf(NGSS);
   14118            2 :             state.dataOutRptPredefined->ShadowRelate(state.dataOutRptPredefined->numShadowRelate).recSurf = HTS;
   14119            2 :             state.dataOutRptPredefined->ShadowRelate(state.dataOutRptPredefined->numShadowRelate).recKind = recKindSurface;
   14120              :         }
   14121          258 :         for (int NGSS = 1; NGSS <= state.dataShadowComb->ShadowComb(HTS).NumSubSurf; ++NGSS) {
   14122            4 :             ++state.dataOutRptPredefined->numShadowRelate;
   14123            4 :             state.dataOutRptPredefined->ShadowRelate(state.dataOutRptPredefined->numShadowRelate).castSurf =
   14124            4 :                 state.dataShadowComb->ShadowComb(HTS).SubSurf(NGSS);
   14125            4 :             state.dataOutRptPredefined->ShadowRelate(state.dataOutRptPredefined->numShadowRelate).recSurf = HTS;
   14126            4 :             state.dataOutRptPredefined->ShadowRelate(state.dataOutRptPredefined->numShadowRelate).recKind = recKindSubsurface;
   14127              :         }
   14128              :     }
   14129           38 :     assert(numreceivingfields == state.dataOutRptPredefined->numShadowRelate);
   14130              : 
   14131          114 :     WriteReportHeaders(state, "Surface Shadowing Summary", "Entire Facility", OutputProcessor::StoreType::Average);
   14132           38 :     unique.allocate(state.dataOutRptPredefined->numShadowRelate);
   14133              :     // do entire process twice, once with surfaces receiving, once with subsurfaces receiving
   14134          114 :     for (int iKindRec = recKindSurface; iKindRec <= recKindSubsurface; ++iKindRec) {
   14135              : 
   14136              :         // Build map from receiving surface to container of names
   14137              :         typedef std::map<int, std::pair<int, std::vector<std::string const *>>> ShadowMap;
   14138           76 :         ShadowMap shadow_map;
   14139           88 :         for (int iShadRel = 1; iShadRel <= state.dataOutRptPredefined->numShadowRelate; ++iShadRel) {
   14140           12 :             if (state.dataOutRptPredefined->ShadowRelate(iShadRel).recKind == iKindRec) {
   14141            6 :                 int const curRecSurf = state.dataOutRptPredefined->ShadowRelate(iShadRel).recSurf;
   14142            6 :                 std::string const &name(state.dataSurface->Surface(state.dataOutRptPredefined->ShadowRelate(iShadRel).castSurf).Name);
   14143            6 :                 auto &elem(shadow_map[curRecSurf]);            // Creates the entry if not present (and zero-initializes the int in the pair)
   14144            6 :                 elem.first += static_cast<int>(name.length()); // Accumulate total of name lengths
   14145            6 :                 elem.second.push_back(&name);                  // Add this name
   14146              :             }
   14147              :         }
   14148           76 :         int const numUnique = static_cast<int>(shadow_map.size());
   14149           76 :         if (numUnique == 0) {
   14150           71 :             columnHead(1) = "None";
   14151              :         } else {
   14152            5 :             columnHead(1) = "Possible Shadow Receivers";
   14153              :         }
   14154           76 :         columnWidth = 14; // array assignment - same for all columns
   14155           76 :         rowHead.allocate(numUnique);
   14156           76 :         tableBody.allocate(1, numUnique);
   14157           76 :         int jUnique = 0;
   14158           82 :         for (auto const &elem : shadow_map) {
   14159            6 :             ++jUnique;
   14160            6 :             int const curRecSurf = elem.first;
   14161            6 :             rowHead(jUnique) = state.dataSurface->Surface(curRecSurf).Name;
   14162              : 
   14163            6 :             std::string listOfSurf;
   14164            6 :             listOfSurf.reserve(elem.second.first + (3 * numUnique)); // To avoid string allocations during appends
   14165           12 :             for (auto const *p : elem.second.second) {
   14166            6 :                 listOfSurf += *p;
   14167            6 :                 listOfSurf += " | "; //'<br>' // Separate append to avoid string temporary
   14168              :             }
   14169            6 :             tableBody(1, jUnique) = listOfSurf;
   14170            6 :         }
   14171              : 
   14172              :         // write the table
   14173           76 :         if (iKindRec == recKindSurface) {
   14174           38 :             WriteSubtitle(state, "Surfaces (Walls, Roofs, etc) that may be Shadowed by Other Surfaces");
   14175           38 :             if (state.dataSQLiteProcedures->sqlite) {
   14176            3 :                 state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
   14177              :                     tableBody,
   14178              :                     rowHead,
   14179              :                     columnHead,
   14180              :                     "SurfaceShadowingSummary",
   14181              :                     "Entire Facility",
   14182              :                     "Surfaces (Walls, Roofs, etc) that may be Shadowed by Other Surfaces");
   14183              :             }
   14184           38 :             if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
   14185            0 :                 state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(
   14186              :                     tableBody,
   14187              :                     rowHead,
   14188              :                     columnHead,
   14189              :                     "SurfaceShadowingSummary",
   14190              :                     "Entire Facility",
   14191              :                     "Surfaces (Walls, Roofs, etc) that may be Shadowed by Other Surfaces");
   14192              :             }
   14193           38 :         } else if (iKindRec == recKindSubsurface) {
   14194           38 :             WriteSubtitle(state, "Subsurfaces (Windows and Doors) that may be Shadowed by Surfaces");
   14195           38 :             if (state.dataSQLiteProcedures->sqlite) {
   14196            3 :                 state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
   14197              :                     tableBody,
   14198              :                     rowHead,
   14199              :                     columnHead,
   14200              :                     "SurfaceShadowingSummary",
   14201              :                     "Entire Facility",
   14202              :                     "Subsurfaces (Windows and Doors) that may be Shadowed by Surfaces");
   14203              :             }
   14204           38 :             if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
   14205            0 :                 state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(
   14206              :                     tableBody,
   14207              :                     rowHead,
   14208              :                     columnHead,
   14209              :                     "SurfaceShadowingSummary",
   14210              :                     "Entire Facility",
   14211              :                     "Subsurfaces (Windows and Doors) that may be Shadowed by Surfaces");
   14212              :             }
   14213              :         }
   14214           76 :         WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
   14215           76 :     }
   14216           38 : }
   14217              : 
   14218              : // Parses the contents of the EIO (initializations) file and creates subtables for each type of record in the tabular output files
   14219              : // Glazer - November 2016
   14220           39 : void WriteEioTables(EnergyPlusData &state)
   14221              : {
   14222              : 
   14223           39 :     auto const &ort = state.dataOutRptTab;
   14224              : 
   14225           39 :     if (!ort->displayEioSummary) {
   14226            0 :         return;
   14227              :     }
   14228              : 
   14229           39 :     Array1D_string columnHead;
   14230           39 :     Array1D_int columnWidth;
   14231           39 :     Array1D_string rowHead;
   14232           39 :     Array2D_string tableBody; // in the format: (row, column)
   14233           39 :     Array1D_int colUnitConv;
   14234              : 
   14235              :     // setting up  report header
   14236          117 :     WriteReportHeaders(state, "Initialization Summary", "Entire Facility", OutputProcessor::StoreType::Average);
   14237              : 
   14238           39 :     std::vector<std::string> headerLines; // holds the lines that describe each type of records - each starts with ! symbol
   14239           39 :     std::vector<std::string> bodyLines;   // holds the data records only
   14240         4443 :     for (auto const &line : state.files.eio.getLines()) {
   14241         4404 :         if (line.at(0) == '!') {
   14242         1830 :             headerLines.push_back(line);
   14243              :         } else {
   14244         2574 :             if (line.at(0) == ' ') {
   14245         1774 :                 bodyLines.push_back(line.substr(1)); // remove leading space
   14246              :             } else {
   14247          800 :                 bodyLines.push_back(line);
   14248              :             }
   14249              :         }
   14250           39 :     }
   14251              : 
   14252           79 :     for (int iUnitSystem = 0; iUnitSystem <= 1; iUnitSystem++) {
   14253           78 :         UnitsStyle unitsStyle_cur = ort->unitsStyle;
   14254           78 :         bool produceTabular = true;
   14255           78 :         bool produceSQLite = false;
   14256           78 :         if (produceDualUnitsFlags(iUnitSystem, ort->unitsStyle, ort->unitsStyle_SQLite, unitsStyle_cur, produceTabular, produceSQLite)) break;
   14257              : 
   14258              :         // now go through each header and create a report for each one
   14259         1872 :         for (std::string const &headerLine : headerLines) {
   14260         1832 :             std::vector<std::string> headerFields = splitCommaString(headerLine);
   14261         1832 :             std::string tableNameWithSigns = headerFields.at(0);
   14262              :             std::string tableName =
   14263         1832 :                 tableNameWithSigns.substr(3, tableNameWithSigns.size() - 4); // get rid of the '! <' from the beginning and the '>' from the end
   14264              :             // first count the number of matching lines
   14265         1832 :             int countOfMatchingLines = 0;
   14266       126900 :             for (std::string const &bodyLine : bodyLines) {
   14267       125068 :                 if (bodyLine.size() > tableName.size()) {
   14268       114445 :                     if (bodyLine.substr(0, tableName.size() + 1) ==
   14269       228890 :                         tableName + ",") { // this needs to match the test used to populate the body of table below
   14270         2537 :                         ++countOfMatchingLines;
   14271              :                     }
   14272              :                 }
   14273              :             }
   14274         1832 :             int numRows = countOfMatchingLines;
   14275         1832 :             int numCols = headerFields.size() - 1;
   14276              : 
   14277         1832 :             if (numRows >= 1) {
   14278         1781 :                 rowHead.allocate(numRows);
   14279         1781 :                 columnHead.allocate(numCols);
   14280         1781 :                 columnWidth.allocate(numCols);
   14281         1781 :                 columnWidth = 14; // array assignment - same for all columns
   14282         1781 :                 tableBody.allocate(numCols, numRows);
   14283         1781 :                 tableBody = ""; // make sure everything is blank
   14284         1781 :                 colUnitConv.allocate(numCols);
   14285              :                 // transfer the header row into column headings
   14286        13966 :                 for (int iCol = 1; iCol <= numCols; ++iCol) {
   14287        12185 :                     columnHead(iCol) = headerFields.at(iCol);
   14288              :                     // set the unit conversions
   14289              :                     // colUnitConv(iCol) = unitsFromHeading(state, columnHead(iCol));
   14290              :                     // Jan 2021: use overloaded version for dual units
   14291        12185 :                     colUnitConv(iCol) = unitsFromHeading(state, columnHead(iCol), unitsStyle_cur);
   14292              :                 }
   14293              :                 // look for data lines
   14294         1781 :                 int rowNum = 0;
   14295       123235 :                 for (std::string const &bodyLine : bodyLines) {
   14296       121454 :                     if (bodyLine.size() > tableName.size()) {
   14297       110937 :                         if (bodyLine.substr(0, tableName.size() + 1) ==
   14298       221874 :                             tableName + ",") { // this needs to match the test used in the original counting
   14299         2537 :                             ++rowNum;
   14300         2537 :                             if (rowNum > countOfMatchingLines) break; // should never happen since same test as original could
   14301         2537 :                             std::vector<std::string> dataFields = splitCommaString(bodyLine);
   14302         2537 :                             rowHead(rowNum) = fmt::to_string(rowNum);
   14303        20790 :                             for (int iCol = 1; iCol <= numCols && iCol < int(dataFields.size()); ++iCol) {
   14304        18253 :                                 if (unitsStyle_cur == OutputReportTabular::UnitsStyle::InchPound ||
   14305        17734 :                                     unitsStyle_cur == OutputReportTabular::UnitsStyle::InchPoundExceptElectricity ||
   14306        17734 :                                     unitsStyle_cur == UnitsStyle::JtoKWH) {
   14307          519 :                                     if (isNumber(dataFields[iCol]) && colUnitConv(iCol) > 0) { // if it is a number that has a conversion
   14308          164 :                                         int numDecimalDigits = digitsAferDecimal(dataFields[iCol]);
   14309          164 :                                         Real64 convertedVal = ConvertIP(state, colUnitConv(iCol), StrToReal(dataFields[iCol]));
   14310          164 :                                         tableBody(iCol, rowNum) = RealToStr(convertedVal, numDecimalDigits);
   14311          355 :                                     } else if (iCol == numCols && columnHead(iCol) == "Value" && iCol > 1) { // if it is the last column and the
   14312              :                                                                                                              // header is Value then treat the
   14313              :                                                                                                              // previous column as source of units
   14314              :                                         // int indexUnitConv =
   14315              :                                         //    unitsFromHeading(state, tableBody(iCol - 1, rowNum)); // base units on previous column
   14316              :                                         // Jan 2021: use overloaded version for dual units
   14317              :                                         int indexUnitConv =
   14318           22 :                                             unitsFromHeading(state, tableBody(iCol - 1, rowNum), unitsStyle_cur); // base units on previous column
   14319              : 
   14320           22 :                                         int numDecimalDigits = digitsAferDecimal(dataFields[iCol]);
   14321           22 :                                         Real64 convertedVal = ConvertIP(state, indexUnitConv, StrToReal(dataFields[iCol]));
   14322           22 :                                         tableBody(iCol, rowNum) = RealToStr(convertedVal, numDecimalDigits);
   14323              :                                     } else {
   14324          333 :                                         tableBody(iCol, rowNum) = dataFields[iCol];
   14325              :                                     }
   14326          519 :                                 } else {
   14327        17734 :                                     tableBody(iCol, rowNum) = dataFields[iCol];
   14328              :                                 }
   14329              :                             }
   14330         2537 :                         }
   14331              :                     }
   14332              :                 }
   14333              : 
   14334         1781 :                 if (produceTabular) {
   14335         1779 :                     WriteSubtitle(state, tableName);
   14336         1779 :                     std::string footnote;
   14337         1779 :                     WriteTable(state, tableBody, rowHead, columnHead, columnWidth, false, footnote);
   14338         1779 :                     if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
   14339            0 :                         state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(
   14340              :                             tableBody, rowHead, columnHead, "InitializationSummary", "Entire Facility", tableName);
   14341              :                     }
   14342         1779 :                 }
   14343         1781 :                 if (produceSQLite) {
   14344         1779 :                     if (state.dataSQLiteProcedures->sqlite) {
   14345          162 :                         state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
   14346              :                             tableBody, rowHead, columnHead, "InitializationSummary", "Entire Facility", tableName);
   14347              :                     }
   14348              :                 }
   14349              :             }
   14350         1832 :         }
   14351              :     }
   14352              : 
   14353              :     // as of Oct 2016 only the <Program Control Information:Threads/Parallel Sims> section is written after this point
   14354           39 : }
   14355              : 
   14356              : // changes the heading that contains and SI to IP as well as providing the unit conversion index
   14357              : // Glazer Nov 2016
   14358            9 : int unitsFromHeading(EnergyPlusData &state, std::string &heading)
   14359              : {
   14360            9 :     auto const &ort = state.dataOutRptTab;
   14361              : 
   14362            9 :     std::string curHeading;
   14363            9 :     int unitConv = 0;
   14364            9 :     if (ort->unitsStyle == UnitsStyle::InchPound) {
   14365            9 :         LookupSItoIP(state, heading, unitConv, curHeading);
   14366            0 :     } else if (ort->unitsStyle == UnitsStyle::InchPoundExceptElectricity) {
   14367            0 :         LookupSItoIP(state, heading, unitConv, curHeading);
   14368            0 :     } else if (ort->unitsStyle == UnitsStyle::JtoKWH) {
   14369            0 :         LookupJtokWH(state, heading, unitConv, curHeading);
   14370              :     } else {
   14371            0 :         curHeading = heading;
   14372              :     }
   14373            9 :     heading = curHeading;
   14374            9 :     return (unitConv);
   14375            9 : }
   14376              : 
   14377              : // Jan 2021: Overloaded this function to accommodate dual units output needs
   14378              : // changes the heading that contains and SI to IP as well as providing the unit conversion index
   14379              : // Glazer Nov 2016
   14380        12207 : int unitsFromHeading(EnergyPlusData &state, std::string &heading, UnitsStyle unitsStyle_para)
   14381              : {
   14382        12207 :     std::string curHeading = "";
   14383        12207 :     int unitConv = 0;
   14384        12207 :     if (unitsStyle_para == UnitsStyle::InchPound) {
   14385          399 :         LookupSItoIP(state, heading, unitConv, curHeading);
   14386        11808 :     } else if (unitsStyle_para == UnitsStyle::InchPoundExceptElectricity) {
   14387            0 :         LookupSItoIP(state, heading, unitConv, curHeading);
   14388        11808 :     } else if (unitsStyle_para == UnitsStyle::JtoKWH) {
   14389            0 :         LookupJtokWH(state, heading, unitConv, curHeading);
   14390              :     } else {
   14391        11808 :         curHeading = heading;
   14392              :     }
   14393        12207 :     heading = curHeading;
   14394        12207 :     return (unitConv);
   14395        12207 : }
   14396              : 
   14397              : // function that returns a vector of strings when given a string with comma delimiters
   14398              : // Glazer Nov 2016
   14399         4375 : std::vector<std::string> splitCommaString(std::string const &inputString)
   14400              : {
   14401         4375 :     std::vector<std::string> fields;
   14402         4375 :     std::string field;
   14403         4375 :     std::stringstream inputSS(inputString);
   14404        39432 :     while (std::getline(inputSS, field, ',')) {
   14405        35057 :         fields.push_back(stripped(field));
   14406              :     }
   14407         8750 :     return fields;
   14408         4375 : }
   14409              : 
   14410           74 : void AddTOCLoadComponentTableSummaries(EnergyPlusData &state)
   14411              : {
   14412              :     // SUBROUTINE INFORMATION:
   14413              :     //       AUTHOR         Jason Glazer
   14414              :     //       DATE WRITTEN   March 2012
   14415              :     //       MODIFIED       na
   14416              :     //       RE-ENGINEERED  na
   14417              : 
   14418              :     // PURPOSE OF THIS SUBROUTINE:
   14419              :     //   Add the table of contents entries for the Zone heat transfer
   14420              :     //   summary report.
   14421              : 
   14422              :     // METHODOLOGY EMPLOYED:
   14423              :     //   Call the AddTOCEntry routine for each zone.
   14424              : 
   14425           74 :     auto const &ort = state.dataOutRptTab;
   14426              : 
   14427           74 :     if (state.dataGlobal->CompLoadReportIsReq) {
   14428            4 :         if (ort->displayZoneComponentLoadSummary) {
   14429            4 :             if (state.dataHeatBal->doSpaceHeatBalanceSizing) {
   14430            0 :                 for (int iSpace = 1; iSpace <= state.dataGlobal->NumOfZones; ++iSpace) {
   14431            0 :                     if (!state.dataZoneEquip->ZoneEquipConfig(state.dataHeatBal->space(iSpace).zoneNum).IsControlled) continue;
   14432            0 :                     AddTOCEntry(state, "Space Component Load Summary", state.dataHeatBal->space(iSpace).Name);
   14433              :                 }
   14434              :             }
   14435            9 :             for (int iZone = 1; iZone <= state.dataGlobal->NumOfZones; ++iZone) {
   14436            5 :                 if (!state.dataZoneEquip->ZoneEquipConfig(iZone).IsControlled) continue;
   14437           15 :                 AddTOCEntry(state, "Zone Component Load Summary", state.dataHeatBal->Zone(iZone).Name);
   14438              :             }
   14439              :         }
   14440            4 :         if (ort->displayAirLoopComponentLoadSummary) {
   14441            7 :             for (int AirLoopNum = 1; AirLoopNum <= state.dataHVACGlobal->NumPrimaryAirSys; ++AirLoopNum) {
   14442            9 :                 AddTOCEntry(state, "AirLoop Component Load Summary", state.dataSize->FinalSysSizing(AirLoopNum).AirPriLoopName);
   14443              :             }
   14444              :         }
   14445            4 :         if (ort->displayFacilityComponentLoadSummary) {
   14446           16 :             AddTOCEntry(state, "Facility Component Load Summary", "Facility");
   14447              :         }
   14448              :     }
   14449           74 : }
   14450              : 
   14451        19265 : void AllocateLoadComponentArrays(EnergyPlusData &state)
   14452              : {
   14453              :     // SUBROUTINE INFORMATION:
   14454              :     //       AUTHOR         Jason Glazer
   14455              :     //       DATE WRITTEN   April 2012
   14456              : 
   14457              :     // PURPOSE OF THIS SUBROUTINE:
   14458              :     //   Allocate the arrays related to the load component report
   14459              : 
   14460        19265 :     auto const &ort = state.dataOutRptTab;
   14461              : 
   14462        19265 :     if (!ort->AllocateLoadComponentArraysDoAllocate) {
   14463        19254 :         return;
   14464              :     }
   14465              : 
   14466           11 :     Real64 timeStepsInDay = state.dataGlobal->TimeStepsInHour * Constant::rHoursInDay;
   14467              : 
   14468              :     // For many of the following arrays the last dimension is the number of environments and is same as sizing arrays
   14469           11 :     ort->radiantPulseTimestep.allocate({0, state.dataEnvrn->TotDesDays + state.dataEnvrn->TotRunDesPersDays}, state.dataGlobal->NumOfZones);
   14470           11 :     ort->radiantPulseTimestep = 0;
   14471           11 :     ort->radiantPulseReceived.allocate({0, state.dataEnvrn->TotDesDays + state.dataEnvrn->TotRunDesPersDays}, state.dataSurface->TotSurfaces);
   14472           11 :     ort->radiantPulseReceived = 0.0;
   14473           11 :     ort->decayCurveCool.allocate(timeStepsInDay, state.dataSurface->TotSurfaces);
   14474           11 :     ort->decayCurveCool = 0.0;
   14475           11 :     ort->decayCurveHeat.allocate(timeStepsInDay, state.dataSurface->TotSurfaces);
   14476           11 :     ort->decayCurveHeat = 0.0;
   14477              : 
   14478           11 :     Real64 const numTSinDay = state.dataGlobal->TimeStepsInHour * Constant::rHoursInDay;
   14479              : 
   14480           11 :     ort->surfCompLoads.resize(state.dataEnvrn->TotDesDays + state.dataEnvrn->TotRunDesPersDays);
   14481           41 :     for (auto &day : ort->surfCompLoads) {
   14482           30 :         day.ts.resize(numTSinDay);
   14483         2910 :         for (auto &ts : day.ts) {
   14484         2880 :             ts.surf.resize(state.dataSurface->TotSurfaces);
   14485              :         }
   14486              :     }
   14487              : 
   14488           11 :     ort->enclCompLoads.resize(state.dataEnvrn->TotDesDays + state.dataEnvrn->TotRunDesPersDays);
   14489           41 :     for (auto &day : ort->enclCompLoads) {
   14490           30 :         day.ts.resize(numTSinDay);
   14491         2910 :         for (auto &ts : day.ts) {
   14492         2880 :             ts.encl.resize(state.dataViewFactor->NumOfRadiantEnclosures);
   14493              :         }
   14494              :     }
   14495              : 
   14496           11 :     ort->znCompLoads.resize(state.dataEnvrn->TotDesDays + state.dataEnvrn->TotRunDesPersDays);
   14497           41 :     for (auto &day : ort->znCompLoads) {
   14498           30 :         day.ts.resize(numTSinDay);
   14499         2910 :         for (auto &ts : day.ts) {
   14500         2880 :             ts.spacezone.resize(state.dataGlobal->NumOfZones);
   14501              :         }
   14502              :     }
   14503           11 :     if (state.dataHeatBal->doSpaceHeatBalanceSizing) {
   14504            0 :         ort->spCompLoads.resize(state.dataEnvrn->TotDesDays + state.dataEnvrn->TotRunDesPersDays);
   14505            0 :         for (auto &day : ort->spCompLoads) {
   14506            0 :             day.ts.resize(numTSinDay);
   14507            0 :             for (auto &ts : day.ts) {
   14508            0 :                 ts.spacezone.resize(state.dataGlobal->numSpaces);
   14509              :             }
   14510              :         }
   14511              :     }
   14512              : 
   14513           11 :     ort->AllocateLoadComponentArraysDoAllocate = false;
   14514              : }
   14515              : 
   14516            6 : void DeallocateLoadComponentArrays(EnergyPlusData const &state)
   14517              : {
   14518              :     // SUBROUTINE INFORMATION:
   14519              :     //       AUTHOR         Jason Glazer
   14520              :     //       DATE WRITTEN   August 2012
   14521              : 
   14522              :     // PURPOSE OF THIS SUBROUTINE:
   14523              :     //   Deallocate the arrays related to the load component report that will not
   14524              :     //   be needed in the reporting.
   14525              : 
   14526            6 :     auto const &ort = state.dataOutRptTab;
   14527            6 :     ort->radiantPulseTimestep.deallocate();
   14528            6 :     ort->radiantPulseReceived.deallocate();
   14529            6 : }
   14530              : 
   14531            6 : void ComputeLoadComponentDecayCurve(EnergyPlusData &state)
   14532              : {
   14533              : 
   14534              :     // SUBROUTINE INFORMATION:
   14535              :     //       AUTHOR         Jason Glazer
   14536              :     //       DATE WRITTEN   August 2012
   14537              : 
   14538              :     // PURPOSE OF THIS SUBROUTINE:
   14539              :     // Determines the load component decay curve based on normal and pulse results from zone sizing.
   14540              : 
   14541              :     // METHODOLOGY EMPLOYED:
   14542              :     // Decay curve is the fraction of the heat convected from a surface over the initial radiant heat
   14543              :     // absorbed by the surface.
   14544              : 
   14545              :     Real64 diff;
   14546            6 :     auto const &ort = state.dataOutRptTab;
   14547              : 
   14548           65 :     for (int surfNum = 1; surfNum <= state.dataSurface->TotSurfaces; ++surfNum) {
   14549           59 :         int const zoneNum = state.dataSurface->Surface(surfNum).Zone;
   14550           59 :         if (zoneNum == 0) continue;
   14551           59 :         if (!state.dataZoneEquip->ZoneEquipConfig(zoneNum).IsControlled) continue;
   14552           57 :         int const spaceNum = state.dataSurface->Surface(surfNum).spaceNum;
   14553           57 :         int coolDesSelected = state.dataSize->CalcFinalZoneSizing(zoneNum).CoolDDNum;
   14554              :         // loop over timesteps after pulse occurred
   14555           57 :         if (coolDesSelected != 0) {
   14556           57 :             auto &surfCLClDay = ort->surfCompLoads[coolDesSelected - 1];
   14557           57 :             int timeOfPulse = ort->radiantPulseTimestep(coolDesSelected, zoneNum);
   14558              :             // if the CoolDesSelected time is on a different day than
   14559              :             // when the pulse occurred, need to scan back and find when
   14560              :             // the pulse occurred.
   14561           57 :             if (timeOfPulse == 0) {
   14562            0 :                 for (int i = coolDesSelected; i >= 1; --i) {
   14563            0 :                     timeOfPulse = ort->radiantPulseTimestep(i, zoneNum);
   14564            0 :                     if (timeOfPulse != 0) break;
   14565              :                 }
   14566              :             }
   14567           57 :             if (timeOfPulse == 0) timeOfPulse = 1;
   14568         3162 :             for (int timeStep = timeOfPulse; timeStep <= state.dataGlobal->TimeStepsInHour * Constant::rHoursInDay; ++timeStep) {
   14569         3105 :                 if (ort->radiantPulseReceived(coolDesSelected, surfNum) != 0.0) {
   14570         3105 :                     auto &surfClDayTS = surfCLClDay.ts[timeStep - 1].surf[surfNum - 1];
   14571         3105 :                     diff = surfClDayTS.loadConvectedWithPulse - surfClDayTS.loadConvectedNormal;
   14572         3105 :                     ort->decayCurveCool(timeStep - timeOfPulse + 1, surfNum) = -diff / ort->radiantPulseReceived(coolDesSelected, surfNum);
   14573              :                 } else {
   14574            0 :                     ort->decayCurveCool(timeStep - timeOfPulse + 1, surfNum) = 0.0;
   14575              :                 }
   14576              :             }
   14577              :         }
   14578           57 :         int const heatDesSelected = state.dataSize->CalcFinalZoneSizing(zoneNum).HeatDDNum;
   14579           57 :         if (heatDesSelected != 0) {
   14580           57 :             auto &surfCLHtDay = ort->surfCompLoads[heatDesSelected - 1];
   14581           57 :             int timeOfPulse = ort->radiantPulseTimestep(heatDesSelected, zoneNum);
   14582              :             // scan back to the day that the heating pulse occurs, if necessary
   14583           57 :             if (timeOfPulse == 0) {
   14584            0 :                 for (int i = heatDesSelected; i >= 1; --i) {
   14585            0 :                     timeOfPulse = ort->radiantPulseTimestep(i, zoneNum);
   14586            0 :                     if (timeOfPulse != 0) break;
   14587              :                 }
   14588              :             }
   14589           57 :             if (timeOfPulse == 0) timeOfPulse = 1;
   14590         3162 :             for (int timeStep = timeOfPulse; timeStep <= state.dataGlobal->TimeStepsInHour * Constant::rHoursInDay; ++timeStep) {
   14591         3105 :                 if (ort->radiantPulseReceived(heatDesSelected, surfNum) != 0.0) {
   14592         3105 :                     auto &surfHtDayTS = surfCLHtDay.ts[timeStep - 1].surf[surfNum - 1];
   14593         3105 :                     diff = surfHtDayTS.loadConvectedWithPulse - surfHtDayTS.loadConvectedNormal;
   14594         3105 :                     ort->decayCurveHeat(timeStep - timeOfPulse + 1, surfNum) = -diff / ort->radiantPulseReceived(heatDesSelected, surfNum);
   14595              :                 } else {
   14596            0 :                     ort->decayCurveHeat(timeStep - timeOfPulse + 1, surfNum) = 0.0;
   14597              :                 }
   14598              :             }
   14599              :         }
   14600              :     }
   14601              : 
   14602            6 :     if (state.dataGlobal->ShowDecayCurvesInEIO) {
   14603              :         // show the line definition for the decay curves
   14604            0 :         print(state.files.eio,
   14605              :               "! <Radiant to Convective Decay Curves for Cooling>,Zone Name, Surface Name, Time "
   14606              :               "1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36\n");
   14607            0 :         print(state.files.eio,
   14608              :               "! <Radiant to Convective Decay Curves for Heating>,Zone Name, Surface Name, Time "
   14609              :               "1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36\n");
   14610              :         // Put the decay curve into the EIO file
   14611            0 :         for (int iZone = 1; iZone <= state.dataGlobal->NumOfZones; ++iZone) {
   14612            0 :             auto &thisZone = state.dataHeatBal->Zone(iZone);
   14613            0 :             for (int kSurf : state.dataSurface->AllSurfaceListReportOrder) {
   14614            0 :                 if (state.dataSurface->Surface(kSurf).Zone != iZone) continue;
   14615            0 :                 print(state.files.eio,
   14616              :                       "{},{},{}",
   14617              :                       "Radiant to Convective Decay Curves for Cooling",
   14618            0 :                       thisZone.Name,
   14619            0 :                       state.dataSurface->Surface(kSurf).Name);
   14620            0 :                 for (int jTime = 1; jTime <= min(int(state.dataGlobal->TimeStepsInHour * Constant::iHoursInDay), 36); ++jTime) {
   14621            0 :                     print(state.files.eio, ",{:6.3F}", ort->decayCurveCool(jTime, kSurf));
   14622              :                 }
   14623              :                 // put a line feed at the end of the line
   14624            0 :                 print(state.files.eio, "\n");
   14625              :             }
   14626              : 
   14627            0 :             for (int kSurf : state.dataSurface->AllSurfaceListReportOrder) {
   14628            0 :                 if (state.dataSurface->Surface(kSurf).Zone != iZone) continue;
   14629            0 :                 print(state.files.eio,
   14630              :                       "{},{},{}",
   14631              :                       "Radiant to Convective Decay Curves for Heating",
   14632            0 :                       thisZone.Name,
   14633            0 :                       state.dataSurface->Surface(kSurf).Name);
   14634            0 :                 for (int jTime = 1; jTime <= min(int(state.dataGlobal->TimeStepsInHour * Constant::iHoursInDay), 36); ++jTime) {
   14635            0 :                     print(state.files.eio, ",{:6.3F}", ort->decayCurveHeat(jTime, kSurf));
   14636              :                 }
   14637              :                 // put a line feed at the end of the line
   14638            0 :                 print(state.files.eio, "\n");
   14639              :             }
   14640              :         }
   14641              :     }
   14642            6 : }
   14643              : 
   14644        83022 : void GatherComponentLoadsSurface(EnergyPlusData &state)
   14645              : {
   14646              :     // SUBROUTINE INFORMATION:
   14647              :     //       AUTHOR         Jason Glazer
   14648              :     //       DATE WRITTEN   September 2012
   14649              : 
   14650              :     // PURPOSE OF THIS SUBROUTINE:
   14651              :     //   Gather values during sizing used for loads component report.
   14652              : 
   14653              :     // METHODOLOGY EMPLOYED:
   14654              :     //   Save sequence of values for report during sizing.
   14655              : 
   14656              :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
   14657        83022 :     auto const &ort = state.dataOutRptTab;
   14658              : 
   14659        83022 :     if (state.dataGlobal->CompLoadReportIsReq && !state.dataGlobal->isPulseZoneSizing) {
   14660         7452 :         int timeStepInDayGCLS = (state.dataGlobal->HourOfDay - 1) * state.dataGlobal->TimeStepsInHour + state.dataGlobal->TimeStep;
   14661         7452 :         auto &znCLDayTS = ort->znCompLoads[state.dataSize->CurOverallSimDay - 1].ts[timeStepInDayGCLS - 1];
   14662        21654 :         for (auto &zone : znCLDayTS.spacezone) {
   14663        14202 :             zone.feneCondInstantSeq = 0.0;
   14664              :         }
   14665         7452 :         if (state.dataHeatBal->doSpaceHeatBalanceSizing) {
   14666            0 :             auto &spCLDayTS = ort->spCompLoads[state.dataSize->CurOverallSimDay - 1].ts[timeStepInDayGCLS - 1];
   14667            0 :             for (auto &space : spCLDayTS.spacezone) {
   14668            0 :                 space.feneCondInstantSeq = 0.0;
   14669              :             }
   14670              :         }
   14671        82566 :         for (int iSurfGCLS = 1; iSurfGCLS <= state.dataSurface->TotSurfaces; ++iSurfGCLS) {
   14672        75114 :             int zoneNumGCLS = state.dataSurface->Surface(iSurfGCLS).Zone;
   14673        75114 :             if (zoneNumGCLS == 0) continue;
   14674        75114 :             if (state.dataSurface->Surface(iSurfGCLS).Class != DataSurfaces::SurfaceClass::Window) continue;
   14675              :             // IF (.not. ZoneEquipConfig(ZoneNum)%IsControlled) CYCLE
   14676         3402 :             Real64 surfCond = state.dataSurface->SurfWinGainConvGlazToZoneRep(iSurfGCLS) + state.dataSurface->SurfWinConvHeatFlowNatural(iSurfGCLS) +
   14677         3402 :                               state.dataSurface->SurfWinGainConvShadeToZoneRep(iSurfGCLS) +
   14678         3402 :                               state.dataSurface->SurfWinGainFrameDividerToZoneRep(iSurfGCLS);
   14679         3402 :             znCLDayTS.spacezone[zoneNumGCLS - 1].feneCondInstantSeq += surfCond;
   14680              : 
   14681         3402 :             if (state.dataHeatBal->doSpaceHeatBalanceSizing) {
   14682            0 :                 int spaceNum = state.dataSurface->Surface(iSurfGCLS).spaceNum;
   14683            0 :                 ort->spCompLoads[state.dataSize->CurOverallSimDay - 1].ts[timeStepInDayGCLS - 1].spacezone[spaceNum - 1].feneCondInstantSeq +=
   14684              :                     surfCond;
   14685              :             }
   14686              : 
   14687              :             // for now assume zero instant solar - may change related
   14688              :             // to how blinds and shades absorb solar radiation and
   14689              :             // convect that heat that timestep.
   14690              :             // feneSolarInstantSeq(ZoneNum,TimeStepInDay,CurOverallSimDay) = 0
   14691              :         }
   14692              : 
   14693        21654 :         for (int izone = 1; izone <= state.dataGlobal->NumOfZones; ++izone) {
   14694        14202 :             Real64 tubularGain = 0.0;
   14695        14202 :             tubularGain = InternalHeatGains::SumInternalConvectionGainsByTypes(state, izone, OutputReportTabular::IntGainTypesTubularGCLS);
   14696        14202 :             znCLDayTS.spacezone[izone - 1].feneCondInstantSeq += tubularGain;
   14697              :         }
   14698         7452 :         if (state.dataHeatBal->doSpaceHeatBalanceSizing) {
   14699            0 :             auto &spCLDayTS = ort->spCompLoads[state.dataSize->CurOverallSimDay - 1].ts[timeStepInDayGCLS - 1];
   14700            0 :             for (int ispace = 1; ispace <= state.dataGlobal->NumOfZones; ++ispace) {
   14701            0 :                 Real64 tubularGain = 0.0;
   14702            0 :                 int zone = state.dataHeatBal->space(ispace).zoneNum;
   14703            0 :                 tubularGain = InternalHeatGains::SumInternalConvectionGainsByTypes(state, zone, OutputReportTabular::IntGainTypesTubularGCLS, ispace);
   14704            0 :                 spCLDayTS.spacezone[ispace - 1].feneCondInstantSeq += tubularGain;
   14705              :             }
   14706              :         }
   14707              :     }
   14708        83022 : }
   14709              : 
   14710         4560 : void GatherComponentLoadsHVAC(EnergyPlusData &state)
   14711              : {
   14712              :     // SUBROUTINE INFORMATION:
   14713              :     //       AUTHOR         Jason Glazer
   14714              :     //       DATE WRITTEN   September 2012
   14715              : 
   14716              :     // PURPOSE OF THIS SUBROUTINE:
   14717              :     //   Gather values during sizing used for loads component report.
   14718              : 
   14719              :     // METHODOLOGY EMPLOYED:
   14720              :     //   Save sequence of values for report during sizing.
   14721              : 
   14722         4560 :     if (!(state.dataGlobal->CompLoadReportIsReq && !state.dataGlobal->isPulseZoneSizing)) {
   14723         3528 :         return;
   14724              :     }
   14725         1032 :     int timeStepInDayGCLH = (state.dataGlobal->HourOfDay - 1) * state.dataGlobal->TimeStepsInHour + state.dataGlobal->TimeStep;
   14726         1032 :     auto &znCompLoadDayTS = state.dataOutRptTab->znCompLoads[state.dataSize->CurOverallSimDay - 1].ts[timeStepInDayGCLH - 1];
   14727         3072 :     for (int iZoneGCLH = 1; iZoneGCLH <= state.dataGlobal->NumOfZones; ++iZoneGCLH) {
   14728         2040 :         auto &znCompLoadDayTSZone = znCompLoadDayTS.spacezone[iZoneGCLH - 1];
   14729         2040 :         auto &zoneAirRpt = state.dataHeatBal->ZnAirRpt(iZoneGCLH);
   14730         2040 :         gatherSpaceZoneCompLoadsHVAC(znCompLoadDayTSZone, zoneAirRpt, state.dataHVACGlobal->TimeStepSysSec);
   14731         2040 :         if (state.afn->simulation_control.type != AirflowNetwork::ControlType::NoMultizoneOrDistribution) {
   14732            0 :             znCompLoadDayTSZone.infilInstantSeq += (state.afn->AirflowNetworkReportData(iZoneGCLH).MultiZoneInfiSenGainW -
   14733            0 :                                                     state.afn->AirflowNetworkReportData(iZoneGCLH).MultiZoneInfiSenLossW); // air flow network
   14734            0 :             znCompLoadDayTSZone.infilLatentSeq += (state.afn->AirflowNetworkReportData(iZoneGCLH).MultiZoneInfiLatGainW -
   14735            0 :                                                    state.afn->AirflowNetworkReportData(iZoneGCLH).MultiZoneInfiLatLossW); // air flow network
   14736            0 :             znCompLoadDayTSZone.zoneVentInstantSeq += (state.afn->AirflowNetworkReportData(iZoneGCLH).MultiZoneVentSenGainW -
   14737            0 :                                                        state.afn->AirflowNetworkReportData(iZoneGCLH).MultiZoneVentSenLossW); // air flow network
   14738            0 :             znCompLoadDayTSZone.zoneVentInstantSeq += (state.afn->AirflowNetworkReportData(iZoneGCLH).MultiZoneVentLatGainW -
   14739            0 :                                                        state.afn->AirflowNetworkReportData(iZoneGCLH).MultiZoneVentLatLossW); // air flow network
   14740            0 :             znCompLoadDayTSZone.interZoneMixInstantSeq += (state.afn->AirflowNetworkReportData(iZoneGCLH).MultiZoneMixSenGainW -
   14741            0 :                                                            state.afn->AirflowNetworkReportData(iZoneGCLH).MultiZoneMixSenLossW); // air flow network
   14742            0 :             znCompLoadDayTSZone.interZoneMixLatentSeq += (state.afn->AirflowNetworkReportData(iZoneGCLH).MultiZoneMixLatGainW -
   14743            0 :                                                           state.afn->AirflowNetworkReportData(iZoneGCLH).MultiZoneMixLatLossW); // air flow network
   14744              :         }
   14745              :     }
   14746         1032 :     if (state.dataHeatBal->doSpaceHeatBalanceSizing) {
   14747            0 :         auto &spCompLoadDayTS = state.dataOutRptTab->spCompLoads[state.dataSize->CurOverallSimDay - 1].ts[timeStepInDayGCLH - 1];
   14748            0 :         for (int iSpace = 1; iSpace <= state.dataGlobal->numSpaces; ++iSpace) {
   14749            0 :             auto &spCompLoadDayTSSpace = spCompLoadDayTS.spacezone[iSpace - 1];
   14750            0 :             auto &spaceAirRpt = state.dataHeatBal->spaceAirRpt(iSpace);
   14751            0 :             gatherSpaceZoneCompLoadsHVAC(spCompLoadDayTSSpace, spaceAirRpt, state.dataHVACGlobal->TimeStepSysSec);
   14752            0 :             if (state.afn->simulation_control.type != AirflowNetwork::ControlType::NoMultizoneOrDistribution) {
   14753            0 :                 auto &space = state.dataHeatBal->space(iSpace);
   14754            0 :                 auto const &znCompLoadDayTSZone = znCompLoadDayTS.spacezone[space.zoneNum - 1];
   14755            0 :                 spCompLoadDayTSSpace.infilInstantSeq = space.fracZoneVolume * znCompLoadDayTSZone.infilInstantSeq;
   14756            0 :                 spCompLoadDayTSSpace.infilLatentSeq = space.fracZoneVolume * znCompLoadDayTSZone.infilLatentSeq;
   14757            0 :                 spCompLoadDayTSSpace.zoneVentInstantSeq = space.fracZoneVolume * znCompLoadDayTSZone.zoneVentInstantSeq;
   14758            0 :                 spCompLoadDayTSSpace.zoneVentInstantSeq = space.fracZoneVolume * znCompLoadDayTSZone.zoneVentInstantSeq;
   14759            0 :                 spCompLoadDayTSSpace.interZoneMixInstantSeq = space.fracZoneVolume * znCompLoadDayTSZone.interZoneMixInstantSeq;
   14760            0 :                 spCompLoadDayTSSpace.interZoneMixLatentSeq = space.fracZoneVolume * znCompLoadDayTSZone.interZoneMixLatentSeq;
   14761              :             }
   14762              :         }
   14763              :     }
   14764              : }
   14765              : 
   14766         2040 : void gatherSpaceZoneCompLoadsHVAC(OutputReportTabular::compLoadsSpaceZone &szCompLoadDayTS,
   14767              :                                   DataHeatBalance::AirReportVars const &szAirRpt,
   14768              :                                   Real64 const timeStepSysSec)
   14769              : {
   14770         2040 :     szCompLoadDayTS.infilInstantSeq = ((szAirRpt.InfilHeatGain - szAirRpt.InfilHeatLoss) / timeStepSysSec);         // zone infiltration
   14771         2040 :     szCompLoadDayTS.infilLatentSeq = ((szAirRpt.InfilLatentGain - szAirRpt.InfilLatentLoss) / timeStepSysSec);      // zone infiltration
   14772         2040 :     szCompLoadDayTS.zoneVentInstantSeq = ((szAirRpt.VentilHeatGain - szAirRpt.VentilHeatLoss) / timeStepSysSec);    // zone ventilation
   14773         2040 :     szCompLoadDayTS.zoneVentLatentSeq = ((szAirRpt.VentilLatentGain - szAirRpt.VentilLatentLoss) / timeStepSysSec); // zone ventilation
   14774         2040 :     szCompLoadDayTS.interZoneMixInstantSeq = ((szAirRpt.MixHeatGain - szAirRpt.MixHeatLoss) / timeStepSysSec);      // zone mixing
   14775         2040 :     szCompLoadDayTS.interZoneMixLatentSeq = ((szAirRpt.MixLatentGain - szAirRpt.MixLatentLoss) / timeStepSysSec);   // zone mixing
   14776         2040 : }
   14777              : 
   14778           40 : void WriteLoadComponentSummaryTables(EnergyPlusData &state)
   14779              : {
   14780              :     // SUBROUTINE INFORMATION:
   14781              :     //       AUTHOR         Jason Glazer
   14782              :     //       DATE WRITTEN   March 2012
   14783              :     //       MODIFIED       na
   14784              :     //       RE-ENGINEERED  Amir Roth, Feb 2016 (unified with ComputeDelayedComponents to simplify code and debugging)
   14785              : 
   14786              :     // PURPOSE OF THIS SUBROUTINE:
   14787              :     //   Write the tables for the ZoneLoadComponentSummary and
   14788              :     //   ZoneLoadComponentDetail reports which summarize the major
   14789              :     //   load components for each zone in the building.
   14790              : 
   14791              :     // METHODOLOGY EMPLOYED:
   14792              :     //   Create arrays for the call to WriteTable and then call it.
   14793              :     //   This report actually consists of many sub-tables each with
   14794              :     //   its own call to WriteTable.
   14795              :     // The overall methodology is explained below:
   14796              :     //
   14797              :     // Determine decay curve - Pulse of radiant heat which is about 5% of lighting and
   14798              :     //   equipment input for a single timestep a few hours after
   14799              :     //   cooling or heat is scheduled on for each zone [radiantPulseTimestep(iZone)].
   14800              :     //   The radiant heat received on each wall is stored [radiantPulseReceived(jSurface)].
   14801              :     //   The load convected in the normal case [loadConvectedNormal(jSurface, kTime, mode)]
   14802              :     //   and in the case with the pulse [loadConvectedWithPulse(jSurface, kTime, mode)].
   14803              :     //   The difference divided by the pulse received by each surface
   14804              :     //   [radiantPulseReceived(jSurface)] is stored in [decayCurve(jSurface,kTime,mode)].
   14805              :     //
   14806              :     // Determine delayed loads - From the last timestep of the peak load on the zone
   14807              :     //   working backwards any radiant heat that was absorbed by the wall from an internal gain
   14808              :     //   or solar gain is multiplied by the appropriate timesteps in the decay curve
   14809              :     //   [decayCurve(jSurface,kTime,mode)] for timesteps that make up
   14810              :     //   the number of averaged timesteps are used to determine the peak load
   14811              :     //   [NumTimeStepsInAvg]. The sum for all surfaces in the zone are added together to
   14812              :     //   determine the delayed load.
   14813              :     //
   14814              :     // Determine instant loads - Average the convective portion of the internal gains
   14815              :     //   for the timesteps made up of the peak load period. Average those across the peak
   14816              :     //   load period.
   14817              :     //
   14818              :     // The comments from ComputeDelayedComponents which was incorporated into this routine follow:
   14819              :     //
   14820              :     // PURPOSE OF THIS SUBROUTINE:
   14821              :     //   For load component report, convert the sequence of radiant gains
   14822              :     //   for people and equipment and other internal loads into convective
   14823              :     //   gains based on the decay curves.
   14824              :     //
   14825              :     // METHODOLOGY EMPLOYED:
   14826              :     //   For each step of sequence from each design day, compute the
   14827              :     //   contributions from previous timesteps multiplied by the decay
   14828              :     //   curve. Rather than store every internal load's radiant contribution
   14829              :     //   to each surface, the EnclRadThermAbsMult and ITABSF sequences were also stored
   14830              :     //   which allocates the total radiant to each surface in the zone. The
   14831              :     //   formula used is:
   14832              :     //       SurfQRadThermInAbs(SurfNum) = QL(NZ) * EnclRadThermAbsMult(NZ) * SurfAbsThermalInt(SurfNum)
   14833              : 
   14834           40 :     auto &ort = state.dataOutRptTab;
   14835           46 :     if (!((ort->displayZoneComponentLoadSummary || ort->displayAirLoopComponentLoadSummary || ort->displayFacilityComponentLoadSummary) &&
   14836            6 :           state.dataGlobal->CompLoadReportIsReq)) {
   14837           34 :         return;
   14838              :     }
   14839              : 
   14840            6 :     auto &NumPrimaryAirSys = state.dataHVACGlobal->NumPrimaryAirSys;
   14841              : 
   14842            6 :     auto const &CalcFinalFacilitySizing(state.dataSize->CalcFinalFacilitySizing);
   14843              : 
   14844              :     int coolDesSelected;
   14845              :     int timeCoolMax;
   14846              :     int heatDesSelected;
   14847              :     int timeHeatMax;
   14848              : 
   14849              :     // Delayed components are moved into this function so that we can calculate them one zone at a time
   14850              :     // with Array1D
   14851            6 :     Array1D<Real64> peopleDelaySeq;
   14852            6 :     Array1D<Real64> lightDelaySeq;
   14853            6 :     Array1D<Real64> equipDelaySeq;
   14854            6 :     Array1D<Real64> hvacLossDelaySeq;
   14855            6 :     Array1D<Real64> powerGenDelaySeq;
   14856            6 :     Array1D<Real64> feneSolarDelaySeq;
   14857            6 :     Array2D<Real64> surfDelaySeq;
   14858              : 
   14859            6 :     Array1D<CompLoadTablesType> SpaceHeatCompLoadTables; // for space level component load summary output tables
   14860            6 :     Array1D<CompLoadTablesType> SpaceCoolCompLoadTables;
   14861              : 
   14862            6 :     Array1D<CompLoadTablesType> ZoneHeatCompLoadTables; // for zone level component load summary output tables
   14863            6 :     Array1D<CompLoadTablesType> ZoneCoolCompLoadTables;
   14864              : 
   14865            6 :     Array1D<CompLoadTablesType> AirLoopHeatCompLoadTables; // for airloop level component load summary output tables
   14866            6 :     Array1D<CompLoadTablesType> AirLoopCoolCompLoadTables;
   14867            6 :     Array1D<CompLoadTablesType> AirLoopZonesHeatCompLoadTables; // zone results used for airloop report - never directly output
   14868            6 :     Array1D<CompLoadTablesType> AirLoopZonesCoolCompLoadTables;
   14869              : 
   14870            6 :     CompLoadTablesType FacilityHeatCompLoadTables; // for facility level component load summary output tables
   14871            6 :     CompLoadTablesType FacilityCoolCompLoadTables;
   14872            6 :     Array1D<CompLoadTablesType> FacilityZonesHeatCompLoadTables; // zone results used for facility report - never directly output
   14873            6 :     Array1D<CompLoadTablesType> FacilityZonesCoolCompLoadTables;
   14874              : 
   14875              :     // Jan 2021: The following variable is redundant in the original code, deleting the line
   14876              :     // CompLoadTablesType curCompLoadTable; // active component load table
   14877              : 
   14878           13 :     for (int iUnitSystem = 0; iUnitSystem <= 1; iUnitSystem++) {
   14879           12 :         UnitsStyle unitsStyle_cur = ort->unitsStyle;
   14880           12 :         bool produceTabular = true;
   14881           12 :         bool produceSQLite = false;
   14882           12 :         if (produceDualUnitsFlags(iUnitSystem, ort->unitsStyle, ort->unitsStyle_SQLite, unitsStyle_cur, produceTabular, produceSQLite)) break;
   14883              : 
   14884            7 :         Real64 timeStepsInDay = state.dataGlobal->TimeStepsInHour * Constant::rHoursInDay;
   14885              : 
   14886              :         // adjusted initialization location to after variable declaration for loops 2021-01-11
   14887            7 :         peopleDelaySeq.dimension(timeStepsInDay, 0.0);
   14888            7 :         peopleDelaySeq = 0.0;
   14889            7 :         lightDelaySeq.allocate(timeStepsInDay);
   14890            7 :         lightDelaySeq = 0.0;
   14891            7 :         equipDelaySeq.allocate(timeStepsInDay);
   14892            7 :         equipDelaySeq = 0.0;
   14893            7 :         hvacLossDelaySeq.allocate(timeStepsInDay);
   14894            7 :         hvacLossDelaySeq = 0.0;
   14895            7 :         powerGenDelaySeq.allocate(timeStepsInDay);
   14896            7 :         powerGenDelaySeq = 0.0;
   14897            7 :         feneSolarDelaySeq.allocate(timeStepsInDay);
   14898            7 :         feneSolarDelaySeq = 0.0;
   14899            7 :         surfDelaySeq.allocate(timeStepsInDay, state.dataSurface->TotSurfaces);
   14900            7 :         surfDelaySeq = 0.0;
   14901              : 
   14902              :         // initialize arrays
   14903            7 :         if (ort->displayZoneComponentLoadSummary) {
   14904            5 :             if (state.dataHeatBal->doSpaceHeatBalanceSizing) {
   14905            0 :                 SpaceHeatCompLoadTables.allocate(state.dataGlobal->numSpaces);
   14906            0 :                 for (auto &e : SpaceHeatCompLoadTables) {
   14907            0 :                     e.cells.allocate(LoadCompCol::PerArea, LoadCompRow::GrdTot);
   14908            0 :                     e.cells = 0.;
   14909            0 :                     e.cellUsed.allocate(LoadCompCol::PerArea, LoadCompRow::GrdTot);
   14910            0 :                     e.cellUsed = false;
   14911              :                 }
   14912            0 :                 SpaceCoolCompLoadTables.allocate(state.dataGlobal->numSpaces);
   14913            0 :                 for (auto &e : SpaceCoolCompLoadTables) {
   14914            0 :                     e.cells.allocate(LoadCompCol::PerArea, LoadCompRow::GrdTot);
   14915            0 :                     e.cells = 0.;
   14916            0 :                     e.cellUsed.allocate(LoadCompCol::PerArea, LoadCompRow::GrdTot);
   14917            0 :                     e.cellUsed = false;
   14918              :                 }
   14919              :             }
   14920            5 :             ZoneHeatCompLoadTables.allocate(state.dataGlobal->NumOfZones);
   14921           11 :             for (auto &e : ZoneHeatCompLoadTables) {
   14922            6 :                 e.cells.allocate(LoadCompCol::PerArea, LoadCompRow::GrdTot);
   14923            6 :                 e.cells = 0.;
   14924            6 :                 e.cellUsed.allocate(LoadCompCol::PerArea, LoadCompRow::GrdTot);
   14925            6 :                 e.cellUsed = false;
   14926              :             }
   14927            5 :             ZoneCoolCompLoadTables.allocate(state.dataGlobal->NumOfZones);
   14928           11 :             for (auto &e : ZoneCoolCompLoadTables) {
   14929            6 :                 e.cells.allocate(LoadCompCol::PerArea, LoadCompRow::GrdTot);
   14930            6 :                 e.cells = 0.;
   14931            6 :                 e.cellUsed.allocate(LoadCompCol::PerArea, LoadCompRow::GrdTot);
   14932            6 :                 e.cellUsed = false;
   14933              :             }
   14934              :         }
   14935            7 :         if (ort->displayAirLoopComponentLoadSummary) {
   14936            7 :             AirLoopHeatCompLoadTables.allocate(NumPrimaryAirSys);
   14937           13 :             for (auto &e : AirLoopHeatCompLoadTables) {
   14938            6 :                 e.cells.allocate(LoadCompCol::PerArea, LoadCompRow::GrdTot);
   14939            6 :                 e.cells = 0.;
   14940            6 :                 e.cellUsed.allocate(LoadCompCol::PerArea, LoadCompRow::GrdTot);
   14941            6 :                 e.cellUsed = false;
   14942            6 :                 e.zoneIndices.allocate(state.dataGlobal->NumOfZones); // only need to allocate this for the AirLoop
   14943            6 :                 e.zoneIndices = 0;
   14944              :             }
   14945            7 :             AirLoopCoolCompLoadTables.allocate(NumPrimaryAirSys);
   14946           13 :             for (auto &e : AirLoopCoolCompLoadTables) {
   14947            6 :                 e.cells.allocate(LoadCompCol::PerArea, LoadCompRow::GrdTot);
   14948            6 :                 e.cells = 0.;
   14949            6 :                 e.cellUsed.allocate(LoadCompCol::PerArea, LoadCompRow::GrdTot);
   14950            6 :                 e.cellUsed = false;
   14951            6 :                 e.zoneIndices.allocate(state.dataGlobal->NumOfZones); // only need to allocate this for the AirLoop
   14952            6 :                 e.zoneIndices = 0;
   14953              :             }
   14954            7 :             AirLoopZonesHeatCompLoadTables.allocate(state.dataGlobal->NumOfZones);
   14955           13 :             for (auto &e : AirLoopZonesHeatCompLoadTables) {
   14956            6 :                 e.cells.allocate(LoadCompCol::PerArea, LoadCompRow::GrdTot);
   14957            6 :                 e.cells = 0.;
   14958            6 :                 e.cellUsed.allocate(LoadCompCol::PerArea, LoadCompRow::GrdTot);
   14959            6 :                 e.cellUsed = false;
   14960              :             }
   14961            7 :             AirLoopZonesCoolCompLoadTables.allocate(state.dataGlobal->NumOfZones);
   14962           13 :             for (auto &e : AirLoopZonesCoolCompLoadTables) {
   14963            6 :                 e.cells.allocate(LoadCompCol::PerArea, LoadCompRow::GrdTot);
   14964            6 :                 e.cells = 0.;
   14965            6 :                 e.cellUsed.allocate(LoadCompCol::PerArea, LoadCompRow::GrdTot);
   14966            6 :                 e.cellUsed = false;
   14967              :             }
   14968              :         }
   14969            7 :         if (ort->displayFacilityComponentLoadSummary) {
   14970            5 :             FacilityHeatCompLoadTables.cells.allocate(LoadCompCol::PerArea, LoadCompRow::GrdTot);
   14971            5 :             FacilityHeatCompLoadTables.cells = 0.;
   14972            5 :             FacilityHeatCompLoadTables.cellUsed.allocate(LoadCompCol::PerArea, LoadCompRow::GrdTot);
   14973            5 :             FacilityHeatCompLoadTables.cellUsed = false;
   14974              : 
   14975            5 :             FacilityCoolCompLoadTables.cells.allocate(LoadCompCol::PerArea, LoadCompRow::GrdTot);
   14976            5 :             FacilityCoolCompLoadTables.cells = 0.;
   14977            5 :             FacilityCoolCompLoadTables.cellUsed.allocate(LoadCompCol::PerArea, LoadCompRow::GrdTot);
   14978            5 :             FacilityCoolCompLoadTables.cellUsed = false;
   14979              : 
   14980            5 :             FacilityZonesHeatCompLoadTables.allocate(state.dataGlobal->NumOfZones);
   14981           11 :             for (auto &e : FacilityZonesHeatCompLoadTables) {
   14982            6 :                 e.cells.allocate(LoadCompCol::PerArea, LoadCompRow::GrdTot);
   14983            6 :                 e.cells = 0.;
   14984            6 :                 e.cellUsed.allocate(LoadCompCol::PerArea, LoadCompRow::GrdTot);
   14985            6 :                 e.cellUsed = false;
   14986              :             }
   14987            5 :             FacilityZonesCoolCompLoadTables.allocate(state.dataGlobal->NumOfZones);
   14988           11 :             for (auto &e : FacilityZonesCoolCompLoadTables) {
   14989            6 :                 e.cells.allocate(LoadCompCol::PerArea, LoadCompRow::GrdTot);
   14990            6 :                 e.cells = 0.;
   14991            6 :                 e.cellUsed.allocate(LoadCompCol::PerArea, LoadCompRow::GrdTot);
   14992            6 :                 e.cellUsed = false;
   14993              :             }
   14994              :         }
   14995              : 
   14996              :         // get the zone areas needed later
   14997            7 :         Array1D<ZompComponentAreasType> spaceComponentAreas;
   14998            7 :         Array1D<ZompComponentAreasType> ZoneComponentAreas;
   14999            7 :         ZoneComponentAreas.allocate(state.dataGlobal->NumOfZones);
   15000            7 :         if (state.dataHeatBal->doSpaceHeatBalanceSizing) {
   15001            0 :             spaceComponentAreas.allocate(state.dataGlobal->numSpaces);
   15002              :         }
   15003            7 :         GetZoneComponentAreas(state, ZoneComponentAreas, spaceComponentAreas);
   15004              : 
   15005              :         // ZoneComponentLoadSummary
   15006            7 :         if (ort->displayZoneComponentLoadSummary) {
   15007            5 :             if (state.dataHeatBal->doSpaceHeatBalanceSizing) {
   15008            0 :                 for (int iSpace = 1; iSpace <= state.dataGlobal->numSpaces; ++iSpace) {
   15009              :                     // Yes, check if the zone is controlled, not the space for this
   15010            0 :                     int zoneNum = state.dataHeatBal->space(iSpace).zoneNum;
   15011            0 :                     if (!state.dataZoneEquip->ZoneEquipConfig(zoneNum).IsControlled) continue;
   15012            0 :                     if (allocated(state.dataSize->CalcFinalSpaceSizing)) {
   15013            0 :                         computeSpaceZoneCompLoads(state,
   15014            0 :                                                   state.dataSize->CalcFinalSpaceSizing(iSpace),
   15015              :                                                   SpaceCoolCompLoadTables(iSpace),
   15016              :                                                   SpaceHeatCompLoadTables(iSpace),
   15017              :                                                   peopleDelaySeq,
   15018              :                                                   equipDelaySeq,
   15019              :                                                   hvacLossDelaySeq,
   15020              :                                                   powerGenDelaySeq,
   15021              :                                                   lightDelaySeq,
   15022              :                                                   feneSolarDelaySeq,
   15023            0 :                                                   ort->spCompLoads,
   15024              :                                                   surfDelaySeq,
   15025              :                                                   spaceComponentAreas(iSpace),
   15026              :                                                   zoneNum,
   15027              :                                                   iSpace);
   15028              :                     }
   15029              :                 }
   15030              :             }
   15031           11 :             for (int iZone = 1; iZone <= state.dataGlobal->NumOfZones; ++iZone) {
   15032            6 :                 if (!state.dataZoneEquip->ZoneEquipConfig(iZone).IsControlled) continue;
   15033            6 :                 if (allocated(state.dataSize->CalcFinalZoneSizing)) {
   15034           12 :                     computeSpaceZoneCompLoads(state,
   15035            6 :                                               state.dataSize->CalcFinalZoneSizing(iZone),
   15036              :                                               ZoneCoolCompLoadTables(iZone),
   15037              :                                               ZoneHeatCompLoadTables(iZone),
   15038              :                                               peopleDelaySeq,
   15039              :                                               equipDelaySeq,
   15040              :                                               hvacLossDelaySeq,
   15041              :                                               powerGenDelaySeq,
   15042              :                                               lightDelaySeq,
   15043              :                                               feneSolarDelaySeq,
   15044            6 :                                               ort->znCompLoads,
   15045              :                                               surfDelaySeq,
   15046              :                                               ZoneComponentAreas(iZone),
   15047              :                                               iZone);
   15048              :                 }
   15049              :             }
   15050              :             // We delay the potential application of SI to IP conversion and actual output until after both the
   15051              :             // AirLoopComponentLoadSummary and FacilityComponentLoadSummary have been processed because below we try
   15052              :             // to retrieve the info directly when the timestamp would match (cf #7356), and if we converted right
   15053              :             // now, we would apply the conversion twice
   15054              :         }
   15055              : 
   15056              :         // AirLoopComponentLoadSummary
   15057            7 :         if (ort->displayAirLoopComponentLoadSummary && NumPrimaryAirSys > 0) {
   15058            6 :             Array1D_int zoneToAirLoopCool;
   15059            6 :             zoneToAirLoopCool.dimension(state.dataGlobal->NumOfZones);
   15060            6 :             Array1D_int zoneToAirLoopHeat;
   15061            6 :             zoneToAirLoopHeat.dimension(state.dataGlobal->NumOfZones);
   15062              :             // set the peak day and time for each zone used by the airloops - use all zones connected to the airloop for both heating and cooling
   15063              :             // (regardless of "heated" or "cooled" zone status)
   15064           12 :             for (int iAirLoop = 1; iAirLoop <= NumPrimaryAirSys; ++iAirLoop) {
   15065            6 :                 auto const &finalSysSizing = state.dataSize->FinalSysSizing(iAirLoop);
   15066            6 :                 auto const &sysSizPeakDDNum = state.dataSize->SysSizPeakDDNum(iAirLoop);
   15067            6 :                 zoneToAirLoopCool = 0;
   15068            6 :                 zoneToAirLoopHeat = 0;
   15069            6 :                 if (finalSysSizing.loadSizingType == DataSizing::LoadSizing::Sensible) {
   15070            1 :                     coolDesSelected = sysSizPeakDDNum.SensCoolPeakDD;
   15071            1 :                     if (coolDesSelected != 0) {
   15072            1 :                         timeCoolMax = sysSizPeakDDNum.TimeStepAtSensCoolPk(coolDesSelected);
   15073              :                     } else {
   15074            0 :                         timeCoolMax = 0;
   15075              :                     }
   15076            5 :                 } else if (finalSysSizing.loadSizingType == DataSizing::LoadSizing::Ventilation) {
   15077            1 :                     coolDesSelected = sysSizPeakDDNum.CoolFlowPeakDD;
   15078            1 :                     if (coolDesSelected != 0) {
   15079            1 :                         timeCoolMax = sysSizPeakDDNum.TimeStepAtCoolFlowPk(coolDesSelected);
   15080              :                     } else {
   15081            0 :                         timeCoolMax = 0;
   15082              :                     }
   15083              :                 } else {
   15084            4 :                     coolDesSelected = sysSizPeakDDNum.TotCoolPeakDD;
   15085            4 :                     if (coolDesSelected != 0) {
   15086            2 :                         timeCoolMax = sysSizPeakDDNum.TimeStepAtTotCoolPk(coolDesSelected);
   15087              :                     } else {
   15088            2 :                         timeCoolMax = 0;
   15089              :                     }
   15090              :                 }
   15091            6 :                 heatDesSelected = sysSizPeakDDNum.HeatPeakDD;
   15092            6 :                 if (heatDesSelected != 0) {
   15093            3 :                     timeHeatMax = sysSizPeakDDNum.TimeStepAtHeatPk(heatDesSelected);
   15094              :                 } else {
   15095            3 :                     timeHeatMax = 0;
   15096              :                 }
   15097              : 
   15098            6 :                 int NumZonesCooled = state.dataAirLoop->AirToZoneNodeInfo(iAirLoop).NumZonesCooled;
   15099           11 :                 for (int ZonesCooledNum = 1; ZonesCooledNum <= NumZonesCooled; ++ZonesCooledNum) { // loop over cooled zones
   15100            5 :                     int CtrlZoneNum = state.dataAirLoop->AirToZoneNodeInfo(iAirLoop).CoolCtrlZoneNums(ZonesCooledNum);
   15101            5 :                     zoneToAirLoopCool(CtrlZoneNum) = iAirLoop;
   15102            5 :                     AirLoopZonesCoolCompLoadTables(CtrlZoneNum).desDayNum = coolDesSelected;
   15103            5 :                     AirLoopZonesCoolCompLoadTables(CtrlZoneNum).timeStepMax = timeCoolMax;
   15104            5 :                     zoneToAirLoopHeat(CtrlZoneNum) = iAirLoop;
   15105            5 :                     AirLoopZonesHeatCompLoadTables(CtrlZoneNum).desDayNum = heatDesSelected;
   15106            5 :                     AirLoopZonesHeatCompLoadTables(CtrlZoneNum).timeStepMax = timeHeatMax;
   15107              :                 }
   15108            6 :                 int NumZonesHeated = state.dataAirLoop->AirToZoneNodeInfo(iAirLoop).NumZonesHeated;
   15109            7 :                 for (int ZonesHeatedNum = 1; ZonesHeatedNum <= NumZonesHeated; ++ZonesHeatedNum) { // loop over heated zones
   15110            1 :                     int CtrlZoneNum = state.dataAirLoop->AirToZoneNodeInfo(iAirLoop).HeatCtrlZoneNums(ZonesHeatedNum);
   15111            1 :                     zoneToAirLoopCool(CtrlZoneNum) = iAirLoop;
   15112            1 :                     AirLoopZonesCoolCompLoadTables(CtrlZoneNum).desDayNum = coolDesSelected;
   15113            1 :                     AirLoopZonesCoolCompLoadTables(CtrlZoneNum).timeStepMax = timeCoolMax;
   15114            1 :                     zoneToAirLoopHeat(CtrlZoneNum) = iAirLoop;
   15115            1 :                     AirLoopZonesHeatCompLoadTables(CtrlZoneNum).desDayNum = heatDesSelected;
   15116            1 :                     AirLoopZonesHeatCompLoadTables(CtrlZoneNum).timeStepMax = timeHeatMax;
   15117              :                 }
   15118              : 
   15119              :                 // now go through the zones and if design day and time of max match the previously calculated zone results use those otherwise
   15120              :                 // compute them for specific design day and time of max
   15121           11 :                 for (int iZone = 1; iZone <= state.dataGlobal->NumOfZones; ++iZone) {
   15122            5 :                     if (!state.dataZoneEquip->ZoneEquipConfig(iZone).IsControlled) continue;
   15123            5 :                     auto &airLoopZonesCoolCompLoadTables = AirLoopZonesCoolCompLoadTables(iZone);
   15124            5 :                     auto &airLoopZonesHeatCompLoadTables = AirLoopZonesHeatCompLoadTables(iZone);
   15125              :                     // The ZoneCoolCompLoadTables already hasn't gotten a potential IP conversion yet, so we won't convert it twice.
   15126            5 :                     if (ort->displayZoneComponentLoadSummary &&
   15127           10 :                         (airLoopZonesCoolCompLoadTables.desDayNum == ZoneCoolCompLoadTables(iZone).desDayNum) &&
   15128            5 :                         (airLoopZonesCoolCompLoadTables.timeStepMax == ZoneCoolCompLoadTables(iZone).timeStepMax)) {
   15129            4 :                         airLoopZonesCoolCompLoadTables = ZoneCoolCompLoadTables(iZone);
   15130              :                     } else {
   15131            1 :                         coolDesSelected = airLoopZonesCoolCompLoadTables.desDayNum;
   15132            1 :                         timeCoolMax = airLoopZonesCoolCompLoadTables.timeStepMax;
   15133              : 
   15134            1 :                         GetDelaySequences(state,
   15135              :                                           coolDesSelected,
   15136              :                                           true,
   15137              :                                           iZone,
   15138              :                                           peopleDelaySeq,
   15139              :                                           equipDelaySeq,
   15140              :                                           hvacLossDelaySeq,
   15141              :                                           powerGenDelaySeq,
   15142              :                                           lightDelaySeq,
   15143              :                                           feneSolarDelaySeq,
   15144            1 :                                           ort->znCompLoads,
   15145              :                                           surfDelaySeq);
   15146            1 :                         ComputeTableBodyUsingMovingAvg(state,
   15147            1 :                                                        airLoopZonesCoolCompLoadTables.cells,
   15148            1 :                                                        airLoopZonesCoolCompLoadTables.cellUsed,
   15149              :                                                        coolDesSelected,
   15150              :                                                        timeCoolMax,
   15151              :                                                        iZone,
   15152              :                                                        peopleDelaySeq,
   15153              :                                                        equipDelaySeq,
   15154              :                                                        hvacLossDelaySeq,
   15155              :                                                        powerGenDelaySeq,
   15156              :                                                        lightDelaySeq,
   15157              :                                                        feneSolarDelaySeq,
   15158            1 :                                                        ort->znCompLoads,
   15159              :                                                        surfDelaySeq);
   15160            1 :                         CollectPeakZoneConditions(state, airLoopZonesCoolCompLoadTables, coolDesSelected, timeCoolMax, iZone, true);
   15161            1 :                         AddAreaColumnForZone(ZoneComponentAreas(iZone), airLoopZonesCoolCompLoadTables);
   15162              :                     }
   15163            5 :                     if (ort->displayZoneComponentLoadSummary &&
   15164            9 :                         (airLoopZonesHeatCompLoadTables.desDayNum == ZoneHeatCompLoadTables(iZone).desDayNum) &&
   15165            4 :                         (airLoopZonesHeatCompLoadTables.timeStepMax == ZoneHeatCompLoadTables(iZone).timeStepMax)) {
   15166            1 :                         airLoopZonesHeatCompLoadTables = ZoneHeatCompLoadTables(iZone);
   15167              :                     } else {
   15168            4 :                         heatDesSelected = airLoopZonesHeatCompLoadTables.desDayNum;
   15169            4 :                         timeHeatMax = airLoopZonesHeatCompLoadTables.timeStepMax;
   15170              : 
   15171            4 :                         GetDelaySequences(state,
   15172              :                                           heatDesSelected,
   15173              :                                           false,
   15174              :                                           iZone,
   15175              :                                           peopleDelaySeq,
   15176              :                                           equipDelaySeq,
   15177              :                                           hvacLossDelaySeq,
   15178              :                                           powerGenDelaySeq,
   15179              :                                           lightDelaySeq,
   15180              :                                           feneSolarDelaySeq,
   15181            4 :                                           ort->znCompLoads,
   15182              :                                           surfDelaySeq);
   15183            4 :                         ComputeTableBodyUsingMovingAvg(state,
   15184            4 :                                                        airLoopZonesHeatCompLoadTables.cells,
   15185            4 :                                                        airLoopZonesHeatCompLoadTables.cellUsed,
   15186              :                                                        heatDesSelected,
   15187              :                                                        timeHeatMax,
   15188              :                                                        iZone,
   15189              :                                                        peopleDelaySeq,
   15190              :                                                        equipDelaySeq,
   15191              :                                                        hvacLossDelaySeq,
   15192              :                                                        powerGenDelaySeq,
   15193              :                                                        lightDelaySeq,
   15194              :                                                        feneSolarDelaySeq,
   15195            4 :                                                        ort->znCompLoads,
   15196              :                                                        surfDelaySeq);
   15197            4 :                         CollectPeakZoneConditions(state, airLoopZonesHeatCompLoadTables, heatDesSelected, timeHeatMax, iZone, false);
   15198            4 :                         AddAreaColumnForZone(ZoneComponentAreas(iZone), airLoopZonesHeatCompLoadTables);
   15199              :                     }
   15200              :                 }
   15201              :                 // combine the zones for each air loop
   15202              : 
   15203            6 :                 auto &airLoopCoolTable = AirLoopCoolCompLoadTables(iAirLoop);
   15204            6 :                 auto &airLoopHeatTable = AirLoopHeatCompLoadTables(iAirLoop);
   15205           11 :                 for (int iZone = 1; iZone <= state.dataGlobal->NumOfZones; ++iZone) {
   15206            5 :                     auto const &thisZone = state.dataHeatBal->Zone(iZone);
   15207              : 
   15208            5 :                     if (zoneToAirLoopCool(iZone) == iAirLoop) {
   15209            5 :                         Real64 mult = thisZone.Multiplier * thisZone.ListMultiplier;
   15210            5 :                         if (mult == 0.0) {
   15211            0 :                             mult = 1.0;
   15212              :                         }
   15213            5 :                         CombineLoadCompResults(airLoopCoolTable, AirLoopZonesCoolCompLoadTables(iZone), mult);
   15214              :                     }
   15215            5 :                     if (zoneToAirLoopHeat(iZone) == iAirLoop) {
   15216            5 :                         Real64 mult = thisZone.Multiplier * thisZone.ListMultiplier;
   15217            5 :                         if (mult == 0.0) {
   15218            0 :                             mult = 1.0;
   15219              :                         }
   15220            5 :                         CombineLoadCompResults(airLoopHeatTable, AirLoopZonesHeatCompLoadTables(iZone), mult);
   15221              :                     }
   15222              :                 }
   15223           10 :                 for (int SysSizIndex = 1; SysSizIndex <= state.dataSize->NumSysSizInput; ++SysSizIndex) {
   15224            4 :                     if (state.dataSize->SysSizInput(SysSizIndex).AirLoopNum != iAirLoop) continue;
   15225            4 :                     if (state.dataSize->SysSizInput(SysSizIndex).SizingOption == DataSizing::SizingConcurrence::Coincident) {
   15226            0 :                         airLoopCoolTable.peakDesSensLoad = finalSysSizing.SysCoolCoinSpaceSens;
   15227            0 :                         airLoopCoolTable.designPeakLoad = finalSysSizing.SysDesCoolLoad;
   15228              : 
   15229            0 :                         airLoopHeatTable.peakDesSensLoad = -finalSysSizing.SysHeatCoinSpaceSens;
   15230            0 :                         airLoopHeatTable.designPeakLoad = -finalSysSizing.SysDesHeatLoad;
   15231              : 
   15232            0 :                         airLoopCoolTable.diffPeakEst = airLoopCoolTable.peakDesSensLoad - airLoopCoolTable.estInstDelSensLoad;
   15233            0 :                         airLoopCoolTable.diffDesignPeak = airLoopCoolTable.designPeakLoad - airLoopCoolTable.peakDesSensLoad;
   15234              : 
   15235            0 :                         airLoopHeatTable.diffPeakEst = airLoopHeatTable.peakDesSensLoad - airLoopHeatTable.estInstDelSensLoad;
   15236            0 :                         airLoopHeatTable.diffDesignPeak = airLoopHeatTable.designPeakLoad - airLoopHeatTable.peakDesSensLoad;
   15237              :                     }
   15238              :                 }
   15239              : 
   15240              :                 // Coincident and NonCoincident alike
   15241            6 :                 airLoopCoolTable.mixAirTemp = finalSysSizing.MixTempAtCoolPeak;
   15242            6 :                 airLoopHeatTable.mixAirTemp = finalSysSizing.HeatMixTemp;
   15243              : 
   15244            6 :                 ComputeEngineeringChecks(airLoopCoolTable);
   15245            6 :                 ComputeEngineeringChecks(airLoopHeatTable);
   15246              : 
   15247            6 :                 AddTotalRowsForLoadSummary(airLoopCoolTable);
   15248            6 :                 AddTotalRowsForLoadSummary(airLoopHeatTable);
   15249              : 
   15250            6 :                 ComputePeakDifference(airLoopCoolTable);
   15251            6 :                 ComputePeakDifference(airLoopHeatTable);
   15252              : 
   15253            6 :                 CreateListOfZonesForAirLoop(state, airLoopCoolTable, zoneToAirLoopCool, iAirLoop);
   15254            6 :                 CreateListOfZonesForAirLoop(state, airLoopHeatTable, zoneToAirLoopHeat, iAirLoop);
   15255              : 
   15256            6 :                 LoadSummaryUnitConversion(state, airLoopCoolTable, unitsStyle_cur);
   15257            6 :                 LoadSummaryUnitConversion(state, airLoopHeatTable, unitsStyle_cur);
   15258              : 
   15259            6 :                 OutputCompLoadSummary(
   15260              :                     state, OutputType::AirLoop, airLoopCoolTable, airLoopHeatTable, iAirLoop, unitsStyle_cur, produceTabular, produceSQLite);
   15261              :             }
   15262            6 :         }
   15263              : 
   15264              :         // FacilityComponentLoadSummary
   15265            7 :         if (ort->displayFacilityComponentLoadSummary) {
   15266              : 
   15267            5 :             coolDesSelected = CalcFinalFacilitySizing.CoolDDNum;
   15268            5 :             timeCoolMax = CalcFinalFacilitySizing.TimeStepNumAtCoolMax;
   15269              : 
   15270            5 :             heatDesSelected = CalcFinalFacilitySizing.HeatDDNum;
   15271            5 :             timeHeatMax = CalcFinalFacilitySizing.TimeStepNumAtHeatMax;
   15272              : 
   15273           11 :             for (int iZone = 1; iZone <= state.dataGlobal->NumOfZones; ++iZone) {
   15274            6 :                 if (!state.dataZoneEquip->ZoneEquipConfig(iZone).IsControlled) continue;
   15275            6 :                 auto &facilityZonesCoolCompLoadTables = FacilityZonesCoolCompLoadTables(iZone);
   15276            6 :                 auto &facilityZonesHeatCompLoadTables = FacilityZonesHeatCompLoadTables(iZone);
   15277            6 :                 auto const &thisZone = state.dataHeatBal->Zone(iZone);
   15278              : 
   15279            6 :                 Real64 mult = thisZone.Multiplier * thisZone.ListMultiplier;
   15280            6 :                 if (mult == 0.0) {
   15281            0 :                     mult = 1.0;
   15282              :                 }
   15283              : 
   15284              :                 // The ZoneCoolCompLoadTables already hasn't gotten a potential IP conversion yet, so we won't convert it twice.
   15285           12 :                 if (ort->displayZoneComponentLoadSummary && (coolDesSelected == ZoneCoolCompLoadTables(iZone).desDayNum) &&
   15286            6 :                     (timeCoolMax == ZoneCoolCompLoadTables(iZone).timeStepMax)) {
   15287            2 :                     facilityZonesCoolCompLoadTables = ZoneCoolCompLoadTables(iZone);
   15288              :                 } else {
   15289            4 :                     GetDelaySequences(state,
   15290              :                                       coolDesSelected,
   15291              :                                       true,
   15292              :                                       iZone,
   15293              :                                       peopleDelaySeq,
   15294              :                                       equipDelaySeq,
   15295              :                                       hvacLossDelaySeq,
   15296              :                                       powerGenDelaySeq,
   15297              :                                       lightDelaySeq,
   15298              :                                       feneSolarDelaySeq,
   15299            4 :                                       ort->znCompLoads,
   15300              :                                       surfDelaySeq);
   15301            4 :                     ComputeTableBodyUsingMovingAvg(state,
   15302            4 :                                                    facilityZonesCoolCompLoadTables.cells,
   15303            4 :                                                    facilityZonesCoolCompLoadTables.cellUsed,
   15304              :                                                    coolDesSelected,
   15305              :                                                    timeCoolMax,
   15306              :                                                    iZone,
   15307              :                                                    peopleDelaySeq,
   15308              :                                                    equipDelaySeq,
   15309              :                                                    hvacLossDelaySeq,
   15310              :                                                    powerGenDelaySeq,
   15311              :                                                    lightDelaySeq,
   15312              :                                                    feneSolarDelaySeq,
   15313            4 :                                                    ort->znCompLoads,
   15314              :                                                    surfDelaySeq);
   15315            4 :                     CollectPeakZoneConditions(state, facilityZonesCoolCompLoadTables, coolDesSelected, timeCoolMax, iZone, true);
   15316            4 :                     AddAreaColumnForZone(ZoneComponentAreas(iZone), facilityZonesCoolCompLoadTables);
   15317              :                 }
   15318            6 :                 facilityZonesCoolCompLoadTables.timeStepMax = timeCoolMax;
   15319            6 :                 facilityZonesCoolCompLoadTables.desDayNum = coolDesSelected;
   15320            6 :                 CombineLoadCompResults(FacilityCoolCompLoadTables, facilityZonesCoolCompLoadTables, mult);
   15321              : 
   15322           11 :                 if (ort->displayZoneComponentLoadSummary && (heatDesSelected == ZoneHeatCompLoadTables(iZone).desDayNum) &&
   15323            5 :                     (timeHeatMax == ZoneHeatCompLoadTables(iZone).timeStepMax)) {
   15324            3 :                     facilityZonesHeatCompLoadTables = ZoneHeatCompLoadTables(iZone);
   15325              :                 } else {
   15326            3 :                     GetDelaySequences(state,
   15327              :                                       heatDesSelected,
   15328              :                                       false,
   15329              :                                       iZone,
   15330              :                                       peopleDelaySeq,
   15331              :                                       equipDelaySeq,
   15332              :                                       hvacLossDelaySeq,
   15333              :                                       powerGenDelaySeq,
   15334              :                                       lightDelaySeq,
   15335              :                                       feneSolarDelaySeq,
   15336            3 :                                       ort->znCompLoads,
   15337              :                                       surfDelaySeq);
   15338            3 :                     ComputeTableBodyUsingMovingAvg(state,
   15339            3 :                                                    facilityZonesHeatCompLoadTables.cells,
   15340            3 :                                                    facilityZonesHeatCompLoadTables.cellUsed,
   15341              :                                                    heatDesSelected,
   15342              :                                                    timeHeatMax,
   15343              :                                                    iZone,
   15344              :                                                    peopleDelaySeq,
   15345              :                                                    equipDelaySeq,
   15346              :                                                    hvacLossDelaySeq,
   15347              :                                                    powerGenDelaySeq,
   15348              :                                                    lightDelaySeq,
   15349              :                                                    feneSolarDelaySeq,
   15350            3 :                                                    ort->znCompLoads,
   15351              :                                                    surfDelaySeq);
   15352            3 :                     CollectPeakZoneConditions(state, facilityZonesHeatCompLoadTables, heatDesSelected, timeHeatMax, iZone, false);
   15353            3 :                     AddAreaColumnForZone(ZoneComponentAreas(iZone), facilityZonesHeatCompLoadTables);
   15354              :                 }
   15355            6 :                 facilityZonesHeatCompLoadTables.timeStepMax = timeHeatMax;
   15356            6 :                 facilityZonesHeatCompLoadTables.desDayNum = heatDesSelected;
   15357            6 :                 CombineLoadCompResults(FacilityHeatCompLoadTables, facilityZonesHeatCompLoadTables, mult);
   15358              :             }
   15359              : 
   15360            5 :             auto &facilityCoolTable = FacilityCoolCompLoadTables;
   15361            5 :             auto &facilityHeatTable = FacilityHeatCompLoadTables;
   15362            5 :             facilityCoolTable.peakDesSensLoad = 0.0;
   15363            5 :             facilityCoolTable.designPeakLoad = 0.0;
   15364            5 :             facilityHeatTable.peakDesSensLoad = 0.0;
   15365            5 :             facilityHeatTable.designPeakLoad = 0.0;
   15366            5 :             facilityCoolTable.diffPeakEst = 0.0;
   15367            5 :             facilityHeatTable.diffPeakEst = 0.0;
   15368            5 :             facilityCoolTable.diffDesignPeak = 0.0;
   15369            9 :             for (int iAirLoop = 1; iAirLoop <= NumPrimaryAirSys; ++iAirLoop) {
   15370            4 :                 facilityCoolTable.peakDesSensLoad += AirLoopCoolCompLoadTables(iAirLoop).peakDesSensLoad;
   15371            4 :                 facilityCoolTable.designPeakLoad += AirLoopCoolCompLoadTables(iAirLoop).designPeakLoad;
   15372            4 :                 facilityHeatTable.peakDesSensLoad += AirLoopHeatCompLoadTables(iAirLoop).peakDesSensLoad;
   15373            4 :                 facilityHeatTable.designPeakLoad += AirLoopHeatCompLoadTables(iAirLoop).designPeakLoad;
   15374            4 :                 facilityCoolTable.diffPeakEst += AirLoopCoolCompLoadTables(iAirLoop).diffPeakEst;
   15375            4 :                 facilityCoolTable.diffDesignPeak += AirLoopCoolCompLoadTables(iAirLoop).diffDesignPeak;
   15376            4 :                 facilityHeatTable.diffPeakEst += AirLoopHeatCompLoadTables(iAirLoop).diffPeakEst;
   15377            4 :                 facilityCoolTable.diffDesignPeak += AirLoopHeatCompLoadTables(iAirLoop).diffDesignPeak;
   15378              :             }
   15379              : 
   15380            5 :             ComputeEngineeringChecks(FacilityCoolCompLoadTables);
   15381            5 :             ComputeEngineeringChecks(FacilityHeatCompLoadTables);
   15382              : 
   15383            5 :             AddTotalRowsForLoadSummary(FacilityCoolCompLoadTables);
   15384            5 :             AddTotalRowsForLoadSummary(FacilityHeatCompLoadTables);
   15385              : 
   15386            5 :             ComputePeakDifference(FacilityCoolCompLoadTables);
   15387            5 :             ComputePeakDifference(FacilityHeatCompLoadTables);
   15388              : 
   15389            5 :             LoadSummaryUnitConversion(state, FacilityCoolCompLoadTables, unitsStyle_cur);
   15390            5 :             LoadSummaryUnitConversion(state, FacilityHeatCompLoadTables, unitsStyle_cur);
   15391              : 
   15392            5 :             OutputCompLoadSummary(state,
   15393              :                                   OutputType::Facility,
   15394              :                                   FacilityCoolCompLoadTables,
   15395              :                                   FacilityHeatCompLoadTables,
   15396              :                                   0,
   15397              :                                   unitsStyle_cur,
   15398              :                                   produceTabular,
   15399              :                                   produceSQLite);
   15400              :         }
   15401              : 
   15402              :         // SpaceComponentLoadSummary: Now we convert and Display
   15403            7 :         if (state.dataHeatBal->doSpaceHeatBalanceSizing) {
   15404            0 :             if (ort->displayZoneComponentLoadSummary) {
   15405            0 :                 for (int iSpace = 1; iSpace <= state.dataGlobal->numSpaces; ++iSpace) {
   15406              :                     // Test if *zone* is controlled, not space, for sizing
   15407            0 :                     if (!state.dataZoneEquip->ZoneEquipConfig(state.dataHeatBal->space(iSpace).zoneNum).IsControlled) continue;
   15408            0 :                     if (allocated(state.dataSize->CalcFinalSpaceSizing)) {
   15409            0 :                         LoadSummaryUnitConversion(state, SpaceCoolCompLoadTables(iSpace), unitsStyle_cur);
   15410            0 :                         LoadSummaryUnitConversion(state, SpaceHeatCompLoadTables(iSpace), unitsStyle_cur);
   15411              : 
   15412            0 :                         OutputCompLoadSummary(state,
   15413              :                                               OutputType::Space,
   15414            0 :                                               SpaceCoolCompLoadTables(iSpace),
   15415            0 :                                               SpaceHeatCompLoadTables(iSpace),
   15416              :                                               iSpace,
   15417              :                                               unitsStyle_cur,
   15418              :                                               produceTabular,
   15419              :                                               produceSQLite);
   15420              :                     }
   15421              :                 }
   15422              :             }
   15423            0 :             SpaceHeatCompLoadTables.deallocate();
   15424            0 :             SpaceCoolCompLoadTables.deallocate();
   15425              :         }
   15426              : 
   15427              :         // ZoneComponentLoadSummary: Now we convert and Display
   15428            7 :         if (ort->displayZoneComponentLoadSummary) {
   15429           11 :             for (int iZone = 1; iZone <= state.dataGlobal->NumOfZones; ++iZone) {
   15430            6 :                 if (!state.dataZoneEquip->ZoneEquipConfig(iZone).IsControlled) continue;
   15431            6 :                 if (allocated(state.dataSize->CalcFinalZoneSizing)) {
   15432            6 :                     LoadSummaryUnitConversion(state, ZoneCoolCompLoadTables(iZone), unitsStyle_cur);
   15433            6 :                     LoadSummaryUnitConversion(state, ZoneHeatCompLoadTables(iZone), unitsStyle_cur);
   15434              : 
   15435           12 :                     OutputCompLoadSummary(state,
   15436              :                                           OutputType::Zone,
   15437            6 :                                           ZoneCoolCompLoadTables(iZone),
   15438            6 :                                           ZoneHeatCompLoadTables(iZone),
   15439              :                                           iZone,
   15440              :                                           unitsStyle_cur,
   15441              :                                           produceTabular,
   15442              :                                           produceSQLite);
   15443              :                 }
   15444              :             }
   15445              :         }
   15446              : 
   15447            7 :         ZoneHeatCompLoadTables.deallocate();
   15448            7 :         ZoneCoolCompLoadTables.deallocate();
   15449            7 :         AirLoopHeatCompLoadTables.deallocate();
   15450            7 :         AirLoopCoolCompLoadTables.deallocate();
   15451            7 :         AirLoopZonesHeatCompLoadTables.deallocate();
   15452            7 :         AirLoopZonesCoolCompLoadTables.deallocate();
   15453              : 
   15454            7 :         FacilityHeatCompLoadTables.cells.deallocate();
   15455            7 :         FacilityHeatCompLoadTables.cellUsed.deallocate();
   15456            7 :         FacilityCoolCompLoadTables.cells.deallocate();
   15457            7 :         FacilityCoolCompLoadTables.cellUsed.deallocate();
   15458              : 
   15459            7 :         FacilityZonesHeatCompLoadTables.deallocate();
   15460            7 :         FacilityZonesCoolCompLoadTables.deallocate();
   15461              : 
   15462            7 :         peopleDelaySeq.deallocate();
   15463            7 :         lightDelaySeq.deallocate();
   15464            7 :         equipDelaySeq.deallocate();
   15465            7 :         hvacLossDelaySeq.deallocate();
   15466            7 :         powerGenDelaySeq.deallocate();
   15467            7 :         feneSolarDelaySeq.deallocate();
   15468            7 :         surfDelaySeq.deallocate();
   15469            7 :     }
   15470            6 : }
   15471              : 
   15472            6 : void computeSpaceZoneCompLoads(EnergyPlusData &state,
   15473              :                                DataSizing::ZoneSizingData const &calcFinalSizing,
   15474              :                                CompLoadTablesType &coolCompLoadTables,
   15475              :                                CompLoadTablesType &heatCompLoadTables,
   15476              :                                Array1D<Real64> &peopleDelaySeq,
   15477              :                                Array1D<Real64> &equipDelaySeq,
   15478              :                                Array1D<Real64> &hvacLossDelaySeq,
   15479              :                                Array1D<Real64> &powerGenDelaySeq,
   15480              :                                Array1D<Real64> &lightDelaySeq,
   15481              :                                Array1D<Real64> &feneSolarDelaySeq,
   15482              :                                std::vector<OutputReportTabular::componentLoadsSpZn> &szCompLoadLoc,
   15483              :                                Array2D<Real64> &surfDelaySeq,
   15484              :                                ZompComponentAreasType &componentAreas,
   15485              :                                int const iZone,
   15486              :                                int const iSpace)
   15487              : {
   15488            6 :     int coolDesSelected = calcFinalSizing.CoolDDNum;
   15489            6 :     coolCompLoadTables.desDayNum = coolDesSelected;
   15490            6 :     int timeCoolMax = calcFinalSizing.TimeStepNumAtCoolMax;
   15491            6 :     coolCompLoadTables.timeStepMax = timeCoolMax;
   15492              : 
   15493            6 :     GetDelaySequences(state,
   15494              :                       coolDesSelected,
   15495              :                       true,
   15496              :                       iZone,
   15497              :                       peopleDelaySeq,
   15498              :                       equipDelaySeq,
   15499              :                       hvacLossDelaySeq,
   15500              :                       powerGenDelaySeq,
   15501              :                       lightDelaySeq,
   15502              :                       feneSolarDelaySeq,
   15503              :                       szCompLoadLoc,
   15504              :                       surfDelaySeq,
   15505              :                       iSpace);
   15506            6 :     ComputeTableBodyUsingMovingAvg(state,
   15507            6 :                                    coolCompLoadTables.cells,
   15508            6 :                                    coolCompLoadTables.cellUsed,
   15509              :                                    coolDesSelected,
   15510              :                                    timeCoolMax,
   15511              :                                    iZone,
   15512              :                                    peopleDelaySeq,
   15513              :                                    equipDelaySeq,
   15514              :                                    hvacLossDelaySeq,
   15515              :                                    powerGenDelaySeq,
   15516              :                                    lightDelaySeq,
   15517              :                                    feneSolarDelaySeq,
   15518              :                                    szCompLoadLoc,
   15519              :                                    surfDelaySeq,
   15520              :                                    iSpace);
   15521            6 :     CollectPeakZoneConditions(state, coolCompLoadTables, coolDesSelected, timeCoolMax, iZone, true, iSpace);
   15522              :     // send latent load info to coil summary report
   15523            6 :     state.dataRptCoilSelection->coilSelectionReportObj->setZoneLatentLoadCoolingIdealPeak(
   15524            6 :         iZone, coolCompLoadTables.cells(LoadCompCol::Latent, LoadCompRow::GrdTot));
   15525              : 
   15526            6 :     int heatDesSelected = calcFinalSizing.HeatDDNum;
   15527            6 :     heatCompLoadTables.desDayNum = heatDesSelected;
   15528            6 :     int timeHeatMax = calcFinalSizing.TimeStepNumAtHeatMax;
   15529            6 :     heatCompLoadTables.timeStepMax = timeHeatMax;
   15530              : 
   15531            6 :     GetDelaySequences(state,
   15532              :                       heatDesSelected,
   15533              :                       false,
   15534              :                       iZone,
   15535              :                       peopleDelaySeq,
   15536              :                       equipDelaySeq,
   15537              :                       hvacLossDelaySeq,
   15538              :                       powerGenDelaySeq,
   15539              :                       lightDelaySeq,
   15540              :                       feneSolarDelaySeq,
   15541              :                       szCompLoadLoc,
   15542              :                       surfDelaySeq,
   15543              :                       iSpace);
   15544            6 :     ComputeTableBodyUsingMovingAvg(state,
   15545            6 :                                    heatCompLoadTables.cells,
   15546            6 :                                    heatCompLoadTables.cellUsed,
   15547              :                                    heatDesSelected,
   15548              :                                    timeHeatMax,
   15549              :                                    iZone,
   15550              :                                    peopleDelaySeq,
   15551              :                                    equipDelaySeq,
   15552              :                                    hvacLossDelaySeq,
   15553              :                                    powerGenDelaySeq,
   15554              :                                    lightDelaySeq,
   15555              :                                    feneSolarDelaySeq,
   15556              :                                    szCompLoadLoc,
   15557              :                                    surfDelaySeq,
   15558              :                                    iSpace);
   15559            6 :     CollectPeakZoneConditions(state, heatCompLoadTables, heatDesSelected, timeHeatMax, iZone, false, iSpace);
   15560              : 
   15561              :     // send latent load info to coil summary report
   15562            6 :     state.dataRptCoilSelection->coilSelectionReportObj->setZoneLatentLoadHeatingIdealPeak(
   15563            6 :         iZone, heatCompLoadTables.cells(LoadCompCol::Latent, LoadCompRow::GrdTot));
   15564              : 
   15565            6 :     AddAreaColumnForZone(componentAreas, coolCompLoadTables);
   15566            6 :     AddAreaColumnForZone(componentAreas, heatCompLoadTables);
   15567              : 
   15568            6 :     AddTotalRowsForLoadSummary(coolCompLoadTables);
   15569            6 :     AddTotalRowsForLoadSummary(heatCompLoadTables);
   15570              : 
   15571            6 :     ComputePeakDifference(coolCompLoadTables);
   15572            6 :     ComputePeakDifference(heatCompLoadTables);
   15573            6 : }
   15574              : // populate the delay sequence arrays for the component load summary table output
   15575           28 : void GetDelaySequences(EnergyPlusData &state,
   15576              :                        int const desDaySelected,
   15577              :                        bool const isCooling,
   15578              :                        int const zoneIndex,
   15579              :                        Array1D<Real64> &peopleDelaySeq,
   15580              :                        Array1D<Real64> &equipDelaySeq,
   15581              :                        Array1D<Real64> &hvacLossDelaySeq,
   15582              :                        Array1D<Real64> &powerGenDelaySeq,
   15583              :                        Array1D<Real64> &lightDelaySeq,
   15584              :                        Array1D<Real64> &feneSolarDelaySeq,
   15585              :                        std::vector<OutputReportTabular::componentLoadsSpZn> &szCompLoadLoc,
   15586              :                        Array2D<Real64> &surfDelaySeq,
   15587              :                        int const iSpace)
   15588              : {
   15589              : 
   15590              :     // static bool initAdjFenDone(false); moved to anonymous namespace for unit testing
   15591           28 :     auto &ort = state.dataOutRptTab;
   15592           28 :     int const szNumMinus1 = (iSpace == 0) ? zoneIndex - 1 : iSpace - 1; // space or zone num minus 1 for vector
   15593              :     // reset to zero
   15594           28 :     surfDelaySeq = 0.0;
   15595              : 
   15596           28 :     if (desDaySelected != 0) {
   15597           26 :         auto const &surfCLDay = ort->surfCompLoads[desDaySelected - 1];
   15598           26 :         auto const &enclCLDay = ort->enclCompLoads[desDaySelected - 1];
   15599           26 :         auto &szCLDay = szCompLoadLoc[desDaySelected - 1];
   15600              : 
   15601           26 :         Array2D<Real64> decayCurve;
   15602           26 :         if (isCooling) {
   15603           15 :             decayCurve = ort->decayCurveCool;
   15604              :         } else {
   15605           11 :             decayCurve = ort->decayCurveHeat;
   15606              :         }
   15607              : 
   15608         2378 :         for (int kTimeStep = 1; kTimeStep <= state.dataGlobal->TimeStepsInHour * Constant::iHoursInDay; ++kTimeStep) {
   15609         2352 :             Real64 peopleConvIntoZone = 0.0;
   15610         2352 :             Real64 equipConvIntoZone = 0.0;
   15611         2352 :             Real64 hvacLossConvIntoZone = 0.0;
   15612         2352 :             Real64 powerGenConvIntoZone = 0.0;
   15613         2352 :             Real64 lightLWConvIntoZone = 0.0;
   15614         2352 :             Real64 lightSWConvIntoZone = 0.0;
   15615         2352 :             Real64 feneSolarConvIntoZone = 0.0;
   15616         2352 :             Real64 adjFeneSurfNetRadSeq = 0.0;
   15617              : 
   15618              :             // code from ComputeDelayedComponents starts
   15619         4704 :             for (int spaceNum : state.dataHeatBal->Zone(zoneIndex).spaceIndexes) {
   15620         2352 :                 if ((iSpace > 0) && (spaceNum != iSpace)) continue;
   15621         2352 :                 auto const &thisSpace = state.dataHeatBal->space(spaceNum);
   15622        14784 :                 for (int jSurf = thisSpace.HTSurfaceFirst; jSurf <= thisSpace.HTSurfaceLast; ++jSurf) {
   15623        12432 :                     int const radEnclosureNum = state.dataSurface->Surface(jSurf).RadEnclIndex;
   15624              :                     // for each time step, step back through time and apply decay curve to radiant heat for each end use absorbed in each surface
   15625        12432 :                     Real64 peopleConvFromSurf = 0.0;
   15626        12432 :                     Real64 equipConvFromSurf = 0.0;
   15627        12432 :                     Real64 hvacLossConvFromSurf = 0.0;
   15628        12432 :                     Real64 powerGenConvFromSurf = 0.0;
   15629        12432 :                     Real64 lightLWConvFromSurf = 0.0;
   15630        12432 :                     Real64 lightSWConvFromSurf = 0.0;
   15631        12432 :                     Real64 feneSolarConvFromSurf = 0.0;
   15632              : 
   15633       603288 :                     for (int mStepBack = 1; mStepBack <= kTimeStep; ++mStepBack) {
   15634       590856 :                         int sourceStep = kTimeStep - mStepBack + 1;
   15635       590856 :                         auto &compLoadTS = szCLDay.ts[sourceStep - 1].spacezone[szNumMinus1];
   15636       590856 :                         auto const &surfCLDayTS = surfCLDay.ts[sourceStep - 1].surf[jSurf - 1];
   15637       590856 :                         auto const &enclCLDayTS = enclCLDay.ts[sourceStep - 1].encl[radEnclosureNum - 1];
   15638              :                         Real64 thisQRadThermInAbsMult =
   15639       590856 :                             surfCLDayTS.TMULTseq * surfCLDayTS.ITABSFseq * state.dataSurface->Surface(jSurf).Area * decayCurve(mStepBack, jSurf);
   15640       590856 :                         peopleConvFromSurf += enclCLDayTS.peopleRadSeq * thisQRadThermInAbsMult;
   15641       590856 :                         equipConvFromSurf += enclCLDayTS.equipRadSeq * thisQRadThermInAbsMult;
   15642       590856 :                         hvacLossConvFromSurf += enclCLDayTS.hvacLossRadSeq * thisQRadThermInAbsMult;
   15643       590856 :                         powerGenConvFromSurf += enclCLDayTS.powerGenRadSeq * thisQRadThermInAbsMult;
   15644       590856 :                         lightLWConvFromSurf += enclCLDayTS.lightLWRadSeq * thisQRadThermInAbsMult;
   15645              :                         // short wave is already accumulated by surface
   15646       590856 :                         lightSWConvFromSurf += surfCLDayTS.lightSWRadSeq * decayCurve(mStepBack, jSurf);
   15647       590856 :                         feneSolarConvFromSurf += surfCLDayTS.feneSolarRadSeq * decayCurve(mStepBack, jSurf);
   15648              :                     } // for mStepBack
   15649              : 
   15650        12432 :                     peopleConvIntoZone += peopleConvFromSurf;
   15651        12432 :                     equipConvIntoZone += equipConvFromSurf;
   15652        12432 :                     hvacLossConvIntoZone += hvacLossConvFromSurf;
   15653        12432 :                     powerGenConvIntoZone += powerGenConvFromSurf;
   15654        12432 :                     lightLWConvIntoZone += lightLWConvFromSurf;
   15655        12432 :                     lightSWConvIntoZone += lightSWConvFromSurf;
   15656        12432 :                     feneSolarConvIntoZone += feneSolarConvFromSurf;
   15657              :                     // code from ComputeDelayedComponents ends
   15658              :                     // determine the remaining convective heat from the surfaces that are not based
   15659              :                     // on any of these other loads
   15660              :                     // negative because heat from surface should be positive
   15661        12432 :                     auto &surfCLDaykTS = surfCLDay.ts[kTimeStep - 1].surf[jSurf - 1];
   15662        24864 :                     surfDelaySeq(kTimeStep, jSurf) =
   15663        12432 :                         -surfCLDaykTS.loadConvectedNormal - surfCLDaykTS.netSurfRadSeq -
   15664        12432 :                         (peopleConvFromSurf + equipConvFromSurf + hvacLossConvFromSurf + powerGenConvFromSurf + lightLWConvFromSurf +
   15665        12432 :                          lightSWConvFromSurf +
   15666              :                          feneSolarConvFromSurf); // remove net radiant for the surface
   15667              :                                                  // also remove the net radiant component on the instantaneous conduction for fenestration
   15668        12432 :                     if (state.dataSurface->Surface(jSurf).Class == DataSurfaces::SurfaceClass::Window) {
   15669         1200 :                         adjFeneSurfNetRadSeq += surfCLDaykTS.netSurfRadSeq;
   15670              :                     }
   15671              :                 } // for jSurf
   15672              :             }
   15673         2352 :             peopleDelaySeq(kTimeStep) = peopleConvIntoZone;
   15674         2352 :             equipDelaySeq(kTimeStep) = equipConvIntoZone;
   15675         2352 :             hvacLossDelaySeq(kTimeStep) = hvacLossConvIntoZone;
   15676         2352 :             powerGenDelaySeq(kTimeStep) = powerGenConvIntoZone;
   15677              :             // combine short wave (visible) and long wave (thermal) impacts
   15678         2352 :             lightDelaySeq(kTimeStep) = lightLWConvIntoZone + lightSWConvIntoZone;
   15679         2352 :             feneSolarDelaySeq(kTimeStep) = feneSolarConvIntoZone;
   15680              :             // also remove the net radiant component on the instantaneous conduction for fenestration
   15681         2352 :             auto &szCompLoadDayTS = szCLDay.ts[kTimeStep - 1].spacezone[szNumMinus1];
   15682         2352 :             if (!szCompLoadDayTS.adjFenDone) {
   15683         1200 :                 szCompLoadDayTS.feneCondInstantSeq -= adjFeneSurfNetRadSeq;
   15684         1200 :                 szCompLoadDayTS.adjFenDone = true;
   15685              :             }
   15686              :         } // for kTimeStep
   15687              : 
   15688           26 :         decayCurve.deallocate();
   15689              : 
   15690           26 :     } // if desDaySelected != 0
   15691           28 : }
   15692              : 
   15693              : // set the load summary table cells based on the load sequences using moving averages to smooth out
   15694           24 : void ComputeTableBodyUsingMovingAvg(EnergyPlusData &state,
   15695              :                                     Array2D<Real64> &resultCells,
   15696              :                                     Array2D_bool &resCellsUsd,
   15697              :                                     int const desDaySelected,
   15698              :                                     int const timeOfMax,
   15699              :                                     int const zoneIndex,
   15700              :                                     Array1D<Real64> const &peopleDelaySeq,
   15701              :                                     Array1D<Real64> const &equipDelaySeq,
   15702              :                                     Array1D<Real64> const &hvacLossDelaySeq,
   15703              :                                     Array1D<Real64> const &powerGenDelaySeq,
   15704              :                                     Array1D<Real64> const &lightDelaySeq,
   15705              :                                     Array1D<Real64> const &feneSolarDelaySeq,
   15706              :                                     std::vector<OutputReportTabular::componentLoadsSpZn> &szCompLoadLoc,
   15707              :                                     Array2D<Real64> const &surfDelaySeq,
   15708              :                                     int const iSpace)
   15709              : {
   15710           24 :     Array1D<Real64> AvgData;     // sequence data to be averaging
   15711           24 :     Array1D<Real64> delayOpaque; // hold values for report for delayed opaque
   15712              : 
   15713           24 :     resultCells = 0.;
   15714           24 :     resCellsUsd = false;
   15715           24 :     delayOpaque.allocate(LoadCompRow::GrdTot);
   15716           24 :     Real64 numTSinDay = state.dataGlobal->TimeStepsInHour * Constant::iHoursInDay;
   15717           24 :     AvgData.allocate(numTSinDay);
   15718           24 :     int const szNumMinus1 = (iSpace == 0) ? zoneIndex - 1 : iSpace - 1; // space or zone num minus 1 for vector
   15719              : 
   15720           24 :     if (desDaySelected != 0 && timeOfMax != 0) {
   15721              :         // Don't update/average original array data
   15722              :         // PEOPLE
   15723           22 :         auto &compLoadDay = szCompLoadLoc[desDaySelected - 1];
   15724         1990 :         for (int iTS = 1; iTS <= numTSinDay; ++iTS) {
   15725         1968 :             AvgData(iTS) = compLoadDay.ts[iTS - 1].spacezone[szNumMinus1].peopleInstantSeq;
   15726              :         }
   15727           22 :         General::MovingAvg(AvgData, state.dataSize->NumTimeStepsInAvg);
   15728           22 :         resultCells(LoadCompCol::SensInst, LoadCompRow::People) = AvgData(timeOfMax);
   15729           22 :         resCellsUsd(LoadCompCol::SensInst, LoadCompRow::People) = true;
   15730         1990 :         for (int iTS = 1; iTS <= numTSinDay; ++iTS) {
   15731         1968 :             AvgData(iTS) = compLoadDay.ts[iTS - 1].spacezone[szNumMinus1].peopleLatentSeq;
   15732              :         }
   15733           22 :         General::MovingAvg(AvgData, state.dataSize->NumTimeStepsInAvg);
   15734           22 :         resultCells(LoadCompCol::Latent, LoadCompRow::People) = AvgData(timeOfMax);
   15735           22 :         resCellsUsd(LoadCompCol::Latent, LoadCompRow::People) = true;
   15736           22 :         AvgData = peopleDelaySeq(_);
   15737           22 :         General::MovingAvg(AvgData, state.dataSize->NumTimeStepsInAvg);
   15738           22 :         resultCells(LoadCompCol::SensDelay, LoadCompRow::People) = AvgData(timeOfMax);
   15739           22 :         resCellsUsd(LoadCompCol::SensDelay, LoadCompRow::People) = true;
   15740              : 
   15741              :         // LIGHTS
   15742         1990 :         for (int iTS = 1; iTS <= numTSinDay; ++iTS) {
   15743         1968 :             AvgData(iTS) = compLoadDay.ts[iTS - 1].spacezone[szNumMinus1].lightInstantSeq;
   15744              :         }
   15745           22 :         General::MovingAvg(AvgData, state.dataSize->NumTimeStepsInAvg);
   15746           22 :         resultCells(LoadCompCol::SensInst, LoadCompRow::Lights) = AvgData(timeOfMax);
   15747           22 :         resCellsUsd(LoadCompCol::SensInst, LoadCompRow::Lights) = true;
   15748         1990 :         for (int iTS = 1; iTS <= numTSinDay; ++iTS) {
   15749         1968 :             AvgData(iTS) = compLoadDay.ts[iTS - 1].spacezone[szNumMinus1].lightRetAirSeq;
   15750              :         }
   15751           22 :         General::MovingAvg(AvgData, state.dataSize->NumTimeStepsInAvg);
   15752           22 :         resultCells(LoadCompCol::SensRA, LoadCompRow::Lights) = AvgData(timeOfMax);
   15753           22 :         resCellsUsd(LoadCompCol::SensRA, LoadCompRow::Lights) = true;
   15754           22 :         AvgData = lightDelaySeq(_);
   15755           22 :         General::MovingAvg(AvgData, state.dataSize->NumTimeStepsInAvg);
   15756           22 :         resultCells(LoadCompCol::SensDelay, LoadCompRow::Lights) = AvgData(timeOfMax);
   15757           22 :         resCellsUsd(LoadCompCol::SensDelay, LoadCompRow::Lights) = true;
   15758              : 
   15759              :         // EQUIPMENT
   15760         1990 :         for (int iTS = 1; iTS <= numTSinDay; ++iTS) {
   15761         1968 :             AvgData(iTS) = compLoadDay.ts[iTS - 1].spacezone[szNumMinus1].equipInstantSeq;
   15762              :         }
   15763           22 :         General::MovingAvg(AvgData, state.dataSize->NumTimeStepsInAvg);
   15764           22 :         resultCells(LoadCompCol::SensInst, LoadCompRow::Equip) = AvgData(timeOfMax);
   15765           22 :         resCellsUsd(LoadCompCol::SensInst, LoadCompRow::Equip) = true;
   15766         1990 :         for (int iTS = 1; iTS <= numTSinDay; ++iTS) {
   15767         1968 :             AvgData(iTS) = compLoadDay.ts[iTS - 1].spacezone[szNumMinus1].equipLatentSeq;
   15768              :         }
   15769           22 :         General::MovingAvg(AvgData, state.dataSize->NumTimeStepsInAvg);
   15770           22 :         resultCells(LoadCompCol::Latent, LoadCompRow::Equip) = AvgData(timeOfMax);
   15771           22 :         resCellsUsd(LoadCompCol::Latent, LoadCompRow::Equip) = true;
   15772           22 :         AvgData = equipDelaySeq(_);
   15773           22 :         General::MovingAvg(AvgData, state.dataSize->NumTimeStepsInAvg);
   15774           22 :         resultCells(LoadCompCol::SensDelay, LoadCompRow::Equip) = AvgData(timeOfMax);
   15775           22 :         resCellsUsd(LoadCompCol::SensDelay, LoadCompRow::Equip) = true;
   15776              : 
   15777              :         // REFRIGERATION EQUIPMENT
   15778         1990 :         for (int iTS = 1; iTS <= numTSinDay; ++iTS) {
   15779         1968 :             AvgData(iTS) = compLoadDay.ts[iTS - 1].spacezone[szNumMinus1].refrigInstantSeq;
   15780              :         }
   15781           22 :         General::MovingAvg(AvgData, state.dataSize->NumTimeStepsInAvg);
   15782           22 :         resultCells(LoadCompCol::SensInst, LoadCompRow::Refrig) = AvgData(timeOfMax);
   15783           22 :         resCellsUsd(LoadCompCol::SensInst, LoadCompRow::Refrig) = true;
   15784         1990 :         for (int iTS = 1; iTS <= numTSinDay; ++iTS) {
   15785         1968 :             AvgData(iTS) = compLoadDay.ts[iTS - 1].spacezone[szNumMinus1].refrigRetAirSeq;
   15786              :         }
   15787           22 :         General::MovingAvg(AvgData, state.dataSize->NumTimeStepsInAvg);
   15788           22 :         resultCells(LoadCompCol::SensRA, LoadCompRow::Refrig) = AvgData(timeOfMax);
   15789           22 :         resCellsUsd(LoadCompCol::SensRA, LoadCompRow::Refrig) = true;
   15790         1990 :         for (int iTS = 1; iTS <= numTSinDay; ++iTS) {
   15791         1968 :             AvgData(iTS) = compLoadDay.ts[iTS - 1].spacezone[szNumMinus1].refrigLatentSeq;
   15792              :         }
   15793           22 :         General::MovingAvg(AvgData, state.dataSize->NumTimeStepsInAvg);
   15794           22 :         resultCells(LoadCompCol::Latent, LoadCompRow::Refrig) = AvgData(timeOfMax);
   15795           22 :         resCellsUsd(LoadCompCol::Latent, LoadCompRow::Refrig) = true;
   15796              : 
   15797              :         // WATER USE EQUIPMENT
   15798         1990 :         for (int iTS = 1; iTS <= numTSinDay; ++iTS) {
   15799         1968 :             AvgData(iTS) = compLoadDay.ts[iTS - 1].spacezone[szNumMinus1].waterUseInstantSeq;
   15800              :         }
   15801           22 :         General::MovingAvg(AvgData, state.dataSize->NumTimeStepsInAvg);
   15802           22 :         resultCells(LoadCompCol::SensInst, LoadCompRow::WaterUse) = AvgData(timeOfMax);
   15803           22 :         resCellsUsd(LoadCompCol::SensInst, LoadCompRow::WaterUse) = true;
   15804         1990 :         for (int iTS = 1; iTS <= numTSinDay; ++iTS) {
   15805         1968 :             AvgData(iTS) = compLoadDay.ts[iTS - 1].spacezone[szNumMinus1].waterUseLatentSeq;
   15806              :         }
   15807           22 :         General::MovingAvg(AvgData, state.dataSize->NumTimeStepsInAvg);
   15808           22 :         resultCells(LoadCompCol::Latent, LoadCompRow::WaterUse) = AvgData(timeOfMax);
   15809           22 :         resCellsUsd(LoadCompCol::Latent, LoadCompRow::WaterUse) = true;
   15810              : 
   15811              :         // HVAC EQUIPMENT LOSSES
   15812         1990 :         for (int iTS = 1; iTS <= numTSinDay; ++iTS) {
   15813         1968 :             AvgData(iTS) = compLoadDay.ts[iTS - 1].spacezone[szNumMinus1].hvacLossInstantSeq;
   15814              :         }
   15815           22 :         General::MovingAvg(AvgData, state.dataSize->NumTimeStepsInAvg);
   15816           22 :         resultCells(LoadCompCol::SensInst, LoadCompRow::HvacLoss) = AvgData(timeOfMax);
   15817           22 :         resCellsUsd(LoadCompCol::SensInst, LoadCompRow::HvacLoss) = true;
   15818           22 :         AvgData = hvacLossDelaySeq(_);
   15819           22 :         General::MovingAvg(AvgData, state.dataSize->NumTimeStepsInAvg);
   15820           22 :         resultCells(LoadCompCol::SensDelay, LoadCompRow::HvacLoss) = AvgData(timeOfMax);
   15821           22 :         resCellsUsd(LoadCompCol::SensDelay, LoadCompRow::HvacLoss) = true;
   15822              : 
   15823              :         // POWER GENERATION EQUIPMENT
   15824         1990 :         for (int iTS = 1; iTS <= numTSinDay; ++iTS) {
   15825         1968 :             AvgData(iTS) = compLoadDay.ts[iTS - 1].spacezone[szNumMinus1].powerGenInstantSeq;
   15826              :         }
   15827           22 :         General::MovingAvg(AvgData, state.dataSize->NumTimeStepsInAvg);
   15828           22 :         resultCells(LoadCompCol::SensInst, LoadCompRow::PowerGen) = AvgData(timeOfMax);
   15829           22 :         resCellsUsd(LoadCompCol::SensInst, LoadCompRow::PowerGen) = true;
   15830           22 :         AvgData = powerGenDelaySeq(_);
   15831           22 :         General::MovingAvg(AvgData, state.dataSize->NumTimeStepsInAvg);
   15832           22 :         resultCells(LoadCompCol::SensDelay, LoadCompRow::PowerGen) = AvgData(timeOfMax);
   15833           22 :         resCellsUsd(LoadCompCol::SensDelay, LoadCompRow::PowerGen) = true;
   15834              : 
   15835              :         // DOAS
   15836           22 :         Real64 const mult = state.dataHeatBal->Zone(zoneIndex).Multiplier * state.dataHeatBal->Zone(zoneIndex).ListMultiplier;
   15837           44 :         resultCells(LoadCompCol::SensInst, LoadCompRow::DOAS) =
   15838           22 :             state.dataSize->CalcZoneSizing(desDaySelected, zoneIndex).DOASHeatAddSeq(timeOfMax) / mult;
   15839           22 :         resCellsUsd(LoadCompCol::SensInst, LoadCompRow::DOAS) = true;
   15840           44 :         resultCells(LoadCompCol::Latent, LoadCompRow::DOAS) =
   15841           22 :             state.dataSize->CalcZoneSizing(desDaySelected, zoneIndex).DOASLatAddSeq(timeOfMax) / mult;
   15842           22 :         resCellsUsd(LoadCompCol::Latent, LoadCompRow::DOAS) = true;
   15843              : 
   15844              :         // INFILTRATION
   15845         1990 :         for (int iTS = 1; iTS <= numTSinDay; ++iTS) {
   15846         1968 :             AvgData(iTS) = compLoadDay.ts[iTS - 1].spacezone[szNumMinus1].infilInstantSeq;
   15847              :         }
   15848           22 :         General::MovingAvg(AvgData, state.dataSize->NumTimeStepsInAvg);
   15849           22 :         resultCells(LoadCompCol::SensInst, LoadCompRow::Infil) = AvgData(timeOfMax);
   15850           22 :         resCellsUsd(LoadCompCol::SensInst, LoadCompRow::Infil) = true;
   15851         1990 :         for (int iTS = 1; iTS <= numTSinDay; ++iTS) {
   15852         1968 :             AvgData(iTS) = compLoadDay.ts[iTS - 1].spacezone[szNumMinus1].infilLatentSeq;
   15853              :         }
   15854           22 :         General::MovingAvg(AvgData, state.dataSize->NumTimeStepsInAvg);
   15855           22 :         resultCells(LoadCompCol::Latent, LoadCompRow::Infil) = AvgData(timeOfMax);
   15856           22 :         resCellsUsd(LoadCompCol::Latent, LoadCompRow::Infil) = true;
   15857              : 
   15858              :         // ZONE VENTILATION
   15859         1990 :         for (int iTS = 1; iTS <= numTSinDay; ++iTS) {
   15860         1968 :             AvgData(iTS) = compLoadDay.ts[iTS - 1].spacezone[szNumMinus1].zoneVentInstantSeq;
   15861              :         }
   15862           22 :         General::MovingAvg(AvgData, state.dataSize->NumTimeStepsInAvg);
   15863           22 :         resultCells(LoadCompCol::SensInst, LoadCompRow::ZoneVent) = AvgData(timeOfMax);
   15864           22 :         resCellsUsd(LoadCompCol::SensInst, LoadCompRow::ZoneVent) = true;
   15865         1990 :         for (int iTS = 1; iTS <= numTSinDay; ++iTS) {
   15866         1968 :             AvgData(iTS) = compLoadDay.ts[iTS - 1].spacezone[szNumMinus1].zoneVentLatentSeq;
   15867              :         }
   15868           22 :         General::MovingAvg(AvgData, state.dataSize->NumTimeStepsInAvg);
   15869           22 :         resultCells(LoadCompCol::Latent, LoadCompRow::ZoneVent) = AvgData(timeOfMax);
   15870           22 :         resCellsUsd(LoadCompCol::Latent, LoadCompRow::ZoneVent) = true;
   15871              : 
   15872              :         // INTERZONE MIXING
   15873         1990 :         for (int iTS = 1; iTS <= numTSinDay; ++iTS) {
   15874         1968 :             AvgData(iTS) = compLoadDay.ts[iTS - 1].spacezone[szNumMinus1].interZoneMixInstantSeq;
   15875              :         }
   15876           22 :         General::MovingAvg(AvgData, state.dataSize->NumTimeStepsInAvg);
   15877           22 :         resultCells(LoadCompCol::SensInst, LoadCompRow::IntZonMix) = AvgData(timeOfMax);
   15878           22 :         resCellsUsd(LoadCompCol::SensInst, LoadCompRow::IntZonMix) = true;
   15879         1990 :         for (int iTS = 1; iTS <= numTSinDay; ++iTS) {
   15880         1968 :             AvgData(iTS) = compLoadDay.ts[iTS - 1].spacezone[szNumMinus1].interZoneMixLatentSeq;
   15881              :         }
   15882           22 :         General::MovingAvg(AvgData, state.dataSize->NumTimeStepsInAvg);
   15883           22 :         resultCells(LoadCompCol::Latent, LoadCompRow::IntZonMix) = AvgData(timeOfMax);
   15884           22 :         resCellsUsd(LoadCompCol::Latent, LoadCompRow::IntZonMix) = true;
   15885              : 
   15886              :         // FENESTRATION CONDUCTION
   15887         1990 :         for (int iTS = 1; iTS <= numTSinDay; ++iTS) {
   15888         1968 :             AvgData(iTS) = compLoadDay.ts[iTS - 1].spacezone[szNumMinus1].feneCondInstantSeq;
   15889              :         }
   15890           22 :         General::MovingAvg(AvgData, state.dataSize->NumTimeStepsInAvg);
   15891           22 :         resultCells(LoadCompCol::SensInst, LoadCompRow::FeneCond) = AvgData(timeOfMax);
   15892           22 :         resCellsUsd(LoadCompCol::SensInst, LoadCompRow::FeneCond) = true;
   15893              : 
   15894              :         // FENESTRATION SOLAR
   15895           22 :         AvgData = feneSolarDelaySeq(_);
   15896           22 :         General::MovingAvg(AvgData, state.dataSize->NumTimeStepsInAvg);
   15897           22 :         resultCells(LoadCompCol::SensDelay, LoadCompRow::FeneSolr) = AvgData(timeOfMax);
   15898           22 :         resCellsUsd(LoadCompCol::SensDelay, LoadCompRow::FeneSolr) = true;
   15899              : 
   15900              :         // opaque surfaces - must combine individual surfaces by class and other side conditions
   15901           22 :         delayOpaque = 0.0;
   15902           44 :         for (int spaceNum : state.dataHeatBal->Zone(zoneIndex).spaceIndexes) {
   15903           22 :             auto const &thisSpace = state.dataHeatBal->space(spaceNum);
   15904          152 :             for (int kSurf = thisSpace.HTSurfaceFirst; kSurf <= thisSpace.HTSurfaceLast; ++kSurf) {
   15905              : 
   15906          130 :                 int curExtBoundCond = state.dataSurface->Surface(kSurf).ExtBoundCond;
   15907              :                 // if exterior is other side coefficients using ground preprocessor terms then
   15908              :                 // set it to ground instead of other side coefficients
   15909          130 :                 if (curExtBoundCond == DataSurfaces::OtherSideCoefNoCalcExt || curExtBoundCond == DataSurfaces::OtherSideCoefCalcExt) {
   15910            0 :                     if (has_prefixi(state.dataSurface->OSC(state.dataSurface->Surface(kSurf).OSCPtr).Name, "surfPropOthSdCoef")) {
   15911            0 :                         curExtBoundCond = DataSurfaces::Ground;
   15912              :                     }
   15913              :                 }
   15914          130 :                 AvgData = surfDelaySeq(_, kSurf);
   15915          130 :                 General::MovingAvg(AvgData, state.dataSize->NumTimeStepsInAvg);
   15916          130 :                 Real64 singleSurfDelay = AvgData(timeOfMax);
   15917          130 :                 switch (state.dataSurface->Surface(kSurf).Class) {
   15918           80 :                 case DataSurfaces::SurfaceClass::Wall: {
   15919           80 :                     switch (curExtBoundCond) {
   15920           50 :                     case DataSurfaces::ExternalEnvironment: {
   15921           50 :                         delayOpaque(LoadCompRow::ExtWall) += singleSurfDelay;
   15922           50 :                     } break;
   15923            0 :                     case DataSurfaces::Ground:
   15924              :                     case DataSurfaces::GroundFCfactorMethod:
   15925              :                     case DataSurfaces::KivaFoundation: {
   15926            0 :                         delayOpaque(LoadCompRow::GrdWall) += singleSurfDelay;
   15927            0 :                     } break;
   15928            0 :                     case DataSurfaces::OtherSideCoefNoCalcExt:
   15929              :                     case DataSurfaces::OtherSideCoefCalcExt:
   15930              :                     case DataSurfaces::OtherSideCondModeledExt: {
   15931            0 :                         delayOpaque(LoadCompRow::OtherWall) += singleSurfDelay;
   15932            0 :                     } break;
   15933           30 :                     default: { // interzone
   15934           30 :                         delayOpaque(LoadCompRow::IntZonWall) += singleSurfDelay;
   15935           30 :                     } break;
   15936              :                     }
   15937           80 :                 } break;
   15938           20 :                 case DataSurfaces::SurfaceClass::Floor: {
   15939           20 :                     switch (curExtBoundCond) {
   15940            0 :                     case DataSurfaces::ExternalEnvironment: {
   15941            0 :                         delayOpaque(LoadCompRow::ExtFlr) += singleSurfDelay;
   15942            0 :                     } break;
   15943           10 :                     case DataSurfaces::Ground:
   15944              :                     case DataSurfaces::GroundFCfactorMethod:
   15945              :                     case DataSurfaces::KivaFoundation: {
   15946           10 :                         delayOpaque(LoadCompRow::GrdFlr) += singleSurfDelay;
   15947           10 :                     } break;
   15948            0 :                     case DataSurfaces::OtherSideCoefNoCalcExt:
   15949              :                     case DataSurfaces::OtherSideCoefCalcExt:
   15950              :                     case DataSurfaces::OtherSideCondModeledExt: {
   15951            0 :                         delayOpaque(LoadCompRow::OtherFlr) += singleSurfDelay;
   15952            0 :                     } break;
   15953           10 :                     default: { // interzone
   15954           10 :                         delayOpaque(LoadCompRow::IntZonFlr) += singleSurfDelay;
   15955           10 :                     } break;
   15956              :                     }
   15957           20 :                 } break;
   15958           20 :                 case DataSurfaces::SurfaceClass::Roof: {
   15959           20 :                     switch (curExtBoundCond) {
   15960           20 :                     case DataSurfaces::ExternalEnvironment: {
   15961           20 :                         delayOpaque(LoadCompRow::Roof) += singleSurfDelay;
   15962           20 :                     } break;
   15963            0 :                     case DataSurfaces::Ground:
   15964              :                     case DataSurfaces::GroundFCfactorMethod:
   15965              :                     case DataSurfaces::KivaFoundation:
   15966              :                     case DataSurfaces::OtherSideCoefNoCalcExt:
   15967              :                     case DataSurfaces::OtherSideCoefCalcExt:
   15968              :                     case DataSurfaces::OtherSideCondModeledExt: {
   15969            0 :                         delayOpaque(LoadCompRow::OtherRoof) += singleSurfDelay;
   15970            0 :                     } break;
   15971            0 :                     default: { // interzone
   15972            0 :                         delayOpaque(LoadCompRow::IntZonCeil) += singleSurfDelay;
   15973            0 :                     } break;
   15974              :                     }
   15975           20 :                 } break;
   15976            0 :                 case DataSurfaces::SurfaceClass::Door: {
   15977            0 :                     delayOpaque(LoadCompRow::OpqDoor) += singleSurfDelay;
   15978            0 :                 } break;
   15979           10 :                 default:
   15980           10 :                     break;
   15981              :                 }
   15982              :             }
   15983              :         }
   15984          264 :         for (int k = LoadCompRow::Roof; k <= LoadCompRow::OtherFlr; ++k) {
   15985          242 :             resultCells(LoadCompCol::SensDelay, k) = delayOpaque(k);
   15986          242 :             resCellsUsd(LoadCompCol::SensDelay, k) = true;
   15987              :         }
   15988           22 :         resultCells(LoadCompCol::SensDelay, LoadCompRow::OpqDoor) = delayOpaque(LoadCompRow::OpqDoor);
   15989           22 :         resCellsUsd(LoadCompCol::SensDelay, LoadCompRow::OpqDoor) = true;
   15990              :     }
   15991           24 : }
   15992              : 
   15993              : // for the load summary report add values the peak conditions subtable
   15994           25 : void CollectPeakZoneConditions(EnergyPlusData &state,
   15995              :                                CompLoadTablesType &compLoad,
   15996              :                                int const desDaySelected,
   15997              :                                int const timeOfMax,
   15998              :                                int const zoneIndex,
   15999              :                                bool const isCooling,
   16000              :                                int const spaceIndex)
   16001              : {
   16002              : 
   16003           25 :     if (timeOfMax != 0) {
   16004              : 
   16005           23 :         auto const &thisZone = state.dataHeatBal->Zone(zoneIndex);
   16006           23 :         Real64 mult = thisZone.Multiplier * thisZone.ListMultiplier;
   16007              :         auto const &szCalcFinalSizing =
   16008           23 :             (spaceIndex == 0) ? state.dataSize->CalcFinalZoneSizing(zoneIndex) : state.dataSize->CalcFinalSpaceSizing(spaceIndex);
   16009           23 :         auto const &szFinalSizing = (spaceIndex == 0) ? state.dataSize->FinalZoneSizing(zoneIndex) : state.dataSize->FinalSpaceSizing(spaceIndex);
   16010              : 
   16011           23 :         if (mult == 0.0) mult = 1.0;
   16012              : 
   16013           23 :         if (isCooling) {
   16014              :             // Time of Peak Load
   16015           12 :             if ((desDaySelected > 0) && ((size_t)desDaySelected <= state.dataWeather->DesDayInput.size())) {
   16016           36 :                 compLoad.peakDateHrMin = format("{}/{} {}",
   16017           12 :                                                 state.dataWeather->DesDayInput(desDaySelected).Month,
   16018           12 :                                                 state.dataWeather->DesDayInput(desDaySelected).DayOfMonth,
   16019           24 :                                                 state.dataRptCoilSelection->coilSelectionReportObj->getTimeText(state, timeOfMax));
   16020              :             } else {
   16021            0 :                 compLoad.peakDateHrMin = szCalcFinalSizing.CoolPeakDateHrMin;
   16022              :             }
   16023              : 
   16024              :             // Outside Dry Bulb Temperature
   16025           12 :             compLoad.outsideDryBulb = szCalcFinalSizing.CoolOutTempSeq(timeOfMax);
   16026              : 
   16027              :             // Outside Wet Bulb Temperature
   16028              :             // use standard air pressure because air pressure is not tracked with sizing data
   16029           12 :             if (szCalcFinalSizing.CoolOutHumRatSeq(timeOfMax) < 1.0 && szCalcFinalSizing.CoolOutHumRatSeq(timeOfMax) > 0.0) {
   16030           24 :                 compLoad.outsideWetBulb = Psychrometrics::PsyTwbFnTdbWPb(
   16031           12 :                     state, szCalcFinalSizing.CoolOutTempSeq(timeOfMax), szCalcFinalSizing.CoolOutHumRatSeq(timeOfMax), state.dataEnvrn->StdBaroPress);
   16032              :             }
   16033              : 
   16034              :             // Outside Humidity Ratio at Peak
   16035           12 :             compLoad.outsideHumRatio = szCalcFinalSizing.CoolOutHumRatSeq(timeOfMax);
   16036              : 
   16037              :             // Zone Dry Bulb Temperature
   16038           12 :             compLoad.zoneDryBulb = szCalcFinalSizing.CoolZoneTempSeq(timeOfMax);
   16039              : 
   16040              :             // Zone Relative Humidity
   16041              :             // use standard air pressure because air pressure is not tracked with sizing data
   16042           12 :             compLoad.zoneRelHum = Psychrometrics::PsyRhFnTdbWPb(
   16043           12 :                 state, szCalcFinalSizing.CoolZoneTempSeq(timeOfMax), szCalcFinalSizing.CoolZoneHumRatSeq(timeOfMax), state.dataEnvrn->StdBaroPress);
   16044              : 
   16045              :             // Zone Humidity Ratio at Peak
   16046           12 :             compLoad.zoneHumRatio = szCalcFinalSizing.CoolZoneHumRatSeq(timeOfMax);
   16047              : 
   16048              :             // Peak Design Sensible Load
   16049           12 :             compLoad.peakDesSensLoad = szCalcFinalSizing.DesCoolLoad / mult; // change sign
   16050              : 
   16051              :             // Design Peak Load
   16052           12 :             compLoad.designPeakLoad = szFinalSizing.DesCoolLoad / mult;
   16053              : 
   16054              :             // Supply air temperature
   16055           12 :             if (szCalcFinalSizing.ZnCoolDgnSAMethod == DataSizing::SupplyAirTemperature) {
   16056           12 :                 compLoad.supAirTemp = szCalcFinalSizing.CoolDesTemp;
   16057              :             } else {
   16058            0 :                 Real64 DeltaTemp = -std::abs(szCalcFinalSizing.CoolDesTempDiff);
   16059            0 :                 compLoad.supAirTemp = DeltaTemp + szCalcFinalSizing.ZoneTempAtCoolPeak;
   16060              :             }
   16061              : 
   16062              :             // Main fan air flow
   16063           12 :             compLoad.mainFanAirFlow = szCalcFinalSizing.DesCoolVolFlow;
   16064              : 
   16065              :         } else {
   16066              :             // Time of Peak Load
   16067           11 :             if ((size_t)desDaySelected <= state.dataWeather->DesDayInput.size()) {
   16068           33 :                 compLoad.peakDateHrMin = format("{}/{} {}",
   16069           11 :                                                 state.dataWeather->DesDayInput(desDaySelected).Month,
   16070           11 :                                                 state.dataWeather->DesDayInput(desDaySelected).DayOfMonth,
   16071           22 :                                                 state.dataRptCoilSelection->coilSelectionReportObj->getTimeText(state, timeOfMax));
   16072              :             } else {
   16073            0 :                 compLoad.peakDateHrMin = szCalcFinalSizing.HeatPeakDateHrMin;
   16074              :             }
   16075              : 
   16076              :             // Outside Dry Bulb Temperature
   16077           11 :             compLoad.outsideDryBulb = szCalcFinalSizing.HeatOutTempSeq(timeOfMax);
   16078              : 
   16079              :             // Outside Wet Bulb Temperature
   16080              :             // use standard air pressure because air pressure is not tracked with sizing data
   16081           11 :             if (szCalcFinalSizing.HeatOutHumRatSeq(timeOfMax) < 1.0 && szCalcFinalSizing.HeatOutHumRatSeq(timeOfMax) > 0.0) {
   16082           22 :                 compLoad.outsideWetBulb = Psychrometrics::PsyTwbFnTdbWPb(
   16083           11 :                     state, szCalcFinalSizing.HeatOutTempSeq(timeOfMax), szCalcFinalSizing.HeatOutHumRatSeq(timeOfMax), state.dataEnvrn->StdBaroPress);
   16084              :             }
   16085              : 
   16086              :             // Outside Humidity Ratio at Peak
   16087           11 :             compLoad.outsideHumRatio = szCalcFinalSizing.HeatOutHumRatSeq(timeOfMax);
   16088              : 
   16089              :             // Zone Dry Bulb Temperature
   16090           11 :             compLoad.zoneDryBulb = szCalcFinalSizing.HeatZoneTempSeq(timeOfMax);
   16091              : 
   16092              :             // Zone Relative Humidity
   16093              :             // use standard air pressure because air pressure is not tracked with sizing data
   16094           11 :             compLoad.zoneRelHum = Psychrometrics::PsyRhFnTdbWPb(
   16095           11 :                 state, szCalcFinalSizing.HeatZoneTempSeq(timeOfMax), szCalcFinalSizing.HeatZoneHumRatSeq(timeOfMax), state.dataEnvrn->StdBaroPress);
   16096              : 
   16097              :             // Zone Humidity Ratio at Peak
   16098           11 :             compLoad.zoneHumRatio = szCalcFinalSizing.HeatZoneHumRatSeq(timeOfMax);
   16099              : 
   16100              :             // Peak Design Sensible Load
   16101           11 :             compLoad.peakDesSensLoad = -szCalcFinalSizing.DesHeatLoad / mult; // change sign
   16102              : 
   16103              :             // Design Peak Load
   16104           11 :             compLoad.designPeakLoad = -szFinalSizing.DesHeatLoad / mult;
   16105              : 
   16106              :             // Supply air temperature
   16107           11 :             if (szCalcFinalSizing.ZnHeatDgnSAMethod == DataSizing::SupplyAirTemperature) {
   16108           11 :                 compLoad.supAirTemp = szCalcFinalSizing.HeatDesTemp;
   16109              :             } else {
   16110            0 :                 Real64 DeltaTemp = -std::abs(szCalcFinalSizing.HeatDesTempDiff);
   16111            0 :                 compLoad.supAirTemp = DeltaTemp + szCalcFinalSizing.ZoneTempAtHeatPeak;
   16112              :             }
   16113              : 
   16114              :             // Main fan air flow
   16115           11 :             compLoad.mainFanAirFlow = szCalcFinalSizing.DesHeatVolFlow;
   16116              :         }
   16117              : 
   16118              :         // Outside air flow
   16119           23 :         compLoad.outsideAirFlow = szCalcFinalSizing.MinOA;
   16120              : 
   16121              :         // outside air %
   16122           23 :         if (compLoad.mainFanAirFlow != 0.) {
   16123           21 :             compLoad.outsideAirRatio = compLoad.outsideAirFlow / compLoad.mainFanAirFlow;
   16124              :         }
   16125              : 
   16126           23 :         compLoad.floorArea = thisZone.FloorArea;
   16127              : 
   16128           23 :         if (compLoad.floorArea != 0.) {
   16129              :             // airflow per floor area
   16130           23 :             compLoad.airflowPerFlrArea = compLoad.mainFanAirFlow / compLoad.floorArea;
   16131              : 
   16132              :             // capacity per floor area
   16133           23 :             compLoad.totCapPerArea = compLoad.designPeakLoad / compLoad.floorArea;
   16134              :         }
   16135           23 :         if (compLoad.designPeakLoad != 0.) {
   16136              :             // airflow per capacity
   16137           21 :             compLoad.airflowPerTotCap = compLoad.mainFanAirFlow / compLoad.designPeakLoad;
   16138              : 
   16139              :             // floor area per capacity
   16140           21 :             compLoad.areaPerTotCap = thisZone.FloorArea / compLoad.designPeakLoad;
   16141              :         }
   16142              : 
   16143              :         // Number of people
   16144           23 :         Real64 totNumPeople = 0;
   16145           23 :         if (spaceIndex == 0) {
   16146           23 :             totNumPeople = std::accumulate(state.dataHeatBal->People.cbegin(),
   16147           23 :                                            state.dataHeatBal->People.cend(),
   16148              :                                            0.0,
   16149           24 :                                            [&zoneIndex](const Real64 &sum, const DataHeatBalance::PeopleData &people) {
   16150           24 :                                                return zoneIndex == people.ZonePtr ? (sum + people.NumberOfPeople) : sum;
   16151              :                                            });
   16152              :         } else {
   16153            0 :             totNumPeople = std::accumulate(state.dataHeatBal->People.cbegin(),
   16154            0 :                                            state.dataHeatBal->People.cend(),
   16155              :                                            0.0,
   16156            0 :                                            [&spaceIndex](const Real64 &sum, const DataHeatBalance::PeopleData &people) {
   16157            0 :                                                return spaceIndex == people.spaceIndex ? (sum + people.NumberOfPeople) : sum;
   16158              :                                            });
   16159              :         }
   16160           23 :         compLoad.numPeople = totNumPeople;
   16161              :     }
   16162           25 : }
   16163              : 
   16164           23 : void ComputeEngineeringChecks(CompLoadTablesType &compLoad)
   16165              : {
   16166              :     // outside air %
   16167           23 :     if (compLoad.mainFanAirFlow != 0.) {
   16168           16 :         compLoad.outsideAirRatio = compLoad.outsideAirFlow / compLoad.mainFanAirFlow;
   16169              :     }
   16170              : 
   16171           23 :     if (compLoad.floorArea != 0.) {
   16172              :         // airflow per floor area
   16173           17 :         compLoad.airflowPerFlrArea = compLoad.mainFanAirFlow / compLoad.floorArea;
   16174              : 
   16175              :         // capacity per floor area
   16176           17 :         compLoad.totCapPerArea = compLoad.designPeakLoad / compLoad.floorArea;
   16177              :     }
   16178           23 :     if (compLoad.designPeakLoad != 0.) {
   16179              :         // airflow per capacity
   16180           13 :         compLoad.airflowPerTotCap = compLoad.mainFanAirFlow / compLoad.designPeakLoad;
   16181              : 
   16182              :         // floor area per capacity
   16183           13 :         compLoad.areaPerTotCap = compLoad.floorArea / compLoad.designPeakLoad;
   16184              :     }
   16185           23 : }
   16186              : 
   16187              : // gather the areas used in the load component tables
   16188            8 : void GetZoneComponentAreas(EnergyPlusData &state, Array1D<ZompComponentAreasType> &znAreas, Array1D<ZompComponentAreasType> &spAreas)
   16189              : {
   16190           15 :     for (int iZone = 1; iZone <= state.dataGlobal->NumOfZones; ++iZone) {
   16191            7 :         znAreas(iZone).floor = state.dataHeatBal->Zone(iZone).FloorArea;
   16192              :     }
   16193            8 :     if (state.dataHeatBal->doSpaceHeatBalanceSizing) {
   16194            0 :         for (int iSpace = 1; iSpace <= state.dataGlobal->numSpaces; ++iSpace) {
   16195            0 :             spAreas(iSpace).floor = state.dataHeatBal->space(iSpace).FloorArea;
   16196              :         }
   16197              :     }
   16198              : 
   16199            8 :     bool isZone = true;
   16200           54 :     for (auto const &curSurface : state.dataSurface->Surface) {
   16201           46 :         if (!curSurface.HeatTransSurf) continue;
   16202           46 :         addSurfaceArea(curSurface, znAreas, isZone);
   16203              :     }
   16204            8 :     if (state.dataHeatBal->doSpaceHeatBalanceSizing) {
   16205            0 :         isZone = false;
   16206            0 :         for (auto const &curSurface : state.dataSurface->Surface) {
   16207            0 :             addSurfaceArea(curSurface, spAreas, isZone);
   16208              :         }
   16209              :     }
   16210            8 : }
   16211           46 : void addSurfaceArea(DataSurfaces::SurfaceData const &surf, Array1D<ZompComponentAreasType> &areas, bool isZone)
   16212              : {
   16213           46 :     bool isExterior = surf.ExtBoundCond == DataSurfaces::ExternalEnvironment || surf.ExtBoundCond == DataSurfaces::OtherSideCondModeledExt;
   16214           88 :     bool isTouchingGround = surf.ExtBoundCond == DataSurfaces::Ground || surf.ExtBoundCond == DataSurfaces::GroundFCfactorMethod ||
   16215           42 :                             surf.ExtBoundCond == DataSurfaces::KivaFoundation;
   16216           46 :     int curIndex = (isZone) ? surf.Zone : surf.spaceNum;
   16217           46 :     switch (surf.Class) {
   16218           23 :     case DataSurfaces::SurfaceClass::Wall: {
   16219           23 :         if (isExterior) {
   16220           15 :             areas(curIndex).extWall += surf.GrossArea;
   16221            8 :         } else if (isTouchingGround) {
   16222            1 :             areas(curIndex).grndCntWall += surf.GrossArea;
   16223              :         } else {
   16224            7 :             areas(curIndex).intZoneWall += surf.GrossArea;
   16225              :         }
   16226           23 :     } break;
   16227            7 :     case DataSurfaces::SurfaceClass::Roof: {
   16228            7 :         if (isExterior) {
   16229            6 :             areas(curIndex).roof += surf.GrossArea;
   16230              :         } else {
   16231            1 :             areas(curIndex).ceiling += surf.GrossArea;
   16232              :         }
   16233            7 :     } break;
   16234            9 :     case DataSurfaces::SurfaceClass::Floor: {
   16235            9 :         if (isExterior) {
   16236            1 :             areas(curIndex).extFloor += surf.GrossArea;
   16237            8 :         } else if (isTouchingGround) {
   16238            4 :             areas(curIndex).grndCntFloor += surf.GrossArea;
   16239              :         } else {
   16240            4 :             areas(curIndex).intZoneFloor += surf.GrossArea;
   16241              :         }
   16242            9 :     } break;
   16243            5 :     case DataSurfaces::SurfaceClass::Window:
   16244              :     case DataSurfaces::SurfaceClass::TDD_Dome: {
   16245            5 :         areas(curIndex).fenestration += surf.GrossArea;
   16246            5 :     } break;
   16247            2 :     case DataSurfaces::SurfaceClass::Door:
   16248              :     case DataSurfaces::SurfaceClass::GlassDoor: {
   16249            2 :         areas(curIndex).door += surf.GrossArea;
   16250            2 :     } break;
   16251              :     }
   16252           46 : }
   16253              : 
   16254              : // adds the area column for the load component tables
   16255           24 : void AddAreaColumnForZone(ZompComponentAreasType const &compAreas, CompLoadTablesType &compLoad)
   16256              : {
   16257           24 :     compLoad.cells(LoadCompCol::Area, LoadCompRow::People) = compAreas.floor;
   16258           24 :     compLoad.cellUsed(LoadCompCol::Area, LoadCompRow::People) = true;
   16259              : 
   16260           24 :     compLoad.cells(LoadCompCol::Area, LoadCompRow::Lights) = compAreas.floor;
   16261           24 :     compLoad.cellUsed(LoadCompCol::Area, LoadCompRow::Lights) = true;
   16262              : 
   16263           24 :     compLoad.cells(LoadCompCol::Area, LoadCompRow::Equip) = compAreas.floor;
   16264           24 :     compLoad.cellUsed(LoadCompCol::Area, LoadCompRow::Equip) = true;
   16265              : 
   16266           24 :     compLoad.cells(LoadCompCol::Area, LoadCompRow::Refrig) = compAreas.floor;
   16267           24 :     compLoad.cellUsed(LoadCompCol::Area, LoadCompRow::Refrig) = true;
   16268              : 
   16269           24 :     compLoad.cells(LoadCompCol::Area, LoadCompRow::WaterUse) = compAreas.floor;
   16270           24 :     compLoad.cellUsed(LoadCompCol::Area, LoadCompRow::WaterUse) = true;
   16271              : 
   16272           24 :     compLoad.cells(LoadCompCol::Area, LoadCompRow::Infil) = compAreas.extWall;
   16273           24 :     compLoad.cellUsed(LoadCompCol::Area, LoadCompRow::Infil) = true;
   16274              : 
   16275           24 :     compLoad.cells(LoadCompCol::Area, LoadCompRow::Roof) = compAreas.roof;
   16276           24 :     compLoad.cellUsed(LoadCompCol::Area, LoadCompRow::Roof) = true;
   16277              : 
   16278           24 :     compLoad.cells(LoadCompCol::Area, LoadCompRow::IntZonCeil) = compAreas.ceiling;
   16279           24 :     compLoad.cellUsed(LoadCompCol::Area, LoadCompRow::IntZonCeil) = true;
   16280              : 
   16281           24 :     compLoad.cells(LoadCompCol::Area, LoadCompRow::OtherRoof) = compAreas.roof;
   16282           24 :     compLoad.cellUsed(LoadCompCol::Area, LoadCompRow::OtherRoof) = true;
   16283              : 
   16284           24 :     compLoad.cells(LoadCompCol::Area, LoadCompRow::ExtWall) = compAreas.extWall;
   16285           24 :     compLoad.cellUsed(LoadCompCol::Area, LoadCompRow::ExtWall) = true;
   16286              : 
   16287           24 :     compLoad.cells(LoadCompCol::Area, LoadCompRow::IntZonWall) = compAreas.intZoneWall;
   16288           24 :     compLoad.cellUsed(LoadCompCol::Area, LoadCompRow::IntZonWall) = true;
   16289              : 
   16290           24 :     compLoad.cells(LoadCompCol::Area, LoadCompRow::GrdWall) = compAreas.grndCntWall;
   16291           24 :     compLoad.cellUsed(LoadCompCol::Area, LoadCompRow::GrdWall) = true;
   16292              : 
   16293           24 :     compLoad.cells(LoadCompCol::Area, LoadCompRow::OtherWall) = compAreas.extWall;
   16294           24 :     compLoad.cellUsed(LoadCompCol::Area, LoadCompRow::OtherWall) = true;
   16295              : 
   16296           24 :     compLoad.cells(LoadCompCol::Area, LoadCompRow::ExtFlr) = compAreas.extFloor;
   16297           24 :     compLoad.cellUsed(LoadCompCol::Area, LoadCompRow::ExtFlr) = true;
   16298              : 
   16299           24 :     compLoad.cells(LoadCompCol::Area, LoadCompRow::IntZonFlr) = compAreas.intZoneFloor;
   16300           24 :     compLoad.cellUsed(LoadCompCol::Area, LoadCompRow::IntZonFlr) = true;
   16301              : 
   16302           24 :     compLoad.cells(LoadCompCol::Area, LoadCompRow::GrdFlr) = compAreas.grndCntFloor;
   16303           24 :     compLoad.cellUsed(LoadCompCol::Area, LoadCompRow::GrdFlr) = true;
   16304              : 
   16305           24 :     compLoad.cells(LoadCompCol::Area, LoadCompRow::OtherFlr) = compAreas.intZoneFloor;
   16306           24 :     compLoad.cellUsed(LoadCompCol::Area, LoadCompRow::OtherFlr) = true;
   16307              : 
   16308           24 :     compLoad.cells(LoadCompCol::Area, LoadCompRow::FeneCond) = compAreas.fenestration;
   16309           24 :     compLoad.cellUsed(LoadCompCol::Area, LoadCompRow::FeneCond) = true;
   16310              : 
   16311           24 :     compLoad.cells(LoadCompCol::Area, LoadCompRow::FeneSolr) = compAreas.fenestration;
   16312           24 :     compLoad.cellUsed(LoadCompCol::Area, LoadCompRow::FeneSolr) = true;
   16313              : 
   16314           24 :     compLoad.cells(LoadCompCol::Area, LoadCompRow::OpqDoor) = compAreas.door;
   16315           24 :     compLoad.cellUsed(LoadCompCol::Area, LoadCompRow::OpqDoor) = true;
   16316           24 : }
   16317              : 
   16318              : // Used for the AirLoop and Facility level load component tables to sum the results from individual zones
   16319           23 : void CombineLoadCompResults(CompLoadTablesType &compLoadTotal, CompLoadTablesType const &compLoadPartial, Real64 const multiplier)
   16320              : {
   16321              :     // sum the main results
   16322          207 :     for (int col = 1; col <= LoadCompCol::PerArea; ++col) {
   16323         4968 :         for (int row = 1; row <= LoadCompRow::GrdTot; ++row) {
   16324         4784 :             compLoadTotal.cells(col, row) += compLoadPartial.cells(col, row) * multiplier;
   16325         4784 :             compLoadTotal.cellUsed(col, row) = compLoadTotal.cellUsed(col, row) || compLoadPartial.cellUsed(col, row);
   16326              :         }
   16327              :     }
   16328              : 
   16329              :     // take the partial value for these
   16330           23 :     compLoadTotal.desDayNum = compLoadPartial.desDayNum;
   16331           23 :     compLoadTotal.timeStepMax = compLoadPartial.timeStepMax;
   16332           23 :     compLoadTotal.peakDateHrMin = compLoadPartial.peakDateHrMin;
   16333           23 :     compLoadTotal.outsideDryBulb = compLoadPartial.outsideDryBulb;
   16334           23 :     compLoadTotal.outsideWetBulb = compLoadPartial.outsideWetBulb;
   16335           23 :     compLoadTotal.outsideHumRatio = compLoadPartial.outsideHumRatio;
   16336           23 :     compLoadTotal.zoneDryBulb = compLoadPartial.zoneDryBulb;
   16337           23 :     compLoadTotal.zoneRelHum = compLoadPartial.zoneRelHum;
   16338           23 :     compLoadTotal.zoneHumRatio = compLoadPartial.zoneHumRatio;
   16339           23 :     compLoadTotal.supAirTemp = compLoadPartial.supAirTemp;
   16340              : 
   16341              :     // sum the peak related values
   16342           23 :     compLoadTotal.designPeakLoad += compLoadPartial.designPeakLoad * multiplier;
   16343           23 :     compLoadTotal.diffDesignPeak += compLoadPartial.diffDesignPeak * multiplier;
   16344           23 :     compLoadTotal.peakDesSensLoad += compLoadPartial.peakDesSensLoad * multiplier;
   16345           23 :     compLoadTotal.estInstDelSensLoad += compLoadPartial.estInstDelSensLoad * multiplier;
   16346           23 :     compLoadTotal.diffPeakEst += compLoadPartial.diffPeakEst * multiplier;
   16347           23 :     compLoadTotal.mainFanAirFlow += compLoadPartial.mainFanAirFlow * multiplier;
   16348           23 :     compLoadTotal.outsideAirFlow += compLoadPartial.outsideAirFlow * multiplier;
   16349              : 
   16350              :     // sum the engineering checks
   16351           23 :     compLoadTotal.numPeople += compLoadPartial.numPeople * multiplier;
   16352           23 :     compLoadTotal.floorArea += compLoadPartial.floorArea * multiplier;
   16353           23 : }
   16354              : 
   16355              : // create the total row and total columns for the load summary tables
   16356           35 : void AddTotalRowsForLoadSummary(CompLoadTablesType &compLoadTotal)
   16357              : {
   16358              : 
   16359              :     // zero the grand total -total cell
   16360           35 :     compLoadTotal.cells(LoadCompCol::Total, LoadCompRow::GrdTot) = 0.;
   16361           35 :     compLoadTotal.cellUsed(LoadCompCol::Total, LoadCompRow::GrdTot) = true;
   16362              : 
   16363              :     // zero the grand total row
   16364          175 :     for (int col = 1; col <= LoadCompCol::Latent; ++col) {
   16365          140 :         compLoadTotal.cells(col, LoadCompRow::GrdTot) = 0.;
   16366          140 :         compLoadTotal.cellUsed(col, LoadCompRow::GrdTot) = true;
   16367              :     }
   16368              : 
   16369          910 :     for (int row = 1; row <= LoadCompRow::OpqDoor; ++row) {
   16370              :         // zero the total column
   16371          875 :         compLoadTotal.cells(LoadCompCol::Total, row) = 0.;
   16372          875 :         compLoadTotal.cellUsed(LoadCompCol::Total, row) = true;
   16373         4375 :         for (int col = 1; col <= LoadCompCol::Latent; ++col) {
   16374              :             // add the cell to the grand total row and total column
   16375         3500 :             if (compLoadTotal.cellUsed(col, row)) {
   16376         1220 :                 compLoadTotal.cells(LoadCompCol::Total, row) += compLoadTotal.cells(col, row);
   16377         1220 :                 compLoadTotal.cells(col, LoadCompRow::GrdTot) += compLoadTotal.cells(col, row);
   16378         1220 :                 compLoadTotal.cells(LoadCompCol::Total, LoadCompRow::GrdTot) += compLoadTotal.cells(col, row);
   16379              :             }
   16380              :         }
   16381              :     }
   16382              : 
   16383              :     // compute the % grand total column
   16384           35 :     Real64 grandTotalTotal = compLoadTotal.cells(LoadCompCol::Total, LoadCompRow::GrdTot);
   16385           35 :     if (grandTotalTotal != 0.0) {
   16386          598 :         for (int row = 1; row <= LoadCompRow::OpqDoor; ++row) {
   16387          575 :             compLoadTotal.cells(LoadCompCol::Perc, row) = 100 * compLoadTotal.cells(LoadCompCol::Total, row) / grandTotalTotal;
   16388          575 :             compLoadTotal.cellUsed(LoadCompCol::Perc, row) = true;
   16389              :         }
   16390              :     }
   16391              :     // compute the Total per Area column
   16392          910 :     for (int row = 1; row <= LoadCompRow::OpqDoor; ++row) {
   16393          875 :         if (compLoadTotal.cellUsed(LoadCompCol::Total, row) && compLoadTotal.cells(LoadCompCol::Area, row) != 0.) {
   16394          704 :             compLoadTotal.cells(LoadCompCol::PerArea, row) =
   16395          352 :                 compLoadTotal.cells(LoadCompCol::Total, row) / compLoadTotal.cells(LoadCompCol::Area, row);
   16396          352 :             compLoadTotal.cellUsed(LoadCompCol::PerArea, row) = true;
   16397              :         }
   16398              :     }
   16399           35 : }
   16400              : 
   16401              : // compute the peak difference between actual and estimated load in load component summary peak conditions table
   16402           34 : void ComputePeakDifference(CompLoadTablesType &compLoad)
   16403              : {
   16404              :     // Estimated Instant + Delayed Sensible Load
   16405           34 :     compLoad.estInstDelSensLoad =
   16406           34 :         compLoad.cells(LoadCompCol::SensInst, LoadCompRow::GrdTot) + compLoad.cells(LoadCompCol::SensDelay, LoadCompRow::GrdTot);
   16407              : 
   16408              :     // Difference
   16409           34 :     compLoad.diffPeakEst = compLoad.peakDesSensLoad - compLoad.estInstDelSensLoad;
   16410              : 
   16411              :     // Peak Design Diff
   16412           34 :     compLoad.diffDesignPeak = compLoad.designPeakLoad - compLoad.peakDesSensLoad;
   16413           34 : }
   16414              : 
   16415              : // apply unit conversions to the load components summary tables
   16416            1 : void LoadSummaryUnitConversion(EnergyPlusData &state, CompLoadTablesType &compLoadTotal)
   16417              : {
   16418            1 :     auto const &ort = state.dataOutRptTab;
   16419              : 
   16420            1 :     if (!ort->ip()) {
   16421            0 :         return;
   16422              :     }
   16423              : 
   16424            4 :     Real64 const powerConversion = getSpecificUnitMultiplier(state, "W", "Btu/h");
   16425            4 :     Real64 const areaConversion = getSpecificUnitMultiplier(state, "m2", "ft2");
   16426            4 :     Real64 const powerPerAreaConversion = getSpecificUnitMultiplier(state, "W/m2", "Btu/h-ft2");
   16427            4 :     Real64 const airFlowConversion = getSpecificUnitMultiplier(state, "m3/s", "ft3/min");
   16428            4 :     Real64 const airFlowPerAreaConversion = getSpecificUnitMultiplier(state, "m3/s-m2", "ft3/min-ft2");
   16429            3 :     Real64 const powerPerFlowLiquidConversion = getSpecificUnitMultiplier(state, "W-s/m3", "W-min/gal");
   16430           27 :     for (int row = 1; row <= LoadCompRow::GrdTot; ++row) {
   16431          156 :         for (int col = 1; col <= LoadCompCol::Total; ++col) {
   16432          130 :             if (compLoadTotal.cellUsed(col, row)) {
   16433          130 :                 compLoadTotal.cells(col, row) *= powerConversion;
   16434              :             }
   16435              :         }
   16436           26 :         if (compLoadTotal.cellUsed(LoadCompCol::PerArea, row)) {
   16437           26 :             compLoadTotal.cells(LoadCompCol::PerArea, row) *= powerConversion;
   16438              :         }
   16439           26 :         if (compLoadTotal.cellUsed(LoadCompCol::Area, row)) {
   16440           26 :             compLoadTotal.cells(LoadCompCol::Area, row) *= areaConversion;
   16441              :         }
   16442           26 :         if (compLoadTotal.cellUsed(LoadCompCol::PerArea, row)) {
   16443           26 :             compLoadTotal.cells(LoadCompCol::PerArea, row) *= powerPerAreaConversion;
   16444              :         }
   16445              :     }
   16446            3 :     int const tempConvIndx = getSpecificUnitIndex(state, "C", "F");
   16447            1 :     compLoadTotal.outsideDryBulb = ConvertIP(state, tempConvIndx, compLoadTotal.outsideDryBulb);
   16448            1 :     compLoadTotal.outsideWetBulb = ConvertIP(state, tempConvIndx, compLoadTotal.outsideWetBulb);
   16449            1 :     compLoadTotal.zoneDryBulb = ConvertIP(state, tempConvIndx, compLoadTotal.zoneDryBulb);
   16450            1 :     compLoadTotal.peakDesSensLoad *= powerConversion;
   16451              : 
   16452            1 :     compLoadTotal.supAirTemp = ConvertIP(state, tempConvIndx, compLoadTotal.supAirTemp);
   16453            1 :     compLoadTotal.mixAirTemp = ConvertIP(state, tempConvIndx, compLoadTotal.mixAirTemp);
   16454            1 :     compLoadTotal.mainFanAirFlow *= airFlowConversion;
   16455            1 :     compLoadTotal.outsideAirFlow *= airFlowConversion;
   16456            1 :     compLoadTotal.designPeakLoad *= powerConversion;
   16457            1 :     compLoadTotal.diffDesignPeak *= powerConversion;
   16458              : 
   16459            1 :     compLoadTotal.estInstDelSensLoad *= powerConversion;
   16460            1 :     compLoadTotal.diffPeakEst *= powerConversion;
   16461              : 
   16462            1 :     compLoadTotal.airflowPerFlrArea *= airFlowPerAreaConversion;
   16463            1 :     if (powerConversion != 0.) {
   16464            1 :         compLoadTotal.airflowPerTotCap = compLoadTotal.airflowPerTotCap * airFlowPerAreaConversion / powerConversion;
   16465            1 :         compLoadTotal.areaPerTotCap = compLoadTotal.areaPerTotCap * areaConversion / powerConversion;
   16466              :     }
   16467            1 :     if (areaConversion != 0.) {
   16468            1 :         compLoadTotal.totCapPerArea = compLoadTotal.totCapPerArea * powerConversion / areaConversion;
   16469              :     }
   16470            1 :     compLoadTotal.chlPumpPerFlow *= powerPerFlowLiquidConversion;
   16471            1 :     compLoadTotal.cndPumpPerFlow *= powerPerFlowLiquidConversion;
   16472              : }
   16473              : 
   16474              : // Jan 2021: Overloaded the function with additional parameters for dual units;
   16475              : //           used overloading since the original function was checked in an existing test unit.
   16476              : // apply unit conversions to the load components summary tables
   16477           35 : void LoadSummaryUnitConversion(EnergyPlusData &state, CompLoadTablesType &compLoadTotal, UnitsStyle unitsStyle_para)
   16478              : {
   16479           35 :     if (unitsStyle_para == OutputReportTabular::UnitsStyle::InchPound ||
   16480              :         unitsStyle_para == OutputReportTabular::UnitsStyle::InchPoundExceptElectricity) {
   16481           52 :         Real64 powerConversion = getSpecificUnitMultiplier(state, "W", "Btu/h");
   16482           52 :         Real64 areaConversion = getSpecificUnitMultiplier(state, "m2", "ft2");
   16483           52 :         Real64 powerPerAreaConversion = getSpecificUnitMultiplier(state, "W/m2", "Btu/h-ft2");
   16484           52 :         Real64 airFlowConversion = getSpecificUnitMultiplier(state, "m3/s", "ft3/min");
   16485           52 :         Real64 airFlowPerAreaConversion = getSpecificUnitMultiplier(state, "m3/s-m2", "ft3/min-ft2");
   16486           39 :         Real64 powerPerFlowLiquidConversion = getSpecificUnitMultiplier(state, "W-s/m3", "W-min/gal");
   16487          351 :         for (int row = 1; row <= LoadCompRow::GrdTot; ++row) {
   16488         2028 :             for (int col = 1; col <= LoadCompCol::Total; ++col) {
   16489         1690 :                 if (compLoadTotal.cellUsed(col, row)) {
   16490          970 :                     compLoadTotal.cells(col, row) *= powerConversion;
   16491              :                 }
   16492              :             }
   16493          338 :             if (compLoadTotal.cellUsed(LoadCompCol::PerArea, row)) {
   16494          140 :                 compLoadTotal.cells(LoadCompCol::PerArea, row) *= powerConversion;
   16495              :             }
   16496          338 :             if (compLoadTotal.cellUsed(LoadCompCol::Area, row)) {
   16497          266 :                 compLoadTotal.cells(LoadCompCol::Area, row) *= areaConversion;
   16498              :             }
   16499          338 :             if (compLoadTotal.cellUsed(LoadCompCol::PerArea, row)) {
   16500          140 :                 compLoadTotal.cells(LoadCompCol::PerArea, row) *= powerPerAreaConversion;
   16501              :             }
   16502              :         }
   16503           39 :         int tempConvIndx = getSpecificUnitIndex(state, "C", "F");
   16504           13 :         compLoadTotal.outsideDryBulb = ConvertIP(state, tempConvIndx, compLoadTotal.outsideDryBulb);
   16505           13 :         compLoadTotal.outsideWetBulb = ConvertIP(state, tempConvIndx, compLoadTotal.outsideWetBulb);
   16506           13 :         compLoadTotal.zoneDryBulb = ConvertIP(state, tempConvIndx, compLoadTotal.zoneDryBulb);
   16507           13 :         compLoadTotal.peakDesSensLoad *= powerConversion;
   16508              : 
   16509           13 :         compLoadTotal.supAirTemp = ConvertIP(state, tempConvIndx, compLoadTotal.supAirTemp);
   16510           13 :         compLoadTotal.mixAirTemp = ConvertIP(state, tempConvIndx, compLoadTotal.mixAirTemp);
   16511           13 :         compLoadTotal.mainFanAirFlow *= airFlowConversion;
   16512           13 :         compLoadTotal.outsideAirFlow *= airFlowConversion;
   16513           13 :         compLoadTotal.designPeakLoad *= powerConversion;
   16514           13 :         compLoadTotal.diffDesignPeak *= powerConversion;
   16515              : 
   16516           13 :         compLoadTotal.estInstDelSensLoad *= powerConversion;
   16517           13 :         compLoadTotal.diffPeakEst *= powerConversion;
   16518              : 
   16519           13 :         compLoadTotal.airflowPerFlrArea *= airFlowPerAreaConversion;
   16520           13 :         if (powerConversion != 0.) {
   16521           13 :             compLoadTotal.airflowPerTotCap = compLoadTotal.airflowPerTotCap * airFlowPerAreaConversion / powerConversion;
   16522           13 :             compLoadTotal.areaPerTotCap = compLoadTotal.areaPerTotCap * areaConversion / powerConversion;
   16523              :         }
   16524           13 :         if (areaConversion != 0.) {
   16525           13 :             compLoadTotal.totCapPerArea = compLoadTotal.totCapPerArea * powerConversion / areaConversion;
   16526              :         }
   16527           13 :         compLoadTotal.chlPumpPerFlow *= powerPerFlowLiquidConversion;
   16528           13 :         compLoadTotal.cndPumpPerFlow *= powerPerFlowLiquidConversion;
   16529              :     }
   16530           35 : }
   16531              : 
   16532              : // make a list of the zones for the airloop component loads report
   16533           15 : void CreateListOfZonesForAirLoop(EnergyPlusData const &state, CompLoadTablesType &compLoad, Array1D_int const &zoneToAirLoop, int const curAirLoop)
   16534              : {
   16535           15 :     int counter = 0;
   16536           70 :     for (int zi = 1; zi <= state.dataGlobal->NumOfZones; ++zi) {
   16537           55 :         if (zoneToAirLoop(zi) == curAirLoop) {
   16538           25 :             ++counter;
   16539           25 :             compLoad.zoneIndices(counter) = zi;
   16540              :         }
   16541              :     }
   16542           15 : }
   16543              : 
   16544              : // Jan 2021: Added additional parameters to accommodate dual-unit reporting
   16545              : // provide output from the load component summary tables
   16546           17 : void OutputCompLoadSummary(EnergyPlusData &state,
   16547              :                            EnergyPlus::OutputReportTabular::OutputType const kind,
   16548              :                            CompLoadTablesType const &compLoadCool,
   16549              :                            CompLoadTablesType const &compLoadHeat,
   16550              :                            int const zoneOrAirLoopIndex,
   16551              :                            UnitsStyle unitsStyle_para,
   16552              :                            bool produceTabular_para,
   16553              :                            bool produceSQLite_para)
   16554              : {
   16555              : 
   16556           17 :     auto const &ort = state.dataOutRptTab;
   16557              : 
   16558           17 :     std::string reportName;
   16559           17 :     std::string zoneAirLoopFacilityName;
   16560           17 :     bool writeOutput = false;
   16561              : 
   16562           17 :     if (kind == OutputType::Space && ort->displayZoneComponentLoadSummary) {
   16563            0 :         reportName = "Space Component Load Summary";
   16564            0 :         zoneAirLoopFacilityName = state.dataHeatBal->space(zoneOrAirLoopIndex).Name;
   16565            0 :         writeOutput = true;
   16566           17 :     } else if (kind == OutputType::Zone && ort->displayZoneComponentLoadSummary) {
   16567            6 :         reportName = "Zone Component Load Summary";
   16568            6 :         zoneAirLoopFacilityName = state.dataHeatBal->Zone(zoneOrAirLoopIndex).Name;
   16569            6 :         writeOutput = true;
   16570           11 :     } else if (kind == OutputType::AirLoop && ort->displayAirLoopComponentLoadSummary) {
   16571            6 :         reportName = "AirLoop Component Load Summary";
   16572            6 :         zoneAirLoopFacilityName = state.dataSize->FinalSysSizing(zoneOrAirLoopIndex).AirPriLoopName;
   16573            6 :         writeOutput = true;
   16574            5 :     } else if (kind == OutputType::Facility && ort->displayFacilityComponentLoadSummary) {
   16575            5 :         reportName = "Facility Component Load Summary";
   16576            5 :         zoneAirLoopFacilityName = "Facility";
   16577            5 :         writeOutput = true;
   16578              :     } else {
   16579            0 :         writeOutput = false;
   16580              :     }
   16581              : 
   16582           17 :     if (!writeOutput) {
   16583            0 :         return;
   16584              :     }
   16585              : 
   16586           17 :     CompLoadTablesType curCompLoad;
   16587           17 :     Array1D_string columnHead;
   16588           17 :     Array1D_int columnWidth;
   16589           17 :     Array1D_string rowHead;
   16590           17 :     Array2D_string tableBody; //(row, column)
   16591              : 
   16592           17 :     if (produceTabular_para) {
   16593           16 :         WriteReportHeaders(state, reportName, zoneAirLoopFacilityName, OutputProcessor::StoreType::Average);
   16594              :     }
   16595           17 :     std::string peakLoadCompName;
   16596           17 :     std::string peakCondName;
   16597           17 :     std::string zonesIncludedName;
   16598           17 :     std::string engineeringCheckName;
   16599           51 :     for (int coolHeat = 1; coolHeat <= 2; ++coolHeat) {
   16600           34 :         tableBody.allocate(LoadCompCol::PerArea, LoadCompRow::GrdTot);
   16601           34 :         tableBody = "";
   16602           34 :         if (coolHeat == 1) {
   16603           17 :             curCompLoad = compLoadCool;
   16604           17 :             peakLoadCompName = "Estimated Cooling Peak Load Components";
   16605           17 :             peakCondName = "Cooling Peak Conditions";
   16606           17 :             zonesIncludedName = "Zones Included for Cooling";
   16607           17 :             engineeringCheckName = "Engineering Checks for Cooling";
   16608              :         } else {
   16609           17 :             curCompLoad = compLoadHeat;
   16610           17 :             peakLoadCompName = "Estimated Heating Peak Load Components";
   16611           17 :             peakCondName = "Heating Peak Conditions";
   16612           17 :             zonesIncludedName = "Zones Included for Heating";
   16613           17 :             engineeringCheckName = "Engineering Checks for Heating";
   16614              :         }
   16615              :         // move number array into string array
   16616          306 :         for (int c = 1; c <= LoadCompCol::PerArea; ++c) {
   16617         7344 :             for (int r = 1; r <= LoadCompRow::GrdTot; ++r) { // to last row before total
   16618         7072 :                 if (curCompLoad.cellUsed(c, r)) {
   16619         3640 :                     tableBody(c, r) = RealToStr(curCompLoad.cells(c, r), 2);
   16620              :                 }
   16621              :             }
   16622              :         }
   16623           34 :         rowHead.allocate(LoadCompRow::GrdTot);
   16624              :         // internal gains
   16625           34 :         rowHead(LoadCompRow::People) = "People";
   16626           34 :         rowHead(LoadCompRow::Lights) = "Lights";
   16627           34 :         rowHead(LoadCompRow::Equip) = "Equipment";
   16628           34 :         rowHead(LoadCompRow::Refrig) = "Refrigeration Equipment";
   16629           34 :         rowHead(LoadCompRow::WaterUse) = "Water Use Equipment";
   16630           34 :         rowHead(LoadCompRow::PowerGen) = "Power Generation Equipment";
   16631           34 :         rowHead(LoadCompRow::HvacLoss) = "HVAC Equipment Losses";
   16632           34 :         rowHead(LoadCompRow::Refrig) = "Refrigeration";
   16633              :         // misc
   16634           34 :         rowHead(LoadCompRow::DOAS) = "DOAS Direct to Zone";
   16635           34 :         rowHead(LoadCompRow::Infil) = "Infiltration";
   16636           34 :         rowHead(LoadCompRow::ZoneVent) = "Zone Ventilation";
   16637           34 :         rowHead(LoadCompRow::IntZonMix) = "Interzone Mixing";
   16638              :         // opaque surfaces
   16639           34 :         rowHead(LoadCompRow::Roof) = "Roof";
   16640           34 :         rowHead(LoadCompRow::IntZonCeil) = "Interzone Ceiling";
   16641           34 :         rowHead(LoadCompRow::OtherRoof) = "Other Roof";
   16642           34 :         rowHead(LoadCompRow::ExtWall) = "Exterior Wall";
   16643           34 :         rowHead(LoadCompRow::IntZonWall) = "Interzone Wall";
   16644           34 :         rowHead(LoadCompRow::GrdWall) = "Ground Contact Wall";
   16645           34 :         rowHead(LoadCompRow::OtherWall) = "Other Wall";
   16646           34 :         rowHead(LoadCompRow::ExtFlr) = "Exterior Floor";
   16647           34 :         rowHead(LoadCompRow::IntZonFlr) = "Interzone Floor";
   16648           34 :         rowHead(LoadCompRow::GrdFlr) = "Ground Contact Floor";
   16649           34 :         rowHead(LoadCompRow::OtherFlr) = "Other Floor";
   16650              :         // subsurfaces
   16651           34 :         rowHead(LoadCompRow::FeneCond) = "Fenestration Conduction";
   16652           34 :         rowHead(LoadCompRow::FeneSolr) = "Fenestration Solar";
   16653           34 :         rowHead(LoadCompRow::OpqDoor) = "Opaque Door";
   16654           34 :         rowHead(LoadCompRow::GrdTot) = "Grand Total";
   16655              : 
   16656           34 :         columnHead.allocate(LoadCompCol::PerArea);
   16657           34 :         if (!(unitsStyle_para == OutputReportTabular::UnitsStyle::InchPound ||
   16658              :               unitsStyle_para == OutputReportTabular::UnitsStyle::InchPoundExceptElectricity)) {
   16659           22 :             columnHead(LoadCompCol::SensInst) = "Sensible - Instant [W]";
   16660           22 :             columnHead(LoadCompCol::SensDelay) = "Sensible - Delayed [W]";
   16661           22 :             columnHead(LoadCompCol::SensRA) = "Sensible - Return Air [W]";
   16662           22 :             columnHead(LoadCompCol::Latent) = "Latent [W]";
   16663           22 :             columnHead(LoadCompCol::Total) = "Total [W]";
   16664           22 :             columnHead(LoadCompCol::Perc) = "%Grand Total";
   16665           22 :             columnHead(LoadCompCol::Area) = "Related Area [m2]";
   16666           22 :             columnHead(LoadCompCol::PerArea) = "Total per Area [W/m2]";
   16667              :         } else {
   16668           12 :             columnHead(LoadCompCol::SensInst) = "Sensible - Instant [Btu/h]";
   16669           12 :             columnHead(LoadCompCol::SensDelay) = "Sensible - Delayed [Btu/h]";
   16670           12 :             columnHead(LoadCompCol::SensRA) = "Sensible - Return Air [Btu/h]";
   16671           12 :             columnHead(LoadCompCol::Latent) = "Latent [Btu/h]";
   16672           12 :             columnHead(LoadCompCol::Total) = "Total [Btu/h]";
   16673           12 :             columnHead(LoadCompCol::Perc) = "%Grand Total";
   16674           12 :             columnHead(LoadCompCol::Area) = "Related Area [ft2]";
   16675           12 :             columnHead(LoadCompCol::PerArea) = "Total per Area [Btu/h-ft2]";
   16676              :         }
   16677           34 :         columnWidth.dimension(LoadCompCol::PerArea, 14); // array assignment - same for all columns
   16678              : 
   16679           34 :         if (produceTabular_para) {
   16680           32 :             WriteSubtitle(state, peakLoadCompName);
   16681           32 :             WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
   16682              :         }
   16683           34 :         if (produceSQLite_para) {
   16684           32 :             if (state.dataSQLiteProcedures->sqlite) {
   16685           20 :                 state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
   16686              :                     tableBody, rowHead, columnHead, reportName, zoneAirLoopFacilityName, peakLoadCompName);
   16687              :             }
   16688              :         }
   16689           34 :         if (produceTabular_para) {
   16690           32 :             if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
   16691            0 :                 state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(
   16692              :                     tableBody, rowHead, columnHead, reportName, zoneAirLoopFacilityName, peakLoadCompName);
   16693              :             }
   16694              :         }
   16695              : 
   16696              :         //---- Peak Conditions
   16697              : 
   16698           34 :         rowHead.allocate(16);
   16699           34 :         columnHead.allocate(1);
   16700           34 :         columnWidth.allocate(1);
   16701           34 :         columnWidth = 14; // array assignment - same for all columns
   16702              : 
   16703           34 :         tableBody.allocate(1, 16);
   16704           34 :         tableBody = "";
   16705              : 
   16706           34 :         columnHead(1) = "Value";
   16707           34 :         if (!(unitsStyle_para == OutputReportTabular::UnitsStyle::InchPound ||
   16708              :               unitsStyle_para == OutputReportTabular::UnitsStyle::InchPoundExceptElectricity)) {
   16709           22 :             rowHead(1) = "Time of Peak Load";
   16710           22 :             rowHead(2) = "Outside Dry Bulb Temperature [C]";
   16711           22 :             rowHead(3) = "Outside Wet Bulb Temperature [C]";
   16712           22 :             rowHead(4) = "Outside Humidity Ratio at Peak [kgWater/kgDryAir]";
   16713           22 :             rowHead(5) = "Zone Dry Bulb Temperature [C]";
   16714           22 :             rowHead(6) = "Zone Relative Humidity [%]";
   16715           22 :             rowHead(7) = "Zone Humidity Ratio at Peak [kgWater/kgDryAir]";
   16716              : 
   16717           22 :             rowHead(8) = "Supply Air Temperature [C]";
   16718           22 :             rowHead(9) = "Mixed Air Temperature [C]";
   16719           22 :             rowHead(10) = "Main Fan Air Flow [m3/s]";
   16720           22 :             rowHead(11) = "Outside Air Flow [m3/s]";
   16721           22 :             rowHead(12) = "Peak Sensible Load with Sizing Factor [W]";
   16722           22 :             rowHead(13) = "Difference Due to Sizing Factor [W]";
   16723              : 
   16724           22 :             rowHead(14) = "Peak Sensible Load [W]";
   16725           22 :             rowHead(15) = "Estimated Instant + Delayed Sensible Load [W]";
   16726           22 :             rowHead(16) = "Difference Between Peak and Estimated Sensible Load [W]";
   16727              :         } else {
   16728           12 :             rowHead(1) = "Time of Peak Load";
   16729           12 :             rowHead(2) = "Outside Dry Bulb Temperature [F]";
   16730           12 :             rowHead(3) = "Outside Wet Bulb Temperature [F]";
   16731           12 :             rowHead(4) = "Outside Humidity Ratio at Peak [lbWater/lbAir]";
   16732           12 :             rowHead(5) = "Zone Dry Bulb Temperature [F]";
   16733           12 :             rowHead(6) = "Zone Relative Humidity [%]";
   16734           12 :             rowHead(7) = "Zone Humidity Ratio at Peak [lbWater/lbAir]";
   16735              : 
   16736           12 :             rowHead(8) = "Supply Air Temperature [F]";
   16737           12 :             rowHead(9) = "Mixed Air Temperature [F]";
   16738           12 :             rowHead(10) = "Main Fan Air Flow [ft3/min]";
   16739           12 :             rowHead(11) = "Outside Air Flow [ft3/min]";
   16740           12 :             rowHead(12) = "Peak Sensible Load with Sizing Factor [Btu/h]";
   16741           12 :             rowHead(13) = "Difference Due to Sizing Factor [Btu/h]";
   16742              : 
   16743           12 :             rowHead(14) = "Peak Sensible Load  [Btu/h]";
   16744           12 :             rowHead(15) = "Estimated Instant + Delayed Sensible Load [Btu/h]";
   16745           12 :             rowHead(16) = "Difference Between Peak and Estimated Sensible Load [Btu/h]";
   16746              :         }
   16747              : 
   16748           34 :         if (curCompLoad.timeStepMax != 0) {
   16749           28 :             tableBody(1, 1) = curCompLoad.peakDateHrMin;                  // Time of Peak Load
   16750           28 :             tableBody(1, 2) = RealToStr(curCompLoad.outsideDryBulb, 2);   // Outside Dry Bulb Temperature
   16751           28 :             tableBody(1, 3) = RealToStr(curCompLoad.outsideWetBulb, 2);   // Outside Wet Bulb Temperature
   16752           28 :             tableBody(1, 4) = RealToStr(curCompLoad.outsideHumRatio, 5);  // Outside Humidity Ratio at Peak
   16753           28 :             tableBody(1, 5) = RealToStr(curCompLoad.zoneDryBulb, 2);      // Zone Dry Bulb Temperature
   16754           28 :             tableBody(1, 6) = RealToStr(100 * curCompLoad.zoneRelHum, 2); // Zone Relative Humidity
   16755           28 :             tableBody(1, 7) = RealToStr(curCompLoad.zoneHumRatio, 5);     // Zone Humidity Ratio at Peak
   16756              :         }
   16757           34 :         tableBody(1, 8) = RealToStr(curCompLoad.supAirTemp, 2); // supply air temperature
   16758           34 :         if (kind == OutputType::AirLoop) {
   16759           12 :             tableBody(1, 9) = RealToStr(curCompLoad.mixAirTemp, 2); // mixed air temperature - not for zone or facility
   16760              :         }
   16761           34 :         tableBody(1, 10) = RealToStr(curCompLoad.mainFanAirFlow, 4);     // main fan air flow
   16762           34 :         tableBody(1, 11) = RealToStr(curCompLoad.outsideAirFlow, 4);     // outside air flow
   16763           34 :         tableBody(1, 12) = RealToStr(curCompLoad.designPeakLoad, 2);     // design peak load
   16764           34 :         tableBody(1, 13) = RealToStr(curCompLoad.diffDesignPeak, 2);     // difference between Design and Peak Load
   16765           34 :         tableBody(1, 14) = RealToStr(curCompLoad.peakDesSensLoad, 2);    // Peak Design Sensible Load
   16766           34 :         tableBody(1, 15) = RealToStr(curCompLoad.estInstDelSensLoad, 2); // Estimated Instant + Delayed Sensible Load
   16767           34 :         tableBody(1, 16) = RealToStr(curCompLoad.diffPeakEst, 2);        // Difference
   16768              : 
   16769           34 :         if (produceTabular_para) {
   16770           32 :             WriteSubtitle(state, peakCondName);
   16771           32 :             WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
   16772              :         }
   16773           34 :         if (produceSQLite_para) {
   16774           32 :             if (state.dataSQLiteProcedures->sqlite) {
   16775           20 :                 state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
   16776              :                     tableBody, rowHead, columnHead, reportName, zoneAirLoopFacilityName, peakCondName);
   16777              :             }
   16778              :         }
   16779           34 :         if (produceTabular_para) {
   16780           32 :             if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
   16781            0 :                 state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(
   16782              :                     tableBody, rowHead, columnHead, reportName, zoneAirLoopFacilityName, peakCondName);
   16783              :             }
   16784              :         }
   16785              : 
   16786              :         //---- Engineering Checks
   16787              : 
   16788           34 :         rowHead.allocate(6);
   16789           34 :         columnHead.allocate(1);
   16790           34 :         columnWidth.allocate(1);
   16791           34 :         columnWidth = 14; // array assignment - same for all columns
   16792              : 
   16793           34 :         tableBody.allocate(1, 6);
   16794           34 :         tableBody = "";
   16795              : 
   16796           34 :         columnHead(1) = "Value";
   16797           34 :         if (!(unitsStyle_para == OutputReportTabular::UnitsStyle::InchPound ||
   16798              :               unitsStyle_para == OutputReportTabular::UnitsStyle::InchPoundExceptElectricity)) {
   16799           22 :             rowHead(1) = "Outside Air Fraction [fraction]";
   16800           22 :             rowHead(2) = "Airflow per Floor Area [m3/s-m2]";
   16801           22 :             rowHead(3) = "Airflow per Total Capacity [m3/s-W]";
   16802           22 :             rowHead(4) = "Floor Area per Total Capacity [m2/W]";
   16803           22 :             rowHead(5) = "Total Capacity per Floor Area [W/m2]";
   16804              :             // rowHead( 6 ) = "Chiller Pump Power per Flow [W-s/m3]"; // facility only
   16805              :             // rowHead( 7 ) = "Condenser Pump Power per Flow [W-s/m3]"; // facility only
   16806           22 :             rowHead(6) = "Number of People";
   16807              :         } else {
   16808           12 :             rowHead(1) = "Outside Air Fraction [fraction]";
   16809           12 :             rowHead(2) = "Airflow per Floor Area [ft3/min-ft2]";
   16810           12 :             rowHead(3) = "Airflow per Total Capacity [ft3-h/min-Btu]";
   16811           12 :             rowHead(4) = "Floor Area per Total Capacity [ft2-h/Btu]";
   16812           12 :             rowHead(5) = "Total Capacity per Floor Area [Btu/h-ft2]";
   16813              :             // rowHead( 6 ) = "Chiller Pump Power per Flow [W-min/gal]";
   16814              :             // rowHead( 7 ) = "Condenser Pump Power per Flow [W-min/gal]";
   16815           12 :             rowHead(6) = "Number of People";
   16816              :         }
   16817              : 
   16818           68 :         tableBody(1, 1) = fmt::format("{:.{}f}", curCompLoad.outsideAirRatio, 4); // outside Air
   16819           34 :         tableBody(1, 2) = fmt::format("{:0.3E}", curCompLoad.airflowPerFlrArea);  // airflow per floor area
   16820           34 :         tableBody(1, 3) = fmt::format("{:0.3E}", curCompLoad.airflowPerTotCap);   // airflow per total capacity
   16821           34 :         tableBody(1, 4) = fmt::format("{:0.3E}", curCompLoad.areaPerTotCap);      // area per total capacity
   16822           34 :         tableBody(1, 5) = fmt::format("{:0.3E}", curCompLoad.totCapPerArea);      // total capacity per area
   16823           68 :         tableBody(1, 6) = fmt::format("{:.{}f}", curCompLoad.numPeople, 1);       // number of people
   16824              : 
   16825           34 :         if (produceTabular_para) {
   16826           32 :             WriteSubtitle(state, engineeringCheckName);
   16827           32 :             WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
   16828              :         }
   16829           34 :         if (produceSQLite_para) {
   16830           32 :             if (state.dataSQLiteProcedures->sqlite) {
   16831           20 :                 state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
   16832              :                     tableBody, rowHead, columnHead, reportName, zoneAirLoopFacilityName, engineeringCheckName);
   16833              :             }
   16834              :         }
   16835           34 :         if (produceTabular_para) {
   16836           32 :             if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
   16837            0 :                 state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(
   16838              :                     tableBody, rowHead, columnHead, reportName, zoneAirLoopFacilityName, engineeringCheckName);
   16839              :             }
   16840              :         }
   16841              : 
   16842              :         // write the list of zone for the AirLoop level report
   16843           34 :         if (kind == OutputType::AirLoop && curCompLoad.zoneIndices.allocated()) {
   16844            8 :             int maxRow = 0;
   16845           18 :             for (size_t zi = 1; zi <= curCompLoad.zoneIndices.size(); ++zi) {
   16846           10 :                 if (curCompLoad.zoneIndices(zi) > 0) {
   16847           10 :                     maxRow = zi;
   16848              :                 }
   16849              :             }
   16850              : 
   16851            8 :             rowHead.allocate(maxRow);
   16852            8 :             columnHead.allocate(1);
   16853            8 :             columnWidth.allocate(1);
   16854            8 :             columnWidth = 14; // array assignment - same for all columns
   16855            8 :             tableBody.allocate(1, maxRow);
   16856            8 :             tableBody = "";
   16857              : 
   16858            8 :             columnHead(1) = "Zone Name";
   16859           18 :             for (int zi = 1; zi <= maxRow; ++zi) {
   16860           10 :                 rowHead(zi) = fmt::to_string(zi);
   16861           10 :                 if (curCompLoad.zoneIndices(zi) > 0) {
   16862           10 :                     tableBody(1, zi) = state.dataHeatBal->Zone(curCompLoad.zoneIndices(zi)).Name;
   16863              :                 }
   16864              :             }
   16865              : 
   16866            8 :             if (produceTabular_para) {
   16867            8 :                 WriteSubtitle(state, zonesIncludedName);
   16868            8 :                 WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
   16869              :             }
   16870            8 :             if (produceSQLite_para) {
   16871            8 :                 if (state.dataSQLiteProcedures->sqlite) {
   16872            6 :                     state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
   16873              :                         tableBody, rowHead, columnHead, reportName, zoneAirLoopFacilityName, zonesIncludedName);
   16874              :                 }
   16875              :             }
   16876            8 :             if (produceTabular_para) {
   16877            8 :                 if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
   16878            0 :                     state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(
   16879              :                         tableBody, rowHead, columnHead, reportName, zoneAirLoopFacilityName, zonesIncludedName);
   16880              :                 }
   16881              :             }
   16882              :         }
   16883              :     }
   16884           17 : }
   16885              : 
   16886         1044 : void WriteReportHeaders(EnergyPlusData &state,
   16887              :                         std::string const &reportName,
   16888              :                         std::string const &objectName,
   16889              :                         OutputProcessor::StoreType const averageOrSum)
   16890              : {
   16891              :     // SUBROUTINE INFORMATION:
   16892              :     //       AUTHOR         Jason Glazer
   16893              :     //       DATE WRITTEN   August 2003
   16894              :     //       MODIFIED       na
   16895              :     //       RE-ENGINEERED  na
   16896              : 
   16897              :     // PURPOSE OF THIS SUBROUTINE:
   16898              :     //   Write the first few lines of each report with headers to the output
   16899              :     //   file for tabular reports.
   16900              : 
   16901         1044 :     std::string const modifiedReportName(reportName + (averageOrSum == OutputProcessor::StoreType::Sum ? " per second" : ""));
   16902         1044 :     auto &ort = state.dataOutRptTab;
   16903              : 
   16904         4375 :     for (int iStyle = 1; iStyle <= ort->numStyles; ++iStyle) {
   16905         3331 :         std::ostream &tbl_stream(*ort->TabularOutputFile(iStyle));
   16906         3331 :         std::string const &curDel(ort->del(iStyle));
   16907         3331 :         TableStyle const style = ort->TableStyle(iStyle);
   16908         3331 :         if ((style == TableStyle::Comma) || (style == TableStyle::Tab)) {
   16909         1466 :             tbl_stream << "----------------------------------------------------------------------------------------------------\n";
   16910         1466 :             tbl_stream << "REPORT:" << curDel << modifiedReportName << '\n';
   16911         1466 :             tbl_stream << "FOR:" << curDel << objectName << '\n';
   16912         1865 :         } else if (style == TableStyle::Fixed) {
   16913          572 :             tbl_stream << "----------------------------------------------------------------------------------------------------\n";
   16914          572 :             tbl_stream << "REPORT:      " << curDel << modifiedReportName << '\n';
   16915          572 :             tbl_stream << "FOR:         " << curDel << objectName << '\n';
   16916         1293 :         } else if (style == TableStyle::HTML) {
   16917          721 :             tbl_stream << "<hr>\n";
   16918          721 :             tbl_stream << "<p><a href=\"#toc\" style=\"float: right\">Table of Contents</a></p>\n";
   16919          721 :             tbl_stream << "<a name=" << MakeAnchorName(reportName, objectName) << "></a>\n";
   16920          721 :             tbl_stream << "<p>Report:<b>" << curDel << modifiedReportName << "</b></p>\n";
   16921          721 :             tbl_stream << "<p>For:<b>" << curDel << objectName << "</b></p>\n";
   16922          721 :             tbl_stream << "<p>Timestamp: <b>" << std::setw(4) << ort->td(1) << '-' << std::setfill('0') << std::setw(2) << ort->td(2) << '-'
   16923          721 :                        << std::setw(2) << ort->td(3) << '\n';
   16924          721 :             tbl_stream << "    " << std::setw(2) << ort->td(5) << ':' << std::setw(2) << ort->td(6) << ':' << std::setw(2) << ort->td(7)
   16925          721 :                        << std::setfill(' ') << "</b></p>\n";
   16926          572 :         } else if (style == TableStyle::XML) {
   16927          572 :             if (len(ort->prevReportName) != 0) {
   16928          550 :                 tbl_stream << "</" << ort->prevReportName << ">\n"; // close the last element if it was used.
   16929              :             }
   16930          572 :             tbl_stream << "<" << ConvertToElementTag(modifiedReportName) << ">\n";
   16931          572 :             tbl_stream << "  <for>" << ConvertToEscaped(objectName) << "</for>\n";
   16932          572 :             ort->prevReportName = ConvertToElementTag(modifiedReportName); // save the name for next time
   16933              :         }
   16934              :     }
   16935              :     // clear the active subtable name for the XML reporting
   16936         1044 :     ort->activeSubTableName = "";
   16937              :     // save the report name if the subtable name is not available during XML processing
   16938         1044 :     ort->activeReportName = modifiedReportName;
   16939              :     // save the "for" which is the object name in the report for HTML comment that contains the report, for, and subtable
   16940         1044 :     ort->activeForName = objectName;
   16941         1044 : }
   16942              : 
   16943         7196 : void WriteSubtitle(EnergyPlusData &state, std::string const &subtitle)
   16944              : {
   16945              :     // SUBROUTINE INFORMATION:
   16946              :     //       AUTHOR         Jason Glazer
   16947              :     //       DATE WRITTEN   November 2003
   16948              :     //       MODIFIED       na
   16949              :     //       RE-ENGINEERED  na
   16950              : 
   16951              :     // PURPOSE OF THIS SUBROUTINE:
   16952              :     //   Insert a subtitle into the current report
   16953              : 
   16954              :     // Locals
   16955              :     // SUBROUTINE ARGUMENT DEFINITIONS:
   16956              : 
   16957              :     // SUBROUTINE PARAMETER DEFINITIONS:
   16958              : 
   16959              :     // INTERFACE BLOCK SPECIFICATIONS:
   16960              :     // na
   16961              : 
   16962              :     // DERIVED TYPE DEFINITIONS:
   16963              :     // na
   16964              : 
   16965              :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
   16966              :     int iStyle;
   16967         7196 :     auto &ort = state.dataOutRptTab;
   16968              : 
   16969        30346 :     for (iStyle = 1; iStyle <= ort->numStyles; ++iStyle) {
   16970        23150 :         TableStyle const style = ort->TableStyle(iStyle);
   16971        23150 :         if ((style == TableStyle::Comma) || (style == TableStyle::Tab) || (style == TableStyle::Fixed)) {
   16972        14119 :             std::ostream &tbl_stream(*ort->TabularOutputFile(iStyle));
   16973        14119 :             tbl_stream << subtitle << "\n\n";
   16974        23150 :         } else if (style == TableStyle::HTML) {
   16975         5054 :             std::ostream &tbl_stream(*ort->TabularOutputFile(iStyle));
   16976         5054 :             tbl_stream << "<b>" << subtitle << "</b><br><br>\n";
   16977         5054 :             tbl_stream << "<!-- FullName:" << ort->activeReportName << '_' << ort->activeForName << '_' << subtitle << "-->\n";
   16978         3977 :         } else if (style == TableStyle::XML) {
   16979              :             // save the active subtable name for the XML reporting
   16980         3977 :             ort->activeSubTableName = subtitle;
   16981              :             // no other output is needed since WriteTable uses the subtable name for each record.
   16982              :         }
   16983              :     }
   16984         7196 : }
   16985              : 
   16986          458 : void WriteTextLine(EnergyPlusData &state, std::string const &lineOfText, bool const useBold)
   16987              : {
   16988              :     // SUBROUTINE INFORMATION:
   16989              :     //       AUTHOR         Jason Glazer
   16990              :     //       DATE WRITTEN   April 2007
   16991              :     //       MODIFIED       na
   16992              :     //       RE-ENGINEERED  na
   16993              : 
   16994              :     // PURPOSE OF THIS SUBROUTINE:
   16995              :     //   Insert a subtitle into the current report
   16996              : 
   16997              :     // Locals
   16998              :     // SUBROUTINE ARGUMENT DEFINITIONS:
   16999              : 
   17000              :     // SUBROUTINE PARAMETER DEFINITIONS:
   17001              : 
   17002              :     // INTERFACE BLOCK SPECIFICATIONS:
   17003              :     // na
   17004              : 
   17005              :     // DERIVED TYPE DEFINITIONS:
   17006              :     // na
   17007              : 
   17008              :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
   17009              :     int iStyle;
   17010          458 :     auto &ort = state.dataOutRptTab;
   17011              : 
   17012         1855 :     for (iStyle = 1; iStyle <= ort->numStyles; ++iStyle) {
   17013         1397 :         TableStyle const style = ort->TableStyle(iStyle);
   17014         1397 :         if ((style == TableStyle::Comma) || (style == TableStyle::Tab) || (style == TableStyle::Fixed)) {
   17015          858 :             std::ostream &tbl_stream(*ort->TabularOutputFile(iStyle));
   17016          858 :             tbl_stream << lineOfText << '\n';
   17017         1397 :         } else if (style == TableStyle::HTML) {
   17018          297 :             std::ostream &tbl_stream(*ort->TabularOutputFile(iStyle));
   17019          297 :             if (useBold) {
   17020          270 :                 tbl_stream << "<b>" << lineOfText << "</b><br><br>\n";
   17021              :             } else {
   17022           27 :                 tbl_stream << lineOfText << "<br>\n";
   17023              :             }
   17024          242 :         } else if (style == TableStyle::XML) {
   17025          242 :             std::ostream &tbl_stream(*ort->TabularOutputFile(iStyle));
   17026          242 :             if (!lineOfText.empty()) {
   17027          198 :                 tbl_stream << "<note>" << lineOfText << "</note>\n";
   17028              :             }
   17029              :         }
   17030              :     }
   17031          458 : }
   17032              : 
   17033         7196 : void WriteTable(EnergyPlusData &state,
   17034              :                 Array2S_string const body, // row,column
   17035              :                 const Array1D_string &rowLabels,
   17036              :                 const Array1D_string &columnLabels,
   17037              :                 Array1D_int &widthColumn,
   17038              :                 bool transposeXML,
   17039              :                 std::string_view const footnoteText)
   17040              : {
   17041              :     // SUBROUTINE INFORMATION:
   17042              :     //       AUTHOR         Jason Glazer
   17043              :     //       DATE WRITTEN   August 2003
   17044              :     //       MODIFIED       na
   17045              :     //       RE-ENGINEERED  na
   17046              : 
   17047              :     // PURPOSE OF THIS SUBROUTINE:
   17048              :     //   Output a table to the tabular output file in the selected
   17049              :     //   style (comma, tab, space, html, xml).
   17050              :     //   The widthColumn array is only used for fixed space formatted reports
   17051              :     //   if columnLables contain a vertical bar '|', they are broken into multiple
   17052              :     //   rows.  If they exceed the column width even after that and the format is
   17053              :     //   fixed, they are further shortened.
   17054              :     //   To include the currency symbol ($ by default but other symbols if the user
   17055              :     //   has input it with Economics:CurrencyType) use the string ~~$~~ in the row
   17056              :     //   headers, column headers, and body. For HTML files, the ASCII or UNICODE
   17057              :     //   symbol for the currency will be included. For TXT files, the ASCII symbol
   17058              :     //   will be used.
   17059              : 
   17060              :     // Argument array dimensioning
   17061              : 
   17062              :     // Locals
   17063              :     // SUBROUTINE ARGUMENT DEFINITIONS:
   17064              : 
   17065              :     // SUBROUTINE PARAMETER DEFINITIONS:
   17066         7196 :     static std::string const blank;
   17067              : 
   17068              :     // INTERFACE BLOCK SPECIFICATIONS:
   17069              :     // na
   17070              : 
   17071              :     // DERIVED TYPE DEFINITIONS:
   17072              :     // na
   17073              : 
   17074              :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
   17075         7196 :     Array2D_string colLabelMulti;
   17076         7196 :     std::string workColumn;
   17077         7196 :     Array1D_string rowLabelTags;
   17078         7196 :     Array1D_string columnLabelTags;
   17079         7196 :     Array1D_string rowUnitStrings;
   17080         7196 :     Array1D_string columnUnitStrings;
   17081         7196 :     Array2D_string bodyEsc;
   17082              : 
   17083         7196 :     std::string outputLine;
   17084         7196 :     std::string tagWithAttrib;
   17085              :     std::string::size_type col1start;
   17086         7196 :     auto &ort = state.dataOutRptTab;
   17087              : 
   17088              :     // create blank string
   17089              :     // get sizes of arrays
   17090         7196 :     int rowsBody = isize(body, 2);
   17091         7196 :     int colsBody = isize(body, 1);
   17092         7196 :     int rowsRowLabels = isize(rowLabels);
   17093         7196 :     int colsColumnLabels = isize(columnLabels);
   17094         7196 :     int const colsWidthColumn = isize(widthColumn);
   17095              :     // check size of arrays for consistency and if inconsistent use smaller value
   17096              :     // and display warning
   17097         7196 :     if (rowsBody != rowsRowLabels) {
   17098            0 :         ShowWarningError(state, "REPORT:TABLE Inconsistent number of rows.");
   17099            0 :         rowsBody = min(rowsBody, rowsRowLabels);
   17100            0 :         rowsRowLabels = rowsBody;
   17101              :     }
   17102         7196 :     if ((colsBody != colsColumnLabels) || (colsBody != colsWidthColumn)) {
   17103            0 :         ShowWarningError(state, "REPORT:TABLE Inconsistent number of columns.");
   17104            0 :         colsBody = min(colsBody, min(colsColumnLabels, colsWidthColumn));
   17105            0 :         colsColumnLabels = colsBody;
   17106              :     }
   17107              :     // create arrays to hold the XML tags
   17108         7196 :     rowLabelTags.allocate(rowsBody);
   17109         7196 :     columnLabelTags.allocate(colsBody);
   17110         7196 :     rowUnitStrings.allocate(rowsBody);
   17111         7196 :     columnUnitStrings.allocate(colsBody);
   17112         7196 :     bodyEsc.allocate(colsBody, rowsBody);
   17113              :     // create new array to hold multiple line column labels
   17114         7196 :     colLabelMulti.allocate(colsColumnLabels, 50);
   17115         7196 :     colLabelMulti = blank; // set array to blank
   17116         7196 :     int maxNumColLabelRows = 0;
   17117              : 
   17118        30346 :     for (int iStyle = 1; iStyle <= ort->numStyles; ++iStyle) {
   17119        23150 :         std::ostream &tbl_stream(*ort->TabularOutputFile(iStyle));
   17120        23150 :         std::string const &curDel = ort->del(iStyle);
   17121              :         // go through the columns and break them into multiple lines
   17122              :         // if bar '|' is found in a row then break into two lines
   17123              :         // if longer than the column width break into two lines for fixed style only
   17124       204002 :         for (int iCol = 1; iCol <= colsColumnLabels; ++iCol) {
   17125       180852 :             int numColLabelRows = 0;
   17126       180852 :             workColumn = columnLabels(iCol);
   17127       180852 :             widthColumn(iCol) = max(widthColumn(iCol), static_cast<int>(len(columnLabels(iCol))));
   17128              :             while (true) {
   17129       183646 :                 std::string::size_type const barLoc = index(workColumn, '|');
   17130       183646 :                 if (barLoc != std::string::npos) {
   17131         2794 :                     ++numColLabelRows;
   17132         2794 :                     colLabelMulti(iCol, numColLabelRows) = workColumn.substr(0, barLoc);
   17133         2794 :                     workColumn.erase(0, barLoc + 1);
   17134              :                 } else {
   17135       180852 :                     ++numColLabelRows;
   17136       180852 :                     colLabelMulti(iCol, numColLabelRows) = workColumn;
   17137       180852 :                     break; // inner do loop
   17138              :                 }
   17139         2794 :             }
   17140       180852 :             if (numColLabelRows > maxNumColLabelRows) {
   17141         7057 :                 maxNumColLabelRows = numColLabelRows;
   17142              :             }
   17143              :         }
   17144              : 
   17145        23150 :         auto const &thisStyle = ort->TableStyle(iStyle);
   17146              : 
   17147              :         // output depending on style of format
   17148        23150 :         if ((thisStyle == TableStyle::Comma) || (thisStyle == TableStyle::Tab)) {
   17149              :             // column headers
   17150        21348 :             for (int jRow = 1; jRow <= maxNumColLabelRows; ++jRow) {
   17151        11206 :                 outputLine = curDel; // one leading delimiters on column header lines
   17152        93121 :                 for (int iCol = 1; iCol <= colsColumnLabels; ++iCol) {
   17153        81915 :                     outputLine += curDel + stripped(colLabelMulti(iCol, jRow));
   17154              :                 }
   17155        11206 :                 tbl_stream << InsertCurrencySymbol(state, outputLine, false) << '\n';
   17156              :             }
   17157              :             // body with row headers
   17158        42615 :             for (int jRow = 1; jRow <= rowsBody; ++jRow) {
   17159        32473 :                 outputLine = curDel + rowLabels(jRow); // one leading delimiters on table body lines
   17160       287271 :                 for (int iCol = 1; iCol <= colsBody; ++iCol) {
   17161       254798 :                     outputLine += curDel + stripped(body(iCol, jRow));
   17162              :                 }
   17163        32473 :                 tbl_stream << InsertCurrencySymbol(state, outputLine, false) << '\n';
   17164              :             }
   17165        10142 :             if (!footnoteText.empty()) {
   17166         1290 :                 tbl_stream << fmt::format("{}\n", footnoteText);
   17167              :             }
   17168        10142 :             tbl_stream << "\n\n";
   17169              : 
   17170        23150 :         } else if (thisStyle == TableStyle::Fixed) {
   17171              : 
   17172              :             // extra preprocessing for fixed style reports
   17173              :             // break column headings into multiple rows if long (for fixed) or contain two spaces in a row.
   17174        35038 :             for (int iCol = 1; iCol <= colsColumnLabels; ++iCol) {
   17175        31061 :                 int const colWidthLimit = widthColumn(iCol);
   17176        63090 :                 for (int jRow = 1; jRow <= maxNumColLabelRows; ++jRow) {
   17177        32029 :                     pare(colLabelMulti(iCol, jRow), colWidthLimit);
   17178              :                 }
   17179              :             }
   17180         3977 :             std::string::size_type maxWidthRowLabel = 0;
   17181        16758 :             for (int jRow = 1; jRow <= rowsRowLabels; ++jRow) {
   17182        12781 :                 std::string::size_type widthRowLabel = len(rowLabels(jRow));
   17183        12781 :                 if (widthRowLabel > maxWidthRowLabel) {
   17184         5652 :                     maxWidthRowLabel = widthRowLabel;
   17185              :                 }
   17186              :             }
   17187              : 
   17188              :             // column headers
   17189         8372 :             for (int jRow = 1; jRow <= maxNumColLabelRows; ++jRow) {
   17190         4395 :                 outputLine = blank; // spaces(:maxWidthRowLabel+2)  // two extra spaces and leave blank area for row labels
   17191         4395 :                 col1start = max(maxWidthRowLabel + 2u, static_cast<std::string::size_type>(3u));
   17192        36424 :                 for (int iCol = 1; iCol <= colsColumnLabels; ++iCol) {
   17193        32029 :                     if (iCol != 1) {
   17194        27634 :                         outputLine += "  " + rjustified(sized(colLabelMulti(iCol, jRow), widthColumn(iCol)));
   17195              :                     } else {
   17196        13185 :                         outputLine = std::string(col1start - 1, ' ') + "  " + rjustified(sized(colLabelMulti(iCol, jRow), widthColumn(iCol)));
   17197              :                     }
   17198              :                 }
   17199         4395 :                 tbl_stream << InsertCurrencySymbol(state, outputLine, false) << '\n';
   17200              :             }
   17201              :             // body with row headers
   17202        16758 :             for (int jRow = 1; jRow <= rowsBody; ++jRow) {
   17203        12781 :                 outputLine = "  " + rjustified(sized(rowLabels(jRow), maxWidthRowLabel)); // two blank spaces on table body lines
   17204              :                 // col1start = max( len( outputLine ) + 2u, maxWidthRowLabel + 2u );
   17205       111934 :                 for (int iCol = 1; iCol <= colsBody; ++iCol) {
   17206        99153 :                     if (iCol != 1) {
   17207        86372 :                         outputLine += "  " + rjustified(sized(body(iCol, jRow), widthColumn(iCol)));
   17208              :                     } else {
   17209        12781 :                         outputLine += "   " + rjustified(sized(body(iCol, jRow), widthColumn(iCol)));
   17210              :                     }
   17211              :                 }
   17212        12781 :                 tbl_stream << InsertCurrencySymbol(state, outputLine, false) << '\n';
   17213              :             }
   17214         3977 :             if (!footnoteText.empty()) {
   17215          506 :                 tbl_stream << fmt::format("{}\n", footnoteText);
   17216              :             }
   17217         3977 :             tbl_stream << "\n\n";
   17218              : 
   17219         9031 :         } else if (thisStyle == TableStyle::HTML) {
   17220              :             // set up it being a table
   17221         5054 :             tbl_stream << "<table border=\"1\" cellpadding=\"4\" cellspacing=\"0\">\n";
   17222              :             // column headers
   17223         5054 :             tbl_stream << "  <tr><td></td>\n"; // start new row and leave empty cell
   17224        44333 :             for (int iCol = 1; iCol <= colsColumnLabels; ++iCol) {
   17225        39279 :                 outputLine = "    <td align=\"right\">";
   17226        79746 :                 for (int jRow = 1; jRow <= maxNumColLabelRows; ++jRow) {
   17227        40467 :                     outputLine += ConvertToEscaped(colLabelMulti(iCol, jRow), false);
   17228        40467 :                     if (jRow < maxNumColLabelRows) {
   17229         1188 :                         outputLine += "<br>";
   17230              :                     }
   17231              :                 }
   17232        39279 :                 tbl_stream << InsertCurrencySymbol(state, outputLine, true) << "</td>\n";
   17233              :             }
   17234         5054 :             tbl_stream << "  </tr>\n";
   17235              :             // body with row headers
   17236        22172 :             for (int jRow = 1; jRow <= rowsBody; ++jRow) {
   17237        17118 :                 tbl_stream << "  <tr>\n";
   17238        17118 :                 if (rowLabels(jRow) != "") {
   17239        33854 :                     tbl_stream << "    <td align=\"right\">" << ConvertToEscaped(InsertCurrencySymbol(state, rowLabels(jRow), true), false)
   17240        33854 :                                << "</td>\n";
   17241              :                 } else {
   17242          191 :                     tbl_stream << "    <td align=\"right\">&nbsp;</td>\n";
   17243              :                 }
   17244       148383 :                 for (int iCol = 1; iCol <= colsBody; ++iCol) {
   17245       131265 :                     if (body(iCol, jRow) != "") {
   17246       200698 :                         tbl_stream << "    <td align=\"right\">" << ConvertToEscaped(InsertCurrencySymbol(state, body(iCol, jRow), true), false)
   17247       200698 :                                    << "</td>\n";
   17248              :                     } else {
   17249        30916 :                         tbl_stream << "    <td align=\"right\">&nbsp;</td>\n";
   17250              :                     }
   17251              :                 }
   17252        17118 :                 tbl_stream << "  </tr>\n";
   17253              :             }
   17254              :             // end the table
   17255         5054 :             tbl_stream << "</table>\n";
   17256         5054 :             if (!footnoteText.empty()) {
   17257          663 :                 tbl_stream << fmt::format("<div class=\"footnote\" style=\"font-style: italic;\">{}</div>\n", footnoteText);
   17258              :             }
   17259         5054 :             tbl_stream << "<br><br>\n";
   17260         3977 :         } else if (thisStyle == TableStyle::XML) {
   17261              :             // check if entire table is blank and it if is skip generating anything
   17262         3977 :             bool isTableBlank = true;
   17263         5746 :             for (int jRow = 1; jRow <= rowsBody; ++jRow) {
   17264        23349 :                 for (int iCol = 1; iCol <= colsBody; ++iCol) {
   17265        21580 :                     if (len(body(iCol, jRow)) > 0) {
   17266         2560 :                         isTableBlank = false;
   17267         2560 :                         break;
   17268              :                     }
   17269              :                 }
   17270         4329 :                 if (!isTableBlank) break;
   17271              :             }
   17272              :             // if non-blank cells in the table body were found create the table.
   17273         3977 :             if (!isTableBlank) {
   17274              :                 // if report name and subtable name the same add "record" to the end
   17275         2560 :                 ort->activeSubTableName = ConvertToElementTag(ort->activeSubTableName);
   17276         2560 :                 ort->activeReportNameNoSpace = ConvertToElementTag(ort->activeReportName);
   17277         2560 :                 if (Util::SameString(ort->activeSubTableName, ort->activeReportNameNoSpace)) {
   17278           22 :                     ort->activeSubTableName += "Record";
   17279              :                 }
   17280              :                 // if no subtable name use the report name and add "record" to the end
   17281         2560 :                 if (len(ort->activeSubTableName) == 0) {
   17282            0 :                     ort->activeSubTableName = ort->activeReportNameNoSpace + "Record";
   17283              :                 }
   17284              :                 // if a single column table, transpose it automatically
   17285         2560 :                 if ((colsBody == 1) && (rowsBody > 1)) {
   17286          324 :                     transposeXML = true;
   17287              :                 }
   17288              :                 // first convert all row and column headers into tags compatible with XML strings
   17289        13572 :                 for (int jRow = 1; jRow <= rowsBody; ++jRow) {
   17290        11012 :                     rowLabelTags(jRow) = ConvertToElementTag(rowLabels(jRow));
   17291        11012 :                     if (len(rowLabelTags(jRow)) == 0) {
   17292          198 :                         rowLabelTags(jRow) = "none";
   17293              :                     }
   17294        11012 :                     rowUnitStrings(jRow) = GetUnitSubString(rowLabels(jRow));
   17295        11012 :                     if (Util::SameString(rowUnitStrings(jRow), "Invalid/Undefined")) {
   17296            0 :                         rowUnitStrings(jRow) = "";
   17297              :                     }
   17298              :                 }
   17299        20124 :                 for (int iCol = 1; iCol <= colsBody; ++iCol) {
   17300        17564 :                     columnLabelTags(iCol) = ConvertToElementTag(columnLabels(iCol));
   17301        17564 :                     if (len(columnLabelTags(iCol)) == 0) {
   17302            0 :                         columnLabelTags(iCol) = "none";
   17303              :                     }
   17304        17564 :                     columnUnitStrings(iCol) = GetUnitSubString(columnLabels(iCol));
   17305        17564 :                     if (Util::SameString(columnUnitStrings(iCol), "Invalid/Undefined")) {
   17306            0 :                         columnUnitStrings(iCol) = "";
   17307              :                     }
   17308              :                 }
   17309              :                 // convert entire table body to one with escape characters (no " ' < > &)
   17310        13572 :                 for (int jRow = 1; jRow <= rowsBody; ++jRow) {
   17311        91498 :                     for (int iCol = 1; iCol <= colsBody; ++iCol) {
   17312        80486 :                         bodyEsc(iCol, jRow) = ConvertToEscaped(body(iCol, jRow));
   17313              :                     }
   17314              :                 }
   17315         2560 :                 if (!transposeXML) {
   17316              :                     // body with row headers
   17317        11150 :                     for (int jRow = 1; jRow <= rowsBody; ++jRow) {
   17318              :                         // check if record is blank and it if is skip generating anything
   17319         8914 :                         bool isRecordBlank = true;
   17320        10896 :                         for (int iCol = 1; iCol <= colsBody; ++iCol) {
   17321        10764 :                             if (len(bodyEsc(iCol, jRow)) > 0) {
   17322         8782 :                                 isRecordBlank = false;
   17323         8782 :                                 break;
   17324              :                             }
   17325              :                         }
   17326         8914 :                         if (!isRecordBlank) {
   17327         8782 :                             tbl_stream << "  <" << ort->activeSubTableName << ">\n";
   17328         8782 :                             if (len(rowLabelTags(jRow)) > 0) {
   17329         8782 :                                 tbl_stream << "    <name>" << rowLabelTags(jRow) << "</name>\n";
   17330              :                             }
   17331        85894 :                             for (int iCol = 1; iCol <= colsBody; ++iCol) {
   17332        77112 :                                 if (len(stripped(bodyEsc(iCol, jRow))) > 0) { // skip blank cells
   17333        71808 :                                     tagWithAttrib = "<" + columnLabelTags(iCol);
   17334        71808 :                                     if (len(columnUnitStrings(iCol)) > 0) {
   17335       222384 :                                         tagWithAttrib += std::string(" units=") + char(34) + columnUnitStrings(iCol) + char(34) +
   17336        55596 :                                                          '>'; // if units are present add them as an attribute
   17337              :                                     } else {
   17338        16212 :                                         tagWithAttrib += ">";
   17339              :                                     }
   17340        71808 :                                     tbl_stream << "    " << tagWithAttrib << stripped(bodyEsc(iCol, jRow)) << "</" << columnLabelTags(iCol) << ">\n";
   17341              :                                 }
   17342              :                             }
   17343         8782 :                             tbl_stream << "  </" << ort->activeSubTableName << ">\n";
   17344              :                         }
   17345              :                     }
   17346              :                 } else { // transpose XML table
   17347              :                     // body with row headers
   17348          648 :                     for (int iCol = 1; iCol <= colsBody; ++iCol) {
   17349              :                         // check if record is blank and it if is skip generating anything
   17350          324 :                         bool isRecordBlank = true;
   17351          324 :                         for (int jRow = 1; jRow <= rowsBody; ++jRow) {
   17352          324 :                             if (len(bodyEsc(iCol, jRow)) > 0) {
   17353          324 :                                 isRecordBlank = false;
   17354          324 :                                 break;
   17355              :                             }
   17356              :                         }
   17357          324 :                         if (!isRecordBlank) {
   17358          324 :                             tbl_stream << "  <" << ort->activeSubTableName << ">\n";
   17359              :                             // if the column has units put them into the name tag
   17360          324 :                             if (len(columnLabelTags(iCol)) > 0) {
   17361          324 :                                 if (len(columnUnitStrings(iCol)) > 0) {
   17362          264 :                                     tbl_stream << "    <name units=" << char(34) << columnUnitStrings(iCol) << char(34) << '>'
   17363          132 :                                                << columnLabelTags(iCol) << "</name>\n";
   17364              :                                 } else {
   17365          192 :                                     tbl_stream << "    <name>" << columnLabelTags(iCol) << "</name>\n";
   17366              :                                 }
   17367              :                             }
   17368         2422 :                             for (int jRow = 1; jRow <= rowsBody; ++jRow) {
   17369         2098 :                                 if (len(bodyEsc(iCol, jRow)) > 0) { // skip blank cells
   17370         2093 :                                     tagWithAttrib = "<" + rowLabelTags(jRow);
   17371         2093 :                                     if (len(rowUnitStrings(jRow)) > 0) {
   17372         1008 :                                         tagWithAttrib += std::string(" units=") + char(34) + rowUnitStrings(jRow) + char(34) +
   17373          252 :                                                          ">\n"; // if units are present add them as an attribute
   17374              :                                     } else {
   17375         1841 :                                         tagWithAttrib += ">";
   17376              :                                     }
   17377         2093 :                                     tbl_stream << "    " << tagWithAttrib << stripped(bodyEsc(iCol, jRow)) << "</" << rowLabelTags(jRow) << ">\n";
   17378              :                                 }
   17379              :                             }
   17380          324 :                             tbl_stream << "  </" << ort->activeSubTableName << ">\n";
   17381              :                         }
   17382              :                     }
   17383              :                 }
   17384         2560 :                 if (!footnoteText.empty()) {
   17385          198 :                     if (footnoteText.find("<br") != std::string_view::npos) {
   17386            0 :                         tbl_stream << fmt::format("  <footnote><![CDATA[{}]]></footnote>\n", footnoteText);
   17387              :                     } else {
   17388          198 :                         tbl_stream << fmt::format("  <footnote>{}</footnote>\n", footnoteText);
   17389              :                     }
   17390              :                 }
   17391              :             }
   17392              :         } else {
   17393              :         }
   17394              :     }
   17395         7196 : }
   17396              : 
   17397         1465 : std::string MakeAnchorName(std::string const &reportString, std::string const &objectString)
   17398              : {
   17399              :     // SUBROUTINE INFORMATION:
   17400              :     //       AUTHOR         Jason Glazer
   17401              :     //       DATE WRITTEN   June 2005
   17402              :     //       MODIFIED
   17403              :     //       RE-ENGINEERED  na
   17404              : 
   17405              :     // PURPOSE OF THIS SUBROUTINE:
   17406              :     //   Use the name of the report and object be used to create and HTML anchor
   17407              : 
   17408              :     // METHODOLOGY EMPLOYED:
   17409              :     //   Remove spaces and put double colon between names
   17410              : 
   17411              :     // REFERENCES:
   17412              :     // na
   17413              : 
   17414              :     // USE STATEMENTS:
   17415              : 
   17416              :     // Return value
   17417         1465 :     std::string StringOut;
   17418         1465 :     StringOut.reserve(reportString.size() + objectString.size() + 2);
   17419              : 
   17420              :     // Locals
   17421              :     // SUBROUTINE ARGUMENT DEFINITIONS:
   17422              :     // na
   17423              : 
   17424              :     // SUBROUTINE PARAMETER DEFINITIONS:
   17425              : 
   17426              :     // INTERFACE BLOCK SPECIFICATIONS:
   17427              :     // na
   17428              : 
   17429              :     // DERIVED TYPE DEFINITIONS:
   17430              :     // na
   17431              : 
   17432              :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
   17433              : 
   17434        35747 :     for (char const i : reportString) {
   17435        34282 :         if (has(validChars, i)) {
   17436        31062 :             StringOut += i;
   17437              :         }
   17438              :     }
   17439         1465 :     StringOut += "::";
   17440        23324 :     for (char const i : objectString) {
   17441        21859 :         if (has(validChars, i)) {
   17442        20402 :             StringOut += i;
   17443              :         }
   17444              :     }
   17445         1465 :     return StringOut;
   17446            0 : }
   17447              : 
   17448       217410 : std::string InsertCurrencySymbol(EnergyPlusData &state,
   17449              :                                  std::string const &inString, // Input String
   17450              :                                  bool const isHTML            // True if an HTML string
   17451              : )
   17452              : {
   17453              :     // SUBROUTINE INFORMATION:
   17454              :     //       AUTHOR         Jason Glazer
   17455              :     //       DATE WRITTEN   August 2008
   17456              :     //       MODIFIED       na
   17457              :     //       RE-ENGINEERED  na
   17458              : 
   17459              :     // PURPOSE OF THIS SUBROUTINE:
   17460              :     //   Looks for the ~~$~~
   17461              : 
   17462              :     // METHODOLOGY EMPLOYED:
   17463              :     //   na
   17464              :     // Using/Aliasing
   17465              : 
   17466              :     // Return value
   17467              : 
   17468              :     // Locals
   17469              :     // SUBROUTINE ARGUMENT DEFINITIONS:
   17470              : 
   17471              :     // SUBROUTINE PARAMETER DEFINITIONS:
   17472              :     // na
   17473              : 
   17474              :     // INTERFACE BLOCK SPECIFICATIONS:
   17475              :     // na
   17476              : 
   17477              :     // DERIVED TYPE DEFINITIONS:
   17478              :     // na
   17479              : 
   17480              :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
   17481              : 
   17482       217410 :     std::string outSt(trimmed(inString)); // Result String
   17483       217410 :     std::string::size_type loc = index(outSt, "~~$~~");
   17484       217410 :     while (loc != std::string::npos) {
   17485            0 :         if (isHTML) {
   17486            0 :             outSt = inString.substr(0, loc) + state.dataCostEstimateManager->monetaryUnit(state.dataCostEstimateManager->selectedMonetaryUnit).html +
   17487            0 :                     outSt.substr(loc + 5);
   17488              :         } else {
   17489            0 :             outSt = inString.substr(0, loc) + state.dataCostEstimateManager->monetaryUnit(state.dataCostEstimateManager->selectedMonetaryUnit).txt +
   17490            0 :                     outSt.substr(loc + 5);
   17491              :         }
   17492            0 :         loc = index(outSt, "~~$~~");
   17493              :     }
   17494       217410 :     return outSt;
   17495            0 : }
   17496              : 
   17497        34840 : std::string ConvertToElementTag(std::string const &inString) // Input String
   17498              : {
   17499              :     // SUBROUTINE INFORMATION:
   17500              :     //       AUTHOR         Jason Glazer
   17501              :     //       DATE WRITTEN   February 2013
   17502              :     //       MODIFIED       na
   17503              :     //       RE-ENGINEERED  na
   17504              : 
   17505              :     // PURPOSE OF THIS SUBROUTINE:
   17506              :     //   Convert report column or row header into a tag string
   17507              :     //   that just has A-Z, a-z, or 0-1 characters and is
   17508              :     //   shown in camelCase.
   17509              : 
   17510              :     // METHODOLOGY EMPLOYED:
   17511              :     //   na
   17512              : 
   17513              :     // Return value
   17514        34840 :     std::string outString; // Result String
   17515              : 
   17516              :     // Locals
   17517              :     // SUBROUTINE ARGUMENT DEFINITIONS:
   17518              : 
   17519              :     // SUBROUTINE PARAMETER DEFINITIONS:
   17520              :     // na
   17521              : 
   17522              :     // INTERFACE BLOCK SPECIFICATIONS:
   17523              :     // na
   17524              : 
   17525              :     // DERIVED TYPE DEFINITIONS:
   17526              :     // na
   17527              : 
   17528              :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
   17529              : 
   17530        34840 :     bool foundOther = true; // flag if character found besides A-Z, a-z, 0-9
   17531       723688 :     for (std::string::size_type iIn = 0, e = inString.length(); iIn < e; ++iIn) {
   17532       697482 :         char const c(inString[iIn]);
   17533       697482 :         int const curCharVal = int(c);
   17534       697482 :         if ((curCharVal >= 65) && (curCharVal <= 90)) { // A-Z upper case
   17535       103883 :             if (foundOther) {
   17536        88382 :                 outString += c; // keep as upper case after finding a space or another character
   17537              :             } else {
   17538        15501 :                 outString += char(curCharVal + 32); // convert to lower case
   17539              :             }
   17540       103883 :             foundOther = false;
   17541       593599 :         } else if ((curCharVal >= 97) && (curCharVal <= 122)) { // A-Z lower case
   17542       483635 :             if (foundOther) {
   17543         7028 :                 outString += char(curCharVal - 32); // convert to upper case
   17544              :             } else {
   17545       476607 :                 outString += c; // leave as lower case
   17546              :             }
   17547       483635 :             foundOther = false;
   17548       109964 :         } else if ((curCharVal >= 48) && (curCharVal <= 57)) { // 0-9 numbers
   17549              :             // if first character is a number then prepend with the letter "t"
   17550         9118 :             if (outString.length() == 0) outString += 't';
   17551         9118 :             outString += c;
   17552         9118 :             foundOther = false;
   17553       100846 :         } else if (curCharVal == 91) { // [ bracket
   17554         8634 :             break;                     // stop parsing because unit string was found
   17555              :         } else {
   17556        92212 :             foundOther = true;
   17557              :         }
   17558              :     }
   17559        34840 :     return outString;
   17560            0 : }
   17561              : 
   17562           10 : std::string ConvertUnicodeToUTF8(unsigned long const codepoint)
   17563              : {
   17564              :     // Taken from http://stackoverflow.com/a/19968992/2358662 and http://stackoverflow.com/a/148766/2358662
   17565           10 :     std::string s;
   17566           10 :     if (codepoint <= 0x7f) {
   17567            2 :         s.push_back(static_cast<char>(codepoint));
   17568            8 :     } else if (codepoint <= 0x7ff) {
   17569            4 :         s.push_back(static_cast<char>(0xc0 | ((codepoint >> 6) & 0x1f)));
   17570            4 :         s.push_back(static_cast<char>(0x80 | (codepoint & 0x3f)));
   17571            4 :     } else if (codepoint <= 0xffff) {
   17572            1 :         s.push_back(static_cast<char>(0xe0 | ((codepoint >> 12) & 0x0f)));
   17573            1 :         s.push_back(static_cast<char>(0x80 | ((codepoint >> 6) & 0x3f)));
   17574            1 :         s.push_back(static_cast<char>(0x80 | (codepoint & 0x3f)));
   17575            3 :     } else if (codepoint <= 0x10ffff) {
   17576            1 :         s.push_back(static_cast<char>(0xf0 | ((codepoint >> 18) & 0x07)));
   17577            1 :         s.push_back(static_cast<char>(0x80 | ((codepoint >> 12) & 0x3f)));
   17578            1 :         s.push_back(static_cast<char>(0x80 | ((codepoint >> 6) & 0x3f)));
   17579            1 :         s.push_back(static_cast<char>(0x80 | (codepoint & 0x3f)));
   17580              :     }
   17581           10 :     return s;
   17582            0 : }
   17583              : 
   17584       238912 : std::string ConvertToEscaped(std::string const &inString, bool isXML) // Input String
   17585              : {
   17586              :     // SUBROUTINE INFORMATION:
   17587              :     //       AUTHOR         Jason Glazer
   17588              :     //       DATE WRITTEN   February 2013
   17589              :     //       MODIFIED       na
   17590              :     //       RE-ENGINEERED  na
   17591              : 
   17592              :     // PURPOSE OF THIS SUBROUTINE:
   17593              :     //   Convert to XML safe escaped character string
   17594              :     //   so it excludes:
   17595              :     //               " ' < > & degree-sign
   17596              :     //   If isXML=false, it does an HTML conversion, so only ` < > & ` and degree sign
   17597              :     //   Technically HTML4 doesn't support &quot, though most browsers would anyways.
   17598              :     //   Also, escaping single and double quotes is only needed inside attributes
   17599              : 
   17600       238912 :     if (inString.empty()) {
   17601        14384 :         return "";
   17602              :     };
   17603              : 
   17604       231720 :     std::string s;
   17605       231720 :     size_t const inputSize = inString.size();
   17606       231720 :     s.reserve(inputSize);
   17607       231720 :     size_t index = 0;
   17608              : 
   17609              :     while (true) {
   17610      3382422 :         if (index == inputSize) {
   17611       231716 :             break;
   17612              :         }
   17613      3150706 :         char c = inString[index++];
   17614      3150706 :         if ((c == '\"') && isXML) {
   17615            1 :             s += "&quot;";
   17616      3150705 :         } else if (c == '&') {
   17617          188 :             s += "&amp;";
   17618      3150517 :         } else if ((c == '\'') && isXML) {
   17619           33 :             s += "&apos;";
   17620      3150484 :         } else if (c == '<') {
   17621          408 :             s += "&lt;";
   17622      3150076 :         } else if (c == '>') {
   17623         1324 :             s += "&gt;";
   17624      3148752 :         } else if (c == char(176) && !isXML) {
   17625           50 :             s += "&deg;";
   17626      3148702 :         } else if (c == char(226) && char(inString[index]) == char(137) && char(inString[index + 1]) == char(164) && !isXML) { // ≤
   17627          649 :             s += "&le;";
   17628          649 :             index += 2;
   17629      3148053 :         } else if (c == char(226) && char(inString[index]) == char(137) && char(inString[index + 1]) == char(165) && !isXML) { // ≥
   17630            1 :             s += "&ge;";
   17631            1 :             index += 2;
   17632      3148052 :         } else if (c == '\xC2') {
   17633         1328 :             if (index == inputSize) {
   17634            0 :                 s += '\xC2';
   17635              :             } else {
   17636         1328 :                 c = inString[index++];
   17637         1328 :                 if (c == '\xB0' && !isXML) {
   17638         1018 :                     s += "&deg;";
   17639              :                 } else {
   17640          310 :                     s += '\xC2';
   17641          310 :                     s += c;
   17642              :                 }
   17643              :             }
   17644      3146724 :         } else if (c == '\xB0' && !isXML) {
   17645            0 :             s += "&deg;";
   17646      3146724 :         } else if (c == '\\') {
   17647            8 :             if (index == inputSize) {
   17648            0 :                 break;
   17649              :             };
   17650            8 :             c = inString[index++];
   17651            8 :             if ((c == '"') && isXML) {
   17652            1 :                 s += "&quot;";
   17653            7 :             } else if ((c == '\'') && isXML) {
   17654            1 :                 s += "&apos;";
   17655            6 :             } else if (c == 'u' || c == 'x') {
   17656            6 :                 int remainingLen = inputSize - index;
   17657            6 :                 unsigned long codePoint(0);
   17658            6 :                 if (c == 'u' && remainingLen > 3) {
   17659            5 :                     codePoint = std::stoul(inString.substr(index, 4), nullptr, 16);
   17660            1 :                     index += 4;
   17661            3 :                 } else if (c == 'x' && remainingLen > 1) {
   17662            5 :                     codePoint = std::stoul(inString.substr(index, 2), nullptr, 16);
   17663            1 :                     index += 2;
   17664              :                 }
   17665            2 :                 std::string const unicodeString = ConvertUnicodeToUTF8(codePoint);
   17666            2 :                 if (unicodeString == "\xC2\xB0" && !isXML) { // only check for degree at this point
   17667            2 :                     s += "&deg;";
   17668              :                 } else {
   17669            0 :                     s += unicodeString;
   17670              :                 }
   17671            2 :             } else {
   17672            0 :                 s += c;
   17673              :             }
   17674              :         } else {
   17675      3146716 :             s += c;
   17676              :         }
   17677      3150702 :     }
   17678       231716 :     return s;
   17679       231720 : }
   17680              : 
   17681          144 : void DetermineBuildingFloorArea(EnergyPlusData &state)
   17682              : {
   17683              : 
   17684              :     // SUBROUTINE INFORMATION:
   17685              :     //       AUTHOR         Jason Glazer
   17686              :     //       DATE WRITTEN   November 2003
   17687              :     //       MODIFIED       BTG added checks for plenums. Feb2004
   17688              :     //       RE-ENGINEERED  na
   17689              : 
   17690              :     // PURPOSE OF THIS SUBROUTINE:
   17691              :     //   To determine the total floor area of the building and the
   17692              :     //   conditioned floor area of the building
   17693              : 
   17694              :     // METHODOLOGY EMPLOYED:
   17695              :     //   Use the Zone array and sum the areas for all zones
   17696              : 
   17697              :     // REFERENCES:
   17698              :     // na
   17699              : 
   17700              :     // Using/Aliasing
   17701              : 
   17702              :     // Locals
   17703              :     // SUBROUTINE ARGUMENT DEFINITIONS:
   17704              :     // na
   17705              : 
   17706              :     // SUBROUTINE PARAMETER DEFINITIONS:
   17707              : 
   17708              :     // INTERFACE BLOCK SPECIFICATIONS:
   17709              :     // na
   17710              : 
   17711              :     // DERIVED TYPE DEFINITIONS:
   17712              :     // na
   17713              : 
   17714              :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
   17715          144 :     auto const &ort = state.dataOutRptTab;
   17716              : 
   17717          144 :     ort->buildingGrossFloorArea = 0.0;
   17718          144 :     ort->buildingConditionedFloorArea = 0.0;
   17719          317 :     for (int iZone = 1; iZone <= state.dataGlobal->NumOfZones; ++iZone) {
   17720          173 :         auto const &thisZone = state.dataHeatBal->Zone(iZone);
   17721          173 :         Real64 const curZoneArea = thisZone.FloorArea * thisZone.Multiplier * thisZone.ListMultiplier;
   17722              : 
   17723              :         // OLD CHECK IF PLENUM SHOULD BE EXCLUDED AUTOMATICALLY
   17724              :         // check if this zone is also a return plenum or a supply plenum
   17725              :         // found = 0
   17726              :         // if (NumZoneReturnPlenums > 0) THEN
   17727              :         //  found = Util::FindItemInList(thisZone%Name, ZoneRetPlenCond%ZoneName, NumZoneReturnPlenums)
   17728              :         // endif
   17729              :         // IF (found /= 0)  curZoneArea = 0.0d0
   17730              :         // found = 0
   17731              :         // if (NumZoneSupplyPlenums > 0) THEN
   17732              :         //  found = Util::FindItemInList(thisZone%Name, ZoneSupPlenCond%ZoneName, NumZoneSupplyPlenums)
   17733              :         // endif
   17734              :         // IF (found /= 0)  curZoneArea = 0.0d0
   17735              : 
   17736          173 :         if (thisZone.isPartOfTotalArea) {
   17737          170 :             ort->buildingGrossFloorArea += curZoneArea;
   17738              :             // If a ZoneHVAC:EquipmentConnections is used for a zone then
   17739              :             // it is considered conditioned. Also ZONE SUPPLY PLENUM and ZONE RETURN PLENUM are
   17740              :             // also is considered conditioned.
   17741          170 :             if (thisZone.SystemZoneNodeNumber > 0) {
   17742           73 :                 ort->buildingConditionedFloorArea += curZoneArea;
   17743              :             }
   17744              :         }
   17745              :     }
   17746          144 : }
   17747              : 
   17748          132 : void FillRowHead(Array1D_string &rowHead)
   17749              : {
   17750              :     // Forward fill the blanks in rowHead (eg End use column)
   17751          132 :     std::string currentEndUseName;
   17752         1992 :     for (size_t i = 1; i <= rowHead.size(); ++i) {
   17753         1860 :         std::string &thisEndUseName = rowHead(i);
   17754         1860 :         if (thisEndUseName.empty()) {
   17755           12 :             thisEndUseName = currentEndUseName;
   17756              :         } else {
   17757         1848 :             currentEndUseName = thisEndUseName;
   17758              :         }
   17759              :     }
   17760          132 : }
   17761              : 
   17762              : //======================================================================================================================
   17763              : //======================================================================================================================
   17764              : 
   17765              : //    ROUTINES TO RESET GATHERED VALUES TO ZERO
   17766              : 
   17767              : //======================================================================================================================
   17768              : //======================================================================================================================
   17769              : 
   17770            0 : void ResetTabularReports(EnergyPlusData &state)
   17771              : {
   17772              :     // Jason Glazer - October 2015
   17773              :     // Reset all gathering arrays to zero for multi-year simulations
   17774              :     // so that only last year is reported in tabular reports
   17775            0 :     state.dataOutRptTab->gatherElapsedTimeBEPS = 0.0;
   17776            0 :     ResetMonthlyGathering(state);
   17777            0 :     OutputReportTabularAnnual::ResetAnnualGathering(state);
   17778            0 :     ResetBinGathering(state);
   17779            0 :     ResetBEPSGathering(state);
   17780            0 :     ResetSourceEnergyEndUseGathering(state);
   17781            0 :     ResetPeakDemandGathering(state);
   17782            0 :     ResetHeatGainGathering(state);
   17783            0 :     ResetRemainingPredefinedEntries(state);
   17784            0 :     ThermalComfort::ResetThermalComfortSimpleASH55(state);
   17785            0 :     ThermalComfort::ResetSetPointMet(state);
   17786            0 :     ResetAdaptiveComfort(state);
   17787            0 :     state.dataOutputProcessor->isFinalYear = true;
   17788            0 : }
   17789              : 
   17790            1 : void ResetMonthlyGathering(EnergyPlusData &state)
   17791              : {
   17792              :     // Jason Glazer - October 2015
   17793              :     // Reset all monthly gathering arrays to zero for multi-year simulations
   17794              :     // so that only last year is reported in tabular reports
   17795            1 :     auto &ort = state.dataOutRptTab;
   17796              : 
   17797            2 :     for (int iInput = 1; iInput <= ort->MonthlyInputCount; ++iInput) {
   17798            4 :         for (int jTable = 1; jTable <= ort->MonthlyInput(iInput).numTables; ++jTable) {
   17799            3 :             int const curTable = jTable + ort->MonthlyInput(iInput).firstTable - 1;
   17800           12 :             for (int kColumn = 1; kColumn <= ort->MonthlyTables(curTable).numColumns; ++kColumn) {
   17801            9 :                 int const curCol = kColumn + ort->MonthlyTables(curTable).firstColumn - 1;
   17802            9 :                 ort->MonthlyColumns(curCol).timeStamp = 0;
   17803            9 :                 ort->MonthlyColumns(curCol).duration = 0.0;
   17804           18 :                 if (ort->MonthlyColumns(curCol).aggType == AggType::Maximum ||
   17805            9 :                     ort->MonthlyColumns(curCol).aggType == AggType::MaximumDuringHoursShown) {
   17806            0 :                     ort->MonthlyColumns(curCol).reslt = -HUGE_(state.dataOutRptTab->BigNumRMG);
   17807           18 :                 } else if (ort->MonthlyColumns(curCol).aggType == AggType::Minimum ||
   17808            9 :                            ort->MonthlyColumns(curCol).aggType == AggType::MinimumDuringHoursShown) {
   17809            0 :                     ort->MonthlyColumns(curCol).reslt = HUGE_(state.dataOutRptTab->BigNumRMG);
   17810              :                 } else {
   17811            9 :                     ort->MonthlyColumns(curCol).reslt = 0.0;
   17812              :                 }
   17813              :             }
   17814              :         }
   17815              :     }
   17816            1 : }
   17817              : 
   17818            0 : void ResetBinGathering(EnergyPlusData const &state)
   17819              : {
   17820              :     // Jason Glazer - October 2015
   17821              :     // Reset all timebins gathering arrays to zero for multi-year simulations
   17822              :     // so that only last year is reported in tabular reports
   17823            0 :     Real64 constexpr bigVal(0.0); // used with HUGE: Value doesn't matter, only type: Initialize so compiler doesn't warn about use uninitialized
   17824            0 :     auto const &ort = state.dataOutRptTab;
   17825              : 
   17826              :     // clear the binning arrays to zeros
   17827            0 :     for (auto &e : ort->BinResults) {
   17828            0 :         e.mnth = 0.0;
   17829            0 :         e.hrly = 0.0;
   17830              :     }
   17831            0 :     for (auto &e : ort->BinResultsBelow) {
   17832            0 :         e.mnth = 0.0;
   17833            0 :         e.hrly = 0.0;
   17834              :     }
   17835            0 :     for (auto &e : ort->BinResultsAbove) {
   17836            0 :         e.mnth = 0.0;
   17837            0 :         e.hrly = 0.0;
   17838              :     }
   17839              : 
   17840              :     // re-initialize statistics counters
   17841            0 :     for (auto &e : ort->BinStatistics) {
   17842            0 :         e.minimum = HUGE_(bigVal);
   17843            0 :         e.maximum = -HUGE_(bigVal);
   17844            0 :         e.n = 0;
   17845            0 :         e.sum = 0.0;
   17846            0 :         e.sum2 = 0.0;
   17847              :     }
   17848            0 : }
   17849              : 
   17850            1 : void ResetBEPSGathering(EnergyPlusData const &state)
   17851              : {
   17852              :     // Jason Glazer - October 2015
   17853              :     // Reset all ABUPS gathering arrays to zero for multi-year simulations
   17854              :     // so that only last year is reported in tabular reports
   17855            1 :     auto const &ort = state.dataOutRptTab;
   17856            1 :     ort->gatherTotalsBEPS = 0.0;
   17857            1 :     ort->gatherEndUseBEPS = 0.0;
   17858            1 :     ort->gatherEndUseSubBEPS = 0.0;
   17859            1 :     ort->gatherTotalsSource = 0.0;
   17860              :     // reset the specific components being gathered
   17861            1 :     ort->gatherPowerFuelFireGen = 0.0;
   17862            1 :     ort->gatherPowerPV = 0.0;
   17863            1 :     ort->gatherPowerWind = 0.0;
   17864            1 :     ort->gatherPowerHTGeothermal = 0.0;
   17865            1 :     ort->gatherElecProduced = 0.0;
   17866            1 :     ort->gatherElecPurchased = 0.0;
   17867            1 :     ort->gatherElecSurplusSold = 0.0;
   17868            1 :     ort->gatherElecStorage = 0.0;
   17869            1 :     ort->gatherPowerConversion = 0.0;
   17870            1 :     ort->gatherWaterHeatRecovery = 0.0;
   17871            1 :     ort->gatherAirHeatRecoveryCool = 0.0;
   17872            1 :     ort->gatherAirHeatRecoveryHeat = 0.0;
   17873            1 :     ort->gatherHeatHTGeothermal = 0.0;
   17874            1 :     ort->gatherHeatSolarWater = 0.0;
   17875            1 :     ort->gatherHeatSolarAir = 0.0;
   17876            1 :     ort->gatherRainWater = 0.0;
   17877            1 :     ort->gatherCondensate = 0.0;
   17878            1 :     ort->gatherWellwater = 0.0;
   17879            1 :     ort->gatherMains = 0.0;
   17880            1 :     ort->gatherWaterEndUseTotal = 0.0;
   17881            1 : }
   17882              : 
   17883            0 : void ResetSourceEnergyEndUseGathering(EnergyPlusData const &state)
   17884              : {
   17885              :     // Jason Glazer - October 2015
   17886              :     // Reset all source energy end use table gathering arrays to zero for multi-year simulations
   17887              :     // so that only last year is reported in tabular reports
   17888            0 :     auto const &ort = state.dataOutRptTab;
   17889            0 :     ort->gatherTotalsBySourceBEPS = 0.0;
   17890            0 :     ort->gatherEndUseBySourceBEPS = 0.0;
   17891            0 : }
   17892              : 
   17893            0 : void ResetPeakDemandGathering(EnergyPlusData const &state)
   17894              : {
   17895              :     // Jason Glazer - October 2015
   17896              :     // Reset all demand end use components table gathering arrays to zero for multi-year simulations
   17897              :     // so that only last year is reported in tabular reports
   17898            0 :     auto const &ort = state.dataOutRptTab;
   17899            0 :     ort->gatherDemandTotal = 0.0;
   17900            0 :     ort->gatherDemandTimeStamp = 0;
   17901            0 :     ort->gatherDemandEndUse = 0.0;
   17902            0 :     ort->gatherDemandEndUseSub = 0.0;
   17903            0 : }
   17904              : 
   17905            0 : void ResetHeatGainGathering(EnergyPlusData &state)
   17906              : {
   17907              :     // Jason Glazer - October 2015
   17908              :     // Reset all sensible heat gas summary report gathering arrays to zero for multi-year simulations
   17909              :     // so that only last year is reported in tabular reports
   17910            0 :     for (int iZone = 1; iZone <= state.dataGlobal->NumOfZones; ++iZone) {
   17911            0 :         auto &thisZonePreDefRep = state.dataHeatBal->ZonePreDefRep(iZone);
   17912              : 
   17913            0 :         thisZonePreDefRep.SHGSAnPeoplAdd = 0.;
   17914            0 :         thisZonePreDefRep.SHGSAnLiteAdd = 0.;
   17915            0 :         thisZonePreDefRep.SHGSAnZoneEqHt = 0.;
   17916            0 :         thisZonePreDefRep.SHGSAnZoneEqCl = 0.;
   17917            0 :         thisZonePreDefRep.SHGSAnIzaAdd = 0.;
   17918            0 :         thisZonePreDefRep.SHGSAnIzaRem = 0.;
   17919            0 :         thisZonePreDefRep.SHGSAnWindAdd = 0.;
   17920            0 :         thisZonePreDefRep.SHGSAnWindRem = 0.;
   17921            0 :         thisZonePreDefRep.SHGSAnInfilAdd = 0.;
   17922            0 :         thisZonePreDefRep.SHGSAnInfilRem = 0.;
   17923            0 :         thisZonePreDefRep.SHGSAnEquipAdd = 0.;
   17924            0 :         thisZonePreDefRep.SHGSAnEquipRem = 0.;
   17925            0 :         thisZonePreDefRep.SHGSAnHvacATUHt = 0.;
   17926            0 :         thisZonePreDefRep.SHGSAnHvacATUCl = 0.;
   17927            0 :         thisZonePreDefRep.SHGSAnSurfHt = 0.;
   17928            0 :         thisZonePreDefRep.SHGSAnSurfCl = 0.;
   17929            0 :         thisZonePreDefRep.SHGSAnOtherAdd = 0.;
   17930            0 :         thisZonePreDefRep.SHGSAnOtherRem = 0.;
   17931            0 :         thisZonePreDefRep.htPeak = 0.;
   17932            0 :         thisZonePreDefRep.htPtTimeStamp = 0;
   17933            0 :         thisZonePreDefRep.SHGSHtHvacHt = 0.;
   17934            0 :         thisZonePreDefRep.SHGSHtHvacCl = 0.;
   17935            0 :         thisZonePreDefRep.SHGSHtSurfHt = 0.;
   17936            0 :         thisZonePreDefRep.SHGSHtSurfCl = 0.;
   17937            0 :         thisZonePreDefRep.SHGSHtHvacATUHt = 0.;
   17938            0 :         thisZonePreDefRep.SHGSHtHvacATUCl = 0.;
   17939            0 :         thisZonePreDefRep.SHGSHtPeoplAdd = 0.;
   17940            0 :         thisZonePreDefRep.SHGSHtLiteAdd = 0.;
   17941            0 :         thisZonePreDefRep.SHGSHtEquipAdd = 0.;
   17942            0 :         thisZonePreDefRep.SHGSHtEquipRem = 0.;
   17943            0 :         thisZonePreDefRep.SHGSHtWindAdd = 0.;
   17944            0 :         thisZonePreDefRep.SHGSHtWindRem = 0.;
   17945            0 :         thisZonePreDefRep.SHGSHtIzaAdd = 0.;
   17946            0 :         thisZonePreDefRep.SHGSHtIzaRem = 0.;
   17947            0 :         thisZonePreDefRep.SHGSHtInfilAdd = 0.;
   17948            0 :         thisZonePreDefRep.SHGSHtInfilRem = 0.;
   17949            0 :         thisZonePreDefRep.SHGSHtOtherAdd = 0.;
   17950            0 :         thisZonePreDefRep.SHGSHtOtherRem = 0.;
   17951            0 :         thisZonePreDefRep.clPeak = 0.;
   17952            0 :         thisZonePreDefRep.clPtTimeStamp = 0;
   17953            0 :         thisZonePreDefRep.SHGSClHvacHt = 0.;
   17954            0 :         thisZonePreDefRep.SHGSClHvacCl = 0.;
   17955            0 :         thisZonePreDefRep.SHGSClSurfHt = 0.;
   17956            0 :         thisZonePreDefRep.SHGSClSurfCl = 0.;
   17957            0 :         thisZonePreDefRep.SHGSClHvacATUHt = 0.;
   17958            0 :         thisZonePreDefRep.SHGSClHvacATUCl = 0.;
   17959            0 :         thisZonePreDefRep.SHGSClPeoplAdd = 0.;
   17960            0 :         thisZonePreDefRep.SHGSClLiteAdd = 0.;
   17961            0 :         thisZonePreDefRep.SHGSClEquipAdd = 0.;
   17962            0 :         thisZonePreDefRep.SHGSClEquipRem = 0.;
   17963            0 :         thisZonePreDefRep.SHGSClWindAdd = 0.;
   17964            0 :         thisZonePreDefRep.SHGSClWindRem = 0.;
   17965            0 :         thisZonePreDefRep.SHGSClIzaAdd = 0.;
   17966            0 :         thisZonePreDefRep.SHGSClIzaRem = 0.;
   17967            0 :         thisZonePreDefRep.SHGSClInfilAdd = 0.;
   17968            0 :         thisZonePreDefRep.SHGSClInfilRem = 0.;
   17969            0 :         thisZonePreDefRep.SHGSClOtherAdd = 0.;
   17970            0 :         thisZonePreDefRep.SHGSClOtherRem = 0.;
   17971              :     }
   17972              : 
   17973            0 :     state.dataHeatBal->BuildingPreDefRep.htPeak = 0.;
   17974            0 :     state.dataHeatBal->BuildingPreDefRep.htPtTimeStamp = 0;
   17975            0 :     state.dataHeatBal->BuildingPreDefRep.SHGSHtHvacHt = 0.0;
   17976            0 :     state.dataHeatBal->BuildingPreDefRep.SHGSHtHvacCl = 0.0;
   17977            0 :     state.dataHeatBal->BuildingPreDefRep.SHGSHtHvacATUHt = 0.0;
   17978            0 :     state.dataHeatBal->BuildingPreDefRep.SHGSHtHvacATUCl = 0.0;
   17979            0 :     state.dataHeatBal->BuildingPreDefRep.SHGSHtSurfHt = 0.0;
   17980            0 :     state.dataHeatBal->BuildingPreDefRep.SHGSHtSurfCl = 0.0;
   17981            0 :     state.dataHeatBal->BuildingPreDefRep.SHGSHtPeoplAdd = 0.0;
   17982            0 :     state.dataHeatBal->BuildingPreDefRep.SHGSHtLiteAdd = 0.0;
   17983            0 :     state.dataHeatBal->BuildingPreDefRep.SHGSHtEquipAdd = 0.0;
   17984            0 :     state.dataHeatBal->BuildingPreDefRep.SHGSHtWindAdd = 0.0;
   17985            0 :     state.dataHeatBal->BuildingPreDefRep.SHGSHtIzaAdd = 0.0;
   17986            0 :     state.dataHeatBal->BuildingPreDefRep.SHGSHtInfilAdd = 0.0;
   17987            0 :     state.dataHeatBal->BuildingPreDefRep.SHGSHtOtherAdd = 0.0;
   17988            0 :     state.dataHeatBal->BuildingPreDefRep.SHGSHtEquipRem = 0.0;
   17989            0 :     state.dataHeatBal->BuildingPreDefRep.SHGSHtWindRem = 0.0;
   17990            0 :     state.dataHeatBal->BuildingPreDefRep.SHGSHtIzaRem = 0.0;
   17991            0 :     state.dataHeatBal->BuildingPreDefRep.SHGSHtInfilRem = 0.0;
   17992            0 :     state.dataHeatBal->BuildingPreDefRep.SHGSHtOtherRem = 0.0;
   17993              : 
   17994            0 :     state.dataHeatBal->BuildingPreDefRep.clPeak = 0.;
   17995            0 :     state.dataHeatBal->BuildingPreDefRep.clPtTimeStamp = 0;
   17996            0 :     state.dataHeatBal->BuildingPreDefRep.SHGSClHvacHt = 0.0;
   17997            0 :     state.dataHeatBal->BuildingPreDefRep.SHGSClHvacCl = 0.0;
   17998            0 :     state.dataHeatBal->BuildingPreDefRep.SHGSClSurfHt = 0.0;
   17999            0 :     state.dataHeatBal->BuildingPreDefRep.SHGSClSurfCl = 0.0;
   18000            0 :     state.dataHeatBal->BuildingPreDefRep.SHGSClHvacATUHt = 0.0;
   18001            0 :     state.dataHeatBal->BuildingPreDefRep.SHGSClHvacATUCl = 0.0;
   18002            0 :     state.dataHeatBal->BuildingPreDefRep.SHGSClPeoplAdd = 0.0;
   18003            0 :     state.dataHeatBal->BuildingPreDefRep.SHGSClLiteAdd = 0.0;
   18004            0 :     state.dataHeatBal->BuildingPreDefRep.SHGSClEquipAdd = 0.0;
   18005            0 :     state.dataHeatBal->BuildingPreDefRep.SHGSClWindAdd = 0.0;
   18006            0 :     state.dataHeatBal->BuildingPreDefRep.SHGSClIzaAdd = 0.0;
   18007            0 :     state.dataHeatBal->BuildingPreDefRep.SHGSClInfilAdd = 0.0;
   18008            0 :     state.dataHeatBal->BuildingPreDefRep.SHGSClOtherAdd = 0.0;
   18009            0 :     state.dataHeatBal->BuildingPreDefRep.SHGSClEquipRem = 0.0;
   18010            0 :     state.dataHeatBal->BuildingPreDefRep.SHGSClWindRem = 0.0;
   18011            0 :     state.dataHeatBal->BuildingPreDefRep.SHGSClIzaRem = 0.0;
   18012            0 :     state.dataHeatBal->BuildingPreDefRep.SHGSClInfilRem = 0.0;
   18013            0 :     state.dataHeatBal->BuildingPreDefRep.SHGSClOtherRem = 0.0;
   18014            0 : }
   18015              : 
   18016            0 : void ResetRemainingPredefinedEntries(EnergyPlusData &state)
   18017              : {
   18018              :     // Jason Glazer - October 2015
   18019              :     // Reset all entries that are added to the predefined reports in the FillRemainingPredefinedEntries() function to zero for multi-year
   18020              :     // simulations so that only last year is reported in tabular reports
   18021              : 
   18022            0 :     Real64 constexpr bigVal(0.0); // used with HUGE: Value doesn't matter, only type: Initialize so compiler doesn't warn about use uninitialized
   18023              : 
   18024            0 :     for (int iLight = 1; iLight <= state.dataHeatBal->TotLights; ++iLight) {
   18025            0 :         state.dataHeatBal->Lights(iLight).SumTimeNotZeroCons = 0.;
   18026            0 :         state.dataHeatBal->Lights(iLight).SumConsumption = 0.;
   18027              :     }
   18028              : 
   18029            0 :     for (int iZone = 1; iZone <= state.dataGlobal->NumOfZones; ++iZone) {
   18030            0 :         auto const &thisZone = state.dataHeatBal->Zone(iZone);
   18031              : 
   18032            0 :         if (thisZone.SystemZoneNodeNumber >= 0) { // conditioned zones only
   18033            0 :             if (thisZone.isNominalOccupied) {
   18034            0 :                 auto &thisZonePreDefRep = state.dataHeatBal->ZonePreDefRep(iZone);
   18035              : 
   18036            0 :                 thisZonePreDefRep.MechVentVolTotalOcc = 0.;
   18037            0 :                 thisZonePreDefRep.MechVentVolTotalOccStdDen = 0.;
   18038            0 :                 thisZonePreDefRep.MechVentVolMin = HUGE_(bigVal);
   18039            0 :                 thisZonePreDefRep.InfilVolTotalOcc = 0.;
   18040            0 :                 thisZonePreDefRep.InfilVolTotalOccStdDen = 0.;
   18041            0 :                 thisZonePreDefRep.InfilVolMin = HUGE_(bigVal);
   18042            0 :                 thisZonePreDefRep.AFNInfilVolTotalOcc = 0.;
   18043            0 :                 thisZonePreDefRep.AFNInfilVolTotalOccStdDen = 0.;
   18044            0 :                 thisZonePreDefRep.AFNInfilVolMin = HUGE_(bigVal);
   18045            0 :                 thisZonePreDefRep.SimpVentVolTotalOcc = 0.;
   18046            0 :                 thisZonePreDefRep.SimpVentVolTotalOccStdDen = 0.;
   18047            0 :                 thisZonePreDefRep.SimpVentVolMin = HUGE_(bigVal);
   18048            0 :                 thisZonePreDefRep.AFNVentVolTotalOccStdDen = 0.;
   18049            0 :                 thisZonePreDefRep.TotTimeOcc = 0.;
   18050              :             }
   18051              :         }
   18052              :     }
   18053            0 : }
   18054              : 
   18055            0 : void ResetAdaptiveComfort(EnergyPlusData &state)
   18056              : {
   18057              :     // Jason Glazer - October 2015
   18058              :     // Reset accumulation variable for adaptive comfort report to zero for multi-year simulations
   18059              :     // so that only last year is reported in tabular reports
   18060            0 :     auto const &ort = state.dataOutRptTab;
   18061            0 :     if (ort->displayAdaptiveComfort && state.dataHeatBal->TotPeople > 0) {
   18062            0 :         for (int i = 1; i <= state.dataHeatBal->TotPeople; ++i) {
   18063            0 :             auto &thisPeople = state.dataHeatBal->People(i);
   18064              : 
   18065            0 :             if (thisPeople.AdaptiveASH55) {
   18066            0 :                 thisPeople.TimeNotMetASH5590 = 0.;
   18067            0 :                 thisPeople.TimeNotMetASH5580 = 0.;
   18068              :             }
   18069            0 :             if (thisPeople.AdaptiveCEN15251) {
   18070            0 :                 thisPeople.TimeNotMetCEN15251CatI = 0.;
   18071            0 :                 thisPeople.TimeNotMetCEN15251CatII = 0.;
   18072            0 :                 thisPeople.TimeNotMetCEN15251CatIII = 0.;
   18073              :             }
   18074              :         }
   18075              :     }
   18076            0 : }
   18077              : 
   18078              : //======================================================================================================================
   18079              : //======================================================================================================================
   18080              : 
   18081              : //    ROUTINES RELATED TO IF VALUE IS IN A RANGE
   18082              : 
   18083              : //======================================================================================================================
   18084              : //======================================================================================================================
   18085              : 
   18086        30496 : bool isInTriangle(
   18087              :     Real64 const qx, Real64 const qy, Real64 const x1, Real64 const y1, Real64 const x2, Real64 const y2, Real64 const x3, Real64 const y3)
   18088              : {
   18089              :     // SUBROUTINE INFORMATION:
   18090              :     //       AUTHOR         Jason Glazer
   18091              :     //       DATE WRITTEN   June 2005
   18092              :     //       MODIFIED
   18093              :     //       RE-ENGINEERED  na
   18094              : 
   18095              :     // PURPOSE OF THIS SUBROUTINE:
   18096              :     //   Determine if point q is in triangle defined by points a,b,c
   18097              : 
   18098              :     // METHODOLOGY EMPLOYED:
   18099              :     //   The function used three times is positive the point is on the "right"
   18100              :     //   side and negative if on "left" side. By checking to make sure the signs
   18101              :     //   are always the same. it determines that the point is inside of the
   18102              :     //   triangle.
   18103              : 
   18104              :     // REFERENCES:
   18105              :     //   http://mcraefamily.com/MathHelp/GeometryPointAndTriangle2.htm
   18106              : 
   18107        30496 :     Real64 const fAB = (qy - y1) * (x2 - x1) - (qx - x1) * (y2 - y1);
   18108        30496 :     Real64 const fCA = (qy - y3) * (x1 - x3) - (qx - x3) * (y1 - y3);
   18109        30496 :     Real64 const fBC = (qy - y2) * (x3 - x2) - (qx - x2) * (y3 - y2);
   18110        30496 :     return ((fAB * fBC) >= 0.0 && (fBC * fCA) >= 0.0);
   18111              : }
   18112              : 
   18113        15248 : bool isInQuadrilateral(Real64 const qx,
   18114              :                        Real64 const qy,
   18115              :                        Real64 const ax,
   18116              :                        Real64 const ay,
   18117              :                        Real64 const bx,
   18118              :                        Real64 const by,
   18119              :                        Real64 const cx,
   18120              :                        Real64 const cy,
   18121              :                        Real64 const dx,
   18122              :                        Real64 const dy)
   18123              : {
   18124              :     // SUBROUTINE INFORMATION:
   18125              :     //       AUTHOR         Jason Glazer
   18126              :     //       DATE WRITTEN   June 2005
   18127              :     //       MODIFIED
   18128              :     //       RE-ENGINEERED  na
   18129              : 
   18130              :     // PURPOSE OF THIS SUBROUTINE:
   18131              :     //   Determine if point q is in a quadrilateral defined by points a,b,c,d
   18132              :     //   Those points should express a quadrilateral in order of the points going
   18133              :     //   around the outside of the polygon. They should not describe an "hourglass"
   18134              :     //   shape where the lines cross in the middle of the figure.
   18135              : 
   18136              :     // METHODOLOGY EMPLOYED:
   18137              :     //   Check if the point is in triangle a,b,c or in triangle c,d,a
   18138              : 
   18139              :     // REFERENCES:
   18140              :     //   http://mcraefamily.com/MathHelp/GeometryPointAndTriangle4.htm
   18141              : 
   18142        15248 :     bool const inABC = isInTriangle(qx, qy, ax, ay, bx, by, cx, cy);
   18143        15248 :     bool const inCDA = isInTriangle(qx, qy, cx, cy, dx, dy, ax, ay);
   18144        15248 :     return (inABC || inCDA);
   18145              : }
   18146              : 
   18147              : //======================================================================================================================
   18148              : //======================================================================================================================
   18149              : 
   18150              : //    SUPPORT ROUTINES
   18151              : 
   18152              : //======================================================================================================================
   18153              : //======================================================================================================================
   18154              : 
   18155        91152 : std::string RealToStr(Real64 const RealIn, int const numDigits)
   18156              : {
   18157              :     // FUNCTION INFORMATION:
   18158              :     //       AUTHOR         Jason Glazer
   18159              :     //       DATE WRITTEN   August 2003
   18160              :     //       MODIFIED       November 2008; LKL - prevent errors
   18161              :     //       RE-ENGINEERED  na
   18162              : 
   18163              :     // PURPOSE OF THIS FUNCTION:
   18164              :     //   Abstract away the internal write concept
   18165              : 
   18166              :     static constexpr std::array<const char *, 10> formDigitsA{
   18167              :         "{:#11.0F}", "{:12.1F}", "{:12.2F}", "{:12.3F}", "{:12.4F}", "{:12.5F}", "{:12.6F}", "{:12.7F}", "{:12.8F}", "{:12.9F}"};
   18168              : 
   18169              :     static constexpr std::array<Real64, 10> maxvalDigitsA(
   18170              :         {9999999999.0, 999999999.0, 99999999.0, 9999999.0, 999999.0, 99999.0, 9999.0, 999.0, 99.0, 9.0});
   18171              : 
   18172              :     // FUNCTION LOCAL VARIABLE DECLARATIONS:
   18173        91152 :     int nDigits = numDigits;
   18174        91152 :     if (RealIn < 0.0) --nDigits;
   18175        91152 :     if (nDigits > 9) nDigits = 9;
   18176        91152 :     if (nDigits < 0) nDigits = 0;
   18177              : 
   18178        91152 :     if (std::abs(RealIn) > maxvalDigitsA.at(nDigits)) {
   18179          148 :         return format("{:12.6Z}", RealIn);
   18180              :     } else {
   18181        91004 :         return format<FormatSyntax::FMT>(formDigitsA.at(nDigits), RealIn);
   18182              :     }
   18183              :     //  WRITE(FMT=, UNIT=stringOut) RealIn
   18184              :     // check if it did not fit
   18185              :     //  IF (stringOut(1:1) .EQ. "*") THEN
   18186              :     //    WRITE(FMT='(E12.6)', UNIT=stringOut) RealIn
   18187              :     //  END IF
   18188              : 
   18189              :     // WRITE(FMT="(F10.4)", UNIT=stringOut, IOSTAT=status ) RealIn
   18190              : }
   18191              : 
   18192         9142 : Real64 StrToReal(std::string_view stringIn)
   18193              : {
   18194              :     // SUBROUTINE INFORMATION:
   18195              :     //       AUTHOR         Linda Lawrie
   18196              :     //       DATE WRITTEN   March 2010
   18197              :     //       MODIFIED       na
   18198              :     //       RE-ENGINEERED  na
   18199              : 
   18200              :     // PURPOSE OF THIS SUBROUTINE:
   18201              :     //   Abstract away the internal read concept
   18202              : 
   18203         9142 :     size_t first_char = stringIn.find_first_not_of(' ');
   18204         9142 :     if (first_char != std::string_view::npos) {
   18205         9142 :         stringIn.remove_prefix(first_char);
   18206              :     }
   18207              : 
   18208         9142 :     Real64 realValue = -99999.0;
   18209         9142 :     auto answer = fast_float::from_chars(stringIn.data(), stringIn.data() + stringIn.size(), realValue); // (AUTO_OK_OBJ)
   18210         9142 :     if (answer.ec != std::errc()) {
   18211            0 :         return -99999.0;
   18212              :     }
   18213         9142 :     return realValue;
   18214              : }
   18215              : 
   18216         1038 : std::string DateToString(int const codedDate) // word containing encoded month, day, hour, minute
   18217              : {
   18218              :     // SUBROUTINE INFORMATION:
   18219              :     //       AUTHOR         Jason Glazer
   18220              :     //       DATE WRITTEN   August 2003
   18221              :     //       MODIFIED       na
   18222              :     //       RE-ENGINEERED  na
   18223              : 
   18224              :     // PURPOSE OF THIS SUBROUTINE:
   18225              :     //   Convert the coded date format into a usable
   18226              :     //   string
   18227              : 
   18228              :     int Month;  // month in integer format (1-12)
   18229              :     int Day;    // day in integer format (1-31)
   18230              :     int Hour;   // hour in integer format (1-24)
   18231              :     int Minute; // minute in integer format (0:59)
   18232              :     static constexpr std::array<std::string_view, 12> Months{"JAN", "FEB", "MAR", "APR", "MAY", "JUN", "JUL", "AUG", "SEP", "OCT", "NOV", "DEC"};
   18233              : 
   18234         1038 :     if (codedDate == 0) {
   18235         2016 :         return "-";
   18236              :     }
   18237              : 
   18238           30 :     General::DecodeMonDayHrMin(codedDate, Month, Day, Hour, Minute);
   18239           30 :     if (Month < 1 || Month > 12) {
   18240            0 :         return "-";
   18241              :     }
   18242              : 
   18243           30 :     --Hour;
   18244           30 :     if (Minute == 60) {
   18245            0 :         ++Hour;
   18246            0 :         Minute = 0;
   18247              :     }
   18248              : 
   18249           60 :     return fmt::format("{:02}-{:3}-{:02}:{:02}", Day, Months[Month - 1], Hour, Minute);
   18250              : }
   18251              : 
   18252          534 : bool isNumber(std::string const &s)
   18253              : {
   18254              :     char *p;
   18255          534 :     strtod(s.c_str(), &p);
   18256          540 :     for (; isspace(*p); ++p)
   18257              :         ; // handle trailing whitespace
   18258          534 :     return *p == 0;
   18259              : }
   18260              : 
   18261              : // return the number of digits after the decimal point
   18262              : // Glazer - November 2016
   18263          196 : int digitsAferDecimal(std::string const &s)
   18264              : {
   18265          196 :     std::size_t decimalpos = s.find('.');
   18266              :     std::size_t numDigits;
   18267          196 :     if (decimalpos == s.npos) {
   18268            7 :         numDigits = 0;
   18269              :     } else {
   18270          189 :         std::size_t epos = s.find('E');
   18271          189 :         if (epos == s.npos) epos = s.find('e');
   18272          189 :         if (epos == s.npos) {
   18273          177 :             numDigits = s.length() - (decimalpos + 1);
   18274              :         } else {
   18275           12 :             numDigits = epos - (decimalpos + 1);
   18276              :         }
   18277              :     }
   18278          196 :     return int(numDigits);
   18279              : }
   18280              : 
   18281           12 : void AddTOCEntry(EnergyPlusData &state, std::string const &nameSection, std::string const &nameReport)
   18282              : {
   18283              :     // SUBROUTINE INFORMATION:
   18284              :     //    AUTHOR         Jason Glazer of GARD Analytics, Inc.
   18285              :     //    DATE WRITTEN   September 2005
   18286              :     //    MODIFIED       na
   18287              :     //    RE-ENGINEERED  na
   18288              : 
   18289              :     // PURPOSE OF THIS SUBROUTINE:
   18290              :     //   Adds an entry for the TOC so that it can be created
   18291              :     //   prior to the actual reports being generated. Note that
   18292              :     //   the arguments must match what is used in
   18293              :     //   "WriteReportHeaders" for the HTML anchors to work
   18294              :     //   correctly.
   18295              : 
   18296              :     // METHODOLOGY EMPLOYED:
   18297              : 
   18298              :     // REFERENCES:
   18299              :     //    na
   18300              : 
   18301              :     // USE STATEMENTS:
   18302              : 
   18303              :     // Locals
   18304              :     // SUBROUTINE ARGUMENT DEFINITIONS:
   18305              : 
   18306              :     // SUBROUTINE PARAMETER DEFINITIONS:
   18307              :     //    na
   18308              : 
   18309              :     // INTERFACE BLOCK SPECIFICATIONS:
   18310              :     //    na
   18311              : 
   18312              :     // DERIVED TYPE DEFINITIONS:
   18313              :     //    na
   18314              : 
   18315              :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
   18316              :     //    na
   18317           12 :     auto &ort = state.dataOutRptTab;
   18318              : 
   18319           12 :     if (!allocated(ort->TOCEntries)) {
   18320            4 :         ort->TOCEntriesSize = 20;
   18321            4 :         ort->TOCEntries.allocate(ort->TOCEntriesSize);
   18322            4 :         ort->TOCEntriesCount = 1;
   18323              :     } else {
   18324            8 :         ++ort->TOCEntriesCount;
   18325              :         // if larger than current size grow the array
   18326            8 :         if (ort->TOCEntriesCount > ort->TOCEntriesSize) {
   18327            0 :             ort->TOCEntries.redimension(ort->TOCEntriesSize += 20);
   18328              :         }
   18329              :     }
   18330           12 :     ort->TOCEntries(ort->TOCEntriesCount).reportName = nameReport;
   18331           12 :     ort->TOCEntries(ort->TOCEntriesCount).sectionName = nameSection;
   18332           12 : }
   18333              : 
   18334           94 : void SetupUnitConversions(EnergyPlusData &state)
   18335              : {
   18336              :     // SUBROUTINE INFORMATION:
   18337              :     //    AUTHOR         Jason Glazer of GARD Analytics, Inc.
   18338              :     //    DATE WRITTEN   February 12, 2009
   18339              :     //    MODIFIED       March 2010; Linda Lawrie; Add deltaC and KJ/KG
   18340              :     //    RE-ENGINEERED  na
   18341              : 
   18342              :     // PURPOSE OF THIS SUBROUTINE:
   18343              :     //   Initialize the array that contains the unit conversion
   18344              :     //   information. The code is based on code generated
   18345              :     //   in a spreadsheet titled UnitConversion.xls
   18346              : 
   18347              :     // METHODOLOGY EMPLOYED:
   18348              : 
   18349              :     // REFERENCES:
   18350              :     //    na
   18351              : 
   18352              :     // USE STATEMENTS:
   18353              : 
   18354              :     // SUBROUTINE ARGUMENT DEFINITIONS:
   18355              : 
   18356              :     // SUBROUTINE PARAMETER DEFINITIONS:
   18357              :     //    na
   18358              : 
   18359              :     // INTERFACE BLOCK SPECIFICATIONS:
   18360              :     //    na
   18361              : 
   18362              :     // DERIVED TYPE DEFINITIONS:
   18363              :     //    na
   18364              : 
   18365              :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
   18366              :     //    na
   18367           94 :     auto &ort = state.dataOutRptTab;
   18368              : 
   18369           94 :     ort->UnitConvSize = 118;
   18370           94 :     ort->UnitConv.allocate(ort->UnitConvSize);
   18371           94 :     ort->UnitConv(1).siName = "%";
   18372           94 :     ort->UnitConv(2).siName = "°C";
   18373           94 :     ort->UnitConv(3).siName = "0=OFF 1=ON";
   18374           94 :     ort->UnitConv(4).siName = "0-NO  1-YES";
   18375           94 :     ort->UnitConv(5).siName = "1-YES 0-NO";
   18376           94 :     ort->UnitConv(6).siName = "A";
   18377           94 :     ort->UnitConv(7).siName = "ACH";
   18378           94 :     ort->UnitConv(8).siName = "ACH";
   18379           94 :     ort->UnitConv(9).siName = "BASE 10C";
   18380           94 :     ort->UnitConv(10).siName = "BASE 18C";
   18381           94 :     ort->UnitConv(11).siName = "C";
   18382           94 :     ort->UnitConv(12).siName = "CD/M2";
   18383           94 :     ort->UnitConv(13).siName = "DEG";
   18384           94 :     ort->UnitConv(14).siName = "FRAC";
   18385           94 :     ort->UnitConv(15).siName = "HOUR";
   18386           94 :     ort->UnitConv(16).siName = "HOURS";
   18387           94 :     ort->UnitConv(17).siName = "HR";
   18388           94 :     ort->UnitConv(18).siName = "HRS";
   18389           94 :     ort->UnitConv(19).siName = "J";
   18390           94 :     ort->UnitConv(20).siName = "J";
   18391           94 :     ort->UnitConv(21).siName = "J";
   18392           94 :     ort->UnitConv(22).siName = "J";
   18393           94 :     ort->UnitConv(23).siName = "J";
   18394           94 :     ort->UnitConv(24).siName = "J";
   18395           94 :     ort->UnitConv(25).siName = "J/KG";
   18396           94 :     ort->UnitConv(26).siName = "J/KGWATER";
   18397           94 :     ort->UnitConv(27).siName = "J/M2";
   18398           94 :     ort->UnitConv(28).siName = "K/M";
   18399           94 :     ort->UnitConv(29).siName = "KG";
   18400           94 :     ort->UnitConv(30).siName = "KG/KG";
   18401           94 :     ort->UnitConv(31).siName = "KG/M3";
   18402           94 :     ort->UnitConv(32).siName = "KG/S";
   18403           94 :     ort->UnitConv(33).siName = "KGWATER/KGDRYAIR";
   18404           94 :     ort->UnitConv(34).siName = "KGWATER/SEC";
   18405           94 :     ort->UnitConv(35).siName = "KMOL/S";
   18406           94 :     ort->UnitConv(36).siName = "KMOL/SEC";
   18407           94 :     ort->UnitConv(37).siName = "KWH";
   18408           94 :     ort->UnitConv(38).siName = "L";
   18409           94 :     ort->UnitConv(39).siName = "L";
   18410           94 :     ort->UnitConv(40).siName = "LUM/W";
   18411           94 :     ort->UnitConv(41).siName = "LUX";
   18412           94 :     ort->UnitConv(42).siName = "M";
   18413           94 :     ort->UnitConv(43).siName = "M";
   18414           94 :     ort->UnitConv(44).siName = "M/S";
   18415           94 :     ort->UnitConv(45).siName = "M/S";
   18416           94 :     ort->UnitConv(46).siName = "M2";
   18417           94 :     ort->UnitConv(47).siName = "M2/PERSON";
   18418           94 :     ort->UnitConv(48).siName = "M3";
   18419           94 :     ort->UnitConv(49).siName = "M3";
   18420           94 :     ort->UnitConv(50).siName = "M3/M2";
   18421           94 :     ort->UnitConv(51).siName = "M3/S";
   18422           94 :     ort->UnitConv(52).siName = "M3/S";
   18423           94 :     ort->UnitConv(53).siName = "M3/S-M2";
   18424           94 :     ort->UnitConv(54).siName = "M3/S-PERSON";
   18425           94 :     ort->UnitConv(55).siName = "M3/S-PERSON";
   18426           94 :     ort->UnitConv(56).siName = "PA";
   18427           94 :     ort->UnitConv(57).siName = "PA";
   18428           94 :     ort->UnitConv(58).siName = "PA";
   18429           94 :     ort->UnitConv(59).siName = "PA";
   18430           94 :     ort->UnitConv(60).siName = "PA";
   18431           94 :     ort->UnitConv(61).siName = "PA";
   18432           94 :     ort->UnitConv(62).siName = "PA";
   18433           94 :     ort->UnitConv(63).siName = "PA";
   18434           94 :     ort->UnitConv(64).siName = "S";
   18435           94 :     ort->UnitConv(65).siName = "V";
   18436           94 :     ort->UnitConv(66).siName = "W";
   18437           94 :     ort->UnitConv(67).siName = "W";
   18438           94 :     ort->UnitConv(68).siName = "W";
   18439           94 :     ort->UnitConv(69).siName = "W";
   18440           94 :     ort->UnitConv(70).siName = "W";
   18441           94 :     ort->UnitConv(71).siName = "W/KG";
   18442           94 :     ort->UnitConv(72).siName = "W/KG H2O"; // TODO: replace with W/kgWater? or rather just remove
   18443           94 :     ort->UnitConv(73).siName = "W/K";
   18444           94 :     ort->UnitConv(74).siName = "W/M2";
   18445           94 :     ort->UnitConv(75).siName = "W/M2";
   18446           94 :     ort->UnitConv(76).siName = "W/M2-C";
   18447           94 :     ort->UnitConv(77).siName = "W/M2-K";
   18448           94 :     ort->UnitConv(78).siName = "W/W";
   18449           94 :     ort->UnitConv(79).siName = "W/W";
   18450           94 :     ort->UnitConv(80).siName = "deltaC";
   18451           94 :     ort->UnitConv(81).siName = "KJ/KG";
   18452           94 :     ort->UnitConv(82).siName = "W-S/M3";
   18453           94 :     ort->UnitConv(83).siName = "W-S/M3";
   18454           94 :     ort->UnitConv(84).siName = "~~$~~/m2";
   18455           94 :     ort->UnitConv(85).siName = "GJ";
   18456           94 :     ort->UnitConv(86).siName = "GJ";
   18457           94 :     ort->UnitConv(87).siName = "GJ";
   18458           94 :     ort->UnitConv(88).siName = "GJ";
   18459           94 :     ort->UnitConv(89).siName = "GJ";
   18460           94 :     ort->UnitConv(90).siName = "GJ";
   18461           94 :     ort->UnitConv(91).siName = "GJ";
   18462           94 :     ort->UnitConv(92).siName = "MJ/m2";
   18463           94 :     ort->UnitConv(93).siName = "MJ/m2";
   18464           94 :     ort->UnitConv(94).siName = "MJ/m2";
   18465           94 :     ort->UnitConv(95).siName = "MJ/m2";
   18466           94 :     ort->UnitConv(96).siName = "Invalid/Undefined";
   18467           94 :     ort->UnitConv(97).siName = "";
   18468           94 :     ort->UnitConv(98).siName = "W/C";
   18469           94 :     ort->UnitConv(99).siName = "DAY";
   18470           94 :     ort->UnitConv(100).siName = "MIN";
   18471           94 :     ort->UnitConv(101).siName = "HR/WK";
   18472           94 :     ort->UnitConv(102).siName = "$";
   18473           94 :     ort->UnitConv(103).siName = "$/UNIT ENERGY";
   18474           94 :     ort->UnitConv(104).siName = "KW";
   18475           94 :     ort->UnitConv(105).siName = " ";
   18476           94 :     ort->UnitConv(106).siName = "AH";
   18477           94 :     ort->UnitConv(107).siName = "CLO";
   18478           94 :     ort->UnitConv(108).siName = "J/KG-K";
   18479           94 :     ort->UnitConv(109).siName = "KGWATER/S";
   18480           94 :     ort->UnitConv(110).siName = "PPM";
   18481           94 :     ort->UnitConv(111).siName = "RAD";
   18482           94 :     ort->UnitConv(112).siName = "REV/MIN";
   18483           94 :     ort->UnitConv(113).siName = "NM";
   18484           94 :     ort->UnitConv(114).siName = "BTU/W-H"; // Used for AHRI rating metrics (e.g. SEER)
   18485           94 :     ort->UnitConv(115).siName = "PERSON/M2";
   18486           94 :     ort->UnitConv(116).siName = "MM";
   18487           94 :     ort->UnitConv(117).siName = "MM";
   18488           94 :     ort->UnitConv(118).siName = "°C·hr";
   18489              : 
   18490           94 :     ort->UnitConv(1).ipName = "%";
   18491           94 :     ort->UnitConv(2).ipName = "F";
   18492           94 :     ort->UnitConv(3).ipName = "0=Off 1=On";
   18493           94 :     ort->UnitConv(4).ipName = "0-No  1-Yes";
   18494           94 :     ort->UnitConv(5).ipName = "1-Yes 0-No";
   18495           94 :     ort->UnitConv(6).ipName = "A";
   18496           94 :     ort->UnitConv(7).ipName = "ACH";
   18497           94 :     ort->UnitConv(8).ipName = "ach";
   18498           94 :     ort->UnitConv(9).ipName = "base 50F";
   18499           94 :     ort->UnitConv(10).ipName = "base 65F";
   18500           94 :     ort->UnitConv(11).ipName = "F";
   18501           94 :     ort->UnitConv(12).ipName = "cd/in2";
   18502           94 :     ort->UnitConv(13).ipName = "deg";
   18503           94 :     ort->UnitConv(14).ipName = "Frac";
   18504           94 :     ort->UnitConv(15).ipName = "Hour";
   18505           94 :     ort->UnitConv(16).ipName = "Hours";
   18506           94 :     ort->UnitConv(17).ipName = "hr";
   18507           94 :     ort->UnitConv(18).ipName = "hrs";
   18508           94 :     ort->UnitConv(19).ipName = "kBtu";
   18509           94 :     ort->UnitConv(20).ipName = "kWh";
   18510           94 :     ort->UnitConv(21).ipName = "therm";
   18511           94 :     ort->UnitConv(22).ipName = "MMBtu";
   18512           94 :     ort->UnitConv(23).ipName = "Wh";
   18513           94 :     ort->UnitConv(24).ipName = "ton-hrs";
   18514           94 :     ort->UnitConv(25).ipName = "Btu/lb";
   18515           94 :     ort->UnitConv(26).ipName = "Btu/lbWater";
   18516           94 :     ort->UnitConv(27).ipName = "kBtu/sqft";
   18517           94 :     ort->UnitConv(28).ipName = "F/ft";
   18518           94 :     ort->UnitConv(29).ipName = "lb";
   18519           94 :     ort->UnitConv(30).ipName = "lb/lb";
   18520           94 :     ort->UnitConv(31).ipName = "lb/ft3";
   18521           94 :     ort->UnitConv(32).ipName = "lb/s";
   18522           94 :     ort->UnitConv(33).ipName = "lbWater/lbDryAir";
   18523           94 :     ort->UnitConv(34).ipName = "lbWater/s";
   18524           94 :     ort->UnitConv(35).ipName = "kmol/s";
   18525           94 :     ort->UnitConv(36).ipName = "kmol/sec";
   18526           94 :     ort->UnitConv(37).ipName = "kWh";
   18527           94 :     ort->UnitConv(38).ipName = "gal";
   18528           94 :     ort->UnitConv(39).ipName = "ft3";
   18529           94 :     ort->UnitConv(40).ipName = "lum/W";
   18530           94 :     ort->UnitConv(41).ipName = "foot-candles";
   18531           94 :     ort->UnitConv(42).ipName = "ft";
   18532           94 :     ort->UnitConv(43).ipName = "in";
   18533           94 :     ort->UnitConv(44).ipName = "ft/min";
   18534           94 :     ort->UnitConv(45).ipName = "miles/hr";
   18535           94 :     ort->UnitConv(46).ipName = "ft2";
   18536           94 :     ort->UnitConv(47).ipName = "ft2/person";
   18537           94 :     ort->UnitConv(48).ipName = "ft3";
   18538           94 :     ort->UnitConv(49).ipName = "gal";
   18539           94 :     ort->UnitConv(50).ipName = "f3/f2";
   18540           94 :     ort->UnitConv(51).ipName = "ft3/min";
   18541           94 :     ort->UnitConv(52).ipName = "gal/min";
   18542           94 :     ort->UnitConv(53).ipName = "ft3/min-ft2";
   18543           94 :     ort->UnitConv(54).ipName = "ft3/min-person";
   18544           94 :     ort->UnitConv(55).ipName = "gal/min-person";
   18545           94 :     ort->UnitConv(56).ipName = "psi";
   18546           94 :     ort->UnitConv(57).ipName = "inHg";
   18547           94 :     ort->UnitConv(58).ipName = "inH2O";
   18548           94 :     ort->UnitConv(59).ipName = "ftH2O";
   18549           94 :     ort->UnitConv(60).ipName = "psi";
   18550           94 :     ort->UnitConv(61).ipName = "inHg";
   18551           94 :     ort->UnitConv(62).ipName = "inH2O";
   18552           94 :     ort->UnitConv(63).ipName = "ftH2O";
   18553           94 :     ort->UnitConv(64).ipName = "s";
   18554           94 :     ort->UnitConv(65).ipName = "V";
   18555           94 :     ort->UnitConv(66).ipName = "Btu/h";
   18556           94 :     ort->UnitConv(67).ipName = "W";
   18557           94 :     ort->UnitConv(68).ipName = "kW";
   18558           94 :     ort->UnitConv(69).ipName = "kBtuh";
   18559           94 :     ort->UnitConv(70).ipName = "ton";
   18560           94 :     ort->UnitConv(71).ipName = "kBtuh/lb";
   18561           94 :     ort->UnitConv(72).ipName = "kBtuh/lb";
   18562           94 :     ort->UnitConv(73).ipName = "Btu/h-F";
   18563           94 :     ort->UnitConv(74).ipName = "Btu/h-ft2";
   18564           94 :     ort->UnitConv(75).ipName = "kBtuh/ft2";
   18565           94 :     ort->UnitConv(76).ipName = "Btu/h-ft2-F";
   18566           94 :     ort->UnitConv(77).ipName = "Btu/h-ft2-F";
   18567           94 :     ort->UnitConv(78).ipName = "Btuh/Btuh";
   18568           94 :     ort->UnitConv(79).ipName = "W/W";
   18569           94 :     ort->UnitConv(80).ipName = "deltaF";
   18570           94 :     ort->UnitConv(81).ipName = "Btu/lb";
   18571           94 :     ort->UnitConv(82).ipName = "W-min/ft3";
   18572           94 :     ort->UnitConv(83).ipName = "W-min/gal";
   18573           94 :     ort->UnitConv(84).ipName = "~~$~~/ft2";
   18574           94 :     ort->UnitConv(85).ipName = "kBtu";
   18575           94 :     ort->UnitConv(86).ipName = "kWh";
   18576           94 :     ort->UnitConv(87).ipName = "kWh";
   18577           94 :     ort->UnitConv(88).ipName = "therm";
   18578           94 :     ort->UnitConv(89).ipName = "MMBtu";
   18579           94 :     ort->UnitConv(90).ipName = "Wh";
   18580           94 :     ort->UnitConv(91).ipName = "ton-hrs";
   18581           94 :     ort->UnitConv(92).ipName = "kWh/ft2";
   18582           94 :     ort->UnitConv(93).ipName = "kBtu/ft2";
   18583           94 :     ort->UnitConv(94).ipName = "kBtu/ft2";
   18584           94 :     ort->UnitConv(95).ipName = "kWh/m2";
   18585           94 :     ort->UnitConv(96).ipName = "Invalid/Undefined";
   18586           94 :     ort->UnitConv(97).ipName = "";
   18587           94 :     ort->UnitConv(98).ipName = "Btu/h-F";
   18588           94 :     ort->UnitConv(99).ipName = "day";
   18589           94 :     ort->UnitConv(100).ipName = "min";
   18590           94 :     ort->UnitConv(101).ipName = "hr/wk";
   18591           94 :     ort->UnitConv(102).ipName = "$";
   18592           94 :     ort->UnitConv(103).ipName = "$/unit energy";
   18593           94 :     ort->UnitConv(104).ipName = "kW";
   18594           94 :     ort->UnitConv(105).ipName = " ";
   18595           94 :     ort->UnitConv(106).ipName = "Ah";
   18596           94 :     ort->UnitConv(107).ipName = "clo";
   18597           94 :     ort->UnitConv(108).ipName = "Btu/lbm-R";
   18598           94 :     ort->UnitConv(109).ipName = "lbWater/s";
   18599           94 :     ort->UnitConv(110).ipName = "ppm";
   18600           94 :     ort->UnitConv(111).ipName = "rad";
   18601           94 :     ort->UnitConv(112).ipName = "rev/min";
   18602           94 :     ort->UnitConv(113).ipName = "lbf-ft";
   18603           94 :     ort->UnitConv(114).ipName = "Btu/W-h";
   18604           94 :     ort->UnitConv(115).ipName = "person/ft2";
   18605           94 :     ort->UnitConv(116).ipName = "in";
   18606           94 :     ort->UnitConv(117).ipName = "ft";
   18607           94 :     ort->UnitConv(118).ipName = "°F·hr";
   18608              : 
   18609           94 :     ort->UnitConv(1).mult = 1.0;
   18610           94 :     ort->UnitConv(2).mult = 1.8;
   18611           94 :     ort->UnitConv(3).mult = 1.0;
   18612           94 :     ort->UnitConv(4).mult = 1.0;
   18613           94 :     ort->UnitConv(5).mult = 1.0;
   18614           94 :     ort->UnitConv(6).mult = 1.0;
   18615           94 :     ort->UnitConv(7).mult = 1.0;
   18616           94 :     ort->UnitConv(8).mult = 1.0;
   18617           94 :     ort->UnitConv(9).mult = 1.8;
   18618           94 :     ort->UnitConv(10).mult = 1.8;
   18619           94 :     ort->UnitConv(11).mult = 1.8;
   18620           94 :     ort->UnitConv(12).mult = 0.000645160041625726;
   18621           94 :     ort->UnitConv(13).mult = 1.0;
   18622           94 :     ort->UnitConv(14).mult = 1.0;
   18623           94 :     ort->UnitConv(15).mult = 1.0;
   18624           94 :     ort->UnitConv(16).mult = 1.0;
   18625           94 :     ort->UnitConv(17).mult = 1.0;
   18626           94 :     ort->UnitConv(18).mult = 1.0;
   18627           94 :     ort->UnitConv(19).mult = 0.00000094845;
   18628           94 :     ort->UnitConv(20).mult = 0.000000277778;
   18629           94 :     ort->UnitConv(21).mult = 0.0000000094845;
   18630           94 :     ort->UnitConv(22).mult = 0.00000000094845;
   18631           94 :     ort->UnitConv(23).mult = 0.000277777777777778;
   18632           94 :     ort->UnitConv(24).mult = 0.0000000789847;
   18633           94 :     ort->UnitConv(25).mult = 0.00042956;
   18634           94 :     ort->UnitConv(26).mult = 0.0000004302105;
   18635           94 :     ort->UnitConv(27).mult = 0.00000008811404;
   18636           94 :     ort->UnitConv(28).mult = 0.54861322767449;
   18637           94 :     ort->UnitConv(29).mult = 2.2046;
   18638           94 :     ort->UnitConv(30).mult = 1.0;
   18639           94 :     ort->UnitConv(31).mult = 0.062428;
   18640           94 :     ort->UnitConv(32).mult = 2.2046;
   18641           94 :     ort->UnitConv(33).mult = 1.0;
   18642           94 :     ort->UnitConv(34).mult = 2.2046;
   18643           94 :     ort->UnitConv(35).mult = 1.0;
   18644           94 :     ort->UnitConv(36).mult = 1.0;
   18645           94 :     ort->UnitConv(37).mult = 1.0;
   18646           94 :     ort->UnitConv(38).mult = 0.264172037284185;
   18647           94 :     ort->UnitConv(39).mult = 0.0353146624712848;
   18648           94 :     ort->UnitConv(40).mult = 1.0;
   18649           94 :     ort->UnitConv(41).mult = 0.092902267;
   18650           94 :     ort->UnitConv(42).mult = 3.281;
   18651           94 :     ort->UnitConv(43).mult = 39.37;
   18652           94 :     ort->UnitConv(44).mult = 196.86;
   18653           94 :     ort->UnitConv(45).mult = 2.2369;
   18654           94 :     ort->UnitConv(46).mult = 10.764961;
   18655           94 :     ort->UnitConv(47).mult = 10.764961;
   18656           94 :     ort->UnitConv(48).mult = 35.319837041;
   18657           94 :     ort->UnitConv(49).mult = 264.172;
   18658           94 :     ort->UnitConv(50).mult = 3.281;
   18659           94 :     ort->UnitConv(51).mult = 2118.6438;
   18660           94 :     ort->UnitConv(52).mult = 15852.0;
   18661           94 :     ort->UnitConv(53).mult = 196.85;
   18662           94 :     ort->UnitConv(54).mult = 2118.6438;
   18663           94 :     ort->UnitConv(55).mult = 15852.0;
   18664           94 :     ort->UnitConv(56).mult = 0.0001450377;
   18665           94 :     ort->UnitConv(57).mult = 0.00029613;
   18666           94 :     ort->UnitConv(58).mult = 0.00401463;
   18667           94 :     ort->UnitConv(59).mult = 0.00033455;
   18668           94 :     ort->UnitConv(60).mult = 0.0001450377;
   18669           94 :     ort->UnitConv(61).mult = 0.00029613;
   18670           94 :     ort->UnitConv(62).mult = 0.00401463;
   18671           94 :     ort->UnitConv(63).mult = 0.00033455;
   18672           94 :     ort->UnitConv(64).mult = 1.0;
   18673           94 :     ort->UnitConv(65).mult = 1.0;
   18674           94 :     ort->UnitConv(66).mult = 3.412;
   18675           94 :     ort->UnitConv(67).mult = 1.0;
   18676           94 :     ort->UnitConv(68).mult = 0.001;
   18677           94 :     ort->UnitConv(69).mult = 0.00341442;
   18678           94 :     ort->UnitConv(70).mult = 0.0002843333;
   18679           94 :     ort->UnitConv(71).mult = 0.001547673;
   18680           94 :     ort->UnitConv(72).mult = 0.001547673;
   18681           94 :     ort->UnitConv(73).mult = 1.8987;
   18682           94 :     ort->UnitConv(74).mult = 0.316954237;
   18683           94 :     ort->UnitConv(75).mult = 0.000316954237;
   18684           94 :     ort->UnitConv(76).mult = 0.176085687;
   18685           94 :     ort->UnitConv(77).mult = 0.176085687;
   18686           94 :     ort->UnitConv(78).mult = 1.0;
   18687           94 :     ort->UnitConv(79).mult = 1.0;
   18688           94 :     ort->UnitConv(80).mult = 1.8;
   18689           94 :     ort->UnitConv(81).mult = 0.42956;
   18690           94 :     ort->UnitConv(82).mult = 1.0 / 2118.6438;
   18691           94 :     ort->UnitConv(83).mult = 1.0 / 15852;
   18692           94 :     ort->UnitConv(84).mult = 1.0 / 10.764961;
   18693           94 :     ort->UnitConv(85).mult = 0.00000094845 * 1000000000;
   18694           94 :     ort->UnitConv(86).mult = 0.000000277778 * 1000000000;
   18695           94 :     ort->UnitConv(87).mult = 0.000000277778 * 1000000000;
   18696           94 :     ort->UnitConv(88).mult = 0.0000000094845 * 1000000000;
   18697           94 :     ort->UnitConv(89).mult = 0.00000000094845 * 1000000000;
   18698           94 :     ort->UnitConv(90).mult = 0.000277777777777778 * 1000000000;
   18699           94 :     ort->UnitConv(91).mult = 0.0000000789847 * 1000000000;
   18700           94 :     ort->UnitConv(92).mult = 0.277777777777778 / 10.764961;
   18701           94 :     ort->UnitConv(93).mult = 0.94708628903179 / 10.764961;
   18702           94 :     ort->UnitConv(94).mult = 0.94708628903179 / 10.764961;
   18703           94 :     ort->UnitConv(95).mult = 0.27777777777778;
   18704           94 :     ort->UnitConv(96).mult = 1.0;
   18705           94 :     ort->UnitConv(97).mult = 1.0;
   18706           94 :     ort->UnitConv(98).mult = 1.8987;
   18707           94 :     ort->UnitConv(99).mult = 1.0;
   18708           94 :     ort->UnitConv(100).mult = 1.0;
   18709           94 :     ort->UnitConv(101).mult = 1.0;
   18710           94 :     ort->UnitConv(102).mult = 1.0;
   18711           94 :     ort->UnitConv(103).mult = 1.0;
   18712           94 :     ort->UnitConv(104).mult = 1.0;
   18713           94 :     ort->UnitConv(105).mult = 1.0;
   18714           94 :     ort->UnitConv(106).mult = 1.0;
   18715           94 :     ort->UnitConv(107).mult = 1.0;
   18716           94 :     ort->UnitConv(108).mult = 0.000238845896627;
   18717           94 :     ort->UnitConv(109).mult = 2.2046;
   18718           94 :     ort->UnitConv(110).mult = 1.0;
   18719           94 :     ort->UnitConv(111).mult = 1.0;
   18720           94 :     ort->UnitConv(112).mult = 1.0;
   18721           94 :     ort->UnitConv(113).mult = 0.737562149277;
   18722           94 :     ort->UnitConv(114).mult = 1.0;
   18723           94 :     ort->UnitConv(115).mult = 0.09290304;
   18724           94 :     ort->UnitConv(116).mult = 0.03937;
   18725           94 :     ort->UnitConv(117).mult = 0.003281;
   18726           94 :     ort->UnitConv(118).mult = 1.8;
   18727              : 
   18728           94 :     ort->UnitConv(2).offset = 32.0;
   18729           94 :     ort->UnitConv(11).offset = 32.0;
   18730           94 :     ort->UnitConv(25).offset = 7.6736;
   18731           94 :     ort->UnitConv(81).offset = 7.6736; // 80 is KJ/KG -- should this be multiplied by 1000?
   18732              : 
   18733           94 :     ort->UnitConv(20).hint = "ELEC";
   18734           94 :     ort->UnitConv(21).hint = "GAS";
   18735           94 :     ort->UnitConv(24).hint = "COOL";
   18736           94 :     ort->UnitConv(38).hint = "WATER";
   18737           94 :     ort->UnitConv(49).hint = "WATER";
   18738           94 :     ort->UnitConv(52).hint = "WATER";
   18739           94 :     ort->UnitConv(67).hint = "ELEC";
   18740           94 :     ort->UnitConv(70).hint = "COOL";
   18741           94 :     ort->UnitConv(79).hint = "SI";
   18742           94 :     ort->UnitConv(83).hint = "WATER";
   18743           94 :     ort->UnitConv(86).hint = "CONSUMP";
   18744           94 :     ort->UnitConv(87).hint = "ELEC";
   18745           94 :     ort->UnitConv(88).hint = "GAS";
   18746           94 :     ort->UnitConv(91).hint = "COOL";
   18747           94 :     ort->UnitConv(92).hint = "ELEC";
   18748           94 :     ort->UnitConv(93).hint = "GAS";
   18749           94 :     ort->UnitConv(94).hint = "ADDITIONAL";
   18750              : 
   18751           94 :     ort->UnitConv(19).several = true;
   18752           94 :     ort->UnitConv(20).several = true;
   18753           94 :     ort->UnitConv(21).several = true;
   18754           94 :     ort->UnitConv(22).several = true;
   18755           94 :     ort->UnitConv(23).several = true;
   18756           94 :     ort->UnitConv(24).several = true;
   18757           94 :     ort->UnitConv(38).several = true;
   18758           94 :     ort->UnitConv(39).several = true;
   18759           94 :     ort->UnitConv(42).several = true;
   18760           94 :     ort->UnitConv(43).several = true;
   18761           94 :     ort->UnitConv(44).several = true;
   18762           94 :     ort->UnitConv(45).several = true;
   18763           94 :     ort->UnitConv(48).several = true;
   18764           94 :     ort->UnitConv(49).several = true;
   18765           94 :     ort->UnitConv(51).several = true;
   18766           94 :     ort->UnitConv(52).several = true;
   18767           94 :     ort->UnitConv(54).several = true;
   18768           94 :     ort->UnitConv(55).several = true;
   18769           94 :     ort->UnitConv(56).several = true;
   18770           94 :     ort->UnitConv(57).several = true;
   18771           94 :     ort->UnitConv(58).several = true;
   18772           94 :     ort->UnitConv(59).several = true;
   18773           94 :     ort->UnitConv(60).several = true;
   18774           94 :     ort->UnitConv(61).several = true;
   18775           94 :     ort->UnitConv(62).several = true;
   18776           94 :     ort->UnitConv(63).several = true;
   18777           94 :     ort->UnitConv(66).several = true;
   18778           94 :     ort->UnitConv(67).several = true;
   18779           94 :     ort->UnitConv(68).several = true;
   18780           94 :     ort->UnitConv(69).several = true;
   18781           94 :     ort->UnitConv(70).several = true;
   18782           94 :     ort->UnitConv(74).several = true;
   18783           94 :     ort->UnitConv(75).several = true;
   18784           94 :     ort->UnitConv(78).several = true;
   18785           94 :     ort->UnitConv(79).several = true;
   18786           94 :     ort->UnitConv(82).several = true;
   18787           94 :     ort->UnitConv(83).several = true;
   18788           94 :     ort->UnitConv(85).several = true;
   18789           94 :     ort->UnitConv(86).several = true;
   18790           94 :     ort->UnitConv(87).several = true;
   18791           94 :     ort->UnitConv(88).several = true;
   18792           94 :     ort->UnitConv(89).several = true;
   18793           94 :     ort->UnitConv(90).several = true;
   18794           94 :     ort->UnitConv(91).several = true;
   18795           94 :     ort->UnitConv(92).several = true;
   18796           94 :     ort->UnitConv(93).several = true;
   18797           94 :     ort->UnitConv(94).several = true;
   18798           94 :     ort->UnitConv(95).several = true;
   18799           94 :     ort->UnitConv(116).several = true;
   18800           94 :     ort->UnitConv(117).several = true;
   18801           94 : }
   18802              : 
   18803        28596 : std::string GetUnitSubString(std::string const &inString) // Input String
   18804              : {
   18805              :     // SUBROUTINE INFORMATION:
   18806              :     //       AUTHOR         Jason Glazer
   18807              :     //       DATE WRITTEN   February 2013
   18808              :     //       MODIFIED       na
   18809              :     //       RE-ENGINEERED  na
   18810              : 
   18811              :     // PURPOSE OF THIS SUBROUTINE:
   18812              :     //   return the substring contained in brackets []
   18813              :     //   that contains the units.
   18814              : 
   18815              :     // METHODOLOGY EMPLOYED:
   18816              :     //   na
   18817              : 
   18818              :     // Return value
   18819        28596 :     std::string outUnit; // Result String
   18820              : 
   18821              :     // Locals
   18822              :     // SUBROUTINE ARGUMENT DEFINITIONS:
   18823              : 
   18824              :     // SUBROUTINE PARAMETER DEFINITIONS:
   18825              :     // na
   18826              : 
   18827              :     // INTERFACE BLOCK SPECIFICATIONS:
   18828              :     // na
   18829              : 
   18830              :     // DERIVED TYPE DEFINITIONS:
   18831              :     // na
   18832              : 
   18833              :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
   18834              : 
   18835              :     // check if string has brackets or parentheses
   18836        28596 :     std::string::size_type const posLBrac = index(inString, '['); // left bracket
   18837        28596 :     std::string::size_type const posRBrac = index(inString, ']'); // right bracket
   18838              :     // extract the substring with the units
   18839        28596 :     if ((posLBrac != std::string::npos) && (posRBrac != std::string::npos) && (posRBrac - posLBrac >= 1)) {
   18840         8649 :         outUnit = inString.substr(posLBrac + 1, posRBrac - posLBrac - 1);
   18841              :     }
   18842        28596 :     return outUnit;
   18843            0 : }
   18844              : 
   18845         1834 : void LookupSItoIP(EnergyPlusData &state, std::string const &stringInWithSI, int &unitConvIndex, std::string &stringOutWithIP)
   18846              : {
   18847              :     // SUBROUTINE INFORMATION:
   18848              :     //    AUTHOR         Jason Glazer of GARD Analytics, Inc.
   18849              :     //    DATE WRITTEN   February 12, 2009
   18850              : 
   18851              :     // PURPOSE OF THIS SUBROUTINE:
   18852              :     //   The input string to this subroutine can either contain
   18853              :     //   a unit that should be looked up or it can contain
   18854              :     //   but the unit and other text (such as the column heading)
   18855              :     //   that includes a hint for when the unit may have multiple
   18856              :     //   possible conversions. If the input string includes
   18857              :     //   just the unit it does not have either brackets or
   18858              :     //   parenthesis. If the string includes text with a possible
   18859              :     //   hint the units themselves will be in either brackets
   18860              :     //   or parentheses. The index to the unitConv array is returned
   18861              :     //   which can be used with the convertIP function. Also the
   18862              :     //   string with the IP units substituted is returned.
   18863              : 
   18864         1834 :     std::string unitSIOnly;
   18865              :     int modeInString;
   18866         1834 :     int constexpr misBrac(1);
   18867         1834 :     int constexpr misParen(2);
   18868         1834 :     int constexpr misBrce(3);
   18869         1834 :     int constexpr misNoHint(4);
   18870         1834 :     std::string const stringInUpper(Util::makeUPPER(stringInWithSI));
   18871         1834 :     auto &ort = state.dataOutRptTab;
   18872              : 
   18873         1834 :     stringOutWithIP = "";
   18874              :     // check if string has brackets or parentheses
   18875         1834 :     std::string::size_type posLBrac = index(stringInUpper, '[');  // left bracket
   18876         1834 :     std::string::size_type posRBrac = index(stringInUpper, ']');  // right bracket
   18877         1834 :     std::string::size_type posLParen = index(stringInUpper, '('); // left parenthesis
   18878         1834 :     std::string::size_type posRParen = index(stringInUpper, ')'); // right parenthesis
   18879         1834 :     std::string::size_type posLBrce = index(stringInUpper, '{');  // left brace
   18880         1834 :     std::string::size_type posRBrce = index(stringInUpper, '}');  // right brace
   18881         1834 :     bool noBrackets = true;
   18882              :     // extract the substring with the units
   18883         1834 :     if ((posLBrac != std::string::npos) && (posRBrac != std::string::npos) && (posRBrac - posLBrac >= 1)) {
   18884          951 :         unitSIOnly = stringInUpper.substr(posLBrac + 1, posRBrac - posLBrac - 1);
   18885          951 :         modeInString = misBrac;
   18886          951 :         noBrackets = false;
   18887          883 :     } else if ((posLBrce != std::string::npos) && (posRBrce != std::string::npos) && (posRBrce - posLBrce >= 1)) {
   18888          240 :         unitSIOnly = stringInUpper.substr(posLBrce + 1, posRBrce - posLBrce - 1);
   18889          240 :         modeInString = misBrce;
   18890          643 :     } else if ((posLParen != std::string::npos) && (posRParen != std::string::npos) && (posRParen - posLParen >= 1)) {
   18891           21 :         unitSIOnly = stringInUpper.substr(posLParen + 1, posRParen - posLParen - 1);
   18892           21 :         modeInString = misParen;
   18893              :     } else {
   18894          622 :         unitSIOnly = stringInUpper;
   18895          622 :         modeInString = misNoHint;
   18896              :     }
   18897         1834 :     unitSIOnly = stripped(unitSIOnly);
   18898         1834 :     int defaultConv = 0;
   18899         1834 :     int foundConv = 0;
   18900         1834 :     int firstOfSeveral = 0;
   18901       172777 :     for (int iUnit = 1; iUnit <= ort->UnitConvSize; ++iUnit) {
   18902       171547 :         if (Util::SameString(ort->UnitConv(iUnit).siName, unitSIOnly)) {
   18903         2569 :             if (ort->UnitConv(iUnit).several) {
   18904         2043 :                 if (firstOfSeveral == 0) firstOfSeveral = iUnit;
   18905         2043 :                 if (ort->UnitConv(iUnit).is_default) defaultConv = iUnit;
   18906              :                 // look for the hint string
   18907         2043 :                 if (len(ort->UnitConv(iUnit).hint) > 0) {
   18908          854 :                     if (has(stringInUpper, ort->UnitConv(iUnit).hint)) {
   18909           78 :                         foundConv = iUnit;
   18910           78 :                         break;
   18911              :                     }
   18912              :                 }
   18913              :             } else { // not several possibilities so don't bother with rest of array
   18914          526 :                 foundConv = iUnit;
   18915          526 :                 break;
   18916              :             }
   18917              :         }
   18918              :     }
   18919              :     // if it is found set the selected value to what was found. if not found,
   18920              :     // directly set it to the default and if no default set it to the first item
   18921              :     // in group.  Return zero if not found.
   18922         1834 :     int selectedConv(0);
   18923         1834 :     if (foundConv > 0) {
   18924          604 :         selectedConv = foundConv;
   18925              :     } else {
   18926              :         // not found - see if in a group it should be default or first.
   18927         1230 :         if (firstOfSeveral == 0) {
   18928          719 :             selectedConv = 0;
   18929              :         } else {
   18930          511 :             if (defaultConv != 0) {
   18931            0 :                 selectedConv = defaultConv;
   18932              :             } else {
   18933          511 :                 selectedConv = firstOfSeveral;
   18934              :             }
   18935              :         }
   18936              :     }
   18937              :     // if one was selected substitute the units into the output string
   18938         1834 :     if (selectedConv > 0) {
   18939         1115 :         if (modeInString == misBrac) {
   18940          950 :             stringOutWithIP = stringInWithSI.substr(0, posLBrac + 1) + ort->UnitConv(selectedConv).ipName + stringInWithSI.substr(posRBrac);
   18941          165 :         } else if (modeInString == misParen) {
   18942           15 :             stringOutWithIP = stringInWithSI.substr(0, posLParen + 1) + ort->UnitConv(selectedConv).ipName + stringInWithSI.substr(posRParen);
   18943          150 :         } else if (modeInString == misBrce) {
   18944          148 :             stringOutWithIP = stringInWithSI.substr(0, posLBrce + 1) + ort->UnitConv(selectedConv).ipName + stringInWithSI.substr(posRBrce);
   18945            2 :         } else if (modeInString == misNoHint) {
   18946            2 :             stringOutWithIP = ort->UnitConv(selectedConv).ipName;
   18947              :         }
   18948              :     } else {
   18949              :         // if no conversion just output the input string
   18950          719 :         stringOutWithIP = stringInWithSI;
   18951              :     }
   18952              : 
   18953         1834 :     unitConvIndex = selectedConv;
   18954              : 
   18955              :     // Add warning if units not found.
   18956         1834 :     if (unitConvIndex == 0 && !noBrackets) {
   18957            1 :         ShowWarningError(state, format("Unable to find a unit conversion from {} into IP units", stringInWithSI));
   18958            3 :         ShowContinueError(state, "Applying default conversion factor of 1.0");
   18959              :     }
   18960         1834 : }
   18961              : 
   18962          108 : void LookupJtokWH(EnergyPlusData &state, std::string const &stringInWithJ, int &unitConvIndex, std::string &stringOutWithKWH)
   18963              : {
   18964              :     //    AUTHOR         Jason Glazer of GARD Analytics, Inc.
   18965              :     //    DATE WRITTEN   April 15, 2016
   18966              : 
   18967              :     // For the given unit expressed in J find the unit conversion
   18968              :     // using kWh instead. This is used when unitsStyle == unitsStyleJtoKWH
   18969              :     // return zero if no unit conversion should be done
   18970              : 
   18971          108 :     stringOutWithKWH = stringInWithJ;
   18972          108 :     std::string::size_type gjPos = stringOutWithKWH.find("[GJ]");
   18973          108 :     std::string::size_type mjm2Pos = stringOutWithKWH.find("[MJ/m2]");
   18974          108 :     if (gjPos != std::string::npos) {
   18975            1 :         stringOutWithKWH.replace(gjPos, 4, "[kWh]");
   18976            4 :         unitConvIndex = getSpecificUnitIndex(state, "GJ", "kWh");
   18977          107 :     } else if (mjm2Pos != std::string::npos) {
   18978            1 :         stringOutWithKWH.replace(mjm2Pos, 7, "[kWh/m2]");
   18979            4 :         unitConvIndex = getSpecificUnitIndex(state, "MJ/m2", "kWh/m2");
   18980              :     } else {
   18981          106 :         unitConvIndex = 0;
   18982              :     }
   18983          108 : }
   18984              : 
   18985         1398 : Real64 ConvertIP(EnergyPlusData &state, int const unitConvIndex, Real64 const SIvalue)
   18986              : {
   18987              :     // SUBROUTINE INFORMATION:
   18988              :     //    AUTHOR         Jason Glazer of GARD Analytics, Inc.
   18989              :     //    DATE WRITTEN   February 13, 2009
   18990              :     //    MODIFIED       September 2012
   18991              :     //    RE-ENGINEERED  na
   18992              : 
   18993              :     // PURPOSE OF THIS SUBROUTINE:
   18994              :     //   Apply the selected unit conversion to the input value
   18995              :     //   expressed in SI units to result in IP units.
   18996              :     //   If zero is provided as unit index, return the original
   18997              :     //   value (no conversion)
   18998              : 
   18999              :     // METHODOLOGY EMPLOYED:
   19000              : 
   19001              :     // REFERENCES:
   19002              :     //    na
   19003              : 
   19004              :     // USE STATEMENTS:
   19005              : 
   19006              :     // Return value
   19007              :     Real64 ConvertIP;
   19008              : 
   19009              :     // Locals
   19010              :     // SUBROUTINE ARGUMENT DEFINITIONS:
   19011              : 
   19012              :     // SUBROUTINE PARAMETER DEFINITIONS:
   19013              :     //    na
   19014              : 
   19015              :     // INTERFACE BLOCK SPECIFICATIONS:
   19016              :     //    na
   19017              : 
   19018              :     // DERIVED TYPE DEFINITIONS:
   19019              :     //    na
   19020              : 
   19021              :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
   19022              :     //    na
   19023              : 
   19024         1398 :     auto &ort = state.dataOutRptTab;
   19025              : 
   19026         1398 :     if (unitConvIndex == 0 || SIvalue == -999.0 || SIvalue == -99999.0) { // don't convert unknown data to IP
   19027           66 :         ConvertIP = SIvalue;
   19028         1332 :     } else if ((unitConvIndex > 0) && (unitConvIndex <= ort->UnitConvSize)) {
   19029         1332 :         ConvertIP = (SIvalue * ort->UnitConv(unitConvIndex).mult) + ort->UnitConv(unitConvIndex).offset;
   19030              :     } else {
   19031            0 :         ConvertIP = SIvalue;
   19032              :     }
   19033         1398 :     return ConvertIP;
   19034              : }
   19035              : 
   19036           12 : Real64 ConvertIPdelta(EnergyPlusData &state, int const unitConvIndex, Real64 const SIvalue)
   19037              : {
   19038              :     // SUBROUTINE INFORMATION:
   19039              :     //    AUTHOR         Jason Glazer of GARD Analytics, Inc.
   19040              :     //    DATE WRITTEN   February 18, 2009
   19041              :     //    MODIFIED       na
   19042              :     //    RE-ENGINEERED  na
   19043              : 
   19044              :     // PURPOSE OF THIS SUBROUTINE:
   19045              :     //   Apply the selected unit conversion to the input value
   19046              :     //   expressed in SI units to result in IP units. This routine
   19047              :     //   only uses the multiplier and NOT the offset and is appropriate
   19048              :     //   when the number being converted is a difference or delta
   19049              :     //   between values (such as a temperature difference).
   19050              : 
   19051              :     // METHODOLOGY EMPLOYED:
   19052              : 
   19053              :     // REFERENCES:
   19054              :     //    na
   19055              : 
   19056              :     // USE STATEMENTS:
   19057              : 
   19058              :     // Return value
   19059              :     Real64 ConvertIPdelta;
   19060              : 
   19061              :     // Locals
   19062              :     // SUBROUTINE ARGUMENT DEFINITIONS:
   19063              : 
   19064              :     // SUBROUTINE PARAMETER DEFINITIONS:
   19065              :     //    na
   19066              : 
   19067              :     // INTERFACE BLOCK SPECIFICATIONS:
   19068              :     //    na
   19069              : 
   19070              :     // DERIVED TYPE DEFINITIONS:
   19071              :     //    na
   19072              : 
   19073              :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
   19074              :     //    na
   19075              : 
   19076           12 :     auto &ort = state.dataOutRptTab;
   19077              : 
   19078           12 :     if (unitConvIndex == 0) {
   19079            0 :         ConvertIPdelta = SIvalue;
   19080           12 :     } else if ((unitConvIndex > 0) && (unitConvIndex <= ort->UnitConvSize)) {
   19081           12 :         ConvertIPdelta = SIvalue * ort->UnitConv(unitConvIndex).mult;
   19082              :     } else {
   19083            0 :         ConvertIPdelta = SIvalue;
   19084              :     }
   19085           12 :     return ConvertIPdelta;
   19086              : }
   19087              : 
   19088           10 : void GetUnitConversion(EnergyPlusData &state, int const unitConvIndex, Real64 &multiplier, Real64 &offset, std::string &IPunit)
   19089              : {
   19090              :     // SUBROUTINE INFORMATION:
   19091              :     //    AUTHOR         Jason Glazer of GARD Analytics, Inc.
   19092              :     //    DATE WRITTEN   February 13, 2009
   19093              :     //    MODIFIED       na
   19094              :     //    RE-ENGINEERED  na
   19095              : 
   19096              :     // PURPOSE OF THIS SUBROUTINE:
   19097              :     //   Return of the multiplier and adder for the given
   19098              :     //   SI to IP unit conversion.
   19099              :     //     SI = (IP * multiplier) + offset
   19100              :     //  This function could be replaced by referencing the
   19101              :     //  array directly but does include some checking of the
   19102              :     //  bounds of the array.
   19103              : 
   19104              :     // METHODOLOGY EMPLOYED:
   19105              : 
   19106              :     // REFERENCES:
   19107              :     //    na
   19108              : 
   19109              :     // USE STATEMENTS:
   19110              : 
   19111              :     // Locals
   19112              :     // SUBROUTINE ARGUMENT DEFINITIONS:
   19113              : 
   19114              :     // SUBROUTINE PARAMETER DEFINITIONS:
   19115              :     //    na
   19116              : 
   19117              :     // INTERFACE BLOCK SPECIFICATIONS:
   19118              :     //    na
   19119              : 
   19120              :     // DERIVED TYPE DEFINITIONS:
   19121              :     //    na
   19122              : 
   19123              :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
   19124              :     //    na
   19125              : 
   19126           10 :     auto &ort = state.dataOutRptTab;
   19127              : 
   19128           10 :     if ((unitConvIndex > 0) && (unitConvIndex <= ort->UnitConvSize)) {
   19129            9 :         multiplier = ort->UnitConv(unitConvIndex).mult;
   19130            9 :         offset = ort->UnitConv(unitConvIndex).offset;
   19131            9 :         IPunit = ort->UnitConv(unitConvIndex).ipName;
   19132              :     } else {
   19133            1 :         multiplier = 1.0;
   19134            1 :         offset = 0.0;
   19135            1 :         IPunit = "";
   19136              :     }
   19137           10 : }
   19138              : 
   19139          126 : Real64 getSpecificUnitMultiplier(EnergyPlusData &state, std::string const &SIunit, std::string const &IPunit)
   19140              : {
   19141              :     // SUBROUTINE INFORMATION:
   19142              :     //    AUTHOR         Jason Glazer of GARD Analytics, Inc.
   19143              :     //    DATE WRITTEN   February 13, 2009
   19144              :     //    MODIFIED       na
   19145              :     //    RE-ENGINEERED  na
   19146              : 
   19147              :     // PURPOSE OF THIS SUBROUTINE:
   19148              :     //   Return of the multiplier for a specific
   19149              :     //   SI to IP unit conversion. No offset is provided so
   19150              :     //   it cannot be used to convert units such as temperatures
   19151              :     //   that include an offset.
   19152              :     //     SI = (IP * multiplier) + offset
   19153              :     //   Unlike LookupSItoIP, this function does not expect more
   19154              :     //   the units in the two input parameters. No hints or
   19155              :     //   defaults are used since both the SI and IP units are
   19156              :     //   input by the user.
   19157              : 
   19158              :     // METHODOLOGY EMPLOYED:
   19159              : 
   19160              :     // REFERENCES:
   19161              :     //    na
   19162              : 
   19163              :     // USE STATEMENTS:
   19164              : 
   19165              :     // Return value
   19166              :     Real64 getSpecificUnitMultiplier;
   19167              : 
   19168              :     // Locals
   19169              :     // SUBROUTINE ARGUMENT DEFINITIONS:
   19170              : 
   19171              :     // SUBROUTINE PARAMETER DEFINITIONS:
   19172              :     //    na
   19173              : 
   19174              :     // INTERFACE BLOCK SPECIFICATIONS:
   19175              :     //    na
   19176              : 
   19177              :     // DERIVED TYPE DEFINITIONS:
   19178              :     //    na
   19179              : 
   19180              :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
   19181          126 :     auto &ort = state.dataOutRptTab;
   19182              : 
   19183         6238 :     for (state.dataOutRptTab->iUnitGsum = 1; state.dataOutRptTab->iUnitGsum <= ort->UnitConvSize; ++state.dataOutRptTab->iUnitGsum) {
   19184         6218 :         if (Util::SameString(ort->UnitConv(state.dataOutRptTab->iUnitGsum).siName, SIunit)) {
   19185          133 :             if (Util::SameString(ort->UnitConv(state.dataOutRptTab->iUnitGsum).ipName, IPunit)) {
   19186          106 :                 state.dataOutRptTab->foundGsum = state.dataOutRptTab->iUnitGsum;
   19187          106 :                 break;
   19188              :             }
   19189              :         }
   19190              :     }
   19191          126 :     if (state.dataOutRptTab->foundGsum != 0) {
   19192          106 :         getSpecificUnitMultiplier = ort->UnitConv(state.dataOutRptTab->foundGsum).mult;
   19193              :     } else {
   19194           20 :         ShowWarningError(state, format("Unable to find a unit conversion from {} to {}", SIunit, IPunit));
   19195           40 :         ShowContinueError(state, "Applying default conversion factor of 1.0");
   19196           20 :         getSpecificUnitMultiplier = 1.0;
   19197              :     }
   19198          126 :     return getSpecificUnitMultiplier;
   19199              : }
   19200              : 
   19201           27 : Real64 getSpecificUnitDivider(EnergyPlusData &state, std::string const &SIunit, std::string const &IPunit)
   19202              : {
   19203              :     // SUBROUTINE INFORMATION:
   19204              :     //    AUTHOR         Jason Glazer of GARD Analytics, Inc.
   19205              :     //    DATE WRITTEN   February 13, 2009
   19206              :     //    MODIFIED       na
   19207              :     //    RE-ENGINEERED  na
   19208              : 
   19209              :     // PURPOSE OF THIS SUBROUTINE:
   19210              :     //   Returns the divider (1/multiplier) for a specific
   19211              :     //   SI to IP unit conversion. No offset is provided so
   19212              :     //   it cannot be used to convert units such as temperatures
   19213              :     //   that include an offset.
   19214              :     //     SI = (IP * multiplier) + offset
   19215              :     //   Unlike LookupSItoIP, this function does not expect more
   19216              :     //   the units in the two input parameters. No hints or
   19217              :     //   defaults are used since both the SI and IP units are
   19218              :     //   input by the user.
   19219              : 
   19220              :     // METHODOLOGY EMPLOYED:
   19221              : 
   19222              :     // REFERENCES:
   19223              :     //    na
   19224              : 
   19225              :     // USE STATEMENTS:
   19226              : 
   19227              :     // Return value
   19228              :     Real64 getSpecificUnitDivider;
   19229              : 
   19230              :     // Locals
   19231              :     // SUBROUTINE ARGUMENT DEFINITIONS:
   19232              : 
   19233              :     // SUBROUTINE PARAMETER DEFINITIONS:
   19234              :     //    na
   19235              : 
   19236              :     // INTERFACE BLOCK SPECIFICATIONS:
   19237              :     //    na
   19238              : 
   19239              :     // DERIVED TYPE DEFINITIONS:
   19240              :     //    na
   19241              : 
   19242              :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
   19243              :     Real64 mult;
   19244              : 
   19245           27 :     mult = getSpecificUnitMultiplier(state, SIunit, IPunit);
   19246           27 :     if (mult != 0) {
   19247           27 :         getSpecificUnitDivider = 1 / mult;
   19248              :     } else {
   19249            0 :         ShowWarningError(state, format("Unable to find a unit conversion from {} to {}", SIunit, IPunit));
   19250            0 :         ShowContinueError(state, "Applying default conversion factor of 1.0");
   19251            0 :         getSpecificUnitDivider = 1.0;
   19252              :     }
   19253           27 :     return getSpecificUnitDivider;
   19254              : }
   19255              : 
   19256           18 : Real64 getSpecificUnitIndex(EnergyPlusData &state, std::string const &SIunit, std::string const &IPunit)
   19257              : {
   19258              :     // SUBROUTINE INFORMATION:
   19259              :     //    AUTHOR         Jason Glazer of GARD Analytics, Inc.
   19260              :     //    DATE WRITTEN   September 21, 2012
   19261              :     //    MODIFIED       na
   19262              :     //    RE-ENGINEERED  na
   19263              : 
   19264              :     // PURPOSE OF THIS SUBROUTINE:
   19265              :     //   Return of the unit conversion index for a specific
   19266              :     //   SI to IP unit conversion.
   19267              :     //   Unlike LookupSItoIP, this function does not expect more
   19268              :     //   the units in the two input parameters. No hints or
   19269              :     //   defaults are used since both the SI and IP units are
   19270              :     //   input by the user.
   19271              : 
   19272              :     // METHODOLOGY EMPLOYED:
   19273              : 
   19274              :     // REFERENCES:
   19275              :     //    na
   19276              : 
   19277              :     // USE STATEMENTS:
   19278              : 
   19279              :     // Return value
   19280              :     Real64 getSpecificUnitIndex;
   19281              : 
   19282              :     // Locals
   19283              :     // SUBROUTINE ARGUMENT DEFINITIONS:
   19284              : 
   19285              :     // SUBROUTINE PARAMETER DEFINITIONS:
   19286              :     //    na
   19287              : 
   19288              :     // INTERFACE BLOCK SPECIFICATIONS:
   19289              :     //    na
   19290              : 
   19291              :     // DERIVED TYPE DEFINITIONS:
   19292              :     //    na
   19293              : 
   19294              :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
   19295           18 :     auto &ort = state.dataOutRptTab;
   19296              : 
   19297          317 :     for (state.dataOutRptTab->iUnitGsui = 1; state.dataOutRptTab->iUnitGsui <= ort->UnitConvSize; ++state.dataOutRptTab->iUnitGsui) {
   19298          313 :         if (Util::SameString(ort->UnitConv(state.dataOutRptTab->iUnitGsui).siName, SIunit)) {
   19299           18 :             if (Util::SameString(ort->UnitConv(state.dataOutRptTab->iUnitGsui).ipName, IPunit)) {
   19300           14 :                 state.dataOutRptTab->foundGsui = state.dataOutRptTab->iUnitGsui;
   19301           14 :                 break;
   19302              :             }
   19303              :         }
   19304              :     }
   19305           18 :     if (state.dataOutRptTab->foundGsui != 0) {
   19306           14 :         getSpecificUnitIndex = state.dataOutRptTab->foundGsui;
   19307              :     } else {
   19308            4 :         getSpecificUnitIndex = 0.0;
   19309              :     }
   19310           18 :     return getSpecificUnitIndex;
   19311              : }
   19312              : 
   19313              : } // namespace EnergyPlus::OutputReportTabular
        

Generated by: LCOV version 2.0-1