LCOV - code coverage report
Current view: top level - EnergyPlus - OutputReportTabular.cc (source / functions) Coverage Total Hit
Test: lcov.output.filtered Lines: 77.7 % 11862 9212
Test Date: 2025-06-02 12:03:30 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) {
     967            3 :                     break; // if no variable was ever found than stop checking
     968              :                 }
     969            2 :                 AggType curAggType = ort->MonthlyColumns(curCol).aggType;
     970            2 :                 if ((curAggType == AggType::Maximum) || (curAggType == AggType::Minimum)) {
     971            0 :                     foundMinOrMax = true;
     972            2 :                 } else if ((curAggType == AggType::HoursNonZero) || (curAggType == AggType::HoursZero) || (curAggType == AggType::HoursPositive) ||
     973            2 :                            (curAggType == AggType::HoursNonPositive) || (curAggType == AggType::HoursNegative) ||
     974              :                            (curAggType == AggType::HoursNonNegative)) {
     975            0 :                     foundHourAgg = true;
     976            2 :                 } else if (curAggType == AggType::ValueWhenMaxMin) {
     977            0 :                     if (!foundMinOrMax) {
     978            0 :                         missingMaxOrMinError = true;
     979              :                     }
     980            2 :                 } else if ((curAggType == AggType::SumOrAverageHoursShown) || (curAggType == AggType::MaximumDuringHoursShown) ||
     981              :                            (curAggType == AggType::MinimumDuringHoursShown)) {
     982            2 :                     if (!foundHourAgg) {
     983            2 :                         missingHourAggError = true;
     984              :                     }
     985              :                 }
     986              :             }
     987              :         }
     988            1 :         if (missingMaxOrMinError) {
     989            0 :             ShowSevereError(state,
     990            0 :                             format("The Output:Table:Monthly report named=\"{}\" has a valueWhenMaxMin aggregation type for a column without a "
     991              :                                    "previous column that uses either the minimum or maximum aggregation types. The report will not be generated.",
     992            0 :                                    ort->MonthlyInput(iInput).name));
     993            0 :             foundError = true;
     994              :         }
     995            1 :         if (missingHourAggError) {
     996            2 :             ShowSevereError(state,
     997            2 :                             format("The Output:Table:Monthly report named=\"{}\" has a --DuringHoursShown aggregation type for a column without a "
     998              :                                    "previous field that uses one of the Hour-- aggregation types. The report will not be generated.",
     999            1 :                                    ort->MonthlyInput(iInput).name));
    1000            1 :             foundError = true;
    1001              :         }
    1002              :     }
    1003            2 :     return foundError;
    1004              : }
    1005              : 
    1006           75 : void GetInputTabularTimeBins(EnergyPlusData &state)
    1007              : {
    1008              :     // SUBROUTINE INFORMATION:
    1009              :     //       AUTHOR         Jason Glazer
    1010              :     //       DATE WRITTEN   July 2003
    1011              :     //       MODIFIED       na
    1012              :     //       RE-ENGINEERED  na
    1013              : 
    1014              :     // PURPOSE OF THIS SUBROUTINE:
    1015              :     //   This routine initializes the data structures based
    1016              :     //   on input from in the IDF file.  The data structures
    1017              :     //   follow the IDD closely.
    1018              : 
    1019              :     // METHODOLOGY EMPLOYED:
    1020              :     //   Uses get input structure similar to other objects
    1021              : 
    1022              :     // REFERENCES:
    1023              :     // na
    1024              : 
    1025              :     // Locals
    1026              :     // SUBROUTINE ARGUMENT DEFINITIONS:
    1027              :     // na
    1028              : 
    1029              :     // SUBROUTINE PARAMETER DEFINITIONS:
    1030          209 :     static std::string const CurrentModuleObject("Output:Table:TimeBins");
    1031              : 
    1032              :     // INTERFACE BLOCK SPECIFICATIONS:
    1033              :     // na
    1034              : 
    1035              :     // DERIVED TYPE DEFINITIONS:
    1036              :     // na
    1037              : 
    1038              :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
    1039           75 :     int NumParams = 0;            // Number of elements combined
    1040           75 :     int NumAlphas = 0;            // Number of elements in the alpha array
    1041           75 :     int NumNums = 0;              // Number of elements in the numeric array
    1042           75 :     Array1D_string AlphArray;     // character string data
    1043           75 :     Array1D<Real64> NumArray;     // numeric data
    1044           75 :     int IOStat = -1;              // IO Status when calling get input subroutine
    1045           75 :     Real64 constexpr bigVal(0.0); // used with HUGE: Value doesn't matter, only type: Initialize so compiler doesn't warn about use uninitialized
    1046              : 
    1047           75 :     Array1D_int objVarIDs;
    1048           75 :     Array1D_string objNames;
    1049              : 
    1050              :     static constexpr std::string_view routineName = "GetInputTabularTimeBins";
    1051              : 
    1052           75 :     auto &ort = state.dataOutRptTab;
    1053              : 
    1054           75 :     if (!state.files.outputControl.writeTabular(state)) {
    1055            0 :         ort->WriteTabularFiles = false;
    1056            0 :         return;
    1057              :     }
    1058              : 
    1059           75 :     state.dataInputProcessing->inputProcessor->getObjectDefMaxArgs(state, CurrentModuleObject, NumParams, NumAlphas, NumNums);
    1060           75 :     AlphArray.allocate(NumAlphas);
    1061           75 :     NumArray.dimension(NumNums, 0.0);
    1062              : 
    1063           75 :     ort->timeInYear = 0.0; // initialize the time in year counter
    1064              :     // determine size of array that holds the IDF description
    1065           75 :     ort->OutputTableBinnedCount = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, CurrentModuleObject);
    1066           75 :     ort->OutputTableBinned.allocate(ort->OutputTableBinnedCount);
    1067           75 :     if (ort->OutputTableBinnedCount > 0) {
    1068            1 :         ort->WriteTabularFiles = true;
    1069              :         // if not a run period using weather do not create reports
    1070            1 :         if (!state.dataGlobal->DoWeathSim) {
    1071            0 :             ShowWarningError(
    1072              :                 state,
    1073            0 :                 format("{} requested with SimulationControl Run Simulation for Weather File Run Periods set to No so {} will not be generated",
    1074              :                        CurrentModuleObject,
    1075              :                        CurrentModuleObject));
    1076            0 :             return;
    1077              :         }
    1078              :     }
    1079              :     // looking for maximum number of intervals for sizing
    1080           75 :     ort->BinResultsIntervalCount = 0;
    1081           75 :     ort->BinResultsTableCount = 0;
    1082           76 :     for (int iInObj = 1; iInObj <= ort->OutputTableBinnedCount; ++iInObj) {
    1083            2 :         state.dataInputProcessing->inputProcessor->getObjectItem(state,
    1084              :                                                                  CurrentModuleObject,
    1085              :                                                                  iInObj,
    1086              :                                                                  AlphArray,
    1087              :                                                                  NumAlphas,
    1088              :                                                                  NumArray,
    1089              :                                                                  NumNums,
    1090              :                                                                  IOStat,
    1091            1 :                                                                  state.dataIPShortCut->lNumericFieldBlanks,
    1092            1 :                                                                  state.dataIPShortCut->lAlphaFieldBlanks,
    1093            1 :                                                                  state.dataIPShortCut->cAlphaFieldNames,
    1094            1 :                                                                  state.dataIPShortCut->cNumericFieldNames);
    1095              : 
    1096            1 :         ErrorObjectHeader eoh{routineName, CurrentModuleObject, AlphArray(1)};
    1097              : 
    1098            1 :         ort->OutputTableBinned(iInObj).keyValue = AlphArray(1);
    1099            1 :         ort->OutputTableBinned(iInObj).varOrMeter = AlphArray(2);
    1100              :         // if a schedule has been specified assign
    1101            1 :         if (state.dataIPShortCut->lAlphaFieldBlanks(3)) {
    1102            1 :         } else if ((ort->OutputTableBinned(iInObj).sched = Sched::GetSchedule(state, AlphArray(3))) == nullptr) {
    1103            0 :             ShowWarningItemNotFound(state, eoh, state.dataIPShortCut->cAlphaFieldNames(3), AlphArray(3), "");
    1104              :         }
    1105              : 
    1106              :         // validate the kind of variable - not used internally except for validation
    1107            1 :         if (len(AlphArray(4)) > 0) {
    1108            0 :             if (!(Util::SameString(AlphArray(4), "ENERGY") || Util::SameString(AlphArray(4), "DEMAND") ||
    1109            0 :                   Util::SameString(AlphArray(4), "TEMPERATURE") || Util::SameString(AlphArray(4), "FLOWRATE"))) {
    1110            0 :                 ShowWarningError(
    1111              :                     state,
    1112            0 :                     format("In {} named {} the Variable Type was not energy, demand, temperature, or flowrate.", CurrentModuleObject, AlphArray(1)));
    1113              :             }
    1114              :         }
    1115            1 :         ort->OutputTableBinned(iInObj).intervalStart = NumArray(1);
    1116            1 :         ort->OutputTableBinned(iInObj).intervalSize = NumArray(2);
    1117            1 :         ort->OutputTableBinned(iInObj).intervalCount = int(NumArray(3));
    1118              :         // valid range checking on inputs
    1119            1 :         if (ort->OutputTableBinned(iInObj).intervalCount < 1) {
    1120            0 :             ort->OutputTableBinned(iInObj).intervalCount = 1;
    1121              :         }
    1122            1 :         if (ort->OutputTableBinned(iInObj).intervalCount > 20) {
    1123            0 :             ort->OutputTableBinned(iInObj).intervalCount = 20;
    1124              :         }
    1125            1 :         if (ort->OutputTableBinned(iInObj).intervalSize < 0) {
    1126            0 :             ort->OutputTableBinned(iInObj).intervalSize = 1000.0;
    1127              :         }
    1128            1 :         ort->OutputTableBinned(iInObj).resIndex = ort->BinResultsTableCount + 1; // the next results report
    1129              :         // find maximum number of intervals
    1130            1 :         if (ort->OutputTableBinned(iInObj).intervalCount > ort->BinResultsIntervalCount) {
    1131            1 :             ort->BinResultsIntervalCount = ort->OutputTableBinned(iInObj).intervalCount;
    1132              :         }
    1133            1 :         GetVariableKeyCountandType(state,
    1134            1 :                                    ort->OutputTableBinned(iInObj).varOrMeter,
    1135            1 :                                    ort->OutputTableBinned(iInObj).numTables,
    1136            1 :                                    ort->OutputTableBinned(iInObj).typeOfVar,
    1137            1 :                                    ort->OutputTableBinned(iInObj).avgSum,
    1138            1 :                                    ort->OutputTableBinned(iInObj).stepType,
    1139            1 :                                    ort->OutputTableBinned(iInObj).units);
    1140            1 :         if (ort->OutputTableBinned(iInObj).typeOfVar == OutputProcessor::VariableType::Invalid) {
    1141            2 :             ShowWarningError(
    1142            2 :                 state, format("{}: User specified meter or variable not found: {}", CurrentModuleObject, ort->OutputTableBinned(iInObj).varOrMeter));
    1143              :         }
    1144              :         // If only a single table key is requested than only one should be counted
    1145              :         // later will reset the numTables array pointer but for now use it to know
    1146              :         // how many items to scan through
    1147            1 :         if (ort->OutputTableBinned(iInObj).keyValue == "*") {
    1148            0 :             ort->BinResultsTableCount += ort->OutputTableBinned(iInObj).numTables;
    1149              :         } else {
    1150            1 :             ++ort->BinResultsTableCount; // if a particular key is requested then only one more report
    1151              :         }
    1152              :     }
    1153              :     // size the arrays that holds the bin results
    1154           75 :     ort->BinResults.allocate(ort->BinResultsIntervalCount, ort->BinResultsTableCount);
    1155           75 :     ort->BinResultsBelow.allocate(ort->BinResultsTableCount);
    1156           75 :     ort->BinResultsAbove.allocate(ort->BinResultsTableCount);
    1157           75 :     ort->BinStatistics.allocate(ort->BinResultsTableCount);
    1158           75 :     ort->BinObjVarID.allocate(ort->BinResultsTableCount);
    1159              :     // now that the arrays are sized go back and fill in
    1160              :     // what ID numbers are used for each table
    1161           76 :     for (int iInObj = 1; iInObj <= ort->OutputTableBinnedCount; ++iInObj) {
    1162            1 :         int firstReport = ort->OutputTableBinned(iInObj).resIndex;
    1163              :         // allocate the arrays to the number of objects
    1164            1 :         objVarIDs.allocate(ort->OutputTableBinned(iInObj).numTables);
    1165            1 :         objNames.allocate(ort->OutputTableBinned(iInObj).numTables);
    1166            1 :         GetVariableKeys(state, ort->OutputTableBinned(iInObj).varOrMeter, ort->OutputTableBinned(iInObj).typeOfVar, objNames, objVarIDs);
    1167              : 
    1168            1 :         if (ort->OutputTableBinned(iInObj).keyValue == "*") {
    1169            0 :             for (int iTable = 1; iTable <= ort->OutputTableBinned(iInObj).numTables; ++iTable) {
    1170            0 :                 int repIndex = firstReport + (iTable - 1);
    1171            0 :                 ort->BinObjVarID(repIndex).namesOfObj = objNames(iTable);
    1172            0 :                 ort->BinObjVarID(repIndex).varMeterNum = objVarIDs(iTable);
    1173              :                 // check if valid meter or number
    1174              :                 // Why is this here?
    1175            0 :                 if (objVarIDs(iTable) == -1) {
    1176            0 :                     ShowWarningError(state, format("{}: Specified variable or meter not found: {}", CurrentModuleObject, objNames(iTable)));
    1177              :                 }
    1178              :             }
    1179              :         } else {
    1180              :             // scan through the keys and look for the user specified key
    1181            1 :             int found = 0;
    1182            1 :             for (int iTable = 1; iTable <= ort->OutputTableBinned(iInObj).numTables; ++iTable) {
    1183            0 :                 if (Util::SameString(objNames(iTable), ort->OutputTableBinned(iInObj).keyValue)) {
    1184            0 :                     found = iTable;
    1185            0 :                     break;
    1186              :                 }
    1187              :             }
    1188              :             // the first and only report is assigned to the found object name
    1189            1 :             if (!warningAboutKeyNotFound(state, found, iInObj, CurrentModuleObject)) {
    1190            0 :                 ort->BinObjVarID(firstReport).namesOfObj = objNames(found);
    1191            0 :                 ort->BinObjVarID(firstReport).varMeterNum = objVarIDs(found);
    1192              :             }
    1193              :             // reset the number of tables to one
    1194            1 :             ort->OutputTableBinned(iInObj).numTables = 1;
    1195              :         }
    1196              :     }
    1197              :     // clear the binning arrays to zeros
    1198           80 :     for (auto &e : ort->BinResults) {
    1199            5 :         e.mnth = 0.0;
    1200            5 :         e.hrly = 0.0;
    1201              :     }
    1202           76 :     for (auto &e : ort->BinResultsBelow) {
    1203            1 :         e.mnth = 0.0;
    1204            1 :         e.hrly = 0.0;
    1205              :     }
    1206           76 :     for (auto &e : ort->BinResultsAbove) {
    1207            1 :         e.mnth = 0.0;
    1208            1 :         e.hrly = 0.0;
    1209              :     }
    1210              : 
    1211              :     // initialize statistics counters
    1212           76 :     for (auto &e : ort->BinStatistics) {
    1213            1 :         e.minimum = HUGE_(bigVal);
    1214            1 :         e.maximum = -HUGE_(bigVal);
    1215            1 :         e.n = 0;
    1216            1 :         e.sum = 0.0;
    1217            1 :         e.sum2 = 0.0;
    1218              :     }
    1219           75 : }
    1220              : 
    1221            3 : bool warningAboutKeyNotFound(EnergyPlusData &state, int foundIndex, int inObjIndex, std::string const &moduleName)
    1222              : {
    1223            3 :     if (foundIndex == 0) {
    1224            4 :         ShowWarningError(state,
    1225            4 :                          format("{}: Specified key not found: {} for variable: {}",
    1226              :                                 moduleName,
    1227            2 :                                 state.dataOutRptTab->OutputTableBinned(inObjIndex).keyValue,
    1228            2 :                                 state.dataOutRptTab->OutputTableBinned(inObjIndex).varOrMeter));
    1229            2 :         return true;
    1230              :     } else {
    1231            1 :         return false;
    1232              :     }
    1233              : }
    1234              : 
    1235           74 : void GetInputTabularStyle(EnergyPlusData &state)
    1236              : {
    1237              :     // SUBROUTINE INFORMATION:
    1238              :     //       AUTHOR         Jason Glazer
    1239              :     //       DATE WRITTEN   July 2003
    1240              :     //       MODIFIED       na
    1241              :     //       RE-ENGINEERED  na
    1242              : 
    1243              :     // PURPOSE OF THIS SUBROUTINE:
    1244              :     //   This routine set a flag for the output format for
    1245              :     //   all tabular reports. This is a "unique" object.
    1246              : 
    1247              :     // METHODOLOGY EMPLOYED:
    1248              :     //   Uses get input structure similar to other objects
    1249              : 
    1250              :     // REFERENCES:
    1251              :     // na
    1252              : 
    1253              :     // Using/Aliasing
    1254              :     using DataStringGlobals::CharComma;
    1255              :     using DataStringGlobals::CharSpace;
    1256              :     using DataStringGlobals::CharTab;
    1257              : 
    1258              :     // Locals
    1259              :     // SUBROUTINE ARGUMENT DEFINITIONS:
    1260              :     // na
    1261              : 
    1262              :     // SUBROUTINE PARAMETER DEFINITIONS:
    1263          206 :     static std::string const CurrentModuleObject("OutputControl:Table:Style");
    1264              : 
    1265              :     // INTERFACE BLOCK SPECIFICATIONS:
    1266              :     // na
    1267              : 
    1268              :     // DERIVED TYPE DEFINITIONS:
    1269              :     // na
    1270              : 
    1271              :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
    1272           74 :     int NumParams = 0;        // Number of elements combined
    1273           74 :     int NumAlphas = 0;        // Number of elements in the alpha array
    1274           74 :     int NumNums = 0;          // Number of elements in the numeric array
    1275           74 :     Array1D_string AlphArray; // character string data
    1276           74 :     Array1D<Real64> NumArray; // numeric data
    1277           74 :     int IOStat = -1;          // IO Status when calling get input subroutine
    1278           74 :     auto &ort = state.dataOutRptTab;
    1279              : 
    1280           74 :     state.dataInputProcessing->inputProcessor->getObjectDefMaxArgs(state, CurrentModuleObject, NumParams, NumAlphas, NumNums);
    1281           74 :     AlphArray.allocate(NumAlphas);
    1282           74 :     NumArray.dimension(NumNums, 0.0);
    1283              : 
    1284           74 :     int NumTabularStyle = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, CurrentModuleObject);
    1285              : 
    1286           74 :     if (NumTabularStyle == 0) {
    1287           46 :         AlphArray(1) = "COMMA";
    1288           46 :         ort->numStyles = 1;
    1289           46 :         ort->TableStyle(1) = TableStyle::Comma;
    1290           46 :         ort->del(1) = CharComma; // comma
    1291           46 :         ort->unitsStyle = UnitsStyle::None;
    1292           28 :     } else if (NumTabularStyle == 1) {
    1293           56 :         state.dataInputProcessing->inputProcessor->getObjectItem(state,
    1294              :                                                                  CurrentModuleObject,
    1295              :                                                                  1,
    1296              :                                                                  AlphArray,
    1297              :                                                                  NumAlphas,
    1298              :                                                                  NumArray,
    1299              :                                                                  NumNums,
    1300              :                                                                  IOStat,
    1301           28 :                                                                  state.dataIPShortCut->lNumericFieldBlanks,
    1302           28 :                                                                  state.dataIPShortCut->lAlphaFieldBlanks,
    1303           28 :                                                                  state.dataIPShortCut->cAlphaFieldNames,
    1304           28 :                                                                  state.dataIPShortCut->cNumericFieldNames);
    1305              :         // ColumnSeparator
    1306           28 :         if (Util::SameString(AlphArray(1), "Comma")) {
    1307            0 :             ort->numStyles = 1;
    1308            0 :             ort->TableStyle(1) = TableStyle::Comma;
    1309            0 :             ort->del(1) = CharComma; // comma
    1310           28 :         } else if (Util::SameString(AlphArray(1), "Tab")) {
    1311            0 :             ort->numStyles = 1;
    1312            0 :             ort->TableStyle(1) = TableStyle::Tab;
    1313            0 :             ort->del(1) = CharTab; // tab
    1314           28 :         } else if (Util::SameString(AlphArray(1), "Fixed")) {
    1315            0 :             ort->numStyles = 1;
    1316            0 :             ort->TableStyle(1) = TableStyle::Fixed;
    1317            0 :             ort->del(1) = CharSpace; // space
    1318           28 :         } else if (Util::SameString(AlphArray(1), "HTML")) {
    1319            4 :             ort->numStyles = 1;
    1320            4 :             ort->TableStyle(1) = TableStyle::HTML;
    1321            4 :             ort->del(1) = CharSpace; // space - this is not used much for HTML output
    1322           24 :         } else if (Util::SameString(AlphArray(1), "XML")) {
    1323            0 :             ort->numStyles = 1;
    1324            0 :             ort->TableStyle(1) = TableStyle::XML;
    1325            0 :             ort->del(1) = CharSpace; // space - this is not used much for XML output
    1326           24 :         } else if (Util::SameString(AlphArray(1), "CommaAndHTML")) {
    1327            1 :             ort->numStyles = 2;
    1328            1 :             ort->TableStyle(1) = TableStyle::Comma;
    1329            1 :             ort->del(1) = CharComma; // comma
    1330            1 :             ort->TableStyle(2) = TableStyle::HTML;
    1331            1 :             ort->del(2) = CharSpace; // space - this is not used much for HTML output
    1332           23 :         } else if (Util::SameString(AlphArray(1), "CommaAndXML")) {
    1333            0 :             ort->numStyles = 2;
    1334            0 :             ort->TableStyle(1) = TableStyle::Comma;
    1335            0 :             ort->del(1) = CharComma; // comma
    1336            0 :             ort->TableStyle(2) = TableStyle::XML;
    1337            0 :             ort->del(2) = CharSpace; // space - this is not used much for XML output
    1338           23 :         } else if (Util::SameString(AlphArray(1), "TabAndHTML")) {
    1339            1 :             ort->numStyles = 2;
    1340            1 :             ort->TableStyle(1) = TableStyle::Tab;
    1341            1 :             ort->del(1) = CharTab; // tab
    1342            1 :             ort->TableStyle(2) = TableStyle::HTML;
    1343            1 :             ort->del(2) = CharSpace; // space - this is not used much for HTML output
    1344           22 :         } else if (Util::SameString(AlphArray(1), "XMLandHTML")) {
    1345            0 :             ort->numStyles = 2;
    1346            0 :             ort->TableStyle(1) = TableStyle::XML;
    1347            0 :             ort->del(1) = CharSpace; // space - this is not used much for XML output
    1348            0 :             ort->TableStyle(2) = TableStyle::HTML;
    1349            0 :             ort->del(2) = CharSpace; // space - this is not used much for HTML output
    1350           22 :         } else if (Util::SameString(AlphArray(1), "All")) {
    1351           22 :             ort->numStyles = 5;
    1352           22 :             ort->TableStyle(1) = TableStyle::Comma;
    1353           22 :             ort->del(1) = CharComma; // comma
    1354           22 :             ort->TableStyle(2) = TableStyle::Tab;
    1355           22 :             ort->del(2) = CharTab; // tab
    1356           22 :             ort->TableStyle(3) = TableStyle::Fixed;
    1357           22 :             ort->del(3) = CharSpace; // space
    1358           22 :             ort->TableStyle(4) = TableStyle::HTML;
    1359           22 :             ort->del(4) = CharSpace; // space - this is not used much for HTML output
    1360           22 :             ort->TableStyle(5) = TableStyle::XML;
    1361           22 :             ort->del(5) = CharSpace; // space - this is not used much for XML output
    1362              :         } else {
    1363            0 :             ShowWarningError(
    1364              :                 state,
    1365            0 :                 format("{}: Invalid {}=\"{}\". Commas will be used.", CurrentModuleObject, state.dataIPShortCut->cAlphaFieldNames(1), AlphArray(1)));
    1366            0 :             ort->numStyles = 1;
    1367            0 :             ort->TableStyle(1) = TableStyle::Comma;
    1368            0 :             ort->del(1) = CharComma; // comma
    1369            0 :             AlphArray(1) = "COMMA";
    1370              :         }
    1371              :         // MonthlyUnitConversion
    1372           28 :         if (NumAlphas >= 2) {
    1373            2 :             ort->unitsStyle = SetUnitsStyleFromString(AlphArray(2));
    1374            2 :             if (ort->unitsStyle == UnitsStyle::NotFound) {
    1375            0 :                 ShowWarningError(state,
    1376            0 :                                  format("{}: Invalid {}=\"{}\". No unit conversion will be performed. Normal SI units will be shown.",
    1377              :                                         CurrentModuleObject,
    1378            0 :                                         state.dataIPShortCut->cAlphaFieldNames(2),
    1379              :                                         AlphArray(2)));
    1380              :             }
    1381              :         } else {
    1382           26 :             ort->unitsStyle = UnitsStyle::None;
    1383           26 :             AlphArray(2) = "None";
    1384              :         }
    1385            0 :     } else if (NumTabularStyle > 1) {
    1386            0 :         ShowWarningError(state, format("{}: Only one instance of this object is allowed. Commas will be used.", CurrentModuleObject));
    1387            0 :         ort->TableStyle = TableStyle::Comma;
    1388            0 :         ort->del = std::string(1, CharComma); // comma
    1389            0 :         AlphArray(1) = "COMMA";
    1390            0 :         ort->unitsStyle = UnitsStyle::None;
    1391            0 :         AlphArray(2) = "None";
    1392              :     }
    1393              : 
    1394           74 :     if (ort->WriteTabularFiles) {
    1395            0 :         print(state.files.eio, "! <Tabular Report>,Style,Unit Conversion\n");
    1396            0 :         if (AlphArray(1) != "HTML") {
    1397            0 :             ConvertCaseToLower(AlphArray(1), AlphArray(2));
    1398            0 :             AlphArray(1).erase(1);
    1399            0 :             AlphArray(1) += AlphArray(2).substr(1);
    1400              :         }
    1401            0 :         print(state.files.eio, "Tabular Report,{},{}\n", AlphArray(1), AlphArray(2));
    1402              :     }
    1403           74 : }
    1404              : 
    1405            8 : UnitsStyle SetUnitsStyleFromString(std::string const &unitStringIn)
    1406              : {
    1407            8 :     UnitsStyle unitsStyleReturn = static_cast<UnitsStyle>(getEnumValue(UnitsStyleNamesUC, Util::makeUPPER(unitStringIn)));
    1408            8 :     if (unitsStyleReturn == UnitsStyle::Invalid) {
    1409            1 :         unitsStyleReturn = UnitsStyle::NotFound;
    1410              :     }
    1411              : 
    1412            8 :     return unitsStyleReturn;
    1413              : }
    1414              : 
    1415           88 : void GetInputOutputTableSummaryReports(EnergyPlusData &state)
    1416              : {
    1417              :     // SUBROUTINE INFORMATION:
    1418              :     //       AUTHOR         Jason Glazer
    1419              :     //       DATE WRITTEN   November 2003
    1420              :     //       MODIFIED       na
    1421              :     //       RE-ENGINEERED  na
    1422              : 
    1423              :     // PURPOSE OF THIS SUBROUTINE:
    1424              :     //   This routine flags if any of the predefined reports
    1425              :     //   are requested by the user
    1426              : 
    1427              :     // METHODOLOGY EMPLOYED:
    1428              :     //   Uses get input structure similar to other objects
    1429              : 
    1430              :     // REFERENCES:
    1431              :     // na
    1432              : 
    1433              :     // Using/Aliasing
    1434              :     using DataStringGlobals::CharComma;
    1435              :     using DataStringGlobals::CharSpace;
    1436              :     using DataStringGlobals::CharTab;
    1437              : 
    1438              :     // SUBROUTINE PARAMETER DEFINITIONS:
    1439          248 :     static std::string const CurrentModuleObject("Output:Table:SummaryReports");
    1440              : 
    1441              :     // INTERFACE BLOCK SPECIFICATIONS:
    1442              :     // na
    1443              : 
    1444              :     // DERIVED TYPE DEFINITIONS:
    1445              : 
    1446              :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
    1447           88 :     auto &ort = state.dataOutRptTab;
    1448           88 :     bool ErrorsFound = false;
    1449              : 
    1450           88 :     if (!state.files.outputControl.writeTabular(state)) {
    1451            0 :         ort->WriteTabularFiles = false;
    1452            0 :         return;
    1453              :     }
    1454              : 
    1455           88 :     int NumTabularPredefined = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, CurrentModuleObject);
    1456           88 :     if (NumTabularPredefined == 1) {
    1457              : 
    1458           47 :         int NumParams = 0;
    1459           47 :         int NumAlphas = 0; // Number of elements in the alpha array
    1460           47 :         int NumNums = 0;   // Number of elements in the numeric array
    1461           47 :         Array1D_string AlphArray;
    1462           47 :         Array1D<Real64> NumArray;
    1463           47 :         int IOStat = -1; // IO Status when calling get input subroutine
    1464              : 
    1465              :         // find out how many fields since the object is extensible
    1466           47 :         state.dataInputProcessing->inputProcessor->getObjectDefMaxArgs(state, CurrentModuleObject, NumParams, NumAlphas, NumNums);
    1467              :         // allocate the temporary arrays for the call to get the filed
    1468           47 :         AlphArray.allocate(NumAlphas);
    1469              :         // don't really need the NumArray since not expecting any numbers but the call requires it
    1470           47 :         NumArray.dimension(NumNums, 0.0);
    1471              :         // get the object
    1472           47 :         state.dataInputProcessing->inputProcessor->getObjectItem(state, CurrentModuleObject, 1, AlphArray, NumAlphas, NumArray, NumNums, IOStat);
    1473              :         // default all report flags to false (do not get produced)
    1474           47 :         ort->displayTabularBEPS = false;
    1475              :         // initialize the names of the predefined monthly report titles
    1476           47 :         InitializePredefinedMonthlyTitles(state);
    1477              :         // loop through the fields looking for matching report titles
    1478           97 :         for (int iReport = 1; iReport <= NumAlphas; ++iReport) {
    1479           50 :             bool nameFound = false;
    1480           50 :             if (AlphArray(iReport).empty()) {
    1481            0 :                 ShowWarningError(state, "Blank report name in Output:Table:SummaryReports");
    1482           50 :             } else if (Util::SameString(AlphArray(iReport), "AnnualBuildingUtilityPerformanceSummary")) {
    1483            0 :                 ort->displayTabularBEPS = true;
    1484            0 :                 ort->WriteTabularFiles = true;
    1485            0 :                 nameFound = true;
    1486           50 :             } else if (Util::SameString(AlphArray(iReport), "ComponentCostEconomicsSummary")) {
    1487            0 :                 ort->displayTabularCompCosts = true;
    1488            0 :                 ort->WriteTabularFiles = true;
    1489            0 :                 nameFound = true;
    1490           50 :             } else if (Util::SameString(AlphArray(iReport), "InputVerificationandResultsSummary")) {
    1491            0 :                 ort->displayTabularVeriSum = true;
    1492            0 :                 ort->WriteTabularFiles = true;
    1493            0 :                 nameFound = true;
    1494           50 :             } else if (Util::SameString(AlphArray(iReport), "ComponentSizingSummary")) {
    1495            0 :                 ort->displayComponentSizing = true;
    1496            0 :                 ort->WriteTabularFiles = true;
    1497            0 :                 nameFound = true;
    1498           50 :             } else if (Util::SameString(AlphArray(iReport), "SurfaceShadowingSummary")) {
    1499            0 :                 ort->displaySurfaceShadowing = true;
    1500            0 :                 ort->WriteTabularFiles = true;
    1501            0 :                 nameFound = true;
    1502           50 :             } else if (Util::SameString(AlphArray(iReport), "DemandEndUseComponentsSummary")) {
    1503            0 :                 ort->displayDemandEndUse = true;
    1504            0 :                 ort->WriteTabularFiles = true;
    1505            0 :                 nameFound = true;
    1506           50 :             } else if (Util::SameString(AlphArray(iReport), "AdaptiveComfortSummary")) {
    1507            0 :                 ort->displayAdaptiveComfort = true;
    1508            0 :                 ort->WriteTabularFiles = true;
    1509            0 :                 nameFound = true;
    1510           50 :             } else if (Util::SameString(AlphArray(iReport), "SourceEnergyEndUseComponentsSummary")) {
    1511            0 :                 ort->displaySourceEnergyEndUseSummary = true;
    1512            0 :                 ort->WriteTabularFiles = true;
    1513            0 :                 nameFound = true;
    1514           50 :             } else if (Util::SameString(AlphArray(iReport), "ZoneComponentLoadSummary")) {
    1515            0 :                 ort->displayZoneComponentLoadSummary = true;
    1516            0 :                 ort->WriteTabularFiles = true;
    1517            0 :                 nameFound = true;
    1518           50 :             } else if (Util::SameString(AlphArray(iReport), "AirLoopComponentLoadSummary")) {
    1519            0 :                 ort->displayAirLoopComponentLoadSummary = true;
    1520            0 :                 ort->WriteTabularFiles = true;
    1521            0 :                 nameFound = true;
    1522           50 :             } else if (Util::SameString(AlphArray(iReport), "FacilityComponentLoadSummary")) {
    1523            0 :                 ort->displayFacilityComponentLoadSummary = true;
    1524            0 :                 ort->WriteTabularFiles = true;
    1525            0 :                 nameFound = true;
    1526           50 :             } else if (Util::SameString(AlphArray(iReport), "LEEDSummary")) {
    1527            0 :                 ort->displayLEEDSummary = true;
    1528            0 :                 ort->WriteTabularFiles = true;
    1529            0 :                 nameFound = true;
    1530           50 :             } else if (Util::SameString(AlphArray(iReport), "LifeCycleCostReport")) {
    1531            0 :                 ort->displayLifeCycleCostReport = true;
    1532            0 :                 ort->WriteTabularFiles = true;
    1533            0 :                 nameFound = true;
    1534           50 :             } else if (Util::SameString(AlphArray(iReport), "TariffReport")) {
    1535            0 :                 ort->displayTariffReport = true;
    1536            0 :                 ort->WriteTabularFiles = true;
    1537            0 :                 nameFound = true;
    1538           50 :             } else if (Util::SameString(AlphArray(iReport), "EconomicResultSummary")) {
    1539            0 :                 ort->displayEconomicResultSummary = true;
    1540            0 :                 ort->WriteTabularFiles = true;
    1541            0 :                 nameFound = true;
    1542           50 :             } else if (Util::SameString(AlphArray(iReport), "HeatEmissionsSummary")) {
    1543            0 :                 ort->displayHeatEmissionsSummary = true;
    1544            0 :                 ort->WriteTabularFiles = true;
    1545            0 :                 nameFound = true;
    1546           50 :             } else if (Util::SameString(AlphArray(iReport), "ThermalResilienceSummary")) {
    1547            0 :                 ort->displayThermalResilienceSummary = true;
    1548            0 :                 ort->displayThermalResilienceSummaryExplicitly = true;
    1549            0 :                 ort->WriteTabularFiles = true;
    1550            0 :                 nameFound = true;
    1551           50 :             } else if (Util::SameString(AlphArray(iReport), "CO2ResilienceSummary")) {
    1552            0 :                 ort->displayCO2ResilienceSummary = true;
    1553            0 :                 ort->displayCO2ResilienceSummaryExplicitly = true;
    1554            0 :                 ort->WriteTabularFiles = true;
    1555            0 :                 nameFound = true;
    1556           50 :             } else if (Util::SameString(AlphArray(iReport), "VisualResilienceSummary")) {
    1557            0 :                 ort->displayVisualResilienceSummary = true;
    1558            0 :                 ort->displayVisualResilienceSummaryExplicitly = true;
    1559            0 :                 ort->WriteTabularFiles = true;
    1560            0 :                 nameFound = true;
    1561           50 :             } else if (Util::SameString(AlphArray(iReport), "EnergyMeters")) {
    1562            0 :                 ort->WriteTabularFiles = true;
    1563            0 :                 nameFound = true;
    1564           50 :             } else if (Util::SameString(AlphArray(iReport), "InitializationSummary")) {
    1565            0 :                 ort->WriteTabularFiles = true;
    1566            0 :                 ort->displayEioSummary = true;
    1567            0 :                 nameFound = true;
    1568           50 :             } else if (Util::SameString(AlphArray(iReport), "AllSummary")) {
    1569           37 :                 ort->WriteTabularFiles = true;
    1570           37 :                 ort->displayTabularBEPS = true;
    1571           37 :                 ort->displayTabularVeriSum = true;
    1572           37 :                 ort->displayTabularCompCosts = true;
    1573           37 :                 ort->displaySurfaceShadowing = true;
    1574           37 :                 ort->displayComponentSizing = true;
    1575           37 :                 ort->displayDemandEndUse = true;
    1576           37 :                 ort->displayAdaptiveComfort = true;
    1577           37 :                 ort->displaySourceEnergyEndUseSummary = true;
    1578           37 :                 ort->displayLifeCycleCostReport = true;
    1579           37 :                 ort->displayTariffReport = true;
    1580           37 :                 ort->displayEconomicResultSummary = true;
    1581           37 :                 ort->displayEioSummary = true;
    1582           37 :                 ort->displayLEEDSummary = true;
    1583           37 :                 ort->displayHeatEmissionsSummary = true;
    1584           37 :                 ort->displayThermalResilienceSummary = true;
    1585           37 :                 ort->displayCO2ResilienceSummary = true;
    1586           37 :                 ort->displayVisualResilienceSummary = true;
    1587           37 :                 nameFound = true;
    1588          679 :                 for (int jReport = 1; jReport <= state.dataOutRptPredefined->numReportName; ++jReport) {
    1589          642 :                     state.dataOutRptPredefined->reportName(jReport).show = true;
    1590              :                 }
    1591           13 :             } else if (Util::SameString(AlphArray(iReport), "AllSummaryAndSizingPeriod")) {
    1592            4 :                 ort->WriteTabularFiles = true;
    1593            4 :                 ort->displayTabularBEPS = true;
    1594            4 :                 ort->displayTabularVeriSum = true;
    1595            4 :                 ort->displayTabularCompCosts = true;
    1596            4 :                 ort->displaySurfaceShadowing = true;
    1597            4 :                 ort->displayComponentSizing = true;
    1598            4 :                 ort->displayDemandEndUse = true;
    1599            4 :                 ort->displayAdaptiveComfort = true;
    1600            4 :                 ort->displaySourceEnergyEndUseSummary = true;
    1601            4 :                 ort->displayLifeCycleCostReport = true;
    1602            4 :                 ort->displayTariffReport = true;
    1603            4 :                 ort->displayEconomicResultSummary = true;
    1604            4 :                 ort->displayEioSummary = true;
    1605            4 :                 ort->displayLEEDSummary = true;
    1606            4 :                 ort->displayHeatEmissionsSummary = true;
    1607            4 :                 ort->displayThermalResilienceSummary = true;
    1608            4 :                 ort->displayCO2ResilienceSummary = true;
    1609            4 :                 ort->displayVisualResilienceSummary = true;
    1610            4 :                 nameFound = true;
    1611           76 :                 for (int jReport = 1; jReport <= state.dataOutRptPredefined->numReportName; ++jReport) {
    1612           72 :                     state.dataOutRptPredefined->reportName(jReport).show = true;
    1613              :                 }
    1614              :                 // the sizing period reports
    1615            4 :                 ort->displayZoneComponentLoadSummary = true;
    1616            4 :                 ort->displayAirLoopComponentLoadSummary = true;
    1617            4 :                 ort->displayFacilityComponentLoadSummary = true;
    1618            9 :             } else if (Util::SameString(AlphArray(iReport), "AllMonthly")) {
    1619            0 :                 ort->WriteTabularFiles = true;
    1620            0 :                 for (int jReport = 1; jReport <= numNamedMonthly; ++jReport) {
    1621            0 :                     ort->namedMonthly(jReport).show = true;
    1622              :                 }
    1623            0 :                 nameFound = true;
    1624            9 :             } else if (Util::SameString(AlphArray(iReport), "AllSummaryAndMonthly")) {
    1625            6 :                 ort->WriteTabularFiles = true;
    1626            6 :                 ort->displayTabularBEPS = true;
    1627            6 :                 ort->displayTabularVeriSum = true;
    1628            6 :                 ort->displayTabularCompCosts = true;
    1629            6 :                 ort->displaySurfaceShadowing = true;
    1630            6 :                 ort->displayComponentSizing = true;
    1631            6 :                 ort->displayDemandEndUse = true;
    1632            6 :                 ort->displayAdaptiveComfort = true;
    1633            6 :                 ort->displaySourceEnergyEndUseSummary = true;
    1634            6 :                 ort->displayLifeCycleCostReport = true;
    1635            6 :                 ort->displayTariffReport = true;
    1636            6 :                 ort->displayEconomicResultSummary = true;
    1637            6 :                 ort->displayEioSummary = true;
    1638            6 :                 ort->displayLEEDSummary = true;
    1639            6 :                 ort->displayHeatEmissionsSummary = true;
    1640            6 :                 ort->displayThermalResilienceSummary = true;
    1641            6 :                 ort->displayCO2ResilienceSummary = true;
    1642            6 :                 ort->displayVisualResilienceSummary = true;
    1643            6 :                 nameFound = true;
    1644            6 :                 for (int jReport = 1; jReport <= state.dataOutRptPredefined->numReportName; ++jReport) {
    1645            0 :                     state.dataOutRptPredefined->reportName(jReport).show = true;
    1646              :                 }
    1647          384 :                 for (int jReport = 1; jReport <= numNamedMonthly; ++jReport) {
    1648          378 :                     ort->namedMonthly(jReport).show = true;
    1649              :                 }
    1650            3 :             } else if (Util::SameString(AlphArray(iReport), "AllSummaryMonthlyAndSizingPeriod")) {
    1651            0 :                 ort->WriteTabularFiles = true;
    1652            0 :                 ort->displayTabularBEPS = true;
    1653            0 :                 ort->displayTabularVeriSum = true;
    1654            0 :                 ort->displayTabularCompCosts = true;
    1655            0 :                 ort->displaySurfaceShadowing = true;
    1656            0 :                 ort->displayComponentSizing = true;
    1657            0 :                 ort->displayDemandEndUse = true;
    1658            0 :                 ort->displayAdaptiveComfort = true;
    1659            0 :                 ort->displaySourceEnergyEndUseSummary = true;
    1660            0 :                 ort->displayLifeCycleCostReport = true;
    1661            0 :                 ort->displayTariffReport = true;
    1662            0 :                 ort->displayEconomicResultSummary = true;
    1663            0 :                 ort->displayEioSummary = true;
    1664            0 :                 ort->displayLEEDSummary = true;
    1665            0 :                 ort->displayHeatEmissionsSummary = true;
    1666            0 :                 ort->displayThermalResilienceSummary = true;
    1667            0 :                 ort->displayCO2ResilienceSummary = true;
    1668            0 :                 ort->displayVisualResilienceSummary = true;
    1669            0 :                 nameFound = true;
    1670            0 :                 for (int jReport = 1; jReport <= state.dataOutRptPredefined->numReportName; ++jReport) {
    1671            0 :                     state.dataOutRptPredefined->reportName(jReport).show = true;
    1672              :                 }
    1673            0 :                 for (int jReport = 1; jReport <= numNamedMonthly; ++jReport) {
    1674            0 :                     ort->namedMonthly(jReport).show = true;
    1675              :                 }
    1676              :                 // the sizing period reports
    1677            0 :                 ort->displayZoneComponentLoadSummary = true;
    1678            0 :                 ort->displayAirLoopComponentLoadSummary = true;
    1679            0 :                 ort->displayFacilityComponentLoadSummary = true;
    1680              :             }
    1681              :             // check the reports that are predefined and are created by OutputReportPredefined
    1682          799 :             for (int jReport = 1; jReport <= state.dataOutRptPredefined->numReportName; ++jReport) {
    1683          749 :                 if (Util::SameString(AlphArray(iReport), state.dataOutRptPredefined->reportName(jReport).name)) {
    1684            1 :                     ort->WriteTabularFiles = true;
    1685            1 :                     state.dataOutRptPredefined->reportName(jReport).show = true;
    1686            1 :                     nameFound = true;
    1687              :                 }
    1688          749 :                 if (Util::SameString(AlphArray(iReport), state.dataOutRptPredefined->reportName(jReport).abrev)) {
    1689            0 :                     ort->WriteTabularFiles = true;
    1690            0 :                     state.dataOutRptPredefined->reportName(jReport).show = true;
    1691            0 :                     nameFound = true;
    1692              :                 }
    1693              :             }
    1694              :             // check if the predefined monthly reports are used
    1695         3200 :             for (int jReport = 1; jReport <= numNamedMonthly; ++jReport) {
    1696         3150 :                 if (Util::SameString(AlphArray(iReport), ort->namedMonthly(jReport).title)) {
    1697            1 :                     ort->namedMonthly(jReport).show = true;
    1698            1 :                     ort->WriteTabularFiles = true;
    1699            1 :                     nameFound = true;
    1700              :                 }
    1701              :             }
    1702           50 :             if (!nameFound) {
    1703            1 :                 if (Util::SameString(AlphArray(iReport), "Standard62.1Summary")) {
    1704            1 :                     ShowWarningError(state, format("{} Field[{}]=\"Standard62.1Summary\", Report is not enabled.", CurrentModuleObject, iReport));
    1705            3 :                     ShowContinueError(state, "Do Zone Sizing or Do System Sizing must be enabled in SimulationControl.");
    1706              : 
    1707              :                 } else {
    1708            0 :                     ShowSevereError(
    1709              :                         state,
    1710            0 :                         format(
    1711              :                             "{} Field[{}]=\"{}\", invalid report name -- will not be reported.", CurrentModuleObject, iReport, AlphArray(iReport)));
    1712              :                     //      ErrorsFound=.TRUE.
    1713              :                 }
    1714              :             }
    1715              :         }
    1716           47 :         CreatePredefinedMonthlyReports(state);
    1717           88 :     } else if (NumTabularPredefined > 1) {
    1718            0 :         ShowSevereError(state, format("{}: Only one instance of this object is allowed.", CurrentModuleObject));
    1719            0 :         ErrorsFound = true;
    1720              :     }
    1721           88 :     if (ErrorsFound) {
    1722            0 :         ShowFatalError(state, format("{}: Preceding errors cause termination.", CurrentModuleObject));
    1723              :     }
    1724              :     // if the BEPS report has been called for than initialize its arrays
    1725           88 :     if (ort->displayTabularBEPS || ort->displayDemandEndUse || ort->displaySourceEnergyEndUseSummary || ort->displayLEEDSummary) {
    1726              :         // initialize the resource type names
    1727           49 :         ort->resourceTypeNames(1) = Constant::eResourceNames[static_cast<int>(Constant::eResource::Electricity)];
    1728           49 :         ort->resourceTypeNames(2) = Constant::eResourceNames[static_cast<int>(Constant::eResource::NaturalGas)];
    1729           49 :         ort->resourceTypeNames(3) = Constant::eResourceNames[static_cast<int>(Constant::eResource::DistrictCooling)];
    1730           49 :         ort->resourceTypeNames(4) = Constant::eResourceNames[static_cast<int>(Constant::eResource::DistrictHeatingWater)];
    1731           49 :         ort->resourceTypeNames(5) = Constant::eResourceNames[static_cast<int>(Constant::eResource::DistrictHeatingSteam)];
    1732           49 :         ort->resourceTypeNames(6) = Constant::eResourceNames[static_cast<int>(Constant::eResource::Gasoline)];
    1733           49 :         ort->resourceTypeNames(7) = Constant::eResourceNames[static_cast<int>(Constant::eResource::Water)];
    1734           49 :         ort->resourceTypeNames(8) = Constant::eResourceNames[static_cast<int>(Constant::eResource::Diesel)];
    1735           49 :         ort->resourceTypeNames(9) = Constant::eResourceNames[static_cast<int>(Constant::eResource::Coal)];
    1736           49 :         ort->resourceTypeNames(10) = Constant::eResourceNames[static_cast<int>(Constant::eResource::FuelOilNo1)];
    1737           49 :         ort->resourceTypeNames(11) = Constant::eResourceNames[static_cast<int>(Constant::eResource::FuelOilNo2)];
    1738           49 :         ort->resourceTypeNames(12) = Constant::eResourceNames[static_cast<int>(Constant::eResource::Propane)];
    1739           49 :         ort->resourceTypeNames(13) = Constant::eResourceNames[static_cast<int>(Constant::eResource::OtherFuel1)];
    1740           49 :         ort->resourceTypeNames(14) = Constant::eResourceNames[static_cast<int>(Constant::eResource::OtherFuel2)];
    1741              : 
    1742           49 :         ort->sourceTypeNames(1) = "Electricity";
    1743           49 :         ort->sourceTypeNames(2) = "NaturalGas";
    1744           49 :         ort->sourceTypeNames(3) = "Gasoline";
    1745           49 :         ort->sourceTypeNames(4) = "Diesel";
    1746           49 :         ort->sourceTypeNames(5) = "Coal";
    1747           49 :         ort->sourceTypeNames(6) = "FuelOilNo1";
    1748           49 :         ort->sourceTypeNames(7) = "FuelOilNo2";
    1749           49 :         ort->sourceTypeNames(8) = "Propane";
    1750           49 :         ort->sourceTypeNames(9) = "PurchasedElectricity";
    1751           49 :         ort->sourceTypeNames(10) = "SoldElectricity";
    1752           49 :         ort->sourceTypeNames(11) = "OtherFuel1";
    1753           49 :         ort->sourceTypeNames(12) = "OtherFuel2";
    1754              : 
    1755              :         // initialize the end use names
    1756           49 :         ort->endUseNames(static_cast<int>(Constant::EndUse::Heating) + 1) = "Heating";
    1757           49 :         ort->endUseNames(static_cast<int>(Constant::EndUse::Cooling) + 1) = "Cooling";
    1758           49 :         ort->endUseNames(static_cast<int>(Constant::EndUse::InteriorLights) + 1) = "InteriorLights";
    1759           49 :         ort->endUseNames(static_cast<int>(Constant::EndUse::ExteriorLights) + 1) = "ExteriorLights";
    1760           49 :         ort->endUseNames(static_cast<int>(Constant::EndUse::InteriorEquipment) + 1) = "InteriorEquipment";
    1761           49 :         ort->endUseNames(static_cast<int>(Constant::EndUse::ExteriorEquipment) + 1) = "ExteriorEquipment";
    1762           49 :         ort->endUseNames(static_cast<int>(Constant::EndUse::Fans) + 1) = "Fans";
    1763           49 :         ort->endUseNames(static_cast<int>(Constant::EndUse::Pumps) + 1) = "Pumps";
    1764           49 :         ort->endUseNames(static_cast<int>(Constant::EndUse::HeatRejection) + 1) = "HeatRejection";
    1765           49 :         ort->endUseNames(static_cast<int>(Constant::EndUse::Humidification) + 1) = "Humidifier";
    1766           49 :         ort->endUseNames(static_cast<int>(Constant::EndUse::HeatRecovery) + 1) = "HeatRecovery";
    1767           49 :         ort->endUseNames(static_cast<int>(Constant::EndUse::WaterSystem) + 1) = "WaterSystems";
    1768           49 :         ort->endUseNames(static_cast<int>(Constant::EndUse::Refrigeration) + 1) = "Refrigeration";
    1769           49 :         ort->endUseNames(static_cast<int>(Constant::EndUse::Cogeneration) + 1) = "Cogeneration";
    1770              : 
    1771           49 :         auto &op = state.dataOutputProcessor;
    1772              :         // End use subs must be dynamically allocated to accommodate the end use with the most subcategories
    1773           49 :         ort->meterNumEndUseSubBEPS.allocate(op->MaxNumSubcategories, static_cast<int>(Constant::EndUse::Num), numResourceTypes);
    1774           49 :         ort->meterNumEndUseSpTypeBEPS.allocate(op->maxNumEndUseSpaceTypes, static_cast<int>(Constant::EndUse::Num), numResourceTypes);
    1775          735 :         for (int endUse = 1; endUse <= static_cast<int>(Constant::EndUse::Num); ++endUse) {
    1776        10290 :             for (int resType = 1; resType <= numResourceTypes; ++resType) {
    1777        19992 :                 for (int subCat = 1; subCat <= op->MaxNumSubcategories; ++subCat) {
    1778        10388 :                     ort->meterNumEndUseSubBEPS(subCat, endUse, resType) = -1;
    1779              :                 }
    1780        19208 :                 for (int spType = 1; spType <= op->maxNumEndUseSpaceTypes; ++spType) {
    1781         9604 :                     ort->meterNumEndUseSpTypeBEPS(spType, endUse, resType) = -1;
    1782              :                 }
    1783              :             }
    1784              :         }
    1785              : 
    1786              :         // loop through all of the resources and end uses and sub end uses for the entire facility
    1787          735 :         for (int iResource = 1; iResource <= numResourceTypes; ++iResource) {
    1788          686 :             std::string meterName = format("{}:FACILITY", ort->resourceTypeNames(iResource));
    1789          686 :             int meterNumber = GetMeterIndex(state, Util::makeUPPER(meterName));
    1790          686 :             ort->meterNumTotalsBEPS(iResource) = meterNumber;
    1791              : 
    1792        10290 :             for (int jEndUse = 1; jEndUse <= static_cast<int>(Constant::EndUse::Num); ++jEndUse) {
    1793         9604 :                 meterName = format("{}:{}", ort->endUseNames(jEndUse), ort->resourceTypeNames(iResource)); //// ':FACILITY'
    1794         9604 :                 meterNumber = GetMeterIndex(state, Util::makeUPPER(meterName));
    1795         9604 :                 ort->meterNumEndUseBEPS(iResource, jEndUse) = meterNumber;
    1796              : 
    1797        12152 :                 for (int kEndUseSub = 1; kEndUseSub <= op->EndUseCategory(jEndUse).NumSubcategories; ++kEndUseSub) {
    1798        10192 :                     meterName = format("{}:{}:{}",
    1799         2548 :                                        op->EndUseCategory(jEndUse).SubcategoryName(kEndUseSub),
    1800         2548 :                                        ort->endUseNames(jEndUse),
    1801         5096 :                                        ort->resourceTypeNames(iResource));
    1802         2548 :                     meterNumber = GetMeterIndex(state, Util::makeUPPER(meterName));
    1803         2548 :                     ort->meterNumEndUseSubBEPS(kEndUseSub, jEndUse, iResource) = meterNumber;
    1804              :                 }
    1805         9940 :                 for (int kEndUseSpType = 1; kEndUseSpType <= op->EndUseCategory(jEndUse).numSpaceTypes; ++kEndUseSpType) {
    1806         1008 :                     meterName = format("{}:{}:SpaceType:{}",
    1807          336 :                                        ort->endUseNames(jEndUse),
    1808          336 :                                        ort->resourceTypeNames(iResource),
    1809          672 :                                        op->EndUseCategory(jEndUse).spaceTypeName(kEndUseSpType));
    1810          336 :                     meterNumber = GetMeterIndex(state, Util::makeUPPER(meterName));
    1811          336 :                     ort->meterNumEndUseSpTypeBEPS(kEndUseSpType, jEndUse, iResource) = meterNumber;
    1812              :                 }
    1813              :             }
    1814          686 :         }
    1815              : 
    1816          637 :         for (int iResource = 1; iResource <= numSourceTypes; ++iResource) {
    1817          588 :             int const meterNumber = GetMeterIndex(state, Util::makeUPPER(format("{}Emissions:Source", ort->sourceTypeNames(iResource))));
    1818          588 :             ort->meterNumTotalsSource(iResource) = meterNumber;
    1819              :         }
    1820              : 
    1821              :         // initialize the gathering arrays to zero
    1822           49 :         ort->gatherTotalsBEPS = 0.0;
    1823           49 :         ort->gatherTotalsBySourceBEPS = 0.0;
    1824           49 :         ort->gatherTotalsSource = 0.0;
    1825           49 :         ort->gatherTotalsBySource = 0.0;
    1826           49 :         ort->gatherEndUseBEPS = 0.0;
    1827           49 :         ort->gatherEndUseBySourceBEPS = 0.0;
    1828              :         // End use subs must be dynamically allocated to accommodate the end use with the most subcategories
    1829           49 :         ort->gatherEndUseSubBEPS.allocate(op->MaxNumSubcategories, static_cast<int>(Constant::EndUse::Num), numResourceTypes);
    1830           49 :         ort->gatherEndUseSubBEPS = 0.0;
    1831           49 :         ort->gatherEndUseSpTypeBEPS.allocate(op->maxNumEndUseSpaceTypes, static_cast<int>(Constant::EndUse::Num), numResourceTypes);
    1832           49 :         ort->gatherEndUseSpTypeBEPS = 0.0;
    1833           49 :         ort->gatherDemandEndUseSub.allocate(op->MaxNumSubcategories, static_cast<int>(Constant::EndUse::Num), numResourceTypes);
    1834           49 :         ort->gatherDemandEndUseSub = 0.0;
    1835           49 :         ort->gatherDemandIndEndUseSub.allocate(op->MaxNumSubcategories, static_cast<int>(Constant::EndUse::Num), numResourceTypes);
    1836           49 :         ort->gatherDemandIndEndUseSub = 0.0;
    1837              : 
    1838              :         // get meter numbers for other meters relating to electric load components
    1839           98 :         ort->meterNumPowerFuelFireGen = GetMeterIndex(state, "COGENERATION:ELECTRICITYPRODUCED");
    1840           98 :         ort->meterNumPowerPV = GetMeterIndex(state, "PHOTOVOLTAIC:ELECTRICITYPRODUCED");
    1841           98 :         ort->meterNumPowerWind = GetMeterIndex(state, "WINDTURBINE:ELECTRICITYPRODUCED");
    1842           98 :         ort->meterNumPowerHTGeothermal = GetMeterIndex(state, "HTGEOTHERMAL:ELECTRICITYPRODUCED");
    1843           98 :         ort->meterNumElecStorage = GetMeterIndex(state, "ELECTRICSTORAGE:ELECTRICITYPRODUCED");
    1844           98 :         ort->meterNumPowerConversion = GetMeterIndex(state, "POWERCONVERSION:ELECTRICITYPRODUCED");
    1845           98 :         ort->meterNumElecProduced = GetMeterIndex(state, "ELECTRICITYPRODUCED:FACILITY");
    1846           98 :         ort->meterNumElecPurchased = GetMeterIndex(state, "ELECTRICITYPURCHASED:FACILITY");
    1847           49 :         ort->meterNumElecSurplusSold = GetMeterIndex(state, "ELECTRICITYSURPLUSSOLD:FACILITY");
    1848              :         // if no ElectricityPurchased:Facility meter is defined then no electric load center
    1849              :         // was created by the user and no power generation will occur in the plant. The amount
    1850              :         // purchased would be the total end use.
    1851           49 :         if (ort->meterNumElecPurchased == 0) {
    1852            0 :             ort->meterNumElecPurchased = GetMeterIndex(state, "ELECTRICITY:FACILITY");
    1853              :         }
    1854              : 
    1855              :         // initialize the gathering variables for the electric load components
    1856           49 :         ort->gatherPowerFuelFireGen = 0.0;
    1857           49 :         ort->gatherPowerPV = 0.0;
    1858           49 :         ort->gatherPowerWind = 0.0;
    1859           49 :         ort->gatherPowerHTGeothermal = 0.0;
    1860           49 :         ort->gatherElecProduced = 0.0;
    1861           49 :         ort->gatherElecPurchased = 0.0;
    1862           49 :         ort->gatherElecSurplusSold = 0.0;
    1863           49 :         ort->gatherElecStorage = 0.0;
    1864           49 :         ort->gatherPowerConversion = 0.0;
    1865              : 
    1866              :         // get meter numbers for onsite thermal components on BEPS report
    1867           98 :         ort->meterNumWaterHeatRecovery = GetMeterIndex(state, "HEATRECOVERY:ENERGYTRANSFER");
    1868           98 :         ort->meterNumAirHeatRecoveryCool = GetMeterIndex(state, "HEATRECOVERYFORCOOLING:ENERGYTRANSFER");
    1869           98 :         ort->meterNumAirHeatRecoveryHeat = GetMeterIndex(state, "HEATRECOVERYFORHEATING:ENERGYTRANSFER");
    1870           98 :         ort->meterNumHeatHTGeothermal = GetMeterIndex(state, "HTGEOTHERMAL:HEATPRODUCED");
    1871           98 :         ort->meterNumHeatSolarWater = GetMeterIndex(state, "SOLARWATER:FACILITY");
    1872           49 :         ort->meterNumHeatSolarAir = GetMeterIndex(state, "HEATPRODUCED:SOLARAIR");
    1873              :         // initialize the gathering variables for onsite thermal components on BEPS report
    1874           49 :         ort->gatherWaterHeatRecovery = 0.0;
    1875           49 :         ort->gatherAirHeatRecoveryCool = 0.0;
    1876           49 :         ort->gatherAirHeatRecoveryHeat = 0.0;
    1877           49 :         ort->gatherHeatHTGeothermal = 0.0;
    1878           49 :         ort->gatherHeatSolarWater = 0.0;
    1879           49 :         ort->gatherHeatSolarAir = 0.0;
    1880              : 
    1881              :         // get meter numbers for water components on BEPS report
    1882           98 :         ort->meterNumRainWater = GetMeterIndex(state, "RAINWATER:ONSITEWATER");
    1883           98 :         ort->meterNumCondensate = GetMeterIndex(state, "CONDENSATE:ONSITEWATER");
    1884           98 :         ort->meterNumGroundwater = GetMeterIndex(state, "WELLWATER:ONSITEWATER");
    1885           98 :         ort->meterNumMains = GetMeterIndex(state, "MAINSWATER:FACILITY");
    1886           49 :         ort->meterNumWaterEndUseTotal = GetMeterIndex(state, "WATER:FACILITY");
    1887              : 
    1888              :         // initialize the gathering variables for water components on BEPS report
    1889           49 :         ort->gatherRainWater = 0.0;
    1890           49 :         ort->gatherCondensate = 0.0;
    1891           49 :         ort->gatherWellwater = 0.0;
    1892           49 :         ort->gatherMains = 0.0;
    1893           49 :         ort->gatherWaterEndUseTotal = 0.0;
    1894              :     }
    1895              : }
    1896              : 
    1897           91 : bool isCompLoadRepReq(EnergyPlusData &state)
    1898              : {
    1899              :     // SUBROUTINE INFORMATION:
    1900              :     //       AUTHOR         Jason Glazer
    1901              :     //       DATE WRITTEN   November 2003
    1902              :     //       MODIFIED       na
    1903              :     //       RE-ENGINEERED  na
    1904              : 
    1905              :     // PURPOSE OF THIS SUBROUTINE:
    1906              :     //   Determine if the ZoneComponentLoadSummary or
    1907              :     //   ZoneComponentLoadDetail reports are requested.
    1908              : 
    1909              :     // METHODOLOGY EMPLOYED:
    1910              :     //   Uses get input structure similar to other objects
    1911              : 
    1912              :     // REFERENCES:
    1913              :     // na
    1914              : 
    1915              :     // USE STATEMENTS:
    1916              :     // na
    1917              : 
    1918              :     // Return value
    1919              :     bool isCompLoadRepReq;
    1920              : 
    1921              :     // Locals
    1922              :     // SUBROUTINE ARGUMENT DEFINITIONS:
    1923              :     // na
    1924              : 
    1925              :     // SUBROUTINE PARAMETER DEFINITIONS:
    1926          253 :     static std::string const CurrentModuleObject("Output:Table:SummaryReports");
    1927              : 
    1928              :     // INTERFACE BLOCK SPECIFICATIONS:
    1929              :     // na
    1930              : 
    1931              :     // DERIVED TYPE DEFINITIONS:
    1932              : 
    1933              :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
    1934              : 
    1935           91 :     bool isFound = false;
    1936              : 
    1937           91 :     int const NumTabularPredefined = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, CurrentModuleObject);
    1938           91 :     if (NumTabularPredefined == 1) {
    1939              : 
    1940           42 :         int NumParams = 0;
    1941           42 :         int NumAlphas = 0; // Number of elements in the alpha array
    1942           42 :         int NumNums = 0;   // Number of elements in the numeric array
    1943           42 :         Array1D_string AlphArray;
    1944           42 :         Array1D<Real64> NumArray;
    1945           42 :         int IOStat = -1; // IO Status when calling get input subroutine
    1946              : 
    1947              :         // find out how many fields since the object is extensible
    1948           42 :         state.dataInputProcessing->inputProcessor->getObjectDefMaxArgs(state, CurrentModuleObject, NumParams, NumAlphas, NumNums);
    1949              :         // allocate the temporary arrays for the call to get the filed
    1950           42 :         AlphArray.allocate(NumAlphas);
    1951              :         // don't really need the NumArray since not expecting any numbers but the call requires it
    1952           42 :         NumArray.dimension(NumNums, 0.0);
    1953              :         // get the object
    1954           42 :         state.dataInputProcessing->inputProcessor->getObjectItem(state, CurrentModuleObject, 1, AlphArray, NumAlphas, NumArray, NumNums, IOStat);
    1955              :         // loop through the fields looking for matching report titles
    1956           87 :         for (int iReport = 1; iReport <= NumAlphas; ++iReport) {
    1957           45 :             if (Util::SameString(AlphArray(iReport), "ZoneComponentLoadSummary")) {
    1958            0 :                 isFound = true;
    1959              :             }
    1960           45 :             if (Util::SameString(AlphArray(iReport), "AirLoopComponentLoadSummary")) {
    1961            0 :                 isFound = true;
    1962              :             }
    1963           45 :             if (Util::SameString(AlphArray(iReport), "FacilityComponentLoadSummary")) {
    1964            0 :                 isFound = true;
    1965              :             }
    1966           45 :             if (Util::SameString(AlphArray(iReport), "AllSummaryAndSizingPeriod")) {
    1967            6 :                 isFound = true;
    1968              :             }
    1969           45 :             if (Util::SameString(AlphArray(iReport), "AllSummaryMonthlyAndSizingPeriod")) {
    1970            0 :                 isFound = true;
    1971              :             }
    1972              :         }
    1973           42 :     }
    1974           91 :     isCompLoadRepReq = isFound; // return true if either report was found
    1975           91 :     return isCompLoadRepReq;
    1976              : }
    1977              : 
    1978           94 : bool hasSizingPeriodsDays(EnergyPlusData &state)
    1979              : {
    1980           94 :     int const sizePerDesDays = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "SizingPeriod:DesignDay");
    1981           94 :     int const sizePerWeathFileDays = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "SizingPeriod:WeatherFileDays");
    1982           94 :     return ((sizePerDesDays + sizePerWeathFileDays) > 0);
    1983              : }
    1984              : 
    1985           47 : void InitializePredefinedMonthlyTitles(EnergyPlusData &state)
    1986              : {
    1987              :     // SUBROUTINE INFORMATION:
    1988              :     //       AUTHOR         Jason Glazer
    1989              :     //       DATE WRITTEN   September 2008
    1990              :     //       MODIFIED       na
    1991              :     //       RE-ENGINEERED  na
    1992              : 
    1993              :     // PURPOSE OF THIS SUBROUTINE:
    1994              :     //   Initialize the NamedMonthly array for the titles
    1995              :     //   of the monthly predefined reports
    1996              : 
    1997              :     // METHODOLOGY EMPLOYED:
    1998              :     // REFERENCES:
    1999              :     // na
    2000              : 
    2001              :     // Using/Aliasing
    2002              :     using namespace DataOutputs;
    2003              : 
    2004              :     // Locals
    2005              :     // SUBROUTINE ARGUMENT DEFINITIONS:
    2006              :     // na
    2007              : 
    2008              :     // SUBROUTINE PARAMETER DEFINITIONS:
    2009              :     // na
    2010              : 
    2011              :     // INTERFACE BLOCK SPECIFICATIONS:
    2012              :     // na
    2013              : 
    2014              :     // DERIVED TYPE DEFINITIONS:
    2015              :     // na
    2016              : 
    2017              :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
    2018           47 :     auto &ort = state.dataOutRptTab;
    2019              : 
    2020           47 :     ort->namedMonthly.allocate(numNamedMonthly);
    2021           47 :     ort->namedMonthly(1).title = "ZoneCoolingSummaryMonthly";
    2022           47 :     ort->namedMonthly(2).title = "ZoneHeatingSummaryMonthly";
    2023           47 :     ort->namedMonthly(3).title = "ZoneElectricSummaryMonthly";
    2024           47 :     ort->namedMonthly(4).title = "SpaceGainsMonthly";
    2025           47 :     ort->namedMonthly(5).title = "PeakSpaceGainsMonthly";
    2026           47 :     ort->namedMonthly(6).title = "SpaceGainComponentsAtCoolingPeakMonthly";
    2027           47 :     ort->namedMonthly(7).title = "EnergyConsumptionElectricityNaturalGasMonthly";
    2028           47 :     ort->namedMonthly(8).title = "EnergyConsumptionElectricityGeneratedPropaneMonthly";
    2029           47 :     ort->namedMonthly(9).title = "EnergyConsumptionDieselFuelOilMonthly";
    2030           47 :     ort->namedMonthly(10).title = "EnergyConsumptionDistrictHeatingCoolingMonthly";
    2031           47 :     ort->namedMonthly(11).title = "EnergyConsumptionCoalGasolineMonthly";
    2032           47 :     ort->namedMonthly(12).title = "EnergyConsumptionOtherFuelsMonthly";
    2033           47 :     ort->namedMonthly(13).title = "EndUseEnergyConsumptionElectricityMonthly";
    2034           47 :     ort->namedMonthly(14).title = "EndUseEnergyConsumptionNaturalGasMonthly";
    2035           47 :     ort->namedMonthly(15).title = "EndUseEnergyConsumptionDieselMonthly";
    2036           47 :     ort->namedMonthly(16).title = "EndUseEnergyConsumptionFuelOilMonthly";
    2037           47 :     ort->namedMonthly(17).title = "EndUseEnergyConsumptionCoalMonthly";
    2038           47 :     ort->namedMonthly(18).title = "EndUseEnergyConsumptionPropaneMonthly";
    2039           47 :     ort->namedMonthly(19).title = "EndUseEnergyConsumptionGasolineMonthly";
    2040           47 :     ort->namedMonthly(20).title = "EndUseEnergyConsumptionOtherFuelsMonthly";
    2041           47 :     ort->namedMonthly(21).title = "PeakEnergyEndUseElectricityPart1Monthly";
    2042           47 :     ort->namedMonthly(22).title = "PeakEnergyEndUseElectricityPart2Monthly";
    2043           47 :     ort->namedMonthly(23).title = "ElectricComponentsOfPeakDemandMonthly";
    2044           47 :     ort->namedMonthly(24).title = "PeakEnergyEndUseNaturalGasMonthly";
    2045           47 :     ort->namedMonthly(25).title = "PeakEnergyEndUseDieselMonthly";
    2046           47 :     ort->namedMonthly(26).title = "PeakEnergyEndUseFuelOilMonthly";
    2047           47 :     ort->namedMonthly(27).title = "PeakEnergyEndUseCoalMonthly";
    2048           47 :     ort->namedMonthly(28).title = "PeakEnergyEndUsePropaneMonthly";
    2049           47 :     ort->namedMonthly(29).title = "PeakEnergyEndUseGasolineMonthly";
    2050           47 :     ort->namedMonthly(30).title = "PeakEnergyEndUseOtherFuelsMonthly";
    2051           47 :     ort->namedMonthly(31).title = "SetpointsNotMetWithTemperaturesMonthly";
    2052           47 :     ort->namedMonthly(32).title = "ComfortReportSimple55Monthly";
    2053           47 :     ort->namedMonthly(33).title = "UnglazedTranspiredSolarCollectorSummaryMonthly";
    2054           47 :     ort->namedMonthly(34).title = "OccupantComfortDataSummaryMonthly";
    2055           47 :     ort->namedMonthly(35).title = "ChillerReportMonthly";
    2056           47 :     ort->namedMonthly(36).title = "TowerReportMonthly";
    2057           47 :     ort->namedMonthly(37).title = "BoilerReportMonthly";
    2058           47 :     ort->namedMonthly(38).title = "DXReportMonthly";
    2059           47 :     ort->namedMonthly(39).title = "WindowReportMonthly";
    2060           47 :     ort->namedMonthly(40).title = "WindowEnergyReportMonthly";
    2061           47 :     ort->namedMonthly(41).title = "WindowZoneSummaryMonthly";
    2062           47 :     ort->namedMonthly(42).title = "WindowEnergyZoneSummaryMonthly";
    2063           47 :     ort->namedMonthly(43).title = "AverageOutdoorConditionsMonthly";
    2064           47 :     ort->namedMonthly(44).title = "OutdoorConditionsMaximumDryBulbMonthly";
    2065           47 :     ort->namedMonthly(45).title = "OutdoorConditionsMinimumDryBulbMonthly";
    2066           47 :     ort->namedMonthly(46).title = "OutdoorConditionsMaximumWetBulbMonthly";
    2067           47 :     ort->namedMonthly(47).title = "OutdoorConditionsMaximumDewPointMonthly";
    2068           47 :     ort->namedMonthly(48).title = "OutdoorGroundConditionsMonthly";
    2069           47 :     ort->namedMonthly(49).title = "WindowACReportMonthly";
    2070           47 :     ort->namedMonthly(50).title = "WaterHeaterReportMonthly";
    2071           47 :     ort->namedMonthly(51).title = "GeneratorReportMonthly";
    2072           47 :     ort->namedMonthly(52).title = "DaylightingReportMonthly";
    2073           47 :     ort->namedMonthly(53).title = "CoilReportMonthly";
    2074           47 :     ort->namedMonthly(54).title = "PlantLoopDemandReportMonthly";
    2075           47 :     ort->namedMonthly(55).title = "FanReportMonthly";
    2076           47 :     ort->namedMonthly(56).title = "PumpReportMonthly";
    2077           47 :     ort->namedMonthly(57).title = "CondLoopDemandReportMonthly";
    2078           47 :     ort->namedMonthly(58).title = "ZoneTemperatureOscillationReportMonthly";
    2079           47 :     ort->namedMonthly(59).title = "AirLoopSystemEnergyAndWaterUseMonthly";
    2080           47 :     ort->namedMonthly(60).title = "AirLoopSystemComponentLoadsMonthly";
    2081           47 :     ort->namedMonthly(61).title = "AirLoopSystemComponentEnergyUseMonthly";
    2082           47 :     ort->namedMonthly(62).title = "MechanicalVentilationLoadsMonthly";
    2083           47 :     ort->namedMonthly(63).title = "HeatEmissionsReportMonthly";
    2084              : 
    2085              :     if (numNamedMonthly != NumMonthlyReports) {
    2086              :         ShowFatalError(state,
    2087              :                        format("InitializePredefinedMonthlyTitles: Number of Monthly Reports in OutputReportTabular=[{}] does not match number in "
    2088              :                               "DataOutputs=[{}].",
    2089              :                               numNamedMonthly,
    2090              :                               NumMonthlyReports));
    2091              :     } else {
    2092         3008 :         for (int xcount = 1; xcount <= numNamedMonthly; ++xcount) {
    2093         2961 :             if (!Util::SameString(MonthlyNamedReports(xcount), ort->namedMonthly(xcount).title)) {
    2094            0 :                 ShowSevereError(state,
    2095              :                                 "InitializePredefinedMonthlyTitles: Monthly Report Titles in OutputReportTabular do not match titles in DataOutput.");
    2096            0 :                 ShowContinueError(state, format("first mismatch at ORT [{}] =\"{}\".", numNamedMonthly, ort->namedMonthly(xcount).title));
    2097            0 :                 ShowContinueError(state, format("same location in DO =\"{}\".", MonthlyNamedReports(xcount)));
    2098            0 :                 ShowFatalError(state, "Preceding condition causes termination.");
    2099              :             }
    2100              :         }
    2101              :     }
    2102           47 : }
    2103              : 
    2104           47 : void CreatePredefinedMonthlyReports(EnergyPlusData &state)
    2105              : {
    2106              :     // SUBROUTINE INFORMATION:
    2107              :     //       AUTHOR         Jason Glazer
    2108              :     //       DATE WRITTEN   September 2008
    2109              :     //       MODIFIED       na
    2110              :     //       RE-ENGINEERED  na
    2111              : 
    2112              :     // PURPOSE OF THIS SUBROUTINE:
    2113              :     //   For any predefined monthly reports that have been
    2114              :     //   called out, define the individual columns.
    2115              : 
    2116              :     // METHODOLOGY EMPLOYED:
    2117              :     // REFERENCES:
    2118              :     // na
    2119              : 
    2120              :     // USE STATEMENTS:
    2121              : 
    2122              :     // Locals
    2123              :     // SUBROUTINE ARGUMENT DEFINITIONS:
    2124              :     // na
    2125              : 
    2126              :     // SUBROUTINE PARAMETER DEFINITIONS:
    2127              :     // na
    2128              : 
    2129              :     // INTERFACE BLOCK SPECIFICATIONS:
    2130              :     // na
    2131              : 
    2132              :     // DERIVED TYPE DEFINITIONS:
    2133              :     // na
    2134              : 
    2135              :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
    2136              :     int curReport;
    2137           47 :     auto &ort = state.dataOutRptTab;
    2138              : 
    2139              :     // ----------------------------------------------------------------------------------------
    2140              :     // If any variable are added to these reports they also need to be added to the
    2141              :     // AddVariablesForMonthlyReport routine in InputProcessor.
    2142              :     // ----------------------------------------------------------------------------------------
    2143              : 
    2144           47 :     if (ort->namedMonthly(1).show) {
    2145           12 :         curReport = AddMonthlyReport(state, "ZoneCoolingSummaryMonthly", 2, true);
    2146           24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Air System Sensible Cooling Energy", "", AggType::SumOrAvg);
    2147           24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Air System Sensible Cooling Rate", "", AggType::Maximum);
    2148           24 :         AddMonthlyFieldSetInput(state, curReport, "Site Outdoor Air Drybulb Temperature", "", AggType::ValueWhenMaxMin);
    2149           24 :         AddMonthlyFieldSetInput(state, curReport, "Site Outdoor Air Wetbulb Temperature", "", AggType::ValueWhenMaxMin);
    2150           24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Total Internal Latent Gain Energy", "", AggType::SumOrAvg);
    2151           24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Total Internal Latent Gain Rate", "", AggType::Maximum);
    2152           24 :         AddMonthlyFieldSetInput(state, curReport, "Site Outdoor Air Drybulb Temperature", "", AggType::ValueWhenMaxMin);
    2153           24 :         AddMonthlyFieldSetInput(state, curReport, "Site Outdoor Air Wetbulb Temperature", "", AggType::ValueWhenMaxMin);
    2154              :     }
    2155           47 :     if (ort->namedMonthly(2).show) {
    2156           12 :         curReport = AddMonthlyReport(state, "ZoneHeatingSummaryMonthly", 2, true);
    2157           24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Air System Sensible Heating Energy", "", AggType::SumOrAvg);
    2158           24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Air System Sensible Heating Rate", "", AggType::Maximum);
    2159           24 :         AddMonthlyFieldSetInput(state, curReport, "Site Outdoor Air Drybulb Temperature", "", AggType::ValueWhenMaxMin);
    2160              :     }
    2161           47 :     if (ort->namedMonthly(3).show) {
    2162           12 :         curReport = AddMonthlyReport(state, "ZoneElectricSummaryMonthly", 2, true);
    2163           24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Lights Electricity Energy", "", AggType::SumOrAvg);
    2164           24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Lights Electricity Energy", "", AggType::Maximum);
    2165           24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Electric Equipment Electricity Energy", "", AggType::SumOrAvg);
    2166           24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Electric Equipment Electricity Energy", "", AggType::Maximum);
    2167              :     }
    2168           47 :     if (ort->namedMonthly(4).show) {
    2169           12 :         curReport = AddMonthlyReport(state, "SpaceGainsMonthly", 2, true);
    2170           24 :         AddMonthlyFieldSetInput(state, curReport, "Zone People Total Heating Energy", "", AggType::SumOrAvg);
    2171           24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Lights Total Heating Energy", "", AggType::SumOrAvg);
    2172           24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Electric Equipment Total Heating Energy", "", AggType::SumOrAvg);
    2173           24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Gas Equipment Total Heating Energy", "", AggType::SumOrAvg);
    2174           24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Hot Water Equipment Total Heating Energy", "", AggType::SumOrAvg);
    2175           24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Steam Equipment Total Heating Energy", "", AggType::SumOrAvg);
    2176           24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Other Equipment Total Heating Energy", "", AggType::SumOrAvg);
    2177           24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Infiltration Sensible Heat Gain Energy", "", AggType::SumOrAvg);
    2178           24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Infiltration Sensible Heat Loss Energy", "", AggType::SumOrAvg);
    2179              :     }
    2180           47 :     if (ort->namedMonthly(5).show) {
    2181           12 :         curReport = AddMonthlyReport(state, "PeakSpaceGainsMonthly", 2, true);
    2182           24 :         AddMonthlyFieldSetInput(state, curReport, "Zone People Total Heating Energy", "", AggType::Maximum);
    2183           24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Lights Total Heating Energy", "", AggType::Maximum);
    2184           24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Electric Equipment Total Heating Energy", "", AggType::Maximum);
    2185           24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Gas Equipment Total Heating Energy", "", AggType::Maximum);
    2186           24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Hot Water Equipment Total Heating Energy", "", AggType::Maximum);
    2187           24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Steam Equipment Total Heating Energy", "", AggType::Maximum);
    2188           24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Other Equipment Total Heating Energy", "", AggType::Maximum);
    2189           24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Infiltration Sensible Heat Gain Energy", "", AggType::Maximum);
    2190           24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Infiltration Sensible Heat Loss Energy", "", AggType::Maximum);
    2191              :     }
    2192           47 :     if (ort->namedMonthly(6).show) {
    2193           12 :         curReport = AddMonthlyReport(state, "SpaceGainComponentsAtCoolingPeakMonthly", 2, true);
    2194           24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Air System Sensible Cooling Rate", "", AggType::Maximum);
    2195           24 :         AddMonthlyFieldSetInput(state, curReport, "Zone People Total Heating Energy", "", AggType::ValueWhenMaxMin);
    2196           24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Lights Total Heating Energy", "", AggType::ValueWhenMaxMin);
    2197           24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Electric Equipment Total Heating Energy", "", AggType::ValueWhenMaxMin);
    2198           24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Gas Equipment Total Heating Energy", "", AggType::ValueWhenMaxMin);
    2199           24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Hot Water Equipment Total Heating Energy", "", AggType::ValueWhenMaxMin);
    2200           24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Steam Equipment Total Heating Energy", "", AggType::ValueWhenMaxMin);
    2201           24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Other Equipment Total Heating Energy", "", AggType::ValueWhenMaxMin);
    2202           24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Infiltration Sensible Heat Gain Energy", "", AggType::ValueWhenMaxMin);
    2203           24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Infiltration Sensible Heat Loss Energy", "", AggType::ValueWhenMaxMin);
    2204              :     }
    2205           47 :     if (ort->namedMonthly(7).show) {
    2206           12 :         curReport = AddMonthlyReport(state, "EnergyConsumptionElectricityNaturalGasMonthly", 2, true);
    2207           24 :         AddMonthlyFieldSetInput(state, curReport, "Electricity:Facility", "", AggType::SumOrAvg);
    2208           24 :         AddMonthlyFieldSetInput(state, curReport, "Electricity:Facility", "", AggType::Maximum);
    2209           24 :         AddMonthlyFieldSetInput(state, curReport, "NaturalGas:Facility", "", AggType::SumOrAvg);
    2210           24 :         AddMonthlyFieldSetInput(state, curReport, "NaturalGas:Facility", "", AggType::Maximum);
    2211              :     }
    2212           47 :     if (ort->namedMonthly(8).show) {
    2213           12 :         curReport = AddMonthlyReport(state, "EnergyConsumptionElectricityGeneratedPropaneMonthly", 2, true);
    2214           24 :         AddMonthlyFieldSetInput(state, curReport, "ElectricityProduced:Facility", "", AggType::SumOrAvg);
    2215           24 :         AddMonthlyFieldSetInput(state, curReport, "ElectricityProduced:Facility", "", AggType::Maximum);
    2216           24 :         AddMonthlyFieldSetInput(state, curReport, "Propane:Facility", "", AggType::SumOrAvg);
    2217           24 :         AddMonthlyFieldSetInput(state, curReport, "Propane:Facility", "", AggType::Maximum);
    2218              :     }
    2219           47 :     if (ort->namedMonthly(9).show) {
    2220           12 :         curReport = AddMonthlyReport(state, "EnergyConsumptionDieselFuelOilMonthly", 2, true);
    2221           24 :         AddMonthlyFieldSetInput(state, curReport, "Diesel:Facility", "", AggType::SumOrAvg);
    2222           24 :         AddMonthlyFieldSetInput(state, curReport, "Diesel:Facility", "", AggType::Maximum);
    2223           24 :         AddMonthlyFieldSetInput(state, curReport, "FuelOilNo1:Facility", "", AggType::SumOrAvg);
    2224           24 :         AddMonthlyFieldSetInput(state, curReport, "FuelOilNo1:Facility", "", AggType::Maximum);
    2225           24 :         AddMonthlyFieldSetInput(state, curReport, "FuelOilNo2:Facility", "", AggType::SumOrAvg);
    2226           24 :         AddMonthlyFieldSetInput(state, curReport, "FuelOilNo2:Facility", "", AggType::Maximum);
    2227              :     }
    2228           47 :     if (ort->namedMonthly(10).show) {
    2229           12 :         curReport = AddMonthlyReport(state, "EnergyConsumptionDistrictHeatingCoolingMonthly", 2, true);
    2230           24 :         AddMonthlyFieldSetInput(state, curReport, "DistrictCooling:Facility", "", AggType::SumOrAvg);
    2231           24 :         AddMonthlyFieldSetInput(state, curReport, "DistrictCooling:Facility", "", AggType::Maximum);
    2232           24 :         AddMonthlyFieldSetInput(state, curReport, "DistrictHeatingWater:Facility", "", AggType::SumOrAvg);
    2233           24 :         AddMonthlyFieldSetInput(state, curReport, "DistrictHeatingWater:Facility", "", AggType::Maximum);
    2234           24 :         AddMonthlyFieldSetInput(state, curReport, "DistrictHeatingSteam:Facility", "", AggType::SumOrAvg);
    2235           24 :         AddMonthlyFieldSetInput(state, curReport, "DistrictHeatingSteam:Facility", "", AggType::Maximum);
    2236              :     }
    2237           47 :     if (ort->namedMonthly(11).show) {
    2238           12 :         curReport = AddMonthlyReport(state, "EnergyConsumptionCoalGasolineMonthly", 2, true);
    2239           24 :         AddMonthlyFieldSetInput(state, curReport, "Coal:Facility", "", AggType::SumOrAvg);
    2240           24 :         AddMonthlyFieldSetInput(state, curReport, "Coal:Facility", "", AggType::Maximum);
    2241           24 :         AddMonthlyFieldSetInput(state, curReport, "Gasoline:Facility", "", AggType::SumOrAvg);
    2242           24 :         AddMonthlyFieldSetInput(state, curReport, "Gasoline:Facility", "", AggType::Maximum);
    2243              :     }
    2244           47 :     if (ort->namedMonthly(12).show) {
    2245           12 :         curReport = AddMonthlyReport(state, "EnergyConsumptionOtherFuelsMonthly", 2, true);
    2246           24 :         AddMonthlyFieldSetInput(state, curReport, "OtherFuel1:Facility", "", AggType::SumOrAvg);
    2247           24 :         AddMonthlyFieldSetInput(state, curReport, "OtherFuel1:Facility", "", AggType::Maximum);
    2248           24 :         AddMonthlyFieldSetInput(state, curReport, "OtherFuel2:Facility", "", AggType::SumOrAvg);
    2249           24 :         AddMonthlyFieldSetInput(state, curReport, "OtherFuel2:Facility", "", AggType::Maximum);
    2250              :     }
    2251           47 :     if (ort->namedMonthly(13).show) {
    2252           12 :         curReport = AddMonthlyReport(state, "EndUseEnergyConsumptionElectricityMonthly", 2, true);
    2253           24 :         AddMonthlyFieldSetInput(state, curReport, "InteriorLights:Electricity", "", AggType::SumOrAvg);
    2254           24 :         AddMonthlyFieldSetInput(state, curReport, "ExteriorLights:Electricity", "", AggType::SumOrAvg);
    2255           24 :         AddMonthlyFieldSetInput(state, curReport, "InteriorEquipment:Electricity", "", AggType::SumOrAvg);
    2256           24 :         AddMonthlyFieldSetInput(state, curReport, "ExteriorEquipment:Electricity", "", AggType::SumOrAvg);
    2257           24 :         AddMonthlyFieldSetInput(state, curReport, "Fans:Electricity", "", AggType::SumOrAvg);
    2258           24 :         AddMonthlyFieldSetInput(state, curReport, "Pumps:Electricity", "", AggType::SumOrAvg);
    2259           24 :         AddMonthlyFieldSetInput(state, curReport, "Heating:Electricity", "", AggType::SumOrAvg);
    2260           24 :         AddMonthlyFieldSetInput(state, curReport, "Cooling:Electricity", "", AggType::SumOrAvg);
    2261           24 :         AddMonthlyFieldSetInput(state, curReport, "HeatRejection:Electricity", "", AggType::SumOrAvg);
    2262           24 :         AddMonthlyFieldSetInput(state, curReport, "Humidifier:Electricity", "", AggType::SumOrAvg);
    2263           24 :         AddMonthlyFieldSetInput(state, curReport, "HeatRecovery:Electricity", "", AggType::SumOrAvg);
    2264           24 :         AddMonthlyFieldSetInput(state, curReport, "WaterSystems:Electricity", "", AggType::SumOrAvg);
    2265           24 :         AddMonthlyFieldSetInput(state, curReport, "Cogeneration:Electricity", "", AggType::SumOrAvg);
    2266              :     }
    2267           47 :     if (ort->namedMonthly(14).show) {
    2268           12 :         curReport = AddMonthlyReport(state, "EndUseEnergyConsumptionNaturalGasMonthly", 2, true);
    2269           24 :         AddMonthlyFieldSetInput(state, curReport, "InteriorEquipment:NaturalGas", "", AggType::SumOrAvg);
    2270           24 :         AddMonthlyFieldSetInput(state, curReport, "ExteriorEquipment:NaturalGas", "", AggType::SumOrAvg);
    2271           24 :         AddMonthlyFieldSetInput(state, curReport, "Heating:NaturalGas", "", AggType::SumOrAvg);
    2272           24 :         AddMonthlyFieldSetInput(state, curReport, "Cooling:NaturalGas", "", AggType::SumOrAvg);
    2273           24 :         AddMonthlyFieldSetInput(state, curReport, "WaterSystems:NaturalGas", "", AggType::SumOrAvg);
    2274           24 :         AddMonthlyFieldSetInput(state, curReport, "Cogeneration:NaturalGas", "", AggType::SumOrAvg);
    2275           24 :         AddMonthlyFieldSetInput(state, curReport, "Humidifier:NaturalGas", "", AggType::SumOrAvg);
    2276              :     }
    2277           47 :     if (ort->namedMonthly(15).show) {
    2278           12 :         curReport = AddMonthlyReport(state, "EndUseEnergyConsumptionDieselMonthly", 2, true);
    2279           24 :         AddMonthlyFieldSetInput(state, curReport, "ExteriorEquipment:Diesel", "", AggType::SumOrAvg);
    2280           24 :         AddMonthlyFieldSetInput(state, curReport, "Cooling:Diesel", "", AggType::SumOrAvg);
    2281           24 :         AddMonthlyFieldSetInput(state, curReport, "Heating:Diesel", "", AggType::SumOrAvg);
    2282           24 :         AddMonthlyFieldSetInput(state, curReport, "WaterSystems:Diesel", "", AggType::SumOrAvg);
    2283           24 :         AddMonthlyFieldSetInput(state, curReport, "Cogeneration:Diesel", "", AggType::SumOrAvg);
    2284              :     }
    2285           47 :     if (ort->namedMonthly(16).show) {
    2286           12 :         curReport = AddMonthlyReport(state, "EndUseEnergyConsumptionFuelOilMonthly", 2, true);
    2287           24 :         AddMonthlyFieldSetInput(state, curReport, "ExteriorEquipment:FuelOilNo1", "", AggType::SumOrAvg);
    2288           24 :         AddMonthlyFieldSetInput(state, curReport, "Cooling:FuelOilNo1", "", AggType::SumOrAvg);
    2289           24 :         AddMonthlyFieldSetInput(state, curReport, "Heating:FuelOilNo1", "", AggType::SumOrAvg);
    2290           24 :         AddMonthlyFieldSetInput(state, curReport, "WaterSystems:FuelOilNo1", "", AggType::SumOrAvg);
    2291           24 :         AddMonthlyFieldSetInput(state, curReport, "Cogeneration:FuelOilNo1", "", AggType::SumOrAvg);
    2292           24 :         AddMonthlyFieldSetInput(state, curReport, "ExteriorEquipment:FuelOilNo2", "", AggType::SumOrAvg);
    2293           24 :         AddMonthlyFieldSetInput(state, curReport, "Cooling:FuelOilNo2", "", AggType::SumOrAvg);
    2294           24 :         AddMonthlyFieldSetInput(state, curReport, "Heating:FuelOilNo2", "", AggType::SumOrAvg);
    2295           24 :         AddMonthlyFieldSetInput(state, curReport, "WaterSystems:FuelOilNo2", "", AggType::SumOrAvg);
    2296           24 :         AddMonthlyFieldSetInput(state, curReport, "Cogeneration:FuelOilNo2", "", AggType::SumOrAvg);
    2297              :     }
    2298           47 :     if (ort->namedMonthly(17).show) {
    2299           12 :         curReport = AddMonthlyReport(state, "EndUseEnergyConsumptionCoalMonthly", 2, true);
    2300           24 :         AddMonthlyFieldSetInput(state, curReport, "ExteriorEquipment:Coal", "", AggType::SumOrAvg);
    2301           24 :         AddMonthlyFieldSetInput(state, curReport, "Heating:Coal", "", AggType::SumOrAvg);
    2302           24 :         AddMonthlyFieldSetInput(state, curReport, "WaterSystems:Coal", "", AggType::SumOrAvg);
    2303              :     }
    2304           47 :     if (ort->namedMonthly(18).show) {
    2305           12 :         curReport = AddMonthlyReport(state, "EndUseEnergyConsumptionPropaneMonthly", 2, true);
    2306           24 :         AddMonthlyFieldSetInput(state, curReport, "ExteriorEquipment:Propane", "", AggType::SumOrAvg);
    2307           24 :         AddMonthlyFieldSetInput(state, curReport, "Cooling:Propane", "", AggType::SumOrAvg);
    2308           24 :         AddMonthlyFieldSetInput(state, curReport, "Heating:Propane", "", AggType::SumOrAvg);
    2309           24 :         AddMonthlyFieldSetInput(state, curReport, "WaterSystems:Propane", "", AggType::SumOrAvg);
    2310           24 :         AddMonthlyFieldSetInput(state, curReport, "Cogeneration:Propane", "", AggType::SumOrAvg);
    2311           24 :         AddMonthlyFieldSetInput(state, curReport, "Humidifier:Propane", "", AggType::SumOrAvg);
    2312              :     }
    2313           47 :     if (ort->namedMonthly(19).show) {
    2314           12 :         curReport = AddMonthlyReport(state, "EndUseEnergyConsumptionGasolineMonthly", 2, true);
    2315           24 :         AddMonthlyFieldSetInput(state, curReport, "ExteriorEquipment:Gasoline", "", AggType::SumOrAvg);
    2316           24 :         AddMonthlyFieldSetInput(state, curReport, "Cooling:Gasoline", "", AggType::SumOrAvg);
    2317           24 :         AddMonthlyFieldSetInput(state, curReport, "Heating:Gasoline", "", AggType::SumOrAvg);
    2318           24 :         AddMonthlyFieldSetInput(state, curReport, "WaterSystems:Gasoline", "", AggType::SumOrAvg);
    2319           24 :         AddMonthlyFieldSetInput(state, curReport, "Cogeneration:Gasoline", "", AggType::SumOrAvg);
    2320              :     }
    2321           47 :     if (ort->namedMonthly(20).show) {
    2322           12 :         curReport = AddMonthlyReport(state, "EndUseEnergyConsumptionOtherFuelsMonthly", 2, true);
    2323           24 :         AddMonthlyFieldSetInput(state, curReport, "ExteriorEquipment:OtherFuel1", "", AggType::SumOrAvg);
    2324           24 :         AddMonthlyFieldSetInput(state, curReport, "Cooling:OtherFuel1", "", AggType::SumOrAvg);
    2325           24 :         AddMonthlyFieldSetInput(state, curReport, "Heating:OtherFuel1", "", AggType::SumOrAvg);
    2326           24 :         AddMonthlyFieldSetInput(state, curReport, "WaterSystems:OtherFuel1", "", AggType::SumOrAvg);
    2327           24 :         AddMonthlyFieldSetInput(state, curReport, "Cogeneration:OtherFuel1", "", AggType::SumOrAvg);
    2328           24 :         AddMonthlyFieldSetInput(state, curReport, "ExteriorEquipment:OtherFuel2", "", AggType::SumOrAvg);
    2329           24 :         AddMonthlyFieldSetInput(state, curReport, "Cooling:OtherFuel2", "", AggType::SumOrAvg);
    2330           24 :         AddMonthlyFieldSetInput(state, curReport, "Heating:OtherFuel2", "", AggType::SumOrAvg);
    2331           24 :         AddMonthlyFieldSetInput(state, curReport, "WaterSystems:OtherFuel2", "", AggType::SumOrAvg);
    2332           24 :         AddMonthlyFieldSetInput(state, curReport, "Cogeneration:OtherFuel2", "", AggType::SumOrAvg);
    2333              :     }
    2334           47 :     if (ort->namedMonthly(21).show) {
    2335           12 :         curReport = AddMonthlyReport(state, "PeakEnergyEndUseElectricityPart1Monthly", 2, true);
    2336           24 :         AddMonthlyFieldSetInput(state, curReport, "InteriorLights:Electricity", "", AggType::Maximum);
    2337           24 :         AddMonthlyFieldSetInput(state, curReport, "ExteriorLights:Electricity", "", AggType::Maximum);
    2338           24 :         AddMonthlyFieldSetInput(state, curReport, "InteriorEquipment:Electricity", "", AggType::Maximum);
    2339           24 :         AddMonthlyFieldSetInput(state, curReport, "ExteriorEquipment:Electricity", "", AggType::Maximum);
    2340           24 :         AddMonthlyFieldSetInput(state, curReport, "Fans:Electricity", "", AggType::Maximum);
    2341           24 :         AddMonthlyFieldSetInput(state, curReport, "Pumps:Electricity", "", AggType::Maximum);
    2342           24 :         AddMonthlyFieldSetInput(state, curReport, "Heating:Electricity", "", AggType::Maximum);
    2343              :     }
    2344           47 :     if (ort->namedMonthly(22).show) {
    2345           12 :         curReport = AddMonthlyReport(state, "PeakEnergyEndUseElectricityPart2Monthly", 2, true);
    2346           24 :         AddMonthlyFieldSetInput(state, curReport, "Cooling:Electricity", "", AggType::Maximum);
    2347           24 :         AddMonthlyFieldSetInput(state, curReport, "HeatRejection:Electricity", "", AggType::Maximum);
    2348           24 :         AddMonthlyFieldSetInput(state, curReport, "Humidifier:Electricity", "", AggType::Maximum);
    2349           24 :         AddMonthlyFieldSetInput(state, curReport, "HeatRecovery:Electricity", "", AggType::Maximum);
    2350           24 :         AddMonthlyFieldSetInput(state, curReport, "WaterSystems:Electricity", "", AggType::Maximum);
    2351           24 :         AddMonthlyFieldSetInput(state, curReport, "Cogeneration:Electricity", "", AggType::Maximum);
    2352              :     }
    2353           47 :     if (ort->namedMonthly(23).show) {
    2354           12 :         curReport = AddMonthlyReport(state, "ElectricComponentsOfPeakDemandMonthly", 2, true);
    2355           24 :         AddMonthlyFieldSetInput(state, curReport, "Electricity:Facility", "", AggType::Maximum);
    2356           24 :         AddMonthlyFieldSetInput(state, curReport, "InteriorLights:Electricity", "", AggType::ValueWhenMaxMin);
    2357           24 :         AddMonthlyFieldSetInput(state, curReport, "InteriorEquipment:Electricity", "", AggType::ValueWhenMaxMin);
    2358           24 :         AddMonthlyFieldSetInput(state, curReport, "ExteriorLights:Electricity", "", AggType::ValueWhenMaxMin);
    2359           24 :         AddMonthlyFieldSetInput(state, curReport, "ExteriorEquipment:Electricity", "", AggType::ValueWhenMaxMin);
    2360           24 :         AddMonthlyFieldSetInput(state, curReport, "Fans:Electricity", "", AggType::ValueWhenMaxMin);
    2361           24 :         AddMonthlyFieldSetInput(state, curReport, "Pumps:Electricity", "", AggType::ValueWhenMaxMin);
    2362           24 :         AddMonthlyFieldSetInput(state, curReport, "Heating:Electricity", "", AggType::ValueWhenMaxMin);
    2363           24 :         AddMonthlyFieldSetInput(state, curReport, "Cooling:Electricity", "", AggType::ValueWhenMaxMin);
    2364           24 :         AddMonthlyFieldSetInput(state, curReport, "HeatRejection:Electricity", "", AggType::ValueWhenMaxMin);
    2365              :     }
    2366           47 :     if (ort->namedMonthly(24).show) {
    2367           12 :         curReport = AddMonthlyReport(state, "PeakEnergyEndUseNaturalGasMonthly", 2, true);
    2368           24 :         AddMonthlyFieldSetInput(state, curReport, "InteriorEquipment:NaturalGas", "", AggType::Maximum);
    2369           24 :         AddMonthlyFieldSetInput(state, curReport, "ExteriorEquipment:NaturalGas", "", AggType::Maximum);
    2370           24 :         AddMonthlyFieldSetInput(state, curReport, "Heating:NaturalGas", "", AggType::Maximum);
    2371           24 :         AddMonthlyFieldSetInput(state, curReport, "Cooling:NaturalGas", "", AggType::Maximum);
    2372           24 :         AddMonthlyFieldSetInput(state, curReport, "WaterSystems:NaturalGas", "", AggType::Maximum);
    2373           24 :         AddMonthlyFieldSetInput(state, curReport, "Cogeneration:NaturalGas", "", AggType::Maximum);
    2374              :     }
    2375           47 :     if (ort->namedMonthly(25).show) {
    2376           12 :         curReport = AddMonthlyReport(state, "PeakEnergyEndUseDieselMonthly", 2, true);
    2377           24 :         AddMonthlyFieldSetInput(state, curReport, "ExteriorEquipment:Diesel", "", AggType::Maximum);
    2378           24 :         AddMonthlyFieldSetInput(state, curReport, "Cooling:Diesel", "", AggType::Maximum);
    2379           24 :         AddMonthlyFieldSetInput(state, curReport, "Heating:Diesel", "", AggType::Maximum);
    2380           24 :         AddMonthlyFieldSetInput(state, curReport, "WaterSystems:Diesel", "", AggType::Maximum);
    2381           24 :         AddMonthlyFieldSetInput(state, curReport, "Cogeneration:Diesel", "", AggType::Maximum);
    2382              :     }
    2383           47 :     if (ort->namedMonthly(26).show) {
    2384           12 :         curReport = AddMonthlyReport(state, "PeakEnergyEndUseFuelOilMonthly", 2, true);
    2385           24 :         AddMonthlyFieldSetInput(state, curReport, "ExteriorEquipment:FuelOilNo1", "", AggType::Maximum);
    2386           24 :         AddMonthlyFieldSetInput(state, curReport, "Cooling:FuelOilNo1", "", AggType::Maximum);
    2387           24 :         AddMonthlyFieldSetInput(state, curReport, "Heating:FuelOilNo1", "", AggType::Maximum);
    2388           24 :         AddMonthlyFieldSetInput(state, curReport, "WaterSystems:FuelOilNo1", "", AggType::Maximum);
    2389           24 :         AddMonthlyFieldSetInput(state, curReport, "Cogeneration:FuelOilNo1", "", AggType::Maximum);
    2390           24 :         AddMonthlyFieldSetInput(state, curReport, "ExteriorEquipment:FuelOilNo2", "", AggType::Maximum);
    2391           24 :         AddMonthlyFieldSetInput(state, curReport, "Cooling:FuelOilNo2", "", AggType::Maximum);
    2392           24 :         AddMonthlyFieldSetInput(state, curReport, "Heating:FuelOilNo2", "", AggType::Maximum);
    2393           24 :         AddMonthlyFieldSetInput(state, curReport, "WaterSystems:FuelOilNo2", "", AggType::Maximum);
    2394           24 :         AddMonthlyFieldSetInput(state, curReport, "Cogeneration:FuelOilNo2", "", AggType::Maximum);
    2395              :     }
    2396           47 :     if (ort->namedMonthly(27).show) {
    2397           12 :         curReport = AddMonthlyReport(state, "PeakEnergyEndUseCoalMonthly", 2, true);
    2398           24 :         AddMonthlyFieldSetInput(state, curReport, "ExteriorEquipment:Coal", "", AggType::Maximum);
    2399           24 :         AddMonthlyFieldSetInput(state, curReport, "Heating:Coal", "", AggType::Maximum);
    2400           24 :         AddMonthlyFieldSetInput(state, curReport, "WaterSystems:Coal", "", AggType::Maximum);
    2401              :     }
    2402           47 :     if (ort->namedMonthly(28).show) {
    2403           12 :         curReport = AddMonthlyReport(state, "PeakEnergyEndUsePropaneMonthly", 2, true);
    2404           24 :         AddMonthlyFieldSetInput(state, curReport, "ExteriorEquipment:Propane", "", AggType::Maximum);
    2405           24 :         AddMonthlyFieldSetInput(state, curReport, "Cooling:Propane", "", AggType::Maximum);
    2406           24 :         AddMonthlyFieldSetInput(state, curReport, "Heating:Propane", "", AggType::Maximum);
    2407           24 :         AddMonthlyFieldSetInput(state, curReport, "WaterSystems:Propane", "", AggType::Maximum);
    2408           24 :         AddMonthlyFieldSetInput(state, curReport, "Cogeneration:Propane", "", AggType::Maximum);
    2409              :     }
    2410           47 :     if (ort->namedMonthly(29).show) {
    2411           12 :         curReport = AddMonthlyReport(state, "PeakEnergyEndUseGasolineMonthly", 2, true);
    2412           24 :         AddMonthlyFieldSetInput(state, curReport, "ExteriorEquipment:Gasoline", "", AggType::Maximum);
    2413           24 :         AddMonthlyFieldSetInput(state, curReport, "Cooling:Gasoline", "", AggType::Maximum);
    2414           24 :         AddMonthlyFieldSetInput(state, curReport, "Heating:Gasoline", "", AggType::Maximum);
    2415           24 :         AddMonthlyFieldSetInput(state, curReport, "WaterSystems:Gasoline", "", AggType::Maximum);
    2416           24 :         AddMonthlyFieldSetInput(state, curReport, "Cogeneration:Gasoline", "", AggType::Maximum);
    2417              :     }
    2418           47 :     if (ort->namedMonthly(30).show) {
    2419           12 :         curReport = AddMonthlyReport(state, "PeakEnergyEndUseOtherFuelsMonthly", 2, true);
    2420           24 :         AddMonthlyFieldSetInput(state, curReport, "ExteriorEquipment:OtherFuel1", "", AggType::Maximum);
    2421           24 :         AddMonthlyFieldSetInput(state, curReport, "Cooling:OtherFuel1", "", AggType::Maximum);
    2422           24 :         AddMonthlyFieldSetInput(state, curReport, "Heating:OtherFuel1", "", AggType::Maximum);
    2423           24 :         AddMonthlyFieldSetInput(state, curReport, "WaterSystems:OtherFuel1", "", AggType::Maximum);
    2424           24 :         AddMonthlyFieldSetInput(state, curReport, "Cogeneration:OtherFuel1", "", AggType::Maximum);
    2425           24 :         AddMonthlyFieldSetInput(state, curReport, "ExteriorEquipment:OtherFuel2", "", AggType::Maximum);
    2426           24 :         AddMonthlyFieldSetInput(state, curReport, "Cooling:OtherFuel2", "", AggType::Maximum);
    2427           24 :         AddMonthlyFieldSetInput(state, curReport, "Heating:OtherFuel2", "", AggType::Maximum);
    2428           24 :         AddMonthlyFieldSetInput(state, curReport, "WaterSystems:OtherFuel2", "", AggType::Maximum);
    2429           24 :         AddMonthlyFieldSetInput(state, curReport, "Cogeneration:OtherFuel2", "", AggType::Maximum);
    2430              :     }
    2431           47 :     if (ort->namedMonthly(31).show) {
    2432           14 :         curReport = AddMonthlyReport(state, "SetpointsNotMetWithTemperaturesMonthly", 2, true);
    2433           28 :         AddMonthlyFieldSetInput(state, curReport, "Zone Heating Setpoint Not Met Time", "", AggType::HoursNonZero);
    2434           28 :         AddMonthlyFieldSetInput(state, curReport, "Zone Mean Air Temperature", "", AggType::SumOrAverageHoursShown);
    2435           28 :         AddMonthlyFieldSetInput(state, curReport, "Zone Heating Setpoint Not Met While Occupied Time", "", AggType::HoursNonZero);
    2436           28 :         AddMonthlyFieldSetInput(state, curReport, "Zone Mean Air Temperature", "", AggType::SumOrAverageHoursShown);
    2437           28 :         AddMonthlyFieldSetInput(state, curReport, "Zone Cooling Setpoint Not Met Time", "", AggType::HoursNonZero);
    2438           28 :         AddMonthlyFieldSetInput(state, curReport, "Zone Mean Air Temperature", "", AggType::SumOrAverageHoursShown);
    2439           28 :         AddMonthlyFieldSetInput(state, curReport, "Zone Cooling Setpoint Not Met While Occupied Time", "", AggType::HoursNonZero);
    2440           28 :         AddMonthlyFieldSetInput(state, curReport, "Zone Mean Air Temperature", "", AggType::SumOrAverageHoursShown);
    2441              :     }
    2442           47 :     if (ort->namedMonthly(32).show) {
    2443           12 :         curReport = AddMonthlyReport(state, "ComfortReportSimple55Monthly", 2, true);
    2444           24 :         AddMonthlyFieldSetInput(
    2445              :             state, curReport, "Zone Thermal Comfort ASHRAE 55 Simple Model Summer Clothes Not Comfortable Time", "", AggType::HoursNonZero);
    2446           24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Mean Air Temperature", "", AggType::SumOrAverageHoursShown);
    2447           24 :         AddMonthlyFieldSetInput(
    2448              :             state, curReport, "Zone Thermal Comfort ASHRAE 55 Simple Model Winter Clothes Not Comfortable Time", "", AggType::HoursNonZero);
    2449           24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Mean Air Temperature", "", AggType::SumOrAverageHoursShown);
    2450           24 :         AddMonthlyFieldSetInput(
    2451              :             state, curReport, "Zone Thermal Comfort ASHRAE 55 Simple Model Summer or Winter Clothes Not Comfortable Time", "", AggType::HoursNonZero);
    2452           24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Mean Air Temperature", "", AggType::SumOrAverageHoursShown);
    2453              :     }
    2454           47 :     if (ort->namedMonthly(33).show) {
    2455           12 :         curReport = AddMonthlyReport(state, "UnglazedTranspiredSolarCollectorSummaryMonthly", 5, true);
    2456           24 :         AddMonthlyFieldSetInput(state, curReport, "Solar Collector System Efficiency", "", AggType::HoursNonZero);
    2457           24 :         AddMonthlyFieldSetInput(state, curReport, "Solar Collector System Efficiency", "", AggType::SumOrAverageHoursShown);
    2458           24 :         AddMonthlyFieldSetInput(state, curReport, "Solar Collector Outside Face Suction Velocity", "", AggType::SumOrAverageHoursShown);
    2459           24 :         AddMonthlyFieldSetInput(state, curReport, "Solar Collector Sensible Heating Rate", "", AggType::SumOrAverageHoursShown);
    2460              :     }
    2461           47 :     if (ort->namedMonthly(34).show) {
    2462           12 :         curReport = AddMonthlyReport(state, "OccupantComfortDataSummaryMonthly", 5, true);
    2463           24 :         AddMonthlyFieldSetInput(state, curReport, "People Occupant Count", "", AggType::HoursNonZero);
    2464           24 :         AddMonthlyFieldSetInput(state, curReport, "People Air Temperature", "", AggType::SumOrAverageHoursShown);
    2465           24 :         AddMonthlyFieldSetInput(state, curReport, "People Air Relative Humidity", "", AggType::SumOrAverageHoursShown);
    2466           24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Thermal Comfort Fanger Model PMV", "", AggType::SumOrAverageHoursShown);
    2467           24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Thermal Comfort Fanger Model PPD", "", AggType::SumOrAverageHoursShown);
    2468              :     }
    2469           47 :     if (ort->namedMonthly(35).show) {
    2470           12 :         curReport = AddMonthlyReport(state, "ChillerReportMonthly", 2, true);
    2471           24 :         AddMonthlyFieldSetInput(state, curReport, "Chiller Electricity Energy", "", AggType::SumOrAvg);
    2472           24 :         AddMonthlyFieldSetInput(state, curReport, "Chiller Electricity Rate", "", AggType::Maximum);
    2473           24 :         AddMonthlyFieldSetInput(state, curReport, "Chiller Electricity Energy", "", AggType::HoursNonZero);
    2474           24 :         AddMonthlyFieldSetInput(state, curReport, "Chiller Evaporator Cooling Energy", "", AggType::SumOrAvg);
    2475           24 :         AddMonthlyFieldSetInput(state, curReport, "Chiller Evaporator Cooling Rate", "", AggType::Maximum);
    2476           24 :         AddMonthlyFieldSetInput(state, curReport, "Chiller Condenser Heat Transfer Energy", "", AggType::SumOrAvg);
    2477           24 :         AddMonthlyFieldSetInput(state, curReport, "Chiller COP", "", AggType::SumOrAvg);
    2478           24 :         AddMonthlyFieldSetInput(state, curReport, "Chiller COP", "", AggType::Maximum);
    2479           24 :         AddMonthlyFieldSetInput(state, curReport, "Chiller Part Load Ratio", "", AggType::SumOrAvg);
    2480           24 :         AddMonthlyFieldSetInput(state, curReport, "Chiller Part Load Ratio", "", AggType::Maximum);
    2481              :     }
    2482           47 :     if (ort->namedMonthly(36).show) {
    2483           12 :         curReport = AddMonthlyReport(state, "TowerReportMonthly", 2, true);
    2484           24 :         AddMonthlyFieldSetInput(state, curReport, "Cooling Tower Fan Electricity Energy", "", AggType::SumOrAvg);
    2485           24 :         AddMonthlyFieldSetInput(state, curReport, "Cooling Tower Fan Electricity Energy", "", AggType::HoursNonZero);
    2486           24 :         AddMonthlyFieldSetInput(state, curReport, "Cooling Tower Fan Electricity Rate", "", AggType::Maximum);
    2487           24 :         AddMonthlyFieldSetInput(state, curReport, "Cooling Tower Heat Transfer Rate", "", AggType::Maximum);
    2488           24 :         AddMonthlyFieldSetInput(state, curReport, "Cooling Tower Inlet Temperature", "", AggType::SumOrAvg);
    2489           24 :         AddMonthlyFieldSetInput(state, curReport, "Cooling Tower Outlet Temperature", "", AggType::SumOrAvg);
    2490           24 :         AddMonthlyFieldSetInput(state, curReport, "Cooling Tower Mass Flow Rate", "", AggType::SumOrAvg);
    2491              :     }
    2492           47 :     if (ort->namedMonthly(37).show) {
    2493           12 :         curReport = AddMonthlyReport(state, "BoilerReportMonthly", 2, true);
    2494           24 :         AddMonthlyFieldSetInput(state, curReport, "Boiler Heating Energy", "", AggType::SumOrAvg);
    2495           24 :         AddMonthlyFieldSetInput(state, curReport, "Boiler Gas Consumption", "", AggType::SumOrAvg);
    2496           24 :         AddMonthlyFieldSetInput(state, curReport, "Boiler Heating Energy", "", AggType::HoursNonZero);
    2497           24 :         AddMonthlyFieldSetInput(state, curReport, "Boiler Heating Rate", "", AggType::Maximum);
    2498           24 :         AddMonthlyFieldSetInput(state, curReport, "Boiler Gas Consumption Rate", "", AggType::Maximum);
    2499           24 :         AddMonthlyFieldSetInput(state, curReport, "Boiler Inlet Temperature", "", AggType::SumOrAvg);
    2500           24 :         AddMonthlyFieldSetInput(state, curReport, "Boiler Outlet Temperature", "", AggType::SumOrAvg);
    2501           24 :         AddMonthlyFieldSetInput(state, curReport, "Boiler Mass Flow Rate", "", AggType::SumOrAvg);
    2502           24 :         AddMonthlyFieldSetInput(state, curReport, "Boiler Ancillary Electricity Rate", "", AggType::SumOrAvg);
    2503           24 :         AddMonthlyFieldSetInput(state, curReport, "Boiler Part Load Ratio", "", AggType::SumOrAvg);
    2504           24 :         AddMonthlyFieldSetInput(state, curReport, "Boiler Part Load Ratio", "", AggType::Maximum);
    2505              :     }
    2506           47 :     if (ort->namedMonthly(38).show) {
    2507           12 :         curReport = AddMonthlyReport(state, "DXReportMonthly", 2, true);
    2508           24 :         AddMonthlyFieldSetInput(state, curReport, "Cooling Coil Total Cooling Energy", "", AggType::SumOrAvg);
    2509           24 :         AddMonthlyFieldSetInput(state, curReport, "Cooling Coil Electricity Energy", "", AggType::SumOrAvg);
    2510           24 :         AddMonthlyFieldSetInput(state, curReport, "Cooling Coil Total Cooling Energy", "", AggType::HoursNonZero);
    2511           24 :         AddMonthlyFieldSetInput(state, curReport, "Cooling Coil Sensible Cooling Energy", "", AggType::SumOrAvg);
    2512           24 :         AddMonthlyFieldSetInput(state, curReport, "Cooling Coil Latent Cooling Energy", "", AggType::SumOrAvg);
    2513           24 :         AddMonthlyFieldSetInput(state, curReport, "Cooling Coil Crankcase Heater Electricity Energy", "", AggType::SumOrAvg);
    2514           24 :         AddMonthlyFieldSetInput(state, curReport, "Cooling Coil Runtime Fraction", "", AggType::Maximum);
    2515           24 :         AddMonthlyFieldSetInput(state, curReport, "Cooling Coil Runtime Fraction", "", AggType::Minimum);
    2516           24 :         AddMonthlyFieldSetInput(state, curReport, "Cooling Coil Total Cooling Rate", "", AggType::Maximum);
    2517           24 :         AddMonthlyFieldSetInput(state, curReport, "Cooling Coil Sensible Cooling Rate", "", AggType::Maximum);
    2518           24 :         AddMonthlyFieldSetInput(state, curReport, "Cooling Coil Latent Cooling Rate", "", AggType::Maximum);
    2519           24 :         AddMonthlyFieldSetInput(state, curReport, "Cooling Coil Electricity Rate", "", AggType::Maximum);
    2520           24 :         AddMonthlyFieldSetInput(state, curReport, "Cooling Coil Crankcase Heater Electricity Rate", "", AggType::Maximum);
    2521              :     }
    2522           47 :     if (ort->namedMonthly(39).show) {
    2523           12 :         curReport = AddMonthlyReport(state, "WindowReportMonthly", 2, true);
    2524           24 :         AddMonthlyFieldSetInput(state, curReport, "Surface Window Transmitted Solar Radiation Rate", "", AggType::SumOrAvg);
    2525           24 :         AddMonthlyFieldSetInput(state, curReport, "Surface Window Transmitted Beam Solar Radiation Rate", "", AggType::SumOrAvg);
    2526           24 :         AddMonthlyFieldSetInput(state, curReport, "Surface Window Transmitted Diffuse Solar Radiation Rate", "", AggType::SumOrAvg);
    2527           24 :         AddMonthlyFieldSetInput(state, curReport, "Surface Window Heat Gain Rate", "", AggType::SumOrAvg);
    2528           24 :         AddMonthlyFieldSetInput(state, curReport, "Surface Window Heat Loss Rate", "", AggType::SumOrAvg);
    2529           24 :         AddMonthlyFieldSetInput(state, curReport, "Surface Window Inside Face Glazing Condensation Status", "", AggType::HoursNonZero);
    2530           24 :         AddMonthlyFieldSetInput(state, curReport, "Surface Shading Device Is On Time Fraction", "", AggType::HoursNonZero);
    2531           24 :         AddMonthlyFieldSetInput(state, curReport, "Surface Storm Window On Off Status", "", AggType::HoursNonZero);
    2532              :     }
    2533           47 :     if (ort->namedMonthly(40).show) {
    2534           12 :         curReport = AddMonthlyReport(state, "WindowEnergyReportMonthly", 2, true);
    2535           24 :         AddMonthlyFieldSetInput(state, curReport, "Surface Window Transmitted Solar Radiation Energy", "", AggType::SumOrAvg);
    2536           24 :         AddMonthlyFieldSetInput(state, curReport, "Surface Window Transmitted Beam Solar Radiation Energy", "", AggType::SumOrAvg);
    2537           24 :         AddMonthlyFieldSetInput(state, curReport, "Surface Window Transmitted Diffuse Solar Radiation Energy", "", AggType::SumOrAvg);
    2538           24 :         AddMonthlyFieldSetInput(state, curReport, "Surface Window Heat Gain Energy", "", AggType::SumOrAvg);
    2539           24 :         AddMonthlyFieldSetInput(state, curReport, "Surface Window Heat Loss Energy", "", AggType::SumOrAvg);
    2540              :     }
    2541           47 :     if (ort->namedMonthly(41).show) {
    2542           12 :         curReport = AddMonthlyReport(state, "WindowZoneSummaryMonthly", 2, true);
    2543           24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Windows Total Heat Gain Rate", "", AggType::SumOrAvg);
    2544           24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Windows Total Heat Loss Rate", "", AggType::SumOrAvg);
    2545           24 :         AddMonthlyFieldSetInput(state, curReport, "Enclosure Windows Total Transmitted Solar Radiation Rate", "", AggType::SumOrAvg);
    2546           24 :         AddMonthlyFieldSetInput(state, curReport, "Enclosure Exterior Windows Total Transmitted Beam Solar Radiation Rate", "", AggType::SumOrAvg);
    2547           24 :         AddMonthlyFieldSetInput(state, curReport, "Enclosure Exterior Windows Total Transmitted Diffuse Solar Radiation Rate", "", AggType::SumOrAvg);
    2548           24 :         AddMonthlyFieldSetInput(state, curReport, "Enclosure Interior Windows Total Transmitted Diffuse Solar Radiation Rate", "", AggType::SumOrAvg);
    2549           24 :         AddMonthlyFieldSetInput(state, curReport, "Enclosure Interior Windows Total Transmitted Beam Solar Radiation Rate", "", AggType::SumOrAvg);
    2550              :     }
    2551           47 :     if (ort->namedMonthly(42).show) {
    2552           12 :         curReport = AddMonthlyReport(state, "WindowEnergyZoneSummaryMonthly", 2, true);
    2553           24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Windows Total Heat Gain Energy", "", AggType::SumOrAvg);
    2554           24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Windows Total Heat Loss Energy", "", AggType::SumOrAvg);
    2555           24 :         AddMonthlyFieldSetInput(state, curReport, "Enclosure Windows Total Transmitted Solar Radiation Energy", "", AggType::SumOrAvg);
    2556           24 :         AddMonthlyFieldSetInput(state, curReport, "Enclosure Exterior Windows Total Transmitted Beam Solar Radiation Energy", "", AggType::SumOrAvg);
    2557           24 :         AddMonthlyFieldSetInput(
    2558              :             state, curReport, "Enclosure Exterior Windows Total Transmitted Diffuse Solar Radiation Energy", "", AggType::SumOrAvg);
    2559           24 :         AddMonthlyFieldSetInput(
    2560              :             state, curReport, "Enclosure Interior Windows Total Transmitted Diffuse Solar Radiation Energy", "", AggType::SumOrAvg);
    2561           24 :         AddMonthlyFieldSetInput(state, curReport, "Enclosure Interior Windows Total Transmitted Beam Solar Radiation Energy", "", AggType::SumOrAvg);
    2562              :     }
    2563           47 :     if (ort->namedMonthly(43).show) {
    2564           12 :         curReport = AddMonthlyReport(state, "AverageOutdoorConditionsMonthly", 2, true);
    2565           24 :         AddMonthlyFieldSetInput(state, curReport, "Site Outdoor Air Drybulb Temperature", "", AggType::SumOrAvg);
    2566           24 :         AddMonthlyFieldSetInput(state, curReport, "Site Outdoor Air Wetbulb Temperature", "", AggType::SumOrAvg);
    2567           24 :         AddMonthlyFieldSetInput(state, curReport, "Site Outdoor Air Dewpoint Temperature", "", AggType::SumOrAvg);
    2568           24 :         AddMonthlyFieldSetInput(state, curReport, "Site Wind Speed", "", AggType::SumOrAvg);
    2569           24 :         AddMonthlyFieldSetInput(state, curReport, "Site Sky Temperature", "", AggType::SumOrAvg);
    2570           24 :         AddMonthlyFieldSetInput(state, curReport, "Site Diffuse Solar Radiation Rate per Area", "", AggType::SumOrAvg);
    2571           24 :         AddMonthlyFieldSetInput(state, curReport, "Site Direct Solar Radiation Rate per Area", "", AggType::SumOrAvg);
    2572           24 :         AddMonthlyFieldSetInput(state, curReport, "Site Rain Status", "", AggType::SumOrAvg);
    2573              :     }
    2574           47 :     if (ort->namedMonthly(44).show) {
    2575           12 :         curReport = AddMonthlyReport(state, "OutdoorConditionsMaximumDryBulbMonthly", 2, true);
    2576           24 :         AddMonthlyFieldSetInput(state, curReport, "Site Outdoor Air Drybulb Temperature", "", AggType::Maximum);
    2577           24 :         AddMonthlyFieldSetInput(state, curReport, "Site Outdoor Air Wetbulb Temperature", "", AggType::ValueWhenMaxMin);
    2578           24 :         AddMonthlyFieldSetInput(state, curReport, "Site Outdoor Air Dewpoint Temperature", "", AggType::ValueWhenMaxMin);
    2579           24 :         AddMonthlyFieldSetInput(state, curReport, "Site Wind Speed", "", AggType::ValueWhenMaxMin);
    2580           24 :         AddMonthlyFieldSetInput(state, curReport, "Site Sky Temperature", "", AggType::ValueWhenMaxMin);
    2581           24 :         AddMonthlyFieldSetInput(state, curReport, "Site Diffuse Solar Radiation Rate per Area", "", AggType::ValueWhenMaxMin);
    2582           24 :         AddMonthlyFieldSetInput(state, curReport, "Site Direct Solar Radiation Rate per Area", "", AggType::ValueWhenMaxMin);
    2583              :     }
    2584           47 :     if (ort->namedMonthly(45).show) {
    2585           12 :         curReport = AddMonthlyReport(state, "OutdoorConditionsMinimumDryBulbMonthly", 2, true);
    2586           24 :         AddMonthlyFieldSetInput(state, curReport, "Site Outdoor Air Drybulb Temperature", "", AggType::Minimum);
    2587           24 :         AddMonthlyFieldSetInput(state, curReport, "Site Outdoor Air Wetbulb Temperature", "", AggType::ValueWhenMaxMin);
    2588           24 :         AddMonthlyFieldSetInput(state, curReport, "Site Outdoor Air Dewpoint Temperature", "", AggType::ValueWhenMaxMin);
    2589           24 :         AddMonthlyFieldSetInput(state, curReport, "Site Wind Speed", "", AggType::ValueWhenMaxMin);
    2590           24 :         AddMonthlyFieldSetInput(state, curReport, "Site Sky Temperature", "", AggType::ValueWhenMaxMin);
    2591           24 :         AddMonthlyFieldSetInput(state, curReport, "Site Diffuse Solar Radiation Rate per Area", "", AggType::ValueWhenMaxMin);
    2592           24 :         AddMonthlyFieldSetInput(state, curReport, "Site Direct Solar Radiation Rate per Area", "", AggType::ValueWhenMaxMin);
    2593              :     }
    2594           47 :     if (ort->namedMonthly(46).show) {
    2595           12 :         curReport = AddMonthlyReport(state, "OutdoorConditionsMaximumWetBulbMonthly", 2, true);
    2596           24 :         AddMonthlyFieldSetInput(state, curReport, "Site Outdoor Air Wetbulb Temperature", "", AggType::Maximum);
    2597           24 :         AddMonthlyFieldSetInput(state, curReport, "Site Outdoor Air Drybulb Temperature", "", AggType::ValueWhenMaxMin);
    2598           24 :         AddMonthlyFieldSetInput(state, curReport, "Site Outdoor Air Dewpoint Temperature", "", AggType::ValueWhenMaxMin);
    2599           24 :         AddMonthlyFieldSetInput(state, curReport, "Site Wind Speed", "", AggType::ValueWhenMaxMin);
    2600           24 :         AddMonthlyFieldSetInput(state, curReport, "Site Sky Temperature", "", AggType::ValueWhenMaxMin);
    2601           24 :         AddMonthlyFieldSetInput(state, curReport, "Site Diffuse Solar Radiation Rate per Area", "", AggType::ValueWhenMaxMin);
    2602           24 :         AddMonthlyFieldSetInput(state, curReport, "Site Direct Solar Radiation Rate per Area", "", AggType::ValueWhenMaxMin);
    2603              :     }
    2604           47 :     if (ort->namedMonthly(47).show) {
    2605           12 :         curReport = AddMonthlyReport(state, "OutdoorConditionsMaximumDewPointMonthly", 2, true);
    2606           24 :         AddMonthlyFieldSetInput(state, curReport, "Site Outdoor Air Dewpoint Temperature", "", AggType::Maximum);
    2607           24 :         AddMonthlyFieldSetInput(state, curReport, "Site Outdoor Air Drybulb Temperature", "", AggType::ValueWhenMaxMin);
    2608           24 :         AddMonthlyFieldSetInput(state, curReport, "Site Outdoor Air Wetbulb Temperature", "", AggType::ValueWhenMaxMin);
    2609           24 :         AddMonthlyFieldSetInput(state, curReport, "Site Wind Speed", "", AggType::ValueWhenMaxMin);
    2610           24 :         AddMonthlyFieldSetInput(state, curReport, "Site Sky Temperature", "", AggType::ValueWhenMaxMin);
    2611           24 :         AddMonthlyFieldSetInput(state, curReport, "Site Diffuse Solar Radiation Rate per Area", "", AggType::ValueWhenMaxMin);
    2612           24 :         AddMonthlyFieldSetInput(state, curReport, "Site Direct Solar Radiation Rate per Area", "", AggType::ValueWhenMaxMin);
    2613              :     }
    2614           47 :     if (ort->namedMonthly(48).show) {
    2615           12 :         curReport = AddMonthlyReport(state, "OutdoorGroundConditionsMonthly", 2, true);
    2616           24 :         AddMonthlyFieldSetInput(state, curReport, "Site Ground Temperature", "", AggType::SumOrAvg);
    2617           24 :         AddMonthlyFieldSetInput(state, curReport, "Site Surface Ground Temperature", "", AggType::SumOrAvg);
    2618           24 :         AddMonthlyFieldSetInput(state, curReport, "Site Deep Ground Temperature", "", AggType::SumOrAvg);
    2619           24 :         AddMonthlyFieldSetInput(state, curReport, "Site Mains Water Temperature", "", AggType::SumOrAvg);
    2620           24 :         AddMonthlyFieldSetInput(state, curReport, "Site Ground Reflected Solar Radiation Rate per Area", "", AggType::SumOrAvg);
    2621           24 :         AddMonthlyFieldSetInput(state, curReport, "Site Snow on Ground Status", "", AggType::SumOrAvg);
    2622              :     }
    2623           47 :     if (ort->namedMonthly(49).show) {
    2624           12 :         curReport = AddMonthlyReport(state, "WindowACReportMonthly", 2, true);
    2625           24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Window Air Conditioner Total Cooling Energy", "", AggType::SumOrAvg);
    2626           24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Window Air Conditioner Electricity Energy", "", AggType::SumOrAvg);
    2627           24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Window Air Conditioner Total Cooling Energy", "", AggType::HoursNonZero);
    2628           24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Window Air Conditioner Sensible Cooling Energy", "", AggType::SumOrAvg);
    2629           24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Window Air Conditioner Latent Cooling Energy", "", AggType::SumOrAvg);
    2630           24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Window Air Conditioner Total Cooling Rate", "", AggType::Maximum);
    2631           24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Window Air Conditioner Sensible Cooling Rate", "", AggType::ValueWhenMaxMin);
    2632           24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Window Air Conditioner Latent Cooling Rate", "", AggType::ValueWhenMaxMin);
    2633           24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Window Air Conditioner Electricity Rate", "", AggType::ValueWhenMaxMin);
    2634              :     }
    2635           47 :     if (ort->namedMonthly(50).show) {
    2636           12 :         curReport = AddMonthlyReport(state, "WaterHeaterReportMonthly", 2, true);
    2637           24 :         AddMonthlyFieldSetInput(state, curReport, "Water Heater Total Demand Heat Transfer Energy", "", AggType::SumOrAvg);
    2638           24 :         AddMonthlyFieldSetInput(state, curReport, "Water Heater Use Side Heat Transfer Energy", "", AggType::SumOrAvg);
    2639           24 :         AddMonthlyFieldSetInput(state, curReport, "Water Heater Burner Heating Energy", "", AggType::SumOrAvg);
    2640           24 :         AddMonthlyFieldSetInput(state, curReport, "Water Heater Gas Consumption", "", AggType::SumOrAvg);
    2641           24 :         AddMonthlyFieldSetInput(state, curReport, "Water Heater Total Demand Heat Transfer Energy", "", AggType::HoursNonZero);
    2642           24 :         AddMonthlyFieldSetInput(state, curReport, "Water Heater Loss Demand Energy", "", AggType::SumOrAvg);
    2643           24 :         AddMonthlyFieldSetInput(state, curReport, "Water Heater Heat Loss Energy", "", AggType::SumOrAvg);
    2644           24 :         AddMonthlyFieldSetInput(state, curReport, "Water Heater Tank Temperature", "", AggType::SumOrAvg);
    2645           24 :         AddMonthlyFieldSetInput(state, curReport, "Water Heater Heat Recovery Supply Energy", "", AggType::SumOrAvg);
    2646           24 :         AddMonthlyFieldSetInput(state, curReport, "Water Heater Source Side Heat Transfer Energy", "", AggType::SumOrAvg);
    2647              :     }
    2648           47 :     if (ort->namedMonthly(51).show) {
    2649           12 :         curReport = AddMonthlyReport(state, "GeneratorReportMonthly", 2, true);
    2650           24 :         AddMonthlyFieldSetInput(state, curReport, "Generator Produced AC Electricity Energy", "", AggType::SumOrAvg);
    2651           24 :         AddMonthlyFieldSetInput(state, curReport, "Generator Diesel Consumption", "", AggType::SumOrAvg);
    2652           24 :         AddMonthlyFieldSetInput(state, curReport, "Generator Gas Consumption", "", AggType::SumOrAvg);
    2653           24 :         AddMonthlyFieldSetInput(state, curReport, "Generator Produced AC Electricity Energy", "", AggType::HoursNonZero);
    2654           24 :         AddMonthlyFieldSetInput(state, curReport, "Generator Total Heat Recovery", "", AggType::SumOrAvg);
    2655           24 :         AddMonthlyFieldSetInput(state, curReport, "Generator Jacket Heat Recovery Energy", "", AggType::SumOrAvg);
    2656           24 :         AddMonthlyFieldSetInput(state, curReport, "Generator Lube Heat Recovery", "", AggType::SumOrAvg);
    2657           24 :         AddMonthlyFieldSetInput(state, curReport, "Generator Exhaust Heat Recovery Energy", "", AggType::SumOrAvg);
    2658           24 :         AddMonthlyFieldSetInput(state, curReport, "Generator Exhaust Air Temperature", "", AggType::SumOrAvg);
    2659              :     }
    2660           47 :     if (ort->namedMonthly(52).show) {
    2661           12 :         curReport = AddMonthlyReport(state, "DaylightingReportMonthly", 2, true);
    2662           24 :         AddMonthlyFieldSetInput(state, curReport, "Site Exterior Beam Normal Illuminance", "", AggType::HoursNonZero);
    2663           24 :         AddMonthlyFieldSetInput(state, curReport, "Daylighting Lighting Power Multiplier", "", AggType::SumOrAverageHoursShown);
    2664           24 :         AddMonthlyFieldSetInput(state, curReport, "Daylighting Lighting Power Multiplier", "", AggType::MinimumDuringHoursShown);
    2665           24 :         AddMonthlyFieldSetInput(state, curReport, "Daylighting Reference Point 1 Illuminance", "", AggType::SumOrAverageHoursShown);
    2666           24 :         AddMonthlyFieldSetInput(state, curReport, "Daylighting Reference Point 1 Glare Index", "", AggType::SumOrAverageHoursShown);
    2667           24 :         AddMonthlyFieldSetInput(state, curReport, "Daylighting Reference Point 1 Glare Index Setpoint Exceeded Time", "", AggType::SumOrAvg);
    2668           24 :         AddMonthlyFieldSetInput(state, curReport, "Daylighting Reference Point 1 Daylight Illuminance Setpoint Exceeded Time", "", AggType::SumOrAvg);
    2669           24 :         AddMonthlyFieldSetInput(state, curReport, "Daylighting Reference Point 2 Illuminance", "", AggType::SumOrAverageHoursShown);
    2670           24 :         AddMonthlyFieldSetInput(state, curReport, "Daylighting Reference Point 2 Glare Index", "", AggType::SumOrAverageHoursShown);
    2671           24 :         AddMonthlyFieldSetInput(state, curReport, "Daylighting Reference Point 2 Glare Index Setpoint Exceeded Time", "", AggType::SumOrAvg);
    2672           24 :         AddMonthlyFieldSetInput(state, curReport, "Daylighting Reference Point 2 Daylight Illuminance Setpoint Exceeded Time", "", AggType::SumOrAvg);
    2673              :     }
    2674           47 :     if (ort->namedMonthly(53).show) {
    2675           12 :         curReport = AddMonthlyReport(state, "CoilReportMonthly", 2, true);
    2676           24 :         AddMonthlyFieldSetInput(state, curReport, "Heating Coil Heating Energy", "", AggType::SumOrAvg);
    2677           24 :         AddMonthlyFieldSetInput(state, curReport, "Heating Coil Heating Rate", "", AggType::Maximum);
    2678           24 :         AddMonthlyFieldSetInput(state, curReport, "Cooling Coil Total Cooling Energy", "", AggType::SumOrAvg);
    2679           24 :         AddMonthlyFieldSetInput(state, curReport, "Cooling Coil Sensible Cooling Energy", "", AggType::SumOrAvg);
    2680           24 :         AddMonthlyFieldSetInput(state, curReport, "Cooling Coil Total Cooling Rate", "", AggType::Maximum);
    2681           24 :         AddMonthlyFieldSetInput(state, curReport, "Cooling Coil Sensible Cooling Rate", "", AggType::ValueWhenMaxMin);
    2682           24 :         AddMonthlyFieldSetInput(state, curReport, "Cooling Coil Wetted Area Fraction", "", AggType::SumOrAvg);
    2683              :     }
    2684           47 :     if (ort->namedMonthly(54).show) {
    2685           12 :         curReport = AddMonthlyReport(state, "PlantLoopDemandReportMonthly", 2, true);
    2686           24 :         AddMonthlyFieldSetInput(state, curReport, "Plant Supply Side Cooling Demand Rate", "", AggType::SumOrAvg);
    2687           24 :         AddMonthlyFieldSetInput(state, curReport, "Plant Supply Side Cooling Demand Rate", "", AggType::Maximum);
    2688           24 :         AddMonthlyFieldSetInput(state, curReport, "Plant Supply Side Heating Demand Rate", "", AggType::SumOrAvg);
    2689           24 :         AddMonthlyFieldSetInput(state, curReport, "Plant Supply Side Heating Demand Rate", "", AggType::Maximum);
    2690              :     }
    2691           47 :     if (ort->namedMonthly(55).show) {
    2692           12 :         curReport = AddMonthlyReport(state, "FanReportMonthly", 2, true);
    2693           24 :         AddMonthlyFieldSetInput(state, curReport, "Fan Electricity Energy", "", AggType::SumOrAvg);
    2694           24 :         AddMonthlyFieldSetInput(state, curReport, "Fan Rise in Air Temperature", "", AggType::SumOrAvg);
    2695           24 :         AddMonthlyFieldSetInput(state, curReport, "Fan Electricity Rate", "", AggType::Maximum);
    2696           24 :         AddMonthlyFieldSetInput(state, curReport, "Fan Rise in Air Temperature", "", AggType::ValueWhenMaxMin);
    2697              :     }
    2698           47 :     if (ort->namedMonthly(56).show) {
    2699           12 :         curReport = AddMonthlyReport(state, "PumpReportMonthly", 2, true);
    2700           24 :         AddMonthlyFieldSetInput(state, curReport, "Pump Electricity Energy", "", AggType::SumOrAvg);
    2701           24 :         AddMonthlyFieldSetInput(state, curReport, "Pump Fluid Heat Gain Energy", "", AggType::SumOrAvg);
    2702           24 :         AddMonthlyFieldSetInput(state, curReport, "Pump Electricity Rate", "", AggType::Maximum);
    2703           24 :         AddMonthlyFieldSetInput(state, curReport, "Pump Shaft Power", "", AggType::ValueWhenMaxMin);
    2704           24 :         AddMonthlyFieldSetInput(state, curReport, "Pump Fluid Heat Gain Rate", "", AggType::ValueWhenMaxMin);
    2705           24 :         AddMonthlyFieldSetInput(state, curReport, "Pump Outlet Temperature", "", AggType::ValueWhenMaxMin);
    2706           24 :         AddMonthlyFieldSetInput(state, curReport, "Pump Mass Flow Rate", "", AggType::ValueWhenMaxMin);
    2707              :     }
    2708           47 :     if (ort->namedMonthly(57).show) {
    2709           12 :         curReport = AddMonthlyReport(state, "CondLoopDemandReportMonthly", 2, true);
    2710           24 :         AddMonthlyFieldSetInput(state, curReport, "Plant Supply Side Cooling Demand Rate", "", AggType::SumOrAvg);
    2711           24 :         AddMonthlyFieldSetInput(state, curReport, "Plant Supply Side Cooling Demand Rate", "", AggType::Maximum);
    2712           24 :         AddMonthlyFieldSetInput(state, curReport, "Plant Supply Side Inlet Temperature", "", AggType::ValueWhenMaxMin);
    2713           24 :         AddMonthlyFieldSetInput(state, curReport, "Plant Supply Side Outlet Temperature", "", AggType::ValueWhenMaxMin);
    2714           24 :         AddMonthlyFieldSetInput(state, curReport, "Plant Supply Side Heating Demand Rate", "", AggType::SumOrAvg);
    2715           24 :         AddMonthlyFieldSetInput(state, curReport, "Plant Supply Side Heating Demand Rate", "", AggType::Maximum);
    2716              :     }
    2717           47 :     if (ort->namedMonthly(58).show) {
    2718           12 :         curReport = AddMonthlyReport(state, "ZoneTemperatureOscillationReportMonthly", 2, true);
    2719           24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Oscillating Temperatures Time", "", AggType::HoursNonZero);
    2720           24 :         AddMonthlyFieldSetInput(state, curReport, "Zone People Occupant Count", "", AggType::SumOrAverageHoursShown);
    2721              :     }
    2722           47 :     if (ort->namedMonthly(59).show) {
    2723           12 :         curReport = AddMonthlyReport(state, "AirLoopSystemEnergyAndWaterUseMonthly", 2, true);
    2724           24 :         AddMonthlyFieldSetInput(state, curReport, "Air System Hot Water Energy", "", AggType::SumOrAvg);
    2725           24 :         AddMonthlyFieldSetInput(state, curReport, "Air System Steam Energy", "", AggType::SumOrAvg);
    2726           24 :         AddMonthlyFieldSetInput(state, curReport, "Air System Chilled Water Energy", "", AggType::SumOrAvg);
    2727           24 :         AddMonthlyFieldSetInput(state, curReport, "Air System Electricity Energy", "", AggType::SumOrAvg);
    2728           24 :         AddMonthlyFieldSetInput(state, curReport, "Air System Natural Gas Energy", "", AggType::SumOrAvg);
    2729           24 :         AddMonthlyFieldSetInput(state, curReport, "Air System Water Volume", "", AggType::SumOrAvg);
    2730              :     }
    2731              : 
    2732           47 :     if (ort->namedMonthly(60).show) {
    2733           12 :         curReport = AddMonthlyReport(state, "AirLoopSystemComponentLoadsMonthly", 2, true);
    2734           24 :         AddMonthlyFieldSetInput(state, curReport, "Air System Fan Air Heating Energy", "", AggType::SumOrAvg);
    2735           24 :         AddMonthlyFieldSetInput(state, curReport, "Air System Cooling Coil Total Cooling Energy", "", AggType::SumOrAvg);
    2736           24 :         AddMonthlyFieldSetInput(state, curReport, "Air System Heating Coil Total Heating Energy", "", AggType::SumOrAvg);
    2737           24 :         AddMonthlyFieldSetInput(state, curReport, "Air System Heat Exchanger Total Heating Energy", "", AggType::SumOrAvg);
    2738           24 :         AddMonthlyFieldSetInput(state, curReport, "Air System Heat Exchanger Total Cooling Energy", "", AggType::SumOrAvg);
    2739           24 :         AddMonthlyFieldSetInput(state, curReport, "Air System Humidifier Total Heating Energy", "", AggType::SumOrAvg);
    2740           24 :         AddMonthlyFieldSetInput(state, curReport, "Air System Evaporative Cooler Total Cooling Energy", "", AggType::SumOrAvg);
    2741           24 :         AddMonthlyFieldSetInput(state, curReport, "Air System Desiccant Dehumidifier Total Cooling Energy", "", AggType::SumOrAvg);
    2742              :     }
    2743           47 :     if (ort->namedMonthly(61).show) {
    2744           12 :         curReport = AddMonthlyReport(state, "AirLoopSystemComponentEnergyUseMonthly", 2, true);
    2745           24 :         AddMonthlyFieldSetInput(state, curReport, "Air System Fan Electricity Energy", "", AggType::SumOrAvg);
    2746           24 :         AddMonthlyFieldSetInput(state, curReport, "Air System Heating Coil Hot Water Energy", "", AggType::SumOrAvg);
    2747           24 :         AddMonthlyFieldSetInput(state, curReport, "Air System Cooling Coil Chilled Water Energy", "", AggType::SumOrAvg);
    2748           24 :         AddMonthlyFieldSetInput(state, curReport, "Air System DX Heating Coil Electricity Energy", "", AggType::SumOrAvg);
    2749           24 :         AddMonthlyFieldSetInput(state, curReport, "Air System DX Cooling Coil Electricity Energy", "", AggType::SumOrAvg);
    2750           24 :         AddMonthlyFieldSetInput(state, curReport, "Air System Heating Coil Electricity Energy", "", AggType::SumOrAvg);
    2751           24 :         AddMonthlyFieldSetInput(state, curReport, "Air System Heating Coil Natural Gas Energy", "", AggType::SumOrAvg);
    2752           24 :         AddMonthlyFieldSetInput(state, curReport, "Air System Heating Coil Steam Energy", "", AggType::SumOrAvg);
    2753           24 :         AddMonthlyFieldSetInput(state, curReport, "Air System Humidifier Electricity Energy", "", AggType::SumOrAvg);
    2754           24 :         AddMonthlyFieldSetInput(state, curReport, "Air System Humidifier Natural Gas Energy", "", AggType::SumOrAvg);
    2755           24 :         AddMonthlyFieldSetInput(state, curReport, "Air System Evaporative Cooler Electricity Energy", "", AggType::SumOrAvg);
    2756           24 :         AddMonthlyFieldSetInput(state, curReport, "Air System Desiccant Dehumidifier Electricity Energy", "", AggType::SumOrAvg);
    2757              :     }
    2758           47 :     if (ort->namedMonthly(62).show) {
    2759           12 :         curReport = AddMonthlyReport(state, "MechanicalVentilationLoadsMonthly", 2, true);
    2760           24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Mechanical Ventilation No Load Heat Removal Energy", "", AggType::SumOrAvg);
    2761           24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Mechanical Ventilation Cooling Load Increase Energy", "", AggType::SumOrAvg);
    2762           24 :         AddMonthlyFieldSetInput(
    2763              :             state, curReport, "Zone Mechanical Ventilation Cooling Load Increase Due to Overheating Energy", "", AggType::SumOrAvg);
    2764           24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Mechanical Ventilation Cooling Load Decrease Energy", "", AggType::SumOrAvg);
    2765           24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Mechanical Ventilation No Load Heat Addition Energy", "", AggType::SumOrAvg);
    2766           24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Mechanical Ventilation Heating Load Increase Energy", "", AggType::SumOrAvg);
    2767           24 :         AddMonthlyFieldSetInput(
    2768              :             state, curReport, "Zone Mechanical Ventilation Heating Load Increase Due to Overcooling Energy", "", AggType::SumOrAvg);
    2769           24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Mechanical Ventilation Heating Load Decrease Energy", "", AggType::SumOrAvg);
    2770           24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Mechanical Ventilation Air Changes per Hour", "", AggType::SumOrAvg);
    2771              :     }
    2772           47 :     if (ort->namedMonthly(63).show) {
    2773           12 :         curReport = AddMonthlyReport(state, "HeatEmissionsReportMonthly", 2, true);
    2774              :         // Place holder
    2775           24 :         AddMonthlyFieldSetInput(state, curReport, "Site Total Surface Heat Emission to Air", "", AggType::SumOrAvg);
    2776           24 :         AddMonthlyFieldSetInput(state, curReport, "Site Total Zone Exfiltration Heat Loss", "", AggType::SumOrAvg);
    2777           24 :         AddMonthlyFieldSetInput(state, curReport, "Site Total Zone Exhaust Air Heat Loss", "", AggType::SumOrAvg);
    2778           24 :         AddMonthlyFieldSetInput(state, curReport, "Air System Relief Air Total Heat Loss Energy", "", AggType::SumOrAvg);
    2779           24 :         AddMonthlyFieldSetInput(state, curReport, "HVAC System Total Heat Rejection Energy", "", AggType::SumOrAvg);
    2780              :     }
    2781           47 : }
    2782              : 
    2783           74 : void GetInputFuelAndPollutionFactors(EnergyPlusData &state)
    2784              : {
    2785              :     // SUBROUTINE INFORMATION:
    2786              :     //       AUTHOR         Jason Glazer
    2787              :     //       DATE WRITTEN   January 2004
    2788              :     //       MODIFIED       na
    2789              :     //       RE-ENGINEERED  na
    2790              : 
    2791              :     // PURPOSE OF THIS SUBROUTINE:
    2792              :     //   Read the Fuel Factor inputs by the user to
    2793              :     //   get the source energy conversion factors
    2794              :     //   Also reads PolutionCalculationFactors to
    2795              :     //   get information on district cooling and heating
    2796              : 
    2797              :     // METHODOLOGY EMPLOYED:
    2798              :     //   Uses get input structure similar to other objects
    2799              : 
    2800              :     // REFERENCES:
    2801              :     // na
    2802              : 
    2803              :     // Using/Aliasing
    2804              :     using Pollution::GetEnvironmentalImpactFactorInfo;
    2805              :     using Pollution::GetFuelFactorInfo;
    2806              : 
    2807              :     // Locals
    2808              :     // SUBROUTINE ARGUMENT DEFINITIONS:
    2809              :     // na
    2810              : 
    2811              :     // SUBROUTINE PARAMETER DEFINITIONS:
    2812              :     // na
    2813              : 
    2814              :     // INTERFACE BLOCK SPECIFICATIONS:
    2815              :     // na
    2816              : 
    2817              :     // DERIVED TYPE DEFINITIONS:
    2818              :     // na
    2819              : 
    2820              :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
    2821              :     Real64 curSourceFactor;
    2822              :     bool fuelFactorUsed;
    2823              :     bool fFScheduleUsed;
    2824           74 :     Sched::Schedule *ffSched = nullptr;
    2825              : 
    2826           74 :     auto &ort = state.dataOutRptTab;
    2827              : 
    2828              :     // set the default factors for source energy - they will be overwritten if the user sets any values
    2829           74 :     ort->sourceFactorElectric = 3.167;
    2830           74 :     ort->sourceFactorNaturalGas = 1.084;
    2831           74 :     ort->sourceFactorDistrictHeatingSteam = 1.20;
    2832           74 :     ort->sourceFactorGasoline = 1.05;
    2833           74 :     ort->sourceFactorDiesel = 1.05;
    2834           74 :     ort->sourceFactorCoal = 1.05;
    2835           74 :     ort->sourceFactorFuelOil1 = 1.05;
    2836           74 :     ort->sourceFactorFuelOil2 = 1.05;
    2837           74 :     ort->sourceFactorPropane = 1.05;
    2838           74 :     ort->sourceFactorOtherFuel1 = 1.0;
    2839           74 :     ort->sourceFactorOtherFuel2 = 1.0;
    2840              :     // the following should be kept consistent with the assumptions in the pollution calculation routines
    2841           74 :     ort->efficiencyDistrictCooling = 3.0;
    2842           74 :     ort->efficiencyDistrictHeatingWater = 0.3;
    2843              : 
    2844              :     //  TotalSourceEnergyUse = (gatherTotalsSource(1) & !total source from electricity
    2845              :     //                  +  gatherTotalsSource(2)   & !natural gas
    2846              :     //                  + gatherTotalsSource(3)    & !gasoline
    2847              :     //                  + gatherTotalsSource(4)    & !diesel
    2848              :     //                  + gatherTotalsSource(5)    & !coal
    2849              :     //                  + gatherTotalsSource(6)    & !Fuel Oil No1
    2850              :     //                  + gatherTotalsSource(7)    & !Fuel Oil No2
    2851              :     //                  + gatherTotalsSource(8)    &  !propane
    2852              :     //                  + gatherTotalsBEPS(3)*sourceFactorElectric/efficiencyDistrictCooling  & !district cooling
    2853              :     //                  + gatherTotalsBEPS(4)*sourceFactorNaturalGas/efficiencyDistrictHeating  & !district heating
    2854              :     //                  + gatherTotalsBEPS(5)*sourceFactorSteam  & !steam
    2855              :     //                                          ) / largeConversionFactor
    2856              : 
    2857           74 :     GetFuelFactorInfo(state, Constant::eFuel::NaturalGas, fuelFactorUsed, curSourceFactor, fFScheduleUsed, &ffSched);
    2858           74 :     if (fuelFactorUsed) {
    2859            0 :         ort->sourceFactorNaturalGas = curSourceFactor;
    2860            0 :         ort->fuelfactorsused(2) = true;
    2861            0 :         ort->ffUsed(2) = true;
    2862              :     }
    2863           74 :     ort->SourceFactors(2) = curSourceFactor;
    2864           74 :     if (fFScheduleUsed) {
    2865            0 :         ort->fuelFactorSchedulesUsed = true;
    2866            0 :         ort->ffSchedUsed(2) = true;
    2867            0 :         ort->ffScheds(2) = ffSched;
    2868              :     }
    2869              : 
    2870           74 :     GetFuelFactorInfo(state, Constant::eFuel::FuelOilNo2, fuelFactorUsed, curSourceFactor, fFScheduleUsed, &ffSched);
    2871           74 :     if (fuelFactorUsed) {
    2872            0 :         ort->sourceFactorFuelOil2 = curSourceFactor;
    2873            0 :         ort->fuelfactorsused(7) = true;
    2874            0 :         ort->ffUsed(11) = true;
    2875              :     }
    2876           74 :     ort->SourceFactors(11) = curSourceFactor;
    2877           74 :     if (fFScheduleUsed) {
    2878            0 :         ort->fuelFactorSchedulesUsed = true;
    2879            0 :         ort->ffSchedUsed(11) = true;
    2880            0 :         ort->ffScheds(11) = ffSched;
    2881              :     }
    2882              : 
    2883           74 :     GetFuelFactorInfo(state, Constant::eFuel::FuelOilNo1, fuelFactorUsed, curSourceFactor, fFScheduleUsed, &ffSched);
    2884           74 :     if (fuelFactorUsed) {
    2885            0 :         ort->sourceFactorFuelOil1 = curSourceFactor;
    2886            0 :         ort->fuelfactorsused(6) = true;
    2887            0 :         ort->ffUsed(10) = true;
    2888              :     }
    2889           74 :     ort->SourceFactors(10) = curSourceFactor;
    2890           74 :     if (fFScheduleUsed) {
    2891            0 :         ort->fuelFactorSchedulesUsed = true;
    2892            0 :         ort->ffSchedUsed(10) = true;
    2893            0 :         ort->ffScheds(10) = ffSched;
    2894              :     }
    2895              : 
    2896           74 :     GetFuelFactorInfo(state, Constant::eFuel::Coal, fuelFactorUsed, curSourceFactor, fFScheduleUsed, &ffSched);
    2897           74 :     if (fuelFactorUsed) {
    2898            0 :         ort->sourceFactorCoal = curSourceFactor;
    2899            0 :         ort->fuelfactorsused(5) = true;
    2900            0 :         ort->ffUsed(9) = true;
    2901              :     }
    2902           74 :     ort->SourceFactors(9) = curSourceFactor;
    2903           74 :     if (fFScheduleUsed) {
    2904            0 :         ort->fuelFactorSchedulesUsed = true;
    2905            0 :         ort->ffSchedUsed(9) = true;
    2906            0 :         ort->ffScheds(9) = ffSched;
    2907              :     }
    2908              : 
    2909           74 :     GetFuelFactorInfo(state, Constant::eFuel::Electricity, fuelFactorUsed, curSourceFactor, fFScheduleUsed, &ffSched);
    2910           74 :     if (fuelFactorUsed) {
    2911            0 :         ort->sourceFactorElectric = curSourceFactor;
    2912            0 :         ort->fuelfactorsused(1) = true;
    2913            0 :         ort->ffUsed(1) = true;
    2914              :     }
    2915           74 :     ort->SourceFactors(1) = curSourceFactor;
    2916           74 :     if (fFScheduleUsed) {
    2917            0 :         ort->fuelFactorSchedulesUsed = true;
    2918            0 :         ort->ffSchedUsed(1) = true;
    2919            0 :         ort->ffScheds(1) = ffSched;
    2920              :     }
    2921              : 
    2922           74 :     GetFuelFactorInfo(state, Constant::eFuel::Gasoline, fuelFactorUsed, curSourceFactor, fFScheduleUsed, &ffSched);
    2923           74 :     if (fuelFactorUsed) {
    2924            0 :         ort->sourceFactorGasoline = curSourceFactor;
    2925            0 :         ort->fuelfactorsused(3) = true;
    2926            0 :         ort->ffUsed(6) = true;
    2927              :     }
    2928           74 :     ort->SourceFactors(6) = curSourceFactor;
    2929           74 :     if (fFScheduleUsed) {
    2930            0 :         ort->fuelFactorSchedulesUsed = true;
    2931            0 :         ort->ffSchedUsed(6) = true;
    2932            0 :         ort->ffScheds(6) = ffSched;
    2933              :     }
    2934              : 
    2935           74 :     GetFuelFactorInfo(state, Constant::eFuel::Propane, fuelFactorUsed, curSourceFactor, fFScheduleUsed, &ffSched);
    2936           74 :     if (fuelFactorUsed) {
    2937            0 :         ort->sourceFactorPropane = curSourceFactor;
    2938            0 :         ort->fuelfactorsused(8) = true;
    2939            0 :         ort->ffUsed(12) = true;
    2940              :     }
    2941           74 :     ort->SourceFactors(12) = curSourceFactor;
    2942           74 :     if (fFScheduleUsed) {
    2943            0 :         ort->fuelFactorSchedulesUsed = true;
    2944            0 :         ort->ffSchedUsed(12) = true;
    2945            0 :         ort->ffScheds(12) = ffSched;
    2946              :     }
    2947              : 
    2948           74 :     GetFuelFactorInfo(state, Constant::eFuel::Diesel, fuelFactorUsed, curSourceFactor, fFScheduleUsed, &ffSched);
    2949           74 :     if (fuelFactorUsed) {
    2950            0 :         ort->sourceFactorDiesel = curSourceFactor;
    2951            0 :         ort->fuelfactorsused(4) = true;
    2952            0 :         ort->ffUsed(8) = true;
    2953              :     }
    2954           74 :     ort->SourceFactors(8) = curSourceFactor;
    2955           74 :     if (fFScheduleUsed) {
    2956            0 :         ort->fuelFactorSchedulesUsed = true;
    2957            0 :         ort->ffSchedUsed(8) = true;
    2958            0 :         ort->ffScheds(8) = ffSched;
    2959              :     }
    2960              : 
    2961           74 :     GetFuelFactorInfo(state, Constant::eFuel::DistrictCooling, fuelFactorUsed, curSourceFactor, fFScheduleUsed, &ffSched);
    2962           74 :     if (fuelFactorUsed) {
    2963            0 :         ort->ffUsed(3) = true;
    2964              :     }
    2965           74 :     ort->SourceFactors(3) = curSourceFactor;
    2966           74 :     if (fFScheduleUsed) {
    2967            0 :         ort->ffSchedUsed(3) = true;
    2968            0 :         ort->ffScheds(3) = ffSched;
    2969              :     }
    2970              : 
    2971           74 :     GetFuelFactorInfo(state, Constant::eFuel::DistrictHeatingWater, fuelFactorUsed, curSourceFactor, fFScheduleUsed, &ffSched);
    2972           74 :     if (fuelFactorUsed) {
    2973            0 :         ort->ffUsed(4) = true;
    2974              :     }
    2975           74 :     ort->SourceFactors(4) = curSourceFactor;
    2976           74 :     if (fFScheduleUsed) {
    2977            0 :         ort->ffSchedUsed(4) = true;
    2978            0 :         ort->ffScheds(4) = ffSched;
    2979              :     }
    2980              : 
    2981           74 :     GetFuelFactorInfo(state, Constant::eFuel::DistrictHeatingSteam, fuelFactorUsed, curSourceFactor, fFScheduleUsed, &ffSched);
    2982           74 :     if (fuelFactorUsed) {
    2983            0 :         ort->ffUsed(5) = true;
    2984              :     }
    2985           74 :     ort->SourceFactors(5) = curSourceFactor;
    2986           74 :     if (fFScheduleUsed) {
    2987            0 :         ort->ffSchedUsed(5) = true;
    2988            0 :         ort->ffScheds(5) = ffSched;
    2989              :     }
    2990              : 
    2991           74 :     GetFuelFactorInfo(state, Constant::eFuel::OtherFuel1, fuelFactorUsed, curSourceFactor, fFScheduleUsed, &ffSched);
    2992           74 :     if (fuelFactorUsed) {
    2993            0 :         ort->sourceFactorOtherFuel1 = curSourceFactor;
    2994            0 :         ort->fuelfactorsused(11) = true; // should be source number
    2995            0 :         ort->ffUsed(13) = true;
    2996              :     }
    2997           74 :     ort->SourceFactors(13) = curSourceFactor;
    2998           74 :     if (fFScheduleUsed) {
    2999            0 :         ort->fuelFactorSchedulesUsed = true;
    3000            0 :         ort->ffSchedUsed(13) = true;
    3001            0 :         ort->ffScheds(13) = ffSched;
    3002              :     }
    3003              : 
    3004           74 :     GetFuelFactorInfo(state, Constant::eFuel::OtherFuel2, fuelFactorUsed, curSourceFactor, fFScheduleUsed, &ffSched);
    3005           74 :     if (fuelFactorUsed) {
    3006            0 :         ort->sourceFactorOtherFuel2 = curSourceFactor;
    3007            0 :         ort->fuelfactorsused(12) = true; // should be source number
    3008            0 :         ort->ffUsed(14) = true;
    3009              :     }
    3010           74 :     ort->SourceFactors(14) = curSourceFactor;
    3011           74 :     if (fFScheduleUsed) {
    3012            0 :         ort->fuelFactorSchedulesUsed = true;
    3013            0 :         ort->ffSchedUsed(14) = true;
    3014            0 :         ort->ffScheds(14) = ffSched;
    3015              :     }
    3016              : 
    3017           74 :     GetEnvironmentalImpactFactorInfo(
    3018           74 :         state, ort->efficiencyDistrictHeatingWater, ort->efficiencyDistrictCooling, ort->sourceFactorDistrictHeatingSteam);
    3019           74 : }
    3020              : 
    3021              : //======================================================================================================================
    3022              : //======================================================================================================================
    3023              : 
    3024              : //    OTHER INITIALIZATION ROUTINES
    3025              : 
    3026              : //======================================================================================================================
    3027              : //======================================================================================================================
    3028              : 
    3029           74 : void OpenOutputTabularFile(EnergyPlusData &state)
    3030              : {
    3031              :     // SUBROUTINE INFORMATION:
    3032              :     //       AUTHOR         Jason Glazer
    3033              :     //       DATE WRITTEN   July 2003
    3034              :     //       MODIFIED       na
    3035              :     //       RE-ENGINEERED  na
    3036              : 
    3037              :     // PURPOSE OF THIS SUBROUTINE:
    3038              :     //   Create a file that holds the output from the tabular reports
    3039              :     //   the output is in a CSV file if it is comma delimited otherwise
    3040              :     //   it is in a TXT file.
    3041              : 
    3042              :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
    3043           74 :     auto &ort = state.dataOutRptTab;
    3044              : 
    3045              :     // get a new file unit number
    3046              :     // create a file to hold the results
    3047              :     // Use a CSV file if comma separated but otherwise use TXT file
    3048              :     // extension.
    3049           74 :     if (ort->WriteTabularFiles && state.files.outputControl.tabular) {
    3050          167 :         for (int iStyle = 1; iStyle <= ort->numStyles; ++iStyle) {
    3051          128 :             std::string const &curDel = ort->del(iStyle);
    3052          128 :             if (ort->TableStyle(iStyle) == TableStyle::Comma) {
    3053           33 :                 DisplayString(state, "Writing tabular output file results using comma format.");
    3054              :                 std::ofstream &tbl_stream =
    3055           33 :                     open_tbl_stream(state, iStyle, state.dataStrGlobals->outputTblCsvFilePath, state.files.outputControl.tabular);
    3056           33 :                 tbl_stream << "Program Version:" << curDel << state.dataStrGlobals->VerStringVar << '\n';
    3057           33 :                 tbl_stream << "Tabular Output Report in Format: " << curDel << "Comma\n";
    3058           33 :                 tbl_stream << '\n';
    3059           33 :                 tbl_stream << "Building:" << curDel << state.dataHeatBal->BuildingName << '\n';
    3060           33 :                 if (state.dataEnvrn->EnvironmentName == state.dataEnvrn->WeatherFileLocationTitle) {
    3061            0 :                     tbl_stream << "Environment:" << curDel << state.dataEnvrn->EnvironmentName << '\n';
    3062              :                 } else {
    3063          132 :                     tbl_stream << "Environment:" << curDel << state.dataEnvrn->EnvironmentName << " ** " << state.dataEnvrn->WeatherFileLocationTitle
    3064           33 :                                << '\n';
    3065              :                 }
    3066           33 :                 tbl_stream << '\n';
    3067           95 :             } else if (ort->TableStyle(iStyle) == TableStyle::Tab) {
    3068           23 :                 DisplayString(state, "Writing tabular output file results using tab format.");
    3069              :                 std::ofstream &tbl_stream =
    3070           23 :                     open_tbl_stream(state, iStyle, state.dataStrGlobals->outputTblTabFilePath, state.files.outputControl.tabular);
    3071           23 :                 tbl_stream << "Program Version" << curDel << state.dataStrGlobals->VerStringVar << '\n';
    3072           23 :                 tbl_stream << "Tabular Output Report in Format: " << curDel << "Tab\n";
    3073           23 :                 tbl_stream << '\n';
    3074           23 :                 tbl_stream << "Building:" << curDel << state.dataHeatBal->BuildingName << '\n';
    3075           23 :                 if (state.dataEnvrn->EnvironmentName == state.dataEnvrn->WeatherFileLocationTitle) {
    3076            0 :                     tbl_stream << "Environment:" << curDel << state.dataEnvrn->EnvironmentName << '\n';
    3077              :                 } else {
    3078           92 :                     tbl_stream << "Environment:" << curDel << state.dataEnvrn->EnvironmentName << " ** " << state.dataEnvrn->WeatherFileLocationTitle
    3079           23 :                                << '\n';
    3080              :                 }
    3081           23 :                 tbl_stream << '\n';
    3082           72 :             } else if (ort->TableStyle(iStyle) == TableStyle::HTML) {
    3083           28 :                 DisplayString(state, "Writing tabular output file results using HTML format.");
    3084              :                 std::ofstream &tbl_stream =
    3085           28 :                     open_tbl_stream(state, iStyle, state.dataStrGlobals->outputTblHtmFilePath, state.files.outputControl.tabular);
    3086           28 :                 tbl_stream << "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"\"http://www.w3.org/TR/html4/loose.dtd\">\n";
    3087           28 :                 tbl_stream << "<html>\n";
    3088           28 :                 tbl_stream << "<head>\n";
    3089           28 :                 if (state.dataEnvrn->EnvironmentName == state.dataEnvrn->WeatherFileLocationTitle) {
    3090            1 :                     tbl_stream << "<title> " << state.dataHeatBal->BuildingName << ' ' << state.dataEnvrn->EnvironmentName << '\n';
    3091              :                 } else {
    3092          108 :                     tbl_stream << "<title> " << state.dataHeatBal->BuildingName << ' ' << state.dataEnvrn->EnvironmentName << " ** "
    3093           27 :                                << state.dataEnvrn->WeatherFileLocationTitle << '\n';
    3094              :                 }
    3095           28 :                 tbl_stream << "  " << std::setw(4) << ort->td(1) << '-' << std::setfill('0') << std::setw(2) << ort->td(2) << '-' << std::setw(2)
    3096           28 :                            << ort->td(3) << '\n';
    3097           28 :                 tbl_stream << "  " << std::setw(2) << ort->td(5) << ':' << std::setw(2) << ort->td(6) << ':' << std::setw(2) << ort->td(7)
    3098           28 :                            << std::setfill(' ') << '\n';
    3099           28 :                 tbl_stream << " - EnergyPlus</title>\n";
    3100           28 :                 tbl_stream << "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">\n";
    3101           28 :                 tbl_stream << "</head>\n";
    3102           28 :                 tbl_stream << "<body>\n";
    3103           28 :                 tbl_stream << "<p><a href=\"#toc\" style=\"float: right\">Table of Contents</a></p>\n";
    3104           28 :                 tbl_stream << "<a name=top></a>\n";
    3105           28 :                 tbl_stream << "<p>Program Version:<b>" << state.dataStrGlobals->VerStringVar << "</b></p>\n";
    3106           28 :                 tbl_stream << "<p>Tabular Output Report in Format: <b>HTML</b></p>\n";
    3107           28 :                 tbl_stream << "<p>Building: <b>" << state.dataHeatBal->BuildingName << "</b></p>\n";
    3108           28 :                 if (state.dataEnvrn->EnvironmentName == state.dataEnvrn->WeatherFileLocationTitle) {
    3109            1 :                     tbl_stream << "<p>Environment: <b>" << ConvertToEscaped(state.dataEnvrn->EnvironmentName, false) << "</b></p>\n";
    3110              :                 } else {
    3111           54 :                     tbl_stream << "<p>Environment: <b>" << ConvertToEscaped(state.dataEnvrn->EnvironmentName, false) << " ** "
    3112           54 :                                << ConvertToEscaped(state.dataEnvrn->WeatherFileLocationTitle, false) << "</b></p>\n";
    3113              :                 }
    3114           28 :                 tbl_stream << "<p>Simulation Timestamp: <b>" << std::setw(4) << ort->td(1) << '-' << std::setfill('0') << std::setw(2) << ort->td(2)
    3115           28 :                            << '-' << std::setw(2) << ort->td(3) << '\n';
    3116           28 :                 tbl_stream << "  " << std::setw(2) << ort->td(5) << ':' << std::setw(2) << ort->td(6) << ':' << std::setw(2) << ort->td(7)
    3117           28 :                            << std::setfill(' ') << "</b></p>\n";
    3118           44 :             } else if (ort->TableStyle(iStyle) == TableStyle::XML) {
    3119           22 :                 DisplayString(state, "Writing tabular output file results using XML format.");
    3120              :                 std::ofstream &tbl_stream =
    3121           22 :                     open_tbl_stream(state, iStyle, state.dataStrGlobals->outputTblXmlFilePath, state.files.outputControl.tabular);
    3122           22 :                 tbl_stream << "<?xml version=\"1.0\"?>\n";
    3123           22 :                 tbl_stream << "<EnergyPlusTabularReports>\n";
    3124           22 :                 tbl_stream << "  <BuildingName>" << ConvertToEscaped(state.dataHeatBal->BuildingName) << "</BuildingName>\n";
    3125           22 :                 tbl_stream << "  <EnvironmentName>" << state.dataEnvrn->EnvironmentName << "</EnvironmentName>\n";
    3126           22 :                 tbl_stream << "  <WeatherFileLocationTitle>" << state.dataEnvrn->WeatherFileLocationTitle << "</WeatherFileLocationTitle>\n";
    3127           22 :                 tbl_stream << "  <ProgramVersion>" << state.dataStrGlobals->VerStringVar << "</ProgramVersion>\n";
    3128           22 :                 tbl_stream << "  <SimulationTimestamp>\n";
    3129           22 :                 tbl_stream << "    <Date>\n";
    3130           22 :                 tbl_stream << "      " << std::setw(4) << ort->td(1) << '-' << std::setfill('0') << std::setw(2) << ort->td(2) << '-' << std::setw(2)
    3131           22 :                            << ort->td(3) << '\n';
    3132           22 :                 tbl_stream << "    </Date>\n";
    3133           22 :                 tbl_stream << "    <Time>\n";
    3134           22 :                 tbl_stream << "      " << std::setw(2) << ort->td(5) << ':' << std::setw(2) << ort->td(6) << ':' << std::setw(2) << ort->td(7)
    3135           22 :                            << std::setfill(' ') << '\n';
    3136           22 :                 tbl_stream << "    </Time>\n";
    3137           22 :                 tbl_stream << "  </SimulationTimestamp>\n";
    3138           22 :                 tbl_stream << '\n';
    3139              :             } else {
    3140           22 :                 DisplayString(state, "Writing tabular output file results using text format.");
    3141              :                 std::ofstream &tbl_stream =
    3142           22 :                     open_tbl_stream(state, iStyle, state.dataStrGlobals->outputTblTxtFilePath, state.files.outputControl.tabular);
    3143           22 :                 tbl_stream << "Program Version: " << state.dataStrGlobals->VerStringVar << '\n';
    3144           22 :                 tbl_stream << "Tabular Output Report in Format: " << curDel << "Fixed\n";
    3145           22 :                 tbl_stream << '\n';
    3146           22 :                 tbl_stream << "Building:        " << state.dataHeatBal->BuildingName << '\n';
    3147           22 :                 if (state.dataEnvrn->EnvironmentName == state.dataEnvrn->WeatherFileLocationTitle) {
    3148            0 :                     tbl_stream << "Environment:     " << state.dataEnvrn->EnvironmentName << '\n';
    3149              :                 } else {
    3150           88 :                     tbl_stream << "Environment:     " << state.dataEnvrn->EnvironmentName << " ** " << state.dataEnvrn->WeatherFileLocationTitle
    3151           22 :                                << '\n';
    3152              :                 }
    3153           22 :                 tbl_stream << '\n';
    3154              :             }
    3155              :         }
    3156              :     }
    3157           74 : }
    3158              : 
    3159           74 : void CloseOutputTabularFile(EnergyPlusData &state)
    3160              : {
    3161              :     // SUBROUTINE INFORMATION:
    3162              :     //       AUTHOR         Jason Glazer
    3163              :     //       DATE WRITTEN   July 2003
    3164              :     //       MODIFIED       na
    3165              :     //       RE-ENGINEERED  na
    3166              : 
    3167              :     // PURPOSE OF THIS SUBROUTINE:
    3168              :     //   Create a file that holds the output from the tabular reports
    3169              :     //   the output is in a CSV file if it is comma delimited otherwise
    3170              :     //   it is in a TXT file.
    3171              : 
    3172              :     // METHODOLOGY EMPLOYED:
    3173              :     //   Uses get input structure similar to other objects
    3174              : 
    3175              :     // REFERENCES:
    3176              :     // na
    3177              : 
    3178              :     // USE STATEMENTS:
    3179              :     // na
    3180              : 
    3181              :     // Locals
    3182              :     // SUBROUTINE ARGUMENT DEFINITIONS:
    3183              :     // na
    3184              : 
    3185              :     // SUBROUTINE PARAMETER DEFINITIONS:
    3186              : 
    3187              :     // INTERFACE BLOCK SPECIFICATIONS:
    3188              :     // na
    3189              : 
    3190              :     // DERIVED TYPE DEFINITIONS:
    3191              :     // na
    3192              : 
    3193              :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
    3194           74 :     auto &ort = state.dataOutRptTab;
    3195              : 
    3196           74 :     if (ort->WriteTabularFiles) {
    3197          167 :         for (int iStyle = 1; iStyle <= ort->numStyles; ++iStyle) {
    3198          128 :             std::ofstream &tbl_stream(*ort->TabularOutputFile(iStyle));
    3199          128 :             if (ort->TableStyle(iStyle) == TableStyle::HTML) { // if HTML file put ending info
    3200           28 :                 tbl_stream << "</body>\n";
    3201           28 :                 tbl_stream << "</html>\n";
    3202          100 :             } else if (ort->TableStyle(iStyle) == TableStyle::XML) {
    3203           22 :                 if (!ort->prevReportName.empty()) {
    3204           22 :                     tbl_stream << "</" << ort->prevReportName << ">\n"; // close the last element if it was used.
    3205              :                 }
    3206           22 :                 tbl_stream << "</EnergyPlusTabularReports>\n";
    3207              :             }
    3208          128 :             tbl_stream.close();
    3209              :         }
    3210              :     }
    3211           74 : }
    3212              : 
    3213           38 : void WriteTableOfContents(EnergyPlusData &state)
    3214              : {
    3215              :     // SUBROUTINE INFORMATION:
    3216              :     //       AUTHOR         Jason Glazer
    3217              :     //       DATE WRITTEN   June 2005
    3218              :     //       MODIFIED       na
    3219              :     //       RE-ENGINEERED  na
    3220              : 
    3221              :     // PURPOSE OF THIS SUBROUTINE:
    3222              :     //   Creates hyperlinks for table of contents
    3223              : 
    3224              :     // METHODOLOGY EMPLOYED:
    3225              :     //   Go through the reports and create links
    3226              : 
    3227              :     // SUBROUTINE PARAMETER DEFINITIONS:
    3228           98 :     static std::string const Entire_Facility("Entire Facility");
    3229           98 :     static std::string const Annual_Building_Utility_Performance_Summary("Annual Building Utility Performance Summary");
    3230           98 :     static std::string const Input_Verification_and_Results_Summary("Input Verification and Results Summary");
    3231           98 :     static std::string const Demand_End_Use_Components_Summary("Demand End Use Components Summary");
    3232           98 :     static std::string const Source_Energy_End_Use_Components_Summary("Source Energy End Use Components Summary");
    3233           98 :     static std::string const Component_Cost_Economics_Summary("Component Cost Economics Summary");
    3234           98 :     static std::string const Component_Sizing_Summary("Component Sizing Summary");
    3235           98 :     static std::string const Surface_Shadowing_Summary("Surface Shadowing Summary");
    3236           98 :     static std::string const Adaptive_Comfort_Summary("Adaptive Comfort Summary");
    3237           98 :     static std::string const Initialization_Summary("Initialization Summary");
    3238           98 :     static std::string const Annual_Heat_Emissions_Summary("Annual Heat Emissions Summary");
    3239           98 :     static std::string const Annual_Thermal_Resilience_Summary("Annual Thermal Resilience Summary");
    3240           98 :     static std::string const Annual_CO2_Resilience_Summary("Annual CO2 Resilience Summary");
    3241           98 :     static std::string const Annual_Visual_Resilience_Summary("Annual Visual Resilience Summary");
    3242              : 
    3243              :     // INTERFACE BLOCK SPECIFICATIONS:
    3244              :     // na
    3245              : 
    3246              :     // DERIVED TYPE DEFINITIONS:
    3247              :     // na
    3248              : 
    3249              :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
    3250           38 :     auto &ort = state.dataOutRptTab;
    3251              : 
    3252              :     // normally do not add to the table of contents here but the order of calls is different for the life-cycle costs
    3253           38 :     if (ort->displayLifeCycleCostReport && state.dataEconLifeCycleCost->LCCparamPresent) {
    3254            0 :         AddTOCEntry(state, "Life-Cycle Cost Report", "Entire Facility");
    3255              :     }
    3256              : 
    3257          165 :     for (int iStyle = 1; iStyle <= ort->numStyles; ++iStyle) {
    3258          127 :         if (ort->TableStyle(iStyle) == TableStyle::HTML) {
    3259           27 :             std::ostream &tbl_stream(*ort->TabularOutputFile(iStyle));
    3260           27 :             tbl_stream << "<hr>\n";
    3261           27 :             tbl_stream << "<a name=toc></a>\n";
    3262           27 :             tbl_stream << "<p><b>Table of Contents</b></p>\n";
    3263           27 :             tbl_stream << "<a href=\"#top\">Top</a>\n";
    3264           27 :             if (ort->displayTabularBEPS) {
    3265           27 :                 tbl_stream << "<br><a href=\"#" << MakeAnchorName(Annual_Building_Utility_Performance_Summary, Entire_Facility)
    3266           27 :                            << "\">Annual Building Utility Performance Summary</a>\n";
    3267              :             }
    3268           27 :             if (ort->displayTabularVeriSum) {
    3269           27 :                 tbl_stream << "<br><a href=\"#" << MakeAnchorName(Input_Verification_and_Results_Summary, Entire_Facility)
    3270           27 :                            << "\">Input Verification and Results Summary</a>\n";
    3271              :             }
    3272           27 :             if (ort->displayDemandEndUse) {
    3273           27 :                 tbl_stream << "<br><a href=\"#" << MakeAnchorName(Demand_End_Use_Components_Summary, Entire_Facility)
    3274           27 :                            << "\">Demand End Use Components Summary</a>\n";
    3275              :             }
    3276           27 :             if (ort->displaySourceEnergyEndUseSummary) {
    3277           27 :                 tbl_stream << "<br><a href=\"#" << MakeAnchorName(Source_Energy_End_Use_Components_Summary, Entire_Facility)
    3278           27 :                            << "\">Source Energy End Use Components Summary</a>\n";
    3279              :             }
    3280           27 :             if (state.dataCostEstimateManager->DoCostEstimate) {
    3281            0 :                 tbl_stream << "<br><a href=\"#" << MakeAnchorName(Component_Cost_Economics_Summary, Entire_Facility)
    3282            0 :                            << "\">Component Cost Economics Summary</a>\n";
    3283              :             }
    3284           27 :             if (ort->displayComponentSizing) {
    3285           27 :                 tbl_stream << "<br><a href=\"#" << MakeAnchorName(Component_Sizing_Summary, Entire_Facility) << "\">Component Sizing Summary</a>\n";
    3286              :             }
    3287           27 :             if (ort->displaySurfaceShadowing) {
    3288           27 :                 tbl_stream << "<br><a href=\"#" << MakeAnchorName(Surface_Shadowing_Summary, Entire_Facility) << "\">Surface Shadowing Summary</a>\n";
    3289              :             }
    3290           27 :             if (ort->displayAdaptiveComfort) {
    3291           27 :                 tbl_stream << "<br><a href=\"#" << MakeAnchorName(Adaptive_Comfort_Summary, Entire_Facility) << "\">Adaptive Comfort Summary</a>\n";
    3292              :             }
    3293           27 :             if (ort->displayEioSummary) {
    3294           27 :                 tbl_stream << "<br><a href=\"#" << MakeAnchorName(Initialization_Summary, Entire_Facility) << "\">Initialization Summary</a>\n";
    3295              :             }
    3296           27 :             if (ort->displayHeatEmissionsSummary) {
    3297           27 :                 tbl_stream << "<br><a href=\"#" << MakeAnchorName(Annual_Heat_Emissions_Summary, Entire_Facility)
    3298           27 :                            << "\">Annual Heat Emissions Summary</a>\n";
    3299              :             }
    3300           27 :             if (ort->displayThermalResilienceSummary) {
    3301           27 :                 tbl_stream << "<br><a href=\"#" << MakeAnchorName(Annual_Thermal_Resilience_Summary, Entire_Facility)
    3302           27 :                            << "\">Annual Thermal Resilience Summary</a>\n";
    3303              :             }
    3304              :             //                if (displayCO2ResilienceSummary) {
    3305              :             //                    tbl_stream << "<br><a href=\"#" << MakeAnchorName(Annual_CO2_Resilience_Summary, Entire_Facility)
    3306              :             //                               << "\">Annual CO2 Resilience Summary</a>\n";
    3307              :             //                }
    3308              :             //                if (displayVisualResilienceSummary) {
    3309              :             //                    tbl_stream << "<br><a href=\"#" << MakeAnchorName(Annual_Visual_Resilience_Summary, Entire_Facility)
    3310              :             //                               << "\">Annual Visual Resilience Summary</a>\n";
    3311              :             //                }
    3312          491 :             for (int kReport = 1; kReport <= state.dataOutRptPredefined->numReportName; ++kReport) {
    3313          464 :                 if (state.dataOutRptPredefined->reportName(kReport).show) {
    3314          928 :                     tbl_stream << "<br><a href=\"#" << MakeAnchorName(state.dataOutRptPredefined->reportName(kReport).namewithspaces, Entire_Facility)
    3315          928 :                                << "\">" << state.dataOutRptPredefined->reportName(kReport).namewithspaces << "</a>\n";
    3316              :                 }
    3317              :             }
    3318           27 :             if (state.dataGlobal->DoWeathSim) {
    3319            0 :                 for (int iInput = 1; iInput <= ort->MonthlyInputCount; ++iInput) {
    3320            0 :                     if (ort->MonthlyInput(iInput).numTables > 0) {
    3321            0 :                         tbl_stream << "<p><b>" << ort->MonthlyInput(iInput).name << "</b></p> |\n";
    3322            0 :                         for (int jTable = 1; jTable <= ort->MonthlyInput(iInput).numTables; ++jTable) {
    3323            0 :                             int const curTable = jTable + ort->MonthlyInput(iInput).firstTable - 1;
    3324            0 :                             tbl_stream << "<a href=\"#" << MakeAnchorName(ort->MonthlyInput(iInput).name, ort->MonthlyTables(curTable).keyValue)
    3325            0 :                                        << "\">" << ort->MonthlyTables(curTable).keyValue << "</a>    |   \n";
    3326              :                         }
    3327              :                     }
    3328              :                 }
    3329            0 :                 for (int iInput = 1; iInput <= ort->OutputTableBinnedCount; ++iInput) {
    3330            0 :                     if (ort->OutputTableBinned(iInput).numTables > 0) {
    3331            0 :                         if (ort->OutputTableBinned(iInput).sched == nullptr) {
    3332            0 :                             tbl_stream << "<p><b>" << ort->OutputTableBinned(iInput).varOrMeter << "</b></p> |\n";
    3333              :                         } else {
    3334            0 :                             tbl_stream << "<p><b>" << ort->OutputTableBinned(iInput).varOrMeter << " [" << ort->OutputTableBinned(iInput).sched->Name
    3335            0 :                                        << "]</b></p> |\n";
    3336              :                         }
    3337            0 :                         for (int jTable = 1; jTable <= ort->OutputTableBinned(iInput).numTables; ++jTable) {
    3338            0 :                             int const curTable = ort->OutputTableBinned(iInput).resIndex + (jTable - 1);
    3339            0 :                             std::string curName;
    3340            0 :                             if (ort->ip()) {
    3341            0 :                                 std::string origName = format("{} [{}]",
    3342            0 :                                                               ort->OutputTableBinned(iInput).varOrMeter,
    3343            0 :                                                               Constant::unitNames[(int)ort->OutputTableBinned(iInput).units]);
    3344            0 :                                 [[maybe_unused]] int indexUnitConv = -1;
    3345            0 :                                 LookupSItoIP(state, origName, indexUnitConv, curName);
    3346            0 :                             } else {
    3347            0 :                                 curName = format("{}[{}]",
    3348            0 :                                                  ort->OutputTableBinned(iInput).varOrMeter,
    3349            0 :                                                  Constant::unitNames[(int)ort->OutputTableBinned(iInput).units]);
    3350              :                             }
    3351            0 :                             if (ort->OutputTableBinned(iInput).sched == nullptr) {
    3352            0 :                                 tbl_stream << "<a href=\"#" << MakeAnchorName(curName, ort->BinObjVarID(curTable).namesOfObj) << "\">"
    3353            0 :                                            << ort->BinObjVarID(curTable).namesOfObj << "</a>   |  \n";
    3354              :                             } else {
    3355              :                                 tbl_stream << "<a href=\"#"
    3356            0 :                                            << MakeAnchorName(curName + ort->OutputTableBinned(iInput).sched->Name,
    3357            0 :                                                              ort->BinObjVarID(curTable).namesOfObj)
    3358            0 :                                            << "\">" << ort->BinObjVarID(curTable).namesOfObj << "</a>   |  \n";
    3359              :                             }
    3360            0 :                         }
    3361              :                     }
    3362              :                 }
    3363            0 :                 OutputReportTabularAnnual::AddAnnualTableOfContents(state, tbl_stream);
    3364              :             }
    3365              :             // add entries specifically added using AddTOCEntry
    3366           37 :             for (int iEntry = 1; iEntry <= ort->TOCEntriesCount; ++iEntry) {
    3367           10 :                 if (!ort->TOCEntries(iEntry).isWritten) {
    3368            9 :                     std::string const &curSection = ort->TOCEntries(iEntry).sectionName;
    3369            9 :                     tbl_stream << "<p><b>" << curSection << "</b></p> |\n";
    3370           28 :                     for (int jEntry = iEntry; jEntry <= ort->TOCEntriesCount; ++jEntry) {
    3371           19 :                         if (!ort->TOCEntries(jEntry).isWritten) {
    3372           19 :                             if (ort->TOCEntries(jEntry).sectionName == curSection) {
    3373           20 :                                 tbl_stream << "<a href=\"#" << MakeAnchorName(ort->TOCEntries(jEntry).sectionName, ort->TOCEntries(jEntry).reportName)
    3374           20 :                                            << "\">" << ort->TOCEntries(jEntry).reportName << "</a>   |  \n";
    3375           10 :                                 ort->TOCEntries(jEntry).isWritten = true;
    3376              :                             }
    3377              :                         }
    3378              :                     }
    3379              :                 }
    3380              :             }
    3381              : 
    3382           27 :             if (state.dataWeather->TotReportPers > 0) {
    3383            0 :                 std::string ReportPeriodSummary = "Reporting Period Summary";
    3384            0 :                 tbl_stream << "<br><a href=\"#" << MakeAnchorName(ReportPeriodSummary, Entire_Facility) << "\">" << "Reporting Period Summary"
    3385            0 :                            << "</a>\n";
    3386            0 :                 AddTOCReportPeriod(state.dataWeather->TotThermalReportPers, "Thermal", state.dataWeather->ThermalReportPeriodInput, tbl_stream);
    3387            0 :                 AddTOCReportPeriod(state.dataWeather->TotCO2ReportPers, "CO2", state.dataWeather->CO2ReportPeriodInput, tbl_stream);
    3388            0 :                 AddTOCReportPeriod(state.dataWeather->TotVisualReportPers, "Visual", state.dataWeather->VisualReportPeriodInput, tbl_stream);
    3389            0 :             }
    3390              :         }
    3391              :     }
    3392           38 : }
    3393              : 
    3394            0 : void AddTOCReportPeriod(const int nReportPeriods,
    3395              :                         const std::string &kw,
    3396              :                         const Array1D<Weather::ReportPeriodData> &ReportPeriodInputData,
    3397              :                         std::ostream &tbl_stream)
    3398              : {
    3399            0 :     static std::string const Entire_Facility("Entire Facility");
    3400            0 :     for (int i = 1; i <= nReportPeriods; i++) {
    3401              :         std::string ReportPeriod_Resilience_Summary = fmt::format(
    3402            0 :             "{} Resilience Summary for Reporting Period {}: {}", kw, i, ReportPeriodInputData(i).title, ReportPeriodInputData(i).totalElectricityUse);
    3403            0 :         tbl_stream << "<br><a href=\"#" << MakeAnchorName(ReportPeriod_Resilience_Summary, Entire_Facility) << "\">" << kw
    3404            0 :                    << " Resilience Summary for Reporting Period " << i << ": " << ReportPeriodInputData(i).title << "</a>\n";
    3405            0 :     }
    3406            0 : }
    3407              : 
    3408              : //======================================================================================================================
    3409              : //======================================================================================================================
    3410              : 
    3411              : //    GATHER DATA EACH TIME STEP ROUTINES
    3412              : 
    3413              : //======================================================================================================================
    3414              : //======================================================================================================================
    3415              : 
    3416            2 : void GatherBinResultsForTimestep(EnergyPlusData &state, OutputProcessor::TimeStepType t_timeStepType) // What kind of data to update (Zone, HVAC)
    3417              : {
    3418              :     // SUBROUTINE INFORMATION:
    3419              :     //       AUTHOR         Jason Glazer
    3420              :     //       DATE WRITTEN   August 2003
    3421              :     //       MODIFIED       na
    3422              :     //       RE-ENGINEERED  na
    3423              : 
    3424              :     // PURPOSE OF THIS SUBROUTINE:
    3425              :     //   Gathers the data each timestep and adds the length of the
    3426              :     //   timestep to the appropriate bin.
    3427              : 
    3428              :     // Locals
    3429              :     // SUBROUTINE ARGUMENT DEFINITIONS:
    3430              : 
    3431              :     // SUBROUTINE PARAMETER DEFINITIONS:
    3432              :     // na
    3433              : 
    3434              :     // INTERFACE BLOCK SPECIFICATIONS:
    3435              :     // na
    3436              : 
    3437              :     // DERIVED TYPE DEFINITIONS:
    3438              :     // na
    3439              : 
    3440              :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
    3441              :     // values of OutputTableBinned array for current index
    3442            2 :     auto &ort = state.dataOutRptTab;
    3443              : 
    3444            2 :     if (!state.dataGlobal->DoWeathSim) {
    3445            0 :         return;
    3446              :     }
    3447              : 
    3448              :     Real64 const elapsedTime =
    3449            2 :         (t_timeStepType == OutputProcessor::TimeStepType::System) ? state.dataHVACGlobal->TimeStepSys : state.dataGlobal->TimeStepZone;
    3450              : 
    3451            2 :     ort->timeInYear += state.dataHVACGlobal->TimeStepSys;
    3452              : 
    3453            2 :     for (int iInObj = 1; iInObj <= ort->OutputTableBinnedCount; ++iInObj) {
    3454              :         // get values of array for current object being referenced
    3455              : 
    3456            0 :         auto *sched = ort->OutputTableBinned(iInObj).sched;
    3457              :         // if a schedule was used, check if it was non-zero value
    3458            0 :         bool gatherThisTime = (sched == nullptr) || (sched->getCurrentVal() != 0.0);
    3459              : 
    3460            0 :         if (gatherThisTime) {
    3461            0 :             Real64 const &curIntervalStart = ort->OutputTableBinned(iInObj).intervalStart;
    3462            0 :             Real64 const &curIntervalSize = ort->OutputTableBinned(iInObj).intervalSize;
    3463            0 :             int const curIntervalCount = ort->OutputTableBinned(iInObj).intervalCount;
    3464            0 :             Real64 const topValue = curIntervalStart + curIntervalSize * curIntervalCount;
    3465            0 :             OutputProcessor::VariableType const curTypeOfVar = ort->OutputTableBinned(iInObj).typeOfVar;
    3466            0 :             OutputProcessor::TimeStepType const curStepType = ort->OutputTableBinned(iInObj).stepType;
    3467              : 
    3468            0 :             for (int jTable = 1; jTable <= ort->OutputTableBinned(iInObj).numTables; ++jTable) {
    3469            0 :                 int curResIndex = ort->OutputTableBinned(iInObj).resIndex;
    3470            0 :                 int repIndex = curResIndex + (jTable - 1);
    3471            0 :                 if (((curStepType == OutputProcessor::TimeStepType::Zone) && (t_timeStepType == OutputProcessor::TimeStepType::Zone)) ||
    3472            0 :                     ((curStepType == OutputProcessor::TimeStepType::System) && (t_timeStepType == OutputProcessor::TimeStepType::System))) {
    3473              :                     // put actual value from OutputProcesser arrays
    3474            0 :                     Real64 curValue = GetInternalVariableValue(state, curTypeOfVar, ort->BinObjVarID(repIndex).varMeterNum);
    3475              :                     // per MJW when a summed variable is used divide it by the length of the time step
    3476            0 :                     if (ort->OutputTableBinned(iInObj).avgSum == OutputProcessor::StoreType::Sum) { // if it is a summed variable
    3477            0 :                         curValue /= (elapsedTime * Constant::rSecsInHour);
    3478              :                     }
    3479              :                     // round the value to the number of significant digits used in the final output report
    3480            0 :                     if (curIntervalSize < 1) {
    3481            0 :                         curValue = round(curValue * 10000.0) / 10000.0; // four significant digits
    3482            0 :                     } else if (curIntervalSize >= 10) {
    3483            0 :                         curValue = round(curValue); // zero significant digits
    3484              :                     } else {
    3485            0 :                         curValue = round(curValue * 100.0) / 100.0; // two significant digits
    3486              :                     }
    3487              :                     // check if the value is above the maximum or below the minimum value
    3488              :                     // first before binning the value within the range.
    3489            0 :                     if (curValue < curIntervalStart) {
    3490            0 :                         ort->BinResultsBelow(repIndex).mnth(state.dataEnvrn->Month) += elapsedTime;
    3491            0 :                         ort->BinResultsBelow(repIndex).hrly(state.dataGlobal->HourOfDay) += elapsedTime;
    3492            0 :                     } else if (curValue >= topValue) {
    3493            0 :                         ort->BinResultsAbove(repIndex).mnth(state.dataEnvrn->Month) += elapsedTime;
    3494            0 :                         ort->BinResultsAbove(repIndex).hrly(state.dataGlobal->HourOfDay) += elapsedTime;
    3495              :                     } else {
    3496              :                         // determine which bin the results are in
    3497            0 :                         int binNum = static_cast<int>((curValue - curIntervalStart) / curIntervalSize) + 1;
    3498            0 :                         ort->BinResults(binNum, repIndex).mnth(state.dataEnvrn->Month) += elapsedTime;
    3499            0 :                         ort->BinResults(binNum, repIndex).hrly(state.dataGlobal->HourOfDay) += elapsedTime;
    3500              :                     }
    3501              :                     // add to statistics array
    3502            0 :                     ++ort->BinStatistics(repIndex).n;
    3503            0 :                     ort->BinStatistics(repIndex).sum += curValue;
    3504            0 :                     ort->BinStatistics(repIndex).sum2 += curValue * curValue;
    3505            0 :                     if (curValue < ort->BinStatistics(repIndex).minimum) {
    3506            0 :                         ort->BinStatistics(repIndex).minimum = curValue;
    3507              :                     }
    3508            0 :                     if (curValue > ort->BinStatistics(repIndex).maximum) {
    3509            0 :                         ort->BinStatistics(repIndex).maximum = curValue;
    3510              :                     }
    3511              :                 }
    3512              :             }
    3513              :         }
    3514              :     }
    3515              : }
    3516              : 
    3517           11 : void GatherMonthlyResultsForTimestep(EnergyPlusData &state, OutputProcessor::TimeStepType t_timeStepType) // What kind of data to update (Zone, HVAC)
    3518              : {
    3519              :     // SUBROUTINE INFORMATION:
    3520              :     //       AUTHOR         Jason Glazer
    3521              :     //       DATE WRITTEN   September 2003
    3522              :     //       MODIFIED       na
    3523              :     //       RE-ENGINEERED  na
    3524              : 
    3525              :     // PURPOSE OF THIS SUBROUTINE:
    3526              :     //   Gathers the data each timestep and updates the arrays
    3527              :     //   holding the data that will be reported later.
    3528              : 
    3529              :     // Using/Aliasing
    3530           11 :     Real64 const TimeStepSysSec = state.dataHVACGlobal->TimeStepSysSec;
    3531              :     using General::EncodeMonDayHrMin;
    3532              : 
    3533              :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
    3534              : 
    3535           11 :     if (!state.dataGlobal->DoWeathSim) {
    3536            0 :         return;
    3537              :     }
    3538              : 
    3539           11 :     auto &ort = state.dataOutRptTab;
    3540           11 :     assert(state.dataGlobal->TimeStepZoneSec > 0.0);
    3541              : 
    3542              :     // create temporary arrays to speed processing of these arrays
    3543           11 :     if (ort->GatherMonthlyResultsForTimestepRunOnce) {
    3544              :         // MonthlyColumns
    3545            4 :         state.dataOutRptTab->MonthlyColumnsTypeOfVar.allocate(ort->MonthlyColumns.I());
    3546            4 :         state.dataOutRptTab->MonthlyColumnsStepType.allocate(ort->MonthlyColumns.I());
    3547            4 :         state.dataOutRptTab->MonthlyColumnsAggType.allocate(ort->MonthlyColumns.I());
    3548            4 :         state.dataOutRptTab->MonthlyColumnsVarNum.allocate(ort->MonthlyColumns.I());
    3549           18 :         for (int i = ort->MonthlyColumns.l(), e = ort->MonthlyColumns.u(); i <= e; ++i) {
    3550           14 :             auto const &col = ort->MonthlyColumns(i);
    3551           14 :             state.dataOutRptTab->MonthlyColumnsTypeOfVar(i) = col.typeOfVar;
    3552           14 :             state.dataOutRptTab->MonthlyColumnsStepType(i) = col.stepType;
    3553           14 :             state.dataOutRptTab->MonthlyColumnsAggType(i) = col.aggType;
    3554           14 :             state.dataOutRptTab->MonthlyColumnsVarNum(i) = col.varNum;
    3555              :         }
    3556              : 
    3557              :         // MonthlyTables
    3558            4 :         state.dataOutRptTab->MonthlyTablesNumColumns.allocate(ort->MonthlyTables.I());
    3559            8 :         for (int i = ort->MonthlyTables.l(), e = ort->MonthlyTables.u(); i <= e; ++i) {
    3560            4 :             state.dataOutRptTab->MonthlyTablesNumColumns(i) = ort->MonthlyTables(i).numColumns;
    3561              :         }
    3562              : 
    3563              :         // set flag so this block is only executed once
    3564            4 :         ort->GatherMonthlyResultsForTimestepRunOnce = false;
    3565              :     }
    3566              : 
    3567              :     Real64 const elapsedTime =
    3568           11 :         (t_timeStepType == OutputProcessor::TimeStepType::System) ? state.dataHVACGlobal->TimeStepSys : state.dataGlobal->TimeStepZone;
    3569              : 
    3570           11 :     ort->IsMonthGathered(state.dataEnvrn->Month) = true;
    3571           28 :     for (int iTable = 1; iTable <= ort->MonthlyTablesCount; ++iTable) {
    3572           17 :         bool activeMinMax = false;     // at the beginning of the new timestep
    3573           17 :         bool activeHoursShown = false; // fix by JG addressing CR6482
    3574           17 :         state.dataOutRptTab->curFirstColumn = ort->MonthlyTables(iTable).firstColumn;
    3575           78 :         for (int jColumn = 1; jColumn <= state.dataOutRptTab->MonthlyTablesNumColumns(iTable); ++jColumn) {
    3576           61 :             int const curCol = jColumn + state.dataOutRptTab->curFirstColumn - 1;
    3577           61 :             OutputProcessor::VariableType const curTypeOfVar = state.dataOutRptTab->MonthlyColumnsTypeOfVar(curCol);
    3578           61 :             OutputProcessor::TimeStepType const curStepType = state.dataOutRptTab->MonthlyColumnsStepType(curCol);
    3579           61 :             if (((curStepType == OutputProcessor::TimeStepType::Zone) && (t_timeStepType == OutputProcessor::TimeStepType::Zone)) ||
    3580            0 :                 ((curStepType == OutputProcessor::TimeStepType::System) && (t_timeStepType == OutputProcessor::TimeStepType::System))) {
    3581              :                 //  the above condition used to include the following prior to new scan method
    3582              :                 //  (MonthlyColumns(curCol)%aggType .EQ. AggType::ValueWhenMaxMin)
    3583           61 :                 int const curVarNum = state.dataOutRptTab->MonthlyColumnsVarNum(curCol);
    3584           61 :                 Real64 curValue = GetInternalVariableValue(state, curTypeOfVar, curVarNum);
    3585              :                 // Get the value from the result array
    3586           61 :                 Real64 const &oldResultValue = ort->MonthlyColumns(curCol).reslt(state.dataEnvrn->Month);
    3587              :                 // Real64 oldTimeStamp = ort->MonthlyColumns(curCol).timeStamp(state.dataEnvrn->Month);
    3588           61 :                 Real64 const &oldDuration = ort->MonthlyColumns(curCol).duration(state.dataEnvrn->Month);
    3589              :                 // Zero the revised values (as default if not set later in SELECT)
    3590           61 :                 Real64 newResultValue = 0.0;
    3591           61 :                 int newTimeStamp = 0;
    3592           61 :                 Real64 newDuration = 0.0;
    3593           61 :                 bool activeNewValue = false;
    3594              :                 // the current timestamp
    3595           61 :                 int const minuteCalculated = OutputProcessor::DetermineMinuteForReporting(state);
    3596              :                 //      minuteCalculated = (CurrentTime - INT(CurrentTime))*60
    3597              :                 //      IF (t_timeStepType .EQ. OutputProcessor::TimeStepType::TimeStepSystem) minuteCalculated = minuteCalculated +
    3598              :                 //      SysTimeElapsed * 60 minuteCalculated = INT((TimeStep-1) * TimeStepZone * 60) + INT((SysTimeElapsed + TimeStepSys) * 60)
    3599              :                 int timestepTimeStamp;
    3600           61 :                 EncodeMonDayHrMin(
    3601           61 :                     timestepTimeStamp, state.dataEnvrn->Month, state.dataEnvrn->DayOfMonth, state.dataGlobal->HourOfDay, minuteCalculated);
    3602              :                 // perform the selected aggregation type
    3603              :                 // use next lines since it is faster was: SELECT CASE (MonthlyColumns(curCol)%aggType)
    3604           61 :                 switch (state.dataOutRptTab->MonthlyColumnsAggType(curCol)) {
    3605           41 :                 case AggType::SumOrAvg: {
    3606           41 :                     if (ort->MonthlyColumns(curCol).avgSum == OutputProcessor::StoreType::Sum) { // if it is a summed variable
    3607           17 :                         newResultValue = oldResultValue + curValue;
    3608              :                     } else {
    3609           24 :                         newResultValue = oldResultValue + curValue * elapsedTime; // for averaging - weight by elapsed time
    3610              :                     }
    3611           41 :                     newDuration = oldDuration + elapsedTime;
    3612           41 :                     activeNewValue = true;
    3613           41 :                 } break;
    3614            0 :                 case AggType::Maximum: {
    3615              :                     // per MJW when a summed variable is used divide it by the length of the time step
    3616            0 :                     if (ort->MonthlyColumns(curCol).avgSum == OutputProcessor::StoreType::Sum) { // if it is a summed variable
    3617            0 :                         if (t_timeStepType == OutputProcessor::TimeStepType::System) {
    3618            0 :                             curValue /= TimeStepSysSec;
    3619              :                         } else {
    3620            0 :                             curValue /= state.dataGlobal->TimeStepZoneSec;
    3621              :                         }
    3622              :                     }
    3623            0 :                     if (curValue > oldResultValue) {
    3624            0 :                         newResultValue = curValue;
    3625            0 :                         newTimeStamp = timestepTimeStamp;
    3626            0 :                         activeMinMax = true;
    3627            0 :                         activeNewValue = true;
    3628              :                     } else {
    3629            0 :                         activeMinMax = false; // reset this
    3630              :                     }
    3631            0 :                 } break;
    3632            0 :                 case AggType::Minimum: {
    3633              :                     // per MJW when a summed variable is used divide it by the length of the time step
    3634            0 :                     if (ort->MonthlyColumns(curCol).avgSum == OutputProcessor::StoreType::Sum) { // if it is a summed variable
    3635            0 :                         if (t_timeStepType == OutputProcessor::TimeStepType::System) {
    3636            0 :                             curValue /= TimeStepSysSec;
    3637              :                         } else {
    3638            0 :                             curValue /= state.dataGlobal->TimeStepZoneSec;
    3639              :                         }
    3640              :                     }
    3641            0 :                     if (curValue < oldResultValue) {
    3642            0 :                         newResultValue = curValue;
    3643            0 :                         newTimeStamp = timestepTimeStamp;
    3644            0 :                         activeMinMax = true;
    3645            0 :                         activeNewValue = true;
    3646              :                     } else {
    3647            0 :                         activeMinMax = false; // reset this
    3648              :                     }
    3649            0 :                 } break;
    3650            0 :                 case AggType::HoursZero: {
    3651            0 :                     if (curValue == 0) {
    3652            0 :                         newResultValue = oldResultValue + elapsedTime;
    3653            0 :                         activeHoursShown = true;
    3654            0 :                         activeNewValue = true;
    3655              :                     } else {
    3656            0 :                         activeHoursShown = false;
    3657              :                     }
    3658            0 :                 } break;
    3659           10 :                 case AggType::HoursNonZero: {
    3660           10 :                     if (curValue != 0) {
    3661            5 :                         newResultValue = oldResultValue + elapsedTime;
    3662            5 :                         activeHoursShown = true;
    3663            5 :                         activeNewValue = true;
    3664              :                     } else {
    3665            5 :                         activeHoursShown = false;
    3666              :                     }
    3667           10 :                 } break;
    3668            0 :                 case AggType::HoursPositive: {
    3669            0 :                     if (curValue > 0) {
    3670            0 :                         newResultValue = oldResultValue + elapsedTime;
    3671            0 :                         activeHoursShown = true;
    3672            0 :                         activeNewValue = true;
    3673              :                     } else {
    3674            0 :                         activeHoursShown = false;
    3675              :                     }
    3676            0 :                 } break;
    3677            0 :                 case AggType::HoursNonPositive: {
    3678            0 :                     if (curValue <= 0) {
    3679            0 :                         newResultValue = oldResultValue + elapsedTime;
    3680            0 :                         activeHoursShown = true;
    3681            0 :                         activeNewValue = true;
    3682              :                     } else {
    3683            0 :                         activeHoursShown = false;
    3684              :                     }
    3685            0 :                 } break;
    3686            0 :                 case AggType::HoursNegative: {
    3687            0 :                     if (curValue < 0) {
    3688            0 :                         newResultValue = oldResultValue + elapsedTime;
    3689            0 :                         activeHoursShown = true;
    3690            0 :                         activeNewValue = true;
    3691              :                     } else {
    3692            0 :                         activeHoursShown = false;
    3693              :                     }
    3694            0 :                 } break;
    3695            0 :                 case AggType::HoursNonNegative: {
    3696            0 :                     if (curValue >= 0) {
    3697            0 :                         newResultValue = oldResultValue + elapsedTime;
    3698            0 :                         activeHoursShown = true;
    3699            0 :                         activeNewValue = true;
    3700              :                     } else {
    3701            0 :                         activeHoursShown = false;
    3702              :                     }
    3703              :                     // The valueWhenMaxMin is picked up now during the activeMinMax if block below.
    3704              :                     // CASE (iAggType::ValueWhenMaxMin)
    3705              :                     // CASE (iAggType::SumOrAverageHoursShown)
    3706              :                     // CASE (iAggType::MaximumDuringHoursShown)
    3707              :                     // CASE (iAggType::MinimumDuringHoursShown)
    3708            0 :                 } break;
    3709           10 :                 default:
    3710           10 :                     break;
    3711              :                 }
    3712              :                 // if the new value has been set then set the monthly values to the
    3713              :                 // new columns. This skips the aggregation types that don't even get
    3714              :                 // triggered now such as valueWhenMinMax and all the agg*HoursShown
    3715           61 :                 if (activeNewValue) {
    3716           46 :                     ort->MonthlyColumns(curCol).reslt(state.dataEnvrn->Month) = newResultValue;
    3717           46 :                     ort->MonthlyColumns(curCol).timeStamp(state.dataEnvrn->Month) = newTimeStamp;
    3718           46 :                     ort->MonthlyColumns(curCol).duration(state.dataEnvrn->Month) = newDuration;
    3719              :                 }
    3720              :                 // if a minimum or maximum value was set this timeStep then
    3721              :                 // scan the remaining columns of the table looking for values
    3722              :                 // that are aggregation type "ValueWhenMaxMin" and set their values
    3723              :                 // if another minimum or maximum column is found then end
    3724              :                 // the scan (it will be taken care of when that column is done)
    3725           61 :                 if (activeMinMax) {
    3726            0 :                     for (int kOtherColumn = jColumn + 1; kOtherColumn <= ort->MonthlyTables(iTable).numColumns; ++kOtherColumn) {
    3727            0 :                         int const scanColumn = kOtherColumn + ort->MonthlyTables(iTable).firstColumn - 1;
    3728            0 :                         switch (ort->MonthlyColumns(scanColumn).aggType) {
    3729            0 :                         case AggType::Maximum:
    3730              :                         case AggType::Minimum:
    3731              :                             // end scanning since these might reset
    3732            0 :                             break; // do
    3733            0 :                         case AggType::ValueWhenMaxMin: {
    3734              :                             // this case is when the value should be set
    3735            0 :                             OutputProcessor::VariableType const scanTypeOfVar = ort->MonthlyColumns(scanColumn).typeOfVar;
    3736            0 :                             int const scanVarNum = ort->MonthlyColumns(scanColumn).varNum;
    3737            0 :                             Real64 scanValue = GetInternalVariableValue(state, scanTypeOfVar, scanVarNum);
    3738              :                             // When a summed variable is used divide it by the length of the time step
    3739            0 :                             if (ort->MonthlyColumns(scanColumn).avgSum == OutputProcessor::StoreType::Sum) { // if it is a summed variable
    3740            0 :                                 if (t_timeStepType == OutputProcessor::TimeStepType::System) {
    3741            0 :                                     scanValue /= TimeStepSysSec;
    3742              :                                 } else {
    3743            0 :                                     scanValue /= state.dataGlobal->TimeStepZoneSec;
    3744              :                                 }
    3745              :                             }
    3746            0 :                             ort->MonthlyColumns(scanColumn).reslt(state.dataEnvrn->Month) = scanValue;
    3747            0 :                         } break;
    3748            0 :                         default:
    3749            0 :                             break;
    3750              :                         }
    3751              :                     }
    3752              :                 }
    3753              :                 // If the hours variable is active then scan through the rest of the variables
    3754              :                 // and accumulate
    3755           61 :                 if (activeHoursShown) {
    3756            5 :                     bool exit_loop = false;
    3757           15 :                     for (int kOtherColumn = jColumn + 1; kOtherColumn <= ort->MonthlyTables(iTable).numColumns; ++kOtherColumn) {
    3758           13 :                         if (exit_loop) {
    3759            3 :                             break;
    3760              :                         }
    3761           10 :                         int const scanColumn = kOtherColumn + ort->MonthlyTables(iTable).firstColumn - 1;
    3762           10 :                         OutputProcessor::VariableType const scanTypeOfVar = ort->MonthlyColumns(scanColumn).typeOfVar;
    3763           10 :                         int const scanVarNum = ort->MonthlyColumns(scanColumn).varNum;
    3764           10 :                         Real64 scanValue = GetInternalVariableValue(state, scanTypeOfVar, scanVarNum);
    3765           10 :                         Real64 const oldScanValue = ort->MonthlyColumns(scanColumn).reslt(state.dataEnvrn->Month);
    3766           10 :                         switch (ort->MonthlyColumns(scanColumn).aggType) {
    3767            3 :                         case AggType::HoursZero:
    3768              :                         case AggType::HoursNonZero:
    3769              :                         case AggType::HoursPositive:
    3770              :                         case AggType::HoursNonPositive:
    3771              :                         case AggType::HoursNegative:
    3772              :                         case AggType::HoursNonNegative:
    3773              :                             // end scanning since these might reset
    3774            3 :                             exit_loop = true;
    3775            3 :                             break; // do
    3776            5 :                         case AggType::SumOrAverageHoursShown: {
    3777              :                             // this case is when the value should be set
    3778            5 :                             if (ort->MonthlyColumns(scanColumn).avgSum == OutputProcessor::StoreType::Sum) { // if it is a summed variable
    3779            5 :                                 ort->MonthlyColumns(scanColumn).reslt(state.dataEnvrn->Month) = oldScanValue + scanValue;
    3780              :                             } else {
    3781              :                                 // for averaging - weight by elapsed time
    3782            0 :                                 ort->MonthlyColumns(scanColumn).reslt(state.dataEnvrn->Month) = oldScanValue + scanValue * elapsedTime;
    3783              :                             }
    3784            5 :                             ort->MonthlyColumns(scanColumn).duration(state.dataEnvrn->Month) += elapsedTime;
    3785            5 :                         } break;
    3786            0 :                         case AggType::MaximumDuringHoursShown: {
    3787            0 :                             if (ort->MonthlyColumns(scanColumn).avgSum == OutputProcessor::StoreType::Sum) { // if it is a summed variable
    3788            0 :                                 if (t_timeStepType == OutputProcessor::TimeStepType::System) {
    3789            0 :                                     scanValue /= TimeStepSysSec;
    3790              :                                 } else {
    3791            0 :                                     scanValue /= state.dataGlobal->TimeStepZoneSec;
    3792              :                                 }
    3793              :                             }
    3794            0 :                             if (scanValue > oldScanValue) {
    3795            0 :                                 ort->MonthlyColumns(scanColumn).reslt(state.dataEnvrn->Month) = scanValue;
    3796            0 :                                 ort->MonthlyColumns(scanColumn).timeStamp(state.dataEnvrn->Month) = timestepTimeStamp;
    3797              :                             }
    3798            0 :                         } break;
    3799            0 :                         case AggType::MinimumDuringHoursShown: {
    3800            0 :                             if (ort->MonthlyColumns(scanColumn).avgSum == OutputProcessor::StoreType::Sum) { // if it is a summed variable
    3801            0 :                                 if (t_timeStepType == OutputProcessor::TimeStepType::System) {
    3802            0 :                                     scanValue /= TimeStepSysSec;
    3803              :                                 } else {
    3804            0 :                                     scanValue /= state.dataGlobal->TimeStepZoneSec;
    3805              :                                 }
    3806              :                             }
    3807            0 :                             if (scanValue < oldScanValue) {
    3808            0 :                                 ort->MonthlyColumns(scanColumn).reslt(state.dataEnvrn->Month) = scanValue;
    3809            0 :                                 ort->MonthlyColumns(scanColumn).timeStamp(state.dataEnvrn->Month) = timestepTimeStamp;
    3810              :                             }
    3811            0 :                         } break;
    3812            2 :                         default:
    3813            2 :                             break;
    3814              :                         }
    3815           10 :                         activeHoursShown = false; // fixed CR8317
    3816              :                     }
    3817              :                 }
    3818              :             }
    3819              :         }
    3820              :     }
    3821              : }
    3822              : 
    3823           17 : void GatherBEPSResultsForTimestep(EnergyPlusData &state, OutputProcessor::TimeStepType t_timeStepType) // What kind of data to update (Zone, HVAC)
    3824              : {
    3825              :     // SUBROUTINE INFORMATION:
    3826              :     //       AUTHOR         Jason Glazer
    3827              :     //       DATE WRITTEN   November 2003
    3828              :     //       MODIFIED       na
    3829              :     //       RE-ENGINEERED  na
    3830              : 
    3831              :     // PURPOSE OF THIS SUBROUTINE:
    3832              :     //   This routine gathers data for producing the BEPS report
    3833              : 
    3834              :     // METHODOLOGY EMPLOYED:
    3835              :     //   Uses get input structure similar to other objects
    3836              :     //   Meter names are of two forms:
    3837              :     //         <ResourceType>:<name>
    3838              :     //   or
    3839              :     //         <EndUseType>:<ResourceType>
    3840              :     //   For the purposes of this routine, only the facility <name>
    3841              :     //   is used.  Remember that 'Building' is actually the sum of
    3842              :     //   the zones only without system,plant and exterior. The only
    3843              :     //   way to get them all is to use 'facility'
    3844              :     //   The <EndUseType> are:
    3845              :     //          Heating
    3846              :     //          Cooling
    3847              :     //          InteriorLights
    3848              :     //          ExteriorLights
    3849              :     //          InteriorEquipment
    3850              :     //          ExteriorEquipment
    3851              :     //          Fans
    3852              :     //          Pumps
    3853              :     //          HeatRejection
    3854              :     //          Humidifier
    3855              :     //          HeatRecovery
    3856              :     //          Refrigeration
    3857              :     //          Cogeneration
    3858              :     //          WaterSystems
    3859              :     //   The <ResourceType> are:
    3860              :     //          Electricity
    3861              :     //          Gas
    3862              :     //          Gasoline
    3863              :     //          Diesel
    3864              :     //          Coal
    3865              :     //          FuelOilNo1
    3866              :     //          FuelOilNo2
    3867              :     //          Propane
    3868              :     //          Water
    3869              :     //          Steam
    3870              :     //          DistrictCooling
    3871              :     //          DistrictHeatingWater
    3872              :     //          DistrictHeatingSteam
    3873              : 
    3874              :     using DataStringGlobals::CharComma;
    3875              :     using DataStringGlobals::CharSpace;
    3876              :     using DataStringGlobals::CharTab;
    3877              : 
    3878           17 :     auto &ort = state.dataOutRptTab;
    3879              :     // if no beps report is called then skip
    3880              : 
    3881           17 :     if ((ort->displayTabularBEPS || ort->displayLEEDSummary) && (t_timeStepType == OutputProcessor::TimeStepType::Zone)) {
    3882           15 :         auto &op = state.dataOutputProcessor;
    3883              :         // add the current time to the total elapsed time
    3884              :         // FOLLOWING LINE MOVED TO UPDATETABULARREPORTS because used even when beps is not called
    3885              :         // gatherElapsedTimeBEPS = gatherElapsedTimeBEPS + TimeStepZone
    3886              :         // loop through all of the resource types for the entire facility
    3887              :         //  DO iResource = 1, numResourceTypes
    3888              :         //    curMeterNumber = meterNumTotalsBEPS(iResource)
    3889              :         //    IF (curMeterNumber .GT. 0) THEN
    3890              :         //      curMeterValue = GetCurrentMeterValue(curMeterNumber)
    3891              :         //      gatherTotalsBEPS(iResource) = gatherTotalsBEPS(iResource) + curMeterValue
    3892              :         //    END IF
    3893              :         //  END DO
    3894              : 
    3895              :         // loop through all of the resources and end uses for the entire facility
    3896          225 :         for (int iResource = 1; iResource <= numResourceTypes; ++iResource) {
    3897          210 :             int curResMeterNumber = ort->meterNumTotalsBEPS(iResource);
    3898          210 :             if (curResMeterNumber > -1) {
    3899           44 :                 Real64 curResMeterValue = GetCurrentMeterValue(state, curResMeterNumber);
    3900           44 :                 ort->gatherTotalsBEPS(iResource) += curResMeterValue;
    3901              :             }
    3902              : 
    3903         3150 :             for (int jEndUse = 1; jEndUse <= static_cast<int>(Constant::EndUse::Num); ++jEndUse) {
    3904         2940 :                 int curEndUseMeterNumber = ort->meterNumEndUseBEPS(iResource, jEndUse);
    3905         2940 :                 if (curEndUseMeterNumber > -1) {
    3906           44 :                     Real64 curEndUseMeterValue = GetCurrentMeterValue(state, curEndUseMeterNumber);
    3907           44 :                     ort->gatherEndUseBEPS(iResource, jEndUse) += curEndUseMeterValue;
    3908              : 
    3909           97 :                     for (int kEndUseSub = 1; kEndUseSub <= op->EndUseCategory(jEndUse).NumSubcategories; ++kEndUseSub) {
    3910           53 :                         int curSubMeterNumber = ort->meterNumEndUseSubBEPS(kEndUseSub, jEndUse, iResource);
    3911           53 :                         if (curSubMeterNumber > -1) {
    3912           53 :                             Real64 curSubMeterValue = GetCurrentMeterValue(state, curSubMeterNumber);
    3913           53 :                             ort->gatherEndUseSubBEPS(kEndUseSub, jEndUse, iResource) += curSubMeterValue;
    3914              :                         }
    3915              :                     }
    3916           44 :                     for (int kEndUseSpType = 1; kEndUseSpType <= op->EndUseCategory(jEndUse).numSpaceTypes; ++kEndUseSpType) {
    3917            0 :                         int curSpTypeMeterNumber = ort->meterNumEndUseSpTypeBEPS(kEndUseSpType, jEndUse, iResource);
    3918            0 :                         if (curSpTypeMeterNumber > -1) {
    3919            0 :                             Real64 curSpTypeMeterValue = GetCurrentMeterValue(state, curSpTypeMeterNumber);
    3920            0 :                             ort->gatherEndUseSpTypeBEPS(kEndUseSpType, jEndUse, iResource) += curSpTypeMeterValue;
    3921              :                         }
    3922              :                     }
    3923              :                 }
    3924              :             }
    3925              :         }
    3926              : 
    3927          195 :         for (int iResource = 1; iResource <= numSourceTypes; ++iResource) {
    3928          180 :             int curResMeterNumber = ort->meterNumTotalsSource(iResource);
    3929          180 :             if (curResMeterNumber > -1) {
    3930            0 :                 Real64 curResMeterValue = GetCurrentMeterValue(state, curResMeterNumber);
    3931            0 :                 ort->gatherTotalsSource(iResource) += curResMeterValue;
    3932              :             }
    3933              :         }
    3934              : 
    3935              :         // gather the electric load components
    3936           15 :         ort->gatherPowerFuelFireGen += GetCurrentMeterValue(state, ort->meterNumPowerFuelFireGen);
    3937           15 :         ort->gatherPowerPV += GetCurrentMeterValue(state, ort->meterNumPowerPV);
    3938           15 :         ort->gatherPowerWind += GetCurrentMeterValue(state, ort->meterNumPowerWind);
    3939           15 :         ort->gatherPowerHTGeothermal += GetCurrentMeterValue(state, ort->meterNumPowerHTGeothermal);
    3940           15 :         ort->gatherElecProduced += GetCurrentMeterValue(state, ort->meterNumElecProduced);
    3941           15 :         ort->gatherElecPurchased += GetCurrentMeterValue(state, ort->meterNumElecPurchased);
    3942           15 :         ort->gatherElecSurplusSold += GetCurrentMeterValue(state, ort->meterNumElecSurplusSold);
    3943           15 :         ort->gatherElecStorage += GetCurrentMeterValue(state, ort->meterNumElecStorage);
    3944           15 :         ort->gatherPowerConversion += GetCurrentMeterValue(state, ort->meterNumPowerConversion);
    3945              :         // gather the onsite thermal components
    3946           15 :         ort->gatherWaterHeatRecovery += GetCurrentMeterValue(state, ort->meterNumWaterHeatRecovery);
    3947           15 :         ort->gatherAirHeatRecoveryCool += GetCurrentMeterValue(state, ort->meterNumAirHeatRecoveryCool);
    3948           15 :         ort->gatherAirHeatRecoveryHeat += GetCurrentMeterValue(state, ort->meterNumAirHeatRecoveryHeat);
    3949           15 :         ort->gatherHeatHTGeothermal += GetCurrentMeterValue(state, ort->meterNumHeatHTGeothermal);
    3950           15 :         ort->gatherHeatSolarWater += GetCurrentMeterValue(state, ort->meterNumHeatSolarWater);
    3951           15 :         ort->gatherHeatSolarAir += GetCurrentMeterValue(state, ort->meterNumHeatSolarAir);
    3952              :         // gather the water supply components
    3953           15 :         ort->gatherRainWater += GetCurrentMeterValue(state, ort->meterNumRainWater);
    3954           15 :         ort->gatherCondensate += GetCurrentMeterValue(state, ort->meterNumCondensate);
    3955           15 :         ort->gatherWellwater += GetCurrentMeterValue(state, ort->meterNumGroundwater);
    3956           15 :         ort->gatherMains += GetCurrentMeterValue(state, ort->meterNumMains);
    3957           15 :         ort->gatherWaterEndUseTotal += GetCurrentMeterValue(state, ort->meterNumWaterEndUseTotal);
    3958              :     }
    3959           17 : }
    3960              : 
    3961            2 : void GatherSourceEnergyEndUseResultsForTimestep(EnergyPlusData &state,
    3962              :                                                 OutputProcessor::TimeStepType t_timeStepType) // What kind of data to update (Zone, HVAC)
    3963              : {
    3964              :     // SUBROUTINE INFORMATION:
    3965              :     //       AUTHOR         Mangesh Basarkar
    3966              :     //       DATE WRITTEN   September 2011
    3967              :     //       MODIFIED       na
    3968              :     //       RE-ENGINEERED  na
    3969              : 
    3970              :     // PURPOSE OF THIS SUBROUTINE:
    3971              :     //   This routine gathers data for producing the end uses report in source energy
    3972              : 
    3973              :     // METHODOLOGY EMPLOYED:
    3974              :     //   Uses get input structure similar to other objects
    3975              :     //   Meter names are of two forms:
    3976              :     //         <ResourceType>:<name>
    3977              :     //   or
    3978              :     //         <EndUseType>:<ResourceType>
    3979              :     //   The <EndUseType> are:
    3980              :     //          Heating
    3981              :     //          Cooling
    3982              :     //          InteriorLights
    3983              :     //          ExteriorLights
    3984              :     //          InteriorEquipment
    3985              :     //          ExteriorEquipment
    3986              :     //          Fans
    3987              :     //          Pumps
    3988              :     //          HeatRejection
    3989              :     //          Humidifier
    3990              :     //          HeatRecovery
    3991              :     //          Refrigeration
    3992              :     //          Cogeneration
    3993              :     //          WaterSystems
    3994              :     //   The <ResourceType> are:
    3995              :     //          Electricity 1
    3996              :     //          Gas 2
    3997              :     //          Gasoline 6
    3998              :     //          Diesel 8
    3999              :     //          Coal 9
    4000              :     //          FuelOilNo1 10
    4001              :     //          FuelOilNo2 11
    4002              :     //          Propane 12
    4003              :     //          Water 7
    4004              :     //          DistrictCooling 3
    4005              :     //          DistrictHeatingWater 4
    4006              :     //          DistrictHeatingSteam 5
    4007              : 
    4008              :     //          sourceTypeNames(1)='Electric'
    4009              :     //          sourceTypeNames(2)='NaturalGas'
    4010              :     //          sourceTypeNames(3)='Gasoline'
    4011              :     //          sourceTypeNames(4)='Diesel'
    4012              :     //          sourceTypeNames(5)='Coal'
    4013              :     //          sourceTypeNames(6)='FuelOilNo1'
    4014              :     //          sourceTypeNames(7)='FuelOilNo2'
    4015              :     //          sourceTypeNames(8)='Propane'
    4016              :     //          sourceTypeNames(9)='PurchasedElectricity'
    4017              :     //          sourceTypeNames(10)='SoldElectricity'
    4018              :     //          sourceTypeNames(11)='OtherFuel1'
    4019              :     //          sourceTypeNames(12)='OtherFuel2'
    4020              : 
    4021              :     // REFERENCES:
    4022              :     // na
    4023              : 
    4024              :     // Using/Aliasing
    4025              :     using DataStringGlobals::CharComma;
    4026              :     using DataStringGlobals::CharSpace;
    4027              :     using DataStringGlobals::CharTab;
    4028              : 
    4029              :     // Locals
    4030              :     // SUBROUTINE ARGUMENT DEFINITIONS:
    4031              : 
    4032              :     // SUBROUTINE PARAMETER DEFINITIONS:
    4033              :     // na
    4034              : 
    4035              :     // INTERFACE BLOCK SPECIFICATIONS:
    4036              :     // na
    4037              : 
    4038              :     // DERIVED TYPE DEFINITIONS:
    4039              :     // na
    4040              : 
    4041              :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
    4042            2 :     auto &ort = state.dataOutRptTab;
    4043              : 
    4044              :     // if no beps by source report is called then skip
    4045              : 
    4046            2 :     if ((ort->displaySourceEnergyEndUseSummary) && (t_timeStepType == OutputProcessor::TimeStepType::Zone)) {
    4047              :         // loop through all of the resources and end uses for the entire facility
    4048            0 :         for (int iResource = 1; iResource <= numResourceTypes; ++iResource) {
    4049              : 
    4050            0 :             if (ort->ffSchedUsed(iResource)) {
    4051            0 :                 int const curMeterNumber = ort->meterNumTotalsBEPS(iResource);
    4052            0 :                 if (curMeterNumber > -1) {
    4053              :                     Real64 const curMeterValue =
    4054            0 :                         GetCurrentMeterValue(state, curMeterNumber) * ort->ffScheds(iResource)->getCurrentVal() * ort->SourceFactors(iResource);
    4055            0 :                     ort->gatherTotalsBySourceBEPS(iResource) += curMeterValue;
    4056              :                 }
    4057              :             } else {
    4058            0 :                 int const curMeterNumber = ort->meterNumTotalsBEPS(iResource);
    4059            0 :                 if (curMeterNumber > -1) {
    4060            0 :                     Real64 const curMeterValue = GetCurrentMeterValue(state, curMeterNumber) * ort->SourceFactors(iResource);
    4061            0 :                     ort->gatherTotalsBySourceBEPS(iResource) += curMeterValue;
    4062              :                 }
    4063              :             }
    4064              : 
    4065            0 :             for (int jEndUse = 1; jEndUse <= static_cast<int>(Constant::EndUse::Num); ++jEndUse) {
    4066            0 :                 if (ort->ffSchedUsed(iResource)) {
    4067            0 :                     int const curMeterNumber = ort->meterNumEndUseBEPS(iResource, jEndUse);
    4068            0 :                     if (curMeterNumber > -1) {
    4069              :                         Real64 const curMeterValue =
    4070            0 :                             GetCurrentMeterValue(state, curMeterNumber) * ort->ffScheds(iResource)->getCurrentVal() * ort->SourceFactors(iResource);
    4071            0 :                         ort->gatherEndUseBySourceBEPS(iResource, jEndUse) += curMeterValue;
    4072              :                     }
    4073              :                 } else {
    4074            0 :                     int const curMeterNumber = ort->meterNumEndUseBEPS(iResource, jEndUse);
    4075            0 :                     if (curMeterNumber > -1) {
    4076            0 :                         Real64 const curMeterValue = GetCurrentMeterValue(state, curMeterNumber) * ort->SourceFactors(iResource);
    4077            0 :                         ort->gatherEndUseBySourceBEPS(iResource, jEndUse) += curMeterValue;
    4078              :                     }
    4079              :                 }
    4080              :             }
    4081              :         }
    4082              :     }
    4083            2 : }
    4084              : 
    4085           17 : void GatherPeakDemandForTimestep(EnergyPlusData &state, OutputProcessor::TimeStepType t_timeStepType) // What kind of data to update (Zone, HVAC)
    4086              : {
    4087              :     // SUBROUTINE INFORMATION:
    4088              :     //       AUTHOR         Jason Glazer
    4089              :     //       DATE WRITTEN   January 2009
    4090              :     //       MODIFIED       na
    4091              :     //       RE-ENGINEERED  na
    4092              : 
    4093              :     // PURPOSE OF THIS SUBROUTINE:
    4094              :     //   This routine gathers data for producing the Peak Demand
    4095              :     //   by end-use report
    4096              : 
    4097              :     // METHODOLOGY EMPLOYED:
    4098              :     //   Uses get input structure similar to other objects
    4099              :     //   Meter names are of two forms:
    4100              :     //         <ResourceType>:<name>
    4101              :     //   or
    4102              :     //         <EndUseType>:<ResourceType>
    4103              :     //   For the purposes of this routine, only the facility <name>
    4104              :     //   is used.  Remember that 'Building' is actually the sum of
    4105              :     //   the zones only without system,plant and exterior. The only
    4106              :     //   way to get them all is to use 'facility'
    4107              :     //   The <EndUseType> are:
    4108              :     //          Heating
    4109              :     //          Cooling
    4110              :     //          InteriorLights
    4111              :     //          ExteriorLights
    4112              :     //          InteriorEquipment
    4113              :     //          ExteriorEquipment
    4114              :     //          Fans
    4115              :     //          Pumps
    4116              :     //          HeatRejection
    4117              :     //          Humidifier
    4118              :     //          HeatRecovery
    4119              :     //          Refrigeration
    4120              :     //          Cogeneration
    4121              :     //          WaterSystems
    4122              :     //   The <ResourceType> are:
    4123              :     //          Electricity
    4124              :     //          Gas
    4125              :     //          Gasoline
    4126              :     //          Diesel
    4127              :     //          Coal
    4128              :     //          FuelOilNo1
    4129              :     //          FuelOilNo2
    4130              :     //          Propane
    4131              :     //          Water
    4132              :     //          DistrictCooling
    4133              :     //          DistrictHeatingWater
    4134              :     //          DistrictHeatingSteam
    4135              : 
    4136              :     // REFERENCES:
    4137              :     // na
    4138              : 
    4139              :     // Using/Aliasing
    4140              :     using DataStringGlobals::CharComma;
    4141              :     using DataStringGlobals::CharSpace;
    4142              :     using DataStringGlobals::CharTab;
    4143              :     using General::EncodeMonDayHrMin;
    4144              : 
    4145              :     // Locals
    4146              :     // SUBROUTINE ARGUMENT DEFINITIONS:
    4147              : 
    4148              :     // SUBROUTINE PARAMETER DEFINITIONS:
    4149              :     // na
    4150              : 
    4151              :     // INTERFACE BLOCK SPECIFICATIONS:
    4152              :     // na
    4153              : 
    4154              :     // DERIVED TYPE DEFINITIONS:
    4155              :     // na
    4156              : 
    4157              :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
    4158           17 :     assert(state.dataGlobal->TimeStepZoneSec > 0.0);
    4159           17 :     auto &ort = state.dataOutRptTab;
    4160           17 :     auto &op = state.dataOutputProcessor;
    4161              : 
    4162           17 :     if ((ort->displayDemandEndUse) && (t_timeStepType == OutputProcessor::TimeStepType::Zone)) {
    4163              :         // loop through all of the resources and end uses for the entire facility
    4164          225 :         for (int iResource = 1; iResource <= numResourceTypes; ++iResource) {
    4165          210 :             int curMeterNumber = ort->meterNumTotalsBEPS(iResource);
    4166          210 :             if (curMeterNumber > -1) {
    4167           44 :                 Real64 curDemandValue = GetCurrentMeterValue(state, curMeterNumber) / state.dataGlobal->TimeStepZoneSec;
    4168              :                 // check if current value is greater than existing peak demand value
    4169           44 :                 if (curDemandValue > ort->gatherDemandTotal(iResource)) {
    4170           17 :                     ort->gatherDemandTotal(iResource) = curDemandValue;
    4171              :                     // save the time that the peak demand occurred
    4172              :                     //        minuteCalculated = (CurrentTime - INT(CurrentTime))*60
    4173           17 :                     int const minuteCalculated = OutputProcessor::DetermineMinuteForReporting(state);
    4174              :                     int timestepTimeStamp;
    4175           17 :                     EncodeMonDayHrMin(
    4176           17 :                         timestepTimeStamp, state.dataEnvrn->Month, state.dataEnvrn->DayOfMonth, state.dataGlobal->HourOfDay, minuteCalculated);
    4177           17 :                     ort->gatherDemandTimeStamp(iResource) = timestepTimeStamp;
    4178              :                     // if new peak demand is set, then gather all of the end use values at this particular
    4179              :                     // time to find the components of the peak demand
    4180          255 :                     for (int jEndUse = 1; jEndUse <= static_cast<int>(Constant::EndUse::Num); ++jEndUse) {
    4181          238 :                         curMeterNumber = ort->meterNumEndUseBEPS(iResource, jEndUse);
    4182          238 :                         if (curMeterNumber > -1) {
    4183           17 :                             curDemandValue = GetCurrentMeterValue(state, curMeterNumber) / state.dataGlobal->TimeStepZoneSec;
    4184           17 :                             ort->gatherDemandEndUse(iResource, jEndUse) = curDemandValue;
    4185           37 :                             for (int kEndUseSub = 1; kEndUseSub <= op->EndUseCategory(jEndUse).NumSubcategories; ++kEndUseSub) {
    4186           20 :                                 curMeterNumber = ort->meterNumEndUseSubBEPS(kEndUseSub, jEndUse, iResource);
    4187           20 :                                 if (curMeterNumber > -1) {
    4188           20 :                                     curDemandValue = GetCurrentMeterValue(state, curMeterNumber) / state.dataGlobal->TimeStepZoneSec;
    4189           20 :                                     ort->gatherDemandEndUseSub(kEndUseSub, jEndUse, iResource) = curDemandValue;
    4190              :                                 }
    4191              :                             }
    4192              :                         }
    4193              :                     }
    4194              :                 }
    4195              :             }
    4196              :         }
    4197              :     }
    4198              : 
    4199              :     // gather the peak demands of each individual enduse subcategory for the LEED report
    4200           17 :     if ((ort->displayLEEDSummary) && (t_timeStepType == OutputProcessor::TimeStepType::Zone)) {
    4201              :         // loop through all of the resources and end uses for the entire facility
    4202          225 :         for (int iResource = 1; iResource <= numResourceTypes; ++iResource) {
    4203         3150 :             for (int jEndUse = 1; jEndUse <= static_cast<int>(Constant::EndUse::Num); ++jEndUse) {
    4204         2940 :                 int curMeterNumber = ort->meterNumEndUseBEPS(iResource, jEndUse);
    4205         2940 :                 if (curMeterNumber > -1) {
    4206           44 :                     Real64 curDemandValue = GetCurrentMeterValue(state, curMeterNumber) / state.dataGlobal->TimeStepZoneSec;
    4207           44 :                     if (curDemandValue > ort->gatherDemandIndEndUse(iResource, jEndUse)) {
    4208           17 :                         ort->gatherDemandIndEndUse(iResource, jEndUse) = curDemandValue;
    4209              :                     }
    4210           97 :                     for (int kEndUseSub = 1; kEndUseSub <= op->EndUseCategory(jEndUse).NumSubcategories; ++kEndUseSub) {
    4211           53 :                         curMeterNumber = ort->meterNumEndUseSubBEPS(kEndUseSub, jEndUse, iResource);
    4212           53 :                         if (curMeterNumber > -1) {
    4213           53 :                             curDemandValue = GetCurrentMeterValue(state, curMeterNumber) / state.dataGlobal->TimeStepZoneSec;
    4214              :                             // check if current value is greater than existing peak demand value
    4215           53 :                             if (curDemandValue > ort->gatherDemandIndEndUseSub(kEndUseSub, jEndUse, iResource)) {
    4216           20 :                                 ort->gatherDemandIndEndUseSub(kEndUseSub, jEndUse, iResource) = curDemandValue;
    4217              :                             }
    4218              :                         }
    4219              :                     }
    4220              :                 }
    4221              :             }
    4222              :         }
    4223              :     }
    4224           17 : }
    4225              : 
    4226            5 : void GatherHeatEmissionReport(EnergyPlusData &state, OutputProcessor::TimeStepType t_timeStepType)
    4227              : {
    4228              :     // PURPOSE OF THIS SUBROUTINE:
    4229              :     // Gathers the data each zone timestep for the heat gain report.
    4230              :     // The routine generates an annual table with the following columns which correspond to
    4231              :     // the output variables and data structures shown.
    4232              : 
    4233            5 :     state.dataHeatBal->SysTotalHVACReliefHeatLoss = 0;
    4234            5 :     state.dataHeatBal->SysTotalHVACRejectHeatLoss = 0;
    4235            5 :     auto const &ort = state.dataOutRptTab;
    4236              : 
    4237            5 :     if (!ort->displayHeatEmissionsSummary) {
    4238            0 :         return; // don't gather data if report isn't requested
    4239              :     }
    4240              : 
    4241              :     // Only gather zone report at zone time steps
    4242            5 :     if (t_timeStepType == OutputProcessor::TimeStepType::Zone) {
    4243            0 :         state.dataHeatBal->BuildingPreDefRep.emiEnvelopConv += state.dataHeatBalSurf->SumSurfaceHeatEmission * Constant::convertJtoGJ;
    4244            0 :         return;
    4245              :     }
    4246              : 
    4247            5 :     CalcHeatEmissionReport(state);
    4248            5 :     state.dataHeatBal->BuildingPreDefRep.emiZoneExfiltration += state.dataHeatBal->ZoneTotalExfiltrationHeatLoss * Constant::convertJtoGJ;
    4249            5 :     state.dataHeatBal->BuildingPreDefRep.emiZoneExhaust += state.dataHeatBal->ZoneTotalExhaustHeatLoss * Constant::convertJtoGJ;
    4250            5 :     state.dataHeatBal->BuildingPreDefRep.emiHVACRelief += state.dataHeatBal->SysTotalHVACReliefHeatLoss * Constant::convertJtoGJ;
    4251            5 :     state.dataHeatBal->BuildingPreDefRep.emiHVACReject += state.dataHeatBal->SysTotalHVACRejectHeatLoss * Constant::convertJtoGJ;
    4252              : 
    4253            5 :     state.dataHeatBal->BuildingPreDefRep.emiTotHeat =
    4254            5 :         state.dataHeatBal->BuildingPreDefRep.emiEnvelopConv + state.dataHeatBal->BuildingPreDefRep.emiZoneExfiltration +
    4255            5 :         state.dataHeatBal->BuildingPreDefRep.emiZoneExhaust + state.dataHeatBal->BuildingPreDefRep.emiHVACRelief +
    4256            5 :         state.dataHeatBal->BuildingPreDefRep.emiHVACReject;
    4257              : }
    4258              : 
    4259        71337 : void CalcHeatEmissionReport(EnergyPlusData &state)
    4260              : {
    4261              :     // PURPOSE OF THIS SUBROUTINE:
    4262              :     // Gathers the data each zone timestep for the heat gain report.
    4263              :     // The routine generates an annual table with the following columns which correspond to
    4264              :     // the output variables and data structures shown.
    4265              : 
    4266              :     // Using/Aliasing
    4267        71337 :     Real64 const TimeStepSysSec = state.dataHVACGlobal->TimeStepSysSec;
    4268              : 
    4269        71337 :     Real64 H2OHtOfVap_HVAC = Psychrometrics::PsyHgAirFnWTdb(state.dataEnvrn->OutHumRat, state.dataEnvrn->OutDryBulbTemp);
    4270        71337 :     Real64 RhoWater = Psychrometrics::RhoH2O(state.dataEnvrn->OutDryBulbTemp);
    4271              : 
    4272        71337 :     state.dataHeatBal->SysTotalHVACReliefHeatLoss = 0;
    4273        71337 :     state.dataHeatBal->SysTotalHVACRejectHeatLoss = 0;
    4274              : 
    4275              :     // HVAC relief air
    4276        73682 :     for (int iOACtrl = 1; iOACtrl <= state.dataMixedAir->NumOAControllers; ++iOACtrl) {
    4277         2345 :         state.dataHeatBal->SysTotalHVACReliefHeatLoss += state.dataMixedAir->OAController(iOACtrl).RelTotalLossRate * TimeStepSysSec;
    4278              :     }
    4279              : 
    4280              :     // Airloop HVAC Exhaust System
    4281        71337 :     for (int iExhSys = 1; iExhSys < state.dataZoneEquip->NumExhaustAirSystems; ++iExhSys) {
    4282            0 :         state.dataHeatBal->SysTotalHVACReliefHeatLoss += state.dataZoneEquip->ExhaustAirSystem(iExhSys).exhTotalHVACReliefHeatLoss;
    4283              :     }
    4284              : 
    4285              :     // Condenser water loop
    4286        71340 :     for (int iCooler = 1; iCooler <= (int)state.dataCondenserLoopTowers->towers.size(); ++iCooler) {
    4287            6 :         state.dataHeatBal->SysTotalHVACRejectHeatLoss += state.dataCondenserLoopTowers->towers(iCooler).Qactual * TimeStepSysSec +
    4288            3 :                                                          state.dataCondenserLoopTowers->towers(iCooler).FanEnergy +
    4289            3 :                                                          state.dataCondenserLoopTowers->towers(iCooler).BasinHeaterConsumption;
    4290              :     }
    4291        71337 :     for (auto const &thisCooler : state.dataEvapFluidCoolers->SimpleEvapFluidCooler) {
    4292            0 :         state.dataHeatBal->SysTotalHVACRejectHeatLoss += thisCooler.Qactual * TimeStepSysSec + thisCooler.FanEnergy;
    4293              :     }
    4294        71337 :     for (auto const &cooler : state.dataFluidCoolers->SimpleFluidCooler) {
    4295            0 :         state.dataHeatBal->SysTotalHVACRejectHeatLoss += cooler.Qactual * TimeStepSysSec + cooler.FanEnergy;
    4296              :     }
    4297              : 
    4298              :     // Air- and Evap-cooled chiller
    4299        71337 :     for (int iChiller = 1; iChiller <= state.dataPlantChillers->NumElectricChillers; ++iChiller) {
    4300            0 :         auto const &thisChiller = state.dataPlantChillers->ElectricChiller(iChiller);
    4301              : 
    4302            0 :         if (thisChiller.CondenserType != DataPlant::CondenserType::WaterCooled) {
    4303            0 :             state.dataHeatBal->SysTotalHVACRejectHeatLoss += thisChiller.CondenserEnergy;
    4304              :         }
    4305              :     }
    4306        71337 :     for (int iChiller = 1; iChiller <= state.dataPlantChillers->NumEngineDrivenChillers; ++iChiller) {
    4307            0 :         auto const &thisChiller = state.dataPlantChillers->EngineDrivenChiller(iChiller);
    4308              : 
    4309            0 :         if (thisChiller.CondenserType != DataPlant::CondenserType::WaterCooled) {
    4310            0 :             state.dataHeatBal->SysTotalHVACRejectHeatLoss += thisChiller.CondenserEnergy;
    4311              :         }
    4312              :     }
    4313        71337 :     for (int iChiller = 1; iChiller <= state.dataPlantChillers->NumGTChillers; ++iChiller) {
    4314            0 :         auto const &thisChiller = state.dataPlantChillers->GTChiller(iChiller);
    4315              : 
    4316            0 :         if (thisChiller.CondenserType != DataPlant::CondenserType::WaterCooled) {
    4317            0 :             state.dataHeatBal->SysTotalHVACRejectHeatLoss += thisChiller.CondenserEnergy;
    4318              :         }
    4319              :     }
    4320        71337 :     for (int iChiller = 1; iChiller <= state.dataPlantChillers->NumConstCOPChillers; ++iChiller) {
    4321            0 :         auto const &thisChiller = state.dataPlantChillers->ConstCOPChiller(iChiller);
    4322              : 
    4323            0 :         if (thisChiller.CondenserType != DataPlant::CondenserType::WaterCooled) {
    4324            0 :             state.dataHeatBal->SysTotalHVACRejectHeatLoss += thisChiller.CondenserEnergy;
    4325              :         }
    4326              :     }
    4327              : 
    4328        71337 :     for (int iChiller = 1; iChiller <= (int)state.dataChillerElectricEIR->ElectricEIRChiller.size(); ++iChiller) {
    4329            0 :         auto const &thisChiller = state.dataChillerElectricEIR->ElectricEIRChiller(iChiller);
    4330              : 
    4331            0 :         if (thisChiller.CondenserType != DataPlant::CondenserType::WaterCooled) {
    4332            0 :             state.dataHeatBal->SysTotalHVACRejectHeatLoss += thisChiller.CondEnergy;
    4333              :         }
    4334              :     }
    4335        71337 :     for (int iChiller = 1; iChiller <= (int)state.dataChillerReformulatedEIR->ElecReformEIRChiller.size(); ++iChiller) {
    4336            0 :         auto const &thisChiller = state.dataChillerReformulatedEIR->ElecReformEIRChiller(iChiller);
    4337              : 
    4338            0 :         if (thisChiller.CondenserType != DataPlant::CondenserType::WaterCooled) {
    4339            0 :             state.dataHeatBal->SysTotalHVACRejectHeatLoss += thisChiller.CondEnergy;
    4340              :         }
    4341              :     }
    4342              : 
    4343              :     // Water / steam boiler
    4344        71337 :     for (int iBoiler = 1; iBoiler <= (int)state.dataBoilers->Boiler.size(); ++iBoiler) {
    4345            0 :         state.dataHeatBal->SysTotalHVACRejectHeatLoss +=
    4346            0 :             state.dataBoilers->Boiler(iBoiler).FuelConsumed + state.dataBoilers->Boiler(iBoiler).ParasiticFuelConsumption +
    4347            0 :             state.dataBoilers->Boiler(iBoiler).ParasiticElecConsumption - state.dataBoilers->Boiler(iBoiler).BoilerEnergy;
    4348              :     }
    4349              : 
    4350              :     // DX Coils air to air
    4351        75260 :     for (int iCoil = 1; iCoil <= state.dataDXCoils->NumDXCoils; ++iCoil) {
    4352         3923 :         auto const &thisDXCoil = state.dataDXCoils->DXCoil(iCoil);
    4353              : 
    4354         3923 :         if (thisDXCoil.DXCoilType_Num == HVAC::CoilDX_CoolingSingleSpeed || thisDXCoil.DXCoilType_Num == HVAC::CoilDX_CoolingTwoSpeed ||
    4355            4 :             thisDXCoil.DXCoilType_Num == HVAC::CoilDX_MultiSpeedCooling || thisDXCoil.DXCoilType_Num == HVAC::CoilDX_CoolingTwoStageWHumControl) {
    4356         3921 :             if (thisDXCoil.CondenserType(1) == DataHeatBalance::RefrigCondenserType::Air) {
    4357         3147 :                 state.dataHeatBal->SysTotalHVACRejectHeatLoss += thisDXCoil.ElecCoolingConsumption + thisDXCoil.DefrostConsumption +
    4358         3147 :                                                                  thisDXCoil.CrankcaseHeaterConsumption + thisDXCoil.TotalCoolingEnergy;
    4359          774 :             } else if (thisDXCoil.CondenserType(1) == DataHeatBalance::RefrigCondenserType::Evap) {
    4360          774 :                 state.dataHeatBal->SysTotalHVACRejectHeatLoss += thisDXCoil.EvapCondPumpElecConsumption + thisDXCoil.BasinHeaterConsumption +
    4361          774 :                                                                  thisDXCoil.EvapWaterConsump * RhoWater * H2OHtOfVap_HVAC;
    4362              :             }
    4363         3921 :             if (thisDXCoil.FuelType != Constant::eFuel::Electricity) {
    4364         3921 :                 state.dataHeatBal->SysTotalHVACRejectHeatLoss += thisDXCoil.MSFuelWasteHeat * TimeStepSysSec;
    4365              :             }
    4366            2 :         } else if (thisDXCoil.DXCoilType_Num == HVAC::CoilDX_HeatingEmpirical || thisDXCoil.DXCoilType_Num == HVAC::CoilDX_MultiSpeedHeating) {
    4367            2 :             state.dataHeatBal->SysTotalHVACRejectHeatLoss += thisDXCoil.ElecHeatingConsumption + thisDXCoil.DefrostConsumption +
    4368            2 :                                                              thisDXCoil.FuelConsumed + thisDXCoil.CrankcaseHeaterConsumption -
    4369            2 :                                                              thisDXCoil.TotalHeatingEnergy;
    4370              :         }
    4371              :     }
    4372              :     // VAV coils - air to air
    4373        71337 :     for (int iCoil = 1; iCoil <= state.dataVariableSpeedCoils->NumVarSpeedCoils; ++iCoil) {
    4374            0 :         auto const &thisCoil = state.dataVariableSpeedCoils->VarSpeedCoil(iCoil);
    4375              : 
    4376            0 :         if (thisCoil.VSCoilType == HVAC::Coil_CoolingAirToAirVariableSpeed) {
    4377            0 :             if (thisCoil.CondenserType == DataHeatBalance::RefrigCondenserType::Air) {
    4378            0 :                 state.dataHeatBal->SysTotalHVACRejectHeatLoss +=
    4379            0 :                     thisCoil.Energy + thisCoil.CrankcaseHeaterConsumption + thisCoil.DefrostConsumption + thisCoil.EnergyLoadTotal;
    4380            0 :             } else if (thisCoil.CondenserType == DataHeatBalance::RefrigCondenserType::Evap) {
    4381            0 :                 state.dataHeatBal->SysTotalHVACRejectHeatLoss +=
    4382            0 :                     thisCoil.EvapCondPumpElecConsumption + thisCoil.BasinHeaterConsumption + thisCoil.EvapWaterConsump * RhoWater * H2OHtOfVap_HVAC;
    4383              :             }
    4384            0 :         } else if (thisCoil.VSCoilType == HVAC::Coil_HeatingAirToAirVariableSpeed) {
    4385            0 :             state.dataHeatBal->SysTotalHVACRejectHeatLoss +=
    4386            0 :                 thisCoil.Energy + thisCoil.CrankcaseHeaterConsumption + thisCoil.DefrostConsumption - thisCoil.EnergyLoadTotal;
    4387              :         }
    4388              :     }
    4389              : 
    4390              :     // Heating coils - fuel
    4391        73676 :     for (int iCoil = 1; iCoil <= state.dataHeatingCoils->NumHeatingCoils; ++iCoil) {
    4392         2339 :         auto const &thisCoil = state.dataHeatingCoils->HeatingCoil(iCoil);
    4393              : 
    4394         2339 :         if (thisCoil.HCoilType_Num == HVAC::Coil_HeatingGas_MultiStage || thisCoil.HCoilType_Num == HVAC::Coil_HeatingGasOrOtherFuel) {
    4395          774 :             state.dataHeatBal->SysTotalHVACRejectHeatLoss += thisCoil.FuelUseLoad + thisCoil.ParasiticFuelConsumption - thisCoil.HeatingCoilLoad;
    4396              :         }
    4397              :     }
    4398              : 
    4399              :     // Packaged TES
    4400        71337 :     for (int iCoil = 1; iCoil <= state.dataPackagedThermalStorageCoil->NumTESCoils; ++iCoil) {
    4401            0 :         auto const &thisCoil = state.dataPackagedThermalStorageCoil->TESCoil(iCoil);
    4402              : 
    4403            0 :         if (thisCoil.CondenserType == PackagedThermalStorageCoil::TESCondenserType::Air) {
    4404            0 :             state.dataHeatBal->SysTotalHVACRejectHeatLoss +=
    4405            0 :                 thisCoil.EvapTotCoolingEnergy + thisCoil.ElecCoolingEnergy + thisCoil.ElectColdWeatherEnergy - thisCoil.Q_Ambient;
    4406            0 :         } else if (thisCoil.CondenserType == PackagedThermalStorageCoil::TESCondenserType::Evap) {
    4407            0 :             state.dataHeatBal->SysTotalHVACRejectHeatLoss += thisCoil.EvapCondPumpElecConsumption + thisCoil.ElectEvapCondBasinHeaterEnergy +
    4408            0 :                                                              thisCoil.EvapWaterConsump * RhoWater * H2OHtOfVap_HVAC - thisCoil.Q_Ambient;
    4409              :         }
    4410              :     }
    4411              : 
    4412              :     // Water heater and thermal storage
    4413        71337 :     for (int iTank = 1; iTank <= state.dataWaterThermalTanks->numWaterThermalTank; ++iTank) {
    4414            0 :         auto const &thisTank = state.dataWaterThermalTanks->WaterThermalTank(iTank);
    4415              : 
    4416            0 :         if (thisTank.AmbientTempIndicator == WaterThermalTanks::WTTAmbientTemp::OutsideAir) {
    4417            0 :             state.dataHeatBal->SysTotalHVACRejectHeatLoss += thisTank.FuelEnergy - thisTank.TotalDemandEnergy;
    4418              :         }
    4419              :     }
    4420              : 
    4421              :     // Variable Refrigerant Flow
    4422        71337 :     for (int iCoil = 1; iCoil <= state.dataHVACVarRefFlow->NumVRFCond; ++iCoil) {
    4423            0 :         auto const &thisVRF = state.dataHVACVarRefFlow->VRF(iCoil);
    4424              : 
    4425            0 :         if (thisVRF.CondenserType == DataHeatBalance::RefrigCondenserType::Air) {
    4426            0 :             state.dataHeatBal->SysTotalHVACRejectHeatLoss += thisVRF.CoolElecConsumption + thisVRF.HeatElecConsumption +
    4427            0 :                                                              thisVRF.CrankCaseHeaterElecConsumption + thisVRF.DefrostConsumption +
    4428            0 :                                                              (thisVRF.TotalCoolingCapacity - thisVRF.TotalHeatingCapacity) * TimeStepSysSec;
    4429            0 :         } else if (thisVRF.CondenserType == DataHeatBalance::RefrigCondenserType::Evap) {
    4430            0 :             state.dataHeatBal->SysTotalHVACRejectHeatLoss += thisVRF.EvapCondPumpElecConsumption + thisVRF.BasinHeaterConsumption +
    4431            0 :                                                              thisVRF.EvapWaterConsumpRate * TimeStepSysSec * RhoWater * H2OHtOfVap_HVAC;
    4432            0 :         } else if (thisVRF.CondenserType == DataHeatBalance::RefrigCondenserType::Water) {
    4433            0 :             state.dataHeatBal->SysTotalHVACRejectHeatLoss += thisVRF.QCondEnergy;
    4434              :         }
    4435              :     }
    4436              : 
    4437              :     // Refrigerated Rack
    4438        71337 :     for (int iRef = 1; iRef <= state.dataRefrigCase->NumRefrigeratedRacks; ++iRef) {
    4439            0 :         auto const &thisRack = state.dataRefrigCase->RefrigRack(iRef);
    4440              : 
    4441            0 :         if (thisRack.CondenserType == DataHeatBalance::RefrigCondenserType::Air) {
    4442            0 :             state.dataHeatBal->SysTotalHVACRejectHeatLoss += thisRack.RackElecConsumption + thisRack.RackCoolingEnergy;
    4443            0 :         } else if (thisRack.CondenserType == DataHeatBalance::RefrigCondenserType::Evap) {
    4444            0 :             state.dataHeatBal->SysTotalHVACRejectHeatLoss +=
    4445            0 :                 thisRack.EvapPumpConsumption + thisRack.BasinHeaterConsumption + thisRack.EvapWaterConsumption * RhoWater * H2OHtOfVap_HVAC;
    4446            0 :         } else if (thisRack.CondenserType == DataHeatBalance::RefrigCondenserType::Water) {
    4447            0 :             state.dataHeatBal->SysTotalHVACRejectHeatLoss += thisRack.CondEnergy;
    4448              :         }
    4449              :     }
    4450              : 
    4451              :     // Refrigerated Case - Condenser
    4452        71337 :     for (int iRef = 1; iRef <= state.dataRefrigCase->NumRefrigCondensers; ++iRef) {
    4453            0 :         state.dataHeatBal->SysTotalHVACRejectHeatLoss += state.dataRefrigCase->Condenser(iRef).CondEnergy;
    4454              :     }
    4455              : 
    4456              :     // Evaporative coolers
    4457        71337 :     for (int iCooler = 1; iCooler <= state.dataEvapCoolers->NumEvapCool; ++iCooler) {
    4458            0 :         auto const &thisCooler = state.dataEvapCoolers->EvapCond(iCooler);
    4459              : 
    4460            0 :         state.dataHeatBal->SysTotalHVACRejectHeatLoss += thisCooler.EvapWaterConsump * RhoWater * H2OHtOfVap_HVAC + thisCooler.EvapCoolerEnergy;
    4461              :     }
    4462        71337 : }
    4463              : 
    4464            3 : void GatherHeatGainReport(EnergyPlusData &state, OutputProcessor::TimeStepType t_timeStepType) // What kind of data to update (Zone, HVAC)
    4465              : {
    4466              :     // SUBROUTINE INFORMATION:
    4467              :     //       AUTHOR         Jason Glazer
    4468              :     //       DATE WRITTEN   August 2011
    4469              :     //       MODIFIED       na
    4470              :     //       RE-ENGINEERED  na
    4471              : 
    4472              :     // PURPOSE OF THIS SUBROUTINE:
    4473              :     //   Gathers the data each zone timestep for the heat gain report.
    4474              :     // The routine generates an annual table with the following columns which correspond to
    4475              :     // the output variables and data structures shown:
    4476              :     // Column                               Output Variable                                Internal Data Structure      Timestep Type
    4477              :     // ------                               ---------------                                -----------------------      -------- -----
    4478              :     // HVAC Input Sensible Air Heating      Zone Air Heat Balance System Air Transfer Rate ZnAirRpt()%SumMCpDTsystem    HVAC     Rate
    4479              :     //                                   Zone Air Heat Balance System Convective Heat Gain Rate ZnAirRpt()%SumNonAirSystem HVAC   Rate
    4480              :     // HVAC Input Sensible Air Cooling      Zone Air Heat Balance System Air Transfer Rate ZnAirRpt()%SumMCpDTsystem    HVAC     Rate
    4481              :     // HVAC sensible heating by ATU         sensible heating by the air terminal unit                                   HVAC     Rate
    4482              :     // HVAC sensible cooling by ATU         sensible cooling by the air terminal unit                                   HVAC     Rate
    4483              :     //                                    Zone Air Heat Balance System Convective Heat Gain Rate ZnAirRpt()%SumNonAirSystem HVAC  Rate
    4484              :     // HVAC Input Heated Surface Heating    Electric Low Temp Radiant Heating Energy       ElecRadSys()%HeatEnergy      HVAC     Energy
    4485              :     //                                      Zone Ventilated Slab Radiant Heating Energy    VentSlab()%RadHeatingEnergy  HVAC     Energy
    4486              :     //                                      Hydronic Low Temp Radiant Heating Energy       HydrRadSys()%HeatEnergy      HVAC     Energy
    4487              :     //                                      Constant Flow Low Temp Radiant Heating Energy  CFloRadSys()%HeatEnergy      HVAC     Energy
    4488              :     // HVAC Input Cooled Surface Cooling    Zone Ventilated Slab Radiant Cooling Energy    -VentSlab()%RadCoolingEnergy HVAC     Energy
    4489              :     //                                      Hydronic Low Temp Radiant Cooling Energy       -HydrRadSys()%CoolEnergy     HVAC     Energy
    4490              :     //                                      Constant Flow Low Temp Radiant Cooling Energy  -CFloRadSys()%CoolEnergy     HVAC     Energy
    4491              :     // People Sensible Heat Addition        Zone People Sensible Heating Energy            ZoneRpt()%PeopleSenGain        Zone     Energy
    4492              :     // Lights Sensible Heat Addition        Zone Lights Total Heating Energy               ZoneRpt()%LtsTotGain           Zone     Energy
    4493              :     // Equipment Sensible Heat Addition     Zone Electric Equipment Radiant Heating Energy ZoneRpt()%ElecRadGain          Zone     Energy
    4494              :     //                                      Zone Gas Equipment Radiant Heating Energy      ZoneRpt()%GasRadGain           Zone     Energy
    4495              :     //                                      Zone Steam Equipment Radiant Heating Energy    ZoneRpt()%SteamRadGain         Zone     Energy
    4496              :     //                                      Zone Hot Water Equipment Radiant Heating Energy ZoneRpt()%HWRadGain           Zone     Energy
    4497              :     //                                      Zone Other Equipment Radiant Heating Energy    ZoneRpt()%OtherRadGain         Zone     Energy
    4498              :     //                                   Zone Electric Equipment Convective Heating Energy ZoneRpt()%ElecConGain          Zone     Energy
    4499              :     //                                      Zone Gas Equipment Convective Heating Energy   ZoneRpt()%GasConGain           Zone     Energy
    4500              :     //                                      Zone Steam Equipment Convective Heating Energy ZoneRpt()%SteamConGain         Zone     Energy
    4501              :     //                                    Zone Hot Water Equipment Convective Heating Energy ZoneRpt()%HWConGain          Zone     Energy
    4502              :     //                                      Zone Other Equipment Convective Heating Energy ZoneRpt()%OtherConGain         Zone     Energy
    4503              :     // Window Heat Addition                 Zone Windows Total Heat Gain Energy            ZoneWinHeatGainRepEnergy()   Zone     Energy
    4504              :     // Interzone Air Transfer Heat Addition Zone Air Heat Balance Interzone Air Transfer Rate  ZnAirRpt()%SumMCpDTzones HVAC     Rate
    4505              :     // Infiltration Heat Addition           Zone Air Heat Balance Outdoor Air Transfer Rate ZnAirRpt()%SumMCpDtInfil     HVAC     Rate
    4506              :     // Equipment Sensible Heat Removal      Zone Electric Equipment Radiant Heating Energy ZoneRpt()%ElecRadGain          Zone     Energy
    4507              :     //                                      Zone Gas Equipment Radiant Heating Energy      ZoneRpt()%GasRadGain           Zone     Energy
    4508              :     //                                      Zone Steam Equipment Radiant Heating Energy    ZoneRpt()%SteamRadGain         Zone     Energy
    4509              :     //                                      Zone Hot Water Equipment Radiant Heating Energy ZoneRpt()%HWRadGain           Zone     Energy
    4510              :     //                                      Zone Other Equipment Radiant Heating Energy    ZoneRpt()%OtherRadGain         Zone     Energy
    4511              :     //                                   Zone Electric Equipment Convective Heating Energy ZoneRpt()%ElecConGain          Zone     Energy
    4512              :     //                                      Zone Gas Equipment Convective Heating Energy   ZoneRpt()%GasConGain           Zone     Energy
    4513              :     //                                      Zone Steam Equipment Convective Heating Energy ZoneRpt()%SteamConGain         Zone     Energy
    4514              :     //                                     Zone Hot Water Equipment Convective Heating Energy ZoneRpt()%HWConGain         Zone     Energy
    4515              :     //                                      Zone Other Equipment Convective Heating Energy ZoneRpt()%OtherConGain         Zone     Energy
    4516              :     // Window Heat Removal                  Zone Windows Total Heat Loss Energy            -ZoneWinHeatLossRepEnergy()  Zone     Energy
    4517              :     // Interzone Air Transfer Heat Removal  Zone Air Heat Balance Interzone Air Transfer Rate ZnAirRpt()%SumMCpDTzones  HVAC     Rate
    4518              :     // Infiltration Heat Removal            Zone Air Heat Balance Outdoor Air Transfer Rate ZnAirRpt()%SumMCpDtInfil     HVAC     Rate
    4519              :     // The following two columns are derived based on the values of the other columns and need to be computed on every HVAC timestep.
    4520              :     //   Opaque Surface Conduction and Other Heat Addition
    4521              :     //   Opaque Surface Conduction and Other Heat Removal
    4522              :     // For variables that are updated on a zone timestep basis, the values are used on the HVAC timestep but are ratio-ed by the
    4523              :     // timestep lengths.
    4524              :     // The peak reports follow a similar example.
    4525              : 
    4526              :     // Using/Aliasing
    4527            3 :     Real64 const TimeStepSysSec = state.dataHVACGlobal->TimeStepSysSec;
    4528              : 
    4529              :     using General::EncodeMonDayHrMin;
    4530              : 
    4531            3 :     auto &Zone = state.dataHeatBal->Zone;
    4532            3 :     auto &ZonePreDefRep = state.dataHeatBal->ZonePreDefRep;
    4533              : 
    4534            3 :     if (!state.dataGlobal->DoWeathSim) {
    4535            0 :         return;
    4536              :     }
    4537              : 
    4538            3 :     if (!state.dataOutRptPredefined->reportName(state.dataOutRptPredefined->pdrSensibleGain).show) {
    4539            0 :         return; // don't gather data if report isn't requested
    4540              :     }
    4541              : 
    4542            3 :     if (t_timeStepType == OutputProcessor::TimeStepType::Zone) {
    4543            0 :         return; // only add values over the HVAC timestep basis
    4544              :     }
    4545              : 
    4546            3 :     auto &ort = state.dataOutRptTab;
    4547              : 
    4548            3 :     if (ort->GatherHeatGainReportfirstTime) {
    4549            3 :         state.dataOutRptTab->radiantHeat.allocate(state.dataGlobal->NumOfZones);
    4550            3 :         state.dataOutRptTab->radiantCool.allocate(state.dataGlobal->NumOfZones);
    4551            3 :         state.dataOutRptTab->ATUHeat.allocate(state.dataGlobal->NumOfZones);
    4552            3 :         state.dataOutRptTab->ATUCool.allocate(state.dataGlobal->NumOfZones);
    4553            3 :         ort->GatherHeatGainReportfirstTime = false;
    4554              :     }
    4555              :     // clear the radiant surface accumulation variables
    4556            3 :     state.dataOutRptTab->radiantHeat = 0.0;
    4557            3 :     state.dataOutRptTab->radiantCool = 0.0;
    4558              :     // clear the ATU accumulation variables
    4559            3 :     state.dataOutRptTab->ATUHeat = 0.0;
    4560            3 :     state.dataOutRptTab->ATUCool = 0.0;
    4561              :     //--------------------
    4562              :     //     ANNUAL
    4563              :     //--------------------
    4564              :     // HVAC annual heating by ATU
    4565              :     // HVAC annual cooling by ATU
    4566            6 :     for (state.dataOutRptTab->iunitGHGR = 1; state.dataOutRptTab->iunitGHGR <= (int)state.dataDefineEquipment->AirDistUnit.size();
    4567            3 :          ++state.dataOutRptTab->iunitGHGR) {
    4568              :         // HVAC equipment should already have the multipliers included, no "* mult" needed (assumes autosized or multiplied hard-sized air flow).
    4569            3 :         state.dataOutRptTab->curZoneGHGR = state.dataDefineEquipment->AirDistUnit(state.dataOutRptTab->iunitGHGR).ZoneNum;
    4570            3 :         if ((state.dataOutRptTab->curZoneGHGR > 0) && (state.dataOutRptTab->curZoneGHGR <= state.dataGlobal->NumOfZones)) {
    4571            3 :             ZonePreDefRep(state.dataOutRptTab->curZoneGHGR).SHGSAnHvacATUHt +=
    4572            3 :                 state.dataDefineEquipment->AirDistUnit(state.dataOutRptTab->iunitGHGR).HeatGain;
    4573            3 :             ZonePreDefRep(state.dataOutRptTab->curZoneGHGR).SHGSAnHvacATUCl -=
    4574            3 :                 state.dataDefineEquipment->AirDistUnit(state.dataOutRptTab->iunitGHGR).CoolGain;
    4575            3 :             state.dataOutRptTab->ATUHeat(state.dataOutRptTab->curZoneGHGR) +=
    4576            3 :                 state.dataDefineEquipment->AirDistUnit(state.dataOutRptTab->iunitGHGR).HeatRate;
    4577            3 :             state.dataOutRptTab->ATUCool(state.dataOutRptTab->curZoneGHGR) -=
    4578            3 :                 state.dataDefineEquipment->AirDistUnit(state.dataOutRptTab->iunitGHGR).CoolRate;
    4579              :         }
    4580              :     }
    4581              :     // the fraction of the zone time step used by the system timestep
    4582            3 :     state.dataOutRptTab->timeStepRatio = state.dataHVACGlobal->TimeStepSys / state.dataGlobal->TimeStepZone;
    4583            8 :     for (state.dataOutRptTab->iZoneGHGR = 1; state.dataOutRptTab->iZoneGHGR <= state.dataGlobal->NumOfZones; ++state.dataOutRptTab->iZoneGHGR) {
    4584            5 :         Real64 const mult = Zone(state.dataOutRptTab->iZoneGHGR).Multiplier * Zone(state.dataOutRptTab->iZoneGHGR).ListMultiplier;
    4585              :         // People Sensible Heat Addition
    4586            5 :         ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSAnPeoplAdd +=
    4587            5 :             state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).PeopleSenGain * mult * state.dataOutRptTab->timeStepRatio;
    4588              :         // Lights Sensible Heat Addition
    4589            5 :         ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSAnLiteAdd +=
    4590            5 :             state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).LtsTotGain * mult * state.dataOutRptTab->timeStepRatio;
    4591              :         // HVAC Input Sensible Air Heating
    4592              :         // HVAC Input Sensible Air Cooling
    4593            5 :         Real64 ZoneEqHeatorCool = state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDTsystem +
    4594            5 :                                   state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumNonAirSystem * mult -
    4595            5 :                                   state.dataOutRptTab->ATUHeat(state.dataOutRptTab->iZoneGHGR) -
    4596            5 :                                   state.dataOutRptTab->ATUCool(state.dataOutRptTab->iZoneGHGR);
    4597            5 :         if (ZoneEqHeatorCool > 0.0) {
    4598            1 :             ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSAnZoneEqHt += ZoneEqHeatorCool * TimeStepSysSec;
    4599              :         } else {
    4600            4 :             ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSAnZoneEqCl += ZoneEqHeatorCool * TimeStepSysSec;
    4601              :         }
    4602              :         // Interzone Air Transfer Heat Addition
    4603              :         // Interzone Air Transfer Heat Removal
    4604            5 :         if (state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDTzones > 0.0) {
    4605            0 :             ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSAnIzaAdd +=
    4606            0 :                 state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDTzones * mult * TimeStepSysSec;
    4607              :         } else {
    4608            5 :             ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSAnIzaRem +=
    4609            5 :                 state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDTzones * mult * TimeStepSysSec;
    4610              :         }
    4611              :         // Window Heat Addition
    4612              :         // Window Heat Removal
    4613            5 :         ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSAnWindAdd +=
    4614            5 :             state.dataHeatBal->ZoneWinHeatGainRepEnergy(state.dataOutRptTab->iZoneGHGR) * mult * state.dataOutRptTab->timeStepRatio;
    4615            5 :         ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSAnWindRem -=
    4616            5 :             state.dataHeatBal->ZoneWinHeatLossRepEnergy(state.dataOutRptTab->iZoneGHGR) * mult * state.dataOutRptTab->timeStepRatio;
    4617              :         // Infiltration Heat Addition
    4618              :         // Infiltration Heat Removal
    4619            5 :         if (state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDtInfil > 0.0) {
    4620            0 :             ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSAnInfilAdd +=
    4621            0 :                 state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDtInfil * mult * TimeStepSysSec;
    4622              :         } else {
    4623            5 :             ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSAnInfilRem +=
    4624            5 :                 state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDtInfil * mult * TimeStepSysSec;
    4625              :         }
    4626              :         // Equipment Sensible Heat Addition
    4627              :         // Equipment Sensible Heat Removal
    4628              :         // the following variables are already gains so they do not need to be converted by multiplying by time.
    4629            5 :         state.dataOutRptTab->eqpSensGHGR = (state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).ElecRadGain +
    4630            5 :                                             state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).GasRadGain +
    4631            5 :                                             state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).HWRadGain +
    4632            5 :                                             state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).SteamRadGain +
    4633            5 :                                             state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).OtherRadGain +
    4634            5 :                                             state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).ElecConGain +
    4635            5 :                                             state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).GasConGain +
    4636            5 :                                             state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).HWConGain +
    4637            5 :                                             state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).SteamConGain +
    4638            5 :                                             state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).OtherConGain) *
    4639            5 :                                            state.dataOutRptTab->timeStepRatio;
    4640            5 :         if (state.dataOutRptTab->eqpSensGHGR > 0.0) {
    4641            4 :             ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSAnEquipAdd += state.dataOutRptTab->eqpSensGHGR * mult;
    4642              :         } else {
    4643            1 :             ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSAnEquipRem += state.dataOutRptTab->eqpSensGHGR * mult;
    4644              :         }
    4645              :     }
    4646            3 :     state.dataOutRptTab->curZoneGHGR = 0;
    4647              :     // HVAC Input Heated Surface Heating
    4648              :     // HVAC Input Cooled Surface Cooling
    4649            3 :     for (state.dataOutRptTab->iRadiantGHGR = 1; state.dataOutRptTab->iRadiantGHGR <= state.dataVentilatedSlab->NumOfVentSlabs;
    4650            0 :          ++state.dataOutRptTab->iRadiantGHGR) {
    4651            0 :         state.dataOutRptTab->curZoneGHGR = state.dataVentilatedSlab->VentSlab(state.dataOutRptTab->iRadiantGHGR).ZonePtr;
    4652            0 :         Real64 const mult = Zone(state.dataOutRptTab->curZoneGHGR).Multiplier * Zone(state.dataOutRptTab->curZoneGHGR).ListMultiplier;
    4653            0 :         if ((state.dataOutRptTab->curZoneGHGR > 0) && (state.dataOutRptTab->curZoneGHGR <= state.dataGlobal->NumOfZones)) {
    4654            0 :             ZonePreDefRep(state.dataOutRptTab->curZoneGHGR).SHGSAnSurfHt +=
    4655            0 :                 state.dataVentilatedSlab->VentSlab(state.dataOutRptTab->iRadiantGHGR).RadHeatingEnergy * mult;
    4656            0 :             ZonePreDefRep(state.dataOutRptTab->curZoneGHGR).SHGSAnSurfCl -=
    4657            0 :                 state.dataVentilatedSlab->VentSlab(state.dataOutRptTab->iRadiantGHGR).RadCoolingEnergy * mult;
    4658            0 :             state.dataOutRptTab->radiantHeat(state.dataOutRptTab->curZoneGHGR) =
    4659            0 :                 state.dataVentilatedSlab->VentSlab(state.dataOutRptTab->iRadiantGHGR).RadHeatingPower * mult;
    4660            0 :             state.dataOutRptTab->radiantCool(state.dataOutRptTab->curZoneGHGR) =
    4661            0 :                 -state.dataVentilatedSlab->VentSlab(state.dataOutRptTab->iRadiantGHGR).RadCoolingPower * mult;
    4662              :         }
    4663              :     }
    4664            3 :     for (state.dataOutRptTab->iRadiantGHGR = 1; state.dataOutRptTab->iRadiantGHGR <= state.dataLowTempRadSys->NumOfHydrLowTempRadSys;
    4665            0 :          ++state.dataOutRptTab->iRadiantGHGR) {
    4666            0 :         state.dataOutRptTab->curZoneGHGR = state.dataLowTempRadSys->HydrRadSys(state.dataOutRptTab->iRadiantGHGR).ZonePtr;
    4667            0 :         Real64 const mult = Zone(state.dataOutRptTab->curZoneGHGR).Multiplier * Zone(state.dataOutRptTab->curZoneGHGR).ListMultiplier;
    4668            0 :         if ((state.dataOutRptTab->curZoneGHGR > 0) && (state.dataOutRptTab->curZoneGHGR <= state.dataGlobal->NumOfZones)) {
    4669            0 :             ZonePreDefRep(state.dataOutRptTab->curZoneGHGR).SHGSAnSurfHt +=
    4670            0 :                 state.dataLowTempRadSys->HydrRadSys(state.dataOutRptTab->iRadiantGHGR).HeatEnergy * mult;
    4671            0 :             ZonePreDefRep(state.dataOutRptTab->curZoneGHGR).SHGSAnSurfCl -=
    4672            0 :                 state.dataLowTempRadSys->HydrRadSys(state.dataOutRptTab->iRadiantGHGR).CoolEnergy * mult;
    4673            0 :             state.dataOutRptTab->radiantHeat(state.dataOutRptTab->curZoneGHGR) +=
    4674            0 :                 state.dataLowTempRadSys->HydrRadSys(state.dataOutRptTab->iRadiantGHGR).HeatPower * mult;
    4675            0 :             state.dataOutRptTab->radiantCool(state.dataOutRptTab->curZoneGHGR) -=
    4676            0 :                 state.dataLowTempRadSys->HydrRadSys(state.dataOutRptTab->iRadiantGHGR).CoolPower * mult;
    4677              :         }
    4678              :     }
    4679            3 :     for (state.dataOutRptTab->iRadiantGHGR = 1; state.dataOutRptTab->iRadiantGHGR <= state.dataLowTempRadSys->NumOfCFloLowTempRadSys;
    4680            0 :          ++state.dataOutRptTab->iRadiantGHGR) {
    4681            0 :         state.dataOutRptTab->curZoneGHGR = state.dataLowTempRadSys->CFloRadSys(state.dataOutRptTab->iRadiantGHGR).ZonePtr;
    4682            0 :         Real64 const mult = Zone(state.dataOutRptTab->curZoneGHGR).Multiplier * Zone(state.dataOutRptTab->curZoneGHGR).ListMultiplier;
    4683            0 :         if ((state.dataOutRptTab->curZoneGHGR > 0) && (state.dataOutRptTab->curZoneGHGR <= state.dataGlobal->NumOfZones)) {
    4684            0 :             ZonePreDefRep(state.dataOutRptTab->curZoneGHGR).SHGSAnSurfHt +=
    4685            0 :                 state.dataLowTempRadSys->CFloRadSys(state.dataOutRptTab->iRadiantGHGR).HeatEnergy * mult;
    4686            0 :             ZonePreDefRep(state.dataOutRptTab->curZoneGHGR).SHGSAnSurfCl -=
    4687            0 :                 state.dataLowTempRadSys->CFloRadSys(state.dataOutRptTab->iRadiantGHGR).CoolEnergy * mult;
    4688            0 :             state.dataOutRptTab->radiantHeat(state.dataOutRptTab->curZoneGHGR) +=
    4689            0 :                 state.dataLowTempRadSys->CFloRadSys(state.dataOutRptTab->iRadiantGHGR).HeatPower * mult;
    4690            0 :             state.dataOutRptTab->radiantCool(state.dataOutRptTab->curZoneGHGR) -=
    4691            0 :                 state.dataLowTempRadSys->CFloRadSys(state.dataOutRptTab->iRadiantGHGR).CoolPower * mult;
    4692              :         }
    4693              :     }
    4694            3 :     for (state.dataOutRptTab->iRadiantGHGR = 1; state.dataOutRptTab->iRadiantGHGR <= state.dataLowTempRadSys->NumOfElecLowTempRadSys;
    4695            0 :          ++state.dataOutRptTab->iRadiantGHGR) {
    4696            0 :         state.dataOutRptTab->curZoneGHGR = state.dataLowTempRadSys->ElecRadSys(state.dataOutRptTab->iRadiantGHGR).ZonePtr;
    4697            0 :         Real64 const mult = Zone(state.dataOutRptTab->curZoneGHGR).Multiplier * Zone(state.dataOutRptTab->curZoneGHGR).ListMultiplier;
    4698            0 :         if ((state.dataOutRptTab->curZoneGHGR > 0) && (state.dataOutRptTab->curZoneGHGR <= state.dataGlobal->NumOfZones)) {
    4699            0 :             ZonePreDefRep(state.dataOutRptTab->curZoneGHGR).SHGSAnSurfHt +=
    4700            0 :                 state.dataLowTempRadSys->ElecRadSys(state.dataOutRptTab->iRadiantGHGR).HeatEnergy * mult;
    4701            0 :             state.dataOutRptTab->radiantHeat(state.dataOutRptTab->curZoneGHGR) +=
    4702            0 :                 state.dataLowTempRadSys->ElecRadSys(state.dataOutRptTab->iRadiantGHGR).HeatPower * mult;
    4703              :         }
    4704              :     }
    4705              :     // Opaque Surface Conduction and Other Heat Addition
    4706              :     // Opaque Surface Conduction and Other Heat Removal
    4707            8 :     for (state.dataOutRptTab->iZoneGHGR = 1; state.dataOutRptTab->iZoneGHGR <= state.dataGlobal->NumOfZones; ++state.dataOutRptTab->iZoneGHGR) {
    4708              :         // ZonePreDefRep variables above already include zone list and group multipliers
    4709           10 :         state.dataOutRptTab->totalGHGR =
    4710            5 :             ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSAnPeoplAdd + ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSAnLiteAdd +
    4711            5 :             ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSAnZoneEqHt + ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSAnZoneEqCl +
    4712            5 :             ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSAnHvacATUHt + ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSAnHvacATUCl +
    4713            5 :             ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSAnIzaAdd + ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSAnIzaRem +
    4714            5 :             ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSAnWindAdd + ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSAnWindRem +
    4715            5 :             ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSAnInfilAdd + ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSAnInfilRem +
    4716            5 :             ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSAnEquipAdd + ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSAnEquipRem +
    4717            5 :             ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSAnSurfHt + ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSAnSurfCl;
    4718           10 :         state.dataOutRptTab->totalGHGR =
    4719            5 :             -state.dataOutRptTab->totalGHGR; // want to know the negative value of the sum since the row should add up to zero
    4720            5 :         if (state.dataOutRptTab->totalGHGR > 0) {
    4721            0 :             ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSAnOtherAdd = state.dataOutRptTab->totalGHGR;
    4722              :         } else {
    4723            5 :             ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSAnOtherRem = state.dataOutRptTab->totalGHGR;
    4724              :         }
    4725              :     }
    4726              :     //--------------------------------
    4727              :     // ZONE PEAK COOLING AND HEATING
    4728              :     //--------------------------------
    4729            8 :     for (state.dataOutRptTab->iZoneGHGR = 1; state.dataOutRptTab->iZoneGHGR <= state.dataGlobal->NumOfZones; ++state.dataOutRptTab->iZoneGHGR) {
    4730            5 :         Real64 const mult = Zone(state.dataOutRptTab->iZoneGHGR).Multiplier * Zone(state.dataOutRptTab->iZoneGHGR).ListMultiplier;
    4731              :         // RR I can't get the Infiltration Heat Addition/Removal columns to add up.
    4732              :         // THis is the only suspect line, mixing MCpDt terms and a power term looks fishy.
    4733            5 :         if ((state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDTsystem +
    4734            5 :              state.dataOutRptTab->radiantHeat(state.dataOutRptTab->iZoneGHGR) +
    4735            5 :              state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumNonAirSystem * mult) > 0) {
    4736            0 :             if ((state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDTsystem +
    4737            0 :                  state.dataOutRptTab->radiantHeat(state.dataOutRptTab->iZoneGHGR) +
    4738            0 :                  state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumNonAirSystem * mult) >
    4739            0 :                 ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).htPeak) {
    4740            0 :                 ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).htPeak =
    4741            0 :                     state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDTsystem +
    4742            0 :                     state.dataOutRptTab->radiantHeat(state.dataOutRptTab->iZoneGHGR) +
    4743            0 :                     state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumNonAirSystem * mult;
    4744              :                 // determine timestamp
    4745              :                 //      ActualTimeS = CurrentTime-TimeStepZone+SysTimeElapsed
    4746              :                 //      ActualtimeE = ActualTimeS+TimeStepSys
    4747              :                 //      ActualTimeHrS=INT(ActualTimeS)
    4748              :                 //      ActualTimeMin=NINT((ActualtimeE - ActualTimeHrS)*FracToMin)
    4749            0 :                 int const ActualTimeMin = OutputProcessor::DetermineMinuteForReporting(state);
    4750            0 :                 EncodeMonDayHrMin(state.dataOutRptTab->timestepTimeStampGHGR,
    4751            0 :                                   state.dataEnvrn->Month,
    4752            0 :                                   state.dataEnvrn->DayOfMonth,
    4753            0 :                                   state.dataGlobal->HourOfDay,
    4754              :                                   ActualTimeMin);
    4755            0 :                 ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).htPtTimeStamp = state.dataOutRptTab->timestepTimeStampGHGR;
    4756              :                 // HVAC Input Sensible Air Heating
    4757              :                 // HVAC Input Sensible Air Cooling
    4758              :                 // non-HVAC ZnAirRpt variables DO NOT include zone multipliers
    4759            0 :                 ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtHvacHt =
    4760            0 :                     state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDTsystem +
    4761            0 :                     state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumNonAirSystem * mult;
    4762            0 :                 ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtHvacCl = 0.0;
    4763              :                 // HVAC Input Heated Surface Heating
    4764              :                 // HVAC Input Cooled Surface Cooling
    4765            0 :                 ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtSurfHt =
    4766            0 :                     state.dataOutRptTab->radiantHeat(state.dataOutRptTab->iZoneGHGR); // multipliers included above
    4767            0 :                 ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtSurfCl =
    4768            0 :                     state.dataOutRptTab->radiantCool(state.dataOutRptTab->iZoneGHGR); // multipliers included above
    4769              :                 // HVAC ATU Heating at Heat Peak
    4770              :                 // HVAC ATU Cooling at Heat Peak
    4771            0 :                 ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtHvacATUHt =
    4772            0 :                     state.dataOutRptTab->ATUHeat(state.dataOutRptTab->iZoneGHGR); // multipliers included above
    4773            0 :                 ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtHvacATUCl =
    4774            0 :                     state.dataOutRptTab->ATUCool(state.dataOutRptTab->iZoneGHGR); // multipliers included above
    4775              :                 // People Sensible Heat Addition
    4776            0 :                 ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtPeoplAdd =
    4777            0 :                     state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).PeopleSenGainRate * mult;
    4778              :                 // Lights Sensible Heat Addition
    4779            0 :                 ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtLiteAdd =
    4780            0 :                     state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).LtsTotGainRate * mult;
    4781              :                 // Equipment Sensible Heat Addition
    4782              :                 // Equipment Sensible Heat Removal
    4783              :                 // non-HVAC ZnAirRpt variables DO NOT include zone multipliers
    4784            0 :                 state.dataOutRptTab->eqpSensGHGR = state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).ElecRadGainRate +
    4785            0 :                                                    state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).GasRadGainRate +
    4786            0 :                                                    state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).HWRadGainRate +
    4787            0 :                                                    state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).SteamRadGainRate +
    4788            0 :                                                    state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).OtherRadGainRate +
    4789            0 :                                                    state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).ElecConGainRate +
    4790            0 :                                                    state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).GasConGainRate +
    4791            0 :                                                    state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).HWConGainRate +
    4792            0 :                                                    state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).SteamConGainRate +
    4793            0 :                                                    state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).OtherConGainRate;
    4794            0 :                 if (state.dataOutRptTab->eqpSensGHGR > 0.0) {
    4795            0 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtEquipAdd = state.dataOutRptTab->eqpSensGHGR * mult;
    4796            0 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtEquipRem = 0.0;
    4797              :                 } else {
    4798            0 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtEquipAdd = 0.0;
    4799            0 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtEquipRem = state.dataOutRptTab->eqpSensGHGR * mult;
    4800              :                 }
    4801              :                 // Window Heat Addition
    4802              :                 // Window Heat Removal
    4803            0 :                 ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtWindAdd =
    4804            0 :                     state.dataHeatBal->ZoneWinHeatGainRep(state.dataOutRptTab->iZoneGHGR) * mult;
    4805            0 :                 ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtWindRem =
    4806            0 :                     -state.dataHeatBal->ZoneWinHeatLossRep(state.dataOutRptTab->iZoneGHGR) * mult;
    4807              :                 // mixing object heat addition and removal
    4808            0 :                 if (state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDTzones > 0.0) {
    4809            0 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtIzaAdd =
    4810            0 :                         state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDTzones * mult;
    4811            0 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtIzaRem = 0.0;
    4812              :                 } else {
    4813            0 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtIzaAdd = 0.0;
    4814            0 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtIzaRem =
    4815            0 :                         state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDTzones * mult;
    4816              :                 }
    4817              :                 // Infiltration Heat Addition
    4818              :                 // Infiltration Heat Removal
    4819            0 :                 if (state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDtInfil > 0.0) {
    4820            0 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtInfilAdd =
    4821            0 :                         state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDtInfil * mult;
    4822            0 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtInfilRem = 0.0;
    4823              :                 } else {
    4824            0 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtInfilAdd = 0.0;
    4825            0 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtInfilRem =
    4826            0 :                         state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDtInfil * mult;
    4827              :                 }
    4828              :                 // Opaque Surface Conduction and Other Heat Addition
    4829              :                 // Opaque Surface Conduction and Other Heat Removal
    4830            0 :                 state.dataOutRptTab->totalGHGR =
    4831            0 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtPeoplAdd + ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtLiteAdd +
    4832            0 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtHvacHt + ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtHvacCl +
    4833            0 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtIzaAdd + ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtIzaRem +
    4834            0 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtWindAdd + ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtWindRem +
    4835            0 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtInfilAdd + ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtInfilRem +
    4836            0 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtEquipAdd + ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtEquipRem +
    4837            0 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtSurfHt + ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtSurfCl;
    4838            0 :                 state.dataOutRptTab->totalGHGR =
    4839            0 :                     -state.dataOutRptTab->totalGHGR; // want to know the negative value of the sum since the row should add up to zero
    4840            0 :                 if (state.dataOutRptTab->totalGHGR > 0) {
    4841            0 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtOtherAdd = state.dataOutRptTab->totalGHGR;
    4842            0 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtOtherRem = 0.0;
    4843              :                 } else {
    4844            0 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtOtherAdd = 0.0;
    4845            0 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtOtherRem = state.dataOutRptTab->totalGHGR;
    4846              :                 }
    4847              :             }
    4848              :         } else {
    4849            5 :             if ((state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDTsystem +
    4850            5 :                  state.dataOutRptTab->radiantCool(state.dataOutRptTab->iZoneGHGR) +
    4851            5 :                  state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumNonAirSystem * mult) <
    4852            5 :                 ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).clPeak) {
    4853            2 :                 ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).clPeak =
    4854            2 :                     state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDTsystem +
    4855            2 :                     state.dataOutRptTab->radiantCool(state.dataOutRptTab->iZoneGHGR) +
    4856            2 :                     state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumNonAirSystem * mult;
    4857              :                 // determine timestamp
    4858              :                 //      ActualTimeS = CurrentTime-TimeStepZone+SysTimeElapsed
    4859              :                 //      ActualtimeE = ActualTimeS+TimeStepSys
    4860              :                 //      ActualTimeHrS=INT(ActualTimeS)
    4861              :                 //      ActualTimeMin=NINT((ActualtimeE - ActualTimeHrS)*FracToMin)
    4862            2 :                 int const ActualTimeMin = OutputProcessor::DetermineMinuteForReporting(state);
    4863            2 :                 EncodeMonDayHrMin(state.dataOutRptTab->timestepTimeStampGHGR,
    4864            2 :                                   state.dataEnvrn->Month,
    4865            2 :                                   state.dataEnvrn->DayOfMonth,
    4866            2 :                                   state.dataGlobal->HourOfDay,
    4867              :                                   ActualTimeMin);
    4868            2 :                 ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).clPtTimeStamp = state.dataOutRptTab->timestepTimeStampGHGR;
    4869              :                 // HVAC Input Sensible Air Heating
    4870              :                 // HVAC Input Sensible Air Cooling
    4871            2 :                 ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClHvacHt = 0.0;
    4872            2 :                 ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClHvacCl =
    4873            2 :                     state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDTsystem +
    4874            2 :                     state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumNonAirSystem * mult;
    4875              :                 // HVAC Input Heated Surface Heating
    4876              :                 // HVAC Input Cooled Surface Cooling
    4877            2 :                 ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClSurfHt = state.dataOutRptTab->radiantHeat(state.dataOutRptTab->iZoneGHGR);
    4878            2 :                 ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClSurfCl = state.dataOutRptTab->radiantCool(state.dataOutRptTab->iZoneGHGR);
    4879              :                 // HVAC heating by ATU at cool peak
    4880              :                 // HVAC cooling by ATU at cool peak
    4881            2 :                 ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClHvacATUHt = state.dataOutRptTab->ATUHeat(state.dataOutRptTab->iZoneGHGR);
    4882            2 :                 ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClHvacATUCl = state.dataOutRptTab->ATUCool(state.dataOutRptTab->iZoneGHGR);
    4883              :                 // People Sensible Heat Addition
    4884            2 :                 ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClPeoplAdd =
    4885            2 :                     state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).PeopleSenGainRate * mult;
    4886              :                 // Lights Sensible Heat Addition
    4887            2 :                 ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClLiteAdd =
    4888            2 :                     state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).LtsTotGainRate * mult;
    4889              :                 // Equipment Sensible Heat Addition
    4890              :                 // Equipment Sensible Heat Removal
    4891            2 :                 state.dataOutRptTab->eqpSensGHGR = state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).ElecRadGainRate +
    4892            2 :                                                    state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).GasRadGainRate +
    4893            2 :                                                    state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).HWRadGainRate +
    4894            2 :                                                    state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).SteamRadGainRate +
    4895            2 :                                                    state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).OtherRadGainRate +
    4896            2 :                                                    state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).ElecConGainRate +
    4897            2 :                                                    state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).GasConGainRate +
    4898            2 :                                                    state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).HWConGainRate +
    4899            2 :                                                    state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).SteamConGainRate +
    4900            2 :                                                    state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).OtherConGainRate;
    4901            2 :                 if (state.dataOutRptTab->eqpSensGHGR > 0.0) {
    4902            2 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClEquipAdd = state.dataOutRptTab->eqpSensGHGR * mult;
    4903            2 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClEquipRem = 0.0;
    4904              :                 } else {
    4905            0 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClEquipAdd = 0.0;
    4906            0 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClEquipRem = state.dataOutRptTab->eqpSensGHGR * mult;
    4907              :                 }
    4908              :                 // Window Heat Addition
    4909              :                 // Window Heat Removal
    4910            2 :                 ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClWindAdd =
    4911            2 :                     state.dataHeatBal->ZoneWinHeatGainRep(state.dataOutRptTab->iZoneGHGR) * mult;
    4912            2 :                 ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClWindRem =
    4913            2 :                     -state.dataHeatBal->ZoneWinHeatLossRep(state.dataOutRptTab->iZoneGHGR) * mult;
    4914              :                 // mixing object cool addition and removal
    4915            2 :                 if (state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDTzones > 0.0) {
    4916            0 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClIzaAdd =
    4917            0 :                         state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDTzones * mult;
    4918            0 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClIzaRem = 0.0;
    4919              :                 } else {
    4920            2 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClIzaAdd = 0.0;
    4921            2 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClIzaRem =
    4922            2 :                         state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDTzones * mult;
    4923              :                 }
    4924              :                 // Infiltration Heat Addition
    4925              :                 // Infiltration Heat Removal
    4926            2 :                 if (state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDtInfil > 0.0) {
    4927            0 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClInfilAdd =
    4928            0 :                         state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDtInfil * mult;
    4929            0 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClInfilRem = 0.0;
    4930              :                 } else {
    4931            2 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClInfilAdd = 0.0;
    4932            2 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClInfilRem =
    4933            2 :                         state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDtInfil * mult;
    4934              :                 }
    4935              :                 // Opaque Surface Conduction and Other Heat Addition
    4936              :                 // Opaque Surface Conduction and Other Heat Removal
    4937            4 :                 state.dataOutRptTab->totalGHGR =
    4938            2 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClPeoplAdd + ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClLiteAdd +
    4939            2 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClHvacHt + ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClHvacCl +
    4940            2 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClIzaAdd + ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClIzaRem +
    4941            2 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClWindAdd + ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClWindRem +
    4942            2 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClInfilAdd + ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClInfilRem +
    4943            2 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClEquipAdd + ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClEquipRem +
    4944            2 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClSurfHt + ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClSurfCl;
    4945            4 :                 state.dataOutRptTab->totalGHGR =
    4946            2 :                     -state.dataOutRptTab->totalGHGR; // want to know the negative value of the sum since the row should add up to zero
    4947            2 :                 if (state.dataOutRptTab->totalGHGR > 0) {
    4948            0 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClOtherAdd = state.dataOutRptTab->totalGHGR;
    4949            0 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClOtherRem = 0.0;
    4950              :                 } else {
    4951            2 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClOtherAdd = 0.0;
    4952            2 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClOtherRem = state.dataOutRptTab->totalGHGR;
    4953              :                 }
    4954              :             }
    4955              :         }
    4956              :     }
    4957              :     //------------------------------------
    4958              :     // BUILDING PEAK COOLING AND HEATING
    4959              :     //------------------------------------
    4960            3 :     state.dataOutRptTab->bldgHtPk = 0.0;
    4961            3 :     state.dataOutRptTab->bldgClPk = 0.0;
    4962            8 :     for (state.dataOutRptTab->iZoneGHGR = 1; state.dataOutRptTab->iZoneGHGR <= state.dataGlobal->NumOfZones; ++state.dataOutRptTab->iZoneGHGR) {
    4963            5 :         Real64 const mult = Zone(state.dataOutRptTab->iZoneGHGR).Multiplier * Zone(state.dataOutRptTab->iZoneGHGR).ListMultiplier;
    4964            5 :         if ((state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDTsystem +
    4965            5 :              state.dataOutRptTab->radiantHeat(state.dataOutRptTab->iZoneGHGR) +
    4966            5 :              state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumNonAirSystem * mult) > 0) {
    4967            0 :             state.dataOutRptTab->bldgHtPk += state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDTsystem +
    4968            0 :                                              state.dataOutRptTab->radiantHeat(state.dataOutRptTab->iZoneGHGR) +
    4969            0 :                                              state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumNonAirSystem * mult;
    4970              :         } else {
    4971           10 :             state.dataOutRptTab->bldgClPk += state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDTsystem +
    4972            5 :                                              state.dataOutRptTab->radiantCool(state.dataOutRptTab->iZoneGHGR) +
    4973            5 :                                              state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumNonAirSystem * mult;
    4974              :         }
    4975              :     }
    4976            3 :     if (state.dataOutRptTab->bldgHtPk > state.dataHeatBal->BuildingPreDefRep.htPeak) {
    4977            0 :         state.dataHeatBal->BuildingPreDefRep.htPeak = state.dataOutRptTab->bldgHtPk;
    4978              :         // determine timestamp
    4979              :         //  ActualTimeS = CurrentTime-TimeStepZone+SysTimeElapsed
    4980              :         //  ActualtimeE = ActualTimeS+TimeStepSys
    4981              :         //  ActualTimeHrS=INT(ActualTimeS)
    4982              :         //  ActualTimeMin=NINT((ActualtimeE - ActualTimeHrS)*FracToMin)
    4983            0 :         int const ActualTimeMin = OutputProcessor::DetermineMinuteForReporting(state);
    4984            0 :         EncodeMonDayHrMin(state.dataOutRptTab->timestepTimeStampGHGR,
    4985            0 :                           state.dataEnvrn->Month,
    4986            0 :                           state.dataEnvrn->DayOfMonth,
    4987            0 :                           state.dataGlobal->HourOfDay,
    4988              :                           ActualTimeMin);
    4989            0 :         state.dataHeatBal->BuildingPreDefRep.htPtTimeStamp = state.dataOutRptTab->timestepTimeStampGHGR;
    4990              :         // reset building level results to zero prior to accumulating across zones
    4991            0 :         state.dataHeatBal->BuildingPreDefRep.SHGSHtHvacHt = 0.0;
    4992            0 :         state.dataHeatBal->BuildingPreDefRep.SHGSHtHvacCl = 0.0;
    4993            0 :         state.dataHeatBal->BuildingPreDefRep.SHGSHtHvacATUHt = 0.0;
    4994            0 :         state.dataHeatBal->BuildingPreDefRep.SHGSHtHvacATUCl = 0.0;
    4995            0 :         state.dataHeatBal->BuildingPreDefRep.SHGSHtSurfHt = 0.0;
    4996            0 :         state.dataHeatBal->BuildingPreDefRep.SHGSHtSurfCl = 0.0;
    4997            0 :         state.dataHeatBal->BuildingPreDefRep.SHGSHtPeoplAdd = 0.0;
    4998            0 :         state.dataHeatBal->BuildingPreDefRep.SHGSHtLiteAdd = 0.0;
    4999            0 :         state.dataHeatBal->BuildingPreDefRep.SHGSHtEquipAdd = 0.0;
    5000            0 :         state.dataHeatBal->BuildingPreDefRep.SHGSHtWindAdd = 0.0;
    5001            0 :         state.dataHeatBal->BuildingPreDefRep.SHGSHtIzaAdd = 0.0;
    5002            0 :         state.dataHeatBal->BuildingPreDefRep.SHGSHtInfilAdd = 0.0;
    5003            0 :         state.dataHeatBal->BuildingPreDefRep.SHGSHtOtherAdd = 0.0;
    5004            0 :         state.dataHeatBal->BuildingPreDefRep.SHGSHtEquipRem = 0.0;
    5005            0 :         state.dataHeatBal->BuildingPreDefRep.SHGSHtWindRem = 0.0;
    5006            0 :         state.dataHeatBal->BuildingPreDefRep.SHGSHtIzaRem = 0.0;
    5007            0 :         state.dataHeatBal->BuildingPreDefRep.SHGSHtInfilRem = 0.0;
    5008            0 :         state.dataHeatBal->BuildingPreDefRep.SHGSHtOtherRem = 0.0;
    5009            0 :         for (state.dataOutRptTab->iZoneGHGR = 1; state.dataOutRptTab->iZoneGHGR <= state.dataGlobal->NumOfZones; ++state.dataOutRptTab->iZoneGHGR) {
    5010            0 :             Real64 const mult = Zone(state.dataOutRptTab->iZoneGHGR).Multiplier * Zone(state.dataOutRptTab->iZoneGHGR).ListMultiplier;
    5011              :             // HVAC Input Sensible Air Heating
    5012              :             // HVAC Input Sensible Air Cooling
    5013            0 :             state.dataHeatBal->BuildingPreDefRep.SHGSHtHvacHt += state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDTsystem +
    5014            0 :                                                                  state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumNonAirSystem * mult;
    5015              :             // HVAC Input Heated Surface Heating
    5016              :             // HVAC Input Cooled Surface Cooling
    5017            0 :             state.dataHeatBal->BuildingPreDefRep.SHGSHtSurfHt += state.dataOutRptTab->radiantHeat(state.dataOutRptTab->iZoneGHGR);
    5018            0 :             state.dataHeatBal->BuildingPreDefRep.SHGSHtSurfCl += state.dataOutRptTab->radiantCool(state.dataOutRptTab->iZoneGHGR);
    5019              :             // HVAC ATU Heating
    5020              :             // HVAC ATU Cooling
    5021            0 :             state.dataHeatBal->BuildingPreDefRep.SHGSHtHvacATUHt += state.dataOutRptTab->ATUHeat(state.dataOutRptTab->iZoneGHGR);
    5022            0 :             state.dataHeatBal->BuildingPreDefRep.SHGSHtHvacATUCl += state.dataOutRptTab->ATUCool(state.dataOutRptTab->iZoneGHGR);
    5023              :             // People Sensible Heat Addition
    5024            0 :             state.dataHeatBal->BuildingPreDefRep.SHGSHtPeoplAdd +=
    5025            0 :                 state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).PeopleSenGainRate * mult;
    5026              :             // Lights Sensible Heat Addition
    5027            0 :             state.dataHeatBal->BuildingPreDefRep.SHGSHtLiteAdd += state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).LtsTotGainRate * mult;
    5028              :             // Equipment Sensible Heat Addition
    5029              :             // Equipment Sensible Heat Removal
    5030            0 :             state.dataOutRptTab->eqpSensGHGR = state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).ElecRadGainRate +
    5031            0 :                                                state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).GasRadGainRate +
    5032            0 :                                                state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).HWRadGainRate +
    5033            0 :                                                state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).SteamRadGainRate +
    5034            0 :                                                state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).OtherRadGainRate +
    5035            0 :                                                state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).ElecConGainRate +
    5036            0 :                                                state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).GasConGainRate +
    5037            0 :                                                state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).HWConGainRate +
    5038            0 :                                                state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).SteamConGainRate +
    5039            0 :                                                state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).OtherConGainRate;
    5040            0 :             if (state.dataOutRptTab->eqpSensGHGR > 0.0) {
    5041            0 :                 state.dataHeatBal->BuildingPreDefRep.SHGSHtEquipAdd += state.dataOutRptTab->eqpSensGHGR * mult;
    5042              :             } else {
    5043            0 :                 state.dataHeatBal->BuildingPreDefRep.SHGSHtEquipRem += state.dataOutRptTab->eqpSensGHGR * mult;
    5044              :             }
    5045              :             // Window Heat Addition
    5046              :             // Window Heat Removal
    5047            0 :             state.dataHeatBal->BuildingPreDefRep.SHGSHtWindAdd += state.dataHeatBal->ZoneWinHeatGainRep(state.dataOutRptTab->iZoneGHGR) * mult;
    5048            0 :             state.dataHeatBal->BuildingPreDefRep.SHGSHtWindRem -= state.dataHeatBal->ZoneWinHeatLossRep(state.dataOutRptTab->iZoneGHGR) * mult;
    5049              :             // mixing object heat addition and removal
    5050            0 :             if (state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDTzones > 0.0) {
    5051            0 :                 state.dataHeatBal->BuildingPreDefRep.SHGSHtIzaAdd += state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDTzones * mult;
    5052              :             } else {
    5053            0 :                 state.dataHeatBal->BuildingPreDefRep.SHGSHtIzaRem += state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDTzones * mult;
    5054              :             }
    5055              :             // Infiltration Heat Addition
    5056              :             // Infiltration Heat Removal
    5057            0 :             if (state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDtInfil > 00) {
    5058            0 :                 state.dataHeatBal->BuildingPreDefRep.SHGSHtInfilAdd +=
    5059            0 :                     state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDtInfil * mult;
    5060              :             } else {
    5061            0 :                 state.dataHeatBal->BuildingPreDefRep.SHGSHtInfilRem +=
    5062            0 :                     state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDtInfil * mult;
    5063              :             }
    5064              :         }
    5065              :         // Opaque Surface Conduction and Other Heat Addition
    5066              :         // Opaque Surface Conduction and Other Heat Removal
    5067            0 :         state.dataOutRptTab->totalGHGR = state.dataHeatBal->BuildingPreDefRep.SHGSHtPeoplAdd + state.dataHeatBal->BuildingPreDefRep.SHGSHtLiteAdd +
    5068            0 :                                          state.dataHeatBal->BuildingPreDefRep.SHGSHtHvacHt + state.dataHeatBal->BuildingPreDefRep.SHGSHtHvacCl +
    5069            0 :                                          state.dataHeatBal->BuildingPreDefRep.SHGSHtIzaAdd + state.dataHeatBal->BuildingPreDefRep.SHGSHtIzaRem +
    5070            0 :                                          state.dataHeatBal->BuildingPreDefRep.SHGSHtWindAdd + state.dataHeatBal->BuildingPreDefRep.SHGSHtWindRem +
    5071            0 :                                          state.dataHeatBal->BuildingPreDefRep.SHGSHtInfilAdd + state.dataHeatBal->BuildingPreDefRep.SHGSHtInfilRem +
    5072            0 :                                          state.dataHeatBal->BuildingPreDefRep.SHGSHtEquipAdd + state.dataHeatBal->BuildingPreDefRep.SHGSHtEquipRem +
    5073            0 :                                          state.dataHeatBal->BuildingPreDefRep.SHGSHtSurfHt + state.dataHeatBal->BuildingPreDefRep.SHGSHtSurfCl;
    5074            0 :         state.dataOutRptTab->totalGHGR =
    5075            0 :             -state.dataOutRptTab->totalGHGR; // want to know the negative value of the sum since the row should add up to zero
    5076            0 :         if (state.dataOutRptTab->totalGHGR > 0) {
    5077            0 :             state.dataHeatBal->BuildingPreDefRep.SHGSHtOtherAdd += state.dataOutRptTab->totalGHGR;
    5078              :         } else {
    5079            0 :             state.dataHeatBal->BuildingPreDefRep.SHGSHtOtherRem += state.dataOutRptTab->totalGHGR;
    5080              :         }
    5081              :     }
    5082            3 :     if (state.dataOutRptTab->bldgClPk < state.dataHeatBal->BuildingPreDefRep.clPeak) {
    5083            1 :         state.dataHeatBal->BuildingPreDefRep.clPeak = state.dataOutRptTab->bldgClPk;
    5084              :         // determine timestamp
    5085              :         //  ActualTimeS = CurrentTime-TimeStepZone+SysTimeElapsed
    5086              :         //  ActualtimeE = ActualTimeS+TimeStepSys
    5087              :         //  ActualTimeHrS=INT(ActualTimeS)
    5088              :         //  ActualTimeMin=NINT((ActualtimeE - ActualTimeHrS)*FracToMin)
    5089            1 :         int const ActualTimeMin = OutputProcessor::DetermineMinuteForReporting(state);
    5090            1 :         EncodeMonDayHrMin(state.dataOutRptTab->timestepTimeStampGHGR,
    5091            1 :                           state.dataEnvrn->Month,
    5092            1 :                           state.dataEnvrn->DayOfMonth,
    5093            1 :                           state.dataGlobal->HourOfDay,
    5094              :                           ActualTimeMin);
    5095            1 :         state.dataHeatBal->BuildingPreDefRep.clPtTimeStamp = state.dataOutRptTab->timestepTimeStampGHGR;
    5096              :         // reset building level results to zero prior to accumulating across zones
    5097            1 :         state.dataHeatBal->BuildingPreDefRep.SHGSClHvacHt = 0.0;
    5098            1 :         state.dataHeatBal->BuildingPreDefRep.SHGSClHvacCl = 0.0;
    5099            1 :         state.dataHeatBal->BuildingPreDefRep.SHGSClSurfHt = 0.0;
    5100            1 :         state.dataHeatBal->BuildingPreDefRep.SHGSClSurfCl = 0.0;
    5101            1 :         state.dataHeatBal->BuildingPreDefRep.SHGSClHvacATUHt = 0.0;
    5102            1 :         state.dataHeatBal->BuildingPreDefRep.SHGSClHvacATUCl = 0.0;
    5103            1 :         state.dataHeatBal->BuildingPreDefRep.SHGSClPeoplAdd = 0.0;
    5104            1 :         state.dataHeatBal->BuildingPreDefRep.SHGSClLiteAdd = 0.0;
    5105            1 :         state.dataHeatBal->BuildingPreDefRep.SHGSClEquipAdd = 0.0;
    5106            1 :         state.dataHeatBal->BuildingPreDefRep.SHGSClWindAdd = 0.0;
    5107            1 :         state.dataHeatBal->BuildingPreDefRep.SHGSClIzaAdd = 0.0;
    5108            1 :         state.dataHeatBal->BuildingPreDefRep.SHGSClInfilAdd = 0.0;
    5109            1 :         state.dataHeatBal->BuildingPreDefRep.SHGSClOtherAdd = 0.0;
    5110            1 :         state.dataHeatBal->BuildingPreDefRep.SHGSClEquipRem = 0.0;
    5111            1 :         state.dataHeatBal->BuildingPreDefRep.SHGSClWindRem = 0.0;
    5112            1 :         state.dataHeatBal->BuildingPreDefRep.SHGSClIzaRem = 0.0;
    5113            1 :         state.dataHeatBal->BuildingPreDefRep.SHGSClInfilRem = 0.0;
    5114            1 :         state.dataHeatBal->BuildingPreDefRep.SHGSClOtherRem = 0.0;
    5115            3 :         for (state.dataOutRptTab->iZoneGHGR = 1; state.dataOutRptTab->iZoneGHGR <= state.dataGlobal->NumOfZones; ++state.dataOutRptTab->iZoneGHGR) {
    5116            2 :             Real64 const mult = Zone(state.dataOutRptTab->iZoneGHGR).Multiplier * Zone(state.dataOutRptTab->iZoneGHGR).ListMultiplier;
    5117              :             // HVAC Input Sensible Air Heating
    5118              :             // HVAC Input Sensible Air Cooling
    5119            2 :             state.dataHeatBal->BuildingPreDefRep.SHGSClHvacCl += state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDTsystem +
    5120            2 :                                                                  state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumNonAirSystem * mult;
    5121              :             // HVAC Input Heated Surface Heating
    5122              :             // HVAC Input Cooled Surface Cooling
    5123            2 :             state.dataHeatBal->BuildingPreDefRep.SHGSClSurfHt += state.dataOutRptTab->radiantHeat(state.dataOutRptTab->iZoneGHGR);
    5124            2 :             state.dataHeatBal->BuildingPreDefRep.SHGSClSurfCl += state.dataOutRptTab->radiantCool(state.dataOutRptTab->iZoneGHGR);
    5125              :             // HVAC ATU Heating
    5126              :             // HVAC ATU Cooling
    5127            2 :             state.dataHeatBal->BuildingPreDefRep.SHGSClHvacATUHt += state.dataOutRptTab->ATUHeat(state.dataOutRptTab->iZoneGHGR);
    5128            2 :             state.dataHeatBal->BuildingPreDefRep.SHGSClHvacATUCl += state.dataOutRptTab->ATUCool(state.dataOutRptTab->iZoneGHGR);
    5129              :             // People Sensible Heat Addition
    5130            4 :             state.dataHeatBal->BuildingPreDefRep.SHGSClPeoplAdd +=
    5131            2 :                 state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).PeopleSenGainRate * mult;
    5132              :             // Lights Sensible Heat Addition
    5133            2 :             state.dataHeatBal->BuildingPreDefRep.SHGSClLiteAdd += state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).LtsTotGainRate * mult;
    5134              :             // Equipment Sensible Heat Addition
    5135              :             // Equipment Sensible Heat Removal
    5136            2 :             state.dataOutRptTab->eqpSensGHGR = state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).ElecRadGainRate +
    5137            2 :                                                state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).GasRadGainRate +
    5138            2 :                                                state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).HWRadGainRate +
    5139            2 :                                                state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).SteamRadGainRate +
    5140            2 :                                                state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).OtherRadGainRate +
    5141            2 :                                                state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).ElecConGainRate +
    5142            2 :                                                state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).GasConGainRate +
    5143            2 :                                                state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).HWConGainRate +
    5144            2 :                                                state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).SteamConGainRate +
    5145            2 :                                                state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).OtherConGainRate;
    5146            2 :             if (state.dataOutRptTab->eqpSensGHGR > 0.0) {
    5147            2 :                 state.dataHeatBal->BuildingPreDefRep.SHGSClEquipAdd += state.dataOutRptTab->eqpSensGHGR * mult;
    5148              :             } else {
    5149            0 :                 state.dataHeatBal->BuildingPreDefRep.SHGSClEquipRem += state.dataOutRptTab->eqpSensGHGR * mult;
    5150              :             }
    5151              :             // Window Heat Addition
    5152              :             // Window Heat Removal
    5153            2 :             state.dataHeatBal->BuildingPreDefRep.SHGSClWindAdd += state.dataHeatBal->ZoneWinHeatGainRep(state.dataOutRptTab->iZoneGHGR) * mult;
    5154            2 :             state.dataHeatBal->BuildingPreDefRep.SHGSClWindRem -= state.dataHeatBal->ZoneWinHeatLossRep(state.dataOutRptTab->iZoneGHGR) * mult;
    5155              :             // mixing object cool addition and removal
    5156            2 :             if (state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDTzones > 0.0) {
    5157            0 :                 state.dataHeatBal->BuildingPreDefRep.SHGSClIzaAdd += state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDTzones * mult;
    5158              :             } else {
    5159            2 :                 state.dataHeatBal->BuildingPreDefRep.SHGSClIzaRem += state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDTzones * mult;
    5160              :             }
    5161              :             // Infiltration Heat Addition
    5162              :             // Infiltration Heat Removal
    5163            2 :             if (state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDtInfil > 00) {
    5164            0 :                 state.dataHeatBal->BuildingPreDefRep.SHGSClInfilAdd +=
    5165            0 :                     state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDtInfil * mult;
    5166              :             } else {
    5167            2 :                 state.dataHeatBal->BuildingPreDefRep.SHGSClInfilRem +=
    5168            2 :                     state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDtInfil * mult;
    5169              :             }
    5170              :         }
    5171              :         // Opaque Surface Conduction and Other Heat Addition
    5172              :         // Opaque Surface Conduction and Other Heat Removal
    5173            1 :         state.dataOutRptTab->totalGHGR = state.dataHeatBal->BuildingPreDefRep.SHGSClPeoplAdd + state.dataHeatBal->BuildingPreDefRep.SHGSClLiteAdd +
    5174            1 :                                          state.dataHeatBal->BuildingPreDefRep.SHGSClHvacHt + state.dataHeatBal->BuildingPreDefRep.SHGSClHvacCl +
    5175            1 :                                          state.dataHeatBal->BuildingPreDefRep.SHGSClIzaAdd + state.dataHeatBal->BuildingPreDefRep.SHGSClIzaRem +
    5176            1 :                                          state.dataHeatBal->BuildingPreDefRep.SHGSClWindAdd + state.dataHeatBal->BuildingPreDefRep.SHGSClWindRem +
    5177            1 :                                          state.dataHeatBal->BuildingPreDefRep.SHGSClInfilAdd + state.dataHeatBal->BuildingPreDefRep.SHGSClInfilRem +
    5178            1 :                                          state.dataHeatBal->BuildingPreDefRep.SHGSClEquipAdd + state.dataHeatBal->BuildingPreDefRep.SHGSClEquipRem +
    5179            1 :                                          state.dataHeatBal->BuildingPreDefRep.SHGSClSurfHt + state.dataHeatBal->BuildingPreDefRep.SHGSClSurfCl;
    5180            2 :         state.dataOutRptTab->totalGHGR =
    5181            1 :             -state.dataOutRptTab->totalGHGR; // want to know the negative value of the sum since the row should add up to zero
    5182            1 :         if (state.dataOutRptTab->totalGHGR > 0) {
    5183            0 :             state.dataHeatBal->BuildingPreDefRep.SHGSClOtherAdd += state.dataOutRptTab->totalGHGR;
    5184              :         } else {
    5185            1 :             state.dataHeatBal->BuildingPreDefRep.SHGSClOtherRem += state.dataOutRptTab->totalGHGR;
    5186              :         }
    5187              :     }
    5188              : }
    5189              : 
    5190              : //======================================================================================================================
    5191              : //======================================================================================================================
    5192              : 
    5193              : //    WRITE OUTPUT FILE ROUTINES
    5194              : 
    5195              : //======================================================================================================================
    5196              : //======================================================================================================================
    5197              : 
    5198           73 : void WriteTabularReports(EnergyPlusData &state)
    5199              : {
    5200              :     // SUBROUTINE INFORMATION:
    5201              :     //       AUTHOR         Jason Glazer
    5202              :     //       DATE WRITTEN   August 2003
    5203              :     //       MODIFIED       January 2021, J. Yuan
    5204              :     //                      Modified to accommodate dual-unit reporting
    5205              :     //       RE-ENGINEERED  na
    5206              : 
    5207              :     // PURPOSE OF THIS SUBROUTINE:
    5208              :     //   This routine hides from the main simulation that four specific
    5209              :     //   types of tabular reports are each created. If another type of
    5210              :     //   report is added it can be added to the list here.
    5211              : 
    5212           73 :     FillWeatherPredefinedEntries(state);
    5213           73 :     FillRemainingPredefinedEntries(state);
    5214           73 :     WaterManager::ReportRainfall(state);
    5215           73 :     auto &ort = state.dataOutRptTab;
    5216              : 
    5217              :     // Here to it is ready to assign ort->unitStyle_SQLite (not in SQLiteProcedures.cc)
    5218              :     // when ort->unitsStyle inputs should have been concretely processed and assigned.
    5219           73 :     if (ort->unitsStyle_SQLite == UnitsStyle::NotFound) {
    5220           73 :         ort->unitsStyle_SQLite = ort->unitsStyle; // This is the default UseOutputControlTableStyles
    5221              :     }
    5222              : 
    5223           73 :     if (ort->WriteTabularFiles) {
    5224              : 
    5225              :         // call each type of report in turn
    5226           38 :         WriteBEPSTable(state);
    5227           38 :         WriteTableOfContents(state);
    5228           38 :         WriteVeriSumTable(state);
    5229           38 :         WriteDemandEndUseSummary(state);
    5230           38 :         WriteSourceEnergyEndUseSummary(state);
    5231           38 :         WriteComponentSizing(state);
    5232           38 :         WriteSurfaceShadowing(state);
    5233           38 :         WriteCompCostTable(state);
    5234           38 :         WriteAdaptiveComfortTable(state);
    5235           38 :         WriteEioTables(state);
    5236           38 :         WriteLoadComponentSummaryTables(state);
    5237           38 :         WriteHeatEmissionTable(state);
    5238              : 
    5239           38 :         if (ort->displayThermalResilienceSummary && !state.dataGlobal->DoPureLoadCalc) { // code will crash if pure load calc
    5240           30 :             WriteThermalResilienceTables(state);                                         // code will crash if pure load calc
    5241              :         }
    5242           38 :         if (ort->displayCO2ResilienceSummary && !state.dataGlobal->DoPureLoadCalc) { // code will crash if pure load calc
    5243            0 :             WriteCO2ResilienceTables(state);                                         // code will crash if pure load calc
    5244              :         }
    5245           38 :         if (ort->displayVisualResilienceSummary && !state.dataGlobal->DoPureLoadCalc) { // code will crash if pure load calc
    5246            0 :             WriteVisualResilienceTables(state);                                         // code will crash if pure load calc
    5247              :         }
    5248           38 :         if (state.dataWeather->TotReportPers > 0) {
    5249            0 :             WriteReportPeriodTimeConsumption(state);
    5250              :         }
    5251           38 :         for (int i = 1; i <= state.dataWeather->TotThermalReportPers; i++) {
    5252            0 :             WriteThermalResilienceTablesRepPeriod(state, i);
    5253              :         }
    5254           38 :         for (int i = 1; i <= state.dataWeather->TotCO2ReportPers; i++) {
    5255            0 :             WriteCO2ResilienceTablesRepPeriod(state, i);
    5256              :         }
    5257           38 :         for (int i = 1; i <= state.dataWeather->TotVisualReportPers; i++) {
    5258            0 :             WriteVisualResilienceTablesRepPeriod(state, i);
    5259              :         }
    5260              : 
    5261           38 :         state.dataRptCoilSelection->coilSelectionReportObj->finishCoilSummaryReportTable(
    5262              :             state);                   // call to write out the coil selection summary table data
    5263           38 :         WritePredefinedTables(state); // moved to come after zone load components is finished
    5264              : 
    5265           38 :         if (state.dataGlobal->DoWeathSim) {
    5266            0 :             WriteMonthlyTables(state);
    5267            0 :             WriteTimeBinTables(state);
    5268            0 :             OutputReportTabularAnnual::WriteAnnualTables(state);
    5269              :         }
    5270              :     }
    5271              : 
    5272              :     constexpr static std::string_view variable_fmt = " {}={:12}\n";
    5273              :     constexpr static auto variable_fmt_syntax = check_syntax(variable_fmt); // (AUTO_OK) not sure what this is
    5274          146 :     state.files.audit.ensure_open(state, "WriteTabularReports", state.files.outputControl.audit);
    5275           73 :     print<variable_fmt_syntax>(state.files.audit, variable_fmt, "MonthlyInputCount", ort->MonthlyInputCount);
    5276           73 :     print<variable_fmt_syntax>(state.files.audit, variable_fmt, "sizeMonthlyInput", ort->sizeMonthlyInput);
    5277           73 :     print<variable_fmt_syntax>(state.files.audit, variable_fmt, "MonthlyFieldSetInputCount", ort->MonthlyFieldSetInputCount);
    5278           73 :     print<variable_fmt_syntax>(state.files.audit, variable_fmt, "sizeMonthlyFieldSetInput", ort->sizeMonthlyFieldSetInput);
    5279           73 :     print<variable_fmt_syntax>(state.files.audit, variable_fmt, "MonthlyTablesCount", ort->MonthlyTablesCount);
    5280           73 :     print<variable_fmt_syntax>(state.files.audit, variable_fmt, "MonthlyColumnsCount", ort->MonthlyColumnsCount);
    5281           73 :     print<variable_fmt_syntax>(state.files.audit, variable_fmt, "sizeReportName", state.dataOutRptPredefined->sizeReportName);
    5282           73 :     print<variable_fmt_syntax>(state.files.audit, variable_fmt, "numReportName", state.dataOutRptPredefined->numReportName);
    5283           73 :     print<variable_fmt_syntax>(state.files.audit, variable_fmt, "sizeSubTable", state.dataOutRptPredefined->sizeSubTable);
    5284           73 :     print<variable_fmt_syntax>(state.files.audit, variable_fmt, "numSubTable", state.dataOutRptPredefined->numSubTable);
    5285           73 :     print<variable_fmt_syntax>(state.files.audit, variable_fmt, "sizeColumnTag", state.dataOutRptPredefined->sizeColumnTag);
    5286           73 :     print<variable_fmt_syntax>(state.files.audit, variable_fmt, "numColumnTag", state.dataOutRptPredefined->numColumnTag);
    5287           73 :     print<variable_fmt_syntax>(state.files.audit, variable_fmt, "sizeTableEntry", state.dataOutRptPredefined->sizeTableEntry);
    5288           73 :     print<variable_fmt_syntax>(state.files.audit, variable_fmt, "numTableEntry", state.dataOutRptPredefined->numTableEntry);
    5289           73 :     print<variable_fmt_syntax>(state.files.audit, variable_fmt, "sizeCompSizeTableEntry", state.dataOutRptPredefined->sizeCompSizeTableEntry);
    5290           73 :     print<variable_fmt_syntax>(state.files.audit, variable_fmt, "numCompSizeTableEntry", state.dataOutRptPredefined->numCompSizeTableEntry);
    5291           73 : }
    5292              : 
    5293          674 : bool produceDualUnitsFlags(const int iUnit_Sys,
    5294              :                            const UnitsStyle unitsStyle_Tab,
    5295              :                            const UnitsStyle unitsStyle_Sql,
    5296              :                            UnitsStyle &unitsStyle_Cur,
    5297              :                            bool &produce_Tab,
    5298              :                            bool &produce_Sql)
    5299              : {
    5300              :     // January 2021:
    5301              :     // PURPOSE OF THIS SUBROUTINE:
    5302              :     // This routine sets the order and flags for tabular data and sqlite writing for a Dual-Unit reporting.
    5303              :     // It will set the unit styles to used, a flag for tabular data writing, and a flag for sqlite writing.
    5304              :     // The function will return a false flag if only a second round of (SQLite) writing is needed
    5305              :     // and will return a true flag if a second round SQLite writing is not needed.
    5306              : 
    5307          674 :     bool brkflag(false);
    5308              : 
    5309          674 :     if (iUnit_Sys == 0) {
    5310          337 :         unitsStyle_Cur = unitsStyle_Tab;
    5311          337 :         produce_Tab = true;
    5312          337 :         if (unitsStyle_Sql == unitsStyle_Tab) {
    5313          321 :             produce_Sql = true;
    5314              :         } else {
    5315           16 :             produce_Sql = false;
    5316              :         }
    5317              :     } else { // iUnit_Sys == 1
    5318          337 :         unitsStyle_Cur = unitsStyle_Sql;
    5319          337 :         produce_Tab = false;
    5320          337 :         produce_Sql = true;
    5321          337 :         if (unitsStyle_Sql == unitsStyle_Tab) {
    5322              :             // flag true if a separate SQLite round writing is not needed
    5323          321 :             brkflag = true;
    5324          321 :             produce_Sql = false;
    5325              :         }
    5326              :     }
    5327              : 
    5328              :     // False if a separate sqlite round is needed;
    5329              :     // true if not
    5330          674 :     return brkflag;
    5331              : }
    5332              : 
    5333        10269 : void parseStatLine(const std::string &lineIn,
    5334              :                    StatLineType &lineType,
    5335              :                    bool &desConditionlinepassed,
    5336              :                    bool &heatingDesignlinepassed,
    5337              :                    bool &coolingDesignlinepassed,
    5338              :                    bool isKoppen,
    5339              :                    bool &insideLiquidPrecipitation)
    5340              : {
    5341              :     // assumes that all the variables are initialized outside of this routine -- it does not re-initialize them
    5342        10269 :     if (has_prefix(lineIn, "Statistics")) {
    5343           18 :         lineType = StatLineType::StatisticsLine;
    5344        10251 :     } else if (has_prefix(lineIn, "Location")) {
    5345           18 :         lineType = StatLineType::LocationLine;
    5346        10233 :     } else if (has_prefix(lineIn, "{")) {
    5347           18 :         lineType = StatLineType::LatLongLine;
    5348        10215 :     } else if (has_prefix(lineIn, "Elevation")) {
    5349           18 :         lineType = StatLineType::ElevationLine;
    5350        10197 :     } else if (has_prefix(lineIn, "Standard Pressure")) {
    5351           18 :         lineType = StatLineType::StdPressureLine;
    5352        10179 :     } else if (has_prefix(lineIn, "Data Source")) {
    5353           18 :         lineType = StatLineType::DataSourceLine;
    5354        10161 :     } else if (has_prefix(lineIn, "WMO Station")) {
    5355           18 :         lineType = StatLineType::WMOStationLine;
    5356        10143 :     } else if (has(lineIn, "Design Conditions")) {
    5357           35 :         if (!desConditionlinepassed) {
    5358           18 :             desConditionlinepassed = true;
    5359           18 :             lineType = StatLineType::DesignConditionsLine;
    5360              :         }
    5361        10108 :     } else if (has_prefix(lineIn, "\tHeating")) {
    5362           18 :         if (!heatingDesignlinepassed) {
    5363           18 :             heatingDesignlinepassed = true;
    5364           18 :             lineType = StatLineType::HeatingConditionsLine;
    5365              :         }
    5366        10090 :     } else if (has_prefix(lineIn, "\tCooling")) {
    5367           18 :         if (!coolingDesignlinepassed) {
    5368           18 :             coolingDesignlinepassed = true;
    5369           18 :             lineType = StatLineType::CoolingConditionsLine;
    5370              :         }
    5371        10072 :     } else if (has(lineIn, "(standard) heating degree-days (18.3")) {
    5372           18 :         lineType = StatLineType::StdHDDLine;
    5373        10054 :     } else if (has(lineIn, "(standard) cooling degree-days (10")) {
    5374           20 :         lineType = StatLineType::StdCDDLine;
    5375              : 
    5376        10034 :     } else if (has(lineIn, "Maximum Dry Bulb")) {
    5377           18 :         lineType = StatLineType::MaxDryBulbLine;
    5378        10016 :     } else if (has(lineIn, "Minimum Dry Bulb")) {
    5379           18 :         lineType = StatLineType::MinDryBulbLine;
    5380         9998 :     } else if (has(lineIn, "Maximum Dew Point")) {
    5381           18 :         lineType = StatLineType::MaxDewPointLine;
    5382         9980 :     } else if (has(lineIn, "Minimum Dew Point")) {
    5383           18 :         lineType = StatLineType::MinDewPointLine;
    5384         9962 :     } else if (has(lineIn, "(wthr file) heating degree-days (18") || has(lineIn, "heating degree-days (18")) {
    5385           18 :         lineType = StatLineType::WithHDDLine;
    5386         9944 :     } else if (has(lineIn, "(wthr file) cooling degree-days (10") || has(lineIn, "cooling degree-days (10")) {
    5387           18 :         lineType = StatLineType::WithCDDLine;
    5388              : 
    5389         9926 :     } else if (has(lineIn, "Statistics for Liquid Precipitation")) {
    5390           18 :         insideLiquidPrecipitation = true;
    5391         9908 :     } else if (insideLiquidPrecipitation && has(lineIn, "Total")) {
    5392           18 :         lineType = StatLineType::MonthlyPrec;
    5393         9890 :     } else if (insideLiquidPrecipitation && has(lineIn, "Max Hourly")) {
    5394           18 :         lineType = StatLineType::MaxHourlyPrec;
    5395           18 :         insideLiquidPrecipitation = false;
    5396              :     }
    5397              : 
    5398              :     // these not part of big if/else because sequential
    5399        10269 :     if (lineType == StatLineType::KoppenDes1Line && isKoppen) {
    5400           18 :         lineType = StatLineType::KoppenDes2Line;
    5401              :     }
    5402        10269 :     if (lineType == StatLineType::KoppenLine && isKoppen) {
    5403           18 :         lineType = StatLineType::KoppenDes1Line;
    5404              :     }
    5405        10269 :     if (has(lineIn, "ppen classification)")) {
    5406           20 :         lineType = StatLineType::KoppenLine;
    5407              :     }
    5408        10269 :     if (lineType == StatLineType::AshStdDes2Line) {
    5409           18 :         lineType = StatLineType::AshStdDes3Line;
    5410              :     }
    5411        10269 :     if (lineType == StatLineType::AshStdDes1Line) {
    5412           18 :         lineType = StatLineType::AshStdDes2Line;
    5413              :     }
    5414        10269 :     if (lineType == StatLineType::AshStdLine) {
    5415           18 :         lineType = StatLineType::AshStdDes1Line;
    5416              :     }
    5417        10269 :     if (has(lineIn, "ASHRAE Standard")) {
    5418           18 :         lineType = StatLineType::AshStdLine;
    5419              :     }
    5420        10269 : }
    5421              : 
    5422           74 : void FillWeatherPredefinedEntries(EnergyPlusData &state)
    5423              : {
    5424              :     // SUBROUTINE INFORMATION:
    5425              :     //       AUTHOR         Jason Glazer
    5426              :     //       DATE WRITTEN   Feb 2008
    5427              :     //       MODIFIED       na
    5428              :     //       RE-ENGINEERED  na
    5429              : 
    5430              :     // PURPOSE OF THIS SUBROUTINE:
    5431              :     //   Read the STAT file for the active weather file and summarize in a predefined report.
    5432              :     //   The stat file that is attached may have several formats -- from evolution of the
    5433              :     //   stat file from the weather converter (or others that produce a similar stat file).
    5434              : 
    5435              :     // Using/Aliasing
    5436              :     using namespace OutputReportPredefined;
    5437              : 
    5438              :     // SUBROUTINE PARAMETER DEFINITIONS:
    5439          204 :     static std::string const degChar("°");
    5440              : 
    5441           74 :     if (!FileSystem::fileExists(state.files.inStatFilePath.filePath)) {
    5442           56 :         return;
    5443              :     }
    5444              : 
    5445           18 :     auto const &ort = state.dataOutRptTab;
    5446              : 
    5447              :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
    5448              : 
    5449           18 :     StatLineType lineTypeinterim = StatLineType::Initialized;
    5450              :     std::string::size_type ashPtr;
    5451              :     std::string::size_type lnPtr;
    5452              :     int col1;
    5453              :     int col2;
    5454              :     int col3;
    5455              :     std::string::size_type sposlt;
    5456              :     std::string::size_type eposlt;
    5457              :     std::string::size_type sposlg;
    5458              :     std::string::size_type eposlg;
    5459              :     std::string::size_type spostz;
    5460              :     std::string::size_type epostz;
    5461           18 :     std::string ashDesYear;
    5462           18 :     std::string ashZone; // ashrae climate zone
    5463           18 :     std::string curNameWithSIUnits;
    5464           18 :     std::string curNameAndUnits;
    5465              :     int indexUnitConv;
    5466              : 
    5467           18 :     bool isASHRAE = false;
    5468           18 :     bool iscalc = false;
    5469           18 :     bool isKoppen = false;
    5470           18 :     bool heatingDesignlinepassed = false;
    5471           18 :     bool coolingDesignlinepassed = false;
    5472           18 :     bool desConditionlinepassed = false;
    5473           18 :     bool insideLiquidPrecipitation = false;
    5474           18 :     std::string storeASHRAEHDD;
    5475           18 :     std::string storeASHRAECDD;
    5476              : 
    5477           36 :     auto statFile = state.files.inStatFilePath.open(state, "FillWeatherPredefinedEntries");
    5478        10283 :     while (statFile.good()) { // end of file, or error
    5479        10265 :         StatLineType lineType = lineTypeinterim;
    5480        10265 :         auto lineIn = statFile.readLine().data;
    5481              :         // reconcile line with different versions of stat file
    5482              :         // v7.1 added version as first line.
    5483        10265 :         strip(lineIn);
    5484        10265 :         parseStatLine(
    5485              :             lineIn, lineType, desConditionlinepassed, heatingDesignlinepassed, coolingDesignlinepassed, isKoppen, insideLiquidPrecipitation);
    5486              : 
    5487        10265 :         switch (lineType) {
    5488           18 :         case StatLineType::StatisticsLine: { // Statistics for USA_CA_San.Francisco_TMY2
    5489           18 :             PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "Reference", lineIn.substr(15));
    5490           18 :         } break;
    5491           18 :         case StatLineType::LocationLine: { // Location -- SAN_FRANCISCO CA USA
    5492           18 :             PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "Site:Location", lineIn.substr(11));
    5493           18 :         } break;
    5494           18 :         case StatLineType::LatLongLine: { //      {N 37° 37'} {W 122° 22'} {GMT -8.0 Hours}
    5495              :             // find the {}
    5496           18 :             sposlt = index(lineIn, '{');
    5497           18 :             eposlt = index(lineIn, '}');
    5498           18 :             if (sposlt != std::string::npos && eposlt != std::string::npos) {
    5499           18 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "Latitude", lineIn.substr(sposlt, eposlt - sposlt + 1));
    5500              :                 // redefine so next scan can go with {}
    5501           18 :                 lineIn[sposlt] = '[';
    5502           18 :                 lineIn[eposlt] = ']';
    5503              :             } else {
    5504            0 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "Latitude", "not found");
    5505              :             }
    5506           18 :             sposlg = index(lineIn, '{');
    5507           18 :             eposlg = index(lineIn, '}');
    5508           18 :             if (sposlg != std::string::npos && eposlg != std::string::npos) {
    5509           18 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "Longitude", lineIn.substr(sposlg, eposlg - sposlg + 1));
    5510              :                 // redefine so next scan can go with {}
    5511           18 :                 lineIn[sposlg] = '[';
    5512           18 :                 lineIn[eposlg] = ']';
    5513              :             } else {
    5514            0 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "Longitude", "not found");
    5515              :             }
    5516           18 :             spostz = index(lineIn, '{');
    5517           18 :             epostz = index(lineIn, '}');
    5518           18 :             if (spostz != std::string::npos && epostz != std::string::npos) {
    5519           18 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "Time Zone", lineIn.substr(spostz, epostz - spostz + 1));
    5520              :                 // redefine so next scan can go with {}
    5521           18 :                 lineIn[spostz] = '[';
    5522           18 :                 lineIn[epostz] = ']';
    5523              :             } else {
    5524            0 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "Time Zone", "not found");
    5525              :             }
    5526           18 :         } break;
    5527           18 :         case StatLineType::ElevationLine: { // Elevation --     5m above sea level
    5528           18 :             lnPtr = index(lineIn.substr(12), 'm');
    5529           18 :             if (lnPtr != std::string::npos) {
    5530           18 :                 curNameWithSIUnits = "Elevation (m) " + lineIn.substr(12 + lnPtr + 2);
    5531           18 :                 if (ort->ip()) {
    5532            1 :                     LookupSItoIP(state, curNameWithSIUnits, indexUnitConv, curNameAndUnits);
    5533            2 :                     PreDefTableEntry(state,
    5534            1 :                                      state.dataOutRptPredefined->pdchWthrVal,
    5535              :                                      curNameAndUnits,
    5536            2 :                                      RealToStr(ConvertIP(state, indexUnitConv, StrToReal(lineIn.substr(12, lnPtr))), 1));
    5537              :                 } else {
    5538           17 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, curNameWithSIUnits, lineIn.substr(12, lnPtr));
    5539              :                 }
    5540              :             } else {
    5541            0 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "Elevation", "not found");
    5542              :             }
    5543           18 :         } break;
    5544           18 :         case StatLineType::StdPressureLine: { // Standard Pressure at Elevation -- 101265Pa
    5545           18 :             PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "Standard Pressure at Elevation", lineIn.substr(34));
    5546           18 :         } break;
    5547           18 :         case StatLineType::DataSourceLine: { // Data Source -- TMY2-23234
    5548           18 :             PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "Data Source", lineIn.substr(15));
    5549           18 :         } break;
    5550           18 :         case StatLineType::WMOStationLine: { // WMO Station 724940
    5551           18 :             PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "WMO Station", lineIn.substr(12));
    5552           18 :         } break;
    5553           18 :         case StatLineType::DesignConditionsLine: { //  - Using Design Conditions from "Climate Design Data 2005 ASHRAE Handbook"
    5554           18 :             ashPtr = index(lineIn, "ASHRAE");
    5555           18 :             if (ashPtr != std::string::npos) {
    5556           18 :                 isASHRAE = true;
    5557           18 :                 iscalc = true;
    5558           18 :                 if (ashPtr > 4u) { // Autodesk:BoundsViolation IF block added to protect against ashPtr<=5
    5559           18 :                     ashDesYear = lineIn.substr(ashPtr - 5, 5);
    5560              :                 } else {
    5561            0 :                     ashDesYear = "";
    5562              :                 }
    5563           36 :                 PreDefTableEntry(state,
    5564           18 :                                  state.dataOutRptPredefined->pdchWthrVal,
    5565              :                                  "Weather File Design Conditions",
    5566           36 :                                  "Climate Design Data " + ashDesYear + "ASHRAE Handbook");
    5567            0 :             } else if (has(lineIn, "not calculated") || lineIn == "") {
    5568            0 :                 iscalc = false;
    5569            0 :                 PreDefTableEntry(
    5570            0 :                     state, state.dataOutRptPredefined->pdchWthrVal, "Weather File Design Conditions", "not calculated, Number of days < 1 year");
    5571              :             } else {
    5572            0 :                 isASHRAE = false;
    5573            0 :                 iscalc = true;
    5574            0 :                 PreDefTableEntry(
    5575            0 :                     state, state.dataOutRptPredefined->pdchWthrVal, "Weather File Design Conditions", "Calculated from the weather file");
    5576              :             }
    5577           18 :         } break;
    5578           18 :         case StatLineType::HeatingConditionsLine: { //  winter/heating design conditions
    5579           18 :             if (iscalc) {
    5580           18 :                 if (isASHRAE) {
    5581           18 :                     if (ashDesYear == "2001") {
    5582            0 :                         if (ort->ip()) {
    5583            0 :                             curNameWithSIUnits = "Heating Design Temperature 99.6% (C)";
    5584            0 :                             LookupSItoIP(state, curNameWithSIUnits, indexUnitConv, curNameAndUnits);
    5585            0 :                             PreDefTableEntry(state,
    5586            0 :                                              state.dataOutRptPredefined->pdchWthrVal,
    5587              :                                              curNameAndUnits,
    5588            0 :                                              RealToStr(ConvertIP(state, indexUnitConv, StrToReal(GetColumnUsingTabs(lineIn, 2))), 1) + degChar);
    5589            0 :                             PreDefTableEntry(state,
    5590            0 :                                              state.dataOutRptPredefined->pdchWthrVal,
    5591              :                                              "Heating Design Temperature 99% (F)",
    5592            0 :                                              RealToStr(ConvertIP(state, indexUnitConv, StrToReal(GetColumnUsingTabs(lineIn, 3))), 1) + degChar);
    5593              :                         } else {
    5594            0 :                             PreDefTableEntry(state,
    5595            0 :                                              state.dataOutRptPredefined->pdchWthrVal,
    5596              :                                              "Heating Design Temperature 99.6% (C)",
    5597            0 :                                              GetColumnUsingTabs(lineIn, 2) + degChar);
    5598            0 :                             PreDefTableEntry(state,
    5599            0 :                                              state.dataOutRptPredefined->pdchWthrVal,
    5600              :                                              "Heating Design Temperature 99% (C)",
    5601            0 :                                              GetColumnUsingTabs(lineIn, 3) + degChar);
    5602              :                         }
    5603              :                     } else { // 2005 and 2009 are the same
    5604           18 :                         if (ort->ip()) {
    5605            1 :                             curNameWithSIUnits = "Heating Design Temperature 99.6% (C)";
    5606            1 :                             LookupSItoIP(state, curNameWithSIUnits, indexUnitConv, curNameAndUnits);
    5607            2 :                             PreDefTableEntry(state,
    5608            1 :                                              state.dataOutRptPredefined->pdchWthrVal,
    5609              :                                              curNameAndUnits,
    5610            2 :                                              RealToStr(ConvertIP(state, indexUnitConv, StrToReal(GetColumnUsingTabs(lineIn, 4))), 1) + degChar);
    5611            2 :                             PreDefTableEntry(state,
    5612            1 :                                              state.dataOutRptPredefined->pdchWthrVal,
    5613              :                                              "Heating Design Temperature 99% (F)",
    5614            2 :                                              RealToStr(ConvertIP(state, indexUnitConv, StrToReal(GetColumnUsingTabs(lineIn, 5))), 1) + degChar);
    5615              :                         } else {
    5616           34 :                             PreDefTableEntry(state,
    5617           17 :                                              state.dataOutRptPredefined->pdchWthrVal,
    5618              :                                              "Heating Design Temperature 99.6% (C)",
    5619           34 :                                              GetColumnUsingTabs(lineIn, 4) + degChar);
    5620           34 :                             PreDefTableEntry(state,
    5621           17 :                                              state.dataOutRptPredefined->pdchWthrVal,
    5622              :                                              "Heating Design Temperature 99% (C)",
    5623           34 :                                              GetColumnUsingTabs(lineIn, 5) + degChar);
    5624              :                         }
    5625              :                     }
    5626              :                 } else { // from weather file
    5627            0 :                     if (is_blank(GetColumnUsingTabs(lineIn, 5))) {
    5628            0 :                         col1 = 3;
    5629            0 :                         col2 = 4;
    5630              :                     } else {
    5631            0 :                         col1 = 4;
    5632            0 :                         col2 = 5;
    5633              :                     }
    5634            0 :                     if (ort->ip()) {
    5635            0 :                         curNameWithSIUnits = "Heating Design Temperature 99.6% (C)";
    5636            0 :                         LookupSItoIP(state, curNameWithSIUnits, indexUnitConv, curNameAndUnits);
    5637            0 :                         PreDefTableEntry(state,
    5638            0 :                                          state.dataOutRptPredefined->pdchWthrVal,
    5639              :                                          curNameAndUnits,
    5640            0 :                                          RealToStr(ConvertIP(state, indexUnitConv, StrToReal(GetColumnUsingTabs(lineIn, col1))), 1) + degChar);
    5641            0 :                         PreDefTableEntry(state,
    5642            0 :                                          state.dataOutRptPredefined->pdchWthrVal,
    5643              :                                          "Heating Design Temperature 99% (F)",
    5644            0 :                                          RealToStr(ConvertIP(state, indexUnitConv, StrToReal(GetColumnUsingTabs(lineIn, col2))), 1) + degChar);
    5645              :                     } else {
    5646            0 :                         PreDefTableEntry(state,
    5647            0 :                                          state.dataOutRptPredefined->pdchWthrVal,
    5648              :                                          "Heating Design Temperature 99.6% (C)",
    5649            0 :                                          GetColumnUsingTabs(lineIn, col1) + degChar);
    5650            0 :                         PreDefTableEntry(state,
    5651            0 :                                          state.dataOutRptPredefined->pdchWthrVal,
    5652              :                                          "Heating Design Temperature 99% (C)",
    5653            0 :                                          GetColumnUsingTabs(lineIn, col2) + degChar);
    5654              :                     }
    5655              :                 }
    5656              :             }
    5657           18 :         } break;
    5658           18 :         case StatLineType::CoolingConditionsLine: { //  summer/cooling design conditions
    5659           18 :             if (iscalc) {
    5660           18 :                 if (isASHRAE) {
    5661           18 :                     if (ashDesYear == "2001") {
    5662            0 :                         if (ort->ip()) {
    5663            0 :                             curNameWithSIUnits = "Cooling Design Temperature 0.4% (C)";
    5664            0 :                             LookupSItoIP(state, curNameWithSIUnits, indexUnitConv, curNameAndUnits);
    5665            0 :                             PreDefTableEntry(state,
    5666            0 :                                              state.dataOutRptPredefined->pdchWthrVal,
    5667              :                                              curNameAndUnits,
    5668            0 :                                              RealToStr(ConvertIP(state, indexUnitConv, StrToReal(GetColumnUsingTabs(lineIn, 2))), 1) + degChar);
    5669            0 :                             PreDefTableEntry(state,
    5670            0 :                                              state.dataOutRptPredefined->pdchWthrVal,
    5671              :                                              "Cooling Design Temperature 1% (F)",
    5672            0 :                                              RealToStr(ConvertIP(state, indexUnitConv, StrToReal(GetColumnUsingTabs(lineIn, 4))), 1) + degChar);
    5673            0 :                             PreDefTableEntry(state,
    5674            0 :                                              state.dataOutRptPredefined->pdchWthrVal,
    5675              :                                              "Cooling Design Temperature 2% (F)",
    5676            0 :                                              RealToStr(ConvertIP(state, indexUnitConv, StrToReal(GetColumnUsingTabs(lineIn, 6))), 1) + degChar);
    5677              :                         } else {
    5678            0 :                             PreDefTableEntry(state,
    5679            0 :                                              state.dataOutRptPredefined->pdchWthrVal,
    5680              :                                              "Cooling Design Temperature 0.4% (C)",
    5681            0 :                                              GetColumnUsingTabs(lineIn, 2) + degChar);
    5682            0 :                             PreDefTableEntry(state,
    5683            0 :                                              state.dataOutRptPredefined->pdchWthrVal,
    5684              :                                              "Cooling Design Temperature 1% (C)",
    5685            0 :                                              GetColumnUsingTabs(lineIn, 4) + degChar);
    5686            0 :                             PreDefTableEntry(state,
    5687            0 :                                              state.dataOutRptPredefined->pdchWthrVal,
    5688              :                                              "Cooling Design Temperature 2% (C)",
    5689            0 :                                              GetColumnUsingTabs(lineIn, 6) + degChar);
    5690              :                         }
    5691              :                     } else { // 2005 and 2009 are the same
    5692           18 :                         if (ort->ip()) {
    5693            1 :                             curNameWithSIUnits = "Cooling Design Temperature 0.4% (C)";
    5694            1 :                             LookupSItoIP(state, curNameWithSIUnits, indexUnitConv, curNameAndUnits);
    5695            2 :                             PreDefTableEntry(state,
    5696            1 :                                              state.dataOutRptPredefined->pdchWthrVal,
    5697              :                                              curNameAndUnits,
    5698            2 :                                              RealToStr(ConvertIP(state, indexUnitConv, StrToReal(GetColumnUsingTabs(lineIn, 5))), 1) + degChar);
    5699            2 :                             PreDefTableEntry(state,
    5700            1 :                                              state.dataOutRptPredefined->pdchWthrVal,
    5701              :                                              "Cooling Design Temperature 1% (F)",
    5702            2 :                                              RealToStr(ConvertIP(state, indexUnitConv, StrToReal(GetColumnUsingTabs(lineIn, 7))), 1) + degChar);
    5703            2 :                             PreDefTableEntry(state,
    5704            1 :                                              state.dataOutRptPredefined->pdchWthrVal,
    5705              :                                              "Cooling Design Temperature 2% (F)",
    5706            2 :                                              RealToStr(ConvertIP(state, indexUnitConv, StrToReal(GetColumnUsingTabs(lineIn, 9))), 1) + degChar);
    5707              :                         } else {
    5708           34 :                             PreDefTableEntry(state,
    5709           17 :                                              state.dataOutRptPredefined->pdchWthrVal,
    5710              :                                              "Cooling Design Temperature 0.4% (C)",
    5711           34 :                                              GetColumnUsingTabs(lineIn, 5) + degChar);
    5712           34 :                             PreDefTableEntry(state,
    5713           17 :                                              state.dataOutRptPredefined->pdchWthrVal,
    5714              :                                              "Cooling Design Temperature 1% (C)",
    5715           34 :                                              GetColumnUsingTabs(lineIn, 7) + degChar);
    5716           34 :                             PreDefTableEntry(state,
    5717           17 :                                              state.dataOutRptPredefined->pdchWthrVal,
    5718              :                                              "Cooling Design Temperature 2% (C)",
    5719           34 :                                              GetColumnUsingTabs(lineIn, 9) + degChar);
    5720              :                         }
    5721              :                     }
    5722              :                 } else { // from weather file
    5723            0 :                     if (is_blank(GetColumnUsingTabs(lineIn, 6))) {
    5724            0 :                         col1 = 3;
    5725            0 :                         col2 = 4;
    5726            0 :                         col3 = 5;
    5727              :                     } else {
    5728            0 :                         col1 = 4;
    5729            0 :                         col2 = 5;
    5730            0 :                         col3 = 6;
    5731              :                     }
    5732            0 :                     if (ort->ip()) {
    5733            0 :                         curNameWithSIUnits = "Cooling Design Temperature 0.4% (C)";
    5734            0 :                         LookupSItoIP(state, curNameWithSIUnits, indexUnitConv, curNameAndUnits);
    5735            0 :                         PreDefTableEntry(state,
    5736            0 :                                          state.dataOutRptPredefined->pdchWthrVal,
    5737              :                                          curNameAndUnits,
    5738            0 :                                          RealToStr(ConvertIP(state, indexUnitConv, StrToReal(GetColumnUsingTabs(lineIn, col1))), 1) + degChar);
    5739            0 :                         PreDefTableEntry(state,
    5740            0 :                                          state.dataOutRptPredefined->pdchWthrVal,
    5741              :                                          "Cooling Design Temperature 1% (F)",
    5742            0 :                                          RealToStr(ConvertIP(state, indexUnitConv, StrToReal(GetColumnUsingTabs(lineIn, col2))), 1) + degChar);
    5743            0 :                         PreDefTableEntry(state,
    5744            0 :                                          state.dataOutRptPredefined->pdchWthrVal,
    5745              :                                          "Cooling Design Temperature 2% (F)",
    5746            0 :                                          RealToStr(ConvertIP(state, indexUnitConv, StrToReal(GetColumnUsingTabs(lineIn, col3))), 1) + degChar);
    5747              :                     } else {
    5748            0 :                         PreDefTableEntry(state,
    5749            0 :                                          state.dataOutRptPredefined->pdchWthrVal,
    5750              :                                          "Cooling Design Temperature 0.4% (C)",
    5751            0 :                                          GetColumnUsingTabs(lineIn, col1) + degChar);
    5752            0 :                         PreDefTableEntry(state,
    5753            0 :                                          state.dataOutRptPredefined->pdchWthrVal,
    5754              :                                          "Cooling Design Temperature 1% (C)",
    5755            0 :                                          GetColumnUsingTabs(lineIn, col2) + degChar);
    5756            0 :                         PreDefTableEntry(state,
    5757            0 :                                          state.dataOutRptPredefined->pdchWthrVal,
    5758              :                                          "Cooling Design Temperature 2% (C)",
    5759            0 :                                          GetColumnUsingTabs(lineIn, col3) + degChar);
    5760              :                     }
    5761              :                 }
    5762              :             }
    5763           18 :         } break;
    5764           18 :         case StatLineType::StdHDDLine: { //  - 1745 annual (standard) heating degree-days (10°C baseline)
    5765           18 :             storeASHRAEHDD = lineIn.substr(2, 4);
    5766           18 :         } break;
    5767           18 :         case StatLineType::StdCDDLine: { //  -  464 annual (standard) cooling degree-days (18.3°C baseline)
    5768           18 :             storeASHRAECDD = lineIn.substr(2, 4);
    5769           18 :         } break;
    5770           18 :         case StatLineType::MaxDryBulbLine: { //   - Maximum Dry Bulb temperature of  35.6°C on Jul  9
    5771           18 :             sposlt = index(lineIn, "of");
    5772           18 :             eposlt = index(lineIn, 'C');
    5773           18 :             sposlt += 2;
    5774           18 :             size_t deg_index = index(lineIn, degChar);
    5775           18 :             if (deg_index != std::string::npos) {
    5776            0 :                 eposlt = deg_index - 1;
    5777              :             } else {
    5778           18 :                 eposlt -= 2;
    5779              :             }
    5780           18 :             if (sposlt != std::string::npos && eposlt != std::string::npos) {
    5781           36 :                 if (ort->ip()) {
    5782            1 :                     curNameWithSIUnits = "Maximum Dry Bulb Temperature (C)";
    5783            1 :                     LookupSItoIP(state, curNameWithSIUnits, indexUnitConv, curNameAndUnits);
    5784            2 :                     PreDefTableEntry(state,
    5785            1 :                                      state.dataOutRptPredefined->pdchWthrVal,
    5786              :                                      curNameAndUnits,
    5787            2 :                                      RealToStr(ConvertIP(state, indexUnitConv, StrToReal(lineIn.substr(sposlt, eposlt - sposlt + 1))), 1) + degChar);
    5788              :                 } else {
    5789           34 :                     PreDefTableEntry(state,
    5790           17 :                                      state.dataOutRptPredefined->pdchWthrVal,
    5791              :                                      "Maximum Dry Bulb Temperature (C)",
    5792           34 :                                      lineIn.substr(sposlt, eposlt - sposlt + 1) + degChar);
    5793              :                 }
    5794              :             } else {
    5795            0 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "Maximum Dry Bulb Temperature", "not found");
    5796              :             }
    5797           18 :             sposlt = index(lineIn, "on");
    5798           18 :             sposlt += 2;
    5799           18 :             if (sposlt != std::string::npos) {
    5800           18 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "Maximum Dry Bulb Occurs on", lineIn.substr(sposlt));
    5801              :             } else {
    5802            0 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "Maximum Dry Bulb Occurs on", "not found");
    5803              :             }
    5804           18 :         } break;
    5805           18 :         case StatLineType::MinDryBulbLine: { //   - Minimum Dry Bulb temperature of -22.8°C on Jan  7
    5806           18 :             sposlt = index(lineIn, "of");
    5807           18 :             eposlt = index(lineIn, 'C');
    5808           18 :             sposlt += 2;
    5809           18 :             size_t deg_index = index(lineIn, degChar);
    5810           18 :             if (deg_index != std::string::npos) {
    5811            0 :                 eposlt = deg_index - 1;
    5812              :             } else {
    5813           18 :                 eposlt -= 2;
    5814              :             }
    5815           18 :             if (sposlt != std::string::npos && eposlt != std::string::npos) {
    5816           36 :                 if (ort->ip()) {
    5817            1 :                     curNameWithSIUnits = "Minimum Dry Bulb Temperature (C)";
    5818            1 :                     LookupSItoIP(state, curNameWithSIUnits, indexUnitConv, curNameAndUnits);
    5819            2 :                     PreDefTableEntry(state,
    5820            1 :                                      state.dataOutRptPredefined->pdchWthrVal,
    5821              :                                      curNameAndUnits,
    5822            2 :                                      RealToStr(ConvertIP(state, indexUnitConv, StrToReal(lineIn.substr(sposlt, eposlt - sposlt + 1))), 1) + degChar);
    5823              :                 } else {
    5824           34 :                     PreDefTableEntry(state,
    5825           17 :                                      state.dataOutRptPredefined->pdchWthrVal,
    5826              :                                      "Minimum Dry Bulb Temperature (C)",
    5827           34 :                                      lineIn.substr(sposlt, eposlt - sposlt + 1) + degChar);
    5828              :                 }
    5829              :             } else {
    5830            0 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "Minimum Dry Bulb Temperature", "not found");
    5831              :             }
    5832           18 :             sposlt = index(lineIn, "on");
    5833           18 :             sposlt += 2;
    5834           18 :             if (sposlt != std::string::npos) {
    5835           18 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "Minimum Dry Bulb Occurs on", lineIn.substr(sposlt));
    5836              :             } else {
    5837            0 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "Minimum Dry Bulb Occurs on", "not found");
    5838              :             }
    5839           18 :         } break;
    5840           18 :         case StatLineType::MaxDewPointLine: { //   - Maximum Dew Point temperature of  25.6°C on Aug  4
    5841           18 :             sposlt = index(lineIn, "of");
    5842           18 :             eposlt = index(lineIn, 'C');
    5843           18 :             sposlt += 2;
    5844           18 :             size_t deg_index = index(lineIn, degChar);
    5845           18 :             if (deg_index != std::string::npos) {
    5846            0 :                 eposlt = deg_index - 1;
    5847              :             } else {
    5848           18 :                 eposlt -= 2;
    5849              :             }
    5850           18 :             if (sposlt != std::string::npos && eposlt != std::string::npos) {
    5851           36 :                 if (ort->ip()) {
    5852            1 :                     curNameWithSIUnits = "Maximum Dew Point Temperature (C)";
    5853            1 :                     LookupSItoIP(state, curNameWithSIUnits, indexUnitConv, curNameAndUnits);
    5854            2 :                     PreDefTableEntry(state,
    5855            1 :                                      state.dataOutRptPredefined->pdchWthrVal,
    5856              :                                      curNameAndUnits,
    5857            2 :                                      RealToStr(ConvertIP(state, indexUnitConv, StrToReal(lineIn.substr(sposlt, eposlt - sposlt + 1))), 1) + degChar);
    5858              :                 } else {
    5859           34 :                     PreDefTableEntry(state,
    5860           17 :                                      state.dataOutRptPredefined->pdchWthrVal,
    5861              :                                      "Maximum Dew Point Temperature (C)",
    5862           34 :                                      lineIn.substr(sposlt, eposlt - sposlt + 1) + degChar);
    5863              :                 }
    5864              :             } else {
    5865            0 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "Maximum Dew Point Temperature", "not found");
    5866              :             }
    5867           18 :             sposlt = index(lineIn, "on");
    5868           18 :             sposlt += 2;
    5869           18 :             if (sposlt != std::string::npos) {
    5870           18 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "Maximum Dew Point Occurs on", lineIn.substr(sposlt));
    5871              :             } else {
    5872            0 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "Maximum Dew Point Occurs on", "not found");
    5873              :             }
    5874           18 :         } break;
    5875           18 :         case StatLineType::MinDewPointLine: { //   - Minimum Dew Point temperature of -28.9°C on Dec 31
    5876           18 :             sposlt = index(lineIn, "of");
    5877           18 :             eposlt = index(lineIn, 'C');
    5878           18 :             sposlt += 2;
    5879           18 :             size_t deg_index = index(lineIn, degChar);
    5880           18 :             if (deg_index != std::string::npos) {
    5881            0 :                 eposlt = deg_index - 1;
    5882              :             } else {
    5883           18 :                 eposlt -= 2;
    5884              :             }
    5885           18 :             if (sposlt != std::string::npos && eposlt != std::string::npos) {
    5886           36 :                 if (ort->ip()) {
    5887            1 :                     curNameWithSIUnits = "Minimum Dew Point Temperature (C)";
    5888            1 :                     LookupSItoIP(state, curNameWithSIUnits, indexUnitConv, curNameAndUnits);
    5889            2 :                     PreDefTableEntry(state,
    5890            1 :                                      state.dataOutRptPredefined->pdchWthrVal,
    5891              :                                      curNameAndUnits,
    5892            2 :                                      RealToStr(ConvertIP(state, indexUnitConv, StrToReal(lineIn.substr(sposlt, eposlt - sposlt + 1))), 1) + degChar);
    5893              :                 } else {
    5894           34 :                     PreDefTableEntry(state,
    5895           17 :                                      state.dataOutRptPredefined->pdchWthrVal,
    5896              :                                      "Minimum Dew Point Temperature (C)",
    5897           34 :                                      lineIn.substr(sposlt, eposlt - sposlt + 1) + degChar);
    5898              :                 }
    5899              :             } else {
    5900            0 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "Minimum Dew Point Temperature", "not found");
    5901              :             }
    5902           18 :             sposlt = index(lineIn, "on");
    5903           18 :             sposlt += 2;
    5904           18 :             if (sposlt != std::string::npos) {
    5905           18 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "Minimum Dew Point Occurs on", lineIn.substr(sposlt));
    5906              :             } else {
    5907            0 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "Minimum Dew Point Occurs on", "not found");
    5908              :             }
    5909           18 :         } break;
    5910           18 :         case StatLineType::MonthlyPrec: { //   - Monthly precipitation mm
    5911           18 :             std::stringstream ss(lineIn);
    5912           18 :             std::vector<std::string> result;
    5913          288 :             while (ss.good()) {
    5914          270 :                 std::string substr;
    5915          270 :                 getline(ss, substr, '\t');
    5916          270 :                 substr.erase(remove_if(substr.begin(), substr.end(), isspace), substr.end());
    5917          270 :                 result.push_back(substr);
    5918          270 :             }
    5919              :             int monthlyTotalPrecFromStat[12];
    5920           18 :             int annualTotalPrecFromStat = 0;
    5921          234 :             for (int i = 0; i < 12; i++) {
    5922          216 :                 monthlyTotalPrecFromStat[i] = std::stoi(result[i + 2]);
    5923              :                 // fixme: add to monthly data structure
    5924          216 :                 annualTotalPrecFromStat += monthlyTotalPrecFromStat[i];
    5925              :             }
    5926           18 :             PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "Annual Total Precipitation [mm]", annualTotalPrecFromStat);
    5927              :             // fixme: store the monthly data in some data structure
    5928           18 :         } break;
    5929           18 :         case StatLineType::MaxHourlyPrec: { //   - Highest hourly precipitation in each month
    5930              :             // Split string by \t into substrings and remove the space in each substring
    5931           18 :             std::stringstream ss(lineIn);
    5932           18 :             std::vector<std::string> result;
    5933          288 :             while (ss.good()) {
    5934          270 :                 std::string substr;
    5935          270 :                 getline(ss, substr, '\t');
    5936          270 :                 substr.erase(remove_if(substr.begin(), substr.end(), isspace), substr.end());
    5937          270 :                 result.push_back(substr);
    5938          270 :             }
    5939              :             int MaxHourlyPrecEachMonth[12];
    5940           18 :             int MaxHourlyPrec = 0;
    5941           18 :             int MaxHourlyPrecIdx = 0;
    5942          234 :             for (int i = 0; i < 12; i++) {
    5943          216 :                 MaxHourlyPrecEachMonth[i] = std::stoi(result[i + 2]);
    5944          216 :                 if (MaxHourlyPrecEachMonth[i] > MaxHourlyPrec) {
    5945           19 :                     MaxHourlyPrec = MaxHourlyPrecEachMonth[i];
    5946           19 :                     MaxHourlyPrecIdx = i;
    5947              :                 }
    5948              :             }
    5949           18 :             constexpr std::array<std::string_view, 12> Months{"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
    5950           18 :             PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "Max Hourly Precipitation [mm]", MaxHourlyPrec);
    5951           18 :             PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "Max Hourly Precipitation Occurs in", Months[MaxHourlyPrecIdx]);
    5952           18 :         } break;
    5953           18 :         case StatLineType::WithHDDLine: { //  - 1745 (wthr file) annual heating degree-days (10°C baseline)
    5954           18 :             if (storeASHRAEHDD != "") {
    5955           18 :                 if (ort->ip()) {
    5956            1 :                     curNameWithSIUnits = "ASHRAE Handbook 2009 Heating Degree-Days - base 65°(C)";
    5957            1 :                     LookupSItoIP(state, curNameWithSIUnits, indexUnitConv, curNameAndUnits);
    5958            2 :                     PreDefTableEntry(state,
    5959            1 :                                      state.dataOutRptPredefined->pdchWthrVal,
    5960              :                                      curNameAndUnits,
    5961            2 :                                      RealToStr(ConvertIPdelta(state, indexUnitConv, StrToReal(storeASHRAEHDD)), 1));
    5962              :                 } else {
    5963           34 :                     PreDefTableEntry(
    5964           17 :                         state, state.dataOutRptPredefined->pdchWthrVal, "ASHRAE Handbook 2009 Heating Degree-Days (base 18.3°C)", storeASHRAEHDD);
    5965              :                 }
    5966              :             } else {
    5967            0 :                 if (ort->ip()) {
    5968            0 :                     PreDefTableEntry(
    5969            0 :                         state, state.dataOutRptPredefined->pdchWthrVal, "ASHRAE Handbook 2009 Heating Degree-Days (base 65°F)", "not found");
    5970              :                 } else {
    5971            0 :                     PreDefTableEntry(
    5972            0 :                         state, state.dataOutRptPredefined->pdchWthrVal, "ASHRAE Handbook 2009 Heating Degree-Days (base 18.3°C)", "not found");
    5973              :                 }
    5974              :             }
    5975           18 :             if (ort->ip()) {
    5976            1 :                 curNameWithSIUnits = "Weather File Heating Degree-Days - base 65°(C)";
    5977            1 :                 LookupSItoIP(state, curNameWithSIUnits, indexUnitConv, curNameAndUnits);
    5978            2 :                 PreDefTableEntry(state,
    5979            1 :                                  state.dataOutRptPredefined->pdchWthrVal,
    5980              :                                  curNameAndUnits,
    5981            2 :                                  RealToStr(ConvertIPdelta(state, indexUnitConv, StrToReal(lineIn.substr(2, 4))), 1));
    5982            2 :                 PreDefTableEntry(state,
    5983            1 :                                  state.dataOutRptPredefined->pdchLeedGenData,
    5984              :                                  "Heating Degree Days",
    5985            2 :                                  RealToStr(ConvertIPdelta(state, indexUnitConv, StrToReal(lineIn.substr(2, 4))), 1));
    5986              :             } else {
    5987           17 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "Weather File Heating Degree-Days (base 18°C)", lineIn.substr(2, 4));
    5988           17 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchLeedGenData, "Heating Degree Days", lineIn.substr(2, 4));
    5989              :             }
    5990           18 :             PreDefTableEntry(state, state.dataOutRptPredefined->pdchLeedGenData, "HDD and CDD data source", "Weather File Stat");
    5991           18 :         } break;
    5992           18 :         case StatLineType::WithCDDLine: { //  -  464 (wthr file) annual cooling degree-days (18°C baseline)
    5993           18 :             if (storeASHRAECDD != "") {
    5994           18 :                 if (ort->ip()) {
    5995            1 :                     curNameWithSIUnits = "ASHRAE Handbook 2009  Cooling Degree-Days - base 50°(C)";
    5996            1 :                     LookupSItoIP(state, curNameWithSIUnits, indexUnitConv, curNameAndUnits);
    5997            2 :                     PreDefTableEntry(state,
    5998            1 :                                      state.dataOutRptPredefined->pdchWthrVal,
    5999              :                                      curNameAndUnits,
    6000            2 :                                      RealToStr(ConvertIPdelta(state, indexUnitConv, StrToReal(storeASHRAECDD)), 1));
    6001              :                 } else {
    6002           34 :                     PreDefTableEntry(
    6003           17 :                         state, state.dataOutRptPredefined->pdchWthrVal, "ASHRAE Handbook 2009  Cooling Degree-Days (base 10°C)", storeASHRAECDD);
    6004              :                 }
    6005              :             } else {
    6006            0 :                 if (ort->ip()) {
    6007            0 :                     PreDefTableEntry(
    6008            0 :                         state, state.dataOutRptPredefined->pdchWthrVal, "ASHRAE Handbook 2009  Cooling Degree-Days (base 50°F)", "not found");
    6009              :                 } else {
    6010            0 :                     PreDefTableEntry(
    6011            0 :                         state, state.dataOutRptPredefined->pdchWthrVal, "ASHRAE Handbook 2009  Cooling Degree-Days (base 10°C)", "not found");
    6012              :                 }
    6013              :             }
    6014           18 :             if (ort->ip()) {
    6015            1 :                 curNameWithSIUnits = "Weather File Cooling Degree-Days - base 50°(C)";
    6016            1 :                 LookupSItoIP(state, curNameWithSIUnits, indexUnitConv, curNameAndUnits);
    6017            2 :                 PreDefTableEntry(state,
    6018            1 :                                  state.dataOutRptPredefined->pdchWthrVal,
    6019              :                                  curNameAndUnits,
    6020            2 :                                  RealToStr(ConvertIPdelta(state, indexUnitConv, StrToReal(lineIn.substr(2, 4))), 1));
    6021            2 :                 PreDefTableEntry(state,
    6022            1 :                                  state.dataOutRptPredefined->pdchLeedGenData,
    6023              :                                  "Cooling Degree Days",
    6024            2 :                                  RealToStr(ConvertIPdelta(state, indexUnitConv, StrToReal(lineIn.substr(2, 4))), 1));
    6025              :             } else {
    6026           17 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "Weather File Cooling Degree-Days (base 10°C)", lineIn.substr(2, 4));
    6027           17 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchLeedGenData, "Cooling Degree Days", lineIn.substr(2, 4));
    6028              :             }
    6029           18 :         } break;
    6030           18 :         case StatLineType::KoppenLine: { // - Climate type "BSk" (Köppen classification)
    6031           18 :             if (!has(lineIn, "not shown")) {
    6032           18 :                 isKoppen = true;
    6033           18 :                 if (lineIn[18] == '"') { // two character classification
    6034            0 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "Köppen Classification", lineIn.substr(16, 2));
    6035              :                 } else {
    6036           18 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "Köppen Classification", lineIn.substr(16, 3));
    6037              :                 }
    6038              :             } else {
    6039            0 :                 isKoppen = false;
    6040            0 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "Köppen Recommendation", lineIn.substr(2));
    6041              :             }
    6042           18 :         } break;
    6043           18 :         case StatLineType::KoppenDes1Line: { // - Tropical monsoonal or tradewind-coastal (short dry season, lat. 5-25°)
    6044           18 :             if (isKoppen) {
    6045           18 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "Köppen Description", lineIn.substr(2));
    6046              :             }
    6047           18 :         } break;
    6048           18 :         case StatLineType::KoppenDes2Line: { // - Unbearably humid periods in summer, but passive cooling is possible
    6049           18 :             if (isKoppen) {
    6050           18 :                 if (len(lineIn) > 3) {                 // avoid blank lines
    6051           17 :                     if (lineIn.substr(2, 2) != "**") { // avoid line with warning
    6052           17 :                         PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "Köppen Recommendation", lineIn.substr(2));
    6053              :                     } else {
    6054            0 :                         PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "Köppen Recommendation", "");
    6055              :                     }
    6056              :                 } else {
    6057            1 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "Köppen Recommendation", "");
    6058              :                 }
    6059              :             }
    6060           18 :         } break;
    6061           72 :         case StatLineType::AshStdLine:
    6062              :         case StatLineType::AshStdDes1Line:
    6063              :         case StatLineType::AshStdDes2Line:
    6064              :         case StatLineType::AshStdDes3Line: {
    6065              :             //  - Climate type "1A" (ASHRAE Standards 90.1-2004 and 90.2-2004 Climate Zone)**
    6066           72 :             if (has(lineIn, "Standard")) {
    6067           18 :                 ashZone = lineIn.substr(16, 2);
    6068           18 :                 if (ashZone[1] == '"') {
    6069            0 :                     ashZone[1] = ' ';
    6070              :                 }
    6071           18 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "ASHRAE Climate Zone", ashZone);
    6072           18 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchLeedGenData, "Climate Zone", ashZone);
    6073           18 :                 if (ashZone == "1A") {
    6074            0 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "ASHRAE Description", "Very Hot-Humid");
    6075           18 :                 } else if (ashZone == "1B") {
    6076            0 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "ASHRAE Description", "Very Hot-Dry");
    6077           18 :                 } else if (ashZone == "2A") {
    6078            0 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "ASHRAE Description", "Hot-Humid");
    6079           18 :                 } else if (ashZone == "2B") {
    6080            0 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "ASHRAE Description", "Hot-Dry");
    6081           18 :                 } else if (ashZone == "3A") {
    6082            0 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "ASHRAE Description", "Warm-Humid");
    6083           18 :                 } else if (ashZone == "3B") {
    6084            0 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "ASHRAE Description", "Warm-Dry");
    6085           18 :                 } else if (ashZone == "3C") {
    6086            0 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "ASHRAE Description", "Warm-Marine");
    6087           18 :                 } else if (ashZone == "4A") {
    6088            0 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "ASHRAE Description", "Mixed-Humid");
    6089           18 :                 } else if (ashZone == "4B") {
    6090            0 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "ASHRAE Description", "Mixed-Dry");
    6091           18 :                 } else if (ashZone == "4C") {
    6092            0 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "ASHRAE Description", "Mixed-Marine");
    6093           18 :                 } else if (ashZone == "5A") {
    6094           18 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "ASHRAE Description", "Cool-Humid");
    6095            0 :                 } else if (ashZone == "5B") {
    6096            0 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "ASHRAE Description", "Cool-Dry");
    6097            0 :                 } else if (ashZone == "5C") {
    6098            0 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "ASHRAE Description", "Cool-Marine");
    6099            0 :                 } else if (ashZone == "6A") {
    6100            0 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "ASHRAE Description", "Cold-Humid");
    6101            0 :                 } else if (ashZone == "6B") {
    6102            0 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "ASHRAE Description", "Cold-Dry");
    6103            0 :                 } else if (ashZone == "7 ") {
    6104            0 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "ASHRAE Description", "Very Cold");
    6105            0 :                 } else if (ashZone == "8 ") {
    6106            0 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "ASHRAE Description", "Subarctic");
    6107              :                 }
    6108              :             }
    6109           72 :         } break;
    6110         9779 :         default:
    6111         9779 :             break;
    6112              :         }
    6113        10265 :         lineIn = "";
    6114        10265 :         lineTypeinterim = StatLineType::Initialized;
    6115        10265 :         if (lineType == StatLineType::AshStdDes3Line) {
    6116           18 :             lineTypeinterim = StatLineType::Initialized;
    6117              :         }
    6118        10265 :         if (lineType == StatLineType::AshStdDes2Line) {
    6119           18 :             lineTypeinterim = StatLineType::AshStdDes2Line;
    6120              :         }
    6121        10265 :         if (lineType == StatLineType::AshStdDes1Line) {
    6122           18 :             lineTypeinterim = StatLineType::AshStdDes1Line;
    6123              :         }
    6124        10265 :         if (lineType == StatLineType::AshStdLine) {
    6125           18 :             lineTypeinterim = StatLineType::AshStdLine;
    6126              :         }
    6127        10265 :         if (lineType == StatLineType::KoppenDes2Line) {
    6128           18 :             lineTypeinterim = StatLineType::Initialized;
    6129              :         }
    6130        10265 :         if (lineType == StatLineType::KoppenDes1Line) {
    6131           18 :             lineTypeinterim = StatLineType::KoppenDes1Line;
    6132              :         }
    6133        10265 :         if (lineType == StatLineType::KoppenLine) {
    6134           18 :             lineTypeinterim = StatLineType::KoppenLine;
    6135              :         }
    6136        10265 :     }
    6137           18 : }
    6138              : 
    6139          136 : std::string GetColumnUsingTabs(std::string const &inString, // Input String
    6140              :                                int const colNum             // Column number
    6141              : )
    6142              : {
    6143              :     // SUBROUTINE INFORMATION:
    6144              :     //       AUTHOR         Jason Glazer
    6145              :     //       DATE WRITTEN   March 2008
    6146              :     //       MODIFIED       na
    6147              :     //       RE-ENGINEERED  na
    6148              : 
    6149              :     // PURPOSE OF THIS SUBROUTINE:
    6150              :     //   Assumes that the input string contains tabs that mark the
    6151              :     //   separation between columns. Returns the string that appears
    6152              :     //   in the column specified.
    6153              : 
    6154              :     // SUBROUTINE PARAMETER DEFINITIONS:
    6155              :     static char const tb('\t'); // tab character
    6156              : 
    6157              :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
    6158          136 :     std::string::size_type startPos = 0;
    6159              : 
    6160          136 :     size_t endPos = inString.find_first_of(tb);
    6161          136 :     if (colNum == 1) {
    6162            9 :         if (endPos == std::string::npos) {
    6163            2 :             return inString;
    6164              :         }
    6165            7 :         return inString.substr(startPos, endPos - startPos);
    6166              :     }
    6167          127 :     if (endPos == std::string::npos) {
    6168            4 :         return "";
    6169              :     }
    6170              : 
    6171          125 :     int numCols = 1;
    6172          700 :     while (numCols < colNum) {
    6173          588 :         startPos = endPos + 1;
    6174          588 :         endPos = inString.find_first_of(tb, startPos);
    6175          588 :         ++numCols;
    6176          588 :         if (endPos == std::string::npos) {
    6177           13 :             break;
    6178              :         }
    6179              :     }
    6180          125 :     if (colNum > numCols) {
    6181           12 :         return "";
    6182              :     }
    6183          119 :     if (endPos == std::string::npos) {
    6184            7 :         endPos = inString.size();
    6185              :     }
    6186          119 :     return inString.substr(startPos, endPos - startPos);
    6187              : }
    6188              : 
    6189           73 : void FillRemainingPredefinedEntries(EnergyPlusData &state)
    6190              : {
    6191              :     // SUBROUTINE INFORMATION:
    6192              :     //       AUTHOR         Jason Glazer
    6193              :     //       DATE WRITTEN   May 2007
    6194              :     //       MODIFIED       na
    6195              :     //       RE-ENGINEERED  na
    6196              : 
    6197              :     // PURPOSE OF THIS SUBROUTINE:
    6198              :     //   Just before writing the output reports, will gather up
    6199              :     //   any additional report entries for the predefined reports.
    6200              : 
    6201              :     // Using/Aliasing
    6202           73 :     int NumPrimaryAirSys = state.dataHVACGlobal->NumPrimaryAirSys;
    6203           73 :     int iNumberOfAutoCalcedFields = state.dataOutput->iNumberOfAutoCalcedFields;
    6204           73 :     int iNumberOfAutoSizedFields = state.dataOutput->iNumberOfAutoSizedFields;
    6205           73 :     int iNumberOfDefaultedFields = state.dataOutput->iNumberOfDefaultedFields;
    6206           73 :     int iNumberOfRecords = state.dataOutput->iNumberOfRecords;
    6207           73 :     int iTotalAutoCalculatableFields = state.dataOutput->iTotalAutoCalculatableFields;
    6208           73 :     int iTotalAutoSizableFields = state.dataOutput->iTotalAutoSizableFields;
    6209           73 :     int iTotalFieldsWithDefaults = state.dataOutput->iTotalFieldsWithDefaults;
    6210              : 
    6211              :     Real64 consumptionTotal;
    6212              : 
    6213           73 :     auto const &ort = state.dataOutRptTab;
    6214              : 
    6215           73 :     int StartOfWeek = state.dataEnvrn->RunPeriodStartDayOfWeek;
    6216           73 :     if (StartOfWeek == 0) {
    6217           73 :         StartOfWeek = 2; // if the first day of the week has not been set yet, assume monday
    6218              :     }
    6219              : 
    6220              :     // Interior Connected Lighting Power
    6221           73 :     consumptionTotal = 0.0;
    6222          110 :     for (int iLight = 1; iLight <= state.dataHeatBal->TotLights; ++iLight) {
    6223           37 :         auto const &thisLight = state.dataHeatBal->Lights(iLight);
    6224           37 :         int const iZone = state.dataHeatBal->Lights(iLight).ZonePtr;
    6225           37 :         auto const &thisZone = state.dataHeatBal->Zone(iZone);
    6226              : 
    6227           37 :         Real64 const mult = thisZone.Multiplier * thisZone.ListMultiplier;
    6228           37 :         if (thisZone.SystemZoneNodeNumber > 0) { // conditioned y/n
    6229           32 :             PreDefTableEntry(state, state.dataOutRptPredefined->pdchInLtCond, thisLight.Name, "Y");
    6230              :         } else {
    6231            5 :             PreDefTableEntry(state, state.dataOutRptPredefined->pdchInLtCond, thisLight.Name, "N");
    6232              :         }
    6233          111 :         PreDefTableEntry(state,
    6234           37 :                          state.dataOutRptPredefined->pdchInLtAvgHrSchd,
    6235              :                          thisLight.Name,
    6236           37 :                          thisLight.sched->getAverageWeeklyHoursFullLoad(state, StartOfWeek, state.dataEnvrn->CurrentYearIsLeapYear));
    6237              :         // average operating hours per week
    6238           37 :         if (ort->gatherElapsedTimeBEPS > 0) {
    6239            0 :             state.dataOutRptTab->HrsPerWeek = 24 * 7 * thisLight.SumTimeNotZeroCons / ort->gatherElapsedTimeBEPS;
    6240            0 :             PreDefTableEntry(state, state.dataOutRptPredefined->pdchInLtAvgHrOper, thisLight.Name, state.dataOutRptTab->HrsPerWeek);
    6241              :         }
    6242              :         // full load hours per week
    6243           37 :         if ((thisLight.DesignLevel * ort->gatherElapsedTimeBEPS) > 0) {
    6244            0 :             state.dataOutRptTab->HrsPerWeek =
    6245            0 :                 24 * 7 * thisLight.SumConsumption / (thisLight.DesignLevel * ort->gatherElapsedTimeBEPS * Constant::rSecsInHour);
    6246            0 :             PreDefTableEntry(state, state.dataOutRptPredefined->pdchInLtFullLoadHrs, thisLight.Name, state.dataOutRptTab->HrsPerWeek);
    6247              :         }
    6248           37 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchInLtConsump, thisLight.Name, thisLight.SumConsumption * mult / 1000000000.0);
    6249           37 :         consumptionTotal += thisLight.SumConsumption / 1000000000.0;
    6250              :     }
    6251           73 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchInLtConsump, "Interior Lighting Total", consumptionTotal);
    6252              : 
    6253              :     // Exterior Lighting
    6254           73 :     consumptionTotal = 0.0;
    6255           97 :     for (int iLight = 1; iLight <= state.dataExteriorEnergyUse->NumExteriorLights; ++iLight) {
    6256           24 :         auto const &thisLight = state.dataExteriorEnergyUse->ExteriorLights(iLight);
    6257              : 
    6258           24 :         if (thisLight.ControlMode == ExteriorEnergyUse::LightControlType::ScheduleOnly) { // photocell/schedule
    6259            3 :             PreDefTableEntry(state,
    6260            1 :                              state.dataOutRptPredefined->pdchExLtAvgHrSchd,
    6261              :                              thisLight.Name,
    6262            1 :                              thisLight.sched->getAverageWeeklyHoursFullLoad(state, StartOfWeek, state.dataEnvrn->CurrentYearIsLeapYear));
    6263              :         }
    6264              :         // average operating hours per week
    6265           24 :         if (ort->gatherElapsedTimeBEPS > 0) {
    6266            0 :             state.dataOutRptTab->HrsPerWeek = 24 * 7 * thisLight.SumTimeNotZeroCons / ort->gatherElapsedTimeBEPS;
    6267            0 :             PreDefTableEntry(state, state.dataOutRptPredefined->pdchExLtAvgHrOper, thisLight.Name, state.dataOutRptTab->HrsPerWeek);
    6268              :         }
    6269              :         // full load hours per week
    6270           24 :         if ((thisLight.DesignLevel * ort->gatherElapsedTimeBEPS) > 0) {
    6271            0 :             state.dataOutRptTab->HrsPerWeek =
    6272            0 :                 24 * 7 * thisLight.SumConsumption / (thisLight.DesignLevel * ort->gatherElapsedTimeBEPS * Constant::rSecsInHour);
    6273            0 :             PreDefTableEntry(state, state.dataOutRptPredefined->pdchExLtFullLoadHrs, thisLight.Name, state.dataOutRptTab->HrsPerWeek);
    6274              :         }
    6275           24 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchExLtConsump, thisLight.Name, thisLight.SumConsumption / 1000000000.0);
    6276           24 :         consumptionTotal += thisLight.SumConsumption / 1000000000.0;
    6277              :     }
    6278           73 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchExLtConsump, "Exterior Lighting Total", consumptionTotal);
    6279              : 
    6280              :     // outside air ventilation
    6281           73 :     Real64 totalOccupants = 0.;
    6282           73 :     Real64 totalAverageOccupants = 0.;
    6283           73 :     Real64 totalArea = 0.;
    6284           73 :     Real64 totalVozMin = 0;
    6285           73 :     Real64 totalMechVentVol = 0;
    6286           73 :     Real64 totalNatVentVol = 0;
    6287           73 :     Real64 totalInfilVol = 0;
    6288           73 :     Real64 totalVozDyn = 0;
    6289           73 :     Real64 totalMechVentRateOcc = 0;
    6290           73 :     Real64 totalNatVentRateOcc = 0;
    6291           73 :     Real64 totalInfilRateOcc = 0;
    6292           73 :     Real64 totalVozDynOcc = 0;
    6293              : 
    6294              :     // Outdoor Air Summary and Outdoor Air Details
    6295          167 :     for (int iZone = 1; iZone <= state.dataGlobal->NumOfZones; ++iZone) {
    6296              : 
    6297           94 :         auto const &thisZone = state.dataHeatBal->Zone(iZone);
    6298              : 
    6299           94 :         int const zoneMult = thisZone.Multiplier * thisZone.ListMultiplier;
    6300           94 :         if (thisZone.SystemZoneNodeNumber >= 0) { // conditioned zones only
    6301              : 
    6302           94 :             auto &thisZonePreDefRep = state.dataHeatBal->ZonePreDefRep(iZone);
    6303              : 
    6304              :             // AFN infiltration -- check that afn sim is being done.
    6305           94 :             if (!state.afn->multizone_always_simulated) {
    6306           91 :                 thisZonePreDefRep.AFNInfilVolTotalStdDen = 0.0;
    6307           91 :                 thisZonePreDefRep.AFNVentVolTotalStdDen = 0.0;
    6308           91 :                 thisZonePreDefRep.AFNInfilVolTotalOccStdDen = 0.0;
    6309           91 :                 thisZonePreDefRep.AFNVentVolTotalOccStdDen = 0.0;
    6310           91 :                 thisZonePreDefRep.AFNInfilVolMin = 0.0;
    6311           91 :                 thisZonePreDefRep.AFNInfilVolTotalOcc = 0.0;
    6312              :             }
    6313              : 
    6314              :             // air loop name
    6315           94 :             if (thisZone.IsControlled) {
    6316           52 :                 std::string airLoopName = "";
    6317          107 :                 for (int zoneInNode = 1; zoneInNode <= state.dataZoneEquip->ZoneEquipConfig(iZone).NumInletNodes; ++zoneInNode) {
    6318           55 :                     int airLoopNumber = state.dataZoneEquip->ZoneEquipConfig(iZone).InletNodeAirLoopNum(zoneInNode);
    6319           55 :                     if (airLoopNumber > 0) {
    6320           35 :                         if (airLoopName.empty()) {
    6321           35 :                             airLoopName = state.dataAirSystemsData->PrimaryAirSystems(airLoopNumber).Name;
    6322              :                         } else {
    6323            0 :                             airLoopName += "; " + state.dataAirSystemsData->PrimaryAirSystems(airLoopNumber).Name;
    6324              :                         }
    6325              :                     }
    6326              :                 }
    6327           52 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaMvAirLpNm, thisZone.Name, airLoopName);
    6328              : 
    6329              :                 // occupants
    6330           52 :                 if (thisZone.isNominalOccupied) {
    6331           31 :                     if (thisZonePreDefRep.NumOccAccumTime > 0) {
    6332           30 :                         Real64 const avgOcc = thisZonePreDefRep.NumOccAccum / thisZonePreDefRep.NumOccAccumTime;
    6333           30 :                         PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaoAvgNumOcc1, thisZone.Name, avgOcc);
    6334           30 :                         PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaoAvgNumOcc2, thisZone.Name, avgOcc);
    6335           30 :                         PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaMvAvgNumOcc, thisZone.Name, avgOcc);
    6336           30 :                         totalAverageOccupants += avgOcc * zoneMult;
    6337              :                     }
    6338              :                 }
    6339           52 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaMvNomNumOcc, thisZone.Name, thisZone.TotOccupants);
    6340           52 :                 totalOccupants += thisZone.TotOccupants * zoneMult;
    6341              : 
    6342              :                 // Zone volume and area
    6343              : 
    6344           52 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaoZoneVol1, thisZone.Name, thisZone.Volume);
    6345           52 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaoZoneVol2, thisZone.Name, thisZone.Volume);
    6346           52 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaMvZoneVol, thisZone.Name, thisZone.Volume);
    6347           52 :                 state.dataOutRptTab->totalVolume += thisZone.Volume * zoneMult;
    6348           52 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaMvZoneArea, thisZone.Name, thisZone.FloorArea);
    6349           52 :                 totalArea += thisZone.FloorArea * zoneMult;
    6350              : 
    6351              :                 // minimum dynamic target ventilation Voz-dyn-min
    6352           52 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaMvMinDynTrgVent, thisZone.Name, thisZonePreDefRep.VozMin / zoneMult, 3);
    6353           52 :                 totalVozMin += thisZonePreDefRep.VozMin;
    6354              : 
    6355              :                 // Mechanical ventilation
    6356           52 :                 if (thisZone.Volume > 0 && thisZonePreDefRep.TotTimeOcc > 0) {
    6357           30 :                     PreDefTableEntry(state,
    6358           30 :                                      state.dataOutRptPredefined->pdchOaoAvgMechVent,
    6359              :                                      thisZone.Name,
    6360           30 :                                      thisZonePreDefRep.MechVentVolTotalOcc / (thisZonePreDefRep.TotTimeOcc * thisZone.Volume * zoneMult),
    6361           30 :                                      3);
    6362           30 :                     PreDefTableEntry(state,
    6363           30 :                                      state.dataOutRptPredefined->pdchOaoMinMechVent,
    6364              :                                      thisZone.Name,
    6365           30 :                                      thisZonePreDefRep.MechVentVolMin / (thisZone.Volume * zoneMult),
    6366           60 :                                      3);
    6367              :                 }
    6368          104 :                 PreDefTableEntry(
    6369           52 :                     state, state.dataOutRptPredefined->pdchOaTaBzMechVent, thisZone.Name, thisZonePreDefRep.MechVentVolTotalStdDen / zoneMult);
    6370           52 :                 totalMechVentVol += thisZonePreDefRep.MechVentVolTotalStdDen;
    6371              : 
    6372              :                 // Natural ventilation
    6373          104 :                 PreDefTableEntry(state,
    6374           52 :                                  state.dataOutRptPredefined->pdchOaTaBzNatVent,
    6375              :                                  thisZone.Name,
    6376           52 :                                  thisZonePreDefRep.SimpVentVolTotalStdDen + thisZonePreDefRep.AFNVentVolTotalStdDen);
    6377           52 :                 totalNatVentVol += (thisZonePreDefRep.SimpVentVolTotalStdDen + thisZonePreDefRep.AFNVentVolTotalStdDen) * zoneMult;
    6378              : 
    6379              :                 // Total ventilation
    6380          104 :                 PreDefTableEntry(state,
    6381           52 :                                  state.dataOutRptPredefined->pdchOaTaBzTotVent,
    6382              :                                  thisZone.Name,
    6383           52 :                                  thisZonePreDefRep.MechVentVolTotalStdDen / zoneMult + thisZonePreDefRep.SimpVentVolTotalStdDen +
    6384           52 :                                      thisZonePreDefRep.AFNVentVolTotalStdDen);
    6385              : 
    6386              :                 // infiltration
    6387           52 :                 if (thisZone.Volume > 0 && thisZonePreDefRep.TotTimeOcc > 0) {
    6388           30 :                     PreDefTableEntry(state,
    6389           30 :                                      state.dataOutRptPredefined->pdchOaoAvgInfil,
    6390              :                                      thisZone.Name,
    6391           30 :                                      thisZonePreDefRep.InfilVolTotalOcc / (thisZonePreDefRep.TotTimeOcc * thisZone.Volume),
    6392           30 :                                      3);
    6393           30 :                     PreDefTableEntry(
    6394           30 :                         state, state.dataOutRptPredefined->pdchOaoMinInfil, thisZone.Name, thisZonePreDefRep.InfilVolMin / (thisZone.Volume), 3);
    6395              : 
    6396           30 :                     PreDefTableEntry(state,
    6397           30 :                                      state.dataOutRptPredefined->pdchOaoAvgAFNInfil,
    6398              :                                      thisZone.Name,
    6399           30 :                                      thisZonePreDefRep.AFNInfilVolTotalOcc / (thisZonePreDefRep.TotTimeOcc * thisZone.Volume),
    6400           30 :                                      3);
    6401              : 
    6402           30 :                     PreDefTableEntry(state,
    6403           30 :                                      state.dataOutRptPredefined->pdchOaoMinAFNInfil,
    6404              :                                      thisZone.Name,
    6405           30 :                                      thisZonePreDefRep.AFNInfilVolMin / (thisZone.Volume),
    6406           30 :                                      3);
    6407              : 
    6408              :                     // simple 'ZoneVentilation'
    6409           30 :                     PreDefTableEntry(state,
    6410           30 :                                      state.dataOutRptPredefined->pdchOaoAvgSimpVent,
    6411              :                                      thisZone.Name,
    6412           30 :                                      thisZonePreDefRep.SimpVentVolTotalOcc / (thisZonePreDefRep.TotTimeOcc * thisZone.Volume),
    6413           30 :                                      3);
    6414              : 
    6415           30 :                     PreDefTableEntry(state,
    6416           30 :                                      state.dataOutRptPredefined->pdchOaoMinSimpVent,
    6417              :                                      thisZone.Name,
    6418           30 :                                      thisZonePreDefRep.SimpVentVolMin / (thisZone.Volume),
    6419           60 :                                      3);
    6420              :                 }
    6421              : 
    6422              :                 // Infiltration
    6423          104 :                 PreDefTableEntry(state,
    6424           52 :                                  state.dataOutRptPredefined->pdchOaTaBzInfil,
    6425              :                                  thisZone.Name,
    6426           52 :                                  thisZonePreDefRep.InfilVolTotalStdDen + thisZonePreDefRep.AFNInfilVolTotalStdDen);
    6427           52 :                 totalInfilVol += (thisZonePreDefRep.InfilVolTotalStdDen + thisZonePreDefRep.AFNInfilVolTotalStdDen) * zoneMult;
    6428              : 
    6429              :                 // Total ventilation and infiltration
    6430          104 :                 PreDefTableEntry(state,
    6431           52 :                                  state.dataOutRptPredefined->pdchOaTaBzTotVentInfil,
    6432              :                                  thisZone.Name,
    6433           52 :                                  thisZonePreDefRep.MechVentVolTotalStdDen / zoneMult + thisZonePreDefRep.SimpVentVolTotalStdDen +
    6434           52 :                                      thisZonePreDefRep.AFNVentVolTotalStdDen + thisZonePreDefRep.AFNInfilVolTotalStdDen +
    6435           52 :                                      thisZonePreDefRep.InfilVolTotalStdDen);
    6436              : 
    6437              :                 // Dynamic target ventilation Voz-dyn
    6438           52 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaTaBzDynTrgVent, thisZone.Name, thisZonePreDefRep.VozTargetTotal / zoneMult);
    6439           52 :                 totalVozDyn += thisZonePreDefRep.VozTargetTotal;
    6440           52 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaTaBzTmBelow, thisZone.Name, thisZonePreDefRep.VozTargetTimeBelow);
    6441           52 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaTaBzTmAt, thisZone.Name, thisZonePreDefRep.VozTargetTimeAt);
    6442           52 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaTaBzTmAbove, thisZone.Name, thisZonePreDefRep.VozTargetTimeAbove);
    6443           52 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaTaBzTmAboveUnocc, thisZone.Name, thisZonePreDefRep.TotVentTimeNonZeroUnocc);
    6444              : 
    6445           52 :                 if (thisZone.isNominalOccupied && (thisZonePreDefRep.TotTimeOcc > 0.0)) {
    6446           30 :                     Real64 totTimeOccSec = thisZonePreDefRep.TotTimeOcc * Constant::rSecsInHour;
    6447              :                     // Mechanical ventilation
    6448           30 :                     Real64 mechVent = thisZonePreDefRep.MechVentVolTotalOccStdDen / totTimeOccSec;
    6449           30 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaOccBzMechVent, thisZone.Name, mechVent / zoneMult, 4);
    6450           30 :                     totalMechVentRateOcc += mechVent;
    6451              : 
    6452              :                     // Natural ventilation
    6453           30 :                     Real64 natVent = (thisZonePreDefRep.SimpVentVolTotalOccStdDen + thisZonePreDefRep.AFNVentVolTotalOccStdDen) / totTimeOccSec;
    6454           30 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaOccBzNatVent, thisZone.Name, natVent, 4);
    6455           30 :                     totalNatVentRateOcc += natVent * zoneMult;
    6456              : 
    6457              :                     // Total ventilation
    6458           30 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaOccBzTotVent, thisZone.Name, mechVent / zoneMult + natVent, 4);
    6459              : 
    6460              :                     // infiltration
    6461           30 :                     Real64 infil = (thisZonePreDefRep.InfilVolTotalOccStdDen + thisZonePreDefRep.AFNInfilVolTotalOccStdDen) / totTimeOccSec;
    6462           30 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaOccBzInfil, thisZone.Name, infil, 4);
    6463           30 :                     totalInfilRateOcc += infil * zoneMult;
    6464              : 
    6465              :                     // Total ventilation and infiltration
    6466           30 :                     PreDefTableEntry(
    6467           30 :                         state, state.dataOutRptPredefined->pdchOaOccBzTotVentInfil, thisZone.Name, mechVent / zoneMult + natVent + infil, 4);
    6468              : 
    6469              :                     // Dynamic target ventilation Voz-dyn
    6470           30 :                     Real64 avgVoz = thisZonePreDefRep.VozTargetTotalOcc / totTimeOccSec;
    6471           30 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaOccBzDynTrgVent, thisZone.Name, avgVoz / zoneMult, 4);
    6472           30 :                     totalVozDynOcc += avgVoz;
    6473           30 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaOccBzTmBelow, thisZone.Name, thisZonePreDefRep.VozTargetTimeBelowOcc);
    6474           30 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaOccBzTmAt, thisZone.Name, thisZonePreDefRep.VozTargetTimeAtOcc);
    6475           30 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaOccBzTmAbove, thisZone.Name, thisZonePreDefRep.VozTargetTimeAboveOcc);
    6476              :                 }
    6477           52 :             }
    6478              :         }
    6479              :     }
    6480              : 
    6481           95 :     for (int iSys = 1; iSys <= state.dataHVACGlobal->NumPrimaryAirSys; ++iSys) {
    6482           22 :         auto const &thisPrimaryAirSys = state.dataAirSystemsData->PrimaryAirSystems(iSys);
    6483           22 :         auto const &thisSysPreDefRep = state.dataSysRpts->SysPreDefRep(iSys);
    6484              : 
    6485              :         // Total Outdoor Air by Airloop
    6486           22 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaTaAlMechVent, thisPrimaryAirSys.Name, thisSysPreDefRep.MechVentTotal);
    6487           22 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaTaAlNatVent, thisPrimaryAirSys.Name, thisSysPreDefRep.NatVentTotal);
    6488           44 :         PreDefTableEntry(state,
    6489           22 :                          state.dataOutRptPredefined->pdchOaTaAlTotVent,
    6490              :                          thisPrimaryAirSys.Name,
    6491           22 :                          thisSysPreDefRep.MechVentTotal + thisSysPreDefRep.NatVentTotal);
    6492           22 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaTaAlSumDynTrgVent, thisPrimaryAirSys.Name, thisSysPreDefRep.TargetVentTotalVoz);
    6493           22 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaTaAlTmBelow, thisPrimaryAirSys.Name, thisSysPreDefRep.TimeBelowVozDynTotal);
    6494           22 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaTaAlTmAt, thisPrimaryAirSys.Name, thisSysPreDefRep.TimeAtVozDynTotal);
    6495           22 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaTaAlTmAbove, thisPrimaryAirSys.Name, thisSysPreDefRep.TimeAboveVozDynTotal);
    6496           22 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaTaAlTmAboveUnocc, thisPrimaryAirSys.Name, thisSysPreDefRep.TimeVentUnoccTotal);
    6497              : 
    6498              :         // Air loop times at OA limiting factors
    6499           66 :         PreDefTableEntry(state,
    6500           22 :                          state.dataOutRptPredefined->pdchOaTmFctNoLimit,
    6501              :                          thisPrimaryAirSys.Name,
    6502           22 :                          thisSysPreDefRep.TimeAtOALimit[static_cast<int>(MixedAir::OALimitFactor::None)]);
    6503           66 :         PreDefTableEntry(state,
    6504           22 :                          state.dataOutRptPredefined->pdchOaTmFctLimit,
    6505              :                          thisPrimaryAirSys.Name,
    6506           22 :                          thisSysPreDefRep.TimeAtOALimit[static_cast<int>(MixedAir::OALimitFactor::Limits)]);
    6507           66 :         PreDefTableEntry(state,
    6508           22 :                          state.dataOutRptPredefined->pdchOaTmFctEcono,
    6509              :                          thisPrimaryAirSys.Name,
    6510           22 :                          thisSysPreDefRep.TimeAtOALimit[static_cast<int>(MixedAir::OALimitFactor::Economizer)]);
    6511           66 :         PreDefTableEntry(state,
    6512           22 :                          state.dataOutRptPredefined->pdchOaTmFctExhaust,
    6513              :                          thisPrimaryAirSys.Name,
    6514           22 :                          thisSysPreDefRep.TimeAtOALimit[static_cast<int>(MixedAir::OALimitFactor::Exhaust)]);
    6515           66 :         PreDefTableEntry(state,
    6516           22 :                          state.dataOutRptPredefined->pdchOaTmFctMixedLimit,
    6517              :                          thisPrimaryAirSys.Name,
    6518           22 :                          thisSysPreDefRep.TimeAtOALimit[static_cast<int>(MixedAir::OALimitFactor::MixedAir)]);
    6519           66 :         PreDefTableEntry(state,
    6520           22 :                          state.dataOutRptPredefined->pdchOaTmFctHiHumid,
    6521              :                          thisPrimaryAirSys.Name,
    6522           22 :                          thisSysPreDefRep.TimeAtOALimit[static_cast<int>(MixedAir::OALimitFactor::HighHum)]);
    6523           66 :         PreDefTableEntry(state,
    6524           22 :                          state.dataOutRptPredefined->pdchOaTmFctDCV,
    6525              :                          thisPrimaryAirSys.Name,
    6526           22 :                          thisSysPreDefRep.TimeAtOALimit[static_cast<int>(MixedAir::OALimitFactor::DCV)]);
    6527           66 :         PreDefTableEntry(state,
    6528           22 :                          state.dataOutRptPredefined->pdchOaTmFctNiteVent,
    6529              :                          thisPrimaryAirSys.Name,
    6530           22 :                          thisSysPreDefRep.TimeAtOALimit[static_cast<int>(MixedAir::OALimitFactor::NightVent)]);
    6531           66 :         PreDefTableEntry(state,
    6532           22 :                          state.dataOutRptPredefined->pdchOaTmFctDemand,
    6533              :                          thisPrimaryAirSys.Name,
    6534           22 :                          thisSysPreDefRep.TimeAtOALimit[static_cast<int>(MixedAir::OALimitFactor::DemandLimit)]);
    6535           66 :         PreDefTableEntry(state,
    6536           22 :                          state.dataOutRptPredefined->pdchOaTmFctEMS,
    6537              :                          thisPrimaryAirSys.Name,
    6538           22 :                          thisSysPreDefRep.TimeAtOALimit[static_cast<int>(MixedAir::OALimitFactor::EMS)]);
    6539              : 
    6540           22 :         if (thisSysPreDefRep.TimeOccupiedTotal > 0.0) {
    6541              :             // Average Outdoor Air During Occupancy by Airloop
    6542           13 :             Real64 totTimeOccSec = thisSysPreDefRep.TimeOccupiedTotal * Constant::rSecsInHour;
    6543           13 :             PreDefTableEntry(
    6544           13 :                 state, state.dataOutRptPredefined->pdchOaOccAlMechVent, thisPrimaryAirSys.Name, thisSysPreDefRep.MechVentTotalOcc / totTimeOccSec, 4);
    6545           13 :             PreDefTableEntry(
    6546           13 :                 state, state.dataOutRptPredefined->pdchOaOccAlNatVent, thisPrimaryAirSys.Name, thisSysPreDefRep.NatVentTotalOcc / totTimeOccSec, 4);
    6547           13 :             PreDefTableEntry(state,
    6548           13 :                              state.dataOutRptPredefined->pdchOaOccAlTotVent,
    6549              :                              thisPrimaryAirSys.Name,
    6550           13 :                              (thisSysPreDefRep.MechVentTotalOcc + thisSysPreDefRep.NatVentTotalOcc) / totTimeOccSec,
    6551           13 :                              4);
    6552           13 :             PreDefTableEntry(state,
    6553           13 :                              state.dataOutRptPredefined->pdchOaOccAlSumDynTrgVent,
    6554              :                              thisPrimaryAirSys.Name,
    6555           13 :                              thisSysPreDefRep.TargetVentTotalVozOcc / totTimeOccSec,
    6556           13 :                              4);
    6557           13 :             PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaOccAlTmBelow, thisPrimaryAirSys.Name, thisSysPreDefRep.TimeBelowVozDynTotalOcc);
    6558           13 :             PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaOccAlTmAt, thisPrimaryAirSys.Name, thisSysPreDefRep.TimeAtVozDynTotalOcc);
    6559           13 :             PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaOccAlTmAbove, thisPrimaryAirSys.Name, thisSysPreDefRep.TimeAboveVozDynTotalOcc);
    6560              : 
    6561              :             // Average Outdoor Air at OA Limiting Factors During Occupancy by Airloop
    6562              :             // lambda to set avgFlow during occupancy for a given airloop and limiting factor type
    6563          130 :             auto avgFlowRate = [&state](int sysNum, MixedAir::OALimitFactor limitingFactorType) {
    6564          130 :                 int time = state.dataSysRpts->SysPreDefRep(sysNum).TimeAtOALimitOcc[static_cast<int>(limitingFactorType)];
    6565          130 :                 if (time > 0) {
    6566           11 :                     return state.dataSysRpts->SysPreDefRep(sysNum).MechVentTotAtLimitOcc[static_cast<int>(limitingFactorType)] /
    6567           11 :                            (time * Constant::rSecsInHour);
    6568              :                 } else {
    6569          119 :                     return 0.0;
    6570              :                 }
    6571           13 :             };
    6572           26 :             PreDefTableEntry(
    6573           26 :                 state, state.dataOutRptPredefined->pdchOaAvFctNoLimit, thisPrimaryAirSys.Name, avgFlowRate(iSys, MixedAir::OALimitFactor::None), 4);
    6574           26 :             PreDefTableEntry(
    6575           26 :                 state, state.dataOutRptPredefined->pdchOaAvFctLimit, thisPrimaryAirSys.Name, avgFlowRate(iSys, MixedAir::OALimitFactor::Limits), 4);
    6576           26 :             PreDefTableEntry(state,
    6577           13 :                              state.dataOutRptPredefined->pdchOaAvFctEcono,
    6578              :                              thisPrimaryAirSys.Name,
    6579              :                              avgFlowRate(iSys, MixedAir::OALimitFactor::Economizer),
    6580           13 :                              4);
    6581           26 :             PreDefTableEntry(state,
    6582           13 :                              state.dataOutRptPredefined->pdchOaAvFctExhaust,
    6583              :                              thisPrimaryAirSys.Name,
    6584              :                              avgFlowRate(iSys, MixedAir::OALimitFactor::Exhaust),
    6585           13 :                              4);
    6586           26 :             PreDefTableEntry(state,
    6587           13 :                              state.dataOutRptPredefined->pdchOaAvFctMixedLimit,
    6588              :                              thisPrimaryAirSys.Name,
    6589              :                              avgFlowRate(iSys, MixedAir::OALimitFactor::MixedAir),
    6590           13 :                              4);
    6591           26 :             PreDefTableEntry(state,
    6592           13 :                              state.dataOutRptPredefined->pdchOaAvFctHiHumid,
    6593              :                              thisPrimaryAirSys.Name,
    6594              :                              avgFlowRate(iSys, MixedAir::OALimitFactor::HighHum),
    6595           13 :                              4);
    6596           26 :             PreDefTableEntry(
    6597           26 :                 state, state.dataOutRptPredefined->pdchOaAvFctDCV, thisPrimaryAirSys.Name, avgFlowRate(iSys, MixedAir::OALimitFactor::DCV), 4);
    6598           26 :             PreDefTableEntry(state,
    6599           13 :                              state.dataOutRptPredefined->pdchOaAvFctNiteVent,
    6600              :                              thisPrimaryAirSys.Name,
    6601              :                              avgFlowRate(iSys, MixedAir::OALimitFactor::NightVent),
    6602           13 :                              4);
    6603           26 :             PreDefTableEntry(state,
    6604           13 :                              state.dataOutRptPredefined->pdchOaAvFctDemand,
    6605              :                              thisPrimaryAirSys.Name,
    6606              :                              avgFlowRate(iSys, MixedAir::OALimitFactor::DemandLimit),
    6607           13 :                              4);
    6608           26 :             PreDefTableEntry(
    6609           39 :                 state, state.dataOutRptPredefined->pdchOaAvFctEMS, thisPrimaryAirSys.Name, avgFlowRate(iSys, MixedAir::OALimitFactor::EMS), 4);
    6610              :         }
    6611              :     }
    6612              :     // add total rows for outdoor air details
    6613          146 :     OutputReportPredefined::PreDefTableEntry(
    6614          146 :         state, state.dataOutRptPredefined->pdchOaMvDesZnOa, "Total Facility", state.dataOutRptPredefined->TotalVozMax, 4);
    6615              : 
    6616           73 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaMvZoneVol, "Total Facility", state.dataOutRptTab->totalVolume);
    6617           73 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaMvZoneArea, "Total Facility", totalArea);
    6618           73 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaMvNomNumOcc, "Total Facility", totalOccupants);
    6619           73 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaMvAvgNumOcc, "Total Facility", totalAverageOccupants);
    6620           73 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaMvMinDynTrgVent, "Total Facility", totalVozMin, 3);
    6621              : 
    6622           73 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaTaBzMechVent, "Total Facility", totalMechVentVol);
    6623           73 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaTaBzNatVent, "Total Facility", totalNatVentVol);
    6624           73 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaTaBzTotVent, "Total Facility", totalMechVentVol + totalNatVentVol);
    6625           73 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaTaBzInfil, "Total Facility", totalInfilVol);
    6626           73 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaTaBzTotVentInfil, "Total Facility", totalMechVentVol + totalNatVentVol + totalInfilVol);
    6627           73 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaTaBzDynTrgVent, "Total Facility", totalVozDyn);
    6628          219 :     PreDefTableEntry(
    6629          146 :         state, state.dataOutRptPredefined->pdchOaTaBzTmBelow, "Total Facility", state.dataOutRptPredefined->TotalAnyZoneBelowVozDynForOA);
    6630           73 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaTaBzTmAt, "Total Facility", state.dataOutRptPredefined->TotalAllZonesAtVozDynForOA);
    6631          219 :     PreDefTableEntry(
    6632          146 :         state, state.dataOutRptPredefined->pdchOaTaBzTmAbove, "Total Facility", state.dataOutRptPredefined->TotalAnyZoneAboveVozDynForOA);
    6633          219 :     PreDefTableEntry(
    6634          146 :         state, state.dataOutRptPredefined->pdchOaTaBzTmAboveUnocc, "Total Facility", state.dataOutRptPredefined->TotalAnyZoneVentUnoccForOA);
    6635              : 
    6636           73 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaOccBzMechVent, "Total Facility", totalMechVentRateOcc, 4);
    6637           73 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaOccBzNatVent, "Total Facility", totalNatVentRateOcc, 4);
    6638           73 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaOccBzTotVent, "Total Facility", totalMechVentRateOcc + totalNatVentRateOcc, 4);
    6639           73 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaOccBzInfil, "Total Facility", totalInfilRateOcc, 4);
    6640           73 :     PreDefTableEntry(state,
    6641           73 :                      state.dataOutRptPredefined->pdchOaOccBzTotVentInfil,
    6642              :                      "Total Facility",
    6643           73 :                      totalMechVentRateOcc + totalNatVentRateOcc + totalInfilRateOcc,
    6644           73 :                      4);
    6645           73 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaOccBzDynTrgVent, "Total Facility", totalVozDynOcc, 4);
    6646          219 :     PreDefTableEntry(
    6647          146 :         state, state.dataOutRptPredefined->pdchOaOccBzTmBelow, "Total Facility", state.dataOutRptPredefined->TotalAnyZoneBelowVozDynOccForOA);
    6648           73 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaOccBzTmAt, "Total Facility", state.dataOutRptPredefined->TotalAllZonesAtVozDynOccForOA);
    6649          219 :     PreDefTableEntry(
    6650          146 :         state, state.dataOutRptPredefined->pdchOaOccBzTmAbove, "Total Facility", state.dataOutRptPredefined->TotalAnyZoneAboveVozDynOccForOA);
    6651              : 
    6652              :     // Add the number of central air distributions system to the count report
    6653           73 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchHVACcntVal, "HVAC Air Loops", NumPrimaryAirSys);
    6654              :     // Add the number of conditioned and unconditioned zones to the count report
    6655          167 :     for (int iZone = 1; iZone <= state.dataGlobal->NumOfZones; ++iZone) {
    6656              : 
    6657           94 :         if (state.dataHeatBal->Zone(iZone).SystemZoneNodeNumber > 0) { // conditioned zones only
    6658           52 :             ++state.dataOutRptTab->numCondZones;
    6659              :         } else {
    6660           42 :             ++state.dataOutRptTab->numUncondZones;
    6661              :         }
    6662              :     }
    6663           73 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchHVACcntVal, "Conditioned Zones", state.dataOutRptTab->numCondZones);
    6664           73 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchHVACcntVal, "Unconditioned Zones", state.dataOutRptTab->numUncondZones);
    6665              :     // add the number of plenums to the count report
    6666           73 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchHVACcntVal, "Supply Plenums", state.dataZonePlenum->NumZoneSupplyPlenums);
    6667           73 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchHVACcntVal, "Return Plenums", state.dataZonePlenum->NumZoneReturnPlenums);
    6668              : 
    6669              :     // Add footnote saying if it is a design day or other kind of environment
    6670              : 
    6671              :     // Field counts
    6672           73 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchFieldCntVal, "IDF Objects", iNumberOfRecords);
    6673           73 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchFieldCntVal, "Defaulted Fields", iNumberOfDefaultedFields);
    6674           73 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchFieldCntVal, "Fields with Defaults", iTotalFieldsWithDefaults);
    6675           73 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchFieldCntVal, "Autosized Fields", iNumberOfAutoSizedFields);
    6676           73 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchFieldCntVal, "Autosizable Fields", iTotalAutoSizableFields);
    6677           73 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchFieldCntVal, "Autocalculated Fields", iNumberOfAutoCalcedFields);
    6678           73 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchFieldCntVal, "Autocalculatable Fields", iTotalAutoCalculatableFields);
    6679              : 
    6680          167 :     for (int iZone = 1; iZone <= state.dataGlobal->NumOfZones; ++iZone) {
    6681              : 
    6682           94 :         auto const &thisZone = state.dataHeatBal->Zone(iZone);
    6683           94 :         auto const &thisZonePreDefRep = state.dataHeatBal->ZonePreDefRep(iZone);
    6684              : 
    6685              :         // annual
    6686              :         // PreDefTableEntry(state,  pdchSHGSAnHvacHt, Zone( iZone ).Name, ZonePreDefRep( iZone ).SHGSAnHvacHt * convertJtoGJ, 3 );
    6687              :         // PreDefTableEntry(state,  pdchSHGSAnHvacCl, Zone( iZone ).Name, ZonePreDefRep( iZone ).SHGSAnHvacCl * convertJtoGJ, 3 );
    6688           94 :         PreDefTableEntry(
    6689           94 :             state, state.dataOutRptPredefined->pdchSHGSAnZoneEqHt, thisZone.Name, thisZonePreDefRep.SHGSAnZoneEqHt * Constant::convertJtoGJ, 3);
    6690           94 :         PreDefTableEntry(
    6691           94 :             state, state.dataOutRptPredefined->pdchSHGSAnZoneEqCl, thisZone.Name, thisZonePreDefRep.SHGSAnZoneEqCl * Constant::convertJtoGJ, 3);
    6692           94 :         PreDefTableEntry(
    6693           94 :             state, state.dataOutRptPredefined->pdchSHGSAnHvacATUHt, thisZone.Name, thisZonePreDefRep.SHGSAnHvacATUHt * Constant::convertJtoGJ, 3);
    6694           94 :         PreDefTableEntry(
    6695           94 :             state, state.dataOutRptPredefined->pdchSHGSAnHvacATUCl, thisZone.Name, thisZonePreDefRep.SHGSAnHvacATUCl * Constant::convertJtoGJ, 3);
    6696           94 :         PreDefTableEntry(
    6697           94 :             state, state.dataOutRptPredefined->pdchSHGSAnSurfHt, thisZone.Name, thisZonePreDefRep.SHGSAnSurfHt * Constant::convertJtoGJ, 3);
    6698           94 :         PreDefTableEntry(
    6699           94 :             state, state.dataOutRptPredefined->pdchSHGSAnSurfCl, thisZone.Name, thisZonePreDefRep.SHGSAnSurfCl * Constant::convertJtoGJ, 3);
    6700           94 :         PreDefTableEntry(
    6701           94 :             state, state.dataOutRptPredefined->pdchSHGSAnPeoplAdd, thisZone.Name, thisZonePreDefRep.SHGSAnPeoplAdd * Constant::convertJtoGJ, 3);
    6702           94 :         PreDefTableEntry(
    6703           94 :             state, state.dataOutRptPredefined->pdchSHGSAnLiteAdd, thisZone.Name, thisZonePreDefRep.SHGSAnLiteAdd * Constant::convertJtoGJ, 3);
    6704           94 :         PreDefTableEntry(
    6705           94 :             state, state.dataOutRptPredefined->pdchSHGSAnEquipAdd, thisZone.Name, thisZonePreDefRep.SHGSAnEquipAdd * Constant::convertJtoGJ, 3);
    6706           94 :         PreDefTableEntry(
    6707           94 :             state, state.dataOutRptPredefined->pdchSHGSAnWindAdd, thisZone.Name, thisZonePreDefRep.SHGSAnWindAdd * Constant::convertJtoGJ, 3);
    6708           94 :         PreDefTableEntry(
    6709           94 :             state, state.dataOutRptPredefined->pdchSHGSAnIzaAdd, thisZone.Name, thisZonePreDefRep.SHGSAnIzaAdd * Constant::convertJtoGJ, 3);
    6710           94 :         PreDefTableEntry(
    6711           94 :             state, state.dataOutRptPredefined->pdchSHGSAnInfilAdd, thisZone.Name, thisZonePreDefRep.SHGSAnInfilAdd * Constant::convertJtoGJ, 3);
    6712           94 :         PreDefTableEntry(
    6713           94 :             state, state.dataOutRptPredefined->pdchSHGSAnOtherAdd, thisZone.Name, thisZonePreDefRep.SHGSAnOtherAdd * Constant::convertJtoGJ, 3);
    6714           94 :         PreDefTableEntry(
    6715           94 :             state, state.dataOutRptPredefined->pdchSHGSAnEquipRem, thisZone.Name, thisZonePreDefRep.SHGSAnEquipRem * Constant::convertJtoGJ, 3);
    6716           94 :         PreDefTableEntry(
    6717           94 :             state, state.dataOutRptPredefined->pdchSHGSAnWindRem, thisZone.Name, thisZonePreDefRep.SHGSAnWindRem * Constant::convertJtoGJ, 3);
    6718           94 :         PreDefTableEntry(
    6719           94 :             state, state.dataOutRptPredefined->pdchSHGSAnIzaRem, thisZone.Name, thisZonePreDefRep.SHGSAnIzaRem * Constant::convertJtoGJ, 3);
    6720           94 :         PreDefTableEntry(
    6721           94 :             state, state.dataOutRptPredefined->pdchSHGSAnInfilRem, thisZone.Name, thisZonePreDefRep.SHGSAnInfilRem * Constant::convertJtoGJ, 3);
    6722           94 :         PreDefTableEntry(
    6723           94 :             state, state.dataOutRptPredefined->pdchSHGSAnOtherRem, thisZone.Name, thisZonePreDefRep.SHGSAnOtherRem * Constant::convertJtoGJ, 3);
    6724              :         // peak cooling
    6725           94 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSClTimePeak, thisZone.Name, DateToString(thisZonePreDefRep.clPtTimeStamp));
    6726              :         // PreDefTableEntry(state,  pdchSHGSClHvacHt, Zone( iZone ).Name, ZonePreDefRep( iZone ).SHGSClHvacHt );
    6727              :         // PreDefTableEntry(state,  pdchSHGSClHvacCl, Zone( iZone ).Name, ZonePreDefRep( iZone ).SHGSClHvacCl );
    6728          188 :         PreDefTableEntry(
    6729           94 :             state, state.dataOutRptPredefined->pdchSHGSClHvacHt, thisZone.Name, (thisZonePreDefRep.SHGSClHvacHt - thisZonePreDefRep.SHGSClHvacATUHt));
    6730          188 :         PreDefTableEntry(
    6731           94 :             state, state.dataOutRptPredefined->pdchSHGSClHvacCl, thisZone.Name, (thisZonePreDefRep.SHGSClHvacCl - thisZonePreDefRep.SHGSClHvacATUCl));
    6732           94 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSClHvacATUHt, thisZone.Name, thisZonePreDefRep.SHGSClHvacATUHt);
    6733           94 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSClHvacATUCl, thisZone.Name, thisZonePreDefRep.SHGSClHvacATUCl);
    6734           94 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSClSurfHt, thisZone.Name, thisZonePreDefRep.SHGSClSurfHt);
    6735           94 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSClSurfCl, thisZone.Name, thisZonePreDefRep.SHGSClSurfCl);
    6736           94 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSClPeoplAdd, thisZone.Name, thisZonePreDefRep.SHGSClPeoplAdd);
    6737           94 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSClLiteAdd, thisZone.Name, thisZonePreDefRep.SHGSClLiteAdd);
    6738           94 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSClEquipAdd, thisZone.Name, thisZonePreDefRep.SHGSClEquipAdd);
    6739           94 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSClWindAdd, thisZone.Name, thisZonePreDefRep.SHGSClWindAdd);
    6740           94 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSClIzaAdd, thisZone.Name, thisZonePreDefRep.SHGSClIzaAdd);
    6741           94 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSClInfilAdd, thisZone.Name, thisZonePreDefRep.SHGSClInfilAdd);
    6742           94 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSClOtherAdd, thisZone.Name, thisZonePreDefRep.SHGSClOtherAdd);
    6743           94 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSClEquipRem, thisZone.Name, thisZonePreDefRep.SHGSClEquipRem);
    6744           94 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSClWindRem, thisZone.Name, thisZonePreDefRep.SHGSClWindRem);
    6745           94 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSClIzaRem, thisZone.Name, thisZonePreDefRep.SHGSClIzaRem);
    6746           94 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSClInfilRem, thisZone.Name, thisZonePreDefRep.SHGSClInfilRem);
    6747           94 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSClOtherRem, thisZone.Name, thisZonePreDefRep.SHGSClOtherRem);
    6748              :         // peak heating
    6749           94 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSHtTimePeak, thisZone.Name, DateToString(thisZonePreDefRep.htPtTimeStamp));
    6750              :         // PreDefTableEntry(state,  pdchSHGSHtHvacHt, Zone( iZone ).Name, ZonePreDefRep( iZone ).SHGSHtHvacHt );
    6751              :         // PreDefTableEntry(state,  pdchSHGSHtHvacCl, Zone( iZone ).Name, ZonePreDefRep( iZone ).SHGSHtHvacCl );
    6752          188 :         PreDefTableEntry(
    6753           94 :             state, state.dataOutRptPredefined->pdchSHGSHtHvacHt, thisZone.Name, (thisZonePreDefRep.SHGSHtHvacHt - thisZonePreDefRep.SHGSHtHvacATUHt));
    6754          188 :         PreDefTableEntry(
    6755           94 :             state, state.dataOutRptPredefined->pdchSHGSHtHvacCl, thisZone.Name, (thisZonePreDefRep.SHGSHtHvacCl - thisZonePreDefRep.SHGSHtHvacATUCl));
    6756           94 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSHtHvacATUHt, thisZone.Name, thisZonePreDefRep.SHGSHtHvacATUHt);
    6757           94 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSHtHvacATUCl, thisZone.Name, thisZonePreDefRep.SHGSHtHvacATUCl);
    6758           94 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSHtSurfHt, thisZone.Name, thisZonePreDefRep.SHGSHtSurfHt);
    6759           94 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSHtSurfCl, thisZone.Name, thisZonePreDefRep.SHGSHtSurfCl);
    6760           94 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSHtPeoplAdd, thisZone.Name, thisZonePreDefRep.SHGSHtPeoplAdd);
    6761           94 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSHtLiteAdd, thisZone.Name, thisZonePreDefRep.SHGSHtLiteAdd);
    6762           94 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSHtEquipAdd, thisZone.Name, thisZonePreDefRep.SHGSHtEquipAdd);
    6763           94 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSHtWindAdd, thisZone.Name, thisZonePreDefRep.SHGSHtWindAdd);
    6764           94 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSHtIzaAdd, thisZone.Name, thisZonePreDefRep.SHGSHtIzaAdd);
    6765           94 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSHtInfilAdd, thisZone.Name, thisZonePreDefRep.SHGSHtInfilAdd);
    6766           94 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSHtOtherAdd, thisZone.Name, thisZonePreDefRep.SHGSHtOtherAdd);
    6767           94 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSHtEquipRem, thisZone.Name, thisZonePreDefRep.SHGSHtEquipRem);
    6768           94 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSHtWindRem, thisZone.Name, thisZonePreDefRep.SHGSHtWindRem);
    6769           94 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSHtIzaRem, thisZone.Name, thisZonePreDefRep.SHGSHtIzaRem);
    6770           94 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSHtInfilRem, thisZone.Name, thisZonePreDefRep.SHGSHtInfilRem);
    6771           94 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSHtOtherRem, thisZone.Name, thisZonePreDefRep.SHGSHtOtherRem);
    6772              :     }
    6773              :     // totals for annual report
    6774          167 :     for (int iZone = 1; iZone <= state.dataGlobal->NumOfZones; ++iZone) {
    6775           94 :         auto const &thisZonePreDefRep = state.dataHeatBal->ZonePreDefRep(iZone);
    6776              : 
    6777           94 :         state.dataOutRptTab->totalZoneEqHt += thisZonePreDefRep.SHGSAnZoneEqHt;
    6778           94 :         state.dataOutRptTab->totalZoneEqCl += thisZonePreDefRep.SHGSAnZoneEqCl;
    6779           94 :         state.dataOutRptTab->totalHvacATUHt += thisZonePreDefRep.SHGSAnHvacATUHt;
    6780           94 :         state.dataOutRptTab->totalHvacATUCl += thisZonePreDefRep.SHGSAnHvacATUCl;
    6781           94 :         state.dataOutRptTab->totalSurfHt += thisZonePreDefRep.SHGSAnSurfHt;
    6782           94 :         state.dataOutRptTab->totalSurfCl += thisZonePreDefRep.SHGSAnSurfCl;
    6783           94 :         state.dataOutRptTab->totalPeoplAdd += thisZonePreDefRep.SHGSAnPeoplAdd;
    6784           94 :         state.dataOutRptTab->totalLiteAdd += thisZonePreDefRep.SHGSAnLiteAdd;
    6785           94 :         state.dataOutRptTab->totalEquipAdd += thisZonePreDefRep.SHGSAnEquipAdd;
    6786           94 :         state.dataOutRptTab->totalWindAdd += thisZonePreDefRep.SHGSAnWindAdd;
    6787           94 :         state.dataOutRptTab->totalIzaAdd += thisZonePreDefRep.SHGSAnIzaAdd;
    6788           94 :         state.dataOutRptTab->totalInfilAdd += thisZonePreDefRep.SHGSAnInfilAdd;
    6789           94 :         state.dataOutRptTab->totalOtherAdd += thisZonePreDefRep.SHGSAnOtherAdd;
    6790           94 :         state.dataOutRptTab->totalEquipRem += thisZonePreDefRep.SHGSAnEquipRem;
    6791           94 :         state.dataOutRptTab->totalWindRem += thisZonePreDefRep.SHGSAnWindRem;
    6792           94 :         state.dataOutRptTab->totalIzaRem += thisZonePreDefRep.SHGSAnIzaRem;
    6793           94 :         state.dataOutRptTab->totalInfilRem += thisZonePreDefRep.SHGSAnInfilRem;
    6794           94 :         state.dataOutRptTab->totalOtherRem += thisZonePreDefRep.SHGSAnOtherRem;
    6795              :     }
    6796              :     // PreDefTableEntry(state,  pdchSHGSAnHvacHt, "Total Facility", totalHvacHt * convertJtoGJ, 3 );
    6797              :     // PreDefTableEntry(state,  pdchSHGSAnHvacCl, "Total Facility", totalHvacCl * convertJtoGJ, 3 );
    6798           73 :     PreDefTableEntry(
    6799           73 :         state, state.dataOutRptPredefined->pdchSHGSAnZoneEqHt, "Total Facility", state.dataOutRptTab->totalZoneEqHt * Constant::convertJtoGJ, 3);
    6800           73 :     PreDefTableEntry(
    6801           73 :         state, state.dataOutRptPredefined->pdchSHGSAnZoneEqCl, "Total Facility", state.dataOutRptTab->totalZoneEqCl * Constant::convertJtoGJ, 3);
    6802           73 :     PreDefTableEntry(
    6803           73 :         state, state.dataOutRptPredefined->pdchSHGSAnHvacATUHt, "Total Facility", state.dataOutRptTab->totalHvacATUHt * Constant::convertJtoGJ, 3);
    6804           73 :     PreDefTableEntry(
    6805           73 :         state, state.dataOutRptPredefined->pdchSHGSAnHvacATUCl, "Total Facility", state.dataOutRptTab->totalHvacATUCl * Constant::convertJtoGJ, 3);
    6806           73 :     PreDefTableEntry(
    6807           73 :         state, state.dataOutRptPredefined->pdchSHGSAnSurfHt, "Total Facility", state.dataOutRptTab->totalSurfHt * Constant::convertJtoGJ, 3);
    6808           73 :     PreDefTableEntry(
    6809           73 :         state, state.dataOutRptPredefined->pdchSHGSAnSurfCl, "Total Facility", state.dataOutRptTab->totalSurfCl * Constant::convertJtoGJ, 3);
    6810           73 :     PreDefTableEntry(
    6811           73 :         state, state.dataOutRptPredefined->pdchSHGSAnPeoplAdd, "Total Facility", state.dataOutRptTab->totalPeoplAdd * Constant::convertJtoGJ, 3);
    6812           73 :     PreDefTableEntry(
    6813           73 :         state, state.dataOutRptPredefined->pdchSHGSAnLiteAdd, "Total Facility", state.dataOutRptTab->totalLiteAdd * Constant::convertJtoGJ, 3);
    6814           73 :     PreDefTableEntry(
    6815           73 :         state, state.dataOutRptPredefined->pdchSHGSAnEquipAdd, "Total Facility", state.dataOutRptTab->totalEquipAdd * Constant::convertJtoGJ, 3);
    6816           73 :     PreDefTableEntry(
    6817           73 :         state, state.dataOutRptPredefined->pdchSHGSAnWindAdd, "Total Facility", state.dataOutRptTab->totalWindAdd * Constant::convertJtoGJ, 3);
    6818           73 :     PreDefTableEntry(
    6819           73 :         state, state.dataOutRptPredefined->pdchSHGSAnIzaAdd, "Total Facility", state.dataOutRptTab->totalIzaAdd * Constant::convertJtoGJ, 3);
    6820           73 :     PreDefTableEntry(
    6821           73 :         state, state.dataOutRptPredefined->pdchSHGSAnInfilAdd, "Total Facility", state.dataOutRptTab->totalInfilAdd * Constant::convertJtoGJ, 3);
    6822           73 :     PreDefTableEntry(
    6823           73 :         state, state.dataOutRptPredefined->pdchSHGSAnOtherAdd, "Total Facility", state.dataOutRptTab->totalOtherAdd * Constant::convertJtoGJ, 3);
    6824           73 :     PreDefTableEntry(
    6825           73 :         state, state.dataOutRptPredefined->pdchSHGSAnEquipRem, "Total Facility", state.dataOutRptTab->totalEquipRem * Constant::convertJtoGJ, 3);
    6826           73 :     PreDefTableEntry(
    6827           73 :         state, state.dataOutRptPredefined->pdchSHGSAnWindRem, "Total Facility", state.dataOutRptTab->totalWindRem * Constant::convertJtoGJ, 3);
    6828           73 :     PreDefTableEntry(
    6829           73 :         state, state.dataOutRptPredefined->pdchSHGSAnIzaRem, "Total Facility", state.dataOutRptTab->totalIzaRem * Constant::convertJtoGJ, 3);
    6830           73 :     PreDefTableEntry(
    6831           73 :         state, state.dataOutRptPredefined->pdchSHGSAnInfilRem, "Total Facility", state.dataOutRptTab->totalInfilRem * Constant::convertJtoGJ, 3);
    6832           73 :     PreDefTableEntry(
    6833           73 :         state, state.dataOutRptPredefined->pdchSHGSAnOtherRem, "Total Facility", state.dataOutRptTab->totalOtherRem * Constant::convertJtoGJ, 3);
    6834              :     // building level results for peak cooling
    6835          146 :     PreDefTableEntry(
    6836          219 :         state, state.dataOutRptPredefined->pdchSHGSClTimePeak, "Total Facility", DateToString(state.dataHeatBal->BuildingPreDefRep.clPtTimeStamp));
    6837              :     // PreDefTableEntry(state,  pdchSHGSClHvacHt, "Total Facility", BuildingPreDefRep.SHGSClHvacHt );
    6838              :     // PreDefTableEntry(state,  pdchSHGSClHvacCl, "Total Facility", BuildingPreDefRep.SHGSClHvacCl );
    6839          146 :     PreDefTableEntry(state,
    6840           73 :                      state.dataOutRptPredefined->pdchSHGSClHvacHt,
    6841              :                      "Total Facility",
    6842           73 :                      (state.dataHeatBal->BuildingPreDefRep.SHGSClHvacHt - state.dataHeatBal->BuildingPreDefRep.SHGSClHvacATUHt));
    6843          146 :     PreDefTableEntry(state,
    6844           73 :                      state.dataOutRptPredefined->pdchSHGSClHvacCl,
    6845              :                      "Total Facility",
    6846           73 :                      (state.dataHeatBal->BuildingPreDefRep.SHGSClHvacCl - state.dataHeatBal->BuildingPreDefRep.SHGSClHvacATUCl));
    6847           73 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSClHvacATUHt, "Total Facility", state.dataHeatBal->BuildingPreDefRep.SHGSClHvacATUHt);
    6848           73 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSClHvacATUCl, "Total Facility", state.dataHeatBal->BuildingPreDefRep.SHGSClHvacATUCl);
    6849           73 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSClSurfHt, "Total Facility", state.dataHeatBal->BuildingPreDefRep.SHGSClSurfHt);
    6850           73 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSClSurfCl, "Total Facility", state.dataHeatBal->BuildingPreDefRep.SHGSClSurfCl);
    6851           73 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSClPeoplAdd, "Total Facility", state.dataHeatBal->BuildingPreDefRep.SHGSClPeoplAdd);
    6852           73 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSClLiteAdd, "Total Facility", state.dataHeatBal->BuildingPreDefRep.SHGSClLiteAdd);
    6853           73 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSClEquipAdd, "Total Facility", state.dataHeatBal->BuildingPreDefRep.SHGSClEquipAdd);
    6854           73 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSClWindAdd, "Total Facility", state.dataHeatBal->BuildingPreDefRep.SHGSClWindAdd);
    6855           73 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSClIzaAdd, "Total Facility", state.dataHeatBal->BuildingPreDefRep.SHGSClIzaAdd);
    6856           73 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSClInfilAdd, "Total Facility", state.dataHeatBal->BuildingPreDefRep.SHGSClInfilAdd);
    6857           73 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSClOtherAdd, "Total Facility", state.dataHeatBal->BuildingPreDefRep.SHGSClOtherAdd);
    6858           73 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSClEquipRem, "Total Facility", state.dataHeatBal->BuildingPreDefRep.SHGSClEquipRem);
    6859           73 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSClWindRem, "Total Facility", state.dataHeatBal->BuildingPreDefRep.SHGSClWindRem);
    6860           73 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSClIzaRem, "Total Facility", state.dataHeatBal->BuildingPreDefRep.SHGSClIzaRem);
    6861           73 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSClInfilRem, "Total Facility", state.dataHeatBal->BuildingPreDefRep.SHGSClInfilRem);
    6862           73 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSClOtherRem, "Total Facility", state.dataHeatBal->BuildingPreDefRep.SHGSClOtherRem);
    6863              :     // building level results for peak heating
    6864          146 :     PreDefTableEntry(
    6865          219 :         state, state.dataOutRptPredefined->pdchSHGSHtTimePeak, "Total Facility", DateToString(state.dataHeatBal->BuildingPreDefRep.htPtTimeStamp));
    6866              :     // PreDefTableEntry(state,  pdchSHGSHtHvacHt, "Total Facility", BuildingPreDefRep.SHGSHtHvacHt );
    6867              :     // PreDefTableEntry(state,  pdchSHGSHtHvacCl, "Total Facility", BuildingPreDefRep.SHGSHtHvacCl );
    6868          146 :     PreDefTableEntry(state,
    6869           73 :                      state.dataOutRptPredefined->pdchSHGSHtHvacHt,
    6870              :                      "Total Facility",
    6871           73 :                      (state.dataHeatBal->BuildingPreDefRep.SHGSHtHvacHt - state.dataHeatBal->BuildingPreDefRep.SHGSHtHvacATUHt));
    6872          146 :     PreDefTableEntry(state,
    6873           73 :                      state.dataOutRptPredefined->pdchSHGSHtHvacCl,
    6874              :                      "Total Facility",
    6875           73 :                      (state.dataHeatBal->BuildingPreDefRep.SHGSHtHvacCl - state.dataHeatBal->BuildingPreDefRep.SHGSHtHvacATUCl));
    6876           73 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSHtHvacATUHt, "Total Facility", state.dataHeatBal->BuildingPreDefRep.SHGSHtHvacATUHt);
    6877           73 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSHtHvacATUCl, "Total Facility", state.dataHeatBal->BuildingPreDefRep.SHGSHtHvacATUCl);
    6878           73 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSHtSurfHt, "Total Facility", state.dataHeatBal->BuildingPreDefRep.SHGSHtSurfHt);
    6879           73 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSHtSurfCl, "Total Facility", state.dataHeatBal->BuildingPreDefRep.SHGSHtSurfCl);
    6880           73 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSHtPeoplAdd, "Total Facility", state.dataHeatBal->BuildingPreDefRep.SHGSHtPeoplAdd);
    6881           73 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSHtLiteAdd, "Total Facility", state.dataHeatBal->BuildingPreDefRep.SHGSHtLiteAdd);
    6882           73 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSHtEquipAdd, "Total Facility", state.dataHeatBal->BuildingPreDefRep.SHGSHtEquipAdd);
    6883           73 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSHtWindAdd, "Total Facility", state.dataHeatBal->BuildingPreDefRep.SHGSHtWindAdd);
    6884           73 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSHtIzaAdd, "Total Facility", state.dataHeatBal->BuildingPreDefRep.SHGSHtIzaAdd);
    6885           73 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSHtInfilAdd, "Total Facility", state.dataHeatBal->BuildingPreDefRep.SHGSHtInfilAdd);
    6886           73 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSHtOtherAdd, "Total Facility", state.dataHeatBal->BuildingPreDefRep.SHGSHtOtherAdd);
    6887           73 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSHtEquipRem, "Total Facility", state.dataHeatBal->BuildingPreDefRep.SHGSHtEquipRem);
    6888           73 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSHtWindRem, "Total Facility", state.dataHeatBal->BuildingPreDefRep.SHGSHtWindRem);
    6889           73 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSHtIzaRem, "Total Facility", state.dataHeatBal->BuildingPreDefRep.SHGSHtIzaRem);
    6890           73 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSHtInfilRem, "Total Facility", state.dataHeatBal->BuildingPreDefRep.SHGSHtInfilRem);
    6891           73 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSHtOtherRem, "Total Facility", state.dataHeatBal->BuildingPreDefRep.SHGSHtOtherRem);
    6892              : 
    6893              :     // LEED Report
    6894              :     // 1.1A-General Information
    6895           73 :     if (state.dataEnvrn->EnvironmentName == state.dataEnvrn->WeatherFileLocationTitle) {
    6896            0 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchLeedGenData, "Weather File", state.dataEnvrn->EnvironmentName);
    6897              :     } else {
    6898          146 :         PreDefTableEntry(state,
    6899           73 :                          state.dataOutRptPredefined->pdchLeedGenData,
    6900              :                          "Weather File",
    6901          146 :                          state.dataEnvrn->EnvironmentName + " ** " + state.dataEnvrn->WeatherFileLocationTitle);
    6902              :     }
    6903              : 
    6904           73 :     if (ort->ip()) {
    6905            2 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchLeedGenData, "Total gross floor area [ft2]", "-");
    6906              :     } else {
    6907           71 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchLeedGenData, "Total gross floor area [m2]", "-");
    6908              :     }
    6909              :     // LEED schedule sub table
    6910          607 :     for (auto *sched : state.dataSched->schedules) {
    6911          534 :         if (sched->schedTypeNum == -1) {
    6912          196 :             continue;
    6913              :         }
    6914          338 :         if (!Util::SameString(state.dataSched->scheduleTypes[sched->schedTypeNum]->Name, "FRACTION")) {
    6915          252 :             continue;
    6916              :         }
    6917              : 
    6918          172 :         PreDefTableEntry(state,
    6919           86 :                          state.dataOutRptPredefined->pdchLeedEflhEflh,
    6920              :                          sched->Name,
    6921           86 :                          sched->getAnnualHoursFullLoad(state, StartOfWeek, state.dataEnvrn->CurrentYearIsLeapYear),
    6922           86 :                          0);
    6923          172 :         PreDefTableEntry(state,
    6924           86 :                          state.dataOutRptPredefined->pdchLeedEflhNonZerHrs,
    6925              :                          sched->Name,
    6926           86 :                          sched->getAnnualHoursGreaterThan1Percent(state, StartOfWeek, state.dataEnvrn->CurrentYearIsLeapYear),
    6927          172 :                          0);
    6928           73 :     }
    6929              : 
    6930              :     // fill the LEED setpoint table
    6931           73 :     ZoneTempPredictorCorrector::FillPredefinedTableOnThermostatSetpoints(state);
    6932           73 :     ZoneTempPredictorCorrector::FillPredefinedTableOnThermostatSchedules(state);
    6933           73 : }
    6934              : 
    6935            1 : void WriteMonthlyTables(EnergyPlusData &state)
    6936              : {
    6937              :     // SUBROUTINE INFORMATION:
    6938              :     //       AUTHOR         Jason Glazer
    6939              :     //       DATE WRITTEN   August 2003
    6940              :     //       MODIFIED       January 2010, Kyle Benne
    6941              :     //                      Added SQLite output
    6942              :     //                      January 2021, J. Yuan
    6943              :     //                      Modified to accommodate dual-unit reporting
    6944              :     //       RE-ENGINEERED  na
    6945              : 
    6946              :     // PURPOSE OF THIS SUBROUTINE:
    6947              :     //   Set up the monthly tabular report results
    6948              : 
    6949              :     // METHODOLOGY EMPLOYED:
    6950              :     //   Creates several arrays that are passed to the WriteTable
    6951              :     //   routine.  All arrays are strings so numbers need to be
    6952              :     //   converted prior to calling WriteTable.
    6953              : 
    6954              :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
    6955            1 :     Array1D_string columnHead;
    6956            1 :     Array1D_int columnWidth;
    6957            1 :     Array1D_string rowHead(16);
    6958            1 :     Array2D_string tableBody;
    6959            1 :     std::string curAggString;
    6960              :     int iInput;
    6961              :     int jTable;
    6962              :     int kColumn;
    6963              :     int lMonth;
    6964              :     int curTable;
    6965              :     int curCol;
    6966              :     Real64 curVal;
    6967              :     Real64 curConversionFactor;
    6968              :     int columnUsedCount;
    6969              :     int columnRecount;
    6970              :     int digitsShown;
    6971              :     Real64 minVal;
    6972              :     Real64 maxVal;
    6973              :     Real64 sumVal;
    6974              :     Real64 sumDuration;
    6975            1 :     std::string curUnits;
    6976            1 :     std::string energyUnitsString;
    6977              :     Real64 energyUnitsConversionFactor;
    6978              :     int indexUnitConv;
    6979            1 :     std::string varNameWithUnits;
    6980              :     Real64 veryLarge;
    6981              :     Real64 verySmall;
    6982              : 
    6983              :     static Real64 const storedMaxVal(std::numeric_limits<Real64>::max());
    6984              :     static Real64 const storedMinVal(std::numeric_limits<Real64>::lowest());
    6985              : 
    6986            1 :     rowHead(1) = "January";
    6987            1 :     rowHead(2) = "February";
    6988            1 :     rowHead(3) = "March";
    6989            1 :     rowHead(4) = "April";
    6990            1 :     rowHead(5) = "May";
    6991            1 :     rowHead(6) = "June";
    6992            1 :     rowHead(7) = "July";
    6993            1 :     rowHead(8) = "August";
    6994            1 :     rowHead(9) = "September";
    6995            1 :     rowHead(10) = "October";
    6996            1 :     rowHead(11) = "November";
    6997            1 :     rowHead(12) = "December";
    6998            1 :     rowHead(13) = "";
    6999            1 :     rowHead(14) = "Annual Sum or Average";
    7000            1 :     rowHead(15) = "Minimum of Months";
    7001            1 :     rowHead(16) = "Maximum of Months";
    7002              : 
    7003              :     // Why is this a map? If the enum/integer is the independent variable/index, it should be a std::array.
    7004              :     std::unordered_map<AggType, std::string> aggString = {
    7005            0 :         {AggType::SumOrAvg, ""},
    7006            0 :         {AggType::Maximum, " Maximum "},
    7007            0 :         {AggType::Minimum, " MINIMUM "},
    7008            0 :         {AggType::ValueWhenMaxMin, " AT MAX/MIN "},
    7009            0 :         {AggType::HoursZero, " HOURS ZERO "},
    7010            0 :         {AggType::HoursNonZero, " HOURS NON-ZERO "},
    7011            0 :         {AggType::HoursPositive, " HOURS POSITIVE "},
    7012            0 :         {AggType::HoursNonPositive, " HOURS NON-POSITIVE "},
    7013            0 :         {AggType::HoursNegative, " HOURS NEGATIVE "},
    7014            0 :         {AggType::HoursNonNegative, " HOURS NON-NEGATIVE "},
    7015            0 :         {AggType::SumOrAverageHoursShown, " FOR HOURS SHOWN "},
    7016            0 :         {AggType::MaximumDuringHoursShown, " MAX FOR HOURS SHOWN "},
    7017            0 :         {AggType::MinimumDuringHoursShown, " MIN FOR HOURS SHOWN "},
    7018           15 :     };
    7019              : 
    7020            1 :     veryLarge = 1.0E280;
    7021            1 :     verySmall = -1.0E280;
    7022              : 
    7023            1 :     auto &ort = state.dataOutRptTab;
    7024              : 
    7025            3 :     for (int iUnitSystem = 0; iUnitSystem <= 1; iUnitSystem++) {
    7026            2 :         UnitsStyle unitsStyle_cur = ort->unitsStyle;
    7027            2 :         bool produceTabular = true;
    7028            2 :         bool produceSQLite = false;
    7029            2 :         if (produceDualUnitsFlags(iUnitSystem, ort->unitsStyle, ort->unitsStyle_SQLite, unitsStyle_cur, produceTabular, produceSQLite)) {
    7030            0 :             break;
    7031              :         }
    7032              : 
    7033              :         // set the unit conversion
    7034            2 :         if (unitsStyle_cur == UnitsStyle::None) {
    7035            1 :             energyUnitsString = "J";
    7036            1 :             energyUnitsConversionFactor = 1.0;
    7037            1 :         } else if (unitsStyle_cur == UnitsStyle::JtoKWH) {
    7038            0 :             energyUnitsString = "kWh";
    7039            0 :             energyUnitsConversionFactor = 1.0 / 3600000.0;
    7040            1 :         } else if (unitsStyle_cur == UnitsStyle::JtoMJ) {
    7041            0 :             energyUnitsString = "MJ";
    7042            0 :             energyUnitsConversionFactor = 1.0 / 1000000.0;
    7043            1 :         } else if (unitsStyle_cur == UnitsStyle::JtoGJ) {
    7044            0 :             energyUnitsString = "GJ";
    7045            0 :             energyUnitsConversionFactor = 1.0 / 1000000000.0;
    7046              :         } else { // Should never happen but assures compilers of initialization
    7047            1 :             energyUnitsString = "J";
    7048            1 :             energyUnitsConversionFactor = 1.0;
    7049              :         }
    7050              : 
    7051              :         // loop through each input to get the name of the tables
    7052            4 :         for (iInput = 1; iInput <= ort->MonthlyInputCount; ++iInput) {
    7053              :             // loop through each report and
    7054            2 :             digitsShown = ort->MonthlyInput(iInput).showDigits;
    7055            4 :             for (jTable = 1; jTable <= ort->MonthlyInput(iInput).numTables; ++jTable) {
    7056            2 :                 curTable = jTable + ort->MonthlyInput(iInput).firstTable - 1;
    7057              :                 // first loop through and count how many 'columns' are defined
    7058              :                 // since max and min actually define two columns (the value
    7059              :                 // and the timestamp).
    7060            2 :                 columnUsedCount = 0;
    7061           28 :                 for (kColumn = 1; kColumn <= ort->MonthlyTables(curTable).numColumns; ++kColumn) {
    7062           26 :                     curCol = kColumn + ort->MonthlyTables(curTable).firstColumn - 1;
    7063           26 :                     switch (ort->MonthlyColumns(curCol).aggType) {
    7064           18 :                     case AggType::SumOrAvg:
    7065              :                     case AggType::ValueWhenMaxMin:
    7066              :                     case AggType::HoursZero:
    7067              :                     case AggType::HoursNonZero:
    7068              :                     case AggType::HoursPositive:
    7069              :                     case AggType::HoursNonPositive:
    7070              :                     case AggType::HoursNegative:
    7071              :                     case AggType::HoursNonNegative:
    7072              :                     case AggType::SumOrAverageHoursShown: {
    7073           18 :                         ++columnUsedCount;
    7074           18 :                     } break;
    7075            8 :                     case AggType::Maximum:
    7076              :                     case AggType::Minimum:
    7077              :                     case AggType::MaximumDuringHoursShown:
    7078              :                     case AggType::MinimumDuringHoursShown: {
    7079            8 :                         columnUsedCount += 2;
    7080            8 :                     } break;
    7081            0 :                     default:
    7082            0 :                         break;
    7083              :                     }
    7084              :                 } // jColumn
    7085            2 :                 columnHead.allocate(columnUsedCount);
    7086            2 :                 columnWidth.dimension(columnUsedCount, 14); // array assignment - same for all columns
    7087            2 :                 tableBody.allocate(columnUsedCount, 16);
    7088            2 :                 tableBody = ""; // set entire table to blank as default
    7089            2 :                 columnRecount = 0;
    7090           28 :                 for (kColumn = 1; kColumn <= ort->MonthlyTables(curTable).numColumns; ++kColumn) {
    7091           26 :                     curCol = kColumn + ort->MonthlyTables(curTable).firstColumn - 1;
    7092           26 :                     curAggString = aggString.at(ort->MonthlyColumns(curCol).aggType);
    7093           26 :                     if (len(curAggString) > 0) {
    7094           24 :                         curAggString = " {" + stripped(curAggString) + '}';
    7095              :                     }
    7096              :                     // do the unit conversions
    7097           26 :                     if (unitsStyle_cur == OutputReportTabular::UnitsStyle::InchPound ||
    7098           26 :                         unitsStyle_cur == OutputReportTabular::UnitsStyle::InchPoundExceptElectricity) {
    7099              :                         varNameWithUnits =
    7100            0 :                             format("{} [{}]", ort->MonthlyColumns(curCol).varName, Constant::unitNames[(int)ort->MonthlyColumns(curCol).units]);
    7101            0 :                         LookupSItoIP(state, varNameWithUnits, indexUnitConv, curUnits);
    7102            0 :                         GetUnitConversion(state, indexUnitConv, curConversionFactor, state.dataOutRptTab->curConversionOffset, curUnits);
    7103           26 :                     } else if (Util::SameString(Constant::unitNames[(int)ort->MonthlyColumns(curCol).units], "J")) {
    7104           26 :                         curUnits = energyUnitsString;
    7105           26 :                         curConversionFactor = energyUnitsConversionFactor;
    7106           26 :                         state.dataOutRptTab->curConversionOffset = 0.0;
    7107              :                     } else { // if not joules don't perform conversion
    7108            0 :                         curUnits = Constant::unitNames[(int)ort->MonthlyColumns(curCol).units];
    7109            0 :                         curConversionFactor = 1.0;
    7110            0 :                         state.dataOutRptTab->curConversionOffset = 0.0;
    7111              :                     }
    7112           26 :                     switch (ort->MonthlyColumns(curCol).aggType) {
    7113            4 :                     case AggType::SumOrAvg:
    7114              :                     case AggType::SumOrAverageHoursShown: {
    7115            4 :                         ++columnRecount;
    7116              :                         // put in the name of the variable for the column
    7117            4 :                         columnHead(columnRecount) = ort->MonthlyColumns(curCol).varName + curAggString + " [" + curUnits + ']';
    7118            4 :                         sumVal = 0.0;
    7119            4 :                         sumDuration = 0.0;
    7120            4 :                         minVal = storedMaxVal;
    7121            4 :                         maxVal = storedMinVal;
    7122           52 :                         for (lMonth = 1; lMonth <= 12; ++lMonth) {
    7123           48 :                             if (ort->MonthlyColumns(curCol).avgSum ==
    7124              :                                 OutputProcessor::StoreType::Average) { // if it is a average variable divide by duration
    7125            0 :                                 if (ort->MonthlyColumns(curCol).duration(lMonth) != 0) {
    7126            0 :                                     curVal = ((ort->MonthlyColumns(curCol).reslt(lMonth) / ort->MonthlyColumns(curCol).duration(lMonth)) *
    7127              :                                               curConversionFactor) +
    7128            0 :                                              state.dataOutRptTab->curConversionOffset;
    7129              :                                 } else {
    7130            0 :                                     curVal = 0.0;
    7131              :                                 }
    7132            0 :                                 sumVal +=
    7133            0 :                                     (ort->MonthlyColumns(curCol).reslt(lMonth) * curConversionFactor) + state.dataOutRptTab->curConversionOffset;
    7134            0 :                                 sumDuration += ort->MonthlyColumns(curCol).duration(lMonth);
    7135              :                             } else {
    7136           48 :                                 curVal = (ort->MonthlyColumns(curCol).reslt(lMonth) * curConversionFactor) + state.dataOutRptTab->curConversionOffset;
    7137           48 :                                 sumVal += curVal;
    7138              :                             }
    7139           48 :                             if (ort->IsMonthGathered(lMonth)) {
    7140            0 :                                 tableBody(columnRecount, lMonth) = RealToStr(curVal, digitsShown);
    7141            0 :                                 if (curVal > maxVal) {
    7142            0 :                                     maxVal = curVal;
    7143              :                                 }
    7144            0 :                                 if (curVal < minVal) {
    7145            0 :                                     minVal = curVal;
    7146              :                                 }
    7147              :                             } else {
    7148           48 :                                 tableBody(columnRecount, lMonth) = "-";
    7149              :                             }
    7150              :                         } // lMonth
    7151              :                         // add the summary to bottom
    7152            4 :                         if (ort->MonthlyColumns(curCol).avgSum ==
    7153              :                             OutputProcessor::StoreType::Average) { // if it is a average variable divide by duration
    7154            0 :                             if (sumDuration > 0) {
    7155            0 :                                 tableBody(columnRecount, 14) = RealToStr(sumVal / sumDuration, digitsShown);
    7156              :                             } else {
    7157            0 :                                 tableBody(columnRecount, 14) = "";
    7158              :                             }
    7159              :                         } else {
    7160            4 :                             tableBody(columnRecount, 14) = RealToStr(sumVal, digitsShown);
    7161              :                         }
    7162            4 :                         if (minVal != storedMaxVal) {
    7163            0 :                             tableBody(columnRecount, 15) = RealToStr(minVal, digitsShown);
    7164              :                         }
    7165            4 :                         if (maxVal != storedMinVal) {
    7166            0 :                             tableBody(columnRecount, 16) = RealToStr(maxVal, digitsShown);
    7167              :                         }
    7168            4 :                     } break;
    7169           12 :                     case AggType::HoursZero:
    7170              :                     case AggType::HoursNonZero:
    7171              :                     case AggType::HoursPositive:
    7172              :                     case AggType::HoursNonPositive:
    7173              :                     case AggType::HoursNegative:
    7174              :                     case AggType::HoursNonNegative: {
    7175           12 :                         ++columnRecount;
    7176              :                         // put in the name of the variable for the column
    7177           12 :                         columnHead(columnRecount) = ort->MonthlyColumns(curCol).varName + curAggString + " [HOURS]";
    7178           12 :                         sumVal = 0.0;
    7179           12 :                         minVal = storedMaxVal;
    7180           12 :                         maxVal = storedMinVal;
    7181          156 :                         for (lMonth = 1; lMonth <= 12; ++lMonth) {
    7182          144 :                             curVal = ort->MonthlyColumns(curCol).reslt(lMonth);
    7183          144 :                             if (ort->IsMonthGathered(lMonth)) {
    7184            0 :                                 tableBody(columnRecount, lMonth) = RealToStr(curVal, digitsShown);
    7185            0 :                                 sumVal += curVal;
    7186            0 :                                 if (curVal > maxVal) {
    7187            0 :                                     maxVal = curVal;
    7188              :                                 }
    7189            0 :                                 if (curVal < minVal) {
    7190            0 :                                     minVal = curVal;
    7191              :                                 }
    7192              :                             } else {
    7193          144 :                                 tableBody(columnRecount, lMonth) = "-";
    7194              :                             }
    7195              :                         } // lMonth
    7196              :                         // add the summary to bottom
    7197           12 :                         tableBody(columnRecount, 14) = RealToStr(sumVal, digitsShown);
    7198           12 :                         if (minVal != storedMaxVal) {
    7199            0 :                             tableBody(columnRecount, 15) = RealToStr(minVal, digitsShown);
    7200              :                         }
    7201           12 :                         if (maxVal != storedMinVal) {
    7202            0 :                             tableBody(columnRecount, 16) = RealToStr(maxVal, digitsShown);
    7203              :                         }
    7204           12 :                     } break;
    7205            2 :                     case AggType::ValueWhenMaxMin: {
    7206            2 :                         ++columnRecount;
    7207            2 :                         if (ort->MonthlyColumns(curCol).avgSum == OutputProcessor::StoreType::Sum) {
    7208            2 :                             curUnits += "/s";
    7209              :                         }
    7210            2 :                         if (Util::SameString(curUnits, "J/s")) {
    7211            2 :                             curUnits = "W";
    7212              :                         }
    7213              :                         // CR7783 fix
    7214            2 :                         if (Util::SameString(curUnits, "kWh/s")) {
    7215            0 :                             curUnits = "W";
    7216            0 :                             curConversionFactor *= 3600000.0;
    7217              :                         }
    7218            2 :                         if (Util::SameString(curUnits, "GJ/s")) {
    7219            0 :                             curUnits = "kW";
    7220            0 :                             curConversionFactor *= 1000000.0;
    7221              :                         }
    7222            2 :                         if (Util::SameString(curUnits, "MJ/s")) {
    7223            0 :                             curUnits = "kW";
    7224            0 :                             curConversionFactor *= 1000.0;
    7225              :                         }
    7226            2 :                         if (Util::SameString(curUnits, "therm/s")) {
    7227            0 :                             curUnits = "kBtu/h";
    7228            0 :                             curConversionFactor *= 360000.0;
    7229              :                         }
    7230            2 :                         if (Util::SameString(curUnits, "kBtu/s")) {
    7231            0 :                             curUnits = "kBtu/h";
    7232            0 :                             curConversionFactor *= 3600.0;
    7233              :                         }
    7234            2 :                         if (Util::SameString(curUnits, "ton-hrs/s")) {
    7235            0 :                             curUnits = "ton";
    7236            0 :                             curConversionFactor *= 3600.0;
    7237              :                         }
    7238            2 :                         columnHead(columnRecount) = ort->MonthlyColumns(curCol).varName + curAggString + " [" + curUnits + ']';
    7239            2 :                         minVal = storedMaxVal;
    7240            2 :                         maxVal = storedMinVal;
    7241           26 :                         for (lMonth = 1; lMonth <= 12; ++lMonth) {
    7242           24 :                             curVal = ort->MonthlyColumns(curCol).reslt(lMonth) * curConversionFactor + state.dataOutRptTab->curConversionOffset;
    7243           24 :                             if (ort->IsMonthGathered(lMonth)) {
    7244            0 :                                 tableBody(columnRecount, lMonth) = RealToStr(curVal, digitsShown);
    7245            0 :                                 if (curVal > maxVal) {
    7246            0 :                                     maxVal = curVal;
    7247              :                                 }
    7248            0 :                                 if (curVal < minVal) {
    7249            0 :                                     minVal = curVal;
    7250              :                                 }
    7251              :                             } else {
    7252           24 :                                 tableBody(columnRecount, lMonth) = "-";
    7253              :                             }
    7254              :                         } // lMonth
    7255              :                         // add the summary to bottom
    7256            2 :                         if (minVal != storedMaxVal) {
    7257            0 :                             tableBody(columnRecount, 15) = RealToStr(minVal, digitsShown);
    7258              :                         }
    7259            2 :                         if (maxVal != storedMinVal) {
    7260            0 :                             tableBody(columnRecount, 16) = RealToStr(maxVal, digitsShown);
    7261              :                         }
    7262            2 :                     } break;
    7263            8 :                     case AggType::Maximum:
    7264              :                     case AggType::Minimum:
    7265              :                     case AggType::MaximumDuringHoursShown:
    7266              :                     case AggType::MinimumDuringHoursShown: {
    7267            8 :                         columnRecount += 2;
    7268              :                         // put in the name of the variable for the column
    7269            8 :                         if (ort->MonthlyColumns(curCol).avgSum == OutputProcessor::StoreType::Sum) { // if it is a summed variable
    7270            8 :                             curUnits += "/s";
    7271              :                         }
    7272            8 :                         if (Util::SameString(curUnits, "J/s")) {
    7273            8 :                             curUnits = "W";
    7274              :                         }
    7275              :                         // CR7783 fix
    7276            8 :                         if (Util::SameString(curUnits, "kWh/s")) {
    7277            0 :                             curUnits = "W";
    7278            0 :                             curConversionFactor *= 3600000.0;
    7279              :                         }
    7280            8 :                         if (Util::SameString(curUnits, "GJ/s")) {
    7281            0 :                             curUnits = "kW";
    7282            0 :                             curConversionFactor *= 1000000.0;
    7283              :                         }
    7284            8 :                         if (Util::SameString(curUnits, "MJ/s")) {
    7285            0 :                             curUnits = "kW";
    7286            0 :                             curConversionFactor *= 1000.0;
    7287              :                         }
    7288            8 :                         if (Util::SameString(curUnits, "therm/s")) {
    7289            0 :                             curUnits = "kBtu/h";
    7290            0 :                             curConversionFactor *= 360000.0;
    7291              :                         }
    7292            8 :                         if (Util::SameString(curUnits, "kBtu/s")) {
    7293            0 :                             curUnits = "kBtu/h";
    7294            0 :                             curConversionFactor *= 3600.0;
    7295              :                         }
    7296            8 :                         if (Util::SameString(curUnits, "ton-hrs/s")) {
    7297            0 :                             curUnits = "ton";
    7298            0 :                             curConversionFactor *= 3600.0;
    7299              :                         }
    7300            8 :                         columnHead(columnRecount - 1) = ort->MonthlyColumns(curCol).varName + curAggString + " [" + curUnits + ']';
    7301            8 :                         columnHead(columnRecount) = ort->MonthlyColumns(curCol).varName + " {TIMESTAMP}";
    7302            8 :                         minVal = storedMaxVal;
    7303            8 :                         maxVal = storedMinVal;
    7304          104 :                         for (lMonth = 1; lMonth <= 12; ++lMonth) {
    7305           96 :                             if (ort->IsMonthGathered(lMonth)) {
    7306            0 :                                 curVal = ort->MonthlyColumns(curCol).reslt(lMonth);
    7307              :                                 // CR7788 the conversion factors were causing an overflow for the InchPound case since the
    7308              :                                 // value was very small
    7309              :                                 // restructured the following lines to hide showing HUGE and -HUGE values in output table CR8154 Glazer
    7310            0 :                                 if ((curVal < veryLarge) && (curVal > verySmall)) {
    7311            0 :                                     curVal = curVal * curConversionFactor + state.dataOutRptTab->curConversionOffset;
    7312            0 :                                     if (curVal > maxVal) {
    7313            0 :                                         maxVal = curVal;
    7314              :                                     }
    7315            0 :                                     if (curVal < minVal) {
    7316            0 :                                         minVal = curVal;
    7317              :                                     }
    7318            0 :                                     if (curVal < veryLarge && curVal > verySmall) {
    7319            0 :                                         tableBody(columnRecount - 1, lMonth) = RealToStr(curVal, digitsShown);
    7320              :                                     } else {
    7321            0 :                                         tableBody(columnRecount - 1, lMonth) = "-";
    7322              :                                     }
    7323            0 :                                     tableBody(columnRecount, lMonth) = DateToString(ort->MonthlyColumns(curCol).timeStamp(lMonth));
    7324              :                                 } else {
    7325            0 :                                     tableBody(columnRecount - 1, lMonth) = "-";
    7326            0 :                                     tableBody(columnRecount, lMonth) = "-";
    7327              :                                 }
    7328              :                             } else {
    7329           96 :                                 tableBody(columnRecount - 1, lMonth) = "-";
    7330           96 :                                 tableBody(columnRecount, lMonth) = "-";
    7331              :                             }
    7332              :                         } // lMonth
    7333              :                         // add the summary to bottom
    7334              :                         // Don't include if the original min and max values are still present
    7335            8 :                         if (minVal < veryLarge) {
    7336            0 :                             tableBody(columnRecount - 1, 15) = RealToStr(minVal, digitsShown);
    7337              :                         } else {
    7338            8 :                             tableBody(columnRecount - 1, 15) = "-";
    7339              :                         }
    7340            8 :                         if (maxVal > verySmall) {
    7341            0 :                             tableBody(columnRecount - 1, 16) = RealToStr(maxVal, digitsShown);
    7342              :                         } else {
    7343            8 :                             tableBody(columnRecount - 1, 15) = "-";
    7344              :                         }
    7345            8 :                     } break;
    7346            0 :                     default:
    7347            0 :                         break;
    7348              :                     }
    7349              :                 } // KColumn
    7350            2 :                 if (produceTabular) {
    7351            1 :                     WriteReportHeaders(
    7352            1 :                         state, ort->MonthlyInput(iInput).name, ort->MonthlyTables(curTable).keyValue, OutputProcessor::StoreType::Average);
    7353            1 :                     WriteSubtitle(state, "Custom Monthly Report");
    7354            1 :                     WriteTable(state, tableBody, rowHead, columnHead, columnWidth, true); // transpose monthly XML tables.
    7355              :                 }
    7356            2 :                 if (produceSQLite) {
    7357            1 :                     if (state.dataSQLiteProcedures->sqlite) {
    7358            2 :                         state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(tableBody,
    7359              :                                                                                            rowHead,
    7360              :                                                                                            columnHead,
    7361            1 :                                                                                            ort->MonthlyInput(iInput).name,
    7362            1 :                                                                                            ort->MonthlyTables(curTable).keyValue,
    7363              :                                                                                            "Custom Monthly Report");
    7364              :                     }
    7365              :                 }
    7366            2 :                 if (produceTabular) {
    7367            1 :                     if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
    7368            0 :                         state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(tableBody,
    7369              :                                                                                                               rowHead,
    7370              :                                                                                                               columnHead,
    7371            0 :                                                                                                               ort->MonthlyInput(iInput).name,
    7372            0 :                                                                                                               ort->MonthlyTables(curTable).keyValue,
    7373              :                                                                                                               "Custom Monthly Report");
    7374              :                     }
    7375              :                 }
    7376              :             } // jTables
    7377              :         } // iInput
    7378              :     }
    7379            2 : }
    7380              : 
    7381            0 : void WriteTimeBinTables(EnergyPlusData &state)
    7382              : {
    7383              :     // SUBROUTINE INFORMATION:
    7384              :     //       AUTHOR         Jason Glazer
    7385              :     //       DATE WRITTEN   August 2003
    7386              :     //       MODIFIED       January 2010, Kyle Benne
    7387              :     //                      Added SQLite output
    7388              :     //       RE-ENGINEERED  na
    7389              : 
    7390              :     // PURPOSE OF THIS SUBROUTINE:
    7391              :     //   Set up the time bin tabular report results
    7392              : 
    7393              :     // METHODOLOGY EMPLOYED:
    7394              :     //   Creates several arrays that are passed to the WriteTable
    7395              :     //   routine.  All arrays are strings so numbers need to be
    7396              :     //   converted prior to calling WriteTable.
    7397              : 
    7398              :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
    7399              :     // main table
    7400            0 :     Array1D_string columnHead;
    7401            0 :     Array1D_int columnWidth;
    7402            0 :     Array1D_string rowHead(39);
    7403            0 :     Array2D_string tableBody;
    7404              :     // stat table
    7405            0 :     Array1D_string columnHeadStat(1);
    7406            0 :     Array1D_int columnWidthStat(1);
    7407            0 :     Array1D_string rowHeadStat(6);
    7408            0 :     Array2D_string tableBodyStat(1, 6);
    7409              : 
    7410            0 :     std::string repNameWithUnitsandscheduleName;
    7411            0 :     std::string curNameWithSIUnits;
    7412            0 :     std::string curNameAndUnits;
    7413              : 
    7414            0 :     auto &ort = state.dataOutRptTab;
    7415              : 
    7416            0 :     for (int iUnitSystem = 0; iUnitSystem <= 1; iUnitSystem++) {
    7417            0 :         UnitsStyle unitsStyle_cur = ort->unitsStyle;
    7418            0 :         bool produceTabular = true;
    7419            0 :         bool produceSQLite = false;
    7420            0 :         if (produceDualUnitsFlags(iUnitSystem, ort->unitsStyle, ort->unitsStyle_SQLite, unitsStyle_cur, produceTabular, produceSQLite)) {
    7421            0 :             break;
    7422              :         }
    7423              : 
    7424            0 :         rowHead(1) = "Interval Start";
    7425            0 :         rowHead(2) = "Interval End";
    7426            0 :         rowHead(3) = "January";
    7427            0 :         rowHead(4) = "February";
    7428            0 :         rowHead(5) = "March";
    7429            0 :         rowHead(6) = "April";
    7430            0 :         rowHead(7) = "May";
    7431            0 :         rowHead(8) = "June";
    7432            0 :         rowHead(9) = "July";
    7433            0 :         rowHead(10) = "August";
    7434            0 :         rowHead(11) = "September";
    7435            0 :         rowHead(12) = "October";
    7436            0 :         rowHead(13) = "November";
    7437            0 :         rowHead(14) = "December";
    7438            0 :         rowHead(15) = "12:01 to  1:00 am";
    7439            0 :         rowHead(16) = " 1:01 to  2:00 am";
    7440            0 :         rowHead(17) = " 2:01 to  3:00 am";
    7441            0 :         rowHead(18) = " 3:01 to  4:00 am";
    7442            0 :         rowHead(19) = " 4:01 to  5:00 am";
    7443            0 :         rowHead(20) = " 5:01 to  6:00 am";
    7444            0 :         rowHead(21) = " 6:01 to  7:00 am";
    7445            0 :         rowHead(22) = " 7:01 to  8:00 am";
    7446            0 :         rowHead(23) = " 8:01 to  9:00 am";
    7447            0 :         rowHead(24) = " 9:01 to 10:00 am";
    7448            0 :         rowHead(25) = "10:01 to 11:00 am";
    7449            0 :         rowHead(26) = "11:01 to 12:00 pm";
    7450            0 :         rowHead(27) = "12:01 to  1:00 pm";
    7451            0 :         rowHead(28) = " 1:01 to  2:00 pm";
    7452            0 :         rowHead(29) = " 2:01 to  3:00 pm";
    7453            0 :         rowHead(30) = " 3:01 to  4:00 pm";
    7454            0 :         rowHead(31) = " 4:01 to  5:00 pm";
    7455            0 :         rowHead(32) = " 5:01 to  6:00 pm";
    7456            0 :         rowHead(33) = " 6:01 to  7:00 pm";
    7457            0 :         rowHead(34) = " 7:01 to  8:00 pm";
    7458            0 :         rowHead(35) = " 8:01 to  9:00 pm";
    7459            0 :         rowHead(36) = " 9:01 to 10:00 pm";
    7460            0 :         rowHead(37) = "10:01 to 11:00 pm";
    7461            0 :         rowHead(38) = "11:01 to 12:00 am";
    7462            0 :         rowHead(39) = "Total";
    7463              : 
    7464            0 :         for (int iInObj = 1; iInObj <= ort->OutputTableBinnedCount; ++iInObj) {
    7465            0 :             int const firstReport = ort->OutputTableBinned(iInObj).resIndex;
    7466              :             curNameWithSIUnits =
    7467            0 :                 format("{} [{}]", ort->OutputTableBinned(iInObj).varOrMeter, Constant::unitNames[(int)ort->OutputTableBinned(iInObj).units]);
    7468              :             Real64 curIntervalStart;
    7469              :             Real64 curIntervalSize;
    7470            0 :             int indexUnitConv = -1;
    7471            0 :             if (unitsStyle_cur == UnitsStyle::InchPound) {
    7472            0 :                 LookupSItoIP(state, curNameWithSIUnits, indexUnitConv, curNameAndUnits);
    7473            0 :                 curIntervalStart = ConvertIP(state, indexUnitConv, ort->OutputTableBinned(iInObj).intervalStart);
    7474            0 :                 curIntervalSize = ConvertIPdelta(state, indexUnitConv, ort->OutputTableBinned(iInObj).intervalSize);
    7475            0 :             } else if (unitsStyle_cur == UnitsStyle::InchPoundExceptElectricity) {
    7476            0 :                 LookupSItoIP(state, curNameWithSIUnits, indexUnitConv, curNameAndUnits);
    7477            0 :                 curIntervalStart = ConvertIP(state, indexUnitConv, ort->OutputTableBinned(iInObj).intervalStart);
    7478            0 :                 curIntervalSize = ConvertIPdelta(state, indexUnitConv, ort->OutputTableBinned(iInObj).intervalSize);
    7479              :             } else {
    7480            0 :                 curNameAndUnits = curNameWithSIUnits;
    7481            0 :                 curIntervalStart = ort->OutputTableBinned(iInObj).intervalStart;
    7482            0 :                 curIntervalSize = ort->OutputTableBinned(iInObj).intervalSize;
    7483              :             }
    7484            0 :             int const curIntervalCount = ort->OutputTableBinned(iInObj).intervalCount;
    7485            0 :             int const curNumTables = ort->OutputTableBinned(iInObj).numTables;
    7486            0 :             Real64 const topValue = curIntervalStart + curIntervalSize * curIntervalCount;
    7487            0 :             int numIntervalDigits = 2;
    7488            0 :             if (curIntervalSize < 1) {
    7489            0 :                 numIntervalDigits = 4;
    7490            0 :             } else if (curIntervalSize >= 10) {
    7491            0 :                 numIntervalDigits = 0;
    7492              :             }
    7493            0 :             int const numCols = curIntervalCount + 3;
    7494              :             // make arrays two columns wider for below and above bin range
    7495            0 :             columnHead.allocate(numCols);
    7496            0 :             columnWidth.allocate(numCols);
    7497            0 :             columnWidth = 14; // array assignment - same for all columns
    7498            0 :             tableBody.allocate(numCols, 39);
    7499            0 :             tableBody = "";
    7500            0 :             columnHead = "- [hr]";
    7501            0 :             tableBody(1, 1) = "less than";
    7502            0 :             tableBody(1, 2) = RealToStr(curIntervalStart, numIntervalDigits);
    7503            0 :             for (int nCol = 1; nCol <= curIntervalCount; ++nCol) {
    7504            0 :                 columnHead(nCol + 1) = fmt::format("{} [hr]", nCol);
    7505              :                 // beginning of interval
    7506            0 :                 tableBody(nCol + 1, 1) = RealToStr(curIntervalStart + (nCol - 1) * curIntervalSize, numIntervalDigits) + "<=";
    7507              :                 // end of interval
    7508            0 :                 tableBody(nCol + 1, 2) = RealToStr(curIntervalStart + nCol * curIntervalSize, numIntervalDigits) + '>';
    7509              :             }
    7510            0 :             tableBody(curIntervalCount + 2, 1) = "equal to or more than";
    7511            0 :             tableBody(curIntervalCount + 2, 2) = RealToStr(topValue, numIntervalDigits);
    7512            0 :             tableBody(numCols, 1) = "Row";
    7513            0 :             tableBody(numCols, 2) = "Total";
    7514            0 :             for (int iTable = 1; iTable <= curNumTables; ++iTable) {
    7515            0 :                 int const repIndex = firstReport + (iTable - 1);
    7516            0 :                 if (ort->OutputTableBinned(iInObj).sched == nullptr) {
    7517            0 :                     repNameWithUnitsandscheduleName = curNameAndUnits;
    7518              :                 } else {
    7519            0 :                     repNameWithUnitsandscheduleName = curNameAndUnits + " [" + ort->OutputTableBinned(iInObj).sched->Name + ']';
    7520              :                 }
    7521            0 :                 if (produceTabular) {
    7522            0 :                     WriteReportHeaders(
    7523            0 :                         state, repNameWithUnitsandscheduleName, ort->BinObjVarID(repIndex).namesOfObj, ort->OutputTableBinned(iInObj).avgSum);
    7524              :                 }
    7525            0 :                 for (int kHour = 1; kHour <= 24; ++kHour) {
    7526            0 :                     tableBody(1, 14 + kHour) = RealToStr(ort->BinResultsBelow(repIndex).hrly(kHour), 2);
    7527            0 :                     tableBody(curIntervalCount + 2, 14 + kHour) = RealToStr(ort->BinResultsAbove(repIndex).hrly(kHour), 2);
    7528            0 :                     Real64 rowTotal = ort->BinResultsBelow(repIndex).hrly(kHour) + ort->BinResultsAbove(repIndex).hrly(kHour);
    7529            0 :                     for (int nCol = 1; nCol <= curIntervalCount; ++nCol) {
    7530            0 :                         tableBody(nCol + 1, 14 + kHour) = RealToStr(ort->BinResults(nCol, repIndex).hrly(kHour), 2);
    7531              :                         // sum the total for all columns
    7532            0 :                         rowTotal += ort->BinResults(nCol, repIndex).hrly(kHour);
    7533              :                     }
    7534            0 :                     tableBody(numCols, 14 + kHour) = RealToStr(rowTotal, 2);
    7535              :                 }
    7536            0 :                 Real64 tableTotal = 0.0;
    7537            0 :                 for (int kMonth = 1; kMonth <= 12; ++kMonth) {
    7538            0 :                     tableBody(1, 2 + kMonth) = RealToStr(ort->BinResultsBelow(repIndex).mnth(kMonth), 2);
    7539            0 :                     tableBody(curIntervalCount + 2, 2 + kMonth) = RealToStr(ort->BinResultsAbove(repIndex).mnth(kMonth), 2);
    7540            0 :                     Real64 rowTotal = ort->BinResultsBelow(repIndex).mnth(kMonth) + ort->BinResultsAbove(repIndex).mnth(kMonth);
    7541            0 :                     for (int nCol = 1; nCol <= curIntervalCount; ++nCol) {
    7542            0 :                         tableBody(nCol + 1, 2 + kMonth) = RealToStr(ort->BinResults(nCol, repIndex).mnth(kMonth), 2);
    7543              :                         // sum the total for all columns
    7544            0 :                         rowTotal += ort->BinResults(nCol, repIndex).mnth(kMonth);
    7545              :                     }
    7546            0 :                     tableBody(numCols, 2 + kMonth) = RealToStr(rowTotal, 2);
    7547            0 :                     tableTotal += rowTotal;
    7548              :                 }
    7549              :                 // compute total row
    7550            0 :                 for (int nCol = 1; nCol <= curIntervalCount; ++nCol) {
    7551            0 :                     Real64 colTotal = 0.0;
    7552            0 :                     for (int kMonth = 1; kMonth <= 12; ++kMonth) {
    7553            0 :                         colTotal += ort->BinResults(nCol, repIndex).mnth(kMonth);
    7554              :                     }
    7555            0 :                     tableBody(nCol + 1, 39) = RealToStr(colTotal, 2);
    7556              :                 }
    7557            0 :                 Real64 aboveTotal = 0.0;
    7558            0 :                 Real64 belowTotal = 0.0;
    7559            0 :                 for (int kMonth = 1; kMonth <= 12; ++kMonth) {
    7560            0 :                     aboveTotal += ort->BinResultsAbove(repIndex).mnth(kMonth);
    7561            0 :                     belowTotal += ort->BinResultsBelow(repIndex).mnth(kMonth);
    7562              :                 }
    7563            0 :                 tableBody(1, 39) = RealToStr(belowTotal, 2);
    7564            0 :                 tableBody(curIntervalCount + 2, 39) = RealToStr(aboveTotal, 2);
    7565            0 :                 tableBody(numCols, 39) = RealToStr(tableTotal, 2);
    7566            0 :                 if (produceTabular) {
    7567            0 :                     WriteTextLine(state, "Values in table are in hours.");
    7568            0 :                     WriteTextLine(state, "");
    7569            0 :                     WriteSubtitle(state, "Time Bin Results");
    7570            0 :                     WriteTable(state, tableBody, rowHead, columnHead, columnWidth, true); // transpose XML tables
    7571              :                 }
    7572            0 :                 if (produceSQLite) {
    7573            0 :                     if (state.dataSQLiteProcedures->sqlite) {
    7574            0 :                         state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(tableBody,
    7575              :                                                                                            rowHead,
    7576              :                                                                                            columnHead,
    7577              :                                                                                            repNameWithUnitsandscheduleName,
    7578            0 :                                                                                            ort->BinObjVarID(repIndex).namesOfObj,
    7579              :                                                                                            "Time Bin Results");
    7580              :                     }
    7581              :                 }
    7582            0 :                 if (produceTabular) {
    7583            0 :                     if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
    7584            0 :                         state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(tableBody,
    7585              :                                                                                                               rowHead,
    7586              :                                                                                                               columnHead,
    7587              :                                                                                                               repNameWithUnitsandscheduleName,
    7588            0 :                                                                                                               ort->BinObjVarID(repIndex).namesOfObj,
    7589              :                                                                                                               "Time Bin Results");
    7590              :                     }
    7591              :                 }
    7592              :                 // create statistics table
    7593            0 :                 rowHeadStat(1) = "Minimum";
    7594            0 :                 rowHeadStat(2) = "Mean minus two standard deviations";
    7595            0 :                 rowHeadStat(3) = "Mean";
    7596            0 :                 rowHeadStat(4) = "Mean plus two standard deviations";
    7597            0 :                 rowHeadStat(5) = "Maximum";
    7598            0 :                 rowHeadStat(6) = "Standard deviation";
    7599            0 :                 columnHeadStat(1) = "Statistic";
    7600            0 :                 columnWidthStat(1) = 14;
    7601              :                 // per Applied Regression Analysis and Other Multivariate Methods, Kleinburger/Kupper, 1978
    7602              :                 // first check if very large constant number has caused the second part to be larger than the first
    7603            0 :                 Real64 repStDev = 0.0;
    7604            0 :                 Real64 repMean = 0.0;
    7605              : 
    7606            0 :                 if (ort->BinStatistics(repIndex).n > 1) {
    7607            0 :                     if (ort->BinStatistics(repIndex).sum2 > (pow_2(ort->BinStatistics(repIndex).sum) / ort->BinStatistics(repIndex).n)) {
    7608            0 :                         repStDev = std::sqrt(
    7609            0 :                             (ort->BinStatistics(repIndex).sum2 - (pow_2(ort->BinStatistics(repIndex).sum) / ort->BinStatistics(repIndex).n)) /
    7610            0 :                             (ort->BinStatistics(repIndex).n - 1));
    7611              :                     } else {
    7612            0 :                         repStDev = 0.0;
    7613              :                     }
    7614            0 :                     repMean = ort->BinStatistics(repIndex).sum / ort->BinStatistics(repIndex).n;
    7615              :                 }
    7616              : 
    7617            0 :                 if (unitsStyle_cur == OutputReportTabular::UnitsStyle::InchPound ||
    7618            0 :                     unitsStyle_cur == OutputReportTabular::UnitsStyle::InchPoundExceptElectricity) {
    7619            0 :                     tableBodyStat(1, 1) = RealToStr(ConvertIP(state, indexUnitConv, ort->BinStatistics(repIndex).minimum), 2);
    7620            0 :                     tableBodyStat(1, 2) = RealToStr(ConvertIP(state, indexUnitConv, repMean - 2 * repStDev), 2);
    7621            0 :                     tableBodyStat(1, 3) = RealToStr(ConvertIP(state, indexUnitConv, repMean), 2);
    7622            0 :                     tableBodyStat(1, 4) = RealToStr(ConvertIP(state, indexUnitConv, repMean + 2 * repStDev), 2);
    7623            0 :                     tableBodyStat(1, 5) = RealToStr(ConvertIP(state, indexUnitConv, ort->BinStatistics(repIndex).maximum), 2);
    7624            0 :                     tableBodyStat(1, 6) = RealToStr(ConvertIPdelta(state, indexUnitConv, repStDev), 2);
    7625              :                 } else {
    7626            0 :                     tableBodyStat(1, 1) = RealToStr(ort->BinStatistics(repIndex).minimum, 2);
    7627            0 :                     tableBodyStat(1, 2) = RealToStr(repMean - 2 * repStDev, 2);
    7628            0 :                     tableBodyStat(1, 3) = RealToStr(repMean, 2);
    7629            0 :                     tableBodyStat(1, 4) = RealToStr(repMean + 2 * repStDev, 2);
    7630            0 :                     tableBodyStat(1, 5) = RealToStr(ort->BinStatistics(repIndex).maximum, 2);
    7631            0 :                     tableBodyStat(1, 6) = RealToStr(repStDev, 2);
    7632              :                 }
    7633            0 :                 if (produceTabular) {
    7634            0 :                     WriteSubtitle(state, "Statistics");
    7635            0 :                     WriteTable(state, tableBodyStat, rowHeadStat, columnHeadStat, columnWidthStat, true); // transpose XML table
    7636              :                 }
    7637            0 :                 if (produceSQLite) {
    7638            0 :                     if (state.dataSQLiteProcedures->sqlite) {
    7639            0 :                         state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
    7640            0 :                             tableBody, rowHead, columnHead, repNameWithUnitsandscheduleName, ort->BinObjVarID(repIndex).namesOfObj, "Statistics");
    7641              :                     }
    7642              :                 }
    7643            0 :                 if (produceTabular) {
    7644            0 :                     if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
    7645            0 :                         state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(
    7646            0 :                             tableBody, rowHead, columnHead, repNameWithUnitsandscheduleName, ort->BinObjVarID(repIndex).namesOfObj, "Statistics");
    7647              :                     }
    7648              :                 }
    7649              :             }
    7650              :         }
    7651              :     }
    7652            0 : }
    7653              : 
    7654           42 : void WriteBEPSTable(EnergyPlusData &state)
    7655              : {
    7656              :     // SUBROUTINE INFORMATION:
    7657              :     //       AUTHOR         Jason Glazer
    7658              :     //       DATE WRITTEN   November 2003
    7659              :     //       MODIFIED       January 2010, Kyle Benne; Added SQLite output
    7660              :     //                      March 2020, Dareum Nam; Disaggregated "Additional Fuel"
    7661              : 
    7662              :     // PURPOSE OF THIS SUBROUTINE:
    7663              :     //   Take the gathered total and enduse meter data and structure
    7664              :     //   the results into a tabular report for output.
    7665              : 
    7666              :     // METHODOLOGY EMPLOYED:
    7667              :     //   Create arrays for the call to WriteTable and then call it.
    7668              :     //   This report actually consists of many sub-tables each with
    7669              :     //   its own call to WriteTable.  Anytime that column headings are
    7670              :     //   desired they are done in a new table because the only place
    7671              :     //   that will split up very long header lines for the fixed width
    7672              :     //   table is the header rows.
    7673              : 
    7674           42 :     int constexpr colElectricity(1);
    7675           42 :     int constexpr colGas(2);
    7676           42 :     int constexpr colGasoline(3);
    7677           42 :     int constexpr colDiesel(4);
    7678           42 :     int constexpr colCoal(5);
    7679           42 :     int constexpr colFuelOilNo1(6);
    7680           42 :     int constexpr colFuelOilNo2(7);
    7681           42 :     int constexpr colPropane(8);
    7682           42 :     int constexpr colOtherFuel1(9);
    7683           42 :     int constexpr colOtherFuel2(10);
    7684           42 :     int constexpr colPurchCool(11);
    7685           42 :     int constexpr colPurchHeatWtr(12);
    7686           42 :     int constexpr colPurchHeatSt(13);
    7687              : 
    7688           42 :     Real64 constexpr SmallValue(1.e-14);
    7689           42 :     auto &ort = state.dataOutRptTab;
    7690           42 :     auto &op = state.dataOutputProcessor;
    7691              : 
    7692           42 :     if (!ort->displayTabularBEPS && !ort->displayLEEDSummary) {
    7693            0 :         return;
    7694              :     }
    7695              : 
    7696              :     // all arrays are in the format: (row, column)
    7697           42 :     Array1D_string columnHead;
    7698           42 :     Array1D_int columnWidth;
    7699           42 :     Array1D_string rowHead;
    7700           42 :     Array2D_string tableBody;
    7701              : 
    7702           42 :     Array2D<Real64> useVal(14, 15);
    7703           42 :     Array2D<Real64> normalVal(14, 4);
    7704           42 :     Array1D<Real64> collapsedTotal(14);
    7705           42 :     Array2D<Real64> collapsedEndUse(14, static_cast<int>(Constant::EndUse::Num));
    7706           42 :     Array3D<Real64> collapsedEndUseSub(state.dataOutputProcessor->MaxNumSubcategories, static_cast<int>(Constant::EndUse::Num), 14);
    7707           42 :     Array2D<Real64> endUseSubOther(14, static_cast<int>(Constant::EndUse::Num));
    7708           42 :     Array3D<Real64> collapsedEndUseSpType(state.dataOutputProcessor->maxNumEndUseSpaceTypes, static_cast<int>(Constant::EndUse::Num), 14);
    7709              : 
    7710              :     // Jan 2021: Added temp storage
    7711           42 :     Real64 gtPowerFuelFireGen = ort->gatherPowerFuelFireGen;
    7712           42 :     Real64 gtPowerPV = ort->gatherPowerPV;
    7713           42 :     Real64 gtPowerWind = ort->gatherPowerWind;
    7714           42 :     Real64 gtPowerHTGeothermal = ort->gatherPowerHTGeothermal;
    7715           42 :     Real64 gtPowerConversion = ort->gatherPowerConversion;
    7716           42 :     Real64 gtElecProduced = ort->gatherElecProduced;
    7717           42 :     Real64 gtElecPUrchased = ort->gatherElecPurchased;
    7718           42 :     Real64 gtElecSurplusSold = ort->gatherElecSurplusSold;
    7719              : 
    7720           42 :     Real64 gtWaterHeatRecovery = ort->gatherWaterHeatRecovery;
    7721           42 :     Real64 gtAirHeatRecoveryCool = ort->gatherAirHeatRecoveryCool;
    7722           42 :     Real64 gtAirHeatRecoveryHeat = ort->gatherAirHeatRecoveryHeat;
    7723           42 :     Real64 gtHeatHTGeothermal = ort->gatherHeatHTGeothermal;
    7724           42 :     Real64 gtHeatSolarWater = ort->gatherHeatSolarWater;
    7725           42 :     Real64 gtHeatSolarAir = ort->gatherHeatSolarAir;
    7726              : 
    7727              :     // show the headers of the report
    7728           42 :     if (ort->displayTabularBEPS) {
    7729          126 :         WriteReportHeaders(state, "Annual Building Utility Performance Summary", "Entire Facility", OutputProcessor::StoreType::Average);
    7730              :         // show the number of hours that the table applies to
    7731           42 :         WriteTextLine(state, "Values gathered over " + RealToStr(ort->gatherElapsedTimeBEPS, 2) + " hours", true);
    7732           42 :         if (ort->gatherElapsedTimeBEPS < 8759.0) { // might not add up to 8760 exactly but can't be more than 1 hour diff.
    7733           84 :             WriteTextLine(state, "WARNING: THE REPORT DOES NOT REPRESENT A FULL ANNUAL SIMULATION.", true);
    7734              :         }
    7735           84 :         WriteTextLine(state, "", true);
    7736              :     }
    7737              : 
    7738           86 :     for (int iUnitSystem = 0; iUnitSystem <= 1; iUnitSystem++) {
    7739           84 :         UnitsStyle unitsStyle_cur = ort->unitsStyle;
    7740           84 :         bool produceTabular = true;
    7741           84 :         bool produceSQLite = false;
    7742           84 :         if (produceDualUnitsFlags(iUnitSystem, ort->unitsStyle, ort->unitsStyle_SQLite, unitsStyle_cur, produceTabular, produceSQLite)) {
    7743           40 :             break;
    7744              :         }
    7745              : 
    7746              :         // determine building floor areas
    7747           44 :         DetermineBuildingFloorArea(state);
    7748              :         // collapse the gatherEndUseBEPS array to the resource groups displayed
    7749          660 :         for (int jEndUse = 1; jEndUse <= static_cast<int>(Constant::EndUse::Num); ++jEndUse) {
    7750          616 :             collapsedEndUse(1, jEndUse) = ort->gatherEndUseBEPS(1, jEndUse);   // electricity
    7751          616 :             collapsedEndUse(2, jEndUse) = ort->gatherEndUseBEPS(2, jEndUse);   // natural gas
    7752          616 :             collapsedEndUse(3, jEndUse) = ort->gatherEndUseBEPS(6, jEndUse);   // gasoline
    7753          616 :             collapsedEndUse(4, jEndUse) = ort->gatherEndUseBEPS(8, jEndUse);   // diesel
    7754          616 :             collapsedEndUse(5, jEndUse) = ort->gatherEndUseBEPS(9, jEndUse);   // coal
    7755          616 :             collapsedEndUse(6, jEndUse) = ort->gatherEndUseBEPS(10, jEndUse);  // Fuel Oil No1
    7756          616 :             collapsedEndUse(7, jEndUse) = ort->gatherEndUseBEPS(11, jEndUse);  // Fuel Oil No2
    7757          616 :             collapsedEndUse(8, jEndUse) = ort->gatherEndUseBEPS(12, jEndUse);  // propane
    7758          616 :             collapsedEndUse(9, jEndUse) = ort->gatherEndUseBEPS(13, jEndUse);  // otherfuel1
    7759          616 :             collapsedEndUse(10, jEndUse) = ort->gatherEndUseBEPS(14, jEndUse); // otherfuel2
    7760          616 :             collapsedEndUse(11, jEndUse) = ort->gatherEndUseBEPS(3, jEndUse);  // district cooling <- purchased cooling
    7761          616 :             collapsedEndUse(12, jEndUse) = ort->gatherEndUseBEPS(4, jEndUse);  // district heating water <- purchased heating
    7762          616 :             collapsedEndUse(13, jEndUse) = ort->gatherEndUseBEPS(5, jEndUse);  // district heating steam  <- purchased heating
    7763          616 :             collapsedEndUse(14, jEndUse) = ort->gatherEndUseBEPS(7, jEndUse);  // water
    7764              :         }
    7765              :         // repeat with totals
    7766           44 :         collapsedTotal(1) = ort->gatherTotalsBEPS(1);   // electricity
    7767           44 :         collapsedTotal(2) = ort->gatherTotalsBEPS(2);   // natural gas
    7768           44 :         collapsedTotal(3) = ort->gatherTotalsBEPS(6);   // gasoline
    7769           44 :         collapsedTotal(4) = ort->gatherTotalsBEPS(8);   // diesel
    7770           44 :         collapsedTotal(5) = ort->gatherTotalsBEPS(9);   // coal
    7771           44 :         collapsedTotal(6) = ort->gatherTotalsBEPS(10);  // Fuel Oil No1
    7772           44 :         collapsedTotal(7) = ort->gatherTotalsBEPS(11);  // Fuel Oil No2
    7773           44 :         collapsedTotal(8) = ort->gatherTotalsBEPS(12);  // propane
    7774           44 :         collapsedTotal(9) = ort->gatherTotalsBEPS(13);  // other fuel 1
    7775           44 :         collapsedTotal(10) = ort->gatherTotalsBEPS(14); // other fuel 2
    7776           44 :         collapsedTotal(11) = ort->gatherTotalsBEPS(3);  // district cooling <- purchased cooling
    7777           44 :         collapsedTotal(12) = ort->gatherTotalsBEPS(4);  // district heating water <- purchased heating
    7778           44 :         collapsedTotal(13) = ort->gatherTotalsBEPS(5);  // district heating steam  <- purchased heating
    7779           44 :         collapsedTotal(14) = ort->gatherTotalsBEPS(7);  // water
    7780              : 
    7781           44 :         if (produceTabular) {
    7782           42 :             if (state.dataGlobal->createPerfLog) {
    7783            0 :                 Util::appendPerfLog(state, "Electricity ABUPS Total [J]", format("{:.3R}", collapsedTotal(1)));
    7784            0 :                 Util::appendPerfLog(state, "Natural Gas ABUPS Total [J]", format("{:.3R}", collapsedTotal(2)));
    7785            0 :                 Util::appendPerfLog(state, "Gasoline ABUPS Total [J]", format("{:.3R}", collapsedTotal(3)));
    7786            0 :                 Util::appendPerfLog(state, "Diesel ABUPS Total [J]", format("{:.3R}", collapsedTotal(4)));
    7787            0 :                 Util::appendPerfLog(state, "Coal ABUPS Total [J]", format("{:.3R}", collapsedTotal(5)));
    7788            0 :                 Util::appendPerfLog(state, "Fuel Oil No 1 ABUPS Total [J]", format("{:.3R}", collapsedTotal(6)));
    7789            0 :                 Util::appendPerfLog(state, "Fuel Oil No 2 ABUPS Total [J]", format("{:.3R}", collapsedTotal(7)));
    7790            0 :                 Util::appendPerfLog(state, "Propane ABUPS Total [J]", format("{:.3R}", collapsedTotal(8)));
    7791            0 :                 Util::appendPerfLog(state, "Other Fuel 1 ABUPS Total [J]", format("{:.3R}", collapsedTotal(9)));
    7792            0 :                 Util::appendPerfLog(state, "Other Fuel 2 ABUPS Total [J]", format("{:.3R}", collapsedTotal(10)));
    7793            0 :                 Util::appendPerfLog(state, "District Cooling ABUPS Total [J]", format("{:.3R}", collapsedTotal(11)));
    7794            0 :                 Util::appendPerfLog(state, "District Heating Water ABUPS Total [J]", format("{:.3R}", collapsedTotal(12)));
    7795            0 :                 Util::appendPerfLog(state, "District Heating Steam ABUPS Total [J]", format("{:.3R}", collapsedTotal(13)));
    7796            0 :                 Util::appendPerfLog(state, "Water ABUPS Total [m3]", format("{:.3R}", collapsedTotal(14)));
    7797            0 :                 Util::appendPerfLog(state, "Values Gathered Over [hours]", format("{:.2R}", ort->gatherElapsedTimeBEPS));
    7798            0 :                 Util::appendPerfLog(state,
    7799              :                                     "Facility Any Zone Oscillating Temperatures Time [hours]",
    7800            0 :                                     format("{:.2R}", state.dataZoneTempPredictorCorrector->AnnualAnyZoneTempOscillate));
    7801            0 :                 Util::appendPerfLog(state,
    7802              :                                     "Facility Any Zone Oscillating Temperatures During Occupancy Time [hours]",
    7803            0 :                                     format("{:.2R}", state.dataZoneTempPredictorCorrector->AnnualAnyZoneTempOscillateDuringOccupancy));
    7804            0 :                 Util::appendPerfLog(state,
    7805              :                                     "Facility Any Zone Oscillating Temperatures in Deadband Time [hours]",
    7806            0 :                                     format("{:.2R}", state.dataZoneTempPredictorCorrector->AnnualAnyZoneTempOscillateInDeadband));
    7807              :             }
    7808              :         }
    7809          660 :         for (int jEndUse = 1; jEndUse <= static_cast<int>(Constant::EndUse::Num); ++jEndUse) {
    7810          797 :             for (int kEndUseSub = 1; kEndUseSub <= op->EndUseCategory(jEndUse).NumSubcategories; ++kEndUseSub) {
    7811          181 :                 collapsedEndUseSub(kEndUseSub, jEndUse, 1) = ort->gatherEndUseSubBEPS(kEndUseSub, jEndUse, 1);   // electricity
    7812          181 :                 collapsedEndUseSub(kEndUseSub, jEndUse, 2) = ort->gatherEndUseSubBEPS(kEndUseSub, jEndUse, 2);   // natural gas
    7813          181 :                 collapsedEndUseSub(kEndUseSub, jEndUse, 3) = ort->gatherEndUseSubBEPS(kEndUseSub, jEndUse, 6);   // gasoline
    7814          181 :                 collapsedEndUseSub(kEndUseSub, jEndUse, 4) = ort->gatherEndUseSubBEPS(kEndUseSub, jEndUse, 8);   // diesel
    7815          181 :                 collapsedEndUseSub(kEndUseSub, jEndUse, 5) = ort->gatherEndUseSubBEPS(kEndUseSub, jEndUse, 9);   // coal
    7816          181 :                 collapsedEndUseSub(kEndUseSub, jEndUse, 6) = ort->gatherEndUseSubBEPS(kEndUseSub, jEndUse, 10);  // Fuel Oil No1
    7817          181 :                 collapsedEndUseSub(kEndUseSub, jEndUse, 7) = ort->gatherEndUseSubBEPS(kEndUseSub, jEndUse, 11);  // Fuel Oil No2
    7818          181 :                 collapsedEndUseSub(kEndUseSub, jEndUse, 8) = ort->gatherEndUseSubBEPS(kEndUseSub, jEndUse, 12);  // propane
    7819          181 :                 collapsedEndUseSub(kEndUseSub, jEndUse, 9) = ort->gatherEndUseSubBEPS(kEndUseSub, jEndUse, 13);  // otherfuel1
    7820          181 :                 collapsedEndUseSub(kEndUseSub, jEndUse, 10) = ort->gatherEndUseSubBEPS(kEndUseSub, jEndUse, 14); // otherfuel2
    7821          181 :                 collapsedEndUseSub(kEndUseSub, jEndUse, 11) = ort->gatherEndUseSubBEPS(kEndUseSub, jEndUse, 3);  // district cooling <- purch cooling
    7822          362 :                 collapsedEndUseSub(kEndUseSub, jEndUse, 12) =
    7823          181 :                     ort->gatherEndUseSubBEPS(kEndUseSub, jEndUse, 4); // district heating water <- purch heating
    7824          362 :                 collapsedEndUseSub(kEndUseSub, jEndUse, 13) =
    7825          181 :                     ort->gatherEndUseSubBEPS(kEndUseSub, jEndUse, 5); // district heating steam <- purch heating
    7826          181 :                 collapsedEndUseSub(kEndUseSub, jEndUse, 14) = ort->gatherEndUseSubBEPS(kEndUseSub, jEndUse, 7); // water
    7827              :             }
    7828              : 
    7829          640 :             for (int kEndUseSpType = 1; kEndUseSpType <= op->EndUseCategory(jEndUse).numSpaceTypes; ++kEndUseSpType) {
    7830           24 :                 collapsedEndUseSpType(kEndUseSpType, jEndUse, 1) = ort->gatherEndUseSpTypeBEPS(kEndUseSpType, jEndUse, 1);   // electricity
    7831           24 :                 collapsedEndUseSpType(kEndUseSpType, jEndUse, 2) = ort->gatherEndUseSpTypeBEPS(kEndUseSpType, jEndUse, 2);   // natural gas
    7832           24 :                 collapsedEndUseSpType(kEndUseSpType, jEndUse, 3) = ort->gatherEndUseSpTypeBEPS(kEndUseSpType, jEndUse, 6);   // gasoline
    7833           24 :                 collapsedEndUseSpType(kEndUseSpType, jEndUse, 4) = ort->gatherEndUseSpTypeBEPS(kEndUseSpType, jEndUse, 8);   // diesel
    7834           24 :                 collapsedEndUseSpType(kEndUseSpType, jEndUse, 5) = ort->gatherEndUseSpTypeBEPS(kEndUseSpType, jEndUse, 9);   // coal
    7835           24 :                 collapsedEndUseSpType(kEndUseSpType, jEndUse, 6) = ort->gatherEndUseSpTypeBEPS(kEndUseSpType, jEndUse, 10);  // Fuel Oil No1
    7836           24 :                 collapsedEndUseSpType(kEndUseSpType, jEndUse, 7) = ort->gatherEndUseSpTypeBEPS(kEndUseSpType, jEndUse, 11);  // Fuel Oil No2
    7837           24 :                 collapsedEndUseSpType(kEndUseSpType, jEndUse, 8) = ort->gatherEndUseSpTypeBEPS(kEndUseSpType, jEndUse, 12);  // propane
    7838           24 :                 collapsedEndUseSpType(kEndUseSpType, jEndUse, 9) = ort->gatherEndUseSpTypeBEPS(kEndUseSpType, jEndUse, 13);  // otherfuel1
    7839           24 :                 collapsedEndUseSpType(kEndUseSpType, jEndUse, 10) = ort->gatherEndUseSpTypeBEPS(kEndUseSpType, jEndUse, 14); // otherfuel2
    7840           48 :                 collapsedEndUseSpType(kEndUseSpType, jEndUse, 11) =
    7841           24 :                     ort->gatherEndUseSpTypeBEPS(kEndUseSpType, jEndUse, 3); // district cooling <- purch cooling
    7842           48 :                 collapsedEndUseSpType(kEndUseSpType, jEndUse, 12) =
    7843           24 :                     ort->gatherEndUseSpTypeBEPS(kEndUseSpType, jEndUse, 4); // district heating water <- purch heating
    7844           48 :                 collapsedEndUseSpType(kEndUseSpType, jEndUse, 13) =
    7845           24 :                     ort->gatherEndUseSpTypeBEPS(kEndUseSpType, jEndUse, 5); // district heating steam <- purch heating
    7846           24 :                 collapsedEndUseSpType(kEndUseSpType, jEndUse, 14) = ort->gatherEndUseSpTypeBEPS(kEndUseSpType, jEndUse, 7); // water
    7847              :             }
    7848              :         }
    7849              :         // unit conversion - all values are used as divisors
    7850              :         Real64 largeConversionFactor;
    7851              :         Real64 kConversionFactor;
    7852              :         Real64 waterConversionFactor;
    7853              :         Real64 areaConversionFactor;
    7854           44 :         Real64 ipElectricityConversionFactor = 1.0;
    7855           44 :         switch (unitsStyle_cur) {
    7856            4 :         case UnitsStyle::JtoKWH: {
    7857            4 :             largeConversionFactor = 3600000.0;
    7858            4 :             kConversionFactor = 1.0;
    7859            4 :             waterConversionFactor = 1.0;
    7860            4 :             areaConversionFactor = 1.0;
    7861            4 :         } break;
    7862            2 :         case UnitsStyle::InchPound: {
    7863            6 :             largeConversionFactor = getSpecificUnitDivider(state, "J", "kBtu"); // 1054351.84 J to kBtu
    7864            2 :             kConversionFactor = 1.0;
    7865            8 :             waterConversionFactor = getSpecificUnitDivider(state, "m3", "gal"); // 0.003785413 m3 to gal
    7866            6 :             areaConversionFactor = getSpecificUnitDivider(state, "m2", "ft2");  // 0.092893973 m2 to ft2
    7867            2 :         } break;
    7868            1 :         case UnitsStyle::InchPoundExceptElectricity: {
    7869            3 :             largeConversionFactor = getSpecificUnitDivider(state, "J", "kBtu"); // 1054351.84 J to kBtu
    7870            1 :             kConversionFactor = 1.0;
    7871            4 :             waterConversionFactor = getSpecificUnitDivider(state, "m3", "gal"); // 0.003785413 m3 to gal
    7872            3 :             areaConversionFactor = getSpecificUnitDivider(state, "m2", "ft2");  // 0.092893973 m2 to ft2
    7873            1 :             ipElectricityConversionFactor = largeConversionFactor / (1000.0 * 3600.0);
    7874            1 :         } break;
    7875           37 :         default: {
    7876           37 :             largeConversionFactor = 1000000000.0;
    7877           37 :             kConversionFactor = 1000.0;
    7878           37 :             waterConversionFactor = 1.0;
    7879           37 :             areaConversionFactor = 1.0;
    7880           37 :         } break;
    7881              :         }
    7882              : 
    7883              :         // convert units into GJ (divide by 1,000,000,000) if J otherwise kWh
    7884          616 :         for (int iResource = 1; iResource <= 13; ++iResource) { // don't do water
    7885          572 :             Real64 ipElectricityAdjust = (iResource == 1) ? ipElectricityConversionFactor : 1.0;
    7886         8580 :             for (int jEndUse = 1; jEndUse <= static_cast<int>(Constant::EndUse::Num); ++jEndUse) {
    7887         8008 :                 collapsedEndUse(iResource, jEndUse) /= (largeConversionFactor / ipElectricityAdjust);
    7888        10361 :                 for (int kEndUseSub = 1; kEndUseSub <= op->EndUseCategory(jEndUse).NumSubcategories; ++kEndUseSub) {
    7889         2353 :                     collapsedEndUseSub(kEndUseSub, jEndUse, iResource) /= (largeConversionFactor / ipElectricityAdjust);
    7890              :                 }
    7891         8320 :                 for (int kEndUseSpType = 1; kEndUseSpType <= op->EndUseCategory(jEndUse).numSpaceTypes; ++kEndUseSpType) {
    7892          312 :                     collapsedEndUseSpType(kEndUseSpType, jEndUse, iResource) /= (largeConversionFactor / ipElectricityAdjust);
    7893              :                 }
    7894              :             }
    7895          572 :             collapsedTotal(iResource) /= (largeConversionFactor / ipElectricityAdjust);
    7896              :         }
    7897              :         // do water
    7898          660 :         for (int jEndUse = 1; jEndUse <= static_cast<int>(Constant::EndUse::Num); ++jEndUse) {
    7899          616 :             collapsedEndUse(14, jEndUse) /= waterConversionFactor;
    7900          797 :             for (int kEndUseSub = 1; kEndUseSub <= state.dataOutputProcessor->EndUseCategory(jEndUse).NumSubcategories; ++kEndUseSub) {
    7901          181 :                 collapsedEndUseSub(kEndUseSub, jEndUse, 14) /= waterConversionFactor;
    7902              :             }
    7903          640 :             for (int kEndUseSpType = 1; kEndUseSpType <= state.dataOutputProcessor->EndUseCategory(jEndUse).numSpaceTypes; ++kEndUseSpType) {
    7904           24 :                 collapsedEndUseSpType(kEndUseSpType, jEndUse, 14) /= waterConversionFactor;
    7905              :             }
    7906              :         }
    7907              : 
    7908           44 :         collapsedTotal(14) = WaterConversionFunct(collapsedTotal(14), waterConversionFactor);
    7909              : 
    7910           44 :         if (iUnitSystem == 0) {
    7911           42 :             gtPowerFuelFireGen = ort->gatherPowerFuelFireGen;
    7912           42 :             gtPowerPV = ort->gatherPowerPV;
    7913           42 :             gtPowerWind = ort->gatherPowerWind;
    7914           42 :             gtPowerHTGeothermal = ort->gatherPowerHTGeothermal;
    7915           42 :             gtPowerConversion = ort->gatherPowerConversion;
    7916           42 :             gtElecProduced = ort->gatherElecProduced;
    7917           42 :             gtElecPUrchased = ort->gatherElecPurchased;
    7918           42 :             gtElecSurplusSold = ort->gatherElecSurplusSold;
    7919              :         } else { // if(iUnitSystem == 1)
    7920            2 :             ort->gatherPowerFuelFireGen = gtPowerFuelFireGen;
    7921            2 :             ort->gatherPowerPV = gtPowerPV;
    7922            2 :             ort->gatherPowerWind = gtPowerWind;
    7923            2 :             ort->gatherPowerHTGeothermal = gtPowerHTGeothermal;
    7924            2 :             ort->gatherPowerConversion = gtPowerConversion;
    7925            2 :             ort->gatherElecProduced = gtElecProduced;
    7926            2 :             ort->gatherElecPurchased = gtElecPUrchased;
    7927            2 :             ort->gatherElecSurplusSold = gtElecSurplusSold;
    7928              :         }
    7929              :         // convert to GJ
    7930           44 :         Real64 convFactorMulti = ipElectricityConversionFactor / largeConversionFactor;
    7931           44 :         ort->gatherPowerFuelFireGen *= convFactorMulti;
    7932           44 :         ort->gatherPowerPV *= convFactorMulti;
    7933           44 :         ort->gatherPowerWind *= convFactorMulti;
    7934           44 :         ort->gatherPowerHTGeothermal *= convFactorMulti;
    7935           44 :         ort->gatherPowerConversion *= convFactorMulti;
    7936           44 :         ort->gatherElecProduced *= convFactorMulti;
    7937           44 :         ort->gatherElecPurchased *= convFactorMulti;
    7938           44 :         ort->gatherElecSurplusSold *= convFactorMulti;
    7939              : 
    7940              :         // get change in overall state of charge for electrical storage devices.
    7941           44 :         if (state.dataElectPwrSvcMgr->facilityElectricServiceObj->numElecStorageDevices > 0) {
    7942              :             // All flow in/out of storage is accounted for in gatherElecStorage, so separate calculation of change in state of charge is not
    7943              :             // necessary OverallNetEnergyFromStorage = ( sum( ElecStorage.StartingEnergyStored() ) - sum(
    7944              :             // ElecStorage.ThisTimeStepStateOfCharge() ) ) + gatherElecStorage;
    7945            0 :             ort->OverallNetEnergyFromStorage = ort->gatherElecStorage;
    7946            0 :             ort->OverallNetEnergyFromStorage *= convFactorMulti;
    7947              :         } else {
    7948           44 :             ort->OverallNetEnergyFromStorage = 0.0;
    7949              :         }
    7950              :         // determine which resource is the primary heating resource
    7951           44 :         int resourcePrimaryHeating = 0;
    7952           44 :         Real64 heatingMaximum = 0.0;
    7953          616 :         for (int iResource = 1; iResource <= 13; ++iResource) { // don't do water
    7954          572 :             if (collapsedEndUse(iResource, static_cast<int>(Constant::EndUse::Heating) + 1) > heatingMaximum) {
    7955           10 :                 heatingMaximum = collapsedEndUse(iResource, static_cast<int>(Constant::EndUse::Heating) + 1); // +1 because enum is 0-based
    7956           10 :                 resourcePrimaryHeating = iResource;
    7957              :             }
    7958              :         }
    7959              : 
    7960              :         //---- Source and Site Energy Sub-Table
    7961           44 :         rowHead.allocate(4);
    7962           44 :         columnHead.allocate(3);
    7963           44 :         columnWidth.allocate(3);
    7964           44 :         columnWidth = 14; // array assignment - same for all columns
    7965           44 :         tableBody.allocate(3, 4);
    7966              : 
    7967           44 :         switch (unitsStyle_cur) {
    7968            4 :         case UnitsStyle::JtoKWH: {
    7969            4 :             columnHead(1) = "Total Energy [kWh]";
    7970            4 :             columnHead(2) = "Energy Per Total Building Area [kWh/m2]";
    7971            4 :             columnHead(3) = "Energy Per Conditioned Building Area [kWh/m2]";
    7972            4 :         } break;
    7973            2 :         case UnitsStyle::InchPound: {
    7974            2 :             columnHead(1) = "Total Energy [kBtu]";
    7975            2 :             columnHead(2) = "Energy Per Total Building Area [kBtu/ft2]";
    7976            2 :             columnHead(3) = "Energy Per Conditioned Building Area [kBtu/ft2]";
    7977            2 :         } break;
    7978            1 :         case UnitsStyle::InchPoundExceptElectricity: {
    7979            1 :             columnHead(1) = "Total Energy [kBtu]";
    7980            1 :             columnHead(2) = "Energy Per Total Building Area [kBtu/ft2]";
    7981            1 :             columnHead(3) = "Energy Per Conditioned Building Area [kBtu/ft2]";
    7982            1 :         } break;
    7983           37 :         default: {
    7984           37 :             columnHead(1) = "Total Energy [GJ]";
    7985           37 :             columnHead(2) = "Energy Per Total Building Area [MJ/m2]";
    7986           37 :             columnHead(3) = "Energy Per Conditioned Building Area [MJ/m2]";
    7987           37 :         } break;
    7988              :         }
    7989              : 
    7990           44 :         rowHead(1) = "Total Site Energy";
    7991           44 :         rowHead(2) = "Net Site Energy";
    7992           44 :         rowHead(3) = "Total Source Energy";
    7993           44 :         rowHead(4) = "Net Source Energy";
    7994              : 
    7995           44 :         tableBody = "";
    7996              : 
    7997              :         // compute the net amount of electricity received from the utility which
    7998              :         // is the amount purchased less the amount sold to the utility. Note that
    7999              :         // previously these variables were converted into GJ so now we don't need
    8000              :         // to do any conversion
    8001              :         // water is not included   gatherTotalsBEPS(7)    !water
    8002              :         Real64 const totalSiteEnergyUse =
    8003           44 :             (ort->gatherTotalsBEPS(1) + ort->gatherTotalsBEPS(2) + ort->gatherTotalsBEPS(3) + ort->gatherTotalsBEPS(4) + ort->gatherTotalsBEPS(5) +
    8004           44 :              ort->gatherTotalsBEPS(6) + ort->gatherTotalsBEPS(8) + ort->gatherTotalsBEPS(9) + ort->gatherTotalsBEPS(10) + ort->gatherTotalsBEPS(11) +
    8005           44 :              ort->gatherTotalsBEPS(12) + ort->gatherTotalsBEPS(13) + ort->gatherTotalsBEPS(14)) /
    8006           44 :             largeConversionFactor; // electricity | natural gas | district cooling | district heating water | district heating steam | gasoline |
    8007              :                                    // diesel | coal | Fuel Oil No1 | Fuel Oil No2 | propane | otherfuel1 | otherfuel2
    8008              : 
    8009           44 :         Real64 const netElecPurchasedSold = ort->gatherElecPurchased - ort->gatherElecSurplusSold;
    8010              : 
    8011              :         // water is not included   gatherTotalsBEPS(7)    !water
    8012              :         Real64 const netSiteEnergyUse =
    8013           44 :             netElecPurchasedSold + (ort->gatherTotalsBEPS(2) + ort->gatherTotalsBEPS(3) + ort->gatherTotalsBEPS(4) + ort->gatherTotalsBEPS(5) +
    8014           44 :                                     ort->gatherTotalsBEPS(6) + ort->gatherTotalsBEPS(8) + ort->gatherTotalsBEPS(9) + ort->gatherTotalsBEPS(10) +
    8015           44 :                                     ort->gatherTotalsBEPS(11) + ort->gatherTotalsBEPS(12) + ort->gatherTotalsBEPS(13) + ort->gatherTotalsBEPS(14)) /
    8016           44 :                                        largeConversionFactor; // electricity (already in GJ) | natural gas | district cooling |
    8017              :                                                               // district heating water | district heating steam | gasoline | diesel | coal | Fuel Oil
    8018              :                                                               // No1 | Fuel Oil No2 | propane | otherfuel1 | otherfuel2
    8019              : 
    8020           44 :         if (ort->efficiencyDistrictCooling == 0) {
    8021            4 :             ort->efficiencyDistrictCooling = 1.0;
    8022              :         }
    8023           44 :         if (ort->efficiencyDistrictHeatingWater == 0) {
    8024            4 :             ort->efficiencyDistrictHeatingWater = 1.0;
    8025              :         }
    8026              : 
    8027              :         // source emissions already have the source factors included in the calcs.
    8028           44 :         Real64 totalSourceEnergyUse = 0.0;
    8029              :         //  electricity
    8030           44 :         if (ort->fuelfactorsused(1)) {
    8031            0 :             totalSourceEnergyUse += ort->gatherTotalsSource(1);
    8032              :         } else {
    8033           44 :             totalSourceEnergyUse += ort->gatherTotalsBEPS(1) * ort->sourceFactorElectric;
    8034              :         }
    8035              :         //  natural gas
    8036           44 :         if (ort->fuelfactorsused(2)) {
    8037            0 :             totalSourceEnergyUse += ort->gatherTotalsSource(2);
    8038              :         } else {
    8039           44 :             totalSourceEnergyUse += ort->gatherTotalsBEPS(2) * ort->sourceFactorNaturalGas;
    8040              :         }
    8041              :         // gasoline
    8042           44 :         if (ort->fuelfactorsused(3)) {
    8043            0 :             totalSourceEnergyUse += ort->gatherTotalsSource(3);
    8044              :         } else {
    8045           44 :             totalSourceEnergyUse += ort->gatherTotalsBEPS(6) * ort->sourceFactorGasoline;
    8046              :         }
    8047              :         // diesel
    8048           44 :         if (ort->fuelfactorsused(4)) {
    8049            0 :             totalSourceEnergyUse += ort->gatherTotalsSource(4);
    8050              :         } else {
    8051           44 :             totalSourceEnergyUse += ort->gatherTotalsBEPS(8) * ort->sourceFactorDiesel;
    8052              :         }
    8053              :         // coal
    8054           44 :         if (ort->fuelfactorsused(5)) {
    8055            0 :             totalSourceEnergyUse += ort->gatherTotalsSource(5);
    8056              :         } else {
    8057           44 :             totalSourceEnergyUse += ort->gatherTotalsBEPS(9) * ort->sourceFactorCoal;
    8058              :         }
    8059              :         // Fuel Oil No1
    8060           44 :         if (ort->fuelfactorsused(6)) {
    8061            0 :             totalSourceEnergyUse += ort->gatherTotalsSource(6);
    8062              :         } else {
    8063           44 :             totalSourceEnergyUse += ort->gatherTotalsBEPS(10) * ort->sourceFactorFuelOil1;
    8064              :         }
    8065              :         // Fuel Oil No2
    8066           44 :         if (ort->fuelfactorsused(7)) {
    8067            0 :             totalSourceEnergyUse += ort->gatherTotalsSource(7);
    8068              :         } else {
    8069           44 :             totalSourceEnergyUse += ort->gatherTotalsBEPS(11) * ort->sourceFactorFuelOil2;
    8070              :         }
    8071              :         // propane
    8072           44 :         if (ort->fuelfactorsused(8)) {
    8073            0 :             totalSourceEnergyUse += ort->gatherTotalsSource(8);
    8074              :         } else {
    8075           44 :             totalSourceEnergyUse += ort->gatherTotalsBEPS(12) * ort->sourceFactorPropane;
    8076              :         }
    8077              :         // otherfuel1
    8078           44 :         if (ort->fuelfactorsused(11)) {
    8079            0 :             totalSourceEnergyUse += ort->gatherTotalsSource(11);
    8080              :         } else {
    8081           44 :             totalSourceEnergyUse += ort->gatherTotalsBEPS(13) * ort->sourceFactorOtherFuel1;
    8082              :         }
    8083              :         // otherfuel2
    8084           44 :         if (ort->fuelfactorsused(12)) {
    8085            0 :             totalSourceEnergyUse += ort->gatherTotalsSource(12);
    8086              :         } else {
    8087           44 :             totalSourceEnergyUse += ort->gatherTotalsBEPS(14) * ort->sourceFactorOtherFuel2;
    8088              :         }
    8089              : 
    8090           44 :         totalSourceEnergyUse = (totalSourceEnergyUse + ort->gatherTotalsBEPS(3) * ort->sourceFactorElectric / ort->efficiencyDistrictCooling +
    8091           44 :                                 ort->gatherTotalsBEPS(4) * ort->sourceFactorNaturalGas / ort->efficiencyDistrictHeatingWater +
    8092           44 :                                 ort->gatherTotalsBEPS(5) * ort->sourceFactorDistrictHeatingSteam) /
    8093              :                                largeConversionFactor; // district cooling | district heating water | district heating steam
    8094              : 
    8095              :         // now determine "net" source from purchased and surplus sold (still in J)
    8096              : 
    8097              :         Real64 netSourceElecPurchasedSold;
    8098           44 :         if (ort->fuelfactorsused(1)) {
    8099            0 :             netSourceElecPurchasedSold = ort->gatherTotalsSource(9) - ort->gatherTotalsSource(10);
    8100              :         } else {
    8101           44 :             netSourceElecPurchasedSold = netElecPurchasedSold * ort->sourceFactorElectric * largeConversionFactor; // back to J
    8102              :         }
    8103              : 
    8104           44 :         Real64 netSourceEnergyUse = 0.0;
    8105              :         //  natural gas
    8106           44 :         if (ort->fuelfactorsused(2)) {
    8107            0 :             netSourceEnergyUse += ort->gatherTotalsSource(2);
    8108              :         } else {
    8109           44 :             netSourceEnergyUse += ort->gatherTotalsBEPS(2) * ort->sourceFactorNaturalGas;
    8110              :         }
    8111              :         // gasoline
    8112           44 :         if (ort->fuelfactorsused(3)) {
    8113            0 :             netSourceEnergyUse += ort->gatherTotalsSource(3);
    8114              :         } else {
    8115           44 :             netSourceEnergyUse += ort->gatherTotalsBEPS(6) * ort->sourceFactorGasoline;
    8116              :         }
    8117              :         // diesel
    8118           44 :         if (ort->fuelfactorsused(4)) {
    8119            0 :             netSourceEnergyUse += ort->gatherTotalsSource(4);
    8120              :         } else {
    8121           44 :             netSourceEnergyUse += ort->gatherTotalsBEPS(8) * ort->sourceFactorDiesel;
    8122              :         }
    8123              :         // coal
    8124           44 :         if (ort->fuelfactorsused(5)) {
    8125            0 :             netSourceEnergyUse += ort->gatherTotalsSource(5);
    8126              :         } else {
    8127           44 :             netSourceEnergyUse += ort->gatherTotalsBEPS(9) * ort->sourceFactorCoal;
    8128              :         }
    8129              :         // Fuel Oil No1
    8130           44 :         if (ort->fuelfactorsused(6)) {
    8131            0 :             netSourceEnergyUse += ort->gatherTotalsSource(6);
    8132              :         } else {
    8133           44 :             netSourceEnergyUse += ort->gatherTotalsBEPS(10) * ort->sourceFactorFuelOil1;
    8134              :         }
    8135              :         // Fuel Oil No2
    8136           44 :         if (ort->fuelfactorsused(7)) {
    8137            0 :             netSourceEnergyUse += ort->gatherTotalsSource(7);
    8138              :         } else {
    8139           44 :             netSourceEnergyUse += ort->gatherTotalsBEPS(11) * ort->sourceFactorFuelOil2;
    8140              :         }
    8141              :         // propane
    8142           44 :         if (ort->fuelfactorsused(8)) {
    8143            0 :             netSourceEnergyUse += ort->gatherTotalsSource(8);
    8144              :         } else {
    8145           44 :             netSourceEnergyUse += ort->gatherTotalsBEPS(12) * ort->sourceFactorPropane;
    8146              :         }
    8147              :         // otherfuel1
    8148           44 :         if (ort->fuelfactorsused(11)) {
    8149            0 :             netSourceEnergyUse += ort->gatherTotalsSource(11);
    8150              :         } else {
    8151           44 :             netSourceEnergyUse += ort->gatherTotalsBEPS(13) * ort->sourceFactorOtherFuel1;
    8152              :         }
    8153              :         // otherfuel2
    8154           44 :         if (ort->fuelfactorsused(12)) {
    8155            0 :             netSourceEnergyUse += ort->gatherTotalsSource(12);
    8156              :         } else {
    8157           44 :             netSourceEnergyUse += ort->gatherTotalsBEPS(14) * ort->sourceFactorOtherFuel2;
    8158              :         }
    8159              : 
    8160           44 :         netSourceEnergyUse =
    8161           44 :             (netSourceEnergyUse + netSourceElecPurchasedSold + ort->gatherTotalsBEPS(3) * ort->sourceFactorElectric / ort->efficiencyDistrictCooling +
    8162           44 :              ort->gatherTotalsBEPS(4) * ort->sourceFactorNaturalGas / ort->efficiencyDistrictHeatingWater +
    8163           44 :              ort->gatherTotalsBEPS(5) * ort->sourceFactorDistrictHeatingSteam) /
    8164              :             largeConversionFactor; // from other fuels | net source from electricity | district cooling | district heating water | district heating
    8165              :                                    // steam
    8166              : 
    8167              :         // show annual values
    8168           44 :         tableBody(1, 1) = RealToStr(totalSiteEnergyUse, 2);
    8169           44 :         tableBody(1, 2) = RealToStr(netSiteEnergyUse, 2);
    8170           44 :         tableBody(1, 3) = RealToStr(totalSourceEnergyUse, 2);
    8171           44 :         tableBody(1, 4) = RealToStr(netSourceEnergyUse, 2);
    8172              : 
    8173              :         // convert floor areas
    8174           44 :         Real64 const convBldgGrossFloorArea = ort->buildingGrossFloorArea / areaConversionFactor;
    8175           44 :         Real64 const convBldgCondFloorArea = ort->buildingConditionedFloorArea / areaConversionFactor;
    8176              : 
    8177              :         // show  per building area
    8178           44 :         if (convBldgGrossFloorArea > 0) {
    8179           38 :             tableBody(2, 1) = RealToStr(totalSiteEnergyUse * kConversionFactor / convBldgGrossFloorArea, 2);
    8180           38 :             tableBody(2, 2) = RealToStr(netSiteEnergyUse * kConversionFactor / convBldgGrossFloorArea, 2);
    8181           38 :             tableBody(2, 3) = RealToStr(totalSourceEnergyUse * kConversionFactor / convBldgGrossFloorArea, 2);
    8182           38 :             tableBody(2, 4) = RealToStr(netSourceEnergyUse * kConversionFactor / convBldgGrossFloorArea, 2);
    8183              :         }
    8184              :         // show  per conditioned building area
    8185           44 :         if (convBldgCondFloorArea > 0) {
    8186           14 :             tableBody(3, 1) = RealToStr(totalSiteEnergyUse * kConversionFactor / convBldgCondFloorArea, 2);
    8187           14 :             tableBody(3, 2) = RealToStr(netSiteEnergyUse * kConversionFactor / convBldgCondFloorArea, 2);
    8188           14 :             tableBody(3, 3) = RealToStr(totalSourceEnergyUse * kConversionFactor / convBldgCondFloorArea, 2);
    8189           14 :             tableBody(3, 4) = RealToStr(netSourceEnergyUse * kConversionFactor / convBldgCondFloorArea, 2);
    8190              :         }
    8191              : 
    8192              :         // heading for the entire sub-table
    8193           44 :         if (ort->displayTabularBEPS) {
    8194           44 :             if (produceTabular) {
    8195           42 :                 WriteSubtitle(state, "Site and Source Energy");
    8196           42 :                 WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
    8197              :             }
    8198           44 :             if (produceSQLite) {
    8199           42 :                 if (state.dataSQLiteProcedures->sqlite) {
    8200            7 :                     state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
    8201              :                         tableBody, rowHead, columnHead, "AnnualBuildingUtilityPerformanceSummary", "Entire Facility", "Site and Source Energy");
    8202              :                 }
    8203              :             }
    8204           44 :             if (produceTabular) {
    8205           42 :                 if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
    8206            0 :                     state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(
    8207              :                         tableBody, rowHead, columnHead, "AnnualBuildingUtilityPerformanceSummary", "Entire Facility", "Site and Source Energy");
    8208              :                 }
    8209              :             }
    8210              :         }
    8211              : 
    8212              :         //---- Source and Site Energy Sub-Table
    8213           44 :         rowHead.allocate(13);
    8214           44 :         columnHead.allocate(1);
    8215           44 :         columnWidth.allocate(1);
    8216           44 :         columnWidth = 50; // array assignment
    8217           44 :         tableBody.allocate(1, 13);
    8218              : 
    8219           44 :         columnHead(1) = "Site=>Source Conversion Factor";
    8220              : 
    8221           44 :         rowHead(1) = "Electricity";
    8222           44 :         rowHead(2) = "Natural Gas";
    8223           44 :         rowHead(3) = "District Cooling";
    8224           44 :         rowHead(4) = "District Heating Water";
    8225           44 :         rowHead(5) = "District Heating Steam";
    8226           44 :         rowHead(6) = "Gasoline";
    8227           44 :         rowHead(7) = "Diesel";
    8228           44 :         rowHead(8) = "Coal";
    8229           44 :         rowHead(9) = "Fuel Oil No 1";
    8230           44 :         rowHead(10) = "Fuel Oil No 2";
    8231           44 :         rowHead(11) = "Propane";
    8232           44 :         rowHead(12) = "Other Fuel 1";
    8233           44 :         rowHead(13) = "Other Fuel 2";
    8234              : 
    8235           44 :         tableBody = "";
    8236              : 
    8237              :         // set columns to conversion factors
    8238              :         // show values
    8239              :         //  tableBody(1,1)  = TRIM(RealToStr(sourceFactorElectric,3))
    8240              :         //  tableBody(2,1)  = TRIM(RealToStr(sourceFactorNaturalGas, 3))
    8241              :         //  tableBody(3,1)  = TRIM(RealToStr(sourceFactorElectric/ efficiencyDistrictCooling,3))
    8242              :         //  tableBody(4,1)  = TRIM(RealToStr(sourceFactorNaturalGas/ efficiencyDistrictHeating ,3))
    8243              :         //  tableBody(5,1)  = TRIM(RealToStr(sourceFactorSteam ,3))
    8244              :         //  tableBody(6,1)  = TRIM(RealToStr(sourceFactorGasoline ,3))
    8245              :         //  tableBody(7,1)  = TRIM(RealToStr(sourceFactorDiesel ,3))
    8246              :         //  tableBody(8,1)  = TRIM(RealToStr(sourceFactorCoal ,3))
    8247              :         //  tableBody(9,1)  = TRIM(RealToStr(sourceFactorFuelOil1 ,3))
    8248              :         //  tableBody(10,1) = TRIM(RealToStr(sourceFactorFuelOil2 ,3))
    8249              :         //  tableBody(11,1) = TRIM(RealToStr(sourceFactorPropane ,3))
    8250              : 
    8251           44 :         if (!ort->ffSchedUsed(1)) {
    8252           44 :             tableBody(1, 1) = RealToStr(ort->sourceFactorElectric, 3);
    8253            0 :         } else if (ort->gatherTotalsBEPS(1) > SmallValue) {
    8254            0 :             tableBody(1, 1) = "Effective Factor = " + RealToStr(ort->gatherTotalsBySourceBEPS(1) / ort->gatherTotalsBEPS(1), 3) +
    8255            0 :                               " (calculated using schedule \"" + ort->ffScheds(1)->Name + "\")";
    8256              :         } else {
    8257            0 :             tableBody(1, 1) = "N/A";
    8258              :         }
    8259              : 
    8260           44 :         if (!ort->ffSchedUsed(2)) {
    8261           44 :             tableBody(1, 2) = RealToStr(ort->sourceFactorNaturalGas, 3);
    8262            0 :         } else if (ort->gatherTotalsBEPS(2) > SmallValue) {
    8263            0 :             tableBody(1, 2) = "Effective Factor = " + RealToStr(ort->gatherTotalsBySourceBEPS(2) / ort->gatherTotalsBEPS(2), 3) +
    8264            0 :                               " (calculated using schedule \"" + ort->ffScheds(2)->Name + "\")";
    8265              :         } else {
    8266            0 :             tableBody(1, 2) = "N/A";
    8267              :         }
    8268              : 
    8269           44 :         tableBody(1, 3) = RealToStr(ort->sourceFactorElectric / ort->efficiencyDistrictCooling, 3); // District Cooling
    8270              : 
    8271           44 :         tableBody(1, 4) = RealToStr(ort->sourceFactorNaturalGas / ort->efficiencyDistrictHeatingWater, 3); // District Heating Water
    8272              : 
    8273           44 :         tableBody(1, 5) = RealToStr(ort->sourceFactorDistrictHeatingSteam, 3); // District Heating Steam
    8274              : 
    8275           44 :         if (!ort->ffSchedUsed(6)) {
    8276           44 :             tableBody(1, 6) = RealToStr(ort->sourceFactorGasoline, 3);
    8277            0 :         } else if (ort->gatherTotalsBEPS(6) > SmallValue) {
    8278            0 :             tableBody(1, 6) = "Effective Factor = " + RealToStr(ort->gatherTotalsBySourceBEPS(6) / ort->gatherTotalsBEPS(6), 3) +
    8279            0 :                               " (calculated using schedule \"" + ort->ffScheds(6)->Name + "\")";
    8280              :         } else {
    8281            0 :             tableBody(1, 6) = "N/A";
    8282              :         }
    8283              : 
    8284           44 :         if (!ort->ffSchedUsed(8)) {
    8285           44 :             tableBody(1, 7) = RealToStr(ort->sourceFactorDiesel, 3);
    8286            0 :         } else if (ort->gatherTotalsBEPS(8) > SmallValue) {
    8287            0 :             tableBody(1, 7) = "Effective Factor = " + RealToStr(ort->gatherTotalsBySourceBEPS(8) / ort->gatherTotalsBEPS(8), 3) +
    8288            0 :                               " (calculated using schedule \"" + ort->ffScheds(8)->Name + "\")";
    8289              :         } else {
    8290            0 :             tableBody(1, 7) = "N/A";
    8291              :         }
    8292              : 
    8293           44 :         if (!ort->ffSchedUsed(9)) {
    8294           44 :             tableBody(1, 8) = RealToStr(ort->sourceFactorCoal, 3);
    8295            0 :         } else if (ort->gatherTotalsBEPS(9) > SmallValue) {
    8296            0 :             tableBody(1, 8) = "Effective Factor = " + RealToStr(ort->gatherTotalsBySourceBEPS(9) / ort->gatherTotalsBEPS(9), 3) +
    8297            0 :                               " (calculated using schedule \"" + ort->ffScheds(9)->Name + "\")";
    8298              :         } else {
    8299            0 :             tableBody(1, 8) = "N/A";
    8300              :         }
    8301              : 
    8302           44 :         if (!ort->ffSchedUsed(10)) {
    8303           44 :             tableBody(1, 9) = RealToStr(ort->sourceFactorFuelOil1, 3);
    8304            0 :         } else if (ort->gatherTotalsBEPS(10) > SmallValue) {
    8305            0 :             tableBody(1, 9) = "Effective Factor = " + RealToStr(ort->gatherTotalsBySourceBEPS(10) / ort->gatherTotalsBEPS(10), 3) +
    8306            0 :                               " (calculated using schedule \"" + ort->ffScheds(10)->Name + "\")";
    8307              :         } else {
    8308            0 :             tableBody(1, 9) = "N/A";
    8309              :         }
    8310              : 
    8311           44 :         if (!ort->ffSchedUsed(11)) {
    8312           44 :             tableBody(1, 10) = RealToStr(ort->sourceFactorFuelOil2, 3);
    8313            0 :         } else if (ort->gatherTotalsBEPS(11) > SmallValue) {
    8314            0 :             tableBody(1, 10) = "Effective Factor = " + RealToStr(ort->gatherTotalsBySourceBEPS(11) / ort->gatherTotalsBEPS(11), 3) +
    8315            0 :                                " (calculated using schedule \"" + ort->ffScheds(11)->Name + "\")";
    8316              :         } else {
    8317            0 :             tableBody(1, 10) = "N/A";
    8318              :         }
    8319              : 
    8320           44 :         if (!ort->ffSchedUsed(12)) {
    8321           44 :             tableBody(1, 11) = RealToStr(ort->sourceFactorPropane, 3);
    8322            0 :         } else if (ort->gatherTotalsBEPS(12) > SmallValue) {
    8323            0 :             tableBody(1, 11) = "Effective Factor = " + RealToStr(ort->gatherTotalsBySourceBEPS(12) / ort->gatherTotalsBEPS(12), 3) +
    8324            0 :                                " (calculated using schedule \"" + ort->ffScheds(12)->Name + "\")";
    8325              :         } else {
    8326            0 :             tableBody(1, 11) = "N/A";
    8327              :         }
    8328              : 
    8329           44 :         if (!ort->ffSchedUsed(13)) {
    8330           44 :             tableBody(1, 12) = RealToStr(ort->sourceFactorOtherFuel1, 3);
    8331            0 :         } else if (ort->gatherTotalsBEPS(13) > SmallValue) {
    8332            0 :             tableBody(1, 12) = "Effective Factor = " + RealToStr(ort->gatherTotalsBySourceBEPS(13) / ort->gatherTotalsBEPS(13), 3) +
    8333            0 :                                " (calculated using schedule \"" + ort->ffScheds(13)->Name + "\")";
    8334              :         } else {
    8335            0 :             tableBody(1, 12) = "N/A";
    8336              :         }
    8337              : 
    8338           44 :         if (!ort->ffSchedUsed(14)) {
    8339           44 :             tableBody(1, 13) = RealToStr(ort->sourceFactorOtherFuel2, 3);
    8340            0 :         } else if (ort->gatherTotalsBEPS(14) > SmallValue) {
    8341            0 :             tableBody(1, 13) = "Effective Factor = " + RealToStr(ort->gatherTotalsBySourceBEPS(14) / ort->gatherTotalsBEPS(14), 3) +
    8342            0 :                                " (calculated using schedule \"" + ort->ffScheds(14)->Name + "\")";
    8343              :         } else {
    8344            0 :             tableBody(1, 13) = "N/A";
    8345              :         }
    8346              : 
    8347              :         // heading for the entire sub-table
    8348           44 :         if (ort->displayTabularBEPS) {
    8349           44 :             if (produceTabular) {
    8350           42 :                 WriteSubtitle(state, "Site to Source Energy Conversion Factors");
    8351           42 :                 WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
    8352              :             }
    8353           44 :             if (produceSQLite) {
    8354           42 :                 if (state.dataSQLiteProcedures->sqlite) {
    8355            7 :                     state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(tableBody,
    8356              :                                                                                        rowHead,
    8357              :                                                                                        columnHead,
    8358              :                                                                                        "AnnualBuildingUtilityPerformanceSummary",
    8359              :                                                                                        "Entire Facility",
    8360              :                                                                                        "Site to Source Energy Conversion Factors");
    8361              :                 }
    8362              :             }
    8363           44 :             if (produceTabular) {
    8364           42 :                 if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
    8365            0 :                     state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(tableBody,
    8366              :                                                                                                           rowHead,
    8367              :                                                                                                           columnHead,
    8368              :                                                                                                           "AnnualBuildingUtilityPerformanceSummary",
    8369              :                                                                                                           "Entire Facility",
    8370              :                                                                                                           "Site to Source Energy Conversion Factors");
    8371              :                 }
    8372              :             }
    8373              :         }
    8374              : 
    8375              :         //---- Building Area Sub-Table
    8376           44 :         rowHead.allocate(3);
    8377           44 :         columnHead.allocate(1);
    8378           44 :         columnWidth.allocate(1);
    8379           44 :         columnWidth = 14; // array assignment - same for all columns
    8380           44 :         tableBody.allocate(1, 3);
    8381              : 
    8382           44 :         switch (unitsStyle_cur) {
    8383            4 :         case UnitsStyle::JtoKWH: {
    8384            4 :             columnHead(1) = "Area [m2]";
    8385            4 :         } break;
    8386            2 :         case UnitsStyle::InchPound: {
    8387            2 :             columnHead(1) = "Area [ft2]";
    8388            2 :         } break;
    8389            1 :         case UnitsStyle::InchPoundExceptElectricity: {
    8390            1 :             columnHead(1) = "Area [ft2]";
    8391            1 :         } break;
    8392           37 :         default: {
    8393           37 :             columnHead(1) = "Area [m2]";
    8394           37 :         } break;
    8395              :         }
    8396              : 
    8397           44 :         rowHead(1) = "Total Building Area";
    8398           44 :         rowHead(2) = "Net Conditioned Building Area";
    8399           44 :         rowHead(3) = "Unconditioned Building Area";
    8400              : 
    8401           44 :         tableBody = "";
    8402           44 :         tableBody(1, 1) = RealToStr(convBldgGrossFloorArea, 2);
    8403              : 
    8404           44 :         if (unitsStyle_cur == OutputReportTabular::UnitsStyle::InchPound ||
    8405           42 :             unitsStyle_cur == OutputReportTabular::UnitsStyle::InchPoundExceptElectricity) {
    8406            3 :             if (produceTabular) {
    8407            2 :                 PreDefTableEntry(
    8408            3 :                     state, state.dataOutRptPredefined->pdchLeedGenData, "Total gross floor area [ft2]", RealToStr(convBldgGrossFloorArea, 2));
    8409              :             }
    8410              :         } else {
    8411           41 :             if (produceTabular) {
    8412           82 :                 PreDefTableEntry(
    8413          123 :                     state, state.dataOutRptPredefined->pdchLeedGenData, "Total gross floor area [m2]", RealToStr(convBldgGrossFloorArea, 2));
    8414              :             }
    8415              :         }
    8416              : 
    8417           44 :         tableBody(1, 2) = RealToStr(convBldgCondFloorArea, 2);
    8418           44 :         tableBody(1, 3) = RealToStr(convBldgGrossFloorArea - convBldgCondFloorArea, 2);
    8419              : 
    8420              :         // heading for the entire sub-table
    8421           44 :         if (ort->displayTabularBEPS) {
    8422           44 :             if (produceTabular) {
    8423           42 :                 WriteSubtitle(state, "Building Area");
    8424           42 :                 WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
    8425              :             }
    8426           44 :             if (produceSQLite) {
    8427           42 :                 if (state.dataSQLiteProcedures->sqlite) {
    8428            7 :                     state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
    8429              :                         tableBody, rowHead, columnHead, "AnnualBuildingUtilityPerformanceSummary", "Entire Facility", "Building Area");
    8430              :                 }
    8431              :             }
    8432           44 :             if (produceTabular) {
    8433           42 :                 if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
    8434            0 :                     state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(
    8435              :                         tableBody, rowHead, columnHead, "AnnualBuildingUtilityPerformanceSummary", "Entire Facility", "Building Area");
    8436              :                 }
    8437              :             }
    8438              :         }
    8439              : 
    8440              :         //---- End Use Sub-Table
    8441           44 :         rowHead.allocate(16);
    8442           44 :         columnHead.allocate(14);
    8443           44 :         columnWidth.allocate(14);
    8444           44 :         columnWidth = 10; // array assignment - same for all columns
    8445           44 :         tableBody.allocate(14, 16);
    8446          660 :         for (int iResource = 1; iResource <= 14; ++iResource) {
    8447         9240 :             for (int iEndUse = 0; iEndUse < static_cast<int>(Constant::EndUse::Num); ++iEndUse) {
    8448         8624 :                 useVal(iResource, iEndUse + 1) = collapsedEndUse(iResource, iEndUse + 1);
    8449              :             }
    8450          616 :             useVal(iResource, 15) = collapsedTotal(iResource); // totals
    8451              :         }
    8452              : 
    8453           44 :         rowHead(static_cast<int>(Constant::EndUse::Heating) + 1) = "Heating";
    8454           44 :         rowHead(static_cast<int>(Constant::EndUse::Cooling) + 1) = "Cooling";
    8455           44 :         rowHead(static_cast<int>(Constant::EndUse::InteriorLights) + 1) = "Interior Lighting";
    8456           44 :         rowHead(static_cast<int>(Constant::EndUse::ExteriorLights) + 1) = "Exterior Lighting";
    8457           44 :         rowHead(static_cast<int>(Constant::EndUse::InteriorEquipment) + 1) = "Interior Equipment";
    8458           44 :         rowHead(static_cast<int>(Constant::EndUse::ExteriorEquipment) + 1) = "Exterior Equipment";
    8459           44 :         rowHead(static_cast<int>(Constant::EndUse::Fans) + 1) = "Fans";
    8460           44 :         rowHead(static_cast<int>(Constant::EndUse::Pumps) + 1) = "Pumps";
    8461           44 :         rowHead(static_cast<int>(Constant::EndUse::HeatRejection) + 1) = "Heat Rejection";
    8462           44 :         rowHead(static_cast<int>(Constant::EndUse::Humidification) + 1) = "Humidification";
    8463           44 :         rowHead(static_cast<int>(Constant::EndUse::HeatRecovery) + 1) = "Heat Recovery";
    8464           44 :         rowHead(static_cast<int>(Constant::EndUse::WaterSystem) + 1) = "Water Systems";
    8465           44 :         rowHead(static_cast<int>(Constant::EndUse::Refrigeration) + 1) = "Refrigeration";
    8466           44 :         rowHead(static_cast<int>(Constant::EndUse::Cogeneration) + 1) = "Generators";
    8467           44 :         rowHead(15) = "";
    8468           44 :         rowHead(16) = "Total End Uses";
    8469              : 
    8470           44 :         switch (unitsStyle_cur) {
    8471            4 :         case UnitsStyle::JtoKWH: {
    8472            4 :             columnHead(1) = "Electricity [kWh]";
    8473            4 :             columnHead(2) = "Natural Gas [kWh]";
    8474            4 :             columnHead(3) = "Gasoline [kWh]";
    8475            4 :             columnHead(4) = "Diesel [kWh]";
    8476            4 :             columnHead(5) = "Coal [kWh]";
    8477            4 :             columnHead(6) = "Fuel Oil No 1 [kWh]";
    8478            4 :             columnHead(7) = "Fuel Oil No 2 [kWh]";
    8479            4 :             columnHead(8) = "Propane [kWh]";
    8480            4 :             columnHead(9) = "Other Fuel 1 [kWh]";
    8481            4 :             columnHead(10) = "Other Fuel 2 [kWh]";
    8482            4 :             columnHead(11) = "District Cooling [kWh]";
    8483            4 :             columnHead(12) = "District Heating Water [kWh]";
    8484            4 :             columnHead(13) = "District Heating Steam [kWh]";
    8485            4 :             columnHead(14) = "Water [m3]";
    8486            4 :         } break;
    8487            2 :         case UnitsStyle::InchPound: {
    8488            2 :             columnHead(1) = "Electricity [kBtu]";
    8489            2 :             columnHead(2) = "Natural Gas [kBtu]";
    8490            2 :             columnHead(3) = "Gasoline [kBtu]";
    8491            2 :             columnHead(4) = "Diesel [kBtu]";
    8492            2 :             columnHead(5) = "Coal [kBtu]";
    8493            2 :             columnHead(6) = "Fuel Oil No 1 [kBtu]";
    8494            2 :             columnHead(7) = "Fuel Oil No 2 [kBtu]";
    8495            2 :             columnHead(8) = "Propane [kBtu]";
    8496            2 :             columnHead(9) = "Other Fuel 1 [kBtu]";
    8497            2 :             columnHead(10) = "Other Fuel 2 [kBtu]";
    8498            2 :             columnHead(11) = "District Cooling [kBtu]";
    8499            2 :             columnHead(12) = "District Heating Water [kBtu]";
    8500            2 :             columnHead(13) = "District Heating Steam [kBtu]";
    8501            2 :             columnHead(14) = "Water [gal]";
    8502            2 :         } break;
    8503            1 :         case UnitsStyle::InchPoundExceptElectricity: {
    8504            1 :             columnHead(1) = "Electricity [kWh]";
    8505            1 :             columnHead(2) = "Natural Gas [kBtu]";
    8506            1 :             columnHead(3) = "Gasoline [kBtu]";
    8507            1 :             columnHead(4) = "Diesel [kBtu]";
    8508            1 :             columnHead(5) = "Coal [kBtu]";
    8509            1 :             columnHead(6) = "Fuel Oil No 1 [kBtu]";
    8510            1 :             columnHead(7) = "Fuel Oil No 2 [kBtu]";
    8511            1 :             columnHead(8) = "Propane [kBtu]";
    8512            1 :             columnHead(9) = "Other Fuel 1 [kBtu]";
    8513            1 :             columnHead(10) = "Other Fuel 2 [kBtu]";
    8514            1 :             columnHead(11) = "District Cooling [kBtu]";
    8515            1 :             columnHead(12) = "District Heating Water [kBtu]";
    8516            1 :             columnHead(13) = "District Heating Steam [kBtu]";
    8517            1 :             columnHead(14) = "Water [gal]";
    8518            1 :         } break;
    8519           37 :         default: {
    8520           37 :             columnHead(1) = "Electricity [GJ]";
    8521           37 :             columnHead(2) = "Natural Gas [GJ]";
    8522           37 :             columnHead(3) = "Gasoline [GJ]";
    8523           37 :             columnHead(4) = "Diesel [GJ]";
    8524           37 :             columnHead(5) = "Coal [GJ]";
    8525           37 :             columnHead(6) = "Fuel Oil No 1 [GJ]";
    8526           37 :             columnHead(7) = "Fuel Oil No 2 [GJ]";
    8527           37 :             columnHead(8) = "Propane [GJ]";
    8528           37 :             columnHead(9) = "Other Fuel 1 [GJ]";
    8529           37 :             columnHead(10) = "Other Fuel 2 [GJ]";
    8530           37 :             columnHead(11) = "District Cooling [GJ]";
    8531           37 :             columnHead(12) = "District Heating Water [GJ]";
    8532           37 :             columnHead(13) = "District Heating Steam [GJ]";
    8533           37 :             columnHead(14) = "Water [m3]";
    8534           37 :         } break;
    8535              :         }
    8536              : 
    8537           44 :         tableBody = "";
    8538          660 :         for (int iResource = 1; iResource <= 14; ++iResource) {
    8539         9240 :             for (int jEndUse = 1; jEndUse <= 14; ++jEndUse) {
    8540         8624 :                 tableBody(iResource, jEndUse) = RealToStr(useVal(iResource, jEndUse), 2);
    8541              :             }
    8542          616 :             tableBody(iResource, 16) = RealToStr(useVal(iResource, 15), 2);
    8543              :         }
    8544              :         // add warning message if end use values do not add up to total
    8545          660 :         for (int iResource = 1; iResource <= 14; ++iResource) {
    8546          616 :             Real64 curTotal = 0.0;
    8547         9240 :             for (int jUse = 1; jUse <= 14; ++jUse) {
    8548         8624 :                 curTotal += useVal(iResource, jUse);
    8549              :             }
    8550          616 :             if (std::abs(curTotal - collapsedTotal(iResource)) > (collapsedTotal(iResource) * 0.001)) {
    8551            0 :                 ShowWarningError(state, ResourceWarningMessage(columnHead(iResource)));
    8552              :             }
    8553              :         }
    8554              : 
    8555           44 :         Real64 const unconvert = largeConversionFactor / 1000000000.0; // to avoid double converting, the values for the LEED report should be in GJ
    8556           44 :         Real64 const unconvert_ipExceptElec = (largeConversionFactor / ipElectricityConversionFactor) /
    8557              :                                               1000000000.0; // to avoid double converting, the values for the LEED report should be in GJ
    8558              : 
    8559              :         //  Energy Use Intensities - Electricity
    8560           44 :         if (ort->buildingGrossFloorArea > 0) {
    8561           38 :             if (produceTabular) {
    8562           38 :                 PreDefTableEntry(state,
    8563           38 :                                  state.dataOutRptPredefined->pdchLeedEuiElec,
    8564              :                                  "Interior Lighting (All)",
    8565           38 :                                  unconvert_ipExceptElec * 1000 * useVal(colElectricity, 3) / ort->buildingGrossFloorArea,
    8566           38 :                                  2);
    8567           38 :                 PreDefTableEntry(state,
    8568           38 :                                  state.dataOutRptPredefined->pdchLeedEuiElec,
    8569              :                                  "Space Heating",
    8570           38 :                                  unconvert_ipExceptElec * 1000 * useVal(colElectricity, 1) / ort->buildingGrossFloorArea,
    8571           38 :                                  2);
    8572           38 :                 PreDefTableEntry(state,
    8573           38 :                                  state.dataOutRptPredefined->pdchLeedEuiElec,
    8574              :                                  "Space Cooling",
    8575           38 :                                  unconvert_ipExceptElec * 1000 * useVal(colElectricity, 2) / ort->buildingGrossFloorArea,
    8576           38 :                                  2);
    8577           38 :                 PreDefTableEntry(state,
    8578           38 :                                  state.dataOutRptPredefined->pdchLeedEuiElec,
    8579              :                                  "Fans (All)",
    8580           38 :                                  unconvert_ipExceptElec * 1000 * useVal(colElectricity, 7) / ort->buildingGrossFloorArea,
    8581           38 :                                  2);
    8582           38 :                 PreDefTableEntry(state,
    8583           38 :                                  state.dataOutRptPredefined->pdchLeedEuiElec,
    8584              :                                  "Service Water Heating",
    8585           38 :                                  unconvert_ipExceptElec * 1000 * useVal(colElectricity, 12) / ort->buildingGrossFloorArea,
    8586           38 :                                  2);
    8587           38 :                 PreDefTableEntry(state,
    8588           38 :                                  state.dataOutRptPredefined->pdchLeedEuiElec,
    8589              :                                  "Receptacle Equipment",
    8590           38 :                                  unconvert_ipExceptElec * 1000 * useVal(colElectricity, 5) / ort->buildingGrossFloorArea,
    8591           38 :                                  2);
    8592           38 :                 PreDefTableEntry(state,
    8593           38 :                                  state.dataOutRptPredefined->pdchLeedEuiElec,
    8594              :                                  "Miscellaneous (All)",
    8595           38 :                                  unconvert_ipExceptElec * 1000 * (useVal(colElectricity, 15)) / ort->buildingGrossFloorArea,
    8596           38 :                                  2);
    8597           38 :                 PreDefTableEntry(state,
    8598           38 :                                  state.dataOutRptPredefined->pdchLeedEuiElec,
    8599              :                                  "Subtotal",
    8600           38 :                                  unconvert_ipExceptElec * 1000 * useVal(colElectricity, 15) / ort->buildingGrossFloorArea,
    8601           76 :                                  2);
    8602              :             }
    8603              :         }
    8604              : 
    8605           44 :         if (produceTabular) {
    8606           42 :             PreDefTableEntry(
    8607           42 :                 state, state.dataOutRptPredefined->pdchLeedEusTotal, "Electricity", unconvert_ipExceptElec * useVal(colElectricity, 15), 2);
    8608           42 :             PreDefTableEntry(state,
    8609           42 :                              state.dataOutRptPredefined->pdchLeedEusProc,
    8610              :                              "Electricity",
    8611           42 :                              unconvert_ipExceptElec * (useVal(colElectricity, 5) + useVal(colElectricity, 13)),
    8612           84 :                              2);
    8613              :         }
    8614              : 
    8615           44 :         Real64 processElecCost = 0.0;
    8616           44 :         if (useVal(colElectricity, 15) != 0) {
    8617            5 :             Real64 const processFraction = (useVal(colElectricity, 5) + useVal(colElectricity, 13)) / useVal(colElectricity, 15);
    8618            5 :             processElecCost = state.dataOutRptPredefined->LEEDelecCostTotal * processFraction;
    8619              :         }
    8620           44 :         if (produceTabular) {
    8621           42 :             PreDefTableEntry(state, state.dataOutRptPredefined->pdchLeedEcsProc, "Electricity", processElecCost, 2);
    8622           84 :             addFootNoteSubTable(
    8623           42 :                 state, state.dataOutRptPredefined->pdstLeedEneCostSum, "Process energy cost based on ratio of process to total energy.");
    8624              :         }
    8625              : 
    8626              :         //  Energy Use Intensities- Natural Gas
    8627           44 :         if (ort->buildingGrossFloorArea > 0) {
    8628           38 :             if (produceTabular) {
    8629           38 :                 PreDefTableEntry(state,
    8630           38 :                                  state.dataOutRptPredefined->pdchLeedEuiNatG,
    8631              :                                  "Space Heating",
    8632           38 :                                  unconvert * 1000 * useVal(colGas, 1) / ort->buildingGrossFloorArea,
    8633           38 :                                  2);
    8634           38 :                 PreDefTableEntry(state,
    8635           38 :                                  state.dataOutRptPredefined->pdchLeedEuiNatG,
    8636              :                                  "Service Water Heating",
    8637           38 :                                  unconvert * 1000 * useVal(colGas, 12) / ort->buildingGrossFloorArea,
    8638           38 :                                  2);
    8639           38 :                 PreDefTableEntry(state,
    8640           38 :                                  state.dataOutRptPredefined->pdchLeedEuiNatG,
    8641              :                                  "Miscellaneous (All)",
    8642           38 :                                  unconvert * 1000 * useVal(colGas, 15) / ort->buildingGrossFloorArea,
    8643           38 :                                  2);
    8644           38 :                 PreDefTableEntry(state,
    8645           38 :                                  state.dataOutRptPredefined->pdchLeedEuiNatG,
    8646              :                                  "Subtotal",
    8647           38 :                                  unconvert * 1000 * useVal(colGas, 15) / ort->buildingGrossFloorArea,
    8648           76 :                                  2);
    8649              :             }
    8650              :         }
    8651           44 :         if (produceTabular) {
    8652           42 :             PreDefTableEntry(state, state.dataOutRptPredefined->pdchLeedEusTotal, "Natural Gas", unconvert * useVal(colGas, 15), 2);
    8653           42 :             PreDefTableEntry(
    8654           84 :                 state, state.dataOutRptPredefined->pdchLeedEusProc, "Natural Gas", unconvert * (useVal(colGas, 5) + useVal(colGas, 13)), 2);
    8655              :         }
    8656              : 
    8657           44 :         Real64 processGasCost = 0.0;
    8658           44 :         if (useVal(colGas, 15) != 0) {
    8659            0 :             Real64 const processFraction = (useVal(colGas, 5) + useVal(colGas, 13)) / useVal(colGas, 15);
    8660            0 :             processGasCost = state.dataOutRptPredefined->LEEDgasCostTotal * processFraction;
    8661              :         }
    8662           44 :         if (produceTabular) {
    8663           42 :             PreDefTableEntry(state, state.dataOutRptPredefined->pdchLeedEcsProc, "Natural Gas", processGasCost, 2);
    8664              :         }
    8665              :         //  Energy Use Intensities  - Additional Fuel
    8666              :         Real64 const useValColAddFuel15 =
    8667           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);
    8668              :         Real64 const useValColAddFuel5 =
    8669           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);
    8670              :         Real64 const useValColAddFuel13 =
    8671           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);
    8672           44 :         if (ort->buildingGrossFloorArea > 0) {
    8673           38 :             if (produceTabular) {
    8674           38 :                 PreDefTableEntry(state,
    8675           38 :                                  state.dataOutRptPredefined->pdchLeedEuiOthr,
    8676              :                                  "Miscellaneous",
    8677           38 :                                  unconvert * 1000 * useValColAddFuel15 / ort->buildingGrossFloorArea,
    8678           38 :                                  2);
    8679           38 :                 PreDefTableEntry(state,
    8680           38 :                                  state.dataOutRptPredefined->pdchLeedEuiOthr,
    8681              :                                  "Subtotal",
    8682           38 :                                  unconvert * 1000 * useValColAddFuel15 / ort->buildingGrossFloorArea,
    8683           76 :                                  2);
    8684              :             }
    8685              :         }
    8686           44 :         if (produceTabular) {
    8687           42 :             PreDefTableEntry(state,
    8688           42 :                              state.dataOutRptPredefined->pdchLeedEusTotal,
    8689              :                              "Additional",
    8690           42 :                              (useValColAddFuel15 + useVal(colPurchCool, 15) + useVal(colPurchHeatWtr, 15) + useVal(colPurchHeatSt, 15)),
    8691           42 :                              2);
    8692           42 :             PreDefTableEntry(state,
    8693           42 :                              state.dataOutRptPredefined->pdchLeedEusProc,
    8694              :                              "Additional",
    8695              :                              unconvert *
    8696           42 :                                  (useValColAddFuel5 + useValColAddFuel13 + useVal(colPurchCool, 5) + useVal(colPurchCool, 13) +
    8697           42 :                                   useVal(colPurchHeatWtr, 5) + useVal(colPurchHeatWtr, 13) + useVal(colPurchHeatSt, 5) + useVal(colPurchHeatSt, 13)),
    8698           84 :                              2);
    8699              :         }
    8700              : 
    8701           44 :         Real64 processOthrCost = 0.0;
    8702           44 :         if ((useValColAddFuel15 + useVal(colPurchCool, 15) + useVal(colPurchHeatWtr, 15) + useVal(colPurchHeatSt, 15)) > 0.001) {
    8703              :             Real64 const processFraction =
    8704            6 :                 (useValColAddFuel5 + useValColAddFuel13 + useVal(colPurchCool, 5) + useVal(colPurchCool, 13) + useVal(colPurchHeatWtr, 5) +
    8705            6 :                  useVal(colPurchHeatWtr, 13) + useVal(colPurchHeatSt, 5) + useVal(colPurchHeatSt, 13)) /
    8706            6 :                 (useValColAddFuel15 + useVal(colPurchCool, 15) + useVal(colPurchHeatWtr, 15) + useVal(colPurchHeatSt, 15));
    8707            6 :             processOthrCost = state.dataOutRptPredefined->LEEDothrCostTotal * processFraction;
    8708              :         }
    8709           44 :         if (produceTabular) {
    8710           42 :             PreDefTableEntry(state, state.dataOutRptPredefined->pdchLeedEcsProc, "Additional", processOthrCost, 2);
    8711           42 :             PreDefTableEntry(state, state.dataOutRptPredefined->pdchLeedEcsProc, "Total", processElecCost + processGasCost + processOthrCost, 2);
    8712              :         }
    8713              :         // accumulate for percentage table
    8714           44 :         state.dataOutRptTab->leedSiteIntLite = 0.0;
    8715           44 :         state.dataOutRptTab->leedSiteSpHeat = 0.0;
    8716           44 :         state.dataOutRptTab->leedSiteSpCool = 0.0;
    8717           44 :         state.dataOutRptTab->leedSiteFanInt = 0.0;
    8718           44 :         state.dataOutRptTab->leedSiteSrvWatr = 0.0;
    8719           44 :         state.dataOutRptTab->leedSiteRecept = 0.0;
    8720           44 :         state.dataOutRptTab->leedSiteTotal = 0.0;
    8721          616 :         for (int iResource = 1; iResource <= 13; ++iResource) { // don't bother with water
    8722          572 :             state.dataOutRptTab->leedSiteIntLite += useVal(iResource, 3);
    8723          572 :             state.dataOutRptTab->leedSiteSpHeat += useVal(iResource, 1);
    8724          572 :             state.dataOutRptTab->leedSiteSpCool += useVal(iResource, 2);
    8725          572 :             state.dataOutRptTab->leedSiteFanInt += useVal(iResource, 7);
    8726          572 :             state.dataOutRptTab->leedSiteSrvWatr += useVal(iResource, 12);
    8727          572 :             state.dataOutRptTab->leedSiteRecept += useVal(iResource, 5);
    8728          572 :             state.dataOutRptTab->leedSiteTotal += useVal(iResource, 15);
    8729              :         }
    8730           44 :         if (state.dataOutRptTab->leedSiteTotal != 0) {
    8731            6 :             if (produceTabular) {
    8732            4 :                 PreDefTableEntry(state,
    8733            4 :                                  state.dataOutRptPredefined->pdchLeedEupPerc,
    8734              :                                  "Interior Lighting (All)",
    8735            4 :                                  100 * state.dataOutRptTab->leedSiteIntLite / state.dataOutRptTab->leedSiteTotal,
    8736            4 :                                  2);
    8737            4 :                 PreDefTableEntry(state,
    8738            4 :                                  state.dataOutRptPredefined->pdchLeedEupPerc,
    8739              :                                  "Space Heating",
    8740            4 :                                  100 * state.dataOutRptTab->leedSiteSpHeat / state.dataOutRptTab->leedSiteTotal,
    8741            4 :                                  2);
    8742            4 :                 PreDefTableEntry(state,
    8743            4 :                                  state.dataOutRptPredefined->pdchLeedEupPerc,
    8744              :                                  "Space Cooling",
    8745            4 :                                  100 * state.dataOutRptTab->leedSiteSpCool / state.dataOutRptTab->leedSiteTotal,
    8746            4 :                                  2);
    8747            4 :                 PreDefTableEntry(state,
    8748            4 :                                  state.dataOutRptPredefined->pdchLeedEupPerc,
    8749              :                                  "Fans (All)",
    8750            4 :                                  100 * state.dataOutRptTab->leedSiteFanInt / state.dataOutRptTab->leedSiteTotal,
    8751            4 :                                  2);
    8752            4 :                 PreDefTableEntry(state,
    8753            4 :                                  state.dataOutRptPredefined->pdchLeedEupPerc,
    8754              :                                  "Service Water Heating",
    8755            4 :                                  100 * state.dataOutRptTab->leedSiteSrvWatr / state.dataOutRptTab->leedSiteTotal,
    8756            4 :                                  2);
    8757            4 :                 PreDefTableEntry(state,
    8758            4 :                                  state.dataOutRptPredefined->pdchLeedEupPerc,
    8759              :                                  "Receptacle Equipment",
    8760            4 :                                  100 * state.dataOutRptTab->leedSiteRecept / state.dataOutRptTab->leedSiteTotal,
    8761            4 :                                  2);
    8762            4 :                 PreDefTableEntry(
    8763              :                     state,
    8764            4 :                     state.dataOutRptPredefined->pdchLeedEupPerc,
    8765              :                     "Miscellaneous",
    8766            4 :                     100 *
    8767            4 :                         (state.dataOutRptTab->leedSiteTotal -
    8768            4 :                          (state.dataOutRptTab->leedSiteIntLite + state.dataOutRptTab->leedSiteSpHeat + state.dataOutRptTab->leedSiteSpCool +
    8769            4 :                           state.dataOutRptTab->leedSiteFanInt + state.dataOutRptTab->leedSiteSrvWatr + state.dataOutRptTab->leedSiteRecept)) /
    8770            4 :                         state.dataOutRptTab->leedSiteTotal,
    8771            8 :                     2);
    8772              :             }
    8773              :         }
    8774              :         // totals across energy source
    8775           44 :         if (produceTabular) {
    8776           42 :             PreDefTableEntry(state,
    8777           42 :                              state.dataOutRptPredefined->pdchLeedEusTotal,
    8778              :                              "Total",
    8779           42 :                              unconvert_ipExceptElec * useVal(colElectricity, 15) +
    8780           42 :                                  unconvert * (useValColAddFuel15 + useVal(colPurchCool, 15) + useVal(colPurchHeatWtr, 15) +
    8781           42 :                                               useVal(colPurchHeatSt, 15) + +useVal(colGas, 15)),
    8782           42 :                              2);
    8783           42 :             PreDefTableEntry(state,
    8784           42 :                              state.dataOutRptPredefined->pdchLeedEusProc,
    8785              :                              "Total",
    8786           42 :                              unconvert_ipExceptElec * (useVal(colElectricity, 5) + useVal(colElectricity, 13)) +
    8787           42 :                                  unconvert * (useValColAddFuel5 + useValColAddFuel13 + useVal(colPurchCool, 5) + useVal(colPurchCool, 13) +
    8788           42 :                                               useVal(colPurchHeatWtr, 5) + useVal(colPurchHeatWtr, 13) + useVal(colPurchHeatSt, 5) +
    8789           42 :                                               useVal(colPurchHeatSt, 13) + +useVal(colGas, 5) + useVal(colGas, 13)),
    8790           84 :                              2);
    8791              :         }
    8792              : 
    8793           88 :         std::string footnote;
    8794           44 :         switch (resourcePrimaryHeating) {
    8795            0 :         case colElectricity: {
    8796            0 :             if (produceTabular) {
    8797            0 :                 footnote = "Note: Electricity appears to be the principal heating source based on energy usage.";
    8798            0 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchLeedGenData, "Principal Heating Source", "Electricity");
    8799              :             }
    8800            0 :         } break;
    8801            0 :         case colGas: {
    8802            0 :             if (produceTabular) {
    8803            0 :                 footnote = "Note: Natural gas appears to be the principal heating source based on energy usage.";
    8804            0 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchLeedGenData, "Principal Heating Source", "Natural Gas");
    8805              :             }
    8806            0 :         } break;
    8807            5 :         case colGasoline:
    8808              :         case colDiesel:
    8809              :         case colCoal:
    8810              :         case colFuelOilNo1:
    8811              :         case colFuelOilNo2:
    8812              :         case colPropane:
    8813              :         case colOtherFuel1:
    8814              :         case colOtherFuel2: {
    8815            5 :             if (produceTabular) {
    8816            3 :                 footnote = "Note: Additional fuel appears to be the principal heating source based on energy usage.";
    8817            3 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchLeedGenData, "Principal Heating Source", "Additional Fuel");
    8818              :             }
    8819            5 :         } break;
    8820            0 :         case colPurchHeatWtr: {
    8821            0 :             if (produceTabular) {
    8822            0 :                 footnote = "Note: District heating water appears to be the principal heating source based on energy usage.";
    8823            0 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchLeedGenData, "Principal Heating Source", "District Heating Water");
    8824              :             }
    8825            0 :         } break;
    8826            0 :         case colPurchHeatSt: {
    8827            0 :             if (produceTabular) {
    8828            0 :                 footnote = "Note: District heating steam appears to be the principal heating source based on energy usage.";
    8829            0 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchLeedGenData, "Principal Heating Source", "District Heating steam");
    8830              :             }
    8831            0 :         } break;
    8832              :         }
    8833              :         // heading for the entire sub-table
    8834           44 :         if (ort->displayTabularBEPS) {
    8835           44 :             if (produceTabular) {
    8836           42 :                 WriteSubtitle(state, "End Uses");
    8837           42 :                 WriteTable(state, tableBody, rowHead, columnHead, columnWidth, false, footnote);
    8838              :             }
    8839           44 :             if (produceSQLite) {
    8840           42 :                 if (state.dataSQLiteProcedures->sqlite) {
    8841            7 :                     state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
    8842              :                         tableBody, rowHead, columnHead, "AnnualBuildingUtilityPerformanceSummary", "Entire Facility", "End Uses");
    8843              :                 }
    8844              :             }
    8845           44 :             if (produceTabular) {
    8846           42 :                 if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
    8847            0 :                     state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(
    8848              :                         tableBody, rowHead, columnHead, "AnnualBuildingUtilityPerformanceSummary", "Entire Facility", "End Uses");
    8849              :                 }
    8850              :             }
    8851              :         }
    8852              : 
    8853              :         //---- End Uses By Subcategory Sub-Table
    8854           88 :         writeBEPSEndUseBySubCatOrSpaceType(state,
    8855              :                                            EndUseSubTableType::BySubCategory,
    8856              :                                            endUseSubOther,
    8857              :                                            collapsedEndUse,
    8858              :                                            collapsedEndUseSub,
    8859           44 :                                            ort->needOtherRowLEED45,
    8860              :                                            unitsStyle_cur,
    8861              :                                            produceTabular,
    8862              :                                            produceSQLite);
    8863              : 
    8864           88 :         writeBEPSEndUseBySubCatOrSpaceType(state,
    8865              :                                            EndUseSubTableType::BySpaceType,
    8866              :                                            endUseSubOther,
    8867              :                                            collapsedEndUse,
    8868              :                                            collapsedEndUseSpType,
    8869           44 :                                            ort->needOtherRowEndUse,
    8870              :                                            unitsStyle_cur,
    8871              :                                            produceTabular,
    8872              :                                            produceSQLite);
    8873              : 
    8874              :         // EAp2-4/5. Performance Rating Method Compliance
    8875              :         // repeat some of the code for the end use subcategory table but only looping over the energy resources and not including water
    8876              : 
    8877           88 :         Array1D_int resource_entry_map;
    8878           44 :         resource_entry_map.allocate(13);
    8879           44 :         resource_entry_map(1) = state.dataOutRptPredefined->pdchLeedPerfElEneUse;          // electricity
    8880           44 :         resource_entry_map(2) = state.dataOutRptPredefined->pdchLeedPerfGasEneUse;         // natural gas
    8881           44 :         resource_entry_map(3) = state.dataOutRptPredefined->pdchLeedPerfGasolineEneUse;    // gasoline
    8882           44 :         resource_entry_map(4) = state.dataOutRptPredefined->pdchLeedPerfDieselEneUse;      // diesel
    8883           44 :         resource_entry_map(5) = state.dataOutRptPredefined->pdchLeedPerfCoalEneUse;        // coal
    8884           44 :         resource_entry_map(6) = state.dataOutRptPredefined->pdchLeedPerfFuelOil1EneUse;    // fuel oil no 1
    8885           44 :         resource_entry_map(7) = state.dataOutRptPredefined->pdchLeedPerfFuelOil2EneUse;    // fuel oil no 2
    8886           44 :         resource_entry_map(8) = state.dataOutRptPredefined->pdchLeedPerfPropaneEneUse;     // propane
    8887           44 :         resource_entry_map(9) = state.dataOutRptPredefined->pdchLeedPerfOtherFuel1EneUse;  // other fuel 1
    8888           44 :         resource_entry_map(10) = state.dataOutRptPredefined->pdchLeedPerfOtherFuel2EneUse; // other fuel 2
    8889           44 :         resource_entry_map(11) = state.dataOutRptPredefined->pdchLeedPerfDisClEneUse;      // district cooling
    8890           44 :         resource_entry_map(12) = state.dataOutRptPredefined->pdchLeedPerfDisHtWtrEneUse;   // district heating Water
    8891           44 :         resource_entry_map(13) = state.dataOutRptPredefined->pdchLeedPerfDisHtStEneUse;    // district heating Steam
    8892              : 
    8893          616 :         for (int iResource = 1; iResource <= 13; ++iResource) {
    8894          572 :             int i = 1;
    8895          572 :             Real64 localUnconvert = (iResource == 1) ? unconvert_ipExceptElec : unconvert;
    8896         8580 :             for (int jEndUse = 1; jEndUse <= static_cast<int>(Constant::EndUse::Num); ++jEndUse) {
    8897         8008 :                 if (op->EndUseCategory(jEndUse).NumSubcategories > 0) {
    8898         4628 :                     for (int kEndUseSub = 1; kEndUseSub <= op->EndUseCategory(jEndUse).NumSubcategories; ++kEndUseSub) {
    8899         2353 :                         if (produceTabular) {
    8900         6825 :                             PreDefTableEntry(state,
    8901         2275 :                                              resource_entry_map(iResource),
    8902         4550 :                                              op->EndUseCategory(jEndUse).DisplayName + " -- " +
    8903         2275 :                                                  op->EndUseCategory(jEndUse).SubcategoryName(kEndUseSub),
    8904         2275 :                                              localUnconvert * collapsedEndUseSub(kEndUseSub, jEndUse, iResource));
    8905              :                         }
    8906         2353 :                         ++i;
    8907              :                     }
    8908              :                     // put other
    8909         2275 :                     if (ort->needOtherRowLEED45(jEndUse)) {
    8910            0 :                         if (produceTabular) {
    8911            0 :                             PreDefTableEntry(state,
    8912            0 :                                              resource_entry_map(iResource),
    8913            0 :                                              op->EndUseCategory(jEndUse).DisplayName + " -- Other",
    8914            0 :                                              localUnconvert * endUseSubOther(iResource, jEndUse));
    8915              :                         }
    8916            0 :                         ++i;
    8917              :                     }
    8918              :                 } else {
    8919         5733 :                     if (produceTabular) {
    8920        16263 :                         PreDefTableEntry(state,
    8921         5421 :                                          resource_entry_map(iResource),
    8922        10842 :                                          op->EndUseCategory(jEndUse).DisplayName + " -- Not Subdivided",
    8923         5421 :                                          localUnconvert * collapsedEndUse(iResource, jEndUse));
    8924              :                     }
    8925         5733 :                     ++i;
    8926              :                 }
    8927              :             }
    8928              :         }
    8929              : 
    8930              :         //---- Normalized by Conditioned Area Sub-Table
    8931              :         // Calculations for both normalized tables are first
    8932           44 :         rowHead.allocate(4);
    8933           44 :         columnHead.allocate(14);
    8934           44 :         columnWidth.allocate(14);
    8935           44 :         columnWidth = 7; // array assignment - same for all columns
    8936           44 :         tableBody.allocate(14, 4);
    8937          660 :         for (int iResource = 1; iResource <= 14; ++iResource) {
    8938              :             // Lights     <- InteriorLights | <- ExteriorLights
    8939          616 :             normalVal(iResource, 1) = collapsedEndUse(iResource, static_cast<int>(Constant::EndUse::InteriorLights) + 1) +
    8940          616 :                                       collapsedEndUse(iResource, static_cast<int>(Constant::EndUse::ExteriorLights) + 1);
    8941              : 
    8942              :             // HVAC       <- fans | <- pumps | <- heating | <- cooling | <- heat rejection | <- humidification | <- water system | <- domestic hot
    8943              :             // water
    8944          616 :             normalVal(iResource, 2) = collapsedEndUse(iResource, static_cast<int>(Constant::EndUse::Fans) + 1) +
    8945          616 :                                       collapsedEndUse(iResource, static_cast<int>(Constant::EndUse::Pumps) + 1) +
    8946          616 :                                       collapsedEndUse(iResource, static_cast<int>(Constant::EndUse::Heating) + 1) +
    8947          616 :                                       collapsedEndUse(iResource, static_cast<int>(Constant::EndUse::Cooling) + 1) +
    8948          616 :                                       collapsedEndUse(iResource, static_cast<int>(Constant::EndUse::HeatRejection) + 1) +
    8949          616 :                                       collapsedEndUse(iResource, static_cast<int>(Constant::EndUse::Humidification) + 1) +
    8950          616 :                                       collapsedEndUse(iResource, static_cast<int>(Constant::EndUse::WaterSystem) + 1);
    8951              : 
    8952              :             // Other <- InteriorEquipment | <- ExteriorEquipment | <- generator fuel | <- Heat Recovery (parasitics) | <- Refrigeration
    8953          616 :             normalVal(iResource, 3) = collapsedEndUse(iResource, static_cast<int>(Constant::EndUse::InteriorEquipment) + 1) +
    8954          616 :                                       collapsedEndUse(iResource, static_cast<int>(Constant::EndUse::ExteriorEquipment) + 1) +
    8955          616 :                                       collapsedEndUse(iResource, static_cast<int>(Constant::EndUse::Cogeneration) + 1) +
    8956          616 :                                       collapsedEndUse(iResource, static_cast<int>(Constant::EndUse::HeatRecovery) + 1) +
    8957          616 :                                       collapsedEndUse(iResource, static_cast<int>(Constant::EndUse::Refrigeration) + 1);
    8958              : 
    8959          616 :             normalVal(iResource, 4) = collapsedTotal(iResource); // totals
    8960              :         }
    8961              :         // convert the normalized end use values to MJ from GJ if using J
    8962          616 :         for (int iResource = 1; iResource <= 13; ++iResource) { // not including resource=14 water
    8963         2860 :             for (int jEndUse = 1; jEndUse <= 4; ++jEndUse) {
    8964         2288 :                 normalVal(iResource, jEndUse) *= kConversionFactor;
    8965              :             }
    8966              :         }
    8967              : 
    8968           44 :         rowHead(1) = "Lighting"; // typo fixed 5-17-04 BTG
    8969           44 :         rowHead(2) = "HVAC";
    8970           44 :         rowHead(3) = "Other";
    8971           44 :         rowHead(4) = "Total";
    8972              : 
    8973           44 :         switch (unitsStyle_cur) {
    8974            4 :         case UnitsStyle::JtoKWH: {
    8975            4 :             columnHead(1) = "Electricity Intensity [kWh/m2]";
    8976            4 :             columnHead(2) = "Natural Gas Intensity [kWh/m2]";
    8977            4 :             columnHead(3) = "Gasoline Intensity [kWh/m2]";
    8978            4 :             columnHead(4) = "Diesel Intensity [kWh/m2]";
    8979            4 :             columnHead(5) = "Coal Intensity [kWh/m2]";
    8980            4 :             columnHead(6) = "Fuel Oil No 1 Intensity [kWh/m2]";
    8981            4 :             columnHead(7) = "Fuel Oil No 2 Intensity [kWh/m2]";
    8982            4 :             columnHead(8) = "Propane Intensity [kWh/m2]";
    8983            4 :             columnHead(9) = "Other Fuel 1 Intensity [kWh/m2]";
    8984            4 :             columnHead(10) = "Other Fuel 2 Intensity [kWh/m2]";
    8985            4 :             columnHead(11) = "District Cooling Intensity [kWh/m2]";
    8986            4 :             columnHead(12) = "District Heating Water Intensity [kWh/m2]";
    8987            4 :             columnHead(13) = "District Heating Steam Intensity [kWh/m2]";
    8988            4 :             columnHead(14) = "Water Intensity [m3/m2]";
    8989            4 :         } break;
    8990            2 :         case UnitsStyle::InchPound: {
    8991            2 :             columnHead(1) = "Electricity Intensity [kBtu/ft2]";
    8992            2 :             columnHead(2) = "Natural Gas Intensity [kBtu/ft2]";
    8993            2 :             columnHead(3) = "Gasoline Intensity [kBtu/ft2]";
    8994            2 :             columnHead(4) = "Diesel Intensity [kBtu/ft2]";
    8995            2 :             columnHead(5) = "Coal Intensity [kBtu/ft2]";
    8996            2 :             columnHead(6) = "Fuel Oil No 1 Intensity [kBtu/ft2]";
    8997            2 :             columnHead(7) = "Fuel Oil No 2 Intensity [kBtu/ft2]";
    8998            2 :             columnHead(8) = "Propane Intensity [kBtu/ft2]";
    8999            2 :             columnHead(9) = "Other Fuel 1 Intensity [kBtu/ft2]";
    9000            2 :             columnHead(10) = "Other Fuel 2 Intensity [kBtu/ft2]";
    9001            2 :             columnHead(11) = "District Cooling Intensity [kBtu/ft2]";
    9002            2 :             columnHead(12) = "District Heating Water Intensity [kBtu/ft2]";
    9003            2 :             columnHead(13) = "District Heating Steam Intensity [kBtu/ft2]";
    9004            2 :             columnHead(14) = "Water Intensity [gal/ft2]";
    9005            2 :         } break;
    9006            1 :         case UnitsStyle::InchPoundExceptElectricity: {
    9007            1 :             columnHead(1) = "Electricity Intensity [kWh/ft2]";
    9008            1 :             columnHead(2) = "Natural Gas Intensity [kBtu/ft2]";
    9009            1 :             columnHead(3) = "Gasoline Intensity [kBtu/ft2]";
    9010            1 :             columnHead(4) = "Diesel Intensity [kBtu/ft2]";
    9011            1 :             columnHead(5) = "Coal Intensity [kBtu/ft2]";
    9012            1 :             columnHead(6) = "Fuel Oil No 1 Intensity [kBtu/ft2]";
    9013            1 :             columnHead(7) = "Fuel Oil No 2 Intensity [kBtu/ft2]";
    9014            1 :             columnHead(8) = "Propane Intensity [kBtu/ft2]";
    9015            1 :             columnHead(9) = "Other Fuel 1 Intensity [kBtu/ft2]";
    9016            1 :             columnHead(10) = "Other Fuel 2 Intensity [kBtu/ft2]";
    9017            1 :             columnHead(11) = "District Cooling Intensity [kBtu/ft2]";
    9018            1 :             columnHead(12) = "District Heating Water Intensity [kBtu/ft2]";
    9019            1 :             columnHead(13) = "District Heating Steam Intensity [kBtu/ft2]";
    9020            1 :             columnHead(14) = "Water Intensity [gal/ft2]";
    9021            1 :         } break;
    9022           37 :         default: {
    9023           37 :             columnHead(1) = "Electricity Intensity [MJ/m2]";
    9024           37 :             columnHead(2) = "Natural Gas Intensity [MJ/m2]";
    9025           37 :             columnHead(3) = "Gasoline Intensity [MJ/m2]";
    9026           37 :             columnHead(4) = "Diesel Intensity [MJ/m2]";
    9027           37 :             columnHead(5) = "Coal Intensity [MJ/m2]";
    9028           37 :             columnHead(6) = "Fuel Oil No 1 Intensity [MJ/m2]";
    9029           37 :             columnHead(7) = "Fuel Oil No 2 Intensity [MJ/m2]";
    9030           37 :             columnHead(8) = "Propane Intensity [MJ/m2]";
    9031           37 :             columnHead(9) = "Other Fuel 1 Intensity [MJ/m2]";
    9032           37 :             columnHead(10) = "Other Fuel 2 Intensity [MJ/m2]";
    9033           37 :             columnHead(11) = "District Cooling Intensity [MJ/m2]";
    9034           37 :             columnHead(12) = "District Heating Water Intensity [MJ/m2]";
    9035           37 :             columnHead(13) = "District Heating Steam Intensity [MJ/m2]";
    9036           37 :             columnHead(14) = "Water Intensity [m3/m2]";
    9037           37 :         } break;
    9038              :         }
    9039              : 
    9040           44 :         if (produceTabular) {
    9041           84 :             WriteTextLine(state, "Normalized Metrics", true);
    9042              :         }
    9043              : 
    9044              :         // write the conditioned area based table
    9045           44 :         tableBody = "";
    9046           44 :         if (convBldgCondFloorArea > 0) {
    9047          210 :             for (int iResource = 1; iResource <= 14; ++iResource) {
    9048          980 :                 for (int jEndUse = 1; jEndUse <= 4; ++jEndUse) {
    9049          784 :                     tableBody(iResource, jEndUse) = RealToStr(normalVal(iResource, jEndUse) / convBldgCondFloorArea, 2);
    9050              :                 }
    9051              :             }
    9052              :         }
    9053              :         // heading for the entire sub-table
    9054           44 :         if (ort->displayTabularBEPS) {
    9055           44 :             if (produceTabular) {
    9056           42 :                 WriteSubtitle(state, "Utility Use Per Conditioned Floor Area");
    9057           42 :                 WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
    9058              :             }
    9059           44 :             if (produceSQLite) {
    9060           42 :                 if (state.dataSQLiteProcedures->sqlite) {
    9061            7 :                     state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(tableBody,
    9062              :                                                                                        rowHead,
    9063              :                                                                                        columnHead,
    9064              :                                                                                        "AnnualBuildingUtilityPerformanceSummary",
    9065              :                                                                                        "Entire Facility",
    9066              :                                                                                        "Utility Use Per Conditioned Floor Area");
    9067              :                 }
    9068              :             }
    9069           44 :             if (produceTabular) {
    9070           42 :                 if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
    9071            0 :                     state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(tableBody,
    9072              :                                                                                                           rowHead,
    9073              :                                                                                                           columnHead,
    9074              :                                                                                                           "AnnualBuildingUtilityPerformanceSummary",
    9075              :                                                                                                           "Entire Facility",
    9076              :                                                                                                           "Utility Use Per Conditioned Floor Area");
    9077              :                 }
    9078              :             }
    9079              :         }
    9080              :         //---- Normalized by Total Area Sub-Table
    9081           44 :         tableBody = "";
    9082           44 :         if (convBldgGrossFloorArea > 0) {
    9083          532 :             for (int iResource = 1; iResource <= 13; ++iResource) {
    9084         2470 :                 for (int jEndUse = 1; jEndUse <= 4; ++jEndUse) {
    9085         1976 :                     tableBody(iResource, jEndUse) = RealToStr(normalVal(iResource, jEndUse) / convBldgGrossFloorArea, 2);
    9086              :                 }
    9087              :             }
    9088              :         }
    9089              :         // heading for the entire sub-table
    9090           44 :         if (ort->displayTabularBEPS) {
    9091           44 :             if (produceTabular) {
    9092           42 :                 WriteSubtitle(state, "Utility Use Per Total Floor Area");
    9093           42 :                 WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
    9094              :             }
    9095           44 :             if (produceSQLite) {
    9096           42 :                 if (state.dataSQLiteProcedures->sqlite) {
    9097            7 :                     state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(tableBody,
    9098              :                                                                                        rowHead,
    9099              :                                                                                        columnHead,
    9100              :                                                                                        "AnnualBuildingUtilityPerformanceSummary",
    9101              :                                                                                        "Entire Facility",
    9102              :                                                                                        "Utility Use Per Total Floor Area");
    9103              :                 }
    9104              :             }
    9105           44 :             if (produceTabular) {
    9106           42 :                 if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
    9107            0 :                     state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(tableBody,
    9108              :                                                                                                           rowHead,
    9109              :                                                                                                           columnHead,
    9110              :                                                                                                           "AnnualBuildingUtilityPerformanceSummary",
    9111              :                                                                                                           "Entire Facility",
    9112              :                                                                                                           "Utility Use Per Total Floor Area");
    9113              :                 }
    9114              :             }
    9115              :         }
    9116              : 
    9117              :         //---- Electric Loads Satisfied Sub-Table
    9118           44 :         rowHead.allocate(14);
    9119           44 :         columnHead.allocate(2);
    9120           44 :         columnWidth.allocate(2);
    9121           44 :         columnWidth = 14; // array assignment - same for all columns
    9122           44 :         tableBody.allocate(2, 14);
    9123              : 
    9124           44 :         switch (unitsStyle_cur) {
    9125            4 :         case UnitsStyle::JtoKWH: {
    9126            4 :             columnHead(1) = "Electricity [kWh]";
    9127            4 :         } break;
    9128            2 :         case UnitsStyle::InchPound: {
    9129            2 :             columnHead(1) = "Electricity [kBtu]";
    9130            2 :         } break;
    9131            1 :         case UnitsStyle::InchPoundExceptElectricity: {
    9132            1 :             columnHead(1) = "Electricity [kWh]";
    9133            1 :         } break;
    9134           37 :         default: {
    9135           37 :             columnHead(1) = "Electricity [GJ]";
    9136           37 :         } break;
    9137              :         }
    9138           44 :         columnHead(2) = "Percent Electricity [%]";
    9139              : 
    9140           44 :         rowHead(1) = "Fuel-Fired Power Generation";
    9141           44 :         rowHead(2) = "High Temperature Geothermal*";
    9142           44 :         rowHead(3) = "Photovoltaic Power";
    9143           44 :         rowHead(4) = "Wind Power";
    9144           44 :         rowHead(5) = "Power Conversion";
    9145           44 :         rowHead(6) = "Net Decrease in On-Site Storage";
    9146           44 :         rowHead(7) = "Total On-Site Electric Sources";
    9147           44 :         rowHead(8) = "";
    9148           44 :         rowHead(9) = "Electricity Coming From Utility";
    9149           44 :         rowHead(10) = "Surplus Electricity Going To Utility";
    9150           44 :         rowHead(11) = "Net Electricity From Utility";
    9151           44 :         rowHead(12) = "";
    9152           44 :         rowHead(13) = "Total On-Site and Utility Electric Sources";
    9153           44 :         rowHead(14) = "Total Electricity End Uses";
    9154              : 
    9155           44 :         tableBody = "";
    9156              : 
    9157              :         // show annual values
    9158           44 :         tableBody(1, 1) = RealToStr(ort->gatherPowerFuelFireGen, 3);
    9159           44 :         tableBody(1, 2) = RealToStr(ort->gatherPowerHTGeothermal, 3);
    9160           44 :         tableBody(1, 3) = RealToStr(ort->gatherPowerPV, 3);
    9161           44 :         if (produceTabular) {
    9162           42 :             PreDefTableEntry(state, state.dataOutRptPredefined->pdchLeedRenAnGen, "Photovoltaic", unconvert_ipExceptElec * ort->gatherPowerPV, 2);
    9163              :         }
    9164           44 :         tableBody(1, 4) = RealToStr(ort->gatherPowerWind, 3);
    9165           44 :         if (produceTabular) {
    9166           42 :             PreDefTableEntry(state, state.dataOutRptPredefined->pdchLeedRenAnGen, "Wind", unconvert_ipExceptElec * ort->gatherPowerWind, 2);
    9167              :         }
    9168           44 :         tableBody(1, 5) = RealToStr(ort->gatherPowerConversion, 3);
    9169           44 :         tableBody(1, 6) = RealToStr(ort->OverallNetEnergyFromStorage, 3);
    9170           44 :         tableBody(1, 7) = RealToStr(ort->gatherElecProduced, 3);
    9171           44 :         tableBody(1, 9) = RealToStr(ort->gatherElecPurchased, 3);
    9172           44 :         tableBody(1, 10) = RealToStr(ort->gatherElecSurplusSold, 3);
    9173           44 :         tableBody(1, 11) = RealToStr(ort->gatherElecPurchased - ort->gatherElecSurplusSold, 3);
    9174           44 :         tableBody(1, 13) = RealToStr(ort->gatherElecProduced + (ort->gatherElecPurchased - ort->gatherElecSurplusSold), 3);
    9175           44 :         tableBody(1, 14) = RealToStr(collapsedTotal(1), 3);
    9176              : 
    9177              :         // show annual percentages
    9178           44 :         if (collapsedTotal(1) > 0) {
    9179            5 :             tableBody(2, 1) = RealToStr(100.0 * ort->gatherPowerFuelFireGen / collapsedTotal(1), 2);
    9180            5 :             tableBody(2, 2) = RealToStr(100.0 * ort->gatherPowerHTGeothermal / collapsedTotal(1), 2);
    9181            5 :             tableBody(2, 3) = RealToStr(100.0 * ort->gatherPowerPV / collapsedTotal(1), 2);
    9182            5 :             tableBody(2, 4) = RealToStr(100.0 * ort->gatherPowerWind / collapsedTotal(1), 2);
    9183            5 :             tableBody(2, 5) = RealToStr(100.0 * ort->gatherPowerConversion / collapsedTotal(1), 2);
    9184            5 :             tableBody(2, 6) = RealToStr(100.0 * ort->OverallNetEnergyFromStorage / collapsedTotal(1), 2);
    9185            5 :             tableBody(2, 7) = RealToStr(100.0 * ort->gatherElecProduced / collapsedTotal(1), 2);
    9186            5 :             tableBody(2, 9) = RealToStr(100.0 * ort->gatherElecPurchased / collapsedTotal(1), 2);
    9187            5 :             tableBody(2, 10) = RealToStr(100.0 * ort->gatherElecSurplusSold / collapsedTotal(1), 2);
    9188            5 :             tableBody(2, 11) = RealToStr(100.0 * (ort->gatherElecPurchased - ort->gatherElecSurplusSold) / collapsedTotal(1), 2);
    9189            5 :             tableBody(2, 13) =
    9190           10 :                 RealToStr(100.0 * (ort->gatherElecProduced + (ort->gatherElecPurchased - ort->gatherElecSurplusSold)) / collapsedTotal(1), 2);
    9191            5 :             tableBody(2, 14) = RealToStr(100.0, 2);
    9192              :         }
    9193              : 
    9194              :         // heading for the entire sub-table
    9195           44 :         if (ort->displayTabularBEPS) {
    9196           44 :             if (produceTabular) {
    9197           42 :                 WriteSubtitle(state, "Electric Loads Satisfied");
    9198           42 :                 WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
    9199              :             }
    9200           44 :             if (produceSQLite) {
    9201           42 :                 if (state.dataSQLiteProcedures->sqlite) {
    9202            7 :                     state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
    9203              :                         tableBody, rowHead, columnHead, "AnnualBuildingUtilityPerformanceSummary", "Entire Facility", "Electric Loads Satisfied");
    9204              :                 }
    9205              :             }
    9206           44 :             if (produceTabular) {
    9207           42 :                 if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
    9208            0 :                     state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(
    9209              :                         tableBody, rowHead, columnHead, "AnnualBuildingUtilityPerformanceSummary", "Entire Facility", "Electric Loads Satisfied");
    9210              :                 }
    9211              :             }
    9212              :         }
    9213              : 
    9214              :         //---- On-Site Thermal Sources Sub-Table
    9215           44 :         rowHead.allocate(7);
    9216           44 :         columnHead.allocate(2);
    9217           44 :         columnWidth.allocate(2);
    9218           44 :         columnWidth = 14; // array assignment - same for all columns
    9219           44 :         tableBody.allocate(2, 7);
    9220              : 
    9221           44 :         switch (unitsStyle_cur) {
    9222            4 :         case UnitsStyle::JtoKWH: {
    9223            4 :             columnHead(1) = "Heat [kWh]";
    9224            4 :         } break;
    9225            2 :         case UnitsStyle::InchPound: {
    9226            2 :             columnHead(1) = "Heat [kBtu]";
    9227            2 :         } break;
    9228            1 :         case UnitsStyle::InchPoundExceptElectricity: {
    9229            1 :             columnHead(1) = "Heat [kBtu]";
    9230            1 :         } break;
    9231           37 :         default: {
    9232           37 :             columnHead(1) = "Heat [GJ]";
    9233           37 :         } break;
    9234              :         }
    9235              : 
    9236           44 :         columnHead(2) = "Percent Heat [%]";
    9237              : 
    9238           44 :         rowHead(1) = "Water-Side Heat Recovery";
    9239           44 :         rowHead(2) = "Air to Air Heat Recovery for Cooling";
    9240           44 :         rowHead(3) = "Air to Air Heat Recovery for Heating";
    9241           44 :         rowHead(4) = "High-Temperature Geothermal*";
    9242           44 :         rowHead(5) = "Solar Water Thermal";
    9243           44 :         rowHead(6) = "Solar Air Thermal";
    9244           44 :         rowHead(7) = "Total On-Site Thermal Sources";
    9245              : 
    9246           44 :         tableBody = "";
    9247              : 
    9248           44 :         if (iUnitSystem == 0) {
    9249           42 :             gtWaterHeatRecovery = ort->gatherWaterHeatRecovery;
    9250           42 :             gtAirHeatRecoveryCool = ort->gatherAirHeatRecoveryCool;
    9251           42 :             gtAirHeatRecoveryHeat = ort->gatherAirHeatRecoveryHeat;
    9252           42 :             gtHeatHTGeothermal = ort->gatherHeatHTGeothermal;
    9253           42 :             gtHeatSolarWater = ort->gatherHeatSolarWater;
    9254           42 :             gtHeatSolarAir = ort->gatherHeatSolarAir;
    9255              :         } else {
    9256            2 :             ort->gatherWaterHeatRecovery = gtWaterHeatRecovery;
    9257            2 :             ort->gatherAirHeatRecoveryCool = gtAirHeatRecoveryCool;
    9258            2 :             ort->gatherAirHeatRecoveryHeat = gtAirHeatRecoveryHeat;
    9259            2 :             ort->gatherHeatHTGeothermal = gtHeatHTGeothermal;
    9260            2 :             ort->gatherHeatSolarWater = gtHeatSolarWater;
    9261            2 :             ort->gatherHeatSolarAir = gtHeatSolarAir;
    9262              :         }
    9263              : 
    9264              :         // convert to GJ
    9265           44 :         ort->gatherWaterHeatRecovery /= largeConversionFactor;
    9266           44 :         ort->gatherAirHeatRecoveryCool /= largeConversionFactor;
    9267           44 :         ort->gatherAirHeatRecoveryHeat /= largeConversionFactor;
    9268           44 :         ort->gatherHeatHTGeothermal /= largeConversionFactor;
    9269           44 :         ort->gatherHeatSolarWater /= largeConversionFactor;
    9270           44 :         ort->gatherHeatSolarAir /= largeConversionFactor;
    9271              : 
    9272              :         // determine total on site heat
    9273           44 :         Real64 const totalOnsiteHeat = ort->gatherWaterHeatRecovery + ort->gatherAirHeatRecoveryCool + ort->gatherAirHeatRecoveryHeat +
    9274           44 :                                        ort->gatherHeatHTGeothermal + ort->gatherHeatSolarWater + ort->gatherHeatSolarAir;
    9275              : 
    9276              :         // show annual values
    9277           44 :         tableBody(1, 1) = RealToStr(ort->gatherWaterHeatRecovery, 2);
    9278           44 :         tableBody(1, 2) = RealToStr(ort->gatherAirHeatRecoveryCool, 2);
    9279           44 :         tableBody(1, 3) = RealToStr(ort->gatherAirHeatRecoveryHeat, 2);
    9280           44 :         tableBody(1, 4) = RealToStr(ort->gatherHeatHTGeothermal, 2);
    9281           44 :         tableBody(1, 5) = RealToStr(ort->gatherHeatSolarWater, 2);
    9282           44 :         tableBody(1, 6) = RealToStr(ort->gatherHeatSolarAir, 2);
    9283           44 :         tableBody(1, 7) = RealToStr(totalOnsiteHeat, 2);
    9284              : 
    9285           44 :         if (totalOnsiteHeat > 0) {
    9286            0 :             tableBody(2, 1) = RealToStr(100.0 * ort->gatherWaterHeatRecovery / totalOnsiteHeat, 2);
    9287            0 :             tableBody(2, 2) = RealToStr(100.0 * ort->gatherAirHeatRecoveryCool / totalOnsiteHeat, 2);
    9288            0 :             tableBody(2, 3) = RealToStr(100.0 * ort->gatherAirHeatRecoveryHeat / totalOnsiteHeat, 2);
    9289            0 :             tableBody(2, 4) = RealToStr(100.0 * ort->gatherHeatHTGeothermal / totalOnsiteHeat, 2);
    9290            0 :             tableBody(2, 5) = RealToStr(100.0 * ort->gatherHeatSolarWater / totalOnsiteHeat, 2);
    9291            0 :             tableBody(2, 6) = RealToStr(100.0 * ort->gatherHeatSolarAir / totalOnsiteHeat, 2);
    9292            0 :             tableBody(2, 7) = RealToStr(100.0, 2);
    9293              :         }
    9294              : 
    9295              :         // heading for the entire sub-table
    9296           44 :         if (ort->displayTabularBEPS) {
    9297           44 :             if (produceTabular) {
    9298           42 :                 WriteSubtitle(state, "On-Site Thermal Sources");
    9299           42 :                 WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
    9300              :             }
    9301           44 :             if (produceSQLite) {
    9302           42 :                 if (state.dataSQLiteProcedures->sqlite) {
    9303            7 :                     state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
    9304              :                         tableBody, rowHead, columnHead, "AnnualBuildingUtilityPerformanceSummary", "Entire Facility", "On-Site Thermal Sources");
    9305              :                 }
    9306              :             }
    9307           44 :             if (produceTabular) {
    9308           42 :                 if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
    9309            0 :                     state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(
    9310              :                         tableBody, rowHead, columnHead, "AnnualBuildingUtilityPerformanceSummary", "Entire Facility", "On-Site Thermal Sources");
    9311              :                 }
    9312              :             }
    9313              :         }
    9314              : 
    9315              :         //---- Water Loads Sub-Table
    9316              :         // As of 12/8/2003 decided to not include this sub-table to wait
    9317              :         // until water use is implemented in EnergyPlus before displaying
    9318              :         // the table. Implementing water end-uses makes sense for EnergyPlus
    9319              :         // but since they are not really implemented as of December 2003 the
    9320              :         // table would be all zeros.  Recommendation to exclude this table
    9321              :         // for now made by Glazer and Crawley.
    9322              :         // Aug 2006, adding table in with implementation of water system, BGriffith
    9323           44 :         rowHead.allocate(13);
    9324           44 :         columnHead.allocate(2);
    9325           44 :         columnWidth.allocate(2);
    9326           44 :         columnWidth = 14; // array assignment - same for all columns
    9327           44 :         tableBody.allocate(2, 13);
    9328           44 :         switch (unitsStyle_cur) {
    9329            4 :         case UnitsStyle::JtoKWH: {
    9330            4 :             columnHead(1) = "Water [m3]";
    9331            4 :         } break;
    9332            2 :         case UnitsStyle::InchPound: {
    9333            2 :             columnHead(1) = "Water [gal]";
    9334            2 :         } break;
    9335            1 :         case UnitsStyle::InchPoundExceptElectricity: {
    9336            1 :             columnHead(1) = "Water [gal]";
    9337            1 :         } break;
    9338           37 :         default: {
    9339           37 :             columnHead(1) = "Water [m3]";
    9340           37 :         } break;
    9341              :         }
    9342              : 
    9343           44 :         columnHead(2) = "Percent Water [%]";
    9344           44 :         rowHead(1) = "Rainwater Collection";
    9345           44 :         rowHead(2) = "Condensate Collection";
    9346           44 :         rowHead(3) = "Groundwater Well";
    9347           44 :         rowHead(4) = "Total On Site Water Sources";
    9348           44 :         rowHead(5) = "-";
    9349           44 :         rowHead(6) = "Initial Storage";
    9350           44 :         rowHead(7) = "Final Storage";
    9351           44 :         rowHead(8) = "Change in Storage";
    9352           44 :         rowHead(9) = "-";
    9353           44 :         rowHead(10) = "Water Supplied by Utility";
    9354           44 :         rowHead(11) = "-";
    9355           44 :         rowHead(12) = "Total On Site, Change in Storage, and Utility Water Sources";
    9356           44 :         rowHead(13) = "Total Water End Uses";
    9357           44 :         tableBody = "-";
    9358              : 
    9359           44 :         Real64 const totalOnsiteWater = ort->gatherRainWater + ort->gatherCondensate + ort->gatherWellwater;
    9360              : 
    9361              :         //  ! show annual values
    9362           44 :         tableBody(1, 1) = RealToStr(ort->gatherRainWater / waterConversionFactor, 2);
    9363           44 :         tableBody(1, 2) = RealToStr(ort->gatherCondensate / waterConversionFactor, 2);
    9364           44 :         tableBody(1, 3) = RealToStr(ort->gatherWellwater / waterConversionFactor, 2);
    9365           44 :         tableBody(1, 4) = RealToStr(totalOnsiteWater / waterConversionFactor, 2);
    9366              : 
    9367           44 :         Real64 initialStorage = 0.0;
    9368           44 :         Real64 finalStorage = 0.0;
    9369           44 :         Real64 StorageChange = 0.0;
    9370           44 :         if (allocated(state.dataWaterData->WaterStorage)) {
    9371            0 :             initialStorage = sum(state.dataWaterData->WaterStorage, &DataWater::StorageTankDataStruct::InitialVolume);
    9372            0 :             finalStorage = sum(state.dataWaterData->WaterStorage, &DataWater::StorageTankDataStruct::ThisTimeStepVolume);
    9373            0 :             StorageChange = initialStorage - finalStorage;
    9374              :         }
    9375           44 :         tableBody(1, 6) = RealToStr(initialStorage / waterConversionFactor, 2);
    9376           44 :         tableBody(1, 7) = RealToStr(finalStorage / waterConversionFactor, 2);
    9377           44 :         tableBody(1, 8) = RealToStr(StorageChange / waterConversionFactor, 2);
    9378              : 
    9379           44 :         Real64 const totalWater = totalOnsiteWater + ort->gatherMains + StorageChange;
    9380              : 
    9381           44 :         tableBody(1, 10) = RealToStr(ort->gatherMains / waterConversionFactor, 2);
    9382           44 :         tableBody(1, 12) = RealToStr(totalWater / waterConversionFactor, 2);
    9383           44 :         tableBody(1, 13) = RealToStr(ort->gatherWaterEndUseTotal / waterConversionFactor, 2);
    9384              : 
    9385           44 :         if (ort->gatherWaterEndUseTotal > 0) {
    9386            0 :             tableBody(2, 1) = RealToStr(100.0 * ort->gatherRainWater / ort->gatherWaterEndUseTotal, 2);
    9387            0 :             tableBody(2, 2) = RealToStr(100.0 * ort->gatherCondensate / ort->gatherWaterEndUseTotal, 2);
    9388            0 :             tableBody(2, 3) = RealToStr(100.0 * ort->gatherWellwater / ort->gatherWaterEndUseTotal, 2);
    9389            0 :             tableBody(2, 4) = RealToStr(100.0 * totalOnsiteWater / ort->gatherWaterEndUseTotal, 2);
    9390            0 :             tableBody(2, 6) = RealToStr(100.0 * initialStorage / ort->gatherWaterEndUseTotal, 2);
    9391            0 :             tableBody(2, 7) = RealToStr(100.0 * finalStorage / ort->gatherWaterEndUseTotal, 2);
    9392            0 :             tableBody(2, 8) = RealToStr(100.0 * StorageChange / ort->gatherWaterEndUseTotal, 2);
    9393              : 
    9394            0 :             tableBody(2, 10) = RealToStr(100.0 * ort->gatherMains / ort->gatherWaterEndUseTotal, 2);
    9395              : 
    9396            0 :             tableBody(2, 12) = RealToStr(100.0 * totalWater / ort->gatherWaterEndUseTotal, 2);
    9397            0 :             tableBody(2, 13) = RealToStr(100.0, 2);
    9398              :         }
    9399              : 
    9400              :         //  ! heading for the entire sub-table
    9401           44 :         if (ort->displayTabularBEPS) {
    9402           44 :             if (produceTabular) {
    9403           42 :                 WriteSubtitle(state, "Water Source Summary");
    9404           42 :                 WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
    9405              :             }
    9406           44 :             if (produceSQLite) {
    9407           42 :                 if (state.dataSQLiteProcedures->sqlite) {
    9408            7 :                     state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
    9409              :                         tableBody, rowHead, columnHead, "AnnualBuildingUtilityPerformanceSummary", "Entire Facility", "Water Source Summary");
    9410              :                 }
    9411              :             }
    9412           44 :             if (produceTabular) {
    9413           42 :                 if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
    9414            0 :                     state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(
    9415              :                         tableBody, rowHead, columnHead, "AnnualBuildingUtilityPerformanceSummary", "Entire Facility", "Water Source Summary");
    9416              :                 }
    9417              :             }
    9418              : 
    9419              :             //---- Comfort and Setpoint Not Met Sub-Table
    9420           44 :             rowHead.allocate(2);
    9421           44 :             columnHead.allocate(1);
    9422           44 :             columnWidth.allocate(1);
    9423           44 :             columnWidth = 14; // array assignment - same for all columns
    9424           44 :             tableBody.allocate(1, 2);
    9425              : 
    9426           44 :             if (produceTabular) {
    9427           84 :                 WriteSubtitle(state, "Setpoint Not Met Criteria");
    9428              :             }
    9429              : 
    9430           44 :             std::string const curNameWithSIUnits = "Degrees [deltaC]";
    9431           44 :             if (unitsStyle_cur == OutputReportTabular::UnitsStyle::InchPound ||
    9432           42 :                 unitsStyle_cur == OutputReportTabular::UnitsStyle::InchPoundExceptElectricity) {
    9433            3 :                 int indexUnitConv = -1;
    9434            3 :                 std::string curNameAndUnits;
    9435            3 :                 LookupSItoIP(state, curNameWithSIUnits, indexUnitConv, curNameAndUnits);
    9436            3 :                 columnHead(1) = curNameAndUnits;
    9437            3 :             } else {
    9438           41 :                 columnHead(1) = curNameWithSIUnits;
    9439              :             }
    9440              : 
    9441           44 :             rowHead(1) = "Tolerance for Zone Heating Setpoint Not Met Time";
    9442           44 :             rowHead(2) = "Tolerance for Zone Cooling Setpoint Not Met Time";
    9443              : 
    9444           44 :             if (!(unitsStyle_cur == OutputReportTabular::UnitsStyle::InchPound ||
    9445           42 :                   unitsStyle_cur == OutputReportTabular::UnitsStyle::InchPoundExceptElectricity)) {
    9446           41 :                 tableBody(1, 1) = RealToStr(std::abs(state.dataHVACGlobal->deviationFromSetPtThresholdHtg), 2);
    9447           41 :                 tableBody(1, 2) = RealToStr(state.dataHVACGlobal->deviationFromSetPtThresholdClg, 2);
    9448              :             } else {
    9449            3 :                 int indexUnitConv = -1;
    9450            3 :                 std::string curNameAndUnits;
    9451            3 :                 LookupSItoIP(state, curNameWithSIUnits, indexUnitConv, curNameAndUnits);
    9452            3 :                 tableBody(1, 1) = RealToStr(ConvertIPdelta(state, indexUnitConv, std::abs(state.dataHVACGlobal->deviationFromSetPtThresholdHtg)), 2);
    9453            3 :                 tableBody(1, 2) = RealToStr(ConvertIPdelta(state, indexUnitConv, state.dataHVACGlobal->deviationFromSetPtThresholdClg), 2);
    9454            3 :             }
    9455              : 
    9456           44 :             if (produceTabular) {
    9457           42 :                 WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
    9458              :             }
    9459           44 :             if (produceSQLite) {
    9460           42 :                 if (state.dataSQLiteProcedures->sqlite) {
    9461            7 :                     state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
    9462              :                         tableBody, rowHead, columnHead, "AnnualBuildingUtilityPerformanceSummary", "Entire Facility", "Setpoint Not Met Criteria");
    9463              :                 }
    9464              :             }
    9465           44 :             if (produceTabular) {
    9466           42 :                 if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
    9467            0 :                     state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(
    9468              :                         tableBody, rowHead, columnHead, "AnnualBuildingUtilityPerformanceSummary", "Entire Facility", "Setpoint Not Met Criteria");
    9469              :                 }
    9470              :             }
    9471           44 :         }
    9472              : 
    9473           44 :         rowHead.allocate(3);
    9474           44 :         columnHead.allocate(1);
    9475           44 :         columnWidth.allocate(1);
    9476           44 :         columnWidth = 14; // array assignment - same for all columns
    9477           44 :         tableBody.allocate(1, 3);
    9478              : 
    9479           44 :         if (ort->displayTabularBEPS) {
    9480           44 :             if (produceTabular) {
    9481           84 :                 WriteSubtitle(state, "Comfort and Setpoint Not Met Summary");
    9482              :             }
    9483              :         }
    9484              : 
    9485           44 :         columnHead(1) = "Facility [Hours]";
    9486              : 
    9487           44 :         rowHead(1) = "Time Setpoint Not Met During Occupied Heating";
    9488           44 :         rowHead(2) = "Time Setpoint Not Met During Occupied Cooling";
    9489           44 :         rowHead(3) = "Time Not Comfortable Based on Simple ASHRAE 55-2004";
    9490              : 
    9491           44 :         tableBody(1, 1) = RealToStr(state.dataOutRptPredefined->TotalNotMetHeatingOccupiedForABUPS, 2);
    9492           44 :         tableBody(1, 2) = RealToStr(state.dataOutRptPredefined->TotalNotMetCoolingOccupiedForABUPS, 2);
    9493           44 :         if (produceTabular) {
    9494           84 :             PreDefTableEntry(state,
    9495           42 :                              state.dataOutRptPredefined->pdchLeedAmData,
    9496              :                              "Number of hours heating loads not met",
    9497           84 :                              RealToStr(state.dataOutRptPredefined->TotalNotMetHeatingOccupiedForABUPS, 2));
    9498           84 :             PreDefTableEntry(state,
    9499           42 :                              state.dataOutRptPredefined->pdchLeedAmData,
    9500              :                              "Number of hours cooling loads not met",
    9501           84 :                              RealToStr(state.dataOutRptPredefined->TotalNotMetCoolingOccupiedForABUPS, 2));
    9502           84 :             PreDefTableEntry(state,
    9503           42 :                              state.dataOutRptPredefined->pdchLeedAmData,
    9504              :                              "Number of hours not met",
    9505           84 :                              RealToStr(state.dataOutRptPredefined->TotalNotMetOccupiedForABUPS, 2));
    9506              :         }
    9507           44 :         tableBody(1, 3) = RealToStr(state.dataOutRptPredefined->TotalTimeNotSimpleASH55EitherForABUPS, 2);
    9508              : 
    9509           44 :         if (ort->displayTabularBEPS) {
    9510           44 :             if (produceTabular) {
    9511           42 :                 WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
    9512              :             }
    9513           44 :             if (produceSQLite) {
    9514           42 :                 if (state.dataSQLiteProcedures->sqlite) {
    9515            7 :                     state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(tableBody,
    9516              :                                                                                        rowHead,
    9517              :                                                                                        columnHead,
    9518              :                                                                                        "AnnualBuildingUtilityPerformanceSummary",
    9519              :                                                                                        "Entire Facility",
    9520              :                                                                                        "Comfort and Setpoint Not Met Summary");
    9521              :                 }
    9522              :             }
    9523           44 :             if (produceTabular) {
    9524           42 :                 if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
    9525            0 :                     state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(tableBody,
    9526              :                                                                                                           rowHead,
    9527              :                                                                                                           columnHead,
    9528              :                                                                                                           "AnnualBuildingUtilityPerformanceSummary",
    9529              :                                                                                                           "Entire Facility",
    9530              :                                                                                                           "Comfort and Setpoint Not Met Summary");
    9531              :                 }
    9532              :             }
    9533              :         }
    9534              :     }
    9535              :     //---- Control Summary Sub-Table
    9536              : 
    9537              :     //---- End Notes
    9538           42 :     if (ort->displayTabularBEPS) {
    9539           84 :         WriteTextLine(state, "Note 1: An asterisk (*) indicates that the feature is not yet implemented.");
    9540              :     }
    9541           42 : }
    9542              : 
    9543            8 : std::string ResourceWarningMessage(std::string const &resource)
    9544              : {
    9545            8 :     return "In the Annual Building Utility Performance Summary Report the total row does not match the sum of the column for: " + resource;
    9546              : }
    9547              : 
    9548           49 : Real64 WaterConversionFunct(Real64 WaterTotal, Real64 ConversionFactor)
    9549              : {
    9550           49 :     return WaterTotal / ConversionFactor;
    9551              : }
    9552              : 
    9553           88 : void writeBEPSEndUseBySubCatOrSpaceType(EnergyPlusData &state,
    9554              :                                         EndUseSubTableType tableType,
    9555              :                                         Array2D<Real64> &endUseSubOther,
    9556              :                                         Array2D<Real64> &collapsedEndUse,
    9557              :                                         Array3D<Real64> &collapsedEndUseSubTable,
    9558              :                                         Array1D_bool &needOtherRow,
    9559              :                                         const UnitsStyle unitsStyle_cur,
    9560              :                                         const bool produceTabular,
    9561              :                                         const bool produceSQLite)
    9562              : {
    9563           88 :     auto const &ort = state.dataOutRptTab;
    9564           88 :     auto &op = state.dataOutputProcessor;
    9565           88 :     constexpr int numCol = 15;
    9566           88 :     Array1D_string columnHead;
    9567           88 :     Array1D_int columnWidth;
    9568           88 :     columnHead.allocate(numCol);
    9569           88 :     columnWidth.allocate(numCol);
    9570         1408 :     for (int col = 1; col <= numCol; ++col) {
    9571         1320 :         columnWidth(col) = 10; // array assignment - same for all columns
    9572              :     }
    9573           88 :     switch (unitsStyle_cur) {
    9574            8 :     case UnitsStyle::JtoKWH: {
    9575            8 :         columnHead(2) = "Electricity [kWh]";
    9576            8 :         columnHead(3) = "Natural Gas [kWh]";
    9577            8 :         columnHead(4) = "Gasoline [kWh]";
    9578            8 :         columnHead(5) = "Diesel [kWh]";
    9579            8 :         columnHead(6) = "Coal [kWh]";
    9580            8 :         columnHead(7) = "Fuel Oil No 1 [kWh]";
    9581            8 :         columnHead(8) = "Fuel Oil No 2 [kWh]";
    9582            8 :         columnHead(9) = "Propane [kWh]";
    9583            8 :         columnHead(10) = "Other Fuel 1 [kWh]";
    9584            8 :         columnHead(11) = "Other Fuel 2 [kWh]";
    9585            8 :         columnHead(12) = "District Cooling [kWh]";
    9586            8 :         columnHead(13) = "District Heating Water [kWh]";
    9587            8 :         columnHead(14) = "District Heating Steam [kWh]";
    9588            8 :         columnHead(15) = "Water [m3]";
    9589            8 :     } break;
    9590            4 :     case UnitsStyle::InchPound: {
    9591            4 :         columnHead(2) = "Electricity [kBtu]";
    9592            4 :         columnHead(3) = "Natural Gas [kBtu]";
    9593            4 :         columnHead(4) = "Gasoline [kBtu]";
    9594            4 :         columnHead(5) = "Diesel [kBtu]";
    9595            4 :         columnHead(6) = "Coal [kBtu]";
    9596            4 :         columnHead(7) = "Fuel Oil No 1 [kBtu]";
    9597            4 :         columnHead(8) = "Fuel Oil No 2 [kBtu]";
    9598            4 :         columnHead(9) = "Propane [kBtu]";
    9599            4 :         columnHead(10) = "Other Fuel 1 [kBtu]";
    9600            4 :         columnHead(11) = "Other Fuel 2 [kBtu]";
    9601            4 :         columnHead(12) = "District Cooling [kBtu]";
    9602            4 :         columnHead(13) = "District Heating Water [kBtu]";
    9603            4 :         columnHead(14) = "District Heating Steam [kBtu]";
    9604            4 :         columnHead(15) = "Water [gal]";
    9605            4 :     } break;
    9606            2 :     case UnitsStyle::InchPoundExceptElectricity: {
    9607            2 :         columnHead(2) = "Electricity [kWh]";
    9608            2 :         columnHead(3) = "Natural Gas [kBtu]";
    9609            2 :         columnHead(4) = "Gasoline [kBtu]";
    9610            2 :         columnHead(5) = "Diesel [kBtu]";
    9611            2 :         columnHead(6) = "Coal [kBtu]";
    9612            2 :         columnHead(7) = "Fuel Oil No 1 [kBtu]";
    9613            2 :         columnHead(8) = "Fuel Oil No 2 [kBtu]";
    9614            2 :         columnHead(9) = "Propane [kBtu]";
    9615            2 :         columnHead(10) = "Other Fuel 1 [kBtu]";
    9616            2 :         columnHead(11) = "Other Fuel 2 [kBtu]";
    9617            2 :         columnHead(12) = "District Cooling [kBtu]";
    9618            2 :         columnHead(13) = "District Heating Water [kBtu]";
    9619            2 :         columnHead(14) = "District Heating Steam [kBtu]";
    9620            2 :         columnHead(15) = "Water [gal]";
    9621            2 :     } break;
    9622           74 :     default: {
    9623           74 :         columnHead(2) = "Electricity [GJ]";
    9624           74 :         columnHead(3) = "Natural Gas [GJ]";
    9625           74 :         columnHead(4) = "Gasoline [GJ]";
    9626           74 :         columnHead(5) = "Diesel [GJ]";
    9627           74 :         columnHead(6) = "Coal [GJ]";
    9628           74 :         columnHead(7) = "Fuel Oil No 1 [GJ]";
    9629           74 :         columnHead(8) = "Fuel Oil No 2 [GJ]";
    9630           74 :         columnHead(9) = "Propane [GJ]";
    9631           74 :         columnHead(10) = "Other Fuel 1 [GJ]";
    9632           74 :         columnHead(11) = "Other Fuel 2 [GJ]";
    9633           74 :         columnHead(12) = "District Cooling [GJ]";
    9634           74 :         columnHead(13) = "District Heating Water [GJ]";
    9635           74 :         columnHead(14) = "District Heating Steam [GJ]";
    9636           74 :         columnHead(15) = "Water [m3]";
    9637           74 :     } break;
    9638              :     }
    9639              : 
    9640           88 :     int numSubCatOrTypes = 0;
    9641           88 :     int numRows = 0;
    9642           88 :     if (tableType == EndUseSubTableType::BySubCategory) {
    9643           44 :         columnHead(1) = "Subcategory";
    9644           44 :     } else if (tableType == EndUseSubTableType::BySpaceType) {
    9645           44 :         columnHead(1) = "Space Type";
    9646              :     }
    9647              : 
    9648              :     // determine number of rows and if subcategories add up to the total
    9649              :     // if not, determine the difference for the 'other' row
    9650         1320 :     for (int i = 1; i <= static_cast<int>(Constant::EndUse::Num); ++i) {
    9651         1232 :         needOtherRow(i) = false; // set array to all false assuming no other rows are needed
    9652              :     }
    9653         1320 :     for (int iResource = 1; iResource <= 14; ++iResource) {
    9654        18480 :         for (int jEndUse = 1; jEndUse <= static_cast<int>(Constant::EndUse::Num); ++jEndUse) {
    9655        17248 :             if (tableType == EndUseSubTableType::BySubCategory) {
    9656         8624 :                 numSubCatOrTypes = op->EndUseCategory(jEndUse).NumSubcategories;
    9657         8624 :             } else if (tableType == EndUseSubTableType::BySpaceType) {
    9658         8624 :                 numSubCatOrTypes = op->EndUseCategory(jEndUse).numSpaceTypes;
    9659              :             }
    9660        17248 :             if (numSubCatOrTypes > 0) {
    9661              :                 // set the value to the total for the end use
    9662         2786 :                 endUseSubOther(iResource, jEndUse) = collapsedEndUse(iResource, jEndUse);
    9663              :                 // subtract off each sub end use category value
    9664         5656 :                 for (int kEndUseSub = 1; kEndUseSub <= numSubCatOrTypes; ++kEndUseSub) {
    9665         2870 :                     endUseSubOther(iResource, jEndUse) -= collapsedEndUseSubTable(kEndUseSub, jEndUse, iResource);
    9666              :                 }
    9667              :                 // if just a small value remains set it to zero
    9668         2786 :                 if (std::abs(endUseSubOther(iResource, jEndUse)) > 0.01) {
    9669            0 :                     needOtherRow(jEndUse) = true;
    9670              :                 } else {
    9671         2786 :                     endUseSubOther(iResource, jEndUse) = 0.0;
    9672              :                 }
    9673              :             } else {
    9674        14462 :                 endUseSubOther(iResource, jEndUse) = 0.0;
    9675              :             }
    9676              :         }
    9677              :     }
    9678              : 
    9679         1320 :     for (int jEndUse = 1; jEndUse <= static_cast<int>(Constant::EndUse::Num); ++jEndUse) {
    9680         1232 :         if (tableType == EndUseSubTableType::BySubCategory) {
    9681          616 :             numSubCatOrTypes = op->EndUseCategory(jEndUse).NumSubcategories;
    9682          616 :         } else if (tableType == EndUseSubTableType::BySpaceType) {
    9683          616 :             numSubCatOrTypes = op->EndUseCategory(jEndUse).numSpaceTypes;
    9684              :         }
    9685         1232 :         if (numSubCatOrTypes > 0) {
    9686          404 :             for (int kEndUseSub = 1; kEndUseSub <= numSubCatOrTypes; ++kEndUseSub) {
    9687          205 :                 ++numRows;
    9688              :             }
    9689          199 :             if (needOtherRow(jEndUse)) {
    9690            0 :                 ++numRows;
    9691              :             }
    9692              :         } else {
    9693         1033 :             ++numRows;
    9694              :         }
    9695              :     }
    9696              :     // all arrays are in the format: (row, column)
    9697          176 :     Array1D_string rowHead;
    9698          176 :     Array2D_string tableBody;
    9699           88 :     rowHead.allocate(numRows);
    9700           88 :     tableBody.allocate(numCol, numRows); // TODO: this appears to be (column, row)...
    9701         1408 :     for (int col = 1; col <= numCol; ++col) {
    9702        19890 :         for (int row = 1; row <= numRows; ++row) {
    9703        18570 :             rowHead(row) = "";
    9704        18570 :             tableBody(col, row) = "";
    9705              :         }
    9706              :     }
    9707              : 
    9708              :     // Build row head and subcategories columns
    9709              :     {
    9710           88 :         int i = 1;
    9711         1320 :         for (int jEndUse = 1; jEndUse <= static_cast<int>(Constant::EndUse::Num); ++jEndUse) {
    9712         1232 :             if (tableType == EndUseSubTableType::BySubCategory) {
    9713          616 :                 numSubCatOrTypes = op->EndUseCategory(jEndUse).NumSubcategories;
    9714          616 :             } else if (tableType == EndUseSubTableType::BySpaceType) {
    9715          616 :                 numSubCatOrTypes = op->EndUseCategory(jEndUse).numSpaceTypes;
    9716              :             }
    9717         1232 :             rowHead(i) = op->EndUseCategory(jEndUse).DisplayName;
    9718         1232 :             if (numSubCatOrTypes > 0) {
    9719          404 :                 for (int kEndUseSub = 1; kEndUseSub <= numSubCatOrTypes; ++kEndUseSub) {
    9720          205 :                     if (tableType == EndUseSubTableType::BySubCategory) {
    9721          181 :                         tableBody(1, i) = op->EndUseCategory(jEndUse).SubcategoryName(kEndUseSub);
    9722           24 :                     } else if (tableType == EndUseSubTableType::BySpaceType) {
    9723           24 :                         tableBody(1, i) = op->EndUseCategory(jEndUse).spaceTypeName(kEndUseSub);
    9724              :                     }
    9725          205 :                     ++i;
    9726              :                 }
    9727              :                 // check if an 'other' row is needed
    9728          199 :                 if (needOtherRow(jEndUse)) {
    9729            0 :                     tableBody(1, i) = "Other";
    9730            0 :                     ++i;
    9731              :                 }
    9732              :             } else {
    9733         1033 :                 if (tableType == EndUseSubTableType::BySubCategory) {
    9734          441 :                     tableBody(1, i) = "General";
    9735          592 :                 } else if (tableType == EndUseSubTableType::BySpaceType) {
    9736          592 :                     tableBody(1, i) = "Unassigned";
    9737              :                 }
    9738         1033 :                 ++i;
    9739              :             }
    9740              :         }
    9741              :     }
    9742              : 
    9743         1320 :     for (int iResource = 1; iResource <= 14; ++iResource) {
    9744         1232 :         int i = 1;
    9745        18480 :         for (int jEndUse = 1; jEndUse <= static_cast<int>(Constant::EndUse::Num); ++jEndUse) {
    9746        17248 :             if (tableType == EndUseSubTableType::BySubCategory) {
    9747         8624 :                 numSubCatOrTypes = op->EndUseCategory(jEndUse).NumSubcategories;
    9748         8624 :             } else if (tableType == EndUseSubTableType::BySpaceType) {
    9749         8624 :                 numSubCatOrTypes = op->EndUseCategory(jEndUse).numSpaceTypes;
    9750              :             }
    9751        17248 :             if (numSubCatOrTypes > 0) {
    9752         5656 :                 for (int kEndUseSub = 1; kEndUseSub <= numSubCatOrTypes; ++kEndUseSub) {
    9753         2870 :                     tableBody(iResource + 1, i) = RealToStr(collapsedEndUseSubTable(kEndUseSub, jEndUse, iResource), 2);
    9754         2870 :                     ++i;
    9755              :                 }
    9756              :                 // put other
    9757         2786 :                 if (needOtherRow(jEndUse)) {
    9758            0 :                     tableBody(iResource + 1, i) = RealToStr(endUseSubOther(iResource, jEndUse), 2);
    9759            0 :                     ++i;
    9760              :                 }
    9761              :             } else {
    9762        14462 :                 tableBody(iResource + 1, i) = RealToStr(collapsedEndUse(iResource, jEndUse), 2);
    9763        14462 :                 ++i;
    9764              :             }
    9765              :         }
    9766              :     }
    9767              : 
    9768              :     // heading for the entire sub-table
    9769           88 :     if (ort->displayTabularBEPS) {
    9770           88 :         std::string subTableTitle;
    9771           88 :         if (tableType == EndUseSubTableType::BySubCategory) {
    9772           44 :             subTableTitle = "End Uses By Subcategory";
    9773           44 :         } else if (tableType == EndUseSubTableType::BySpaceType) {
    9774           44 :             subTableTitle = "End Uses By Space Type";
    9775              :         }
    9776           88 :         if (produceTabular) {
    9777           84 :             WriteSubtitle(state, subTableTitle);
    9778           84 :             WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
    9779              :         }
    9780           88 :         Array1D_string rowHeadTemp(rowHead);
    9781              :         // Before outputting to SQL, we forward fill the End use column (rowHead)
    9782              :         // for better sql queries
    9783           88 :         FillRowHead(rowHeadTemp);
    9784              : 
    9785         1326 :         for (int i = 1; i <= numRows; ++i) {
    9786         1238 :             rowHeadTemp(i) = rowHeadTemp(i) + ":" + tableBody(1, i);
    9787              :         }
    9788              : 
    9789              :         // Erase the SubCategory (first column), using slicing
    9790          616 :         Array2D_string tableBodyTemp(tableBody({2, _, _}, {_, _, _}));
    9791          352 :         Array1D_string columnHeadTemp(columnHead({2, _, _}));
    9792           88 :         if (produceSQLite) {
    9793           84 :             if (state.dataSQLiteProcedures->sqlite) {
    9794           14 :                 state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
    9795              :                     tableBodyTemp, rowHeadTemp, columnHeadTemp, "AnnualBuildingUtilityPerformanceSummary", "Entire Facility", subTableTitle);
    9796              :             }
    9797              :         }
    9798           88 :         if (produceTabular) {
    9799           84 :             if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
    9800            0 :                 state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(
    9801              :                     tableBodyTemp, rowHeadTemp, columnHeadTemp, "AnnualBuildingUtilityPerformanceSummary", "Entire Facility", subTableTitle);
    9802              :             }
    9803              :         }
    9804           88 :         rowHeadTemp.deallocate();
    9805           88 :         tableBodyTemp.deallocate();
    9806           88 :         columnHeadTemp.deallocate();
    9807           88 :     }
    9808          264 : }
    9809           41 : void WriteSourceEnergyEndUseSummary(EnergyPlusData &state)
    9810              : {
    9811              :     // SUBROUTINE INFORMATION:
    9812              :     //       AUTHOR         Mangesh Basarkar
    9813              :     //       DATE WRITTEN   September 2011
    9814              :     //       MODIFIED       March 2020, Dareum Nam; Disaggregated "Additional Fuel"
    9815              :     //       RE-ENGINEERED  na
    9816              : 
    9817              :     // PURPOSE OF THIS SUBROUTINE:
    9818              :     //   Take the gathered total and end use source energy meter data and structure
    9819              :     //   the results into a tabular report for output.
    9820              : 
    9821              :     // METHODOLOGY EMPLOYED:
    9822              :     //   Create arrays for the call to WriteTable and then call it.
    9823              : 
    9824           41 :     auto &ort = state.dataOutRptTab;
    9825              : 
    9826           41 :     if (!ort->displaySourceEnergyEndUseSummary) {
    9827            0 :         return;
    9828              :     }
    9829              : 
    9830              :     // all arrays are in the format: (row, column)
    9831           41 :     Array1D_string columnHead;
    9832           41 :     Array1D_int columnWidth;
    9833           41 :     Array1D_string rowHead;
    9834           41 :     Array2D_string tableBody;
    9835              : 
    9836              :     // all arrays are in the format: (row, columnm)
    9837           41 :     Array2D<Real64> useVal(14, 15);
    9838           41 :     Array1D<Real64> collapsedTotal(14);
    9839           41 :     Array2D<Real64> collapsedEndUse(14, static_cast<int>(Constant::EndUse::Num));
    9840           41 :     Array3D<Real64> collapsedEndUseSub(state.dataOutputProcessor->MaxNumSubcategories, static_cast<int>(Constant::EndUse::Num), 14);
    9841              : 
    9842              :     // show the headers of the report
    9843          123 :     WriteReportHeaders(state, "Source Energy End Use Components Summary", "Entire Facility", OutputProcessor::StoreType::Average);
    9844              :     // show the number of hours that the table applies to
    9845           41 :     WriteTextLine(state, "Values gathered over " + RealToStr(ort->gatherElapsedTimeBEPS, 2) + " hours", true);
    9846           41 :     if (ort->gatherElapsedTimeBEPS < 8759.0) { // might not add up to 8760 exactly but can't be more than 1 hour diff.
    9847           82 :         WriteTextLine(state, "WARNING: THE REPORT DOES NOT REPRESENT A FULL ANNUAL SIMULATION.", true);
    9848              :     }
    9849           41 :     WriteTextLine(state, "", true);
    9850              : 
    9851              :     // determine building floor areas
    9852           41 :     DetermineBuildingFloorArea(state);
    9853              : 
    9854           83 :     for (int iUnitSystem = 0; iUnitSystem <= 1; iUnitSystem++) {
    9855           82 :         UnitsStyle unitsStyle_cur = ort->unitsStyle;
    9856           82 :         bool produceTabular = true;
    9857           82 :         bool produceSQLite = false;
    9858           82 :         if (produceDualUnitsFlags(iUnitSystem, ort->unitsStyle, ort->unitsStyle_SQLite, unitsStyle_cur, produceTabular, produceSQLite)) {
    9859           40 :             break;
    9860              :         }
    9861              : 
    9862              :         // collapse the gatherEndUseBEPS array to the resource groups displayed
    9863          630 :         for (int jEndUse = 1; jEndUse <= static_cast<int>(Constant::EndUse::Num); ++jEndUse) {
    9864          588 :             collapsedEndUse(1, jEndUse) = ort->gatherEndUseBySourceBEPS(1, jEndUse);   // electricity
    9865          588 :             collapsedEndUse(2, jEndUse) = ort->gatherEndUseBySourceBEPS(2, jEndUse);   // natural gas
    9866          588 :             collapsedEndUse(3, jEndUse) = ort->gatherEndUseBySourceBEPS(6, jEndUse);   // gasoline
    9867          588 :             collapsedEndUse(4, jEndUse) = ort->gatherEndUseBySourceBEPS(8, jEndUse);   // diesel
    9868          588 :             collapsedEndUse(5, jEndUse) = ort->gatherEndUseBySourceBEPS(9, jEndUse);   // coal
    9869          588 :             collapsedEndUse(6, jEndUse) = ort->gatherEndUseBySourceBEPS(10, jEndUse);  // Fuel Oil No1
    9870          588 :             collapsedEndUse(7, jEndUse) = ort->gatherEndUseBySourceBEPS(11, jEndUse);  // Fuel Oil No2
    9871          588 :             collapsedEndUse(8, jEndUse) = ort->gatherEndUseBySourceBEPS(12, jEndUse);  // propane
    9872          588 :             collapsedEndUse(9, jEndUse) = ort->gatherEndUseBySourceBEPS(13, jEndUse);  // otherfuel1
    9873          588 :             collapsedEndUse(10, jEndUse) = ort->gatherEndUseBySourceBEPS(14, jEndUse); // otherfuel2
    9874          588 :             collapsedEndUse(11, jEndUse) = ort->gatherEndUseBySourceBEPS(3, jEndUse);  // district cooling <- purchased cooling
    9875          588 :             collapsedEndUse(12, jEndUse) = ort->gatherEndUseBySourceBEPS(4, jEndUse);  // district heating water <- purchased heating
    9876          588 :             collapsedEndUse(13, jEndUse) = ort->gatherEndUseBySourceBEPS(5, jEndUse);  // district heating steam <- purchased heating
    9877          588 :             collapsedEndUse(14, jEndUse) = ort->gatherEndUseBySourceBEPS(7, jEndUse);  // water
    9878              :         }
    9879              :         // repeat with totals
    9880           42 :         collapsedTotal(1) = ort->gatherTotalsBySourceBEPS(1);   // electricity
    9881           42 :         collapsedTotal(2) = ort->gatherTotalsBySourceBEPS(2);   // natural gas
    9882           42 :         collapsedTotal(3) = ort->gatherTotalsBySourceBEPS(6);   // gasoline
    9883           42 :         collapsedTotal(4) = ort->gatherTotalsBySourceBEPS(8);   // diesel
    9884           42 :         collapsedTotal(5) = ort->gatherTotalsBySourceBEPS(9);   // coal
    9885           42 :         collapsedTotal(6) = ort->gatherTotalsBySourceBEPS(10);  // Fuel Oil No1
    9886           42 :         collapsedTotal(7) = ort->gatherTotalsBySourceBEPS(11);  // Fuel Oil No2
    9887           42 :         collapsedTotal(8) = ort->gatherTotalsBySourceBEPS(12);  // propane
    9888           42 :         collapsedTotal(9) = ort->gatherTotalsBySourceBEPS(13);  // otherfuel1
    9889           42 :         collapsedTotal(10) = ort->gatherTotalsBySourceBEPS(14); // otherfuel2
    9890           42 :         collapsedTotal(11) = ort->gatherTotalsBySourceBEPS(3);  // district cooling <- purchased cooling
    9891           42 :         collapsedTotal(12) = ort->gatherTotalsBySourceBEPS(4);  // district heating water <- purchased heating
    9892           42 :         collapsedTotal(13) = ort->gatherTotalsBySourceBEPS(5);  // district heating steam <- purchased heating
    9893           42 :         collapsedTotal(14) = ort->gatherTotalsBySourceBEPS(7);  // water
    9894              : 
    9895              :         // unit conversion - all values are used as divisors
    9896              :         Real64 largeConversionFactor;
    9897              :         Real64 areaConversionFactor;
    9898           42 :         Real64 ipElectricityConversionFactor = 1.0;
    9899           42 :         switch (unitsStyle_cur) {
    9900            2 :         case UnitsStyle::JtoKWH: {
    9901            2 :             largeConversionFactor = 3600000.0;
    9902            2 :             areaConversionFactor = 1.0;
    9903            2 :         } break;
    9904            2 :         case UnitsStyle::InchPound: {
    9905            8 :             largeConversionFactor = getSpecificUnitDivider(state, "J", "kBtu"); // 1054351.84 J to kBtu
    9906            6 :             areaConversionFactor = getSpecificUnitDivider(state, "m2", "ft2");  // 0.092893973 m2 to ft2
    9907            2 :         } break;
    9908            1 :         case UnitsStyle::InchPoundExceptElectricity: {
    9909            4 :             largeConversionFactor = getSpecificUnitDivider(state, "J", "kBtu"); // 1054351.84 J to kBtu
    9910            3 :             areaConversionFactor = getSpecificUnitDivider(state, "m2", "ft2");  // 0.092893973 m2 to ft2
    9911            1 :             ipElectricityConversionFactor = largeConversionFactor / (1000.0 * 3600.0);
    9912            1 :         } break;
    9913           37 :         default: {
    9914           37 :             largeConversionFactor = 1000000.0; // to MJ
    9915           37 :             areaConversionFactor = 1.0;
    9916           37 :         } break;
    9917              :         }
    9918              : 
    9919              :         // convert units into MJ (divide by 1,000,000) if J otherwise kWh
    9920          588 :         for (int iResource = 1; iResource <= 13; ++iResource) { // don't do water
    9921          546 :             Real64 ipElectricityAdjust = (iResource == 1) ? ipElectricityConversionFactor : 1.0;
    9922         8190 :             for (int jEndUse = 1; jEndUse <= static_cast<int>(Constant::EndUse::Num); ++jEndUse) {
    9923         7644 :                 collapsedEndUse(iResource, jEndUse) /= (largeConversionFactor / ipElectricityAdjust);
    9924              :             }
    9925          546 :             collapsedTotal(iResource) /= (largeConversionFactor / ipElectricityAdjust);
    9926              :         }
    9927              : 
    9928           42 :         rowHead.allocate(16);
    9929           42 :         columnHead.allocate(13);
    9930           42 :         columnWidth.allocate(13);
    9931           42 :         columnWidth = 10; // array assignment - same for all columns
    9932           42 :         tableBody.allocate(13, 16);
    9933          630 :         for (int iResource = 1; iResource <= 14; ++iResource) {
    9934         8820 :             for (int iEndUse = 0; iEndUse < static_cast<int>(Constant::EndUse::Num); ++iEndUse) {
    9935         8232 :                 useVal(iResource, iEndUse + 1) = collapsedEndUse(iResource, iEndUse + 1);
    9936              :             }
    9937          588 :             useVal(iResource, 15) = collapsedTotal(iResource); // totals
    9938              :         }
    9939              : 
    9940           42 :         rowHead(static_cast<int>(Constant::EndUse::Heating) + 1) = "Heating";
    9941           42 :         rowHead(static_cast<int>(Constant::EndUse::Cooling) + 1) = "Cooling";
    9942           42 :         rowHead(static_cast<int>(Constant::EndUse::InteriorLights) + 1) = "Interior Lighting";
    9943           42 :         rowHead(static_cast<int>(Constant::EndUse::ExteriorLights) + 1) = "Exterior Lighting";
    9944           42 :         rowHead(static_cast<int>(Constant::EndUse::InteriorEquipment) + 1) = "Interior Equipment";
    9945           42 :         rowHead(static_cast<int>(Constant::EndUse::ExteriorEquipment) + 1) = "Exterior Equipment";
    9946           42 :         rowHead(static_cast<int>(Constant::EndUse::Fans) + 1) = "Fans";
    9947           42 :         rowHead(static_cast<int>(Constant::EndUse::Pumps) + 1) = "Pumps";
    9948           42 :         rowHead(static_cast<int>(Constant::EndUse::HeatRejection) + 1) = "Heat Rejection";
    9949           42 :         rowHead(static_cast<int>(Constant::EndUse::Humidification) + 1) = "Humidification";
    9950           42 :         rowHead(static_cast<int>(Constant::EndUse::HeatRecovery) + 1) = "Heat Recovery";
    9951           42 :         rowHead(static_cast<int>(Constant::EndUse::WaterSystem) + 1) = "Water Systems";
    9952           42 :         rowHead(static_cast<int>(Constant::EndUse::Refrigeration) + 1) = "Refrigeration";
    9953           42 :         rowHead(static_cast<int>(Constant::EndUse::Cogeneration) + 1) = "Generators";
    9954           42 :         rowHead(15) = "";
    9955           42 :         rowHead(16) = "Total Source Energy End Use Components";
    9956              : 
    9957           42 :         largeConversionFactor = 1.0;
    9958              : 
    9959           42 :         switch (unitsStyle_cur) {
    9960            2 :         case UnitsStyle::JtoKWH: {
    9961            2 :             columnHead(1) = "Source Electricity [kWh]";
    9962            2 :             columnHead(2) = "Source Natural Gas [kWh]";
    9963            2 :             columnHead(3) = "Source Gasoline [kWh]";
    9964            2 :             columnHead(4) = "Source Diesel [kWh]";
    9965            2 :             columnHead(5) = "Source Coal [kWh]";
    9966            2 :             columnHead(6) = "Source Fuel Oil No 1 [kWh]";
    9967            2 :             columnHead(7) = "Source Fuel Oil No 2 [kWh]";
    9968            2 :             columnHead(8) = "Source Propane [kWh]";
    9969            2 :             columnHead(9) = "Source Other Fuel 1 [kWh]";
    9970            2 :             columnHead(10) = "Source Other Fuel 2 [kWh]";
    9971            2 :             columnHead(11) = "Source District Cooling [kWh]";
    9972            2 :             columnHead(12) = "Source District Heating Water [kWh]";
    9973            2 :             columnHead(13) = "Source District Heating Steam [kWh]";
    9974            2 :         } break;
    9975            2 :         case UnitsStyle::InchPound: {
    9976            2 :             columnHead(1) = "Source Electricity [kBtu]";
    9977            2 :             columnHead(2) = "Source Natural Gas [kBtu]";
    9978            2 :             columnHead(3) = "Source Gasoline [kBtu]";
    9979            2 :             columnHead(4) = "Source Diesel [kBtu]";
    9980            2 :             columnHead(5) = "Source Coal [kBtu]";
    9981            2 :             columnHead(6) = "Source Fuel Oil No 1 [kBtu]";
    9982            2 :             columnHead(7) = "Source Fuel Oil No 2 [kBtu]";
    9983            2 :             columnHead(8) = "Source Propane [kBtu]";
    9984            2 :             columnHead(9) = "Source Other Fuel 1 [kBtu]";
    9985            2 :             columnHead(10) = "Source Other Fuel 2 [kBtu]";
    9986            2 :             columnHead(11) = "Source District Cooling [kBtu]";
    9987            2 :             columnHead(12) = "Source District Heating Water [kBtu]";
    9988            2 :             columnHead(13) = "Source District Heating Steam [kBtu]";
    9989            2 :         } break;
    9990            1 :         case UnitsStyle::InchPoundExceptElectricity: {
    9991            1 :             columnHead(1) = "Source Electricity [kWh]";
    9992            1 :             columnHead(2) = "Source Natural Gas [kBtu]";
    9993            1 :             columnHead(3) = "Source Gasoline [kBtu]";
    9994            1 :             columnHead(4) = "Source Diesel [kBtu]";
    9995            1 :             columnHead(5) = "Source Coal [kBtu]";
    9996            1 :             columnHead(6) = "Source Fuel Oil No 1 [kBtu]";
    9997            1 :             columnHead(7) = "Source Fuel Oil No 2 [kBtu]";
    9998            1 :             columnHead(8) = "Source Propane [kBtu]";
    9999            1 :             columnHead(9) = "Source Other Fuel 1 [kBtu]";
   10000            1 :             columnHead(10) = "Source Other Fuel 2 [kBtu]";
   10001            1 :             columnHead(11) = "Source District Cooling [kBtu]";
   10002            1 :             columnHead(12) = "Source District Heating Water [kBtu]";
   10003            1 :             columnHead(13) = "Source District Heating Steam [kBtu]";
   10004            1 :         } break;
   10005           37 :         default: {
   10006           37 :             columnHead(1) = "Source Electricity [GJ]";
   10007           37 :             columnHead(2) = "Source Natural Gas [GJ]";
   10008           37 :             columnHead(3) = "Source Gasoline [GJ]";
   10009           37 :             columnHead(4) = "Source Diesel [GJ]";
   10010           37 :             columnHead(5) = "Source Coal [GJ]";
   10011           37 :             columnHead(6) = "Source Fuel Oil No 1 [GJ]";
   10012           37 :             columnHead(7) = "Source Fuel Oil No 2 [GJ]";
   10013           37 :             columnHead(8) = "Source Propane [GJ]";
   10014           37 :             columnHead(9) = "Source Other Fuel 1 [GJ]";
   10015           37 :             columnHead(10) = "Source Other Fuel 2 [GJ]";
   10016           37 :             columnHead(11) = "Source District Cooling [GJ]";
   10017           37 :             columnHead(12) = "Source District Heating Water [GJ]";
   10018           37 :             columnHead(13) = "Source District Heating Steam [GJ]";
   10019           37 :             largeConversionFactor = 1000.0; // for converting MJ to GJ
   10020           37 :         } break;
   10021              :         }
   10022              : 
   10023              :         //---- End Uses by Source Energy Sub-Table
   10024              : 
   10025           42 :         tableBody = "";
   10026          588 :         for (int iResource = 1; iResource <= 13; ++iResource) {
   10027         8190 :             for (int jEndUse = 1; jEndUse <= static_cast<int>(Constant::EndUse::Num); ++jEndUse) {
   10028         7644 :                 tableBody(iResource, jEndUse) = RealToStr(useVal(iResource, jEndUse) / largeConversionFactor, 2);
   10029              :             }
   10030          546 :             tableBody(iResource, 16) = RealToStr(useVal(iResource, 15) / largeConversionFactor, 2);
   10031              :         }
   10032              : 
   10033              :         // heading for the entire sub-table
   10034           42 :         if (produceTabular) {
   10035           41 :             WriteSubtitle(state, "Source Energy End Use Components Summary");
   10036           41 :             WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
   10037              :         }
   10038           42 :         if (produceSQLite) {
   10039           41 :             if (state.dataSQLiteProcedures->sqlite) {
   10040            6 :                 state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(tableBody,
   10041              :                                                                                    rowHead,
   10042              :                                                                                    columnHead,
   10043              :                                                                                    "SourceEnergyEndUseComponentsSummary",
   10044              :                                                                                    "Entire Facility",
   10045              :                                                                                    "Source Energy End Use Components Summary");
   10046              :             }
   10047              :         }
   10048           42 :         if (produceTabular) {
   10049           41 :             if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
   10050            0 :                 state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(tableBody,
   10051              :                                                                                                       rowHead,
   10052              :                                                                                                       columnHead,
   10053              :                                                                                                       "SourceEnergyEndUseComponentsSummary",
   10054              :                                                                                                       "Entire Facility",
   10055              :                                                                                                       "Source Energy End Use Components Summary");
   10056              :             }
   10057              :         }
   10058              : 
   10059              :         // Normalized by Area tables
   10060              : 
   10061           42 :         switch (unitsStyle_cur) {
   10062            2 :         case UnitsStyle::JtoKWH: {
   10063            2 :             columnHead(1) = "Source Electricity [kWh/m2]";
   10064            2 :             columnHead(2) = "Source Natural Gas [kWh/m2]";
   10065            2 :             columnHead(3) = "Source Gasoline [kWh/m2]";
   10066            2 :             columnHead(4) = "Source Diesel [kWh/m2]";
   10067            2 :             columnHead(5) = "Source Coal [kWh/m2]";
   10068            2 :             columnHead(6) = "Source Fuel Oil No 1 [kWh/m2]";
   10069            2 :             columnHead(7) = "Source Fuel Oil No 2 [kWh/m2]";
   10070            2 :             columnHead(8) = "Source Propane [kWh/m2]";
   10071            2 :             columnHead(9) = "Source Other Fuel 1 [kWh/m2]";
   10072            2 :             columnHead(10) = "Source Other Fuel 2 [kWh/m2]";
   10073            2 :             columnHead(11) = "Source District Cooling [kWh/m2]";
   10074            2 :             columnHead(12) = "Source District Heating Water [kWh/m2]";
   10075            2 :             columnHead(13) = "Source District Heating Steam [kWh/m2]";
   10076            2 :         } break;
   10077            2 :         case UnitsStyle::InchPound: {
   10078            2 :             columnHead(1) = "Source Electricity [kBtu/ft2]";
   10079            2 :             columnHead(2) = "Source Natural Gas [kBtu/ft2]";
   10080            2 :             columnHead(3) = "Source Gasoline [kBtu/ft2]";
   10081            2 :             columnHead(4) = "Source Diesel [kBtu/ft2]";
   10082            2 :             columnHead(5) = "Source Coal [kBtu/ft2]";
   10083            2 :             columnHead(6) = "Source Fuel Oil No 1 [kBtu/ft2]";
   10084            2 :             columnHead(7) = "Source Fuel Oil No 2 [kBtu/ft2]";
   10085            2 :             columnHead(8) = "Source Propane [kBtu/ft2]";
   10086            2 :             columnHead(9) = "Source Other Fuel 1 [kBtu/ft2]";
   10087            2 :             columnHead(10) = "Source Other Fuel 2 [kBtu/ft2]";
   10088            2 :             columnHead(11) = "Source District Cooling [kBtu/ft2]";
   10089            2 :             columnHead(12) = "Source District Heating Water [kBtu/ft2]";
   10090            2 :             columnHead(13) = "Source District Heating Steam [kBtu/ft2]";
   10091            2 :         } break;
   10092            1 :         case UnitsStyle::InchPoundExceptElectricity: {
   10093            1 :             columnHead(1) = "Source Electricity [kWh/ft2]";
   10094            1 :             columnHead(2) = "Source Natural Gas [kBtu/ft2]";
   10095            1 :             columnHead(3) = "Source Gasoline [kBtu/ft2]";
   10096            1 :             columnHead(4) = "Source Diesel [kBtu/ft2]";
   10097            1 :             columnHead(5) = "Source Coal [kBtu/ft2]";
   10098            1 :             columnHead(6) = "Source Fuel Oil No 1 [kBtu/ft2]";
   10099            1 :             columnHead(7) = "Source Fuel Oil No 2 [kBtu/ft2]";
   10100            1 :             columnHead(8) = "Source Propane [kBtu/ft2]";
   10101            1 :             columnHead(9) = "Source Other Fuel 1 [kBtu/ft2]";
   10102            1 :             columnHead(10) = "Source Other Fuel 2 [kBtu/ft2]";
   10103            1 :             columnHead(11) = "Source District Cooling [kBtu/ft2]";
   10104            1 :             columnHead(12) = "Source District Heating Water [kBtu/ft2]";
   10105            1 :             columnHead(13) = "Source District Heating Steam [kBtu/ft2]";
   10106            1 :         } break;
   10107           37 :         default: {
   10108           37 :             columnHead(1) = "Source Electricity [MJ/m2]";
   10109           37 :             columnHead(2) = "Source Natural Gas [MJ/m2]";
   10110           37 :             columnHead(3) = "Source Gasoline [MJ/m2]";
   10111           37 :             columnHead(4) = "Source Diesel [MJ/m2]";
   10112           37 :             columnHead(5) = "Source Coal [MJ/m2]";
   10113           37 :             columnHead(6) = "Source Fuel Oil No 1 [MJ/m2]";
   10114           37 :             columnHead(7) = "Source Fuel Oil No 2 [MJ/m2]";
   10115           37 :             columnHead(8) = "Source Propane [MJ/m2]";
   10116           37 :             columnHead(9) = "Source Other Fuel 1 [MJ/m2]";
   10117           37 :             columnHead(10) = "Source Other Fuel 2 [MJ/m2]";
   10118           37 :             columnHead(11) = "Source District Cooling [MJ/m2]";
   10119           37 :             columnHead(12) = "Source District Heating Water [MJ/m2]";
   10120           37 :             columnHead(13) = "Source District Heating Steam [MJ/m2]";
   10121           37 :         } break;
   10122              :         }
   10123              : 
   10124              :         //---- Normalized by Conditioned Area Sub-Table
   10125              :         {
   10126           42 :             tableBody = "";
   10127              :             // convert floor area
   10128           42 :             Real64 convBldgCondFloorArea = ort->buildingConditionedFloorArea / areaConversionFactor;
   10129           42 :             if (convBldgCondFloorArea > 0) {
   10130          252 :                 for (int iResource = 1; iResource <= 13; ++iResource) {
   10131         3510 :                     for (int jEndUse = 1; jEndUse <= static_cast<int>(Constant::EndUse::Num); ++jEndUse) {
   10132         3276 :                         tableBody(iResource, jEndUse) = RealToStr(useVal(iResource, jEndUse) / convBldgCondFloorArea, 2);
   10133              :                     }
   10134          234 :                     tableBody(iResource, 16) = RealToStr(useVal(iResource, 15) / convBldgCondFloorArea, 2);
   10135              :                 }
   10136              :             }
   10137              : 
   10138           42 :             if (produceTabular) {
   10139           82 :                 WriteTextLine(state, "Normalized Metrics", true);
   10140              : 
   10141              :                 // heading for the entire sub-table
   10142           41 :                 WriteSubtitle(state, "Source Energy End Use Components Per Conditioned Floor Area");
   10143           41 :                 WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
   10144              :             }
   10145           42 :             if (produceSQLite) {
   10146           41 :                 if (state.dataSQLiteProcedures->sqlite) {
   10147            6 :                     state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(tableBody,
   10148              :                                                                                        rowHead,
   10149              :                                                                                        columnHead,
   10150              :                                                                                        "SourceEnergyEndUseComponentsSummary",
   10151              :                                                                                        "Entire Facility",
   10152              :                                                                                        "Source Energy End Use Components Per Conditioned Floor Area");
   10153              :                 }
   10154              :             }
   10155           42 :             if (produceTabular) {
   10156           41 :                 if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
   10157            0 :                     state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(
   10158              :                         tableBody,
   10159              :                         rowHead,
   10160              :                         columnHead,
   10161              :                         "SourceEnergyEndUseComponentsSummary",
   10162              :                         "Entire Facility",
   10163              :                         "Source Energy End Use Components Per Conditioned Floor Area");
   10164              :                 }
   10165              :             }
   10166              :         } // End of Normalized by Conditioned Area
   10167              : 
   10168              :         //---- Normalized by Total Area Sub-Table
   10169              :         {
   10170           42 :             tableBody = "";
   10171           42 :             Real64 convBldgGrossFloorArea = ort->buildingGrossFloorArea / areaConversionFactor;
   10172              : 
   10173           42 :             if (convBldgGrossFloorArea > 0) {
   10174          588 :                 for (int iResource = 1; iResource <= 13; ++iResource) {
   10175         8190 :                     for (int jEndUse = 1; jEndUse <= static_cast<int>(Constant::EndUse::Num); ++jEndUse) {
   10176         7644 :                         tableBody(iResource, jEndUse) = RealToStr(useVal(iResource, jEndUse) / convBldgGrossFloorArea, 2);
   10177              :                     }
   10178          546 :                     tableBody(iResource, 16) = RealToStr(useVal(iResource, 15) / convBldgGrossFloorArea, 2);
   10179              :                 }
   10180              :             }
   10181              : 
   10182              :             // heading for the entire sub-table
   10183           42 :             if (produceTabular) {
   10184           41 :                 WriteSubtitle(state, "Source Energy End Use Components Per Total Floor Area");
   10185           41 :                 WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
   10186              :             }
   10187           42 :             if (produceSQLite) {
   10188           41 :                 if (state.dataSQLiteProcedures->sqlite) {
   10189            6 :                     state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(tableBody,
   10190              :                                                                                        rowHead,
   10191              :                                                                                        columnHead,
   10192              :                                                                                        "SourceEnergyEndUseComponentsSummary",
   10193              :                                                                                        "Entire Facility",
   10194              :                                                                                        "Source Energy End Use Components Per Total Floor Area");
   10195              :                 }
   10196              :             }
   10197           42 :             if (produceTabular) {
   10198           41 :                 if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
   10199            0 :                     state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(
   10200              :                         tableBody,
   10201              :                         rowHead,
   10202              :                         columnHead,
   10203              :                         "SourceEnergyEndUseComponentsSummary",
   10204              :                         "Entire Facility",
   10205              :                         "Source Energy End Use Components Per Total Floor Area");
   10206              :                 }
   10207              :             }
   10208              :         } // End of Normalized by Total Area
   10209              :     } // End of Dual Units reporting
   10210           41 : }
   10211              : 
   10212           42 : void WriteDemandEndUseSummary(EnergyPlusData &state)
   10213              : {
   10214              :     // SUBROUTINE INFORMATION:
   10215              :     //       AUTHOR         Jason Glazer
   10216              :     //       DATE WRITTEN   January 2009
   10217              :     //       MODIFIED       January 2010, Kyle Benne; Added SQLite output
   10218              :     //                      March 2020, Dareum Nam; Disaggregated "Additional Fuel"
   10219              :     //       RE-ENGINEERED  na
   10220              : 
   10221              :     // PURPOSE OF THIS SUBROUTINE:
   10222              :     //   Take the gathered total and enduse meter data and structure
   10223              :     //   the results into a tabular report for output.
   10224              : 
   10225              :     // METHODOLOGY EMPLOYED:
   10226              :     //   Create arrays for the call to WriteTable and then call it.
   10227              :     //   This report actually consists of many sub-tables each with
   10228              :     //   its own call to WriteTable.
   10229              : 
   10230           42 :     auto &ort = state.dataOutRptTab;
   10231           42 :     auto &op = state.dataOutputProcessor;
   10232              : 
   10233           42 :     if (!ort->displayDemandEndUse) {
   10234            0 :         return;
   10235              :     }
   10236              : 
   10237              :     // all arrays are in the format: (row, column)
   10238           42 :     Array1D_string columnHead;
   10239           42 :     Array1D_int columnWidth;
   10240           42 :     Array1D_string rowHead;
   10241           42 :     Array2D_string tableBody;
   10242              : 
   10243              :     // all arrays are in the format: (row, column)
   10244           42 :     Array2D<Real64> useVal(14, 15);
   10245           42 :     Array1D<Real64> collapsedTotal(14);
   10246           42 :     Array2D<Real64> collapsedEndUse(14, static_cast<int>(Constant::EndUse::Num));
   10247           42 :     Array2D<Real64> collapsedIndEndUse(14, static_cast<int>(Constant::EndUse::Num));
   10248           42 :     Array1D_int collapsedTimeStep(14);
   10249           42 :     Array3D<Real64> collapsedEndUseSub(state.dataOutputProcessor->MaxNumSubcategories, static_cast<int>(Constant::EndUse::Num), 14);
   10250           42 :     Array3D<Real64> collapsedIndEndUseSub(state.dataOutputProcessor->MaxNumSubcategories, static_cast<int>(Constant::EndUse::Num), 14);
   10251           42 :     Array2D<Real64> endUseSubOther(14, static_cast<int>(Constant::EndUse::Num));
   10252              : 
   10253              :     // show the headers of the report
   10254          126 :     WriteReportHeaders(state, "Demand End Use Components Summary", "Entire Facility", OutputProcessor::StoreType::Average);
   10255              : 
   10256           42 :     Real64 ipElectricityConversion = 1.0; // declare here so that last one used is correct for LEED section
   10257           86 :     for (int iUnitSystem = 0; iUnitSystem <= 1; iUnitSystem++) {
   10258           84 :         UnitsStyle unitsStyle_cur = ort->unitsStyle;
   10259           84 :         bool produceTabular = true;
   10260           84 :         bool produceSQLite = false;
   10261           84 :         if (produceDualUnitsFlags(iUnitSystem, ort->unitsStyle, ort->unitsStyle_SQLite, unitsStyle_cur, produceTabular, produceSQLite)) {
   10262           40 :             break;
   10263              :         }
   10264              : 
   10265              :         // totals - select which additional fuel to display
   10266           44 :         collapsedTotal = 0.0;
   10267           44 :         collapsedTotal(1) = ort->gatherDemandTotal(1); // electricity
   10268           44 :         collapsedTimeStep(1) = ort->gatherDemandTimeStamp(1);
   10269           44 :         collapsedTotal(2) = ort->gatherDemandTotal(2); // natural gas
   10270           44 :         collapsedTimeStep(2) = ort->gatherDemandTimeStamp(2);
   10271           44 :         collapsedTotal(3) = ort->gatherDemandTotal(6); // gasoline
   10272           44 :         collapsedTimeStep(3) = ort->gatherDemandTimeStamp(6);
   10273           44 :         collapsedTotal(4) = ort->gatherDemandTotal(8); // diesel
   10274           44 :         collapsedTimeStep(4) = ort->gatherDemandTimeStamp(8);
   10275           44 :         collapsedTotal(5) = ort->gatherDemandTotal(9); // coal
   10276           44 :         collapsedTimeStep(5) = ort->gatherDemandTimeStamp(9);
   10277           44 :         collapsedTotal(6) = ort->gatherDemandTotal(10); // fuel oil no 1
   10278           44 :         collapsedTimeStep(6) = ort->gatherDemandTimeStamp(10);
   10279           44 :         collapsedTotal(7) = ort->gatherDemandTotal(11); // fuel oil no 2
   10280           44 :         collapsedTimeStep(7) = ort->gatherDemandTimeStamp(11);
   10281           44 :         collapsedTotal(8) = ort->gatherDemandTotal(12); // propane
   10282           44 :         collapsedTimeStep(8) = ort->gatherDemandTimeStamp(12);
   10283           44 :         collapsedTotal(9) = ort->gatherDemandTotal(13); // other fuel 1
   10284           44 :         collapsedTimeStep(9) = ort->gatherDemandTimeStamp(13);
   10285           44 :         collapsedTotal(10) = ort->gatherDemandTotal(14); // other fuel 2
   10286           44 :         collapsedTimeStep(10) = ort->gatherDemandTimeStamp(14);
   10287           44 :         collapsedTotal(11) = ort->gatherDemandTotal(3); // district cooling <- purchased cooling
   10288           44 :         collapsedTimeStep(11) = ort->gatherDemandTimeStamp(3);
   10289           44 :         collapsedTotal(12) = ort->gatherDemandTotal(4); // district heating water <- purchased heating
   10290           44 :         collapsedTimeStep(12) = ort->gatherDemandTimeStamp(4);
   10291           44 :         collapsedTotal(13) = ort->gatherDemandTotal(5); // district heating steam <- purchased heating
   10292           44 :         collapsedTimeStep(13) = ort->gatherDemandTimeStamp(5);
   10293           44 :         collapsedTotal(14) = ort->gatherDemandTotal(7); // water
   10294           44 :         collapsedTimeStep(14) = ort->gatherDemandTimeStamp(7);
   10295              : 
   10296           44 :         Real64 powerConversion = 1.0;
   10297           44 :         Real64 flowConversion = 1.0;
   10298           44 :         ipElectricityConversion = 1.0;
   10299              : 
   10300              :         // establish unit conversion factors
   10301           44 :         if (unitsStyle_cur == UnitsStyle::InchPound) {
   10302            8 :             powerConversion = getSpecificUnitMultiplier(state, "W", "kBtuh");
   10303            8 :             flowConversion = getSpecificUnitMultiplier(state, "m3/s", "gal/min");
   10304           42 :         } else if (unitsStyle_cur == UnitsStyle::InchPoundExceptElectricity) {
   10305            4 :             powerConversion = getSpecificUnitMultiplier(state, "W", "kBtuh");
   10306            3 :             flowConversion = getSpecificUnitMultiplier(state, "m3/s", "gal/min");
   10307            1 :             ipElectricityConversion = powerConversion * 1000.0; // W to kW adjustment
   10308              :         }
   10309              : 
   10310              :         // collapse the gatherEndUseBEPS array to the resource groups displayed
   10311           44 :         collapsedEndUse = 0.0;
   10312          660 :         for (int jEndUse = 1; jEndUse <= static_cast<int>(Constant::EndUse::Num); ++jEndUse) {
   10313          616 :             collapsedEndUse(1, jEndUse) = ort->gatherDemandEndUse(1, jEndUse) * (powerConversion / ipElectricityConversion); // electricity
   10314          616 :             collapsedEndUse(2, jEndUse) = ort->gatherDemandEndUse(2, jEndUse) * powerConversion;                             // natural gas
   10315          616 :             collapsedEndUse(3, jEndUse) = ort->gatherDemandEndUse(6, jEndUse) * powerConversion;                             // gasoline
   10316          616 :             collapsedEndUse(4, jEndUse) = ort->gatherDemandEndUse(8, jEndUse) * powerConversion;                             // diesel
   10317          616 :             collapsedEndUse(5, jEndUse) = ort->gatherDemandEndUse(9, jEndUse) * powerConversion;                             // coal
   10318          616 :             collapsedEndUse(6, jEndUse) = ort->gatherDemandEndUse(10, jEndUse) * powerConversion;                            // fuel oil no 1
   10319          616 :             collapsedEndUse(7, jEndUse) = ort->gatherDemandEndUse(11, jEndUse) * powerConversion;                            // fuel oil no 2
   10320          616 :             collapsedEndUse(8, jEndUse) = ort->gatherDemandEndUse(12, jEndUse) * powerConversion;                            // propane
   10321          616 :             collapsedEndUse(9, jEndUse) = ort->gatherDemandEndUse(13, jEndUse) * powerConversion;                            // otherfuel1
   10322          616 :             collapsedEndUse(10, jEndUse) = ort->gatherDemandEndUse(14, jEndUse) * powerConversion;                           // otherfuel2
   10323          616 :             collapsedEndUse(11, jEndUse) = ort->gatherDemandEndUse(3, jEndUse) * powerConversion;                            // purchased cooling
   10324          616 :             collapsedEndUse(12, jEndUse) = ort->gatherDemandEndUse(4, jEndUse) * powerConversion;                            // district heating water
   10325          616 :             collapsedEndUse(13, jEndUse) = ort->gatherDemandEndUse(5, jEndUse) * powerConversion;                            // district heating steam
   10326          616 :             collapsedEndUse(14, jEndUse) = ort->gatherDemandEndUse(7, jEndUse) * flowConversion;                             // water
   10327              :         }
   10328          660 :         for (int jEndUse = 1; jEndUse <= static_cast<int>(Constant::EndUse::Num); ++jEndUse) {
   10329          797 :             for (int kEndUseSub = 1; kEndUseSub <= op->EndUseCategory(jEndUse).NumSubcategories; ++kEndUseSub) {
   10330          362 :                 collapsedEndUseSub(kEndUseSub, jEndUse, 1) =
   10331          181 :                     ort->gatherDemandEndUseSub(kEndUseSub, jEndUse, 1) * (powerConversion / ipElectricityConversion);                // electricity
   10332          181 :                 collapsedEndUseSub(kEndUseSub, jEndUse, 2) = ort->gatherDemandEndUseSub(kEndUseSub, jEndUse, 2) * powerConversion;   // natural gas
   10333          181 :                 collapsedEndUseSub(kEndUseSub, jEndUse, 3) = ort->gatherDemandEndUseSub(kEndUseSub, jEndUse, 6) * powerConversion;   // gasoline
   10334          181 :                 collapsedEndUseSub(kEndUseSub, jEndUse, 4) = ort->gatherDemandEndUseSub(kEndUseSub, jEndUse, 8) * powerConversion;   // diesel
   10335          181 :                 collapsedEndUseSub(kEndUseSub, jEndUse, 5) = ort->gatherDemandEndUseSub(kEndUseSub, jEndUse, 9) * powerConversion;   // coal
   10336          181 :                 collapsedEndUseSub(kEndUseSub, jEndUse, 6) = ort->gatherDemandEndUseSub(kEndUseSub, jEndUse, 10) * powerConversion;  // fuel oil no 1
   10337          181 :                 collapsedEndUseSub(kEndUseSub, jEndUse, 7) = ort->gatherDemandEndUseSub(kEndUseSub, jEndUse, 11) * powerConversion;  // fuel oil no 2
   10338          181 :                 collapsedEndUseSub(kEndUseSub, jEndUse, 8) = ort->gatherDemandEndUseSub(kEndUseSub, jEndUse, 12) * powerConversion;  // propane
   10339          181 :                 collapsedEndUseSub(kEndUseSub, jEndUse, 9) = ort->gatherDemandEndUseSub(kEndUseSub, jEndUse, 13) * powerConversion;  // otherfuel1
   10340          181 :                 collapsedEndUseSub(kEndUseSub, jEndUse, 10) = ort->gatherDemandEndUseSub(kEndUseSub, jEndUse, 14) * powerConversion; // otherfuel2
   10341          181 :                 collapsedEndUseSub(kEndUseSub, jEndUse, 11) = ort->gatherDemandEndUseSub(kEndUseSub, jEndUse, 3) * powerConversion;  // purch cooling
   10342          362 :                 collapsedEndUseSub(kEndUseSub, jEndUse, 12) =
   10343          181 :                     ort->gatherDemandEndUseSub(kEndUseSub, jEndUse, 4) * powerConversion; // district heating water
   10344          362 :                 collapsedEndUseSub(kEndUseSub, jEndUse, 13) =
   10345          181 :                     ort->gatherDemandEndUseSub(kEndUseSub, jEndUse, 5) * powerConversion; // district heating steam
   10346          181 :                 collapsedEndUseSub(kEndUseSub, jEndUse, 14) = ort->gatherDemandEndUseSub(kEndUseSub, jEndUse, 7) * flowConversion; // water
   10347              :             }
   10348              :         }
   10349              :         // collapse the individual peaks for the end use subcategories for the LEED report
   10350              :         // collapse the gatherEndUseBEPS array to the resource groups displayed
   10351              :         // no unit conversion, it is done at the reporting stage if necessary
   10352           44 :         collapsedIndEndUse = 0.0;
   10353          660 :         for (int jEndUse = 1; jEndUse <= static_cast<int>(Constant::EndUse::Num); ++jEndUse) {
   10354          616 :             collapsedIndEndUse(1, jEndUse) = ort->gatherDemandIndEndUse(1, jEndUse) * (1.0 / ipElectricityConversion); // electricity
   10355          616 :             collapsedIndEndUse(2, jEndUse) = ort->gatherDemandIndEndUse(2, jEndUse);                                   // natural gas
   10356          616 :             collapsedIndEndUse(3, jEndUse) = ort->gatherDemandIndEndUse(6, jEndUse);                                   // gasoline
   10357          616 :             collapsedIndEndUse(4, jEndUse) = ort->gatherDemandIndEndUse(8, jEndUse);                                   // diesel
   10358          616 :             collapsedIndEndUse(5, jEndUse) = ort->gatherDemandIndEndUse(9, jEndUse);                                   // coal
   10359          616 :             collapsedIndEndUse(6, jEndUse) = ort->gatherDemandIndEndUse(10, jEndUse);                                  // fuel oil no 1
   10360          616 :             collapsedIndEndUse(7, jEndUse) = ort->gatherDemandIndEndUse(11, jEndUse);                                  // fuel oil no 2
   10361          616 :             collapsedIndEndUse(8, jEndUse) = ort->gatherDemandIndEndUse(12, jEndUse);                                  // propane
   10362          616 :             collapsedIndEndUse(9, jEndUse) = ort->gatherDemandIndEndUse(13, jEndUse);                                  // otherfuel1
   10363          616 :             collapsedIndEndUse(10, jEndUse) = ort->gatherDemandIndEndUse(14, jEndUse);                                 // otherfuel2
   10364          616 :             collapsedIndEndUse(11, jEndUse) = ort->gatherDemandIndEndUse(3, jEndUse);                                  // purchased cooling
   10365          616 :             collapsedIndEndUse(12, jEndUse) = ort->gatherDemandIndEndUse(4, jEndUse);                                  // district heating water
   10366          616 :             collapsedIndEndUse(13, jEndUse) = ort->gatherDemandIndEndUse(5, jEndUse);                                  // district heating steam
   10367          616 :             collapsedIndEndUse(14, jEndUse) = ort->gatherDemandIndEndUse(7, jEndUse);                                  // water
   10368              :         }
   10369          660 :         for (int jEndUse = 1; jEndUse <= static_cast<int>(Constant::EndUse::Num); ++jEndUse) {
   10370          797 :             for (int kEndUseSub = 1; kEndUseSub <= op->EndUseCategory(jEndUse).NumSubcategories; ++kEndUseSub) {
   10371          362 :                 collapsedIndEndUseSub(kEndUseSub, jEndUse, 1) =
   10372          181 :                     ort->gatherDemandIndEndUseSub(kEndUseSub, jEndUse, 1) * (1.0 / ipElectricityConversion);             // electricity
   10373          181 :                 collapsedIndEndUseSub(kEndUseSub, jEndUse, 2) = ort->gatherDemandIndEndUseSub(kEndUseSub, jEndUse, 2);   // natural gas
   10374          181 :                 collapsedIndEndUseSub(kEndUseSub, jEndUse, 3) = ort->gatherDemandIndEndUseSub(kEndUseSub, jEndUse, 6);   // gasoline
   10375          181 :                 collapsedIndEndUseSub(kEndUseSub, jEndUse, 4) = ort->gatherDemandIndEndUseSub(kEndUseSub, jEndUse, 8);   // diesel
   10376          181 :                 collapsedIndEndUseSub(kEndUseSub, jEndUse, 5) = ort->gatherDemandIndEndUseSub(kEndUseSub, jEndUse, 9);   // coal
   10377          181 :                 collapsedIndEndUseSub(kEndUseSub, jEndUse, 6) = ort->gatherDemandIndEndUseSub(kEndUseSub, jEndUse, 10);  // fuel oil no 1
   10378          181 :                 collapsedIndEndUseSub(kEndUseSub, jEndUse, 7) = ort->gatherDemandIndEndUseSub(kEndUseSub, jEndUse, 11);  // fuel oil no 2
   10379          181 :                 collapsedIndEndUseSub(kEndUseSub, jEndUse, 8) = ort->gatherDemandIndEndUseSub(kEndUseSub, jEndUse, 12);  // propane
   10380          181 :                 collapsedIndEndUseSub(kEndUseSub, jEndUse, 9) = ort->gatherDemandIndEndUseSub(kEndUseSub, jEndUse, 13);  // otherfuel1
   10381          181 :                 collapsedIndEndUseSub(kEndUseSub, jEndUse, 10) = ort->gatherDemandIndEndUseSub(kEndUseSub, jEndUse, 14); // otherfuel2
   10382          181 :                 collapsedIndEndUseSub(kEndUseSub, jEndUse, 11) = ort->gatherDemandIndEndUseSub(kEndUseSub, jEndUse, 3);  // purch cooling
   10383          181 :                 collapsedIndEndUseSub(kEndUseSub, jEndUse, 12) = ort->gatherDemandIndEndUseSub(kEndUseSub, jEndUse, 4);  // district heating water
   10384          181 :                 collapsedIndEndUseSub(kEndUseSub, jEndUse, 13) = ort->gatherDemandIndEndUseSub(kEndUseSub, jEndUse, 5);  // district heating steam
   10385          181 :                 collapsedIndEndUseSub(kEndUseSub, jEndUse, 14) = ort->gatherDemandIndEndUseSub(kEndUseSub, jEndUse, 7);  // water
   10386              :             }
   10387              :         }
   10388              : 
   10389              :         // convert totals
   10390           44 :         collapsedTotal(1) *= (powerConversion / ipElectricityConversion); // electricity
   10391           44 :         collapsedTotal(2) *= powerConversion;                             // natural gas
   10392           44 :         collapsedTotal(3) *= powerConversion;                             // gasoline
   10393           44 :         collapsedTotal(4) *= powerConversion;                             // diesel
   10394           44 :         collapsedTotal(5) *= powerConversion;                             // coal
   10395           44 :         collapsedTotal(6) *= powerConversion;                             // fuel oil no 1
   10396           44 :         collapsedTotal(7) *= powerConversion;                             // fuel oil no 2
   10397           44 :         collapsedTotal(8) *= powerConversion;                             // propane
   10398           44 :         collapsedTotal(9) *= powerConversion;                             // otherfuel1
   10399           44 :         collapsedTotal(10) *= powerConversion;                            // otherfuel2
   10400           44 :         collapsedTotal(11) *= powerConversion;                            // purchased cooling
   10401           44 :         collapsedTotal(12) *= powerConversion;                            // district heating water
   10402           44 :         collapsedTotal(13) *= powerConversion;                            // district heating steam
   10403           44 :         collapsedTotal(14) *= flowConversion;                             // water
   10404              :         //---- End Use Sub-Table
   10405           44 :         rowHead.allocate(17);
   10406           44 :         columnHead.allocate(14);
   10407           44 :         columnWidth.allocate(14);
   10408           44 :         columnWidth = 10; // array assignment - same for all columns
   10409           44 :         tableBody.allocate(14, 17);
   10410          660 :         for (int iResource = 1; iResource <= 14; ++iResource) {
   10411         9240 :             for (int iEndUse = 0; iEndUse < static_cast<int>(Constant::EndUse::Num); ++iEndUse) {
   10412         8624 :                 useVal(iResource, iEndUse + 1) = collapsedEndUse(iResource, iEndUse + 1);
   10413              :             }
   10414          616 :             useVal(iResource, 15) = collapsedTotal(iResource); // totals
   10415              :         }
   10416              : 
   10417           44 :         rowHead(1) = "Time of Peak";
   10418           44 :         rowHead(static_cast<int>(Constant::EndUse::Heating) + 2) = "Heating";
   10419           44 :         rowHead(static_cast<int>(Constant::EndUse::Cooling) + 2) = "Cooling";
   10420           44 :         rowHead(static_cast<int>(Constant::EndUse::InteriorLights) + 2) = "Interior Lighting";
   10421           44 :         rowHead(static_cast<int>(Constant::EndUse::ExteriorLights) + 2) = "Exterior Lighting";
   10422           44 :         rowHead(static_cast<int>(Constant::EndUse::InteriorEquipment) + 2) = "Interior Equipment";
   10423           44 :         rowHead(static_cast<int>(Constant::EndUse::ExteriorEquipment) + 2) = "Exterior Equipment";
   10424           44 :         rowHead(static_cast<int>(Constant::EndUse::Fans) + 2) = "Fans";
   10425           44 :         rowHead(static_cast<int>(Constant::EndUse::Pumps) + 2) = "Pumps";
   10426           44 :         rowHead(static_cast<int>(Constant::EndUse::HeatRejection) + 2) = "Heat Rejection";
   10427           44 :         rowHead(static_cast<int>(Constant::EndUse::Humidification) + 2) = "Humidification";
   10428           44 :         rowHead(static_cast<int>(Constant::EndUse::HeatRecovery) + 2) = "Heat Recovery";
   10429           44 :         rowHead(static_cast<int>(Constant::EndUse::WaterSystem) + 2) = "Water Systems";
   10430           44 :         rowHead(static_cast<int>(Constant::EndUse::Refrigeration) + 2) = "Refrigeration";
   10431           44 :         rowHead(static_cast<int>(Constant::EndUse::Cogeneration) + 2) = "Generators";
   10432           44 :         rowHead(16) = "";
   10433           44 :         rowHead(17) = "Total End Uses";
   10434              : 
   10435           44 :         if (unitsStyle_cur == UnitsStyle::InchPound) {
   10436            2 :             columnHead(1) = "Electricity [kBtuh]";
   10437            2 :             columnHead(2) = "Natural Gas [kBtuh]";
   10438            2 :             columnHead(3) = "Gasoline [kBtuh]";
   10439            2 :             columnHead(4) = "Diesel [kBtuh]";
   10440            2 :             columnHead(5) = "Coal [kBtuh]";
   10441            2 :             columnHead(6) = "Fuel Oil No 1 [kBtuh]";
   10442            2 :             columnHead(7) = "Fuel Oil No 2 [kBtuh]";
   10443            2 :             columnHead(8) = "Propane [kBtuh]";
   10444            2 :             columnHead(9) = "Other Fuel 1 [kBtuh]";
   10445            2 :             columnHead(10) = "Other Fuel 2 [kBtuh]";
   10446            2 :             columnHead(11) = "District Cooling [kBtuh]";
   10447            2 :             columnHead(12) = "District Heating Water [kBtuh]";
   10448            2 :             columnHead(13) = "District Heating Steam [kBtuh]";
   10449            2 :             columnHead(14) = "Water [gal/min]";
   10450           42 :         } else if (unitsStyle_cur == UnitsStyle::InchPoundExceptElectricity) {
   10451            1 :             columnHead(1) = "Electricity [kW]";
   10452            1 :             columnHead(2) = "Natural Gas [kBtuh]";
   10453            1 :             columnHead(3) = "Gasoline [kBtuh]";
   10454            1 :             columnHead(4) = "Diesel [kBtuh]";
   10455            1 :             columnHead(5) = "Coal [kBtuh]";
   10456            1 :             columnHead(6) = "Fuel Oil No 1 [kBtuh]";
   10457            1 :             columnHead(7) = "Fuel Oil No 2 [kBtuh]";
   10458            1 :             columnHead(8) = "Propane [kBtuh]";
   10459            1 :             columnHead(9) = "Other Fuel 1 [kBtuh]";
   10460            1 :             columnHead(10) = "Other Fuel 2 [kBtuh]";
   10461            1 :             columnHead(11) = "District Cooling [kBtuh]";
   10462            1 :             columnHead(12) = "District Heating Water [kBtuh]";
   10463            1 :             columnHead(13) = "District Heating Steam [kBtuh]";
   10464            1 :             columnHead(14) = "Water [gal/min]";
   10465              :         } else {
   10466           41 :             columnHead(1) = "Electricity [W]";
   10467           41 :             columnHead(2) = "Natural Gas [W]";
   10468           41 :             columnHead(3) = "Gasoline [W]";
   10469           41 :             columnHead(4) = "Diesel [W]";
   10470           41 :             columnHead(5) = "Coal [W]";
   10471           41 :             columnHead(6) = "Fuel Oil No 1 [W]";
   10472           41 :             columnHead(7) = "Fuel Oil No 2 [W]";
   10473           41 :             columnHead(8) = "Propane [W]";
   10474           41 :             columnHead(9) = "Other Fuel 1 [W]";
   10475           41 :             columnHead(10) = "Other Fuel 2 [W]";
   10476           41 :             columnHead(11) = "District Cooling [W]";
   10477           41 :             columnHead(12) = "District Heating Water [W]";
   10478           41 :             columnHead(13) = "District Heating Steam [W]";
   10479           41 :             columnHead(14) = "Water [m3/s]";
   10480              :         }
   10481              : 
   10482           44 :         tableBody = "";
   10483          660 :         for (int iResource = 1; iResource <= 14; ++iResource) {
   10484         9240 :             for (int jEndUse = 1; jEndUse <= static_cast<int>(Constant::EndUse::Num); ++jEndUse) {
   10485         8624 :                 tableBody(iResource, 1 + jEndUse) = RealToStr(useVal(iResource, jEndUse), 2);
   10486              :             }
   10487          616 :             tableBody(iResource, 1) = DateToString(collapsedTimeStep(iResource));
   10488          616 :             tableBody(iResource, 17) = RealToStr(collapsedTotal(iResource), 2);
   10489              :         }
   10490              : 
   10491              :         // complete the LEED end use table using the same values
   10492              : 
   10493           44 :         if (produceTabular) {
   10494           42 :             WriteSubtitle(state, "End Uses");
   10495           42 :             WriteTable(state, tableBody, rowHead, columnHead, columnWidth, false, state.dataOutRptTab->footnote);
   10496              :         }
   10497           44 :         if (produceSQLite) {
   10498           42 :             if (state.dataSQLiteProcedures->sqlite) {
   10499            7 :                 state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
   10500              :                     tableBody, rowHead, columnHead, "DemandEndUseComponentsSummary", "Entire Facility", "End Uses");
   10501              :             }
   10502              :         }
   10503           44 :         if (produceTabular) {
   10504           42 :             if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
   10505            0 :                 state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(
   10506              :                     tableBody, rowHead, columnHead, "DemandEndUseComponentsSummary", "Entire Facility", "End Uses");
   10507              :             }
   10508              :         }
   10509              : 
   10510              :         //---- End Uses By Subcategory Sub-Table
   10511           44 :         int numRows = 0;
   10512          660 :         for (int jEndUse = 1; jEndUse <= static_cast<int>(Constant::EndUse::Num); ++jEndUse) {
   10513          616 :             if (op->EndUseCategory(jEndUse).NumSubcategories > 0) {
   10514          356 :                 for (int kEndUseSub = 1; kEndUseSub <= op->EndUseCategory(jEndUse).NumSubcategories; ++kEndUseSub) {
   10515          181 :                     ++numRows;
   10516              :                 }
   10517              :             } else {
   10518          441 :                 ++numRows;
   10519              :             }
   10520              :         }
   10521              : 
   10522           44 :         rowHead.allocate(numRows);
   10523           44 :         columnHead.allocate(15);
   10524           44 :         columnWidth.allocate(15);
   10525           44 :         columnWidth = 10; // array assignment - same for all columns
   10526           44 :         tableBody.allocate(15, numRows);
   10527              : 
   10528           88 :         rowHead = "";
   10529           44 :         tableBody = "";
   10530              : 
   10531              :         // Build row head and subcategories columns
   10532              :         {
   10533           44 :             int i = 1;
   10534          660 :             for (int jEndUse = 1; jEndUse <= static_cast<int>(Constant::EndUse::Num); ++jEndUse) {
   10535          616 :                 rowHead(i) = op->EndUseCategory(jEndUse).DisplayName;
   10536          616 :                 if (op->EndUseCategory(jEndUse).NumSubcategories > 0) {
   10537          356 :                     for (int kEndUseSub = 1; kEndUseSub <= op->EndUseCategory(jEndUse).NumSubcategories; ++kEndUseSub) {
   10538          181 :                         tableBody(1, i) = op->EndUseCategory(jEndUse).SubcategoryName(kEndUseSub);
   10539          181 :                         ++i;
   10540              :                     }
   10541              :                 } else {
   10542          441 :                     tableBody(1, i) = "General";
   10543          441 :                     ++i;
   10544              :                 }
   10545              :             }
   10546              :         }
   10547              : 
   10548           44 :         if (unitsStyle_cur == UnitsStyle::InchPound) {
   10549            2 :             columnHead(1) = "Subcategory";
   10550            2 :             columnHead(2) = "Electricity [kBtuh]";
   10551            2 :             columnHead(3) = "Natural Gas [kBtuh]";
   10552            2 :             columnHead(4) = "Gasoline [kBtuh]";
   10553            2 :             columnHead(5) = "Diesel [kBtuh]";
   10554            2 :             columnHead(6) = "Coal [kBtuh]";
   10555            2 :             columnHead(7) = "Fuel Oil No 1 [kBtuh]";
   10556            2 :             columnHead(8) = "Fuel Oil No 2 [kBtuh]";
   10557            2 :             columnHead(9) = "Propane [kBtuh]";
   10558            2 :             columnHead(10) = "Other Fuel 1 [kBtuh]";
   10559            2 :             columnHead(11) = "Other Fuel 2 [kBtuh]";
   10560            2 :             columnHead(12) = "District Cooling [kBtuh]";
   10561            2 :             columnHead(13) = "District Heating Water [kBtuh]";
   10562            2 :             columnHead(14) = "District Heating Steam [kBtuh]";
   10563            2 :             columnHead(15) = "Water [gal/min]";
   10564           42 :         } else if (unitsStyle_cur == UnitsStyle::InchPoundExceptElectricity) {
   10565            1 :             columnHead(1) = "Subcategory";
   10566            1 :             columnHead(2) = "Electricity [kW]";
   10567            1 :             columnHead(3) = "Natural Gas [kBtuh]";
   10568            1 :             columnHead(4) = "Gasoline [kBtuh]";
   10569            1 :             columnHead(5) = "Diesel [kBtuh]";
   10570            1 :             columnHead(6) = "Coal [kBtuh]";
   10571            1 :             columnHead(7) = "Fuel Oil No 1 [kBtuh]";
   10572            1 :             columnHead(8) = "Fuel Oil No 2 [kBtuh]";
   10573            1 :             columnHead(9) = "Propane [kBtuh]";
   10574            1 :             columnHead(10) = "Other Fuel 1 [kBtuh]";
   10575            1 :             columnHead(11) = "Other Fuel 2 [kBtuh]";
   10576            1 :             columnHead(12) = "District Cooling [kBtuh]";
   10577            1 :             columnHead(13) = "District Heating Water [kBtuh]";
   10578            1 :             columnHead(14) = "District Heating Steam [kBtuh]";
   10579            1 :             columnHead(15) = "Water [gal/min]";
   10580              :         } else {
   10581           41 :             columnHead(1) = "Subcategory";
   10582           41 :             columnHead(2) = "Electricity [W]";
   10583           41 :             columnHead(3) = "Natural Gas [W]";
   10584           41 :             columnHead(4) = "Gasoline [W]";
   10585           41 :             columnHead(5) = "Diesel [W]";
   10586           41 :             columnHead(6) = "Coal [W]";
   10587           41 :             columnHead(7) = "Fuel Oil No 1 [W]";
   10588           41 :             columnHead(8) = "Fuel Oil No 2 [W]";
   10589           41 :             columnHead(9) = "Propane [W]";
   10590           41 :             columnHead(10) = "Other Fuel 1 [W]";
   10591           41 :             columnHead(11) = "Other Fuel 2 [W]";
   10592           41 :             columnHead(12) = "District Cooling [W]";
   10593           41 :             columnHead(13) = "District Heating Water [W]";
   10594           41 :             columnHead(14) = "District Heating Steam [W]";
   10595           41 :             columnHead(15) = "Water [m3/s]";
   10596              :         }
   10597              : 
   10598          660 :         for (int iResource = 1; iResource <= 14; ++iResource) {
   10599          616 :             int i = 1;
   10600         9240 :             for (int jEndUse = 1; jEndUse <= static_cast<int>(Constant::EndUse::Num); ++jEndUse) {
   10601         8624 :                 if (op->EndUseCategory(jEndUse).NumSubcategories > 0) {
   10602         4984 :                     for (int kEndUseSub = 1; kEndUseSub <= op->EndUseCategory(jEndUse).NumSubcategories; ++kEndUseSub) {
   10603         2534 :                         tableBody(iResource + 1, i) = RealToStr(collapsedEndUseSub(kEndUseSub, jEndUse, iResource), 2);
   10604         2534 :                         ++i;
   10605              :                     }
   10606              :                 } else {
   10607         6174 :                     tableBody(iResource + 1, i) = RealToStr(collapsedEndUse(iResource, jEndUse), 2);
   10608         6174 :                     ++i;
   10609              :                 }
   10610              :             }
   10611              :         }
   10612              : 
   10613              :         // heading for the entire sub-table
   10614           44 :         if (produceTabular) {
   10615           42 :             WriteSubtitle(state, "End Uses By Subcategory");
   10616           42 :             WriteTable(state, tableBody, rowHead, columnHead, columnWidth, false, state.dataOutRptTab->footnote);
   10617              :         }
   10618              : 
   10619           44 :         Array1D_string rowHeadTemp(rowHead);
   10620              :         // Before outputting to SQL, we forward fill the End use column (rowHead) (cf #7481)
   10621              :         // for better sql queries
   10622           44 :         FillRowHead(rowHeadTemp);
   10623              : 
   10624          666 :         for (int i = 1; i <= numRows; ++i) {
   10625          622 :             rowHeadTemp(i) = rowHeadTemp(i) + ":" + tableBody(1, i);
   10626              :         }
   10627              : 
   10628              :         // Erase the SubCategory (first column), using slicing
   10629          308 :         Array2D_string tableBodyTemp(tableBody({2, _, _}, {_, _, _}));
   10630          176 :         Array1D_string columnHeadTemp(columnHead({2, _, _}));
   10631              : 
   10632           44 :         if (produceSQLite) {
   10633           42 :             if (state.dataSQLiteProcedures->sqlite) {
   10634            7 :                 state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
   10635              :                     tableBodyTemp, rowHeadTemp, columnHeadTemp, "DemandEndUseComponentsSummary", "Entire Facility", "End Uses By Subcategory");
   10636              :             }
   10637              :         }
   10638              : 
   10639           44 :         if (produceTabular) {
   10640           42 :             if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
   10641            0 :                 state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(
   10642              :                     tableBodyTemp, rowHeadTemp, columnHeadTemp, "DemandEndUseComponentsSummary", "Entire Facility", "End Uses By Subcategory");
   10643              :             }
   10644              :         }
   10645           44 :         rowHeadTemp.deallocate();
   10646           44 :         tableBodyTemp.deallocate();
   10647           44 :         columnHeadTemp.deallocate();
   10648           44 :     }
   10649              : 
   10650              :     // EAp2-4/5. Performance Rating Method Compliance
   10651          630 :     for (int iResource = 1; iResource <= 14; ++iResource) {
   10652         8820 :         for (int jEndUse = 1; jEndUse <= static_cast<int>(Constant::EndUse::Num); ++jEndUse) {
   10653         8232 :             if (ort->needOtherRowLEED45(jEndUse)) {
   10654            0 :                 if (op->EndUseCategory(jEndUse).NumSubcategories == 0) {
   10655            0 :                     endUseSubOther(iResource, jEndUse) = collapsedIndEndUse(iResource, jEndUse); // often the case that no subcategories are defined
   10656              :                 } else {
   10657            0 :                     Real64 sumOfSubcategories = 0.;
   10658            0 :                     for (int kEndUseSub = 1; kEndUseSub <= op->EndUseCategory(jEndUse).NumSubcategories; ++kEndUseSub) {
   10659            0 :                         sumOfSubcategories += collapsedIndEndUseSub(kEndUseSub, jEndUse, iResource);
   10660              :                     }
   10661            0 :                     endUseSubOther(iResource, jEndUse) = collapsedIndEndUse(iResource, jEndUse) - sumOfSubcategories;
   10662            0 :                     if (endUseSubOther(iResource, jEndUse) < 0.) {
   10663            0 :                         endUseSubOther(iResource, jEndUse) = 0.;
   10664              :                     }
   10665              :                 }
   10666              :             }
   10667              :         }
   10668              :     }
   10669              : 
   10670           42 :     Array1D_int resource_entry_map;
   10671           42 :     resource_entry_map.allocate(13);
   10672           42 :     resource_entry_map(1) = state.dataOutRptPredefined->pdchLeedPerfElDem;          // electricity
   10673           42 :     resource_entry_map(2) = state.dataOutRptPredefined->pdchLeedPerfGasDem;         // natural gas
   10674           42 :     resource_entry_map(3) = state.dataOutRptPredefined->pdchLeedPerfGasolineDem;    // gasoline
   10675           42 :     resource_entry_map(4) = state.dataOutRptPredefined->pdchLeedPerfDieselDem;      // diesel
   10676           42 :     resource_entry_map(5) = state.dataOutRptPredefined->pdchLeedPerfCoalDem;        // coal
   10677           42 :     resource_entry_map(6) = state.dataOutRptPredefined->pdchLeedPerfFuelOil1Dem;    // fuel oil no 1
   10678           42 :     resource_entry_map(7) = state.dataOutRptPredefined->pdchLeedPerfFuelOil2Dem;    // fuel oil no 2
   10679           42 :     resource_entry_map(8) = state.dataOutRptPredefined->pdchLeedPerfPropaneDem;     // propane
   10680           42 :     resource_entry_map(9) = state.dataOutRptPredefined->pdchLeedPerfOtherFuel1Dem;  // other fuel 1
   10681           42 :     resource_entry_map(10) = state.dataOutRptPredefined->pdchLeedPerfOtherFuel2Dem; // other fuel 2
   10682           42 :     resource_entry_map(11) = state.dataOutRptPredefined->pdchLeedPerfDisClDem;      // district cooling
   10683           42 :     resource_entry_map(12) = state.dataOutRptPredefined->pdchLeedPerfDisHtWtrDem;   // district heating water
   10684           42 :     resource_entry_map(13) = state.dataOutRptPredefined->pdchLeedPerfDisHtStDem;    // district heating steam
   10685              : 
   10686          588 :     for (int iResource = 1; iResource <= 13; ++iResource) {
   10687          546 :         int i = 1;
   10688          546 :         Real64 localUnconvert = (iResource == 1) ? ipElectricityConversion : 1.0;
   10689         8190 :         for (int jEndUse = 1; jEndUse <= static_cast<int>(Constant::EndUse::Num); ++jEndUse) {
   10690         7644 :             if (op->EndUseCategory(jEndUse).NumSubcategories > 0) {
   10691         4498 :                 for (int kEndUseSub = 1; kEndUseSub <= op->EndUseCategory(jEndUse).NumSubcategories; ++kEndUseSub) {
   10692         4550 :                     PreDefTableEntry(state,
   10693         2275 :                                      resource_entry_map(iResource),
   10694         4550 :                                      op->EndUseCategory(jEndUse).DisplayName + " -- " + op->EndUseCategory(jEndUse).SubcategoryName(kEndUseSub),
   10695         2275 :                                      localUnconvert * collapsedIndEndUseSub(kEndUseSub, jEndUse, iResource));
   10696         2275 :                     ++i;
   10697              :                 }
   10698              :                 // put other
   10699         2223 :                 if (ort->needOtherRowLEED45(jEndUse)) {
   10700            0 :                     PreDefTableEntry(state,
   10701            0 :                                      resource_entry_map(iResource),
   10702            0 :                                      op->EndUseCategory(jEndUse).DisplayName + " -- Other",
   10703            0 :                                      localUnconvert * endUseSubOther(iResource, jEndUse));
   10704            0 :                     ++i;
   10705              :                 }
   10706              :             } else {
   10707        10842 :                 PreDefTableEntry(state,
   10708         5421 :                                  resource_entry_map(iResource),
   10709        10842 :                                  op->EndUseCategory(jEndUse).DisplayName + " -- Not Subdivided",
   10710         5421 :                                  localUnconvert * collapsedIndEndUse(iResource, jEndUse));
   10711         5421 :                 ++i;
   10712              :             }
   10713              :         }
   10714              :     }
   10715          130 : }
   10716              : 
   10717           38 : void WriteCompCostTable(EnergyPlusData &state)
   10718              : {
   10719              : 
   10720              :     // SUBROUTINE INFORMATION:
   10721              :     //       AUTHOR         BGriffith
   10722              :     //       DATE WRITTEN   April/May 2004
   10723              :     //       MODIFIED       January 2010, Kyle Benne
   10724              :     //                      Added SQLite output
   10725              :     //       RE-ENGINEERED  na
   10726              : 
   10727              :     // PURPOSE OF THIS SUBROUTINE:
   10728              :     // produce a results table from Cost Estimate Calculations
   10729              : 
   10730              :     // METHODOLOGY EMPLOYED:
   10731              :     // USE data from CostEstimateManager, call JGlazer's subroutines
   10732              : 
   10733              :     // REFERENCES:
   10734              :     // na
   10735              : 
   10736              :     // Using/Aliasing
   10737              : 
   10738              :     // Locals
   10739              :     // SUBROUTINE ARGUMENT DEFINITIONS:
   10740              :     // na
   10741              : 
   10742              :     // SUBROUTINE PARAMETER DEFINITIONS:
   10743              :     // na
   10744              : 
   10745              :     // INTERFACE BLOCK SPECIFICATIONS:
   10746              :     // na
   10747              : 
   10748              :     // DERIVED TYPE DEFINITIONS:
   10749              :     // na
   10750              : 
   10751              :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
   10752           38 :     auto const &ort = state.dataOutRptTab;
   10753              : 
   10754           38 :     if (!state.dataCostEstimateManager->DoCostEstimate) {
   10755           38 :         return;
   10756              :     }
   10757              : 
   10758            0 :     Array2D<Real64> TableBodyData(3, 10);
   10759            0 :     Array1D_string columnHead;
   10760            0 :     Array1D_int columnWidth;
   10761            0 :     Array1D_string rowHead;
   10762            0 :     Array2D_string tableBody;
   10763              : 
   10764            0 :     WriteReportHeaders(state, "Component Cost Economics Summary", "Entire Facility", OutputProcessor::StoreType::Average);
   10765              : 
   10766              :     // compute floor area if no ABUPS
   10767            0 :     if (ort->buildingConditionedFloorArea == 0.0) {
   10768            0 :         DetermineBuildingFloorArea(state);
   10769              :     }
   10770              : 
   10771            0 :     for (int iUnitSystem = 0; iUnitSystem <= 1; iUnitSystem++) {
   10772            0 :         UnitsStyle unitsStyle_cur = ort->unitsStyle;
   10773            0 :         bool produceTabular = true;
   10774            0 :         bool produceSQLite = false;
   10775            0 :         if (produceDualUnitsFlags(iUnitSystem, ort->unitsStyle, ort->unitsStyle_SQLite, unitsStyle_cur, produceTabular, produceSQLite)) {
   10776            0 :             break;
   10777              :         }
   10778              : 
   10779              :         // 1st sub-table with total Costs and normalized with area
   10780            0 :         rowHead.allocate(10);
   10781            0 :         columnHead.allocate(3);
   10782            0 :         columnWidth.allocate(3);
   10783            0 :         columnWidth = 14; // array assignment - same for all columns
   10784            0 :         tableBody.allocate(3, 10);
   10785              : 
   10786            0 :         columnHead(1) = "Reference Bldg.";
   10787            0 :         columnHead(2) = "Current Bldg. Model";
   10788            0 :         columnHead(3) = "Difference";
   10789              : 
   10790            0 :         rowHead(1) = "Line Item SubTotal (~~$~~)";
   10791            0 :         rowHead(2) = "Misc. Costs (~~$~~)";
   10792            0 :         rowHead(3) = "Regional Adjustment (~~$~~)";
   10793            0 :         rowHead(4) = "Design Fee (~~$~~)";
   10794            0 :         rowHead(5) = "Contractor Fee (~~$~~)";
   10795            0 :         rowHead(6) = "Contingency (~~$~~)";
   10796            0 :         rowHead(7) = "Permits, Bonds, Insurance (~~$~~)";
   10797            0 :         rowHead(8) = "Commissioning (~~$~~)";
   10798            0 :         rowHead(9) = "Cost Estimate Total (~~$~~)";
   10799            0 :         if (unitsStyle_cur == OutputReportTabular::UnitsStyle::InchPound ||
   10800            0 :             unitsStyle_cur == OutputReportTabular::UnitsStyle::InchPoundExceptElectricity) {
   10801            0 :             std::string const SIunit = "[m2]";
   10802            0 :             std::string m2_unitName;
   10803            0 :             LookupSItoIP(state, SIunit, state.dataOutRptTab->unitConvIndexWCCT, m2_unitName);
   10804            0 :             state.dataOutRptTab->m2_unitConv = ConvertIP(state, state.dataOutRptTab->unitConvIndexWCCT, 1.0);
   10805            0 :             rowHead(10) = "Cost Per Conditioned Building Area (~~$~~/ft2)";
   10806            0 :         } else {
   10807            0 :             rowHead(10) = "Cost Per Conditioned Building Area (~~$~~/m2)";
   10808            0 :             state.dataOutRptTab->m2_unitConv = 1.0;
   10809              :         }
   10810            0 :         TableBodyData = 0.0;
   10811            0 :         tableBody = "";
   10812              : 
   10813            0 :         TableBodyData(1, 1) = state.dataCostEstimateManager->RefrncBldg.LineItemTot;
   10814            0 :         tableBody(1, 1) = RealToStr(TableBodyData(1, 1), 2);
   10815            0 :         TableBodyData(1, 2) = state.dataCostEstimateManager->RefrncBldg.MiscCostperSqMeter * ort->buildingConditionedFloorArea;
   10816            0 :         tableBody(1, 2) = RealToStr(TableBodyData(1, 2), 2);
   10817              : 
   10818            0 :         if (state.dataCostEstimateManager->RefrncBldg.RegionalModifier != 1.0) {
   10819            0 :             TableBodyData(1, 3) = (state.dataCostEstimateManager->RefrncBldg.LineItemTot +
   10820            0 :                                    state.dataCostEstimateManager->RefrncBldg.MiscCostperSqMeter * ort->buildingConditionedFloorArea) *
   10821            0 :                                   (state.dataCostEstimateManager->RefrncBldg.RegionalModifier - 1.0);
   10822              :         } else {
   10823            0 :             TableBodyData(1, 3) = 0.0;
   10824              :         }
   10825              : 
   10826              :         // holds interim value for construction component costs: reference bldg.
   10827            0 :         Real64 const RefBldgConstCost = sum(TableBodyData(1, {1, 3}));
   10828              : 
   10829            0 :         tableBody(1, 3) = RealToStr(TableBodyData(1, 3), 2);
   10830            0 :         TableBodyData(1, 4) = RefBldgConstCost * state.dataCostEstimateManager->RefrncBldg.DesignFeeFrac;
   10831            0 :         tableBody(1, 4) = RealToStr(TableBodyData(1, 4), 2);
   10832            0 :         TableBodyData(1, 5) = RefBldgConstCost * state.dataCostEstimateManager->RefrncBldg.ContractorFeeFrac;
   10833            0 :         tableBody(1, 5) = RealToStr(TableBodyData(1, 5), 2);
   10834            0 :         TableBodyData(1, 6) = RefBldgConstCost * state.dataCostEstimateManager->RefrncBldg.ContingencyFrac;
   10835            0 :         tableBody(1, 6) = RealToStr(TableBodyData(1, 6), 2);
   10836            0 :         TableBodyData(1, 7) = RefBldgConstCost * state.dataCostEstimateManager->RefrncBldg.BondCostFrac;
   10837            0 :         tableBody(1, 7) = RealToStr(TableBodyData(1, 7), 2);
   10838            0 :         TableBodyData(1, 8) = RefBldgConstCost * state.dataCostEstimateManager->RefrncBldg.CommissioningFrac;
   10839            0 :         tableBody(1, 8) = RealToStr(TableBodyData(1, 8), 2);
   10840            0 :         state.dataCostEstimateManager->RefrncBldg.GrandTotal = sum(TableBodyData(1, {1, 8}));
   10841            0 :         TableBodyData(1, 9) = state.dataCostEstimateManager->RefrncBldg.GrandTotal;
   10842            0 :         tableBody(1, 9) = RealToStr(TableBodyData(1, 9), 2);
   10843            0 :         if (ort->buildingConditionedFloorArea > 0.0) {
   10844            0 :             TableBodyData(1, 10) = TableBodyData(1, 9) / (ort->buildingConditionedFloorArea * state.dataOutRptTab->m2_unitConv);
   10845              :         }
   10846            0 :         tableBody(1, 10) = RealToStr(TableBodyData(1, 10), 2);
   10847              : 
   10848            0 :         TableBodyData(2, 1) = state.dataCostEstimateManager->CurntBldg.LineItemTot;
   10849            0 :         tableBody(2, 1) = RealToStr(TableBodyData(2, 1), 2);
   10850            0 :         TableBodyData(2, 2) = state.dataCostEstimateManager->CurntBldg.MiscCostperSqMeter * ort->buildingConditionedFloorArea;
   10851            0 :         tableBody(2, 2) = RealToStr(TableBodyData(2, 2), 2);
   10852            0 :         if (state.dataCostEstimateManager->CurntBldg.RegionalModifier != 1.0) {
   10853            0 :             TableBodyData(2, 3) = (state.dataCostEstimateManager->CurntBldg.LineItemTot +
   10854            0 :                                    state.dataCostEstimateManager->CurntBldg.MiscCostperSqMeter * ort->buildingConditionedFloorArea) *
   10855            0 :                                   (state.dataCostEstimateManager->CurntBldg.RegionalModifier - 1.0);
   10856              :         } else {
   10857            0 :             TableBodyData(2, 3) = 0.0;
   10858              :         }
   10859            0 :         tableBody(2, 3) = RealToStr(TableBodyData(2, 3), 2);
   10860              : 
   10861              :         // holds interim value for construction component costs: current bldg.
   10862            0 :         Real64 const CurntBldgConstCost = sum(TableBodyData(2, {1, 3}));
   10863              : 
   10864            0 :         TableBodyData(2, 4) = CurntBldgConstCost * state.dataCostEstimateManager->CurntBldg.DesignFeeFrac;
   10865            0 :         tableBody(2, 4) = RealToStr(TableBodyData(2, 4), 2);
   10866              : 
   10867            0 :         TableBodyData(2, 5) = CurntBldgConstCost * state.dataCostEstimateManager->CurntBldg.ContractorFeeFrac;
   10868            0 :         tableBody(2, 5) = RealToStr(TableBodyData(2, 5), 2);
   10869            0 :         TableBodyData(2, 6) = CurntBldgConstCost * state.dataCostEstimateManager->CurntBldg.ContingencyFrac;
   10870            0 :         tableBody(2, 6) = RealToStr(TableBodyData(2, 6), 2);
   10871            0 :         TableBodyData(2, 7) = CurntBldgConstCost * state.dataCostEstimateManager->CurntBldg.BondCostFrac;
   10872            0 :         tableBody(2, 7) = RealToStr(TableBodyData(2, 7), 2);
   10873            0 :         TableBodyData(2, 8) = CurntBldgConstCost * state.dataCostEstimateManager->CurntBldg.CommissioningFrac;
   10874            0 :         tableBody(2, 8) = RealToStr(TableBodyData(2, 8), 2);
   10875              : 
   10876            0 :         state.dataCostEstimateManager->CurntBldg.GrandTotal = sum(TableBodyData(2, {1, 8}));
   10877            0 :         TableBodyData(2, 9) = state.dataCostEstimateManager->CurntBldg.GrandTotal;
   10878            0 :         tableBody(2, 9) = RealToStr(TableBodyData(2, 9), 2);
   10879            0 :         if (ort->buildingConditionedFloorArea > 0) {
   10880            0 :             TableBodyData(2, 10) = TableBodyData(2, 9) / (ort->buildingConditionedFloorArea * state.dataOutRptTab->m2_unitConv);
   10881              :         }
   10882            0 :         tableBody(2, 10) = RealToStr(TableBodyData(2, 10), 2);
   10883              : 
   10884            0 :         TableBodyData(3, {1, 10}) = TableBodyData(2, {1, 10}) - TableBodyData(1, {1, 10});
   10885            0 :         tableBody(3, 1) = RealToStr(TableBodyData(3, 1), 2);
   10886            0 :         tableBody(3, 2) = RealToStr(TableBodyData(3, 2), 2);
   10887            0 :         tableBody(3, 3) = RealToStr(TableBodyData(3, 3), 2);
   10888            0 :         tableBody(3, 4) = RealToStr(TableBodyData(3, 4), 2);
   10889            0 :         tableBody(3, 5) = RealToStr(TableBodyData(3, 5), 2);
   10890            0 :         tableBody(3, 6) = RealToStr(TableBodyData(3, 6), 2);
   10891            0 :         tableBody(3, 7) = RealToStr(TableBodyData(3, 7), 2);
   10892            0 :         tableBody(3, 8) = RealToStr(TableBodyData(3, 8), 2);
   10893            0 :         tableBody(3, 9) = RealToStr(TableBodyData(3, 9), 2);
   10894            0 :         tableBody(3, 10) = RealToStr(TableBodyData(3, 10), 2);
   10895              : 
   10896            0 :         if (produceTabular) {
   10897            0 :             WriteSubtitle(state, "Construction Cost Estimate Summary");
   10898            0 :             WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
   10899              :         }
   10900            0 :         if (produceSQLite) {
   10901            0 :             if (state.dataSQLiteProcedures->sqlite) {
   10902            0 :                 state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
   10903              :                     tableBody, rowHead, columnHead, "Construction Cost Estimate Summary", "Entire Facility", "Construction Cost Estimate Summary");
   10904              :             }
   10905              :         }
   10906            0 :         if (produceTabular) {
   10907            0 :             if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
   10908            0 :                 state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(
   10909              :                     tableBody, rowHead, columnHead, "Construction Cost Estimate Summary", "Entire Facility", "Construction Cost Estimate Summary");
   10910              :             }
   10911              :         }
   10912              : 
   10913            0 :         int const NumRows = static_cast<int>(state.dataCostEstimateManager->CostLineItem.size()) + 1; // body will have the total and line items
   10914            0 :         int const NumCols = 6; // Line no., Line name, Qty, Units, ValperQty, Subtotal
   10915            0 :         rowHead.allocate(NumRows);
   10916            0 :         columnHead.allocate(NumCols);
   10917            0 :         columnWidth.dimension(NumCols, 14); // array assignment - same for all columns
   10918            0 :         tableBody.allocate(NumCols, NumRows);
   10919            0 :         tableBody = "--";                        // array init
   10920            0 :         rowHead = "--";                          // array init
   10921            0 :         rowHead(NumRows) = "Line Item SubTotal"; // last line in table will be a total
   10922              :         // setup up column headers
   10923            0 :         columnHead(1) = "Line No.";
   10924            0 :         columnHead(2) = "Item Name";
   10925            0 :         columnHead(3) = "Quantity.";
   10926            0 :         columnHead(4) = "Units";
   10927            0 :         columnHead(5) = "~~$~~ per Qty.";
   10928            0 :         columnHead(6) = "SubTotal ~~$~~";
   10929              : 
   10930            0 :         columnWidth = {7, 30, 16, 10, 16, 16}; // array assignment - for all columns
   10931              : 
   10932            0 :         for (int item = 1; item <= (int)state.dataCostEstimateManager->CostLineItem.size(); ++item) {
   10933            0 :             tableBody(1, item) = fmt::to_string(state.dataCostEstimateManager->CostLineItem(item).LineNumber);
   10934            0 :             tableBody(2, item) = state.dataCostEstimateManager->CostLineItem(item).LineName;
   10935            0 :             if (unitsStyle_cur == OutputReportTabular::UnitsStyle::InchPound ||
   10936            0 :                 unitsStyle_cur == OutputReportTabular::UnitsStyle::InchPoundExceptElectricity) {
   10937            0 :                 std::string IPunitName;
   10938            0 :                 LookupSItoIP(state, state.dataCostEstimateManager->CostLineItem(item).Units, state.dataOutRptTab->unitConvIndexWCCT, IPunitName);
   10939            0 :                 if (state.dataOutRptTab->unitConvIndexWCCT != 0) {
   10940              :                     Real64 const IPqty =
   10941            0 :                         ConvertIP(state, state.dataOutRptTab->unitConvIndexWCCT, state.dataCostEstimateManager->CostLineItem(item).Qty);
   10942            0 :                     tableBody(3, item) = RealToStr(IPqty, 2);
   10943            0 :                     tableBody(4, item) = IPunitName;
   10944            0 :                     Real64 const IPsingleValue = ConvertIP(state, state.dataOutRptTab->unitConvIndexWCCT, 1.0);
   10945            0 :                     if (IPsingleValue != 0.0) {
   10946            0 :                         Real64 const IPvaluePer = state.dataCostEstimateManager->CostLineItem(item).ValuePer / IPsingleValue;
   10947            0 :                         tableBody(5, item) = RealToStr(IPvaluePer, 2);
   10948              :                     }
   10949              :                 } else {
   10950            0 :                     tableBody(3, item) = RealToStr(state.dataCostEstimateManager->CostLineItem(item).Qty, 2);
   10951            0 :                     tableBody(4, item) = state.dataCostEstimateManager->CostLineItem(item).Units;
   10952            0 :                     tableBody(5, item) = RealToStr(state.dataCostEstimateManager->CostLineItem(item).ValuePer, 2);
   10953              :                 }
   10954            0 :             } else {
   10955            0 :                 tableBody(3, item) = RealToStr(state.dataCostEstimateManager->CostLineItem(item).Qty, 2);
   10956            0 :                 tableBody(4, item) = state.dataCostEstimateManager->CostLineItem(item).Units;
   10957            0 :                 tableBody(5, item) = RealToStr(state.dataCostEstimateManager->CostLineItem(item).ValuePer, 2);
   10958              :             }
   10959            0 :             tableBody(6, item) = RealToStr(state.dataCostEstimateManager->CostLineItem(item).LineSubTotal, 2);
   10960              :         }
   10961            0 :         tableBody(6, NumRows) = RealToStr(state.dataCostEstimateManager->CurntBldg.LineItemTot, 2);
   10962            0 :         if (produceTabular) {
   10963            0 :             WriteSubtitle(state, "Cost Line Item Details"); //: '//TRIM(RealToStr(CostEstimateTotal, 2)))
   10964            0 :             WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
   10965              :         }
   10966            0 :         if (produceSQLite) {
   10967            0 :             if (state.dataSQLiteProcedures->sqlite) {
   10968            0 :                 state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
   10969              :                     tableBody, rowHead, columnHead, "Construction Cost Estimate Summary", "Entire Facility", "Cost Line Item Details");
   10970              :             }
   10971              :         }
   10972            0 :         if (produceTabular) {
   10973            0 :             if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
   10974            0 :                 state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(
   10975              :                     tableBody, rowHead, columnHead, "Construction Cost Estimate Summary", "Entire Facility", "Cost Line Item Details");
   10976              :             }
   10977              :         }
   10978              :     }
   10979            0 : }
   10980              : 
   10981              : // modify the ith row in the reportingperiod input verification table
   10982            0 : void writeRowReportPeriodInputVeri(const std::string &reportType,
   10983              :                                    Array2D_string &tableBody,
   10984              :                                    const int rowid,
   10985              :                                    const int periodIdx,
   10986              :                                    const Array1D<Weather::ReportPeriodData> &ReportPeriodInputData)
   10987              : {
   10988            0 :     tableBody(1, rowid) = reportType;
   10989            0 :     tableBody(2, rowid) = std::to_string(periodIdx);
   10990            0 :     tableBody(3, rowid) = ReportPeriodInputData(periodIdx).title;
   10991            0 :     tableBody(4, rowid) = formatReportPeriodTimestamp(ReportPeriodInputData(periodIdx).startYear,
   10992            0 :                                                       ReportPeriodInputData(periodIdx).startMonth,
   10993            0 :                                                       ReportPeriodInputData(periodIdx).startDay,
   10994            0 :                                                       ReportPeriodInputData(periodIdx).startHour);
   10995            0 :     tableBody(5, rowid) = formatReportPeriodTimestamp(ReportPeriodInputData(periodIdx).endYear,
   10996            0 :                                                       ReportPeriodInputData(periodIdx).endMonth,
   10997            0 :                                                       ReportPeriodInputData(periodIdx).endDay,
   10998            0 :                                                       ReportPeriodInputData(periodIdx).endHour);
   10999            0 :     tableBody(6, rowid) = RealToStr(ReportPeriodInputData(periodIdx).totalElectricityUse / 3600000.0, 2);
   11000            0 : }
   11001              : 
   11002           42 : void WriteVeriSumTable(EnergyPlusData &state)
   11003              : {
   11004              :     // SUBROUTINE INFORMATION:
   11005              :     //       AUTHOR         Jason Glazer
   11006              :     //       DATE WRITTEN   June 2006
   11007              :     //       MODIFIED       Jan. 2010, Kyle Benne. Added SQLite output
   11008              :     //                      Aug. 2015, Sang Hoon Lee. Added a new table for hybrid modeling multiplier output.
   11009              :     //       RE-ENGINEERED  na
   11010              : 
   11011              :     // PURPOSE OF THIS SUBROUTINE:
   11012              :     //   Summarize inputs and results for use with code and beyond-code
   11013              :     //   compliance into a tabular report for output.
   11014              : 
   11015              :     // METHODOLOGY EMPLOYED:
   11016              :     //   Create arrays for the call to WriteTable and then call it.
   11017              :     //   This report actually consists of many sub-tables each with
   11018              :     //   its own call to WriteTable.
   11019              : 
   11020              :     // Using/Aliasing
   11021              :     using DataHeatBalance::ZoneData;
   11022              :     using DataSurfaces::ExternalEnvironment;
   11023              :     using DataSurfaces::Ground;
   11024              :     using DataSurfaces::GroundFCfactorMethod;
   11025              :     using DataSurfaces::KivaFoundation;
   11026              :     using DataSurfaces::OtherSideCondModeledExt;
   11027              :     using DataSurfaces::SurfaceClass;
   11028              :     using General::SafeDivide;
   11029              : 
   11030           42 :     auto const &ort = state.dataOutRptTab;
   11031              : 
   11032              :     // all arrays are in the format: (row, column)
   11033           42 :     if (!ort->displayTabularVeriSum) {
   11034            0 :         return;
   11035              :     }
   11036              : 
   11037              :     // SUBROUTINE PARAMETER DEFINITIONS:
   11038           42 :     int constexpr wwrcTotal(1);
   11039           42 :     int constexpr wwrcNorth(2);
   11040           42 :     int constexpr wwrcEast(3);
   11041           42 :     int constexpr wwrcSouth(4);
   11042           42 :     int constexpr wwrcWest(5);
   11043           42 :     int constexpr wwrrWall(1);
   11044           42 :     int constexpr wwrrAbvGndWall(2);
   11045           42 :     int constexpr wwrrWindow(3);
   11046           42 :     int constexpr wwrrWWR(4);
   11047           42 :     int constexpr wwrrAbvGndWWR(5);
   11048              : 
   11049              :     // all arrays are in the format: (row, column)
   11050           42 :     Array1D_string columnHead;
   11051           42 :     Array1D_int columnWidth;
   11052           42 :     Array1D_string rowHead;
   11053           42 :     Array2D_string tableBody;
   11054              : 
   11055           42 :     Array1D<Real64> zoneOpeningArea;
   11056           42 :     zoneOpeningArea.allocate(state.dataGlobal->NumOfZones);
   11057              :     // zoneOpeningArea = 0.0;
   11058              : 
   11059           42 :     Array1D<Real64> zoneGlassArea;
   11060           42 :     zoneGlassArea.allocate(state.dataGlobal->NumOfZones);
   11061              :     // zoneGlassArea = 0.0;
   11062              : 
   11063           88 :     for (int iUnitSystem = 0; iUnitSystem <= 1; iUnitSystem++) {
   11064           84 :         UnitsStyle unitsStyle_cur = ort->unitsStyle;
   11065           84 :         bool produceTabular = true;
   11066           84 :         bool produceSQLite = false;
   11067           84 :         if (produceDualUnitsFlags(iUnitSystem, ort->unitsStyle, ort->unitsStyle_SQLite, unitsStyle_cur, produceTabular, produceSQLite)) {
   11068           38 :             break;
   11069              :         }
   11070              : 
   11071              :         // show the headers of the report
   11072           46 :         if (produceTabular) {
   11073          168 :             WriteReportHeaders(state, "Input Verification and Results Summary", "Entire Facility", OutputProcessor::StoreType::Average);
   11074              :         }
   11075              : 
   11076              :         // Moved these initializations into the loop
   11077           46 :         state.dataOutRptTab->zstArea = 0.0;
   11078           46 :         state.dataOutRptTab->zstVolume = 0.0;
   11079           46 :         state.dataOutRptTab->zstWallArea = 0.0;
   11080           46 :         state.dataOutRptTab->zstUndWallArea = 0.0;
   11081           46 :         state.dataOutRptTab->zstWindowArea = 0.0;
   11082           46 :         state.dataOutRptTab->zstOpeningArea = 0.0;
   11083           46 :         state.dataOutRptTab->zstLight = 0.0;
   11084           46 :         state.dataOutRptTab->zstPeople = 0.0;
   11085           46 :         state.dataOutRptTab->zstPlug = 0.0;
   11086              : 
   11087           46 :         zoneOpeningArea = 0.0;
   11088           46 :         zoneGlassArea = 0.0;
   11089              : 
   11090              :         // do unit conversions if necessary
   11091           46 :         if (unitsStyle_cur == UnitsStyle::InchPound) {
   11092            3 :             std::string SIunit;
   11093            3 :             SIunit = "[m]";
   11094            3 :             LookupSItoIP(state, SIunit, state.dataOutRptTab->unitConvIndexWVST, state.dataOutRptTab->m_unitName);
   11095            3 :             state.dataOutRptTab->m_unitConv = ConvertIP(state, state.dataOutRptTab->unitConvIndexWVST, 1.0);
   11096            3 :             SIunit = "[m2]";
   11097            3 :             LookupSItoIP(state, SIunit, state.dataOutRptTab->unitConvIndexWVST, state.dataOutRptTab->m2_unitName);
   11098            3 :             state.dataOutRptTab->m2_unitConvWVST = ConvertIP(state, state.dataOutRptTab->unitConvIndexWVST, 1.0);
   11099            3 :             SIunit = "[m3]";
   11100            3 :             LookupSItoIP(state, SIunit, state.dataOutRptTab->unitConvIndexWVST, state.dataOutRptTab->m3_unitName);
   11101            3 :             state.dataOutRptTab->m3_unitConv = ConvertIP(state, state.dataOutRptTab->unitConvIndexWVST, 1.0);
   11102            3 :             SIunit = "[W/m2]";
   11103            3 :             LookupSItoIP(state, SIunit, state.dataOutRptTab->unitConvIndexWVST, state.dataOutRptTab->Wm2_unitName);
   11104            3 :             state.dataOutRptTab->Wm2_unitConv = ConvertIP(state, state.dataOutRptTab->unitConvIndexWVST, 1.0);
   11105           46 :         } else if (unitsStyle_cur == UnitsStyle::InchPoundExceptElectricity) {
   11106            0 :             std::string SIunit;
   11107            0 :             SIunit = "[m]";
   11108            0 :             LookupSItoIP(state, SIunit, state.dataOutRptTab->unitConvIndexWVST, state.dataOutRptTab->m_unitName);
   11109            0 :             state.dataOutRptTab->m_unitConv = ConvertIP(state, state.dataOutRptTab->unitConvIndexWVST, 1.0);
   11110            0 :             SIunit = "[m2]";
   11111            0 :             LookupSItoIP(state, SIunit, state.dataOutRptTab->unitConvIndexWVST, state.dataOutRptTab->m2_unitName);
   11112            0 :             state.dataOutRptTab->m2_unitConvWVST = ConvertIP(state, state.dataOutRptTab->unitConvIndexWVST, 1.0);
   11113            0 :             SIunit = "[m3]";
   11114            0 :             LookupSItoIP(state, SIunit, state.dataOutRptTab->unitConvIndexWVST, state.dataOutRptTab->m3_unitName);
   11115            0 :             state.dataOutRptTab->m3_unitConv = ConvertIP(state, state.dataOutRptTab->unitConvIndexWVST, 1.0);
   11116              :             // SIunit = "[W/m2]";
   11117              :             // LookupSItoIP(state, SIunit, state.dataOutRptTab->unitConvIndexWVST, state.dataOutRptTab->Wm2_unitName);
   11118            0 :             state.dataOutRptTab->Wm2_unitName = "[W/ft2]";
   11119            0 :             state.dataOutRptTab->Wm2_unitConv = 0.3048 * 0.3048; // ConvertIP(state, state.dataOutRptTab->unitConvIndexWVST, 1.0);
   11120            0 :         } else {
   11121           43 :             state.dataOutRptTab->m_unitName = "[m]";
   11122           43 :             state.dataOutRptTab->m_unitConv = 1.0;
   11123           43 :             state.dataOutRptTab->m2_unitName = "[m2]";
   11124           43 :             state.dataOutRptTab->m2_unitConvWVST = 1.0;
   11125           43 :             state.dataOutRptTab->m3_unitName = "[m3]";
   11126           43 :             state.dataOutRptTab->m3_unitConv = 1.0;
   11127           43 :             state.dataOutRptTab->Wm2_unitName = "[W/m2]";
   11128           43 :             state.dataOutRptTab->Wm2_unitConv = 1.0;
   11129              :         }
   11130              :         //---- General Sub-Table
   11131              : 
   11132              :         // since a variable number of design days is possible, first read them before sizing the arrays
   11133           46 :         rowHead.allocate(10);
   11134           46 :         columnHead.allocate(1);
   11135           46 :         columnWidth.allocate(1);
   11136           46 :         columnWidth = 14; // array assignment - same for all columns
   11137           46 :         tableBody.allocate(1, 10);
   11138              : 
   11139           46 :         columnHead(1) = "Value";
   11140           46 :         rowHead(1) = "Program Version and Build";
   11141           46 :         rowHead(2) = "RunPeriod";
   11142           46 :         rowHead(3) = "Weather File";
   11143           46 :         rowHead(4) = "Latitude [deg]";
   11144           46 :         rowHead(5) = "Longitude [deg]";
   11145              : 
   11146           46 :         rowHead(6) = "Elevation " + state.dataOutRptTab->m_unitName;
   11147           46 :         rowHead(7) = "Time Zone";
   11148           46 :         rowHead(8) = "North Axis Angle [deg]";
   11149           46 :         rowHead(9) = "Rotation for Appendix G [deg]";
   11150           46 :         rowHead(10) = "Hours Simulated [hrs]";
   11151              :         //  rowHead(9)  = 'Num Table Entries' !used for debugging
   11152              : 
   11153           46 :         tableBody = "";
   11154              : 
   11155           46 :         tableBody(1, 1) = state.dataStrGlobals->VerStringVar;                                         // program
   11156           46 :         tableBody(1, 2) = state.dataEnvrn->EnvironmentName;                                           // runperiod name
   11157           46 :         tableBody(1, 3) = state.dataEnvrn->WeatherFileLocationTitle;                                  // weather
   11158           46 :         tableBody(1, 4) = RealToStr(state.dataEnvrn->Latitude, 2);                                    // latitude
   11159           46 :         tableBody(1, 5) = RealToStr(state.dataEnvrn->Longitude, 2);                                   // longitude
   11160           46 :         tableBody(1, 6) = RealToStr(state.dataEnvrn->Elevation * state.dataOutRptTab->m_unitConv, 2); // Elevation
   11161           46 :         tableBody(1, 7) = RealToStr(state.dataEnvrn->TimeZoneNumber, 2);                              // Time Zone
   11162           46 :         tableBody(1, 8) = RealToStr(state.dataHeatBal->BuildingAzimuth, 2);                           // north axis angle
   11163           46 :         tableBody(1, 9) = RealToStr(state.dataHeatBal->BuildingRotationAppendixG, 2);                 // Rotation for Appendix G
   11164           46 :         tableBody(1, 10) = RealToStr(ort->gatherElapsedTimeBEPS, 2);                                  // hours simulated
   11165              :         //  tableBody(9,1) = TRIM(fmt::to_string(numTableEntry)) !number of table entries for predefined tables
   11166              : 
   11167           46 :         if (produceTabular) {
   11168           42 :             WriteSubtitle(state, "General");
   11169           42 :             WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
   11170              :         }
   11171           46 :         if (produceSQLite) {
   11172           42 :             if (state.dataSQLiteProcedures->sqlite) {
   11173            7 :                 state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
   11174              :                     tableBody, rowHead, columnHead, "InputVerificationandResultsSummary", "Entire Facility", "General");
   11175              :             }
   11176              :         }
   11177           46 :         if (produceTabular) {
   11178           42 :             if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
   11179            0 :                 state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(
   11180              :                     tableBody, rowHead, columnHead, "InputVerificationandResultsSummary", "Entire Facility", "General");
   11181              :             }
   11182              : 
   11183              :             //---- Window Wall Ratio Sub-Table
   11184           84 :             WriteTextLine(state, "ENVELOPE", true);
   11185              :         }
   11186              : 
   11187           46 :         rowHead.allocate(5);
   11188           46 :         columnHead.allocate(5);
   11189           46 :         columnWidth.allocate(5);
   11190           46 :         columnWidth = 14; // array assignment - same for all columns
   11191           46 :         tableBody.allocate(5, 5);
   11192              : 
   11193           46 :         columnHead(wwrcTotal) = "Total";
   11194           46 :         columnHead(wwrcNorth) = "North (315 to 45 deg)";
   11195           46 :         columnHead(wwrcEast) = "East (45 to 135 deg)";
   11196           46 :         columnHead(wwrcSouth) = "South (135 to 225 deg)";
   11197           46 :         columnHead(wwrcWest) = "West (225 to 315 deg)";
   11198              : 
   11199           46 :         rowHead(wwrrWall) = "Gross Wall Area " + state.dataOutRptTab->m2_unitName;
   11200           46 :         rowHead(wwrrAbvGndWall) = "Above Ground Wall Area " + state.dataOutRptTab->m2_unitName;
   11201           46 :         rowHead(wwrrWindow) = "Window Opening Area " + state.dataOutRptTab->m2_unitName;
   11202           46 :         rowHead(wwrrWWR) = "Gross Window-Wall Ratio [%]";
   11203           46 :         rowHead(wwrrAbvGndWWR) = "Above Ground Window-Wall Ratio [%]";
   11204              : 
   11205           46 :         Real64 wallAreaN = 0.0;
   11206           46 :         Real64 wallAreaS = 0.0;
   11207           46 :         Real64 wallAreaE = 0.0;
   11208           46 :         Real64 wallAreaW = 0.0;
   11209           46 :         Real64 aboveGroundWallAreaN = 0.0;
   11210           46 :         Real64 aboveGroundWallAreaS = 0.0;
   11211           46 :         Real64 aboveGroundWallAreaE = 0.0;
   11212           46 :         Real64 aboveGroundWallAreaW = 0.0;
   11213           46 :         Real64 windowAreaN = 0.0;
   11214           46 :         Real64 windowAreaS = 0.0;
   11215           46 :         Real64 windowAreaE = 0.0;
   11216           46 :         Real64 windowAreaW = 0.0;
   11217              :         // wall and window areas attached to conditioned zones
   11218           46 :         Real64 wallAreaNcond = 0.0;
   11219           46 :         Real64 wallAreaScond = 0.0;
   11220           46 :         Real64 wallAreaEcond = 0.0;
   11221           46 :         Real64 wallAreaWcond = 0.0;
   11222           46 :         Real64 aboveGroundWallAreaNcond = 0.0;
   11223           46 :         Real64 aboveGroundWallAreaScond = 0.0;
   11224           46 :         Real64 aboveGroundWallAreaEcond = 0.0;
   11225           46 :         Real64 aboveGroundWallAreaWcond = 0.0;
   11226           46 :         Real64 windowAreaNcond = 0.0;
   11227           46 :         Real64 windowAreaScond = 0.0;
   11228           46 :         Real64 windowAreaEcond = 0.0;
   11229           46 :         Real64 windowAreaWcond = 0.0;
   11230              : 
   11231           46 :         Real64 roofArea = 0.0;
   11232           46 :         Real64 skylightArea = 0.0;
   11233              : 
   11234           92 :         bool DetailedWWR = (state.dataInputProcessing->inputProcessor->getNumSectionsFound("DETAILEDWWR_DEBUG") > 0);
   11235           46 :         if (DetailedWWR) {
   11236            0 :             if (produceTabular) {
   11237            0 :                 print(state.files.debug, "{}\n", "======90.1 Classification [>=60 & <=120] tilt = wall==================");
   11238            0 :                 print(state.files.debug, "{}\n", "SurfName,Class,Area,Tilt");
   11239              :             }
   11240              :         }
   11241              : 
   11242          332 :         for (int iSurf = 1; iSurf <= state.dataSurface->TotSurfaces; ++iSurf) {
   11243              :             // only exterior surfaces including underground
   11244          286 :             auto const &thisSurf = state.dataSurface->Surface(iSurf);
   11245          286 :             if (!thisSurf.HeatTransSurf) {
   11246            0 :                 continue;
   11247              :             }
   11248          286 :             bool const isAboveGround = (thisSurf.ExtBoundCond == ExternalEnvironment) || (thisSurf.ExtBoundCond == OtherSideCondModeledExt);
   11249          286 :             if (isAboveGround || (thisSurf.ExtBoundCond == Ground) || (thisSurf.ExtBoundCond == GroundFCfactorMethod) ||
   11250           58 :                 (thisSurf.ExtBoundCond == KivaFoundation)) {
   11251          228 :                 Real64 curAzimuth = thisSurf.Azimuth;
   11252              :                 // Round to two decimals, like the display in tables
   11253          228 :                 curAzimuth = round(curAzimuth * 100.0) / 100.0;
   11254          228 :                 Real64 curArea = thisSurf.GrossArea;
   11255          228 :                 if (thisSurf.FrameDivider != 0) {
   11256            8 :                     Real64 const frameWidth = state.dataSurface->FrameDivider(thisSurf.FrameDivider).FrameWidth;
   11257            8 :                     Real64 const frameArea =
   11258            8 :                         (thisSurf.Height + 2.0 * frameWidth) * (thisSurf.Width + 2.0 * frameWidth) - (thisSurf.Height * thisSurf.Width);
   11259            8 :                     curArea += frameArea;
   11260              :                 }
   11261          228 :                 int const zonePt = thisSurf.Zone;
   11262              : 
   11263          228 :                 bool const isConditioned = (zonePt > 0) && (state.dataHeatBal->Zone(zonePt).SystemZoneNodeNumber > 0);
   11264          228 :                 if ((thisSurf.Tilt >= 60.0) && (thisSurf.Tilt <= 120.0)) {
   11265              :                     // vertical walls and windows
   11266          160 :                     switch (thisSurf.Class) {
   11267          140 :                     case SurfaceClass::Wall:
   11268              :                     case SurfaceClass::Floor:
   11269              :                     case SurfaceClass::Roof: {
   11270          140 :                         auto const &thisZone = state.dataHeatBal->Zone(zonePt);
   11271          140 :                         Real64 const mult = thisZone.Multiplier * thisZone.ListMultiplier;
   11272          140 :                         if ((curAzimuth >= 315.0) || (curAzimuth < 45.0)) {
   11273           35 :                             wallAreaN += curArea * mult;
   11274           35 :                             if (isConditioned) {
   11275           13 :                                 wallAreaNcond += curArea * mult;
   11276              :                             }
   11277           35 :                             if (isAboveGround) {
   11278           35 :                                 aboveGroundWallAreaN += curArea * mult;
   11279           35 :                                 if (isConditioned) {
   11280           13 :                                     aboveGroundWallAreaNcond += curArea * mult;
   11281              :                                 }
   11282              :                             }
   11283          105 :                         } else if ((curAzimuth >= 45.0) && (curAzimuth < 135.0)) {
   11284           35 :                             wallAreaE += curArea * mult;
   11285           35 :                             if (isConditioned) {
   11286            9 :                                 wallAreaEcond += curArea * mult;
   11287              :                             }
   11288           35 :                             if (isAboveGround) {
   11289           35 :                                 aboveGroundWallAreaE += curArea * mult;
   11290           35 :                                 if (isConditioned) {
   11291            9 :                                     aboveGroundWallAreaEcond += curArea * mult;
   11292              :                                 }
   11293              :                             }
   11294           70 :                         } else if ((curAzimuth >= 135.0) && (curAzimuth < 225.0)) {
   11295           43 :                             wallAreaS += curArea * mult;
   11296           43 :                             if (isConditioned) {
   11297           17 :                                 wallAreaScond += curArea * mult;
   11298              :                             }
   11299           43 :                             if (isAboveGround) {
   11300           43 :                                 aboveGroundWallAreaS += curArea * mult;
   11301           43 :                                 if (isConditioned) {
   11302           17 :                                     aboveGroundWallAreaScond += curArea * mult;
   11303              :                                 }
   11304              :                             }
   11305           27 :                         } else if ((curAzimuth >= 225.0) && (curAzimuth < 315.0)) {
   11306           27 :                             wallAreaW += curArea * mult;
   11307           27 :                             if (isConditioned) {
   11308            5 :                                 wallAreaWcond += curArea * mult;
   11309              :                             }
   11310           27 :                             if (isAboveGround) {
   11311           27 :                                 aboveGroundWallAreaW += curArea * mult;
   11312           27 :                                 if (isConditioned) {
   11313            5 :                                     aboveGroundWallAreaWcond += curArea * mult;
   11314              :                                 }
   11315              :                             }
   11316              :                         }
   11317          140 :                         if (DetailedWWR) {
   11318            0 :                             if (produceTabular) {
   11319            0 :                                 print(state.files.debug, "{},Wall,{:.1R},{:.1R}\n", thisSurf.Name, curArea * mult, thisSurf.Tilt);
   11320              :                             }
   11321              :                         }
   11322          140 :                     } break;
   11323           20 :                     case SurfaceClass::Window:
   11324              :                     case SurfaceClass::TDD_Dome: {
   11325           20 :                         auto const &thisZone = state.dataHeatBal->Zone(zonePt);
   11326           20 :                         Real64 const mult = thisZone.Multiplier * thisZone.ListMultiplier * thisSurf.Multiplier;
   11327           20 :                         if ((curAzimuth >= 315.0) || (curAzimuth < 45.0)) {
   11328            8 :                             windowAreaN += curArea * mult;
   11329            8 :                             if (isConditioned) {
   11330            8 :                                 windowAreaNcond += curArea * mult;
   11331              :                             }
   11332           12 :                         } else if ((curAzimuth >= 45.0) && (curAzimuth < 135.0)) {
   11333            8 :                             windowAreaE += curArea * mult;
   11334            8 :                             if (isConditioned) {
   11335            4 :                                 windowAreaEcond += curArea * mult;
   11336              :                             }
   11337            4 :                         } else if ((curAzimuth >= 135.0) && (curAzimuth < 225.0)) {
   11338            4 :                             windowAreaS += curArea * mult;
   11339            4 :                             if (isConditioned) {
   11340            4 :                                 windowAreaScond += curArea * mult;
   11341              :                             }
   11342            0 :                         } else if ((curAzimuth >= 225.0) && (curAzimuth < 315.0)) {
   11343            0 :                             windowAreaW += curArea * mult;
   11344            0 :                             if (isConditioned) {
   11345            0 :                                 windowAreaWcond += curArea * mult;
   11346              :                             }
   11347              :                         }
   11348           20 :                         zoneOpeningArea(zonePt) += curArea * thisSurf.Multiplier; // total window opening area for each zone (glass plus frame area)
   11349           20 :                         zoneGlassArea(zonePt) += thisSurf.GrossArea * thisSurf.Multiplier;
   11350           20 :                         if (DetailedWWR) {
   11351            0 :                             if (produceTabular) {
   11352            0 :                                 print(state.files.debug, "{},Window,{:.1R},{:.1R}\n", thisSurf.Name, curArea * mult, thisSurf.Tilt);
   11353              :                             }
   11354              :                         }
   11355           20 :                     } break;
   11356            0 :                     default:
   11357            0 :                         break;
   11358              :                     }
   11359          228 :                 } else if (thisSurf.Tilt < 60.0) { // roof and skylights
   11360           36 :                     switch (thisSurf.Class) {
   11361           36 :                     case SurfaceClass::Wall:
   11362              :                     case SurfaceClass::Floor:
   11363              :                     case SurfaceClass::Roof: {
   11364           36 :                         auto const &thisZone = state.dataHeatBal->Zone(zonePt);
   11365           36 :                         Real64 const mult = thisZone.Multiplier * thisZone.ListMultiplier;
   11366           36 :                         roofArea += curArea * mult;
   11367           36 :                         if (DetailedWWR) {
   11368            0 :                             if (produceTabular) {
   11369            0 :                                 print(state.files.debug, "{},Roof,{:.1R},{:.1R}\n", thisSurf.Name, curArea * mult, thisSurf.Tilt);
   11370              :                             }
   11371              :                         }
   11372           36 :                     } break;
   11373            0 :                     case SurfaceClass::Window:
   11374              :                     case SurfaceClass::TDD_Dome: {
   11375            0 :                         auto const &thisZone = state.dataHeatBal->Zone(zonePt);
   11376            0 :                         Real64 const mult = thisZone.Multiplier * thisZone.ListMultiplier * thisSurf.Multiplier;
   11377            0 :                         skylightArea += curArea * mult;
   11378            0 :                         if (DetailedWWR) {
   11379            0 :                             if (produceTabular) {
   11380            0 :                                 print(state.files.debug, "{},Skylight,{:.1R},{:.1R}\n", thisSurf.Name, curArea * mult, thisSurf.Tilt);
   11381              :                             }
   11382              :                         }
   11383            0 :                     } break;
   11384            0 :                     default:
   11385            0 :                         break;
   11386              :                     }
   11387              :                 } else { // floors
   11388              :                          // ignored
   11389              :                 }
   11390              :             }
   11391              :         }
   11392              : 
   11393           46 :         Real64 TotalWallArea = wallAreaN + wallAreaS + wallAreaE + wallAreaW;
   11394           46 :         Real64 TotalAboveGroundWallArea = aboveGroundWallAreaN + aboveGroundWallAreaS + aboveGroundWallAreaE + aboveGroundWallAreaW;
   11395           46 :         Real64 TotalWindowArea = windowAreaN + windowAreaS + windowAreaE + windowAreaW;
   11396           46 :         if (DetailedWWR) {
   11397            0 :             if (produceTabular) {
   11398            0 :                 print(state.files.debug, "{}\n", "========================");
   11399            0 :                 print(state.files.debug, "{}\n", "TotalWallArea,WallAreaN,WallAreaS,WallAreaE,WallAreaW");
   11400            0 :                 print(state.files.debug, "{}\n", "TotalWindowArea,WindowAreaN,WindowAreaS,WindowAreaE,WindowAreaW");
   11401            0 :                 print(state.files.debug, "{:.2R},{:.2R},{:.2R},{:.2R},{:.2R}\n", TotalWallArea, wallAreaN, wallAreaS, wallAreaE, wallAreaW);
   11402            0 :                 print(state.files.debug, "{:.2R},{:.2R},{:.2R},{:.2R},{:.2R}\n", TotalWindowArea, windowAreaN, windowAreaS, windowAreaE, windowAreaW);
   11403              :             }
   11404              :         }
   11405              : 
   11406           46 :         tableBody = "";
   11407              : 
   11408           46 :         tableBody(wwrcNorth, wwrrWall) = RealToStr(wallAreaN * state.dataOutRptTab->m2_unitConvWVST, 2);
   11409           46 :         tableBody(wwrcSouth, wwrrWall) = RealToStr(wallAreaS * state.dataOutRptTab->m2_unitConvWVST, 2);
   11410           46 :         tableBody(wwrcEast, wwrrWall) = RealToStr(wallAreaE * state.dataOutRptTab->m2_unitConvWVST, 2);
   11411           46 :         tableBody(wwrcWest, wwrrWall) = RealToStr(wallAreaW * state.dataOutRptTab->m2_unitConvWVST, 2);
   11412           46 :         tableBody(wwrcTotal, wwrrWall) = RealToStr(TotalWallArea * state.dataOutRptTab->m2_unitConvWVST, 2);
   11413              : 
   11414           46 :         tableBody(wwrcNorth, wwrrAbvGndWall) = RealToStr(aboveGroundWallAreaN * state.dataOutRptTab->m2_unitConvWVST, 2);
   11415           46 :         tableBody(wwrcSouth, wwrrAbvGndWall) = RealToStr(aboveGroundWallAreaS * state.dataOutRptTab->m2_unitConvWVST, 2);
   11416           46 :         tableBody(wwrcEast, wwrrAbvGndWall) = RealToStr(aboveGroundWallAreaE * state.dataOutRptTab->m2_unitConvWVST, 2);
   11417           46 :         tableBody(wwrcWest, wwrrAbvGndWall) = RealToStr(aboveGroundWallAreaW * state.dataOutRptTab->m2_unitConvWVST, 2);
   11418           46 :         tableBody(wwrcTotal, wwrrAbvGndWall) = RealToStr(TotalAboveGroundWallArea * state.dataOutRptTab->m2_unitConvWVST, 2);
   11419              : 
   11420           46 :         tableBody(wwrcNorth, wwrrWindow) = RealToStr(windowAreaN * state.dataOutRptTab->m2_unitConvWVST, 2);
   11421           46 :         tableBody(wwrcSouth, wwrrWindow) = RealToStr(windowAreaS * state.dataOutRptTab->m2_unitConvWVST, 2);
   11422           46 :         tableBody(wwrcEast, wwrrWindow) = RealToStr(windowAreaE * state.dataOutRptTab->m2_unitConvWVST, 2);
   11423           46 :         tableBody(wwrcWest, wwrrWindow) = RealToStr(windowAreaW * state.dataOutRptTab->m2_unitConvWVST, 2);
   11424           46 :         tableBody(wwrcTotal, wwrrWindow) = RealToStr(TotalWindowArea * state.dataOutRptTab->m2_unitConvWVST, 2);
   11425              : 
   11426           46 :         tableBody(wwrcNorth, wwrrWWR) = RealToStr(100.0 * SafeDivide(windowAreaN, wallAreaN), 2);
   11427           46 :         tableBody(wwrcSouth, wwrrWWR) = RealToStr(100.0 * SafeDivide(windowAreaS, wallAreaS), 2);
   11428           46 :         tableBody(wwrcEast, wwrrWWR) = RealToStr(100.0 * SafeDivide(windowAreaE, wallAreaE), 2);
   11429           46 :         tableBody(wwrcWest, wwrrWWR) = RealToStr(100.0 * SafeDivide(windowAreaW, wallAreaW), 2);
   11430           46 :         tableBody(wwrcTotal, wwrrWWR) = RealToStr(100.0 * SafeDivide(TotalWindowArea, TotalWallArea), 2);
   11431              : 
   11432           46 :         tableBody(wwrcNorth, wwrrAbvGndWWR) = RealToStr(100.0 * SafeDivide(windowAreaN, aboveGroundWallAreaN), 2);
   11433           46 :         tableBody(wwrcSouth, wwrrAbvGndWWR) = RealToStr(100.0 * SafeDivide(windowAreaS, aboveGroundWallAreaS), 2);
   11434           46 :         tableBody(wwrcEast, wwrrAbvGndWWR) = RealToStr(100.0 * SafeDivide(windowAreaE, aboveGroundWallAreaE), 2);
   11435           46 :         tableBody(wwrcWest, wwrrAbvGndWWR) = RealToStr(100.0 * SafeDivide(windowAreaW, aboveGroundWallAreaW), 2);
   11436           46 :         tableBody(wwrcTotal, wwrrAbvGndWWR) = RealToStr(100.0 * SafeDivide(TotalWindowArea, TotalAboveGroundWallArea), 2);
   11437              : 
   11438           46 :         if (produceTabular) {
   11439           42 :             WriteSubtitle(state, "Window-Wall Ratio");
   11440           42 :             WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
   11441              :         }
   11442           46 :         if (produceSQLite) {
   11443           42 :             if (state.dataSQLiteProcedures->sqlite) {
   11444            7 :                 state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
   11445              :                     tableBody, rowHead, columnHead, "InputVerificationandResultsSummary", "Entire Facility", "Window-Wall Ratio");
   11446              :             }
   11447              :         }
   11448           46 :         if (produceTabular) {
   11449           42 :             if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
   11450            0 :                 state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(
   11451              :                     tableBody, rowHead, columnHead, "InputVerificationandResultsSummary", "Entire Facility", "Window-Wall Ratio");
   11452              :             }
   11453              :         }
   11454              : 
   11455              :         //---- Conditioned Window Wall Ratio Sub-Table
   11456           46 :         rowHead.allocate(5);
   11457           46 :         columnHead.allocate(5);
   11458           46 :         columnWidth.allocate(5);
   11459           46 :         columnWidth = 14; // array assignment - same for all columns
   11460           46 :         tableBody.allocate(5, 5);
   11461              : 
   11462           46 :         columnHead(wwrcTotal) = "Total";
   11463           46 :         columnHead(wwrcNorth) = "North (315 to 45 deg)";
   11464           46 :         columnHead(wwrcEast) = "East (45 to 135 deg)";
   11465           46 :         columnHead(wwrcSouth) = "South (135 to 225 deg)";
   11466           46 :         columnHead(wwrcWest) = "West (225 to 315 deg)";
   11467              : 
   11468           46 :         rowHead(wwrrWall) = "Gross Wall Area " + state.dataOutRptTab->m2_unitName;
   11469           46 :         rowHead(wwrrAbvGndWall) = "Above Ground Wall Area " + state.dataOutRptTab->m2_unitName;
   11470           46 :         rowHead(wwrrWindow) = "Window Opening Area " + state.dataOutRptTab->m2_unitName;
   11471           46 :         rowHead(wwrrWWR) = "Gross Window-Wall Ratio [%]";
   11472           46 :         rowHead(wwrrAbvGndWWR) = "Above Ground Window-Wall Ratio [%]";
   11473              : 
   11474              :         // calculations appear in last block with normal window-wall ratio table
   11475              : 
   11476           46 :         TotalWallArea = wallAreaNcond + wallAreaScond + wallAreaEcond + wallAreaWcond;
   11477           46 :         TotalAboveGroundWallArea = aboveGroundWallAreaNcond + aboveGroundWallAreaScond + aboveGroundWallAreaEcond + aboveGroundWallAreaWcond;
   11478           46 :         TotalWindowArea = windowAreaNcond + windowAreaScond + windowAreaEcond + windowAreaWcond;
   11479              : 
   11480           46 :         tableBody = "";
   11481              : 
   11482           46 :         tableBody(wwrcNorth, wwrrWall) = RealToStr(wallAreaNcond * state.dataOutRptTab->m2_unitConvWVST, 2);
   11483           46 :         tableBody(wwrcSouth, wwrrWall) = RealToStr(wallAreaScond * state.dataOutRptTab->m2_unitConvWVST, 2);
   11484           46 :         tableBody(wwrcEast, wwrrWall) = RealToStr(wallAreaEcond * state.dataOutRptTab->m2_unitConvWVST, 2);
   11485           46 :         tableBody(wwrcWest, wwrrWall) = RealToStr(wallAreaWcond * state.dataOutRptTab->m2_unitConvWVST, 2);
   11486           46 :         tableBody(wwrcTotal, wwrrWall) = RealToStr(TotalWallArea * state.dataOutRptTab->m2_unitConvWVST, 2);
   11487              : 
   11488           46 :         tableBody(wwrcNorth, wwrrAbvGndWall) = RealToStr(aboveGroundWallAreaNcond * state.dataOutRptTab->m2_unitConvWVST, 2);
   11489           46 :         tableBody(wwrcSouth, wwrrAbvGndWall) = RealToStr(aboveGroundWallAreaScond * state.dataOutRptTab->m2_unitConvWVST, 2);
   11490           46 :         tableBody(wwrcEast, wwrrAbvGndWall) = RealToStr(aboveGroundWallAreaEcond * state.dataOutRptTab->m2_unitConvWVST, 2);
   11491           46 :         tableBody(wwrcWest, wwrrAbvGndWall) = RealToStr(aboveGroundWallAreaWcond * state.dataOutRptTab->m2_unitConvWVST, 2);
   11492           46 :         tableBody(wwrcTotal, wwrrAbvGndWall) = RealToStr(TotalAboveGroundWallArea * state.dataOutRptTab->m2_unitConvWVST, 2);
   11493              : 
   11494           46 :         tableBody(wwrcNorth, wwrrWindow) = RealToStr(windowAreaNcond * state.dataOutRptTab->m2_unitConvWVST, 2);
   11495           46 :         tableBody(wwrcSouth, wwrrWindow) = RealToStr(windowAreaScond * state.dataOutRptTab->m2_unitConvWVST, 2);
   11496           46 :         tableBody(wwrcEast, wwrrWindow) = RealToStr(windowAreaEcond * state.dataOutRptTab->m2_unitConvWVST, 2);
   11497           46 :         tableBody(wwrcWest, wwrrWindow) = RealToStr(windowAreaWcond * state.dataOutRptTab->m2_unitConvWVST, 2);
   11498           46 :         tableBody(wwrcTotal, wwrrWindow) = RealToStr(TotalWindowArea * state.dataOutRptTab->m2_unitConvWVST, 2);
   11499              : 
   11500           46 :         tableBody(wwrcNorth, wwrrWWR) = RealToStr(100.0 * SafeDivide(windowAreaNcond, wallAreaNcond), 2);
   11501           46 :         tableBody(wwrcSouth, wwrrWWR) = RealToStr(100.0 * SafeDivide(windowAreaScond, wallAreaScond), 2);
   11502           46 :         tableBody(wwrcEast, wwrrWWR) = RealToStr(100.0 * SafeDivide(windowAreaEcond, wallAreaEcond), 2);
   11503           46 :         tableBody(wwrcWest, wwrrWWR) = RealToStr(100.0 * SafeDivide(windowAreaWcond, wallAreaWcond), 2);
   11504           46 :         tableBody(wwrcTotal, wwrrWWR) = RealToStr(100.0 * SafeDivide(TotalWindowArea, TotalWallArea), 2);
   11505              : 
   11506           46 :         tableBody(wwrcNorth, wwrrAbvGndWWR) = RealToStr(100.0 * SafeDivide(windowAreaNcond, aboveGroundWallAreaNcond), 2);
   11507           46 :         tableBody(wwrcSouth, wwrrAbvGndWWR) = RealToStr(100.0 * SafeDivide(windowAreaScond, aboveGroundWallAreaScond), 2);
   11508           46 :         tableBody(wwrcEast, wwrrAbvGndWWR) = RealToStr(100.0 * SafeDivide(windowAreaEcond, aboveGroundWallAreaEcond), 2);
   11509           46 :         tableBody(wwrcWest, wwrrAbvGndWWR) = RealToStr(100.0 * SafeDivide(windowAreaWcond, aboveGroundWallAreaWcond), 2);
   11510           46 :         tableBody(wwrcTotal, wwrrAbvGndWWR) = RealToStr(100.0 * SafeDivide(TotalWindowArea, TotalAboveGroundWallArea), 2);
   11511              : 
   11512           46 :         if (produceTabular) {
   11513           42 :             WriteSubtitle(state, "Conditioned Window-Wall Ratio");
   11514           42 :             WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
   11515              :         }
   11516           46 :         if (produceSQLite) {
   11517           42 :             if (state.dataSQLiteProcedures->sqlite) {
   11518            7 :                 state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
   11519              :                     tableBody, rowHead, columnHead, "InputVerificationandResultsSummary", "Entire Facility", "Conditioned Window-Wall Ratio");
   11520              :             }
   11521              :         }
   11522           46 :         if (produceTabular) {
   11523           42 :             if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
   11524            0 :                 state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(
   11525              :                     tableBody, rowHead, columnHead, "InputVerificationandResultsSummary", "Entire Facility", "Conditioned Window-Wall Ratio");
   11526              :             }
   11527              :         }
   11528              : 
   11529              :         //---- Skylight Roof Ratio Sub-Table
   11530           46 :         rowHead.allocate(3);
   11531           46 :         columnHead.allocate(1);
   11532           46 :         columnWidth.allocate(1);
   11533           46 :         columnWidth = 14; // array assignment - same for all columns
   11534           46 :         tableBody.allocate(1, 3);
   11535              : 
   11536           46 :         columnHead(1) = "Total";
   11537              : 
   11538           46 :         rowHead(1) = "Gross Roof Area " + state.dataOutRptTab->m2_unitName;
   11539           46 :         rowHead(2) = "Skylight Area " + state.dataOutRptTab->m2_unitName;
   11540           46 :         rowHead(3) = "Skylight-Roof Ratio [%]";
   11541              : 
   11542           46 :         if (DetailedWWR) {
   11543            0 :             if (produceTabular) {
   11544            0 :                 print(state.files.debug, "{}\n", "========================");
   11545            0 :                 print(state.files.debug, "{}\n", "TotalRoofArea,SkylightArea");
   11546            0 :                 print(state.files.debug, "{:.2R},{:.2R}\n", roofArea, skylightArea);
   11547              :             }
   11548              :         }
   11549              : 
   11550           46 :         tableBody(1, 1) = RealToStr(roofArea * state.dataOutRptTab->m2_unitConvWVST, 2);
   11551           46 :         tableBody(1, 2) = RealToStr(skylightArea * state.dataOutRptTab->m2_unitConvWVST, 2);
   11552           46 :         tableBody(1, 3) = RealToStr(100.0 * SafeDivide(skylightArea, roofArea), 2);
   11553              : 
   11554           46 :         if (produceTabular) {
   11555           42 :             WriteSubtitle(state, "Skylight-Roof Ratio");
   11556           42 :             WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
   11557              :         }
   11558           46 :         if (produceSQLite) {
   11559           42 :             if (state.dataSQLiteProcedures->sqlite) {
   11560            7 :                 state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
   11561              :                     tableBody, rowHead, columnHead, "InputVerificationandResultsSummary", "Entire Facility", "Skylight-Roof Ratio");
   11562              :             }
   11563              :         }
   11564           46 :         if (produceTabular) {
   11565           42 :             if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
   11566            0 :                 state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(
   11567              :                     tableBody, rowHead, columnHead, "InputVerificationandResultsSummary", "Entire Facility", "Skylight-Roof Ratio");
   11568              :             }
   11569              :         }
   11570              : 
   11571              :         //---- Hybrid Model: Internal Thermal Mass Sub-Table
   11572           46 :         if (state.dataHybridModel->FlagHybridModel_TM) {
   11573            0 :             rowHead.allocate(state.dataGlobal->NumOfZones);
   11574            0 :             int const NumOfCol = 2;
   11575            0 :             columnHead.allocate(NumOfCol);
   11576            0 :             columnWidth.allocate(NumOfCol);
   11577            0 :             columnWidth = 14; // array assignment - same for all columns
   11578            0 :             tableBody.allocate(NumOfCol, state.dataGlobal->NumOfZones);
   11579              : 
   11580            0 :             columnHead(1) = "Hybrid Modeling (Y/N)";
   11581            0 :             columnHead(2) = "Temperature Capacitance Multiplier ";
   11582              : 
   11583            0 :             rowHead = "";
   11584            0 :             tableBody = "";
   11585              : 
   11586            0 :             for (int iZone = 1; iZone <= state.dataGlobal->NumOfZones; ++iZone) {
   11587            0 :                 auto const &thisZone = state.dataHeatBal->Zone(iZone);
   11588              : 
   11589            0 :                 rowHead(iZone) = thisZone.Name;
   11590            0 :                 if (state.dataHybridModel->hybridModelZones(iZone).InternalThermalMassCalc_T) {
   11591            0 :                     tableBody(1, iZone) = "Yes";
   11592              :                 } else {
   11593            0 :                     tableBody(1, iZone) = "No";
   11594              :                 }
   11595            0 :                 tableBody(2, iZone) = RealToStr(thisZone.ZoneVolCapMultpSensHMAverage, 2);
   11596              :             }
   11597              : 
   11598            0 :             if (produceTabular) {
   11599            0 :                 WriteSubtitle(state, "Hybrid Model: Internal Thermal Mass");
   11600            0 :                 WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
   11601              :             }
   11602            0 :             if (produceSQLite) {
   11603            0 :                 if (state.dataSQLiteProcedures->sqlite) {
   11604            0 :                     state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(tableBody,
   11605              :                                                                                        rowHead,
   11606              :                                                                                        columnHead,
   11607              :                                                                                        "InputVerificationandResultsSummary",
   11608              :                                                                                        "Entire Facility",
   11609              :                                                                                        "Hybrid Model: Internal Thermal Mass");
   11610              :                 }
   11611              :             }
   11612              :         }
   11613              : 
   11614           46 :         Real64 const totExtGrossWallArea_Multiplied = sum(state.dataHeatBal->Zone, &ZoneData::ExtGrossWallArea_Multiplied);
   11615           46 :         Real64 const totExtGrossGroundWallArea_Multiplied = sum(state.dataHeatBal->Zone, &ZoneData::ExtGrossGroundWallArea_Multiplied);
   11616           46 :         if (totExtGrossWallArea_Multiplied > 0.0 || totExtGrossGroundWallArea_Multiplied > 0.0) {
   11617              :             Real64 const pdiff =
   11618           38 :                 std::abs((wallAreaN + wallAreaS + wallAreaE + wallAreaW) - (totExtGrossWallArea_Multiplied + totExtGrossGroundWallArea_Multiplied)) /
   11619           38 :                 (totExtGrossWallArea_Multiplied + totExtGrossGroundWallArea_Multiplied);
   11620           38 :             if (pdiff > 0.019) {
   11621            0 :                 if (produceTabular) {
   11622            0 :                     ShowWarningError(
   11623              :                         state, "WriteVeriSumTable: InputVerificationsAndResultsSummary: Wall area based on [>=60,<=120] degrees (tilt) as walls");
   11624            0 :                     ShowContinueError(state,
   11625            0 :                                       format("differs ~{:.1R}% from user entered Wall class surfaces. Degree calculation based on ASHRAE "
   11626              :                                              "90.1 wall definitions.",
   11627            0 :                                              pdiff * 100.0));
   11628              :                     //      CALL ShowContinueError(state, format("Calculated based on degrees=[{}{}{}{}{}{}] m2, Calculated from user entered Wall
   11629              :                     //      class surfaces=[{}{}{}{}{}{}", //, &, //, TRIM(ADJUSTL(RealToStr((wallAreaN + wallAreaS + wallAreaE +
   11630              :                     //      wallAreaW),3)))//, &, //, //, &, //,
   11631              :                     //      TRIM(ADJUSTL(RealToStr(SUM(Zone(1:NumOfZones)%ExtGrossWallArea_Multiplied),3)))//', m2.'), ShowContinueError(state,
   11632              :                     //      "Check classes of surfaces and tilts for discrepancies."));
   11633            0 :                     ShowContinueError(state,
   11634            0 :                                       format("Total wall area by ASHRAE 90.1 definition={} m2.",
   11635            0 :                                              stripped(RealToStr((wallAreaN + wallAreaS + wallAreaE + wallAreaW), 3))));
   11636            0 :                     ShowContinueError(
   11637              :                         state,
   11638            0 :                         format("Total exterior wall area from user entered classes={} m2.", stripped(RealToStr(totExtGrossWallArea_Multiplied, 3))));
   11639            0 :                     ShowContinueError(state,
   11640            0 :                                       format("Total ground contact wall area from user entered classes={} m2.",
   11641            0 :                                              stripped(RealToStr(totExtGrossGroundWallArea_Multiplied, 3))));
   11642              :                 }
   11643              :             }
   11644              :         }
   11645              :         //---- Space Summary Sub-Table
   11646           46 :         if (produceTabular) {
   11647           84 :             WriteTextLine(state, "PERFORMANCE", true);
   11648              :         }
   11649              : 
   11650           46 :         rowHead.allocate(state.dataGlobal->NumOfZones + 4);
   11651              : 
   11652           46 :         int const NumOfCol = 12;
   11653           46 :         columnHead.allocate(NumOfCol);
   11654           46 :         columnWidth.allocate(NumOfCol);
   11655           46 :         columnWidth = 14; // array assignment - same for all columns
   11656           46 :         tableBody.allocate(NumOfCol, state.dataGlobal->NumOfZones + 4);
   11657              : 
   11658           46 :         columnHead(1) = "Area " + state.dataOutRptTab->m2_unitName;
   11659           46 :         columnHead(2) = "Conditioned (Y/N)";
   11660           46 :         columnHead(3) = "Part of Total Floor Area (Y/N)";
   11661           46 :         columnHead(4) = "Volume " + state.dataOutRptTab->m3_unitName;
   11662           46 :         columnHead(5) = "Multipliers";
   11663           46 :         columnHead(6) = "Above Ground Gross Wall Area " + state.dataOutRptTab->m2_unitName;
   11664           46 :         columnHead(7) = "Underground Gross Wall Area " + state.dataOutRptTab->m2_unitName;
   11665           46 :         columnHead(8) = "Window Glass Area " + state.dataOutRptTab->m2_unitName;
   11666           46 :         columnHead(9) = "Opening Area " + state.dataOutRptTab->m2_unitName;
   11667           46 :         columnHead(10) = "Lighting " + state.dataOutRptTab->Wm2_unitName;
   11668           92 :         columnHead(11) = "People " + state.dataOutRptTab->m2_unitName.substr(0, len(state.dataOutRptTab->m2_unitName) - 1) + " per person" +
   11669           92 :                          state.dataOutRptTab->m2_unitName[len(state.dataOutRptTab->m2_unitName) - 1];
   11670           46 :         columnHead(12) = "Plug and Process " + state.dataOutRptTab->Wm2_unitName;
   11671              : 
   11672           46 :         rowHead = "";
   11673           46 :         rowHead(state.dataGlobal->NumOfZones + state.dataOutRptTab->grandTotal) = "Total";
   11674           46 :         rowHead(state.dataGlobal->NumOfZones + state.dataOutRptTab->condTotal) = "Conditioned Total";
   11675           46 :         rowHead(state.dataGlobal->NumOfZones + state.dataOutRptTab->uncondTotal) = "Unconditioned Total";
   11676           46 :         rowHead(state.dataGlobal->NumOfZones + state.dataOutRptTab->notpartTotal) = "Not Part of Total";
   11677              : 
   11678           46 :         tableBody = "";
   11679              : 
   11680          106 :         for (int iZone = 1; iZone <= state.dataGlobal->NumOfZones; ++iZone) {
   11681           60 :             auto const &thisZone = state.dataHeatBal->Zone(iZone);
   11682              : 
   11683           60 :             Real64 const mult = thisZone.Multiplier * thisZone.ListMultiplier;
   11684           60 :             rowHead(iZone) = thisZone.Name;
   11685              :             // Conditioned or not
   11686           60 :             bool zoneIsCond = false;
   11687           60 :             if (thisZone.SystemZoneNodeNumber > 0) {
   11688           30 :                 tableBody(2, iZone) = "Yes";
   11689           30 :                 zoneIsCond = true;
   11690              :             } else {
   11691           30 :                 tableBody(2, iZone) = "No";
   11692           30 :                 zoneIsCond = false;
   11693              :             }
   11694              :             // Part of Total Floor Area or not
   11695           60 :             bool usezoneFloorArea = false;
   11696           60 :             if (thisZone.isPartOfTotalArea) {
   11697           56 :                 tableBody(3, iZone) = "Yes";
   11698           56 :                 usezoneFloorArea = true;
   11699              :             } else {
   11700            4 :                 tableBody(3, iZone) = "No";
   11701            4 :                 usezoneFloorArea = false;
   11702              :             }
   11703           60 :             tableBody(1, iZone) = RealToStr(thisZone.FloorArea * state.dataOutRptTab->m2_unitConvWVST, 2);
   11704           60 :             tableBody(4, iZone) = RealToStr(thisZone.Volume * state.dataOutRptTab->m3_unitConv, 2);
   11705              :             // no unit conversion necessary since done automatically
   11706           60 :             if (produceTabular) {
   11707           52 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchLeedSutSpArea, thisZone.Name, thisZone.FloorArea, 2);
   11708              :             }
   11709           60 :             if (zoneIsCond) {
   11710           30 :                 if (produceTabular) {
   11711           24 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchLeedSutOcArea, thisZone.Name, thisZone.FloorArea, 2);
   11712           24 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchLeedSutUnArea, thisZone.Name, "0.00");
   11713              :                 }
   11714              :             } else {
   11715           30 :                 if (produceTabular) {
   11716           28 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchLeedSutOcArea, thisZone.Name, "0.00");
   11717           28 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchLeedSutUnArea, thisZone.Name, thisZone.FloorArea, 2);
   11718              :                 }
   11719              :             }
   11720           60 :             tableBody(5, iZone) = RealToStr(mult, 2);
   11721           60 :             tableBody(6, iZone) = RealToStr(thisZone.ExtGrossWallArea * state.dataOutRptTab->m2_unitConvWVST, 2);
   11722           60 :             tableBody(7, iZone) = RealToStr(thisZone.ExtGrossGroundWallArea * state.dataOutRptTab->m2_unitConvWVST, 2);
   11723           60 :             tableBody(8, iZone) = RealToStr(zoneGlassArea(iZone) * state.dataOutRptTab->m2_unitConvWVST, 2);
   11724           60 :             tableBody(9, iZone) = RealToStr(zoneOpeningArea(iZone) * state.dataOutRptTab->m2_unitConvWVST, 2);
   11725              :             // lighting density
   11726           60 :             Real64 totLightPower = 0.0;
   11727          121 :             for (int iLight = 1; iLight <= state.dataHeatBal->TotLights; ++iLight) {
   11728           61 :                 if (iZone == state.dataHeatBal->Lights(iLight).ZonePtr) {
   11729           25 :                     totLightPower += state.dataHeatBal->Lights(iLight).DesignLevel;
   11730              :                 }
   11731              :             }
   11732           60 :             if (thisZone.FloorArea > 0) {
   11733           60 :                 tableBody(10, iZone) = RealToStr(state.dataOutRptTab->Wm2_unitConv * totLightPower / thisZone.FloorArea, 4);
   11734              :             }
   11735              :             // people density
   11736           60 :             Real64 totNumPeople = 0.0;
   11737          122 :             for (int iPeople = 1; iPeople <= state.dataHeatBal->TotPeople; ++iPeople) {
   11738           62 :                 if (iZone == state.dataHeatBal->People(iPeople).ZonePtr) {
   11739           24 :                     totNumPeople += state.dataHeatBal->People(iPeople).NumberOfPeople;
   11740              :                 }
   11741              :             }
   11742           60 :             if (totNumPeople > 0) {
   11743           24 :                 tableBody(11, iZone) = RealToStr(thisZone.FloorArea * state.dataOutRptTab->m2_unitConvWVST / totNumPeople, 2);
   11744              :             }
   11745              :             // plug and process density
   11746           60 :             Real64 totPlugProcess = 0.0;
   11747          152 :             for (int iPlugProc = 1; iPlugProc <= state.dataHeatBal->TotElecEquip; ++iPlugProc) {
   11748           92 :                 if (iZone == state.dataHeatBal->ZoneElectric(iPlugProc).ZonePtr) {
   11749           54 :                     totPlugProcess += state.dataHeatBal->ZoneElectric(iPlugProc).DesignLevel;
   11750              :                 }
   11751              :             }
   11752           60 :             for (int iPlugProc = 1; iPlugProc <= state.dataHeatBal->TotGasEquip; ++iPlugProc) {
   11753            0 :                 if (iZone == state.dataHeatBal->ZoneGas(iPlugProc).ZonePtr) {
   11754            0 :                     totPlugProcess += state.dataHeatBal->ZoneGas(iPlugProc).DesignLevel;
   11755              :                 }
   11756              :             }
   11757          104 :             for (int iPlugProc = 1; iPlugProc <= state.dataHeatBal->TotOthEquip; ++iPlugProc) {
   11758           44 :                 if (iZone == state.dataHeatBal->ZoneOtherEq(iPlugProc).ZonePtr) {
   11759           44 :                     totPlugProcess += state.dataHeatBal->ZoneOtherEq(iPlugProc).DesignLevel;
   11760              :                 }
   11761              :             }
   11762           60 :             for (int iPlugProc = 1; iPlugProc <= state.dataHeatBal->TotHWEquip; ++iPlugProc) {
   11763            0 :                 if (iZone == state.dataHeatBal->ZoneHWEq(iPlugProc).ZonePtr) {
   11764            0 :                     totPlugProcess += state.dataHeatBal->ZoneHWEq(iPlugProc).DesignLevel;
   11765              :                 }
   11766              :             }
   11767           78 :             for (int iPlugProc = 1; iPlugProc <= state.dataHeatBal->TotITEquip; ++iPlugProc) {
   11768           18 :                 if (iZone == state.dataHeatBal->ZoneITEq(iPlugProc).ZonePtr) {
   11769            6 :                     totPlugProcess += state.dataHeatBal->ZoneITEq(iPlugProc).DesignTotalPower;
   11770              :                 }
   11771              :             }
   11772           60 :             if (thisZone.FloorArea > 0) {
   11773           60 :                 tableBody(12, iZone) = RealToStr(totPlugProcess * state.dataOutRptTab->Wm2_unitConv / thisZone.FloorArea, 4);
   11774              :             }
   11775              : 
   11776              :             // total rows for Total / Not Part of Total
   11777              :             // In "Total": break between conditioned/unconditioned
   11778              : 
   11779              :             // If not part of total, goes directly to this row
   11780           60 :             if (!usezoneFloorArea) {
   11781            4 :                 state.dataOutRptTab->zstArea(state.dataOutRptTab->notpartTotal) += mult * thisZone.FloorArea;
   11782            4 :                 state.dataOutRptTab->zstVolume(state.dataOutRptTab->notpartTotal) += mult * thisZone.Volume;
   11783            4 :                 state.dataOutRptTab->zstWallArea(state.dataOutRptTab->notpartTotal) += mult * thisZone.ExtGrossWallArea;
   11784            4 :                 state.dataOutRptTab->zstUndWallArea(state.dataOutRptTab->notpartTotal) += mult * thisZone.ExtGrossGroundWallArea;
   11785            4 :                 state.dataOutRptTab->zstWindowArea(state.dataOutRptTab->notpartTotal) += mult * zoneGlassArea(iZone);
   11786            4 :                 state.dataOutRptTab->zstOpeningArea(state.dataOutRptTab->notpartTotal) += mult * zoneOpeningArea(iZone);
   11787            4 :                 state.dataOutRptTab->zstLight(state.dataOutRptTab->notpartTotal) += mult * totLightPower;
   11788            4 :                 state.dataOutRptTab->zstPeople(state.dataOutRptTab->notpartTotal) += mult * totNumPeople;
   11789            4 :                 state.dataOutRptTab->zstPlug(state.dataOutRptTab->notpartTotal) += mult * totPlugProcess;
   11790              :             } else {
   11791              :                 // Add it to the 'Total'
   11792           56 :                 state.dataOutRptTab->zstArea(state.dataOutRptTab->grandTotal) += mult * thisZone.FloorArea;
   11793           56 :                 state.dataOutRptTab->zstVolume(state.dataOutRptTab->grandTotal) += mult * thisZone.Volume;
   11794           56 :                 state.dataOutRptTab->zstWallArea(state.dataOutRptTab->grandTotal) += mult * thisZone.ExtGrossWallArea;
   11795           56 :                 state.dataOutRptTab->zstUndWallArea(state.dataOutRptTab->grandTotal) += mult * thisZone.ExtGrossGroundWallArea;
   11796           56 :                 state.dataOutRptTab->zstWindowArea(state.dataOutRptTab->grandTotal) += mult * zoneGlassArea(iZone);
   11797           56 :                 state.dataOutRptTab->zstOpeningArea(state.dataOutRptTab->grandTotal) += mult * zoneOpeningArea(iZone);
   11798           56 :                 state.dataOutRptTab->zstLight(state.dataOutRptTab->grandTotal) += mult * totLightPower;
   11799           56 :                 state.dataOutRptTab->zstPeople(state.dataOutRptTab->grandTotal) += mult * totNumPeople;
   11800           56 :                 state.dataOutRptTab->zstPlug(state.dataOutRptTab->grandTotal) += mult * totPlugProcess;
   11801              : 
   11802              :                 // Subtotal between cond/unconditioned
   11803           56 :                 int const condUncondTotal = zoneIsCond ? state.dataOutRptTab->condTotal : state.dataOutRptTab->uncondTotal;
   11804           56 :                 state.dataOutRptTab->zstArea(condUncondTotal) += mult * thisZone.FloorArea;
   11805           56 :                 state.dataOutRptTab->zstVolume(condUncondTotal) += mult * thisZone.Volume;
   11806           56 :                 state.dataOutRptTab->zstWallArea(condUncondTotal) += mult * thisZone.ExtGrossWallArea;
   11807           56 :                 state.dataOutRptTab->zstUndWallArea(condUncondTotal) += mult * thisZone.ExtGrossGroundWallArea;
   11808           56 :                 state.dataOutRptTab->zstWindowArea(condUncondTotal) += mult * zoneGlassArea(iZone);
   11809           56 :                 state.dataOutRptTab->zstOpeningArea(condUncondTotal) += mult * zoneOpeningArea(iZone);
   11810           56 :                 state.dataOutRptTab->zstLight(condUncondTotal) += mult * totLightPower;
   11811           56 :                 state.dataOutRptTab->zstPeople(condUncondTotal) += mult * totNumPeople;
   11812           56 :                 state.dataOutRptTab->zstPlug(condUncondTotal) += mult * totPlugProcess;
   11813              :             }
   11814              :         }
   11815          230 :         for (int iTotal = 1; iTotal <= 4; ++iTotal) {
   11816          184 :             tableBody(1, state.dataGlobal->NumOfZones + iTotal) =
   11817          368 :                 RealToStr(state.dataOutRptTab->zstArea(iTotal) * state.dataOutRptTab->m2_unitConvWVST, 2);
   11818          184 :             tableBody(4, state.dataGlobal->NumOfZones + iTotal) =
   11819          368 :                 RealToStr(state.dataOutRptTab->zstVolume(iTotal) * state.dataOutRptTab->m3_unitConv, 2);
   11820          184 :             tableBody(6, state.dataGlobal->NumOfZones + iTotal) =
   11821          368 :                 RealToStr(state.dataOutRptTab->zstWallArea(iTotal) * state.dataOutRptTab->m2_unitConvWVST, 2);
   11822          184 :             tableBody(7, state.dataGlobal->NumOfZones + iTotal) =
   11823          368 :                 RealToStr(state.dataOutRptTab->zstUndWallArea(iTotal) * state.dataOutRptTab->m2_unitConvWVST, 2);
   11824          184 :             tableBody(8, state.dataGlobal->NumOfZones + iTotal) =
   11825          368 :                 RealToStr(state.dataOutRptTab->zstWindowArea(iTotal) * state.dataOutRptTab->m2_unitConvWVST, 2);
   11826          184 :             tableBody(9, state.dataGlobal->NumOfZones + iTotal) =
   11827          368 :                 RealToStr(state.dataOutRptTab->zstOpeningArea(iTotal) * state.dataOutRptTab->m2_unitConvWVST, 2);
   11828          184 :             if (state.dataOutRptTab->zstArea(iTotal) != 0) {
   11829          100 :                 tableBody(10, state.dataGlobal->NumOfZones + iTotal) =
   11830          200 :                     RealToStr(state.dataOutRptTab->zstLight(iTotal) * state.dataOutRptTab->Wm2_unitConv / state.dataOutRptTab->zstArea(iTotal), 4);
   11831          100 :                 tableBody(12, state.dataGlobal->NumOfZones + iTotal) =
   11832          200 :                     RealToStr(state.dataOutRptTab->zstPlug(iTotal) * state.dataOutRptTab->Wm2_unitConv / state.dataOutRptTab->zstArea(iTotal), 4);
   11833              :             }
   11834          184 :             if (state.dataOutRptTab->zstPeople(iTotal) != 0) {
   11835           56 :                 tableBody(11, state.dataGlobal->NumOfZones + iTotal) = RealToStr(
   11836           56 :                     state.dataOutRptTab->zstArea(iTotal) * state.dataOutRptTab->m2_unitConvWVST / state.dataOutRptTab->zstPeople(iTotal), 2);
   11837              :             }
   11838              :         }
   11839           46 :         if (produceTabular) {
   11840           42 :             PreDefTableEntry(
   11841           42 :                 state, state.dataOutRptPredefined->pdchLeedSutSpArea, "Totals", state.dataOutRptTab->zstArea(state.dataOutRptTab->grandTotal), 2);
   11842           42 :             PreDefTableEntry(
   11843           42 :                 state, state.dataOutRptPredefined->pdchLeedSutOcArea, "Totals", state.dataOutRptTab->zstArea(state.dataOutRptTab->condTotal), 2);
   11844           42 :             PreDefTableEntry(
   11845           84 :                 state, state.dataOutRptPredefined->pdchLeedSutUnArea, "Totals", state.dataOutRptTab->zstArea(state.dataOutRptTab->uncondTotal), 2);
   11846              : 
   11847           42 :             WriteSubtitle(state, "Zone Summary");
   11848           42 :             WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
   11849              :         }
   11850           46 :         if (produceSQLite) {
   11851           42 :             if (state.dataSQLiteProcedures->sqlite) {
   11852            7 :                 state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
   11853              :                     tableBody, rowHead, columnHead, "InputVerificationandResultsSummary", "Entire Facility", "Zone Summary");
   11854              :             }
   11855              :         }
   11856           46 :         if (produceTabular) {
   11857           42 :             if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
   11858            0 :                 state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(
   11859              :                     tableBody, rowHead, columnHead, "InputVerificationandResultsSummary", "Entire Facility", "Zone Summary");
   11860              :             }
   11861              :         }
   11862              : 
   11863           46 :         writeVeriSumSpaceTables(state, produceTabular, produceSQLite);
   11864              :     }
   11865           42 : }
   11866              : 
   11867           47 : void writeVeriSumSpaceTables(EnergyPlusData &state, bool produceTabular, bool produceSQLite)
   11868              : {
   11869              : 
   11870              :     // Write Space and SpaceType sub-tables for Input Verification and Results Summary
   11871           47 :     Array1D_string spaceRowHead;
   11872           47 :     Array1D_string spaceColumnHead;
   11873           47 :     Array1D_int spaceColumnWidth;
   11874           47 :     Array2D_string spaceTableBody;
   11875           47 :     int spaceNumCol = 11;
   11876           47 :     spaceRowHead.allocate(state.dataGlobal->numSpaces + 4); // Extra rows for totals
   11877           47 :     spaceColumnHead.allocate(spaceNumCol);
   11878           47 :     spaceColumnWidth.allocate(spaceNumCol);
   11879           47 :     spaceTableBody.allocate(spaceNumCol, state.dataGlobal->numSpaces + 4); // Extra rows for totals
   11880          564 :     for (int iCol = 1; iCol <= spaceNumCol; ++iCol) {
   11881          517 :         spaceColumnWidth(iCol) = 14;
   11882              :     }
   11883              : 
   11884           47 :     spaceColumnHead(1) = "Area " + state.dataOutRptTab->m2_unitName;
   11885           47 :     spaceColumnHead(2) = "Conditioned (Y/N)";
   11886           47 :     spaceColumnHead(3) = "Part of Total Floor Area (Y/N)";
   11887           47 :     spaceColumnHead(4) = "Multipliers";
   11888           47 :     spaceColumnHead(5) = "Zone Name";
   11889           47 :     spaceColumnHead(6) = "Space Type";
   11890           47 :     spaceColumnHead(7) = "Radiant/Solar Enclosure Name";
   11891           47 :     spaceColumnHead(8) = "Lighting " + state.dataOutRptTab->Wm2_unitName;
   11892           94 :     spaceColumnHead(9) = "People " + state.dataOutRptTab->m2_unitName.substr(0, len(state.dataOutRptTab->m2_unitName) - 1) + " per person" +
   11893           94 :                          state.dataOutRptTab->m2_unitName[len(state.dataOutRptTab->m2_unitName) - 1];
   11894           47 :     spaceColumnHead(10) = "Plug and Process " + state.dataOutRptTab->Wm2_unitName;
   11895           47 :     spaceColumnHead(11) = "Tags";
   11896              : 
   11897           47 :     int constexpr colSpaceArea(1);
   11898           47 :     int constexpr colConditioned(2);
   11899           47 :     int constexpr colPartOfTotal(3);
   11900           47 :     int constexpr colMultipliers(4);
   11901           47 :     int constexpr colZoneName(5);
   11902           47 :     int constexpr colSpaceType(6);
   11903           47 :     int constexpr colEnclName(7);
   11904           47 :     int constexpr colSpaceLighting(8);
   11905           47 :     int constexpr colSpacePeople(9);
   11906           47 :     int constexpr colSpacePlugProcess(10);
   11907           47 :     int constexpr colSpaceTags(11);
   11908              : 
   11909           47 :     spaceRowHead(state.dataGlobal->numSpaces + state.dataOutRptTab->grandTotal) = "Total";
   11910           47 :     spaceRowHead(state.dataGlobal->numSpaces + state.dataOutRptTab->condTotal) = "Conditioned Total";
   11911           47 :     spaceRowHead(state.dataGlobal->numSpaces + state.dataOutRptTab->uncondTotal) = "Unconditioned Total";
   11912           47 :     spaceRowHead(state.dataGlobal->numSpaces + state.dataOutRptTab->notpartTotal) = "Not Part of Total";
   11913              : 
   11914           47 :     EPVector<Real64> spaceTotLighting;
   11915           47 :     EPVector<Real64> spaceTotPeople;
   11916           47 :     EPVector<Real64> spaceTotPlugProcess;
   11917           47 :     spaceTotLighting.allocate(state.dataGlobal->numSpaces);
   11918           47 :     spaceTotPeople.allocate(state.dataGlobal->numSpaces);
   11919           47 :     spaceTotPlugProcess.allocate(state.dataGlobal->numSpaces);
   11920          121 :     for (int iSpace = 1; iSpace <= state.dataGlobal->numSpaces; ++iSpace) {
   11921           74 :         spaceTotLighting(iSpace) = 0.0;
   11922           74 :         spaceTotPeople(iSpace) = 0.0;
   11923           74 :         spaceTotPlugProcess(iSpace) = 0.0;
   11924              :     }
   11925              : 
   11926           47 :     Array1D_string spaceTypeRowHead;
   11927           47 :     Array1D_string spaceTypeColumnHead;
   11928           47 :     Array1D_int spaceTypeColumnWidth;
   11929           47 :     Array2D_string spaceTypeTableBody;
   11930           47 :     int spaceTypeNumCol = 7;
   11931           47 :     spaceTypeRowHead.allocate(state.dataGlobal->numSpaceTypes + 1); // Extra row for total
   11932           47 :     spaceTypeColumnHead.allocate(spaceTypeNumCol);
   11933           47 :     spaceTypeColumnWidth.allocate(spaceTypeNumCol);
   11934           47 :     spaceTypeTableBody.allocate(spaceTypeNumCol, state.dataGlobal->numSpaceTypes + 1); // Extra row for total
   11935          376 :     for (int iCol = 1; iCol <= spaceTypeNumCol; ++iCol) {
   11936          329 :         spaceTypeColumnWidth(iCol) = 14;
   11937              :     }
   11938           47 :     spaceTypeColumnHead(1) = "Total Area " + state.dataOutRptTab->m2_unitName;
   11939           47 :     spaceTypeColumnHead(2) = "Conditioned Area " + state.dataOutRptTab->m2_unitName;
   11940           47 :     spaceTypeColumnHead(3) = "Unconditioned Area " + state.dataOutRptTab->m2_unitName;
   11941           47 :     spaceTypeColumnHead(4) = "Not Part of Total Area " + state.dataOutRptTab->m2_unitName;
   11942           47 :     spaceTypeColumnHead(5) = "Lighting " + state.dataOutRptTab->Wm2_unitName;
   11943           94 :     spaceTypeColumnHead(6) = "People " + state.dataOutRptTab->m2_unitName.substr(0, len(state.dataOutRptTab->m2_unitName) - 1) + " per person" +
   11944           94 :                              state.dataOutRptTab->m2_unitName[len(state.dataOutRptTab->m2_unitName) - 1];
   11945           47 :     spaceTypeColumnHead(7) = "Plug and Process " + state.dataOutRptTab->Wm2_unitName;
   11946              : 
   11947           47 :     int constexpr colSpaceTypeTotArea(1);
   11948           47 :     int constexpr colSpaceTypeCondArea(2);
   11949           47 :     int constexpr colSpaceTypeUncondArea(3);
   11950           47 :     int constexpr colSpaceTypeNotTotArea(4);
   11951           47 :     int constexpr colSpaceTypeLighting(5);
   11952           47 :     int constexpr colSpaceTypePeople(6);
   11953           47 :     int constexpr colSpaceTypePlugProcess(7);
   11954              : 
   11955           47 :     spaceTypeRowHead(state.dataGlobal->numSpaceTypes + state.dataOutRptTab->grandTotal) = "Total";
   11956              : 
   11957           47 :     EPVector<Real64> spaceTypeTotArea;
   11958           47 :     EPVector<Real64> spaceTypeCondArea;
   11959           47 :     EPVector<Real64> spaceTypeUncondArea;
   11960           47 :     EPVector<Real64> spaceTypeNotTotArea;
   11961           47 :     EPVector<Real64> spaceTypeTotLighting;
   11962           47 :     EPVector<Real64> spaceTypeTotPeople;
   11963           47 :     EPVector<Real64> spaceTypeTotPlugProcess;
   11964           47 :     spaceTypeTotArea.allocate(state.dataGlobal->numSpaceTypes);
   11965           47 :     spaceTypeCondArea.allocate(state.dataGlobal->numSpaceTypes);
   11966           47 :     spaceTypeUncondArea.allocate(state.dataGlobal->numSpaceTypes);
   11967           47 :     spaceTypeNotTotArea.allocate(state.dataGlobal->numSpaceTypes);
   11968           47 :     spaceTypeTotLighting.allocate(state.dataGlobal->numSpaceTypes);
   11969           47 :     spaceTypeTotPeople.allocate(state.dataGlobal->numSpaceTypes);
   11970           47 :     spaceTypeTotPlugProcess.allocate(state.dataGlobal->numSpaceTypes);
   11971           90 :     for (int iSpaceType = 1; iSpaceType <= state.dataGlobal->numSpaceTypes; ++iSpaceType) {
   11972           43 :         spaceTypeTotArea(iSpaceType) = 0.0;
   11973           43 :         spaceTypeCondArea(iSpaceType) = 0.0;
   11974           43 :         spaceTypeUncondArea(iSpaceType) = 0.0;
   11975           43 :         spaceTypeNotTotArea(iSpaceType) = 0.0;
   11976           43 :         spaceTypeTotLighting(iSpaceType) = 0.0;
   11977           43 :         spaceTypeTotPeople(iSpaceType) = 0.0;
   11978           43 :         spaceTypeTotPlugProcess(iSpaceType) = 0.0;
   11979              :     }
   11980              : 
   11981              :     // Accumulate internal gain totals by space and space type
   11982           72 :     for (int iPeople = 1; iPeople <= state.dataHeatBal->TotPeople; ++iPeople) {
   11983           25 :         auto const &curPeople = state.dataHeatBal->People(iPeople);
   11984           25 :         int const spaceNum = curPeople.spaceIndex;
   11985           25 :         Real64 const people = curPeople.NumberOfPeople;
   11986           25 :         spaceTotPeople(spaceNum) += people;
   11987           25 :         spaceTypeTotPeople(state.dataHeatBal->space(spaceNum).spaceTypeNum) += people;
   11988              :     }
   11989           73 :     for (int iLights = 1; iLights <= state.dataHeatBal->TotLights; ++iLights) {
   11990           26 :         auto const &curLighting = state.dataHeatBal->Lights(iLights);
   11991           26 :         int const spaceNum = curLighting.spaceIndex;
   11992           26 :         Real64 const lighting = curLighting.DesignLevel;
   11993           26 :         spaceTotLighting(spaceNum) += lighting;
   11994           26 :         spaceTypeTotLighting(state.dataHeatBal->space(spaceNum).spaceTypeNum) += lighting;
   11995              :     }
   11996          101 :     for (int iElecEquip = 1; iElecEquip <= state.dataHeatBal->TotElecEquip; ++iElecEquip) {
   11997           54 :         auto const &curElecEquip = state.dataHeatBal->ZoneElectric(iElecEquip);
   11998           54 :         int const spaceNum = curElecEquip.spaceIndex;
   11999           54 :         Real64 const elecEquip = curElecEquip.DesignLevel;
   12000           54 :         spaceTotPlugProcess(spaceNum) += elecEquip;
   12001           54 :         spaceTypeTotPlugProcess(state.dataHeatBal->space(spaceNum).spaceTypeNum) += elecEquip;
   12002              :     }
   12003           47 :     for (int iGasEquip = 1; iGasEquip <= state.dataHeatBal->TotGasEquip; ++iGasEquip) {
   12004            0 :         auto const &curGasEquip = state.dataHeatBal->ZoneGas(iGasEquip);
   12005            0 :         int const spaceNum = curGasEquip.spaceIndex;
   12006            0 :         Real64 const gasEquip = curGasEquip.DesignLevel;
   12007            0 :         spaceTotPlugProcess(spaceNum) += gasEquip;
   12008            0 :         spaceTypeTotPlugProcess(state.dataHeatBal->space(spaceNum).spaceTypeNum) += gasEquip;
   12009              :     }
   12010           91 :     for (int iOthEquip = 1; iOthEquip <= state.dataHeatBal->TotOthEquip; ++iOthEquip) {
   12011           44 :         auto const &curOthEquip = state.dataHeatBal->ZoneOtherEq(iOthEquip);
   12012           44 :         int const spaceNum = curOthEquip.spaceIndex;
   12013           44 :         Real64 const othEquip = curOthEquip.DesignLevel;
   12014           44 :         spaceTotPlugProcess(spaceNum) += othEquip;
   12015           44 :         spaceTypeTotPlugProcess(state.dataHeatBal->space(spaceNum).spaceTypeNum) += othEquip;
   12016              :     }
   12017           47 :     for (int iHWEquip = 1; iHWEquip <= state.dataHeatBal->TotHWEquip; ++iHWEquip) {
   12018            0 :         auto const &curHWEquip = state.dataHeatBal->ZoneHWEq(iHWEquip);
   12019            0 :         int const spaceNum = curHWEquip.spaceIndex;
   12020            0 :         Real64 const hwEquip = curHWEquip.DesignLevel;
   12021            0 :         spaceTotPlugProcess(spaceNum) += hwEquip;
   12022            0 :         spaceTypeTotPlugProcess(state.dataHeatBal->space(spaceNum).spaceTypeNum) += hwEquip;
   12023              :     }
   12024           47 :     for (int iSteamEquip = 1; iSteamEquip <= state.dataHeatBal->TotStmEquip; ++iSteamEquip) {
   12025            0 :         auto const &curSteamEquip = state.dataHeatBal->ZoneSteamEq(iSteamEquip);
   12026            0 :         int const spaceNum = curSteamEquip.spaceIndex;
   12027            0 :         Real64 const steamEquip = curSteamEquip.DesignLevel;
   12028            0 :         spaceTotPlugProcess(spaceNum) += steamEquip;
   12029            0 :         spaceTypeTotPlugProcess(state.dataHeatBal->space(spaceNum).spaceTypeNum) += steamEquip;
   12030              :     }
   12031           54 :     for (int iITEquip = 1; iITEquip <= state.dataHeatBal->TotITEquip; ++iITEquip) {
   12032            7 :         auto const &curITEquip = state.dataHeatBal->ZoneITEq(iITEquip);
   12033            7 :         int const spaceNum = curITEquip.spaceIndex;
   12034            7 :         Real64 const itEquip = curITEquip.DesignTotalPower;
   12035            7 :         spaceTotPlugProcess(spaceNum) += itEquip;
   12036            7 :         spaceTypeTotPlugProcess(state.dataHeatBal->space(spaceNum).spaceTypeNum) += itEquip;
   12037              :     }
   12038              : 
   12039              :     // re-use existing zone total variables
   12040          235 :     for (int iTotal = 1; iTotal <= 4; ++iTotal) {
   12041          188 :         state.dataOutRptTab->zstArea(iTotal) = 0.0;
   12042          188 :         state.dataOutRptTab->zstLight(iTotal) = 0.0;
   12043          188 :         state.dataOutRptTab->zstPlug(iTotal) = 0.0;
   12044          188 :         state.dataOutRptTab->zstPeople(iTotal) = 0.0;
   12045              :     }
   12046              : 
   12047           47 :     int spaceTableRowNum = 0;
   12048          109 :     for (int iZone = 1; iZone <= state.dataGlobal->NumOfZones; ++iZone) {
   12049           62 :         auto const &curZone = state.dataHeatBal->Zone(iZone);
   12050           62 :         Real64 const mult = Real64(curZone.Multiplier) * Real64(curZone.ListMultiplier);
   12051          136 :         for (int const spaceNum : curZone.spaceIndexes) {
   12052           74 :             auto &curSpace = state.dataHeatBal->space(spaceNum);
   12053           74 :             bool spaceIsCond = false;
   12054           74 :             bool useSpaceFloorArea = false;
   12055           74 :             ++spaceTableRowNum;
   12056           74 :             spaceRowHead(spaceTableRowNum) = curSpace.Name;
   12057           74 :             spaceTableBody(colZoneName, spaceTableRowNum) = curZone.Name;
   12058           74 :             spaceTableBody(colSpaceType, spaceTableRowNum) = curSpace.spaceType;
   12059           74 :             spaceTableBody(colEnclName, spaceTableRowNum) = state.dataViewFactor->EnclSolInfo(curSpace.solarEnclosureNum).Name;
   12060           74 :             spaceTableBody(colSpaceArea, spaceTableRowNum) = RealToStr(curSpace.FloorArea * state.dataOutRptTab->m2_unitConvWVST, 2);
   12061              :             // Conditioned or not
   12062           74 :             if (curZone.SystemZoneNodeNumber > 0) {
   12063           44 :                 spaceTableBody(colConditioned, spaceTableRowNum) = "Yes";
   12064           44 :                 spaceIsCond = true;
   12065              :             } else {
   12066           30 :                 spaceTableBody(colConditioned, spaceTableRowNum) = "No";
   12067           30 :                 spaceIsCond = false;
   12068              :             }
   12069              :             // Part of Total Floor Area or not
   12070           74 :             if (curZone.isPartOfTotalArea) {
   12071           70 :                 spaceTableBody(colPartOfTotal, spaceTableRowNum) = "Yes";
   12072           70 :                 useSpaceFloorArea = true;
   12073              :             } else {
   12074            4 :                 spaceTableBody(colPartOfTotal, spaceTableRowNum) = "No";
   12075            4 :                 useSpaceFloorArea = false;
   12076              :             }
   12077              :             // lighting density
   12078           74 :             spaceTableBody(colMultipliers, spaceTableRowNum) = RealToStr(mult, 2);
   12079           74 :             if (curSpace.FloorArea > 0) {
   12080           62 :                 spaceTableBody(colSpaceLighting, spaceTableRowNum) =
   12081          124 :                     RealToStr(state.dataOutRptTab->Wm2_unitConv * spaceTotLighting(spaceNum) / curSpace.FloorArea, 4);
   12082              :             } else {
   12083           12 :                 spaceTableBody(colSpaceLighting, spaceTableRowNum) = RealToStr(0.0, 4);
   12084              :             }
   12085              :             // people density
   12086           74 :             if (spaceTotPeople(spaceNum) > 0) {
   12087           25 :                 spaceTableBody(colSpacePeople, spaceTableRowNum) =
   12088           50 :                     RealToStr(curSpace.FloorArea * state.dataOutRptTab->m2_unitConvWVST / spaceTotPeople(spaceNum), 2);
   12089              :             } else {
   12090           49 :                 spaceTableBody(colSpacePeople, spaceTableRowNum) = RealToStr(0.0, 2);
   12091              :             }
   12092              :             // plug and process density
   12093           74 :             if (curSpace.FloorArea > 0) {
   12094           62 :                 spaceTableBody(colSpacePlugProcess, spaceTableRowNum) =
   12095          124 :                     RealToStr(spaceTotPlugProcess(spaceNum) * state.dataOutRptTab->Wm2_unitConv / curSpace.FloorArea, 4);
   12096              :             } else {
   12097           12 :                 spaceTableBody(colSpacePlugProcess, spaceTableRowNum) = RealToStr(0.0, 4);
   12098              :             }
   12099              : 
   12100          148 :             spaceTableBody(colSpaceTags, spaceTableRowNum) = fmt::format("{}", fmt::join(curSpace.tags, ", "));
   12101              : 
   12102              :             // If not part of total, goes directly to this row
   12103           74 :             if (!useSpaceFloorArea) {
   12104            4 :                 spaceTypeNotTotArea(curSpace.spaceTypeNum) += curSpace.FloorArea * mult;
   12105            4 :                 state.dataOutRptTab->zstArea(state.dataOutRptTab->notpartTotal) += mult * curSpace.FloorArea;
   12106            4 :                 state.dataOutRptTab->zstLight(state.dataOutRptTab->notpartTotal) += mult * spaceTotLighting(spaceNum);
   12107            4 :                 state.dataOutRptTab->zstPeople(state.dataOutRptTab->notpartTotal) += mult * spaceTotPeople(spaceNum);
   12108            4 :                 state.dataOutRptTab->zstPlug(state.dataOutRptTab->notpartTotal) += mult * spaceTotPlugProcess(spaceNum);
   12109              :             } else {
   12110              :                 // Add it to the 'Total'
   12111           70 :                 spaceTypeTotArea(curSpace.spaceTypeNum) += curSpace.FloorArea * mult;
   12112           70 :                 state.dataOutRptTab->zstArea(state.dataOutRptTab->grandTotal) += mult * curSpace.FloorArea;
   12113           70 :                 state.dataOutRptTab->zstLight(state.dataOutRptTab->grandTotal) += mult * spaceTotLighting(spaceNum);
   12114           70 :                 state.dataOutRptTab->zstPeople(state.dataOutRptTab->grandTotal) += mult * spaceTotPeople(spaceNum);
   12115           70 :                 state.dataOutRptTab->zstPlug(state.dataOutRptTab->grandTotal) += mult * spaceTotPlugProcess(spaceNum);
   12116              : 
   12117              :                 // Subtotal between cond/unconditioned
   12118              :                 int condUncondTotalIndex;
   12119           70 :                 if (spaceIsCond) {
   12120           40 :                     spaceTypeCondArea(curSpace.spaceTypeNum) += curSpace.FloorArea * mult;
   12121           40 :                     condUncondTotalIndex = state.dataOutRptTab->condTotal;
   12122              : 
   12123              :                 } else {
   12124           30 :                     spaceTypeUncondArea(curSpace.spaceTypeNum) += curSpace.FloorArea * mult;
   12125           30 :                     condUncondTotalIndex = state.dataOutRptTab->uncondTotal;
   12126              :                 }
   12127           70 :                 state.dataOutRptTab->zstArea(condUncondTotalIndex) += mult * curSpace.FloorArea;
   12128           70 :                 state.dataOutRptTab->zstLight(condUncondTotalIndex) += mult * spaceTotLighting(spaceNum);
   12129           70 :                 state.dataOutRptTab->zstPeople(condUncondTotalIndex) += mult * spaceTotPeople(spaceNum);
   12130           70 :                 state.dataOutRptTab->zstPlug(condUncondTotalIndex) += mult * spaceTotPlugProcess(spaceNum);
   12131              :             }
   12132           62 :         }
   12133              :     }
   12134              :     // total rows for Total / Not Part of Total
   12135              :     // In "Total": break between conditioned/unconditioned
   12136          235 :     for (int iTotal = 1; iTotal <= 4; ++iTotal) {
   12137          188 :         spaceTableBody(colSpaceArea, state.dataGlobal->numSpaces + iTotal) =
   12138          376 :             RealToStr(state.dataOutRptTab->zstArea(iTotal) * state.dataOutRptTab->m2_unitConvWVST, 2);
   12139          188 :         if (state.dataOutRptTab->zstArea(iTotal) != 0) {
   12140           78 :             spaceTableBody(colSpaceLighting, state.dataGlobal->numSpaces + iTotal) =
   12141          156 :                 RealToStr(state.dataOutRptTab->zstLight(iTotal) * state.dataOutRptTab->Wm2_unitConv / state.dataOutRptTab->zstArea(iTotal), 4);
   12142           78 :             spaceTableBody(colSpacePlugProcess, state.dataGlobal->numSpaces + iTotal) =
   12143          156 :                 RealToStr(state.dataOutRptTab->zstPlug(iTotal) * state.dataOutRptTab->Wm2_unitConv / state.dataOutRptTab->zstArea(iTotal), 4);
   12144              :         } else {
   12145          110 :             spaceTableBody(colSpaceLighting, state.dataGlobal->numSpaces + iTotal) = RealToStr(0.0, 4);
   12146          110 :             spaceTableBody(colSpacePlugProcess, state.dataGlobal->numSpaces + iTotal) = RealToStr(0.0, 4);
   12147              :         }
   12148          188 :         if (state.dataOutRptTab->zstPeople(iTotal) != 0) {
   12149           30 :             spaceTableBody(colSpacePeople, state.dataGlobal->numSpaces + iTotal) =
   12150           60 :                 RealToStr(state.dataOutRptTab->zstArea(iTotal) * state.dataOutRptTab->m2_unitConvWVST / state.dataOutRptTab->zstPeople(iTotal), 2);
   12151              :         } else {
   12152          158 :             spaceTableBody(colSpacePeople, state.dataGlobal->numSpaces + iTotal) = RealToStr(0.0, 2);
   12153              :         }
   12154              :     }
   12155              : 
   12156           47 :     Real64 totalArea = 0.0;
   12157           47 :     Real64 condArea = 0.0;
   12158           47 :     Real64 uncondArea = 0.0;
   12159           47 :     Real64 notTotalArea = 0.0;
   12160           90 :     for (int iSpaceType = 1; iSpaceType <= state.dataGlobal->numSpaceTypes; ++iSpaceType) {
   12161           43 :         spaceTypeRowHead(iSpaceType) = state.dataHeatBal->spaceTypes(iSpaceType);
   12162           43 :         spaceTypeTableBody(colSpaceTypeTotArea, iSpaceType) = RealToStr(spaceTypeTotArea(iSpaceType) * state.dataOutRptTab->m2_unitConvWVST, 2);
   12163           43 :         spaceTypeTableBody(colSpaceTypeCondArea, iSpaceType) = RealToStr(spaceTypeCondArea(iSpaceType) * state.dataOutRptTab->m2_unitConvWVST, 2);
   12164           43 :         spaceTypeTableBody(colSpaceTypeUncondArea, iSpaceType) = RealToStr(spaceTypeUncondArea(iSpaceType) * state.dataOutRptTab->m2_unitConvWVST, 2);
   12165           43 :         spaceTypeTableBody(colSpaceTypeNotTotArea, iSpaceType) = RealToStr(spaceTypeNotTotArea(iSpaceType) * state.dataOutRptTab->m2_unitConvWVST, 2);
   12166           43 :         totalArea += spaceTypeTotArea(iSpaceType);
   12167           43 :         condArea += spaceTypeCondArea(iSpaceType);
   12168           43 :         uncondArea += spaceTypeUncondArea(iSpaceType);
   12169           43 :         notTotalArea += spaceTypeNotTotArea(iSpaceType);
   12170              :         // lighting density
   12171           43 :         if (spaceTypeTotArea(iSpaceType) > 0) {
   12172           39 :             spaceTypeTableBody(colSpaceTypeLighting, iSpaceType) =
   12173           78 :                 RealToStr(state.dataOutRptTab->Wm2_unitConv * spaceTypeTotLighting(iSpaceType) / spaceTypeTotArea(iSpaceType), 4);
   12174              :         } else {
   12175            4 :             spaceTypeTableBody(colSpaceTypeLighting, iSpaceType) = RealToStr(0.0, 4);
   12176              :         }
   12177              :         // people density
   12178           43 :         if (spaceTypeTotPeople(iSpaceType) > 0) {
   12179           11 :             spaceTypeTableBody(colSpaceTypePeople, iSpaceType) =
   12180           22 :                 RealToStr(spaceTypeTotArea(iSpaceType) * state.dataOutRptTab->m2_unitConvWVST / spaceTypeTotPeople(iSpaceType), 2);
   12181              :         } else {
   12182           32 :             spaceTypeTableBody(colSpaceTypePeople, iSpaceType) = RealToStr(0.0, 2);
   12183              :         }
   12184              :         // plug and process density
   12185           43 :         if (spaceTypeTotArea(iSpaceType) > 0) {
   12186           39 :             spaceTypeTableBody(colSpaceTypePlugProcess, iSpaceType) =
   12187           78 :                 RealToStr(spaceTypeTotPlugProcess(iSpaceType) * state.dataOutRptTab->Wm2_unitConv / spaceTypeTotArea(iSpaceType), 4);
   12188              :         } else {
   12189            4 :             spaceTypeTableBody(colSpaceTypePlugProcess, iSpaceType) = RealToStr(0.0, 4);
   12190              :         }
   12191              :     }
   12192              :     // Total Area
   12193           47 :     spaceTypeTableBody(colSpaceTypeTotArea, state.dataGlobal->numSpaceTypes + 1) = RealToStr(totalArea * state.dataOutRptTab->m2_unitConvWVST, 2);
   12194           47 :     spaceTypeTableBody(colSpaceTypeCondArea, state.dataGlobal->numSpaceTypes + 1) = RealToStr(condArea * state.dataOutRptTab->m2_unitConvWVST, 2);
   12195           47 :     spaceTypeTableBody(colSpaceTypeUncondArea, state.dataGlobal->numSpaceTypes + 1) = RealToStr(uncondArea * state.dataOutRptTab->m2_unitConvWVST, 2);
   12196           47 :     spaceTypeTableBody(colSpaceTypeNotTotArea, state.dataGlobal->numSpaceTypes + 1) =
   12197           94 :         RealToStr(notTotalArea * state.dataOutRptTab->m2_unitConvWVST, 2);
   12198              : 
   12199           47 :     if (produceTabular) {
   12200           43 :         WriteSubtitle(state, "Space Summary");
   12201           43 :         WriteTable(state, spaceTableBody, spaceRowHead, spaceColumnHead, spaceColumnWidth);
   12202              : 
   12203           43 :         WriteSubtitle(state, "Space Type Summary");
   12204           43 :         WriteTable(state, spaceTypeTableBody, spaceTypeRowHead, spaceTypeColumnHead, spaceTypeColumnWidth);
   12205              : 
   12206           43 :         if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
   12207            0 :             state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(
   12208              :                 spaceTableBody, spaceRowHead, spaceColumnHead, "InputVerificationandResultsSummary", "Entire Facility", "Space Summary");
   12209              : 
   12210            0 :             state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(spaceTypeTableBody,
   12211              :                                                                                                   spaceTypeRowHead,
   12212              :                                                                                                   spaceTypeColumnHead,
   12213              :                                                                                                   "InputVerificationandResultsSummary",
   12214              :                                                                                                   "Entire Facility",
   12215              :                                                                                                   "Space Type Summary");
   12216              :         }
   12217              :     }
   12218              : 
   12219           47 :     if (produceSQLite) {
   12220           43 :         if (state.dataSQLiteProcedures->sqlite) {
   12221            8 :             state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
   12222              :                 spaceTableBody, spaceRowHead, spaceColumnHead, "InputVerificationandResultsSummary", "Entire Facility", "Space Summary");
   12223              : 
   12224            8 :             state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(spaceTypeTableBody,
   12225              :                                                                                spaceTypeRowHead,
   12226              :                                                                                spaceTypeColumnHead,
   12227              :                                                                                "InputVerificationandResultsSummary",
   12228              :                                                                                "Entire Facility",
   12229              :                                                                                "Space Type Summary");
   12230              :         }
   12231              :     }
   12232           47 : }
   12233              : 
   12234           38 : void WriteAdaptiveComfortTable(EnergyPlusData &state)
   12235              : {
   12236              : 
   12237              :     // SUBROUTINE INFORMATION:
   12238              :     //       AUTHOR         Tyler Hoyt
   12239              :     //       DATE WRITTEN   August 2011
   12240              :     //       MODIFIED       na
   12241              :     //       RE-ENGINEERED  na
   12242              : 
   12243              :     // PURPOSE OF THIS SUBROUTINE:
   12244              :     // Writes summary table for adaptive comfort models. Tabulates
   12245              :     // occupied hours not meeting comfort bounds for ASHRAE-55 and
   12246              :     // CEN-15251 adaptive models.
   12247           38 :     auto &ort = state.dataOutRptTab;
   12248           38 :     if (!ort->displayAdaptiveComfort || state.dataHeatBal->TotPeople <= 0) {
   12249           32 :         return;
   12250              :     }
   12251              : 
   12252            6 :     Array1D_int peopleInd; // Index the relevant people
   12253            6 :     peopleInd.allocate(state.dataHeatBal->TotPeople);
   12254              : 
   12255              :     // Should deallocate after writing table. - LKL
   12256              : 
   12257           18 :     for (int i = 1; i <= state.dataHeatBal->TotPeople; ++i) {
   12258           12 :         if (state.dataHeatBal->People(i).AdaptiveASH55 || state.dataHeatBal->People(i).AdaptiveCEN15251) {
   12259            0 :             ++ort->numPeopleAdaptive;
   12260            0 :             peopleInd(ort->numPeopleAdaptive) = i;
   12261              :         }
   12262              :     }
   12263              : 
   12264            6 :     Array1D_string rowHead;
   12265            6 :     Array2D_string tableBody;
   12266            6 :     rowHead.allocate(ort->numPeopleAdaptive);
   12267            6 :     tableBody.allocate(5, ort->numPeopleAdaptive);
   12268              : 
   12269           24 :     WriteReportHeaders(state, "Adaptive Comfort Summary", "Entire Facility", OutputProcessor::StoreType::Average);
   12270            6 :     WriteSubtitle(state, "Time Not Meeting the Adaptive Comfort Models during Occupied Hours");
   12271              : 
   12272            6 :     Array1D_int columnWidth;
   12273            6 :     columnWidth.allocate(5);
   12274            6 :     columnWidth = 10;
   12275              : 
   12276            6 :     Array1D_string columnHead(5);
   12277            6 :     columnHead(1) = "ASHRAE55 90% Acceptability Limits [Hours]";
   12278            6 :     columnHead(2) = "ASHRAE55 80% Acceptability Limits  [Hours]";
   12279            6 :     columnHead(3) = "CEN15251 Category I Acceptability Limits [Hours]";
   12280            6 :     columnHead(4) = "CEN15251 Category II Acceptability Limits [Hours]";
   12281            6 :     columnHead(5) = "CEN15251 Category III Acceptability Limits [Hours]";
   12282              : 
   12283            6 :     tableBody = "";
   12284            6 :     for (int i = 1; i <= ort->numPeopleAdaptive; ++i) {
   12285            0 :         rowHead(i) = state.dataHeatBal->People(i).Name;
   12286            0 :         if (state.dataHeatBal->People(i).AdaptiveASH55) {
   12287            0 :             tableBody(1, i) = RealToStr(state.dataHeatBal->People(peopleInd(i)).TimeNotMetASH5590, 2);
   12288            0 :             tableBody(2, i) = RealToStr(state.dataHeatBal->People(peopleInd(i)).TimeNotMetASH5580, 2);
   12289              :         }
   12290            0 :         if (state.dataHeatBal->People(i).AdaptiveCEN15251) {
   12291            0 :             tableBody(3, i) = RealToStr(state.dataHeatBal->People(peopleInd(i)).TimeNotMetCEN15251CatI, 2);
   12292            0 :             tableBody(4, i) = RealToStr(state.dataHeatBal->People(peopleInd(i)).TimeNotMetCEN15251CatII, 2);
   12293            0 :             tableBody(5, i) = RealToStr(state.dataHeatBal->People(peopleInd(i)).TimeNotMetCEN15251CatIII, 2);
   12294              :         }
   12295              :     }
   12296              : 
   12297            6 :     WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
   12298            6 :     if (state.dataSQLiteProcedures->sqlite) {
   12299            1 :         state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(tableBody,
   12300              :                                                                            rowHead,
   12301              :                                                                            columnHead,
   12302              :                                                                            "AdaptiveComfortSummary",
   12303              :                                                                            "Entire Facility",
   12304              :                                                                            "Time Not Meeting the Adaptive Comfort Models during Occupied Hours");
   12305              :     }
   12306            6 :     if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
   12307            0 :         state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(
   12308              :             tableBody,
   12309              :             rowHead,
   12310              :             columnHead,
   12311              :             "AdaptiveComfortSummary",
   12312              :             "Entire Facility",
   12313              :             "Time Not Meeting the Adaptive Comfort Models during Occupied Hours");
   12314              :     }
   12315            6 : }
   12316              : 
   12317            0 : std::string formatReportPeriodTimestamp(const int year, const int month, const int day, const int hour)
   12318              : {
   12319            0 :     if (year != 0) {
   12320            0 :         return fmt::format("{}/{}/{} {}:00", year, month, day, hour);
   12321              :     } else {
   12322            0 :         return fmt::format("{}/{} {}:00", month, day, hour);
   12323              :     }
   12324              : }
   12325              : 
   12326            0 : void WriteReportHeaderReportingPeriod(EnergyPlusData &state,
   12327              :                                       const std::string &reportKeyWord,
   12328              :                                       const int periodIdx,
   12329              :                                       const Array1D<Weather::ReportPeriodData> &ReportPeriodInputData)
   12330              : {
   12331            0 :     WriteReportHeaders(
   12332              :         state,
   12333            0 :         fmt::format("{} Resilience Summary for Reporting Period {}: {}", reportKeyWord, periodIdx, ReportPeriodInputData(periodIdx).title),
   12334              :         "Entire Facility",
   12335              :         OutputProcessor::StoreType::Average);
   12336              : 
   12337            0 :     WriteSubtitle(state,
   12338            0 :                   format("Reporting period: {} -- {}, Total Electricity Usage: {:.2R} kWh",
   12339            0 :                          formatReportPeriodTimestamp(ReportPeriodInputData(periodIdx).startYear,
   12340            0 :                                                      ReportPeriodInputData(periodIdx).startMonth,
   12341            0 :                                                      ReportPeriodInputData(periodIdx).startDay,
   12342            0 :                                                      ReportPeriodInputData(periodIdx).startHour),
   12343            0 :                          formatReportPeriodTimestamp(ReportPeriodInputData(periodIdx).endYear,
   12344            0 :                                                      ReportPeriodInputData(periodIdx).endMonth,
   12345            0 :                                                      ReportPeriodInputData(periodIdx).endDay,
   12346            0 :                                                      ReportPeriodInputData(periodIdx).endHour),
   12347            0 :                          ReportPeriodInputData(periodIdx).totalElectricityUse / 3600000.0));
   12348            0 : }
   12349              : 
   12350            0 : void WriteReportPeriodTimeConsumption(EnergyPlusData &state)
   12351              : {
   12352              :     // Reporting Period Time and Consumption Table
   12353              :     // It has the following columns: report type (thermal, co2, visual), period, start, end, total electricity
   12354            0 :     Array1D_string columnHead;
   12355            0 :     Array1D_int columnWidth;
   12356            0 :     Array1D_string rowHead;
   12357            0 :     Array2D_string tableBody;
   12358            0 :     int numRowsReportPeriod = state.dataWeather->TotThermalReportPers + state.dataWeather->TotCO2ReportPers + state.dataWeather->TotVisualReportPers;
   12359            0 :     rowHead.allocate(numRowsReportPeriod);
   12360            0 :     columnHead.allocate(6);
   12361            0 :     columnWidth.allocate(6);
   12362            0 :     columnWidth = 14; // array assignment - same for all columns
   12363            0 :     tableBody.allocate(6, numRowsReportPeriod);
   12364              : 
   12365            0 :     int constexpr reportperiodType(1);
   12366            0 :     int constexpr reportperiodId(2);
   12367            0 :     int constexpr reportperiodTitle(3);
   12368            0 :     int constexpr reportperiodStart(4);
   12369            0 :     int constexpr reportperiodEnd(5);
   12370            0 :     int constexpr reportperiodElectricity(6);
   12371              : 
   12372            0 :     WriteReportHeaders(state, "Reporting Period Summary", "Entire Facility", OutputProcessor::StoreType::Average);
   12373              : 
   12374            0 :     columnHead(reportperiodType) = "Report Type";
   12375            0 :     columnHead(reportperiodId) = "Report Index";
   12376            0 :     columnHead(reportperiodTitle) = "Title";
   12377            0 :     columnHead(reportperiodStart) = "Start Time";
   12378            0 :     columnHead(reportperiodEnd) = "End Time";
   12379            0 :     columnHead(reportperiodElectricity) = "Total Electricity (kWh)";
   12380            0 :     for (int i = 1; i <= numRowsReportPeriod; i++) {
   12381            0 :         rowHead(i) = std::to_string(i);
   12382              :     }
   12383              :     // loop through rows
   12384            0 :     int rowid = 1;
   12385            0 :     for (int periodIdx = 1; periodIdx <= state.dataWeather->TotThermalReportPers; periodIdx++) {
   12386            0 :         writeRowReportPeriodInputVeri("Thermal", tableBody, rowid, periodIdx, state.dataWeather->ThermalReportPeriodInput);
   12387            0 :         rowid += 1;
   12388              :     }
   12389            0 :     for (int periodIdx = 1; periodIdx <= state.dataWeather->TotCO2ReportPers; periodIdx++) {
   12390            0 :         writeRowReportPeriodInputVeri("CO2", tableBody, rowid, periodIdx, state.dataWeather->CO2ReportPeriodInput);
   12391            0 :         rowid += 1;
   12392              :     }
   12393            0 :     for (int periodIdx = 1; periodIdx <= state.dataWeather->TotVisualReportPers; periodIdx++) {
   12394            0 :         writeRowReportPeriodInputVeri("Visual", tableBody, rowid, periodIdx, state.dataWeather->VisualReportPeriodInput);
   12395            0 :         rowid += 1;
   12396              :     }
   12397              : 
   12398            0 :     std::string tableName = "Reporting Period Time and Consumption";
   12399            0 :     WriteSubtitle(state, tableName);
   12400            0 :     WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
   12401            0 :     if (state.dataSQLiteProcedures->sqlite) {
   12402            0 :         state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
   12403              :             tableBody, rowHead, columnHead, "ReportingPeriodSummary", "Entire Facility", tableName);
   12404              :     }
   12405            0 :     if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
   12406            0 :         state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(
   12407              :             tableBody, rowHead, columnHead, "Reporting Period Summary", "Entire Facility", tableName);
   12408              :     }
   12409            0 : }
   12410              : 
   12411            0 : void WriteThermalResilienceTablesRepPeriod(EnergyPlusData &state, int const periodIdx)
   12412              : {
   12413              : 
   12414            0 :     auto const &ort = state.dataOutRptTab;
   12415            0 :     if (!ort->WriteTabularFiles) {
   12416            0 :         return;
   12417              :     }
   12418              : 
   12419              :     Real64 degreeHourConversion;
   12420            0 :     UnitsStyle unitsStyle_cur = ort->unitsStyle;
   12421              : 
   12422            0 :     if (unitsStyle_cur == OutputReportTabular::UnitsStyle::InchPound ||
   12423              :         unitsStyle_cur == OutputReportTabular::UnitsStyle::InchPoundExceptElectricity) {
   12424            0 :         degreeHourConversion = getSpecificUnitMultiplier(state, "°C·hr", "°F·hr");
   12425              :     } else {
   12426            0 :         degreeHourConversion = 1.0;
   12427              :     }
   12428              : 
   12429            0 :     std::string tableType = "Thermal";
   12430            0 :     WriteReportHeaderReportingPeriod(state, tableType, periodIdx, state.dataWeather->ThermalReportPeriodInput);
   12431            0 :     std::string periodTitle = state.dataWeather->ThermalReportPeriodInput(periodIdx).title;
   12432              : 
   12433            0 :     int columnNum = 5;
   12434            0 :     Array1D_int columnWidth;
   12435            0 :     columnWidth.allocate(columnNum);
   12436            0 :     columnWidth = 10;
   12437            0 :     Array1D_string columnHead(5);
   12438            0 :     if (unitsStyle_cur == OutputReportTabular::UnitsStyle::InchPound ||
   12439              :         unitsStyle_cur == OutputReportTabular::UnitsStyle::InchPoundExceptElectricity) {
   12440            0 :         columnHead(1) = "Safe (≤ 80.1°F) [hr]";
   12441            0 :         columnHead(2) = "Caution (> 80.1°F, ≤ 90.0°F) [hr]";
   12442            0 :         columnHead(3) = "Extreme Caution (> 90.0°F, ≤ 102.9°F) [hr]";
   12443            0 :         columnHead(4) = "Danger (> 102.9, ≤ 125.1°F) [hr]";
   12444            0 :         columnHead(5) = "Extreme Danger (> 125.1°F) [hr]";
   12445              :     } else {
   12446            0 :         columnHead(1) = "Safe (≤ 26.7°C) [hr]";
   12447            0 :         columnHead(2) = "Caution (> 26.7°C, ≤ 32.2°C) [hr]";
   12448            0 :         columnHead(3) = "Extreme Caution (> 32.2°C, ≤ 39.4°C) [hr]";
   12449            0 :         columnHead(4) = "Danger (> 39.4°C, ≤ 51.7°C) [hr]";
   12450            0 :         columnHead(5) = "Extreme Danger (> 51.7°C) [hr]";
   12451              :     }
   12452              : 
   12453            0 :     Array1D_string rowHead;
   12454            0 :     Array2D_string tableBody;
   12455            0 :     rowHead.allocate(state.dataGlobal->NumOfZones + 4);
   12456            0 :     tableBody.allocate(columnNum, state.dataGlobal->NumOfZones + 4);
   12457              : 
   12458            0 :     std::string tableName = "Heat Index Hours";
   12459            0 :     WriteResilienceBinsTableReportingPeriod(state,
   12460              :                                             tableType,
   12461              :                                             columnNum,
   12462              :                                             periodIdx,
   12463              :                                             periodTitle,
   12464              :                                             tableName,
   12465              :                                             columnHead,
   12466              :                                             columnWidth,
   12467            0 :                                             state.dataHeatBalFanSys->ZoneHeatIndexHourBinsRepPeriod,
   12468              :                                             rowHead,
   12469              :                                             tableBody);
   12470              : 
   12471            0 :     tableName = "Heat Index OccupantHours";
   12472            0 :     WriteResilienceBinsTableReportingPeriod(state,
   12473              :                                             tableType,
   12474              :                                             columnNum,
   12475              :                                             periodIdx,
   12476              :                                             periodTitle,
   12477              :                                             tableName,
   12478              :                                             columnHead,
   12479              :                                             columnWidth,
   12480            0 :                                             state.dataHeatBalFanSys->ZoneHeatIndexOccuHourBinsRepPeriod,
   12481              :                                             rowHead,
   12482              :                                             tableBody);
   12483              : 
   12484            0 :     tableName = "Heat Index OccupiedHours";
   12485            0 :     WriteResilienceBinsTableReportingPeriod(state,
   12486              :                                             tableType,
   12487              :                                             columnNum,
   12488              :                                             periodIdx,
   12489              :                                             periodTitle,
   12490              :                                             tableName,
   12491              :                                             columnHead,
   12492              :                                             columnWidth,
   12493            0 :                                             state.dataHeatBalFanSys->ZoneHeatIndexOccupiedHourBinsRepPeriod,
   12494              :                                             rowHead,
   12495              :                                             tableBody);
   12496              : 
   12497            0 :     columnHead(1) = "Little to no Discomfort (≤ 29) [hr]";
   12498            0 :     columnHead(2) = "Some Discomfort (> 29, ≤ 40) [hr]";
   12499            0 :     columnHead(3) = "Great Discomfort; Avoid Exertion (> 40, ≤ 45) [hr]";
   12500            0 :     columnHead(4) = "Dangerous (> 45, ≤ 50) [hr]";
   12501            0 :     columnHead(5) = "Heat Stroke Quite Possible (> 50) [hr]";
   12502            0 :     tableName = "Humidex Hours";
   12503            0 :     WriteResilienceBinsTableReportingPeriod(state,
   12504              :                                             tableType,
   12505              :                                             columnNum,
   12506              :                                             periodIdx,
   12507              :                                             periodTitle,
   12508              :                                             tableName,
   12509              :                                             columnHead,
   12510              :                                             columnWidth,
   12511            0 :                                             state.dataHeatBalFanSys->ZoneHumidexHourBinsRepPeriod,
   12512              :                                             rowHead,
   12513              :                                             tableBody);
   12514              : 
   12515            0 :     tableName = "Humidex OccupantHours";
   12516            0 :     WriteResilienceBinsTableReportingPeriod(state,
   12517              :                                             tableType,
   12518              :                                             columnNum,
   12519              :                                             periodIdx,
   12520              :                                             periodTitle,
   12521              :                                             tableName,
   12522              :                                             columnHead,
   12523              :                                             columnWidth,
   12524            0 :                                             state.dataHeatBalFanSys->ZoneHumidexOccuHourBinsRepPeriod,
   12525              :                                             rowHead,
   12526              :                                             tableBody);
   12527              : 
   12528            0 :     tableName = "Humidex OccupiedHours";
   12529            0 :     WriteResilienceBinsTableReportingPeriod(state,
   12530              :                                             tableType,
   12531              :                                             columnNum,
   12532              :                                             periodIdx,
   12533              :                                             periodTitle,
   12534              :                                             tableName,
   12535              :                                             columnHead,
   12536              :                                             columnWidth,
   12537            0 :                                             state.dataHeatBalFanSys->ZoneHumidexOccupiedHourBinsRepPeriod,
   12538              :                                             rowHead,
   12539              :                                             tableBody);
   12540              : 
   12541            0 :     bool hasPierceSET = true;
   12542            0 :     if (state.dataHeatBal->TotPeople == 0) {
   12543            0 :         hasPierceSET = false;
   12544            0 :         if (ort->displayThermalResilienceSummaryExplicitly) {
   12545            0 :             ShowWarningError(state,
   12546              :                              "Writing Reporting Period Thermal Resilience Summary - SET Degree-Hours reports: "
   12547              :                              "Zone Thermal Comfort Pierce Model Standard Effective Temperature is required, "
   12548              :                              "but no People object is defined.");
   12549              :         }
   12550              :     }
   12551            0 :     for (int iPeople = 1; iPeople <= state.dataHeatBal->TotPeople; ++iPeople) {
   12552            0 :         if (!state.dataHeatBal->People(iPeople).Pierce) {
   12553            0 :             hasPierceSET = false;
   12554            0 :             if (ort->displayThermalResilienceSummaryExplicitly) {
   12555            0 :                 ShowWarningError(state,
   12556            0 :                                  format("Writing Reporting Period Thermal Resilience Summary - SET Degree-Hours reports: Zone Thermal Comfort "
   12557              :                                         "Pierce Model Standard Effective Temperature is required, but no Pierce model is defined in {} object.",
   12558            0 :                                         state.dataHeatBal->People(iPeople).Name));
   12559              :             }
   12560              :         }
   12561              :     }
   12562              : 
   12563            0 :     if (hasPierceSET) {
   12564            0 :         columnHead(1) = "SET ≤ 12.2°C Degree-Hours [°C·hr]";
   12565            0 :         columnHead(2) = "SET ≤ 12.2°C Occupant-Weighted Degree-Hours [°C·hr]";
   12566            0 :         columnHead(3) = "SET ≤ 12.2°C Occupied Degree-Hours [°C·hr]";
   12567            0 :         columnHead(4) = "Longest SET ≤ 12.2°C Duration for Occupied Period [hr]";
   12568            0 :         columnHead(5) = "Start Time of the Longest SET ≤ 12.2°C Duration for Occupied Period ";
   12569              : 
   12570            0 :         if (unitsStyle_cur == OutputReportTabular::UnitsStyle::InchPound ||
   12571              :             unitsStyle_cur == OutputReportTabular::UnitsStyle::InchPoundExceptElectricity) {
   12572            0 :             columnHead(1) = "SET ≤ 54.0°F Degree-Hours [°F·hr]";
   12573            0 :             columnHead(2) = "SET ≤ 54.0°F Occupant-Weighted Degree-Hours [°F·hr]";
   12574            0 :             columnHead(3) = "SET ≤ 54.0°F Occupied Degree-Hours [°F·hr]";
   12575            0 :             columnHead(4) = "Longest SET ≤ 54.0°F Duration for Occupied Period [hr]";
   12576            0 :             columnHead(5) = "Start Time of the Longest SET ≤ 54.0°F Duration for Occupied Period ";
   12577              :         } else {
   12578            0 :             columnHead(1) = "SET ≤ 12.2°C Degree-Hours [°C·hr]";
   12579            0 :             columnHead(2) = "SET ≤ 12.2°C Occupant-Weighted Degree-Hours [°C·hr]";
   12580            0 :             columnHead(3) = "SET ≤ 12.2°C Occupied Degree-Hours [°C·hr]";
   12581            0 :             columnHead(4) = "Longest SET ≤ 12.2°C Duration for Occupied Period [hr]";
   12582            0 :             columnHead(5) = "Start Time of the Longest SET ≤ 12.2°C Duration for Occupied Period ";
   12583              :         }
   12584              : 
   12585            0 :         tableName = "Heating SET Degree-Hours";
   12586            0 :         Array1D_string rowHeadSET;
   12587            0 :         Array2D_string tableBodySET;
   12588            0 :         rowHeadSET.allocate(state.dataGlobal->NumOfZones + 3);
   12589            0 :         tableBodySET.allocate(columnNum, state.dataGlobal->NumOfZones + 3);
   12590            0 :         WriteSETHoursTableReportingPeriod(state,
   12591              :                                           columnNum,
   12592              :                                           periodIdx,
   12593              :                                           periodTitle,
   12594              :                                           tableName,
   12595              :                                           columnHead,
   12596              :                                           columnWidth,
   12597            0 :                                           state.dataHeatBalFanSys->ZoneLowSETHoursRepPeriod,
   12598              :                                           rowHeadSET,
   12599              :                                           tableBodySET,
   12600              :                                           degreeHourConversion);
   12601              : 
   12602            0 :         if (unitsStyle_cur == OutputReportTabular::UnitsStyle::InchPound ||
   12603              :             unitsStyle_cur == OutputReportTabular::UnitsStyle::InchPoundExceptElectricity) {
   12604            0 :             columnHead(1) = "SET > 86°F Degree-Hours [°F·hr]";
   12605            0 :             columnHead(2) = "SET > 86°F Occupant-Weighted Degree-Hours [°F·hr]";
   12606            0 :             columnHead(3) = "SET > 86°F Occupied Degree-Hours [°F·hr]";
   12607            0 :             columnHead(4) = "Longest SET > 86°F Duration for Occupied Period [hr]";
   12608            0 :             columnHead(5) = "Start Time of the Longest SET > 86°F Duration for Occupied Period";
   12609              :         } else {
   12610            0 :             columnHead(1) = "SET > 30°C Degree-Hours [°C·hr]";
   12611            0 :             columnHead(2) = "SET > 30°C Occupant-Weighted Degree-Hours [°C·hr]";
   12612            0 :             columnHead(3) = "SET > 30°C Occupied Degree-Hours [°C·hr]";
   12613            0 :             columnHead(4) = "Longest SET > 30°C Duration for Occupied Period [hr]";
   12614            0 :             columnHead(5) = "Start Time of the Longest SET > 30°C Duration for Occupied Period";
   12615              :         }
   12616              : 
   12617            0 :         tableName = "Cooling SET Degree-Hours";
   12618            0 :         WriteSETHoursTableReportingPeriod(state,
   12619              :                                           columnNum,
   12620              :                                           periodIdx,
   12621              :                                           periodTitle,
   12622              :                                           tableName,
   12623              :                                           columnHead,
   12624              :                                           columnWidth,
   12625            0 :                                           state.dataHeatBalFanSys->ZoneHighSETHoursRepPeriod,
   12626              :                                           rowHeadSET,
   12627              :                                           tableBodySET,
   12628              :                                           degreeHourConversion);
   12629            0 :     }
   12630              : 
   12631            0 :     columnHead(1) = "Hours of Safety [hr]";
   12632            0 :     columnHead(2) = "End Time of the Safety Duration";
   12633            0 :     columnHead(3) = "Safe Temperature Exceedance Hours [hr]";
   12634            0 :     columnHead(4) = "Safe Temperature Exceedance OccupantHours [hr]";
   12635            0 :     columnHead(5) = "Safe Temperature Exceedance OccupiedHours [hr]";
   12636            0 :     tableName = "Hours of Safety for Cold Events";
   12637            0 :     WriteHourOfSafetyTableReportingPeriod(state,
   12638              :                                           columnNum,
   12639              :                                           periodIdx,
   12640              :                                           periodTitle,
   12641              :                                           tableName,
   12642              :                                           columnHead,
   12643              :                                           columnWidth,
   12644            0 :                                           state.dataHeatBalFanSys->ZoneColdHourOfSafetyBinsRepPeriod,
   12645              :                                           rowHead,
   12646              :                                           tableBody,
   12647              :                                           2);
   12648              : 
   12649            0 :     tableName = "Hours of Safety for Heat Events";
   12650            0 :     WriteHourOfSafetyTableReportingPeriod(state,
   12651              :                                           columnNum,
   12652              :                                           periodIdx,
   12653              :                                           periodTitle,
   12654              :                                           tableName,
   12655              :                                           columnHead,
   12656              :                                           columnWidth,
   12657            0 :                                           state.dataHeatBalFanSys->ZoneHeatHourOfSafetyBinsRepPeriod,
   12658              :                                           rowHead,
   12659              :                                           tableBody,
   12660              :                                           2);
   12661              : 
   12662            0 :     int columnNumUnmetDegHr = 6;
   12663            0 :     Array1D_string columnHeadUnmetDegHr(6);
   12664              :     // must initialize this otherwise it will only output 5 columns
   12665            0 :     Array1D_int columnWidthUnmetDegHr;
   12666            0 :     columnWidthUnmetDegHr.allocate(columnNumUnmetDegHr);
   12667            0 :     columnWidthUnmetDegHr = 10;
   12668            0 :     columnHeadUnmetDegHr(1) = "Cooling Setpoint Unmet Degree-Hours [°C·hr]";
   12669            0 :     columnHeadUnmetDegHr(2) = "Cooling Setpoint Unmet Occupant-Weighted Degree-Hours [°C·hr]";
   12670            0 :     columnHeadUnmetDegHr(3) = "Cooling Setpoint Unmet Occupied Degree-Hours [°C·hr]";
   12671            0 :     columnHeadUnmetDegHr(4) = "Heating Setpoint Unmet Degree-Hours [°C·hr]";
   12672            0 :     columnHeadUnmetDegHr(5) = "Heating Setpoint Unmet Occupant-Weighted Degree-Hours [°C·hr]";
   12673            0 :     columnHeadUnmetDegHr(6) = "Heating Setpoint Unmet Occupied Degree-Hours [°C·hr]";
   12674            0 :     tableName = "Unmet Degree-Hours";
   12675              : 
   12676            0 :     if (unitsStyle_cur == OutputReportTabular::UnitsStyle::InchPound ||
   12677              :         unitsStyle_cur == OutputReportTabular::UnitsStyle::InchPoundExceptElectricity) {
   12678              :         int indexUnitConv;
   12679            0 :         std::string curUnits;
   12680            0 :         for (int i = 1; i < columnNumUnmetDegHr; i++) {
   12681            0 :             LookupSItoIP(state, columnHeadUnmetDegHr(i), indexUnitConv, curUnits);
   12682            0 :             columnHeadUnmetDegHr(i) = curUnits;
   12683              :         }
   12684            0 :     }
   12685              : 
   12686            0 :     Array2D_string tableBodyUnmetDegHr;
   12687            0 :     tableBodyUnmetDegHr.allocate(columnNumUnmetDegHr, state.dataGlobal->NumOfZones + 4);
   12688            0 :     WriteResilienceBinsTableReportingPeriod(state,
   12689              :                                             tableType,
   12690              :                                             columnNumUnmetDegHr,
   12691              :                                             periodIdx,
   12692              :                                             periodTitle,
   12693              :                                             tableName,
   12694              :                                             columnHeadUnmetDegHr,
   12695              :                                             columnWidthUnmetDegHr,
   12696            0 :                                             state.dataHeatBalFanSys->ZoneUnmetDegreeHourBinsRepPeriod,
   12697              :                                             rowHead,
   12698              :                                             tableBodyUnmetDegHr,
   12699              :                                             degreeHourConversion);
   12700              : 
   12701            0 :     int columnNumDiscomfortWt = 4;
   12702            0 :     Array1D_string columnHeadDiscomfortWt(columnNumDiscomfortWt);
   12703            0 :     columnHeadDiscomfortWt(1) = "Very-cold Exceedance OccupiedHours [hr]";
   12704            0 :     columnHeadDiscomfortWt(2) = "Cool Exceedance OccupiedHours [hr]";
   12705            0 :     columnHeadDiscomfortWt(3) = "Warm Exceedance OccupiedHours [hr]";
   12706            0 :     columnHeadDiscomfortWt(4) = "Very-hot Exceedance OccupiedHours [hr]";
   12707            0 :     tableName = "Discomfort-weighted Exceedance OccupantHours";
   12708            0 :     Array1D_int columnWidthDiscomfortWt;
   12709            0 :     columnWidthDiscomfortWt.allocate(columnNumDiscomfortWt);
   12710            0 :     columnWidth = 10;
   12711            0 :     Array2D_string tableBodyDiscomfortWt;
   12712            0 :     tableBodyDiscomfortWt.allocate(columnNumDiscomfortWt, state.dataGlobal->NumOfZones + 4);
   12713            0 :     WriteResilienceBinsTableReportingPeriod(state,
   12714              :                                             tableType,
   12715              :                                             columnNumDiscomfortWt,
   12716              :                                             periodIdx,
   12717              :                                             periodTitle,
   12718              :                                             tableName,
   12719              :                                             columnHeadDiscomfortWt,
   12720              :                                             columnWidthDiscomfortWt,
   12721            0 :                                             state.dataHeatBalFanSys->ZoneDiscomfortWtExceedOccuHourBinsRepPeriod,
   12722              :                                             rowHead,
   12723              :                                             tableBodyDiscomfortWt);
   12724            0 :     tableName = "Discomfort-weighted Exceedance OccupiedHours";
   12725            0 :     WriteResilienceBinsTableReportingPeriod(state,
   12726              :                                             tableType,
   12727              :                                             columnNumDiscomfortWt,
   12728              :                                             periodIdx,
   12729              :                                             periodTitle,
   12730              :                                             tableName,
   12731              :                                             columnHeadDiscomfortWt,
   12732              :                                             columnWidthDiscomfortWt,
   12733            0 :                                             state.dataHeatBalFanSys->ZoneDiscomfortWtExceedOccupiedHourBinsRepPeriod,
   12734              :                                             rowHead,
   12735              :                                             tableBodyDiscomfortWt);
   12736            0 :     columnHead.deallocate();
   12737            0 :     columnWidth.deallocate();
   12738            0 :     tableBody.deallocate();
   12739            0 :     columnHeadUnmetDegHr.deallocate();
   12740            0 :     columnWidthUnmetDegHr.deallocate();
   12741            0 :     tableBodyUnmetDegHr.deallocate();
   12742            0 :     columnHeadDiscomfortWt.deallocate();
   12743            0 :     columnWidthDiscomfortWt.deallocate();
   12744            0 :     tableBodyDiscomfortWt.deallocate();
   12745            0 : }
   12746              : 
   12747              : template <int columnNum>
   12748            0 : void WriteResilienceBinsTable(EnergyPlusData &state,
   12749              :                               std::array<int, columnNum> const &columnHead,
   12750              :                               const std::array<Real64, columnNum> DataHeatBalance::ZoneResilience::*memberPtr,
   12751              :                               Real64 const unitConvMultiplier)
   12752              : {
   12753            0 :     std::array<Real64, columnNum> columnMax = {0.0};
   12754            0 :     std::array<Real64, columnNum> columnMin = {0.0};
   12755            0 :     std::array<Real64, columnNum> columnSum = {0.0};
   12756            0 :     for (int j = 0; j < columnNum; j++) {
   12757            0 :         columnMin[j] = (state.dataHeatBal->Resilience(1).*memberPtr)[j] * unitConvMultiplier;
   12758              :     }
   12759            0 :     for (int i = 1; i <= state.dataGlobal->NumOfZones; ++i) {
   12760            0 :         const std::string &ZoneName = state.dataHeatBal->Zone(i).Name;
   12761            0 :         for (int j = 0; j < columnNum; j++) {
   12762            0 :             Real64 curValue = (state.dataHeatBal->Resilience(i).*memberPtr)[j] * unitConvMultiplier;
   12763            0 :             if (curValue > columnMax[j]) {
   12764            0 :                 columnMax[j] = curValue;
   12765              :             }
   12766            0 :             if (curValue < columnMin[j]) {
   12767            0 :                 columnMin[j] = curValue;
   12768              :             }
   12769            0 :             columnSum[j] += curValue;
   12770            0 :             PreDefTableEntry(state, columnHead[j], ZoneName, RealToStr(curValue, 2));
   12771              :         }
   12772              :     }
   12773            0 :     for (int j = 0; j < columnNum; j++) {
   12774            0 :         PreDefTableEntry(state, columnHead[j], "Min", RealToStr(columnMin[j], 2));
   12775            0 :         PreDefTableEntry(state, columnHead[j], "Max", RealToStr(columnMax[j], 2));
   12776            0 :         PreDefTableEntry(state, columnHead[j], "Average", RealToStr(columnSum[j] / state.dataGlobal->NumOfZones, 2));
   12777            0 :         PreDefTableEntry(state, columnHead[j], "Sum", RealToStr(columnSum[j], 2));
   12778              :     }
   12779            0 : }
   12780              : 
   12781              : template <int columnNum>
   12782          271 : void WriteResilienceBinsTableNonPreDefUseZoneData(EnergyPlusData &state,
   12783              :                                                   const std::string &tableName,
   12784              :                                                   Array1D_string const &columnHead,
   12785              :                                                   Array1D_int &columnWidth,
   12786              :                                                   const std::array<Real64, columnNum> DataHeatBalance::ZoneResilience::*memberPtr,
   12787              :                                                   Array1D_string &rowHead,
   12788              :                                                   Array2D_string &tableBody,
   12789              :                                                   Real64 const unitConvMultiplier)
   12790              : {
   12791          271 :     WriteSubtitle(state, tableName);
   12792              : 
   12793          271 :     std::array<Real64, columnNum> columnMax = {0.0};
   12794          271 :     std::array<Real64, columnNum> columnMin = {0.0};
   12795          271 :     std::array<Real64, columnNum> columnSum = {0.0};
   12796              : 
   12797         1596 :     for (int j = 0; j < columnNum; j++) {
   12798         1325 :         columnMin.at(j) = (state.dataHeatBal->Resilience(1).*memberPtr).at(j) * unitConvMultiplier;
   12799              :     }
   12800          597 :     for (int ZoneNum = 1; ZoneNum <= state.dataGlobal->NumOfZones; ZoneNum++) {
   12801          326 :         std::string const &ZoneName = state.dataHeatBal->Zone(ZoneNum).Name;
   12802          326 :         rowHead(ZoneNum) = ZoneName;
   12803         1920 :         for (int j = 0; j < columnNum; j++) {
   12804         1594 :             Real64 curValue = (state.dataHeatBal->Resilience(ZoneNum).*memberPtr).at(j) * unitConvMultiplier;
   12805         1594 :             if (curValue > columnMax.at(j)) {
   12806            8 :                 columnMax.at(j) = curValue;
   12807              :             }
   12808         1594 :             if (curValue < columnMin.at(j)) {
   12809            0 :                 columnMin.at(j) = curValue;
   12810              :             }
   12811         1594 :             columnSum.at(j) += curValue;
   12812         1594 :             tableBody(j + 1, ZoneNum) = RealToStr(curValue, 2);
   12813              :         }
   12814              :     }
   12815              : 
   12816          271 :     rowHead(state.dataGlobal->NumOfZones + 1) = "Min";
   12817          271 :     rowHead(state.dataGlobal->NumOfZones + 2) = "Max";
   12818          271 :     rowHead(state.dataGlobal->NumOfZones + 3) = "Average";
   12819          271 :     rowHead(state.dataGlobal->NumOfZones + 4) = "Sum";
   12820              : 
   12821         1596 :     for (int j = 0; j < columnNum; j++) {
   12822         1325 :         tableBody(j + 1, state.dataGlobal->NumOfZones + 1) = RealToStr(columnMin.at(j), 2);
   12823         1325 :         tableBody(j + 1, state.dataGlobal->NumOfZones + 2) = RealToStr(columnMax.at(j), 2);
   12824         1325 :         tableBody(j + 1, state.dataGlobal->NumOfZones + 3) = RealToStr(columnSum.at(j) / state.dataGlobal->NumOfZones, 2);
   12825         1325 :         tableBody(j + 1, state.dataGlobal->NumOfZones + 4) = RealToStr(columnSum.at(j), 2);
   12826              :     }
   12827              : 
   12828          271 :     WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
   12829          271 :     if (state.dataSQLiteProcedures->sqlite) {
   12830           27 :         state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
   12831              :             tableBody, rowHead, columnHead, "AnnualThermalResilienceSummary", "Entire Facility", tableName);
   12832              :     }
   12833          271 :     if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
   12834            0 :         state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(
   12835              :             tableBody, rowHead, columnHead, "AnnualThermalResilienceSummary", "Entire Facility", tableName);
   12836              :     }
   12837          271 : }
   12838              : 
   12839            2 : void WriteResilienceBinsTableReportingPeriod(EnergyPlusData &state,
   12840              :                                              const std::string &tableType,
   12841              :                                              int const columnNum,
   12842              :                                              int const periodIdx,
   12843              :                                              const std::string &periodTitle,
   12844              :                                              const std::string &tableName,
   12845              :                                              Array1D_string const &columnHead,
   12846              :                                              Array1D_int &columnWidth,
   12847              :                                              Array2D<std::vector<Real64>> const &ZoneBins,
   12848              :                                              Array1D_string &rowHead,
   12849              :                                              Array2D_string &tableBody,
   12850              :                                              Real64 const unitConvMultiplier)
   12851              : {
   12852            2 :     WriteSubtitle(state, tableName);
   12853              : 
   12854            2 :     std::vector<Real64> columnMax(columnNum, 0);
   12855            2 :     std::vector<Real64> columnMin(columnNum, 0);
   12856            2 :     std::vector<Real64> columnSum(columnNum, 0);
   12857              : 
   12858           14 :     for (int j = 0; j < columnNum; j++) {
   12859           12 :         columnMin.at(j) = ZoneBins(1, periodIdx).at(j) * unitConvMultiplier;
   12860              :     }
   12861            4 :     for (int ZoneNum = 1; ZoneNum <= state.dataGlobal->NumOfZones; ZoneNum++) {
   12862            2 :         std::string const &ZoneName = state.dataHeatBal->Zone(ZoneNum).Name;
   12863            2 :         rowHead(ZoneNum) = ZoneName;
   12864           14 :         for (int j = 0; j < columnNum; j++) {
   12865           12 :             Real64 curValue = ZoneBins(ZoneNum, periodIdx).at(j) * unitConvMultiplier;
   12866           12 :             if (curValue > columnMax.at(j)) {
   12867            4 :                 columnMax.at(j) = curValue;
   12868              :             }
   12869           12 :             if (curValue < columnMin.at(j)) {
   12870            0 :                 columnMin.at(j) = curValue;
   12871              :             }
   12872           12 :             columnSum.at(j) += curValue;
   12873           12 :             tableBody(j + 1, ZoneNum) = RealToStr(curValue, 2);
   12874              :         }
   12875              :     }
   12876              : 
   12877            2 :     rowHead(state.dataGlobal->NumOfZones + 1) = "Min";
   12878            2 :     rowHead(state.dataGlobal->NumOfZones + 2) = "Max";
   12879            2 :     rowHead(state.dataGlobal->NumOfZones + 3) = "Average";
   12880            2 :     rowHead(state.dataGlobal->NumOfZones + 4) = "Sum";
   12881              : 
   12882           14 :     for (int j = 0; j < columnNum; j++) {
   12883           12 :         tableBody(j + 1, state.dataGlobal->NumOfZones + 1) = RealToStr(columnMin.at(j), 2);
   12884           12 :         tableBody(j + 1, state.dataGlobal->NumOfZones + 2) = RealToStr(columnMax.at(j), 2);
   12885           12 :         tableBody(j + 1, state.dataGlobal->NumOfZones + 3) = RealToStr(columnSum.at(j) / state.dataGlobal->NumOfZones, 2);
   12886           12 :         tableBody(j + 1, state.dataGlobal->NumOfZones + 4) = RealToStr(columnSum.at(j), 2);
   12887              :     }
   12888              : 
   12889            2 :     WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
   12890            2 :     if (state.dataSQLiteProcedures->sqlite) {
   12891            0 :         state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
   12892            0 :             tableBody, rowHead, columnHead, "ReportingPeriod-" + periodTitle + "-" + tableType + "ResilienceSummary", "Entire Facility", tableName);
   12893              :     }
   12894            2 :     if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
   12895            0 :         state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(
   12896            0 :             tableBody, rowHead, columnHead, "ReportingPeriod-" + periodTitle + "-" + tableType + "ResilienceSummary", "Entire Facility", tableName);
   12897              :     }
   12898            2 : }
   12899              : 
   12900            2 : void WriteSETHoursTableNonPreDefUseZoneData(EnergyPlusData &state,
   12901              :                                             int const columnNum,
   12902              :                                             const std::string &tableName,
   12903              :                                             Array1D_string const &columnHead,
   12904              :                                             Array1D_int &columnWidth,
   12905              :                                             const std::array<Real64, 5> DataHeatBalance::ZoneResilience::*memberPtr,
   12906              :                                             Array1D_string &rowHead,
   12907              :                                             Array2D_string &tableBody,
   12908              :                                             Real64 const unitConvMultiplier)
   12909              : {
   12910              : 
   12911            2 :     WriteSubtitle(state, tableName);
   12912              : 
   12913            2 :     std::vector<Real64> columnMax(columnNum - 1, 0);
   12914            2 :     std::vector<Real64> columnMin(columnNum - 1, 0);
   12915            2 :     std::vector<Real64> columnSum(columnNum - 1, 0);
   12916            2 :     std::vector<Real64> multiplier(columnNum - 1, unitConvMultiplier);
   12917            2 :     multiplier[columnNum - 2] = 1.0;
   12918              : 
   12919           10 :     for (int j = 0; j < columnNum - 1; j++) {
   12920            8 :         columnMin.at(j) = (state.dataHeatBal->Resilience(1).*memberPtr).at(j) * multiplier.at(j);
   12921              :     }
   12922            6 :     for (int ZoneNum = 1; ZoneNum <= state.dataGlobal->NumOfZones; ZoneNum++) {
   12923            4 :         std::string const &ZoneName = state.dataHeatBal->Zone(ZoneNum).Name;
   12924            4 :         rowHead(ZoneNum) = ZoneName;
   12925           20 :         for (int j = 0; j < columnNum - 1; j++) {
   12926           16 :             Real64 curValue = (state.dataHeatBal->Resilience(ZoneNum).*memberPtr).at(j) * multiplier.at(j);
   12927           16 :             if (curValue > columnMax.at(j)) {
   12928            4 :                 columnMax.at(j) = curValue;
   12929              :             }
   12930           16 :             if (curValue < columnMin.at(j)) {
   12931            4 :                 columnMin.at(j) = curValue;
   12932              :             }
   12933           16 :             columnSum.at(j) += curValue;
   12934           16 :             tableBody(j + 1, ZoneNum) = RealToStr(curValue, 2);
   12935              :         }
   12936            4 :         tableBody(columnNum, ZoneNum) = DateToString((state.dataHeatBal->Resilience(ZoneNum).*memberPtr).at(columnNum - 1));
   12937              :     }
   12938              : 
   12939            2 :     rowHead(state.dataGlobal->NumOfZones + 1) = "Min";
   12940            2 :     rowHead(state.dataGlobal->NumOfZones + 2) = "Max";
   12941            2 :     rowHead(state.dataGlobal->NumOfZones + 3) = "Average";
   12942              : 
   12943           10 :     for (int j = 0; j < columnNum - 1; j++) {
   12944            8 :         tableBody(j + 1, state.dataGlobal->NumOfZones + 1) = RealToStr(columnMin.at(j), 2);
   12945            8 :         tableBody(j + 1, state.dataGlobal->NumOfZones + 2) = RealToStr(columnMax.at(j), 2);
   12946            8 :         tableBody(j + 1, state.dataGlobal->NumOfZones + 3) = RealToStr(columnSum.at(j) / state.dataGlobal->NumOfZones, 2);
   12947              :     }
   12948            2 :     tableBody(columnNum, state.dataGlobal->NumOfZones + 1) = "-";
   12949            2 :     tableBody(columnNum, state.dataGlobal->NumOfZones + 2) = "-";
   12950            2 :     tableBody(columnNum, state.dataGlobal->NumOfZones + 3) = "-";
   12951              : 
   12952            2 :     WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
   12953            2 :     if (state.dataSQLiteProcedures->sqlite) {
   12954            0 :         state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
   12955              :             tableBody, rowHead, columnHead, "AnnualThermalResilienceSummary", "Entire Facility", tableName);
   12956              :     }
   12957            2 :     if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
   12958            0 :         state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(
   12959              :             tableBody, rowHead, columnHead, "AnnualThermalResilienceSummary", "Entire Facility", tableName);
   12960              :     }
   12961            2 : }
   12962              : 
   12963            2 : void WriteSETHoursTableReportingPeriod(EnergyPlusData &state,
   12964              :                                        int const columnNum,
   12965              :                                        int const periodIdx,
   12966              :                                        const std::string &periodTitle,
   12967              :                                        const std::string &tableName,
   12968              :                                        Array1D_string const &columnHead,
   12969              :                                        Array1D_int &columnWidth,
   12970              :                                        Array2D<std::vector<Real64>> const &ZoneBins,
   12971              :                                        Array1D_string &rowHead,
   12972              :                                        Array2D_string &tableBody,
   12973              :                                        Real64 const unitConvMultiplier)
   12974              : {
   12975              : 
   12976            2 :     WriteSubtitle(state, tableName);
   12977              : 
   12978            2 :     std::vector<Real64> columnMax(columnNum - 1, 0);
   12979            2 :     std::vector<Real64> columnMin(columnNum - 1, 0);
   12980            2 :     std::vector<Real64> columnSum(columnNum - 1, 0);
   12981            2 :     std::vector<Real64> multiplier(columnNum - 1, unitConvMultiplier);
   12982            2 :     multiplier[columnNum - 2] = 1.0;
   12983              : 
   12984           10 :     for (int j = 0; j < columnNum - 1; j++) {
   12985            8 :         columnMin.at(j) = ZoneBins(1, periodIdx).at(j) * multiplier.at(j);
   12986              :     }
   12987            4 :     for (int ZoneNum = 1; ZoneNum <= state.dataGlobal->NumOfZones; ZoneNum++) {
   12988            2 :         std::string const &ZoneName = state.dataHeatBal->Zone(ZoneNum).Name;
   12989            2 :         rowHead(ZoneNum) = ZoneName;
   12990           10 :         for (int j = 0; j < columnNum - 1; j++) {
   12991            8 :             Real64 curValue = ZoneBins(ZoneNum, periodIdx).at(j) * multiplier.at(j);
   12992            8 :             if (curValue > columnMax.at(j)) {
   12993            2 :                 columnMax.at(j) = curValue;
   12994              :             }
   12995            8 :             if (curValue < columnMin.at(j)) {
   12996            0 :                 columnMin.at(j) = curValue;
   12997              :             }
   12998            8 :             columnSum.at(j) += curValue;
   12999            8 :             tableBody(j + 1, ZoneNum) = RealToStr(curValue, 2);
   13000              :         }
   13001            2 :         tableBody(columnNum, ZoneNum) = DateToString(ZoneBins(ZoneNum, periodIdx)[columnNum - 1]);
   13002              :     }
   13003              : 
   13004            2 :     rowHead(state.dataGlobal->NumOfZones + 1) = "Min";
   13005            2 :     rowHead(state.dataGlobal->NumOfZones + 2) = "Max";
   13006            2 :     rowHead(state.dataGlobal->NumOfZones + 3) = "Average";
   13007              : 
   13008           10 :     for (int j = 0; j < columnNum - 1; j++) {
   13009            8 :         tableBody(j + 1, state.dataGlobal->NumOfZones + 1) = RealToStr(columnMin.at(j), 2);
   13010            8 :         tableBody(j + 1, state.dataGlobal->NumOfZones + 2) = RealToStr(columnMax.at(j), 2);
   13011            8 :         tableBody(j + 1, state.dataGlobal->NumOfZones + 3) = RealToStr(columnSum.at(j) / state.dataGlobal->NumOfZones, 2);
   13012              :     }
   13013            2 :     tableBody(columnNum, state.dataGlobal->NumOfZones + 1) = "-";
   13014            2 :     tableBody(columnNum, state.dataGlobal->NumOfZones + 2) = "-";
   13015            2 :     tableBody(columnNum, state.dataGlobal->NumOfZones + 3) = "-";
   13016              : 
   13017            2 :     WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
   13018            2 :     if (state.dataSQLiteProcedures->sqlite) {
   13019            0 :         state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
   13020            0 :             tableBody, rowHead, columnHead, "ReportingPeriod-" + periodTitle + "-ThermalResilienceSummary", "Entire Facility", tableName);
   13021              :     }
   13022            2 :     if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
   13023            0 :         state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(
   13024            0 :             tableBody, rowHead, columnHead, "ReportingPeriod-" + periodTitle + "-ThermalResilienceSummary", "Entire Facility", tableName);
   13025              :     }
   13026            2 : }
   13027              : 
   13028           55 : std::string RetrieveEntryFromTableBody(Array2D_string const &tableBody, int const rowIndex, int const columnIndex)
   13029              : {
   13030           55 :     return trimmed(ljustified(tableBody(columnIndex, rowIndex)));
   13031              : }
   13032              : 
   13033           61 : void WriteHourOfSafetyTableNonPreDefUseZoneData(EnergyPlusData &state,
   13034              :                                                 int const columnNum,
   13035              :                                                 const std::string &tableName,
   13036              :                                                 Array1D_string const &columnHead,
   13037              :                                                 Array1D_int &columnWidth,
   13038              :                                                 const std::array<Real64, 5> DataHeatBalance::ZoneResilience::*memberPtr,
   13039              :                                                 Array1D_string &rowHead,
   13040              :                                                 Array2D_string &tableBody,
   13041              :                                                 int const dateColIdx)
   13042              : {
   13043              : 
   13044           61 :     WriteSubtitle(state, tableName);
   13045          135 :     for (int ZoneNum = 1; ZoneNum <= state.dataGlobal->NumOfZones; ++ZoneNum) {
   13046           74 :         rowHead(ZoneNum) = state.dataHeatBal->Zone(ZoneNum).Name;
   13047          444 :         for (int j = 1; j <= columnNum; j++) {
   13048          370 :             tableBody(j, ZoneNum) = RealToStr((state.dataHeatBal->Resilience(ZoneNum).*memberPtr).at(j - 1), 2);
   13049              :         }
   13050           74 :         tableBody(dateColIdx, ZoneNum) = DateToString((state.dataHeatBal->Resilience(ZoneNum).*memberPtr).at(dateColIdx - 1));
   13051              :     }
   13052              : 
   13053           61 :     std::vector<Real64> columnMax(columnNum, 0);
   13054           61 :     std::vector<Real64> columnMin(columnNum, 0);
   13055           61 :     std::vector<Real64> columnSum(columnNum, 0);
   13056              : 
   13057          366 :     for (int j = 0; j < columnNum; j++) {
   13058          305 :         columnMin.at(j) = (state.dataHeatBal->Resilience(1).*memberPtr).at(j);
   13059              :     }
   13060          135 :     for (int ZoneNum = 1; ZoneNum <= state.dataGlobal->NumOfZones; ++ZoneNum) {
   13061          444 :         for (int j = 0; j < columnNum; j++) {
   13062          370 :             Real64 curValue = (state.dataHeatBal->Resilience(ZoneNum).*memberPtr).at(j);
   13063          370 :             if (curValue > columnMax.at(j)) {
   13064            8 :                 columnMax.at(j) = curValue;
   13065              :             }
   13066          370 :             if (curValue < columnMin.at(j)) {
   13067            0 :                 columnMin.at(j) = curValue;
   13068              :             }
   13069          370 :             columnSum.at(j) += curValue;
   13070              :         }
   13071              :     }
   13072              : 
   13073           61 :     rowHead(state.dataGlobal->NumOfZones + 1) = "Min";
   13074           61 :     rowHead(state.dataGlobal->NumOfZones + 2) = "Max";
   13075           61 :     rowHead(state.dataGlobal->NumOfZones + 3) = "Average";
   13076           61 :     rowHead(state.dataGlobal->NumOfZones + 4) = "Sum";
   13077              : 
   13078          366 :     for (int j = 0; j < columnNum; j++) {
   13079          305 :         tableBody(j + 1, state.dataGlobal->NumOfZones + 1) = RealToStr(columnMin.at(j), 2);
   13080          305 :         tableBody(j + 1, state.dataGlobal->NumOfZones + 2) = RealToStr(columnMax.at(j), 2);
   13081          305 :         tableBody(j + 1, state.dataGlobal->NumOfZones + 3) = RealToStr(columnSum.at(j) / state.dataGlobal->NumOfZones, 2);
   13082          305 :         tableBody(j + 1, state.dataGlobal->NumOfZones + 4) = RealToStr(columnSum.at(j), 2);
   13083              :     }
   13084              : 
   13085          305 :     for (int i = 1; i < 5; i++) {
   13086          244 :         tableBody(dateColIdx, state.dataGlobal->NumOfZones + i) = "-";
   13087              :     }
   13088              : 
   13089           61 :     WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
   13090           61 :     if (state.dataSQLiteProcedures->sqlite) {
   13091            6 :         state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
   13092              :             tableBody, rowHead, columnHead, "AnnualThermalResilienceSummary", "Entire Facility", tableName);
   13093              :     }
   13094           61 :     if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
   13095            0 :         state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(
   13096              :             tableBody, rowHead, columnHead, "AnnualThermalResilienceSummary", "Entire Facility", tableName);
   13097              :     }
   13098           61 : }
   13099              : 
   13100            0 : void WriteHourOfSafetyTableReportingPeriod(EnergyPlusData &state,
   13101              :                                            int const columnNum,
   13102              :                                            int const periodIdx,
   13103              :                                            const std::string &periodTitle,
   13104              :                                            const std::string &tableName,
   13105              :                                            Array1D_string const &columnHead,
   13106              :                                            Array1D_int &columnWidth,
   13107              :                                            Array2D<std::vector<Real64>> const &ZoneBins,
   13108              :                                            Array1D_string &rowHead,
   13109              :                                            Array2D_string &tableBody,
   13110              :                                            int const dateColIdx)
   13111              : {
   13112              : 
   13113            0 :     WriteSubtitle(state, tableName);
   13114            0 :     for (int ZoneNum = 1; ZoneNum <= state.dataGlobal->NumOfZones; ++ZoneNum) {
   13115            0 :         rowHead(ZoneNum) = state.dataHeatBal->Zone(ZoneNum).Name;
   13116            0 :         for (int j = 1; j <= columnNum; j++) {
   13117            0 :             tableBody(j, ZoneNum) = RealToStr(ZoneBins(ZoneNum, periodIdx).at(j - 1), 2);
   13118              :         }
   13119            0 :         tableBody(dateColIdx, ZoneNum) = DateToString(ZoneBins(ZoneNum, periodIdx).at(dateColIdx - 1));
   13120              :     }
   13121              : 
   13122            0 :     std::vector<Real64> columnMax(columnNum, 0);
   13123            0 :     std::vector<Real64> columnMin(columnNum, 0);
   13124            0 :     std::vector<Real64> columnSum(columnNum, 0);
   13125              : 
   13126            0 :     for (int j = 0; j < columnNum; j++) {
   13127            0 :         columnMin.at(j) = ZoneBins(1, periodIdx).at(j);
   13128              :     }
   13129            0 :     for (int i = 1; i <= state.dataGlobal->NumOfZones; ++i) {
   13130            0 :         for (int j = 0; j < columnNum; j++) {
   13131            0 :             Real64 curValue = ZoneBins(i, periodIdx).at(j);
   13132            0 :             if (curValue > columnMax.at(j)) {
   13133            0 :                 columnMax.at(j) = curValue;
   13134              :             }
   13135            0 :             if (curValue < columnMin.at(j)) {
   13136            0 :                 columnMin.at(j) = curValue;
   13137              :             }
   13138            0 :             columnSum.at(j) += curValue;
   13139              :         }
   13140              :     }
   13141              : 
   13142            0 :     rowHead(state.dataGlobal->NumOfZones + 1) = "Min";
   13143            0 :     rowHead(state.dataGlobal->NumOfZones + 2) = "Max";
   13144            0 :     rowHead(state.dataGlobal->NumOfZones + 3) = "Average";
   13145            0 :     rowHead(state.dataGlobal->NumOfZones + 4) = "Sum";
   13146              : 
   13147            0 :     for (int j = 0; j < columnNum; j++) {
   13148            0 :         tableBody(j + 1, state.dataGlobal->NumOfZones + 1) = RealToStr(columnMin.at(j), 2);
   13149            0 :         tableBody(j + 1, state.dataGlobal->NumOfZones + 2) = RealToStr(columnMax.at(j), 2);
   13150            0 :         tableBody(j + 1, state.dataGlobal->NumOfZones + 3) = RealToStr(columnSum.at(j) / state.dataGlobal->NumOfZones, 2);
   13151            0 :         tableBody(j + 1, state.dataGlobal->NumOfZones + 4) = RealToStr(columnSum.at(j), 2);
   13152              :     }
   13153              : 
   13154            0 :     for (int i = 1; i < 5; i++) {
   13155            0 :         tableBody(dateColIdx, state.dataGlobal->NumOfZones + i) = "-";
   13156              :     }
   13157              : 
   13158            0 :     WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
   13159            0 :     if (state.dataSQLiteProcedures->sqlite) {
   13160            0 :         state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
   13161            0 :             tableBody, rowHead, columnHead, "ReportingPeriod-" + periodTitle + "-ThermalResilienceSummary", "Entire Facility", tableName);
   13162              :     }
   13163            0 :     if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
   13164            0 :         state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(
   13165            0 :             tableBody, rowHead, columnHead, "ReportingPeriod-" + periodTitle + "-ThermalResilienceSummary", "Entire Facility", tableName);
   13166              :     }
   13167            0 : }
   13168              : 
   13169            0 : void WriteHourOfSafetyTable(EnergyPlusData &state,
   13170              :                             int const columnNum,
   13171              :                             std::vector<int> const &columnHead,
   13172              :                             Array1D<std::vector<Real64>> const &ZoneBins,
   13173              :                             int const dateColIdx)
   13174              : {
   13175            0 :     std::vector<Real64> columnMax(columnNum, 0);
   13176            0 :     std::vector<Real64> columnMin(columnNum, 0);
   13177            0 :     std::vector<Real64> columnSum(columnNum, 0);
   13178            0 :     for (int j = 0; j < columnNum; j++) {
   13179            0 :         columnMin[j] = ZoneBins(1)[j];
   13180              :     }
   13181            0 :     for (int i = 1; i <= state.dataGlobal->NumOfZones; ++i) {
   13182            0 :         auto const &thisZone = state.dataHeatBal->Zone(i);
   13183            0 :         for (int j = 0; j < columnNum; j++) {
   13184            0 :             if (j == dateColIdx) {
   13185            0 :                 std::string startDateTime = DateToString(int(ZoneBins(i)[dateColIdx]));
   13186            0 :                 PreDefTableEntry(state, columnHead[dateColIdx], thisZone.Name, startDateTime);
   13187            0 :             } else {
   13188            0 :                 Real64 curValue = ZoneBins(i)[j];
   13189            0 :                 if (curValue > columnMax[j]) {
   13190            0 :                     columnMax[j] = curValue;
   13191              :                 }
   13192            0 :                 if (curValue < columnMin[j]) {
   13193            0 :                     columnMin[j] = curValue;
   13194              :                 }
   13195            0 :                 columnSum[j] += curValue;
   13196            0 :                 PreDefTableEntry(state, columnHead[j], thisZone.Name, RealToStr(curValue, 2));
   13197              :             }
   13198              :         }
   13199              :     }
   13200            0 :     for (int j = 0; j < columnNum; j++) {
   13201            0 :         if (j == dateColIdx) {
   13202            0 :             PreDefTableEntry(state, columnHead[j], "Min", "-");
   13203            0 :             PreDefTableEntry(state, columnHead[j], "Max", "-");
   13204            0 :             PreDefTableEntry(state, columnHead[j], "Average", "-");
   13205            0 :             PreDefTableEntry(state, columnHead[j], "Sum", "-");
   13206              :         } else {
   13207            0 :             PreDefTableEntry(state, columnHead[j], "Min", RealToStr(columnMin[j], 2));
   13208            0 :             PreDefTableEntry(state, columnHead[j], "Max", RealToStr(columnMax[j], 2));
   13209            0 :             PreDefTableEntry(state, columnHead[j], "Average", RealToStr(columnSum[j] / state.dataGlobal->NumOfZones, 2));
   13210            0 :             PreDefTableEntry(state, columnHead[j], "Sum", RealToStr(columnSum[j], 2));
   13211              :         }
   13212              :     }
   13213            0 : }
   13214              : 
   13215           30 : void WriteThermalResilienceTables(EnergyPlusData &state)
   13216              : {
   13217              : 
   13218              :     // Using/Aliasing
   13219           30 :     auto const &ort = state.dataOutRptTab;
   13220              : 
   13221           30 :     if (state.dataGlobal->NumOfZones <= 0) {
   13222            0 :         return;
   13223              :     }
   13224              : 
   13225              :     Real64 degreeHourConversion;
   13226           30 :     UnitsStyle unitsStyle_cur = ort->unitsStyle;
   13227           30 :     if (unitsStyle_cur == OutputReportTabular::UnitsStyle::InchPound ||
   13228              :         unitsStyle_cur == OutputReportTabular::UnitsStyle::InchPoundExceptElectricity) {
   13229            4 :         degreeHourConversion = getSpecificUnitMultiplier(state, "°C·hr", "°F·hr");
   13230              :     } else {
   13231           29 :         degreeHourConversion = 1.0;
   13232              :     }
   13233              : 
   13234           90 :     WriteReportHeaders(state, "Annual Thermal Resilience Summary", "Entire Facility", OutputProcessor::StoreType::Average);
   13235              : 
   13236           30 :     Array1D_int columnWidth;
   13237           30 :     columnWidth.allocate(numColumnThermalTbl);
   13238           30 :     columnWidth = 10;
   13239           30 :     Array1D_string rowHead;
   13240           30 :     Array2D_string tableBody;
   13241           30 :     rowHead.allocate(state.dataGlobal->NumOfZones + 4);
   13242           30 :     tableBody.allocate(numColumnThermalTbl, state.dataGlobal->NumOfZones + 4);
   13243           30 :     Array1D_string columnHeadStr(numColumnThermalTbl);
   13244              : 
   13245           30 :     if (unitsStyle_cur == OutputReportTabular::UnitsStyle::InchPound ||
   13246              :         unitsStyle_cur == OutputReportTabular::UnitsStyle::InchPoundExceptElectricity) {
   13247            1 :         columnHeadStr(1) = "Safe (≤ 80.1°F) [hr]";
   13248            1 :         columnHeadStr(2) = "Caution (> 80.1°F, ≤ 90.0°F) [hr]";
   13249            1 :         columnHeadStr(3) = "Extreme Caution (> 90.0°F, ≤ 102.9°F) [hr]";
   13250            1 :         columnHeadStr(4) = "Danger (> 102.9, ≤ 125.1°F) [hr]";
   13251            1 :         columnHeadStr(5) = "Extreme Danger (> 125.1°F) [hr]";
   13252              :     } else {
   13253           29 :         columnHeadStr(1) = "Safe (≤ 26.7°C) [hr]";
   13254           29 :         columnHeadStr(2) = "Caution (> 26.7°C, ≤ 32.2°C) [hr]";
   13255           29 :         columnHeadStr(3) = "Extreme Caution (> 32.2°C, ≤ 39.4°C) [hr]";
   13256           29 :         columnHeadStr(4) = "Danger (> 39.4°C, ≤ 51.7°C) [hr]";
   13257           29 :         columnHeadStr(5) = "Extreme Danger (> 51.7°C) [hr]";
   13258              :     }
   13259              : 
   13260           30 :     std::array<Real64, numColumnThermalTbl> DataHeatBalance::ZoneResilience::*ptrHeatIndex = &DataHeatBalance::ZoneResilience::ZoneHeatIndexHourBins;
   13261           30 :     std::array<Real64, numColumnThermalTbl> DataHeatBalance::ZoneResilience::*ptrHeatIndexOccuHour =
   13262              :         &DataHeatBalance::ZoneResilience::ZoneHeatIndexOccuHourBins;
   13263           30 :     std::array<Real64, numColumnThermalTbl> DataHeatBalance::ZoneResilience::*ptrHeatIndexOccupiedHour =
   13264              :         &DataHeatBalance::ZoneResilience::ZoneHeatIndexOccupiedHourBins;
   13265           30 :     std::string tableName = "Heat Index Hours";
   13266           30 :     WriteResilienceBinsTableNonPreDefUseZoneData<numColumnThermalTbl>(state, tableName, columnHeadStr, columnWidth, ptrHeatIndex, rowHead, tableBody);
   13267           30 :     tableName = "Heat Index OccupantHours";
   13268           30 :     WriteResilienceBinsTableNonPreDefUseZoneData<numColumnThermalTbl>(
   13269              :         state, tableName, columnHeadStr, columnWidth, ptrHeatIndexOccuHour, rowHead, tableBody);
   13270           30 :     tableName = "Heat Index OccupiedHours";
   13271           30 :     WriteResilienceBinsTableNonPreDefUseZoneData<numColumnThermalTbl>(
   13272              :         state, tableName, columnHeadStr, columnWidth, ptrHeatIndexOccupiedHour, rowHead, tableBody);
   13273              : 
   13274           30 :     columnHeadStr(1) = "Little to no Discomfort (≤ 29) [hr]";
   13275           30 :     columnHeadStr(2) = "Some Discomfort (> 29, ≤ 40) [hr]";
   13276           30 :     columnHeadStr(3) = "Great Discomfort; Avoid Exertion (> 40, ≤ 45) [hr]";
   13277           30 :     columnHeadStr(4) = "Dangerous (> 45, ≤ 50) [hr]";
   13278           30 :     columnHeadStr(5) = "Heat Stroke Quite Possible (> 50) [hr]";
   13279              : 
   13280           30 :     std::array<Real64, numColumnThermalTbl> DataHeatBalance::ZoneResilience::*ptrHumidex = &DataHeatBalance::ZoneResilience::ZoneHumidexHourBins;
   13281           30 :     std::array<Real64, numColumnThermalTbl> DataHeatBalance::ZoneResilience::*ptrHumidexOccuHour =
   13282              :         &DataHeatBalance::ZoneResilience::ZoneHumidexOccuHourBins;
   13283           30 :     std::array<Real64, numColumnThermalTbl> DataHeatBalance::ZoneResilience::*ptrHumidexOccupiedHour =
   13284              :         &DataHeatBalance::ZoneResilience::ZoneHumidexOccupiedHourBins;
   13285           30 :     tableName = "Humidex Hours";
   13286           30 :     WriteResilienceBinsTableNonPreDefUseZoneData<numColumnThermalTbl>(state, tableName, columnHeadStr, columnWidth, ptrHumidex, rowHead, tableBody);
   13287           30 :     tableName = "Humidex OccupantHours";
   13288           30 :     WriteResilienceBinsTableNonPreDefUseZoneData<numColumnThermalTbl>(
   13289              :         state, tableName, columnHeadStr, columnWidth, ptrHumidexOccuHour, rowHead, tableBody);
   13290           30 :     tableName = "Humidex OccupiedHours";
   13291           30 :     WriteResilienceBinsTableNonPreDefUseZoneData<numColumnThermalTbl>(
   13292              :         state, tableName, columnHeadStr, columnWidth, ptrHumidexOccupiedHour, rowHead, tableBody);
   13293              : 
   13294           30 :     bool hasPierceSET = true;
   13295           30 :     if (state.dataHeatBal->TotPeople == 0) {
   13296           24 :         hasPierceSET = false;
   13297           24 :         if (ort->displayThermalResilienceSummaryExplicitly) {
   13298            0 :             ShowWarningError(state,
   13299              :                              "Writing Annual Thermal Resilience Summary - SET Degree-Hours reports: "
   13300              :                              "Zone Thermal Comfort Pierce Model Standard Effective Temperature is required, "
   13301              :                              "but no People object is defined.");
   13302              :         }
   13303              :     }
   13304           42 :     for (int iPeople = 1; iPeople <= state.dataHeatBal->TotPeople; ++iPeople) {
   13305           12 :         if (!state.dataHeatBal->People(iPeople).Pierce) {
   13306           12 :             hasPierceSET = false;
   13307           12 :             if (ort->displayThermalResilienceSummaryExplicitly) {
   13308            0 :                 ShowWarningError(state,
   13309            0 :                                  format("Writing Annual Thermal Resilience Summary - SET Degree-Hours reports: Zone Thermal Comfort Pierce Model "
   13310              :                                         "Standard Effective Temperature is required, but no Pierce model is defined in {} object.",
   13311            0 :                                         state.dataHeatBal->People(iPeople).Name));
   13312              :             }
   13313              :         }
   13314              :     }
   13315              : 
   13316           30 :     if (hasPierceSET) {
   13317            0 :         if (unitsStyle_cur == OutputReportTabular::UnitsStyle::InchPound ||
   13318              :             unitsStyle_cur == OutputReportTabular::UnitsStyle::InchPoundExceptElectricity) {
   13319            0 :             columnHeadStr(1) = "SET > 86°F Degree-Hours [°F·hr]";
   13320            0 :             columnHeadStr(2) = "SET > 86°F Occupant-Weighted Degree-Hours [°F·hr]";
   13321            0 :             columnHeadStr(3) = "SET > 86°F Occupied Degree-Hours [°F·hr]";
   13322            0 :             columnHeadStr(4) = "Longest SET > 86°F Duration for Occupied Period [hr]";
   13323            0 :             columnHeadStr(5) = "Start Time of the Longest SET > 86°F Duration for Occupied Period";
   13324              :         } else {
   13325            0 :             columnHeadStr(1) = "SET > 30°C Degree-Hours [°C·hr]";
   13326            0 :             columnHeadStr(2) = "SET > 30°C Occupant-Weighted Degree-Hours [°C·hr]";
   13327            0 :             columnHeadStr(3) = "SET > 30°C Occupied Degree-Hours [°C·hr]";
   13328            0 :             columnHeadStr(4) = "Longest SET > 30°C Duration for Occupied Period [hr]";
   13329            0 :             columnHeadStr(5) = "Start Time of the Longest SET > 30°C Duration for Occupied Period";
   13330              :         }
   13331              : 
   13332            0 :         std::array<Real64, numColumnThermalTbl> DataHeatBalance::ZoneResilience::*ptrLowSETHours = &DataHeatBalance::ZoneResilience::ZoneLowSETHours;
   13333            0 :         std::array<Real64, numColumnThermalTbl> DataHeatBalance::ZoneResilience::*ptrHighSETHours =
   13334              :             &DataHeatBalance::ZoneResilience::ZoneHighSETHours;
   13335            0 :         Array1D_string rowHeadSET;
   13336            0 :         Array2D_string tableBodySET;
   13337            0 :         rowHeadSET.allocate(state.dataGlobal->NumOfZones + 3);
   13338            0 :         tableBodySET.allocate(numColumnThermalTbl, state.dataGlobal->NumOfZones + 3);
   13339            0 :         tableName = "Heating SET Degree-Hours";
   13340            0 :         WriteSETHoursTableNonPreDefUseZoneData(
   13341              :             state, numColumnThermalTbl, tableName, columnHeadStr, columnWidth, ptrLowSETHours, rowHeadSET, tableBodySET, degreeHourConversion);
   13342            0 :         tableName = "Cooling SET Degree-Hours";
   13343            0 :         WriteSETHoursTableNonPreDefUseZoneData(
   13344              :             state, numColumnThermalTbl, tableName, columnHeadStr, columnWidth, ptrHighSETHours, rowHeadSET, tableBodySET, degreeHourConversion);
   13345            0 :     }
   13346              : 
   13347           30 :     std::array<Real64, numColumnThermalTbl> DataHeatBalance::ZoneResilience::*ptrColdHourOfSafetyBins =
   13348              :         &DataHeatBalance::ZoneResilience::ZoneColdHourOfSafetyBins;
   13349           30 :     std::array<Real64, numColumnThermalTbl> DataHeatBalance::ZoneResilience::*ptrHeatHourOfSafetyBins =
   13350              :         &DataHeatBalance::ZoneResilience::ZoneHeatHourOfSafetyBins;
   13351           30 :     tableName = "Hours of Safety for Cold Events";
   13352           30 :     columnHeadStr(1) = "Hours of Safety [hr]";
   13353           30 :     columnHeadStr(2) = "End Time of the Safety Duration";
   13354           30 :     columnHeadStr(3) = "Safe Temperature Exceedance Hours [hr]";
   13355           30 :     columnHeadStr(4) = "Safe Temperature Exceedance OccupantHours [hr]";
   13356           30 :     columnHeadStr(5) = "Safe Temperature Exceedance OccupiedHours [hr]";
   13357           30 :     WriteHourOfSafetyTableNonPreDefUseZoneData(
   13358              :         state, numColumnThermalTbl, tableName, columnHeadStr, columnWidth, ptrColdHourOfSafetyBins, rowHead, tableBody, 2);
   13359           30 :     tableName = "Hours of Safety for Heat Events";
   13360           30 :     WriteHourOfSafetyTableNonPreDefUseZoneData(
   13361              :         state, numColumnThermalTbl, tableName, columnHeadStr, columnWidth, ptrHeatHourOfSafetyBins, rowHead, tableBody, 2);
   13362              : 
   13363           30 :     Array1D_int columnWidthUnmetDegHr;
   13364           30 :     columnWidthUnmetDegHr.allocate(numColumnUnmetDegreeHourTbl);
   13365           30 :     columnWidthUnmetDegHr = 10;
   13366           30 :     Array1D_string columnHeadUnmetDegHr;
   13367           30 :     columnHeadUnmetDegHr.allocate(numColumnUnmetDegreeHourTbl);
   13368           30 :     Array2D_string tableBodyUnmetDegHr;
   13369           30 :     tableBodyUnmetDegHr.allocate(numColumnUnmetDegreeHourTbl, state.dataGlobal->NumOfZones + 4);
   13370           30 :     tableName = "Unmet Degree-Hours";
   13371           30 :     columnHeadUnmetDegHr(1) = "Cooling Setpoint Unmet Degree-Hours [°C·hr]";
   13372           30 :     columnHeadUnmetDegHr(2) = "Cooling Setpoint Unmet Occupant-Weighted Degree-Hours [°C·hr]";
   13373           30 :     columnHeadUnmetDegHr(3) = "Cooling Setpoint Unmet Occupied Degree-Hours [°C·hr]";
   13374           30 :     columnHeadUnmetDegHr(4) = "Heating Setpoint Unmet Degree-Hours [°C·hr]";
   13375           30 :     columnHeadUnmetDegHr(5) = "Heating Setpoint Unmet Occupant-Weighted Degree-Hours [°C·hr]";
   13376           30 :     columnHeadUnmetDegHr(6) = "Heating Setpoint Unmet Occupied Degree-Hours [°C·hr]";
   13377              : 
   13378           30 :     if (unitsStyle_cur == UnitsStyle::InchPound) {
   13379              :         int indexUnitConv;
   13380            1 :         std::string curUnits;
   13381            6 :         for (int i = 1; i < numColumnUnmetDegreeHourTbl; i++) {
   13382            5 :             LookupSItoIP(state, columnHeadUnmetDegHr(i), indexUnitConv, curUnits);
   13383            5 :             columnHeadUnmetDegHr(i) = curUnits;
   13384              :         }
   13385           30 :     } else if (unitsStyle_cur == UnitsStyle::InchPoundExceptElectricity) {
   13386              :         int indexUnitConv;
   13387            0 :         std::string curUnits;
   13388            0 :         for (int i = 1; i < numColumnUnmetDegreeHourTbl; i++) {
   13389            0 :             LookupSItoIP(state, columnHeadUnmetDegHr(i), indexUnitConv, curUnits);
   13390            0 :             columnHeadUnmetDegHr(i) = curUnits;
   13391              :         }
   13392            0 :     }
   13393              : 
   13394           30 :     std::array<Real64, numColumnUnmetDegreeHourTbl> DataHeatBalance::ZoneResilience::*ptrUnmetDegreeHourBins =
   13395              :         &DataHeatBalance::ZoneResilience::ZoneUnmetDegreeHourBins;
   13396           30 :     WriteResilienceBinsTableNonPreDefUseZoneData<numColumnUnmetDegreeHourTbl>(
   13397              :         state, tableName, columnHeadUnmetDegHr, columnWidthUnmetDegHr, ptrUnmetDegreeHourBins, rowHead, tableBodyUnmetDegHr, degreeHourConversion);
   13398              : 
   13399           30 :     columnHeadStr.allocate(numColumnDiscomfortWtExceedHourTbl);
   13400           30 :     columnWidth.allocate(numColumnDiscomfortWtExceedHourTbl);
   13401           30 :     columnWidth = 10;
   13402           30 :     tableBody.allocate(numColumnDiscomfortWtExceedHourTbl, state.dataGlobal->NumOfZones + 4);
   13403           30 :     columnHeadStr(1) = "Very-cold Exceedance OccupantHours [hr]";
   13404           30 :     columnHeadStr(2) = "Cool Exceedance OccupantHours [hr]";
   13405           30 :     columnHeadStr(3) = "Warm Exceedance OccupantHours [hr]";
   13406           30 :     columnHeadStr(4) = "Very-hot Exceedance OccupantHours [hr]";
   13407              : 
   13408           30 :     std::array<Real64, numColumnDiscomfortWtExceedHourTbl> DataHeatBalance::ZoneResilience::*ptrDiscomfortWtExceedOccuHourBins =
   13409              :         &DataHeatBalance::ZoneResilience::ZoneDiscomfortWtExceedOccuHourBins;
   13410           30 :     std::array<Real64, numColumnDiscomfortWtExceedHourTbl> DataHeatBalance::ZoneResilience::*ptrDiscomfortWtExceedOccupiedHourBins =
   13411              :         &DataHeatBalance::ZoneResilience::ZoneDiscomfortWtExceedOccupiedHourBins;
   13412           30 :     tableName = "Discomfort-weighted Exceedance OccupantHours";
   13413           30 :     WriteResilienceBinsTableNonPreDefUseZoneData<numColumnDiscomfortWtExceedHourTbl>(
   13414              :         state, tableName, columnHeadStr, columnWidth, ptrDiscomfortWtExceedOccuHourBins, rowHead, tableBody);
   13415           30 :     tableName = "Discomfort-weighted Exceedance OccupiedHours";
   13416           30 :     WriteResilienceBinsTableNonPreDefUseZoneData<numColumnDiscomfortWtExceedHourTbl>(
   13417              :         state, tableName, columnHeadStr, columnWidth, ptrDiscomfortWtExceedOccupiedHourBins, rowHead, tableBody);
   13418           30 :     rowHead.deallocate();
   13419           30 :     columnHeadStr.deallocate();
   13420           30 :     tableBody.deallocate();
   13421           30 :     tableBodyUnmetDegHr.deallocate();
   13422           30 :     columnWidth.deallocate();
   13423           30 :     columnHeadUnmetDegHr.deallocate();
   13424           30 :     columnWidthUnmetDegHr.deallocate();
   13425           30 : }
   13426              : 
   13427            0 : void WriteCO2ResilienceTables(EnergyPlusData &state)
   13428              : {
   13429              : 
   13430            0 :     if (state.dataGlobal->NumOfZones <= 0) {
   13431            0 :         return;
   13432              :     }
   13433              :     std::array<int, numColumnCO2Tbl> columnHead = {
   13434            0 :         state.dataOutRptPredefined->pdchCO2HourSafe, state.dataOutRptPredefined->pdchCO2HourCaution, state.dataOutRptPredefined->pdchCO2HourHazard};
   13435              : 
   13436            0 :     std::array<Real64, numColumnCO2Tbl> DataHeatBalance::ZoneResilience::*ptrCO2LevelHourBins =
   13437              :         &DataHeatBalance::ZoneResilience::ZoneCO2LevelHourBins;
   13438            0 :     std::array<Real64, numColumnCO2Tbl> DataHeatBalance::ZoneResilience::*ptrCO2LevelOccuHourBins =
   13439              :         &DataHeatBalance::ZoneResilience::ZoneCO2LevelOccuHourBins;
   13440            0 :     std::array<Real64, numColumnCO2Tbl> DataHeatBalance::ZoneResilience::*ptrCO2LevelOccupiedHourBins =
   13441              :         &DataHeatBalance::ZoneResilience::ZoneCO2LevelOccupiedHourBins;
   13442            0 :     WriteResilienceBinsTable<numColumnCO2Tbl>(state, columnHead, ptrCO2LevelHourBins);
   13443              : 
   13444            0 :     columnHead = {state.dataOutRptPredefined->pdchCO2OccuHourSafe,
   13445            0 :                   state.dataOutRptPredefined->pdchCO2OccuHourCaution,
   13446            0 :                   state.dataOutRptPredefined->pdchCO2OccuHourHazard};
   13447            0 :     WriteResilienceBinsTable<numColumnCO2Tbl>(state, columnHead, ptrCO2LevelOccuHourBins);
   13448              : 
   13449            0 :     columnHead = {state.dataOutRptPredefined->pdchCO2OccupiedHourSafe,
   13450            0 :                   state.dataOutRptPredefined->pdchCO2OccupiedHourCaution,
   13451            0 :                   state.dataOutRptPredefined->pdchCO2OccupiedHourHazard};
   13452            0 :     WriteResilienceBinsTable<numColumnCO2Tbl>(state, columnHead, ptrCO2LevelOccupiedHourBins);
   13453              : }
   13454              : 
   13455            0 : void WriteCO2ResilienceTablesRepPeriod(EnergyPlusData &state, const int periodIdx)
   13456              : {
   13457            0 :     auto const &ort = state.dataOutRptTab;
   13458              :     // TODO: this is wrong. This function is called only when ort->WriteTabularFiles is true already. Missing a '!'
   13459            0 :     if (ort->WriteTabularFiles) {
   13460            0 :         return;
   13461              :     }
   13462            0 :     WriteReportHeaderReportingPeriod(state, "CO2", periodIdx, state.dataWeather->CO2ReportPeriodInput);
   13463            0 :     std::string periodTitle = state.dataWeather->CO2ReportPeriodInput(periodIdx).title;
   13464              : 
   13465            0 :     Array1D_int columnWidth;
   13466            0 :     columnWidth.allocate(numColumnCO2Tbl);
   13467            0 :     columnWidth = 10;
   13468            0 :     Array1D_string columnHead(numColumnCO2Tbl);
   13469            0 :     columnHead(1) = "Safe (<= 1000 ppm) [hr]";
   13470            0 :     columnHead(2) = "Caution (> 1000, <= 5000 ppm) [hr]";
   13471            0 :     columnHead(3) = "Hazard (> 5000 ppm) [hr]";
   13472              : 
   13473            0 :     Array1D_string rowHead;
   13474            0 :     Array2D_string tableBody;
   13475            0 :     rowHead.allocate(state.dataGlobal->NumOfZones + 4);
   13476            0 :     tableBody.allocate(numColumnCO2Tbl, state.dataGlobal->NumOfZones + 4);
   13477              : 
   13478            0 :     std::string tableName = "CO2 Level Hours";
   13479            0 :     std::string tableType = "CO2";
   13480            0 :     WriteResilienceBinsTableReportingPeriod(state,
   13481              :                                             tableType,
   13482              :                                             numColumnCO2Tbl,
   13483              :                                             periodIdx,
   13484              :                                             periodTitle,
   13485              :                                             tableName,
   13486              :                                             columnHead,
   13487              :                                             columnWidth,
   13488            0 :                                             state.dataHeatBalFanSys->ZoneCO2LevelHourBinsRepPeriod,
   13489              :                                             rowHead,
   13490              :                                             tableBody);
   13491              : 
   13492            0 :     tableName = "CO2 Level OccupantHours";
   13493            0 :     WriteResilienceBinsTableReportingPeriod(state,
   13494              :                                             tableType,
   13495              :                                             numColumnCO2Tbl,
   13496              :                                             periodIdx,
   13497              :                                             periodTitle,
   13498              :                                             tableName,
   13499              :                                             columnHead,
   13500              :                                             columnWidth,
   13501            0 :                                             state.dataHeatBalFanSys->ZoneCO2LevelOccuHourBinsRepPeriod,
   13502              :                                             rowHead,
   13503              :                                             tableBody);
   13504              : 
   13505            0 :     tableName = "CO2 Level OccupiedHours";
   13506            0 :     WriteResilienceBinsTableReportingPeriod(state,
   13507              :                                             tableType,
   13508              :                                             numColumnCO2Tbl,
   13509              :                                             periodIdx,
   13510              :                                             periodTitle,
   13511              :                                             tableName,
   13512              :                                             columnHead,
   13513              :                                             columnWidth,
   13514            0 :                                             state.dataHeatBalFanSys->ZoneCO2LevelOccupiedHourBinsRepPeriod,
   13515              :                                             rowHead,
   13516              :                                             tableBody);
   13517            0 : }
   13518              : 
   13519            0 : void WriteVisualResilienceTables(EnergyPlusData &state)
   13520              : {
   13521            0 :     for (int ZoneNum = 1; ZoneNum <= state.dataGlobal->NumOfZones; ++ZoneNum) {
   13522            0 :         if (state.dataDayltg->ZoneDaylight(ZoneNum).totRefPts == 0) {
   13523            0 :             if (state.dataOutRptTab->displayVisualResilienceSummaryExplicitly) {
   13524            0 :                 ShowWarningError(state,
   13525            0 :                                  format("Writing Annual Visual Resilience Summary - Lighting Level Hours reports: Zone Average Daylighting Reference "
   13526              :                                         "Point Illuminance output is required, but no Daylighting Controls are defined in Zone:{}",
   13527            0 :                                         state.dataHeatBal->Zone(ZoneNum).Name));
   13528              :             }
   13529              :         }
   13530              :     }
   13531              : 
   13532            0 :     if (state.dataGlobal->NumOfZones <= 0) {
   13533            0 :         return;
   13534              :     }
   13535            0 :     std::array<int, numColumnVisualTbl> columnHead = {state.dataOutRptPredefined->pdchIllumHourDark,
   13536            0 :                                                       state.dataOutRptPredefined->pdchIllumHourDim,
   13537            0 :                                                       state.dataOutRptPredefined->pdchIllumHourAdequate,
   13538            0 :                                                       state.dataOutRptPredefined->pdchIllumHourBright};
   13539              : 
   13540            0 :     std::array<Real64, numColumnVisualTbl> DataHeatBalance::ZoneResilience::*ptrLightingLevelHourBins =
   13541              :         &DataHeatBalance::ZoneResilience::ZoneLightingLevelHourBins;
   13542            0 :     std::array<Real64, numColumnVisualTbl> DataHeatBalance::ZoneResilience::*ptrLightingLevelOccuHourBins =
   13543              :         &DataHeatBalance::ZoneResilience::ZoneLightingLevelOccuHourBins;
   13544            0 :     std::array<Real64, numColumnVisualTbl> DataHeatBalance::ZoneResilience::*ptrLightingLevelOccupiedHourBins =
   13545              :         &DataHeatBalance::ZoneResilience::ZoneLightingLevelOccupiedHourBins;
   13546            0 :     WriteResilienceBinsTable<numColumnVisualTbl>(state, columnHead, ptrLightingLevelHourBins);
   13547              : 
   13548            0 :     columnHead = {state.dataOutRptPredefined->pdchIllumOccuHourDark,
   13549            0 :                   state.dataOutRptPredefined->pdchIllumOccuHourDim,
   13550            0 :                   state.dataOutRptPredefined->pdchIllumOccuHourAdequate,
   13551            0 :                   state.dataOutRptPredefined->pdchIllumOccuHourBright};
   13552            0 :     WriteResilienceBinsTable<numColumnVisualTbl>(state, columnHead, ptrLightingLevelOccuHourBins);
   13553              : 
   13554            0 :     columnHead = {state.dataOutRptPredefined->pdchIllumOccupiedHourDark,
   13555            0 :                   state.dataOutRptPredefined->pdchIllumOccupiedHourDim,
   13556            0 :                   state.dataOutRptPredefined->pdchIllumOccupiedHourAdequate,
   13557            0 :                   state.dataOutRptPredefined->pdchIllumOccupiedHourBright};
   13558            0 :     WriteResilienceBinsTable<numColumnVisualTbl>(state, columnHead, ptrLightingLevelOccupiedHourBins);
   13559              : }
   13560              : 
   13561            0 : void WriteVisualResilienceTablesRepPeriod(EnergyPlusData &state, const int periodIdx)
   13562              : {
   13563            0 :     auto const &ort = state.dataOutRptTab;
   13564            0 :     if (!ort->WriteTabularFiles) {
   13565            0 :         return;
   13566              :     }
   13567              : 
   13568            0 :     WriteReportHeaderReportingPeriod(state, "Visual", periodIdx, state.dataWeather->VisualReportPeriodInput);
   13569            0 :     std::string periodTitle = state.dataWeather->VisualReportPeriodInput(periodIdx).title;
   13570              : 
   13571            0 :     Array1D_int columnWidth;
   13572            0 :     columnWidth.allocate(numColumnVisualTbl);
   13573            0 :     columnWidth = 10;
   13574            0 :     Array1D_string columnHead(numColumnVisualTbl);
   13575            0 :     columnHead(1) = "A Bit Dark (<= 100 lux) [hr]";
   13576            0 :     columnHead(2) = "Dim (> 100, <= 300 lux) [hr]";
   13577            0 :     columnHead(3) = "Adequate (> 300, <= 500 lux) [hr]";
   13578            0 :     columnHead(4) = "Bright (>500 lux) [hr]";
   13579              : 
   13580            0 :     Array1D_string rowHead;
   13581            0 :     Array2D_string tableBody;
   13582            0 :     rowHead.allocate(state.dataGlobal->NumOfZones + 4);
   13583            0 :     tableBody.allocate(numColumnVisualTbl, state.dataGlobal->NumOfZones + 4);
   13584              : 
   13585            0 :     std::string tableName = "Illuminance Level Hours";
   13586            0 :     std::string tableType = "Visual";
   13587            0 :     WriteResilienceBinsTableReportingPeriod(state,
   13588              :                                             tableType,
   13589              :                                             numColumnVisualTbl,
   13590              :                                             periodIdx,
   13591              :                                             periodTitle,
   13592              :                                             tableName,
   13593              :                                             columnHead,
   13594              :                                             columnWidth,
   13595            0 :                                             state.dataHeatBalFanSys->ZoneLightingLevelHourBinsRepPeriod,
   13596              :                                             rowHead,
   13597              :                                             tableBody);
   13598              : 
   13599            0 :     tableName = "Illuminance Level OccupantHours";
   13600            0 :     WriteResilienceBinsTableReportingPeriod(state,
   13601              :                                             tableType,
   13602              :                                             numColumnVisualTbl,
   13603              :                                             periodIdx,
   13604              :                                             periodTitle,
   13605              :                                             tableName,
   13606              :                                             columnHead,
   13607              :                                             columnWidth,
   13608            0 :                                             state.dataHeatBalFanSys->ZoneLightingLevelOccuHourBinsRepPeriod,
   13609              :                                             rowHead,
   13610              :                                             tableBody);
   13611              : 
   13612            0 :     tableName = "Illuminance Level OccupiedHours";
   13613            0 :     WriteResilienceBinsTableReportingPeriod(state,
   13614              :                                             tableType,
   13615              :                                             numColumnVisualTbl,
   13616              :                                             periodIdx,
   13617              :                                             periodTitle,
   13618              :                                             tableName,
   13619              :                                             columnHead,
   13620              :                                             columnWidth,
   13621            0 :                                             state.dataHeatBalFanSys->ZoneLightingLevelOccupiedHourBinsRepPeriod,
   13622              :                                             rowHead,
   13623              :                                             tableBody);
   13624            0 : }
   13625              : 
   13626           41 : void WriteHeatEmissionTable(EnergyPlusData &state)
   13627              : {
   13628              : 
   13629           41 :     Array1D_string columnHead(6);
   13630           41 :     Array1D_int columnWidth;
   13631           41 :     Array1D_string rowHead;
   13632           41 :     Array2D_string tableBody;
   13633           41 :     auto const &ort = state.dataOutRptTab;
   13634              : 
   13635           41 :     if (state.dataOutRptTab->displayHeatEmissionsSummary) {
   13636              : 
   13637           83 :         for (int iUnitSystem = 0; iUnitSystem <= 1; iUnitSystem++) {
   13638           82 :             UnitsStyle unitsStyle_cur = ort->unitsStyle;
   13639           82 :             bool produceTabular = true;
   13640           82 :             bool produceSQLite = false;
   13641           82 :             if (produceDualUnitsFlags(iUnitSystem, ort->unitsStyle, ort->unitsStyle_SQLite, unitsStyle_cur, produceTabular, produceSQLite)) {
   13642           40 :                 break;
   13643              :             }
   13644              : 
   13645           42 :             if (produceTabular) {
   13646          164 :                 WriteReportHeaders(state, "Annual Heat Emissions Report", "Entire Facility", OutputProcessor::StoreType::Average);
   13647           82 :                 WriteSubtitle(state, "Annual Heat Emissions Summary");
   13648              :             }
   13649              : 
   13650           42 :             columnWidth.allocate(6);
   13651           42 :             columnWidth = 10;
   13652              : 
   13653           42 :             rowHead.allocate(1);
   13654           42 :             tableBody.allocate(6, 1);
   13655              : 
   13656           42 :             Real64 energyconversion = 1.0;
   13657           42 :             if (unitsStyle_cur == OutputReportTabular::UnitsStyle::InchPound ||
   13658           40 :                 unitsStyle_cur == OutputReportTabular::UnitsStyle::InchPoundExceptElectricity) {
   13659            2 :                 rowHead(1) = "Heat Emissions [kBtu]";
   13660            8 :                 energyconversion = 1.0 / getSpecificUnitDivider(state, "GJ", "kBtu"); // 1054351.84 J to kBtu
   13661           40 :             } else if (unitsStyle_cur == UnitsStyle::JtoGJ) {
   13662            1 :                 rowHead(1) = "Heat Emissions [GJ]";
   13663            1 :                 energyconversion = 1.0;
   13664           39 :             } else if (unitsStyle_cur == UnitsStyle::JtoKWH) {
   13665            1 :                 rowHead(1) = "Heat Emissions [kWh]";
   13666            1 :                 energyconversion = 1.0e3 / 3.6;
   13667           38 :             } else if (unitsStyle_cur == UnitsStyle::JtoMJ) {
   13668            0 :                 rowHead(1) = "Heat Emissions [MJ]";
   13669            0 :                 energyconversion = 1.0e3;
   13670           38 :             } else if (unitsStyle_cur == UnitsStyle::None) {
   13671           38 :                 rowHead(1) = "Heat Emissions [GJ]";
   13672           38 :                 energyconversion = 1.0;
   13673              :             } else {
   13674            0 :                 rowHead(1) = "Heat Emissions [GJ]";
   13675            0 :                 energyconversion = 1.0;
   13676              :             }
   13677              : 
   13678           42 :             columnHead(1) = "Envelope Convection";
   13679           42 :             columnHead(2) = "Zone Exfiltration";
   13680           42 :             columnHead(3) = "Zone Exhaust Air";
   13681           42 :             columnHead(4) = "HVAC Relief Air";
   13682           42 :             columnHead(5) = "HVAC Reject Heat";
   13683           42 :             columnHead(6) = "Total";
   13684              : 
   13685           42 :             tableBody = "";
   13686           42 :             tableBody(1, 1) = RealToStr(state.dataHeatBal->BuildingPreDefRep.emiEnvelopConv * energyconversion, 2);
   13687           42 :             tableBody(2, 1) = RealToStr(state.dataHeatBal->BuildingPreDefRep.emiZoneExfiltration * energyconversion, 2);
   13688           42 :             tableBody(3, 1) = RealToStr(state.dataHeatBal->BuildingPreDefRep.emiZoneExhaust * energyconversion, 2);
   13689           42 :             tableBody(4, 1) = RealToStr(state.dataHeatBal->BuildingPreDefRep.emiHVACRelief * energyconversion, 2);
   13690           42 :             tableBody(5, 1) = RealToStr(state.dataHeatBal->BuildingPreDefRep.emiHVACReject * energyconversion, 2);
   13691           42 :             tableBody(6, 1) = RealToStr(state.dataHeatBal->BuildingPreDefRep.emiTotHeat * energyconversion, 2);
   13692              : 
   13693           42 :             if (produceTabular) {
   13694           41 :                 WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
   13695           41 :                 if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
   13696            0 :                     state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(
   13697              :                         tableBody, rowHead, columnHead, "AnnualHeatEmissionsReport", "Entire Facility", "Annual Heat Emissions Summary");
   13698              :                 }
   13699              :             }
   13700           42 :             if (produceSQLite) {
   13701           41 :                 if (state.dataSQLiteProcedures->sqlite) {
   13702            6 :                     state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
   13703              :                         tableBody, rowHead, columnHead, "AnnualHeatEmissionsReport", "Entire Facility", "Annual Heat Emissions Summary");
   13704              :                 }
   13705              :             }
   13706              :         }
   13707              :     }
   13708           41 : }
   13709              : 
   13710           42 : void WritePredefinedTables(EnergyPlusData &state)
   13711              : {
   13712              :     // SUBROUTINE INFORMATION:
   13713              :     //       AUTHOR         Jason Glazer
   13714              :     //       DATE WRITTEN   August 2006
   13715              :     //       MODIFIED       January 2010, Kyle Benne; Added SQLite output
   13716              :     //                      March 2010, Linda Lawrie; Modify SizingPeriod:DesignDay to convert column/humidity types
   13717              :     //       RE-ENGINEERED  na
   13718              : 
   13719              :     // PURPOSE OF THIS SUBROUTINE:
   13720              :     //   Write out tables that have been predefined with data gathered
   13721              :     //   throughout the program code.
   13722              : 
   13723              :     // METHODOLOGY EMPLOYED:
   13724              :     //   Create arrays for the call to WriteTable and then call it.
   13725              :     //   This is a generic routine to write a report with multiple
   13726              :     //   subtables. The structure of the report are created in
   13727              :     //   OutputReportPredefined which also includes a routine that
   13728              :     //   builds up a tableEntry array which holds the data for the
   13729              :     //   predefined reports.
   13730              : 
   13731              :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
   13732              : 
   13733              :     // all arrays are in the format: (row, column)
   13734           42 :     Array1D_string columnHead;
   13735           42 :     Array1D_int columnWidth;
   13736           42 :     Array1D_string rowHead;
   13737           42 :     Array2D_string tableBody;
   13738           42 :     Array1D_int rowToUnqObjName;
   13739           42 :     Array1D_int colHeadToColTag;
   13740           42 :     Array1D_string uniqueObjectName;
   13741           42 :     Array1D_bool useUniqueObjectName;
   13742           42 :     int colCurrent(0);
   13743           42 :     int rowCurrent(0);
   13744           42 :     Array1D_int colUnitConv;
   13745           42 :     auto const &ort = state.dataOutRptTab;
   13746              : 
   13747           85 :     for (int iUnitSystem = 0; iUnitSystem <= 1; iUnitSystem++) {
   13748           84 :         UnitsStyle unitsStyle_cur = ort->unitsStyle;
   13749           84 :         bool produceTabular = true;
   13750           84 :         bool produceSQLite = false;
   13751           84 :         if (produceDualUnitsFlags(iUnitSystem, ort->unitsStyle, ort->unitsStyle_SQLite, unitsStyle_cur, produceTabular, produceSQLite)) {
   13752           41 :             break;
   13753              :         }
   13754              : 
   13755              :         // loop through the entries and associate them with the subtable and create
   13756              :         // list of unique object names
   13757              :         // Much of this code is to allow for integer compares instead of string
   13758              :         // compares that are nested three levels in a loop.
   13759           43 :         uniqueObjectName.allocate(state.dataOutRptPredefined->numTableEntry);
   13760           43 :         useUniqueObjectName.allocate(state.dataOutRptPredefined->numTableEntry);
   13761           43 :         int numUnqObjName = 0;
   13762        40144 :         for (int lTableEntry = 1; lTableEntry <= state.dataOutRptPredefined->numTableEntry; ++lTableEntry) {
   13763              :             // associate the subtable with each column
   13764        40101 :             int const curColumn = state.dataOutRptPredefined->tableEntry(lTableEntry).indexColumn;
   13765        40101 :             if ((curColumn >= 1) && (curColumn <= state.dataOutRptPredefined->numColumnTag)) {
   13766        40101 :                 state.dataOutRptPredefined->tableEntry(lTableEntry).subTableIndex = state.dataOutRptPredefined->columnTag(curColumn).indexSubTable;
   13767              :             }
   13768              :             // make a list of unique object names
   13769        40101 :             std::string const &curObjectName = state.dataOutRptPredefined->tableEntry(lTableEntry).objectName;
   13770        40101 :             int found = 0;
   13771      3348148 :             for (int mUnqObjNames = 1; mUnqObjNames <= numUnqObjName; ++mUnqObjNames) {
   13772      3342393 :                 if (curObjectName == uniqueObjectName(mUnqObjNames)) {
   13773        34346 :                     found = mUnqObjNames;
   13774        34346 :                     break;
   13775              :                 }
   13776              :             }
   13777              :             // if found then point to the unique object
   13778        40101 :             if (found > 0) {
   13779        34346 :                 state.dataOutRptPredefined->tableEntry(lTableEntry).uniqueObjName = found;
   13780              :                 // if not found add to the unique object list
   13781              :             } else {
   13782         5755 :                 ++numUnqObjName;
   13783         5755 :                 uniqueObjectName(numUnqObjName) = curObjectName;
   13784         5755 :                 state.dataOutRptPredefined->tableEntry(lTableEntry).uniqueObjName = numUnqObjName;
   13785              :             }
   13786              :         }
   13787              :         // loop through all reports and include those that have been flagged as 'show'
   13788          788 :         for (int iReportName = 1; iReportName <= state.dataOutRptPredefined->numReportName; ++iReportName) {
   13789          745 :             if (state.dataOutRptPredefined->reportName(iReportName).show) {
   13790          666 :                 if (produceTabular) {
   13791         1995 :                     WriteReportHeaders(state,
   13792          665 :                                        state.dataOutRptPredefined->reportName(iReportName).namewithspaces,
   13793              :                                        "Entire Facility",
   13794              :                                        OutputProcessor::StoreType::Average);
   13795              :                 }
   13796              :                 // loop through the subtables and include those that are associated with this report
   13797        65970 :                 for (int jSubTable = 1, jSubTable_end = state.dataOutRptPredefined->numSubTable; jSubTable <= jSubTable_end; ++jSubTable) {
   13798        65304 :                     if (state.dataOutRptPredefined->subTable(jSubTable).indexReportName == iReportName) {
   13799              :                         // determine how many columns
   13800         3767 :                         int curNumColumns = 0;
   13801      3277298 :                         for (int kColumnTag = 1; kColumnTag <= state.dataOutRptPredefined->numColumnTag; ++kColumnTag) {
   13802      3273531 :                             if (state.dataOutRptPredefined->columnTag(kColumnTag).indexSubTable == jSubTable) {
   13803        33574 :                                 ++curNumColumns;
   13804              :                             }
   13805              :                         }
   13806              :                         // determine how many rows by going through table entries and setting
   13807              :                         // flag in useUniqueObjectName to true, then count number of true's.
   13808         3767 :                         useUniqueObjectName = false; // array assignment
   13809      3954272 :                         for (int lTableEntry = 1; lTableEntry <= state.dataOutRptPredefined->numTableEntry; ++lTableEntry) {
   13810      3950505 :                             if (state.dataOutRptPredefined->tableEntry(lTableEntry).subTableIndex == jSubTable) {
   13811        40092 :                                 useUniqueObjectName(state.dataOutRptPredefined->tableEntry(lTableEntry).uniqueObjName) = true;
   13812              :                             }
   13813              :                         }
   13814         3767 :                         int curNumRows = 0;
   13815       563580 :                         for (int mUnqObjNames = 1; mUnqObjNames <= numUnqObjName; ++mUnqObjNames) {
   13816       559813 :                             if (useUniqueObjectName(mUnqObjNames)) {
   13817         6817 :                                 ++curNumRows;
   13818              :                             }
   13819              :                         }
   13820         3767 :                         if (curNumRows == 0) {
   13821         2297 :                             curNumRows = 1;
   13822              :                         }
   13823              :                         // now create the arrays that are filled with values
   13824         3767 :                         rowHead.allocate(curNumRows);
   13825         3767 :                         columnHead.allocate(curNumColumns);
   13826         3767 :                         columnWidth.dimension(curNumColumns, 14); // array assignment - same for all columns
   13827         3767 :                         tableBody.allocate(curNumColumns, curNumRows);
   13828         7534 :                         rowHead = "";
   13829         7534 :                         columnHead = "";
   13830         3767 :                         tableBody = "";
   13831              :                         // this array stores the unique object name index for each row
   13832         3767 :                         rowToUnqObjName.allocate(curNumRows);
   13833              :                         // this array stores the columnHead index for each column
   13834         3767 :                         colHeadToColTag.allocate(curNumColumns);
   13835         3767 :                         colUnitConv.allocate(curNumColumns);
   13836              :                         // set row headings
   13837         3767 :                         int countRow = 0;
   13838         3767 :                         rowHead(1) = "None";
   13839       563580 :                         for (int mUnqObjNames = 1; mUnqObjNames <= numUnqObjName; ++mUnqObjNames) {
   13840       559813 :                             if (useUniqueObjectName(mUnqObjNames)) {
   13841         6817 :                                 ++countRow;
   13842         6817 :                                 rowHead(countRow) = uniqueObjectName(mUnqObjNames);
   13843         6817 :                                 rowToUnqObjName(countRow) = mUnqObjNames;
   13844              :                             }
   13845              :                         }
   13846              :                         // set column headings
   13847         3767 :                         int countColumn = 0;
   13848      3277298 :                         for (int kColumnTag = 1; kColumnTag <= state.dataOutRptPredefined->numColumnTag; ++kColumnTag) {
   13849      3273531 :                             if (state.dataOutRptPredefined->columnTag(kColumnTag).indexSubTable == jSubTable) {
   13850        33574 :                                 ++countColumn;
   13851              :                                 // do the unit conversions
   13852        33574 :                                 std::string const &colTagWithSI = state.dataOutRptPredefined->columnTag(kColumnTag).heading;
   13853              :                                 int indexUnitConv;
   13854        33574 :                                 std::string curColTag;
   13855        33574 :                                 if (unitsStyle_cur == UnitsStyle::InchPound) {
   13856         1311 :                                     LookupSItoIP(state, colTagWithSI, indexUnitConv, curColTag);
   13857         1311 :                                     colUnitConv(countColumn) = indexUnitConv;
   13858        32263 :                                 } else if (unitsStyle_cur == UnitsStyle::InchPoundExceptElectricity) {
   13859            0 :                                     LookupSItoIP(state, colTagWithSI, indexUnitConv, curColTag);
   13860            0 :                                     colUnitConv(countColumn) = indexUnitConv;
   13861        32263 :                                 } else if (unitsStyle_cur == UnitsStyle::JtoKWH) {
   13862          105 :                                     LookupJtokWH(state, colTagWithSI, indexUnitConv, curColTag);
   13863          105 :                                     colUnitConv(countColumn) = indexUnitConv;
   13864              :                                 } else {
   13865        32158 :                                     curColTag = colTagWithSI;
   13866        32158 :                                     colUnitConv(countColumn) = 0;
   13867              :                                 }
   13868        33574 :                                 columnHead(countColumn) = curColTag;
   13869        33574 :                                 colHeadToColTag(countColumn) = kColumnTag;
   13870        33574 :                             }
   13871              :                         }
   13872              :                         // fill the body of the table from the entries
   13873              :                         // find the entries associated with the current subtable
   13874      3954272 :                         for (int lTableEntry = 1; lTableEntry <= state.dataOutRptPredefined->numTableEntry; ++lTableEntry) {
   13875      3950505 :                             if (state.dataOutRptPredefined->tableEntry(lTableEntry).subTableIndex == jSubTable) {
   13876              :                                 // determine what column the current entry is in
   13877        40092 :                                 int const curColTagIndex = state.dataOutRptPredefined->tableEntry(lTableEntry).indexColumn;
   13878       344719 :                                 for (int nColHead = 1; nColHead <= curNumColumns; ++nColHead) {
   13879       344719 :                                     if (curColTagIndex == colHeadToColTag(nColHead)) {
   13880        40092 :                                         colCurrent = nColHead;
   13881        40092 :                                         break;
   13882              :                                     }
   13883              :                                 }
   13884              :                                 // determine what row the current entry is in
   13885        40092 :                                 int const curRowUnqObjIndex = state.dataOutRptPredefined->tableEntry(lTableEntry).uniqueObjName;
   13886       233179 :                                 for (int oRowHead = 1; oRowHead <= curNumRows; ++oRowHead) {
   13887       233179 :                                     if (curRowUnqObjIndex == rowToUnqObjName(oRowHead)) {
   13888        40092 :                                         rowCurrent = oRowHead;
   13889        40092 :                                         break;
   13890              :                                     }
   13891              :                                 }
   13892              :                                 // finally assign the entry to the place in the table body
   13893        40092 :                                 if (unitsStyle_cur == OutputReportTabular::UnitsStyle::InchPound ||
   13894        38482 :                                     unitsStyle_cur == OutputReportTabular::UnitsStyle::InchPoundExceptElectricity ||
   13895        38482 :                                     unitsStyle_cur == UnitsStyle::JtoKWH) {
   13896         1611 :                                     int columnUnitConv = colUnitConv(colCurrent);
   13897         1623 :                                     if (Util::SameString(state.dataOutRptPredefined->subTable(jSubTable).name, "SizingPeriod:DesignDay") &&
   13898           12 :                                         (unitsStyle_cur == OutputReportTabular::UnitsStyle::InchPound ||
   13899            0 :                                          unitsStyle_cur == OutputReportTabular::UnitsStyle::InchPoundExceptElectricity)) {
   13900           12 :                                         if (Util::SameString(columnHead(colCurrent), "Humidity Value")) {
   13901            2 :                                             std::string repTableTag;
   13902            2 :                                             LookupSItoIP(state,
   13903            2 :                                                          state.dataOutRptPredefined->tableEntry(lTableEntry + 1).charEntry,
   13904              :                                                          columnUnitConv,
   13905              :                                                          repTableTag);
   13906            2 :                                             state.dataOutRptPredefined->tableEntry(lTableEntry + 1).charEntry = repTableTag;
   13907            2 :                                         }
   13908              :                                     }
   13909         1611 :                                     if (state.dataOutRptPredefined->tableEntry(lTableEntry).origEntryIsReal && (columnUnitConv != 0)) {
   13910              :                                         Real64 const IPvalue =
   13911         1099 :                                             ConvertIP(state, columnUnitConv, state.dataOutRptPredefined->tableEntry(lTableEntry).origRealEntry);
   13912         1099 :                                         tableBody(colCurrent, rowCurrent) =
   13913         2198 :                                             RealToStr(IPvalue, state.dataOutRptPredefined->tableEntry(lTableEntry).significantDigits);
   13914              :                                     } else {
   13915          512 :                                         tableBody(colCurrent, rowCurrent) = state.dataOutRptPredefined->tableEntry(lTableEntry).charEntry;
   13916              :                                     }
   13917         1611 :                                 } else {
   13918        38481 :                                     tableBody(colCurrent, rowCurrent) = state.dataOutRptPredefined->tableEntry(lTableEntry).charEntry;
   13919              :                                 }
   13920              :                             }
   13921              :                         }
   13922              :                         // create the actual output table
   13923         3767 :                         if (produceTabular) {
   13924         3760 :                             WriteSubtitle(state, state.dataOutRptPredefined->subTable(jSubTable).name);
   13925         3760 :                             WriteTable(
   13926         3760 :                                 state, tableBody, rowHead, columnHead, columnWidth, false, state.dataOutRptPredefined->subTable(jSubTable).footnote);
   13927              :                         }
   13928         3767 :                         if (produceSQLite) {
   13929         3760 :                             if (state.dataSQLiteProcedures->sqlite) {
   13930         1041 :                                 state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
   13931              :                                     tableBody,
   13932              :                                     rowHead,
   13933              :                                     columnHead,
   13934          347 :                                     state.dataOutRptPredefined->reportName(iReportName).name,
   13935              :                                     "Entire Facility",
   13936          347 :                                     state.dataOutRptPredefined->subTable(jSubTable).name);
   13937              :                             }
   13938              :                         }
   13939         3767 :                         if (produceTabular) {
   13940         3760 :                             if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
   13941            0 :                                 state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(
   13942              :                                     tableBody,
   13943              :                                     rowHead,
   13944              :                                     columnHead,
   13945            0 :                                     state.dataOutRptPredefined->reportName(iReportName).name,
   13946              :                                     "Entire Facility",
   13947            0 :                                     state.dataOutRptPredefined->subTable(jSubTable).name);
   13948              :                             }
   13949              :                         }
   13950              :                     }
   13951              :                 }
   13952              :             }
   13953              :         }
   13954              :     }
   13955           42 : }
   13956              : 
   13957           38 : void WriteComponentSizing(EnergyPlusData &state)
   13958              : {
   13959              :     // SUBROUTINE INFORMATION:
   13960              :     //       AUTHOR         Jason Glazer
   13961              :     //       DATE WRITTEN   July 2007
   13962              :     //       MODIFIED       January 2010, Kyle Benne
   13963              :     //                      Added SQLite output
   13964              :     //       RE-ENGINEERED  na
   13965              : 
   13966              :     // PURPOSE OF THIS SUBROUTINE:
   13967              :     //   Write out tables based on component sizing data originally
   13968              :     //   found in the EIO report.
   13969              : 
   13970              :     // METHODOLOGY EMPLOYED:
   13971              :     //   Create arrays for the call to WriteTable and then call it.
   13972              :     //   The tables created do not have known headers for rows or
   13973              :     //   columns so those are determined based on what calls have
   13974              :     //   been made to the Sizer routine.  A table
   13975              :     //   is created for each type of component. Columns are created
   13976              :     //   for each description within that table. Rows are created
   13977              :     //   for each named object.
   13978              : 
   13979           38 :     auto const &ort = state.dataOutRptTab;
   13980           38 :     if (!ort->displayComponentSizing) {
   13981            0 :         return;
   13982              :     }
   13983              : 
   13984              :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
   13985              :     // all arrays are in the format: (row, column)
   13986           38 :     Array1D_string columnHead;
   13987           38 :     Array1D_int columnWidth;
   13988           38 :     Array1D_int colUnitConv;
   13989           38 :     Array1D_string rowHead;
   13990           38 :     Array2D_string tableBody;
   13991           38 :     Array1D_string uniqueDesc;
   13992           38 :     Array1D_string uniqueObj;
   13993              :     int numUniqueObj;
   13994           38 :     std::string curDesc;
   13995           38 :     std::string curObj;
   13996              :     int foundEntry;
   13997              :     int foundDesc;
   13998              :     int foundObj;
   13999              :     int iTableEntry;
   14000              :     int jUnique;
   14001              : 
   14002          114 :     WriteReportHeaders(state, "Component Sizing Summary", "Entire Facility", OutputProcessor::StoreType::Average);
   14003              : 
   14004           76 :     for (int iUnitSystem = 0; iUnitSystem <= 1; iUnitSystem++) {
   14005           76 :         UnitsStyle unitsStyle_cur = ort->unitsStyle;
   14006           76 :         bool produceTabular = true;
   14007           76 :         bool produceSQLite = false;
   14008           76 :         if (produceDualUnitsFlags(iUnitSystem, ort->unitsStyle, ort->unitsStyle_SQLite, unitsStyle_cur, produceTabular, produceSQLite)) {
   14009           38 :             break;
   14010              :         }
   14011              : 
   14012              :         // The arrays that look for unique headers are dimensioned in the
   14013              :         // running program since the size of the number of entries is
   14014              :         // not previously known. Use the size of all entries since that
   14015              :         // is the maximum possible.
   14016           38 :         uniqueDesc.allocate(state.dataOutRptPredefined->numCompSizeTableEntry);
   14017           38 :         uniqueObj.allocate(state.dataOutRptPredefined->numCompSizeTableEntry);
   14018              :         // initially clear the written flags for entire array
   14019              :         // The following line is not really necessary and it is possible that the array has
   14020              :         // not been allocated when this is first called.
   14021              :         //  CompSizeTableEntry%written = .FALSE.
   14022              :         // repeat the following loop until everything in array has been
   14023              :         // written into a table
   14024           38 :         int loopLimit = 0;
   14025           72 :         while (loopLimit <= 100) { // put a maximum count since complex loop that could run indefinitely if error
   14026           72 :             foundEntry = 0;
   14027           72 :             ++loopLimit;
   14028          448 :             for (iTableEntry = 1; iTableEntry <= state.dataOutRptPredefined->numCompSizeTableEntry; ++iTableEntry) {
   14029          410 :                 if (!state.dataOutRptPredefined->CompSizeTableEntry(iTableEntry).written) {
   14030           34 :                     foundEntry = iTableEntry;
   14031           34 :                     break;
   14032              :                 }
   14033              :             }
   14034           72 :             if (foundEntry == 0) {
   14035           38 :                 break; // leave main loop - all items put into tables
   14036              :             }
   14037              :             // clear active items
   14038         3434 :             for (auto &e : state.dataOutRptPredefined->CompSizeTableEntry) {
   14039         3400 :                 e.active = false;
   14040              :             }
   14041              :             // make an unwritten item that is of the same type active - these will be the
   14042              :             // entries for the particular subtable.
   14043          566 :             for (iTableEntry = 1; iTableEntry <= state.dataOutRptPredefined->numCompSizeTableEntry; ++iTableEntry) {
   14044          532 :                 if (!state.dataOutRptPredefined->CompSizeTableEntry(iTableEntry).written) {
   14045          263 :                     if (Util::SameString(state.dataOutRptPredefined->CompSizeTableEntry(iTableEntry).typeField,
   14046          263 :                                          state.dataOutRptPredefined->CompSizeTableEntry(foundEntry).typeField)) {
   14047          113 :                         state.dataOutRptPredefined->CompSizeTableEntry(iTableEntry).active = true;
   14048              :                     }
   14049              :                 }
   14050              :             }
   14051              :             // identify unique descriptions and objects (columns and rows) in order
   14052              :             // to size the table arrays properly.
   14053              :             // reset the counters for the arrays looking for unique rows and columns
   14054           34 :             int numUniqueDesc = 0;
   14055           34 :             numUniqueObj = 0;
   14056          566 :             for (iTableEntry = 1; iTableEntry <= state.dataOutRptPredefined->numCompSizeTableEntry; ++iTableEntry) {
   14057              :                 // search for descriptions
   14058          532 :                 foundDesc = 0;
   14059          532 :                 if (state.dataOutRptPredefined->CompSizeTableEntry(iTableEntry).active) {
   14060          113 :                     curDesc = state.dataOutRptPredefined->CompSizeTableEntry(iTableEntry).description;
   14061              :                     // look through the list of unique items to see if it matches
   14062          313 :                     for (jUnique = 1; jUnique <= numUniqueDesc; ++jUnique) {
   14063          215 :                         if (Util::SameString(curDesc, uniqueDesc(jUnique))) {
   14064           15 :                             foundDesc = jUnique;
   14065           15 :                             break;
   14066              :                         }
   14067              :                     }
   14068              :                     // if not found add to the list
   14069          113 :                     if (foundDesc == 0) {
   14070           98 :                         ++numUniqueDesc;
   14071           98 :                         uniqueDesc(numUniqueDesc) = curDesc;
   14072              :                     }
   14073              :                     // search for objects
   14074          113 :                     foundObj = 0;
   14075          113 :                     curObj = state.dataOutRptPredefined->CompSizeTableEntry(iTableEntry).nameField;
   14076          130 :                     for (jUnique = 1; jUnique <= numUniqueObj; ++jUnique) {
   14077           90 :                         if (Util::SameString(curObj, uniqueObj(jUnique))) {
   14078           73 :                             foundObj = jUnique;
   14079           73 :                             break;
   14080              :                         }
   14081              :                     }
   14082              :                     // if not found add to the list
   14083          113 :                     if (foundObj == 0) {
   14084           40 :                         ++numUniqueObj;
   14085           40 :                         uniqueObj(numUniqueObj) = curObj;
   14086              :                     }
   14087              :                 }
   14088              :             }
   14089              :             // make sure the table has at least one row and columns
   14090           34 :             if (numUniqueDesc == 0) {
   14091            0 :                 numUniqueDesc = 1;
   14092              :             }
   14093           34 :             if (numUniqueObj == 0) {
   14094            0 :                 numUniqueObj = 1;
   14095              :             }
   14096              :             // now that the unique row and column headers are known the array
   14097              :             // sizes can be set for the table arrays
   14098           34 :             rowHead.allocate(numUniqueObj);
   14099           34 :             columnHead.allocate(numUniqueDesc);
   14100           34 :             columnWidth.dimension(numUniqueDesc, 14); // array assignment - same for all columns
   14101           34 :             colUnitConv.allocate(numUniqueDesc);
   14102           34 :             tableBody.allocate(numUniqueDesc, numUniqueObj);
   14103              :             // initialize table body to blanks (in case entries are incomplete)
   14104           34 :             tableBody = "";
   14105              :             // transfer the row and column headings first
   14106          132 :             for (jUnique = 1; jUnique <= numUniqueDesc; ++jUnique) {
   14107              :                 // do the unit conversions
   14108           98 :                 state.dataOutRptTab->curColHeadWithSI = uniqueDesc(jUnique);
   14109           98 :                 if (unitsStyle_cur == UnitsStyle::InchPound) {
   14110           20 :                     LookupSItoIP(
   14111           20 :                         state, state.dataOutRptTab->curColHeadWithSI, state.dataOutRptTab->indexUnitConvWCS, state.dataOutRptTab->curColHead);
   14112           20 :                     colUnitConv(jUnique) = state.dataOutRptTab->indexUnitConvWCS;
   14113           78 :                 } else if (unitsStyle_cur == UnitsStyle::InchPoundExceptElectricity) {
   14114            0 :                     LookupSItoIP(
   14115            0 :                         state, state.dataOutRptTab->curColHeadWithSI, state.dataOutRptTab->indexUnitConvWCS, state.dataOutRptTab->curColHead);
   14116            0 :                     colUnitConv(jUnique) = state.dataOutRptTab->indexUnitConvWCS;
   14117              :                 } else {
   14118           78 :                     state.dataOutRptTab->curColHead = state.dataOutRptTab->curColHeadWithSI;
   14119           78 :                     colUnitConv(jUnique) = 0;
   14120              :                 }
   14121           98 :                 columnHead(jUnique) = state.dataOutRptTab->curColHead;
   14122              :             }
   14123           74 :             for (jUnique = 1; jUnique <= numUniqueObj; ++jUnique) {
   14124           40 :                 rowHead(jUnique) = uniqueObj(jUnique);
   14125              :             }
   14126              :             // fill the table
   14127          566 :             for (iTableEntry = 1; iTableEntry <= state.dataOutRptPredefined->numCompSizeTableEntry; ++iTableEntry) {
   14128              :                 // find the row and column for the specific entry
   14129          532 :                 if (state.dataOutRptPredefined->CompSizeTableEntry(iTableEntry).active) {
   14130          113 :                     curDesc = state.dataOutRptPredefined->CompSizeTableEntry(iTableEntry).description;
   14131          113 :                     foundDesc = 0;
   14132          313 :                     for (jUnique = 1; jUnique <= numUniqueDesc; ++jUnique) {
   14133          313 :                         if (Util::SameString(uniqueDesc(jUnique), curDesc)) {
   14134          113 :                             foundDesc = jUnique;
   14135          113 :                             break;
   14136              :                         }
   14137              :                     }
   14138          113 :                     curObj = state.dataOutRptPredefined->CompSizeTableEntry(iTableEntry).nameField;
   14139          113 :                     foundObj = 0;
   14140          130 :                     for (jUnique = 1; jUnique <= numUniqueObj; ++jUnique) {
   14141          130 :                         if (Util::SameString(rowHead(jUnique), curObj)) {
   14142          113 :                             foundObj = jUnique;
   14143          113 :                             break;
   14144              :                         }
   14145              :                     }
   14146          113 :                     if ((foundDesc >= 1) && (foundObj >= 1)) {
   14147          113 :                         state.dataOutRptTab->curValueSIWCS = state.dataOutRptPredefined->CompSizeTableEntry(iTableEntry).valField;
   14148          113 :                         if (unitsStyle_cur == UnitsStyle::InchPound) {
   14149           20 :                             if (colUnitConv(foundDesc) != 0) {
   14150           17 :                                 state.dataOutRptTab->curValueWCS = ConvertIP(state, colUnitConv(foundDesc), state.dataOutRptTab->curValueSIWCS);
   14151              :                             } else {
   14152            3 :                                 state.dataOutRptTab->curValueWCS = state.dataOutRptTab->curValueSIWCS;
   14153              :                             }
   14154           93 :                         } else if (unitsStyle_cur == UnitsStyle::InchPoundExceptElectricity) {
   14155            0 :                             if (colUnitConv(foundDesc) != 0) {
   14156            0 :                                 state.dataOutRptTab->curValueWCS = ConvertIP(state, colUnitConv(foundDesc), state.dataOutRptTab->curValueSIWCS);
   14157              :                             } else {
   14158            0 :                                 state.dataOutRptTab->curValueWCS = state.dataOutRptTab->curValueSIWCS;
   14159              :                             }
   14160              :                         } else {
   14161           93 :                             state.dataOutRptTab->curValueWCS = state.dataOutRptTab->curValueSIWCS;
   14162              :                         }
   14163          113 :                         if (std::abs(state.dataOutRptTab->curValueWCS) >= 1.0) {
   14164           55 :                             tableBody(foundDesc, foundObj) = RealToStr(state.dataOutRptTab->curValueWCS, 2);
   14165              :                         } else {
   14166           58 :                             tableBody(foundDesc, foundObj) = RealToStr(state.dataOutRptTab->curValueWCS, 6);
   14167              :                         }
   14168          113 :                         state.dataOutRptPredefined->CompSizeTableEntry(iTableEntry).written = true;
   14169              :                     }
   14170              :                 }
   14171              :             }
   14172              :             // write the table
   14173           34 :             if (produceTabular) {
   14174           34 :                 WriteSubtitle(state, state.dataOutRptPredefined->CompSizeTableEntry(foundEntry).typeField);
   14175              :             }
   14176              : 
   14177           68 :             if (state.dataOutRptPredefined->CompSizeTableEntry(foundEntry).typeField == "AirTerminal:SingleDuct:VAV:Reheat" ||
   14178           34 :                 state.dataOutRptPredefined->CompSizeTableEntry(foundEntry).typeField == "AirTerminal:SingleDuct:VAV:NoReheat") {
   14179            3 :                 if (produceTabular) {
   14180            3 :                     WriteTable(state,
   14181              :                                tableBody,
   14182              :                                rowHead,
   14183              :                                columnHead,
   14184              :                                columnWidth,
   14185              :                                false,
   14186              :                                "User-Specified values were used. Design Size values were used if no User-Specified values were provided. "
   14187              :                                "Design Size "
   14188              :                                "values may be derived from alternate User-Specified values.");
   14189              :                 }
   14190              :             } else {
   14191           31 :                 if (produceTabular) {
   14192           31 :                     WriteTable(state,
   14193              :                                tableBody,
   14194              :                                rowHead,
   14195              :                                columnHead,
   14196              :                                columnWidth,
   14197              :                                false,
   14198              :                                "User-Specified values were used. Design Size values were used if no User-Specified values were provided.");
   14199              :                 }
   14200              :             }
   14201              : 
   14202           34 :             if (produceSQLite) {
   14203           34 :                 if (state.dataSQLiteProcedures->sqlite) {
   14204           32 :                     state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
   14205              :                         tableBody,
   14206              :                         rowHead,
   14207              :                         columnHead,
   14208              :                         "ComponentSizingSummary",
   14209              :                         "Entire Facility",
   14210           16 :                         state.dataOutRptPredefined->CompSizeTableEntry(foundEntry).typeField);
   14211              :                 }
   14212              :             }
   14213           34 :             if (produceTabular) {
   14214           34 :                 if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
   14215            0 :                     state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(
   14216              :                         tableBody,
   14217              :                         rowHead,
   14218              :                         columnHead,
   14219              :                         "ComponentSizingSummary",
   14220              :                         "Entire Facility",
   14221            0 :                         state.dataOutRptPredefined->CompSizeTableEntry(foundEntry).typeField,
   14222              :                         "User-Specified values were used. Design Size values were used if no User-Specified values were provided.");
   14223              :                 }
   14224              :             }
   14225              :         }
   14226              :     }
   14227           38 : }
   14228              : 
   14229           38 : void WriteSurfaceShadowing(EnergyPlusData &state)
   14230              : {
   14231              :     // SUBROUTINE INFORMATION:
   14232              :     //       AUTHOR         Jason Glazer
   14233              :     //       DATE WRITTEN   July 2007
   14234              :     //       MODIFIED       January 2010, Kyle Benne
   14235              :     //                      Added SQLite output
   14236              :     //       RE-ENGINEERED  June 2014, Stuart Mentzer, Performance tuning
   14237              : 
   14238              :     // PURPOSE OF THIS SUBROUTINE:
   14239              :     //   Write out tables based on which surfaces shade subsurfaces.
   14240              : 
   14241              :     // METHODOLOGY EMPLOYED:
   14242              :     //   Create arrays for the call to WriteTable and then call it.
   14243              :     //   Use <br> tag to put multiple rows into a single cell.
   14244              : 
   14245              :     // Using/Aliasing
   14246              :     using namespace DataShadowingCombinations;
   14247              : 
   14248           38 :     auto const &ort = state.dataOutRptTab;
   14249              : 
   14250              :     // displaySurfaceShadowing = false  for debugging
   14251           38 :     if (!ort->displaySurfaceShadowing) {
   14252            0 :         return;
   14253              :     }
   14254              : 
   14255              :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
   14256              :     // all arrays are in the format: (row, column)
   14257           38 :     Array1D_string columnHead(1);
   14258           38 :     Array1D_int columnWidth(1);
   14259           38 :     Array1D_string rowHead;
   14260           38 :     Array2D_string tableBody;
   14261           38 :     Array1D_int unique;
   14262              : 
   14263           38 :     int numreceivingfields = 0;
   14264          292 :     for (int HTS = 1; HTS <= state.dataSurface->TotSurfaces; ++HTS) {
   14265          254 :         numreceivingfields += state.dataShadowComb->ShadowComb(HTS).NumGenSurf;
   14266          254 :         numreceivingfields += state.dataShadowComb->ShadowComb(HTS).NumSubSurf;
   14267              :     }
   14268              : 
   14269           38 :     state.dataOutRptPredefined->ShadowRelate.allocate(numreceivingfields);
   14270           38 :     state.dataOutRptPredefined->numShadowRelate = 0;
   14271          292 :     for (int HTS = 1; HTS <= state.dataSurface->TotSurfaces; ++HTS) {
   14272          256 :         for (int NGSS = 1; NGSS <= state.dataShadowComb->ShadowComb(HTS).NumGenSurf; ++NGSS) {
   14273            2 :             ++state.dataOutRptPredefined->numShadowRelate;
   14274            2 :             state.dataOutRptPredefined->ShadowRelate(state.dataOutRptPredefined->numShadowRelate).castSurf =
   14275            2 :                 state.dataShadowComb->ShadowComb(HTS).GenSurf(NGSS);
   14276            2 :             state.dataOutRptPredefined->ShadowRelate(state.dataOutRptPredefined->numShadowRelate).recSurf = HTS;
   14277            2 :             state.dataOutRptPredefined->ShadowRelate(state.dataOutRptPredefined->numShadowRelate).recKind = recKindSurface;
   14278              :         }
   14279          258 :         for (int NGSS = 1; NGSS <= state.dataShadowComb->ShadowComb(HTS).NumSubSurf; ++NGSS) {
   14280            4 :             ++state.dataOutRptPredefined->numShadowRelate;
   14281            4 :             state.dataOutRptPredefined->ShadowRelate(state.dataOutRptPredefined->numShadowRelate).castSurf =
   14282            4 :                 state.dataShadowComb->ShadowComb(HTS).SubSurf(NGSS);
   14283            4 :             state.dataOutRptPredefined->ShadowRelate(state.dataOutRptPredefined->numShadowRelate).recSurf = HTS;
   14284            4 :             state.dataOutRptPredefined->ShadowRelate(state.dataOutRptPredefined->numShadowRelate).recKind = recKindSubsurface;
   14285              :         }
   14286              :     }
   14287           38 :     assert(numreceivingfields == state.dataOutRptPredefined->numShadowRelate);
   14288              : 
   14289          114 :     WriteReportHeaders(state, "Surface Shadowing Summary", "Entire Facility", OutputProcessor::StoreType::Average);
   14290           38 :     unique.allocate(state.dataOutRptPredefined->numShadowRelate);
   14291              :     // do entire process twice, once with surfaces receiving, once with subsurfaces receiving
   14292          114 :     for (int iKindRec = recKindSurface; iKindRec <= recKindSubsurface; ++iKindRec) {
   14293              : 
   14294              :         // Build map from receiving surface to container of names
   14295              :         typedef std::map<int, std::pair<int, std::vector<std::string const *>>> ShadowMap;
   14296           76 :         ShadowMap shadow_map;
   14297           88 :         for (int iShadRel = 1; iShadRel <= state.dataOutRptPredefined->numShadowRelate; ++iShadRel) {
   14298           12 :             if (state.dataOutRptPredefined->ShadowRelate(iShadRel).recKind == iKindRec) {
   14299            6 :                 int const curRecSurf = state.dataOutRptPredefined->ShadowRelate(iShadRel).recSurf;
   14300            6 :                 std::string const &name(state.dataSurface->Surface(state.dataOutRptPredefined->ShadowRelate(iShadRel).castSurf).Name);
   14301            6 :                 auto &elem(shadow_map[curRecSurf]);            // Creates the entry if not present (and zero-initializes the int in the pair)
   14302            6 :                 elem.first += static_cast<int>(name.length()); // Accumulate total of name lengths
   14303            6 :                 elem.second.push_back(&name);                  // Add this name
   14304              :             }
   14305              :         }
   14306           76 :         int const numUnique = static_cast<int>(shadow_map.size());
   14307           76 :         if (numUnique == 0) {
   14308           71 :             columnHead(1) = "None";
   14309              :         } else {
   14310            5 :             columnHead(1) = "Possible Shadow Receivers";
   14311              :         }
   14312           76 :         columnWidth = 14; // array assignment - same for all columns
   14313           76 :         rowHead.allocate(numUnique);
   14314           76 :         tableBody.allocate(1, numUnique);
   14315           76 :         int jUnique = 0;
   14316           82 :         for (auto const &elem : shadow_map) {
   14317            6 :             ++jUnique;
   14318            6 :             int const curRecSurf = elem.first;
   14319            6 :             rowHead(jUnique) = state.dataSurface->Surface(curRecSurf).Name;
   14320              : 
   14321            6 :             std::string listOfSurf;
   14322            6 :             listOfSurf.reserve(elem.second.first + (3 * numUnique)); // To avoid string allocations during appends
   14323           12 :             for (auto const *p : elem.second.second) {
   14324            6 :                 listOfSurf += *p;
   14325            6 :                 listOfSurf += " | "; //'<br>' // Separate append to avoid string temporary
   14326            6 :             }
   14327            6 :             tableBody(1, jUnique) = listOfSurf;
   14328           82 :         }
   14329              : 
   14330              :         // write the table
   14331           76 :         if (iKindRec == recKindSurface) {
   14332           38 :             WriteSubtitle(state, "Surfaces (Walls, Roofs, etc) that may be Shadowed by Other Surfaces");
   14333           38 :             if (state.dataSQLiteProcedures->sqlite) {
   14334            3 :                 state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
   14335              :                     tableBody,
   14336              :                     rowHead,
   14337              :                     columnHead,
   14338              :                     "SurfaceShadowingSummary",
   14339              :                     "Entire Facility",
   14340              :                     "Surfaces (Walls, Roofs, etc) that may be Shadowed by Other Surfaces");
   14341              :             }
   14342           38 :             if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
   14343            0 :                 state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(
   14344              :                     tableBody,
   14345              :                     rowHead,
   14346              :                     columnHead,
   14347              :                     "SurfaceShadowingSummary",
   14348              :                     "Entire Facility",
   14349              :                     "Surfaces (Walls, Roofs, etc) that may be Shadowed by Other Surfaces");
   14350              :             }
   14351           38 :         } else if (iKindRec == recKindSubsurface) {
   14352           38 :             WriteSubtitle(state, "Subsurfaces (Windows and Doors) that may be Shadowed by Surfaces");
   14353           38 :             if (state.dataSQLiteProcedures->sqlite) {
   14354            3 :                 state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
   14355              :                     tableBody,
   14356              :                     rowHead,
   14357              :                     columnHead,
   14358              :                     "SurfaceShadowingSummary",
   14359              :                     "Entire Facility",
   14360              :                     "Subsurfaces (Windows and Doors) that may be Shadowed by Surfaces");
   14361              :             }
   14362           38 :             if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
   14363            0 :                 state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(
   14364              :                     tableBody,
   14365              :                     rowHead,
   14366              :                     columnHead,
   14367              :                     "SurfaceShadowingSummary",
   14368              :                     "Entire Facility",
   14369              :                     "Subsurfaces (Windows and Doors) that may be Shadowed by Surfaces");
   14370              :             }
   14371              :         }
   14372           76 :         WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
   14373           76 :     }
   14374           38 : }
   14375              : 
   14376              : // Parses the contents of the EIO (initializations) file and creates subtables for each type of record in the tabular output files
   14377              : // Glazer - November 2016
   14378           39 : void WriteEioTables(EnergyPlusData &state)
   14379              : {
   14380              : 
   14381           39 :     auto const &ort = state.dataOutRptTab;
   14382              : 
   14383           39 :     if (!ort->displayEioSummary) {
   14384            0 :         return;
   14385              :     }
   14386              : 
   14387           39 :     Array1D_string columnHead;
   14388           39 :     Array1D_int columnWidth;
   14389           39 :     Array1D_string rowHead;
   14390           39 :     Array2D_string tableBody; // in the format: (row, column)
   14391           39 :     Array1D_int colUnitConv;
   14392              : 
   14393              :     // setting up  report header
   14394          117 :     WriteReportHeaders(state, "Initialization Summary", "Entire Facility", OutputProcessor::StoreType::Average);
   14395              : 
   14396           39 :     std::vector<std::string> headerLines; // holds the lines that describe each type of records - each starts with ! symbol
   14397           39 :     std::vector<std::string> bodyLines;   // holds the data records only
   14398         4443 :     for (auto const &line : state.files.eio.getLines()) {
   14399         4404 :         if (line.at(0) == '!') {
   14400         1830 :             headerLines.push_back(line);
   14401              :         } else {
   14402         2574 :             if (line.at(0) == ' ') {
   14403         1774 :                 bodyLines.push_back(line.substr(1)); // remove leading space
   14404              :             } else {
   14405          800 :                 bodyLines.push_back(line);
   14406              :             }
   14407              :         }
   14408           39 :     }
   14409              : 
   14410           79 :     for (int iUnitSystem = 0; iUnitSystem <= 1; iUnitSystem++) {
   14411           78 :         UnitsStyle unitsStyle_cur = ort->unitsStyle;
   14412           78 :         bool produceTabular = true;
   14413           78 :         bool produceSQLite = false;
   14414           78 :         if (produceDualUnitsFlags(iUnitSystem, ort->unitsStyle, ort->unitsStyle_SQLite, unitsStyle_cur, produceTabular, produceSQLite)) {
   14415           38 :             break;
   14416              :         }
   14417              : 
   14418              :         // now go through each header and create a report for each one
   14419         1872 :         for (std::string const &headerLine : headerLines) {
   14420         1832 :             std::vector<std::string> headerFields = splitCommaString(headerLine);
   14421         1832 :             std::string tableNameWithSigns = headerFields.at(0);
   14422              :             std::string tableName =
   14423         1832 :                 tableNameWithSigns.substr(3, tableNameWithSigns.size() - 4); // get rid of the '! <' from the beginning and the '>' from the end
   14424              :             // first count the number of matching lines
   14425         1832 :             int countOfMatchingLines = 0;
   14426       126900 :             for (std::string const &bodyLine : bodyLines) {
   14427       125068 :                 if (bodyLine.size() > tableName.size()) {
   14428       114445 :                     if (bodyLine.substr(0, tableName.size() + 1) ==
   14429       228890 :                         tableName + ",") { // this needs to match the test used to populate the body of table below
   14430         2537 :                         ++countOfMatchingLines;
   14431              :                     }
   14432              :                 }
   14433         1832 :             }
   14434         1832 :             int numRows = countOfMatchingLines;
   14435         1832 :             int numCols = headerFields.size() - 1;
   14436              : 
   14437         1832 :             if (numRows >= 1) {
   14438         1781 :                 rowHead.allocate(numRows);
   14439         1781 :                 columnHead.allocate(numCols);
   14440         1781 :                 columnWidth.allocate(numCols);
   14441         1781 :                 columnWidth = 14; // array assignment - same for all columns
   14442         1781 :                 tableBody.allocate(numCols, numRows);
   14443         1781 :                 tableBody = ""; // make sure everything is blank
   14444         1781 :                 colUnitConv.allocate(numCols);
   14445              :                 // transfer the header row into column headings
   14446        13966 :                 for (int iCol = 1; iCol <= numCols; ++iCol) {
   14447        12185 :                     columnHead(iCol) = headerFields.at(iCol);
   14448              :                     // set the unit conversions
   14449              :                     // colUnitConv(iCol) = unitsFromHeading(state, columnHead(iCol));
   14450              :                     // Jan 2021: use overloaded version for dual units
   14451        12185 :                     colUnitConv(iCol) = unitsFromHeading(state, columnHead(iCol), unitsStyle_cur);
   14452              :                 }
   14453              :                 // look for data lines
   14454         1781 :                 int rowNum = 0;
   14455       123235 :                 for (std::string const &bodyLine : bodyLines) {
   14456       121454 :                     if (bodyLine.size() > tableName.size()) {
   14457       110937 :                         if (bodyLine.substr(0, tableName.size() + 1) ==
   14458       221874 :                             tableName + ",") { // this needs to match the test used in the original counting
   14459         2537 :                             ++rowNum;
   14460         2537 :                             if (rowNum > countOfMatchingLines) {
   14461            0 :                                 break; // should never happen since same test as original could
   14462              :                             }
   14463         2537 :                             std::vector<std::string> dataFields = splitCommaString(bodyLine);
   14464         2537 :                             rowHead(rowNum) = fmt::to_string(rowNum);
   14465        20790 :                             for (int iCol = 1; iCol <= numCols && iCol < int(dataFields.size()); ++iCol) {
   14466        18253 :                                 if (unitsStyle_cur == OutputReportTabular::UnitsStyle::InchPound ||
   14467        17734 :                                     unitsStyle_cur == OutputReportTabular::UnitsStyle::InchPoundExceptElectricity ||
   14468        17734 :                                     unitsStyle_cur == UnitsStyle::JtoKWH) {
   14469          519 :                                     if (isNumber(dataFields[iCol]) && colUnitConv(iCol) > 0) { // if it is a number that has a conversion
   14470          164 :                                         int numDecimalDigits = digitsAferDecimal(dataFields[iCol]);
   14471          164 :                                         Real64 convertedVal = ConvertIP(state, colUnitConv(iCol), StrToReal(dataFields[iCol]));
   14472          164 :                                         tableBody(iCol, rowNum) = RealToStr(convertedVal, numDecimalDigits);
   14473          355 :                                     } else if (iCol == numCols && columnHead(iCol) == "Value" && iCol > 1) { // if it is the last column and the
   14474              :                                                                                                              // header is Value then treat the
   14475              :                                                                                                              // previous column as source of units
   14476              :                                         // int indexUnitConv =
   14477              :                                         //    unitsFromHeading(state, tableBody(iCol - 1, rowNum)); // base units on previous column
   14478              :                                         // Jan 2021: use overloaded version for dual units
   14479              :                                         int indexUnitConv =
   14480           22 :                                             unitsFromHeading(state, tableBody(iCol - 1, rowNum), unitsStyle_cur); // base units on previous column
   14481              : 
   14482           22 :                                         int numDecimalDigits = digitsAferDecimal(dataFields[iCol]);
   14483           22 :                                         Real64 convertedVal = ConvertIP(state, indexUnitConv, StrToReal(dataFields[iCol]));
   14484           22 :                                         tableBody(iCol, rowNum) = RealToStr(convertedVal, numDecimalDigits);
   14485              :                                     } else {
   14486          333 :                                         tableBody(iCol, rowNum) = dataFields[iCol];
   14487              :                                     }
   14488          519 :                                 } else {
   14489        17734 :                                     tableBody(iCol, rowNum) = dataFields[iCol];
   14490              :                                 }
   14491              :                             }
   14492         2537 :                         }
   14493              :                     }
   14494         1781 :                 }
   14495              : 
   14496         1781 :                 if (produceTabular) {
   14497         1779 :                     WriteSubtitle(state, tableName);
   14498         1779 :                     std::string footnote;
   14499         1779 :                     WriteTable(state, tableBody, rowHead, columnHead, columnWidth, false, footnote);
   14500         1779 :                     if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
   14501            0 :                         state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(
   14502              :                             tableBody, rowHead, columnHead, "InitializationSummary", "Entire Facility", tableName);
   14503              :                     }
   14504         1779 :                 }
   14505         1781 :                 if (produceSQLite) {
   14506         1779 :                     if (state.dataSQLiteProcedures->sqlite) {
   14507          162 :                         state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
   14508              :                             tableBody, rowHead, columnHead, "InitializationSummary", "Entire Facility", tableName);
   14509              :                     }
   14510              :                 }
   14511              :             }
   14512         1872 :         }
   14513              :     }
   14514              : 
   14515              :     // as of Oct 2016 only the <Program Control Information:Threads/Parallel Sims> section is written after this point
   14516           39 : }
   14517              : 
   14518              : // changes the heading that contains and SI to IP as well as providing the unit conversion index
   14519              : // Glazer Nov 2016
   14520            9 : int unitsFromHeading(EnergyPlusData &state, std::string &heading)
   14521              : {
   14522            9 :     auto const &ort = state.dataOutRptTab;
   14523              : 
   14524            9 :     std::string curHeading;
   14525            9 :     int unitConv = 0;
   14526            9 :     if (ort->unitsStyle == UnitsStyle::InchPound) {
   14527            9 :         LookupSItoIP(state, heading, unitConv, curHeading);
   14528            0 :     } else if (ort->unitsStyle == UnitsStyle::InchPoundExceptElectricity) {
   14529            0 :         LookupSItoIP(state, heading, unitConv, curHeading);
   14530            0 :     } else if (ort->unitsStyle == UnitsStyle::JtoKWH) {
   14531            0 :         LookupJtokWH(state, heading, unitConv, curHeading);
   14532              :     } else {
   14533            0 :         curHeading = heading;
   14534              :     }
   14535            9 :     heading = curHeading;
   14536            9 :     return (unitConv);
   14537            9 : }
   14538              : 
   14539              : // Jan 2021: Overloaded this function to accommodate dual units output needs
   14540              : // changes the heading that contains and SI to IP as well as providing the unit conversion index
   14541              : // Glazer Nov 2016
   14542        12207 : int unitsFromHeading(EnergyPlusData &state, std::string &heading, UnitsStyle unitsStyle_para)
   14543              : {
   14544        12207 :     std::string curHeading = "";
   14545        12207 :     int unitConv = 0;
   14546        12207 :     if (unitsStyle_para == UnitsStyle::InchPound) {
   14547          399 :         LookupSItoIP(state, heading, unitConv, curHeading);
   14548        11808 :     } else if (unitsStyle_para == UnitsStyle::InchPoundExceptElectricity) {
   14549            0 :         LookupSItoIP(state, heading, unitConv, curHeading);
   14550        11808 :     } else if (unitsStyle_para == UnitsStyle::JtoKWH) {
   14551            0 :         LookupJtokWH(state, heading, unitConv, curHeading);
   14552              :     } else {
   14553        11808 :         curHeading = heading;
   14554              :     }
   14555        12207 :     heading = curHeading;
   14556        12207 :     return (unitConv);
   14557        12207 : }
   14558              : 
   14559              : // function that returns a vector of strings when given a string with comma delimiters
   14560              : // Glazer Nov 2016
   14561         4375 : std::vector<std::string> splitCommaString(std::string const &inputString)
   14562              : {
   14563         4375 :     std::vector<std::string> fields;
   14564         4375 :     std::string field;
   14565         4375 :     std::stringstream inputSS(inputString);
   14566        39432 :     while (std::getline(inputSS, field, ',')) {
   14567        35057 :         fields.push_back(stripped(field));
   14568              :     }
   14569         8750 :     return fields;
   14570         4375 : }
   14571              : 
   14572           74 : void AddTOCLoadComponentTableSummaries(EnergyPlusData &state)
   14573              : {
   14574              :     // SUBROUTINE INFORMATION:
   14575              :     //       AUTHOR         Jason Glazer
   14576              :     //       DATE WRITTEN   March 2012
   14577              :     //       MODIFIED       na
   14578              :     //       RE-ENGINEERED  na
   14579              : 
   14580              :     // PURPOSE OF THIS SUBROUTINE:
   14581              :     //   Add the table of contents entries for the Zone heat transfer
   14582              :     //   summary report.
   14583              : 
   14584              :     // METHODOLOGY EMPLOYED:
   14585              :     //   Call the AddTOCEntry routine for each zone.
   14586              : 
   14587           74 :     auto const &ort = state.dataOutRptTab;
   14588              : 
   14589           74 :     if (state.dataGlobal->CompLoadReportIsReq) {
   14590            4 :         if (ort->displayZoneComponentLoadSummary) {
   14591            4 :             if (state.dataHeatBal->doSpaceHeatBalanceSizing) {
   14592            0 :                 for (int iSpace = 1; iSpace <= state.dataGlobal->NumOfZones; ++iSpace) {
   14593            0 :                     if (!state.dataZoneEquip->ZoneEquipConfig(state.dataHeatBal->space(iSpace).zoneNum).IsControlled) {
   14594            0 :                         continue;
   14595              :                     }
   14596            0 :                     AddTOCEntry(state, "Space Component Load Summary", state.dataHeatBal->space(iSpace).Name);
   14597              :                 }
   14598              :             }
   14599            9 :             for (int iZone = 1; iZone <= state.dataGlobal->NumOfZones; ++iZone) {
   14600            5 :                 if (!state.dataZoneEquip->ZoneEquipConfig(iZone).IsControlled) {
   14601            0 :                     continue;
   14602              :                 }
   14603           15 :                 AddTOCEntry(state, "Zone Component Load Summary", state.dataHeatBal->Zone(iZone).Name);
   14604              :             }
   14605              :         }
   14606            4 :         if (ort->displayAirLoopComponentLoadSummary) {
   14607            7 :             for (int AirLoopNum = 1; AirLoopNum <= state.dataHVACGlobal->NumPrimaryAirSys; ++AirLoopNum) {
   14608            9 :                 AddTOCEntry(state, "AirLoop Component Load Summary", state.dataSize->FinalSysSizing(AirLoopNum).AirPriLoopName);
   14609              :             }
   14610              :         }
   14611            4 :         if (ort->displayFacilityComponentLoadSummary) {
   14612           16 :             AddTOCEntry(state, "Facility Component Load Summary", "Facility");
   14613              :         }
   14614              :     }
   14615           74 : }
   14616              : 
   14617        19265 : void AllocateLoadComponentArrays(EnergyPlusData &state)
   14618              : {
   14619              :     // SUBROUTINE INFORMATION:
   14620              :     //       AUTHOR         Jason Glazer
   14621              :     //       DATE WRITTEN   April 2012
   14622              : 
   14623              :     // PURPOSE OF THIS SUBROUTINE:
   14624              :     //   Allocate the arrays related to the load component report
   14625              : 
   14626        19265 :     auto const &ort = state.dataOutRptTab;
   14627              : 
   14628        19265 :     if (!ort->AllocateLoadComponentArraysDoAllocate) {
   14629        19254 :         return;
   14630              :     }
   14631              : 
   14632           11 :     Real64 timeStepsInDay = state.dataGlobal->TimeStepsInHour * Constant::rHoursInDay;
   14633              : 
   14634              :     // For many of the following arrays the last dimension is the number of environments and is same as sizing arrays
   14635           11 :     ort->radiantPulseTimestep.allocate({0, state.dataEnvrn->TotDesDays + state.dataEnvrn->TotRunDesPersDays}, state.dataGlobal->NumOfZones);
   14636           11 :     ort->radiantPulseTimestep = 0;
   14637           11 :     ort->radiantPulseReceived.allocate({0, state.dataEnvrn->TotDesDays + state.dataEnvrn->TotRunDesPersDays}, state.dataSurface->TotSurfaces);
   14638           11 :     ort->radiantPulseReceived = 0.0;
   14639           11 :     ort->decayCurveCool.allocate(timeStepsInDay, state.dataSurface->TotSurfaces);
   14640           11 :     ort->decayCurveCool = 0.0;
   14641           11 :     ort->decayCurveHeat.allocate(timeStepsInDay, state.dataSurface->TotSurfaces);
   14642           11 :     ort->decayCurveHeat = 0.0;
   14643              : 
   14644           11 :     Real64 const numTSinDay = state.dataGlobal->TimeStepsInHour * Constant::rHoursInDay;
   14645              : 
   14646           11 :     ort->surfCompLoads.resize(state.dataEnvrn->TotDesDays + state.dataEnvrn->TotRunDesPersDays);
   14647           41 :     for (auto &day : ort->surfCompLoads) {
   14648           30 :         day.ts.resize(numTSinDay);
   14649         2910 :         for (auto &ts : day.ts) {
   14650         2880 :             ts.surf.resize(state.dataSurface->TotSurfaces);
   14651           30 :         }
   14652           11 :     }
   14653              : 
   14654           11 :     ort->enclCompLoads.resize(state.dataEnvrn->TotDesDays + state.dataEnvrn->TotRunDesPersDays);
   14655           41 :     for (auto &day : ort->enclCompLoads) {
   14656           30 :         day.ts.resize(numTSinDay);
   14657         2910 :         for (auto &ts : day.ts) {
   14658         2880 :             ts.encl.resize(state.dataViewFactor->NumOfRadiantEnclosures);
   14659           30 :         }
   14660           11 :     }
   14661              : 
   14662           11 :     ort->znCompLoads.resize(state.dataEnvrn->TotDesDays + state.dataEnvrn->TotRunDesPersDays);
   14663           41 :     for (auto &day : ort->znCompLoads) {
   14664           30 :         day.ts.resize(numTSinDay);
   14665         2910 :         for (auto &ts : day.ts) {
   14666         2880 :             ts.spacezone.resize(state.dataGlobal->NumOfZones);
   14667           30 :         }
   14668           11 :     }
   14669           11 :     if (state.dataHeatBal->doSpaceHeatBalanceSizing) {
   14670            0 :         ort->spCompLoads.resize(state.dataEnvrn->TotDesDays + state.dataEnvrn->TotRunDesPersDays);
   14671            0 :         for (auto &day : ort->spCompLoads) {
   14672            0 :             day.ts.resize(numTSinDay);
   14673            0 :             for (auto &ts : day.ts) {
   14674            0 :                 ts.spacezone.resize(state.dataGlobal->numSpaces);
   14675            0 :             }
   14676            0 :         }
   14677              :     }
   14678              : 
   14679           11 :     ort->AllocateLoadComponentArraysDoAllocate = false;
   14680              : }
   14681              : 
   14682            6 : void DeallocateLoadComponentArrays(EnergyPlusData const &state)
   14683              : {
   14684              :     // SUBROUTINE INFORMATION:
   14685              :     //       AUTHOR         Jason Glazer
   14686              :     //       DATE WRITTEN   August 2012
   14687              : 
   14688              :     // PURPOSE OF THIS SUBROUTINE:
   14689              :     //   Deallocate the arrays related to the load component report that will not
   14690              :     //   be needed in the reporting.
   14691              : 
   14692            6 :     auto const &ort = state.dataOutRptTab;
   14693            6 :     ort->radiantPulseTimestep.deallocate();
   14694            6 :     ort->radiantPulseReceived.deallocate();
   14695            6 : }
   14696              : 
   14697            6 : void ComputeLoadComponentDecayCurve(EnergyPlusData &state)
   14698              : {
   14699              : 
   14700              :     // SUBROUTINE INFORMATION:
   14701              :     //       AUTHOR         Jason Glazer
   14702              :     //       DATE WRITTEN   August 2012
   14703              : 
   14704              :     // PURPOSE OF THIS SUBROUTINE:
   14705              :     // Determines the load component decay curve based on normal and pulse results from zone sizing.
   14706              : 
   14707              :     // METHODOLOGY EMPLOYED:
   14708              :     // Decay curve is the fraction of the heat convected from a surface over the initial radiant heat
   14709              :     // absorbed by the surface.
   14710              : 
   14711              :     Real64 diff;
   14712            6 :     auto const &ort = state.dataOutRptTab;
   14713              : 
   14714           65 :     for (int surfNum = 1; surfNum <= state.dataSurface->TotSurfaces; ++surfNum) {
   14715           59 :         int const zoneNum = state.dataSurface->Surface(surfNum).Zone;
   14716           59 :         if (zoneNum == 0) {
   14717            0 :             continue;
   14718              :         }
   14719           59 :         if (!state.dataZoneEquip->ZoneEquipConfig(zoneNum).IsControlled) {
   14720            2 :             continue;
   14721              :         }
   14722           57 :         int const spaceNum = state.dataSurface->Surface(surfNum).spaceNum;
   14723           57 :         int coolDesSelected = state.dataSize->CalcFinalZoneSizing(zoneNum).CoolDDNum;
   14724              :         // loop over timesteps after pulse occurred
   14725           57 :         if (coolDesSelected != 0) {
   14726           57 :             auto &surfCLClDay = ort->surfCompLoads[coolDesSelected - 1];
   14727           57 :             int timeOfPulse = ort->radiantPulseTimestep(coolDesSelected, zoneNum);
   14728              :             // if the CoolDesSelected time is on a different day than
   14729              :             // when the pulse occurred, need to scan back and find when
   14730              :             // the pulse occurred.
   14731           57 :             if (timeOfPulse == 0) {
   14732            0 :                 for (int i = coolDesSelected; i >= 1; --i) {
   14733            0 :                     timeOfPulse = ort->radiantPulseTimestep(i, zoneNum);
   14734            0 :                     if (timeOfPulse != 0) {
   14735            0 :                         break;
   14736              :                     }
   14737              :                 }
   14738              :             }
   14739           57 :             if (timeOfPulse == 0) {
   14740            0 :                 timeOfPulse = 1;
   14741              :             }
   14742         3162 :             for (int timeStep = timeOfPulse; timeStep <= state.dataGlobal->TimeStepsInHour * Constant::rHoursInDay; ++timeStep) {
   14743         3105 :                 if (ort->radiantPulseReceived(coolDesSelected, surfNum) != 0.0) {
   14744         3105 :                     auto &surfClDayTS = surfCLClDay.ts[timeStep - 1].surf[surfNum - 1];
   14745         3105 :                     diff = surfClDayTS.loadConvectedWithPulse - surfClDayTS.loadConvectedNormal;
   14746         3105 :                     ort->decayCurveCool(timeStep - timeOfPulse + 1, surfNum) = -diff / ort->radiantPulseReceived(coolDesSelected, surfNum);
   14747              :                 } else {
   14748            0 :                     ort->decayCurveCool(timeStep - timeOfPulse + 1, surfNum) = 0.0;
   14749              :                 }
   14750              :             }
   14751              :         }
   14752           57 :         int const heatDesSelected = state.dataSize->CalcFinalZoneSizing(zoneNum).HeatDDNum;
   14753           57 :         if (heatDesSelected != 0) {
   14754           57 :             auto &surfCLHtDay = ort->surfCompLoads[heatDesSelected - 1];
   14755           57 :             int timeOfPulse = ort->radiantPulseTimestep(heatDesSelected, zoneNum);
   14756              :             // scan back to the day that the heating pulse occurs, if necessary
   14757           57 :             if (timeOfPulse == 0) {
   14758            0 :                 for (int i = heatDesSelected; i >= 1; --i) {
   14759            0 :                     timeOfPulse = ort->radiantPulseTimestep(i, zoneNum);
   14760            0 :                     if (timeOfPulse != 0) {
   14761            0 :                         break;
   14762              :                     }
   14763              :                 }
   14764              :             }
   14765           57 :             if (timeOfPulse == 0) {
   14766            0 :                 timeOfPulse = 1;
   14767              :             }
   14768         3162 :             for (int timeStep = timeOfPulse; timeStep <= state.dataGlobal->TimeStepsInHour * Constant::rHoursInDay; ++timeStep) {
   14769         3105 :                 if (ort->radiantPulseReceived(heatDesSelected, surfNum) != 0.0) {
   14770         3105 :                     auto &surfHtDayTS = surfCLHtDay.ts[timeStep - 1].surf[surfNum - 1];
   14771         3105 :                     diff = surfHtDayTS.loadConvectedWithPulse - surfHtDayTS.loadConvectedNormal;
   14772         3105 :                     ort->decayCurveHeat(timeStep - timeOfPulse + 1, surfNum) = -diff / ort->radiantPulseReceived(heatDesSelected, surfNum);
   14773              :                 } else {
   14774            0 :                     ort->decayCurveHeat(timeStep - timeOfPulse + 1, surfNum) = 0.0;
   14775              :                 }
   14776              :             }
   14777              :         }
   14778              :     }
   14779              : 
   14780            6 :     if (state.dataGlobal->ShowDecayCurvesInEIO) {
   14781              :         // show the line definition for the decay curves
   14782            0 :         print(state.files.eio,
   14783              :               "! <Radiant to Convective Decay Curves for Cooling>,Zone Name, Surface Name, Time "
   14784              :               "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");
   14785            0 :         print(state.files.eio,
   14786              :               "! <Radiant to Convective Decay Curves for Heating>,Zone Name, Surface Name, Time "
   14787              :               "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");
   14788              :         // Put the decay curve into the EIO file
   14789            0 :         for (int iZone = 1; iZone <= state.dataGlobal->NumOfZones; ++iZone) {
   14790            0 :             auto &thisZone = state.dataHeatBal->Zone(iZone);
   14791            0 :             for (int kSurf : state.dataSurface->AllSurfaceListReportOrder) {
   14792            0 :                 if (state.dataSurface->Surface(kSurf).Zone != iZone) {
   14793            0 :                     continue;
   14794              :                 }
   14795            0 :                 print(state.files.eio,
   14796              :                       "{},{},{}",
   14797              :                       "Radiant to Convective Decay Curves for Cooling",
   14798            0 :                       thisZone.Name,
   14799            0 :                       state.dataSurface->Surface(kSurf).Name);
   14800            0 :                 for (int jTime = 1; jTime <= min(int(state.dataGlobal->TimeStepsInHour * Constant::iHoursInDay), 36); ++jTime) {
   14801            0 :                     print(state.files.eio, ",{:6.3F}", ort->decayCurveCool(jTime, kSurf));
   14802              :                 }
   14803              :                 // put a line feed at the end of the line
   14804            0 :                 print(state.files.eio, "\n");
   14805            0 :             }
   14806              : 
   14807            0 :             for (int kSurf : state.dataSurface->AllSurfaceListReportOrder) {
   14808            0 :                 if (state.dataSurface->Surface(kSurf).Zone != iZone) {
   14809            0 :                     continue;
   14810              :                 }
   14811            0 :                 print(state.files.eio,
   14812              :                       "{},{},{}",
   14813              :                       "Radiant to Convective Decay Curves for Heating",
   14814            0 :                       thisZone.Name,
   14815            0 :                       state.dataSurface->Surface(kSurf).Name);
   14816            0 :                 for (int jTime = 1; jTime <= min(int(state.dataGlobal->TimeStepsInHour * Constant::iHoursInDay), 36); ++jTime) {
   14817            0 :                     print(state.files.eio, ",{:6.3F}", ort->decayCurveHeat(jTime, kSurf));
   14818              :                 }
   14819              :                 // put a line feed at the end of the line
   14820            0 :                 print(state.files.eio, "\n");
   14821            0 :             }
   14822              :         }
   14823              :     }
   14824            6 : }
   14825              : 
   14826        83022 : void GatherComponentLoadsSurface(EnergyPlusData &state)
   14827              : {
   14828              :     // SUBROUTINE INFORMATION:
   14829              :     //       AUTHOR         Jason Glazer
   14830              :     //       DATE WRITTEN   September 2012
   14831              : 
   14832              :     // PURPOSE OF THIS SUBROUTINE:
   14833              :     //   Gather values during sizing used for loads component report.
   14834              : 
   14835              :     // METHODOLOGY EMPLOYED:
   14836              :     //   Save sequence of values for report during sizing.
   14837              : 
   14838              :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
   14839        83022 :     auto const &ort = state.dataOutRptTab;
   14840              : 
   14841        83022 :     if (state.dataGlobal->CompLoadReportIsReq && !state.dataGlobal->isPulseZoneSizing) {
   14842         7452 :         int timeStepInDayGCLS = (state.dataGlobal->HourOfDay - 1) * state.dataGlobal->TimeStepsInHour + state.dataGlobal->TimeStep;
   14843         7452 :         auto &znCLDayTS = ort->znCompLoads[state.dataSize->CurOverallSimDay - 1].ts[timeStepInDayGCLS - 1];
   14844        21654 :         for (auto &zone : znCLDayTS.spacezone) {
   14845        14202 :             zone.feneCondInstantSeq = 0.0;
   14846         7452 :         }
   14847         7452 :         if (state.dataHeatBal->doSpaceHeatBalanceSizing) {
   14848            0 :             auto &spCLDayTS = ort->spCompLoads[state.dataSize->CurOverallSimDay - 1].ts[timeStepInDayGCLS - 1];
   14849            0 :             for (auto &space : spCLDayTS.spacezone) {
   14850            0 :                 space.feneCondInstantSeq = 0.0;
   14851            0 :             }
   14852              :         }
   14853        82566 :         for (int iSurfGCLS = 1; iSurfGCLS <= state.dataSurface->TotSurfaces; ++iSurfGCLS) {
   14854        75114 :             int zoneNumGCLS = state.dataSurface->Surface(iSurfGCLS).Zone;
   14855        75114 :             if (zoneNumGCLS == 0) {
   14856            0 :                 continue;
   14857              :             }
   14858        75114 :             if (state.dataSurface->Surface(iSurfGCLS).Class != DataSurfaces::SurfaceClass::Window) {
   14859        71712 :                 continue;
   14860              :             }
   14861              :             // IF (.not. ZoneEquipConfig(ZoneNum)%IsControlled) CYCLE
   14862         3402 :             Real64 surfCond = state.dataSurface->SurfWinGainConvGlazToZoneRep(iSurfGCLS) + state.dataSurface->SurfWinConvHeatFlowNatural(iSurfGCLS) +
   14863         3402 :                               state.dataSurface->SurfWinGainConvShadeToZoneRep(iSurfGCLS) +
   14864         3402 :                               state.dataSurface->SurfWinGainFrameDividerToZoneRep(iSurfGCLS);
   14865         3402 :             znCLDayTS.spacezone[zoneNumGCLS - 1].feneCondInstantSeq += surfCond;
   14866              : 
   14867         3402 :             if (state.dataHeatBal->doSpaceHeatBalanceSizing) {
   14868            0 :                 int spaceNum = state.dataSurface->Surface(iSurfGCLS).spaceNum;
   14869            0 :                 ort->spCompLoads[state.dataSize->CurOverallSimDay - 1].ts[timeStepInDayGCLS - 1].spacezone[spaceNum - 1].feneCondInstantSeq +=
   14870              :                     surfCond;
   14871              :             }
   14872              : 
   14873              :             // for now assume zero instant solar - may change related
   14874              :             // to how blinds and shades absorb solar radiation and
   14875              :             // convect that heat that timestep.
   14876              :             // feneSolarInstantSeq(ZoneNum,TimeStepInDay,CurOverallSimDay) = 0
   14877              :         }
   14878              : 
   14879        21654 :         for (int izone = 1; izone <= state.dataGlobal->NumOfZones; ++izone) {
   14880        14202 :             Real64 tubularGain = 0.0;
   14881        14202 :             tubularGain = InternalHeatGains::SumInternalConvectionGainsByTypes(state, izone, OutputReportTabular::IntGainTypesTubularGCLS);
   14882        14202 :             znCLDayTS.spacezone[izone - 1].feneCondInstantSeq += tubularGain;
   14883              :         }
   14884         7452 :         if (state.dataHeatBal->doSpaceHeatBalanceSizing) {
   14885            0 :             auto &spCLDayTS = ort->spCompLoads[state.dataSize->CurOverallSimDay - 1].ts[timeStepInDayGCLS - 1];
   14886            0 :             for (int ispace = 1; ispace <= state.dataGlobal->NumOfZones; ++ispace) {
   14887            0 :                 Real64 tubularGain = 0.0;
   14888            0 :                 int zone = state.dataHeatBal->space(ispace).zoneNum;
   14889            0 :                 tubularGain = InternalHeatGains::SumInternalConvectionGainsByTypes(state, zone, OutputReportTabular::IntGainTypesTubularGCLS, ispace);
   14890            0 :                 spCLDayTS.spacezone[ispace - 1].feneCondInstantSeq += tubularGain;
   14891              :             }
   14892              :         }
   14893              :     }
   14894        83022 : }
   14895              : 
   14896         4560 : void GatherComponentLoadsHVAC(EnergyPlusData &state)
   14897              : {
   14898              :     // SUBROUTINE INFORMATION:
   14899              :     //       AUTHOR         Jason Glazer
   14900              :     //       DATE WRITTEN   September 2012
   14901              : 
   14902              :     // PURPOSE OF THIS SUBROUTINE:
   14903              :     //   Gather values during sizing used for loads component report.
   14904              : 
   14905              :     // METHODOLOGY EMPLOYED:
   14906              :     //   Save sequence of values for report during sizing.
   14907              : 
   14908         4560 :     if (!(state.dataGlobal->CompLoadReportIsReq && !state.dataGlobal->isPulseZoneSizing)) {
   14909         3528 :         return;
   14910              :     }
   14911         1032 :     int timeStepInDayGCLH = (state.dataGlobal->HourOfDay - 1) * state.dataGlobal->TimeStepsInHour + state.dataGlobal->TimeStep;
   14912         1032 :     auto &znCompLoadDayTS = state.dataOutRptTab->znCompLoads[state.dataSize->CurOverallSimDay - 1].ts[timeStepInDayGCLH - 1];
   14913         3072 :     for (int iZoneGCLH = 1; iZoneGCLH <= state.dataGlobal->NumOfZones; ++iZoneGCLH) {
   14914         2040 :         auto &znCompLoadDayTSZone = znCompLoadDayTS.spacezone[iZoneGCLH - 1];
   14915         2040 :         auto &zoneAirRpt = state.dataHeatBal->ZnAirRpt(iZoneGCLH);
   14916         2040 :         gatherSpaceZoneCompLoadsHVAC(znCompLoadDayTSZone, zoneAirRpt, state.dataHVACGlobal->TimeStepSysSec);
   14917         2040 :         if (state.afn->simulation_control.type != AirflowNetwork::ControlType::NoMultizoneOrDistribution) {
   14918            0 :             znCompLoadDayTSZone.infilInstantSeq += (state.afn->AirflowNetworkReportData(iZoneGCLH).MultiZoneInfiSenGainW -
   14919            0 :                                                     state.afn->AirflowNetworkReportData(iZoneGCLH).MultiZoneInfiSenLossW); // air flow network
   14920            0 :             znCompLoadDayTSZone.infilLatentSeq += (state.afn->AirflowNetworkReportData(iZoneGCLH).MultiZoneInfiLatGainW -
   14921            0 :                                                    state.afn->AirflowNetworkReportData(iZoneGCLH).MultiZoneInfiLatLossW); // air flow network
   14922            0 :             znCompLoadDayTSZone.zoneVentInstantSeq += (state.afn->AirflowNetworkReportData(iZoneGCLH).MultiZoneVentSenGainW -
   14923            0 :                                                        state.afn->AirflowNetworkReportData(iZoneGCLH).MultiZoneVentSenLossW); // air flow network
   14924            0 :             znCompLoadDayTSZone.zoneVentInstantSeq += (state.afn->AirflowNetworkReportData(iZoneGCLH).MultiZoneVentLatGainW -
   14925            0 :                                                        state.afn->AirflowNetworkReportData(iZoneGCLH).MultiZoneVentLatLossW); // air flow network
   14926            0 :             znCompLoadDayTSZone.interZoneMixInstantSeq += (state.afn->AirflowNetworkReportData(iZoneGCLH).MultiZoneMixSenGainW -
   14927            0 :                                                            state.afn->AirflowNetworkReportData(iZoneGCLH).MultiZoneMixSenLossW); // air flow network
   14928            0 :             znCompLoadDayTSZone.interZoneMixLatentSeq += (state.afn->AirflowNetworkReportData(iZoneGCLH).MultiZoneMixLatGainW -
   14929            0 :                                                           state.afn->AirflowNetworkReportData(iZoneGCLH).MultiZoneMixLatLossW); // air flow network
   14930              :         }
   14931              :     }
   14932         1032 :     if (state.dataHeatBal->doSpaceHeatBalanceSizing) {
   14933            0 :         auto &spCompLoadDayTS = state.dataOutRptTab->spCompLoads[state.dataSize->CurOverallSimDay - 1].ts[timeStepInDayGCLH - 1];
   14934            0 :         for (int iSpace = 1; iSpace <= state.dataGlobal->numSpaces; ++iSpace) {
   14935            0 :             auto &spCompLoadDayTSSpace = spCompLoadDayTS.spacezone[iSpace - 1];
   14936            0 :             auto &spaceAirRpt = state.dataHeatBal->spaceAirRpt(iSpace);
   14937            0 :             gatherSpaceZoneCompLoadsHVAC(spCompLoadDayTSSpace, spaceAirRpt, state.dataHVACGlobal->TimeStepSysSec);
   14938            0 :             if (state.afn->simulation_control.type != AirflowNetwork::ControlType::NoMultizoneOrDistribution) {
   14939            0 :                 auto &space = state.dataHeatBal->space(iSpace);
   14940            0 :                 auto const &znCompLoadDayTSZone = znCompLoadDayTS.spacezone[space.zoneNum - 1];
   14941            0 :                 spCompLoadDayTSSpace.infilInstantSeq = space.fracZoneVolume * znCompLoadDayTSZone.infilInstantSeq;
   14942            0 :                 spCompLoadDayTSSpace.infilLatentSeq = space.fracZoneVolume * znCompLoadDayTSZone.infilLatentSeq;
   14943            0 :                 spCompLoadDayTSSpace.zoneVentInstantSeq = space.fracZoneVolume * znCompLoadDayTSZone.zoneVentInstantSeq;
   14944            0 :                 spCompLoadDayTSSpace.zoneVentInstantSeq = space.fracZoneVolume * znCompLoadDayTSZone.zoneVentInstantSeq;
   14945            0 :                 spCompLoadDayTSSpace.interZoneMixInstantSeq = space.fracZoneVolume * znCompLoadDayTSZone.interZoneMixInstantSeq;
   14946            0 :                 spCompLoadDayTSSpace.interZoneMixLatentSeq = space.fracZoneVolume * znCompLoadDayTSZone.interZoneMixLatentSeq;
   14947              :             }
   14948              :         }
   14949              :     }
   14950              : }
   14951              : 
   14952         2040 : void gatherSpaceZoneCompLoadsHVAC(OutputReportTabular::compLoadsSpaceZone &szCompLoadDayTS,
   14953              :                                   DataHeatBalance::AirReportVars const &szAirRpt,
   14954              :                                   Real64 const timeStepSysSec)
   14955              : {
   14956         2040 :     szCompLoadDayTS.infilInstantSeq = ((szAirRpt.InfilHeatGain - szAirRpt.InfilHeatLoss) / timeStepSysSec);         // zone infiltration
   14957         2040 :     szCompLoadDayTS.infilLatentSeq = ((szAirRpt.InfilLatentGain - szAirRpt.InfilLatentLoss) / timeStepSysSec);      // zone infiltration
   14958         2040 :     szCompLoadDayTS.zoneVentInstantSeq = ((szAirRpt.VentilHeatGain - szAirRpt.VentilHeatLoss) / timeStepSysSec);    // zone ventilation
   14959         2040 :     szCompLoadDayTS.zoneVentLatentSeq = ((szAirRpt.VentilLatentGain - szAirRpt.VentilLatentLoss) / timeStepSysSec); // zone ventilation
   14960         2040 :     szCompLoadDayTS.interZoneMixInstantSeq = ((szAirRpt.MixHeatGain - szAirRpt.MixHeatLoss) / timeStepSysSec);      // zone mixing
   14961         2040 :     szCompLoadDayTS.interZoneMixLatentSeq = ((szAirRpt.MixLatentGain - szAirRpt.MixLatentLoss) / timeStepSysSec);   // zone mixing
   14962         2040 : }
   14963              : 
   14964           40 : void WriteLoadComponentSummaryTables(EnergyPlusData &state)
   14965              : {
   14966              :     // SUBROUTINE INFORMATION:
   14967              :     //       AUTHOR         Jason Glazer
   14968              :     //       DATE WRITTEN   March 2012
   14969              :     //       MODIFIED       na
   14970              :     //       RE-ENGINEERED  Amir Roth, Feb 2016 (unified with ComputeDelayedComponents to simplify code and debugging)
   14971              : 
   14972              :     // PURPOSE OF THIS SUBROUTINE:
   14973              :     //   Write the tables for the ZoneLoadComponentSummary and
   14974              :     //   ZoneLoadComponentDetail reports which summarize the major
   14975              :     //   load components for each zone in the building.
   14976              : 
   14977              :     // METHODOLOGY EMPLOYED:
   14978              :     //   Create arrays for the call to WriteTable and then call it.
   14979              :     //   This report actually consists of many sub-tables each with
   14980              :     //   its own call to WriteTable.
   14981              :     // The overall methodology is explained below:
   14982              :     //
   14983              :     // Determine decay curve - Pulse of radiant heat which is about 5% of lighting and
   14984              :     //   equipment input for a single timestep a few hours after
   14985              :     //   cooling or heat is scheduled on for each zone [radiantPulseTimestep(iZone)].
   14986              :     //   The radiant heat received on each wall is stored [radiantPulseReceived(jSurface)].
   14987              :     //   The load convected in the normal case [loadConvectedNormal(jSurface, kTime, mode)]
   14988              :     //   and in the case with the pulse [loadConvectedWithPulse(jSurface, kTime, mode)].
   14989              :     //   The difference divided by the pulse received by each surface
   14990              :     //   [radiantPulseReceived(jSurface)] is stored in [decayCurve(jSurface,kTime,mode)].
   14991              :     //
   14992              :     // Determine delayed loads - From the last timestep of the peak load on the zone
   14993              :     //   working backwards any radiant heat that was absorbed by the wall from an internal gain
   14994              :     //   or solar gain is multiplied by the appropriate timesteps in the decay curve
   14995              :     //   [decayCurve(jSurface,kTime,mode)] for timesteps that make up
   14996              :     //   the number of averaged timesteps are used to determine the peak load
   14997              :     //   [NumTimeStepsInAvg]. The sum for all surfaces in the zone are added together to
   14998              :     //   determine the delayed load.
   14999              :     //
   15000              :     // Determine instant loads - Average the convective portion of the internal gains
   15001              :     //   for the timesteps made up of the peak load period. Average those across the peak
   15002              :     //   load period.
   15003              :     //
   15004              :     // The comments from ComputeDelayedComponents which was incorporated into this routine follow:
   15005              :     //
   15006              :     // PURPOSE OF THIS SUBROUTINE:
   15007              :     //   For load component report, convert the sequence of radiant gains
   15008              :     //   for people and equipment and other internal loads into convective
   15009              :     //   gains based on the decay curves.
   15010              :     //
   15011              :     // METHODOLOGY EMPLOYED:
   15012              :     //   For each step of sequence from each design day, compute the
   15013              :     //   contributions from previous timesteps multiplied by the decay
   15014              :     //   curve. Rather than store every internal load's radiant contribution
   15015              :     //   to each surface, the EnclRadThermAbsMult and ITABSF sequences were also stored
   15016              :     //   which allocates the total radiant to each surface in the zone. The
   15017              :     //   formula used is:
   15018              :     //       SurfQRadThermInAbs(SurfNum) = QL(NZ) * EnclRadThermAbsMult(NZ) * SurfAbsThermalInt(SurfNum)
   15019              : 
   15020           40 :     auto &ort = state.dataOutRptTab;
   15021           46 :     if (!((ort->displayZoneComponentLoadSummary || ort->displayAirLoopComponentLoadSummary || ort->displayFacilityComponentLoadSummary) &&
   15022            6 :           state.dataGlobal->CompLoadReportIsReq)) {
   15023           34 :         return;
   15024              :     }
   15025              : 
   15026            6 :     auto &NumPrimaryAirSys = state.dataHVACGlobal->NumPrimaryAirSys;
   15027              : 
   15028            6 :     auto const &CalcFinalFacilitySizing(state.dataSize->CalcFinalFacilitySizing);
   15029              : 
   15030              :     int coolDesSelected;
   15031              :     int timeCoolMax;
   15032              :     int heatDesSelected;
   15033              :     int timeHeatMax;
   15034              : 
   15035              :     // Delayed components are moved into this function so that we can calculate them one zone at a time
   15036              :     // with Array1D
   15037            6 :     Array1D<Real64> peopleDelaySeq;
   15038            6 :     Array1D<Real64> lightDelaySeq;
   15039            6 :     Array1D<Real64> equipDelaySeq;
   15040            6 :     Array1D<Real64> hvacLossDelaySeq;
   15041            6 :     Array1D<Real64> powerGenDelaySeq;
   15042            6 :     Array1D<Real64> feneSolarDelaySeq;
   15043            6 :     Array2D<Real64> surfDelaySeq;
   15044              : 
   15045            6 :     Array1D<CompLoadTablesType> SpaceHeatCompLoadTables; // for space level component load summary output tables
   15046            6 :     Array1D<CompLoadTablesType> SpaceCoolCompLoadTables;
   15047              : 
   15048            6 :     Array1D<CompLoadTablesType> ZoneHeatCompLoadTables; // for zone level component load summary output tables
   15049            6 :     Array1D<CompLoadTablesType> ZoneCoolCompLoadTables;
   15050              : 
   15051            6 :     Array1D<CompLoadTablesType> AirLoopHeatCompLoadTables; // for airloop level component load summary output tables
   15052            6 :     Array1D<CompLoadTablesType> AirLoopCoolCompLoadTables;
   15053            6 :     Array1D<CompLoadTablesType> AirLoopZonesHeatCompLoadTables; // zone results used for airloop report - never directly output
   15054            6 :     Array1D<CompLoadTablesType> AirLoopZonesCoolCompLoadTables;
   15055              : 
   15056            6 :     CompLoadTablesType FacilityHeatCompLoadTables; // for facility level component load summary output tables
   15057            6 :     CompLoadTablesType FacilityCoolCompLoadTables;
   15058            6 :     Array1D<CompLoadTablesType> FacilityZonesHeatCompLoadTables; // zone results used for facility report - never directly output
   15059            6 :     Array1D<CompLoadTablesType> FacilityZonesCoolCompLoadTables;
   15060              : 
   15061              :     // Jan 2021: The following variable is redundant in the original code, deleting the line
   15062              :     // CompLoadTablesType curCompLoadTable; // active component load table
   15063              : 
   15064           13 :     for (int iUnitSystem = 0; iUnitSystem <= 1; iUnitSystem++) {
   15065           12 :         UnitsStyle unitsStyle_cur = ort->unitsStyle;
   15066           12 :         bool produceTabular = true;
   15067           12 :         bool produceSQLite = false;
   15068           12 :         if (produceDualUnitsFlags(iUnitSystem, ort->unitsStyle, ort->unitsStyle_SQLite, unitsStyle_cur, produceTabular, produceSQLite)) {
   15069            5 :             break;
   15070              :         }
   15071              : 
   15072            7 :         Real64 timeStepsInDay = state.dataGlobal->TimeStepsInHour * Constant::rHoursInDay;
   15073              : 
   15074              :         // adjusted initialization location to after variable declaration for loops 2021-01-11
   15075            7 :         peopleDelaySeq.dimension(timeStepsInDay, 0.0);
   15076            7 :         peopleDelaySeq = 0.0;
   15077            7 :         lightDelaySeq.allocate(timeStepsInDay);
   15078            7 :         lightDelaySeq = 0.0;
   15079            7 :         equipDelaySeq.allocate(timeStepsInDay);
   15080            7 :         equipDelaySeq = 0.0;
   15081            7 :         hvacLossDelaySeq.allocate(timeStepsInDay);
   15082            7 :         hvacLossDelaySeq = 0.0;
   15083            7 :         powerGenDelaySeq.allocate(timeStepsInDay);
   15084            7 :         powerGenDelaySeq = 0.0;
   15085            7 :         feneSolarDelaySeq.allocate(timeStepsInDay);
   15086            7 :         feneSolarDelaySeq = 0.0;
   15087            7 :         surfDelaySeq.allocate(timeStepsInDay, state.dataSurface->TotSurfaces);
   15088            7 :         surfDelaySeq = 0.0;
   15089              : 
   15090              :         // initialize arrays
   15091            7 :         if (ort->displayZoneComponentLoadSummary) {
   15092            5 :             if (state.dataHeatBal->doSpaceHeatBalanceSizing) {
   15093            0 :                 SpaceHeatCompLoadTables.allocate(state.dataGlobal->numSpaces);
   15094            0 :                 for (auto &e : SpaceHeatCompLoadTables) {
   15095            0 :                     e.cells.allocate(LoadCompCol::PerArea, LoadCompRow::GrdTot);
   15096            0 :                     e.cells = 0.;
   15097            0 :                     e.cellUsed.allocate(LoadCompCol::PerArea, LoadCompRow::GrdTot);
   15098            0 :                     e.cellUsed = false;
   15099              :                 }
   15100            0 :                 SpaceCoolCompLoadTables.allocate(state.dataGlobal->numSpaces);
   15101            0 :                 for (auto &e : SpaceCoolCompLoadTables) {
   15102            0 :                     e.cells.allocate(LoadCompCol::PerArea, LoadCompRow::GrdTot);
   15103            0 :                     e.cells = 0.;
   15104            0 :                     e.cellUsed.allocate(LoadCompCol::PerArea, LoadCompRow::GrdTot);
   15105            0 :                     e.cellUsed = false;
   15106              :                 }
   15107              :             }
   15108            5 :             ZoneHeatCompLoadTables.allocate(state.dataGlobal->NumOfZones);
   15109           11 :             for (auto &e : ZoneHeatCompLoadTables) {
   15110            6 :                 e.cells.allocate(LoadCompCol::PerArea, LoadCompRow::GrdTot);
   15111            6 :                 e.cells = 0.;
   15112            6 :                 e.cellUsed.allocate(LoadCompCol::PerArea, LoadCompRow::GrdTot);
   15113            6 :                 e.cellUsed = false;
   15114              :             }
   15115            5 :             ZoneCoolCompLoadTables.allocate(state.dataGlobal->NumOfZones);
   15116           11 :             for (auto &e : ZoneCoolCompLoadTables) {
   15117            6 :                 e.cells.allocate(LoadCompCol::PerArea, LoadCompRow::GrdTot);
   15118            6 :                 e.cells = 0.;
   15119            6 :                 e.cellUsed.allocate(LoadCompCol::PerArea, LoadCompRow::GrdTot);
   15120            6 :                 e.cellUsed = false;
   15121              :             }
   15122              :         }
   15123            7 :         if (ort->displayAirLoopComponentLoadSummary) {
   15124            7 :             AirLoopHeatCompLoadTables.allocate(NumPrimaryAirSys);
   15125           13 :             for (auto &e : AirLoopHeatCompLoadTables) {
   15126            6 :                 e.cells.allocate(LoadCompCol::PerArea, LoadCompRow::GrdTot);
   15127            6 :                 e.cells = 0.;
   15128            6 :                 e.cellUsed.allocate(LoadCompCol::PerArea, LoadCompRow::GrdTot);
   15129            6 :                 e.cellUsed = false;
   15130            6 :                 e.zoneIndices.allocate(state.dataGlobal->NumOfZones); // only need to allocate this for the AirLoop
   15131            6 :                 e.zoneIndices = 0;
   15132              :             }
   15133            7 :             AirLoopCoolCompLoadTables.allocate(NumPrimaryAirSys);
   15134           13 :             for (auto &e : AirLoopCoolCompLoadTables) {
   15135            6 :                 e.cells.allocate(LoadCompCol::PerArea, LoadCompRow::GrdTot);
   15136            6 :                 e.cells = 0.;
   15137            6 :                 e.cellUsed.allocate(LoadCompCol::PerArea, LoadCompRow::GrdTot);
   15138            6 :                 e.cellUsed = false;
   15139            6 :                 e.zoneIndices.allocate(state.dataGlobal->NumOfZones); // only need to allocate this for the AirLoop
   15140            6 :                 e.zoneIndices = 0;
   15141              :             }
   15142            7 :             AirLoopZonesHeatCompLoadTables.allocate(state.dataGlobal->NumOfZones);
   15143           13 :             for (auto &e : AirLoopZonesHeatCompLoadTables) {
   15144            6 :                 e.cells.allocate(LoadCompCol::PerArea, LoadCompRow::GrdTot);
   15145            6 :                 e.cells = 0.;
   15146            6 :                 e.cellUsed.allocate(LoadCompCol::PerArea, LoadCompRow::GrdTot);
   15147            6 :                 e.cellUsed = false;
   15148              :             }
   15149            7 :             AirLoopZonesCoolCompLoadTables.allocate(state.dataGlobal->NumOfZones);
   15150           13 :             for (auto &e : AirLoopZonesCoolCompLoadTables) {
   15151            6 :                 e.cells.allocate(LoadCompCol::PerArea, LoadCompRow::GrdTot);
   15152            6 :                 e.cells = 0.;
   15153            6 :                 e.cellUsed.allocate(LoadCompCol::PerArea, LoadCompRow::GrdTot);
   15154            6 :                 e.cellUsed = false;
   15155              :             }
   15156              :         }
   15157            7 :         if (ort->displayFacilityComponentLoadSummary) {
   15158            5 :             FacilityHeatCompLoadTables.cells.allocate(LoadCompCol::PerArea, LoadCompRow::GrdTot);
   15159            5 :             FacilityHeatCompLoadTables.cells = 0.;
   15160            5 :             FacilityHeatCompLoadTables.cellUsed.allocate(LoadCompCol::PerArea, LoadCompRow::GrdTot);
   15161            5 :             FacilityHeatCompLoadTables.cellUsed = false;
   15162              : 
   15163            5 :             FacilityCoolCompLoadTables.cells.allocate(LoadCompCol::PerArea, LoadCompRow::GrdTot);
   15164            5 :             FacilityCoolCompLoadTables.cells = 0.;
   15165            5 :             FacilityCoolCompLoadTables.cellUsed.allocate(LoadCompCol::PerArea, LoadCompRow::GrdTot);
   15166            5 :             FacilityCoolCompLoadTables.cellUsed = false;
   15167              : 
   15168            5 :             FacilityZonesHeatCompLoadTables.allocate(state.dataGlobal->NumOfZones);
   15169           11 :             for (auto &e : FacilityZonesHeatCompLoadTables) {
   15170            6 :                 e.cells.allocate(LoadCompCol::PerArea, LoadCompRow::GrdTot);
   15171            6 :                 e.cells = 0.;
   15172            6 :                 e.cellUsed.allocate(LoadCompCol::PerArea, LoadCompRow::GrdTot);
   15173            6 :                 e.cellUsed = false;
   15174              :             }
   15175            5 :             FacilityZonesCoolCompLoadTables.allocate(state.dataGlobal->NumOfZones);
   15176           11 :             for (auto &e : FacilityZonesCoolCompLoadTables) {
   15177            6 :                 e.cells.allocate(LoadCompCol::PerArea, LoadCompRow::GrdTot);
   15178            6 :                 e.cells = 0.;
   15179            6 :                 e.cellUsed.allocate(LoadCompCol::PerArea, LoadCompRow::GrdTot);
   15180            6 :                 e.cellUsed = false;
   15181              :             }
   15182              :         }
   15183              : 
   15184              :         // get the zone areas needed later
   15185            7 :         Array1D<ZompComponentAreasType> spaceComponentAreas;
   15186            7 :         Array1D<ZompComponentAreasType> ZoneComponentAreas;
   15187            7 :         ZoneComponentAreas.allocate(state.dataGlobal->NumOfZones);
   15188            7 :         if (state.dataHeatBal->doSpaceHeatBalanceSizing) {
   15189            0 :             spaceComponentAreas.allocate(state.dataGlobal->numSpaces);
   15190              :         }
   15191            7 :         GetZoneComponentAreas(state, ZoneComponentAreas, spaceComponentAreas);
   15192              : 
   15193              :         // ZoneComponentLoadSummary
   15194            7 :         if (ort->displayZoneComponentLoadSummary) {
   15195            5 :             if (state.dataHeatBal->doSpaceHeatBalanceSizing) {
   15196            0 :                 for (int iSpace = 1; iSpace <= state.dataGlobal->numSpaces; ++iSpace) {
   15197              :                     // Yes, check if the zone is controlled, not the space for this
   15198            0 :                     int zoneNum = state.dataHeatBal->space(iSpace).zoneNum;
   15199            0 :                     if (!state.dataZoneEquip->ZoneEquipConfig(zoneNum).IsControlled) {
   15200            0 :                         continue;
   15201              :                     }
   15202            0 :                     if (allocated(state.dataSize->CalcFinalSpaceSizing)) {
   15203            0 :                         computeSpaceZoneCompLoads(state,
   15204            0 :                                                   state.dataSize->CalcFinalSpaceSizing(iSpace),
   15205              :                                                   SpaceCoolCompLoadTables(iSpace),
   15206              :                                                   SpaceHeatCompLoadTables(iSpace),
   15207              :                                                   peopleDelaySeq,
   15208              :                                                   equipDelaySeq,
   15209              :                                                   hvacLossDelaySeq,
   15210              :                                                   powerGenDelaySeq,
   15211              :                                                   lightDelaySeq,
   15212              :                                                   feneSolarDelaySeq,
   15213            0 :                                                   ort->spCompLoads,
   15214              :                                                   surfDelaySeq,
   15215              :                                                   spaceComponentAreas(iSpace),
   15216              :                                                   zoneNum,
   15217              :                                                   iSpace);
   15218              :                     }
   15219              :                 }
   15220              :             }
   15221           11 :             for (int iZone = 1; iZone <= state.dataGlobal->NumOfZones; ++iZone) {
   15222            6 :                 if (!state.dataZoneEquip->ZoneEquipConfig(iZone).IsControlled) {
   15223            0 :                     continue;
   15224              :                 }
   15225            6 :                 if (allocated(state.dataSize->CalcFinalZoneSizing)) {
   15226           12 :                     computeSpaceZoneCompLoads(state,
   15227            6 :                                               state.dataSize->CalcFinalZoneSizing(iZone),
   15228              :                                               ZoneCoolCompLoadTables(iZone),
   15229              :                                               ZoneHeatCompLoadTables(iZone),
   15230              :                                               peopleDelaySeq,
   15231              :                                               equipDelaySeq,
   15232              :                                               hvacLossDelaySeq,
   15233              :                                               powerGenDelaySeq,
   15234              :                                               lightDelaySeq,
   15235              :                                               feneSolarDelaySeq,
   15236            6 :                                               ort->znCompLoads,
   15237              :                                               surfDelaySeq,
   15238              :                                               ZoneComponentAreas(iZone),
   15239              :                                               iZone);
   15240              :                 }
   15241              :             }
   15242              :             // We delay the potential application of SI to IP conversion and actual output until after both the
   15243              :             // AirLoopComponentLoadSummary and FacilityComponentLoadSummary have been processed because below we try
   15244              :             // to retrieve the info directly when the timestamp would match (cf #7356), and if we converted right
   15245              :             // now, we would apply the conversion twice
   15246              :         }
   15247              : 
   15248              :         // AirLoopComponentLoadSummary
   15249            7 :         if (ort->displayAirLoopComponentLoadSummary && NumPrimaryAirSys > 0) {
   15250            6 :             Array1D_int zoneToAirLoopCool;
   15251            6 :             zoneToAirLoopCool.dimension(state.dataGlobal->NumOfZones);
   15252            6 :             Array1D_int zoneToAirLoopHeat;
   15253            6 :             zoneToAirLoopHeat.dimension(state.dataGlobal->NumOfZones);
   15254              :             // 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
   15255              :             // (regardless of "heated" or "cooled" zone status)
   15256           12 :             for (int iAirLoop = 1; iAirLoop <= NumPrimaryAirSys; ++iAirLoop) {
   15257            6 :                 auto const &finalSysSizing = state.dataSize->FinalSysSizing(iAirLoop);
   15258            6 :                 auto const &sysSizPeakDDNum = state.dataSize->SysSizPeakDDNum(iAirLoop);
   15259            6 :                 zoneToAirLoopCool = 0;
   15260            6 :                 zoneToAirLoopHeat = 0;
   15261            6 :                 if (finalSysSizing.loadSizingType == DataSizing::LoadSizing::Sensible) {
   15262            1 :                     coolDesSelected = sysSizPeakDDNum.SensCoolPeakDD;
   15263            1 :                     if (coolDesSelected != 0) {
   15264            1 :                         timeCoolMax = sysSizPeakDDNum.TimeStepAtSensCoolPk(coolDesSelected);
   15265              :                     } else {
   15266            0 :                         timeCoolMax = 0;
   15267              :                     }
   15268            5 :                 } else if (finalSysSizing.loadSizingType == DataSizing::LoadSizing::Ventilation) {
   15269            1 :                     coolDesSelected = sysSizPeakDDNum.CoolFlowPeakDD;
   15270            1 :                     if (coolDesSelected != 0) {
   15271            1 :                         timeCoolMax = sysSizPeakDDNum.TimeStepAtCoolFlowPk(coolDesSelected);
   15272              :                     } else {
   15273            0 :                         timeCoolMax = 0;
   15274              :                     }
   15275              :                 } else {
   15276            4 :                     coolDesSelected = sysSizPeakDDNum.TotCoolPeakDD;
   15277            4 :                     if (coolDesSelected != 0) {
   15278            2 :                         timeCoolMax = sysSizPeakDDNum.TimeStepAtTotCoolPk(coolDesSelected);
   15279              :                     } else {
   15280            2 :                         timeCoolMax = 0;
   15281              :                     }
   15282              :                 }
   15283            6 :                 heatDesSelected = sysSizPeakDDNum.HeatPeakDD;
   15284            6 :                 if (heatDesSelected != 0) {
   15285            3 :                     timeHeatMax = sysSizPeakDDNum.TimeStepAtHeatPk(heatDesSelected);
   15286              :                 } else {
   15287            3 :                     timeHeatMax = 0;
   15288              :                 }
   15289              : 
   15290            6 :                 int NumZonesCooled = state.dataAirLoop->AirToZoneNodeInfo(iAirLoop).NumZonesCooled;
   15291           11 :                 for (int ZonesCooledNum = 1; ZonesCooledNum <= NumZonesCooled; ++ZonesCooledNum) { // loop over cooled zones
   15292            5 :                     int CtrlZoneNum = state.dataAirLoop->AirToZoneNodeInfo(iAirLoop).CoolCtrlZoneNums(ZonesCooledNum);
   15293            5 :                     zoneToAirLoopCool(CtrlZoneNum) = iAirLoop;
   15294            5 :                     AirLoopZonesCoolCompLoadTables(CtrlZoneNum).desDayNum = coolDesSelected;
   15295            5 :                     AirLoopZonesCoolCompLoadTables(CtrlZoneNum).timeStepMax = timeCoolMax;
   15296            5 :                     zoneToAirLoopHeat(CtrlZoneNum) = iAirLoop;
   15297            5 :                     AirLoopZonesHeatCompLoadTables(CtrlZoneNum).desDayNum = heatDesSelected;
   15298            5 :                     AirLoopZonesHeatCompLoadTables(CtrlZoneNum).timeStepMax = timeHeatMax;
   15299              :                 }
   15300            6 :                 int NumZonesHeated = state.dataAirLoop->AirToZoneNodeInfo(iAirLoop).NumZonesHeated;
   15301            7 :                 for (int ZonesHeatedNum = 1; ZonesHeatedNum <= NumZonesHeated; ++ZonesHeatedNum) { // loop over heated zones
   15302            1 :                     int CtrlZoneNum = state.dataAirLoop->AirToZoneNodeInfo(iAirLoop).HeatCtrlZoneNums(ZonesHeatedNum);
   15303            1 :                     zoneToAirLoopCool(CtrlZoneNum) = iAirLoop;
   15304            1 :                     AirLoopZonesCoolCompLoadTables(CtrlZoneNum).desDayNum = coolDesSelected;
   15305            1 :                     AirLoopZonesCoolCompLoadTables(CtrlZoneNum).timeStepMax = timeCoolMax;
   15306            1 :                     zoneToAirLoopHeat(CtrlZoneNum) = iAirLoop;
   15307            1 :                     AirLoopZonesHeatCompLoadTables(CtrlZoneNum).desDayNum = heatDesSelected;
   15308            1 :                     AirLoopZonesHeatCompLoadTables(CtrlZoneNum).timeStepMax = timeHeatMax;
   15309              :                 }
   15310              : 
   15311              :                 // now go through the zones and if design day and time of max match the previously calculated zone results use those otherwise
   15312              :                 // compute them for specific design day and time of max
   15313           11 :                 for (int iZone = 1; iZone <= state.dataGlobal->NumOfZones; ++iZone) {
   15314            5 :                     if (!state.dataZoneEquip->ZoneEquipConfig(iZone).IsControlled) {
   15315            0 :                         continue;
   15316              :                     }
   15317            5 :                     auto &airLoopZonesCoolCompLoadTables = AirLoopZonesCoolCompLoadTables(iZone);
   15318            5 :                     auto &airLoopZonesHeatCompLoadTables = AirLoopZonesHeatCompLoadTables(iZone);
   15319              :                     // The ZoneCoolCompLoadTables already hasn't gotten a potential IP conversion yet, so we won't convert it twice.
   15320            5 :                     if (ort->displayZoneComponentLoadSummary &&
   15321           10 :                         (airLoopZonesCoolCompLoadTables.desDayNum == ZoneCoolCompLoadTables(iZone).desDayNum) &&
   15322            5 :                         (airLoopZonesCoolCompLoadTables.timeStepMax == ZoneCoolCompLoadTables(iZone).timeStepMax)) {
   15323            4 :                         airLoopZonesCoolCompLoadTables = ZoneCoolCompLoadTables(iZone);
   15324              :                     } else {
   15325            1 :                         coolDesSelected = airLoopZonesCoolCompLoadTables.desDayNum;
   15326            1 :                         timeCoolMax = airLoopZonesCoolCompLoadTables.timeStepMax;
   15327              : 
   15328            1 :                         GetDelaySequences(state,
   15329              :                                           coolDesSelected,
   15330              :                                           true,
   15331              :                                           iZone,
   15332              :                                           peopleDelaySeq,
   15333              :                                           equipDelaySeq,
   15334              :                                           hvacLossDelaySeq,
   15335              :                                           powerGenDelaySeq,
   15336              :                                           lightDelaySeq,
   15337              :                                           feneSolarDelaySeq,
   15338            1 :                                           ort->znCompLoads,
   15339              :                                           surfDelaySeq);
   15340            1 :                         ComputeTableBodyUsingMovingAvg(state,
   15341            1 :                                                        airLoopZonesCoolCompLoadTables.cells,
   15342            1 :                                                        airLoopZonesCoolCompLoadTables.cellUsed,
   15343              :                                                        coolDesSelected,
   15344              :                                                        timeCoolMax,
   15345              :                                                        iZone,
   15346              :                                                        peopleDelaySeq,
   15347              :                                                        equipDelaySeq,
   15348              :                                                        hvacLossDelaySeq,
   15349              :                                                        powerGenDelaySeq,
   15350              :                                                        lightDelaySeq,
   15351              :                                                        feneSolarDelaySeq,
   15352            1 :                                                        ort->znCompLoads,
   15353              :                                                        surfDelaySeq);
   15354            1 :                         CollectPeakZoneConditions(state, airLoopZonesCoolCompLoadTables, coolDesSelected, timeCoolMax, iZone, true);
   15355            1 :                         AddAreaColumnForZone(ZoneComponentAreas(iZone), airLoopZonesCoolCompLoadTables);
   15356              :                     }
   15357            5 :                     if (ort->displayZoneComponentLoadSummary &&
   15358            9 :                         (airLoopZonesHeatCompLoadTables.desDayNum == ZoneHeatCompLoadTables(iZone).desDayNum) &&
   15359            4 :                         (airLoopZonesHeatCompLoadTables.timeStepMax == ZoneHeatCompLoadTables(iZone).timeStepMax)) {
   15360            1 :                         airLoopZonesHeatCompLoadTables = ZoneHeatCompLoadTables(iZone);
   15361              :                     } else {
   15362            4 :                         heatDesSelected = airLoopZonesHeatCompLoadTables.desDayNum;
   15363            4 :                         timeHeatMax = airLoopZonesHeatCompLoadTables.timeStepMax;
   15364              : 
   15365            4 :                         GetDelaySequences(state,
   15366              :                                           heatDesSelected,
   15367              :                                           false,
   15368              :                                           iZone,
   15369              :                                           peopleDelaySeq,
   15370              :                                           equipDelaySeq,
   15371              :                                           hvacLossDelaySeq,
   15372              :                                           powerGenDelaySeq,
   15373              :                                           lightDelaySeq,
   15374              :                                           feneSolarDelaySeq,
   15375            4 :                                           ort->znCompLoads,
   15376              :                                           surfDelaySeq);
   15377            4 :                         ComputeTableBodyUsingMovingAvg(state,
   15378            4 :                                                        airLoopZonesHeatCompLoadTables.cells,
   15379            4 :                                                        airLoopZonesHeatCompLoadTables.cellUsed,
   15380              :                                                        heatDesSelected,
   15381              :                                                        timeHeatMax,
   15382              :                                                        iZone,
   15383              :                                                        peopleDelaySeq,
   15384              :                                                        equipDelaySeq,
   15385              :                                                        hvacLossDelaySeq,
   15386              :                                                        powerGenDelaySeq,
   15387              :                                                        lightDelaySeq,
   15388              :                                                        feneSolarDelaySeq,
   15389            4 :                                                        ort->znCompLoads,
   15390              :                                                        surfDelaySeq);
   15391            4 :                         CollectPeakZoneConditions(state, airLoopZonesHeatCompLoadTables, heatDesSelected, timeHeatMax, iZone, false);
   15392            4 :                         AddAreaColumnForZone(ZoneComponentAreas(iZone), airLoopZonesHeatCompLoadTables);
   15393              :                     }
   15394              :                 }
   15395              :                 // combine the zones for each air loop
   15396              : 
   15397            6 :                 auto &airLoopCoolTable = AirLoopCoolCompLoadTables(iAirLoop);
   15398            6 :                 auto &airLoopHeatTable = AirLoopHeatCompLoadTables(iAirLoop);
   15399           11 :                 for (int iZone = 1; iZone <= state.dataGlobal->NumOfZones; ++iZone) {
   15400            5 :                     auto const &thisZone = state.dataHeatBal->Zone(iZone);
   15401              : 
   15402            5 :                     if (zoneToAirLoopCool(iZone) == iAirLoop) {
   15403            5 :                         Real64 mult = thisZone.Multiplier * thisZone.ListMultiplier;
   15404            5 :                         if (mult == 0.0) {
   15405            0 :                             mult = 1.0;
   15406              :                         }
   15407            5 :                         CombineLoadCompResults(airLoopCoolTable, AirLoopZonesCoolCompLoadTables(iZone), mult);
   15408              :                     }
   15409            5 :                     if (zoneToAirLoopHeat(iZone) == iAirLoop) {
   15410            5 :                         Real64 mult = thisZone.Multiplier * thisZone.ListMultiplier;
   15411            5 :                         if (mult == 0.0) {
   15412            0 :                             mult = 1.0;
   15413              :                         }
   15414            5 :                         CombineLoadCompResults(airLoopHeatTable, AirLoopZonesHeatCompLoadTables(iZone), mult);
   15415              :                     }
   15416              :                 }
   15417           10 :                 for (int SysSizIndex = 1; SysSizIndex <= state.dataSize->NumSysSizInput; ++SysSizIndex) {
   15418            4 :                     if (state.dataSize->SysSizInput(SysSizIndex).AirLoopNum != iAirLoop) {
   15419            0 :                         continue;
   15420              :                     }
   15421            4 :                     if (state.dataSize->SysSizInput(SysSizIndex).SizingOption == DataSizing::SizingConcurrence::Coincident) {
   15422            0 :                         airLoopCoolTable.peakDesSensLoad = finalSysSizing.SysCoolCoinSpaceSens;
   15423            0 :                         airLoopCoolTable.designPeakLoad = finalSysSizing.SysDesCoolLoad;
   15424              : 
   15425            0 :                         airLoopHeatTable.peakDesSensLoad = -finalSysSizing.SysHeatCoinSpaceSens;
   15426            0 :                         airLoopHeatTable.designPeakLoad = -finalSysSizing.SysDesHeatLoad;
   15427              : 
   15428            0 :                         airLoopCoolTable.diffPeakEst = airLoopCoolTable.peakDesSensLoad - airLoopCoolTable.estInstDelSensLoad;
   15429            0 :                         airLoopCoolTable.diffDesignPeak = airLoopCoolTable.designPeakLoad - airLoopCoolTable.peakDesSensLoad;
   15430              : 
   15431            0 :                         airLoopHeatTable.diffPeakEst = airLoopHeatTable.peakDesSensLoad - airLoopHeatTable.estInstDelSensLoad;
   15432            0 :                         airLoopHeatTable.diffDesignPeak = airLoopHeatTable.designPeakLoad - airLoopHeatTable.peakDesSensLoad;
   15433              :                     }
   15434              :                 }
   15435              : 
   15436              :                 // Coincident and NonCoincident alike
   15437            6 :                 airLoopCoolTable.mixAirTemp = finalSysSizing.MixTempAtCoolPeak;
   15438            6 :                 airLoopHeatTable.mixAirTemp = finalSysSizing.HeatMixTemp;
   15439              : 
   15440            6 :                 ComputeEngineeringChecks(airLoopCoolTable);
   15441            6 :                 ComputeEngineeringChecks(airLoopHeatTable);
   15442              : 
   15443            6 :                 AddTotalRowsForLoadSummary(airLoopCoolTable);
   15444            6 :                 AddTotalRowsForLoadSummary(airLoopHeatTable);
   15445              : 
   15446            6 :                 ComputePeakDifference(airLoopCoolTable);
   15447            6 :                 ComputePeakDifference(airLoopHeatTable);
   15448              : 
   15449            6 :                 CreateListOfZonesForAirLoop(state, airLoopCoolTable, zoneToAirLoopCool, iAirLoop);
   15450            6 :                 CreateListOfZonesForAirLoop(state, airLoopHeatTable, zoneToAirLoopHeat, iAirLoop);
   15451              : 
   15452            6 :                 LoadSummaryUnitConversion(state, airLoopCoolTable, unitsStyle_cur);
   15453            6 :                 LoadSummaryUnitConversion(state, airLoopHeatTable, unitsStyle_cur);
   15454              : 
   15455            6 :                 OutputCompLoadSummary(
   15456              :                     state, OutputType::AirLoop, airLoopCoolTable, airLoopHeatTable, iAirLoop, unitsStyle_cur, produceTabular, produceSQLite);
   15457              :             }
   15458            6 :         }
   15459              : 
   15460              :         // FacilityComponentLoadSummary
   15461            7 :         if (ort->displayFacilityComponentLoadSummary) {
   15462              : 
   15463            5 :             coolDesSelected = CalcFinalFacilitySizing.CoolDDNum;
   15464            5 :             timeCoolMax = CalcFinalFacilitySizing.TimeStepNumAtCoolMax;
   15465              : 
   15466            5 :             heatDesSelected = CalcFinalFacilitySizing.HeatDDNum;
   15467            5 :             timeHeatMax = CalcFinalFacilitySizing.TimeStepNumAtHeatMax;
   15468              : 
   15469           11 :             for (int iZone = 1; iZone <= state.dataGlobal->NumOfZones; ++iZone) {
   15470            6 :                 if (!state.dataZoneEquip->ZoneEquipConfig(iZone).IsControlled) {
   15471            0 :                     continue;
   15472              :                 }
   15473            6 :                 auto &facilityZonesCoolCompLoadTables = FacilityZonesCoolCompLoadTables(iZone);
   15474            6 :                 auto &facilityZonesHeatCompLoadTables = FacilityZonesHeatCompLoadTables(iZone);
   15475            6 :                 auto const &thisZone = state.dataHeatBal->Zone(iZone);
   15476              : 
   15477            6 :                 Real64 mult = thisZone.Multiplier * thisZone.ListMultiplier;
   15478            6 :                 if (mult == 0.0) {
   15479            0 :                     mult = 1.0;
   15480              :                 }
   15481              : 
   15482              :                 // The ZoneCoolCompLoadTables already hasn't gotten a potential IP conversion yet, so we won't convert it twice.
   15483           12 :                 if (ort->displayZoneComponentLoadSummary && (coolDesSelected == ZoneCoolCompLoadTables(iZone).desDayNum) &&
   15484            6 :                     (timeCoolMax == ZoneCoolCompLoadTables(iZone).timeStepMax)) {
   15485            2 :                     facilityZonesCoolCompLoadTables = ZoneCoolCompLoadTables(iZone);
   15486              :                 } else {
   15487            4 :                     GetDelaySequences(state,
   15488              :                                       coolDesSelected,
   15489              :                                       true,
   15490              :                                       iZone,
   15491              :                                       peopleDelaySeq,
   15492              :                                       equipDelaySeq,
   15493              :                                       hvacLossDelaySeq,
   15494              :                                       powerGenDelaySeq,
   15495              :                                       lightDelaySeq,
   15496              :                                       feneSolarDelaySeq,
   15497            4 :                                       ort->znCompLoads,
   15498              :                                       surfDelaySeq);
   15499            4 :                     ComputeTableBodyUsingMovingAvg(state,
   15500            4 :                                                    facilityZonesCoolCompLoadTables.cells,
   15501            4 :                                                    facilityZonesCoolCompLoadTables.cellUsed,
   15502              :                                                    coolDesSelected,
   15503              :                                                    timeCoolMax,
   15504              :                                                    iZone,
   15505              :                                                    peopleDelaySeq,
   15506              :                                                    equipDelaySeq,
   15507              :                                                    hvacLossDelaySeq,
   15508              :                                                    powerGenDelaySeq,
   15509              :                                                    lightDelaySeq,
   15510              :                                                    feneSolarDelaySeq,
   15511            4 :                                                    ort->znCompLoads,
   15512              :                                                    surfDelaySeq);
   15513            4 :                     CollectPeakZoneConditions(state, facilityZonesCoolCompLoadTables, coolDesSelected, timeCoolMax, iZone, true);
   15514            4 :                     AddAreaColumnForZone(ZoneComponentAreas(iZone), facilityZonesCoolCompLoadTables);
   15515              :                 }
   15516            6 :                 facilityZonesCoolCompLoadTables.timeStepMax = timeCoolMax;
   15517            6 :                 facilityZonesCoolCompLoadTables.desDayNum = coolDesSelected;
   15518            6 :                 CombineLoadCompResults(FacilityCoolCompLoadTables, facilityZonesCoolCompLoadTables, mult);
   15519              : 
   15520           11 :                 if (ort->displayZoneComponentLoadSummary && (heatDesSelected == ZoneHeatCompLoadTables(iZone).desDayNum) &&
   15521            5 :                     (timeHeatMax == ZoneHeatCompLoadTables(iZone).timeStepMax)) {
   15522            3 :                     facilityZonesHeatCompLoadTables = ZoneHeatCompLoadTables(iZone);
   15523              :                 } else {
   15524            3 :                     GetDelaySequences(state,
   15525              :                                       heatDesSelected,
   15526              :                                       false,
   15527              :                                       iZone,
   15528              :                                       peopleDelaySeq,
   15529              :                                       equipDelaySeq,
   15530              :                                       hvacLossDelaySeq,
   15531              :                                       powerGenDelaySeq,
   15532              :                                       lightDelaySeq,
   15533              :                                       feneSolarDelaySeq,
   15534            3 :                                       ort->znCompLoads,
   15535              :                                       surfDelaySeq);
   15536            3 :                     ComputeTableBodyUsingMovingAvg(state,
   15537            3 :                                                    facilityZonesHeatCompLoadTables.cells,
   15538            3 :                                                    facilityZonesHeatCompLoadTables.cellUsed,
   15539              :                                                    heatDesSelected,
   15540              :                                                    timeHeatMax,
   15541              :                                                    iZone,
   15542              :                                                    peopleDelaySeq,
   15543              :                                                    equipDelaySeq,
   15544              :                                                    hvacLossDelaySeq,
   15545              :                                                    powerGenDelaySeq,
   15546              :                                                    lightDelaySeq,
   15547              :                                                    feneSolarDelaySeq,
   15548            3 :                                                    ort->znCompLoads,
   15549              :                                                    surfDelaySeq);
   15550            3 :                     CollectPeakZoneConditions(state, facilityZonesHeatCompLoadTables, heatDesSelected, timeHeatMax, iZone, false);
   15551            3 :                     AddAreaColumnForZone(ZoneComponentAreas(iZone), facilityZonesHeatCompLoadTables);
   15552              :                 }
   15553            6 :                 facilityZonesHeatCompLoadTables.timeStepMax = timeHeatMax;
   15554            6 :                 facilityZonesHeatCompLoadTables.desDayNum = heatDesSelected;
   15555            6 :                 CombineLoadCompResults(FacilityHeatCompLoadTables, facilityZonesHeatCompLoadTables, mult);
   15556              :             }
   15557              : 
   15558            5 :             auto &facilityCoolTable = FacilityCoolCompLoadTables;
   15559            5 :             auto &facilityHeatTable = FacilityHeatCompLoadTables;
   15560            5 :             facilityCoolTable.peakDesSensLoad = 0.0;
   15561            5 :             facilityCoolTable.designPeakLoad = 0.0;
   15562            5 :             facilityHeatTable.peakDesSensLoad = 0.0;
   15563            5 :             facilityHeatTable.designPeakLoad = 0.0;
   15564            5 :             facilityCoolTable.diffPeakEst = 0.0;
   15565            5 :             facilityHeatTable.diffPeakEst = 0.0;
   15566            5 :             facilityCoolTable.diffDesignPeak = 0.0;
   15567            9 :             for (int iAirLoop = 1; iAirLoop <= NumPrimaryAirSys; ++iAirLoop) {
   15568            4 :                 facilityCoolTable.peakDesSensLoad += AirLoopCoolCompLoadTables(iAirLoop).peakDesSensLoad;
   15569            4 :                 facilityCoolTable.designPeakLoad += AirLoopCoolCompLoadTables(iAirLoop).designPeakLoad;
   15570            4 :                 facilityHeatTable.peakDesSensLoad += AirLoopHeatCompLoadTables(iAirLoop).peakDesSensLoad;
   15571            4 :                 facilityHeatTable.designPeakLoad += AirLoopHeatCompLoadTables(iAirLoop).designPeakLoad;
   15572            4 :                 facilityCoolTable.diffPeakEst += AirLoopCoolCompLoadTables(iAirLoop).diffPeakEst;
   15573            4 :                 facilityCoolTable.diffDesignPeak += AirLoopCoolCompLoadTables(iAirLoop).diffDesignPeak;
   15574            4 :                 facilityHeatTable.diffPeakEst += AirLoopHeatCompLoadTables(iAirLoop).diffPeakEst;
   15575            4 :                 facilityCoolTable.diffDesignPeak += AirLoopHeatCompLoadTables(iAirLoop).diffDesignPeak;
   15576              :             }
   15577              : 
   15578            5 :             ComputeEngineeringChecks(FacilityCoolCompLoadTables);
   15579            5 :             ComputeEngineeringChecks(FacilityHeatCompLoadTables);
   15580              : 
   15581            5 :             AddTotalRowsForLoadSummary(FacilityCoolCompLoadTables);
   15582            5 :             AddTotalRowsForLoadSummary(FacilityHeatCompLoadTables);
   15583              : 
   15584            5 :             ComputePeakDifference(FacilityCoolCompLoadTables);
   15585            5 :             ComputePeakDifference(FacilityHeatCompLoadTables);
   15586              : 
   15587            5 :             LoadSummaryUnitConversion(state, FacilityCoolCompLoadTables, unitsStyle_cur);
   15588            5 :             LoadSummaryUnitConversion(state, FacilityHeatCompLoadTables, unitsStyle_cur);
   15589              : 
   15590            5 :             OutputCompLoadSummary(state,
   15591              :                                   OutputType::Facility,
   15592              :                                   FacilityCoolCompLoadTables,
   15593              :                                   FacilityHeatCompLoadTables,
   15594              :                                   0,
   15595              :                                   unitsStyle_cur,
   15596              :                                   produceTabular,
   15597              :                                   produceSQLite);
   15598              :         }
   15599              : 
   15600              :         // SpaceComponentLoadSummary: Now we convert and Display
   15601            7 :         if (state.dataHeatBal->doSpaceHeatBalanceSizing) {
   15602            0 :             if (ort->displayZoneComponentLoadSummary) {
   15603            0 :                 for (int iSpace = 1; iSpace <= state.dataGlobal->numSpaces; ++iSpace) {
   15604              :                     // Test if *zone* is controlled, not space, for sizing
   15605            0 :                     if (!state.dataZoneEquip->ZoneEquipConfig(state.dataHeatBal->space(iSpace).zoneNum).IsControlled) {
   15606            0 :                         continue;
   15607              :                     }
   15608            0 :                     if (allocated(state.dataSize->CalcFinalSpaceSizing)) {
   15609            0 :                         LoadSummaryUnitConversion(state, SpaceCoolCompLoadTables(iSpace), unitsStyle_cur);
   15610            0 :                         LoadSummaryUnitConversion(state, SpaceHeatCompLoadTables(iSpace), unitsStyle_cur);
   15611              : 
   15612            0 :                         OutputCompLoadSummary(state,
   15613              :                                               OutputType::Space,
   15614            0 :                                               SpaceCoolCompLoadTables(iSpace),
   15615            0 :                                               SpaceHeatCompLoadTables(iSpace),
   15616              :                                               iSpace,
   15617              :                                               unitsStyle_cur,
   15618              :                                               produceTabular,
   15619              :                                               produceSQLite);
   15620              :                     }
   15621              :                 }
   15622              :             }
   15623            0 :             SpaceHeatCompLoadTables.deallocate();
   15624            0 :             SpaceCoolCompLoadTables.deallocate();
   15625              :         }
   15626              : 
   15627              :         // ZoneComponentLoadSummary: Now we convert and Display
   15628            7 :         if (ort->displayZoneComponentLoadSummary) {
   15629           11 :             for (int iZone = 1; iZone <= state.dataGlobal->NumOfZones; ++iZone) {
   15630            6 :                 if (!state.dataZoneEquip->ZoneEquipConfig(iZone).IsControlled) {
   15631            0 :                     continue;
   15632              :                 }
   15633            6 :                 if (allocated(state.dataSize->CalcFinalZoneSizing)) {
   15634            6 :                     LoadSummaryUnitConversion(state, ZoneCoolCompLoadTables(iZone), unitsStyle_cur);
   15635            6 :                     LoadSummaryUnitConversion(state, ZoneHeatCompLoadTables(iZone), unitsStyle_cur);
   15636              : 
   15637           12 :                     OutputCompLoadSummary(state,
   15638              :                                           OutputType::Zone,
   15639            6 :                                           ZoneCoolCompLoadTables(iZone),
   15640            6 :                                           ZoneHeatCompLoadTables(iZone),
   15641              :                                           iZone,
   15642              :                                           unitsStyle_cur,
   15643              :                                           produceTabular,
   15644              :                                           produceSQLite);
   15645              :                 }
   15646              :             }
   15647              :         }
   15648              : 
   15649            7 :         ZoneHeatCompLoadTables.deallocate();
   15650            7 :         ZoneCoolCompLoadTables.deallocate();
   15651            7 :         AirLoopHeatCompLoadTables.deallocate();
   15652            7 :         AirLoopCoolCompLoadTables.deallocate();
   15653            7 :         AirLoopZonesHeatCompLoadTables.deallocate();
   15654            7 :         AirLoopZonesCoolCompLoadTables.deallocate();
   15655              : 
   15656            7 :         FacilityHeatCompLoadTables.cells.deallocate();
   15657            7 :         FacilityHeatCompLoadTables.cellUsed.deallocate();
   15658            7 :         FacilityCoolCompLoadTables.cells.deallocate();
   15659            7 :         FacilityCoolCompLoadTables.cellUsed.deallocate();
   15660              : 
   15661            7 :         FacilityZonesHeatCompLoadTables.deallocate();
   15662            7 :         FacilityZonesCoolCompLoadTables.deallocate();
   15663              : 
   15664            7 :         peopleDelaySeq.deallocate();
   15665            7 :         lightDelaySeq.deallocate();
   15666            7 :         equipDelaySeq.deallocate();
   15667            7 :         hvacLossDelaySeq.deallocate();
   15668            7 :         powerGenDelaySeq.deallocate();
   15669            7 :         feneSolarDelaySeq.deallocate();
   15670            7 :         surfDelaySeq.deallocate();
   15671            7 :     }
   15672            6 : }
   15673              : 
   15674            6 : void computeSpaceZoneCompLoads(EnergyPlusData &state,
   15675              :                                DataSizing::ZoneSizingData const &calcFinalSizing,
   15676              :                                CompLoadTablesType &coolCompLoadTables,
   15677              :                                CompLoadTablesType &heatCompLoadTables,
   15678              :                                Array1D<Real64> &peopleDelaySeq,
   15679              :                                Array1D<Real64> &equipDelaySeq,
   15680              :                                Array1D<Real64> &hvacLossDelaySeq,
   15681              :                                Array1D<Real64> &powerGenDelaySeq,
   15682              :                                Array1D<Real64> &lightDelaySeq,
   15683              :                                Array1D<Real64> &feneSolarDelaySeq,
   15684              :                                std::vector<OutputReportTabular::componentLoadsSpZn> &szCompLoadLoc,
   15685              :                                Array2D<Real64> &surfDelaySeq,
   15686              :                                ZompComponentAreasType &componentAreas,
   15687              :                                int const iZone,
   15688              :                                int const iSpace)
   15689              : {
   15690            6 :     int coolDesSelected = calcFinalSizing.CoolDDNum;
   15691            6 :     coolCompLoadTables.desDayNum = coolDesSelected;
   15692            6 :     int timeCoolMax = calcFinalSizing.TimeStepNumAtCoolMax;
   15693            6 :     coolCompLoadTables.timeStepMax = timeCoolMax;
   15694              : 
   15695            6 :     GetDelaySequences(state,
   15696              :                       coolDesSelected,
   15697              :                       true,
   15698              :                       iZone,
   15699              :                       peopleDelaySeq,
   15700              :                       equipDelaySeq,
   15701              :                       hvacLossDelaySeq,
   15702              :                       powerGenDelaySeq,
   15703              :                       lightDelaySeq,
   15704              :                       feneSolarDelaySeq,
   15705              :                       szCompLoadLoc,
   15706              :                       surfDelaySeq,
   15707              :                       iSpace);
   15708            6 :     ComputeTableBodyUsingMovingAvg(state,
   15709            6 :                                    coolCompLoadTables.cells,
   15710            6 :                                    coolCompLoadTables.cellUsed,
   15711              :                                    coolDesSelected,
   15712              :                                    timeCoolMax,
   15713              :                                    iZone,
   15714              :                                    peopleDelaySeq,
   15715              :                                    equipDelaySeq,
   15716              :                                    hvacLossDelaySeq,
   15717              :                                    powerGenDelaySeq,
   15718              :                                    lightDelaySeq,
   15719              :                                    feneSolarDelaySeq,
   15720              :                                    szCompLoadLoc,
   15721              :                                    surfDelaySeq,
   15722              :                                    iSpace);
   15723            6 :     CollectPeakZoneConditions(state, coolCompLoadTables, coolDesSelected, timeCoolMax, iZone, true, iSpace);
   15724              :     // send latent load info to coil summary report
   15725            6 :     state.dataRptCoilSelection->coilSelectionReportObj->setZoneLatentLoadCoolingIdealPeak(
   15726            6 :         iZone, coolCompLoadTables.cells(LoadCompCol::Latent, LoadCompRow::GrdTot));
   15727              : 
   15728            6 :     int heatDesSelected = calcFinalSizing.HeatDDNum;
   15729            6 :     heatCompLoadTables.desDayNum = heatDesSelected;
   15730            6 :     int timeHeatMax = calcFinalSizing.TimeStepNumAtHeatMax;
   15731            6 :     heatCompLoadTables.timeStepMax = timeHeatMax;
   15732              : 
   15733            6 :     GetDelaySequences(state,
   15734              :                       heatDesSelected,
   15735              :                       false,
   15736              :                       iZone,
   15737              :                       peopleDelaySeq,
   15738              :                       equipDelaySeq,
   15739              :                       hvacLossDelaySeq,
   15740              :                       powerGenDelaySeq,
   15741              :                       lightDelaySeq,
   15742              :                       feneSolarDelaySeq,
   15743              :                       szCompLoadLoc,
   15744              :                       surfDelaySeq,
   15745              :                       iSpace);
   15746            6 :     ComputeTableBodyUsingMovingAvg(state,
   15747            6 :                                    heatCompLoadTables.cells,
   15748            6 :                                    heatCompLoadTables.cellUsed,
   15749              :                                    heatDesSelected,
   15750              :                                    timeHeatMax,
   15751              :                                    iZone,
   15752              :                                    peopleDelaySeq,
   15753              :                                    equipDelaySeq,
   15754              :                                    hvacLossDelaySeq,
   15755              :                                    powerGenDelaySeq,
   15756              :                                    lightDelaySeq,
   15757              :                                    feneSolarDelaySeq,
   15758              :                                    szCompLoadLoc,
   15759              :                                    surfDelaySeq,
   15760              :                                    iSpace);
   15761            6 :     CollectPeakZoneConditions(state, heatCompLoadTables, heatDesSelected, timeHeatMax, iZone, false, iSpace);
   15762              : 
   15763              :     // send latent load info to coil summary report
   15764            6 :     state.dataRptCoilSelection->coilSelectionReportObj->setZoneLatentLoadHeatingIdealPeak(
   15765            6 :         iZone, heatCompLoadTables.cells(LoadCompCol::Latent, LoadCompRow::GrdTot));
   15766              : 
   15767            6 :     AddAreaColumnForZone(componentAreas, coolCompLoadTables);
   15768            6 :     AddAreaColumnForZone(componentAreas, heatCompLoadTables);
   15769              : 
   15770            6 :     AddTotalRowsForLoadSummary(coolCompLoadTables);
   15771            6 :     AddTotalRowsForLoadSummary(heatCompLoadTables);
   15772              : 
   15773            6 :     ComputePeakDifference(coolCompLoadTables);
   15774            6 :     ComputePeakDifference(heatCompLoadTables);
   15775            6 : }
   15776              : // populate the delay sequence arrays for the component load summary table output
   15777           28 : void GetDelaySequences(EnergyPlusData &state,
   15778              :                        int const desDaySelected,
   15779              :                        bool const isCooling,
   15780              :                        int const zoneIndex,
   15781              :                        Array1D<Real64> &peopleDelaySeq,
   15782              :                        Array1D<Real64> &equipDelaySeq,
   15783              :                        Array1D<Real64> &hvacLossDelaySeq,
   15784              :                        Array1D<Real64> &powerGenDelaySeq,
   15785              :                        Array1D<Real64> &lightDelaySeq,
   15786              :                        Array1D<Real64> &feneSolarDelaySeq,
   15787              :                        std::vector<OutputReportTabular::componentLoadsSpZn> &szCompLoadLoc,
   15788              :                        Array2D<Real64> &surfDelaySeq,
   15789              :                        int const iSpace)
   15790              : {
   15791              : 
   15792              :     // static bool initAdjFenDone(false); moved to anonymous namespace for unit testing
   15793           28 :     auto &ort = state.dataOutRptTab;
   15794           28 :     int const szNumMinus1 = (iSpace == 0) ? zoneIndex - 1 : iSpace - 1; // space or zone num minus 1 for vector
   15795              :     // reset to zero
   15796           28 :     surfDelaySeq = 0.0;
   15797              : 
   15798           28 :     if (desDaySelected != 0) {
   15799           26 :         auto const &surfCLDay = ort->surfCompLoads[desDaySelected - 1];
   15800           26 :         auto const &enclCLDay = ort->enclCompLoads[desDaySelected - 1];
   15801           26 :         auto &szCLDay = szCompLoadLoc[desDaySelected - 1];
   15802              : 
   15803           26 :         Array2D<Real64> decayCurve;
   15804           26 :         if (isCooling) {
   15805           15 :             decayCurve = ort->decayCurveCool;
   15806              :         } else {
   15807           11 :             decayCurve = ort->decayCurveHeat;
   15808              :         }
   15809              : 
   15810         2378 :         for (int kTimeStep = 1; kTimeStep <= state.dataGlobal->TimeStepsInHour * Constant::iHoursInDay; ++kTimeStep) {
   15811         2352 :             Real64 peopleConvIntoZone = 0.0;
   15812         2352 :             Real64 equipConvIntoZone = 0.0;
   15813         2352 :             Real64 hvacLossConvIntoZone = 0.0;
   15814         2352 :             Real64 powerGenConvIntoZone = 0.0;
   15815         2352 :             Real64 lightLWConvIntoZone = 0.0;
   15816         2352 :             Real64 lightSWConvIntoZone = 0.0;
   15817         2352 :             Real64 feneSolarConvIntoZone = 0.0;
   15818         2352 :             Real64 adjFeneSurfNetRadSeq = 0.0;
   15819              : 
   15820              :             // code from ComputeDelayedComponents starts
   15821         4704 :             for (int spaceNum : state.dataHeatBal->Zone(zoneIndex).spaceIndexes) {
   15822         2352 :                 if ((iSpace > 0) && (spaceNum != iSpace)) {
   15823            0 :                     continue;
   15824              :                 }
   15825         2352 :                 auto const &thisSpace = state.dataHeatBal->space(spaceNum);
   15826        14784 :                 for (int jSurf = thisSpace.HTSurfaceFirst; jSurf <= thisSpace.HTSurfaceLast; ++jSurf) {
   15827        12432 :                     int const radEnclosureNum = state.dataSurface->Surface(jSurf).RadEnclIndex;
   15828              :                     // for each time step, step back through time and apply decay curve to radiant heat for each end use absorbed in each surface
   15829        12432 :                     Real64 peopleConvFromSurf = 0.0;
   15830        12432 :                     Real64 equipConvFromSurf = 0.0;
   15831        12432 :                     Real64 hvacLossConvFromSurf = 0.0;
   15832        12432 :                     Real64 powerGenConvFromSurf = 0.0;
   15833        12432 :                     Real64 lightLWConvFromSurf = 0.0;
   15834        12432 :                     Real64 lightSWConvFromSurf = 0.0;
   15835        12432 :                     Real64 feneSolarConvFromSurf = 0.0;
   15836              : 
   15837       603288 :                     for (int mStepBack = 1; mStepBack <= kTimeStep; ++mStepBack) {
   15838       590856 :                         int sourceStep = kTimeStep - mStepBack + 1;
   15839       590856 :                         auto &compLoadTS = szCLDay.ts[sourceStep - 1].spacezone[szNumMinus1];
   15840       590856 :                         auto const &surfCLDayTS = surfCLDay.ts[sourceStep - 1].surf[jSurf - 1];
   15841       590856 :                         auto const &enclCLDayTS = enclCLDay.ts[sourceStep - 1].encl[radEnclosureNum - 1];
   15842              :                         Real64 thisQRadThermInAbsMult =
   15843       590856 :                             surfCLDayTS.TMULTseq * surfCLDayTS.ITABSFseq * state.dataSurface->Surface(jSurf).Area * decayCurve(mStepBack, jSurf);
   15844       590856 :                         peopleConvFromSurf += enclCLDayTS.peopleRadSeq * thisQRadThermInAbsMult;
   15845       590856 :                         equipConvFromSurf += enclCLDayTS.equipRadSeq * thisQRadThermInAbsMult;
   15846       590856 :                         hvacLossConvFromSurf += enclCLDayTS.hvacLossRadSeq * thisQRadThermInAbsMult;
   15847       590856 :                         powerGenConvFromSurf += enclCLDayTS.powerGenRadSeq * thisQRadThermInAbsMult;
   15848       590856 :                         lightLWConvFromSurf += enclCLDayTS.lightLWRadSeq * thisQRadThermInAbsMult;
   15849              :                         // short wave is already accumulated by surface
   15850       590856 :                         lightSWConvFromSurf += surfCLDayTS.lightSWRadSeq * decayCurve(mStepBack, jSurf);
   15851       590856 :                         feneSolarConvFromSurf += surfCLDayTS.feneSolarRadSeq * decayCurve(mStepBack, jSurf);
   15852              :                     } // for mStepBack
   15853              : 
   15854        12432 :                     peopleConvIntoZone += peopleConvFromSurf;
   15855        12432 :                     equipConvIntoZone += equipConvFromSurf;
   15856        12432 :                     hvacLossConvIntoZone += hvacLossConvFromSurf;
   15857        12432 :                     powerGenConvIntoZone += powerGenConvFromSurf;
   15858        12432 :                     lightLWConvIntoZone += lightLWConvFromSurf;
   15859        12432 :                     lightSWConvIntoZone += lightSWConvFromSurf;
   15860        12432 :                     feneSolarConvIntoZone += feneSolarConvFromSurf;
   15861              :                     // code from ComputeDelayedComponents ends
   15862              :                     // determine the remaining convective heat from the surfaces that are not based
   15863              :                     // on any of these other loads
   15864              :                     // negative because heat from surface should be positive
   15865        12432 :                     auto &surfCLDaykTS = surfCLDay.ts[kTimeStep - 1].surf[jSurf - 1];
   15866        24864 :                     surfDelaySeq(kTimeStep, jSurf) =
   15867        12432 :                         -surfCLDaykTS.loadConvectedNormal - surfCLDaykTS.netSurfRadSeq -
   15868        12432 :                         (peopleConvFromSurf + equipConvFromSurf + hvacLossConvFromSurf + powerGenConvFromSurf + lightLWConvFromSurf +
   15869        12432 :                          lightSWConvFromSurf +
   15870              :                          feneSolarConvFromSurf); // remove net radiant for the surface
   15871              :                                                  // also remove the net radiant component on the instantaneous conduction for fenestration
   15872        12432 :                     if (state.dataSurface->Surface(jSurf).Class == DataSurfaces::SurfaceClass::Window) {
   15873         1200 :                         adjFeneSurfNetRadSeq += surfCLDaykTS.netSurfRadSeq;
   15874              :                     }
   15875              :                 } // for jSurf
   15876         2352 :             }
   15877         2352 :             peopleDelaySeq(kTimeStep) = peopleConvIntoZone;
   15878         2352 :             equipDelaySeq(kTimeStep) = equipConvIntoZone;
   15879         2352 :             hvacLossDelaySeq(kTimeStep) = hvacLossConvIntoZone;
   15880         2352 :             powerGenDelaySeq(kTimeStep) = powerGenConvIntoZone;
   15881              :             // combine short wave (visible) and long wave (thermal) impacts
   15882         2352 :             lightDelaySeq(kTimeStep) = lightLWConvIntoZone + lightSWConvIntoZone;
   15883         2352 :             feneSolarDelaySeq(kTimeStep) = feneSolarConvIntoZone;
   15884              :             // also remove the net radiant component on the instantaneous conduction for fenestration
   15885         2352 :             auto &szCompLoadDayTS = szCLDay.ts[kTimeStep - 1].spacezone[szNumMinus1];
   15886         2352 :             if (!szCompLoadDayTS.adjFenDone) {
   15887         1200 :                 szCompLoadDayTS.feneCondInstantSeq -= adjFeneSurfNetRadSeq;
   15888         1200 :                 szCompLoadDayTS.adjFenDone = true;
   15889              :             }
   15890              :         } // for kTimeStep
   15891              : 
   15892           26 :         decayCurve.deallocate();
   15893              : 
   15894           26 :     } // if desDaySelected != 0
   15895           28 : }
   15896              : 
   15897              : // set the load summary table cells based on the load sequences using moving averages to smooth out
   15898           24 : void ComputeTableBodyUsingMovingAvg(EnergyPlusData &state,
   15899              :                                     Array2D<Real64> &resultCells,
   15900              :                                     Array2D_bool &resCellsUsd,
   15901              :                                     int const desDaySelected,
   15902              :                                     int const timeOfMax,
   15903              :                                     int const zoneIndex,
   15904              :                                     Array1D<Real64> const &peopleDelaySeq,
   15905              :                                     Array1D<Real64> const &equipDelaySeq,
   15906              :                                     Array1D<Real64> const &hvacLossDelaySeq,
   15907              :                                     Array1D<Real64> const &powerGenDelaySeq,
   15908              :                                     Array1D<Real64> const &lightDelaySeq,
   15909              :                                     Array1D<Real64> const &feneSolarDelaySeq,
   15910              :                                     std::vector<OutputReportTabular::componentLoadsSpZn> &szCompLoadLoc,
   15911              :                                     Array2D<Real64> const &surfDelaySeq,
   15912              :                                     int const iSpace)
   15913              : {
   15914           24 :     Array1D<Real64> AvgData;     // sequence data to be averaging
   15915           24 :     Array1D<Real64> delayOpaque; // hold values for report for delayed opaque
   15916              : 
   15917           24 :     resultCells = 0.;
   15918           24 :     resCellsUsd = false;
   15919           24 :     delayOpaque.allocate(LoadCompRow::GrdTot);
   15920           24 :     Real64 numTSinDay = state.dataGlobal->TimeStepsInHour * Constant::iHoursInDay;
   15921           24 :     AvgData.allocate(numTSinDay);
   15922           24 :     int const szNumMinus1 = (iSpace == 0) ? zoneIndex - 1 : iSpace - 1; // space or zone num minus 1 for vector
   15923              : 
   15924           24 :     if (desDaySelected != 0 && timeOfMax != 0) {
   15925              :         // Don't update/average original array data
   15926              :         // PEOPLE
   15927           22 :         auto &compLoadDay = szCompLoadLoc[desDaySelected - 1];
   15928         1990 :         for (int iTS = 1; iTS <= numTSinDay; ++iTS) {
   15929         1968 :             AvgData(iTS) = compLoadDay.ts[iTS - 1].spacezone[szNumMinus1].peopleInstantSeq;
   15930              :         }
   15931           22 :         General::MovingAvg(AvgData, state.dataSize->NumTimeStepsInAvg);
   15932           22 :         resultCells(LoadCompCol::SensInst, LoadCompRow::People) = AvgData(timeOfMax);
   15933           22 :         resCellsUsd(LoadCompCol::SensInst, LoadCompRow::People) = true;
   15934         1990 :         for (int iTS = 1; iTS <= numTSinDay; ++iTS) {
   15935         1968 :             AvgData(iTS) = compLoadDay.ts[iTS - 1].spacezone[szNumMinus1].peopleLatentSeq;
   15936              :         }
   15937           22 :         General::MovingAvg(AvgData, state.dataSize->NumTimeStepsInAvg);
   15938           22 :         resultCells(LoadCompCol::Latent, LoadCompRow::People) = AvgData(timeOfMax);
   15939           22 :         resCellsUsd(LoadCompCol::Latent, LoadCompRow::People) = true;
   15940           22 :         AvgData = peopleDelaySeq(_);
   15941           22 :         General::MovingAvg(AvgData, state.dataSize->NumTimeStepsInAvg);
   15942           22 :         resultCells(LoadCompCol::SensDelay, LoadCompRow::People) = AvgData(timeOfMax);
   15943           22 :         resCellsUsd(LoadCompCol::SensDelay, LoadCompRow::People) = true;
   15944              : 
   15945              :         // LIGHTS
   15946         1990 :         for (int iTS = 1; iTS <= numTSinDay; ++iTS) {
   15947         1968 :             AvgData(iTS) = compLoadDay.ts[iTS - 1].spacezone[szNumMinus1].lightInstantSeq;
   15948              :         }
   15949           22 :         General::MovingAvg(AvgData, state.dataSize->NumTimeStepsInAvg);
   15950           22 :         resultCells(LoadCompCol::SensInst, LoadCompRow::Lights) = AvgData(timeOfMax);
   15951           22 :         resCellsUsd(LoadCompCol::SensInst, LoadCompRow::Lights) = true;
   15952         1990 :         for (int iTS = 1; iTS <= numTSinDay; ++iTS) {
   15953         1968 :             AvgData(iTS) = compLoadDay.ts[iTS - 1].spacezone[szNumMinus1].lightRetAirSeq;
   15954              :         }
   15955           22 :         General::MovingAvg(AvgData, state.dataSize->NumTimeStepsInAvg);
   15956           22 :         resultCells(LoadCompCol::SensRA, LoadCompRow::Lights) = AvgData(timeOfMax);
   15957           22 :         resCellsUsd(LoadCompCol::SensRA, LoadCompRow::Lights) = true;
   15958           22 :         AvgData = lightDelaySeq(_);
   15959           22 :         General::MovingAvg(AvgData, state.dataSize->NumTimeStepsInAvg);
   15960           22 :         resultCells(LoadCompCol::SensDelay, LoadCompRow::Lights) = AvgData(timeOfMax);
   15961           22 :         resCellsUsd(LoadCompCol::SensDelay, LoadCompRow::Lights) = true;
   15962              : 
   15963              :         // EQUIPMENT
   15964         1990 :         for (int iTS = 1; iTS <= numTSinDay; ++iTS) {
   15965         1968 :             AvgData(iTS) = compLoadDay.ts[iTS - 1].spacezone[szNumMinus1].equipInstantSeq;
   15966              :         }
   15967           22 :         General::MovingAvg(AvgData, state.dataSize->NumTimeStepsInAvg);
   15968           22 :         resultCells(LoadCompCol::SensInst, LoadCompRow::Equip) = AvgData(timeOfMax);
   15969           22 :         resCellsUsd(LoadCompCol::SensInst, LoadCompRow::Equip) = true;
   15970         1990 :         for (int iTS = 1; iTS <= numTSinDay; ++iTS) {
   15971         1968 :             AvgData(iTS) = compLoadDay.ts[iTS - 1].spacezone[szNumMinus1].equipLatentSeq;
   15972              :         }
   15973           22 :         General::MovingAvg(AvgData, state.dataSize->NumTimeStepsInAvg);
   15974           22 :         resultCells(LoadCompCol::Latent, LoadCompRow::Equip) = AvgData(timeOfMax);
   15975           22 :         resCellsUsd(LoadCompCol::Latent, LoadCompRow::Equip) = true;
   15976           22 :         AvgData = equipDelaySeq(_);
   15977           22 :         General::MovingAvg(AvgData, state.dataSize->NumTimeStepsInAvg);
   15978           22 :         resultCells(LoadCompCol::SensDelay, LoadCompRow::Equip) = AvgData(timeOfMax);
   15979           22 :         resCellsUsd(LoadCompCol::SensDelay, LoadCompRow::Equip) = true;
   15980              : 
   15981              :         // REFRIGERATION EQUIPMENT
   15982         1990 :         for (int iTS = 1; iTS <= numTSinDay; ++iTS) {
   15983         1968 :             AvgData(iTS) = compLoadDay.ts[iTS - 1].spacezone[szNumMinus1].refrigInstantSeq;
   15984              :         }
   15985           22 :         General::MovingAvg(AvgData, state.dataSize->NumTimeStepsInAvg);
   15986           22 :         resultCells(LoadCompCol::SensInst, LoadCompRow::Refrig) = AvgData(timeOfMax);
   15987           22 :         resCellsUsd(LoadCompCol::SensInst, LoadCompRow::Refrig) = true;
   15988         1990 :         for (int iTS = 1; iTS <= numTSinDay; ++iTS) {
   15989         1968 :             AvgData(iTS) = compLoadDay.ts[iTS - 1].spacezone[szNumMinus1].refrigRetAirSeq;
   15990              :         }
   15991           22 :         General::MovingAvg(AvgData, state.dataSize->NumTimeStepsInAvg);
   15992           22 :         resultCells(LoadCompCol::SensRA, LoadCompRow::Refrig) = AvgData(timeOfMax);
   15993           22 :         resCellsUsd(LoadCompCol::SensRA, LoadCompRow::Refrig) = true;
   15994         1990 :         for (int iTS = 1; iTS <= numTSinDay; ++iTS) {
   15995         1968 :             AvgData(iTS) = compLoadDay.ts[iTS - 1].spacezone[szNumMinus1].refrigLatentSeq;
   15996              :         }
   15997           22 :         General::MovingAvg(AvgData, state.dataSize->NumTimeStepsInAvg);
   15998           22 :         resultCells(LoadCompCol::Latent, LoadCompRow::Refrig) = AvgData(timeOfMax);
   15999           22 :         resCellsUsd(LoadCompCol::Latent, LoadCompRow::Refrig) = true;
   16000              : 
   16001              :         // WATER USE EQUIPMENT
   16002         1990 :         for (int iTS = 1; iTS <= numTSinDay; ++iTS) {
   16003         1968 :             AvgData(iTS) = compLoadDay.ts[iTS - 1].spacezone[szNumMinus1].waterUseInstantSeq;
   16004              :         }
   16005           22 :         General::MovingAvg(AvgData, state.dataSize->NumTimeStepsInAvg);
   16006           22 :         resultCells(LoadCompCol::SensInst, LoadCompRow::WaterUse) = AvgData(timeOfMax);
   16007           22 :         resCellsUsd(LoadCompCol::SensInst, LoadCompRow::WaterUse) = true;
   16008         1990 :         for (int iTS = 1; iTS <= numTSinDay; ++iTS) {
   16009         1968 :             AvgData(iTS) = compLoadDay.ts[iTS - 1].spacezone[szNumMinus1].waterUseLatentSeq;
   16010              :         }
   16011           22 :         General::MovingAvg(AvgData, state.dataSize->NumTimeStepsInAvg);
   16012           22 :         resultCells(LoadCompCol::Latent, LoadCompRow::WaterUse) = AvgData(timeOfMax);
   16013           22 :         resCellsUsd(LoadCompCol::Latent, LoadCompRow::WaterUse) = true;
   16014              : 
   16015              :         // HVAC EQUIPMENT LOSSES
   16016         1990 :         for (int iTS = 1; iTS <= numTSinDay; ++iTS) {
   16017         1968 :             AvgData(iTS) = compLoadDay.ts[iTS - 1].spacezone[szNumMinus1].hvacLossInstantSeq;
   16018              :         }
   16019           22 :         General::MovingAvg(AvgData, state.dataSize->NumTimeStepsInAvg);
   16020           22 :         resultCells(LoadCompCol::SensInst, LoadCompRow::HvacLoss) = AvgData(timeOfMax);
   16021           22 :         resCellsUsd(LoadCompCol::SensInst, LoadCompRow::HvacLoss) = true;
   16022           22 :         AvgData = hvacLossDelaySeq(_);
   16023           22 :         General::MovingAvg(AvgData, state.dataSize->NumTimeStepsInAvg);
   16024           22 :         resultCells(LoadCompCol::SensDelay, LoadCompRow::HvacLoss) = AvgData(timeOfMax);
   16025           22 :         resCellsUsd(LoadCompCol::SensDelay, LoadCompRow::HvacLoss) = true;
   16026              : 
   16027              :         // POWER GENERATION EQUIPMENT
   16028         1990 :         for (int iTS = 1; iTS <= numTSinDay; ++iTS) {
   16029         1968 :             AvgData(iTS) = compLoadDay.ts[iTS - 1].spacezone[szNumMinus1].powerGenInstantSeq;
   16030              :         }
   16031           22 :         General::MovingAvg(AvgData, state.dataSize->NumTimeStepsInAvg);
   16032           22 :         resultCells(LoadCompCol::SensInst, LoadCompRow::PowerGen) = AvgData(timeOfMax);
   16033           22 :         resCellsUsd(LoadCompCol::SensInst, LoadCompRow::PowerGen) = true;
   16034           22 :         AvgData = powerGenDelaySeq(_);
   16035           22 :         General::MovingAvg(AvgData, state.dataSize->NumTimeStepsInAvg);
   16036           22 :         resultCells(LoadCompCol::SensDelay, LoadCompRow::PowerGen) = AvgData(timeOfMax);
   16037           22 :         resCellsUsd(LoadCompCol::SensDelay, LoadCompRow::PowerGen) = true;
   16038              : 
   16039              :         // DOAS
   16040           22 :         Real64 const mult = state.dataHeatBal->Zone(zoneIndex).Multiplier * state.dataHeatBal->Zone(zoneIndex).ListMultiplier;
   16041           44 :         resultCells(LoadCompCol::SensInst, LoadCompRow::DOAS) =
   16042           22 :             state.dataSize->CalcZoneSizing(desDaySelected, zoneIndex).DOASHeatAddSeq(timeOfMax) / mult;
   16043           22 :         resCellsUsd(LoadCompCol::SensInst, LoadCompRow::DOAS) = true;
   16044           44 :         resultCells(LoadCompCol::Latent, LoadCompRow::DOAS) =
   16045           22 :             state.dataSize->CalcZoneSizing(desDaySelected, zoneIndex).DOASLatAddSeq(timeOfMax) / mult;
   16046           22 :         resCellsUsd(LoadCompCol::Latent, LoadCompRow::DOAS) = true;
   16047              : 
   16048              :         // INFILTRATION
   16049         1990 :         for (int iTS = 1; iTS <= numTSinDay; ++iTS) {
   16050         1968 :             AvgData(iTS) = compLoadDay.ts[iTS - 1].spacezone[szNumMinus1].infilInstantSeq;
   16051              :         }
   16052           22 :         General::MovingAvg(AvgData, state.dataSize->NumTimeStepsInAvg);
   16053           22 :         resultCells(LoadCompCol::SensInst, LoadCompRow::Infil) = AvgData(timeOfMax);
   16054           22 :         resCellsUsd(LoadCompCol::SensInst, LoadCompRow::Infil) = true;
   16055         1990 :         for (int iTS = 1; iTS <= numTSinDay; ++iTS) {
   16056         1968 :             AvgData(iTS) = compLoadDay.ts[iTS - 1].spacezone[szNumMinus1].infilLatentSeq;
   16057              :         }
   16058           22 :         General::MovingAvg(AvgData, state.dataSize->NumTimeStepsInAvg);
   16059           22 :         resultCells(LoadCompCol::Latent, LoadCompRow::Infil) = AvgData(timeOfMax);
   16060           22 :         resCellsUsd(LoadCompCol::Latent, LoadCompRow::Infil) = true;
   16061              : 
   16062              :         // ZONE VENTILATION
   16063         1990 :         for (int iTS = 1; iTS <= numTSinDay; ++iTS) {
   16064         1968 :             AvgData(iTS) = compLoadDay.ts[iTS - 1].spacezone[szNumMinus1].zoneVentInstantSeq;
   16065              :         }
   16066           22 :         General::MovingAvg(AvgData, state.dataSize->NumTimeStepsInAvg);
   16067           22 :         resultCells(LoadCompCol::SensInst, LoadCompRow::ZoneVent) = AvgData(timeOfMax);
   16068           22 :         resCellsUsd(LoadCompCol::SensInst, LoadCompRow::ZoneVent) = true;
   16069         1990 :         for (int iTS = 1; iTS <= numTSinDay; ++iTS) {
   16070         1968 :             AvgData(iTS) = compLoadDay.ts[iTS - 1].spacezone[szNumMinus1].zoneVentLatentSeq;
   16071              :         }
   16072           22 :         General::MovingAvg(AvgData, state.dataSize->NumTimeStepsInAvg);
   16073           22 :         resultCells(LoadCompCol::Latent, LoadCompRow::ZoneVent) = AvgData(timeOfMax);
   16074           22 :         resCellsUsd(LoadCompCol::Latent, LoadCompRow::ZoneVent) = true;
   16075              : 
   16076              :         // INTERZONE MIXING
   16077         1990 :         for (int iTS = 1; iTS <= numTSinDay; ++iTS) {
   16078         1968 :             AvgData(iTS) = compLoadDay.ts[iTS - 1].spacezone[szNumMinus1].interZoneMixInstantSeq;
   16079              :         }
   16080           22 :         General::MovingAvg(AvgData, state.dataSize->NumTimeStepsInAvg);
   16081           22 :         resultCells(LoadCompCol::SensInst, LoadCompRow::IntZonMix) = AvgData(timeOfMax);
   16082           22 :         resCellsUsd(LoadCompCol::SensInst, LoadCompRow::IntZonMix) = true;
   16083         1990 :         for (int iTS = 1; iTS <= numTSinDay; ++iTS) {
   16084         1968 :             AvgData(iTS) = compLoadDay.ts[iTS - 1].spacezone[szNumMinus1].interZoneMixLatentSeq;
   16085              :         }
   16086           22 :         General::MovingAvg(AvgData, state.dataSize->NumTimeStepsInAvg);
   16087           22 :         resultCells(LoadCompCol::Latent, LoadCompRow::IntZonMix) = AvgData(timeOfMax);
   16088           22 :         resCellsUsd(LoadCompCol::Latent, LoadCompRow::IntZonMix) = true;
   16089              : 
   16090              :         // FENESTRATION CONDUCTION
   16091         1990 :         for (int iTS = 1; iTS <= numTSinDay; ++iTS) {
   16092         1968 :             AvgData(iTS) = compLoadDay.ts[iTS - 1].spacezone[szNumMinus1].feneCondInstantSeq;
   16093              :         }
   16094           22 :         General::MovingAvg(AvgData, state.dataSize->NumTimeStepsInAvg);
   16095           22 :         resultCells(LoadCompCol::SensInst, LoadCompRow::FeneCond) = AvgData(timeOfMax);
   16096           22 :         resCellsUsd(LoadCompCol::SensInst, LoadCompRow::FeneCond) = true;
   16097              : 
   16098              :         // FENESTRATION SOLAR
   16099           22 :         AvgData = feneSolarDelaySeq(_);
   16100           22 :         General::MovingAvg(AvgData, state.dataSize->NumTimeStepsInAvg);
   16101           22 :         resultCells(LoadCompCol::SensDelay, LoadCompRow::FeneSolr) = AvgData(timeOfMax);
   16102           22 :         resCellsUsd(LoadCompCol::SensDelay, LoadCompRow::FeneSolr) = true;
   16103              : 
   16104              :         // opaque surfaces - must combine individual surfaces by class and other side conditions
   16105           22 :         delayOpaque = 0.0;
   16106           44 :         for (int spaceNum : state.dataHeatBal->Zone(zoneIndex).spaceIndexes) {
   16107           22 :             auto const &thisSpace = state.dataHeatBal->space(spaceNum);
   16108          152 :             for (int kSurf = thisSpace.HTSurfaceFirst; kSurf <= thisSpace.HTSurfaceLast; ++kSurf) {
   16109              : 
   16110          130 :                 int curExtBoundCond = state.dataSurface->Surface(kSurf).ExtBoundCond;
   16111              :                 // if exterior is other side coefficients using ground preprocessor terms then
   16112              :                 // set it to ground instead of other side coefficients
   16113          130 :                 if (curExtBoundCond == DataSurfaces::OtherSideCoefNoCalcExt || curExtBoundCond == DataSurfaces::OtherSideCoefCalcExt) {
   16114            0 :                     if (has_prefixi(state.dataSurface->OSC(state.dataSurface->Surface(kSurf).OSCPtr).Name, "surfPropOthSdCoef")) {
   16115            0 :                         curExtBoundCond = DataSurfaces::Ground;
   16116              :                     }
   16117              :                 }
   16118          130 :                 AvgData = surfDelaySeq(_, kSurf);
   16119          130 :                 General::MovingAvg(AvgData, state.dataSize->NumTimeStepsInAvg);
   16120          130 :                 Real64 singleSurfDelay = AvgData(timeOfMax);
   16121          130 :                 switch (state.dataSurface->Surface(kSurf).Class) {
   16122           80 :                 case DataSurfaces::SurfaceClass::Wall: {
   16123           80 :                     switch (curExtBoundCond) {
   16124           50 :                     case DataSurfaces::ExternalEnvironment: {
   16125           50 :                         delayOpaque(LoadCompRow::ExtWall) += singleSurfDelay;
   16126           50 :                     } break;
   16127            0 :                     case DataSurfaces::Ground:
   16128              :                     case DataSurfaces::GroundFCfactorMethod:
   16129              :                     case DataSurfaces::KivaFoundation: {
   16130            0 :                         delayOpaque(LoadCompRow::GrdWall) += singleSurfDelay;
   16131            0 :                     } break;
   16132            0 :                     case DataSurfaces::OtherSideCoefNoCalcExt:
   16133              :                     case DataSurfaces::OtherSideCoefCalcExt:
   16134              :                     case DataSurfaces::OtherSideCondModeledExt: {
   16135            0 :                         delayOpaque(LoadCompRow::OtherWall) += singleSurfDelay;
   16136            0 :                     } break;
   16137           30 :                     default: { // interzone
   16138           30 :                         delayOpaque(LoadCompRow::IntZonWall) += singleSurfDelay;
   16139           30 :                     } break;
   16140              :                     }
   16141           80 :                 } break;
   16142           20 :                 case DataSurfaces::SurfaceClass::Floor: {
   16143           20 :                     switch (curExtBoundCond) {
   16144            0 :                     case DataSurfaces::ExternalEnvironment: {
   16145            0 :                         delayOpaque(LoadCompRow::ExtFlr) += singleSurfDelay;
   16146            0 :                     } break;
   16147           10 :                     case DataSurfaces::Ground:
   16148              :                     case DataSurfaces::GroundFCfactorMethod:
   16149              :                     case DataSurfaces::KivaFoundation: {
   16150           10 :                         delayOpaque(LoadCompRow::GrdFlr) += singleSurfDelay;
   16151           10 :                     } break;
   16152            0 :                     case DataSurfaces::OtherSideCoefNoCalcExt:
   16153              :                     case DataSurfaces::OtherSideCoefCalcExt:
   16154              :                     case DataSurfaces::OtherSideCondModeledExt: {
   16155            0 :                         delayOpaque(LoadCompRow::OtherFlr) += singleSurfDelay;
   16156            0 :                     } break;
   16157           10 :                     default: { // interzone
   16158           10 :                         delayOpaque(LoadCompRow::IntZonFlr) += singleSurfDelay;
   16159           10 :                     } break;
   16160              :                     }
   16161           20 :                 } break;
   16162           20 :                 case DataSurfaces::SurfaceClass::Roof: {
   16163           20 :                     switch (curExtBoundCond) {
   16164           20 :                     case DataSurfaces::ExternalEnvironment: {
   16165           20 :                         delayOpaque(LoadCompRow::Roof) += singleSurfDelay;
   16166           20 :                     } break;
   16167            0 :                     case DataSurfaces::Ground:
   16168              :                     case DataSurfaces::GroundFCfactorMethod:
   16169              :                     case DataSurfaces::KivaFoundation:
   16170              :                     case DataSurfaces::OtherSideCoefNoCalcExt:
   16171              :                     case DataSurfaces::OtherSideCoefCalcExt:
   16172              :                     case DataSurfaces::OtherSideCondModeledExt: {
   16173            0 :                         delayOpaque(LoadCompRow::OtherRoof) += singleSurfDelay;
   16174            0 :                     } break;
   16175            0 :                     default: { // interzone
   16176            0 :                         delayOpaque(LoadCompRow::IntZonCeil) += singleSurfDelay;
   16177            0 :                     } break;
   16178              :                     }
   16179           20 :                 } break;
   16180            0 :                 case DataSurfaces::SurfaceClass::Door: {
   16181            0 :                     delayOpaque(LoadCompRow::OpqDoor) += singleSurfDelay;
   16182            0 :                 } break;
   16183           10 :                 default:
   16184           10 :                     break;
   16185              :                 }
   16186              :             }
   16187           22 :         }
   16188          264 :         for (int k = LoadCompRow::Roof; k <= LoadCompRow::OtherFlr; ++k) {
   16189          242 :             resultCells(LoadCompCol::SensDelay, k) = delayOpaque(k);
   16190          242 :             resCellsUsd(LoadCompCol::SensDelay, k) = true;
   16191              :         }
   16192           22 :         resultCells(LoadCompCol::SensDelay, LoadCompRow::OpqDoor) = delayOpaque(LoadCompRow::OpqDoor);
   16193           22 :         resCellsUsd(LoadCompCol::SensDelay, LoadCompRow::OpqDoor) = true;
   16194              :     }
   16195           24 : }
   16196              : 
   16197              : // for the load summary report add values the peak conditions subtable
   16198           25 : void CollectPeakZoneConditions(EnergyPlusData &state,
   16199              :                                CompLoadTablesType &compLoad,
   16200              :                                int const desDaySelected,
   16201              :                                int const timeOfMax,
   16202              :                                int const zoneIndex,
   16203              :                                bool const isCooling,
   16204              :                                int const spaceIndex)
   16205              : {
   16206              : 
   16207           25 :     if (timeOfMax != 0) {
   16208              : 
   16209           23 :         auto const &thisZone = state.dataHeatBal->Zone(zoneIndex);
   16210           23 :         Real64 mult = thisZone.Multiplier * thisZone.ListMultiplier;
   16211              :         auto const &szCalcFinalSizing =
   16212           23 :             (spaceIndex == 0) ? state.dataSize->CalcFinalZoneSizing(zoneIndex) : state.dataSize->CalcFinalSpaceSizing(spaceIndex);
   16213           23 :         auto const &szFinalSizing = (spaceIndex == 0) ? state.dataSize->FinalZoneSizing(zoneIndex) : state.dataSize->FinalSpaceSizing(spaceIndex);
   16214              : 
   16215           23 :         if (mult == 0.0) {
   16216            0 :             mult = 1.0;
   16217              :         }
   16218              : 
   16219           23 :         if (isCooling) {
   16220              :             // Time of Peak Load
   16221           12 :             if ((desDaySelected > 0) && ((size_t)desDaySelected <= state.dataWeather->DesDayInput.size())) {
   16222           36 :                 compLoad.peakDateHrMin = format("{}/{} {}",
   16223           12 :                                                 state.dataWeather->DesDayInput(desDaySelected).Month,
   16224           12 :                                                 state.dataWeather->DesDayInput(desDaySelected).DayOfMonth,
   16225           24 :                                                 state.dataRptCoilSelection->coilSelectionReportObj->getTimeText(state, timeOfMax));
   16226              :             } else {
   16227            0 :                 compLoad.peakDateHrMin = szCalcFinalSizing.CoolPeakDateHrMin;
   16228              :             }
   16229              : 
   16230              :             // Outside Dry Bulb Temperature
   16231           12 :             compLoad.outsideDryBulb = szCalcFinalSizing.CoolOutTempSeq(timeOfMax);
   16232              : 
   16233              :             // Outside Wet Bulb Temperature
   16234              :             // use standard air pressure because air pressure is not tracked with sizing data
   16235           12 :             if (szCalcFinalSizing.CoolOutHumRatSeq(timeOfMax) < 1.0 && szCalcFinalSizing.CoolOutHumRatSeq(timeOfMax) > 0.0) {
   16236           24 :                 compLoad.outsideWetBulb = Psychrometrics::PsyTwbFnTdbWPb(
   16237           12 :                     state, szCalcFinalSizing.CoolOutTempSeq(timeOfMax), szCalcFinalSizing.CoolOutHumRatSeq(timeOfMax), state.dataEnvrn->StdBaroPress);
   16238              :             }
   16239              : 
   16240              :             // Outside Humidity Ratio at Peak
   16241           12 :             compLoad.outsideHumRatio = szCalcFinalSizing.CoolOutHumRatSeq(timeOfMax);
   16242              : 
   16243              :             // Zone Dry Bulb Temperature
   16244           12 :             compLoad.zoneDryBulb = szCalcFinalSizing.CoolZoneTempSeq(timeOfMax);
   16245              : 
   16246              :             // Zone Relative Humidity
   16247              :             // use standard air pressure because air pressure is not tracked with sizing data
   16248           12 :             compLoad.zoneRelHum = Psychrometrics::PsyRhFnTdbWPb(
   16249           12 :                 state, szCalcFinalSizing.CoolZoneTempSeq(timeOfMax), szCalcFinalSizing.CoolZoneHumRatSeq(timeOfMax), state.dataEnvrn->StdBaroPress);
   16250              : 
   16251              :             // Zone Humidity Ratio at Peak
   16252           12 :             compLoad.zoneHumRatio = szCalcFinalSizing.CoolZoneHumRatSeq(timeOfMax);
   16253              : 
   16254              :             // Peak Design Sensible Load
   16255           12 :             compLoad.peakDesSensLoad = szCalcFinalSizing.DesCoolLoad / mult; // change sign
   16256              : 
   16257              :             // Design Peak Load
   16258           12 :             compLoad.designPeakLoad = szFinalSizing.DesCoolLoad / mult;
   16259              : 
   16260              :             // Supply air temperature
   16261           12 :             if (szCalcFinalSizing.ZnCoolDgnSAMethod == DataSizing::SupplyAirTemperature) {
   16262           12 :                 compLoad.supAirTemp = szCalcFinalSizing.CoolDesTemp;
   16263              :             } else {
   16264            0 :                 Real64 DeltaTemp = -std::abs(szCalcFinalSizing.CoolDesTempDiff);
   16265            0 :                 compLoad.supAirTemp = DeltaTemp + szCalcFinalSizing.ZoneTempAtCoolPeak;
   16266              :             }
   16267              : 
   16268              :             // Main fan air flow
   16269           12 :             compLoad.mainFanAirFlow = szCalcFinalSizing.DesCoolVolFlow;
   16270              : 
   16271              :         } else {
   16272              :             // Time of Peak Load
   16273           11 :             if ((size_t)desDaySelected <= state.dataWeather->DesDayInput.size()) {
   16274           33 :                 compLoad.peakDateHrMin = format("{}/{} {}",
   16275           11 :                                                 state.dataWeather->DesDayInput(desDaySelected).Month,
   16276           11 :                                                 state.dataWeather->DesDayInput(desDaySelected).DayOfMonth,
   16277           22 :                                                 state.dataRptCoilSelection->coilSelectionReportObj->getTimeText(state, timeOfMax));
   16278              :             } else {
   16279            0 :                 compLoad.peakDateHrMin = szCalcFinalSizing.HeatPeakDateHrMin;
   16280              :             }
   16281              : 
   16282              :             // Outside Dry Bulb Temperature
   16283           11 :             compLoad.outsideDryBulb = szCalcFinalSizing.HeatOutTempSeq(timeOfMax);
   16284              : 
   16285              :             // Outside Wet Bulb Temperature
   16286              :             // use standard air pressure because air pressure is not tracked with sizing data
   16287           11 :             if (szCalcFinalSizing.HeatOutHumRatSeq(timeOfMax) < 1.0 && szCalcFinalSizing.HeatOutHumRatSeq(timeOfMax) > 0.0) {
   16288           22 :                 compLoad.outsideWetBulb = Psychrometrics::PsyTwbFnTdbWPb(
   16289           11 :                     state, szCalcFinalSizing.HeatOutTempSeq(timeOfMax), szCalcFinalSizing.HeatOutHumRatSeq(timeOfMax), state.dataEnvrn->StdBaroPress);
   16290              :             }
   16291              : 
   16292              :             // Outside Humidity Ratio at Peak
   16293           11 :             compLoad.outsideHumRatio = szCalcFinalSizing.HeatOutHumRatSeq(timeOfMax);
   16294              : 
   16295              :             // Zone Dry Bulb Temperature
   16296           11 :             compLoad.zoneDryBulb = szCalcFinalSizing.HeatZoneTempSeq(timeOfMax);
   16297              : 
   16298              :             // Zone Relative Humidity
   16299              :             // use standard air pressure because air pressure is not tracked with sizing data
   16300           11 :             compLoad.zoneRelHum = Psychrometrics::PsyRhFnTdbWPb(
   16301           11 :                 state, szCalcFinalSizing.HeatZoneTempSeq(timeOfMax), szCalcFinalSizing.HeatZoneHumRatSeq(timeOfMax), state.dataEnvrn->StdBaroPress);
   16302              : 
   16303              :             // Zone Humidity Ratio at Peak
   16304           11 :             compLoad.zoneHumRatio = szCalcFinalSizing.HeatZoneHumRatSeq(timeOfMax);
   16305              : 
   16306              :             // Peak Design Sensible Load
   16307           11 :             compLoad.peakDesSensLoad = -szCalcFinalSizing.DesHeatLoad / mult; // change sign
   16308              : 
   16309              :             // Design Peak Load
   16310           11 :             compLoad.designPeakLoad = -szFinalSizing.DesHeatLoad / mult;
   16311              : 
   16312              :             // Supply air temperature
   16313           11 :             if (szCalcFinalSizing.ZnHeatDgnSAMethod == DataSizing::SupplyAirTemperature) {
   16314           11 :                 compLoad.supAirTemp = szCalcFinalSizing.HeatDesTemp;
   16315              :             } else {
   16316            0 :                 Real64 DeltaTemp = -std::abs(szCalcFinalSizing.HeatDesTempDiff);
   16317            0 :                 compLoad.supAirTemp = DeltaTemp + szCalcFinalSizing.ZoneTempAtHeatPeak;
   16318              :             }
   16319              : 
   16320              :             // Main fan air flow
   16321           11 :             compLoad.mainFanAirFlow = szCalcFinalSizing.DesHeatVolFlow;
   16322              :         }
   16323              : 
   16324              :         // Outside air flow
   16325           23 :         compLoad.outsideAirFlow = szCalcFinalSizing.MinOA;
   16326              : 
   16327              :         // outside air %
   16328           23 :         if (compLoad.mainFanAirFlow != 0.) {
   16329           21 :             compLoad.outsideAirRatio = compLoad.outsideAirFlow / compLoad.mainFanAirFlow;
   16330              :         }
   16331              : 
   16332           23 :         compLoad.floorArea = thisZone.FloorArea;
   16333              : 
   16334           23 :         if (compLoad.floorArea != 0.) {
   16335              :             // airflow per floor area
   16336           23 :             compLoad.airflowPerFlrArea = compLoad.mainFanAirFlow / compLoad.floorArea;
   16337              : 
   16338              :             // capacity per floor area
   16339           23 :             compLoad.totCapPerArea = compLoad.designPeakLoad / compLoad.floorArea;
   16340              :         }
   16341           23 :         if (compLoad.designPeakLoad != 0.) {
   16342              :             // airflow per capacity
   16343           21 :             compLoad.airflowPerTotCap = compLoad.mainFanAirFlow / compLoad.designPeakLoad;
   16344              : 
   16345              :             // floor area per capacity
   16346           21 :             compLoad.areaPerTotCap = thisZone.FloorArea / compLoad.designPeakLoad;
   16347              :         }
   16348              : 
   16349              :         // Number of people
   16350           23 :         Real64 totNumPeople = 0;
   16351           23 :         if (spaceIndex == 0) {
   16352           23 :             totNumPeople = std::accumulate(state.dataHeatBal->People.cbegin(),
   16353           46 :                                            state.dataHeatBal->People.cend(),
   16354              :                                            0.0,
   16355           24 :                                            [&zoneIndex](const Real64 &sum, const DataHeatBalance::PeopleData &people) {
   16356           24 :                                                return zoneIndex == people.ZonePtr ? (sum + people.NumberOfPeople) : sum;
   16357              :                                            });
   16358              :         } else {
   16359            0 :             totNumPeople = std::accumulate(state.dataHeatBal->People.cbegin(),
   16360            0 :                                            state.dataHeatBal->People.cend(),
   16361              :                                            0.0,
   16362            0 :                                            [&spaceIndex](const Real64 &sum, const DataHeatBalance::PeopleData &people) {
   16363            0 :                                                return spaceIndex == people.spaceIndex ? (sum + people.NumberOfPeople) : sum;
   16364              :                                            });
   16365              :         }
   16366           23 :         compLoad.numPeople = totNumPeople;
   16367              :     }
   16368           25 : }
   16369              : 
   16370           23 : void ComputeEngineeringChecks(CompLoadTablesType &compLoad)
   16371              : {
   16372              :     // outside air %
   16373           23 :     if (compLoad.mainFanAirFlow != 0.) {
   16374           16 :         compLoad.outsideAirRatio = compLoad.outsideAirFlow / compLoad.mainFanAirFlow;
   16375              :     }
   16376              : 
   16377           23 :     if (compLoad.floorArea != 0.) {
   16378              :         // airflow per floor area
   16379           17 :         compLoad.airflowPerFlrArea = compLoad.mainFanAirFlow / compLoad.floorArea;
   16380              : 
   16381              :         // capacity per floor area
   16382           17 :         compLoad.totCapPerArea = compLoad.designPeakLoad / compLoad.floorArea;
   16383              :     }
   16384           23 :     if (compLoad.designPeakLoad != 0.) {
   16385              :         // airflow per capacity
   16386           13 :         compLoad.airflowPerTotCap = compLoad.mainFanAirFlow / compLoad.designPeakLoad;
   16387              : 
   16388              :         // floor area per capacity
   16389           13 :         compLoad.areaPerTotCap = compLoad.floorArea / compLoad.designPeakLoad;
   16390              :     }
   16391           23 : }
   16392              : 
   16393              : // gather the areas used in the load component tables
   16394            8 : void GetZoneComponentAreas(EnergyPlusData &state, Array1D<ZompComponentAreasType> &znAreas, Array1D<ZompComponentAreasType> &spAreas)
   16395              : {
   16396           15 :     for (int iZone = 1; iZone <= state.dataGlobal->NumOfZones; ++iZone) {
   16397            7 :         znAreas(iZone).floor = state.dataHeatBal->Zone(iZone).FloorArea;
   16398              :     }
   16399            8 :     if (state.dataHeatBal->doSpaceHeatBalanceSizing) {
   16400            0 :         for (int iSpace = 1; iSpace <= state.dataGlobal->numSpaces; ++iSpace) {
   16401            0 :             spAreas(iSpace).floor = state.dataHeatBal->space(iSpace).FloorArea;
   16402              :         }
   16403              :     }
   16404              : 
   16405            8 :     bool isZone = true;
   16406           54 :     for (auto const &curSurface : state.dataSurface->Surface) {
   16407           46 :         if (!curSurface.HeatTransSurf) {
   16408            0 :             continue;
   16409              :         }
   16410           46 :         addSurfaceArea(curSurface, znAreas, isZone);
   16411            8 :     }
   16412            8 :     if (state.dataHeatBal->doSpaceHeatBalanceSizing) {
   16413            0 :         isZone = false;
   16414            0 :         for (auto const &curSurface : state.dataSurface->Surface) {
   16415            0 :             addSurfaceArea(curSurface, spAreas, isZone);
   16416            0 :         }
   16417              :     }
   16418            8 : }
   16419           46 : void addSurfaceArea(DataSurfaces::SurfaceData const &surf, Array1D<ZompComponentAreasType> &areas, bool isZone)
   16420              : {
   16421           46 :     bool isExterior = surf.ExtBoundCond == DataSurfaces::ExternalEnvironment || surf.ExtBoundCond == DataSurfaces::OtherSideCondModeledExt;
   16422           88 :     bool isTouchingGround = surf.ExtBoundCond == DataSurfaces::Ground || surf.ExtBoundCond == DataSurfaces::GroundFCfactorMethod ||
   16423           42 :                             surf.ExtBoundCond == DataSurfaces::KivaFoundation;
   16424           46 :     int curIndex = (isZone) ? surf.Zone : surf.spaceNum;
   16425           46 :     switch (surf.Class) {
   16426           23 :     case DataSurfaces::SurfaceClass::Wall: {
   16427           23 :         if (isExterior) {
   16428           15 :             areas(curIndex).extWall += surf.GrossArea;
   16429            8 :         } else if (isTouchingGround) {
   16430            1 :             areas(curIndex).grndCntWall += surf.GrossArea;
   16431              :         } else {
   16432            7 :             areas(curIndex).intZoneWall += surf.GrossArea;
   16433              :         }
   16434           23 :     } break;
   16435            7 :     case DataSurfaces::SurfaceClass::Roof: {
   16436            7 :         if (isExterior) {
   16437            6 :             areas(curIndex).roof += surf.GrossArea;
   16438              :         } else {
   16439            1 :             areas(curIndex).ceiling += surf.GrossArea;
   16440              :         }
   16441            7 :     } break;
   16442            9 :     case DataSurfaces::SurfaceClass::Floor: {
   16443            9 :         if (isExterior) {
   16444            1 :             areas(curIndex).extFloor += surf.GrossArea;
   16445            8 :         } else if (isTouchingGround) {
   16446            4 :             areas(curIndex).grndCntFloor += surf.GrossArea;
   16447              :         } else {
   16448            4 :             areas(curIndex).intZoneFloor += surf.GrossArea;
   16449              :         }
   16450            9 :     } break;
   16451            5 :     case DataSurfaces::SurfaceClass::Window:
   16452              :     case DataSurfaces::SurfaceClass::TDD_Dome: {
   16453            5 :         areas(curIndex).fenestration += surf.GrossArea;
   16454            5 :     } break;
   16455            2 :     case DataSurfaces::SurfaceClass::Door:
   16456              :     case DataSurfaces::SurfaceClass::GlassDoor: {
   16457            2 :         areas(curIndex).door += surf.GrossArea;
   16458            2 :     } break;
   16459              :     }
   16460           46 : }
   16461              : 
   16462              : // adds the area column for the load component tables
   16463           24 : void AddAreaColumnForZone(ZompComponentAreasType const &compAreas, CompLoadTablesType &compLoad)
   16464              : {
   16465           24 :     compLoad.cells(LoadCompCol::Area, LoadCompRow::People) = compAreas.floor;
   16466           24 :     compLoad.cellUsed(LoadCompCol::Area, LoadCompRow::People) = true;
   16467              : 
   16468           24 :     compLoad.cells(LoadCompCol::Area, LoadCompRow::Lights) = compAreas.floor;
   16469           24 :     compLoad.cellUsed(LoadCompCol::Area, LoadCompRow::Lights) = true;
   16470              : 
   16471           24 :     compLoad.cells(LoadCompCol::Area, LoadCompRow::Equip) = compAreas.floor;
   16472           24 :     compLoad.cellUsed(LoadCompCol::Area, LoadCompRow::Equip) = true;
   16473              : 
   16474           24 :     compLoad.cells(LoadCompCol::Area, LoadCompRow::Refrig) = compAreas.floor;
   16475           24 :     compLoad.cellUsed(LoadCompCol::Area, LoadCompRow::Refrig) = true;
   16476              : 
   16477           24 :     compLoad.cells(LoadCompCol::Area, LoadCompRow::WaterUse) = compAreas.floor;
   16478           24 :     compLoad.cellUsed(LoadCompCol::Area, LoadCompRow::WaterUse) = true;
   16479              : 
   16480           24 :     compLoad.cells(LoadCompCol::Area, LoadCompRow::Infil) = compAreas.extWall;
   16481           24 :     compLoad.cellUsed(LoadCompCol::Area, LoadCompRow::Infil) = true;
   16482              : 
   16483           24 :     compLoad.cells(LoadCompCol::Area, LoadCompRow::Roof) = compAreas.roof;
   16484           24 :     compLoad.cellUsed(LoadCompCol::Area, LoadCompRow::Roof) = true;
   16485              : 
   16486           24 :     compLoad.cells(LoadCompCol::Area, LoadCompRow::IntZonCeil) = compAreas.ceiling;
   16487           24 :     compLoad.cellUsed(LoadCompCol::Area, LoadCompRow::IntZonCeil) = true;
   16488              : 
   16489           24 :     compLoad.cells(LoadCompCol::Area, LoadCompRow::OtherRoof) = compAreas.roof;
   16490           24 :     compLoad.cellUsed(LoadCompCol::Area, LoadCompRow::OtherRoof) = true;
   16491              : 
   16492           24 :     compLoad.cells(LoadCompCol::Area, LoadCompRow::ExtWall) = compAreas.extWall;
   16493           24 :     compLoad.cellUsed(LoadCompCol::Area, LoadCompRow::ExtWall) = true;
   16494              : 
   16495           24 :     compLoad.cells(LoadCompCol::Area, LoadCompRow::IntZonWall) = compAreas.intZoneWall;
   16496           24 :     compLoad.cellUsed(LoadCompCol::Area, LoadCompRow::IntZonWall) = true;
   16497              : 
   16498           24 :     compLoad.cells(LoadCompCol::Area, LoadCompRow::GrdWall) = compAreas.grndCntWall;
   16499           24 :     compLoad.cellUsed(LoadCompCol::Area, LoadCompRow::GrdWall) = true;
   16500              : 
   16501           24 :     compLoad.cells(LoadCompCol::Area, LoadCompRow::OtherWall) = compAreas.extWall;
   16502           24 :     compLoad.cellUsed(LoadCompCol::Area, LoadCompRow::OtherWall) = true;
   16503              : 
   16504           24 :     compLoad.cells(LoadCompCol::Area, LoadCompRow::ExtFlr) = compAreas.extFloor;
   16505           24 :     compLoad.cellUsed(LoadCompCol::Area, LoadCompRow::ExtFlr) = true;
   16506              : 
   16507           24 :     compLoad.cells(LoadCompCol::Area, LoadCompRow::IntZonFlr) = compAreas.intZoneFloor;
   16508           24 :     compLoad.cellUsed(LoadCompCol::Area, LoadCompRow::IntZonFlr) = true;
   16509              : 
   16510           24 :     compLoad.cells(LoadCompCol::Area, LoadCompRow::GrdFlr) = compAreas.grndCntFloor;
   16511           24 :     compLoad.cellUsed(LoadCompCol::Area, LoadCompRow::GrdFlr) = true;
   16512              : 
   16513           24 :     compLoad.cells(LoadCompCol::Area, LoadCompRow::OtherFlr) = compAreas.intZoneFloor;
   16514           24 :     compLoad.cellUsed(LoadCompCol::Area, LoadCompRow::OtherFlr) = true;
   16515              : 
   16516           24 :     compLoad.cells(LoadCompCol::Area, LoadCompRow::FeneCond) = compAreas.fenestration;
   16517           24 :     compLoad.cellUsed(LoadCompCol::Area, LoadCompRow::FeneCond) = true;
   16518              : 
   16519           24 :     compLoad.cells(LoadCompCol::Area, LoadCompRow::FeneSolr) = compAreas.fenestration;
   16520           24 :     compLoad.cellUsed(LoadCompCol::Area, LoadCompRow::FeneSolr) = true;
   16521              : 
   16522           24 :     compLoad.cells(LoadCompCol::Area, LoadCompRow::OpqDoor) = compAreas.door;
   16523           24 :     compLoad.cellUsed(LoadCompCol::Area, LoadCompRow::OpqDoor) = true;
   16524           24 : }
   16525              : 
   16526              : // Used for the AirLoop and Facility level load component tables to sum the results from individual zones
   16527           23 : void CombineLoadCompResults(CompLoadTablesType &compLoadTotal, CompLoadTablesType const &compLoadPartial, Real64 const multiplier)
   16528              : {
   16529              :     // sum the main results
   16530          207 :     for (int col = 1; col <= LoadCompCol::PerArea; ++col) {
   16531         4968 :         for (int row = 1; row <= LoadCompRow::GrdTot; ++row) {
   16532         4784 :             compLoadTotal.cells(col, row) += compLoadPartial.cells(col, row) * multiplier;
   16533         4784 :             compLoadTotal.cellUsed(col, row) = compLoadTotal.cellUsed(col, row) || compLoadPartial.cellUsed(col, row);
   16534              :         }
   16535              :     }
   16536              : 
   16537              :     // take the partial value for these
   16538           23 :     compLoadTotal.desDayNum = compLoadPartial.desDayNum;
   16539           23 :     compLoadTotal.timeStepMax = compLoadPartial.timeStepMax;
   16540           23 :     compLoadTotal.peakDateHrMin = compLoadPartial.peakDateHrMin;
   16541           23 :     compLoadTotal.outsideDryBulb = compLoadPartial.outsideDryBulb;
   16542           23 :     compLoadTotal.outsideWetBulb = compLoadPartial.outsideWetBulb;
   16543           23 :     compLoadTotal.outsideHumRatio = compLoadPartial.outsideHumRatio;
   16544           23 :     compLoadTotal.zoneDryBulb = compLoadPartial.zoneDryBulb;
   16545           23 :     compLoadTotal.zoneRelHum = compLoadPartial.zoneRelHum;
   16546           23 :     compLoadTotal.zoneHumRatio = compLoadPartial.zoneHumRatio;
   16547           23 :     compLoadTotal.supAirTemp = compLoadPartial.supAirTemp;
   16548              : 
   16549              :     // sum the peak related values
   16550           23 :     compLoadTotal.designPeakLoad += compLoadPartial.designPeakLoad * multiplier;
   16551           23 :     compLoadTotal.diffDesignPeak += compLoadPartial.diffDesignPeak * multiplier;
   16552           23 :     compLoadTotal.peakDesSensLoad += compLoadPartial.peakDesSensLoad * multiplier;
   16553           23 :     compLoadTotal.estInstDelSensLoad += compLoadPartial.estInstDelSensLoad * multiplier;
   16554           23 :     compLoadTotal.diffPeakEst += compLoadPartial.diffPeakEst * multiplier;
   16555           23 :     compLoadTotal.mainFanAirFlow += compLoadPartial.mainFanAirFlow * multiplier;
   16556           23 :     compLoadTotal.outsideAirFlow += compLoadPartial.outsideAirFlow * multiplier;
   16557              : 
   16558              :     // sum the engineering checks
   16559           23 :     compLoadTotal.numPeople += compLoadPartial.numPeople * multiplier;
   16560           23 :     compLoadTotal.floorArea += compLoadPartial.floorArea * multiplier;
   16561           23 : }
   16562              : 
   16563              : // create the total row and total columns for the load summary tables
   16564           35 : void AddTotalRowsForLoadSummary(CompLoadTablesType &compLoadTotal)
   16565              : {
   16566              : 
   16567              :     // zero the grand total -total cell
   16568           35 :     compLoadTotal.cells(LoadCompCol::Total, LoadCompRow::GrdTot) = 0.;
   16569           35 :     compLoadTotal.cellUsed(LoadCompCol::Total, LoadCompRow::GrdTot) = true;
   16570              : 
   16571              :     // zero the grand total row
   16572          175 :     for (int col = 1; col <= LoadCompCol::Latent; ++col) {
   16573          140 :         compLoadTotal.cells(col, LoadCompRow::GrdTot) = 0.;
   16574          140 :         compLoadTotal.cellUsed(col, LoadCompRow::GrdTot) = true;
   16575              :     }
   16576              : 
   16577          910 :     for (int row = 1; row <= LoadCompRow::OpqDoor; ++row) {
   16578              :         // zero the total column
   16579          875 :         compLoadTotal.cells(LoadCompCol::Total, row) = 0.;
   16580          875 :         compLoadTotal.cellUsed(LoadCompCol::Total, row) = true;
   16581         4375 :         for (int col = 1; col <= LoadCompCol::Latent; ++col) {
   16582              :             // add the cell to the grand total row and total column
   16583         3500 :             if (compLoadTotal.cellUsed(col, row)) {
   16584         1220 :                 compLoadTotal.cells(LoadCompCol::Total, row) += compLoadTotal.cells(col, row);
   16585         1220 :                 compLoadTotal.cells(col, LoadCompRow::GrdTot) += compLoadTotal.cells(col, row);
   16586         1220 :                 compLoadTotal.cells(LoadCompCol::Total, LoadCompRow::GrdTot) += compLoadTotal.cells(col, row);
   16587              :             }
   16588              :         }
   16589              :     }
   16590              : 
   16591              :     // compute the % grand total column
   16592           35 :     Real64 grandTotalTotal = compLoadTotal.cells(LoadCompCol::Total, LoadCompRow::GrdTot);
   16593           35 :     if (grandTotalTotal != 0.0) {
   16594          598 :         for (int row = 1; row <= LoadCompRow::OpqDoor; ++row) {
   16595          575 :             compLoadTotal.cells(LoadCompCol::Perc, row) = 100 * compLoadTotal.cells(LoadCompCol::Total, row) / grandTotalTotal;
   16596          575 :             compLoadTotal.cellUsed(LoadCompCol::Perc, row) = true;
   16597              :         }
   16598              :     }
   16599              :     // compute the Total per Area column
   16600          910 :     for (int row = 1; row <= LoadCompRow::OpqDoor; ++row) {
   16601          875 :         if (compLoadTotal.cellUsed(LoadCompCol::Total, row) && compLoadTotal.cells(LoadCompCol::Area, row) != 0.) {
   16602          704 :             compLoadTotal.cells(LoadCompCol::PerArea, row) =
   16603          352 :                 compLoadTotal.cells(LoadCompCol::Total, row) / compLoadTotal.cells(LoadCompCol::Area, row);
   16604          352 :             compLoadTotal.cellUsed(LoadCompCol::PerArea, row) = true;
   16605              :         }
   16606              :     }
   16607           35 : }
   16608              : 
   16609              : // compute the peak difference between actual and estimated load in load component summary peak conditions table
   16610           34 : void ComputePeakDifference(CompLoadTablesType &compLoad)
   16611              : {
   16612              :     // Estimated Instant + Delayed Sensible Load
   16613           34 :     compLoad.estInstDelSensLoad =
   16614           34 :         compLoad.cells(LoadCompCol::SensInst, LoadCompRow::GrdTot) + compLoad.cells(LoadCompCol::SensDelay, LoadCompRow::GrdTot);
   16615              : 
   16616              :     // Difference
   16617           34 :     compLoad.diffPeakEst = compLoad.peakDesSensLoad - compLoad.estInstDelSensLoad;
   16618              : 
   16619              :     // Peak Design Diff
   16620           34 :     compLoad.diffDesignPeak = compLoad.designPeakLoad - compLoad.peakDesSensLoad;
   16621           34 : }
   16622              : 
   16623              : // apply unit conversions to the load components summary tables
   16624            1 : void LoadSummaryUnitConversion(EnergyPlusData &state, CompLoadTablesType &compLoadTotal)
   16625              : {
   16626            1 :     auto const &ort = state.dataOutRptTab;
   16627              : 
   16628            1 :     if (!ort->ip()) {
   16629            0 :         return;
   16630              :     }
   16631              : 
   16632            4 :     Real64 const powerConversion = getSpecificUnitMultiplier(state, "W", "Btu/h");
   16633            4 :     Real64 const areaConversion = getSpecificUnitMultiplier(state, "m2", "ft2");
   16634            4 :     Real64 const powerPerAreaConversion = getSpecificUnitMultiplier(state, "W/m2", "Btu/h-ft2");
   16635            4 :     Real64 const airFlowConversion = getSpecificUnitMultiplier(state, "m3/s", "ft3/min");
   16636            4 :     Real64 const airFlowPerAreaConversion = getSpecificUnitMultiplier(state, "m3/s-m2", "ft3/min-ft2");
   16637            3 :     Real64 const powerPerFlowLiquidConversion = getSpecificUnitMultiplier(state, "W-s/m3", "W-min/gal");
   16638           27 :     for (int row = 1; row <= LoadCompRow::GrdTot; ++row) {
   16639          156 :         for (int col = 1; col <= LoadCompCol::Total; ++col) {
   16640          130 :             if (compLoadTotal.cellUsed(col, row)) {
   16641          130 :                 compLoadTotal.cells(col, row) *= powerConversion;
   16642              :             }
   16643              :         }
   16644           26 :         if (compLoadTotal.cellUsed(LoadCompCol::PerArea, row)) {
   16645           26 :             compLoadTotal.cells(LoadCompCol::PerArea, row) *= powerConversion;
   16646              :         }
   16647           26 :         if (compLoadTotal.cellUsed(LoadCompCol::Area, row)) {
   16648           26 :             compLoadTotal.cells(LoadCompCol::Area, row) *= areaConversion;
   16649              :         }
   16650           26 :         if (compLoadTotal.cellUsed(LoadCompCol::PerArea, row)) {
   16651           26 :             compLoadTotal.cells(LoadCompCol::PerArea, row) *= powerPerAreaConversion;
   16652              :         }
   16653              :     }
   16654            3 :     int const tempConvIndx = getSpecificUnitIndex(state, "C", "F");
   16655            1 :     compLoadTotal.outsideDryBulb = ConvertIP(state, tempConvIndx, compLoadTotal.outsideDryBulb);
   16656            1 :     compLoadTotal.outsideWetBulb = ConvertIP(state, tempConvIndx, compLoadTotal.outsideWetBulb);
   16657            1 :     compLoadTotal.zoneDryBulb = ConvertIP(state, tempConvIndx, compLoadTotal.zoneDryBulb);
   16658            1 :     compLoadTotal.peakDesSensLoad *= powerConversion;
   16659              : 
   16660            1 :     compLoadTotal.supAirTemp = ConvertIP(state, tempConvIndx, compLoadTotal.supAirTemp);
   16661            1 :     compLoadTotal.mixAirTemp = ConvertIP(state, tempConvIndx, compLoadTotal.mixAirTemp);
   16662            1 :     compLoadTotal.mainFanAirFlow *= airFlowConversion;
   16663            1 :     compLoadTotal.outsideAirFlow *= airFlowConversion;
   16664            1 :     compLoadTotal.designPeakLoad *= powerConversion;
   16665            1 :     compLoadTotal.diffDesignPeak *= powerConversion;
   16666              : 
   16667            1 :     compLoadTotal.estInstDelSensLoad *= powerConversion;
   16668            1 :     compLoadTotal.diffPeakEst *= powerConversion;
   16669              : 
   16670            1 :     compLoadTotal.airflowPerFlrArea *= airFlowPerAreaConversion;
   16671            1 :     if (powerConversion != 0.) {
   16672            1 :         compLoadTotal.airflowPerTotCap = compLoadTotal.airflowPerTotCap * airFlowPerAreaConversion / powerConversion;
   16673            1 :         compLoadTotal.areaPerTotCap = compLoadTotal.areaPerTotCap * areaConversion / powerConversion;
   16674              :     }
   16675            1 :     if (areaConversion != 0.) {
   16676            1 :         compLoadTotal.totCapPerArea = compLoadTotal.totCapPerArea * powerConversion / areaConversion;
   16677              :     }
   16678            1 :     compLoadTotal.chlPumpPerFlow *= powerPerFlowLiquidConversion;
   16679            1 :     compLoadTotal.cndPumpPerFlow *= powerPerFlowLiquidConversion;
   16680              : }
   16681              : 
   16682              : // Jan 2021: Overloaded the function with additional parameters for dual units;
   16683              : //           used overloading since the original function was checked in an existing test unit.
   16684              : // apply unit conversions to the load components summary tables
   16685           35 : void LoadSummaryUnitConversion(EnergyPlusData &state, CompLoadTablesType &compLoadTotal, UnitsStyle unitsStyle_para)
   16686              : {
   16687           35 :     if (unitsStyle_para == OutputReportTabular::UnitsStyle::InchPound ||
   16688              :         unitsStyle_para == OutputReportTabular::UnitsStyle::InchPoundExceptElectricity) {
   16689           52 :         Real64 powerConversion = getSpecificUnitMultiplier(state, "W", "Btu/h");
   16690           52 :         Real64 areaConversion = getSpecificUnitMultiplier(state, "m2", "ft2");
   16691           52 :         Real64 powerPerAreaConversion = getSpecificUnitMultiplier(state, "W/m2", "Btu/h-ft2");
   16692           52 :         Real64 airFlowConversion = getSpecificUnitMultiplier(state, "m3/s", "ft3/min");
   16693           52 :         Real64 airFlowPerAreaConversion = getSpecificUnitMultiplier(state, "m3/s-m2", "ft3/min-ft2");
   16694           39 :         Real64 powerPerFlowLiquidConversion = getSpecificUnitMultiplier(state, "W-s/m3", "W-min/gal");
   16695          351 :         for (int row = 1; row <= LoadCompRow::GrdTot; ++row) {
   16696         2028 :             for (int col = 1; col <= LoadCompCol::Total; ++col) {
   16697         1690 :                 if (compLoadTotal.cellUsed(col, row)) {
   16698          970 :                     compLoadTotal.cells(col, row) *= powerConversion;
   16699              :                 }
   16700              :             }
   16701          338 :             if (compLoadTotal.cellUsed(LoadCompCol::PerArea, row)) {
   16702          140 :                 compLoadTotal.cells(LoadCompCol::PerArea, row) *= powerConversion;
   16703              :             }
   16704          338 :             if (compLoadTotal.cellUsed(LoadCompCol::Area, row)) {
   16705          266 :                 compLoadTotal.cells(LoadCompCol::Area, row) *= areaConversion;
   16706              :             }
   16707          338 :             if (compLoadTotal.cellUsed(LoadCompCol::PerArea, row)) {
   16708          140 :                 compLoadTotal.cells(LoadCompCol::PerArea, row) *= powerPerAreaConversion;
   16709              :             }
   16710              :         }
   16711           39 :         int tempConvIndx = getSpecificUnitIndex(state, "C", "F");
   16712           13 :         compLoadTotal.outsideDryBulb = ConvertIP(state, tempConvIndx, compLoadTotal.outsideDryBulb);
   16713           13 :         compLoadTotal.outsideWetBulb = ConvertIP(state, tempConvIndx, compLoadTotal.outsideWetBulb);
   16714           13 :         compLoadTotal.zoneDryBulb = ConvertIP(state, tempConvIndx, compLoadTotal.zoneDryBulb);
   16715           13 :         compLoadTotal.peakDesSensLoad *= powerConversion;
   16716              : 
   16717           13 :         compLoadTotal.supAirTemp = ConvertIP(state, tempConvIndx, compLoadTotal.supAirTemp);
   16718           13 :         compLoadTotal.mixAirTemp = ConvertIP(state, tempConvIndx, compLoadTotal.mixAirTemp);
   16719           13 :         compLoadTotal.mainFanAirFlow *= airFlowConversion;
   16720           13 :         compLoadTotal.outsideAirFlow *= airFlowConversion;
   16721           13 :         compLoadTotal.designPeakLoad *= powerConversion;
   16722           13 :         compLoadTotal.diffDesignPeak *= powerConversion;
   16723              : 
   16724           13 :         compLoadTotal.estInstDelSensLoad *= powerConversion;
   16725           13 :         compLoadTotal.diffPeakEst *= powerConversion;
   16726              : 
   16727           13 :         compLoadTotal.airflowPerFlrArea *= airFlowPerAreaConversion;
   16728           13 :         if (powerConversion != 0.) {
   16729           13 :             compLoadTotal.airflowPerTotCap = compLoadTotal.airflowPerTotCap * airFlowPerAreaConversion / powerConversion;
   16730           13 :             compLoadTotal.areaPerTotCap = compLoadTotal.areaPerTotCap * areaConversion / powerConversion;
   16731              :         }
   16732           13 :         if (areaConversion != 0.) {
   16733           13 :             compLoadTotal.totCapPerArea = compLoadTotal.totCapPerArea * powerConversion / areaConversion;
   16734              :         }
   16735           13 :         compLoadTotal.chlPumpPerFlow *= powerPerFlowLiquidConversion;
   16736           13 :         compLoadTotal.cndPumpPerFlow *= powerPerFlowLiquidConversion;
   16737              :     }
   16738           35 : }
   16739              : 
   16740              : // make a list of the zones for the airloop component loads report
   16741           15 : void CreateListOfZonesForAirLoop(EnergyPlusData const &state, CompLoadTablesType &compLoad, Array1D_int const &zoneToAirLoop, int const curAirLoop)
   16742              : {
   16743           15 :     int counter = 0;
   16744           70 :     for (int zi = 1; zi <= state.dataGlobal->NumOfZones; ++zi) {
   16745           55 :         if (zoneToAirLoop(zi) == curAirLoop) {
   16746           25 :             ++counter;
   16747           25 :             compLoad.zoneIndices(counter) = zi;
   16748              :         }
   16749              :     }
   16750           15 : }
   16751              : 
   16752              : // Jan 2021: Added additional parameters to accommodate dual-unit reporting
   16753              : // provide output from the load component summary tables
   16754           17 : void OutputCompLoadSummary(EnergyPlusData &state,
   16755              :                            EnergyPlus::OutputReportTabular::OutputType const kind,
   16756              :                            CompLoadTablesType const &compLoadCool,
   16757              :                            CompLoadTablesType const &compLoadHeat,
   16758              :                            int const zoneOrAirLoopIndex,
   16759              :                            UnitsStyle unitsStyle_para,
   16760              :                            bool produceTabular_para,
   16761              :                            bool produceSQLite_para)
   16762              : {
   16763              : 
   16764           17 :     auto const &ort = state.dataOutRptTab;
   16765              : 
   16766           17 :     std::string reportName;
   16767           17 :     std::string zoneAirLoopFacilityName;
   16768           17 :     bool writeOutput = false;
   16769              : 
   16770           17 :     if (kind == OutputType::Space && ort->displayZoneComponentLoadSummary) {
   16771            0 :         reportName = "Space Component Load Summary";
   16772            0 :         zoneAirLoopFacilityName = state.dataHeatBal->space(zoneOrAirLoopIndex).Name;
   16773            0 :         writeOutput = true;
   16774           17 :     } else if (kind == OutputType::Zone && ort->displayZoneComponentLoadSummary) {
   16775            6 :         reportName = "Zone Component Load Summary";
   16776            6 :         zoneAirLoopFacilityName = state.dataHeatBal->Zone(zoneOrAirLoopIndex).Name;
   16777            6 :         writeOutput = true;
   16778           11 :     } else if (kind == OutputType::AirLoop && ort->displayAirLoopComponentLoadSummary) {
   16779            6 :         reportName = "AirLoop Component Load Summary";
   16780            6 :         zoneAirLoopFacilityName = state.dataSize->FinalSysSizing(zoneOrAirLoopIndex).AirPriLoopName;
   16781            6 :         writeOutput = true;
   16782            5 :     } else if (kind == OutputType::Facility && ort->displayFacilityComponentLoadSummary) {
   16783            5 :         reportName = "Facility Component Load Summary";
   16784            5 :         zoneAirLoopFacilityName = "Facility";
   16785            5 :         writeOutput = true;
   16786              :     } else {
   16787            0 :         writeOutput = false;
   16788              :     }
   16789              : 
   16790           17 :     if (!writeOutput) {
   16791            0 :         return;
   16792              :     }
   16793              : 
   16794           17 :     CompLoadTablesType curCompLoad;
   16795           17 :     Array1D_string columnHead;
   16796           17 :     Array1D_int columnWidth;
   16797           17 :     Array1D_string rowHead;
   16798           17 :     Array2D_string tableBody; //(row, column)
   16799              : 
   16800           17 :     if (produceTabular_para) {
   16801           16 :         WriteReportHeaders(state, reportName, zoneAirLoopFacilityName, OutputProcessor::StoreType::Average);
   16802              :     }
   16803           17 :     std::string peakLoadCompName;
   16804           17 :     std::string peakCondName;
   16805           17 :     std::string zonesIncludedName;
   16806           17 :     std::string engineeringCheckName;
   16807           51 :     for (int coolHeat = 1; coolHeat <= 2; ++coolHeat) {
   16808           34 :         tableBody.allocate(LoadCompCol::PerArea, LoadCompRow::GrdTot);
   16809           34 :         tableBody = "";
   16810           34 :         if (coolHeat == 1) {
   16811           17 :             curCompLoad = compLoadCool;
   16812           17 :             peakLoadCompName = "Estimated Cooling Peak Load Components";
   16813           17 :             peakCondName = "Cooling Peak Conditions";
   16814           17 :             zonesIncludedName = "Zones Included for Cooling";
   16815           17 :             engineeringCheckName = "Engineering Checks for Cooling";
   16816              :         } else {
   16817           17 :             curCompLoad = compLoadHeat;
   16818           17 :             peakLoadCompName = "Estimated Heating Peak Load Components";
   16819           17 :             peakCondName = "Heating Peak Conditions";
   16820           17 :             zonesIncludedName = "Zones Included for Heating";
   16821           17 :             engineeringCheckName = "Engineering Checks for Heating";
   16822              :         }
   16823              :         // move number array into string array
   16824          306 :         for (int c = 1; c <= LoadCompCol::PerArea; ++c) {
   16825         7344 :             for (int r = 1; r <= LoadCompRow::GrdTot; ++r) { // to last row before total
   16826         7072 :                 if (curCompLoad.cellUsed(c, r)) {
   16827         3640 :                     tableBody(c, r) = RealToStr(curCompLoad.cells(c, r), 2);
   16828              :                 }
   16829              :             }
   16830              :         }
   16831           34 :         rowHead.allocate(LoadCompRow::GrdTot);
   16832              :         // internal gains
   16833           34 :         rowHead(LoadCompRow::People) = "People";
   16834           34 :         rowHead(LoadCompRow::Lights) = "Lights";
   16835           34 :         rowHead(LoadCompRow::Equip) = "Equipment";
   16836           34 :         rowHead(LoadCompRow::Refrig) = "Refrigeration Equipment";
   16837           34 :         rowHead(LoadCompRow::WaterUse) = "Water Use Equipment";
   16838           34 :         rowHead(LoadCompRow::PowerGen) = "Power Generation Equipment";
   16839           34 :         rowHead(LoadCompRow::HvacLoss) = "HVAC Equipment Losses";
   16840           34 :         rowHead(LoadCompRow::Refrig) = "Refrigeration";
   16841              :         // misc
   16842           34 :         rowHead(LoadCompRow::DOAS) = "DOAS Direct to Zone";
   16843           34 :         rowHead(LoadCompRow::Infil) = "Infiltration";
   16844           34 :         rowHead(LoadCompRow::ZoneVent) = "Zone Ventilation";
   16845           34 :         rowHead(LoadCompRow::IntZonMix) = "Interzone Mixing";
   16846              :         // opaque surfaces
   16847           34 :         rowHead(LoadCompRow::Roof) = "Roof";
   16848           34 :         rowHead(LoadCompRow::IntZonCeil) = "Interzone Ceiling";
   16849           34 :         rowHead(LoadCompRow::OtherRoof) = "Other Roof";
   16850           34 :         rowHead(LoadCompRow::ExtWall) = "Exterior Wall";
   16851           34 :         rowHead(LoadCompRow::IntZonWall) = "Interzone Wall";
   16852           34 :         rowHead(LoadCompRow::GrdWall) = "Ground Contact Wall";
   16853           34 :         rowHead(LoadCompRow::OtherWall) = "Other Wall";
   16854           34 :         rowHead(LoadCompRow::ExtFlr) = "Exterior Floor";
   16855           34 :         rowHead(LoadCompRow::IntZonFlr) = "Interzone Floor";
   16856           34 :         rowHead(LoadCompRow::GrdFlr) = "Ground Contact Floor";
   16857           34 :         rowHead(LoadCompRow::OtherFlr) = "Other Floor";
   16858              :         // subsurfaces
   16859           34 :         rowHead(LoadCompRow::FeneCond) = "Fenestration Conduction";
   16860           34 :         rowHead(LoadCompRow::FeneSolr) = "Fenestration Solar";
   16861           34 :         rowHead(LoadCompRow::OpqDoor) = "Opaque Door";
   16862           34 :         rowHead(LoadCompRow::GrdTot) = "Grand Total";
   16863              : 
   16864           34 :         columnHead.allocate(LoadCompCol::PerArea);
   16865           34 :         if (!(unitsStyle_para == OutputReportTabular::UnitsStyle::InchPound ||
   16866              :               unitsStyle_para == OutputReportTabular::UnitsStyle::InchPoundExceptElectricity)) {
   16867           22 :             columnHead(LoadCompCol::SensInst) = "Sensible - Instant [W]";
   16868           22 :             columnHead(LoadCompCol::SensDelay) = "Sensible - Delayed [W]";
   16869           22 :             columnHead(LoadCompCol::SensRA) = "Sensible - Return Air [W]";
   16870           22 :             columnHead(LoadCompCol::Latent) = "Latent [W]";
   16871           22 :             columnHead(LoadCompCol::Total) = "Total [W]";
   16872           22 :             columnHead(LoadCompCol::Perc) = "%Grand Total";
   16873           22 :             columnHead(LoadCompCol::Area) = "Related Area [m2]";
   16874           22 :             columnHead(LoadCompCol::PerArea) = "Total per Area [W/m2]";
   16875              :         } else {
   16876           12 :             columnHead(LoadCompCol::SensInst) = "Sensible - Instant [Btu/h]";
   16877           12 :             columnHead(LoadCompCol::SensDelay) = "Sensible - Delayed [Btu/h]";
   16878           12 :             columnHead(LoadCompCol::SensRA) = "Sensible - Return Air [Btu/h]";
   16879           12 :             columnHead(LoadCompCol::Latent) = "Latent [Btu/h]";
   16880           12 :             columnHead(LoadCompCol::Total) = "Total [Btu/h]";
   16881           12 :             columnHead(LoadCompCol::Perc) = "%Grand Total";
   16882           12 :             columnHead(LoadCompCol::Area) = "Related Area [ft2]";
   16883           12 :             columnHead(LoadCompCol::PerArea) = "Total per Area [Btu/h-ft2]";
   16884              :         }
   16885           34 :         columnWidth.dimension(LoadCompCol::PerArea, 14); // array assignment - same for all columns
   16886              : 
   16887           34 :         if (produceTabular_para) {
   16888           32 :             WriteSubtitle(state, peakLoadCompName);
   16889           32 :             WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
   16890              :         }
   16891           34 :         if (produceSQLite_para) {
   16892           32 :             if (state.dataSQLiteProcedures->sqlite) {
   16893           20 :                 state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
   16894              :                     tableBody, rowHead, columnHead, reportName, zoneAirLoopFacilityName, peakLoadCompName);
   16895              :             }
   16896              :         }
   16897           34 :         if (produceTabular_para) {
   16898           32 :             if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
   16899            0 :                 state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(
   16900              :                     tableBody, rowHead, columnHead, reportName, zoneAirLoopFacilityName, peakLoadCompName);
   16901              :             }
   16902              :         }
   16903              : 
   16904              :         //---- Peak Conditions
   16905              : 
   16906           34 :         rowHead.allocate(16);
   16907           34 :         columnHead.allocate(1);
   16908           34 :         columnWidth.allocate(1);
   16909           34 :         columnWidth = 14; // array assignment - same for all columns
   16910              : 
   16911           34 :         tableBody.allocate(1, 16);
   16912           34 :         tableBody = "";
   16913              : 
   16914           34 :         columnHead(1) = "Value";
   16915           34 :         if (!(unitsStyle_para == OutputReportTabular::UnitsStyle::InchPound ||
   16916              :               unitsStyle_para == OutputReportTabular::UnitsStyle::InchPoundExceptElectricity)) {
   16917           22 :             rowHead(1) = "Time of Peak Load";
   16918           22 :             rowHead(2) = "Outside Dry Bulb Temperature [C]";
   16919           22 :             rowHead(3) = "Outside Wet Bulb Temperature [C]";
   16920           22 :             rowHead(4) = "Outside Humidity Ratio at Peak [kgWater/kgDryAir]";
   16921           22 :             rowHead(5) = "Zone Dry Bulb Temperature [C]";
   16922           22 :             rowHead(6) = "Zone Relative Humidity [%]";
   16923           22 :             rowHead(7) = "Zone Humidity Ratio at Peak [kgWater/kgDryAir]";
   16924              : 
   16925           22 :             rowHead(8) = "Supply Air Temperature [C]";
   16926           22 :             rowHead(9) = "Mixed Air Temperature [C]";
   16927           22 :             rowHead(10) = "Main Fan Air Flow [m3/s]";
   16928           22 :             rowHead(11) = "Outside Air Flow [m3/s]";
   16929           22 :             rowHead(12) = "Peak Sensible Load with Sizing Factor [W]";
   16930           22 :             rowHead(13) = "Difference Due to Sizing Factor [W]";
   16931              : 
   16932           22 :             rowHead(14) = "Peak Sensible Load [W]";
   16933           22 :             rowHead(15) = "Estimated Instant + Delayed Sensible Load [W]";
   16934           22 :             rowHead(16) = "Difference Between Peak and Estimated Sensible Load [W]";
   16935              :         } else {
   16936           12 :             rowHead(1) = "Time of Peak Load";
   16937           12 :             rowHead(2) = "Outside Dry Bulb Temperature [F]";
   16938           12 :             rowHead(3) = "Outside Wet Bulb Temperature [F]";
   16939           12 :             rowHead(4) = "Outside Humidity Ratio at Peak [lbWater/lbAir]";
   16940           12 :             rowHead(5) = "Zone Dry Bulb Temperature [F]";
   16941           12 :             rowHead(6) = "Zone Relative Humidity [%]";
   16942           12 :             rowHead(7) = "Zone Humidity Ratio at Peak [lbWater/lbAir]";
   16943              : 
   16944           12 :             rowHead(8) = "Supply Air Temperature [F]";
   16945           12 :             rowHead(9) = "Mixed Air Temperature [F]";
   16946           12 :             rowHead(10) = "Main Fan Air Flow [ft3/min]";
   16947           12 :             rowHead(11) = "Outside Air Flow [ft3/min]";
   16948           12 :             rowHead(12) = "Peak Sensible Load with Sizing Factor [Btu/h]";
   16949           12 :             rowHead(13) = "Difference Due to Sizing Factor [Btu/h]";
   16950              : 
   16951           12 :             rowHead(14) = "Peak Sensible Load  [Btu/h]";
   16952           12 :             rowHead(15) = "Estimated Instant + Delayed Sensible Load [Btu/h]";
   16953           12 :             rowHead(16) = "Difference Between Peak and Estimated Sensible Load [Btu/h]";
   16954              :         }
   16955              : 
   16956           34 :         if (curCompLoad.timeStepMax != 0) {
   16957           28 :             tableBody(1, 1) = curCompLoad.peakDateHrMin;                  // Time of Peak Load
   16958           28 :             tableBody(1, 2) = RealToStr(curCompLoad.outsideDryBulb, 2);   // Outside Dry Bulb Temperature
   16959           28 :             tableBody(1, 3) = RealToStr(curCompLoad.outsideWetBulb, 2);   // Outside Wet Bulb Temperature
   16960           28 :             tableBody(1, 4) = RealToStr(curCompLoad.outsideHumRatio, 5);  // Outside Humidity Ratio at Peak
   16961           28 :             tableBody(1, 5) = RealToStr(curCompLoad.zoneDryBulb, 2);      // Zone Dry Bulb Temperature
   16962           28 :             tableBody(1, 6) = RealToStr(100 * curCompLoad.zoneRelHum, 2); // Zone Relative Humidity
   16963           28 :             tableBody(1, 7) = RealToStr(curCompLoad.zoneHumRatio, 5);     // Zone Humidity Ratio at Peak
   16964              :         }
   16965           34 :         tableBody(1, 8) = RealToStr(curCompLoad.supAirTemp, 2); // supply air temperature
   16966           34 :         if (kind == OutputType::AirLoop) {
   16967           12 :             tableBody(1, 9) = RealToStr(curCompLoad.mixAirTemp, 2); // mixed air temperature - not for zone or facility
   16968              :         }
   16969           34 :         tableBody(1, 10) = RealToStr(curCompLoad.mainFanAirFlow, 4);     // main fan air flow
   16970           34 :         tableBody(1, 11) = RealToStr(curCompLoad.outsideAirFlow, 4);     // outside air flow
   16971           34 :         tableBody(1, 12) = RealToStr(curCompLoad.designPeakLoad, 2);     // design peak load
   16972           34 :         tableBody(1, 13) = RealToStr(curCompLoad.diffDesignPeak, 2);     // difference between Design and Peak Load
   16973           34 :         tableBody(1, 14) = RealToStr(curCompLoad.peakDesSensLoad, 2);    // Peak Design Sensible Load
   16974           34 :         tableBody(1, 15) = RealToStr(curCompLoad.estInstDelSensLoad, 2); // Estimated Instant + Delayed Sensible Load
   16975           34 :         tableBody(1, 16) = RealToStr(curCompLoad.diffPeakEst, 2);        // Difference
   16976              : 
   16977           34 :         if (produceTabular_para) {
   16978           32 :             WriteSubtitle(state, peakCondName);
   16979           32 :             WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
   16980              :         }
   16981           34 :         if (produceSQLite_para) {
   16982           32 :             if (state.dataSQLiteProcedures->sqlite) {
   16983           20 :                 state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
   16984              :                     tableBody, rowHead, columnHead, reportName, zoneAirLoopFacilityName, peakCondName);
   16985              :             }
   16986              :         }
   16987           34 :         if (produceTabular_para) {
   16988           32 :             if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
   16989            0 :                 state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(
   16990              :                     tableBody, rowHead, columnHead, reportName, zoneAirLoopFacilityName, peakCondName);
   16991              :             }
   16992              :         }
   16993              : 
   16994              :         //---- Engineering Checks
   16995              : 
   16996           34 :         rowHead.allocate(6);
   16997           34 :         columnHead.allocate(1);
   16998           34 :         columnWidth.allocate(1);
   16999           34 :         columnWidth = 14; // array assignment - same for all columns
   17000              : 
   17001           34 :         tableBody.allocate(1, 6);
   17002           34 :         tableBody = "";
   17003              : 
   17004           34 :         columnHead(1) = "Value";
   17005           34 :         if (!(unitsStyle_para == OutputReportTabular::UnitsStyle::InchPound ||
   17006              :               unitsStyle_para == OutputReportTabular::UnitsStyle::InchPoundExceptElectricity)) {
   17007           22 :             rowHead(1) = "Outside Air Fraction [fraction]";
   17008           22 :             rowHead(2) = "Airflow per Floor Area [m3/s-m2]";
   17009           22 :             rowHead(3) = "Airflow per Total Capacity [m3/s-W]";
   17010           22 :             rowHead(4) = "Floor Area per Total Capacity [m2/W]";
   17011           22 :             rowHead(5) = "Total Capacity per Floor Area [W/m2]";
   17012              :             // rowHead( 6 ) = "Chiller Pump Power per Flow [W-s/m3]"; // facility only
   17013              :             // rowHead( 7 ) = "Condenser Pump Power per Flow [W-s/m3]"; // facility only
   17014           22 :             rowHead(6) = "Number of People";
   17015              :         } else {
   17016           12 :             rowHead(1) = "Outside Air Fraction [fraction]";
   17017           12 :             rowHead(2) = "Airflow per Floor Area [ft3/min-ft2]";
   17018           12 :             rowHead(3) = "Airflow per Total Capacity [ft3-h/min-Btu]";
   17019           12 :             rowHead(4) = "Floor Area per Total Capacity [ft2-h/Btu]";
   17020           12 :             rowHead(5) = "Total Capacity per Floor Area [Btu/h-ft2]";
   17021              :             // rowHead( 6 ) = "Chiller Pump Power per Flow [W-min/gal]";
   17022              :             // rowHead( 7 ) = "Condenser Pump Power per Flow [W-min/gal]";
   17023           12 :             rowHead(6) = "Number of People";
   17024              :         }
   17025              : 
   17026           68 :         tableBody(1, 1) = fmt::format("{:.{}f}", curCompLoad.outsideAirRatio, 4); // outside Air
   17027           34 :         tableBody(1, 2) = fmt::format("{:0.3E}", curCompLoad.airflowPerFlrArea);  // airflow per floor area
   17028           34 :         tableBody(1, 3) = fmt::format("{:0.3E}", curCompLoad.airflowPerTotCap);   // airflow per total capacity
   17029           34 :         tableBody(1, 4) = fmt::format("{:0.3E}", curCompLoad.areaPerTotCap);      // area per total capacity
   17030           34 :         tableBody(1, 5) = fmt::format("{:0.3E}", curCompLoad.totCapPerArea);      // total capacity per area
   17031           68 :         tableBody(1, 6) = fmt::format("{:.{}f}", curCompLoad.numPeople, 1);       // number of people
   17032              : 
   17033           34 :         if (produceTabular_para) {
   17034           32 :             WriteSubtitle(state, engineeringCheckName);
   17035           32 :             WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
   17036              :         }
   17037           34 :         if (produceSQLite_para) {
   17038           32 :             if (state.dataSQLiteProcedures->sqlite) {
   17039           20 :                 state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
   17040              :                     tableBody, rowHead, columnHead, reportName, zoneAirLoopFacilityName, engineeringCheckName);
   17041              :             }
   17042              :         }
   17043           34 :         if (produceTabular_para) {
   17044           32 :             if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
   17045            0 :                 state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(
   17046              :                     tableBody, rowHead, columnHead, reportName, zoneAirLoopFacilityName, engineeringCheckName);
   17047              :             }
   17048              :         }
   17049              : 
   17050              :         // write the list of zone for the AirLoop level report
   17051           34 :         if (kind == OutputType::AirLoop && curCompLoad.zoneIndices.allocated()) {
   17052            8 :             int maxRow = 0;
   17053           18 :             for (size_t zi = 1; zi <= curCompLoad.zoneIndices.size(); ++zi) {
   17054           10 :                 if (curCompLoad.zoneIndices(zi) > 0) {
   17055           10 :                     maxRow = zi;
   17056              :                 }
   17057              :             }
   17058              : 
   17059            8 :             rowHead.allocate(maxRow);
   17060            8 :             columnHead.allocate(1);
   17061            8 :             columnWidth.allocate(1);
   17062            8 :             columnWidth = 14; // array assignment - same for all columns
   17063            8 :             tableBody.allocate(1, maxRow);
   17064            8 :             tableBody = "";
   17065              : 
   17066            8 :             columnHead(1) = "Zone Name";
   17067           18 :             for (int zi = 1; zi <= maxRow; ++zi) {
   17068           10 :                 rowHead(zi) = fmt::to_string(zi);
   17069           10 :                 if (curCompLoad.zoneIndices(zi) > 0) {
   17070           10 :                     tableBody(1, zi) = state.dataHeatBal->Zone(curCompLoad.zoneIndices(zi)).Name;
   17071              :                 }
   17072              :             }
   17073              : 
   17074            8 :             if (produceTabular_para) {
   17075            8 :                 WriteSubtitle(state, zonesIncludedName);
   17076            8 :                 WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
   17077              :             }
   17078            8 :             if (produceSQLite_para) {
   17079            8 :                 if (state.dataSQLiteProcedures->sqlite) {
   17080            6 :                     state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
   17081              :                         tableBody, rowHead, columnHead, reportName, zoneAirLoopFacilityName, zonesIncludedName);
   17082              :                 }
   17083              :             }
   17084            8 :             if (produceTabular_para) {
   17085            8 :                 if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
   17086            0 :                     state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(
   17087              :                         tableBody, rowHead, columnHead, reportName, zoneAirLoopFacilityName, zonesIncludedName);
   17088              :                 }
   17089              :             }
   17090              :         }
   17091              :     }
   17092           17 : }
   17093              : 
   17094         1044 : void WriteReportHeaders(EnergyPlusData &state,
   17095              :                         std::string const &reportName,
   17096              :                         std::string const &objectName,
   17097              :                         OutputProcessor::StoreType const averageOrSum)
   17098              : {
   17099              :     // SUBROUTINE INFORMATION:
   17100              :     //       AUTHOR         Jason Glazer
   17101              :     //       DATE WRITTEN   August 2003
   17102              :     //       MODIFIED       na
   17103              :     //       RE-ENGINEERED  na
   17104              : 
   17105              :     // PURPOSE OF THIS SUBROUTINE:
   17106              :     //   Write the first few lines of each report with headers to the output
   17107              :     //   file for tabular reports.
   17108              : 
   17109         1044 :     std::string const modifiedReportName(reportName + (averageOrSum == OutputProcessor::StoreType::Sum ? " per second" : ""));
   17110         1044 :     auto &ort = state.dataOutRptTab;
   17111              : 
   17112         4375 :     for (int iStyle = 1; iStyle <= ort->numStyles; ++iStyle) {
   17113         3331 :         std::ostream &tbl_stream(*ort->TabularOutputFile(iStyle));
   17114         3331 :         std::string const &curDel(ort->del(iStyle));
   17115         3331 :         TableStyle const style = ort->TableStyle(iStyle);
   17116         3331 :         if ((style == TableStyle::Comma) || (style == TableStyle::Tab)) {
   17117         1466 :             tbl_stream << "----------------------------------------------------------------------------------------------------\n";
   17118         1466 :             tbl_stream << "REPORT:" << curDel << modifiedReportName << '\n';
   17119         1466 :             tbl_stream << "FOR:" << curDel << objectName << '\n';
   17120         1865 :         } else if (style == TableStyle::Fixed) {
   17121          572 :             tbl_stream << "----------------------------------------------------------------------------------------------------\n";
   17122          572 :             tbl_stream << "REPORT:      " << curDel << modifiedReportName << '\n';
   17123          572 :             tbl_stream << "FOR:         " << curDel << objectName << '\n';
   17124         1293 :         } else if (style == TableStyle::HTML) {
   17125          721 :             tbl_stream << "<hr>\n";
   17126          721 :             tbl_stream << "<p><a href=\"#toc\" style=\"float: right\">Table of Contents</a></p>\n";
   17127          721 :             tbl_stream << "<a name=" << MakeAnchorName(reportName, objectName) << "></a>\n";
   17128          721 :             tbl_stream << "<p>Report:<b>" << curDel << modifiedReportName << "</b></p>\n";
   17129          721 :             tbl_stream << "<p>For:<b>" << curDel << objectName << "</b></p>\n";
   17130          721 :             tbl_stream << "<p>Timestamp: <b>" << std::setw(4) << ort->td(1) << '-' << std::setfill('0') << std::setw(2) << ort->td(2) << '-'
   17131          721 :                        << std::setw(2) << ort->td(3) << '\n';
   17132          721 :             tbl_stream << "    " << std::setw(2) << ort->td(5) << ':' << std::setw(2) << ort->td(6) << ':' << std::setw(2) << ort->td(7)
   17133          721 :                        << std::setfill(' ') << "</b></p>\n";
   17134          572 :         } else if (style == TableStyle::XML) {
   17135          572 :             if (len(ort->prevReportName) != 0) {
   17136          550 :                 tbl_stream << "</" << ort->prevReportName << ">\n"; // close the last element if it was used.
   17137              :             }
   17138          572 :             tbl_stream << "<" << ConvertToElementTag(modifiedReportName) << ">\n";
   17139          572 :             tbl_stream << "  <for>" << ConvertToEscaped(objectName) << "</for>\n";
   17140          572 :             ort->prevReportName = ConvertToElementTag(modifiedReportName); // save the name for next time
   17141              :         }
   17142              :     }
   17143              :     // clear the active subtable name for the XML reporting
   17144         1044 :     ort->activeSubTableName = "";
   17145              :     // save the report name if the subtable name is not available during XML processing
   17146         1044 :     ort->activeReportName = modifiedReportName;
   17147              :     // save the "for" which is the object name in the report for HTML comment that contains the report, for, and subtable
   17148         1044 :     ort->activeForName = objectName;
   17149         1044 : }
   17150              : 
   17151         7196 : void WriteSubtitle(EnergyPlusData &state, std::string const &subtitle)
   17152              : {
   17153              :     // SUBROUTINE INFORMATION:
   17154              :     //       AUTHOR         Jason Glazer
   17155              :     //       DATE WRITTEN   November 2003
   17156              :     //       MODIFIED       na
   17157              :     //       RE-ENGINEERED  na
   17158              : 
   17159              :     // PURPOSE OF THIS SUBROUTINE:
   17160              :     //   Insert a subtitle into the current report
   17161              : 
   17162              :     // Locals
   17163              :     // SUBROUTINE ARGUMENT DEFINITIONS:
   17164              : 
   17165              :     // SUBROUTINE PARAMETER DEFINITIONS:
   17166              : 
   17167              :     // INTERFACE BLOCK SPECIFICATIONS:
   17168              :     // na
   17169              : 
   17170              :     // DERIVED TYPE DEFINITIONS:
   17171              :     // na
   17172              : 
   17173              :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
   17174              :     int iStyle;
   17175         7196 :     auto &ort = state.dataOutRptTab;
   17176              : 
   17177        30346 :     for (iStyle = 1; iStyle <= ort->numStyles; ++iStyle) {
   17178        23150 :         TableStyle const style = ort->TableStyle(iStyle);
   17179        23150 :         if ((style == TableStyle::Comma) || (style == TableStyle::Tab) || (style == TableStyle::Fixed)) {
   17180        14119 :             std::ostream &tbl_stream(*ort->TabularOutputFile(iStyle));
   17181        14119 :             tbl_stream << subtitle << "\n\n";
   17182        23150 :         } else if (style == TableStyle::HTML) {
   17183         5054 :             std::ostream &tbl_stream(*ort->TabularOutputFile(iStyle));
   17184         5054 :             tbl_stream << "<b>" << subtitle << "</b><br><br>\n";
   17185         5054 :             tbl_stream << "<!-- FullName:" << ort->activeReportName << '_' << ort->activeForName << '_' << subtitle << "-->\n";
   17186         3977 :         } else if (style == TableStyle::XML) {
   17187              :             // save the active subtable name for the XML reporting
   17188         3977 :             ort->activeSubTableName = subtitle;
   17189              :             // no other output is needed since WriteTable uses the subtable name for each record.
   17190              :         }
   17191              :     }
   17192         7196 : }
   17193              : 
   17194          458 : void WriteTextLine(EnergyPlusData &state, std::string const &lineOfText, bool const useBold)
   17195              : {
   17196              :     // SUBROUTINE INFORMATION:
   17197              :     //       AUTHOR         Jason Glazer
   17198              :     //       DATE WRITTEN   April 2007
   17199              :     //       MODIFIED       na
   17200              :     //       RE-ENGINEERED  na
   17201              : 
   17202              :     // PURPOSE OF THIS SUBROUTINE:
   17203              :     //   Insert a subtitle into the current report
   17204              : 
   17205              :     // Locals
   17206              :     // SUBROUTINE ARGUMENT DEFINITIONS:
   17207              : 
   17208              :     // SUBROUTINE PARAMETER DEFINITIONS:
   17209              : 
   17210              :     // INTERFACE BLOCK SPECIFICATIONS:
   17211              :     // na
   17212              : 
   17213              :     // DERIVED TYPE DEFINITIONS:
   17214              :     // na
   17215              : 
   17216              :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
   17217              :     int iStyle;
   17218          458 :     auto &ort = state.dataOutRptTab;
   17219              : 
   17220         1855 :     for (iStyle = 1; iStyle <= ort->numStyles; ++iStyle) {
   17221         1397 :         TableStyle const style = ort->TableStyle(iStyle);
   17222         1397 :         if ((style == TableStyle::Comma) || (style == TableStyle::Tab) || (style == TableStyle::Fixed)) {
   17223          858 :             std::ostream &tbl_stream(*ort->TabularOutputFile(iStyle));
   17224          858 :             tbl_stream << lineOfText << '\n';
   17225         1397 :         } else if (style == TableStyle::HTML) {
   17226          297 :             std::ostream &tbl_stream(*ort->TabularOutputFile(iStyle));
   17227          297 :             if (useBold) {
   17228          270 :                 tbl_stream << "<b>" << lineOfText << "</b><br><br>\n";
   17229              :             } else {
   17230           27 :                 tbl_stream << lineOfText << "<br>\n";
   17231              :             }
   17232          242 :         } else if (style == TableStyle::XML) {
   17233          242 :             std::ostream &tbl_stream(*ort->TabularOutputFile(iStyle));
   17234          242 :             if (!lineOfText.empty()) {
   17235          198 :                 tbl_stream << "<note>" << lineOfText << "</note>\n";
   17236              :             }
   17237              :         }
   17238              :     }
   17239          458 : }
   17240              : 
   17241         7196 : void WriteTable(EnergyPlusData &state,
   17242              :                 Array2S_string const body, // row,column
   17243              :                 const Array1D_string &rowLabels,
   17244              :                 const Array1D_string &columnLabels,
   17245              :                 Array1D_int &widthColumn,
   17246              :                 bool transposeXML,
   17247              :                 std::string_view const footnoteText)
   17248              : {
   17249              :     // SUBROUTINE INFORMATION:
   17250              :     //       AUTHOR         Jason Glazer
   17251              :     //       DATE WRITTEN   August 2003
   17252              :     //       MODIFIED       na
   17253              :     //       RE-ENGINEERED  na
   17254              : 
   17255              :     // PURPOSE OF THIS SUBROUTINE:
   17256              :     //   Output a table to the tabular output file in the selected
   17257              :     //   style (comma, tab, space, html, xml).
   17258              :     //   The widthColumn array is only used for fixed space formatted reports
   17259              :     //   if columnLables contain a vertical bar '|', they are broken into multiple
   17260              :     //   rows.  If they exceed the column width even after that and the format is
   17261              :     //   fixed, they are further shortened.
   17262              :     //   To include the currency symbol ($ by default but other symbols if the user
   17263              :     //   has input it with Economics:CurrencyType) use the string ~~$~~ in the row
   17264              :     //   headers, column headers, and body. For HTML files, the ASCII or UNICODE
   17265              :     //   symbol for the currency will be included. For TXT files, the ASCII symbol
   17266              :     //   will be used.
   17267              : 
   17268              :     // Argument array dimensioning
   17269              : 
   17270              :     // Locals
   17271              :     // SUBROUTINE ARGUMENT DEFINITIONS:
   17272              : 
   17273              :     // SUBROUTINE PARAMETER DEFINITIONS:
   17274         7196 :     static std::string const blank;
   17275              : 
   17276              :     // INTERFACE BLOCK SPECIFICATIONS:
   17277              :     // na
   17278              : 
   17279              :     // DERIVED TYPE DEFINITIONS:
   17280              :     // na
   17281              : 
   17282              :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
   17283         7196 :     Array2D_string colLabelMulti;
   17284         7196 :     std::string workColumn;
   17285         7196 :     Array1D_string rowLabelTags;
   17286         7196 :     Array1D_string columnLabelTags;
   17287         7196 :     Array1D_string rowUnitStrings;
   17288         7196 :     Array1D_string columnUnitStrings;
   17289         7196 :     Array2D_string bodyEsc;
   17290              : 
   17291         7196 :     std::string outputLine;
   17292         7196 :     std::string tagWithAttrib;
   17293              :     std::string::size_type col1start;
   17294         7196 :     auto &ort = state.dataOutRptTab;
   17295              : 
   17296              :     // create blank string
   17297              :     // get sizes of arrays
   17298         7196 :     int rowsBody = isize(body, 2);
   17299         7196 :     int colsBody = isize(body, 1);
   17300         7196 :     int rowsRowLabels = isize(rowLabels);
   17301         7196 :     int colsColumnLabels = isize(columnLabels);
   17302         7196 :     int const colsWidthColumn = isize(widthColumn);
   17303              :     // check size of arrays for consistency and if inconsistent use smaller value
   17304              :     // and display warning
   17305         7196 :     if (rowsBody != rowsRowLabels) {
   17306            0 :         ShowWarningError(state, "REPORT:TABLE Inconsistent number of rows.");
   17307            0 :         rowsBody = min(rowsBody, rowsRowLabels);
   17308            0 :         rowsRowLabels = rowsBody;
   17309              :     }
   17310         7196 :     if ((colsBody != colsColumnLabels) || (colsBody != colsWidthColumn)) {
   17311            0 :         ShowWarningError(state, "REPORT:TABLE Inconsistent number of columns.");
   17312            0 :         colsBody = min(colsBody, min(colsColumnLabels, colsWidthColumn));
   17313            0 :         colsColumnLabels = colsBody;
   17314              :     }
   17315              :     // create arrays to hold the XML tags
   17316         7196 :     rowLabelTags.allocate(rowsBody);
   17317         7196 :     columnLabelTags.allocate(colsBody);
   17318         7196 :     rowUnitStrings.allocate(rowsBody);
   17319         7196 :     columnUnitStrings.allocate(colsBody);
   17320         7196 :     bodyEsc.allocate(colsBody, rowsBody);
   17321              :     // create new array to hold multiple line column labels
   17322         7196 :     colLabelMulti.allocate(colsColumnLabels, 50);
   17323         7196 :     colLabelMulti = blank; // set array to blank
   17324         7196 :     int maxNumColLabelRows = 0;
   17325              : 
   17326        30346 :     for (int iStyle = 1; iStyle <= ort->numStyles; ++iStyle) {
   17327        23150 :         std::ostream &tbl_stream(*ort->TabularOutputFile(iStyle));
   17328        23150 :         std::string const &curDel = ort->del(iStyle);
   17329              :         // go through the columns and break them into multiple lines
   17330              :         // if bar '|' is found in a row then break into two lines
   17331              :         // if longer than the column width break into two lines for fixed style only
   17332       203875 :         for (int iCol = 1; iCol <= colsColumnLabels; ++iCol) {
   17333       180725 :             int numColLabelRows = 0;
   17334       180725 :             workColumn = columnLabels(iCol);
   17335       180725 :             widthColumn(iCol) = max(widthColumn(iCol), static_cast<int>(len(columnLabels(iCol))));
   17336              :             while (true) {
   17337       183519 :                 std::string::size_type const barLoc = index(workColumn, '|');
   17338       183519 :                 if (barLoc != std::string::npos) {
   17339         2794 :                     ++numColLabelRows;
   17340         2794 :                     colLabelMulti(iCol, numColLabelRows) = workColumn.substr(0, barLoc);
   17341         2794 :                     workColumn.erase(0, barLoc + 1);
   17342              :                 } else {
   17343       180725 :                     ++numColLabelRows;
   17344       180725 :                     colLabelMulti(iCol, numColLabelRows) = workColumn;
   17345       180725 :                     break; // inner do loop
   17346              :                 }
   17347         2794 :             }
   17348       180725 :             if (numColLabelRows > maxNumColLabelRows) {
   17349         7057 :                 maxNumColLabelRows = numColLabelRows;
   17350              :             }
   17351              :         }
   17352              : 
   17353        23150 :         auto const &thisStyle = ort->TableStyle(iStyle);
   17354              : 
   17355              :         // output depending on style of format
   17356        23150 :         if ((thisStyle == TableStyle::Comma) || (thisStyle == TableStyle::Tab)) {
   17357              :             // column headers
   17358        21348 :             for (int jRow = 1; jRow <= maxNumColLabelRows; ++jRow) {
   17359        11206 :                 outputLine = curDel; // one leading delimiters on column header lines
   17360        93065 :                 for (int iCol = 1; iCol <= colsColumnLabels; ++iCol) {
   17361        81859 :                     outputLine += curDel + stripped(colLabelMulti(iCol, jRow));
   17362              :                 }
   17363        11206 :                 tbl_stream << InsertCurrencySymbol(state, outputLine, false) << '\n';
   17364              :             }
   17365              :             // body with row headers
   17366        42615 :             for (int jRow = 1; jRow <= rowsBody; ++jRow) {
   17367        32473 :                 outputLine = curDel + rowLabels(jRow); // one leading delimiters on table body lines
   17368       287215 :                 for (int iCol = 1; iCol <= colsBody; ++iCol) {
   17369       254742 :                     outputLine += curDel + stripped(body(iCol, jRow));
   17370              :                 }
   17371        32473 :                 tbl_stream << InsertCurrencySymbol(state, outputLine, false) << '\n';
   17372              :             }
   17373        10142 :             if (!footnoteText.empty()) {
   17374         1290 :                 tbl_stream << fmt::format("{}\n", footnoteText);
   17375              :             }
   17376        10142 :             tbl_stream << "\n\n";
   17377              : 
   17378        23150 :         } else if (thisStyle == TableStyle::Fixed) {
   17379              : 
   17380              :             // extra preprocessing for fixed style reports
   17381              :             // break column headings into multiple rows if long (for fixed) or contain two spaces in a row.
   17382        35016 :             for (int iCol = 1; iCol <= colsColumnLabels; ++iCol) {
   17383        31039 :                 int const colWidthLimit = widthColumn(iCol);
   17384        63046 :                 for (int jRow = 1; jRow <= maxNumColLabelRows; ++jRow) {
   17385        32007 :                     pare(colLabelMulti(iCol, jRow), colWidthLimit);
   17386              :                 }
   17387              :             }
   17388         3977 :             std::string::size_type maxWidthRowLabel = 0;
   17389        16758 :             for (int jRow = 1; jRow <= rowsRowLabels; ++jRow) {
   17390        12781 :                 std::string::size_type widthRowLabel = len(rowLabels(jRow));
   17391        12781 :                 if (widthRowLabel > maxWidthRowLabel) {
   17392         5652 :                     maxWidthRowLabel = widthRowLabel;
   17393              :                 }
   17394              :             }
   17395              : 
   17396              :             // column headers
   17397         8372 :             for (int jRow = 1; jRow <= maxNumColLabelRows; ++jRow) {
   17398         4395 :                 outputLine = blank; // spaces(:maxWidthRowLabel+2)  // two extra spaces and leave blank area for row labels
   17399         4395 :                 col1start = max(maxWidthRowLabel + 2u, static_cast<std::string::size_type>(3u));
   17400        36402 :                 for (int iCol = 1; iCol <= colsColumnLabels; ++iCol) {
   17401        32007 :                     if (iCol != 1) {
   17402        27612 :                         outputLine += "  " + rjustified(sized(colLabelMulti(iCol, jRow), widthColumn(iCol)));
   17403              :                     } else {
   17404        13185 :                         outputLine = std::string(col1start - 1, ' ') + "  " + rjustified(sized(colLabelMulti(iCol, jRow), widthColumn(iCol)));
   17405              :                     }
   17406              :                 }
   17407         4395 :                 tbl_stream << InsertCurrencySymbol(state, outputLine, false) << '\n';
   17408              :             }
   17409              :             // body with row headers
   17410        16758 :             for (int jRow = 1; jRow <= rowsBody; ++jRow) {
   17411        12781 :                 outputLine = "  " + rjustified(sized(rowLabels(jRow), maxWidthRowLabel)); // two blank spaces on table body lines
   17412              :                 // col1start = max( len( outputLine ) + 2u, maxWidthRowLabel + 2u );
   17413       111912 :                 for (int iCol = 1; iCol <= colsBody; ++iCol) {
   17414        99131 :                     if (iCol != 1) {
   17415        86350 :                         outputLine += "  " + rjustified(sized(body(iCol, jRow), widthColumn(iCol)));
   17416              :                     } else {
   17417        12781 :                         outputLine += "   " + rjustified(sized(body(iCol, jRow), widthColumn(iCol)));
   17418              :                     }
   17419              :                 }
   17420        12781 :                 tbl_stream << InsertCurrencySymbol(state, outputLine, false) << '\n';
   17421              :             }
   17422         3977 :             if (!footnoteText.empty()) {
   17423          506 :                 tbl_stream << fmt::format("{}\n", footnoteText);
   17424              :             }
   17425         3977 :             tbl_stream << "\n\n";
   17426              : 
   17427         9031 :         } else if (thisStyle == TableStyle::HTML) {
   17428              :             // set up it being a table
   17429         5054 :             tbl_stream << "<table border=\"1\" cellpadding=\"4\" cellspacing=\"0\">\n";
   17430              :             // column headers
   17431         5054 :             tbl_stream << "  <tr><td></td>\n"; // start new row and leave empty cell
   17432        44306 :             for (int iCol = 1; iCol <= colsColumnLabels; ++iCol) {
   17433        39252 :                 outputLine = "    <td align=\"right\">";
   17434        79692 :                 for (int jRow = 1; jRow <= maxNumColLabelRows; ++jRow) {
   17435        40440 :                     outputLine += ConvertToEscaped(colLabelMulti(iCol, jRow), false);
   17436        40440 :                     if (jRow < maxNumColLabelRows) {
   17437         1188 :                         outputLine += "<br>";
   17438              :                     }
   17439              :                 }
   17440        39252 :                 tbl_stream << InsertCurrencySymbol(state, outputLine, true) << "</td>\n";
   17441              :             }
   17442         5054 :             tbl_stream << "  </tr>\n";
   17443              :             // body with row headers
   17444        22172 :             for (int jRow = 1; jRow <= rowsBody; ++jRow) {
   17445        17118 :                 tbl_stream << "  <tr>\n";
   17446        17118 :                 if (rowLabels(jRow) != "") {
   17447        33854 :                     tbl_stream << "    <td align=\"right\">" << ConvertToEscaped(InsertCurrencySymbol(state, rowLabels(jRow), true), false)
   17448        33854 :                                << "</td>\n";
   17449              :                 } else {
   17450          191 :                     tbl_stream << "    <td align=\"right\">&nbsp;</td>\n";
   17451              :                 }
   17452       148356 :                 for (int iCol = 1; iCol <= colsBody; ++iCol) {
   17453       131238 :                     if (body(iCol, jRow) != "") {
   17454       200698 :                         tbl_stream << "    <td align=\"right\">" << ConvertToEscaped(InsertCurrencySymbol(state, body(iCol, jRow), true), false)
   17455       200698 :                                    << "</td>\n";
   17456              :                     } else {
   17457        30889 :                         tbl_stream << "    <td align=\"right\">&nbsp;</td>\n";
   17458              :                     }
   17459              :                 }
   17460        17118 :                 tbl_stream << "  </tr>\n";
   17461              :             }
   17462              :             // end the table
   17463         5054 :             tbl_stream << "</table>\n";
   17464         5054 :             if (!footnoteText.empty()) {
   17465          663 :                 tbl_stream << fmt::format("<div class=\"footnote\" style=\"font-style: italic;\">{}</div>\n", footnoteText);
   17466              :             }
   17467         5054 :             tbl_stream << "<br><br>\n";
   17468         3977 :         } else if (thisStyle == TableStyle::XML) {
   17469              :             // check if entire table is blank and it if is skip generating anything
   17470         3977 :             bool isTableBlank = true;
   17471         5746 :             for (int jRow = 1; jRow <= rowsBody; ++jRow) {
   17472        23327 :                 for (int iCol = 1; iCol <= colsBody; ++iCol) {
   17473        21558 :                     if (len(body(iCol, jRow)) > 0) {
   17474         2560 :                         isTableBlank = false;
   17475         2560 :                         break;
   17476              :                     }
   17477              :                 }
   17478         4329 :                 if (!isTableBlank) {
   17479         2560 :                     break;
   17480              :                 }
   17481              :             }
   17482              :             // if non-blank cells in the table body were found create the table.
   17483         3977 :             if (!isTableBlank) {
   17484              :                 // if report name and subtable name the same add "record" to the end
   17485         2560 :                 ort->activeSubTableName = ConvertToElementTag(ort->activeSubTableName);
   17486         2560 :                 ort->activeReportNameNoSpace = ConvertToElementTag(ort->activeReportName);
   17487         2560 :                 if (Util::SameString(ort->activeSubTableName, ort->activeReportNameNoSpace)) {
   17488           22 :                     ort->activeSubTableName += "Record";
   17489              :                 }
   17490              :                 // if no subtable name use the report name and add "record" to the end
   17491         2560 :                 if (len(ort->activeSubTableName) == 0) {
   17492            0 :                     ort->activeSubTableName = ort->activeReportNameNoSpace + "Record";
   17493              :                 }
   17494              :                 // if a single column table, transpose it automatically
   17495         2560 :                 if ((colsBody == 1) && (rowsBody > 1)) {
   17496          324 :                     transposeXML = true;
   17497              :                 }
   17498              :                 // first convert all row and column headers into tags compatible with XML strings
   17499        13572 :                 for (int jRow = 1; jRow <= rowsBody; ++jRow) {
   17500        11012 :                     rowLabelTags(jRow) = ConvertToElementTag(rowLabels(jRow));
   17501        11012 :                     if (len(rowLabelTags(jRow)) == 0) {
   17502          198 :                         rowLabelTags(jRow) = "none";
   17503              :                     }
   17504        11012 :                     rowUnitStrings(jRow) = GetUnitSubString(rowLabels(jRow));
   17505        11012 :                     if (Util::SameString(rowUnitStrings(jRow), "Invalid/Undefined")) {
   17506            0 :                         rowUnitStrings(jRow) = "";
   17507              :                     }
   17508              :                 }
   17509        20124 :                 for (int iCol = 1; iCol <= colsBody; ++iCol) {
   17510        17564 :                     columnLabelTags(iCol) = ConvertToElementTag(columnLabels(iCol));
   17511        17564 :                     if (len(columnLabelTags(iCol)) == 0) {
   17512            0 :                         columnLabelTags(iCol) = "none";
   17513              :                     }
   17514        17564 :                     columnUnitStrings(iCol) = GetUnitSubString(columnLabels(iCol));
   17515        17564 :                     if (Util::SameString(columnUnitStrings(iCol), "Invalid/Undefined")) {
   17516            0 :                         columnUnitStrings(iCol) = "";
   17517              :                     }
   17518              :                 }
   17519              :                 // convert entire table body to one with escape characters (no " ' < > &)
   17520        13572 :                 for (int jRow = 1; jRow <= rowsBody; ++jRow) {
   17521        91498 :                     for (int iCol = 1; iCol <= colsBody; ++iCol) {
   17522        80486 :                         bodyEsc(iCol, jRow) = ConvertToEscaped(body(iCol, jRow));
   17523              :                     }
   17524              :                 }
   17525         2560 :                 if (!transposeXML) {
   17526              :                     // body with row headers
   17527        11150 :                     for (int jRow = 1; jRow <= rowsBody; ++jRow) {
   17528              :                         // check if record is blank and it if is skip generating anything
   17529         8914 :                         bool isRecordBlank = true;
   17530        10896 :                         for (int iCol = 1; iCol <= colsBody; ++iCol) {
   17531        10764 :                             if (len(bodyEsc(iCol, jRow)) > 0) {
   17532         8782 :                                 isRecordBlank = false;
   17533         8782 :                                 break;
   17534              :                             }
   17535              :                         }
   17536         8914 :                         if (!isRecordBlank) {
   17537         8782 :                             tbl_stream << "  <" << ort->activeSubTableName << ">\n";
   17538         8782 :                             if (len(rowLabelTags(jRow)) > 0) {
   17539         8782 :                                 tbl_stream << "    <name>" << rowLabelTags(jRow) << "</name>\n";
   17540              :                             }
   17541        85894 :                             for (int iCol = 1; iCol <= colsBody; ++iCol) {
   17542        77112 :                                 if (len(stripped(bodyEsc(iCol, jRow))) > 0) { // skip blank cells
   17543        71808 :                                     tagWithAttrib = "<" + columnLabelTags(iCol);
   17544        71808 :                                     if (len(columnUnitStrings(iCol)) > 0) {
   17545       222384 :                                         tagWithAttrib += std::string(" units=") + char(34) + columnUnitStrings(iCol) + char(34) +
   17546        55596 :                                                          '>'; // if units are present add them as an attribute
   17547              :                                     } else {
   17548        16212 :                                         tagWithAttrib += ">";
   17549              :                                     }
   17550        71808 :                                     tbl_stream << "    " << tagWithAttrib << stripped(bodyEsc(iCol, jRow)) << "</" << columnLabelTags(iCol) << ">\n";
   17551              :                                 }
   17552              :                             }
   17553         8782 :                             tbl_stream << "  </" << ort->activeSubTableName << ">\n";
   17554              :                         }
   17555              :                     }
   17556              :                 } else { // transpose XML table
   17557              :                     // body with row headers
   17558          648 :                     for (int iCol = 1; iCol <= colsBody; ++iCol) {
   17559              :                         // check if record is blank and it if is skip generating anything
   17560          324 :                         bool isRecordBlank = true;
   17561          324 :                         for (int jRow = 1; jRow <= rowsBody; ++jRow) {
   17562          324 :                             if (len(bodyEsc(iCol, jRow)) > 0) {
   17563          324 :                                 isRecordBlank = false;
   17564          324 :                                 break;
   17565              :                             }
   17566              :                         }
   17567          324 :                         if (!isRecordBlank) {
   17568          324 :                             tbl_stream << "  <" << ort->activeSubTableName << ">\n";
   17569              :                             // if the column has units put them into the name tag
   17570          324 :                             if (len(columnLabelTags(iCol)) > 0) {
   17571          324 :                                 if (len(columnUnitStrings(iCol)) > 0) {
   17572          264 :                                     tbl_stream << "    <name units=" << char(34) << columnUnitStrings(iCol) << char(34) << '>'
   17573          132 :                                                << columnLabelTags(iCol) << "</name>\n";
   17574              :                                 } else {
   17575          192 :                                     tbl_stream << "    <name>" << columnLabelTags(iCol) << "</name>\n";
   17576              :                                 }
   17577              :                             }
   17578         2422 :                             for (int jRow = 1; jRow <= rowsBody; ++jRow) {
   17579         2098 :                                 if (len(bodyEsc(iCol, jRow)) > 0) { // skip blank cells
   17580         2093 :                                     tagWithAttrib = "<" + rowLabelTags(jRow);
   17581         2093 :                                     if (len(rowUnitStrings(jRow)) > 0) {
   17582         1008 :                                         tagWithAttrib += std::string(" units=") + char(34) + rowUnitStrings(jRow) + char(34) +
   17583          252 :                                                          ">\n"; // if units are present add them as an attribute
   17584              :                                     } else {
   17585         1841 :                                         tagWithAttrib += ">";
   17586              :                                     }
   17587         2093 :                                     tbl_stream << "    " << tagWithAttrib << stripped(bodyEsc(iCol, jRow)) << "</" << rowLabelTags(jRow) << ">\n";
   17588              :                                 }
   17589              :                             }
   17590          324 :                             tbl_stream << "  </" << ort->activeSubTableName << ">\n";
   17591              :                         }
   17592              :                     }
   17593              :                 }
   17594         2560 :                 if (!footnoteText.empty()) {
   17595          198 :                     if (footnoteText.find("<br") != std::string_view::npos) {
   17596            0 :                         tbl_stream << fmt::format("  <footnote><![CDATA[{}]]></footnote>\n", footnoteText);
   17597              :                     } else {
   17598          198 :                         tbl_stream << fmt::format("  <footnote>{}</footnote>\n", footnoteText);
   17599              :                     }
   17600              :                 }
   17601              :             }
   17602              :         } else {
   17603              :         }
   17604              :     }
   17605         7196 : }
   17606              : 
   17607         1465 : std::string MakeAnchorName(std::string const &reportString, std::string const &objectString)
   17608              : {
   17609              :     // SUBROUTINE INFORMATION:
   17610              :     //       AUTHOR         Jason Glazer
   17611              :     //       DATE WRITTEN   June 2005
   17612              :     //       MODIFIED
   17613              :     //       RE-ENGINEERED  na
   17614              : 
   17615              :     // PURPOSE OF THIS SUBROUTINE:
   17616              :     //   Use the name of the report and object be used to create and HTML anchor
   17617              : 
   17618              :     // METHODOLOGY EMPLOYED:
   17619              :     //   Remove spaces and put double colon between names
   17620              : 
   17621              :     // REFERENCES:
   17622              :     // na
   17623              : 
   17624              :     // USE STATEMENTS:
   17625              : 
   17626              :     // Return value
   17627         1465 :     std::string StringOut;
   17628         1465 :     StringOut.reserve(reportString.size() + objectString.size() + 2);
   17629              : 
   17630              :     // Locals
   17631              :     // SUBROUTINE ARGUMENT DEFINITIONS:
   17632              :     // na
   17633              : 
   17634              :     // SUBROUTINE PARAMETER DEFINITIONS:
   17635              : 
   17636              :     // INTERFACE BLOCK SPECIFICATIONS:
   17637              :     // na
   17638              : 
   17639              :     // DERIVED TYPE DEFINITIONS:
   17640              :     // na
   17641              : 
   17642              :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
   17643              : 
   17644        35747 :     for (char const i : reportString) {
   17645        34282 :         if (has(validChars, i)) {
   17646        31062 :             StringOut += i;
   17647              :         }
   17648              :     }
   17649         1465 :     StringOut += "::";
   17650        23324 :     for (char const i : objectString) {
   17651        21859 :         if (has(validChars, i)) {
   17652        20402 :             StringOut += i;
   17653              :         }
   17654              :     }
   17655         1465 :     return StringOut;
   17656            0 : }
   17657              : 
   17658       217383 : std::string InsertCurrencySymbol(EnergyPlusData &state,
   17659              :                                  std::string const &inString, // Input String
   17660              :                                  bool const isHTML            // True if an HTML string
   17661              : )
   17662              : {
   17663              :     // SUBROUTINE INFORMATION:
   17664              :     //       AUTHOR         Jason Glazer
   17665              :     //       DATE WRITTEN   August 2008
   17666              :     //       MODIFIED       na
   17667              :     //       RE-ENGINEERED  na
   17668              : 
   17669              :     // PURPOSE OF THIS SUBROUTINE:
   17670              :     //   Looks for the ~~$~~
   17671              : 
   17672              :     // METHODOLOGY EMPLOYED:
   17673              :     //   na
   17674              :     // Using/Aliasing
   17675              : 
   17676              :     // Return value
   17677              : 
   17678              :     // Locals
   17679              :     // SUBROUTINE ARGUMENT DEFINITIONS:
   17680              : 
   17681              :     // SUBROUTINE PARAMETER DEFINITIONS:
   17682              :     // na
   17683              : 
   17684              :     // INTERFACE BLOCK SPECIFICATIONS:
   17685              :     // na
   17686              : 
   17687              :     // DERIVED TYPE DEFINITIONS:
   17688              :     // na
   17689              : 
   17690              :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
   17691              : 
   17692       217383 :     std::string outSt(trimmed(inString)); // Result String
   17693       217383 :     std::string::size_type loc = index(outSt, "~~$~~");
   17694       217383 :     while (loc != std::string::npos) {
   17695            0 :         if (isHTML) {
   17696            0 :             outSt = inString.substr(0, loc) + state.dataCostEstimateManager->monetaryUnit(state.dataCostEstimateManager->selectedMonetaryUnit).html +
   17697            0 :                     outSt.substr(loc + 5);
   17698              :         } else {
   17699            0 :             outSt = inString.substr(0, loc) + state.dataCostEstimateManager->monetaryUnit(state.dataCostEstimateManager->selectedMonetaryUnit).txt +
   17700            0 :                     outSt.substr(loc + 5);
   17701              :         }
   17702            0 :         loc = index(outSt, "~~$~~");
   17703              :     }
   17704       217383 :     return outSt;
   17705            0 : }
   17706              : 
   17707        34840 : std::string ConvertToElementTag(std::string const &inString) // Input String
   17708              : {
   17709              :     // SUBROUTINE INFORMATION:
   17710              :     //       AUTHOR         Jason Glazer
   17711              :     //       DATE WRITTEN   February 2013
   17712              :     //       MODIFIED       na
   17713              :     //       RE-ENGINEERED  na
   17714              : 
   17715              :     // PURPOSE OF THIS SUBROUTINE:
   17716              :     //   Convert report column or row header into a tag string
   17717              :     //   that just has A-Z, a-z, or 0-1 characters and is
   17718              :     //   shown in camelCase.
   17719              : 
   17720              :     // METHODOLOGY EMPLOYED:
   17721              :     //   na
   17722              : 
   17723              :     // Return value
   17724        34840 :     std::string outString; // Result String
   17725              : 
   17726              :     // Locals
   17727              :     // SUBROUTINE ARGUMENT DEFINITIONS:
   17728              : 
   17729              :     // SUBROUTINE PARAMETER DEFINITIONS:
   17730              :     // na
   17731              : 
   17732              :     // INTERFACE BLOCK SPECIFICATIONS:
   17733              :     // na
   17734              : 
   17735              :     // DERIVED TYPE DEFINITIONS:
   17736              :     // na
   17737              : 
   17738              :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
   17739              : 
   17740        34840 :     bool foundOther = true; // flag if character found besides A-Z, a-z, 0-9
   17741       723688 :     for (std::string::size_type iIn = 0, e = inString.length(); iIn < e; ++iIn) {
   17742       697482 :         char const c(inString[iIn]);
   17743       697482 :         int const curCharVal = int(c);
   17744       697482 :         if ((curCharVal >= 65) && (curCharVal <= 90)) { // A-Z upper case
   17745       103883 :             if (foundOther) {
   17746        88382 :                 outString += c; // keep as upper case after finding a space or another character
   17747              :             } else {
   17748        15501 :                 outString += char(curCharVal + 32); // convert to lower case
   17749              :             }
   17750       103883 :             foundOther = false;
   17751       593599 :         } else if ((curCharVal >= 97) && (curCharVal <= 122)) { // A-Z lower case
   17752       483635 :             if (foundOther) {
   17753         7028 :                 outString += char(curCharVal - 32); // convert to upper case
   17754              :             } else {
   17755       476607 :                 outString += c; // leave as lower case
   17756              :             }
   17757       483635 :             foundOther = false;
   17758       109964 :         } else if ((curCharVal >= 48) && (curCharVal <= 57)) { // 0-9 numbers
   17759              :             // if first character is a number then prepend with the letter "t"
   17760         9118 :             if (outString.length() == 0) {
   17761         1534 :                 outString += 't';
   17762              :             }
   17763         9118 :             outString += c;
   17764         9118 :             foundOther = false;
   17765       100846 :         } else if (curCharVal == 91) { // [ bracket
   17766         8634 :             break;                     // stop parsing because unit string was found
   17767              :         } else {
   17768        92212 :             foundOther = true;
   17769              :         }
   17770              :     }
   17771        34840 :     return outString;
   17772            0 : }
   17773              : 
   17774           10 : std::string ConvertUnicodeToUTF8(unsigned long const codepoint)
   17775              : {
   17776              :     // Taken from http://stackoverflow.com/a/19968992/2358662 and http://stackoverflow.com/a/148766/2358662
   17777           10 :     std::string s;
   17778           10 :     if (codepoint <= 0x7f) {
   17779            2 :         s.push_back(static_cast<char>(codepoint));
   17780            8 :     } else if (codepoint <= 0x7ff) {
   17781            4 :         s.push_back(static_cast<char>(0xc0 | ((codepoint >> 6) & 0x1f)));
   17782            4 :         s.push_back(static_cast<char>(0x80 | (codepoint & 0x3f)));
   17783            4 :     } else if (codepoint <= 0xffff) {
   17784            1 :         s.push_back(static_cast<char>(0xe0 | ((codepoint >> 12) & 0x0f)));
   17785            1 :         s.push_back(static_cast<char>(0x80 | ((codepoint >> 6) & 0x3f)));
   17786            1 :         s.push_back(static_cast<char>(0x80 | (codepoint & 0x3f)));
   17787            3 :     } else if (codepoint <= 0x10ffff) {
   17788            1 :         s.push_back(static_cast<char>(0xf0 | ((codepoint >> 18) & 0x07)));
   17789            1 :         s.push_back(static_cast<char>(0x80 | ((codepoint >> 12) & 0x3f)));
   17790            1 :         s.push_back(static_cast<char>(0x80 | ((codepoint >> 6) & 0x3f)));
   17791            1 :         s.push_back(static_cast<char>(0x80 | (codepoint & 0x3f)));
   17792              :     }
   17793           10 :     return s;
   17794            0 : }
   17795              : 
   17796       238885 : std::string ConvertToEscaped(std::string const &inString, bool isXML) // Input String
   17797              : {
   17798              :     // SUBROUTINE INFORMATION:
   17799              :     //       AUTHOR         Jason Glazer
   17800              :     //       DATE WRITTEN   February 2013
   17801              :     //       MODIFIED       na
   17802              :     //       RE-ENGINEERED  na
   17803              : 
   17804              :     // PURPOSE OF THIS SUBROUTINE:
   17805              :     //   Convert to XML safe escaped character string
   17806              :     //   so it excludes:
   17807              :     //               " ' < > & degree-sign
   17808              :     //   If isXML=false, it does an HTML conversion, so only ` < > & ` and degree sign
   17809              :     //   Technically HTML4 doesn't support &quot, though most browsers would anyways.
   17810              :     //   Also, escaping single and double quotes is only needed inside attributes
   17811              : 
   17812       238885 :     if (inString.empty()) {
   17813        14384 :         return "";
   17814              :     };
   17815              : 
   17816       231693 :     std::string s;
   17817       231693 :     size_t const inputSize = inString.size();
   17818       231693 :     s.reserve(inputSize);
   17819       231693 :     size_t index = 0;
   17820              : 
   17821              :     while (true) {
   17822      3382239 :         if (index == inputSize) {
   17823       231689 :             break;
   17824              :         }
   17825      3150550 :         char c = inString[index++];
   17826      3150550 :         if ((c == '\"') && isXML) {
   17827            1 :             s += "&quot;";
   17828      3150549 :         } else if (c == '&') {
   17829          188 :             s += "&amp;";
   17830      3150361 :         } else if ((c == '\'') && isXML) {
   17831           33 :             s += "&apos;";
   17832      3150328 :         } else if (c == '<') {
   17833          408 :             s += "&lt;";
   17834      3149920 :         } else if (c == '>') {
   17835         1324 :             s += "&gt;";
   17836      3148596 :         } else if (c == char(176) && !isXML) {
   17837           50 :             s += "&deg;";
   17838      3148546 :         } else if (c == char(226) && char(inString[index]) == char(137) && char(inString[index + 1]) == char(164) && !isXML) { // ≤
   17839          649 :             s += "&le;";
   17840          649 :             index += 2;
   17841      3147897 :         } else if (c == char(226) && char(inString[index]) == char(137) && char(inString[index + 1]) == char(165) && !isXML) { // ≥
   17842            1 :             s += "&ge;";
   17843            1 :             index += 2;
   17844      3147896 :         } else if (c == '\xC2') {
   17845         1328 :             if (index == inputSize) {
   17846            0 :                 s += '\xC2';
   17847              :             } else {
   17848         1328 :                 c = inString[index++];
   17849         1328 :                 if (c == '\xB0' && !isXML) {
   17850         1018 :                     s += "&deg;";
   17851              :                 } else {
   17852          310 :                     s += '\xC2';
   17853          310 :                     s += c;
   17854              :                 }
   17855              :             }
   17856      3146568 :         } else if (c == '\xB0' && !isXML) {
   17857            0 :             s += "&deg;";
   17858      3146568 :         } else if (c == '\\') {
   17859            8 :             if (index == inputSize) {
   17860            0 :                 break;
   17861              :             };
   17862            8 :             c = inString[index++];
   17863            8 :             if ((c == '"') && isXML) {
   17864            1 :                 s += "&quot;";
   17865            7 :             } else if ((c == '\'') && isXML) {
   17866            1 :                 s += "&apos;";
   17867            6 :             } else if (c == 'u' || c == 'x') {
   17868            6 :                 int remainingLen = inputSize - index;
   17869            6 :                 unsigned long codePoint(0);
   17870            6 :                 if (c == 'u' && remainingLen > 3) {
   17871            5 :                     codePoint = std::stoul(inString.substr(index, 4), nullptr, 16);
   17872            1 :                     index += 4;
   17873            3 :                 } else if (c == 'x' && remainingLen > 1) {
   17874            5 :                     codePoint = std::stoul(inString.substr(index, 2), nullptr, 16);
   17875            1 :                     index += 2;
   17876              :                 }
   17877            2 :                 std::string const unicodeString = ConvertUnicodeToUTF8(codePoint);
   17878            2 :                 if (unicodeString == "\xC2\xB0" && !isXML) { // only check for degree at this point
   17879            2 :                     s += "&deg;";
   17880              :                 } else {
   17881            0 :                     s += unicodeString;
   17882              :                 }
   17883            2 :             } else {
   17884            0 :                 s += c;
   17885              :             }
   17886              :         } else {
   17887      3146560 :             s += c;
   17888              :         }
   17889      3150546 :     }
   17890       231689 :     return s;
   17891       231693 : }
   17892              : 
   17893          144 : void DetermineBuildingFloorArea(EnergyPlusData &state)
   17894              : {
   17895              : 
   17896              :     // SUBROUTINE INFORMATION:
   17897              :     //       AUTHOR         Jason Glazer
   17898              :     //       DATE WRITTEN   November 2003
   17899              :     //       MODIFIED       BTG added checks for plenums. Feb2004
   17900              :     //       RE-ENGINEERED  na
   17901              : 
   17902              :     // PURPOSE OF THIS SUBROUTINE:
   17903              :     //   To determine the total floor area of the building and the
   17904              :     //   conditioned floor area of the building
   17905              : 
   17906              :     // METHODOLOGY EMPLOYED:
   17907              :     //   Use the Zone array and sum the areas for all zones
   17908              : 
   17909              :     // REFERENCES:
   17910              :     // na
   17911              : 
   17912              :     // Using/Aliasing
   17913              : 
   17914              :     // Locals
   17915              :     // SUBROUTINE ARGUMENT DEFINITIONS:
   17916              :     // na
   17917              : 
   17918              :     // SUBROUTINE PARAMETER DEFINITIONS:
   17919              : 
   17920              :     // INTERFACE BLOCK SPECIFICATIONS:
   17921              :     // na
   17922              : 
   17923              :     // DERIVED TYPE DEFINITIONS:
   17924              :     // na
   17925              : 
   17926              :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
   17927          144 :     auto const &ort = state.dataOutRptTab;
   17928              : 
   17929          144 :     ort->buildingGrossFloorArea = 0.0;
   17930          144 :     ort->buildingConditionedFloorArea = 0.0;
   17931          317 :     for (int iZone = 1; iZone <= state.dataGlobal->NumOfZones; ++iZone) {
   17932          173 :         auto const &thisZone = state.dataHeatBal->Zone(iZone);
   17933          173 :         Real64 const curZoneArea = thisZone.FloorArea * thisZone.Multiplier * thisZone.ListMultiplier;
   17934              : 
   17935              :         // OLD CHECK IF PLENUM SHOULD BE EXCLUDED AUTOMATICALLY
   17936              :         // check if this zone is also a return plenum or a supply plenum
   17937              :         // found = 0
   17938              :         // if (NumZoneReturnPlenums > 0) THEN
   17939              :         //  found = Util::FindItemInList(thisZone%Name, ZoneRetPlenCond%ZoneName, NumZoneReturnPlenums)
   17940              :         // endif
   17941              :         // IF (found /= 0)  curZoneArea = 0.0d0
   17942              :         // found = 0
   17943              :         // if (NumZoneSupplyPlenums > 0) THEN
   17944              :         //  found = Util::FindItemInList(thisZone%Name, ZoneSupPlenCond%ZoneName, NumZoneSupplyPlenums)
   17945              :         // endif
   17946              :         // IF (found /= 0)  curZoneArea = 0.0d0
   17947              : 
   17948          173 :         if (thisZone.isPartOfTotalArea) {
   17949          170 :             ort->buildingGrossFloorArea += curZoneArea;
   17950              :             // If a ZoneHVAC:EquipmentConnections is used for a zone then
   17951              :             // it is considered conditioned. Also ZONE SUPPLY PLENUM and ZONE RETURN PLENUM are
   17952              :             // also is considered conditioned.
   17953          170 :             if (thisZone.SystemZoneNodeNumber > 0) {
   17954           73 :                 ort->buildingConditionedFloorArea += curZoneArea;
   17955              :             }
   17956              :         }
   17957              :     }
   17958          144 : }
   17959              : 
   17960          132 : void FillRowHead(Array1D_string &rowHead)
   17961              : {
   17962              :     // Forward fill the blanks in rowHead (eg End use column)
   17963          132 :     std::string currentEndUseName;
   17964         1992 :     for (size_t i = 1; i <= rowHead.size(); ++i) {
   17965         1860 :         std::string &thisEndUseName = rowHead(i);
   17966         1860 :         if (thisEndUseName.empty()) {
   17967           12 :             thisEndUseName = currentEndUseName;
   17968              :         } else {
   17969         1848 :             currentEndUseName = thisEndUseName;
   17970              :         }
   17971              :     }
   17972          132 : }
   17973              : 
   17974              : //======================================================================================================================
   17975              : //======================================================================================================================
   17976              : 
   17977              : //    ROUTINES TO RESET GATHERED VALUES TO ZERO
   17978              : 
   17979              : //======================================================================================================================
   17980              : //======================================================================================================================
   17981              : 
   17982            0 : void ResetTabularReports(EnergyPlusData &state)
   17983              : {
   17984              :     // Jason Glazer - October 2015
   17985              :     // Reset all gathering arrays to zero for multi-year simulations
   17986              :     // so that only last year is reported in tabular reports
   17987            0 :     state.dataOutRptTab->gatherElapsedTimeBEPS = 0.0;
   17988            0 :     ResetMonthlyGathering(state);
   17989            0 :     OutputReportTabularAnnual::ResetAnnualGathering(state);
   17990            0 :     ResetBinGathering(state);
   17991            0 :     ResetBEPSGathering(state);
   17992            0 :     ResetSourceEnergyEndUseGathering(state);
   17993            0 :     ResetPeakDemandGathering(state);
   17994            0 :     ResetHeatGainGathering(state);
   17995            0 :     ResetRemainingPredefinedEntries(state);
   17996            0 :     ThermalComfort::ResetThermalComfortSimpleASH55(state);
   17997            0 :     ThermalComfort::ResetSetPointMet(state);
   17998            0 :     ResetAdaptiveComfort(state);
   17999            0 :     state.dataOutputProcessor->isFinalYear = true;
   18000            0 : }
   18001              : 
   18002            1 : void ResetMonthlyGathering(EnergyPlusData &state)
   18003              : {
   18004              :     // Jason Glazer - October 2015
   18005              :     // Reset all monthly gathering arrays to zero for multi-year simulations
   18006              :     // so that only last year is reported in tabular reports
   18007            1 :     auto &ort = state.dataOutRptTab;
   18008              : 
   18009            2 :     for (int iInput = 1; iInput <= ort->MonthlyInputCount; ++iInput) {
   18010            4 :         for (int jTable = 1; jTable <= ort->MonthlyInput(iInput).numTables; ++jTable) {
   18011            3 :             int const curTable = jTable + ort->MonthlyInput(iInput).firstTable - 1;
   18012           12 :             for (int kColumn = 1; kColumn <= ort->MonthlyTables(curTable).numColumns; ++kColumn) {
   18013            9 :                 int const curCol = kColumn + ort->MonthlyTables(curTable).firstColumn - 1;
   18014            9 :                 ort->MonthlyColumns(curCol).timeStamp = 0;
   18015            9 :                 ort->MonthlyColumns(curCol).duration = 0.0;
   18016           18 :                 if (ort->MonthlyColumns(curCol).aggType == AggType::Maximum ||
   18017            9 :                     ort->MonthlyColumns(curCol).aggType == AggType::MaximumDuringHoursShown) {
   18018            0 :                     ort->MonthlyColumns(curCol).reslt = -HUGE_(state.dataOutRptTab->BigNumRMG);
   18019           18 :                 } else if (ort->MonthlyColumns(curCol).aggType == AggType::Minimum ||
   18020            9 :                            ort->MonthlyColumns(curCol).aggType == AggType::MinimumDuringHoursShown) {
   18021            0 :                     ort->MonthlyColumns(curCol).reslt = HUGE_(state.dataOutRptTab->BigNumRMG);
   18022              :                 } else {
   18023            9 :                     ort->MonthlyColumns(curCol).reslt = 0.0;
   18024              :                 }
   18025              :             }
   18026              :         }
   18027              :     }
   18028            1 : }
   18029              : 
   18030            0 : void ResetBinGathering(EnergyPlusData const &state)
   18031              : {
   18032              :     // Jason Glazer - October 2015
   18033              :     // Reset all timebins gathering arrays to zero for multi-year simulations
   18034              :     // so that only last year is reported in tabular reports
   18035            0 :     Real64 constexpr bigVal(0.0); // used with HUGE: Value doesn't matter, only type: Initialize so compiler doesn't warn about use uninitialized
   18036            0 :     auto const &ort = state.dataOutRptTab;
   18037              : 
   18038              :     // clear the binning arrays to zeros
   18039            0 :     for (auto &e : ort->BinResults) {
   18040            0 :         e.mnth = 0.0;
   18041            0 :         e.hrly = 0.0;
   18042              :     }
   18043            0 :     for (auto &e : ort->BinResultsBelow) {
   18044            0 :         e.mnth = 0.0;
   18045            0 :         e.hrly = 0.0;
   18046              :     }
   18047            0 :     for (auto &e : ort->BinResultsAbove) {
   18048            0 :         e.mnth = 0.0;
   18049            0 :         e.hrly = 0.0;
   18050              :     }
   18051              : 
   18052              :     // re-initialize statistics counters
   18053            0 :     for (auto &e : ort->BinStatistics) {
   18054            0 :         e.minimum = HUGE_(bigVal);
   18055            0 :         e.maximum = -HUGE_(bigVal);
   18056            0 :         e.n = 0;
   18057            0 :         e.sum = 0.0;
   18058            0 :         e.sum2 = 0.0;
   18059              :     }
   18060            0 : }
   18061              : 
   18062            1 : void ResetBEPSGathering(EnergyPlusData const &state)
   18063              : {
   18064              :     // Jason Glazer - October 2015
   18065              :     // Reset all ABUPS gathering arrays to zero for multi-year simulations
   18066              :     // so that only last year is reported in tabular reports
   18067            1 :     auto const &ort = state.dataOutRptTab;
   18068            1 :     ort->gatherTotalsBEPS = 0.0;
   18069            1 :     ort->gatherEndUseBEPS = 0.0;
   18070            1 :     ort->gatherEndUseSubBEPS = 0.0;
   18071            1 :     ort->gatherTotalsSource = 0.0;
   18072              :     // reset the specific components being gathered
   18073            1 :     ort->gatherPowerFuelFireGen = 0.0;
   18074            1 :     ort->gatherPowerPV = 0.0;
   18075            1 :     ort->gatherPowerWind = 0.0;
   18076            1 :     ort->gatherPowerHTGeothermal = 0.0;
   18077            1 :     ort->gatherElecProduced = 0.0;
   18078            1 :     ort->gatherElecPurchased = 0.0;
   18079            1 :     ort->gatherElecSurplusSold = 0.0;
   18080            1 :     ort->gatherElecStorage = 0.0;
   18081            1 :     ort->gatherPowerConversion = 0.0;
   18082            1 :     ort->gatherWaterHeatRecovery = 0.0;
   18083            1 :     ort->gatherAirHeatRecoveryCool = 0.0;
   18084            1 :     ort->gatherAirHeatRecoveryHeat = 0.0;
   18085            1 :     ort->gatherHeatHTGeothermal = 0.0;
   18086            1 :     ort->gatherHeatSolarWater = 0.0;
   18087            1 :     ort->gatherHeatSolarAir = 0.0;
   18088            1 :     ort->gatherRainWater = 0.0;
   18089            1 :     ort->gatherCondensate = 0.0;
   18090            1 :     ort->gatherWellwater = 0.0;
   18091            1 :     ort->gatherMains = 0.0;
   18092            1 :     ort->gatherWaterEndUseTotal = 0.0;
   18093            1 : }
   18094              : 
   18095            0 : void ResetSourceEnergyEndUseGathering(EnergyPlusData const &state)
   18096              : {
   18097              :     // Jason Glazer - October 2015
   18098              :     // Reset all source energy end use table gathering arrays to zero for multi-year simulations
   18099              :     // so that only last year is reported in tabular reports
   18100            0 :     auto const &ort = state.dataOutRptTab;
   18101            0 :     ort->gatherTotalsBySourceBEPS = 0.0;
   18102            0 :     ort->gatherEndUseBySourceBEPS = 0.0;
   18103            0 : }
   18104              : 
   18105            0 : void ResetPeakDemandGathering(EnergyPlusData const &state)
   18106              : {
   18107              :     // Jason Glazer - October 2015
   18108              :     // Reset all demand end use components table gathering arrays to zero for multi-year simulations
   18109              :     // so that only last year is reported in tabular reports
   18110            0 :     auto const &ort = state.dataOutRptTab;
   18111            0 :     ort->gatherDemandTotal = 0.0;
   18112            0 :     ort->gatherDemandTimeStamp = 0;
   18113            0 :     ort->gatherDemandEndUse = 0.0;
   18114            0 :     ort->gatherDemandEndUseSub = 0.0;
   18115            0 : }
   18116              : 
   18117            0 : void ResetHeatGainGathering(EnergyPlusData &state)
   18118              : {
   18119              :     // Jason Glazer - October 2015
   18120              :     // Reset all sensible heat gas summary report gathering arrays to zero for multi-year simulations
   18121              :     // so that only last year is reported in tabular reports
   18122            0 :     for (int iZone = 1; iZone <= state.dataGlobal->NumOfZones; ++iZone) {
   18123            0 :         auto &thisZonePreDefRep = state.dataHeatBal->ZonePreDefRep(iZone);
   18124              : 
   18125            0 :         thisZonePreDefRep.SHGSAnPeoplAdd = 0.;
   18126            0 :         thisZonePreDefRep.SHGSAnLiteAdd = 0.;
   18127            0 :         thisZonePreDefRep.SHGSAnZoneEqHt = 0.;
   18128            0 :         thisZonePreDefRep.SHGSAnZoneEqCl = 0.;
   18129            0 :         thisZonePreDefRep.SHGSAnIzaAdd = 0.;
   18130            0 :         thisZonePreDefRep.SHGSAnIzaRem = 0.;
   18131            0 :         thisZonePreDefRep.SHGSAnWindAdd = 0.;
   18132            0 :         thisZonePreDefRep.SHGSAnWindRem = 0.;
   18133            0 :         thisZonePreDefRep.SHGSAnInfilAdd = 0.;
   18134            0 :         thisZonePreDefRep.SHGSAnInfilRem = 0.;
   18135            0 :         thisZonePreDefRep.SHGSAnEquipAdd = 0.;
   18136            0 :         thisZonePreDefRep.SHGSAnEquipRem = 0.;
   18137            0 :         thisZonePreDefRep.SHGSAnHvacATUHt = 0.;
   18138            0 :         thisZonePreDefRep.SHGSAnHvacATUCl = 0.;
   18139            0 :         thisZonePreDefRep.SHGSAnSurfHt = 0.;
   18140            0 :         thisZonePreDefRep.SHGSAnSurfCl = 0.;
   18141            0 :         thisZonePreDefRep.SHGSAnOtherAdd = 0.;
   18142            0 :         thisZonePreDefRep.SHGSAnOtherRem = 0.;
   18143            0 :         thisZonePreDefRep.htPeak = 0.;
   18144            0 :         thisZonePreDefRep.htPtTimeStamp = 0;
   18145            0 :         thisZonePreDefRep.SHGSHtHvacHt = 0.;
   18146            0 :         thisZonePreDefRep.SHGSHtHvacCl = 0.;
   18147            0 :         thisZonePreDefRep.SHGSHtSurfHt = 0.;
   18148            0 :         thisZonePreDefRep.SHGSHtSurfCl = 0.;
   18149            0 :         thisZonePreDefRep.SHGSHtHvacATUHt = 0.;
   18150            0 :         thisZonePreDefRep.SHGSHtHvacATUCl = 0.;
   18151            0 :         thisZonePreDefRep.SHGSHtPeoplAdd = 0.;
   18152            0 :         thisZonePreDefRep.SHGSHtLiteAdd = 0.;
   18153            0 :         thisZonePreDefRep.SHGSHtEquipAdd = 0.;
   18154            0 :         thisZonePreDefRep.SHGSHtEquipRem = 0.;
   18155            0 :         thisZonePreDefRep.SHGSHtWindAdd = 0.;
   18156            0 :         thisZonePreDefRep.SHGSHtWindRem = 0.;
   18157            0 :         thisZonePreDefRep.SHGSHtIzaAdd = 0.;
   18158            0 :         thisZonePreDefRep.SHGSHtIzaRem = 0.;
   18159            0 :         thisZonePreDefRep.SHGSHtInfilAdd = 0.;
   18160            0 :         thisZonePreDefRep.SHGSHtInfilRem = 0.;
   18161            0 :         thisZonePreDefRep.SHGSHtOtherAdd = 0.;
   18162            0 :         thisZonePreDefRep.SHGSHtOtherRem = 0.;
   18163            0 :         thisZonePreDefRep.clPeak = 0.;
   18164            0 :         thisZonePreDefRep.clPtTimeStamp = 0;
   18165            0 :         thisZonePreDefRep.SHGSClHvacHt = 0.;
   18166            0 :         thisZonePreDefRep.SHGSClHvacCl = 0.;
   18167            0 :         thisZonePreDefRep.SHGSClSurfHt = 0.;
   18168            0 :         thisZonePreDefRep.SHGSClSurfCl = 0.;
   18169            0 :         thisZonePreDefRep.SHGSClHvacATUHt = 0.;
   18170            0 :         thisZonePreDefRep.SHGSClHvacATUCl = 0.;
   18171            0 :         thisZonePreDefRep.SHGSClPeoplAdd = 0.;
   18172            0 :         thisZonePreDefRep.SHGSClLiteAdd = 0.;
   18173            0 :         thisZonePreDefRep.SHGSClEquipAdd = 0.;
   18174            0 :         thisZonePreDefRep.SHGSClEquipRem = 0.;
   18175            0 :         thisZonePreDefRep.SHGSClWindAdd = 0.;
   18176            0 :         thisZonePreDefRep.SHGSClWindRem = 0.;
   18177            0 :         thisZonePreDefRep.SHGSClIzaAdd = 0.;
   18178            0 :         thisZonePreDefRep.SHGSClIzaRem = 0.;
   18179            0 :         thisZonePreDefRep.SHGSClInfilAdd = 0.;
   18180            0 :         thisZonePreDefRep.SHGSClInfilRem = 0.;
   18181            0 :         thisZonePreDefRep.SHGSClOtherAdd = 0.;
   18182            0 :         thisZonePreDefRep.SHGSClOtherRem = 0.;
   18183              :     }
   18184              : 
   18185            0 :     state.dataHeatBal->BuildingPreDefRep.htPeak = 0.;
   18186            0 :     state.dataHeatBal->BuildingPreDefRep.htPtTimeStamp = 0;
   18187            0 :     state.dataHeatBal->BuildingPreDefRep.SHGSHtHvacHt = 0.0;
   18188            0 :     state.dataHeatBal->BuildingPreDefRep.SHGSHtHvacCl = 0.0;
   18189            0 :     state.dataHeatBal->BuildingPreDefRep.SHGSHtHvacATUHt = 0.0;
   18190            0 :     state.dataHeatBal->BuildingPreDefRep.SHGSHtHvacATUCl = 0.0;
   18191            0 :     state.dataHeatBal->BuildingPreDefRep.SHGSHtSurfHt = 0.0;
   18192            0 :     state.dataHeatBal->BuildingPreDefRep.SHGSHtSurfCl = 0.0;
   18193            0 :     state.dataHeatBal->BuildingPreDefRep.SHGSHtPeoplAdd = 0.0;
   18194            0 :     state.dataHeatBal->BuildingPreDefRep.SHGSHtLiteAdd = 0.0;
   18195            0 :     state.dataHeatBal->BuildingPreDefRep.SHGSHtEquipAdd = 0.0;
   18196            0 :     state.dataHeatBal->BuildingPreDefRep.SHGSHtWindAdd = 0.0;
   18197            0 :     state.dataHeatBal->BuildingPreDefRep.SHGSHtIzaAdd = 0.0;
   18198            0 :     state.dataHeatBal->BuildingPreDefRep.SHGSHtInfilAdd = 0.0;
   18199            0 :     state.dataHeatBal->BuildingPreDefRep.SHGSHtOtherAdd = 0.0;
   18200            0 :     state.dataHeatBal->BuildingPreDefRep.SHGSHtEquipRem = 0.0;
   18201            0 :     state.dataHeatBal->BuildingPreDefRep.SHGSHtWindRem = 0.0;
   18202            0 :     state.dataHeatBal->BuildingPreDefRep.SHGSHtIzaRem = 0.0;
   18203            0 :     state.dataHeatBal->BuildingPreDefRep.SHGSHtInfilRem = 0.0;
   18204            0 :     state.dataHeatBal->BuildingPreDefRep.SHGSHtOtherRem = 0.0;
   18205              : 
   18206            0 :     state.dataHeatBal->BuildingPreDefRep.clPeak = 0.;
   18207            0 :     state.dataHeatBal->BuildingPreDefRep.clPtTimeStamp = 0;
   18208            0 :     state.dataHeatBal->BuildingPreDefRep.SHGSClHvacHt = 0.0;
   18209            0 :     state.dataHeatBal->BuildingPreDefRep.SHGSClHvacCl = 0.0;
   18210            0 :     state.dataHeatBal->BuildingPreDefRep.SHGSClSurfHt = 0.0;
   18211            0 :     state.dataHeatBal->BuildingPreDefRep.SHGSClSurfCl = 0.0;
   18212            0 :     state.dataHeatBal->BuildingPreDefRep.SHGSClHvacATUHt = 0.0;
   18213            0 :     state.dataHeatBal->BuildingPreDefRep.SHGSClHvacATUCl = 0.0;
   18214            0 :     state.dataHeatBal->BuildingPreDefRep.SHGSClPeoplAdd = 0.0;
   18215            0 :     state.dataHeatBal->BuildingPreDefRep.SHGSClLiteAdd = 0.0;
   18216            0 :     state.dataHeatBal->BuildingPreDefRep.SHGSClEquipAdd = 0.0;
   18217            0 :     state.dataHeatBal->BuildingPreDefRep.SHGSClWindAdd = 0.0;
   18218            0 :     state.dataHeatBal->BuildingPreDefRep.SHGSClIzaAdd = 0.0;
   18219            0 :     state.dataHeatBal->BuildingPreDefRep.SHGSClInfilAdd = 0.0;
   18220            0 :     state.dataHeatBal->BuildingPreDefRep.SHGSClOtherAdd = 0.0;
   18221            0 :     state.dataHeatBal->BuildingPreDefRep.SHGSClEquipRem = 0.0;
   18222            0 :     state.dataHeatBal->BuildingPreDefRep.SHGSClWindRem = 0.0;
   18223            0 :     state.dataHeatBal->BuildingPreDefRep.SHGSClIzaRem = 0.0;
   18224            0 :     state.dataHeatBal->BuildingPreDefRep.SHGSClInfilRem = 0.0;
   18225            0 :     state.dataHeatBal->BuildingPreDefRep.SHGSClOtherRem = 0.0;
   18226            0 : }
   18227              : 
   18228            0 : void ResetRemainingPredefinedEntries(EnergyPlusData &state)
   18229              : {
   18230              :     // Jason Glazer - October 2015
   18231              :     // Reset all entries that are added to the predefined reports in the FillRemainingPredefinedEntries() function to zero for multi-year
   18232              :     // simulations so that only last year is reported in tabular reports
   18233              : 
   18234            0 :     Real64 constexpr bigVal(0.0); // used with HUGE: Value doesn't matter, only type: Initialize so compiler doesn't warn about use uninitialized
   18235              : 
   18236            0 :     for (int iLight = 1; iLight <= state.dataHeatBal->TotLights; ++iLight) {
   18237            0 :         state.dataHeatBal->Lights(iLight).SumTimeNotZeroCons = 0.;
   18238            0 :         state.dataHeatBal->Lights(iLight).SumConsumption = 0.;
   18239              :     }
   18240              : 
   18241            0 :     for (int iZone = 1; iZone <= state.dataGlobal->NumOfZones; ++iZone) {
   18242            0 :         auto const &thisZone = state.dataHeatBal->Zone(iZone);
   18243              : 
   18244            0 :         if (thisZone.SystemZoneNodeNumber >= 0) { // conditioned zones only
   18245            0 :             if (thisZone.isNominalOccupied) {
   18246            0 :                 auto &thisZonePreDefRep = state.dataHeatBal->ZonePreDefRep(iZone);
   18247              : 
   18248            0 :                 thisZonePreDefRep.MechVentVolTotalOcc = 0.;
   18249            0 :                 thisZonePreDefRep.MechVentVolTotalOccStdDen = 0.;
   18250            0 :                 thisZonePreDefRep.MechVentVolMin = HUGE_(bigVal);
   18251            0 :                 thisZonePreDefRep.InfilVolTotalOcc = 0.;
   18252            0 :                 thisZonePreDefRep.InfilVolTotalOccStdDen = 0.;
   18253            0 :                 thisZonePreDefRep.InfilVolMin = HUGE_(bigVal);
   18254            0 :                 thisZonePreDefRep.AFNInfilVolTotalOcc = 0.;
   18255            0 :                 thisZonePreDefRep.AFNInfilVolTotalOccStdDen = 0.;
   18256            0 :                 thisZonePreDefRep.AFNInfilVolMin = HUGE_(bigVal);
   18257            0 :                 thisZonePreDefRep.SimpVentVolTotalOcc = 0.;
   18258            0 :                 thisZonePreDefRep.SimpVentVolTotalOccStdDen = 0.;
   18259            0 :                 thisZonePreDefRep.SimpVentVolMin = HUGE_(bigVal);
   18260            0 :                 thisZonePreDefRep.AFNVentVolTotalOccStdDen = 0.;
   18261            0 :                 thisZonePreDefRep.TotTimeOcc = 0.;
   18262              :             }
   18263              :         }
   18264              :     }
   18265            0 : }
   18266              : 
   18267            0 : void ResetAdaptiveComfort(EnergyPlusData &state)
   18268              : {
   18269              :     // Jason Glazer - October 2015
   18270              :     // Reset accumulation variable for adaptive comfort report to zero for multi-year simulations
   18271              :     // so that only last year is reported in tabular reports
   18272            0 :     auto const &ort = state.dataOutRptTab;
   18273            0 :     if (ort->displayAdaptiveComfort && state.dataHeatBal->TotPeople > 0) {
   18274            0 :         for (int i = 1; i <= state.dataHeatBal->TotPeople; ++i) {
   18275            0 :             auto &thisPeople = state.dataHeatBal->People(i);
   18276              : 
   18277            0 :             if (thisPeople.AdaptiveASH55) {
   18278            0 :                 thisPeople.TimeNotMetASH5590 = 0.;
   18279            0 :                 thisPeople.TimeNotMetASH5580 = 0.;
   18280              :             }
   18281            0 :             if (thisPeople.AdaptiveCEN15251) {
   18282            0 :                 thisPeople.TimeNotMetCEN15251CatI = 0.;
   18283            0 :                 thisPeople.TimeNotMetCEN15251CatII = 0.;
   18284            0 :                 thisPeople.TimeNotMetCEN15251CatIII = 0.;
   18285              :             }
   18286              :         }
   18287              :     }
   18288            0 : }
   18289              : 
   18290              : //======================================================================================================================
   18291              : //======================================================================================================================
   18292              : 
   18293              : //    ROUTINES RELATED TO IF VALUE IS IN A RANGE
   18294              : 
   18295              : //======================================================================================================================
   18296              : //======================================================================================================================
   18297              : 
   18298        30496 : bool isInTriangle(
   18299              :     Real64 const qx, Real64 const qy, Real64 const x1, Real64 const y1, Real64 const x2, Real64 const y2, Real64 const x3, Real64 const y3)
   18300              : {
   18301              :     // SUBROUTINE INFORMATION:
   18302              :     //       AUTHOR         Jason Glazer
   18303              :     //       DATE WRITTEN   June 2005
   18304              :     //       MODIFIED
   18305              :     //       RE-ENGINEERED  na
   18306              : 
   18307              :     // PURPOSE OF THIS SUBROUTINE:
   18308              :     //   Determine if point q is in triangle defined by points a,b,c
   18309              : 
   18310              :     // METHODOLOGY EMPLOYED:
   18311              :     //   The function used three times is positive the point is on the "right"
   18312              :     //   side and negative if on "left" side. By checking to make sure the signs
   18313              :     //   are always the same. it determines that the point is inside of the
   18314              :     //   triangle.
   18315              : 
   18316              :     // REFERENCES:
   18317              :     //   http://mcraefamily.com/MathHelp/GeometryPointAndTriangle2.htm
   18318              : 
   18319        30496 :     Real64 const fAB = (qy - y1) * (x2 - x1) - (qx - x1) * (y2 - y1);
   18320        30496 :     Real64 const fCA = (qy - y3) * (x1 - x3) - (qx - x3) * (y1 - y3);
   18321        30496 :     Real64 const fBC = (qy - y2) * (x3 - x2) - (qx - x2) * (y3 - y2);
   18322        30496 :     return ((fAB * fBC) >= 0.0 && (fBC * fCA) >= 0.0);
   18323              : }
   18324              : 
   18325        15248 : bool isInQuadrilateral(Real64 const qx,
   18326              :                        Real64 const qy,
   18327              :                        Real64 const ax,
   18328              :                        Real64 const ay,
   18329              :                        Real64 const bx,
   18330              :                        Real64 const by,
   18331              :                        Real64 const cx,
   18332              :                        Real64 const cy,
   18333              :                        Real64 const dx,
   18334              :                        Real64 const dy)
   18335              : {
   18336              :     // SUBROUTINE INFORMATION:
   18337              :     //       AUTHOR         Jason Glazer
   18338              :     //       DATE WRITTEN   June 2005
   18339              :     //       MODIFIED
   18340              :     //       RE-ENGINEERED  na
   18341              : 
   18342              :     // PURPOSE OF THIS SUBROUTINE:
   18343              :     //   Determine if point q is in a quadrilateral defined by points a,b,c,d
   18344              :     //   Those points should express a quadrilateral in order of the points going
   18345              :     //   around the outside of the polygon. They should not describe an "hourglass"
   18346              :     //   shape where the lines cross in the middle of the figure.
   18347              : 
   18348              :     // METHODOLOGY EMPLOYED:
   18349              :     //   Check if the point is in triangle a,b,c or in triangle c,d,a
   18350              : 
   18351              :     // REFERENCES:
   18352              :     //   http://mcraefamily.com/MathHelp/GeometryPointAndTriangle4.htm
   18353              : 
   18354        15248 :     bool const inABC = isInTriangle(qx, qy, ax, ay, bx, by, cx, cy);
   18355        15248 :     bool const inCDA = isInTriangle(qx, qy, cx, cy, dx, dy, ax, ay);
   18356        15248 :     return (inABC || inCDA);
   18357              : }
   18358              : 
   18359              : //======================================================================================================================
   18360              : //======================================================================================================================
   18361              : 
   18362              : //    SUPPORT ROUTINES
   18363              : 
   18364              : //======================================================================================================================
   18365              : //======================================================================================================================
   18366              : 
   18367        91152 : std::string RealToStr(Real64 const RealIn, int const numDigits)
   18368              : {
   18369              :     // FUNCTION INFORMATION:
   18370              :     //       AUTHOR         Jason Glazer
   18371              :     //       DATE WRITTEN   August 2003
   18372              :     //       MODIFIED       November 2008; LKL - prevent errors
   18373              :     //       RE-ENGINEERED  na
   18374              : 
   18375              :     // PURPOSE OF THIS FUNCTION:
   18376              :     //   Abstract away the internal write concept
   18377              : 
   18378              :     static constexpr std::array<const char *, 10> formDigitsA{
   18379              :         "{:#11.0F}", "{:12.1F}", "{:12.2F}", "{:12.3F}", "{:12.4F}", "{:12.5F}", "{:12.6F}", "{:12.7F}", "{:12.8F}", "{:12.9F}"};
   18380              : 
   18381              :     static constexpr std::array<Real64, 10> maxvalDigitsA(
   18382              :         {9999999999.0, 999999999.0, 99999999.0, 9999999.0, 999999.0, 99999.0, 9999.0, 999.0, 99.0, 9.0});
   18383              : 
   18384              :     // FUNCTION LOCAL VARIABLE DECLARATIONS:
   18385        91152 :     int nDigits = numDigits;
   18386        91152 :     if (RealIn < 0.0) {
   18387          491 :         --nDigits;
   18388              :     }
   18389        91152 :     if (nDigits > 9) {
   18390            8 :         nDigits = 9;
   18391              :     }
   18392        91152 :     if (nDigits < 0) {
   18393            0 :         nDigits = 0;
   18394              :     }
   18395              : 
   18396        91152 :     if (std::abs(RealIn) > maxvalDigitsA.at(nDigits)) {
   18397          148 :         return format("{:12.6Z}", RealIn);
   18398              :     } else {
   18399        91004 :         return format<FormatSyntax::FMT>(formDigitsA.at(nDigits), RealIn);
   18400              :     }
   18401              :     //  WRITE(FMT=, UNIT=stringOut) RealIn
   18402              :     // check if it did not fit
   18403              :     //  IF (stringOut(1:1) .EQ. "*") THEN
   18404              :     //    WRITE(FMT='(E12.6)', UNIT=stringOut) RealIn
   18405              :     //  END IF
   18406              : 
   18407              :     // WRITE(FMT="(F10.4)", UNIT=stringOut, IOSTAT=status ) RealIn
   18408              : }
   18409              : 
   18410         9142 : Real64 StrToReal(std::string_view stringIn)
   18411              : {
   18412              :     // SUBROUTINE INFORMATION:
   18413              :     //       AUTHOR         Linda Lawrie
   18414              :     //       DATE WRITTEN   March 2010
   18415              :     //       MODIFIED       na
   18416              :     //       RE-ENGINEERED  na
   18417              : 
   18418              :     // PURPOSE OF THIS SUBROUTINE:
   18419              :     //   Abstract away the internal read concept
   18420              : 
   18421         9142 :     size_t first_char = stringIn.find_first_not_of(' ');
   18422         9142 :     if (first_char != std::string_view::npos) {
   18423         9142 :         stringIn.remove_prefix(first_char);
   18424              :     }
   18425              : 
   18426         9142 :     Real64 realValue = -99999.0;
   18427         9142 :     auto answer = fast_float::from_chars(stringIn.data(), stringIn.data() + stringIn.size(), realValue); // (AUTO_OK_OBJ)
   18428         9142 :     if (answer.ec != std::errc()) {
   18429            0 :         return -99999.0;
   18430              :     }
   18431         9142 :     return realValue;
   18432              : }
   18433              : 
   18434         1038 : std::string DateToString(int const codedDate) // word containing encoded month, day, hour, minute
   18435              : {
   18436              :     // SUBROUTINE INFORMATION:
   18437              :     //       AUTHOR         Jason Glazer
   18438              :     //       DATE WRITTEN   August 2003
   18439              :     //       MODIFIED       na
   18440              :     //       RE-ENGINEERED  na
   18441              : 
   18442              :     // PURPOSE OF THIS SUBROUTINE:
   18443              :     //   Convert the coded date format into a usable
   18444              :     //   string
   18445              : 
   18446              :     int Month;  // month in integer format (1-12)
   18447              :     int Day;    // day in integer format (1-31)
   18448              :     int Hour;   // hour in integer format (1-24)
   18449              :     int Minute; // minute in integer format (0:59)
   18450              :     static constexpr std::array<std::string_view, 12> Months{"JAN", "FEB", "MAR", "APR", "MAY", "JUN", "JUL", "AUG", "SEP", "OCT", "NOV", "DEC"};
   18451              : 
   18452         1038 :     if (codedDate == 0) {
   18453         2016 :         return "-";
   18454              :     }
   18455              : 
   18456           30 :     General::DecodeMonDayHrMin(codedDate, Month, Day, Hour, Minute);
   18457           30 :     if (Month < 1 || Month > 12) {
   18458            0 :         return "-";
   18459              :     }
   18460              : 
   18461           30 :     --Hour;
   18462           30 :     if (Minute == 60) {
   18463            0 :         ++Hour;
   18464            0 :         Minute = 0;
   18465              :     }
   18466              : 
   18467           60 :     return fmt::format("{:02}-{:3}-{:02}:{:02}", Day, Months[Month - 1], Hour, Minute);
   18468              : }
   18469              : 
   18470          534 : bool isNumber(std::string const &s)
   18471              : {
   18472              :     char *p;
   18473          534 :     strtod(s.c_str(), &p);
   18474          540 :     for (; isspace(*p); ++p) {
   18475              :         ; // handle trailing whitespace
   18476              :     }
   18477          534 :     return *p == 0;
   18478              : }
   18479              : 
   18480              : // return the number of digits after the decimal point
   18481              : // Glazer - November 2016
   18482          196 : int digitsAferDecimal(std::string const &s)
   18483              : {
   18484          196 :     std::size_t decimalpos = s.find('.');
   18485              :     std::size_t numDigits;
   18486          196 :     if (decimalpos == s.npos) {
   18487            7 :         numDigits = 0;
   18488              :     } else {
   18489          189 :         std::size_t epos = s.find('E');
   18490          189 :         if (epos == s.npos) {
   18491          177 :             epos = s.find('e');
   18492              :         }
   18493          189 :         if (epos == s.npos) {
   18494          177 :             numDigits = s.length() - (decimalpos + 1);
   18495              :         } else {
   18496           12 :             numDigits = epos - (decimalpos + 1);
   18497              :         }
   18498              :     }
   18499          196 :     return int(numDigits);
   18500              : }
   18501              : 
   18502           12 : void AddTOCEntry(EnergyPlusData &state, std::string const &nameSection, std::string const &nameReport)
   18503              : {
   18504              :     // SUBROUTINE INFORMATION:
   18505              :     //    AUTHOR         Jason Glazer of GARD Analytics, Inc.
   18506              :     //    DATE WRITTEN   September 2005
   18507              :     //    MODIFIED       na
   18508              :     //    RE-ENGINEERED  na
   18509              : 
   18510              :     // PURPOSE OF THIS SUBROUTINE:
   18511              :     //   Adds an entry for the TOC so that it can be created
   18512              :     //   prior to the actual reports being generated. Note that
   18513              :     //   the arguments must match what is used in
   18514              :     //   "WriteReportHeaders" for the HTML anchors to work
   18515              :     //   correctly.
   18516              : 
   18517              :     // METHODOLOGY EMPLOYED:
   18518              : 
   18519              :     // REFERENCES:
   18520              :     //    na
   18521              : 
   18522              :     // USE STATEMENTS:
   18523              : 
   18524              :     // Locals
   18525              :     // SUBROUTINE ARGUMENT DEFINITIONS:
   18526              : 
   18527              :     // SUBROUTINE PARAMETER DEFINITIONS:
   18528              :     //    na
   18529              : 
   18530              :     // INTERFACE BLOCK SPECIFICATIONS:
   18531              :     //    na
   18532              : 
   18533              :     // DERIVED TYPE DEFINITIONS:
   18534              :     //    na
   18535              : 
   18536              :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
   18537              :     //    na
   18538           12 :     auto &ort = state.dataOutRptTab;
   18539              : 
   18540           12 :     if (!allocated(ort->TOCEntries)) {
   18541            4 :         ort->TOCEntriesSize = 20;
   18542            4 :         ort->TOCEntries.allocate(ort->TOCEntriesSize);
   18543            4 :         ort->TOCEntriesCount = 1;
   18544              :     } else {
   18545            8 :         ++ort->TOCEntriesCount;
   18546              :         // if larger than current size grow the array
   18547            8 :         if (ort->TOCEntriesCount > ort->TOCEntriesSize) {
   18548            0 :             ort->TOCEntries.redimension(ort->TOCEntriesSize += 20);
   18549              :         }
   18550              :     }
   18551           12 :     ort->TOCEntries(ort->TOCEntriesCount).reportName = nameReport;
   18552           12 :     ort->TOCEntries(ort->TOCEntriesCount).sectionName = nameSection;
   18553           12 : }
   18554              : 
   18555           94 : void SetupUnitConversions(EnergyPlusData &state)
   18556              : {
   18557              :     // SUBROUTINE INFORMATION:
   18558              :     //    AUTHOR         Jason Glazer of GARD Analytics, Inc.
   18559              :     //    DATE WRITTEN   February 12, 2009
   18560              :     //    MODIFIED       March 2010; Linda Lawrie; Add deltaC and KJ/KG
   18561              :     //    RE-ENGINEERED  na
   18562              : 
   18563              :     // PURPOSE OF THIS SUBROUTINE:
   18564              :     //   Initialize the array that contains the unit conversion
   18565              :     //   information. The code is based on code generated
   18566              :     //   in a spreadsheet titled UnitConversion.xls
   18567              : 
   18568              :     // METHODOLOGY EMPLOYED:
   18569              : 
   18570              :     // REFERENCES:
   18571              :     //    na
   18572              : 
   18573              :     // USE STATEMENTS:
   18574              : 
   18575              :     // SUBROUTINE ARGUMENT DEFINITIONS:
   18576              : 
   18577              :     // SUBROUTINE PARAMETER DEFINITIONS:
   18578              :     //    na
   18579              : 
   18580              :     // INTERFACE BLOCK SPECIFICATIONS:
   18581              :     //    na
   18582              : 
   18583              :     // DERIVED TYPE DEFINITIONS:
   18584              :     //    na
   18585              : 
   18586              :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
   18587              :     //    na
   18588           94 :     auto &ort = state.dataOutRptTab;
   18589              : 
   18590           94 :     ort->UnitConvSize = 118;
   18591           94 :     ort->UnitConv.allocate(ort->UnitConvSize);
   18592           94 :     ort->UnitConv(1).siName = "%";
   18593           94 :     ort->UnitConv(2).siName = "°C";
   18594           94 :     ort->UnitConv(3).siName = "0=OFF 1=ON";
   18595           94 :     ort->UnitConv(4).siName = "0-NO  1-YES";
   18596           94 :     ort->UnitConv(5).siName = "1-YES 0-NO";
   18597           94 :     ort->UnitConv(6).siName = "A";
   18598           94 :     ort->UnitConv(7).siName = "ACH";
   18599           94 :     ort->UnitConv(8).siName = "ACH";
   18600           94 :     ort->UnitConv(9).siName = "BASE 10C";
   18601           94 :     ort->UnitConv(10).siName = "BASE 18C";
   18602           94 :     ort->UnitConv(11).siName = "C";
   18603           94 :     ort->UnitConv(12).siName = "CD/M2";
   18604           94 :     ort->UnitConv(13).siName = "DEG";
   18605           94 :     ort->UnitConv(14).siName = "FRAC";
   18606           94 :     ort->UnitConv(15).siName = "HOUR";
   18607           94 :     ort->UnitConv(16).siName = "HOURS";
   18608           94 :     ort->UnitConv(17).siName = "HR";
   18609           94 :     ort->UnitConv(18).siName = "HRS";
   18610           94 :     ort->UnitConv(19).siName = "J";
   18611           94 :     ort->UnitConv(20).siName = "J";
   18612           94 :     ort->UnitConv(21).siName = "J";
   18613           94 :     ort->UnitConv(22).siName = "J";
   18614           94 :     ort->UnitConv(23).siName = "J";
   18615           94 :     ort->UnitConv(24).siName = "J";
   18616           94 :     ort->UnitConv(25).siName = "J/KG";
   18617           94 :     ort->UnitConv(26).siName = "J/KGWATER";
   18618           94 :     ort->UnitConv(27).siName = "J/M2";
   18619           94 :     ort->UnitConv(28).siName = "K/M";
   18620           94 :     ort->UnitConv(29).siName = "KG";
   18621           94 :     ort->UnitConv(30).siName = "KG/KG";
   18622           94 :     ort->UnitConv(31).siName = "KG/M3";
   18623           94 :     ort->UnitConv(32).siName = "KG/S";
   18624           94 :     ort->UnitConv(33).siName = "KGWATER/KGDRYAIR";
   18625           94 :     ort->UnitConv(34).siName = "KGWATER/SEC";
   18626           94 :     ort->UnitConv(35).siName = "KMOL/S";
   18627           94 :     ort->UnitConv(36).siName = "KMOL/SEC";
   18628           94 :     ort->UnitConv(37).siName = "KWH";
   18629           94 :     ort->UnitConv(38).siName = "L";
   18630           94 :     ort->UnitConv(39).siName = "L";
   18631           94 :     ort->UnitConv(40).siName = "LUM/W";
   18632           94 :     ort->UnitConv(41).siName = "LUX";
   18633           94 :     ort->UnitConv(42).siName = "M";
   18634           94 :     ort->UnitConv(43).siName = "M";
   18635           94 :     ort->UnitConv(44).siName = "M/S";
   18636           94 :     ort->UnitConv(45).siName = "M/S";
   18637           94 :     ort->UnitConv(46).siName = "M2";
   18638           94 :     ort->UnitConv(47).siName = "M2/PERSON";
   18639           94 :     ort->UnitConv(48).siName = "M3";
   18640           94 :     ort->UnitConv(49).siName = "M3";
   18641           94 :     ort->UnitConv(50).siName = "M3/M2";
   18642           94 :     ort->UnitConv(51).siName = "M3/S";
   18643           94 :     ort->UnitConv(52).siName = "M3/S";
   18644           94 :     ort->UnitConv(53).siName = "M3/S-M2";
   18645           94 :     ort->UnitConv(54).siName = "M3/S-PERSON";
   18646           94 :     ort->UnitConv(55).siName = "M3/S-PERSON";
   18647           94 :     ort->UnitConv(56).siName = "PA";
   18648           94 :     ort->UnitConv(57).siName = "PA";
   18649           94 :     ort->UnitConv(58).siName = "PA";
   18650           94 :     ort->UnitConv(59).siName = "PA";
   18651           94 :     ort->UnitConv(60).siName = "PA";
   18652           94 :     ort->UnitConv(61).siName = "PA";
   18653           94 :     ort->UnitConv(62).siName = "PA";
   18654           94 :     ort->UnitConv(63).siName = "PA";
   18655           94 :     ort->UnitConv(64).siName = "S";
   18656           94 :     ort->UnitConv(65).siName = "V";
   18657           94 :     ort->UnitConv(66).siName = "W";
   18658           94 :     ort->UnitConv(67).siName = "W";
   18659           94 :     ort->UnitConv(68).siName = "W";
   18660           94 :     ort->UnitConv(69).siName = "W";
   18661           94 :     ort->UnitConv(70).siName = "W";
   18662           94 :     ort->UnitConv(71).siName = "W/KG";
   18663           94 :     ort->UnitConv(72).siName = "W/KG H2O"; // TODO: replace with W/kgWater? or rather just remove
   18664           94 :     ort->UnitConv(73).siName = "W/K";
   18665           94 :     ort->UnitConv(74).siName = "W/M2";
   18666           94 :     ort->UnitConv(75).siName = "W/M2";
   18667           94 :     ort->UnitConv(76).siName = "W/M2-C";
   18668           94 :     ort->UnitConv(77).siName = "W/M2-K";
   18669           94 :     ort->UnitConv(78).siName = "W/W";
   18670           94 :     ort->UnitConv(79).siName = "W/W";
   18671           94 :     ort->UnitConv(80).siName = "deltaC";
   18672           94 :     ort->UnitConv(81).siName = "KJ/KG";
   18673           94 :     ort->UnitConv(82).siName = "W-S/M3";
   18674           94 :     ort->UnitConv(83).siName = "W-S/M3";
   18675           94 :     ort->UnitConv(84).siName = "~~$~~/m2";
   18676           94 :     ort->UnitConv(85).siName = "GJ";
   18677           94 :     ort->UnitConv(86).siName = "GJ";
   18678           94 :     ort->UnitConv(87).siName = "GJ";
   18679           94 :     ort->UnitConv(88).siName = "GJ";
   18680           94 :     ort->UnitConv(89).siName = "GJ";
   18681           94 :     ort->UnitConv(90).siName = "GJ";
   18682           94 :     ort->UnitConv(91).siName = "GJ";
   18683           94 :     ort->UnitConv(92).siName = "MJ/m2";
   18684           94 :     ort->UnitConv(93).siName = "MJ/m2";
   18685           94 :     ort->UnitConv(94).siName = "MJ/m2";
   18686           94 :     ort->UnitConv(95).siName = "MJ/m2";
   18687           94 :     ort->UnitConv(96).siName = "Invalid/Undefined";
   18688           94 :     ort->UnitConv(97).siName = "";
   18689           94 :     ort->UnitConv(98).siName = "W/C";
   18690           94 :     ort->UnitConv(99).siName = "DAY";
   18691           94 :     ort->UnitConv(100).siName = "MIN";
   18692           94 :     ort->UnitConv(101).siName = "HR/WK";
   18693           94 :     ort->UnitConv(102).siName = "$";
   18694           94 :     ort->UnitConv(103).siName = "$/UNIT ENERGY";
   18695           94 :     ort->UnitConv(104).siName = "KW";
   18696           94 :     ort->UnitConv(105).siName = " ";
   18697           94 :     ort->UnitConv(106).siName = "AH";
   18698           94 :     ort->UnitConv(107).siName = "CLO";
   18699           94 :     ort->UnitConv(108).siName = "J/KG-K";
   18700           94 :     ort->UnitConv(109).siName = "KGWATER/S";
   18701           94 :     ort->UnitConv(110).siName = "PPM";
   18702           94 :     ort->UnitConv(111).siName = "RAD";
   18703           94 :     ort->UnitConv(112).siName = "REV/MIN";
   18704           94 :     ort->UnitConv(113).siName = "NM";
   18705           94 :     ort->UnitConv(114).siName = "BTU/W-H"; // Used for AHRI rating metrics (e.g. SEER)
   18706           94 :     ort->UnitConv(115).siName = "PERSON/M2";
   18707           94 :     ort->UnitConv(116).siName = "MM";
   18708           94 :     ort->UnitConv(117).siName = "MM";
   18709           94 :     ort->UnitConv(118).siName = "°C·hr";
   18710              : 
   18711           94 :     ort->UnitConv(1).ipName = "%";
   18712           94 :     ort->UnitConv(2).ipName = "F";
   18713           94 :     ort->UnitConv(3).ipName = "0=Off 1=On";
   18714           94 :     ort->UnitConv(4).ipName = "0-No  1-Yes";
   18715           94 :     ort->UnitConv(5).ipName = "1-Yes 0-No";
   18716           94 :     ort->UnitConv(6).ipName = "A";
   18717           94 :     ort->UnitConv(7).ipName = "ACH";
   18718           94 :     ort->UnitConv(8).ipName = "ach";
   18719           94 :     ort->UnitConv(9).ipName = "base 50F";
   18720           94 :     ort->UnitConv(10).ipName = "base 65F";
   18721           94 :     ort->UnitConv(11).ipName = "F";
   18722           94 :     ort->UnitConv(12).ipName = "cd/in2";
   18723           94 :     ort->UnitConv(13).ipName = "deg";
   18724           94 :     ort->UnitConv(14).ipName = "Frac";
   18725           94 :     ort->UnitConv(15).ipName = "Hour";
   18726           94 :     ort->UnitConv(16).ipName = "Hours";
   18727           94 :     ort->UnitConv(17).ipName = "hr";
   18728           94 :     ort->UnitConv(18).ipName = "hrs";
   18729           94 :     ort->UnitConv(19).ipName = "kBtu";
   18730           94 :     ort->UnitConv(20).ipName = "kWh";
   18731           94 :     ort->UnitConv(21).ipName = "therm";
   18732           94 :     ort->UnitConv(22).ipName = "MMBtu";
   18733           94 :     ort->UnitConv(23).ipName = "Wh";
   18734           94 :     ort->UnitConv(24).ipName = "ton-hrs";
   18735           94 :     ort->UnitConv(25).ipName = "Btu/lb";
   18736           94 :     ort->UnitConv(26).ipName = "Btu/lbWater";
   18737           94 :     ort->UnitConv(27).ipName = "kBtu/sqft";
   18738           94 :     ort->UnitConv(28).ipName = "F/ft";
   18739           94 :     ort->UnitConv(29).ipName = "lb";
   18740           94 :     ort->UnitConv(30).ipName = "lb/lb";
   18741           94 :     ort->UnitConv(31).ipName = "lb/ft3";
   18742           94 :     ort->UnitConv(32).ipName = "lb/s";
   18743           94 :     ort->UnitConv(33).ipName = "lbWater/lbDryAir";
   18744           94 :     ort->UnitConv(34).ipName = "lbWater/s";
   18745           94 :     ort->UnitConv(35).ipName = "kmol/s";
   18746           94 :     ort->UnitConv(36).ipName = "kmol/sec";
   18747           94 :     ort->UnitConv(37).ipName = "kWh";
   18748           94 :     ort->UnitConv(38).ipName = "gal";
   18749           94 :     ort->UnitConv(39).ipName = "ft3";
   18750           94 :     ort->UnitConv(40).ipName = "lum/W";
   18751           94 :     ort->UnitConv(41).ipName = "foot-candles";
   18752           94 :     ort->UnitConv(42).ipName = "ft";
   18753           94 :     ort->UnitConv(43).ipName = "in";
   18754           94 :     ort->UnitConv(44).ipName = "ft/min";
   18755           94 :     ort->UnitConv(45).ipName = "miles/hr";
   18756           94 :     ort->UnitConv(46).ipName = "ft2";
   18757           94 :     ort->UnitConv(47).ipName = "ft2/person";
   18758           94 :     ort->UnitConv(48).ipName = "ft3";
   18759           94 :     ort->UnitConv(49).ipName = "gal";
   18760           94 :     ort->UnitConv(50).ipName = "f3/f2";
   18761           94 :     ort->UnitConv(51).ipName = "ft3/min";
   18762           94 :     ort->UnitConv(52).ipName = "gal/min";
   18763           94 :     ort->UnitConv(53).ipName = "ft3/min-ft2";
   18764           94 :     ort->UnitConv(54).ipName = "ft3/min-person";
   18765           94 :     ort->UnitConv(55).ipName = "gal/min-person";
   18766           94 :     ort->UnitConv(56).ipName = "psi";
   18767           94 :     ort->UnitConv(57).ipName = "inHg";
   18768           94 :     ort->UnitConv(58).ipName = "inH2O";
   18769           94 :     ort->UnitConv(59).ipName = "ftH2O";
   18770           94 :     ort->UnitConv(60).ipName = "psi";
   18771           94 :     ort->UnitConv(61).ipName = "inHg";
   18772           94 :     ort->UnitConv(62).ipName = "inH2O";
   18773           94 :     ort->UnitConv(63).ipName = "ftH2O";
   18774           94 :     ort->UnitConv(64).ipName = "s";
   18775           94 :     ort->UnitConv(65).ipName = "V";
   18776           94 :     ort->UnitConv(66).ipName = "Btu/h";
   18777           94 :     ort->UnitConv(67).ipName = "W";
   18778           94 :     ort->UnitConv(68).ipName = "kW";
   18779           94 :     ort->UnitConv(69).ipName = "kBtuh";
   18780           94 :     ort->UnitConv(70).ipName = "ton";
   18781           94 :     ort->UnitConv(71).ipName = "kBtuh/lb";
   18782           94 :     ort->UnitConv(72).ipName = "kBtuh/lb";
   18783           94 :     ort->UnitConv(73).ipName = "Btu/h-F";
   18784           94 :     ort->UnitConv(74).ipName = "Btu/h-ft2";
   18785           94 :     ort->UnitConv(75).ipName = "kBtuh/ft2";
   18786           94 :     ort->UnitConv(76).ipName = "Btu/h-ft2-F";
   18787           94 :     ort->UnitConv(77).ipName = "Btu/h-ft2-F";
   18788           94 :     ort->UnitConv(78).ipName = "Btuh/Btuh";
   18789           94 :     ort->UnitConv(79).ipName = "W/W";
   18790           94 :     ort->UnitConv(80).ipName = "deltaF";
   18791           94 :     ort->UnitConv(81).ipName = "Btu/lb";
   18792           94 :     ort->UnitConv(82).ipName = "W-min/ft3";
   18793           94 :     ort->UnitConv(83).ipName = "W-min/gal";
   18794           94 :     ort->UnitConv(84).ipName = "~~$~~/ft2";
   18795           94 :     ort->UnitConv(85).ipName = "kBtu";
   18796           94 :     ort->UnitConv(86).ipName = "kWh";
   18797           94 :     ort->UnitConv(87).ipName = "kWh";
   18798           94 :     ort->UnitConv(88).ipName = "therm";
   18799           94 :     ort->UnitConv(89).ipName = "MMBtu";
   18800           94 :     ort->UnitConv(90).ipName = "Wh";
   18801           94 :     ort->UnitConv(91).ipName = "ton-hrs";
   18802           94 :     ort->UnitConv(92).ipName = "kWh/ft2";
   18803           94 :     ort->UnitConv(93).ipName = "kBtu/ft2";
   18804           94 :     ort->UnitConv(94).ipName = "kBtu/ft2";
   18805           94 :     ort->UnitConv(95).ipName = "kWh/m2";
   18806           94 :     ort->UnitConv(96).ipName = "Invalid/Undefined";
   18807           94 :     ort->UnitConv(97).ipName = "";
   18808           94 :     ort->UnitConv(98).ipName = "Btu/h-F";
   18809           94 :     ort->UnitConv(99).ipName = "day";
   18810           94 :     ort->UnitConv(100).ipName = "min";
   18811           94 :     ort->UnitConv(101).ipName = "hr/wk";
   18812           94 :     ort->UnitConv(102).ipName = "$";
   18813           94 :     ort->UnitConv(103).ipName = "$/unit energy";
   18814           94 :     ort->UnitConv(104).ipName = "kW";
   18815           94 :     ort->UnitConv(105).ipName = " ";
   18816           94 :     ort->UnitConv(106).ipName = "Ah";
   18817           94 :     ort->UnitConv(107).ipName = "clo";
   18818           94 :     ort->UnitConv(108).ipName = "Btu/lbm-R";
   18819           94 :     ort->UnitConv(109).ipName = "lbWater/s";
   18820           94 :     ort->UnitConv(110).ipName = "ppm";
   18821           94 :     ort->UnitConv(111).ipName = "rad";
   18822           94 :     ort->UnitConv(112).ipName = "rev/min";
   18823           94 :     ort->UnitConv(113).ipName = "lbf-ft";
   18824           94 :     ort->UnitConv(114).ipName = "Btu/W-h";
   18825           94 :     ort->UnitConv(115).ipName = "person/ft2";
   18826           94 :     ort->UnitConv(116).ipName = "in";
   18827           94 :     ort->UnitConv(117).ipName = "ft";
   18828           94 :     ort->UnitConv(118).ipName = "°F·hr";
   18829              : 
   18830           94 :     ort->UnitConv(1).mult = 1.0;
   18831           94 :     ort->UnitConv(2).mult = 1.8;
   18832           94 :     ort->UnitConv(3).mult = 1.0;
   18833           94 :     ort->UnitConv(4).mult = 1.0;
   18834           94 :     ort->UnitConv(5).mult = 1.0;
   18835           94 :     ort->UnitConv(6).mult = 1.0;
   18836           94 :     ort->UnitConv(7).mult = 1.0;
   18837           94 :     ort->UnitConv(8).mult = 1.0;
   18838           94 :     ort->UnitConv(9).mult = 1.8;
   18839           94 :     ort->UnitConv(10).mult = 1.8;
   18840           94 :     ort->UnitConv(11).mult = 1.8;
   18841           94 :     ort->UnitConv(12).mult = 0.000645160041625726;
   18842           94 :     ort->UnitConv(13).mult = 1.0;
   18843           94 :     ort->UnitConv(14).mult = 1.0;
   18844           94 :     ort->UnitConv(15).mult = 1.0;
   18845           94 :     ort->UnitConv(16).mult = 1.0;
   18846           94 :     ort->UnitConv(17).mult = 1.0;
   18847           94 :     ort->UnitConv(18).mult = 1.0;
   18848           94 :     ort->UnitConv(19).mult = 0.00000094845;
   18849           94 :     ort->UnitConv(20).mult = 0.000000277778;
   18850           94 :     ort->UnitConv(21).mult = 0.0000000094845;
   18851           94 :     ort->UnitConv(22).mult = 0.00000000094845;
   18852           94 :     ort->UnitConv(23).mult = 0.000277777777777778;
   18853           94 :     ort->UnitConv(24).mult = 0.0000000789847;
   18854           94 :     ort->UnitConv(25).mult = 0.00042956;
   18855           94 :     ort->UnitConv(26).mult = 0.0000004302105;
   18856           94 :     ort->UnitConv(27).mult = 0.00000008811404;
   18857           94 :     ort->UnitConv(28).mult = 0.54861322767449;
   18858           94 :     ort->UnitConv(29).mult = 2.2046;
   18859           94 :     ort->UnitConv(30).mult = 1.0;
   18860           94 :     ort->UnitConv(31).mult = 0.062428;
   18861           94 :     ort->UnitConv(32).mult = 2.2046;
   18862           94 :     ort->UnitConv(33).mult = 1.0;
   18863           94 :     ort->UnitConv(34).mult = 2.2046;
   18864           94 :     ort->UnitConv(35).mult = 1.0;
   18865           94 :     ort->UnitConv(36).mult = 1.0;
   18866           94 :     ort->UnitConv(37).mult = 1.0;
   18867           94 :     ort->UnitConv(38).mult = 0.264172037284185;
   18868           94 :     ort->UnitConv(39).mult = 0.0353146624712848;
   18869           94 :     ort->UnitConv(40).mult = 1.0;
   18870           94 :     ort->UnitConv(41).mult = 0.092902267;
   18871           94 :     ort->UnitConv(42).mult = 3.281;
   18872           94 :     ort->UnitConv(43).mult = 39.37;
   18873           94 :     ort->UnitConv(44).mult = 196.86;
   18874           94 :     ort->UnitConv(45).mult = 2.2369;
   18875           94 :     ort->UnitConv(46).mult = 10.764961;
   18876           94 :     ort->UnitConv(47).mult = 10.764961;
   18877           94 :     ort->UnitConv(48).mult = 35.319837041;
   18878           94 :     ort->UnitConv(49).mult = 264.172;
   18879           94 :     ort->UnitConv(50).mult = 3.281;
   18880           94 :     ort->UnitConv(51).mult = 2118.6438;
   18881           94 :     ort->UnitConv(52).mult = 15852.0;
   18882           94 :     ort->UnitConv(53).mult = 196.85;
   18883           94 :     ort->UnitConv(54).mult = 2118.6438;
   18884           94 :     ort->UnitConv(55).mult = 15852.0;
   18885           94 :     ort->UnitConv(56).mult = 0.0001450377;
   18886           94 :     ort->UnitConv(57).mult = 0.00029613;
   18887           94 :     ort->UnitConv(58).mult = 0.00401463;
   18888           94 :     ort->UnitConv(59).mult = 0.00033455;
   18889           94 :     ort->UnitConv(60).mult = 0.0001450377;
   18890           94 :     ort->UnitConv(61).mult = 0.00029613;
   18891           94 :     ort->UnitConv(62).mult = 0.00401463;
   18892           94 :     ort->UnitConv(63).mult = 0.00033455;
   18893           94 :     ort->UnitConv(64).mult = 1.0;
   18894           94 :     ort->UnitConv(65).mult = 1.0;
   18895           94 :     ort->UnitConv(66).mult = 3.412;
   18896           94 :     ort->UnitConv(67).mult = 1.0;
   18897           94 :     ort->UnitConv(68).mult = 0.001;
   18898           94 :     ort->UnitConv(69).mult = 0.00341442;
   18899           94 :     ort->UnitConv(70).mult = 0.0002843333;
   18900           94 :     ort->UnitConv(71).mult = 0.001547673;
   18901           94 :     ort->UnitConv(72).mult = 0.001547673;
   18902           94 :     ort->UnitConv(73).mult = 1.8987;
   18903           94 :     ort->UnitConv(74).mult = 0.316954237;
   18904           94 :     ort->UnitConv(75).mult = 0.000316954237;
   18905           94 :     ort->UnitConv(76).mult = 0.176085687;
   18906           94 :     ort->UnitConv(77).mult = 0.176085687;
   18907           94 :     ort->UnitConv(78).mult = 1.0;
   18908           94 :     ort->UnitConv(79).mult = 1.0;
   18909           94 :     ort->UnitConv(80).mult = 1.8;
   18910           94 :     ort->UnitConv(81).mult = 0.42956;
   18911           94 :     ort->UnitConv(82).mult = 1.0 / 2118.6438;
   18912           94 :     ort->UnitConv(83).mult = 1.0 / 15852;
   18913           94 :     ort->UnitConv(84).mult = 1.0 / 10.764961;
   18914           94 :     ort->UnitConv(85).mult = 0.00000094845 * 1000000000;
   18915           94 :     ort->UnitConv(86).mult = 0.000000277778 * 1000000000;
   18916           94 :     ort->UnitConv(87).mult = 0.000000277778 * 1000000000;
   18917           94 :     ort->UnitConv(88).mult = 0.0000000094845 * 1000000000;
   18918           94 :     ort->UnitConv(89).mult = 0.00000000094845 * 1000000000;
   18919           94 :     ort->UnitConv(90).mult = 0.000277777777777778 * 1000000000;
   18920           94 :     ort->UnitConv(91).mult = 0.0000000789847 * 1000000000;
   18921           94 :     ort->UnitConv(92).mult = 0.277777777777778 / 10.764961;
   18922           94 :     ort->UnitConv(93).mult = 0.94708628903179 / 10.764961;
   18923           94 :     ort->UnitConv(94).mult = 0.94708628903179 / 10.764961;
   18924           94 :     ort->UnitConv(95).mult = 0.27777777777778;
   18925           94 :     ort->UnitConv(96).mult = 1.0;
   18926           94 :     ort->UnitConv(97).mult = 1.0;
   18927           94 :     ort->UnitConv(98).mult = 1.8987;
   18928           94 :     ort->UnitConv(99).mult = 1.0;
   18929           94 :     ort->UnitConv(100).mult = 1.0;
   18930           94 :     ort->UnitConv(101).mult = 1.0;
   18931           94 :     ort->UnitConv(102).mult = 1.0;
   18932           94 :     ort->UnitConv(103).mult = 1.0;
   18933           94 :     ort->UnitConv(104).mult = 1.0;
   18934           94 :     ort->UnitConv(105).mult = 1.0;
   18935           94 :     ort->UnitConv(106).mult = 1.0;
   18936           94 :     ort->UnitConv(107).mult = 1.0;
   18937           94 :     ort->UnitConv(108).mult = 0.000238845896627;
   18938           94 :     ort->UnitConv(109).mult = 2.2046;
   18939           94 :     ort->UnitConv(110).mult = 1.0;
   18940           94 :     ort->UnitConv(111).mult = 1.0;
   18941           94 :     ort->UnitConv(112).mult = 1.0;
   18942           94 :     ort->UnitConv(113).mult = 0.737562149277;
   18943           94 :     ort->UnitConv(114).mult = 1.0;
   18944           94 :     ort->UnitConv(115).mult = 0.09290304;
   18945           94 :     ort->UnitConv(116).mult = 0.03937;
   18946           94 :     ort->UnitConv(117).mult = 0.003281;
   18947           94 :     ort->UnitConv(118).mult = 1.8;
   18948              : 
   18949           94 :     ort->UnitConv(2).offset = 32.0;
   18950           94 :     ort->UnitConv(11).offset = 32.0;
   18951           94 :     ort->UnitConv(25).offset = 7.6736;
   18952           94 :     ort->UnitConv(81).offset = 7.6736; // 80 is KJ/KG -- should this be multiplied by 1000?
   18953              : 
   18954           94 :     ort->UnitConv(20).hint = "ELEC";
   18955           94 :     ort->UnitConv(21).hint = "GAS";
   18956           94 :     ort->UnitConv(24).hint = "COOL";
   18957           94 :     ort->UnitConv(38).hint = "WATER";
   18958           94 :     ort->UnitConv(49).hint = "WATER";
   18959           94 :     ort->UnitConv(52).hint = "WATER";
   18960           94 :     ort->UnitConv(67).hint = "ELEC";
   18961           94 :     ort->UnitConv(70).hint = "COOL";
   18962           94 :     ort->UnitConv(79).hint = "SI";
   18963           94 :     ort->UnitConv(83).hint = "WATER";
   18964           94 :     ort->UnitConv(86).hint = "CONSUMP";
   18965           94 :     ort->UnitConv(87).hint = "ELEC";
   18966           94 :     ort->UnitConv(88).hint = "GAS";
   18967           94 :     ort->UnitConv(91).hint = "COOL";
   18968           94 :     ort->UnitConv(92).hint = "ELEC";
   18969           94 :     ort->UnitConv(93).hint = "GAS";
   18970           94 :     ort->UnitConv(94).hint = "ADDITIONAL";
   18971              : 
   18972           94 :     ort->UnitConv(19).several = true;
   18973           94 :     ort->UnitConv(20).several = true;
   18974           94 :     ort->UnitConv(21).several = true;
   18975           94 :     ort->UnitConv(22).several = true;
   18976           94 :     ort->UnitConv(23).several = true;
   18977           94 :     ort->UnitConv(24).several = true;
   18978           94 :     ort->UnitConv(38).several = true;
   18979           94 :     ort->UnitConv(39).several = true;
   18980           94 :     ort->UnitConv(42).several = true;
   18981           94 :     ort->UnitConv(43).several = true;
   18982           94 :     ort->UnitConv(44).several = true;
   18983           94 :     ort->UnitConv(45).several = true;
   18984           94 :     ort->UnitConv(48).several = true;
   18985           94 :     ort->UnitConv(49).several = true;
   18986           94 :     ort->UnitConv(51).several = true;
   18987           94 :     ort->UnitConv(52).several = true;
   18988           94 :     ort->UnitConv(54).several = true;
   18989           94 :     ort->UnitConv(55).several = true;
   18990           94 :     ort->UnitConv(56).several = true;
   18991           94 :     ort->UnitConv(57).several = true;
   18992           94 :     ort->UnitConv(58).several = true;
   18993           94 :     ort->UnitConv(59).several = true;
   18994           94 :     ort->UnitConv(60).several = true;
   18995           94 :     ort->UnitConv(61).several = true;
   18996           94 :     ort->UnitConv(62).several = true;
   18997           94 :     ort->UnitConv(63).several = true;
   18998           94 :     ort->UnitConv(66).several = true;
   18999           94 :     ort->UnitConv(67).several = true;
   19000           94 :     ort->UnitConv(68).several = true;
   19001           94 :     ort->UnitConv(69).several = true;
   19002           94 :     ort->UnitConv(70).several = true;
   19003           94 :     ort->UnitConv(74).several = true;
   19004           94 :     ort->UnitConv(75).several = true;
   19005           94 :     ort->UnitConv(78).several = true;
   19006           94 :     ort->UnitConv(79).several = true;
   19007           94 :     ort->UnitConv(82).several = true;
   19008           94 :     ort->UnitConv(83).several = true;
   19009           94 :     ort->UnitConv(85).several = true;
   19010           94 :     ort->UnitConv(86).several = true;
   19011           94 :     ort->UnitConv(87).several = true;
   19012           94 :     ort->UnitConv(88).several = true;
   19013           94 :     ort->UnitConv(89).several = true;
   19014           94 :     ort->UnitConv(90).several = true;
   19015           94 :     ort->UnitConv(91).several = true;
   19016           94 :     ort->UnitConv(92).several = true;
   19017           94 :     ort->UnitConv(93).several = true;
   19018           94 :     ort->UnitConv(94).several = true;
   19019           94 :     ort->UnitConv(95).several = true;
   19020           94 :     ort->UnitConv(116).several = true;
   19021           94 :     ort->UnitConv(117).several = true;
   19022           94 : }
   19023              : 
   19024        28596 : std::string GetUnitSubString(std::string const &inString) // Input String
   19025              : {
   19026              :     // SUBROUTINE INFORMATION:
   19027              :     //       AUTHOR         Jason Glazer
   19028              :     //       DATE WRITTEN   February 2013
   19029              :     //       MODIFIED       na
   19030              :     //       RE-ENGINEERED  na
   19031              : 
   19032              :     // PURPOSE OF THIS SUBROUTINE:
   19033              :     //   return the substring contained in brackets []
   19034              :     //   that contains the units.
   19035              : 
   19036              :     // METHODOLOGY EMPLOYED:
   19037              :     //   na
   19038              : 
   19039              :     // Return value
   19040        28596 :     std::string outUnit; // Result String
   19041              : 
   19042              :     // Locals
   19043              :     // SUBROUTINE ARGUMENT DEFINITIONS:
   19044              : 
   19045              :     // SUBROUTINE PARAMETER DEFINITIONS:
   19046              :     // na
   19047              : 
   19048              :     // INTERFACE BLOCK SPECIFICATIONS:
   19049              :     // na
   19050              : 
   19051              :     // DERIVED TYPE DEFINITIONS:
   19052              :     // na
   19053              : 
   19054              :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
   19055              : 
   19056              :     // check if string has brackets or parentheses
   19057        28596 :     std::string::size_type const posLBrac = index(inString, '['); // left bracket
   19058        28596 :     std::string::size_type const posRBrac = index(inString, ']'); // right bracket
   19059              :     // extract the substring with the units
   19060        28596 :     if ((posLBrac != std::string::npos) && (posRBrac != std::string::npos) && (posRBrac - posLBrac >= 1)) {
   19061         8649 :         outUnit = inString.substr(posLBrac + 1, posRBrac - posLBrac - 1);
   19062              :     }
   19063        28596 :     return outUnit;
   19064            0 : }
   19065              : 
   19066         1832 : void LookupSItoIP(EnergyPlusData &state, std::string const &stringInWithSI, int &unitConvIndex, std::string &stringOutWithIP)
   19067              : {
   19068              :     // SUBROUTINE INFORMATION:
   19069              :     //    AUTHOR         Jason Glazer of GARD Analytics, Inc.
   19070              :     //    DATE WRITTEN   February 12, 2009
   19071              : 
   19072              :     // PURPOSE OF THIS SUBROUTINE:
   19073              :     //   The input string to this subroutine can either contain
   19074              :     //   a unit that should be looked up or it can contain
   19075              :     //   but the unit and other text (such as the column heading)
   19076              :     //   that includes a hint for when the unit may have multiple
   19077              :     //   possible conversions. If the input string includes
   19078              :     //   just the unit it does not have either brackets or
   19079              :     //   parenthesis. If the string includes text with a possible
   19080              :     //   hint the units themselves will be in either brackets
   19081              :     //   or parentheses. The index to the unitConv array is returned
   19082              :     //   which can be used with the convertIP function. Also the
   19083              :     //   string with the IP units substituted is returned.
   19084              : 
   19085         1832 :     std::string unitSIOnly;
   19086              :     int modeInString;
   19087         1832 :     int constexpr misBrac(1);
   19088         1832 :     int constexpr misParen(2);
   19089         1832 :     int constexpr misBrce(3);
   19090         1832 :     int constexpr misNoHint(4);
   19091         1832 :     std::string const stringInUpper(Util::makeUPPER(stringInWithSI));
   19092         1832 :     auto &ort = state.dataOutRptTab;
   19093              : 
   19094         1832 :     stringOutWithIP = "";
   19095              :     // check if string has brackets or parentheses
   19096         1832 :     std::string::size_type posLBrac = index(stringInUpper, '[');  // left bracket
   19097         1832 :     std::string::size_type posRBrac = index(stringInUpper, ']');  // right bracket
   19098         1832 :     std::string::size_type posLParen = index(stringInUpper, '('); // left parenthesis
   19099         1832 :     std::string::size_type posRParen = index(stringInUpper, ')'); // right parenthesis
   19100         1832 :     std::string::size_type posLBrce = index(stringInUpper, '{');  // left brace
   19101         1832 :     std::string::size_type posRBrce = index(stringInUpper, '}');  // right brace
   19102         1832 :     bool noBrackets = true;
   19103              :     // extract the substring with the units
   19104         1832 :     if ((posLBrac != std::string::npos) && (posRBrac != std::string::npos) && (posRBrac - posLBrac >= 1)) {
   19105          951 :         unitSIOnly = stringInUpper.substr(posLBrac + 1, posRBrac - posLBrac - 1);
   19106          951 :         modeInString = misBrac;
   19107          951 :         noBrackets = false;
   19108          881 :     } else if ((posLBrce != std::string::npos) && (posRBrce != std::string::npos) && (posRBrce - posLBrce >= 1)) {
   19109          240 :         unitSIOnly = stringInUpper.substr(posLBrce + 1, posRBrce - posLBrce - 1);
   19110          240 :         modeInString = misBrce;
   19111          641 :     } else if ((posLParen != std::string::npos) && (posRParen != std::string::npos) && (posRParen - posLParen >= 1)) {
   19112           21 :         unitSIOnly = stringInUpper.substr(posLParen + 1, posRParen - posLParen - 1);
   19113           21 :         modeInString = misParen;
   19114              :     } else {
   19115          620 :         unitSIOnly = stringInUpper;
   19116          620 :         modeInString = misNoHint;
   19117              :     }
   19118         1832 :     unitSIOnly = stripped(unitSIOnly);
   19119         1832 :     int defaultConv = 0;
   19120         1832 :     int foundConv = 0;
   19121         1832 :     int firstOfSeveral = 0;
   19122       172887 :     for (int iUnit = 1; iUnit <= ort->UnitConvSize; ++iUnit) {
   19123       171655 :         if (Util::SameString(ort->UnitConv(iUnit).siName, unitSIOnly)) {
   19124         2573 :             if (ort->UnitConv(iUnit).several) {
   19125         2051 :                 if (firstOfSeveral == 0) {
   19126          593 :                     firstOfSeveral = iUnit;
   19127              :                 }
   19128         2051 :                 if (ort->UnitConv(iUnit).is_default) {
   19129            0 :                     defaultConv = iUnit;
   19130              :                 }
   19131              :                 // look for the hint string
   19132         2051 :                 if (len(ort->UnitConv(iUnit).hint) > 0) {
   19133          858 :                     if (has(stringInUpper, ort->UnitConv(iUnit).hint)) {
   19134           78 :                         foundConv = iUnit;
   19135           78 :                         break;
   19136              :                     }
   19137              :                 }
   19138              :             } else { // not several possibilities so don't bother with rest of array
   19139          522 :                 foundConv = iUnit;
   19140          522 :                 break;
   19141              :             }
   19142              :         }
   19143              :     }
   19144              :     // if it is found set the selected value to what was found. if not found,
   19145              :     // directly set it to the default and if no default set it to the first item
   19146              :     // in group.  Return zero if not found.
   19147         1832 :     int selectedConv(0);
   19148         1832 :     if (foundConv > 0) {
   19149          600 :         selectedConv = foundConv;
   19150              :     } else {
   19151              :         // not found - see if in a group it should be default or first.
   19152         1232 :         if (firstOfSeveral == 0) {
   19153          717 :             selectedConv = 0;
   19154              :         } else {
   19155          515 :             if (defaultConv != 0) {
   19156            0 :                 selectedConv = defaultConv;
   19157              :             } else {
   19158          515 :                 selectedConv = firstOfSeveral;
   19159              :             }
   19160              :         }
   19161              :     }
   19162              :     // if one was selected substitute the units into the output string
   19163         1832 :     if (selectedConv > 0) {
   19164         1115 :         if (modeInString == misBrac) {
   19165          950 :             stringOutWithIP = stringInWithSI.substr(0, posLBrac + 1) + ort->UnitConv(selectedConv).ipName + stringInWithSI.substr(posRBrac);
   19166          165 :         } else if (modeInString == misParen) {
   19167           15 :             stringOutWithIP = stringInWithSI.substr(0, posLParen + 1) + ort->UnitConv(selectedConv).ipName + stringInWithSI.substr(posRParen);
   19168          150 :         } else if (modeInString == misBrce) {
   19169          148 :             stringOutWithIP = stringInWithSI.substr(0, posLBrce + 1) + ort->UnitConv(selectedConv).ipName + stringInWithSI.substr(posRBrce);
   19170            2 :         } else if (modeInString == misNoHint) {
   19171            2 :             stringOutWithIP = ort->UnitConv(selectedConv).ipName;
   19172              :         }
   19173              :     } else {
   19174              :         // if no conversion just output the input string
   19175          717 :         stringOutWithIP = stringInWithSI;
   19176              :     }
   19177              : 
   19178         1832 :     unitConvIndex = selectedConv;
   19179              : 
   19180              :     // Add warning if units not found.
   19181         1832 :     if (unitConvIndex == 0 && !noBrackets) {
   19182            1 :         ShowWarningError(state, format("Unable to find a unit conversion from {} into IP units", stringInWithSI));
   19183            3 :         ShowContinueError(state, "Applying default conversion factor of 1.0");
   19184              :     }
   19185         1832 : }
   19186              : 
   19187          108 : void LookupJtokWH(EnergyPlusData &state, std::string const &stringInWithJ, int &unitConvIndex, std::string &stringOutWithKWH)
   19188              : {
   19189              :     //    AUTHOR         Jason Glazer of GARD Analytics, Inc.
   19190              :     //    DATE WRITTEN   April 15, 2016
   19191              : 
   19192              :     // For the given unit expressed in J find the unit conversion
   19193              :     // using kWh instead. This is used when unitsStyle == unitsStyleJtoKWH
   19194              :     // return zero if no unit conversion should be done
   19195              : 
   19196          108 :     stringOutWithKWH = stringInWithJ;
   19197          108 :     std::string::size_type gjPos = stringOutWithKWH.find("[GJ]");
   19198          108 :     std::string::size_type mjm2Pos = stringOutWithKWH.find("[MJ/m2]");
   19199          108 :     if (gjPos != std::string::npos) {
   19200            1 :         stringOutWithKWH.replace(gjPos, 4, "[kWh]");
   19201            4 :         unitConvIndex = getSpecificUnitIndex(state, "GJ", "kWh");
   19202          107 :     } else if (mjm2Pos != std::string::npos) {
   19203            1 :         stringOutWithKWH.replace(mjm2Pos, 7, "[kWh/m2]");
   19204            4 :         unitConvIndex = getSpecificUnitIndex(state, "MJ/m2", "kWh/m2");
   19205              :     } else {
   19206          106 :         unitConvIndex = 0;
   19207              :     }
   19208          108 : }
   19209              : 
   19210         1398 : Real64 ConvertIP(EnergyPlusData &state, int const unitConvIndex, Real64 const SIvalue)
   19211              : {
   19212              :     // SUBROUTINE INFORMATION:
   19213              :     //    AUTHOR         Jason Glazer of GARD Analytics, Inc.
   19214              :     //    DATE WRITTEN   February 13, 2009
   19215              :     //    MODIFIED       September 2012
   19216              :     //    RE-ENGINEERED  na
   19217              : 
   19218              :     // PURPOSE OF THIS SUBROUTINE:
   19219              :     //   Apply the selected unit conversion to the input value
   19220              :     //   expressed in SI units to result in IP units.
   19221              :     //   If zero is provided as unit index, return the original
   19222              :     //   value (no conversion)
   19223              : 
   19224              :     // METHODOLOGY EMPLOYED:
   19225              : 
   19226              :     // REFERENCES:
   19227              :     //    na
   19228              : 
   19229              :     // USE STATEMENTS:
   19230              : 
   19231              :     // Return value
   19232              :     Real64 ConvertIP;
   19233              : 
   19234              :     // Locals
   19235              :     // SUBROUTINE ARGUMENT DEFINITIONS:
   19236              : 
   19237              :     // SUBROUTINE PARAMETER DEFINITIONS:
   19238              :     //    na
   19239              : 
   19240              :     // INTERFACE BLOCK SPECIFICATIONS:
   19241              :     //    na
   19242              : 
   19243              :     // DERIVED TYPE DEFINITIONS:
   19244              :     //    na
   19245              : 
   19246              :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
   19247              :     //    na
   19248              : 
   19249         1398 :     auto &ort = state.dataOutRptTab;
   19250              : 
   19251         1398 :     if (unitConvIndex == 0 || SIvalue == -999.0 || SIvalue == -99999.0) { // don't convert unknown data to IP
   19252           66 :         ConvertIP = SIvalue;
   19253         1332 :     } else if ((unitConvIndex > 0) && (unitConvIndex <= ort->UnitConvSize)) {
   19254         1332 :         ConvertIP = (SIvalue * ort->UnitConv(unitConvIndex).mult) + ort->UnitConv(unitConvIndex).offset;
   19255              :     } else {
   19256            0 :         ConvertIP = SIvalue;
   19257              :     }
   19258         1398 :     return ConvertIP;
   19259              : }
   19260              : 
   19261           12 : Real64 ConvertIPdelta(EnergyPlusData &state, int const unitConvIndex, Real64 const SIvalue)
   19262              : {
   19263              :     // SUBROUTINE INFORMATION:
   19264              :     //    AUTHOR         Jason Glazer of GARD Analytics, Inc.
   19265              :     //    DATE WRITTEN   February 18, 2009
   19266              :     //    MODIFIED       na
   19267              :     //    RE-ENGINEERED  na
   19268              : 
   19269              :     // PURPOSE OF THIS SUBROUTINE:
   19270              :     //   Apply the selected unit conversion to the input value
   19271              :     //   expressed in SI units to result in IP units. This routine
   19272              :     //   only uses the multiplier and NOT the offset and is appropriate
   19273              :     //   when the number being converted is a difference or delta
   19274              :     //   between values (such as a temperature difference).
   19275              : 
   19276              :     // METHODOLOGY EMPLOYED:
   19277              : 
   19278              :     // REFERENCES:
   19279              :     //    na
   19280              : 
   19281              :     // USE STATEMENTS:
   19282              : 
   19283              :     // Return value
   19284              :     Real64 ConvertIPdelta;
   19285              : 
   19286              :     // Locals
   19287              :     // SUBROUTINE ARGUMENT DEFINITIONS:
   19288              : 
   19289              :     // SUBROUTINE PARAMETER DEFINITIONS:
   19290              :     //    na
   19291              : 
   19292              :     // INTERFACE BLOCK SPECIFICATIONS:
   19293              :     //    na
   19294              : 
   19295              :     // DERIVED TYPE DEFINITIONS:
   19296              :     //    na
   19297              : 
   19298              :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
   19299              :     //    na
   19300              : 
   19301           12 :     auto &ort = state.dataOutRptTab;
   19302              : 
   19303           12 :     if (unitConvIndex == 0) {
   19304            0 :         ConvertIPdelta = SIvalue;
   19305           12 :     } else if ((unitConvIndex > 0) && (unitConvIndex <= ort->UnitConvSize)) {
   19306           12 :         ConvertIPdelta = SIvalue * ort->UnitConv(unitConvIndex).mult;
   19307              :     } else {
   19308            0 :         ConvertIPdelta = SIvalue;
   19309              :     }
   19310           12 :     return ConvertIPdelta;
   19311              : }
   19312              : 
   19313           10 : void GetUnitConversion(EnergyPlusData &state, int const unitConvIndex, Real64 &multiplier, Real64 &offset, std::string &IPunit)
   19314              : {
   19315              :     // SUBROUTINE INFORMATION:
   19316              :     //    AUTHOR         Jason Glazer of GARD Analytics, Inc.
   19317              :     //    DATE WRITTEN   February 13, 2009
   19318              :     //    MODIFIED       na
   19319              :     //    RE-ENGINEERED  na
   19320              : 
   19321              :     // PURPOSE OF THIS SUBROUTINE:
   19322              :     //   Return of the multiplier and adder for the given
   19323              :     //   SI to IP unit conversion.
   19324              :     //     SI = (IP * multiplier) + offset
   19325              :     //  This function could be replaced by referencing the
   19326              :     //  array directly but does include some checking of the
   19327              :     //  bounds of the array.
   19328              : 
   19329              :     // METHODOLOGY EMPLOYED:
   19330              : 
   19331              :     // REFERENCES:
   19332              :     //    na
   19333              : 
   19334              :     // USE STATEMENTS:
   19335              : 
   19336              :     // Locals
   19337              :     // SUBROUTINE ARGUMENT DEFINITIONS:
   19338              : 
   19339              :     // SUBROUTINE PARAMETER DEFINITIONS:
   19340              :     //    na
   19341              : 
   19342              :     // INTERFACE BLOCK SPECIFICATIONS:
   19343              :     //    na
   19344              : 
   19345              :     // DERIVED TYPE DEFINITIONS:
   19346              :     //    na
   19347              : 
   19348              :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
   19349              :     //    na
   19350              : 
   19351           10 :     auto &ort = state.dataOutRptTab;
   19352              : 
   19353           10 :     if ((unitConvIndex > 0) && (unitConvIndex <= ort->UnitConvSize)) {
   19354            9 :         multiplier = ort->UnitConv(unitConvIndex).mult;
   19355            9 :         offset = ort->UnitConv(unitConvIndex).offset;
   19356            9 :         IPunit = ort->UnitConv(unitConvIndex).ipName;
   19357              :     } else {
   19358            1 :         multiplier = 1.0;
   19359            1 :         offset = 0.0;
   19360            1 :         IPunit = "";
   19361              :     }
   19362           10 : }
   19363              : 
   19364          126 : Real64 getSpecificUnitMultiplier(EnergyPlusData &state, std::string const &SIunit, std::string const &IPunit)
   19365              : {
   19366              :     // SUBROUTINE INFORMATION:
   19367              :     //    AUTHOR         Jason Glazer of GARD Analytics, Inc.
   19368              :     //    DATE WRITTEN   February 13, 2009
   19369              :     //    MODIFIED       na
   19370              :     //    RE-ENGINEERED  na
   19371              : 
   19372              :     // PURPOSE OF THIS SUBROUTINE:
   19373              :     //   Return of the multiplier for a specific
   19374              :     //   SI to IP unit conversion. No offset is provided so
   19375              :     //   it cannot be used to convert units such as temperatures
   19376              :     //   that include an offset.
   19377              :     //     SI = (IP * multiplier) + offset
   19378              :     //   Unlike LookupSItoIP, this function does not expect more
   19379              :     //   the units in the two input parameters. No hints or
   19380              :     //   defaults are used since both the SI and IP units are
   19381              :     //   input by the user.
   19382              : 
   19383              :     // METHODOLOGY EMPLOYED:
   19384              : 
   19385              :     // REFERENCES:
   19386              :     //    na
   19387              : 
   19388              :     // USE STATEMENTS:
   19389              : 
   19390              :     // Return value
   19391              :     Real64 getSpecificUnitMultiplier;
   19392              : 
   19393              :     // Locals
   19394              :     // SUBROUTINE ARGUMENT DEFINITIONS:
   19395              : 
   19396              :     // SUBROUTINE PARAMETER DEFINITIONS:
   19397              :     //    na
   19398              : 
   19399              :     // INTERFACE BLOCK SPECIFICATIONS:
   19400              :     //    na
   19401              : 
   19402              :     // DERIVED TYPE DEFINITIONS:
   19403              :     //    na
   19404              : 
   19405              :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
   19406          126 :     auto &ort = state.dataOutRptTab;
   19407              : 
   19408         6238 :     for (state.dataOutRptTab->iUnitGsum = 1; state.dataOutRptTab->iUnitGsum <= ort->UnitConvSize; ++state.dataOutRptTab->iUnitGsum) {
   19409         6218 :         if (Util::SameString(ort->UnitConv(state.dataOutRptTab->iUnitGsum).siName, SIunit)) {
   19410          133 :             if (Util::SameString(ort->UnitConv(state.dataOutRptTab->iUnitGsum).ipName, IPunit)) {
   19411          106 :                 state.dataOutRptTab->foundGsum = state.dataOutRptTab->iUnitGsum;
   19412          106 :                 break;
   19413              :             }
   19414              :         }
   19415              :     }
   19416          126 :     if (state.dataOutRptTab->foundGsum != 0) {
   19417          106 :         getSpecificUnitMultiplier = ort->UnitConv(state.dataOutRptTab->foundGsum).mult;
   19418              :     } else {
   19419           20 :         ShowWarningError(state, format("Unable to find a unit conversion from {} to {}", SIunit, IPunit));
   19420           40 :         ShowContinueError(state, "Applying default conversion factor of 1.0");
   19421           20 :         getSpecificUnitMultiplier = 1.0;
   19422              :     }
   19423          126 :     return getSpecificUnitMultiplier;
   19424              : }
   19425              : 
   19426           27 : Real64 getSpecificUnitDivider(EnergyPlusData &state, std::string const &SIunit, std::string const &IPunit)
   19427              : {
   19428              :     // SUBROUTINE INFORMATION:
   19429              :     //    AUTHOR         Jason Glazer of GARD Analytics, Inc.
   19430              :     //    DATE WRITTEN   February 13, 2009
   19431              :     //    MODIFIED       na
   19432              :     //    RE-ENGINEERED  na
   19433              : 
   19434              :     // PURPOSE OF THIS SUBROUTINE:
   19435              :     //   Returns the divider (1/multiplier) for a specific
   19436              :     //   SI to IP unit conversion. No offset is provided so
   19437              :     //   it cannot be used to convert units such as temperatures
   19438              :     //   that include an offset.
   19439              :     //     SI = (IP * multiplier) + offset
   19440              :     //   Unlike LookupSItoIP, this function does not expect more
   19441              :     //   the units in the two input parameters. No hints or
   19442              :     //   defaults are used since both the SI and IP units are
   19443              :     //   input by the user.
   19444              : 
   19445              :     // METHODOLOGY EMPLOYED:
   19446              : 
   19447              :     // REFERENCES:
   19448              :     //    na
   19449              : 
   19450              :     // USE STATEMENTS:
   19451              : 
   19452              :     // Return value
   19453              :     Real64 getSpecificUnitDivider;
   19454              : 
   19455              :     // Locals
   19456              :     // SUBROUTINE ARGUMENT DEFINITIONS:
   19457              : 
   19458              :     // SUBROUTINE PARAMETER DEFINITIONS:
   19459              :     //    na
   19460              : 
   19461              :     // INTERFACE BLOCK SPECIFICATIONS:
   19462              :     //    na
   19463              : 
   19464              :     // DERIVED TYPE DEFINITIONS:
   19465              :     //    na
   19466              : 
   19467              :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
   19468              :     Real64 mult;
   19469              : 
   19470           27 :     mult = getSpecificUnitMultiplier(state, SIunit, IPunit);
   19471           27 :     if (mult != 0) {
   19472           27 :         getSpecificUnitDivider = 1 / mult;
   19473              :     } else {
   19474            0 :         ShowWarningError(state, format("Unable to find a unit conversion from {} to {}", SIunit, IPunit));
   19475            0 :         ShowContinueError(state, "Applying default conversion factor of 1.0");
   19476            0 :         getSpecificUnitDivider = 1.0;
   19477              :     }
   19478           27 :     return getSpecificUnitDivider;
   19479              : }
   19480              : 
   19481           18 : Real64 getSpecificUnitIndex(EnergyPlusData &state, std::string const &SIunit, std::string const &IPunit)
   19482              : {
   19483              :     // SUBROUTINE INFORMATION:
   19484              :     //    AUTHOR         Jason Glazer of GARD Analytics, Inc.
   19485              :     //    DATE WRITTEN   September 21, 2012
   19486              :     //    MODIFIED       na
   19487              :     //    RE-ENGINEERED  na
   19488              : 
   19489              :     // PURPOSE OF THIS SUBROUTINE:
   19490              :     //   Return of the unit conversion index for a specific
   19491              :     //   SI to IP unit conversion.
   19492              :     //   Unlike LookupSItoIP, this function does not expect more
   19493              :     //   the units in the two input parameters. No hints or
   19494              :     //   defaults are used since both the SI and IP units are
   19495              :     //   input by the user.
   19496              : 
   19497              :     // METHODOLOGY EMPLOYED:
   19498              : 
   19499              :     // REFERENCES:
   19500              :     //    na
   19501              : 
   19502              :     // USE STATEMENTS:
   19503              : 
   19504              :     // Return value
   19505              :     Real64 getSpecificUnitIndex;
   19506              : 
   19507              :     // Locals
   19508              :     // SUBROUTINE ARGUMENT DEFINITIONS:
   19509              : 
   19510              :     // SUBROUTINE PARAMETER DEFINITIONS:
   19511              :     //    na
   19512              : 
   19513              :     // INTERFACE BLOCK SPECIFICATIONS:
   19514              :     //    na
   19515              : 
   19516              :     // DERIVED TYPE DEFINITIONS:
   19517              :     //    na
   19518              : 
   19519              :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
   19520           18 :     auto &ort = state.dataOutRptTab;
   19521              : 
   19522          317 :     for (state.dataOutRptTab->iUnitGsui = 1; state.dataOutRptTab->iUnitGsui <= ort->UnitConvSize; ++state.dataOutRptTab->iUnitGsui) {
   19523          313 :         if (Util::SameString(ort->UnitConv(state.dataOutRptTab->iUnitGsui).siName, SIunit)) {
   19524           18 :             if (Util::SameString(ort->UnitConv(state.dataOutRptTab->iUnitGsui).ipName, IPunit)) {
   19525           14 :                 state.dataOutRptTab->foundGsui = state.dataOutRptTab->iUnitGsui;
   19526           14 :                 break;
   19527              :             }
   19528              :         }
   19529              :     }
   19530           18 :     if (state.dataOutRptTab->foundGsui != 0) {
   19531           14 :         getSpecificUnitIndex = state.dataOutRptTab->foundGsui;
   19532              :     } else {
   19533            4 :         getSpecificUnitIndex = 0.0;
   19534              :     }
   19535           18 :     return getSpecificUnitIndex;
   19536              : }
   19537              : 
   19538              : } // namespace EnergyPlus::OutputReportTabular
        

Generated by: LCOV version 2.0-1