LCOV - code coverage report
Current view: top level - EnergyPlus - OutputReportTabular.cc (source / functions) Coverage Total Hit
Test: lcov.output.filtered Lines: 82.8 % 11862 9826
Test Date: 2025-06-02 07:23:51 Functions: 87.9 % 141 124

            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          867 : std::ofstream &open_tbl_stream(EnergyPlusData &state, int const iStyle, fs::path const &filePath, bool output_to_file)
     195              : {
     196          867 :     std::ofstream &tbl_stream(*state.dataOutRptTab->TabularOutputFile(iStyle));
     197          867 :     if (output_to_file) {
     198          867 :         tbl_stream.open(filePath);
     199          867 :         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          867 :     return tbl_stream;
     206              : }
     207              : 
     208      1116252 : 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      1116252 :     auto &ort = state.dataOutRptTab;
     222              : 
     223      1116252 :     if (t_timeStepType != OutputProcessor::TimeStepType::Zone && t_timeStepType != OutputProcessor::TimeStepType::System) {
     224            0 :         ShowFatalError(state, "Invalid reporting requested -- UpdateTabularReports");
     225              :     }
     226              : 
     227      1116252 :     if (ort->UpdateTabularReportsGetInput) {
     228          799 :         GetInputTabularMonthly(state);
     229          799 :         OutputReportTabularAnnual::GetInputTabularAnnual(state);
     230          799 :         OutputReportTabularAnnual::checkAggregationOrderForAnnual(state);
     231          799 :         GetInputTabularTimeBins(state);
     232          799 :         GetInputTabularStyle(state);
     233          799 :         GetInputOutputTableSummaryReports(state);
     234          799 :         if (state.dataOutRptTab->displayThermalResilienceSummary) {
     235              :             // check whether multiple people have different threshold for a zone
     236          680 :             Real64 valueNotInit = -999.0;
     237          680 :             Real64 nearThreshold = 1.0;
     238         4365 :             for (int ZoneNum = 1; ZoneNum <= state.dataGlobal->NumOfZones; ++ZoneNum) {
     239         3685 :                 state.dataHeatBal->Resilience(ZoneNum).ColdStressTempThresh = valueNotInit;
     240         3685 :                 state.dataHeatBal->Resilience(ZoneNum).HeatStressTempThresh = valueNotInit;
     241              :             }
     242         3700 :             for (int iPeople = 1; iPeople <= state.dataHeatBal->TotPeople; ++iPeople) {
     243         3020 :                 int ZoneNum = state.dataHeatBal->People(iPeople).ZonePtr;
     244              : 
     245         3020 :                 Real64 ColdTempThresh = state.dataHeatBal->People(iPeople).ColdStressTempThresh;
     246         3020 :                 if (state.dataHeatBal->Resilience(ZoneNum).ColdStressTempThresh < valueNotInit + nearThreshold) {
     247         2975 :                     state.dataHeatBal->Resilience(ZoneNum).ColdStressTempThresh = ColdTempThresh;
     248              :                 } else {
     249           45 :                     if (state.dataHeatBal->Resilience(ZoneNum).ColdStressTempThresh != ColdTempThresh) {
     250            0 :                         ShowWarningMessage(
     251            0 :                             state, fmt::format("Zone {} has multiple people objects with different Cold Stress Temperature Threshold.", ZoneNum));
     252              :                     }
     253              :                 }
     254              : 
     255         3020 :                 Real64 HeatTempThresh = state.dataHeatBal->People(iPeople).HeatStressTempThresh;
     256         3020 :                 if (state.dataHeatBal->Resilience(ZoneNum).HeatStressTempThresh < valueNotInit + nearThreshold) {
     257         2975 :                     state.dataHeatBal->Resilience(ZoneNum).HeatStressTempThresh = HeatTempThresh;
     258              :                 } else {
     259           45 :                     if (state.dataHeatBal->Resilience(ZoneNum).HeatStressTempThresh != HeatTempThresh) {
     260            0 :                         ShowWarningMessage(
     261            0 :                             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          799 :         InitializeTabularMonthly(state);
     268          799 :         if (isInvalidAggregationOrder(state)) {
     269            0 :             ShowFatalError(state, "OutputReportTabular: Invalid aggregations detected, no simulation performed.");
     270              :         }
     271          799 :         GetInputFuelAndPollutionFactors(state);
     272          799 :         SetupUnitConversions(state);
     273          799 :         AddTOCLoadComponentTableSummaries(state);
     274          799 :         ort->UpdateTabularReportsGetInput = false;
     275          799 :         date_and_time(_, _, _, ort->td);
     276              :     }
     277      1116252 :     if (state.dataGlobal->DoOutputReporting && ort->WriteTabularFiles && (state.dataGlobal->KindOfSim == Constant::KindOfSim::RunPeriodWeather)) {
     278       497501 :         if (t_timeStepType == OutputProcessor::TimeStepType::Zone) {
     279       219096 :             ort->gatherElapsedTimeBEPS += state.dataGlobal->TimeStepZone;
     280              :         }
     281       497501 :         if (state.dataGlobal->DoWeathSim) {
     282       497501 :             GatherMonthlyResultsForTimestep(state, t_timeStepType);
     283       497501 :             OutputReportTabularAnnual::GatherAnnualResultsForTimeStep(state, t_timeStepType);
     284       497501 :             GatherBinResultsForTimestep(state, t_timeStepType);
     285       497501 :             GatherBEPSResultsForTimestep(state, t_timeStepType);
     286       497501 :             GatherSourceEnergyEndUseResultsForTimestep(state, t_timeStepType);
     287       497501 :             GatherPeakDemandForTimestep(state, t_timeStepType);
     288       497501 :             GatherHeatGainReport(state, t_timeStepType);
     289       497501 :             GatherHeatEmissionReport(state, t_timeStepType);
     290              :         }
     291              :     }
     292      1116252 : }
     293              : 
     294              : //======================================================================================================================
     295              : //======================================================================================================================
     296              : 
     297              : //    GET INPUT ROUTINES
     298              : 
     299              : //======================================================================================================================
     300              : //======================================================================================================================
     301              : 
     302          799 : 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         2397 :     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          799 :     auto &ort = state.dataOutRptTab;
     343              : 
     344          799 :     if (!state.files.outputControl.writeTabular(state)) {
     345            1 :         ort->WriteTabularFiles = false;
     346          139 :         return;
     347              :     }
     348              : 
     349          798 :     ort->MonthlyInputCount = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, CurrentModuleObject);
     350          798 :     if (ort->MonthlyInputCount > 0) {
     351          139 :         ort->WriteTabularFiles = true;
     352              :         // if not a run period using weather do not create reports
     353          139 :         if (!state.dataGlobal->DoWeathSim) {
     354          276 :             ShowWarningError(
     355              :                 state,
     356          276 :                 format("{} requested with SimulationControl Run Simulation for Weather File Run Periods set to No so {} will not be generated",
     357              :                        CurrentModuleObject,
     358              :                        CurrentModuleObject));
     359          138 :             return;
     360              :         }
     361              :     }
     362              : 
     363          660 :     int NumParams = 0;        // Number of elements combined
     364          660 :     int NumAlphas = 0;        // Number of elements in the alpha array
     365          660 :     int NumNums = 0;          // Number of elements in the numeric array
     366          660 :     Array1D_string AlphArray; // character string data
     367          660 :     Array1D<Real64> NumArray; // numeric data
     368          660 :     int IOStat = -1;          // IO Status when calling get input subroutine
     369          660 :     bool ErrorsFound = false;
     370              : 
     371          660 :     state.dataInputProcessing->inputProcessor->getObjectDefMaxArgs(state, CurrentModuleObject, NumParams, NumAlphas, NumNums);
     372          660 :     AlphArray.allocate(NumAlphas);
     373          660 :     NumArray.dimension(NumNums, 0.0);
     374          665 :     for (int TabNum = 1, TabNum_end = ort->MonthlyInputCount; TabNum <= TabNum_end; ++TabNum) { // MonthlyInputCount is modified in the loop
     375            5 :         state.dataInputProcessing->inputProcessor->getObjectItem(state, CurrentModuleObject, TabNum, AlphArray, NumAlphas, NumArray, NumNums, IOStat);
     376              : 
     377            5 :         if (TabNum - 1 > 0) {
     378            4 :             Util::IsNameEmpty(state, AlphArray(1), CurrentModuleObject, ErrorsFound);
     379              :         }
     380            5 :         if (NumAlphas < 2) {
     381            0 :             ShowSevereError(state, format("{}: No fields specified.", CurrentModuleObject));
     382              :         }
     383              :         // add to the data structure
     384            5 :         int const curTable = AddMonthlyReport(state, AlphArray(1), int(NumArray(1)));
     385           10 :         for (int jField = 2; jField <= NumAlphas; jField += 2) {
     386            5 :             if (AlphArray(jField).empty()) {
     387            0 :                 ShowWarningError(state,
     388            0 :                                  format("{}: Blank column specified in '{}', need to provide a variable or meter name ",
     389              :                                         CurrentModuleObject,
     390            0 :                                         ort->MonthlyInput(TabNum).name));
     391            0 :                 continue;
     392              :             }
     393            5 :             std::string const curAggString = AlphArray(jField + 1);
     394              :             // kind of aggregation identified (see AggType parameters)
     395            5 :             AggType curAggType = static_cast<AggType>(getEnumValue(AggTypeNamesUC, Util::makeUPPER(curAggString)));
     396              :             // set accumulator values to default as appropriate for aggregation type
     397            5 :             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            5 :             AddMonthlyFieldSetInput(state, curTable, AlphArray(jField), "", curAggType);
     403            5 :         }
     404              :     }
     405          660 : }
     406              : 
     407         1520 : 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         1520 :     int constexpr SizeAdder(25);
     442         1520 :     auto &ort = state.dataOutRptTab;
     443              : 
     444         1520 :     if (!allocated(ort->MonthlyInput)) {
     445           27 :         ort->MonthlyInput.allocate(SizeAdder);
     446           27 :         ort->sizeMonthlyInput = SizeAdder;
     447           27 :         ort->MonthlyInputCount = 1;
     448              :     } else {
     449         1493 :         ++ort->MonthlyInputCount;
     450              :         // if larger than current size grow the array
     451         1493 :         if (ort->MonthlyInputCount > ort->sizeMonthlyInput) {
     452           48 :             ort->MonthlyInput.redimension(ort->sizeMonthlyInput += SizeAdder);
     453              :         }
     454              :     }
     455              :     // initialize new record
     456         1520 :     ort->MonthlyInput(ort->MonthlyInputCount).name = inReportName;
     457         1520 :     ort->MonthlyInput(ort->MonthlyInputCount).showDigits = inNumDigitsShown;
     458         1520 :     ort->MonthlyInput(ort->MonthlyInputCount).isNamedMonthly = isNamedMonthly;
     459         1520 :     return ort->MonthlyInputCount;
     460              : }
     461              : 
     462        10554 : 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        10554 :     int constexpr sizeIncrement(50);
     488        10554 :     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        10554 :     if (!allocated(ort->MonthlyFieldSetInput)) {
     500           27 :         ort->MonthlyFieldSetInput.allocate(sizeIncrement);
     501           27 :         ort->sizeMonthlyFieldSetInput = sizeIncrement;
     502           27 :         ort->MonthlyFieldSetInputCount = 1;
     503              :     } else {
     504        10527 :         ++ort->MonthlyFieldSetInputCount;
     505              :         // if larger than current size grow the array
     506        10527 :         if (ort->MonthlyFieldSetInputCount > ort->sizeMonthlyFieldSetInput) {
     507           96 :             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        10554 :     ort->MonthlyFieldSetInput(ort->MonthlyFieldSetInputCount).variMeter = inVariMeter;
     513        10554 :     ort->MonthlyFieldSetInput(ort->MonthlyFieldSetInputCount).colHead = inColHead;
     514        10554 :     ort->MonthlyFieldSetInput(ort->MonthlyFieldSetInputCount).aggregate = inAggregate;
     515              :     // update the references from the MonthlyInput array
     516        10554 :     if ((inMonthReport > 0) && (inMonthReport <= ort->MonthlyInputCount)) {
     517        10554 :         if (ort->MonthlyInput(inMonthReport).firstFieldSet == 0) {
     518         1520 :             ort->MonthlyInput(inMonthReport).firstFieldSet = ort->MonthlyFieldSetInputCount;
     519         1520 :             ort->MonthlyInput(inMonthReport).numFieldSet = 1;
     520              :         } else {
     521         9034 :             ++ort->MonthlyInput(inMonthReport).numFieldSet;
     522              :         }
     523              :     }
     524        10554 : }
     525              : 
     526          799 : 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          799 :     Constant::Units UnitsVar = Constant::Units::None; // Units enum
     575          799 :     Array1D_string UniqueKeyNames;
     576              :     int found;
     577          799 :     auto &ort = state.dataOutRptTab;
     578              : 
     579              :     // if not a running a weather simulation do not create reports
     580          799 :     if (!state.dataGlobal->DoWeathSim) {
     581          792 :         return;
     582              :     }
     583            7 :     ort->maxUniqueKeyCount = 1500;
     584            7 :     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            7 :     ort->MonthlyColumnsCount = 0;
     602            7 :     ort->MonthlyTablesCount = 0;
     603           12 :     for (int TabNum = 1; TabNum <= ort->MonthlyInputCount; ++TabNum) {
     604              :         // the number of columns based on number of alpha fields
     605            5 :         int const NumColumns = ort->MonthlyInput(TabNum).numFieldSet;
     606            5 :         int const FirstColumn = ort->MonthlyInput(TabNum).firstFieldSet;
     607            5 :         bool environmentKeyFound = false;
     608            5 :         int UniqueKeyCount = 0;
     609           10 :         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            5 :             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            5 :             int KeyCount = 0;
     617            5 :             GetVariableKeyCountandType(state, curVariMeter, KeyCount, TypeVar, AvgSumVar, StepTypeVar, UnitsVar);
     618            5 :             if (TypeVar == OutputProcessor::VariableType::Invalid) { // TODO: This NotFound thing has to go
     619            0 :                 if (!ort->MonthlyInput(TabNum).isNamedMonthly) {
     620            0 :                     ++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            5 :             ort->MonthlyFieldSetInput(FirstColumn + colNum - 1).variMeterUpper = curVariMeter;
     633            5 :             ort->MonthlyFieldSetInput(FirstColumn + colNum - 1).typeOfVar = TypeVar;
     634            5 :             ort->MonthlyFieldSetInput(FirstColumn + colNum - 1).keyCount = KeyCount;
     635            5 :             ort->MonthlyFieldSetInput(FirstColumn + colNum - 1).varAvgSum = AvgSumVar;
     636            5 :             ort->MonthlyFieldSetInput(FirstColumn + colNum - 1).varStepType = StepTypeVar;
     637            5 :             ort->MonthlyFieldSetInput(FirstColumn + colNum - 1).varUnits = UnitsVar;
     638              : 
     639            5 :             if (TypeVar == OutputProcessor::VariableType::Invalid) {
     640            0 :                 continue;
     641              :             }
     642              : 
     643            5 :             ort->MonthlyFieldSetInput(FirstColumn + colNum - 1).NamesOfKeys.allocate(KeyCount);
     644            5 :             ort->MonthlyFieldSetInput(FirstColumn + colNum - 1).IndexesForKeyVar.allocate(KeyCount);
     645              : 
     646              :             // fill keys?
     647            5 :             GetVariableKeys(state,
     648              :                             curVariMeter,
     649              :                             TypeVar,
     650            5 :                             ort->MonthlyFieldSetInput(FirstColumn + colNum - 1).NamesOfKeys,
     651            5 :                             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           10 :             for (int iKey = 1; iKey <= KeyCount; ++iKey) {
     667            5 :                 found = 0;
     668              :                 // set a flag if environment variables are found
     669            5 :                 if (Util::SameString(ort->MonthlyFieldSetInput(FirstColumn + colNum - 1).NamesOfKeys(iKey), "ENVIRONMENT")) {
     670            0 :                     environmentKeyFound = true;
     671            0 :                     found = -1; // so not counted in list of unique keys
     672              :                 }
     673            5 :                 for (int jUnique = 1; jUnique <= UniqueKeyCount; ++jUnique) {
     674            0 :                     if (Util::SameString(UniqueKeyNames(jUnique), ort->MonthlyFieldSetInput(FirstColumn + colNum - 1).NamesOfKeys(iKey))) {
     675            0 :                         found = jUnique;
     676            0 :                         break;
     677              :                     }
     678              :                 }
     679            5 :                 if (found == 0) {
     680            5 :                     ++UniqueKeyCount;
     681            5 :                     if (UniqueKeyCount > ort->maxUniqueKeyCount) {
     682            0 :                         UniqueKeyNames.redimension(ort->maxUniqueKeyCount += 500);
     683              :                     }
     684            5 :                     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            5 :         } // colNum
     694              :         // fix for CR8285 - when monthly report is only environmental variables
     695            5 :         if (environmentKeyFound && UniqueKeyCount == 0) {
     696            0 :             UniqueKeyCount = 1;
     697              :         }
     698              :         // increment the number of tables based on the number of unique keys
     699            5 :         ort->MonthlyTablesCount += UniqueKeyCount;
     700            5 :         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            7 :     ort->MonthlyTables.allocate(ort->MonthlyTablesCount);
     706            7 :     ort->MonthlyColumns.allocate(ort->MonthlyColumnsCount);
     707              :     // Initialize tables and results
     708           12 :     for (auto &e : ort->MonthlyTables) {
     709            5 :         e.keyValue.clear();
     710            5 :         e.firstColumn = 0;
     711            5 :         e.numColumns = 0;
     712              :     }
     713              : 
     714           12 :     for (auto &e : ort->MonthlyColumns) {
     715            5 :         e.varName.clear();
     716            5 :         e.varNum = 0;
     717            5 :         e.typeOfVar = OutputProcessor::VariableType::Invalid;
     718            5 :         e.avgSum = OutputProcessor::StoreType::Average;
     719            5 :         e.stepType = OutputProcessor::TimeStepType::Zone;
     720            5 :         e.units = Constant::Units::None;
     721            5 :         e.aggType = AggType::Invalid;
     722              :     }
     723           12 :     for (int colNum = 1; colNum <= ort->MonthlyColumnsCount; ++colNum) {
     724            5 :         ort->MonthlyColumns(colNum).reslt = 0.0;
     725            5 :         ort->MonthlyColumns(colNum).timeStamp = 0;
     726            5 :         ort->MonthlyColumns(colNum).duration = 0.0;
     727              :     }
     728              : 
     729              :     // If no weather file run requested, don't bother issuing a warning
     730            7 :     bool issueWarnings = false;
     731            7 :     if (state.dataGlobal->DoWeathSim && (state.dataOutRptTab->ErrCount1 > 0)) {
     732            0 :         ShowWarningError(state, "Processing Monthly Tabular Reports: Variable names not valid for this simulation");
     733              : 
     734            0 :         if (!state.dataGlobal->DisplayExtraWarnings) {
     735            0 :             ShowContinueError(state, "...use Output:Diagnostics,DisplayExtraWarnings; to show more details on individual variables.");
     736              :         } else {
     737            0 :             ShowContinueError(state,
     738              :                               "..Variables not valid for this simulation will have \"[Invalid/Undefined]\" in the Units Column of "
     739              :                               "the Table Report.");
     740            0 :             issueWarnings = true;
     741              :         }
     742              :     }
     743              : 
     744            7 :     int ColumnsRecount = 0;
     745            7 :     int TablesRecount = 0;
     746           12 :     for (int TabNum = 1; TabNum <= ort->MonthlyInputCount; ++TabNum) {
     747              :         // the number of columns based on number of alpha fields
     748            5 :         int const NumColumns = ort->MonthlyInput(TabNum).numFieldSet;
     749            5 :         int FirstColumn = ort->MonthlyInput(TabNum).firstFieldSet;
     750            5 :         int UniqueKeyCount = 0;
     751            5 :         bool environmentKeyFound = false;
     752           10 :         for (int colNum = 1; colNum <= NumColumns; ++colNum) {
     753            5 :             std::string const &curVariMeter = ort->MonthlyFieldSetInput(FirstColumn + colNum - 1).variMeterUpper;
     754            5 :             const int KeyCount = ort->MonthlyFieldSetInput(FirstColumn + colNum - 1).keyCount;
     755            5 :             TypeVar = ort->MonthlyFieldSetInput(FirstColumn + colNum - 1).typeOfVar;
     756            5 :             AvgSumVar = ort->MonthlyFieldSetInput(FirstColumn + colNum - 1).varAvgSum;
     757            5 :             StepTypeVar = ort->MonthlyFieldSetInput(FirstColumn + colNum - 1).varStepType;
     758            5 :             UnitsVar = ort->MonthlyFieldSetInput(FirstColumn + colNum - 1).varUnits;
     759              : 
     760            5 :             if (KeyCount == 0 && issueWarnings && !ort->MonthlyInput(TabNum).isNamedMonthly) {
     761            0 :                 ShowWarningError(
     762            0 :                     state, format("In Output:Table:Monthly '{}' invalid Variable or Meter Name '{}'", ort->MonthlyInput(TabNum).name, curVariMeter));
     763              :             }
     764           10 :             for (int iKey = 1; iKey <= KeyCount; ++iKey) {
     765            5 :                 found = 0;
     766              :                 // set a flag if environment variables are found
     767            5 :                 if (Util::SameString(ort->MonthlyFieldSetInput(FirstColumn + colNum - 1).NamesOfKeys(iKey), "ENVIRONMENT")) {
     768            0 :                     environmentKeyFound = true;
     769            0 :                     found = -1; // so not counted in list of unique keys
     770              :                 }
     771            5 :                 for (int jUnique = 1; jUnique <= UniqueKeyCount; ++jUnique) {
     772            0 :                     if (Util::SameString(UniqueKeyNames(jUnique), ort->MonthlyFieldSetInput(FirstColumn + colNum - 1).NamesOfKeys(iKey))) {
     773            0 :                         found = jUnique;
     774            0 :                         break;
     775              :                     }
     776              :                 }
     777            5 :                 if (found == 0) {
     778            5 :                     ++UniqueKeyCount;
     779            5 :                     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            5 :         if (environmentKeyFound && UniqueKeyCount == 0) {
     791            0 :             UniqueKeyCount = 1;
     792              :         }
     793              :         // increment the number of tables based on the number of unique keys
     794            5 :         ort->MonthlyInput(TabNum).firstTable = TablesRecount + 1;
     795            5 :         ort->MonthlyInput(TabNum).numTables = UniqueKeyCount;
     796            5 :         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           10 :         for (int kUniqueKey = 1; kUniqueKey <= UniqueKeyCount; ++kUniqueKey) {
     802            5 :             int const lTable = kUniqueKey + ort->MonthlyInput(TabNum).firstTable - 1;
     803              :             // use the term 'environment' for identifying the report if
     804            5 :             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            5 :                 ort->MonthlyTables(lTable).keyValue = UniqueKeyNames(kUniqueKey);
     808              :             }
     809            5 :             ort->MonthlyTables(lTable).firstColumn = ColumnsRecount + 1;
     810            5 :             ort->MonthlyTables(lTable).numColumns = NumColumns;
     811            5 :             ColumnsRecount += NumColumns;
     812            5 :             FirstColumn = ort->MonthlyInput(TabNum).firstFieldSet;
     813           10 :             for (int colNum = 1; colNum <= NumColumns; ++colNum) {
     814            5 :                 environmentKeyFound = false;
     815            5 :                 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            5 :                 std::string const &curVariMeter = ort->MonthlyFieldSetInput(FirstColumn + colNum - 1).variMeterUpper;
     823            5 :                 int const KeyCount = ort->MonthlyFieldSetInput(FirstColumn + colNum - 1).keyCount;
     824            5 :                 TypeVar = ort->MonthlyFieldSetInput(FirstColumn + colNum - 1).typeOfVar;
     825            5 :                 AvgSumVar = ort->MonthlyFieldSetInput(FirstColumn + colNum - 1).varAvgSum;
     826            5 :                 StepTypeVar = ort->MonthlyFieldSetInput(FirstColumn + colNum - 1).varStepType;
     827            5 :                 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            5 :                 if (KeyCount == 1) { // first test if KeyCount is one to avoid referencing a zero element array
     842            5 :                     if (Util::SameString(ort->MonthlyFieldSetInput(FirstColumn + colNum - 1).NamesOfKeys(1), "ENVIRONMENT")) {
     843            0 :                         environmentKeyFound = true;
     844              :                     }
     845              :                 }
     846              :                 // if this is an environment variable - don't bother searching
     847            5 :                 if (environmentKeyFound) {
     848            0 :                     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            5 :                     found = 0;
     852            5 :                     for (int iKey = 1; iKey <= KeyCount; ++iKey) {
     853            5 :                         if (Util::SameString(ort->MonthlyFieldSetInput(FirstColumn + colNum - 1).NamesOfKeys(iKey), UniqueKeyNames(kUniqueKey))) {
     854            5 :                             found = iKey;
     855            5 :                             break;
     856              :                         }
     857              :                     }
     858              :                 }
     859            5 :                 if ((found > 0) && (KeyCount >= 1)) {
     860            5 :                     ort->MonthlyColumns(mColumn).varName = curVariMeter;
     861            5 :                     ort->MonthlyColumns(mColumn).varNum = ort->MonthlyFieldSetInput(FirstColumn + colNum - 1).IndexesForKeyVar(found);
     862            5 :                     ort->MonthlyColumns(mColumn).typeOfVar = TypeVar;
     863            5 :                     ort->MonthlyColumns(mColumn).avgSum = AvgSumVar;
     864            5 :                     ort->MonthlyColumns(mColumn).stepType = StepTypeVar;
     865            5 :                     ort->MonthlyColumns(mColumn).units = UnitsVar;
     866            5 :                     ort->MonthlyColumns(mColumn).aggType = ort->MonthlyFieldSetInput(FirstColumn + colNum - 1).aggregate;
     867              :                     // set accumulator values to default as appropriate for aggregation type
     868           10 :                     switch (ort->MonthlyColumns(mColumn).aggType) {
     869            0 :                     case AggType::SumOrAvg: {
     870            0 :                         ort->MonthlyColumns(mColumn).reslt = 0.0;
     871            0 :                         ort->MonthlyColumns(mColumn).duration = 0.0;
     872            0 :                     } break;
     873            5 :                     case AggType::Maximum: {
     874            5 :                         ort->MonthlyColumns(mColumn).reslt = -HUGE_(state.dataOutRptTab->BigNum);
     875            5 :                         ort->MonthlyColumns(mColumn).timeStamp = 0;
     876            5 :                     } break;
     877            0 :                     case AggType::Minimum: {
     878            0 :                         ort->MonthlyColumns(mColumn).reslt = HUGE_(state.dataOutRptTab->BigNum);
     879            0 :                         ort->MonthlyColumns(mColumn).timeStamp = 0;
     880            0 :                     } break;
     881            0 :                     case AggType::ValueWhenMaxMin: {
     882            0 :                         ort->MonthlyColumns(mColumn).reslt = 0.0;
     883            0 :                     } break;
     884            0 :                     case AggType::HoursZero: {
     885            0 :                         ort->MonthlyColumns(mColumn).reslt = 0.0;
     886            0 :                     } break;
     887            0 :                     case AggType::HoursNonZero: {
     888            0 :                         ort->MonthlyColumns(mColumn).reslt = 0.0;
     889            0 :                     } break;
     890            0 :                     case AggType::HoursPositive: {
     891            0 :                         ort->MonthlyColumns(mColumn).reslt = 0.0;
     892            0 :                     } break;
     893            0 :                     case AggType::HoursNonPositive: {
     894            0 :                         ort->MonthlyColumns(mColumn).reslt = 0.0;
     895            0 :                     } break;
     896            0 :                     case AggType::HoursNegative: {
     897            0 :                         ort->MonthlyColumns(mColumn).reslt = 0.0;
     898            0 :                     } break;
     899            0 :                     case AggType::HoursNonNegative: {
     900            0 :                         ort->MonthlyColumns(mColumn).reslt = 0.0;
     901            0 :                     } break;
     902            0 :                     case AggType::SumOrAverageHoursShown: {
     903            0 :                         ort->MonthlyColumns(mColumn).reslt = 0.0;
     904            0 :                         ort->MonthlyColumns(mColumn).duration = 0.0;
     905            0 :                     } break;
     906            0 :                     case AggType::MaximumDuringHoursShown: {
     907            0 :                         ort->MonthlyColumns(mColumn).reslt = -HUGE_(state.dataOutRptTab->BigNum);
     908            0 :                         ort->MonthlyColumns(mColumn).timeStamp = 0;
     909            0 :                     } break;
     910            0 :                     case AggType::MinimumDuringHoursShown: {
     911            0 :                         ort->MonthlyColumns(mColumn).reslt = HUGE_(state.dataOutRptTab->BigNum);
     912            0 :                         ort->MonthlyColumns(mColumn).timeStamp = 0;
     913            0 :                     } 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            0 :                     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            0 :                     ort->MonthlyColumns(mColumn).varName = curVariMeter;
     927            0 :                     ort->MonthlyColumns(mColumn).varNum = 0;
     928            0 :                     ort->MonthlyColumns(mColumn).typeOfVar = OutputProcessor::VariableType::Invalid;
     929            0 :                     ort->MonthlyColumns(mColumn).avgSum = OutputProcessor::StoreType::Average;
     930            0 :                     ort->MonthlyColumns(mColumn).stepType = OutputProcessor::TimeStepType::Zone;
     931            0 :                     ort->MonthlyColumns(mColumn).units = Constant::Units::None;
     932            0 :                     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          799 : }
     948              : 
     949          799 : bool isInvalidAggregationOrder(EnergyPlusData &state)
     950              : {
     951          799 :     auto &ort = state.dataOutRptTab;
     952          799 :     bool foundError = false;
     953          799 :     if (!state.dataGlobal->DoWeathSim) { // if no weather simulation than no reading of MonthlyInput array
     954          792 :         return foundError;
     955              :     }
     956           12 :     for (int iInput = 1; iInput <= ort->MonthlyInputCount; ++iInput) {
     957            5 :         bool foundMinOrMax = false;
     958            5 :         bool foundHourAgg = false;
     959            5 :         bool missingMaxOrMinError = false;
     960            5 :         bool missingHourAggError = false;
     961           10 :         for (int jTable = 1; jTable <= ort->MonthlyInput(iInput).numTables; ++jTable) {
     962            5 :             int curTable = jTable + ort->MonthlyInput(iInput).firstTable - 1;
     963              :             // test if the aggregation types are in the correct order
     964            7 :             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            2 :                     foundMinOrMax = true;
     972            0 :                 } else if ((curAggType == AggType::HoursNonZero) || (curAggType == AggType::HoursZero) || (curAggType == AggType::HoursPositive) ||
     973            0 :                            (curAggType == AggType::HoursNonPositive) || (curAggType == AggType::HoursNegative) ||
     974              :                            (curAggType == AggType::HoursNonNegative)) {
     975            0 :                     foundHourAgg = true;
     976            0 :                 } else if (curAggType == AggType::ValueWhenMaxMin) {
     977            0 :                     if (!foundMinOrMax) {
     978            0 :                         missingMaxOrMinError = true;
     979              :                     }
     980            0 :                 } else if ((curAggType == AggType::SumOrAverageHoursShown) || (curAggType == AggType::MaximumDuringHoursShown) ||
     981              :                            (curAggType == AggType::MinimumDuringHoursShown)) {
     982            0 :                     if (!foundHourAgg) {
     983            0 :                         missingHourAggError = true;
     984              :                     }
     985              :                 }
     986              :             }
     987              :         }
     988            5 :         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            5 :         if (missingHourAggError) {
     996            0 :             ShowSevereError(state,
     997            0 :                             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            0 :                                    ort->MonthlyInput(iInput).name));
    1000            0 :             foundError = true;
    1001              :         }
    1002              :     }
    1003            7 :     return foundError;
    1004              : }
    1005              : 
    1006          799 : 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         2397 :     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          799 :     int NumParams = 0;            // Number of elements combined
    1040          799 :     int NumAlphas = 0;            // Number of elements in the alpha array
    1041          799 :     int NumNums = 0;              // Number of elements in the numeric array
    1042          799 :     Array1D_string AlphArray;     // character string data
    1043          799 :     Array1D<Real64> NumArray;     // numeric data
    1044          799 :     int IOStat = -1;              // IO Status when calling get input subroutine
    1045          799 :     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          799 :     Array1D_int objVarIDs;
    1048          799 :     Array1D_string objNames;
    1049              : 
    1050              :     static constexpr std::string_view routineName = "GetInputTabularTimeBins";
    1051              : 
    1052          799 :     auto &ort = state.dataOutRptTab;
    1053              : 
    1054          799 :     if (!state.files.outputControl.writeTabular(state)) {
    1055            1 :         ort->WriteTabularFiles = false;
    1056            1 :         return;
    1057              :     }
    1058              : 
    1059          798 :     state.dataInputProcessing->inputProcessor->getObjectDefMaxArgs(state, CurrentModuleObject, NumParams, NumAlphas, NumNums);
    1060          798 :     AlphArray.allocate(NumAlphas);
    1061          798 :     NumArray.dimension(NumNums, 0.0);
    1062              : 
    1063          798 :     ort->timeInYear = 0.0; // initialize the time in year counter
    1064              :     // determine size of array that holds the IDF description
    1065          798 :     ort->OutputTableBinnedCount = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, CurrentModuleObject);
    1066          798 :     ort->OutputTableBinned.allocate(ort->OutputTableBinnedCount);
    1067          798 :     if (ort->OutputTableBinnedCount > 0) {
    1068           57 :         ort->WriteTabularFiles = true;
    1069              :         // if not a run period using weather do not create reports
    1070           57 :         if (!state.dataGlobal->DoWeathSim) {
    1071          114 :             ShowWarningError(
    1072              :                 state,
    1073          114 :                 format("{} requested with SimulationControl Run Simulation for Weather File Run Periods set to No so {} will not be generated",
    1074              :                        CurrentModuleObject,
    1075              :                        CurrentModuleObject));
    1076           57 :             return;
    1077              :         }
    1078              :     }
    1079              :     // looking for maximum number of intervals for sizing
    1080          741 :     ort->BinResultsIntervalCount = 0;
    1081          741 :     ort->BinResultsTableCount = 0;
    1082          741 :     for (int iInObj = 1; iInObj <= ort->OutputTableBinnedCount; ++iInObj) {
    1083            0 :         state.dataInputProcessing->inputProcessor->getObjectItem(state,
    1084              :                                                                  CurrentModuleObject,
    1085              :                                                                  iInObj,
    1086              :                                                                  AlphArray,
    1087              :                                                                  NumAlphas,
    1088              :                                                                  NumArray,
    1089              :                                                                  NumNums,
    1090              :                                                                  IOStat,
    1091            0 :                                                                  state.dataIPShortCut->lNumericFieldBlanks,
    1092            0 :                                                                  state.dataIPShortCut->lAlphaFieldBlanks,
    1093            0 :                                                                  state.dataIPShortCut->cAlphaFieldNames,
    1094            0 :                                                                  state.dataIPShortCut->cNumericFieldNames);
    1095              : 
    1096            0 :         ErrorObjectHeader eoh{routineName, CurrentModuleObject, AlphArray(1)};
    1097              : 
    1098            0 :         ort->OutputTableBinned(iInObj).keyValue = AlphArray(1);
    1099            0 :         ort->OutputTableBinned(iInObj).varOrMeter = AlphArray(2);
    1100              :         // if a schedule has been specified assign
    1101            0 :         if (state.dataIPShortCut->lAlphaFieldBlanks(3)) {
    1102            0 :         } 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            0 :         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            0 :         ort->OutputTableBinned(iInObj).intervalStart = NumArray(1);
    1116            0 :         ort->OutputTableBinned(iInObj).intervalSize = NumArray(2);
    1117            0 :         ort->OutputTableBinned(iInObj).intervalCount = int(NumArray(3));
    1118              :         // valid range checking on inputs
    1119            0 :         if (ort->OutputTableBinned(iInObj).intervalCount < 1) {
    1120            0 :             ort->OutputTableBinned(iInObj).intervalCount = 1;
    1121              :         }
    1122            0 :         if (ort->OutputTableBinned(iInObj).intervalCount > 20) {
    1123            0 :             ort->OutputTableBinned(iInObj).intervalCount = 20;
    1124              :         }
    1125            0 :         if (ort->OutputTableBinned(iInObj).intervalSize < 0) {
    1126            0 :             ort->OutputTableBinned(iInObj).intervalSize = 1000.0;
    1127              :         }
    1128            0 :         ort->OutputTableBinned(iInObj).resIndex = ort->BinResultsTableCount + 1; // the next results report
    1129              :         // find maximum number of intervals
    1130            0 :         if (ort->OutputTableBinned(iInObj).intervalCount > ort->BinResultsIntervalCount) {
    1131            0 :             ort->BinResultsIntervalCount = ort->OutputTableBinned(iInObj).intervalCount;
    1132              :         }
    1133            0 :         GetVariableKeyCountandType(state,
    1134            0 :                                    ort->OutputTableBinned(iInObj).varOrMeter,
    1135            0 :                                    ort->OutputTableBinned(iInObj).numTables,
    1136            0 :                                    ort->OutputTableBinned(iInObj).typeOfVar,
    1137            0 :                                    ort->OutputTableBinned(iInObj).avgSum,
    1138            0 :                                    ort->OutputTableBinned(iInObj).stepType,
    1139            0 :                                    ort->OutputTableBinned(iInObj).units);
    1140            0 :         if (ort->OutputTableBinned(iInObj).typeOfVar == OutputProcessor::VariableType::Invalid) {
    1141            0 :             ShowWarningError(
    1142            0 :                 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            0 :         if (ort->OutputTableBinned(iInObj).keyValue == "*") {
    1148            0 :             ort->BinResultsTableCount += ort->OutputTableBinned(iInObj).numTables;
    1149              :         } else {
    1150            0 :             ++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          741 :     ort->BinResults.allocate(ort->BinResultsIntervalCount, ort->BinResultsTableCount);
    1155          741 :     ort->BinResultsBelow.allocate(ort->BinResultsTableCount);
    1156          741 :     ort->BinResultsAbove.allocate(ort->BinResultsTableCount);
    1157          741 :     ort->BinStatistics.allocate(ort->BinResultsTableCount);
    1158          741 :     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          741 :     for (int iInObj = 1; iInObj <= ort->OutputTableBinnedCount; ++iInObj) {
    1162            0 :         int firstReport = ort->OutputTableBinned(iInObj).resIndex;
    1163              :         // allocate the arrays to the number of objects
    1164            0 :         objVarIDs.allocate(ort->OutputTableBinned(iInObj).numTables);
    1165            0 :         objNames.allocate(ort->OutputTableBinned(iInObj).numTables);
    1166            0 :         GetVariableKeys(state, ort->OutputTableBinned(iInObj).varOrMeter, ort->OutputTableBinned(iInObj).typeOfVar, objNames, objVarIDs);
    1167              : 
    1168            0 :         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            0 :             int found = 0;
    1182            0 :             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            0 :             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            0 :             ort->OutputTableBinned(iInObj).numTables = 1;
    1195              :         }
    1196              :     }
    1197              :     // clear the binning arrays to zeros
    1198          741 :     for (auto &e : ort->BinResults) {
    1199            0 :         e.mnth = 0.0;
    1200            0 :         e.hrly = 0.0;
    1201              :     }
    1202          741 :     for (auto &e : ort->BinResultsBelow) {
    1203            0 :         e.mnth = 0.0;
    1204            0 :         e.hrly = 0.0;
    1205              :     }
    1206          741 :     for (auto &e : ort->BinResultsAbove) {
    1207            0 :         e.mnth = 0.0;
    1208            0 :         e.hrly = 0.0;
    1209              :     }
    1210              : 
    1211              :     // initialize statistics counters
    1212          741 :     for (auto &e : ort->BinStatistics) {
    1213            0 :         e.minimum = HUGE_(bigVal);
    1214            0 :         e.maximum = -HUGE_(bigVal);
    1215            0 :         e.n = 0;
    1216            0 :         e.sum = 0.0;
    1217            0 :         e.sum2 = 0.0;
    1218              :     }
    1219          973 : }
    1220              : 
    1221            0 : bool warningAboutKeyNotFound(EnergyPlusData &state, int foundIndex, int inObjIndex, std::string const &moduleName)
    1222              : {
    1223            0 :     if (foundIndex == 0) {
    1224            0 :         ShowWarningError(state,
    1225            0 :                          format("{}: Specified key not found: {} for variable: {}",
    1226              :                                 moduleName,
    1227            0 :                                 state.dataOutRptTab->OutputTableBinned(inObjIndex).keyValue,
    1228            0 :                                 state.dataOutRptTab->OutputTableBinned(inObjIndex).varOrMeter));
    1229            0 :         return true;
    1230              :     } else {
    1231            0 :         return false;
    1232              :     }
    1233              : }
    1234              : 
    1235          799 : 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         2397 :     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          799 :     int NumParams = 0;        // Number of elements combined
    1273          799 :     int NumAlphas = 0;        // Number of elements in the alpha array
    1274          799 :     int NumNums = 0;          // Number of elements in the numeric array
    1275          799 :     Array1D_string AlphArray; // character string data
    1276          799 :     Array1D<Real64> NumArray; // numeric data
    1277          799 :     int IOStat = -1;          // IO Status when calling get input subroutine
    1278          799 :     auto &ort = state.dataOutRptTab;
    1279              : 
    1280          799 :     state.dataInputProcessing->inputProcessor->getObjectDefMaxArgs(state, CurrentModuleObject, NumParams, NumAlphas, NumNums);
    1281          799 :     AlphArray.allocate(NumAlphas);
    1282          799 :     NumArray.dimension(NumNums, 0.0);
    1283              : 
    1284          799 :     int NumTabularStyle = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, CurrentModuleObject);
    1285              : 
    1286          799 :     if (NumTabularStyle == 0) {
    1287           38 :         AlphArray(1) = "COMMA";
    1288           38 :         ort->numStyles = 1;
    1289           38 :         ort->TableStyle(1) = TableStyle::Comma;
    1290           38 :         ort->del(1) = CharComma; // comma
    1291           38 :         ort->unitsStyle = UnitsStyle::None;
    1292          761 :     } else if (NumTabularStyle == 1) {
    1293         1522 :         state.dataInputProcessing->inputProcessor->getObjectItem(state,
    1294              :                                                                  CurrentModuleObject,
    1295              :                                                                  1,
    1296              :                                                                  AlphArray,
    1297              :                                                                  NumAlphas,
    1298              :                                                                  NumArray,
    1299              :                                                                  NumNums,
    1300              :                                                                  IOStat,
    1301          761 :                                                                  state.dataIPShortCut->lNumericFieldBlanks,
    1302          761 :                                                                  state.dataIPShortCut->lAlphaFieldBlanks,
    1303          761 :                                                                  state.dataIPShortCut->cAlphaFieldNames,
    1304          761 :                                                                  state.dataIPShortCut->cNumericFieldNames);
    1305              :         // ColumnSeparator
    1306          761 :         if (Util::SameString(AlphArray(1), "Comma")) {
    1307            9 :             ort->numStyles = 1;
    1308            9 :             ort->TableStyle(1) = TableStyle::Comma;
    1309            9 :             ort->del(1) = CharComma; // comma
    1310          752 :         } else if (Util::SameString(AlphArray(1), "Tab")) {
    1311            1 :             ort->numStyles = 1;
    1312            1 :             ort->TableStyle(1) = TableStyle::Tab;
    1313            1 :             ort->del(1) = CharTab; // tab
    1314          751 :         } else if (Util::SameString(AlphArray(1), "Fixed")) {
    1315            1 :             ort->numStyles = 1;
    1316            1 :             ort->TableStyle(1) = TableStyle::Fixed;
    1317            1 :             ort->del(1) = CharSpace; // space
    1318          750 :         } else if (Util::SameString(AlphArray(1), "HTML")) {
    1319          696 :             ort->numStyles = 1;
    1320          696 :             ort->TableStyle(1) = TableStyle::HTML;
    1321          696 :             ort->del(1) = CharSpace; // space - this is not used much for HTML output
    1322           54 :         } 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           54 :         } else if (Util::SameString(AlphArray(1), "CommaAndHTML")) {
    1327           29 :             ort->numStyles = 2;
    1328           29 :             ort->TableStyle(1) = TableStyle::Comma;
    1329           29 :             ort->del(1) = CharComma; // comma
    1330           29 :             ort->TableStyle(2) = TableStyle::HTML;
    1331           29 :             ort->del(2) = CharSpace; // space - this is not used much for HTML output
    1332           25 :         } 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           25 :         } else if (Util::SameString(AlphArray(1), "TabAndHTML")) {
    1339            5 :             ort->numStyles = 2;
    1340            5 :             ort->TableStyle(1) = TableStyle::Tab;
    1341            5 :             ort->del(1) = CharTab; // tab
    1342            5 :             ort->TableStyle(2) = TableStyle::HTML;
    1343            5 :             ort->del(2) = CharSpace; // space - this is not used much for HTML output
    1344           20 :         } else if (Util::SameString(AlphArray(1), "XMLandHTML")) {
    1345            2 :             ort->numStyles = 2;
    1346            2 :             ort->TableStyle(1) = TableStyle::XML;
    1347            2 :             ort->del(1) = CharSpace; // space - this is not used much for XML output
    1348            2 :             ort->TableStyle(2) = TableStyle::HTML;
    1349            2 :             ort->del(2) = CharSpace; // space - this is not used much for HTML output
    1350           18 :         } else if (Util::SameString(AlphArray(1), "All")) {
    1351           18 :             ort->numStyles = 5;
    1352           18 :             ort->TableStyle(1) = TableStyle::Comma;
    1353           18 :             ort->del(1) = CharComma; // comma
    1354           18 :             ort->TableStyle(2) = TableStyle::Tab;
    1355           18 :             ort->del(2) = CharTab; // tab
    1356           18 :             ort->TableStyle(3) = TableStyle::Fixed;
    1357           18 :             ort->del(3) = CharSpace; // space
    1358           18 :             ort->TableStyle(4) = TableStyle::HTML;
    1359           18 :             ort->del(4) = CharSpace; // space - this is not used much for HTML output
    1360           18 :             ort->TableStyle(5) = TableStyle::XML;
    1361           18 :             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          761 :         if (NumAlphas >= 2) {
    1373           18 :             ort->unitsStyle = SetUnitsStyleFromString(AlphArray(2));
    1374           18 :             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          743 :             ort->unitsStyle = UnitsStyle::None;
    1383          743 :             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          799 :     if (ort->WriteTabularFiles) {
    1395          146 :         print(state.files.eio, "! <Tabular Report>,Style,Unit Conversion\n");
    1396          146 :         if (AlphArray(1) != "HTML") {
    1397           30 :             ConvertCaseToLower(AlphArray(1), AlphArray(2));
    1398           30 :             AlphArray(1).erase(1);
    1399           30 :             AlphArray(1) += AlphArray(2).substr(1);
    1400              :         }
    1401          146 :         print(state.files.eio, "Tabular Report,{},{}\n", AlphArray(1), AlphArray(2));
    1402              :     }
    1403          799 : }
    1404              : 
    1405           18 : UnitsStyle SetUnitsStyleFromString(std::string const &unitStringIn)
    1406              : {
    1407           18 :     UnitsStyle unitsStyleReturn = static_cast<UnitsStyle>(getEnumValue(UnitsStyleNamesUC, Util::makeUPPER(unitStringIn)));
    1408           18 :     if (unitsStyleReturn == UnitsStyle::Invalid) {
    1409            0 :         unitsStyleReturn = UnitsStyle::NotFound;
    1410              :     }
    1411              : 
    1412           18 :     return unitsStyleReturn;
    1413              : }
    1414              : 
    1415          799 : 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         2397 :     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          799 :     auto &ort = state.dataOutRptTab;
    1448          799 :     bool ErrorsFound = false;
    1449              : 
    1450          799 :     if (!state.files.outputControl.writeTabular(state)) {
    1451            1 :         ort->WriteTabularFiles = false;
    1452            1 :         return;
    1453              :     }
    1454              : 
    1455          798 :     int NumTabularPredefined = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, CurrentModuleObject);
    1456          798 :     if (NumTabularPredefined == 1) {
    1457              : 
    1458          758 :         int NumParams = 0;
    1459          758 :         int NumAlphas = 0; // Number of elements in the alpha array
    1460          758 :         int NumNums = 0;   // Number of elements in the numeric array
    1461          758 :         Array1D_string AlphArray;
    1462          758 :         Array1D<Real64> NumArray;
    1463          758 :         int IOStat = -1; // IO Status when calling get input subroutine
    1464              : 
    1465              :         // find out how many fields since the object is extensible
    1466          758 :         state.dataInputProcessing->inputProcessor->getObjectDefMaxArgs(state, CurrentModuleObject, NumParams, NumAlphas, NumNums);
    1467              :         // allocate the temporary arrays for the call to get the filed
    1468          758 :         AlphArray.allocate(NumAlphas);
    1469              :         // don't really need the NumArray since not expecting any numbers but the call requires it
    1470          758 :         NumArray.dimension(NumNums, 0.0);
    1471              :         // get the object
    1472          758 :         state.dataInputProcessing->inputProcessor->getObjectItem(state, CurrentModuleObject, 1, AlphArray, NumAlphas, NumArray, NumNums, IOStat);
    1473              :         // default all report flags to false (do not get produced)
    1474          758 :         ort->displayTabularBEPS = false;
    1475              :         // initialize the names of the predefined monthly report titles
    1476          758 :         InitializePredefinedMonthlyTitles(state);
    1477              :         // loop through the fields looking for matching report titles
    1478         2058 :         for (int iReport = 1; iReport <= NumAlphas; ++iReport) {
    1479         1300 :             bool nameFound = false;
    1480         1300 :             if (AlphArray(iReport).empty()) {
    1481            0 :                 ShowWarningError(state, "Blank report name in Output:Table:SummaryReports");
    1482         1300 :             } else if (Util::SameString(AlphArray(iReport), "AnnualBuildingUtilityPerformanceSummary")) {
    1483           80 :                 ort->displayTabularBEPS = true;
    1484           80 :                 ort->WriteTabularFiles = true;
    1485           80 :                 nameFound = true;
    1486         1220 :             } else if (Util::SameString(AlphArray(iReport), "ComponentCostEconomicsSummary")) {
    1487            9 :                 ort->displayTabularCompCosts = true;
    1488            9 :                 ort->WriteTabularFiles = true;
    1489            9 :                 nameFound = true;
    1490         1211 :             } else if (Util::SameString(AlphArray(iReport), "InputVerificationandResultsSummary")) {
    1491           75 :                 ort->displayTabularVeriSum = true;
    1492           75 :                 ort->WriteTabularFiles = true;
    1493           75 :                 nameFound = true;
    1494         1136 :             } else if (Util::SameString(AlphArray(iReport), "ComponentSizingSummary")) {
    1495           60 :                 ort->displayComponentSizing = true;
    1496           60 :                 ort->WriteTabularFiles = true;
    1497           60 :                 nameFound = true;
    1498         1076 :             } else if (Util::SameString(AlphArray(iReport), "SurfaceShadowingSummary")) {
    1499            0 :                 ort->displaySurfaceShadowing = true;
    1500            0 :                 ort->WriteTabularFiles = true;
    1501            0 :                 nameFound = true;
    1502         1076 :             } else if (Util::SameString(AlphArray(iReport), "DemandEndUseComponentsSummary")) {
    1503            3 :                 ort->displayDemandEndUse = true;
    1504            3 :                 ort->WriteTabularFiles = true;
    1505            3 :                 nameFound = true;
    1506         1073 :             } else if (Util::SameString(AlphArray(iReport), "AdaptiveComfortSummary")) {
    1507            0 :                 ort->displayAdaptiveComfort = true;
    1508            0 :                 ort->WriteTabularFiles = true;
    1509            0 :                 nameFound = true;
    1510         1073 :             } else if (Util::SameString(AlphArray(iReport), "SourceEnergyEndUseComponentsSummary")) {
    1511            0 :                 ort->displaySourceEnergyEndUseSummary = true;
    1512            0 :                 ort->WriteTabularFiles = true;
    1513            0 :                 nameFound = true;
    1514         1073 :             } else if (Util::SameString(AlphArray(iReport), "ZoneComponentLoadSummary")) {
    1515           25 :                 ort->displayZoneComponentLoadSummary = true;
    1516           25 :                 ort->WriteTabularFiles = true;
    1517           25 :                 nameFound = true;
    1518         1048 :             } else if (Util::SameString(AlphArray(iReport), "AirLoopComponentLoadSummary")) {
    1519            0 :                 ort->displayAirLoopComponentLoadSummary = true;
    1520            0 :                 ort->WriteTabularFiles = true;
    1521            0 :                 nameFound = true;
    1522         1048 :             } else if (Util::SameString(AlphArray(iReport), "FacilityComponentLoadSummary")) {
    1523            0 :                 ort->displayFacilityComponentLoadSummary = true;
    1524            0 :                 ort->WriteTabularFiles = true;
    1525            0 :                 nameFound = true;
    1526         1048 :             } else if (Util::SameString(AlphArray(iReport), "LEEDSummary")) {
    1527            0 :                 ort->displayLEEDSummary = true;
    1528            0 :                 ort->WriteTabularFiles = true;
    1529            0 :                 nameFound = true;
    1530         1048 :             } else if (Util::SameString(AlphArray(iReport), "LifeCycleCostReport")) {
    1531            0 :                 ort->displayLifeCycleCostReport = true;
    1532            0 :                 ort->WriteTabularFiles = true;
    1533            0 :                 nameFound = true;
    1534         1048 :             } else if (Util::SameString(AlphArray(iReport), "TariffReport")) {
    1535            0 :                 ort->displayTariffReport = true;
    1536            0 :                 ort->WriteTabularFiles = true;
    1537            0 :                 nameFound = true;
    1538         1048 :             } else if (Util::SameString(AlphArray(iReport), "EconomicResultSummary")) {
    1539            0 :                 ort->displayEconomicResultSummary = true;
    1540            0 :                 ort->WriteTabularFiles = true;
    1541            0 :                 nameFound = true;
    1542         1048 :             } else if (Util::SameString(AlphArray(iReport), "HeatEmissionsSummary")) {
    1543            1 :                 ort->displayHeatEmissionsSummary = true;
    1544            1 :                 ort->WriteTabularFiles = true;
    1545            1 :                 nameFound = true;
    1546         1047 :             } else if (Util::SameString(AlphArray(iReport), "ThermalResilienceSummary")) {
    1547            3 :                 ort->displayThermalResilienceSummary = true;
    1548            3 :                 ort->displayThermalResilienceSummaryExplicitly = true;
    1549            3 :                 ort->WriteTabularFiles = true;
    1550            3 :                 nameFound = true;
    1551         1044 :             } else if (Util::SameString(AlphArray(iReport), "CO2ResilienceSummary")) {
    1552            3 :                 ort->displayCO2ResilienceSummary = true;
    1553            3 :                 ort->displayCO2ResilienceSummaryExplicitly = true;
    1554            3 :                 ort->WriteTabularFiles = true;
    1555            3 :                 nameFound = true;
    1556         1041 :             } else if (Util::SameString(AlphArray(iReport), "VisualResilienceSummary")) {
    1557            3 :                 ort->displayVisualResilienceSummary = true;
    1558            3 :                 ort->displayVisualResilienceSummaryExplicitly = true;
    1559            3 :                 ort->WriteTabularFiles = true;
    1560            3 :                 nameFound = true;
    1561         1038 :             } else if (Util::SameString(AlphArray(iReport), "EnergyMeters")) {
    1562            0 :                 ort->WriteTabularFiles = true;
    1563            0 :                 nameFound = true;
    1564         1038 :             } else if (Util::SameString(AlphArray(iReport), "InitializationSummary")) {
    1565            1 :                 ort->WriteTabularFiles = true;
    1566            1 :                 ort->displayEioSummary = true;
    1567            1 :                 nameFound = true;
    1568         1037 :             } else if (Util::SameString(AlphArray(iReport), "AllSummary")) {
    1569          652 :                 ort->WriteTabularFiles = true;
    1570          652 :                 ort->displayTabularBEPS = true;
    1571          652 :                 ort->displayTabularVeriSum = true;
    1572          652 :                 ort->displayTabularCompCosts = true;
    1573          652 :                 ort->displaySurfaceShadowing = true;
    1574          652 :                 ort->displayComponentSizing = true;
    1575          652 :                 ort->displayDemandEndUse = true;
    1576          652 :                 ort->displayAdaptiveComfort = true;
    1577          652 :                 ort->displaySourceEnergyEndUseSummary = true;
    1578          652 :                 ort->displayLifeCycleCostReport = true;
    1579          652 :                 ort->displayTariffReport = true;
    1580          652 :                 ort->displayEconomicResultSummary = true;
    1581          652 :                 ort->displayEioSummary = true;
    1582          652 :                 ort->displayLEEDSummary = true;
    1583          652 :                 ort->displayHeatEmissionsSummary = true;
    1584          652 :                 ort->displayThermalResilienceSummary = true;
    1585          652 :                 ort->displayCO2ResilienceSummary = true;
    1586          652 :                 ort->displayVisualResilienceSummary = true;
    1587          652 :                 nameFound = true;
    1588        12060 :                 for (int jReport = 1; jReport <= state.dataOutRptPredefined->numReportName; ++jReport) {
    1589        11408 :                     state.dataOutRptPredefined->reportName(jReport).show = true;
    1590              :                 }
    1591          385 :             } else if (Util::SameString(AlphArray(iReport), "AllSummaryAndSizingPeriod")) {
    1592            2 :                 ort->WriteTabularFiles = true;
    1593            2 :                 ort->displayTabularBEPS = true;
    1594            2 :                 ort->displayTabularVeriSum = true;
    1595            2 :                 ort->displayTabularCompCosts = true;
    1596            2 :                 ort->displaySurfaceShadowing = true;
    1597            2 :                 ort->displayComponentSizing = true;
    1598            2 :                 ort->displayDemandEndUse = true;
    1599            2 :                 ort->displayAdaptiveComfort = true;
    1600            2 :                 ort->displaySourceEnergyEndUseSummary = true;
    1601            2 :                 ort->displayLifeCycleCostReport = true;
    1602            2 :                 ort->displayTariffReport = true;
    1603            2 :                 ort->displayEconomicResultSummary = true;
    1604            2 :                 ort->displayEioSummary = true;
    1605            2 :                 ort->displayLEEDSummary = true;
    1606            2 :                 ort->displayHeatEmissionsSummary = true;
    1607            2 :                 ort->displayThermalResilienceSummary = true;
    1608            2 :                 ort->displayCO2ResilienceSummary = true;
    1609            2 :                 ort->displayVisualResilienceSummary = true;
    1610            2 :                 nameFound = true;
    1611           38 :                 for (int jReport = 1; jReport <= state.dataOutRptPredefined->numReportName; ++jReport) {
    1612           36 :                     state.dataOutRptPredefined->reportName(jReport).show = true;
    1613              :                 }
    1614              :                 // the sizing period reports
    1615            2 :                 ort->displayZoneComponentLoadSummary = true;
    1616            2 :                 ort->displayAirLoopComponentLoadSummary = true;
    1617            2 :                 ort->displayFacilityComponentLoadSummary = true;
    1618          383 :             } else if (Util::SameString(AlphArray(iReport), "AllMonthly")) {
    1619            1 :                 ort->WriteTabularFiles = true;
    1620           64 :                 for (int jReport = 1; jReport <= numNamedMonthly; ++jReport) {
    1621           63 :                     ort->namedMonthly(jReport).show = true;
    1622              :                 }
    1623            1 :                 nameFound = true;
    1624          382 :             } else if (Util::SameString(AlphArray(iReport), "AllSummaryAndMonthly")) {
    1625           23 :                 ort->WriteTabularFiles = true;
    1626           23 :                 ort->displayTabularBEPS = true;
    1627           23 :                 ort->displayTabularVeriSum = true;
    1628           23 :                 ort->displayTabularCompCosts = true;
    1629           23 :                 ort->displaySurfaceShadowing = true;
    1630           23 :                 ort->displayComponentSizing = true;
    1631           23 :                 ort->displayDemandEndUse = true;
    1632           23 :                 ort->displayAdaptiveComfort = true;
    1633           23 :                 ort->displaySourceEnergyEndUseSummary = true;
    1634           23 :                 ort->displayLifeCycleCostReport = true;
    1635           23 :                 ort->displayTariffReport = true;
    1636           23 :                 ort->displayEconomicResultSummary = true;
    1637           23 :                 ort->displayEioSummary = true;
    1638           23 :                 ort->displayLEEDSummary = true;
    1639           23 :                 ort->displayHeatEmissionsSummary = true;
    1640           23 :                 ort->displayThermalResilienceSummary = true;
    1641           23 :                 ort->displayCO2ResilienceSummary = true;
    1642           23 :                 ort->displayVisualResilienceSummary = true;
    1643           23 :                 nameFound = true;
    1644          435 :                 for (int jReport = 1; jReport <= state.dataOutRptPredefined->numReportName; ++jReport) {
    1645          412 :                     state.dataOutRptPredefined->reportName(jReport).show = true;
    1646              :                 }
    1647         1472 :                 for (int jReport = 1; jReport <= numNamedMonthly; ++jReport) {
    1648         1449 :                     ort->namedMonthly(jReport).show = true;
    1649              :                 }
    1650          359 :             } 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        24346 :             for (int jReport = 1; jReport <= state.dataOutRptPredefined->numReportName; ++jReport) {
    1683        23046 :                 if (Util::SameString(AlphArray(iReport), state.dataOutRptPredefined->reportName(jReport).name)) {
    1684          362 :                     ort->WriteTabularFiles = true;
    1685          362 :                     state.dataOutRptPredefined->reportName(jReport).show = true;
    1686          362 :                     nameFound = true;
    1687              :                 }
    1688        23046 :                 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        83200 :             for (int jReport = 1; jReport <= numNamedMonthly; ++jReport) {
    1696        81900 :                 if (Util::SameString(AlphArray(iReport), ort->namedMonthly(jReport).title)) {
    1697            3 :                     ort->namedMonthly(jReport).show = true;
    1698            3 :                     ort->WriteTabularFiles = true;
    1699            3 :                     nameFound = true;
    1700              :                 }
    1701              :             }
    1702         1300 :             if (!nameFound) {
    1703            0 :                 if (Util::SameString(AlphArray(iReport), "Standard62.1Summary")) {
    1704            0 :                     ShowWarningError(state, format("{} Field[{}]=\"Standard62.1Summary\", Report is not enabled.", CurrentModuleObject, iReport));
    1705            0 :                     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          758 :         CreatePredefinedMonthlyReports(state);
    1717          798 :     } else if (NumTabularPredefined > 1) {
    1718            0 :         ShowSevereError(state, format("{}: Only one instance of this object is allowed.", CurrentModuleObject));
    1719            0 :         ErrorsFound = true;
    1720              :     }
    1721          798 :     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          798 :     if (ort->displayTabularBEPS || ort->displayDemandEndUse || ort->displaySourceEnergyEndUseSummary || ort->displayLEEDSummary) {
    1726              :         // initialize the resource type names
    1727          757 :         ort->resourceTypeNames(1) = Constant::eResourceNames[static_cast<int>(Constant::eResource::Electricity)];
    1728          757 :         ort->resourceTypeNames(2) = Constant::eResourceNames[static_cast<int>(Constant::eResource::NaturalGas)];
    1729          757 :         ort->resourceTypeNames(3) = Constant::eResourceNames[static_cast<int>(Constant::eResource::DistrictCooling)];
    1730          757 :         ort->resourceTypeNames(4) = Constant::eResourceNames[static_cast<int>(Constant::eResource::DistrictHeatingWater)];
    1731          757 :         ort->resourceTypeNames(5) = Constant::eResourceNames[static_cast<int>(Constant::eResource::DistrictHeatingSteam)];
    1732          757 :         ort->resourceTypeNames(6) = Constant::eResourceNames[static_cast<int>(Constant::eResource::Gasoline)];
    1733          757 :         ort->resourceTypeNames(7) = Constant::eResourceNames[static_cast<int>(Constant::eResource::Water)];
    1734          757 :         ort->resourceTypeNames(8) = Constant::eResourceNames[static_cast<int>(Constant::eResource::Diesel)];
    1735          757 :         ort->resourceTypeNames(9) = Constant::eResourceNames[static_cast<int>(Constant::eResource::Coal)];
    1736          757 :         ort->resourceTypeNames(10) = Constant::eResourceNames[static_cast<int>(Constant::eResource::FuelOilNo1)];
    1737          757 :         ort->resourceTypeNames(11) = Constant::eResourceNames[static_cast<int>(Constant::eResource::FuelOilNo2)];
    1738          757 :         ort->resourceTypeNames(12) = Constant::eResourceNames[static_cast<int>(Constant::eResource::Propane)];
    1739          757 :         ort->resourceTypeNames(13) = Constant::eResourceNames[static_cast<int>(Constant::eResource::OtherFuel1)];
    1740          757 :         ort->resourceTypeNames(14) = Constant::eResourceNames[static_cast<int>(Constant::eResource::OtherFuel2)];
    1741              : 
    1742          757 :         ort->sourceTypeNames(1) = "Electricity";
    1743          757 :         ort->sourceTypeNames(2) = "NaturalGas";
    1744          757 :         ort->sourceTypeNames(3) = "Gasoline";
    1745          757 :         ort->sourceTypeNames(4) = "Diesel";
    1746          757 :         ort->sourceTypeNames(5) = "Coal";
    1747          757 :         ort->sourceTypeNames(6) = "FuelOilNo1";
    1748          757 :         ort->sourceTypeNames(7) = "FuelOilNo2";
    1749          757 :         ort->sourceTypeNames(8) = "Propane";
    1750          757 :         ort->sourceTypeNames(9) = "PurchasedElectricity";
    1751          757 :         ort->sourceTypeNames(10) = "SoldElectricity";
    1752          757 :         ort->sourceTypeNames(11) = "OtherFuel1";
    1753          757 :         ort->sourceTypeNames(12) = "OtherFuel2";
    1754              : 
    1755              :         // initialize the end use names
    1756          757 :         ort->endUseNames(static_cast<int>(Constant::EndUse::Heating) + 1) = "Heating";
    1757          757 :         ort->endUseNames(static_cast<int>(Constant::EndUse::Cooling) + 1) = "Cooling";
    1758          757 :         ort->endUseNames(static_cast<int>(Constant::EndUse::InteriorLights) + 1) = "InteriorLights";
    1759          757 :         ort->endUseNames(static_cast<int>(Constant::EndUse::ExteriorLights) + 1) = "ExteriorLights";
    1760          757 :         ort->endUseNames(static_cast<int>(Constant::EndUse::InteriorEquipment) + 1) = "InteriorEquipment";
    1761          757 :         ort->endUseNames(static_cast<int>(Constant::EndUse::ExteriorEquipment) + 1) = "ExteriorEquipment";
    1762          757 :         ort->endUseNames(static_cast<int>(Constant::EndUse::Fans) + 1) = "Fans";
    1763          757 :         ort->endUseNames(static_cast<int>(Constant::EndUse::Pumps) + 1) = "Pumps";
    1764          757 :         ort->endUseNames(static_cast<int>(Constant::EndUse::HeatRejection) + 1) = "HeatRejection";
    1765          757 :         ort->endUseNames(static_cast<int>(Constant::EndUse::Humidification) + 1) = "Humidifier";
    1766          757 :         ort->endUseNames(static_cast<int>(Constant::EndUse::HeatRecovery) + 1) = "HeatRecovery";
    1767          757 :         ort->endUseNames(static_cast<int>(Constant::EndUse::WaterSystem) + 1) = "WaterSystems";
    1768          757 :         ort->endUseNames(static_cast<int>(Constant::EndUse::Refrigeration) + 1) = "Refrigeration";
    1769          757 :         ort->endUseNames(static_cast<int>(Constant::EndUse::Cogeneration) + 1) = "Cogeneration";
    1770              : 
    1771          757 :         auto &op = state.dataOutputProcessor;
    1772              :         // End use subs must be dynamically allocated to accommodate the end use with the most subcategories
    1773          757 :         ort->meterNumEndUseSubBEPS.allocate(op->MaxNumSubcategories, static_cast<int>(Constant::EndUse::Num), numResourceTypes);
    1774          757 :         ort->meterNumEndUseSpTypeBEPS.allocate(op->maxNumEndUseSpaceTypes, static_cast<int>(Constant::EndUse::Num), numResourceTypes);
    1775        11355 :         for (int endUse = 1; endUse <= static_cast<int>(Constant::EndUse::Num); ++endUse) {
    1776       158970 :             for (int resType = 1; resType <= numResourceTypes; ++resType) {
    1777       432180 :                 for (int subCat = 1; subCat <= op->MaxNumSubcategories; ++subCat) {
    1778       283808 :                     ort->meterNumEndUseSubBEPS(subCat, endUse, resType) = -1;
    1779              :                 }
    1780       299096 :                 for (int spType = 1; spType <= op->maxNumEndUseSpaceTypes; ++spType) {
    1781       150724 :                     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        11355 :         for (int iResource = 1; iResource <= numResourceTypes; ++iResource) {
    1788        10598 :             std::string meterName = format("{}:FACILITY", ort->resourceTypeNames(iResource));
    1789        10598 :             int meterNumber = GetMeterIndex(state, Util::makeUPPER(meterName));
    1790        10598 :             ort->meterNumTotalsBEPS(iResource) = meterNumber;
    1791              : 
    1792       158970 :             for (int jEndUse = 1; jEndUse <= static_cast<int>(Constant::EndUse::Num); ++jEndUse) {
    1793       148372 :                 meterName = format("{}:{}", ort->endUseNames(jEndUse), ort->resourceTypeNames(iResource)); //// ':FACILITY'
    1794       148372 :                 meterNumber = GetMeterIndex(state, Util::makeUPPER(meterName));
    1795       148372 :                 ort->meterNumEndUseBEPS(iResource, jEndUse) = meterNumber;
    1796              : 
    1797       236796 :                 for (int kEndUseSub = 1; kEndUseSub <= op->EndUseCategory(jEndUse).NumSubcategories; ++kEndUseSub) {
    1798       353696 :                     meterName = format("{}:{}:{}",
    1799        88424 :                                        op->EndUseCategory(jEndUse).SubcategoryName(kEndUseSub),
    1800        88424 :                                        ort->endUseNames(jEndUse),
    1801       176848 :                                        ort->resourceTypeNames(iResource));
    1802        88424 :                     meterNumber = GetMeterIndex(state, Util::makeUPPER(meterName));
    1803        88424 :                     ort->meterNumEndUseSubBEPS(kEndUseSub, jEndUse, iResource) = meterNumber;
    1804              :                 }
    1805       166838 :                 for (int kEndUseSpType = 1; kEndUseSpType <= op->EndUseCategory(jEndUse).numSpaceTypes; ++kEndUseSpType) {
    1806        55398 :                     meterName = format("{}:{}:SpaceType:{}",
    1807        18466 :                                        ort->endUseNames(jEndUse),
    1808        18466 :                                        ort->resourceTypeNames(iResource),
    1809        36932 :                                        op->EndUseCategory(jEndUse).spaceTypeName(kEndUseSpType));
    1810        18466 :                     meterNumber = GetMeterIndex(state, Util::makeUPPER(meterName));
    1811        18466 :                     ort->meterNumEndUseSpTypeBEPS(kEndUseSpType, jEndUse, iResource) = meterNumber;
    1812              :                 }
    1813              :             }
    1814        10598 :         }
    1815              : 
    1816         9841 :         for (int iResource = 1; iResource <= numSourceTypes; ++iResource) {
    1817         9084 :             int const meterNumber = GetMeterIndex(state, Util::makeUPPER(format("{}Emissions:Source", ort->sourceTypeNames(iResource))));
    1818         9084 :             ort->meterNumTotalsSource(iResource) = meterNumber;
    1819              :         }
    1820              : 
    1821              :         // initialize the gathering arrays to zero
    1822          757 :         ort->gatherTotalsBEPS = 0.0;
    1823          757 :         ort->gatherTotalsBySourceBEPS = 0.0;
    1824          757 :         ort->gatherTotalsSource = 0.0;
    1825          757 :         ort->gatherTotalsBySource = 0.0;
    1826          757 :         ort->gatherEndUseBEPS = 0.0;
    1827          757 :         ort->gatherEndUseBySourceBEPS = 0.0;
    1828              :         // End use subs must be dynamically allocated to accommodate the end use with the most subcategories
    1829          757 :         ort->gatherEndUseSubBEPS.allocate(op->MaxNumSubcategories, static_cast<int>(Constant::EndUse::Num), numResourceTypes);
    1830          757 :         ort->gatherEndUseSubBEPS = 0.0;
    1831          757 :         ort->gatherEndUseSpTypeBEPS.allocate(op->maxNumEndUseSpaceTypes, static_cast<int>(Constant::EndUse::Num), numResourceTypes);
    1832          757 :         ort->gatherEndUseSpTypeBEPS = 0.0;
    1833          757 :         ort->gatherDemandEndUseSub.allocate(op->MaxNumSubcategories, static_cast<int>(Constant::EndUse::Num), numResourceTypes);
    1834          757 :         ort->gatherDemandEndUseSub = 0.0;
    1835          757 :         ort->gatherDemandIndEndUseSub.allocate(op->MaxNumSubcategories, static_cast<int>(Constant::EndUse::Num), numResourceTypes);
    1836          757 :         ort->gatherDemandIndEndUseSub = 0.0;
    1837              : 
    1838              :         // get meter numbers for other meters relating to electric load components
    1839         1514 :         ort->meterNumPowerFuelFireGen = GetMeterIndex(state, "COGENERATION:ELECTRICITYPRODUCED");
    1840         1514 :         ort->meterNumPowerPV = GetMeterIndex(state, "PHOTOVOLTAIC:ELECTRICITYPRODUCED");
    1841         1514 :         ort->meterNumPowerWind = GetMeterIndex(state, "WINDTURBINE:ELECTRICITYPRODUCED");
    1842         1514 :         ort->meterNumPowerHTGeothermal = GetMeterIndex(state, "HTGEOTHERMAL:ELECTRICITYPRODUCED");
    1843         1514 :         ort->meterNumElecStorage = GetMeterIndex(state, "ELECTRICSTORAGE:ELECTRICITYPRODUCED");
    1844         1514 :         ort->meterNumPowerConversion = GetMeterIndex(state, "POWERCONVERSION:ELECTRICITYPRODUCED");
    1845         1514 :         ort->meterNumElecProduced = GetMeterIndex(state, "ELECTRICITYPRODUCED:FACILITY");
    1846         1514 :         ort->meterNumElecPurchased = GetMeterIndex(state, "ELECTRICITYPURCHASED:FACILITY");
    1847          757 :         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          757 :         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          757 :         ort->gatherPowerFuelFireGen = 0.0;
    1857          757 :         ort->gatherPowerPV = 0.0;
    1858          757 :         ort->gatherPowerWind = 0.0;
    1859          757 :         ort->gatherPowerHTGeothermal = 0.0;
    1860          757 :         ort->gatherElecProduced = 0.0;
    1861          757 :         ort->gatherElecPurchased = 0.0;
    1862          757 :         ort->gatherElecSurplusSold = 0.0;
    1863          757 :         ort->gatherElecStorage = 0.0;
    1864          757 :         ort->gatherPowerConversion = 0.0;
    1865              : 
    1866              :         // get meter numbers for onsite thermal components on BEPS report
    1867         1514 :         ort->meterNumWaterHeatRecovery = GetMeterIndex(state, "HEATRECOVERY:ENERGYTRANSFER");
    1868         1514 :         ort->meterNumAirHeatRecoveryCool = GetMeterIndex(state, "HEATRECOVERYFORCOOLING:ENERGYTRANSFER");
    1869         1514 :         ort->meterNumAirHeatRecoveryHeat = GetMeterIndex(state, "HEATRECOVERYFORHEATING:ENERGYTRANSFER");
    1870         1514 :         ort->meterNumHeatHTGeothermal = GetMeterIndex(state, "HTGEOTHERMAL:HEATPRODUCED");
    1871         1514 :         ort->meterNumHeatSolarWater = GetMeterIndex(state, "SOLARWATER:FACILITY");
    1872          757 :         ort->meterNumHeatSolarAir = GetMeterIndex(state, "HEATPRODUCED:SOLARAIR");
    1873              :         // initialize the gathering variables for onsite thermal components on BEPS report
    1874          757 :         ort->gatherWaterHeatRecovery = 0.0;
    1875          757 :         ort->gatherAirHeatRecoveryCool = 0.0;
    1876          757 :         ort->gatherAirHeatRecoveryHeat = 0.0;
    1877          757 :         ort->gatherHeatHTGeothermal = 0.0;
    1878          757 :         ort->gatherHeatSolarWater = 0.0;
    1879          757 :         ort->gatherHeatSolarAir = 0.0;
    1880              : 
    1881              :         // get meter numbers for water components on BEPS report
    1882         1514 :         ort->meterNumRainWater = GetMeterIndex(state, "RAINWATER:ONSITEWATER");
    1883         1514 :         ort->meterNumCondensate = GetMeterIndex(state, "CONDENSATE:ONSITEWATER");
    1884         1514 :         ort->meterNumGroundwater = GetMeterIndex(state, "WELLWATER:ONSITEWATER");
    1885         1514 :         ort->meterNumMains = GetMeterIndex(state, "MAINSWATER:FACILITY");
    1886          757 :         ort->meterNumWaterEndUseTotal = GetMeterIndex(state, "WATER:FACILITY");
    1887              : 
    1888              :         // initialize the gathering variables for water components on BEPS report
    1889          757 :         ort->gatherRainWater = 0.0;
    1890          757 :         ort->gatherCondensate = 0.0;
    1891          757 :         ort->gatherWellwater = 0.0;
    1892          757 :         ort->gatherMains = 0.0;
    1893          757 :         ort->gatherWaterEndUseTotal = 0.0;
    1894              :     }
    1895              : }
    1896              : 
    1897          801 : 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         2403 :     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          801 :     bool isFound = false;
    1936              : 
    1937          801 :     int const NumTabularPredefined = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, CurrentModuleObject);
    1938          801 :     if (NumTabularPredefined == 1) {
    1939              : 
    1940          761 :         int NumParams = 0;
    1941          761 :         int NumAlphas = 0; // Number of elements in the alpha array
    1942          761 :         int NumNums = 0;   // Number of elements in the numeric array
    1943          761 :         Array1D_string AlphArray;
    1944          761 :         Array1D<Real64> NumArray;
    1945          761 :         int IOStat = -1; // IO Status when calling get input subroutine
    1946              : 
    1947              :         // find out how many fields since the object is extensible
    1948          761 :         state.dataInputProcessing->inputProcessor->getObjectDefMaxArgs(state, CurrentModuleObject, NumParams, NumAlphas, NumNums);
    1949              :         // allocate the temporary arrays for the call to get the filed
    1950          761 :         AlphArray.allocate(NumAlphas);
    1951              :         // don't really need the NumArray since not expecting any numbers but the call requires it
    1952          761 :         NumArray.dimension(NumNums, 0.0);
    1953              :         // get the object
    1954          761 :         state.dataInputProcessing->inputProcessor->getObjectItem(state, CurrentModuleObject, 1, AlphArray, NumAlphas, NumArray, NumNums, IOStat);
    1955              :         // loop through the fields looking for matching report titles
    1956         2085 :         for (int iReport = 1; iReport <= NumAlphas; ++iReport) {
    1957         1324 :             if (Util::SameString(AlphArray(iReport), "ZoneComponentLoadSummary")) {
    1958           25 :                 isFound = true;
    1959              :             }
    1960         1324 :             if (Util::SameString(AlphArray(iReport), "AirLoopComponentLoadSummary")) {
    1961            0 :                 isFound = true;
    1962              :             }
    1963         1324 :             if (Util::SameString(AlphArray(iReport), "FacilityComponentLoadSummary")) {
    1964            0 :                 isFound = true;
    1965              :             }
    1966         1324 :             if (Util::SameString(AlphArray(iReport), "AllSummaryAndSizingPeriod")) {
    1967            2 :                 isFound = true;
    1968              :             }
    1969         1324 :             if (Util::SameString(AlphArray(iReport), "AllSummaryMonthlyAndSizingPeriod")) {
    1970            0 :                 isFound = true;
    1971              :             }
    1972              :         }
    1973          761 :     }
    1974          801 :     isCompLoadRepReq = isFound; // return true if either report was found
    1975          801 :     return isCompLoadRepReq;
    1976              : }
    1977              : 
    1978          801 : bool hasSizingPeriodsDays(EnergyPlusData &state)
    1979              : {
    1980          801 :     int const sizePerDesDays = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "SizingPeriod:DesignDay");
    1981          801 :     int const sizePerWeathFileDays = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "SizingPeriod:WeatherFileDays");
    1982          801 :     return ((sizePerDesDays + sizePerWeathFileDays) > 0);
    1983              : }
    1984              : 
    1985          758 : 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          758 :     auto &ort = state.dataOutRptTab;
    2019              : 
    2020          758 :     ort->namedMonthly.allocate(numNamedMonthly);
    2021          758 :     ort->namedMonthly(1).title = "ZoneCoolingSummaryMonthly";
    2022          758 :     ort->namedMonthly(2).title = "ZoneHeatingSummaryMonthly";
    2023          758 :     ort->namedMonthly(3).title = "ZoneElectricSummaryMonthly";
    2024          758 :     ort->namedMonthly(4).title = "SpaceGainsMonthly";
    2025          758 :     ort->namedMonthly(5).title = "PeakSpaceGainsMonthly";
    2026          758 :     ort->namedMonthly(6).title = "SpaceGainComponentsAtCoolingPeakMonthly";
    2027          758 :     ort->namedMonthly(7).title = "EnergyConsumptionElectricityNaturalGasMonthly";
    2028          758 :     ort->namedMonthly(8).title = "EnergyConsumptionElectricityGeneratedPropaneMonthly";
    2029          758 :     ort->namedMonthly(9).title = "EnergyConsumptionDieselFuelOilMonthly";
    2030          758 :     ort->namedMonthly(10).title = "EnergyConsumptionDistrictHeatingCoolingMonthly";
    2031          758 :     ort->namedMonthly(11).title = "EnergyConsumptionCoalGasolineMonthly";
    2032          758 :     ort->namedMonthly(12).title = "EnergyConsumptionOtherFuelsMonthly";
    2033          758 :     ort->namedMonthly(13).title = "EndUseEnergyConsumptionElectricityMonthly";
    2034          758 :     ort->namedMonthly(14).title = "EndUseEnergyConsumptionNaturalGasMonthly";
    2035          758 :     ort->namedMonthly(15).title = "EndUseEnergyConsumptionDieselMonthly";
    2036          758 :     ort->namedMonthly(16).title = "EndUseEnergyConsumptionFuelOilMonthly";
    2037          758 :     ort->namedMonthly(17).title = "EndUseEnergyConsumptionCoalMonthly";
    2038          758 :     ort->namedMonthly(18).title = "EndUseEnergyConsumptionPropaneMonthly";
    2039          758 :     ort->namedMonthly(19).title = "EndUseEnergyConsumptionGasolineMonthly";
    2040          758 :     ort->namedMonthly(20).title = "EndUseEnergyConsumptionOtherFuelsMonthly";
    2041          758 :     ort->namedMonthly(21).title = "PeakEnergyEndUseElectricityPart1Monthly";
    2042          758 :     ort->namedMonthly(22).title = "PeakEnergyEndUseElectricityPart2Monthly";
    2043          758 :     ort->namedMonthly(23).title = "ElectricComponentsOfPeakDemandMonthly";
    2044          758 :     ort->namedMonthly(24).title = "PeakEnergyEndUseNaturalGasMonthly";
    2045          758 :     ort->namedMonthly(25).title = "PeakEnergyEndUseDieselMonthly";
    2046          758 :     ort->namedMonthly(26).title = "PeakEnergyEndUseFuelOilMonthly";
    2047          758 :     ort->namedMonthly(27).title = "PeakEnergyEndUseCoalMonthly";
    2048          758 :     ort->namedMonthly(28).title = "PeakEnergyEndUsePropaneMonthly";
    2049          758 :     ort->namedMonthly(29).title = "PeakEnergyEndUseGasolineMonthly";
    2050          758 :     ort->namedMonthly(30).title = "PeakEnergyEndUseOtherFuelsMonthly";
    2051          758 :     ort->namedMonthly(31).title = "SetpointsNotMetWithTemperaturesMonthly";
    2052          758 :     ort->namedMonthly(32).title = "ComfortReportSimple55Monthly";
    2053          758 :     ort->namedMonthly(33).title = "UnglazedTranspiredSolarCollectorSummaryMonthly";
    2054          758 :     ort->namedMonthly(34).title = "OccupantComfortDataSummaryMonthly";
    2055          758 :     ort->namedMonthly(35).title = "ChillerReportMonthly";
    2056          758 :     ort->namedMonthly(36).title = "TowerReportMonthly";
    2057          758 :     ort->namedMonthly(37).title = "BoilerReportMonthly";
    2058          758 :     ort->namedMonthly(38).title = "DXReportMonthly";
    2059          758 :     ort->namedMonthly(39).title = "WindowReportMonthly";
    2060          758 :     ort->namedMonthly(40).title = "WindowEnergyReportMonthly";
    2061          758 :     ort->namedMonthly(41).title = "WindowZoneSummaryMonthly";
    2062          758 :     ort->namedMonthly(42).title = "WindowEnergyZoneSummaryMonthly";
    2063          758 :     ort->namedMonthly(43).title = "AverageOutdoorConditionsMonthly";
    2064          758 :     ort->namedMonthly(44).title = "OutdoorConditionsMaximumDryBulbMonthly";
    2065          758 :     ort->namedMonthly(45).title = "OutdoorConditionsMinimumDryBulbMonthly";
    2066          758 :     ort->namedMonthly(46).title = "OutdoorConditionsMaximumWetBulbMonthly";
    2067          758 :     ort->namedMonthly(47).title = "OutdoorConditionsMaximumDewPointMonthly";
    2068          758 :     ort->namedMonthly(48).title = "OutdoorGroundConditionsMonthly";
    2069          758 :     ort->namedMonthly(49).title = "WindowACReportMonthly";
    2070          758 :     ort->namedMonthly(50).title = "WaterHeaterReportMonthly";
    2071          758 :     ort->namedMonthly(51).title = "GeneratorReportMonthly";
    2072          758 :     ort->namedMonthly(52).title = "DaylightingReportMonthly";
    2073          758 :     ort->namedMonthly(53).title = "CoilReportMonthly";
    2074          758 :     ort->namedMonthly(54).title = "PlantLoopDemandReportMonthly";
    2075          758 :     ort->namedMonthly(55).title = "FanReportMonthly";
    2076          758 :     ort->namedMonthly(56).title = "PumpReportMonthly";
    2077          758 :     ort->namedMonthly(57).title = "CondLoopDemandReportMonthly";
    2078          758 :     ort->namedMonthly(58).title = "ZoneTemperatureOscillationReportMonthly";
    2079          758 :     ort->namedMonthly(59).title = "AirLoopSystemEnergyAndWaterUseMonthly";
    2080          758 :     ort->namedMonthly(60).title = "AirLoopSystemComponentLoadsMonthly";
    2081          758 :     ort->namedMonthly(61).title = "AirLoopSystemComponentEnergyUseMonthly";
    2082          758 :     ort->namedMonthly(62).title = "MechanicalVentilationLoadsMonthly";
    2083          758 :     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        48512 :         for (int xcount = 1; xcount <= numNamedMonthly; ++xcount) {
    2093        47754 :             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          758 : }
    2103              : 
    2104          758 : 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          758 :     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          758 :     if (ort->namedMonthly(1).show) {
    2145           48 :         curReport = AddMonthlyReport(state, "ZoneCoolingSummaryMonthly", 2, true);
    2146           96 :         AddMonthlyFieldSetInput(state, curReport, "Zone Air System Sensible Cooling Energy", "", AggType::SumOrAvg);
    2147           96 :         AddMonthlyFieldSetInput(state, curReport, "Zone Air System Sensible Cooling Rate", "", AggType::Maximum);
    2148           96 :         AddMonthlyFieldSetInput(state, curReport, "Site Outdoor Air Drybulb Temperature", "", AggType::ValueWhenMaxMin);
    2149           96 :         AddMonthlyFieldSetInput(state, curReport, "Site Outdoor Air Wetbulb Temperature", "", AggType::ValueWhenMaxMin);
    2150           96 :         AddMonthlyFieldSetInput(state, curReport, "Zone Total Internal Latent Gain Energy", "", AggType::SumOrAvg);
    2151           96 :         AddMonthlyFieldSetInput(state, curReport, "Zone Total Internal Latent Gain Rate", "", AggType::Maximum);
    2152           96 :         AddMonthlyFieldSetInput(state, curReport, "Site Outdoor Air Drybulb Temperature", "", AggType::ValueWhenMaxMin);
    2153           96 :         AddMonthlyFieldSetInput(state, curReport, "Site Outdoor Air Wetbulb Temperature", "", AggType::ValueWhenMaxMin);
    2154              :     }
    2155          758 :     if (ort->namedMonthly(2).show) {
    2156           48 :         curReport = AddMonthlyReport(state, "ZoneHeatingSummaryMonthly", 2, true);
    2157           96 :         AddMonthlyFieldSetInput(state, curReport, "Zone Air System Sensible Heating Energy", "", AggType::SumOrAvg);
    2158           96 :         AddMonthlyFieldSetInput(state, curReport, "Zone Air System Sensible Heating Rate", "", AggType::Maximum);
    2159           96 :         AddMonthlyFieldSetInput(state, curReport, "Site Outdoor Air Drybulb Temperature", "", AggType::ValueWhenMaxMin);
    2160              :     }
    2161          758 :     if (ort->namedMonthly(3).show) {
    2162           50 :         curReport = AddMonthlyReport(state, "ZoneElectricSummaryMonthly", 2, true);
    2163          100 :         AddMonthlyFieldSetInput(state, curReport, "Zone Lights Electricity Energy", "", AggType::SumOrAvg);
    2164          100 :         AddMonthlyFieldSetInput(state, curReport, "Zone Lights Electricity Energy", "", AggType::Maximum);
    2165          100 :         AddMonthlyFieldSetInput(state, curReport, "Zone Electric Equipment Electricity Energy", "", AggType::SumOrAvg);
    2166          100 :         AddMonthlyFieldSetInput(state, curReport, "Zone Electric Equipment Electricity Energy", "", AggType::Maximum);
    2167              :     }
    2168          758 :     if (ort->namedMonthly(4).show) {
    2169           48 :         curReport = AddMonthlyReport(state, "SpaceGainsMonthly", 2, true);
    2170           96 :         AddMonthlyFieldSetInput(state, curReport, "Zone People Total Heating Energy", "", AggType::SumOrAvg);
    2171           96 :         AddMonthlyFieldSetInput(state, curReport, "Zone Lights Total Heating Energy", "", AggType::SumOrAvg);
    2172           96 :         AddMonthlyFieldSetInput(state, curReport, "Zone Electric Equipment Total Heating Energy", "", AggType::SumOrAvg);
    2173           96 :         AddMonthlyFieldSetInput(state, curReport, "Zone Gas Equipment Total Heating Energy", "", AggType::SumOrAvg);
    2174           96 :         AddMonthlyFieldSetInput(state, curReport, "Zone Hot Water Equipment Total Heating Energy", "", AggType::SumOrAvg);
    2175           96 :         AddMonthlyFieldSetInput(state, curReport, "Zone Steam Equipment Total Heating Energy", "", AggType::SumOrAvg);
    2176           96 :         AddMonthlyFieldSetInput(state, curReport, "Zone Other Equipment Total Heating Energy", "", AggType::SumOrAvg);
    2177           96 :         AddMonthlyFieldSetInput(state, curReport, "Zone Infiltration Sensible Heat Gain Energy", "", AggType::SumOrAvg);
    2178           96 :         AddMonthlyFieldSetInput(state, curReport, "Zone Infiltration Sensible Heat Loss Energy", "", AggType::SumOrAvg);
    2179              :     }
    2180          758 :     if (ort->namedMonthly(5).show) {
    2181           48 :         curReport = AddMonthlyReport(state, "PeakSpaceGainsMonthly", 2, true);
    2182           96 :         AddMonthlyFieldSetInput(state, curReport, "Zone People Total Heating Energy", "", AggType::Maximum);
    2183           96 :         AddMonthlyFieldSetInput(state, curReport, "Zone Lights Total Heating Energy", "", AggType::Maximum);
    2184           96 :         AddMonthlyFieldSetInput(state, curReport, "Zone Electric Equipment Total Heating Energy", "", AggType::Maximum);
    2185           96 :         AddMonthlyFieldSetInput(state, curReport, "Zone Gas Equipment Total Heating Energy", "", AggType::Maximum);
    2186           96 :         AddMonthlyFieldSetInput(state, curReport, "Zone Hot Water Equipment Total Heating Energy", "", AggType::Maximum);
    2187           96 :         AddMonthlyFieldSetInput(state, curReport, "Zone Steam Equipment Total Heating Energy", "", AggType::Maximum);
    2188           96 :         AddMonthlyFieldSetInput(state, curReport, "Zone Other Equipment Total Heating Energy", "", AggType::Maximum);
    2189           96 :         AddMonthlyFieldSetInput(state, curReport, "Zone Infiltration Sensible Heat Gain Energy", "", AggType::Maximum);
    2190           96 :         AddMonthlyFieldSetInput(state, curReport, "Zone Infiltration Sensible Heat Loss Energy", "", AggType::Maximum);
    2191              :     }
    2192          758 :     if (ort->namedMonthly(6).show) {
    2193           48 :         curReport = AddMonthlyReport(state, "SpaceGainComponentsAtCoolingPeakMonthly", 2, true);
    2194           96 :         AddMonthlyFieldSetInput(state, curReport, "Zone Air System Sensible Cooling Rate", "", AggType::Maximum);
    2195           96 :         AddMonthlyFieldSetInput(state, curReport, "Zone People Total Heating Energy", "", AggType::ValueWhenMaxMin);
    2196           96 :         AddMonthlyFieldSetInput(state, curReport, "Zone Lights Total Heating Energy", "", AggType::ValueWhenMaxMin);
    2197           96 :         AddMonthlyFieldSetInput(state, curReport, "Zone Electric Equipment Total Heating Energy", "", AggType::ValueWhenMaxMin);
    2198           96 :         AddMonthlyFieldSetInput(state, curReport, "Zone Gas Equipment Total Heating Energy", "", AggType::ValueWhenMaxMin);
    2199           96 :         AddMonthlyFieldSetInput(state, curReport, "Zone Hot Water Equipment Total Heating Energy", "", AggType::ValueWhenMaxMin);
    2200           96 :         AddMonthlyFieldSetInput(state, curReport, "Zone Steam Equipment Total Heating Energy", "", AggType::ValueWhenMaxMin);
    2201           96 :         AddMonthlyFieldSetInput(state, curReport, "Zone Other Equipment Total Heating Energy", "", AggType::ValueWhenMaxMin);
    2202           96 :         AddMonthlyFieldSetInput(state, curReport, "Zone Infiltration Sensible Heat Gain Energy", "", AggType::ValueWhenMaxMin);
    2203           96 :         AddMonthlyFieldSetInput(state, curReport, "Zone Infiltration Sensible Heat Loss Energy", "", AggType::ValueWhenMaxMin);
    2204              :     }
    2205          758 :     if (ort->namedMonthly(7).show) {
    2206           48 :         curReport = AddMonthlyReport(state, "EnergyConsumptionElectricityNaturalGasMonthly", 2, true);
    2207           96 :         AddMonthlyFieldSetInput(state, curReport, "Electricity:Facility", "", AggType::SumOrAvg);
    2208           96 :         AddMonthlyFieldSetInput(state, curReport, "Electricity:Facility", "", AggType::Maximum);
    2209           96 :         AddMonthlyFieldSetInput(state, curReport, "NaturalGas:Facility", "", AggType::SumOrAvg);
    2210           96 :         AddMonthlyFieldSetInput(state, curReport, "NaturalGas:Facility", "", AggType::Maximum);
    2211              :     }
    2212          758 :     if (ort->namedMonthly(8).show) {
    2213           48 :         curReport = AddMonthlyReport(state, "EnergyConsumptionElectricityGeneratedPropaneMonthly", 2, true);
    2214           96 :         AddMonthlyFieldSetInput(state, curReport, "ElectricityProduced:Facility", "", AggType::SumOrAvg);
    2215           96 :         AddMonthlyFieldSetInput(state, curReport, "ElectricityProduced:Facility", "", AggType::Maximum);
    2216           96 :         AddMonthlyFieldSetInput(state, curReport, "Propane:Facility", "", AggType::SumOrAvg);
    2217           96 :         AddMonthlyFieldSetInput(state, curReport, "Propane:Facility", "", AggType::Maximum);
    2218              :     }
    2219          758 :     if (ort->namedMonthly(9).show) {
    2220           48 :         curReport = AddMonthlyReport(state, "EnergyConsumptionDieselFuelOilMonthly", 2, true);
    2221           96 :         AddMonthlyFieldSetInput(state, curReport, "Diesel:Facility", "", AggType::SumOrAvg);
    2222           96 :         AddMonthlyFieldSetInput(state, curReport, "Diesel:Facility", "", AggType::Maximum);
    2223           96 :         AddMonthlyFieldSetInput(state, curReport, "FuelOilNo1:Facility", "", AggType::SumOrAvg);
    2224           96 :         AddMonthlyFieldSetInput(state, curReport, "FuelOilNo1:Facility", "", AggType::Maximum);
    2225           96 :         AddMonthlyFieldSetInput(state, curReport, "FuelOilNo2:Facility", "", AggType::SumOrAvg);
    2226           96 :         AddMonthlyFieldSetInput(state, curReport, "FuelOilNo2:Facility", "", AggType::Maximum);
    2227              :     }
    2228          758 :     if (ort->namedMonthly(10).show) {
    2229           48 :         curReport = AddMonthlyReport(state, "EnergyConsumptionDistrictHeatingCoolingMonthly", 2, true);
    2230           96 :         AddMonthlyFieldSetInput(state, curReport, "DistrictCooling:Facility", "", AggType::SumOrAvg);
    2231           96 :         AddMonthlyFieldSetInput(state, curReport, "DistrictCooling:Facility", "", AggType::Maximum);
    2232           96 :         AddMonthlyFieldSetInput(state, curReport, "DistrictHeatingWater:Facility", "", AggType::SumOrAvg);
    2233           96 :         AddMonthlyFieldSetInput(state, curReport, "DistrictHeatingWater:Facility", "", AggType::Maximum);
    2234           96 :         AddMonthlyFieldSetInput(state, curReport, "DistrictHeatingSteam:Facility", "", AggType::SumOrAvg);
    2235           96 :         AddMonthlyFieldSetInput(state, curReport, "DistrictHeatingSteam:Facility", "", AggType::Maximum);
    2236              :     }
    2237          758 :     if (ort->namedMonthly(11).show) {
    2238           48 :         curReport = AddMonthlyReport(state, "EnergyConsumptionCoalGasolineMonthly", 2, true);
    2239           96 :         AddMonthlyFieldSetInput(state, curReport, "Coal:Facility", "", AggType::SumOrAvg);
    2240           96 :         AddMonthlyFieldSetInput(state, curReport, "Coal:Facility", "", AggType::Maximum);
    2241           96 :         AddMonthlyFieldSetInput(state, curReport, "Gasoline:Facility", "", AggType::SumOrAvg);
    2242           96 :         AddMonthlyFieldSetInput(state, curReport, "Gasoline:Facility", "", AggType::Maximum);
    2243              :     }
    2244          758 :     if (ort->namedMonthly(12).show) {
    2245           48 :         curReport = AddMonthlyReport(state, "EnergyConsumptionOtherFuelsMonthly", 2, true);
    2246           96 :         AddMonthlyFieldSetInput(state, curReport, "OtherFuel1:Facility", "", AggType::SumOrAvg);
    2247           96 :         AddMonthlyFieldSetInput(state, curReport, "OtherFuel1:Facility", "", AggType::Maximum);
    2248           96 :         AddMonthlyFieldSetInput(state, curReport, "OtherFuel2:Facility", "", AggType::SumOrAvg);
    2249           96 :         AddMonthlyFieldSetInput(state, curReport, "OtherFuel2:Facility", "", AggType::Maximum);
    2250              :     }
    2251          758 :     if (ort->namedMonthly(13).show) {
    2252           48 :         curReport = AddMonthlyReport(state, "EndUseEnergyConsumptionElectricityMonthly", 2, true);
    2253           96 :         AddMonthlyFieldSetInput(state, curReport, "InteriorLights:Electricity", "", AggType::SumOrAvg);
    2254           96 :         AddMonthlyFieldSetInput(state, curReport, "ExteriorLights:Electricity", "", AggType::SumOrAvg);
    2255           96 :         AddMonthlyFieldSetInput(state, curReport, "InteriorEquipment:Electricity", "", AggType::SumOrAvg);
    2256           96 :         AddMonthlyFieldSetInput(state, curReport, "ExteriorEquipment:Electricity", "", AggType::SumOrAvg);
    2257           96 :         AddMonthlyFieldSetInput(state, curReport, "Fans:Electricity", "", AggType::SumOrAvg);
    2258           96 :         AddMonthlyFieldSetInput(state, curReport, "Pumps:Electricity", "", AggType::SumOrAvg);
    2259           96 :         AddMonthlyFieldSetInput(state, curReport, "Heating:Electricity", "", AggType::SumOrAvg);
    2260           96 :         AddMonthlyFieldSetInput(state, curReport, "Cooling:Electricity", "", AggType::SumOrAvg);
    2261           96 :         AddMonthlyFieldSetInput(state, curReport, "HeatRejection:Electricity", "", AggType::SumOrAvg);
    2262           96 :         AddMonthlyFieldSetInput(state, curReport, "Humidifier:Electricity", "", AggType::SumOrAvg);
    2263           96 :         AddMonthlyFieldSetInput(state, curReport, "HeatRecovery:Electricity", "", AggType::SumOrAvg);
    2264           96 :         AddMonthlyFieldSetInput(state, curReport, "WaterSystems:Electricity", "", AggType::SumOrAvg);
    2265           96 :         AddMonthlyFieldSetInput(state, curReport, "Cogeneration:Electricity", "", AggType::SumOrAvg);
    2266              :     }
    2267          758 :     if (ort->namedMonthly(14).show) {
    2268           48 :         curReport = AddMonthlyReport(state, "EndUseEnergyConsumptionNaturalGasMonthly", 2, true);
    2269           96 :         AddMonthlyFieldSetInput(state, curReport, "InteriorEquipment:NaturalGas", "", AggType::SumOrAvg);
    2270           96 :         AddMonthlyFieldSetInput(state, curReport, "ExteriorEquipment:NaturalGas", "", AggType::SumOrAvg);
    2271           96 :         AddMonthlyFieldSetInput(state, curReport, "Heating:NaturalGas", "", AggType::SumOrAvg);
    2272           96 :         AddMonthlyFieldSetInput(state, curReport, "Cooling:NaturalGas", "", AggType::SumOrAvg);
    2273           96 :         AddMonthlyFieldSetInput(state, curReport, "WaterSystems:NaturalGas", "", AggType::SumOrAvg);
    2274           96 :         AddMonthlyFieldSetInput(state, curReport, "Cogeneration:NaturalGas", "", AggType::SumOrAvg);
    2275           96 :         AddMonthlyFieldSetInput(state, curReport, "Humidifier:NaturalGas", "", AggType::SumOrAvg);
    2276              :     }
    2277          758 :     if (ort->namedMonthly(15).show) {
    2278           48 :         curReport = AddMonthlyReport(state, "EndUseEnergyConsumptionDieselMonthly", 2, true);
    2279           96 :         AddMonthlyFieldSetInput(state, curReport, "ExteriorEquipment:Diesel", "", AggType::SumOrAvg);
    2280           96 :         AddMonthlyFieldSetInput(state, curReport, "Cooling:Diesel", "", AggType::SumOrAvg);
    2281           96 :         AddMonthlyFieldSetInput(state, curReport, "Heating:Diesel", "", AggType::SumOrAvg);
    2282           96 :         AddMonthlyFieldSetInput(state, curReport, "WaterSystems:Diesel", "", AggType::SumOrAvg);
    2283           96 :         AddMonthlyFieldSetInput(state, curReport, "Cogeneration:Diesel", "", AggType::SumOrAvg);
    2284              :     }
    2285          758 :     if (ort->namedMonthly(16).show) {
    2286           48 :         curReport = AddMonthlyReport(state, "EndUseEnergyConsumptionFuelOilMonthly", 2, true);
    2287           96 :         AddMonthlyFieldSetInput(state, curReport, "ExteriorEquipment:FuelOilNo1", "", AggType::SumOrAvg);
    2288           96 :         AddMonthlyFieldSetInput(state, curReport, "Cooling:FuelOilNo1", "", AggType::SumOrAvg);
    2289           96 :         AddMonthlyFieldSetInput(state, curReport, "Heating:FuelOilNo1", "", AggType::SumOrAvg);
    2290           96 :         AddMonthlyFieldSetInput(state, curReport, "WaterSystems:FuelOilNo1", "", AggType::SumOrAvg);
    2291           96 :         AddMonthlyFieldSetInput(state, curReport, "Cogeneration:FuelOilNo1", "", AggType::SumOrAvg);
    2292           96 :         AddMonthlyFieldSetInput(state, curReport, "ExteriorEquipment:FuelOilNo2", "", AggType::SumOrAvg);
    2293           96 :         AddMonthlyFieldSetInput(state, curReport, "Cooling:FuelOilNo2", "", AggType::SumOrAvg);
    2294           96 :         AddMonthlyFieldSetInput(state, curReport, "Heating:FuelOilNo2", "", AggType::SumOrAvg);
    2295           96 :         AddMonthlyFieldSetInput(state, curReport, "WaterSystems:FuelOilNo2", "", AggType::SumOrAvg);
    2296           96 :         AddMonthlyFieldSetInput(state, curReport, "Cogeneration:FuelOilNo2", "", AggType::SumOrAvg);
    2297              :     }
    2298          758 :     if (ort->namedMonthly(17).show) {
    2299           48 :         curReport = AddMonthlyReport(state, "EndUseEnergyConsumptionCoalMonthly", 2, true);
    2300           96 :         AddMonthlyFieldSetInput(state, curReport, "ExteriorEquipment:Coal", "", AggType::SumOrAvg);
    2301           96 :         AddMonthlyFieldSetInput(state, curReport, "Heating:Coal", "", AggType::SumOrAvg);
    2302           96 :         AddMonthlyFieldSetInput(state, curReport, "WaterSystems:Coal", "", AggType::SumOrAvg);
    2303              :     }
    2304          758 :     if (ort->namedMonthly(18).show) {
    2305           48 :         curReport = AddMonthlyReport(state, "EndUseEnergyConsumptionPropaneMonthly", 2, true);
    2306           96 :         AddMonthlyFieldSetInput(state, curReport, "ExteriorEquipment:Propane", "", AggType::SumOrAvg);
    2307           96 :         AddMonthlyFieldSetInput(state, curReport, "Cooling:Propane", "", AggType::SumOrAvg);
    2308           96 :         AddMonthlyFieldSetInput(state, curReport, "Heating:Propane", "", AggType::SumOrAvg);
    2309           96 :         AddMonthlyFieldSetInput(state, curReport, "WaterSystems:Propane", "", AggType::SumOrAvg);
    2310           96 :         AddMonthlyFieldSetInput(state, curReport, "Cogeneration:Propane", "", AggType::SumOrAvg);
    2311           96 :         AddMonthlyFieldSetInput(state, curReport, "Humidifier:Propane", "", AggType::SumOrAvg);
    2312              :     }
    2313          758 :     if (ort->namedMonthly(19).show) {
    2314           48 :         curReport = AddMonthlyReport(state, "EndUseEnergyConsumptionGasolineMonthly", 2, true);
    2315           96 :         AddMonthlyFieldSetInput(state, curReport, "ExteriorEquipment:Gasoline", "", AggType::SumOrAvg);
    2316           96 :         AddMonthlyFieldSetInput(state, curReport, "Cooling:Gasoline", "", AggType::SumOrAvg);
    2317           96 :         AddMonthlyFieldSetInput(state, curReport, "Heating:Gasoline", "", AggType::SumOrAvg);
    2318           96 :         AddMonthlyFieldSetInput(state, curReport, "WaterSystems:Gasoline", "", AggType::SumOrAvg);
    2319           96 :         AddMonthlyFieldSetInput(state, curReport, "Cogeneration:Gasoline", "", AggType::SumOrAvg);
    2320              :     }
    2321          758 :     if (ort->namedMonthly(20).show) {
    2322           48 :         curReport = AddMonthlyReport(state, "EndUseEnergyConsumptionOtherFuelsMonthly", 2, true);
    2323           96 :         AddMonthlyFieldSetInput(state, curReport, "ExteriorEquipment:OtherFuel1", "", AggType::SumOrAvg);
    2324           96 :         AddMonthlyFieldSetInput(state, curReport, "Cooling:OtherFuel1", "", AggType::SumOrAvg);
    2325           96 :         AddMonthlyFieldSetInput(state, curReport, "Heating:OtherFuel1", "", AggType::SumOrAvg);
    2326           96 :         AddMonthlyFieldSetInput(state, curReport, "WaterSystems:OtherFuel1", "", AggType::SumOrAvg);
    2327           96 :         AddMonthlyFieldSetInput(state, curReport, "Cogeneration:OtherFuel1", "", AggType::SumOrAvg);
    2328           96 :         AddMonthlyFieldSetInput(state, curReport, "ExteriorEquipment:OtherFuel2", "", AggType::SumOrAvg);
    2329           96 :         AddMonthlyFieldSetInput(state, curReport, "Cooling:OtherFuel2", "", AggType::SumOrAvg);
    2330           96 :         AddMonthlyFieldSetInput(state, curReport, "Heating:OtherFuel2", "", AggType::SumOrAvg);
    2331           96 :         AddMonthlyFieldSetInput(state, curReport, "WaterSystems:OtherFuel2", "", AggType::SumOrAvg);
    2332           96 :         AddMonthlyFieldSetInput(state, curReport, "Cogeneration:OtherFuel2", "", AggType::SumOrAvg);
    2333              :     }
    2334          758 :     if (ort->namedMonthly(21).show) {
    2335           48 :         curReport = AddMonthlyReport(state, "PeakEnergyEndUseElectricityPart1Monthly", 2, true);
    2336           96 :         AddMonthlyFieldSetInput(state, curReport, "InteriorLights:Electricity", "", AggType::Maximum);
    2337           96 :         AddMonthlyFieldSetInput(state, curReport, "ExteriorLights:Electricity", "", AggType::Maximum);
    2338           96 :         AddMonthlyFieldSetInput(state, curReport, "InteriorEquipment:Electricity", "", AggType::Maximum);
    2339           96 :         AddMonthlyFieldSetInput(state, curReport, "ExteriorEquipment:Electricity", "", AggType::Maximum);
    2340           96 :         AddMonthlyFieldSetInput(state, curReport, "Fans:Electricity", "", AggType::Maximum);
    2341           96 :         AddMonthlyFieldSetInput(state, curReport, "Pumps:Electricity", "", AggType::Maximum);
    2342           96 :         AddMonthlyFieldSetInput(state, curReport, "Heating:Electricity", "", AggType::Maximum);
    2343              :     }
    2344          758 :     if (ort->namedMonthly(22).show) {
    2345           48 :         curReport = AddMonthlyReport(state, "PeakEnergyEndUseElectricityPart2Monthly", 2, true);
    2346           96 :         AddMonthlyFieldSetInput(state, curReport, "Cooling:Electricity", "", AggType::Maximum);
    2347           96 :         AddMonthlyFieldSetInput(state, curReport, "HeatRejection:Electricity", "", AggType::Maximum);
    2348           96 :         AddMonthlyFieldSetInput(state, curReport, "Humidifier:Electricity", "", AggType::Maximum);
    2349           96 :         AddMonthlyFieldSetInput(state, curReport, "HeatRecovery:Electricity", "", AggType::Maximum);
    2350           96 :         AddMonthlyFieldSetInput(state, curReport, "WaterSystems:Electricity", "", AggType::Maximum);
    2351           96 :         AddMonthlyFieldSetInput(state, curReport, "Cogeneration:Electricity", "", AggType::Maximum);
    2352              :     }
    2353          758 :     if (ort->namedMonthly(23).show) {
    2354           48 :         curReport = AddMonthlyReport(state, "ElectricComponentsOfPeakDemandMonthly", 2, true);
    2355           96 :         AddMonthlyFieldSetInput(state, curReport, "Electricity:Facility", "", AggType::Maximum);
    2356           96 :         AddMonthlyFieldSetInput(state, curReport, "InteriorLights:Electricity", "", AggType::ValueWhenMaxMin);
    2357           96 :         AddMonthlyFieldSetInput(state, curReport, "InteriorEquipment:Electricity", "", AggType::ValueWhenMaxMin);
    2358           96 :         AddMonthlyFieldSetInput(state, curReport, "ExteriorLights:Electricity", "", AggType::ValueWhenMaxMin);
    2359           96 :         AddMonthlyFieldSetInput(state, curReport, "ExteriorEquipment:Electricity", "", AggType::ValueWhenMaxMin);
    2360           96 :         AddMonthlyFieldSetInput(state, curReport, "Fans:Electricity", "", AggType::ValueWhenMaxMin);
    2361           96 :         AddMonthlyFieldSetInput(state, curReport, "Pumps:Electricity", "", AggType::ValueWhenMaxMin);
    2362           96 :         AddMonthlyFieldSetInput(state, curReport, "Heating:Electricity", "", AggType::ValueWhenMaxMin);
    2363           96 :         AddMonthlyFieldSetInput(state, curReport, "Cooling:Electricity", "", AggType::ValueWhenMaxMin);
    2364           96 :         AddMonthlyFieldSetInput(state, curReport, "HeatRejection:Electricity", "", AggType::ValueWhenMaxMin);
    2365              :     }
    2366          758 :     if (ort->namedMonthly(24).show) {
    2367           48 :         curReport = AddMonthlyReport(state, "PeakEnergyEndUseNaturalGasMonthly", 2, true);
    2368           96 :         AddMonthlyFieldSetInput(state, curReport, "InteriorEquipment:NaturalGas", "", AggType::Maximum);
    2369           96 :         AddMonthlyFieldSetInput(state, curReport, "ExteriorEquipment:NaturalGas", "", AggType::Maximum);
    2370           96 :         AddMonthlyFieldSetInput(state, curReport, "Heating:NaturalGas", "", AggType::Maximum);
    2371           96 :         AddMonthlyFieldSetInput(state, curReport, "Cooling:NaturalGas", "", AggType::Maximum);
    2372           96 :         AddMonthlyFieldSetInput(state, curReport, "WaterSystems:NaturalGas", "", AggType::Maximum);
    2373           96 :         AddMonthlyFieldSetInput(state, curReport, "Cogeneration:NaturalGas", "", AggType::Maximum);
    2374              :     }
    2375          758 :     if (ort->namedMonthly(25).show) {
    2376           48 :         curReport = AddMonthlyReport(state, "PeakEnergyEndUseDieselMonthly", 2, true);
    2377           96 :         AddMonthlyFieldSetInput(state, curReport, "ExteriorEquipment:Diesel", "", AggType::Maximum);
    2378           96 :         AddMonthlyFieldSetInput(state, curReport, "Cooling:Diesel", "", AggType::Maximum);
    2379           96 :         AddMonthlyFieldSetInput(state, curReport, "Heating:Diesel", "", AggType::Maximum);
    2380           96 :         AddMonthlyFieldSetInput(state, curReport, "WaterSystems:Diesel", "", AggType::Maximum);
    2381           96 :         AddMonthlyFieldSetInput(state, curReport, "Cogeneration:Diesel", "", AggType::Maximum);
    2382              :     }
    2383          758 :     if (ort->namedMonthly(26).show) {
    2384           48 :         curReport = AddMonthlyReport(state, "PeakEnergyEndUseFuelOilMonthly", 2, true);
    2385           96 :         AddMonthlyFieldSetInput(state, curReport, "ExteriorEquipment:FuelOilNo1", "", AggType::Maximum);
    2386           96 :         AddMonthlyFieldSetInput(state, curReport, "Cooling:FuelOilNo1", "", AggType::Maximum);
    2387           96 :         AddMonthlyFieldSetInput(state, curReport, "Heating:FuelOilNo1", "", AggType::Maximum);
    2388           96 :         AddMonthlyFieldSetInput(state, curReport, "WaterSystems:FuelOilNo1", "", AggType::Maximum);
    2389           96 :         AddMonthlyFieldSetInput(state, curReport, "Cogeneration:FuelOilNo1", "", AggType::Maximum);
    2390           96 :         AddMonthlyFieldSetInput(state, curReport, "ExteriorEquipment:FuelOilNo2", "", AggType::Maximum);
    2391           96 :         AddMonthlyFieldSetInput(state, curReport, "Cooling:FuelOilNo2", "", AggType::Maximum);
    2392           96 :         AddMonthlyFieldSetInput(state, curReport, "Heating:FuelOilNo2", "", AggType::Maximum);
    2393           96 :         AddMonthlyFieldSetInput(state, curReport, "WaterSystems:FuelOilNo2", "", AggType::Maximum);
    2394           96 :         AddMonthlyFieldSetInput(state, curReport, "Cogeneration:FuelOilNo2", "", AggType::Maximum);
    2395              :     }
    2396          758 :     if (ort->namedMonthly(27).show) {
    2397           48 :         curReport = AddMonthlyReport(state, "PeakEnergyEndUseCoalMonthly", 2, true);
    2398           96 :         AddMonthlyFieldSetInput(state, curReport, "ExteriorEquipment:Coal", "", AggType::Maximum);
    2399           96 :         AddMonthlyFieldSetInput(state, curReport, "Heating:Coal", "", AggType::Maximum);
    2400           96 :         AddMonthlyFieldSetInput(state, curReport, "WaterSystems:Coal", "", AggType::Maximum);
    2401              :     }
    2402          758 :     if (ort->namedMonthly(28).show) {
    2403           48 :         curReport = AddMonthlyReport(state, "PeakEnergyEndUsePropaneMonthly", 2, true);
    2404           96 :         AddMonthlyFieldSetInput(state, curReport, "ExteriorEquipment:Propane", "", AggType::Maximum);
    2405           96 :         AddMonthlyFieldSetInput(state, curReport, "Cooling:Propane", "", AggType::Maximum);
    2406           96 :         AddMonthlyFieldSetInput(state, curReport, "Heating:Propane", "", AggType::Maximum);
    2407           96 :         AddMonthlyFieldSetInput(state, curReport, "WaterSystems:Propane", "", AggType::Maximum);
    2408           96 :         AddMonthlyFieldSetInput(state, curReport, "Cogeneration:Propane", "", AggType::Maximum);
    2409              :     }
    2410          758 :     if (ort->namedMonthly(29).show) {
    2411           48 :         curReport = AddMonthlyReport(state, "PeakEnergyEndUseGasolineMonthly", 2, true);
    2412           96 :         AddMonthlyFieldSetInput(state, curReport, "ExteriorEquipment:Gasoline", "", AggType::Maximum);
    2413           96 :         AddMonthlyFieldSetInput(state, curReport, "Cooling:Gasoline", "", AggType::Maximum);
    2414           96 :         AddMonthlyFieldSetInput(state, curReport, "Heating:Gasoline", "", AggType::Maximum);
    2415           96 :         AddMonthlyFieldSetInput(state, curReport, "WaterSystems:Gasoline", "", AggType::Maximum);
    2416           96 :         AddMonthlyFieldSetInput(state, curReport, "Cogeneration:Gasoline", "", AggType::Maximum);
    2417              :     }
    2418          758 :     if (ort->namedMonthly(30).show) {
    2419           48 :         curReport = AddMonthlyReport(state, "PeakEnergyEndUseOtherFuelsMonthly", 2, true);
    2420           96 :         AddMonthlyFieldSetInput(state, curReport, "ExteriorEquipment:OtherFuel1", "", AggType::Maximum);
    2421           96 :         AddMonthlyFieldSetInput(state, curReport, "Cooling:OtherFuel1", "", AggType::Maximum);
    2422           96 :         AddMonthlyFieldSetInput(state, curReport, "Heating:OtherFuel1", "", AggType::Maximum);
    2423           96 :         AddMonthlyFieldSetInput(state, curReport, "WaterSystems:OtherFuel1", "", AggType::Maximum);
    2424           96 :         AddMonthlyFieldSetInput(state, curReport, "Cogeneration:OtherFuel1", "", AggType::Maximum);
    2425           96 :         AddMonthlyFieldSetInput(state, curReport, "ExteriorEquipment:OtherFuel2", "", AggType::Maximum);
    2426           96 :         AddMonthlyFieldSetInput(state, curReport, "Cooling:OtherFuel2", "", AggType::Maximum);
    2427           96 :         AddMonthlyFieldSetInput(state, curReport, "Heating:OtherFuel2", "", AggType::Maximum);
    2428           96 :         AddMonthlyFieldSetInput(state, curReport, "WaterSystems:OtherFuel2", "", AggType::Maximum);
    2429           96 :         AddMonthlyFieldSetInput(state, curReport, "Cogeneration:OtherFuel2", "", AggType::Maximum);
    2430              :     }
    2431          758 :     if (ort->namedMonthly(31).show) {
    2432           48 :         curReport = AddMonthlyReport(state, "SetpointsNotMetWithTemperaturesMonthly", 2, true);
    2433           96 :         AddMonthlyFieldSetInput(state, curReport, "Zone Heating Setpoint Not Met Time", "", AggType::HoursNonZero);
    2434           96 :         AddMonthlyFieldSetInput(state, curReport, "Zone Mean Air Temperature", "", AggType::SumOrAverageHoursShown);
    2435           96 :         AddMonthlyFieldSetInput(state, curReport, "Zone Heating Setpoint Not Met While Occupied Time", "", AggType::HoursNonZero);
    2436           96 :         AddMonthlyFieldSetInput(state, curReport, "Zone Mean Air Temperature", "", AggType::SumOrAverageHoursShown);
    2437           96 :         AddMonthlyFieldSetInput(state, curReport, "Zone Cooling Setpoint Not Met Time", "", AggType::HoursNonZero);
    2438           96 :         AddMonthlyFieldSetInput(state, curReport, "Zone Mean Air Temperature", "", AggType::SumOrAverageHoursShown);
    2439           96 :         AddMonthlyFieldSetInput(state, curReport, "Zone Cooling Setpoint Not Met While Occupied Time", "", AggType::HoursNonZero);
    2440           96 :         AddMonthlyFieldSetInput(state, curReport, "Zone Mean Air Temperature", "", AggType::SumOrAverageHoursShown);
    2441              :     }
    2442          758 :     if (ort->namedMonthly(32).show) {
    2443           48 :         curReport = AddMonthlyReport(state, "ComfortReportSimple55Monthly", 2, true);
    2444           96 :         AddMonthlyFieldSetInput(
    2445              :             state, curReport, "Zone Thermal Comfort ASHRAE 55 Simple Model Summer Clothes Not Comfortable Time", "", AggType::HoursNonZero);
    2446           96 :         AddMonthlyFieldSetInput(state, curReport, "Zone Mean Air Temperature", "", AggType::SumOrAverageHoursShown);
    2447           96 :         AddMonthlyFieldSetInput(
    2448              :             state, curReport, "Zone Thermal Comfort ASHRAE 55 Simple Model Winter Clothes Not Comfortable Time", "", AggType::HoursNonZero);
    2449           96 :         AddMonthlyFieldSetInput(state, curReport, "Zone Mean Air Temperature", "", AggType::SumOrAverageHoursShown);
    2450           96 :         AddMonthlyFieldSetInput(
    2451              :             state, curReport, "Zone Thermal Comfort ASHRAE 55 Simple Model Summer or Winter Clothes Not Comfortable Time", "", AggType::HoursNonZero);
    2452           96 :         AddMonthlyFieldSetInput(state, curReport, "Zone Mean Air Temperature", "", AggType::SumOrAverageHoursShown);
    2453              :     }
    2454          758 :     if (ort->namedMonthly(33).show) {
    2455           48 :         curReport = AddMonthlyReport(state, "UnglazedTranspiredSolarCollectorSummaryMonthly", 5, true);
    2456           96 :         AddMonthlyFieldSetInput(state, curReport, "Solar Collector System Efficiency", "", AggType::HoursNonZero);
    2457           96 :         AddMonthlyFieldSetInput(state, curReport, "Solar Collector System Efficiency", "", AggType::SumOrAverageHoursShown);
    2458           96 :         AddMonthlyFieldSetInput(state, curReport, "Solar Collector Outside Face Suction Velocity", "", AggType::SumOrAverageHoursShown);
    2459           96 :         AddMonthlyFieldSetInput(state, curReport, "Solar Collector Sensible Heating Rate", "", AggType::SumOrAverageHoursShown);
    2460              :     }
    2461          758 :     if (ort->namedMonthly(34).show) {
    2462           48 :         curReport = AddMonthlyReport(state, "OccupantComfortDataSummaryMonthly", 5, true);
    2463           96 :         AddMonthlyFieldSetInput(state, curReport, "People Occupant Count", "", AggType::HoursNonZero);
    2464           96 :         AddMonthlyFieldSetInput(state, curReport, "People Air Temperature", "", AggType::SumOrAverageHoursShown);
    2465           96 :         AddMonthlyFieldSetInput(state, curReport, "People Air Relative Humidity", "", AggType::SumOrAverageHoursShown);
    2466           96 :         AddMonthlyFieldSetInput(state, curReport, "Zone Thermal Comfort Fanger Model PMV", "", AggType::SumOrAverageHoursShown);
    2467           96 :         AddMonthlyFieldSetInput(state, curReport, "Zone Thermal Comfort Fanger Model PPD", "", AggType::SumOrAverageHoursShown);
    2468              :     }
    2469          758 :     if (ort->namedMonthly(35).show) {
    2470           48 :         curReport = AddMonthlyReport(state, "ChillerReportMonthly", 2, true);
    2471           96 :         AddMonthlyFieldSetInput(state, curReport, "Chiller Electricity Energy", "", AggType::SumOrAvg);
    2472           96 :         AddMonthlyFieldSetInput(state, curReport, "Chiller Electricity Rate", "", AggType::Maximum);
    2473           96 :         AddMonthlyFieldSetInput(state, curReport, "Chiller Electricity Energy", "", AggType::HoursNonZero);
    2474           96 :         AddMonthlyFieldSetInput(state, curReport, "Chiller Evaporator Cooling Energy", "", AggType::SumOrAvg);
    2475           96 :         AddMonthlyFieldSetInput(state, curReport, "Chiller Evaporator Cooling Rate", "", AggType::Maximum);
    2476           96 :         AddMonthlyFieldSetInput(state, curReport, "Chiller Condenser Heat Transfer Energy", "", AggType::SumOrAvg);
    2477           96 :         AddMonthlyFieldSetInput(state, curReport, "Chiller COP", "", AggType::SumOrAvg);
    2478           96 :         AddMonthlyFieldSetInput(state, curReport, "Chiller COP", "", AggType::Maximum);
    2479           96 :         AddMonthlyFieldSetInput(state, curReport, "Chiller Part Load Ratio", "", AggType::SumOrAvg);
    2480           96 :         AddMonthlyFieldSetInput(state, curReport, "Chiller Part Load Ratio", "", AggType::Maximum);
    2481              :     }
    2482          758 :     if (ort->namedMonthly(36).show) {
    2483           48 :         curReport = AddMonthlyReport(state, "TowerReportMonthly", 2, true);
    2484           96 :         AddMonthlyFieldSetInput(state, curReport, "Cooling Tower Fan Electricity Energy", "", AggType::SumOrAvg);
    2485           96 :         AddMonthlyFieldSetInput(state, curReport, "Cooling Tower Fan Electricity Energy", "", AggType::HoursNonZero);
    2486           96 :         AddMonthlyFieldSetInput(state, curReport, "Cooling Tower Fan Electricity Rate", "", AggType::Maximum);
    2487           96 :         AddMonthlyFieldSetInput(state, curReport, "Cooling Tower Heat Transfer Rate", "", AggType::Maximum);
    2488           96 :         AddMonthlyFieldSetInput(state, curReport, "Cooling Tower Inlet Temperature", "", AggType::SumOrAvg);
    2489           96 :         AddMonthlyFieldSetInput(state, curReport, "Cooling Tower Outlet Temperature", "", AggType::SumOrAvg);
    2490           96 :         AddMonthlyFieldSetInput(state, curReport, "Cooling Tower Mass Flow Rate", "", AggType::SumOrAvg);
    2491              :     }
    2492          758 :     if (ort->namedMonthly(37).show) {
    2493           48 :         curReport = AddMonthlyReport(state, "BoilerReportMonthly", 2, true);
    2494           96 :         AddMonthlyFieldSetInput(state, curReport, "Boiler Heating Energy", "", AggType::SumOrAvg);
    2495           96 :         AddMonthlyFieldSetInput(state, curReport, "Boiler Gas Consumption", "", AggType::SumOrAvg);
    2496           96 :         AddMonthlyFieldSetInput(state, curReport, "Boiler Heating Energy", "", AggType::HoursNonZero);
    2497           96 :         AddMonthlyFieldSetInput(state, curReport, "Boiler Heating Rate", "", AggType::Maximum);
    2498           96 :         AddMonthlyFieldSetInput(state, curReport, "Boiler Gas Consumption Rate", "", AggType::Maximum);
    2499           96 :         AddMonthlyFieldSetInput(state, curReport, "Boiler Inlet Temperature", "", AggType::SumOrAvg);
    2500           96 :         AddMonthlyFieldSetInput(state, curReport, "Boiler Outlet Temperature", "", AggType::SumOrAvg);
    2501           96 :         AddMonthlyFieldSetInput(state, curReport, "Boiler Mass Flow Rate", "", AggType::SumOrAvg);
    2502           96 :         AddMonthlyFieldSetInput(state, curReport, "Boiler Ancillary Electricity Rate", "", AggType::SumOrAvg);
    2503           96 :         AddMonthlyFieldSetInput(state, curReport, "Boiler Part Load Ratio", "", AggType::SumOrAvg);
    2504           96 :         AddMonthlyFieldSetInput(state, curReport, "Boiler Part Load Ratio", "", AggType::Maximum);
    2505              :     }
    2506          758 :     if (ort->namedMonthly(38).show) {
    2507           48 :         curReport = AddMonthlyReport(state, "DXReportMonthly", 2, true);
    2508           96 :         AddMonthlyFieldSetInput(state, curReport, "Cooling Coil Total Cooling Energy", "", AggType::SumOrAvg);
    2509           96 :         AddMonthlyFieldSetInput(state, curReport, "Cooling Coil Electricity Energy", "", AggType::SumOrAvg);
    2510           96 :         AddMonthlyFieldSetInput(state, curReport, "Cooling Coil Total Cooling Energy", "", AggType::HoursNonZero);
    2511           96 :         AddMonthlyFieldSetInput(state, curReport, "Cooling Coil Sensible Cooling Energy", "", AggType::SumOrAvg);
    2512           96 :         AddMonthlyFieldSetInput(state, curReport, "Cooling Coil Latent Cooling Energy", "", AggType::SumOrAvg);
    2513           96 :         AddMonthlyFieldSetInput(state, curReport, "Cooling Coil Crankcase Heater Electricity Energy", "", AggType::SumOrAvg);
    2514           96 :         AddMonthlyFieldSetInput(state, curReport, "Cooling Coil Runtime Fraction", "", AggType::Maximum);
    2515           96 :         AddMonthlyFieldSetInput(state, curReport, "Cooling Coil Runtime Fraction", "", AggType::Minimum);
    2516           96 :         AddMonthlyFieldSetInput(state, curReport, "Cooling Coil Total Cooling Rate", "", AggType::Maximum);
    2517           96 :         AddMonthlyFieldSetInput(state, curReport, "Cooling Coil Sensible Cooling Rate", "", AggType::Maximum);
    2518           96 :         AddMonthlyFieldSetInput(state, curReport, "Cooling Coil Latent Cooling Rate", "", AggType::Maximum);
    2519           96 :         AddMonthlyFieldSetInput(state, curReport, "Cooling Coil Electricity Rate", "", AggType::Maximum);
    2520           96 :         AddMonthlyFieldSetInput(state, curReport, "Cooling Coil Crankcase Heater Electricity Rate", "", AggType::Maximum);
    2521              :     }
    2522          758 :     if (ort->namedMonthly(39).show) {
    2523           48 :         curReport = AddMonthlyReport(state, "WindowReportMonthly", 2, true);
    2524           96 :         AddMonthlyFieldSetInput(state, curReport, "Surface Window Transmitted Solar Radiation Rate", "", AggType::SumOrAvg);
    2525           96 :         AddMonthlyFieldSetInput(state, curReport, "Surface Window Transmitted Beam Solar Radiation Rate", "", AggType::SumOrAvg);
    2526           96 :         AddMonthlyFieldSetInput(state, curReport, "Surface Window Transmitted Diffuse Solar Radiation Rate", "", AggType::SumOrAvg);
    2527           96 :         AddMonthlyFieldSetInput(state, curReport, "Surface Window Heat Gain Rate", "", AggType::SumOrAvg);
    2528           96 :         AddMonthlyFieldSetInput(state, curReport, "Surface Window Heat Loss Rate", "", AggType::SumOrAvg);
    2529           96 :         AddMonthlyFieldSetInput(state, curReport, "Surface Window Inside Face Glazing Condensation Status", "", AggType::HoursNonZero);
    2530           96 :         AddMonthlyFieldSetInput(state, curReport, "Surface Shading Device Is On Time Fraction", "", AggType::HoursNonZero);
    2531           96 :         AddMonthlyFieldSetInput(state, curReport, "Surface Storm Window On Off Status", "", AggType::HoursNonZero);
    2532              :     }
    2533          758 :     if (ort->namedMonthly(40).show) {
    2534           48 :         curReport = AddMonthlyReport(state, "WindowEnergyReportMonthly", 2, true);
    2535           96 :         AddMonthlyFieldSetInput(state, curReport, "Surface Window Transmitted Solar Radiation Energy", "", AggType::SumOrAvg);
    2536           96 :         AddMonthlyFieldSetInput(state, curReport, "Surface Window Transmitted Beam Solar Radiation Energy", "", AggType::SumOrAvg);
    2537           96 :         AddMonthlyFieldSetInput(state, curReport, "Surface Window Transmitted Diffuse Solar Radiation Energy", "", AggType::SumOrAvg);
    2538           96 :         AddMonthlyFieldSetInput(state, curReport, "Surface Window Heat Gain Energy", "", AggType::SumOrAvg);
    2539           96 :         AddMonthlyFieldSetInput(state, curReport, "Surface Window Heat Loss Energy", "", AggType::SumOrAvg);
    2540              :     }
    2541          758 :     if (ort->namedMonthly(41).show) {
    2542           48 :         curReport = AddMonthlyReport(state, "WindowZoneSummaryMonthly", 2, true);
    2543           96 :         AddMonthlyFieldSetInput(state, curReport, "Zone Windows Total Heat Gain Rate", "", AggType::SumOrAvg);
    2544           96 :         AddMonthlyFieldSetInput(state, curReport, "Zone Windows Total Heat Loss Rate", "", AggType::SumOrAvg);
    2545           96 :         AddMonthlyFieldSetInput(state, curReport, "Enclosure Windows Total Transmitted Solar Radiation Rate", "", AggType::SumOrAvg);
    2546           96 :         AddMonthlyFieldSetInput(state, curReport, "Enclosure Exterior Windows Total Transmitted Beam Solar Radiation Rate", "", AggType::SumOrAvg);
    2547           96 :         AddMonthlyFieldSetInput(state, curReport, "Enclosure Exterior Windows Total Transmitted Diffuse Solar Radiation Rate", "", AggType::SumOrAvg);
    2548           96 :         AddMonthlyFieldSetInput(state, curReport, "Enclosure Interior Windows Total Transmitted Diffuse Solar Radiation Rate", "", AggType::SumOrAvg);
    2549           96 :         AddMonthlyFieldSetInput(state, curReport, "Enclosure Interior Windows Total Transmitted Beam Solar Radiation Rate", "", AggType::SumOrAvg);
    2550              :     }
    2551          758 :     if (ort->namedMonthly(42).show) {
    2552           48 :         curReport = AddMonthlyReport(state, "WindowEnergyZoneSummaryMonthly", 2, true);
    2553           96 :         AddMonthlyFieldSetInput(state, curReport, "Zone Windows Total Heat Gain Energy", "", AggType::SumOrAvg);
    2554           96 :         AddMonthlyFieldSetInput(state, curReport, "Zone Windows Total Heat Loss Energy", "", AggType::SumOrAvg);
    2555           96 :         AddMonthlyFieldSetInput(state, curReport, "Enclosure Windows Total Transmitted Solar Radiation Energy", "", AggType::SumOrAvg);
    2556           96 :         AddMonthlyFieldSetInput(state, curReport, "Enclosure Exterior Windows Total Transmitted Beam Solar Radiation Energy", "", AggType::SumOrAvg);
    2557           96 :         AddMonthlyFieldSetInput(
    2558              :             state, curReport, "Enclosure Exterior Windows Total Transmitted Diffuse Solar Radiation Energy", "", AggType::SumOrAvg);
    2559           96 :         AddMonthlyFieldSetInput(
    2560              :             state, curReport, "Enclosure Interior Windows Total Transmitted Diffuse Solar Radiation Energy", "", AggType::SumOrAvg);
    2561           96 :         AddMonthlyFieldSetInput(state, curReport, "Enclosure Interior Windows Total Transmitted Beam Solar Radiation Energy", "", AggType::SumOrAvg);
    2562              :     }
    2563          758 :     if (ort->namedMonthly(43).show) {
    2564           48 :         curReport = AddMonthlyReport(state, "AverageOutdoorConditionsMonthly", 2, true);
    2565           96 :         AddMonthlyFieldSetInput(state, curReport, "Site Outdoor Air Drybulb Temperature", "", AggType::SumOrAvg);
    2566           96 :         AddMonthlyFieldSetInput(state, curReport, "Site Outdoor Air Wetbulb Temperature", "", AggType::SumOrAvg);
    2567           96 :         AddMonthlyFieldSetInput(state, curReport, "Site Outdoor Air Dewpoint Temperature", "", AggType::SumOrAvg);
    2568           96 :         AddMonthlyFieldSetInput(state, curReport, "Site Wind Speed", "", AggType::SumOrAvg);
    2569           96 :         AddMonthlyFieldSetInput(state, curReport, "Site Sky Temperature", "", AggType::SumOrAvg);
    2570           96 :         AddMonthlyFieldSetInput(state, curReport, "Site Diffuse Solar Radiation Rate per Area", "", AggType::SumOrAvg);
    2571           96 :         AddMonthlyFieldSetInput(state, curReport, "Site Direct Solar Radiation Rate per Area", "", AggType::SumOrAvg);
    2572           96 :         AddMonthlyFieldSetInput(state, curReport, "Site Rain Status", "", AggType::SumOrAvg);
    2573              :     }
    2574          758 :     if (ort->namedMonthly(44).show) {
    2575           48 :         curReport = AddMonthlyReport(state, "OutdoorConditionsMaximumDryBulbMonthly", 2, true);
    2576           96 :         AddMonthlyFieldSetInput(state, curReport, "Site Outdoor Air Drybulb Temperature", "", AggType::Maximum);
    2577           96 :         AddMonthlyFieldSetInput(state, curReport, "Site Outdoor Air Wetbulb Temperature", "", AggType::ValueWhenMaxMin);
    2578           96 :         AddMonthlyFieldSetInput(state, curReport, "Site Outdoor Air Dewpoint Temperature", "", AggType::ValueWhenMaxMin);
    2579           96 :         AddMonthlyFieldSetInput(state, curReport, "Site Wind Speed", "", AggType::ValueWhenMaxMin);
    2580           96 :         AddMonthlyFieldSetInput(state, curReport, "Site Sky Temperature", "", AggType::ValueWhenMaxMin);
    2581           96 :         AddMonthlyFieldSetInput(state, curReport, "Site Diffuse Solar Radiation Rate per Area", "", AggType::ValueWhenMaxMin);
    2582           96 :         AddMonthlyFieldSetInput(state, curReport, "Site Direct Solar Radiation Rate per Area", "", AggType::ValueWhenMaxMin);
    2583              :     }
    2584          758 :     if (ort->namedMonthly(45).show) {
    2585           48 :         curReport = AddMonthlyReport(state, "OutdoorConditionsMinimumDryBulbMonthly", 2, true);
    2586           96 :         AddMonthlyFieldSetInput(state, curReport, "Site Outdoor Air Drybulb Temperature", "", AggType::Minimum);
    2587           96 :         AddMonthlyFieldSetInput(state, curReport, "Site Outdoor Air Wetbulb Temperature", "", AggType::ValueWhenMaxMin);
    2588           96 :         AddMonthlyFieldSetInput(state, curReport, "Site Outdoor Air Dewpoint Temperature", "", AggType::ValueWhenMaxMin);
    2589           96 :         AddMonthlyFieldSetInput(state, curReport, "Site Wind Speed", "", AggType::ValueWhenMaxMin);
    2590           96 :         AddMonthlyFieldSetInput(state, curReport, "Site Sky Temperature", "", AggType::ValueWhenMaxMin);
    2591           96 :         AddMonthlyFieldSetInput(state, curReport, "Site Diffuse Solar Radiation Rate per Area", "", AggType::ValueWhenMaxMin);
    2592           96 :         AddMonthlyFieldSetInput(state, curReport, "Site Direct Solar Radiation Rate per Area", "", AggType::ValueWhenMaxMin);
    2593              :     }
    2594          758 :     if (ort->namedMonthly(46).show) {
    2595           48 :         curReport = AddMonthlyReport(state, "OutdoorConditionsMaximumWetBulbMonthly", 2, true);
    2596           96 :         AddMonthlyFieldSetInput(state, curReport, "Site Outdoor Air Wetbulb Temperature", "", AggType::Maximum);
    2597           96 :         AddMonthlyFieldSetInput(state, curReport, "Site Outdoor Air Drybulb Temperature", "", AggType::ValueWhenMaxMin);
    2598           96 :         AddMonthlyFieldSetInput(state, curReport, "Site Outdoor Air Dewpoint Temperature", "", AggType::ValueWhenMaxMin);
    2599           96 :         AddMonthlyFieldSetInput(state, curReport, "Site Wind Speed", "", AggType::ValueWhenMaxMin);
    2600           96 :         AddMonthlyFieldSetInput(state, curReport, "Site Sky Temperature", "", AggType::ValueWhenMaxMin);
    2601           96 :         AddMonthlyFieldSetInput(state, curReport, "Site Diffuse Solar Radiation Rate per Area", "", AggType::ValueWhenMaxMin);
    2602           96 :         AddMonthlyFieldSetInput(state, curReport, "Site Direct Solar Radiation Rate per Area", "", AggType::ValueWhenMaxMin);
    2603              :     }
    2604          758 :     if (ort->namedMonthly(47).show) {
    2605           48 :         curReport = AddMonthlyReport(state, "OutdoorConditionsMaximumDewPointMonthly", 2, true);
    2606           96 :         AddMonthlyFieldSetInput(state, curReport, "Site Outdoor Air Dewpoint Temperature", "", AggType::Maximum);
    2607           96 :         AddMonthlyFieldSetInput(state, curReport, "Site Outdoor Air Drybulb Temperature", "", AggType::ValueWhenMaxMin);
    2608           96 :         AddMonthlyFieldSetInput(state, curReport, "Site Outdoor Air Wetbulb Temperature", "", AggType::ValueWhenMaxMin);
    2609           96 :         AddMonthlyFieldSetInput(state, curReport, "Site Wind Speed", "", AggType::ValueWhenMaxMin);
    2610           96 :         AddMonthlyFieldSetInput(state, curReport, "Site Sky Temperature", "", AggType::ValueWhenMaxMin);
    2611           96 :         AddMonthlyFieldSetInput(state, curReport, "Site Diffuse Solar Radiation Rate per Area", "", AggType::ValueWhenMaxMin);
    2612           96 :         AddMonthlyFieldSetInput(state, curReport, "Site Direct Solar Radiation Rate per Area", "", AggType::ValueWhenMaxMin);
    2613              :     }
    2614          758 :     if (ort->namedMonthly(48).show) {
    2615           48 :         curReport = AddMonthlyReport(state, "OutdoorGroundConditionsMonthly", 2, true);
    2616           96 :         AddMonthlyFieldSetInput(state, curReport, "Site Ground Temperature", "", AggType::SumOrAvg);
    2617           96 :         AddMonthlyFieldSetInput(state, curReport, "Site Surface Ground Temperature", "", AggType::SumOrAvg);
    2618           96 :         AddMonthlyFieldSetInput(state, curReport, "Site Deep Ground Temperature", "", AggType::SumOrAvg);
    2619           96 :         AddMonthlyFieldSetInput(state, curReport, "Site Mains Water Temperature", "", AggType::SumOrAvg);
    2620           96 :         AddMonthlyFieldSetInput(state, curReport, "Site Ground Reflected Solar Radiation Rate per Area", "", AggType::SumOrAvg);
    2621           96 :         AddMonthlyFieldSetInput(state, curReport, "Site Snow on Ground Status", "", AggType::SumOrAvg);
    2622              :     }
    2623          758 :     if (ort->namedMonthly(49).show) {
    2624           48 :         curReport = AddMonthlyReport(state, "WindowACReportMonthly", 2, true);
    2625           96 :         AddMonthlyFieldSetInput(state, curReport, "Zone Window Air Conditioner Total Cooling Energy", "", AggType::SumOrAvg);
    2626           96 :         AddMonthlyFieldSetInput(state, curReport, "Zone Window Air Conditioner Electricity Energy", "", AggType::SumOrAvg);
    2627           96 :         AddMonthlyFieldSetInput(state, curReport, "Zone Window Air Conditioner Total Cooling Energy", "", AggType::HoursNonZero);
    2628           96 :         AddMonthlyFieldSetInput(state, curReport, "Zone Window Air Conditioner Sensible Cooling Energy", "", AggType::SumOrAvg);
    2629           96 :         AddMonthlyFieldSetInput(state, curReport, "Zone Window Air Conditioner Latent Cooling Energy", "", AggType::SumOrAvg);
    2630           96 :         AddMonthlyFieldSetInput(state, curReport, "Zone Window Air Conditioner Total Cooling Rate", "", AggType::Maximum);
    2631           96 :         AddMonthlyFieldSetInput(state, curReport, "Zone Window Air Conditioner Sensible Cooling Rate", "", AggType::ValueWhenMaxMin);
    2632           96 :         AddMonthlyFieldSetInput(state, curReport, "Zone Window Air Conditioner Latent Cooling Rate", "", AggType::ValueWhenMaxMin);
    2633           96 :         AddMonthlyFieldSetInput(state, curReport, "Zone Window Air Conditioner Electricity Rate", "", AggType::ValueWhenMaxMin);
    2634              :     }
    2635          758 :     if (ort->namedMonthly(50).show) {
    2636           48 :         curReport = AddMonthlyReport(state, "WaterHeaterReportMonthly", 2, true);
    2637           96 :         AddMonthlyFieldSetInput(state, curReport, "Water Heater Total Demand Heat Transfer Energy", "", AggType::SumOrAvg);
    2638           96 :         AddMonthlyFieldSetInput(state, curReport, "Water Heater Use Side Heat Transfer Energy", "", AggType::SumOrAvg);
    2639           96 :         AddMonthlyFieldSetInput(state, curReport, "Water Heater Burner Heating Energy", "", AggType::SumOrAvg);
    2640           96 :         AddMonthlyFieldSetInput(state, curReport, "Water Heater Gas Consumption", "", AggType::SumOrAvg);
    2641           96 :         AddMonthlyFieldSetInput(state, curReport, "Water Heater Total Demand Heat Transfer Energy", "", AggType::HoursNonZero);
    2642           96 :         AddMonthlyFieldSetInput(state, curReport, "Water Heater Loss Demand Energy", "", AggType::SumOrAvg);
    2643           96 :         AddMonthlyFieldSetInput(state, curReport, "Water Heater Heat Loss Energy", "", AggType::SumOrAvg);
    2644           96 :         AddMonthlyFieldSetInput(state, curReport, "Water Heater Tank Temperature", "", AggType::SumOrAvg);
    2645           96 :         AddMonthlyFieldSetInput(state, curReport, "Water Heater Heat Recovery Supply Energy", "", AggType::SumOrAvg);
    2646           96 :         AddMonthlyFieldSetInput(state, curReport, "Water Heater Source Side Heat Transfer Energy", "", AggType::SumOrAvg);
    2647              :     }
    2648          758 :     if (ort->namedMonthly(51).show) {
    2649           48 :         curReport = AddMonthlyReport(state, "GeneratorReportMonthly", 2, true);
    2650           96 :         AddMonthlyFieldSetInput(state, curReport, "Generator Produced AC Electricity Energy", "", AggType::SumOrAvg);
    2651           96 :         AddMonthlyFieldSetInput(state, curReport, "Generator Diesel Consumption", "", AggType::SumOrAvg);
    2652           96 :         AddMonthlyFieldSetInput(state, curReport, "Generator Gas Consumption", "", AggType::SumOrAvg);
    2653           96 :         AddMonthlyFieldSetInput(state, curReport, "Generator Produced AC Electricity Energy", "", AggType::HoursNonZero);
    2654           96 :         AddMonthlyFieldSetInput(state, curReport, "Generator Total Heat Recovery", "", AggType::SumOrAvg);
    2655           96 :         AddMonthlyFieldSetInput(state, curReport, "Generator Jacket Heat Recovery Energy", "", AggType::SumOrAvg);
    2656           96 :         AddMonthlyFieldSetInput(state, curReport, "Generator Lube Heat Recovery", "", AggType::SumOrAvg);
    2657           96 :         AddMonthlyFieldSetInput(state, curReport, "Generator Exhaust Heat Recovery Energy", "", AggType::SumOrAvg);
    2658           96 :         AddMonthlyFieldSetInput(state, curReport, "Generator Exhaust Air Temperature", "", AggType::SumOrAvg);
    2659              :     }
    2660          758 :     if (ort->namedMonthly(52).show) {
    2661           48 :         curReport = AddMonthlyReport(state, "DaylightingReportMonthly", 2, true);
    2662           96 :         AddMonthlyFieldSetInput(state, curReport, "Site Exterior Beam Normal Illuminance", "", AggType::HoursNonZero);
    2663           96 :         AddMonthlyFieldSetInput(state, curReport, "Daylighting Lighting Power Multiplier", "", AggType::SumOrAverageHoursShown);
    2664           96 :         AddMonthlyFieldSetInput(state, curReport, "Daylighting Lighting Power Multiplier", "", AggType::MinimumDuringHoursShown);
    2665           96 :         AddMonthlyFieldSetInput(state, curReport, "Daylighting Reference Point 1 Illuminance", "", AggType::SumOrAverageHoursShown);
    2666           96 :         AddMonthlyFieldSetInput(state, curReport, "Daylighting Reference Point 1 Glare Index", "", AggType::SumOrAverageHoursShown);
    2667           96 :         AddMonthlyFieldSetInput(state, curReport, "Daylighting Reference Point 1 Glare Index Setpoint Exceeded Time", "", AggType::SumOrAvg);
    2668           96 :         AddMonthlyFieldSetInput(state, curReport, "Daylighting Reference Point 1 Daylight Illuminance Setpoint Exceeded Time", "", AggType::SumOrAvg);
    2669           96 :         AddMonthlyFieldSetInput(state, curReport, "Daylighting Reference Point 2 Illuminance", "", AggType::SumOrAverageHoursShown);
    2670           96 :         AddMonthlyFieldSetInput(state, curReport, "Daylighting Reference Point 2 Glare Index", "", AggType::SumOrAverageHoursShown);
    2671           96 :         AddMonthlyFieldSetInput(state, curReport, "Daylighting Reference Point 2 Glare Index Setpoint Exceeded Time", "", AggType::SumOrAvg);
    2672           96 :         AddMonthlyFieldSetInput(state, curReport, "Daylighting Reference Point 2 Daylight Illuminance Setpoint Exceeded Time", "", AggType::SumOrAvg);
    2673              :     }
    2674          758 :     if (ort->namedMonthly(53).show) {
    2675           48 :         curReport = AddMonthlyReport(state, "CoilReportMonthly", 2, true);
    2676           96 :         AddMonthlyFieldSetInput(state, curReport, "Heating Coil Heating Energy", "", AggType::SumOrAvg);
    2677           96 :         AddMonthlyFieldSetInput(state, curReport, "Heating Coil Heating Rate", "", AggType::Maximum);
    2678           96 :         AddMonthlyFieldSetInput(state, curReport, "Cooling Coil Total Cooling Energy", "", AggType::SumOrAvg);
    2679           96 :         AddMonthlyFieldSetInput(state, curReport, "Cooling Coil Sensible Cooling Energy", "", AggType::SumOrAvg);
    2680           96 :         AddMonthlyFieldSetInput(state, curReport, "Cooling Coil Total Cooling Rate", "", AggType::Maximum);
    2681           96 :         AddMonthlyFieldSetInput(state, curReport, "Cooling Coil Sensible Cooling Rate", "", AggType::ValueWhenMaxMin);
    2682           96 :         AddMonthlyFieldSetInput(state, curReport, "Cooling Coil Wetted Area Fraction", "", AggType::SumOrAvg);
    2683              :     }
    2684          758 :     if (ort->namedMonthly(54).show) {
    2685           48 :         curReport = AddMonthlyReport(state, "PlantLoopDemandReportMonthly", 2, true);
    2686           96 :         AddMonthlyFieldSetInput(state, curReport, "Plant Supply Side Cooling Demand Rate", "", AggType::SumOrAvg);
    2687           96 :         AddMonthlyFieldSetInput(state, curReport, "Plant Supply Side Cooling Demand Rate", "", AggType::Maximum);
    2688           96 :         AddMonthlyFieldSetInput(state, curReport, "Plant Supply Side Heating Demand Rate", "", AggType::SumOrAvg);
    2689           96 :         AddMonthlyFieldSetInput(state, curReport, "Plant Supply Side Heating Demand Rate", "", AggType::Maximum);
    2690              :     }
    2691          758 :     if (ort->namedMonthly(55).show) {
    2692           50 :         curReport = AddMonthlyReport(state, "FanReportMonthly", 2, true);
    2693          100 :         AddMonthlyFieldSetInput(state, curReport, "Fan Electricity Energy", "", AggType::SumOrAvg);
    2694          100 :         AddMonthlyFieldSetInput(state, curReport, "Fan Rise in Air Temperature", "", AggType::SumOrAvg);
    2695          100 :         AddMonthlyFieldSetInput(state, curReport, "Fan Electricity Rate", "", AggType::Maximum);
    2696          100 :         AddMonthlyFieldSetInput(state, curReport, "Fan Rise in Air Temperature", "", AggType::ValueWhenMaxMin);
    2697              :     }
    2698          758 :     if (ort->namedMonthly(56).show) {
    2699           48 :         curReport = AddMonthlyReport(state, "PumpReportMonthly", 2, true);
    2700           96 :         AddMonthlyFieldSetInput(state, curReport, "Pump Electricity Energy", "", AggType::SumOrAvg);
    2701           96 :         AddMonthlyFieldSetInput(state, curReport, "Pump Fluid Heat Gain Energy", "", AggType::SumOrAvg);
    2702           96 :         AddMonthlyFieldSetInput(state, curReport, "Pump Electricity Rate", "", AggType::Maximum);
    2703           96 :         AddMonthlyFieldSetInput(state, curReport, "Pump Shaft Power", "", AggType::ValueWhenMaxMin);
    2704           96 :         AddMonthlyFieldSetInput(state, curReport, "Pump Fluid Heat Gain Rate", "", AggType::ValueWhenMaxMin);
    2705           96 :         AddMonthlyFieldSetInput(state, curReport, "Pump Outlet Temperature", "", AggType::ValueWhenMaxMin);
    2706           96 :         AddMonthlyFieldSetInput(state, curReport, "Pump Mass Flow Rate", "", AggType::ValueWhenMaxMin);
    2707              :     }
    2708          758 :     if (ort->namedMonthly(57).show) {
    2709           48 :         curReport = AddMonthlyReport(state, "CondLoopDemandReportMonthly", 2, true);
    2710           96 :         AddMonthlyFieldSetInput(state, curReport, "Plant Supply Side Cooling Demand Rate", "", AggType::SumOrAvg);
    2711           96 :         AddMonthlyFieldSetInput(state, curReport, "Plant Supply Side Cooling Demand Rate", "", AggType::Maximum);
    2712           96 :         AddMonthlyFieldSetInput(state, curReport, "Plant Supply Side Inlet Temperature", "", AggType::ValueWhenMaxMin);
    2713           96 :         AddMonthlyFieldSetInput(state, curReport, "Plant Supply Side Outlet Temperature", "", AggType::ValueWhenMaxMin);
    2714           96 :         AddMonthlyFieldSetInput(state, curReport, "Plant Supply Side Heating Demand Rate", "", AggType::SumOrAvg);
    2715           96 :         AddMonthlyFieldSetInput(state, curReport, "Plant Supply Side Heating Demand Rate", "", AggType::Maximum);
    2716              :     }
    2717          758 :     if (ort->namedMonthly(58).show) {
    2718           48 :         curReport = AddMonthlyReport(state, "ZoneTemperatureOscillationReportMonthly", 2, true);
    2719           96 :         AddMonthlyFieldSetInput(state, curReport, "Zone Oscillating Temperatures Time", "", AggType::HoursNonZero);
    2720           96 :         AddMonthlyFieldSetInput(state, curReport, "Zone People Occupant Count", "", AggType::SumOrAverageHoursShown);
    2721              :     }
    2722          758 :     if (ort->namedMonthly(59).show) {
    2723           48 :         curReport = AddMonthlyReport(state, "AirLoopSystemEnergyAndWaterUseMonthly", 2, true);
    2724           96 :         AddMonthlyFieldSetInput(state, curReport, "Air System Hot Water Energy", "", AggType::SumOrAvg);
    2725           96 :         AddMonthlyFieldSetInput(state, curReport, "Air System Steam Energy", "", AggType::SumOrAvg);
    2726           96 :         AddMonthlyFieldSetInput(state, curReport, "Air System Chilled Water Energy", "", AggType::SumOrAvg);
    2727           96 :         AddMonthlyFieldSetInput(state, curReport, "Air System Electricity Energy", "", AggType::SumOrAvg);
    2728           96 :         AddMonthlyFieldSetInput(state, curReport, "Air System Natural Gas Energy", "", AggType::SumOrAvg);
    2729           96 :         AddMonthlyFieldSetInput(state, curReport, "Air System Water Volume", "", AggType::SumOrAvg);
    2730              :     }
    2731              : 
    2732          758 :     if (ort->namedMonthly(60).show) {
    2733           48 :         curReport = AddMonthlyReport(state, "AirLoopSystemComponentLoadsMonthly", 2, true);
    2734           96 :         AddMonthlyFieldSetInput(state, curReport, "Air System Fan Air Heating Energy", "", AggType::SumOrAvg);
    2735           96 :         AddMonthlyFieldSetInput(state, curReport, "Air System Cooling Coil Total Cooling Energy", "", AggType::SumOrAvg);
    2736           96 :         AddMonthlyFieldSetInput(state, curReport, "Air System Heating Coil Total Heating Energy", "", AggType::SumOrAvg);
    2737           96 :         AddMonthlyFieldSetInput(state, curReport, "Air System Heat Exchanger Total Heating Energy", "", AggType::SumOrAvg);
    2738           96 :         AddMonthlyFieldSetInput(state, curReport, "Air System Heat Exchanger Total Cooling Energy", "", AggType::SumOrAvg);
    2739           96 :         AddMonthlyFieldSetInput(state, curReport, "Air System Humidifier Total Heating Energy", "", AggType::SumOrAvg);
    2740           96 :         AddMonthlyFieldSetInput(state, curReport, "Air System Evaporative Cooler Total Cooling Energy", "", AggType::SumOrAvg);
    2741           96 :         AddMonthlyFieldSetInput(state, curReport, "Air System Desiccant Dehumidifier Total Cooling Energy", "", AggType::SumOrAvg);
    2742              :     }
    2743          758 :     if (ort->namedMonthly(61).show) {
    2744           48 :         curReport = AddMonthlyReport(state, "AirLoopSystemComponentEnergyUseMonthly", 2, true);
    2745           96 :         AddMonthlyFieldSetInput(state, curReport, "Air System Fan Electricity Energy", "", AggType::SumOrAvg);
    2746           96 :         AddMonthlyFieldSetInput(state, curReport, "Air System Heating Coil Hot Water Energy", "", AggType::SumOrAvg);
    2747           96 :         AddMonthlyFieldSetInput(state, curReport, "Air System Cooling Coil Chilled Water Energy", "", AggType::SumOrAvg);
    2748           96 :         AddMonthlyFieldSetInput(state, curReport, "Air System DX Heating Coil Electricity Energy", "", AggType::SumOrAvg);
    2749           96 :         AddMonthlyFieldSetInput(state, curReport, "Air System DX Cooling Coil Electricity Energy", "", AggType::SumOrAvg);
    2750           96 :         AddMonthlyFieldSetInput(state, curReport, "Air System Heating Coil Electricity Energy", "", AggType::SumOrAvg);
    2751           96 :         AddMonthlyFieldSetInput(state, curReport, "Air System Heating Coil Natural Gas Energy", "", AggType::SumOrAvg);
    2752           96 :         AddMonthlyFieldSetInput(state, curReport, "Air System Heating Coil Steam Energy", "", AggType::SumOrAvg);
    2753           96 :         AddMonthlyFieldSetInput(state, curReport, "Air System Humidifier Electricity Energy", "", AggType::SumOrAvg);
    2754           96 :         AddMonthlyFieldSetInput(state, curReport, "Air System Humidifier Natural Gas Energy", "", AggType::SumOrAvg);
    2755           96 :         AddMonthlyFieldSetInput(state, curReport, "Air System Evaporative Cooler Electricity Energy", "", AggType::SumOrAvg);
    2756           96 :         AddMonthlyFieldSetInput(state, curReport, "Air System Desiccant Dehumidifier Electricity Energy", "", AggType::SumOrAvg);
    2757              :     }
    2758          758 :     if (ort->namedMonthly(62).show) {
    2759           48 :         curReport = AddMonthlyReport(state, "MechanicalVentilationLoadsMonthly", 2, true);
    2760           96 :         AddMonthlyFieldSetInput(state, curReport, "Zone Mechanical Ventilation No Load Heat Removal Energy", "", AggType::SumOrAvg);
    2761           96 :         AddMonthlyFieldSetInput(state, curReport, "Zone Mechanical Ventilation Cooling Load Increase Energy", "", AggType::SumOrAvg);
    2762           96 :         AddMonthlyFieldSetInput(
    2763              :             state, curReport, "Zone Mechanical Ventilation Cooling Load Increase Due to Overheating Energy", "", AggType::SumOrAvg);
    2764           96 :         AddMonthlyFieldSetInput(state, curReport, "Zone Mechanical Ventilation Cooling Load Decrease Energy", "", AggType::SumOrAvg);
    2765           96 :         AddMonthlyFieldSetInput(state, curReport, "Zone Mechanical Ventilation No Load Heat Addition Energy", "", AggType::SumOrAvg);
    2766           96 :         AddMonthlyFieldSetInput(state, curReport, "Zone Mechanical Ventilation Heating Load Increase Energy", "", AggType::SumOrAvg);
    2767           96 :         AddMonthlyFieldSetInput(
    2768              :             state, curReport, "Zone Mechanical Ventilation Heating Load Increase Due to Overcooling Energy", "", AggType::SumOrAvg);
    2769           96 :         AddMonthlyFieldSetInput(state, curReport, "Zone Mechanical Ventilation Heating Load Decrease Energy", "", AggType::SumOrAvg);
    2770           96 :         AddMonthlyFieldSetInput(state, curReport, "Zone Mechanical Ventilation Air Changes per Hour", "", AggType::SumOrAvg);
    2771              :     }
    2772          758 :     if (ort->namedMonthly(63).show) {
    2773           50 :         curReport = AddMonthlyReport(state, "HeatEmissionsReportMonthly", 2, true);
    2774              :         // Place holder
    2775          100 :         AddMonthlyFieldSetInput(state, curReport, "Site Total Surface Heat Emission to Air", "", AggType::SumOrAvg);
    2776          100 :         AddMonthlyFieldSetInput(state, curReport, "Site Total Zone Exfiltration Heat Loss", "", AggType::SumOrAvg);
    2777          100 :         AddMonthlyFieldSetInput(state, curReport, "Site Total Zone Exhaust Air Heat Loss", "", AggType::SumOrAvg);
    2778          100 :         AddMonthlyFieldSetInput(state, curReport, "Air System Relief Air Total Heat Loss Energy", "", AggType::SumOrAvg);
    2779          100 :         AddMonthlyFieldSetInput(state, curReport, "HVAC System Total Heat Rejection Energy", "", AggType::SumOrAvg);
    2780              :     }
    2781          758 : }
    2782              : 
    2783          799 : 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          799 :     Sched::Schedule *ffSched = nullptr;
    2825              : 
    2826          799 :     auto &ort = state.dataOutRptTab;
    2827              : 
    2828              :     // set the default factors for source energy - they will be overwritten if the user sets any values
    2829          799 :     ort->sourceFactorElectric = 3.167;
    2830          799 :     ort->sourceFactorNaturalGas = 1.084;
    2831          799 :     ort->sourceFactorDistrictHeatingSteam = 1.20;
    2832          799 :     ort->sourceFactorGasoline = 1.05;
    2833          799 :     ort->sourceFactorDiesel = 1.05;
    2834          799 :     ort->sourceFactorCoal = 1.05;
    2835          799 :     ort->sourceFactorFuelOil1 = 1.05;
    2836          799 :     ort->sourceFactorFuelOil2 = 1.05;
    2837          799 :     ort->sourceFactorPropane = 1.05;
    2838          799 :     ort->sourceFactorOtherFuel1 = 1.0;
    2839          799 :     ort->sourceFactorOtherFuel2 = 1.0;
    2840              :     // the following should be kept consistent with the assumptions in the pollution calculation routines
    2841          799 :     ort->efficiencyDistrictCooling = 3.0;
    2842          799 :     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          799 :     GetFuelFactorInfo(state, Constant::eFuel::NaturalGas, fuelFactorUsed, curSourceFactor, fFScheduleUsed, &ffSched);
    2858          799 :     if (fuelFactorUsed) {
    2859           79 :         ort->sourceFactorNaturalGas = curSourceFactor;
    2860           79 :         ort->fuelfactorsused(2) = true;
    2861           79 :         ort->ffUsed(2) = true;
    2862              :     }
    2863          799 :     ort->SourceFactors(2) = curSourceFactor;
    2864          799 :     if (fFScheduleUsed) {
    2865            1 :         ort->fuelFactorSchedulesUsed = true;
    2866            1 :         ort->ffSchedUsed(2) = true;
    2867            1 :         ort->ffScheds(2) = ffSched;
    2868              :     }
    2869              : 
    2870          799 :     GetFuelFactorInfo(state, Constant::eFuel::FuelOilNo2, fuelFactorUsed, curSourceFactor, fFScheduleUsed, &ffSched);
    2871          799 :     if (fuelFactorUsed) {
    2872            0 :         ort->sourceFactorFuelOil2 = curSourceFactor;
    2873            0 :         ort->fuelfactorsused(7) = true;
    2874            0 :         ort->ffUsed(11) = true;
    2875              :     }
    2876          799 :     ort->SourceFactors(11) = curSourceFactor;
    2877          799 :     if (fFScheduleUsed) {
    2878            0 :         ort->fuelFactorSchedulesUsed = true;
    2879            0 :         ort->ffSchedUsed(11) = true;
    2880            0 :         ort->ffScheds(11) = ffSched;
    2881              :     }
    2882              : 
    2883          799 :     GetFuelFactorInfo(state, Constant::eFuel::FuelOilNo1, fuelFactorUsed, curSourceFactor, fFScheduleUsed, &ffSched);
    2884          799 :     if (fuelFactorUsed) {
    2885           22 :         ort->sourceFactorFuelOil1 = curSourceFactor;
    2886           22 :         ort->fuelfactorsused(6) = true;
    2887           22 :         ort->ffUsed(10) = true;
    2888              :     }
    2889          799 :     ort->SourceFactors(10) = curSourceFactor;
    2890          799 :     if (fFScheduleUsed) {
    2891            0 :         ort->fuelFactorSchedulesUsed = true;
    2892            0 :         ort->ffSchedUsed(10) = true;
    2893            0 :         ort->ffScheds(10) = ffSched;
    2894              :     }
    2895              : 
    2896          799 :     GetFuelFactorInfo(state, Constant::eFuel::Coal, fuelFactorUsed, curSourceFactor, fFScheduleUsed, &ffSched);
    2897          799 :     if (fuelFactorUsed) {
    2898            0 :         ort->sourceFactorCoal = curSourceFactor;
    2899            0 :         ort->fuelfactorsused(5) = true;
    2900            0 :         ort->ffUsed(9) = true;
    2901              :     }
    2902          799 :     ort->SourceFactors(9) = curSourceFactor;
    2903          799 :     if (fFScheduleUsed) {
    2904            0 :         ort->fuelFactorSchedulesUsed = true;
    2905            0 :         ort->ffSchedUsed(9) = true;
    2906            0 :         ort->ffScheds(9) = ffSched;
    2907              :     }
    2908              : 
    2909          799 :     GetFuelFactorInfo(state, Constant::eFuel::Electricity, fuelFactorUsed, curSourceFactor, fFScheduleUsed, &ffSched);
    2910          799 :     if (fuelFactorUsed) {
    2911           88 :         ort->sourceFactorElectric = curSourceFactor;
    2912           88 :         ort->fuelfactorsused(1) = true;
    2913           88 :         ort->ffUsed(1) = true;
    2914              :     }
    2915          799 :     ort->SourceFactors(1) = curSourceFactor;
    2916          799 :     if (fFScheduleUsed) {
    2917            1 :         ort->fuelFactorSchedulesUsed = true;
    2918            1 :         ort->ffSchedUsed(1) = true;
    2919            1 :         ort->ffScheds(1) = ffSched;
    2920              :     }
    2921              : 
    2922          799 :     GetFuelFactorInfo(state, Constant::eFuel::Gasoline, fuelFactorUsed, curSourceFactor, fFScheduleUsed, &ffSched);
    2923          799 :     if (fuelFactorUsed) {
    2924            0 :         ort->sourceFactorGasoline = curSourceFactor;
    2925            0 :         ort->fuelfactorsused(3) = true;
    2926            0 :         ort->ffUsed(6) = true;
    2927              :     }
    2928          799 :     ort->SourceFactors(6) = curSourceFactor;
    2929          799 :     if (fFScheduleUsed) {
    2930            0 :         ort->fuelFactorSchedulesUsed = true;
    2931            0 :         ort->ffSchedUsed(6) = true;
    2932            0 :         ort->ffScheds(6) = ffSched;
    2933              :     }
    2934              : 
    2935          799 :     GetFuelFactorInfo(state, Constant::eFuel::Propane, fuelFactorUsed, curSourceFactor, fFScheduleUsed, &ffSched);
    2936          799 :     if (fuelFactorUsed) {
    2937           22 :         ort->sourceFactorPropane = curSourceFactor;
    2938           22 :         ort->fuelfactorsused(8) = true;
    2939           22 :         ort->ffUsed(12) = true;
    2940              :     }
    2941          799 :     ort->SourceFactors(12) = curSourceFactor;
    2942          799 :     if (fFScheduleUsed) {
    2943            0 :         ort->fuelFactorSchedulesUsed = true;
    2944            0 :         ort->ffSchedUsed(12) = true;
    2945            0 :         ort->ffScheds(12) = ffSched;
    2946              :     }
    2947              : 
    2948          799 :     GetFuelFactorInfo(state, Constant::eFuel::Diesel, fuelFactorUsed, curSourceFactor, fFScheduleUsed, &ffSched);
    2949          799 :     if (fuelFactorUsed) {
    2950            2 :         ort->sourceFactorDiesel = curSourceFactor;
    2951            2 :         ort->fuelfactorsused(4) = true;
    2952            2 :         ort->ffUsed(8) = true;
    2953              :     }
    2954          799 :     ort->SourceFactors(8) = curSourceFactor;
    2955          799 :     if (fFScheduleUsed) {
    2956            0 :         ort->fuelFactorSchedulesUsed = true;
    2957            0 :         ort->ffSchedUsed(8) = true;
    2958            0 :         ort->ffScheds(8) = ffSched;
    2959              :     }
    2960              : 
    2961          799 :     GetFuelFactorInfo(state, Constant::eFuel::DistrictCooling, fuelFactorUsed, curSourceFactor, fFScheduleUsed, &ffSched);
    2962          799 :     if (fuelFactorUsed) {
    2963           88 :         ort->ffUsed(3) = true;
    2964              :     }
    2965          799 :     ort->SourceFactors(3) = curSourceFactor;
    2966          799 :     if (fFScheduleUsed) {
    2967            1 :         ort->ffSchedUsed(3) = true;
    2968            1 :         ort->ffScheds(3) = ffSched;
    2969              :     }
    2970              : 
    2971          799 :     GetFuelFactorInfo(state, Constant::eFuel::DistrictHeatingWater, fuelFactorUsed, curSourceFactor, fFScheduleUsed, &ffSched);
    2972          799 :     if (fuelFactorUsed) {
    2973           79 :         ort->ffUsed(4) = true;
    2974              :     }
    2975          799 :     ort->SourceFactors(4) = curSourceFactor;
    2976          799 :     if (fFScheduleUsed) {
    2977            1 :         ort->ffSchedUsed(4) = true;
    2978            1 :         ort->ffScheds(4) = ffSched;
    2979              :     }
    2980              : 
    2981          799 :     GetFuelFactorInfo(state, Constant::eFuel::DistrictHeatingSteam, fuelFactorUsed, curSourceFactor, fFScheduleUsed, &ffSched);
    2982          799 :     if (fuelFactorUsed) {
    2983           79 :         ort->ffUsed(5) = true;
    2984              :     }
    2985          799 :     ort->SourceFactors(5) = curSourceFactor;
    2986          799 :     if (fFScheduleUsed) {
    2987            1 :         ort->ffSchedUsed(5) = true;
    2988            1 :         ort->ffScheds(5) = ffSched;
    2989              :     }
    2990              : 
    2991          799 :     GetFuelFactorInfo(state, Constant::eFuel::OtherFuel1, fuelFactorUsed, curSourceFactor, fFScheduleUsed, &ffSched);
    2992          799 :     if (fuelFactorUsed) {
    2993            1 :         ort->sourceFactorOtherFuel1 = curSourceFactor;
    2994            1 :         ort->fuelfactorsused(11) = true; // should be source number
    2995            1 :         ort->ffUsed(13) = true;
    2996              :     }
    2997          799 :     ort->SourceFactors(13) = curSourceFactor;
    2998          799 :     if (fFScheduleUsed) {
    2999            0 :         ort->fuelFactorSchedulesUsed = true;
    3000            0 :         ort->ffSchedUsed(13) = true;
    3001            0 :         ort->ffScheds(13) = ffSched;
    3002              :     }
    3003              : 
    3004          799 :     GetFuelFactorInfo(state, Constant::eFuel::OtherFuel2, fuelFactorUsed, curSourceFactor, fFScheduleUsed, &ffSched);
    3005          799 :     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          799 :     ort->SourceFactors(14) = curSourceFactor;
    3011          799 :     if (fFScheduleUsed) {
    3012            0 :         ort->fuelFactorSchedulesUsed = true;
    3013            0 :         ort->ffSchedUsed(14) = true;
    3014            0 :         ort->ffScheds(14) = ffSched;
    3015              :     }
    3016              : 
    3017          799 :     GetEnvironmentalImpactFactorInfo(
    3018          799 :         state, ort->efficiencyDistrictHeatingWater, ort->efficiencyDistrictCooling, ort->sourceFactorDistrictHeatingSteam);
    3019          799 : }
    3020              : 
    3021              : //======================================================================================================================
    3022              : //======================================================================================================================
    3023              : 
    3024              : //    OTHER INITIALIZATION ROUTINES
    3025              : 
    3026              : //======================================================================================================================
    3027              : //======================================================================================================================
    3028              : 
    3029          799 : 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          799 :     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          799 :     if (ort->WriteTabularFiles && state.files.outputControl.tabular) {
    3050         1626 :         for (int iStyle = 1; iStyle <= ort->numStyles; ++iStyle) {
    3051          867 :             std::string const &curDel = ort->del(iStyle);
    3052          867 :             if (ort->TableStyle(iStyle) == TableStyle::Comma) {
    3053           56 :                 DisplayString(state, "Writing tabular output file results using comma format.");
    3054              :                 std::ofstream &tbl_stream =
    3055           56 :                     open_tbl_stream(state, iStyle, state.dataStrGlobals->outputTblCsvFilePath, state.files.outputControl.tabular);
    3056           56 :                 tbl_stream << "Program Version:" << curDel << state.dataStrGlobals->VerStringVar << '\n';
    3057           56 :                 tbl_stream << "Tabular Output Report in Format: " << curDel << "Comma\n";
    3058           56 :                 tbl_stream << '\n';
    3059           56 :                 tbl_stream << "Building:" << curDel << state.dataHeatBal->BuildingName << '\n';
    3060           56 :                 if (state.dataEnvrn->EnvironmentName == state.dataEnvrn->WeatherFileLocationTitle) {
    3061            0 :                     tbl_stream << "Environment:" << curDel << state.dataEnvrn->EnvironmentName << '\n';
    3062              :                 } else {
    3063          224 :                     tbl_stream << "Environment:" << curDel << state.dataEnvrn->EnvironmentName << " ** " << state.dataEnvrn->WeatherFileLocationTitle
    3064           56 :                                << '\n';
    3065              :                 }
    3066           56 :                 tbl_stream << '\n';
    3067          811 :             } else if (ort->TableStyle(iStyle) == TableStyle::Tab) {
    3068           24 :                 DisplayString(state, "Writing tabular output file results using tab format.");
    3069              :                 std::ofstream &tbl_stream =
    3070           24 :                     open_tbl_stream(state, iStyle, state.dataStrGlobals->outputTblTabFilePath, state.files.outputControl.tabular);
    3071           24 :                 tbl_stream << "Program Version" << curDel << state.dataStrGlobals->VerStringVar << '\n';
    3072           24 :                 tbl_stream << "Tabular Output Report in Format: " << curDel << "Tab\n";
    3073           24 :                 tbl_stream << '\n';
    3074           24 :                 tbl_stream << "Building:" << curDel << state.dataHeatBal->BuildingName << '\n';
    3075           24 :                 if (state.dataEnvrn->EnvironmentName == state.dataEnvrn->WeatherFileLocationTitle) {
    3076            0 :                     tbl_stream << "Environment:" << curDel << state.dataEnvrn->EnvironmentName << '\n';
    3077              :                 } else {
    3078           96 :                     tbl_stream << "Environment:" << curDel << state.dataEnvrn->EnvironmentName << " ** " << state.dataEnvrn->WeatherFileLocationTitle
    3079           24 :                                << '\n';
    3080              :                 }
    3081           24 :                 tbl_stream << '\n';
    3082          787 :             } else if (ort->TableStyle(iStyle) == TableStyle::HTML) {
    3083          748 :                 DisplayString(state, "Writing tabular output file results using HTML format.");
    3084              :                 std::ofstream &tbl_stream =
    3085          748 :                     open_tbl_stream(state, iStyle, state.dataStrGlobals->outputTblHtmFilePath, state.files.outputControl.tabular);
    3086          748 :                 tbl_stream << "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"\"http://www.w3.org/TR/html4/loose.dtd\">\n";
    3087          748 :                 tbl_stream << "<html>\n";
    3088          748 :                 tbl_stream << "<head>\n";
    3089          748 :                 if (state.dataEnvrn->EnvironmentName == state.dataEnvrn->WeatherFileLocationTitle) {
    3090            0 :                     tbl_stream << "<title> " << state.dataHeatBal->BuildingName << ' ' << state.dataEnvrn->EnvironmentName << '\n';
    3091              :                 } else {
    3092         2992 :                     tbl_stream << "<title> " << state.dataHeatBal->BuildingName << ' ' << state.dataEnvrn->EnvironmentName << " ** "
    3093          748 :                                << state.dataEnvrn->WeatherFileLocationTitle << '\n';
    3094              :                 }
    3095          748 :                 tbl_stream << "  " << std::setw(4) << ort->td(1) << '-' << std::setfill('0') << std::setw(2) << ort->td(2) << '-' << std::setw(2)
    3096          748 :                            << ort->td(3) << '\n';
    3097          748 :                 tbl_stream << "  " << std::setw(2) << ort->td(5) << ':' << std::setw(2) << ort->td(6) << ':' << std::setw(2) << ort->td(7)
    3098          748 :                            << std::setfill(' ') << '\n';
    3099          748 :                 tbl_stream << " - EnergyPlus</title>\n";
    3100          748 :                 tbl_stream << "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">\n";
    3101          748 :                 tbl_stream << "</head>\n";
    3102          748 :                 tbl_stream << "<body>\n";
    3103          748 :                 tbl_stream << "<p><a href=\"#toc\" style=\"float: right\">Table of Contents</a></p>\n";
    3104          748 :                 tbl_stream << "<a name=top></a>\n";
    3105          748 :                 tbl_stream << "<p>Program Version:<b>" << state.dataStrGlobals->VerStringVar << "</b></p>\n";
    3106          748 :                 tbl_stream << "<p>Tabular Output Report in Format: <b>HTML</b></p>\n";
    3107          748 :                 tbl_stream << "<p>Building: <b>" << state.dataHeatBal->BuildingName << "</b></p>\n";
    3108          748 :                 if (state.dataEnvrn->EnvironmentName == state.dataEnvrn->WeatherFileLocationTitle) {
    3109            0 :                     tbl_stream << "<p>Environment: <b>" << ConvertToEscaped(state.dataEnvrn->EnvironmentName, false) << "</b></p>\n";
    3110              :                 } else {
    3111         1496 :                     tbl_stream << "<p>Environment: <b>" << ConvertToEscaped(state.dataEnvrn->EnvironmentName, false) << " ** "
    3112         1496 :                                << ConvertToEscaped(state.dataEnvrn->WeatherFileLocationTitle, false) << "</b></p>\n";
    3113              :                 }
    3114          748 :                 tbl_stream << "<p>Simulation Timestamp: <b>" << std::setw(4) << ort->td(1) << '-' << std::setfill('0') << std::setw(2) << ort->td(2)
    3115          748 :                            << '-' << std::setw(2) << ort->td(3) << '\n';
    3116          748 :                 tbl_stream << "  " << std::setw(2) << ort->td(5) << ':' << std::setw(2) << ort->td(6) << ':' << std::setw(2) << ort->td(7)
    3117          748 :                            << std::setfill(' ') << "</b></p>\n";
    3118           39 :             } else if (ort->TableStyle(iStyle) == TableStyle::XML) {
    3119           20 :                 DisplayString(state, "Writing tabular output file results using XML format.");
    3120              :                 std::ofstream &tbl_stream =
    3121           20 :                     open_tbl_stream(state, iStyle, state.dataStrGlobals->outputTblXmlFilePath, state.files.outputControl.tabular);
    3122           20 :                 tbl_stream << "<?xml version=\"1.0\"?>\n";
    3123           20 :                 tbl_stream << "<EnergyPlusTabularReports>\n";
    3124           20 :                 tbl_stream << "  <BuildingName>" << ConvertToEscaped(state.dataHeatBal->BuildingName) << "</BuildingName>\n";
    3125           20 :                 tbl_stream << "  <EnvironmentName>" << state.dataEnvrn->EnvironmentName << "</EnvironmentName>\n";
    3126           20 :                 tbl_stream << "  <WeatherFileLocationTitle>" << state.dataEnvrn->WeatherFileLocationTitle << "</WeatherFileLocationTitle>\n";
    3127           20 :                 tbl_stream << "  <ProgramVersion>" << state.dataStrGlobals->VerStringVar << "</ProgramVersion>\n";
    3128           20 :                 tbl_stream << "  <SimulationTimestamp>\n";
    3129           20 :                 tbl_stream << "    <Date>\n";
    3130           20 :                 tbl_stream << "      " << std::setw(4) << ort->td(1) << '-' << std::setfill('0') << std::setw(2) << ort->td(2) << '-' << std::setw(2)
    3131           20 :                            << ort->td(3) << '\n';
    3132           20 :                 tbl_stream << "    </Date>\n";
    3133           20 :                 tbl_stream << "    <Time>\n";
    3134           20 :                 tbl_stream << "      " << std::setw(2) << ort->td(5) << ':' << std::setw(2) << ort->td(6) << ':' << std::setw(2) << ort->td(7)
    3135           20 :                            << std::setfill(' ') << '\n';
    3136           20 :                 tbl_stream << "    </Time>\n";
    3137           20 :                 tbl_stream << "  </SimulationTimestamp>\n";
    3138           20 :                 tbl_stream << '\n';
    3139              :             } else {
    3140           19 :                 DisplayString(state, "Writing tabular output file results using text format.");
    3141              :                 std::ofstream &tbl_stream =
    3142           19 :                     open_tbl_stream(state, iStyle, state.dataStrGlobals->outputTblTxtFilePath, state.files.outputControl.tabular);
    3143           19 :                 tbl_stream << "Program Version: " << state.dataStrGlobals->VerStringVar << '\n';
    3144           19 :                 tbl_stream << "Tabular Output Report in Format: " << curDel << "Fixed\n";
    3145           19 :                 tbl_stream << '\n';
    3146           19 :                 tbl_stream << "Building:        " << state.dataHeatBal->BuildingName << '\n';
    3147           19 :                 if (state.dataEnvrn->EnvironmentName == state.dataEnvrn->WeatherFileLocationTitle) {
    3148            0 :                     tbl_stream << "Environment:     " << state.dataEnvrn->EnvironmentName << '\n';
    3149              :                 } else {
    3150           76 :                     tbl_stream << "Environment:     " << state.dataEnvrn->EnvironmentName << " ** " << state.dataEnvrn->WeatherFileLocationTitle
    3151           19 :                                << '\n';
    3152              :                 }
    3153           19 :                 tbl_stream << '\n';
    3154              :             }
    3155              :         }
    3156              :     }
    3157          799 : }
    3158              : 
    3159          799 : 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          799 :     auto &ort = state.dataOutRptTab;
    3195              : 
    3196          799 :     if (ort->WriteTabularFiles) {
    3197         1626 :         for (int iStyle = 1; iStyle <= ort->numStyles; ++iStyle) {
    3198          867 :             std::ofstream &tbl_stream(*ort->TabularOutputFile(iStyle));
    3199          867 :             if (ort->TableStyle(iStyle) == TableStyle::HTML) { // if HTML file put ending info
    3200          748 :                 tbl_stream << "</body>\n";
    3201          748 :                 tbl_stream << "</html>\n";
    3202          119 :             } else if (ort->TableStyle(iStyle) == TableStyle::XML) {
    3203           20 :                 if (!ort->prevReportName.empty()) {
    3204           20 :                     tbl_stream << "</" << ort->prevReportName << ">\n"; // close the last element if it was used.
    3205              :                 }
    3206           20 :                 tbl_stream << "</EnergyPlusTabularReports>\n";
    3207              :             }
    3208          867 :             tbl_stream.close();
    3209              :         }
    3210              :     }
    3211          799 : }
    3212              : 
    3213          759 : 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         2277 :     static std::string const Entire_Facility("Entire Facility");
    3229         2277 :     static std::string const Annual_Building_Utility_Performance_Summary("Annual Building Utility Performance Summary");
    3230         2277 :     static std::string const Input_Verification_and_Results_Summary("Input Verification and Results Summary");
    3231         2277 :     static std::string const Demand_End_Use_Components_Summary("Demand End Use Components Summary");
    3232         2277 :     static std::string const Source_Energy_End_Use_Components_Summary("Source Energy End Use Components Summary");
    3233         2277 :     static std::string const Component_Cost_Economics_Summary("Component Cost Economics Summary");
    3234         2277 :     static std::string const Component_Sizing_Summary("Component Sizing Summary");
    3235         2277 :     static std::string const Surface_Shadowing_Summary("Surface Shadowing Summary");
    3236         2277 :     static std::string const Adaptive_Comfort_Summary("Adaptive Comfort Summary");
    3237         2277 :     static std::string const Initialization_Summary("Initialization Summary");
    3238         2277 :     static std::string const Annual_Heat_Emissions_Summary("Annual Heat Emissions Summary");
    3239         2277 :     static std::string const Annual_Thermal_Resilience_Summary("Annual Thermal Resilience Summary");
    3240         2277 :     static std::string const Annual_CO2_Resilience_Summary("Annual CO2 Resilience Summary");
    3241         2277 :     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          759 :     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          759 :     if (ort->displayLifeCycleCostReport && state.dataEconLifeCycleCost->LCCparamPresent) {
    3254            4 :         AddTOCEntry(state, "Life-Cycle Cost Report", "Entire Facility");
    3255              :     }
    3256              : 
    3257         1626 :     for (int iStyle = 1; iStyle <= ort->numStyles; ++iStyle) {
    3258          867 :         if (ort->TableStyle(iStyle) == TableStyle::HTML) {
    3259          748 :             std::ostream &tbl_stream(*ort->TabularOutputFile(iStyle));
    3260          748 :             tbl_stream << "<hr>\n";
    3261          748 :             tbl_stream << "<a name=toc></a>\n";
    3262          748 :             tbl_stream << "<p><b>Table of Contents</b></p>\n";
    3263          748 :             tbl_stream << "<a href=\"#top\">Top</a>\n";
    3264          748 :             if (ort->displayTabularBEPS) {
    3265          747 :                 tbl_stream << "<br><a href=\"#" << MakeAnchorName(Annual_Building_Utility_Performance_Summary, Entire_Facility)
    3266          747 :                            << "\">Annual Building Utility Performance Summary</a>\n";
    3267              :             }
    3268          748 :             if (ort->displayTabularVeriSum) {
    3269          738 :                 tbl_stream << "<br><a href=\"#" << MakeAnchorName(Input_Verification_and_Results_Summary, Entire_Facility)
    3270          738 :                            << "\">Input Verification and Results Summary</a>\n";
    3271              :             }
    3272          748 :             if (ort->displayDemandEndUse) {
    3273          670 :                 tbl_stream << "<br><a href=\"#" << MakeAnchorName(Demand_End_Use_Components_Summary, Entire_Facility)
    3274          670 :                            << "\">Demand End Use Components Summary</a>\n";
    3275              :             }
    3276          748 :             if (ort->displaySourceEnergyEndUseSummary) {
    3277          667 :                 tbl_stream << "<br><a href=\"#" << MakeAnchorName(Source_Energy_End_Use_Components_Summary, Entire_Facility)
    3278          667 :                            << "\">Source Energy End Use Components Summary</a>\n";
    3279              :             }
    3280          748 :             if (state.dataCostEstimateManager->DoCostEstimate) {
    3281           40 :                 tbl_stream << "<br><a href=\"#" << MakeAnchorName(Component_Cost_Economics_Summary, Entire_Facility)
    3282           40 :                            << "\">Component Cost Economics Summary</a>\n";
    3283              :             }
    3284          748 :             if (ort->displayComponentSizing) {
    3285          727 :                 tbl_stream << "<br><a href=\"#" << MakeAnchorName(Component_Sizing_Summary, Entire_Facility) << "\">Component Sizing Summary</a>\n";
    3286              :             }
    3287          748 :             if (ort->displaySurfaceShadowing) {
    3288          667 :                 tbl_stream << "<br><a href=\"#" << MakeAnchorName(Surface_Shadowing_Summary, Entire_Facility) << "\">Surface Shadowing Summary</a>\n";
    3289              :             }
    3290          748 :             if (ort->displayAdaptiveComfort) {
    3291          667 :                 tbl_stream << "<br><a href=\"#" << MakeAnchorName(Adaptive_Comfort_Summary, Entire_Facility) << "\">Adaptive Comfort Summary</a>\n";
    3292              :             }
    3293          748 :             if (ort->displayEioSummary) {
    3294          668 :                 tbl_stream << "<br><a href=\"#" << MakeAnchorName(Initialization_Summary, Entire_Facility) << "\">Initialization Summary</a>\n";
    3295              :             }
    3296          748 :             if (ort->displayHeatEmissionsSummary) {
    3297          668 :                 tbl_stream << "<br><a href=\"#" << MakeAnchorName(Annual_Heat_Emissions_Summary, Entire_Facility)
    3298          668 :                            << "\">Annual Heat Emissions Summary</a>\n";
    3299              :             }
    3300          748 :             if (ort->displayThermalResilienceSummary) {
    3301          670 :                 tbl_stream << "<br><a href=\"#" << MakeAnchorName(Annual_Thermal_Resilience_Summary, Entire_Facility)
    3302          670 :                            << "\">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        13884 :             for (int kReport = 1; kReport <= state.dataOutRptPredefined->numReportName; ++kReport) {
    3313        13136 :                 if (state.dataOutRptPredefined->reportName(kReport).show) {
    3314        24054 :                     tbl_stream << "<br><a href=\"#" << MakeAnchorName(state.dataOutRptPredefined->reportName(kReport).namewithspaces, Entire_Facility)
    3315        24054 :                                << "\">" << state.dataOutRptPredefined->reportName(kReport).namewithspaces << "</a>\n";
    3316              :                 }
    3317              :             }
    3318          748 :             if (state.dataGlobal->DoWeathSim) {
    3319           11 :                 for (int iInput = 1; iInput <= ort->MonthlyInputCount; ++iInput) {
    3320            5 :                     if (ort->MonthlyInput(iInput).numTables > 0) {
    3321            5 :                         tbl_stream << "<p><b>" << ort->MonthlyInput(iInput).name << "</b></p> |\n";
    3322           10 :                         for (int jTable = 1; jTable <= ort->MonthlyInput(iInput).numTables; ++jTable) {
    3323            5 :                             int const curTable = jTable + ort->MonthlyInput(iInput).firstTable - 1;
    3324           10 :                             tbl_stream << "<a href=\"#" << MakeAnchorName(ort->MonthlyInput(iInput).name, ort->MonthlyTables(curTable).keyValue)
    3325           10 :                                        << "\">" << ort->MonthlyTables(curTable).keyValue << "</a>    |   \n";
    3326              :                         }
    3327              :                     }
    3328              :                 }
    3329            6 :                 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            6 :                 OutputReportTabularAnnual::AddAnnualTableOfContents(state, tbl_stream);
    3364              :             }
    3365              :             // add entries specifically added using AddTOCEntry
    3366         1075 :             for (int iEntry = 1; iEntry <= ort->TOCEntriesCount; ++iEntry) {
    3367          327 :                 if (!ort->TOCEntries(iEntry).isWritten) {
    3368           98 :                     std::string const &curSection = ort->TOCEntries(iEntry).sectionName;
    3369           98 :                     tbl_stream << "<p><b>" << curSection << "</b></p> |\n";
    3370          477 :                     for (int jEntry = iEntry; jEntry <= ort->TOCEntriesCount; ++jEntry) {
    3371          379 :                         if (!ort->TOCEntries(jEntry).isWritten) {
    3372          379 :                             if (ort->TOCEntries(jEntry).sectionName == curSection) {
    3373          654 :                                 tbl_stream << "<a href=\"#" << MakeAnchorName(ort->TOCEntries(jEntry).sectionName, ort->TOCEntries(jEntry).reportName)
    3374          654 :                                            << "\">" << ort->TOCEntries(jEntry).reportName << "</a>   |  \n";
    3375          327 :                                 ort->TOCEntries(jEntry).isWritten = true;
    3376              :                             }
    3377              :                         }
    3378              :                     }
    3379              :                 }
    3380              :             }
    3381              : 
    3382          748 :             if (state.dataWeather->TotReportPers > 0) {
    3383            4 :                 std::string ReportPeriodSummary = "Reporting Period Summary";
    3384            4 :                 tbl_stream << "<br><a href=\"#" << MakeAnchorName(ReportPeriodSummary, Entire_Facility) << "\">" << "Reporting Period Summary"
    3385            4 :                            << "</a>\n";
    3386            8 :                 AddTOCReportPeriod(state.dataWeather->TotThermalReportPers, "Thermal", state.dataWeather->ThermalReportPeriodInput, tbl_stream);
    3387            8 :                 AddTOCReportPeriod(state.dataWeather->TotCO2ReportPers, "CO2", state.dataWeather->CO2ReportPeriodInput, tbl_stream);
    3388            8 :                 AddTOCReportPeriod(state.dataWeather->TotVisualReportPers, "Visual", state.dataWeather->VisualReportPeriodInput, tbl_stream);
    3389            4 :             }
    3390              :         }
    3391              :     }
    3392          759 : }
    3393              : 
    3394           12 : void AddTOCReportPeriod(const int nReportPeriods,
    3395              :                         const std::string &kw,
    3396              :                         const Array1D<Weather::ReportPeriodData> &ReportPeriodInputData,
    3397              :                         std::ostream &tbl_stream)
    3398              : {
    3399           20 :     static std::string const Entire_Facility("Entire Facility");
    3400           23 :     for (int i = 1; i <= nReportPeriods; i++) {
    3401              :         std::string ReportPeriod_Resilience_Summary = fmt::format(
    3402           11 :             "{} Resilience Summary for Reporting Period {}: {}", kw, i, ReportPeriodInputData(i).title, ReportPeriodInputData(i).totalElectricityUse);
    3403           11 :         tbl_stream << "<br><a href=\"#" << MakeAnchorName(ReportPeriod_Resilience_Summary, Entire_Facility) << "\">" << kw
    3404           11 :                    << " Resilience Summary for Reporting Period " << i << ": " << ReportPeriodInputData(i).title << "</a>\n";
    3405           11 :     }
    3406           12 : }
    3407              : 
    3408              : //======================================================================================================================
    3409              : //======================================================================================================================
    3410              : 
    3411              : //    GATHER DATA EACH TIME STEP ROUTINES
    3412              : 
    3413              : //======================================================================================================================
    3414              : //======================================================================================================================
    3415              : 
    3416       497501 : 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       497501 :     auto &ort = state.dataOutRptTab;
    3443              : 
    3444       497501 :     if (!state.dataGlobal->DoWeathSim) {
    3445            0 :         return;
    3446              :     }
    3447              : 
    3448              :     Real64 const elapsedTime =
    3449       497501 :         (t_timeStepType == OutputProcessor::TimeStepType::System) ? state.dataHVACGlobal->TimeStepSys : state.dataGlobal->TimeStepZone;
    3450              : 
    3451       497501 :     ort->timeInYear += state.dataHVACGlobal->TimeStepSys;
    3452              : 
    3453       497501 :     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       497501 : 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       497501 :     Real64 const TimeStepSysSec = state.dataHVACGlobal->TimeStepSysSec;
    3531              :     using General::EncodeMonDayHrMin;
    3532              : 
    3533              :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
    3534              : 
    3535       497501 :     if (!state.dataGlobal->DoWeathSim) {
    3536            0 :         return;
    3537              :     }
    3538              : 
    3539       497501 :     auto &ort = state.dataOutRptTab;
    3540       497501 :     assert(state.dataGlobal->TimeStepZoneSec > 0.0);
    3541              : 
    3542              :     // create temporary arrays to speed processing of these arrays
    3543       497501 :     if (ort->GatherMonthlyResultsForTimestepRunOnce) {
    3544              :         // MonthlyColumns
    3545            6 :         state.dataOutRptTab->MonthlyColumnsTypeOfVar.allocate(ort->MonthlyColumns.I());
    3546            6 :         state.dataOutRptTab->MonthlyColumnsStepType.allocate(ort->MonthlyColumns.I());
    3547            6 :         state.dataOutRptTab->MonthlyColumnsAggType.allocate(ort->MonthlyColumns.I());
    3548            6 :         state.dataOutRptTab->MonthlyColumnsVarNum.allocate(ort->MonthlyColumns.I());
    3549           11 :         for (int i = ort->MonthlyColumns.l(), e = ort->MonthlyColumns.u(); i <= e; ++i) {
    3550            5 :             auto const &col = ort->MonthlyColumns(i);
    3551            5 :             state.dataOutRptTab->MonthlyColumnsTypeOfVar(i) = col.typeOfVar;
    3552            5 :             state.dataOutRptTab->MonthlyColumnsStepType(i) = col.stepType;
    3553            5 :             state.dataOutRptTab->MonthlyColumnsAggType(i) = col.aggType;
    3554            5 :             state.dataOutRptTab->MonthlyColumnsVarNum(i) = col.varNum;
    3555              :         }
    3556              : 
    3557              :         // MonthlyTables
    3558            6 :         state.dataOutRptTab->MonthlyTablesNumColumns.allocate(ort->MonthlyTables.I());
    3559           11 :         for (int i = ort->MonthlyTables.l(), e = ort->MonthlyTables.u(); i <= e; ++i) {
    3560            5 :             state.dataOutRptTab->MonthlyTablesNumColumns(i) = ort->MonthlyTables(i).numColumns;
    3561              :         }
    3562              : 
    3563              :         // set flag so this block is only executed once
    3564            6 :         ort->GatherMonthlyResultsForTimestepRunOnce = false;
    3565              :     }
    3566              : 
    3567              :     Real64 const elapsedTime =
    3568       497501 :         (t_timeStepType == OutputProcessor::TimeStepType::System) ? state.dataHVACGlobal->TimeStepSys : state.dataGlobal->TimeStepZone;
    3569              : 
    3570       497501 :     ort->IsMonthGathered(state.dataEnvrn->Month) = true;
    3571       585101 :     for (int iTable = 1; iTable <= ort->MonthlyTablesCount; ++iTable) {
    3572        87600 :         bool activeMinMax = false;     // at the beginning of the new timestep
    3573        87600 :         bool activeHoursShown = false; // fix by JG addressing CR6482
    3574        87600 :         state.dataOutRptTab->curFirstColumn = ort->MonthlyTables(iTable).firstColumn;
    3575       175200 :         for (int jColumn = 1; jColumn <= state.dataOutRptTab->MonthlyTablesNumColumns(iTable); ++jColumn) {
    3576        87600 :             int const curCol = jColumn + state.dataOutRptTab->curFirstColumn - 1;
    3577        87600 :             OutputProcessor::VariableType const curTypeOfVar = state.dataOutRptTab->MonthlyColumnsTypeOfVar(curCol);
    3578        87600 :             OutputProcessor::TimeStepType const curStepType = state.dataOutRptTab->MonthlyColumnsStepType(curCol);
    3579        87600 :             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        43800 :                 int const curVarNum = state.dataOutRptTab->MonthlyColumnsVarNum(curCol);
    3584        43800 :                 Real64 curValue = GetInternalVariableValue(state, curTypeOfVar, curVarNum);
    3585              :                 // Get the value from the result array
    3586        43800 :                 Real64 const &oldResultValue = ort->MonthlyColumns(curCol).reslt(state.dataEnvrn->Month);
    3587              :                 // Real64 oldTimeStamp = ort->MonthlyColumns(curCol).timeStamp(state.dataEnvrn->Month);
    3588        43800 :                 Real64 const &oldDuration = ort->MonthlyColumns(curCol).duration(state.dataEnvrn->Month);
    3589              :                 // Zero the revised values (as default if not set later in SELECT)
    3590        43800 :                 Real64 newResultValue = 0.0;
    3591        43800 :                 int newTimeStamp = 0;
    3592        43800 :                 Real64 newDuration = 0.0;
    3593        43800 :                 bool activeNewValue = false;
    3594              :                 // the current timestamp
    3595        43800 :                 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        43800 :                 EncodeMonDayHrMin(
    3601        43800 :                     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        43800 :                 switch (state.dataOutRptTab->MonthlyColumnsAggType(curCol)) {
    3605            0 :                 case AggType::SumOrAvg: {
    3606            0 :                     if (ort->MonthlyColumns(curCol).avgSum == OutputProcessor::StoreType::Sum) { // if it is a summed variable
    3607            0 :                         newResultValue = oldResultValue + curValue;
    3608              :                     } else {
    3609            0 :                         newResultValue = oldResultValue + curValue * elapsedTime; // for averaging - weight by elapsed time
    3610              :                     }
    3611            0 :                     newDuration = oldDuration + elapsedTime;
    3612            0 :                     activeNewValue = true;
    3613            0 :                 } break;
    3614        43800 :                 case AggType::Maximum: {
    3615              :                     // per MJW when a summed variable is used divide it by the length of the time step
    3616        43800 :                     if (ort->MonthlyColumns(curCol).avgSum == OutputProcessor::StoreType::Sum) { // if it is a summed variable
    3617        43800 :                         if (t_timeStepType == OutputProcessor::TimeStepType::System) {
    3618            0 :                             curValue /= TimeStepSysSec;
    3619              :                         } else {
    3620        43800 :                             curValue /= state.dataGlobal->TimeStepZoneSec;
    3621              :                         }
    3622              :                     }
    3623        43800 :                     if (curValue > oldResultValue) {
    3624          802 :                         newResultValue = curValue;
    3625          802 :                         newTimeStamp = timestepTimeStamp;
    3626          802 :                         activeMinMax = true;
    3627          802 :                         activeNewValue = true;
    3628              :                     } else {
    3629        42998 :                         activeMinMax = false; // reset this
    3630              :                     }
    3631        43800 :                 } 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            0 :                 case AggType::HoursNonZero: {
    3660            0 :                     if (curValue != 0) {
    3661            0 :                         newResultValue = oldResultValue + elapsedTime;
    3662            0 :                         activeHoursShown = true;
    3663            0 :                         activeNewValue = true;
    3664              :                     } else {
    3665            0 :                         activeHoursShown = false;
    3666              :                     }
    3667            0 :                 } 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            0 :                 default:
    3710            0 :                     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        43800 :                 if (activeNewValue) {
    3716          802 :                     ort->MonthlyColumns(curCol).reslt(state.dataEnvrn->Month) = newResultValue;
    3717          802 :                     ort->MonthlyColumns(curCol).timeStamp(state.dataEnvrn->Month) = newTimeStamp;
    3718          802 :                     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        43800 :                 if (activeMinMax) {
    3726          802 :                     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        43800 :                 if (activeHoursShown) {
    3756            0 :                     bool exit_loop = false;
    3757            0 :                     for (int kOtherColumn = jColumn + 1; kOtherColumn <= ort->MonthlyTables(iTable).numColumns; ++kOtherColumn) {
    3758            0 :                         if (exit_loop) {
    3759            0 :                             break;
    3760              :                         }
    3761            0 :                         int const scanColumn = kOtherColumn + ort->MonthlyTables(iTable).firstColumn - 1;
    3762            0 :                         OutputProcessor::VariableType const scanTypeOfVar = ort->MonthlyColumns(scanColumn).typeOfVar;
    3763            0 :                         int const scanVarNum = ort->MonthlyColumns(scanColumn).varNum;
    3764            0 :                         Real64 scanValue = GetInternalVariableValue(state, scanTypeOfVar, scanVarNum);
    3765            0 :                         Real64 const oldScanValue = ort->MonthlyColumns(scanColumn).reslt(state.dataEnvrn->Month);
    3766            0 :                         switch (ort->MonthlyColumns(scanColumn).aggType) {
    3767            0 :                         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            0 :                             exit_loop = true;
    3775            0 :                             break; // do
    3776            0 :                         case AggType::SumOrAverageHoursShown: {
    3777              :                             // this case is when the value should be set
    3778            0 :                             if (ort->MonthlyColumns(scanColumn).avgSum == OutputProcessor::StoreType::Sum) { // if it is a summed variable
    3779            0 :                                 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            0 :                             ort->MonthlyColumns(scanColumn).duration(state.dataEnvrn->Month) += elapsedTime;
    3785            0 :                         } 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            0 :                         default:
    3813            0 :                             break;
    3814              :                         }
    3815            0 :                         activeHoursShown = false; // fixed CR8317
    3816              :                     }
    3817              :                 }
    3818              :             }
    3819              :         }
    3820              :     }
    3821              : }
    3822              : 
    3823       497501 : 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       497501 :     auto &ort = state.dataOutRptTab;
    3879              :     // if no beps report is called then skip
    3880              : 
    3881       497501 :     if ((ort->displayTabularBEPS || ort->displayLEEDSummary) && (t_timeStepType == OutputProcessor::TimeStepType::Zone)) {
    3882       219096 :         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      3286440 :         for (int iResource = 1; iResource <= numResourceTypes; ++iResource) {
    3897      3067344 :             int curResMeterNumber = ort->meterNumTotalsBEPS(iResource);
    3898      3067344 :             if (curResMeterNumber > -1) {
    3899       552072 :                 Real64 curResMeterValue = GetCurrentMeterValue(state, curResMeterNumber);
    3900       552072 :                 ort->gatherTotalsBEPS(iResource) += curResMeterValue;
    3901              :             }
    3902              : 
    3903     46010160 :             for (int jEndUse = 1; jEndUse <= static_cast<int>(Constant::EndUse::Num); ++jEndUse) {
    3904     42942816 :                 int curEndUseMeterNumber = ort->meterNumEndUseBEPS(iResource, jEndUse);
    3905     42942816 :                 if (curEndUseMeterNumber > -1) {
    3906      1209552 :                     Real64 curEndUseMeterValue = GetCurrentMeterValue(state, curEndUseMeterNumber);
    3907      1209552 :                     ort->gatherEndUseBEPS(iResource, jEndUse) += curEndUseMeterValue;
    3908              : 
    3909      2848728 :                     for (int kEndUseSub = 1; kEndUseSub <= op->EndUseCategory(jEndUse).NumSubcategories; ++kEndUseSub) {
    3910      1639176 :                         int curSubMeterNumber = ort->meterNumEndUseSubBEPS(kEndUseSub, jEndUse, iResource);
    3911      1639176 :                         if (curSubMeterNumber > -1) {
    3912      1393608 :                             Real64 curSubMeterValue = GetCurrentMeterValue(state, curSubMeterNumber);
    3913      1393608 :                             ort->gatherEndUseSubBEPS(kEndUseSub, jEndUse, iResource) += curSubMeterValue;
    3914              :                         }
    3915              :                     }
    3916      1647744 :                     for (int kEndUseSpType = 1; kEndUseSpType <= op->EndUseCategory(jEndUse).numSpaceTypes; ++kEndUseSpType) {
    3917       438192 :                         int curSpTypeMeterNumber = ort->meterNumEndUseSpTypeBEPS(kEndUseSpType, jEndUse, iResource);
    3918       438192 :                         if (curSpTypeMeterNumber > -1) {
    3919       438192 :                             Real64 curSpTypeMeterValue = GetCurrentMeterValue(state, curSpTypeMeterNumber);
    3920       438192 :                             ort->gatherEndUseSpTypeBEPS(kEndUseSpType, jEndUse, iResource) += curSpTypeMeterValue;
    3921              :                         }
    3922              :                     }
    3923              :                 }
    3924              :             }
    3925              :         }
    3926              : 
    3927      2848248 :         for (int iResource = 1; iResource <= numSourceTypes; ++iResource) {
    3928      2629152 :             int curResMeterNumber = ort->meterNumTotalsSource(iResource);
    3929      2629152 :             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       219096 :         ort->gatherPowerFuelFireGen += GetCurrentMeterValue(state, ort->meterNumPowerFuelFireGen);
    3937       219096 :         ort->gatherPowerPV += GetCurrentMeterValue(state, ort->meterNumPowerPV);
    3938       219096 :         ort->gatherPowerWind += GetCurrentMeterValue(state, ort->meterNumPowerWind);
    3939       219096 :         ort->gatherPowerHTGeothermal += GetCurrentMeterValue(state, ort->meterNumPowerHTGeothermal);
    3940       219096 :         ort->gatherElecProduced += GetCurrentMeterValue(state, ort->meterNumElecProduced);
    3941       219096 :         ort->gatherElecPurchased += GetCurrentMeterValue(state, ort->meterNumElecPurchased);
    3942       219096 :         ort->gatherElecSurplusSold += GetCurrentMeterValue(state, ort->meterNumElecSurplusSold);
    3943       219096 :         ort->gatherElecStorage += GetCurrentMeterValue(state, ort->meterNumElecStorage);
    3944       219096 :         ort->gatherPowerConversion += GetCurrentMeterValue(state, ort->meterNumPowerConversion);
    3945              :         // gather the onsite thermal components
    3946       219096 :         ort->gatherWaterHeatRecovery += GetCurrentMeterValue(state, ort->meterNumWaterHeatRecovery);
    3947       219096 :         ort->gatherAirHeatRecoveryCool += GetCurrentMeterValue(state, ort->meterNumAirHeatRecoveryCool);
    3948       219096 :         ort->gatherAirHeatRecoveryHeat += GetCurrentMeterValue(state, ort->meterNumAirHeatRecoveryHeat);
    3949       219096 :         ort->gatherHeatHTGeothermal += GetCurrentMeterValue(state, ort->meterNumHeatHTGeothermal);
    3950       219096 :         ort->gatherHeatSolarWater += GetCurrentMeterValue(state, ort->meterNumHeatSolarWater);
    3951       219096 :         ort->gatherHeatSolarAir += GetCurrentMeterValue(state, ort->meterNumHeatSolarAir);
    3952              :         // gather the water supply components
    3953       219096 :         ort->gatherRainWater += GetCurrentMeterValue(state, ort->meterNumRainWater);
    3954       219096 :         ort->gatherCondensate += GetCurrentMeterValue(state, ort->meterNumCondensate);
    3955       219096 :         ort->gatherWellwater += GetCurrentMeterValue(state, ort->meterNumGroundwater);
    3956       219096 :         ort->gatherMains += GetCurrentMeterValue(state, ort->meterNumMains);
    3957       219096 :         ort->gatherWaterEndUseTotal += GetCurrentMeterValue(state, ort->meterNumWaterEndUseTotal);
    3958              :     }
    3959       497501 : }
    3960              : 
    3961       497501 : 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       497501 :     auto &ort = state.dataOutRptTab;
    4043              : 
    4044              :     // if no beps by source report is called then skip
    4045              : 
    4046       497501 :     if ((ort->displaySourceEnergyEndUseSummary) && (t_timeStepType == OutputProcessor::TimeStepType::Zone)) {
    4047              :         // loop through all of the resources and end uses for the entire facility
    4048      3286440 :         for (int iResource = 1; iResource <= numResourceTypes; ++iResource) {
    4049              : 
    4050      3067344 :             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      3067344 :                 int const curMeterNumber = ort->meterNumTotalsBEPS(iResource);
    4059      3067344 :                 if (curMeterNumber > -1) {
    4060       552072 :                     Real64 const curMeterValue = GetCurrentMeterValue(state, curMeterNumber) * ort->SourceFactors(iResource);
    4061       552072 :                     ort->gatherTotalsBySourceBEPS(iResource) += curMeterValue;
    4062              :                 }
    4063              :             }
    4064              : 
    4065     46010160 :             for (int jEndUse = 1; jEndUse <= static_cast<int>(Constant::EndUse::Num); ++jEndUse) {
    4066     42942816 :                 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     42942816 :                     int const curMeterNumber = ort->meterNumEndUseBEPS(iResource, jEndUse);
    4075     42942816 :                     if (curMeterNumber > -1) {
    4076      1209552 :                         Real64 const curMeterValue = GetCurrentMeterValue(state, curMeterNumber) * ort->SourceFactors(iResource);
    4077      1209552 :                         ort->gatherEndUseBySourceBEPS(iResource, jEndUse) += curMeterValue;
    4078              :                     }
    4079              :                 }
    4080              :             }
    4081              :         }
    4082              :     }
    4083       497501 : }
    4084              : 
    4085       497501 : 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       497501 :     assert(state.dataGlobal->TimeStepZoneSec > 0.0);
    4159       497501 :     auto &ort = state.dataOutRptTab;
    4160       497501 :     auto &op = state.dataOutputProcessor;
    4161              : 
    4162       497501 :     if ((ort->displayDemandEndUse) && (t_timeStepType == OutputProcessor::TimeStepType::Zone)) {
    4163              :         // loop through all of the resources and end uses for the entire facility
    4164      3286440 :         for (int iResource = 1; iResource <= numResourceTypes; ++iResource) {
    4165      3067344 :             int curMeterNumber = ort->meterNumTotalsBEPS(iResource);
    4166      3067344 :             if (curMeterNumber > -1) {
    4167       552072 :                 Real64 curDemandValue = GetCurrentMeterValue(state, curMeterNumber) / state.dataGlobal->TimeStepZoneSec;
    4168              :                 // check if current value is greater than existing peak demand value
    4169       552072 :                 if (curDemandValue > ort->gatherDemandTotal(iResource)) {
    4170          670 :                     ort->gatherDemandTotal(iResource) = curDemandValue;
    4171              :                     // save the time that the peak demand occurred
    4172              :                     //        minuteCalculated = (CurrentTime - INT(CurrentTime))*60
    4173          670 :                     int const minuteCalculated = OutputProcessor::DetermineMinuteForReporting(state);
    4174              :                     int timestepTimeStamp;
    4175          670 :                     EncodeMonDayHrMin(
    4176          670 :                         timestepTimeStamp, state.dataEnvrn->Month, state.dataEnvrn->DayOfMonth, state.dataGlobal->HourOfDay, minuteCalculated);
    4177          670 :                     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        10050 :                     for (int jEndUse = 1; jEndUse <= static_cast<int>(Constant::EndUse::Num); ++jEndUse) {
    4181         9380 :                         curMeterNumber = ort->meterNumEndUseBEPS(iResource, jEndUse);
    4182         9380 :                         if (curMeterNumber > -1) {
    4183         1734 :                             curDemandValue = GetCurrentMeterValue(state, curMeterNumber) / state.dataGlobal->TimeStepZoneSec;
    4184         1734 :                             ort->gatherDemandEndUse(iResource, jEndUse) = curDemandValue;
    4185         4148 :                             for (int kEndUseSub = 1; kEndUseSub <= op->EndUseCategory(jEndUse).NumSubcategories; ++kEndUseSub) {
    4186         2414 :                                 curMeterNumber = ort->meterNumEndUseSubBEPS(kEndUseSub, jEndUse, iResource);
    4187         2414 :                                 if (curMeterNumber > -1) {
    4188         1962 :                                     curDemandValue = GetCurrentMeterValue(state, curMeterNumber) / state.dataGlobal->TimeStepZoneSec;
    4189         1962 :                                     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       497501 :     if ((ort->displayLEEDSummary) && (t_timeStepType == OutputProcessor::TimeStepType::Zone)) {
    4201              :         // loop through all of the resources and end uses for the entire facility
    4202      3286440 :         for (int iResource = 1; iResource <= numResourceTypes; ++iResource) {
    4203     46010160 :             for (int jEndUse = 1; jEndUse <= static_cast<int>(Constant::EndUse::Num); ++jEndUse) {
    4204     42942816 :                 int curMeterNumber = ort->meterNumEndUseBEPS(iResource, jEndUse);
    4205     42942816 :                 if (curMeterNumber > -1) {
    4206      1209552 :                     Real64 curDemandValue = GetCurrentMeterValue(state, curMeterNumber) / state.dataGlobal->TimeStepZoneSec;
    4207      1209552 :                     if (curDemandValue > ort->gatherDemandIndEndUse(iResource, jEndUse)) {
    4208         1298 :                         ort->gatherDemandIndEndUse(iResource, jEndUse) = curDemandValue;
    4209              :                     }
    4210      2848728 :                     for (int kEndUseSub = 1; kEndUseSub <= op->EndUseCategory(jEndUse).NumSubcategories; ++kEndUseSub) {
    4211      1639176 :                         curMeterNumber = ort->meterNumEndUseSubBEPS(kEndUseSub, jEndUse, iResource);
    4212      1639176 :                         if (curMeterNumber > -1) {
    4213      1393608 :                             curDemandValue = GetCurrentMeterValue(state, curMeterNumber) / state.dataGlobal->TimeStepZoneSec;
    4214              :                             // check if current value is greater than existing peak demand value
    4215      1393608 :                             if (curDemandValue > ort->gatherDemandIndEndUseSub(kEndUseSub, jEndUse, iResource)) {
    4216         1372 :                                 ort->gatherDemandIndEndUseSub(kEndUseSub, jEndUse, iResource) = curDemandValue;
    4217              :                             }
    4218              :                         }
    4219              :                     }
    4220              :                 }
    4221              :             }
    4222              :         }
    4223              :     }
    4224       497501 : }
    4225              : 
    4226       497501 : 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       497501 :     state.dataHeatBal->SysTotalHVACReliefHeatLoss = 0;
    4234       497501 :     state.dataHeatBal->SysTotalHVACRejectHeatLoss = 0;
    4235       497501 :     auto const &ort = state.dataOutRptTab;
    4236              : 
    4237       497501 :     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       497501 :     if (t_timeStepType == OutputProcessor::TimeStepType::Zone) {
    4243       219096 :         state.dataHeatBal->BuildingPreDefRep.emiEnvelopConv += state.dataHeatBalSurf->SumSurfaceHeatEmission * Constant::convertJtoGJ;
    4244       219096 :         return;
    4245              :     }
    4246              : 
    4247       278405 :     CalcHeatEmissionReport(state);
    4248       278405 :     state.dataHeatBal->BuildingPreDefRep.emiZoneExfiltration += state.dataHeatBal->ZoneTotalExfiltrationHeatLoss * Constant::convertJtoGJ;
    4249       278405 :     state.dataHeatBal->BuildingPreDefRep.emiZoneExhaust += state.dataHeatBal->ZoneTotalExhaustHeatLoss * Constant::convertJtoGJ;
    4250       278405 :     state.dataHeatBal->BuildingPreDefRep.emiHVACRelief += state.dataHeatBal->SysTotalHVACReliefHeatLoss * Constant::convertJtoGJ;
    4251       278405 :     state.dataHeatBal->BuildingPreDefRep.emiHVACReject += state.dataHeatBal->SysTotalHVACRejectHeatLoss * Constant::convertJtoGJ;
    4252              : 
    4253       278405 :     state.dataHeatBal->BuildingPreDefRep.emiTotHeat =
    4254       278405 :         state.dataHeatBal->BuildingPreDefRep.emiEnvelopConv + state.dataHeatBal->BuildingPreDefRep.emiZoneExfiltration +
    4255       278405 :         state.dataHeatBal->BuildingPreDefRep.emiZoneExhaust + state.dataHeatBal->BuildingPreDefRep.emiHVACRelief +
    4256       278405 :         state.dataHeatBal->BuildingPreDefRep.emiHVACReject;
    4257              : }
    4258              : 
    4259      1697943 : 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      1697943 :     Real64 const TimeStepSysSec = state.dataHVACGlobal->TimeStepSysSec;
    4268              : 
    4269      1697943 :     Real64 H2OHtOfVap_HVAC = Psychrometrics::PsyHgAirFnWTdb(state.dataEnvrn->OutHumRat, state.dataEnvrn->OutDryBulbTemp);
    4270      1697943 :     Real64 RhoWater = Psychrometrics::RhoH2O(state.dataEnvrn->OutDryBulbTemp);
    4271              : 
    4272      1697943 :     state.dataHeatBal->SysTotalHVACReliefHeatLoss = 0;
    4273      1697943 :     state.dataHeatBal->SysTotalHVACRejectHeatLoss = 0;
    4274              : 
    4275              :     // HVAC relief air
    4276      3621497 :     for (int iOACtrl = 1; iOACtrl <= state.dataMixedAir->NumOAControllers; ++iOACtrl) {
    4277      1923554 :         state.dataHeatBal->SysTotalHVACReliefHeatLoss += state.dataMixedAir->OAController(iOACtrl).RelTotalLossRate * TimeStepSysSec;
    4278              :     }
    4279              : 
    4280              :     // Airloop HVAC Exhaust System
    4281      1698905 :     for (int iExhSys = 1; iExhSys < state.dataZoneEquip->NumExhaustAirSystems; ++iExhSys) {
    4282          962 :         state.dataHeatBal->SysTotalHVACReliefHeatLoss += state.dataZoneEquip->ExhaustAirSystem(iExhSys).exhTotalHVACReliefHeatLoss;
    4283              :     }
    4284              : 
    4285              :     // Condenser water loop
    4286      2114113 :     for (int iCooler = 1; iCooler <= (int)state.dataCondenserLoopTowers->towers.size(); ++iCooler) {
    4287       832340 :         state.dataHeatBal->SysTotalHVACRejectHeatLoss += state.dataCondenserLoopTowers->towers(iCooler).Qactual * TimeStepSysSec +
    4288       416170 :                                                          state.dataCondenserLoopTowers->towers(iCooler).FanEnergy +
    4289       416170 :                                                          state.dataCondenserLoopTowers->towers(iCooler).BasinHeaterConsumption;
    4290              :     }
    4291      1702062 :     for (auto const &thisCooler : state.dataEvapFluidCoolers->SimpleEvapFluidCooler) {
    4292         4119 :         state.dataHeatBal->SysTotalHVACRejectHeatLoss += thisCooler.Qactual * TimeStepSysSec + thisCooler.FanEnergy;
    4293              :     }
    4294      1704555 :     for (auto const &cooler : state.dataFluidCoolers->SimpleFluidCooler) {
    4295         6612 :         state.dataHeatBal->SysTotalHVACRejectHeatLoss += cooler.Qactual * TimeStepSysSec + cooler.FanEnergy;
    4296              :     }
    4297              : 
    4298              :     // Air- and Evap-cooled chiller
    4299      2197342 :     for (int iChiller = 1; iChiller <= state.dataPlantChillers->NumElectricChillers; ++iChiller) {
    4300       499399 :         auto const &thisChiller = state.dataPlantChillers->ElectricChiller(iChiller);
    4301              : 
    4302       499399 :         if (thisChiller.CondenserType != DataPlant::CondenserType::WaterCooled) {
    4303       233315 :             state.dataHeatBal->SysTotalHVACRejectHeatLoss += thisChiller.CondenserEnergy;
    4304              :         }
    4305              :     }
    4306      1714227 :     for (int iChiller = 1; iChiller <= state.dataPlantChillers->NumEngineDrivenChillers; ++iChiller) {
    4307        16284 :         auto const &thisChiller = state.dataPlantChillers->EngineDrivenChiller(iChiller);
    4308              : 
    4309        16284 :         if (thisChiller.CondenserType != DataPlant::CondenserType::WaterCooled) {
    4310            0 :             state.dataHeatBal->SysTotalHVACRejectHeatLoss += thisChiller.CondenserEnergy;
    4311              :         }
    4312              :     }
    4313      1700880 :     for (int iChiller = 1; iChiller <= state.dataPlantChillers->NumGTChillers; ++iChiller) {
    4314         2937 :         auto const &thisChiller = state.dataPlantChillers->GTChiller(iChiller);
    4315              : 
    4316         2937 :         if (thisChiller.CondenserType != DataPlant::CondenserType::WaterCooled) {
    4317            0 :             state.dataHeatBal->SysTotalHVACRejectHeatLoss += thisChiller.CondenserEnergy;
    4318              :         }
    4319              :     }
    4320      1871300 :     for (int iChiller = 1; iChiller <= state.dataPlantChillers->NumConstCOPChillers; ++iChiller) {
    4321       173357 :         auto const &thisChiller = state.dataPlantChillers->ConstCOPChiller(iChiller);
    4322              : 
    4323       173357 :         if (thisChiller.CondenserType != DataPlant::CondenserType::WaterCooled) {
    4324         3419 :             state.dataHeatBal->SysTotalHVACRejectHeatLoss += thisChiller.CondenserEnergy;
    4325              :         }
    4326              :     }
    4327              : 
    4328      1735580 :     for (int iChiller = 1; iChiller <= (int)state.dataChillerElectricEIR->ElectricEIRChiller.size(); ++iChiller) {
    4329        37637 :         auto const &thisChiller = state.dataChillerElectricEIR->ElectricEIRChiller(iChiller);
    4330              : 
    4331        37637 :         if (thisChiller.CondenserType != DataPlant::CondenserType::WaterCooled) {
    4332         6658 :             state.dataHeatBal->SysTotalHVACRejectHeatLoss += thisChiller.CondEnergy;
    4333              :         }
    4334              :     }
    4335      1714029 :     for (int iChiller = 1; iChiller <= (int)state.dataChillerReformulatedEIR->ElecReformEIRChiller.size(); ++iChiller) {
    4336        16086 :         auto const &thisChiller = state.dataChillerReformulatedEIR->ElecReformEIRChiller(iChiller);
    4337              : 
    4338        16086 :         if (thisChiller.CondenserType != DataPlant::CondenserType::WaterCooled) {
    4339            0 :             state.dataHeatBal->SysTotalHVACRejectHeatLoss += thisChiller.CondEnergy;
    4340              :         }
    4341              :     }
    4342              : 
    4343              :     // Water / steam boiler
    4344      2093805 :     for (int iBoiler = 1; iBoiler <= (int)state.dataBoilers->Boiler.size(); ++iBoiler) {
    4345       395862 :         state.dataHeatBal->SysTotalHVACRejectHeatLoss +=
    4346       395862 :             state.dataBoilers->Boiler(iBoiler).FuelConsumed + state.dataBoilers->Boiler(iBoiler).ParasiticFuelConsumption +
    4347       395862 :             state.dataBoilers->Boiler(iBoiler).ParasiticElecConsumption - state.dataBoilers->Boiler(iBoiler).BoilerEnergy;
    4348              :     }
    4349              : 
    4350              :     // DX Coils air to air
    4351      3200205 :     for (int iCoil = 1; iCoil <= state.dataDXCoils->NumDXCoils; ++iCoil) {
    4352      1502262 :         auto const &thisDXCoil = state.dataDXCoils->DXCoil(iCoil);
    4353              : 
    4354      1502262 :         if (thisDXCoil.DXCoilType_Num == HVAC::CoilDX_CoolingSingleSpeed || thisDXCoil.DXCoilType_Num == HVAC::CoilDX_CoolingTwoSpeed ||
    4355       701804 :             thisDXCoil.DXCoilType_Num == HVAC::CoilDX_MultiSpeedCooling || thisDXCoil.DXCoilType_Num == HVAC::CoilDX_CoolingTwoStageWHumControl) {
    4356       990332 :             if (thisDXCoil.CondenserType(1) == DataHeatBalance::RefrigCondenserType::Air) {
    4357       986474 :                 state.dataHeatBal->SysTotalHVACRejectHeatLoss += thisDXCoil.ElecCoolingConsumption + thisDXCoil.DefrostConsumption +
    4358       986474 :                                                                  thisDXCoil.CrankcaseHeaterConsumption + thisDXCoil.TotalCoolingEnergy;
    4359         3858 :             } else if (thisDXCoil.CondenserType(1) == DataHeatBalance::RefrigCondenserType::Evap) {
    4360         3858 :                 state.dataHeatBal->SysTotalHVACRejectHeatLoss += thisDXCoil.EvapCondPumpElecConsumption + thisDXCoil.BasinHeaterConsumption +
    4361         3858 :                                                                  thisDXCoil.EvapWaterConsump * RhoWater * H2OHtOfVap_HVAC;
    4362              :             }
    4363       990332 :             if (thisDXCoil.FuelType != Constant::eFuel::Electricity) {
    4364       823273 :                 state.dataHeatBal->SysTotalHVACRejectHeatLoss += thisDXCoil.MSFuelWasteHeat * TimeStepSysSec;
    4365              :             }
    4366       511930 :         } else if (thisDXCoil.DXCoilType_Num == HVAC::CoilDX_HeatingEmpirical || thisDXCoil.DXCoilType_Num == HVAC::CoilDX_MultiSpeedHeating) {
    4367       355896 :             state.dataHeatBal->SysTotalHVACRejectHeatLoss += thisDXCoil.ElecHeatingConsumption + thisDXCoil.DefrostConsumption +
    4368       355896 :                                                              thisDXCoil.FuelConsumed + thisDXCoil.CrankcaseHeaterConsumption -
    4369       355896 :                                                              thisDXCoil.TotalHeatingEnergy;
    4370              :         }
    4371              :     }
    4372              :     // VAV coils - air to air
    4373      1881820 :     for (int iCoil = 1; iCoil <= state.dataVariableSpeedCoils->NumVarSpeedCoils; ++iCoil) {
    4374       183877 :         auto const &thisCoil = state.dataVariableSpeedCoils->VarSpeedCoil(iCoil);
    4375              : 
    4376       183877 :         if (thisCoil.VSCoilType == HVAC::Coil_CoolingAirToAirVariableSpeed) {
    4377       124584 :             if (thisCoil.CondenserType == DataHeatBalance::RefrigCondenserType::Air) {
    4378       124584 :                 state.dataHeatBal->SysTotalHVACRejectHeatLoss +=
    4379       124584 :                     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        59293 :         } else if (thisCoil.VSCoilType == HVAC::Coil_HeatingAirToAirVariableSpeed) {
    4385        10449 :             state.dataHeatBal->SysTotalHVACRejectHeatLoss +=
    4386        10449 :                 thisCoil.Energy + thisCoil.CrankcaseHeaterConsumption + thisCoil.DefrostConsumption - thisCoil.EnergyLoadTotal;
    4387              :         }
    4388              :     }
    4389              : 
    4390              :     // Heating coils - fuel
    4391      4332368 :     for (int iCoil = 1; iCoil <= state.dataHeatingCoils->NumHeatingCoils; ++iCoil) {
    4392      2634425 :         auto const &thisCoil = state.dataHeatingCoils->HeatingCoil(iCoil);
    4393              : 
    4394      2634425 :         if (thisCoil.HCoilType_Num == HVAC::Coil_HeatingGas_MultiStage || thisCoil.HCoilType_Num == HVAC::Coil_HeatingGasOrOtherFuel) {
    4395      1907252 :             state.dataHeatBal->SysTotalHVACRejectHeatLoss += thisCoil.FuelUseLoad + thisCoil.ParasiticFuelConsumption - thisCoil.HeatingCoilLoad;
    4396              :         }
    4397              :     }
    4398              : 
    4399              :     // Packaged TES
    4400      1703667 :     for (int iCoil = 1; iCoil <= state.dataPackagedThermalStorageCoil->NumTESCoils; ++iCoil) {
    4401         5724 :         auto const &thisCoil = state.dataPackagedThermalStorageCoil->TESCoil(iCoil);
    4402              : 
    4403         5724 :         if (thisCoil.CondenserType == PackagedThermalStorageCoil::TESCondenserType::Air) {
    4404         4293 :             state.dataHeatBal->SysTotalHVACRejectHeatLoss +=
    4405         4293 :                 thisCoil.EvapTotCoolingEnergy + thisCoil.ElecCoolingEnergy + thisCoil.ElectColdWeatherEnergy - thisCoil.Q_Ambient;
    4406         1431 :         } else if (thisCoil.CondenserType == PackagedThermalStorageCoil::TESCondenserType::Evap) {
    4407         1431 :             state.dataHeatBal->SysTotalHVACRejectHeatLoss += thisCoil.EvapCondPumpElecConsumption + thisCoil.ElectEvapCondBasinHeaterEnergy +
    4408         1431 :                                                              thisCoil.EvapWaterConsump * RhoWater * H2OHtOfVap_HVAC - thisCoil.Q_Ambient;
    4409              :         }
    4410              :     }
    4411              : 
    4412              :     // Water heater and thermal storage
    4413      1914887 :     for (int iTank = 1; iTank <= state.dataWaterThermalTanks->numWaterThermalTank; ++iTank) {
    4414       216944 :         auto const &thisTank = state.dataWaterThermalTanks->WaterThermalTank(iTank);
    4415              : 
    4416       216944 :         if (thisTank.AmbientTempIndicator == WaterThermalTanks::WTTAmbientTemp::OutsideAir) {
    4417        10674 :             state.dataHeatBal->SysTotalHVACRejectHeatLoss += thisTank.FuelEnergy - thisTank.TotalDemandEnergy;
    4418              :         }
    4419              :     }
    4420              : 
    4421              :     // Variable Refrigerant Flow
    4422      1712711 :     for (int iCoil = 1; iCoil <= state.dataHVACVarRefFlow->NumVRFCond; ++iCoil) {
    4423        14768 :         auto const &thisVRF = state.dataHVACVarRefFlow->VRF(iCoil);
    4424              : 
    4425        14768 :         if (thisVRF.CondenserType == DataHeatBalance::RefrigCondenserType::Air) {
    4426        13763 :             state.dataHeatBal->SysTotalHVACRejectHeatLoss += thisVRF.CoolElecConsumption + thisVRF.HeatElecConsumption +
    4427        13763 :                                                              thisVRF.CrankCaseHeaterElecConsumption + thisVRF.DefrostConsumption +
    4428        13763 :                                                              (thisVRF.TotalCoolingCapacity - thisVRF.TotalHeatingCapacity) * TimeStepSysSec;
    4429         1005 :         } 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         1005 :         } else if (thisVRF.CondenserType == DataHeatBalance::RefrigCondenserType::Water) {
    4433         1005 :             state.dataHeatBal->SysTotalHVACRejectHeatLoss += thisVRF.QCondEnergy;
    4434              :         }
    4435              :     }
    4436              : 
    4437              :     // Refrigerated Rack
    4438      1747956 :     for (int iRef = 1; iRef <= state.dataRefrigCase->NumRefrigeratedRacks; ++iRef) {
    4439        50013 :         auto const &thisRack = state.dataRefrigCase->RefrigRack(iRef);
    4440              : 
    4441        50013 :         if (thisRack.CondenserType == DataHeatBalance::RefrigCondenserType::Air) {
    4442        46442 :             state.dataHeatBal->SysTotalHVACRejectHeatLoss += thisRack.RackElecConsumption + thisRack.RackCoolingEnergy;
    4443         3571 :         } else if (thisRack.CondenserType == DataHeatBalance::RefrigCondenserType::Evap) {
    4444         2306 :             state.dataHeatBal->SysTotalHVACRejectHeatLoss +=
    4445         2306 :                 thisRack.EvapPumpConsumption + thisRack.BasinHeaterConsumption + thisRack.EvapWaterConsumption * RhoWater * H2OHtOfVap_HVAC;
    4446         1265 :         } else if (thisRack.CondenserType == DataHeatBalance::RefrigCondenserType::Water) {
    4447         1265 :             state.dataHeatBal->SysTotalHVACRejectHeatLoss += thisRack.CondEnergy;
    4448              :         }
    4449              :     }
    4450              : 
    4451              :     // Refrigerated Case - Condenser
    4452      1789255 :     for (int iRef = 1; iRef <= state.dataRefrigCase->NumRefrigCondensers; ++iRef) {
    4453        91312 :         state.dataHeatBal->SysTotalHVACRejectHeatLoss += state.dataRefrigCase->Condenser(iRef).CondEnergy;
    4454              :     }
    4455              : 
    4456              :     // Evaporative coolers
    4457      1810110 :     for (int iCooler = 1; iCooler <= state.dataEvapCoolers->NumEvapCool; ++iCooler) {
    4458       112167 :         auto const &thisCooler = state.dataEvapCoolers->EvapCond(iCooler);
    4459              : 
    4460       112167 :         state.dataHeatBal->SysTotalHVACRejectHeatLoss += thisCooler.EvapWaterConsump * RhoWater * H2OHtOfVap_HVAC + thisCooler.EvapCoolerEnergy;
    4461              :     }
    4462      1697943 : }
    4463              : 
    4464       497501 : 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       497501 :     Real64 const TimeStepSysSec = state.dataHVACGlobal->TimeStepSysSec;
    4528              : 
    4529              :     using General::EncodeMonDayHrMin;
    4530              : 
    4531       497501 :     auto &Zone = state.dataHeatBal->Zone;
    4532       497501 :     auto &ZonePreDefRep = state.dataHeatBal->ZonePreDefRep;
    4533              : 
    4534       497501 :     if (!state.dataGlobal->DoWeathSim) {
    4535            0 :         return;
    4536              :     }
    4537              : 
    4538       497501 :     if (!state.dataOutRptPredefined->reportName(state.dataOutRptPredefined->pdrSensibleGain).show) {
    4539            0 :         return; // don't gather data if report isn't requested
    4540              :     }
    4541              : 
    4542       497501 :     if (t_timeStepType == OutputProcessor::TimeStepType::Zone) {
    4543       219096 :         return; // only add values over the HVAC timestep basis
    4544              :     }
    4545              : 
    4546       278405 :     auto &ort = state.dataOutRptTab;
    4547              : 
    4548       278405 :     if (ort->GatherHeatGainReportfirstTime) {
    4549            6 :         state.dataOutRptTab->radiantHeat.allocate(state.dataGlobal->NumOfZones);
    4550            6 :         state.dataOutRptTab->radiantCool.allocate(state.dataGlobal->NumOfZones);
    4551            6 :         state.dataOutRptTab->ATUHeat.allocate(state.dataGlobal->NumOfZones);
    4552            6 :         state.dataOutRptTab->ATUCool.allocate(state.dataGlobal->NumOfZones);
    4553            6 :         ort->GatherHeatGainReportfirstTime = false;
    4554              :     }
    4555              :     // clear the radiant surface accumulation variables
    4556       278405 :     state.dataOutRptTab->radiantHeat = 0.0;
    4557       278405 :     state.dataOutRptTab->radiantCool = 0.0;
    4558              :     // clear the ATU accumulation variables
    4559       278405 :     state.dataOutRptTab->ATUHeat = 0.0;
    4560       278405 :     state.dataOutRptTab->ATUCool = 0.0;
    4561              :     //--------------------
    4562              :     //     ANNUAL
    4563              :     //--------------------
    4564              :     // HVAC annual heating by ATU
    4565              :     // HVAC annual cooling by ATU
    4566      1005390 :     for (state.dataOutRptTab->iunitGHGR = 1; state.dataOutRptTab->iunitGHGR <= (int)state.dataDefineEquipment->AirDistUnit.size();
    4567       726985 :          ++state.dataOutRptTab->iunitGHGR) {
    4568              :         // HVAC equipment should already have the multipliers included, no "* mult" needed (assumes autosized or multiplied hard-sized air flow).
    4569       726985 :         state.dataOutRptTab->curZoneGHGR = state.dataDefineEquipment->AirDistUnit(state.dataOutRptTab->iunitGHGR).ZoneNum;
    4570       726985 :         if ((state.dataOutRptTab->curZoneGHGR > 0) && (state.dataOutRptTab->curZoneGHGR <= state.dataGlobal->NumOfZones)) {
    4571       726985 :             ZonePreDefRep(state.dataOutRptTab->curZoneGHGR).SHGSAnHvacATUHt +=
    4572       726985 :                 state.dataDefineEquipment->AirDistUnit(state.dataOutRptTab->iunitGHGR).HeatGain;
    4573       726985 :             ZonePreDefRep(state.dataOutRptTab->curZoneGHGR).SHGSAnHvacATUCl -=
    4574       726985 :                 state.dataDefineEquipment->AirDistUnit(state.dataOutRptTab->iunitGHGR).CoolGain;
    4575       726985 :             state.dataOutRptTab->ATUHeat(state.dataOutRptTab->curZoneGHGR) +=
    4576       726985 :                 state.dataDefineEquipment->AirDistUnit(state.dataOutRptTab->iunitGHGR).HeatRate;
    4577       726985 :             state.dataOutRptTab->ATUCool(state.dataOutRptTab->curZoneGHGR) -=
    4578       726985 :                 state.dataDefineEquipment->AirDistUnit(state.dataOutRptTab->iunitGHGR).CoolRate;
    4579              :         }
    4580              :     }
    4581              :     // the fraction of the zone time step used by the system timestep
    4582       278405 :     state.dataOutRptTab->timeStepRatio = state.dataHVACGlobal->TimeStepSys / state.dataGlobal->TimeStepZone;
    4583      1544555 :     for (state.dataOutRptTab->iZoneGHGR = 1; state.dataOutRptTab->iZoneGHGR <= state.dataGlobal->NumOfZones; ++state.dataOutRptTab->iZoneGHGR) {
    4584      1266150 :         Real64 const mult = Zone(state.dataOutRptTab->iZoneGHGR).Multiplier * Zone(state.dataOutRptTab->iZoneGHGR).ListMultiplier;
    4585              :         // People Sensible Heat Addition
    4586      1266150 :         ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSAnPeoplAdd +=
    4587      1266150 :             state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).PeopleSenGain * mult * state.dataOutRptTab->timeStepRatio;
    4588              :         // Lights Sensible Heat Addition
    4589      1266150 :         ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSAnLiteAdd +=
    4590      1266150 :             state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).LtsTotGain * mult * state.dataOutRptTab->timeStepRatio;
    4591              :         // HVAC Input Sensible Air Heating
    4592              :         // HVAC Input Sensible Air Cooling
    4593      1266150 :         Real64 ZoneEqHeatorCool = state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDTsystem +
    4594      1266150 :                                   state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumNonAirSystem * mult -
    4595      1266150 :                                   state.dataOutRptTab->ATUHeat(state.dataOutRptTab->iZoneGHGR) -
    4596      1266150 :                                   state.dataOutRptTab->ATUCool(state.dataOutRptTab->iZoneGHGR);
    4597      1266150 :         if (ZoneEqHeatorCool > 0.0) {
    4598       148572 :             ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSAnZoneEqHt += ZoneEqHeatorCool * TimeStepSysSec;
    4599              :         } else {
    4600      1117578 :             ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSAnZoneEqCl += ZoneEqHeatorCool * TimeStepSysSec;
    4601              :         }
    4602              :         // Interzone Air Transfer Heat Addition
    4603              :         // Interzone Air Transfer Heat Removal
    4604      1266150 :         if (state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDTzones > 0.0) {
    4605         1280 :             ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSAnIzaAdd +=
    4606         1280 :                 state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDTzones * mult * TimeStepSysSec;
    4607              :         } else {
    4608      1264870 :             ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSAnIzaRem +=
    4609      1264870 :                 state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDTzones * mult * TimeStepSysSec;
    4610              :         }
    4611              :         // Window Heat Addition
    4612              :         // Window Heat Removal
    4613      1266150 :         ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSAnWindAdd +=
    4614      1266150 :             state.dataHeatBal->ZoneWinHeatGainRepEnergy(state.dataOutRptTab->iZoneGHGR) * mult * state.dataOutRptTab->timeStepRatio;
    4615      1266150 :         ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSAnWindRem -=
    4616      1266150 :             state.dataHeatBal->ZoneWinHeatLossRepEnergy(state.dataOutRptTab->iZoneGHGR) * mult * state.dataOutRptTab->timeStepRatio;
    4617              :         // Infiltration Heat Addition
    4618              :         // Infiltration Heat Removal
    4619      1266150 :         if (state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDtInfil > 0.0) {
    4620        28165 :             ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSAnInfilAdd +=
    4621        28165 :                 state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDtInfil * mult * TimeStepSysSec;
    4622              :         } else {
    4623      1237985 :             ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSAnInfilRem +=
    4624      1237985 :                 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      1266150 :         state.dataOutRptTab->eqpSensGHGR = (state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).ElecRadGain +
    4630      1266150 :                                             state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).GasRadGain +
    4631      1266150 :                                             state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).HWRadGain +
    4632      1266150 :                                             state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).SteamRadGain +
    4633      1266150 :                                             state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).OtherRadGain +
    4634      1266150 :                                             state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).ElecConGain +
    4635      1266150 :                                             state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).GasConGain +
    4636      1266150 :                                             state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).HWConGain +
    4637      1266150 :                                             state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).SteamConGain +
    4638      1266150 :                                             state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).OtherConGain) *
    4639      1266150 :                                            state.dataOutRptTab->timeStepRatio;
    4640      1266150 :         if (state.dataOutRptTab->eqpSensGHGR > 0.0) {
    4641       836842 :             ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSAnEquipAdd += state.dataOutRptTab->eqpSensGHGR * mult;
    4642              :         } else {
    4643       429308 :             ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSAnEquipRem += state.dataOutRptTab->eqpSensGHGR * mult;
    4644              :         }
    4645              :     }
    4646       278405 :     state.dataOutRptTab->curZoneGHGR = 0;
    4647              :     // HVAC Input Heated Surface Heating
    4648              :     // HVAC Input Cooled Surface Cooling
    4649       278405 :     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       278405 :     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       278405 :     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       278405 :     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      1544555 :     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      2532300 :         state.dataOutRptTab->totalGHGR =
    4710      1266150 :             ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSAnPeoplAdd + ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSAnLiteAdd +
    4711      1266150 :             ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSAnZoneEqHt + ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSAnZoneEqCl +
    4712      1266150 :             ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSAnHvacATUHt + ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSAnHvacATUCl +
    4713      1266150 :             ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSAnIzaAdd + ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSAnIzaRem +
    4714      1266150 :             ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSAnWindAdd + ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSAnWindRem +
    4715      1266150 :             ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSAnInfilAdd + ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSAnInfilRem +
    4716      1266150 :             ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSAnEquipAdd + ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSAnEquipRem +
    4717      1266150 :             ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSAnSurfHt + ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSAnSurfCl;
    4718      2532300 :         state.dataOutRptTab->totalGHGR =
    4719      1266150 :             -state.dataOutRptTab->totalGHGR; // want to know the negative value of the sum since the row should add up to zero
    4720      1266150 :         if (state.dataOutRptTab->totalGHGR > 0) {
    4721        34484 :             ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSAnOtherAdd = state.dataOutRptTab->totalGHGR;
    4722              :         } else {
    4723      1231666 :             ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSAnOtherRem = state.dataOutRptTab->totalGHGR;
    4724              :         }
    4725              :     }
    4726              :     //--------------------------------
    4727              :     // ZONE PEAK COOLING AND HEATING
    4728              :     //--------------------------------
    4729      1544555 :     for (state.dataOutRptTab->iZoneGHGR = 1; state.dataOutRptTab->iZoneGHGR <= state.dataGlobal->NumOfZones; ++state.dataOutRptTab->iZoneGHGR) {
    4730      1266150 :         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      1266150 :         if ((state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDTsystem +
    4734      1266150 :              state.dataOutRptTab->radiantHeat(state.dataOutRptTab->iZoneGHGR) +
    4735      1266150 :              state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumNonAirSystem * mult) > 0) {
    4736       324732 :             if ((state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDTsystem +
    4737       324732 :                  state.dataOutRptTab->radiantHeat(state.dataOutRptTab->iZoneGHGR) +
    4738       324732 :                  state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumNonAirSystem * mult) >
    4739       324732 :                 ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).htPeak) {
    4740          735 :                 ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).htPeak =
    4741          735 :                     state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDTsystem +
    4742          735 :                     state.dataOutRptTab->radiantHeat(state.dataOutRptTab->iZoneGHGR) +
    4743          735 :                     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          735 :                 int const ActualTimeMin = OutputProcessor::DetermineMinuteForReporting(state);
    4750          735 :                 EncodeMonDayHrMin(state.dataOutRptTab->timestepTimeStampGHGR,
    4751          735 :                                   state.dataEnvrn->Month,
    4752          735 :                                   state.dataEnvrn->DayOfMonth,
    4753          735 :                                   state.dataGlobal->HourOfDay,
    4754              :                                   ActualTimeMin);
    4755          735 :                 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          735 :                 ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtHvacHt =
    4760          735 :                     state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDTsystem +
    4761          735 :                     state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumNonAirSystem * mult;
    4762          735 :                 ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtHvacCl = 0.0;
    4763              :                 // HVAC Input Heated Surface Heating
    4764              :                 // HVAC Input Cooled Surface Cooling
    4765          735 :                 ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtSurfHt =
    4766          735 :                     state.dataOutRptTab->radiantHeat(state.dataOutRptTab->iZoneGHGR); // multipliers included above
    4767          735 :                 ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtSurfCl =
    4768          735 :                     state.dataOutRptTab->radiantCool(state.dataOutRptTab->iZoneGHGR); // multipliers included above
    4769              :                 // HVAC ATU Heating at Heat Peak
    4770              :                 // HVAC ATU Cooling at Heat Peak
    4771          735 :                 ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtHvacATUHt =
    4772          735 :                     state.dataOutRptTab->ATUHeat(state.dataOutRptTab->iZoneGHGR); // multipliers included above
    4773          735 :                 ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtHvacATUCl =
    4774          735 :                     state.dataOutRptTab->ATUCool(state.dataOutRptTab->iZoneGHGR); // multipliers included above
    4775              :                 // People Sensible Heat Addition
    4776          735 :                 ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtPeoplAdd =
    4777          735 :                     state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).PeopleSenGainRate * mult;
    4778              :                 // Lights Sensible Heat Addition
    4779          735 :                 ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtLiteAdd =
    4780          735 :                     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          735 :                 state.dataOutRptTab->eqpSensGHGR = state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).ElecRadGainRate +
    4785          735 :                                                    state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).GasRadGainRate +
    4786          735 :                                                    state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).HWRadGainRate +
    4787          735 :                                                    state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).SteamRadGainRate +
    4788          735 :                                                    state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).OtherRadGainRate +
    4789          735 :                                                    state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).ElecConGainRate +
    4790          735 :                                                    state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).GasConGainRate +
    4791          735 :                                                    state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).HWConGainRate +
    4792          735 :                                                    state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).SteamConGainRate +
    4793          735 :                                                    state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).OtherConGainRate;
    4794          735 :                 if (state.dataOutRptTab->eqpSensGHGR > 0.0) {
    4795          273 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtEquipAdd = state.dataOutRptTab->eqpSensGHGR * mult;
    4796          273 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtEquipRem = 0.0;
    4797              :                 } else {
    4798          462 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtEquipAdd = 0.0;
    4799          462 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtEquipRem = state.dataOutRptTab->eqpSensGHGR * mult;
    4800              :                 }
    4801              :                 // Window Heat Addition
    4802              :                 // Window Heat Removal
    4803          735 :                 ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtWindAdd =
    4804          735 :                     state.dataHeatBal->ZoneWinHeatGainRep(state.dataOutRptTab->iZoneGHGR) * mult;
    4805          735 :                 ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtWindRem =
    4806          735 :                     -state.dataHeatBal->ZoneWinHeatLossRep(state.dataOutRptTab->iZoneGHGR) * mult;
    4807              :                 // mixing object heat addition and removal
    4808          735 :                 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          735 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtIzaAdd = 0.0;
    4814          735 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtIzaRem =
    4815          735 :                         state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDTzones * mult;
    4816              :                 }
    4817              :                 // Infiltration Heat Addition
    4818              :                 // Infiltration Heat Removal
    4819          735 :                 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          735 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtInfilAdd = 0.0;
    4825          735 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtInfilRem =
    4826          735 :                         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         1470 :                 state.dataOutRptTab->totalGHGR =
    4831          735 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtPeoplAdd + ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtLiteAdd +
    4832          735 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtHvacHt + ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtHvacCl +
    4833          735 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtIzaAdd + ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtIzaRem +
    4834          735 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtWindAdd + ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtWindRem +
    4835          735 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtInfilAdd + ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtInfilRem +
    4836          735 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtEquipAdd + ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtEquipRem +
    4837          735 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtSurfHt + ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtSurfCl;
    4838         1470 :                 state.dataOutRptTab->totalGHGR =
    4839          735 :                     -state.dataOutRptTab->totalGHGR; // want to know the negative value of the sum since the row should add up to zero
    4840          735 :                 if (state.dataOutRptTab->totalGHGR > 0) {
    4841          174 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtOtherAdd = state.dataOutRptTab->totalGHGR;
    4842          174 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtOtherRem = 0.0;
    4843              :                 } else {
    4844          561 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtOtherAdd = 0.0;
    4845          561 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtOtherRem = state.dataOutRptTab->totalGHGR;
    4846              :                 }
    4847              :             }
    4848              :         } else {
    4849       941418 :             if ((state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDTsystem +
    4850       941418 :                  state.dataOutRptTab->radiantCool(state.dataOutRptTab->iZoneGHGR) +
    4851       941418 :                  state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumNonAirSystem * mult) <
    4852       941418 :                 ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).clPeak) {
    4853         2083 :                 ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).clPeak =
    4854         2083 :                     state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDTsystem +
    4855         2083 :                     state.dataOutRptTab->radiantCool(state.dataOutRptTab->iZoneGHGR) +
    4856         2083 :                     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         2083 :                 int const ActualTimeMin = OutputProcessor::DetermineMinuteForReporting(state);
    4863         2083 :                 EncodeMonDayHrMin(state.dataOutRptTab->timestepTimeStampGHGR,
    4864         2083 :                                   state.dataEnvrn->Month,
    4865         2083 :                                   state.dataEnvrn->DayOfMonth,
    4866         2083 :                                   state.dataGlobal->HourOfDay,
    4867              :                                   ActualTimeMin);
    4868         2083 :                 ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).clPtTimeStamp = state.dataOutRptTab->timestepTimeStampGHGR;
    4869              :                 // HVAC Input Sensible Air Heating
    4870              :                 // HVAC Input Sensible Air Cooling
    4871         2083 :                 ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClHvacHt = 0.0;
    4872         2083 :                 ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClHvacCl =
    4873         2083 :                     state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDTsystem +
    4874         2083 :                     state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumNonAirSystem * mult;
    4875              :                 // HVAC Input Heated Surface Heating
    4876              :                 // HVAC Input Cooled Surface Cooling
    4877         2083 :                 ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClSurfHt = state.dataOutRptTab->radiantHeat(state.dataOutRptTab->iZoneGHGR);
    4878         2083 :                 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         2083 :                 ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClHvacATUHt = state.dataOutRptTab->ATUHeat(state.dataOutRptTab->iZoneGHGR);
    4882         2083 :                 ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClHvacATUCl = state.dataOutRptTab->ATUCool(state.dataOutRptTab->iZoneGHGR);
    4883              :                 // People Sensible Heat Addition
    4884         2083 :                 ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClPeoplAdd =
    4885         2083 :                     state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).PeopleSenGainRate * mult;
    4886              :                 // Lights Sensible Heat Addition
    4887         2083 :                 ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClLiteAdd =
    4888         2083 :                     state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).LtsTotGainRate * mult;
    4889              :                 // Equipment Sensible Heat Addition
    4890              :                 // Equipment Sensible Heat Removal
    4891         2083 :                 state.dataOutRptTab->eqpSensGHGR = state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).ElecRadGainRate +
    4892         2083 :                                                    state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).GasRadGainRate +
    4893         2083 :                                                    state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).HWRadGainRate +
    4894         2083 :                                                    state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).SteamRadGainRate +
    4895         2083 :                                                    state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).OtherRadGainRate +
    4896         2083 :                                                    state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).ElecConGainRate +
    4897         2083 :                                                    state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).GasConGainRate +
    4898         2083 :                                                    state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).HWConGainRate +
    4899         2083 :                                                    state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).SteamConGainRate +
    4900         2083 :                                                    state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).OtherConGainRate;
    4901         2083 :                 if (state.dataOutRptTab->eqpSensGHGR > 0.0) {
    4902         1901 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClEquipAdd = state.dataOutRptTab->eqpSensGHGR * mult;
    4903         1901 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClEquipRem = 0.0;
    4904              :                 } else {
    4905          182 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClEquipAdd = 0.0;
    4906          182 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClEquipRem = state.dataOutRptTab->eqpSensGHGR * mult;
    4907              :                 }
    4908              :                 // Window Heat Addition
    4909              :                 // Window Heat Removal
    4910         2083 :                 ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClWindAdd =
    4911         2083 :                     state.dataHeatBal->ZoneWinHeatGainRep(state.dataOutRptTab->iZoneGHGR) * mult;
    4912         2083 :                 ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClWindRem =
    4913         2083 :                     -state.dataHeatBal->ZoneWinHeatLossRep(state.dataOutRptTab->iZoneGHGR) * mult;
    4914              :                 // mixing object cool addition and removal
    4915         2083 :                 if (state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDTzones > 0.0) {
    4916           30 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClIzaAdd =
    4917           30 :                         state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDTzones * mult;
    4918           30 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClIzaRem = 0.0;
    4919              :                 } else {
    4920         2053 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClIzaAdd = 0.0;
    4921         2053 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClIzaRem =
    4922         2053 :                         state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDTzones * mult;
    4923              :                 }
    4924              :                 // Infiltration Heat Addition
    4925              :                 // Infiltration Heat Removal
    4926         2083 :                 if (state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDtInfil > 0.0) {
    4927          102 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClInfilAdd =
    4928          102 :                         state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDtInfil * mult;
    4929          102 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClInfilRem = 0.0;
    4930              :                 } else {
    4931         1981 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClInfilAdd = 0.0;
    4932         1981 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClInfilRem =
    4933         1981 :                         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         4166 :                 state.dataOutRptTab->totalGHGR =
    4938         2083 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClPeoplAdd + ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClLiteAdd +
    4939         2083 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClHvacHt + ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClHvacCl +
    4940         2083 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClIzaAdd + ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClIzaRem +
    4941         2083 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClWindAdd + ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClWindRem +
    4942         2083 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClInfilAdd + ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClInfilRem +
    4943         2083 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClEquipAdd + ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClEquipRem +
    4944         2083 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClSurfHt + ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClSurfCl;
    4945         4166 :                 state.dataOutRptTab->totalGHGR =
    4946         2083 :                     -state.dataOutRptTab->totalGHGR; // want to know the negative value of the sum since the row should add up to zero
    4947         2083 :                 if (state.dataOutRptTab->totalGHGR > 0) {
    4948          298 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClOtherAdd = state.dataOutRptTab->totalGHGR;
    4949          298 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClOtherRem = 0.0;
    4950              :                 } else {
    4951         1785 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClOtherAdd = 0.0;
    4952         1785 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClOtherRem = state.dataOutRptTab->totalGHGR;
    4953              :                 }
    4954              :             }
    4955              :         }
    4956              :     }
    4957              :     //------------------------------------
    4958              :     // BUILDING PEAK COOLING AND HEATING
    4959              :     //------------------------------------
    4960       278405 :     state.dataOutRptTab->bldgHtPk = 0.0;
    4961       278405 :     state.dataOutRptTab->bldgClPk = 0.0;
    4962      1544555 :     for (state.dataOutRptTab->iZoneGHGR = 1; state.dataOutRptTab->iZoneGHGR <= state.dataGlobal->NumOfZones; ++state.dataOutRptTab->iZoneGHGR) {
    4963      1266150 :         Real64 const mult = Zone(state.dataOutRptTab->iZoneGHGR).Multiplier * Zone(state.dataOutRptTab->iZoneGHGR).ListMultiplier;
    4964      1266150 :         if ((state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDTsystem +
    4965      1266150 :              state.dataOutRptTab->radiantHeat(state.dataOutRptTab->iZoneGHGR) +
    4966      1266150 :              state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumNonAirSystem * mult) > 0) {
    4967       649464 :             state.dataOutRptTab->bldgHtPk += state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDTsystem +
    4968       324732 :                                              state.dataOutRptTab->radiantHeat(state.dataOutRptTab->iZoneGHGR) +
    4969       324732 :                                              state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumNonAirSystem * mult;
    4970              :         } else {
    4971      1882836 :             state.dataOutRptTab->bldgClPk += state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDTsystem +
    4972       941418 :                                              state.dataOutRptTab->radiantCool(state.dataOutRptTab->iZoneGHGR) +
    4973       941418 :                                              state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumNonAirSystem * mult;
    4974              :         }
    4975              :     }
    4976       278405 :     if (state.dataOutRptTab->bldgHtPk > state.dataHeatBal->BuildingPreDefRep.htPeak) {
    4977          228 :         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          228 :         int const ActualTimeMin = OutputProcessor::DetermineMinuteForReporting(state);
    4984          228 :         EncodeMonDayHrMin(state.dataOutRptTab->timestepTimeStampGHGR,
    4985          228 :                           state.dataEnvrn->Month,
    4986          228 :                           state.dataEnvrn->DayOfMonth,
    4987          228 :                           state.dataGlobal->HourOfDay,
    4988              :                           ActualTimeMin);
    4989          228 :         state.dataHeatBal->BuildingPreDefRep.htPtTimeStamp = state.dataOutRptTab->timestepTimeStampGHGR;
    4990              :         // reset building level results to zero prior to accumulating across zones
    4991          228 :         state.dataHeatBal->BuildingPreDefRep.SHGSHtHvacHt = 0.0;
    4992          228 :         state.dataHeatBal->BuildingPreDefRep.SHGSHtHvacCl = 0.0;
    4993          228 :         state.dataHeatBal->BuildingPreDefRep.SHGSHtHvacATUHt = 0.0;
    4994          228 :         state.dataHeatBal->BuildingPreDefRep.SHGSHtHvacATUCl = 0.0;
    4995          228 :         state.dataHeatBal->BuildingPreDefRep.SHGSHtSurfHt = 0.0;
    4996          228 :         state.dataHeatBal->BuildingPreDefRep.SHGSHtSurfCl = 0.0;
    4997          228 :         state.dataHeatBal->BuildingPreDefRep.SHGSHtPeoplAdd = 0.0;
    4998          228 :         state.dataHeatBal->BuildingPreDefRep.SHGSHtLiteAdd = 0.0;
    4999          228 :         state.dataHeatBal->BuildingPreDefRep.SHGSHtEquipAdd = 0.0;
    5000          228 :         state.dataHeatBal->BuildingPreDefRep.SHGSHtWindAdd = 0.0;
    5001          228 :         state.dataHeatBal->BuildingPreDefRep.SHGSHtIzaAdd = 0.0;
    5002          228 :         state.dataHeatBal->BuildingPreDefRep.SHGSHtInfilAdd = 0.0;
    5003          228 :         state.dataHeatBal->BuildingPreDefRep.SHGSHtOtherAdd = 0.0;
    5004          228 :         state.dataHeatBal->BuildingPreDefRep.SHGSHtEquipRem = 0.0;
    5005          228 :         state.dataHeatBal->BuildingPreDefRep.SHGSHtWindRem = 0.0;
    5006          228 :         state.dataHeatBal->BuildingPreDefRep.SHGSHtIzaRem = 0.0;
    5007          228 :         state.dataHeatBal->BuildingPreDefRep.SHGSHtInfilRem = 0.0;
    5008          228 :         state.dataHeatBal->BuildingPreDefRep.SHGSHtOtherRem = 0.0;
    5009         1227 :         for (state.dataOutRptTab->iZoneGHGR = 1; state.dataOutRptTab->iZoneGHGR <= state.dataGlobal->NumOfZones; ++state.dataOutRptTab->iZoneGHGR) {
    5010          999 :             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          999 :             state.dataHeatBal->BuildingPreDefRep.SHGSHtHvacHt += state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDTsystem +
    5014          999 :                                                                  state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumNonAirSystem * mult;
    5015              :             // HVAC Input Heated Surface Heating
    5016              :             // HVAC Input Cooled Surface Cooling
    5017          999 :             state.dataHeatBal->BuildingPreDefRep.SHGSHtSurfHt += state.dataOutRptTab->radiantHeat(state.dataOutRptTab->iZoneGHGR);
    5018          999 :             state.dataHeatBal->BuildingPreDefRep.SHGSHtSurfCl += state.dataOutRptTab->radiantCool(state.dataOutRptTab->iZoneGHGR);
    5019              :             // HVAC ATU Heating
    5020              :             // HVAC ATU Cooling
    5021          999 :             state.dataHeatBal->BuildingPreDefRep.SHGSHtHvacATUHt += state.dataOutRptTab->ATUHeat(state.dataOutRptTab->iZoneGHGR);
    5022          999 :             state.dataHeatBal->BuildingPreDefRep.SHGSHtHvacATUCl += state.dataOutRptTab->ATUCool(state.dataOutRptTab->iZoneGHGR);
    5023              :             // People Sensible Heat Addition
    5024         1998 :             state.dataHeatBal->BuildingPreDefRep.SHGSHtPeoplAdd +=
    5025          999 :                 state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).PeopleSenGainRate * mult;
    5026              :             // Lights Sensible Heat Addition
    5027          999 :             state.dataHeatBal->BuildingPreDefRep.SHGSHtLiteAdd += state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).LtsTotGainRate * mult;
    5028              :             // Equipment Sensible Heat Addition
    5029              :             // Equipment Sensible Heat Removal
    5030          999 :             state.dataOutRptTab->eqpSensGHGR = state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).ElecRadGainRate +
    5031          999 :                                                state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).GasRadGainRate +
    5032          999 :                                                state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).HWRadGainRate +
    5033          999 :                                                state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).SteamRadGainRate +
    5034          999 :                                                state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).OtherRadGainRate +
    5035          999 :                                                state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).ElecConGainRate +
    5036          999 :                                                state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).GasConGainRate +
    5037          999 :                                                state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).HWConGainRate +
    5038          999 :                                                state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).SteamConGainRate +
    5039          999 :                                                state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).OtherConGainRate;
    5040          999 :             if (state.dataOutRptTab->eqpSensGHGR > 0.0) {
    5041          560 :                 state.dataHeatBal->BuildingPreDefRep.SHGSHtEquipAdd += state.dataOutRptTab->eqpSensGHGR * mult;
    5042              :             } else {
    5043          439 :                 state.dataHeatBal->BuildingPreDefRep.SHGSHtEquipRem += state.dataOutRptTab->eqpSensGHGR * mult;
    5044              :             }
    5045              :             // Window Heat Addition
    5046              :             // Window Heat Removal
    5047          999 :             state.dataHeatBal->BuildingPreDefRep.SHGSHtWindAdd += state.dataHeatBal->ZoneWinHeatGainRep(state.dataOutRptTab->iZoneGHGR) * mult;
    5048          999 :             state.dataHeatBal->BuildingPreDefRep.SHGSHtWindRem -= state.dataHeatBal->ZoneWinHeatLossRep(state.dataOutRptTab->iZoneGHGR) * mult;
    5049              :             // mixing object heat addition and removal
    5050          999 :             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          999 :                 state.dataHeatBal->BuildingPreDefRep.SHGSHtIzaRem += state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDTzones * mult;
    5054              :             }
    5055              :             // Infiltration Heat Addition
    5056              :             // Infiltration Heat Removal
    5057          999 :             if (state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDtInfil > 00) {
    5058            3 :                 state.dataHeatBal->BuildingPreDefRep.SHGSHtInfilAdd +=
    5059            3 :                     state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDtInfil * mult;
    5060              :             } else {
    5061          996 :                 state.dataHeatBal->BuildingPreDefRep.SHGSHtInfilRem +=
    5062          996 :                     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          228 :         state.dataOutRptTab->totalGHGR = state.dataHeatBal->BuildingPreDefRep.SHGSHtPeoplAdd + state.dataHeatBal->BuildingPreDefRep.SHGSHtLiteAdd +
    5068          228 :                                          state.dataHeatBal->BuildingPreDefRep.SHGSHtHvacHt + state.dataHeatBal->BuildingPreDefRep.SHGSHtHvacCl +
    5069          228 :                                          state.dataHeatBal->BuildingPreDefRep.SHGSHtIzaAdd + state.dataHeatBal->BuildingPreDefRep.SHGSHtIzaRem +
    5070          228 :                                          state.dataHeatBal->BuildingPreDefRep.SHGSHtWindAdd + state.dataHeatBal->BuildingPreDefRep.SHGSHtWindRem +
    5071          228 :                                          state.dataHeatBal->BuildingPreDefRep.SHGSHtInfilAdd + state.dataHeatBal->BuildingPreDefRep.SHGSHtInfilRem +
    5072          228 :                                          state.dataHeatBal->BuildingPreDefRep.SHGSHtEquipAdd + state.dataHeatBal->BuildingPreDefRep.SHGSHtEquipRem +
    5073          228 :                                          state.dataHeatBal->BuildingPreDefRep.SHGSHtSurfHt + state.dataHeatBal->BuildingPreDefRep.SHGSHtSurfCl;
    5074          456 :         state.dataOutRptTab->totalGHGR =
    5075          228 :             -state.dataOutRptTab->totalGHGR; // want to know the negative value of the sum since the row should add up to zero
    5076          228 :         if (state.dataOutRptTab->totalGHGR > 0) {
    5077           40 :             state.dataHeatBal->BuildingPreDefRep.SHGSHtOtherAdd += state.dataOutRptTab->totalGHGR;
    5078              :         } else {
    5079          188 :             state.dataHeatBal->BuildingPreDefRep.SHGSHtOtherRem += state.dataOutRptTab->totalGHGR;
    5080              :         }
    5081              :     }
    5082       278405 :     if (state.dataOutRptTab->bldgClPk < state.dataHeatBal->BuildingPreDefRep.clPeak) {
    5083          618 :         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          618 :         int const ActualTimeMin = OutputProcessor::DetermineMinuteForReporting(state);
    5090          618 :         EncodeMonDayHrMin(state.dataOutRptTab->timestepTimeStampGHGR,
    5091          618 :                           state.dataEnvrn->Month,
    5092          618 :                           state.dataEnvrn->DayOfMonth,
    5093          618 :                           state.dataGlobal->HourOfDay,
    5094              :                           ActualTimeMin);
    5095          618 :         state.dataHeatBal->BuildingPreDefRep.clPtTimeStamp = state.dataOutRptTab->timestepTimeStampGHGR;
    5096              :         // reset building level results to zero prior to accumulating across zones
    5097          618 :         state.dataHeatBal->BuildingPreDefRep.SHGSClHvacHt = 0.0;
    5098          618 :         state.dataHeatBal->BuildingPreDefRep.SHGSClHvacCl = 0.0;
    5099          618 :         state.dataHeatBal->BuildingPreDefRep.SHGSClSurfHt = 0.0;
    5100          618 :         state.dataHeatBal->BuildingPreDefRep.SHGSClSurfCl = 0.0;
    5101          618 :         state.dataHeatBal->BuildingPreDefRep.SHGSClHvacATUHt = 0.0;
    5102          618 :         state.dataHeatBal->BuildingPreDefRep.SHGSClHvacATUCl = 0.0;
    5103          618 :         state.dataHeatBal->BuildingPreDefRep.SHGSClPeoplAdd = 0.0;
    5104          618 :         state.dataHeatBal->BuildingPreDefRep.SHGSClLiteAdd = 0.0;
    5105          618 :         state.dataHeatBal->BuildingPreDefRep.SHGSClEquipAdd = 0.0;
    5106          618 :         state.dataHeatBal->BuildingPreDefRep.SHGSClWindAdd = 0.0;
    5107          618 :         state.dataHeatBal->BuildingPreDefRep.SHGSClIzaAdd = 0.0;
    5108          618 :         state.dataHeatBal->BuildingPreDefRep.SHGSClInfilAdd = 0.0;
    5109          618 :         state.dataHeatBal->BuildingPreDefRep.SHGSClOtherAdd = 0.0;
    5110          618 :         state.dataHeatBal->BuildingPreDefRep.SHGSClEquipRem = 0.0;
    5111          618 :         state.dataHeatBal->BuildingPreDefRep.SHGSClWindRem = 0.0;
    5112          618 :         state.dataHeatBal->BuildingPreDefRep.SHGSClIzaRem = 0.0;
    5113          618 :         state.dataHeatBal->BuildingPreDefRep.SHGSClInfilRem = 0.0;
    5114          618 :         state.dataHeatBal->BuildingPreDefRep.SHGSClOtherRem = 0.0;
    5115         3465 :         for (state.dataOutRptTab->iZoneGHGR = 1; state.dataOutRptTab->iZoneGHGR <= state.dataGlobal->NumOfZones; ++state.dataOutRptTab->iZoneGHGR) {
    5116         2847 :             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         2847 :             state.dataHeatBal->BuildingPreDefRep.SHGSClHvacCl += state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDTsystem +
    5120         2847 :                                                                  state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumNonAirSystem * mult;
    5121              :             // HVAC Input Heated Surface Heating
    5122              :             // HVAC Input Cooled Surface Cooling
    5123         2847 :             state.dataHeatBal->BuildingPreDefRep.SHGSClSurfHt += state.dataOutRptTab->radiantHeat(state.dataOutRptTab->iZoneGHGR);
    5124         2847 :             state.dataHeatBal->BuildingPreDefRep.SHGSClSurfCl += state.dataOutRptTab->radiantCool(state.dataOutRptTab->iZoneGHGR);
    5125              :             // HVAC ATU Heating
    5126              :             // HVAC ATU Cooling
    5127         2847 :             state.dataHeatBal->BuildingPreDefRep.SHGSClHvacATUHt += state.dataOutRptTab->ATUHeat(state.dataOutRptTab->iZoneGHGR);
    5128         2847 :             state.dataHeatBal->BuildingPreDefRep.SHGSClHvacATUCl += state.dataOutRptTab->ATUCool(state.dataOutRptTab->iZoneGHGR);
    5129              :             // People Sensible Heat Addition
    5130         5694 :             state.dataHeatBal->BuildingPreDefRep.SHGSClPeoplAdd +=
    5131         2847 :                 state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).PeopleSenGainRate * mult;
    5132              :             // Lights Sensible Heat Addition
    5133         2847 :             state.dataHeatBal->BuildingPreDefRep.SHGSClLiteAdd += state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).LtsTotGainRate * mult;
    5134              :             // Equipment Sensible Heat Addition
    5135              :             // Equipment Sensible Heat Removal
    5136         2847 :             state.dataOutRptTab->eqpSensGHGR = state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).ElecRadGainRate +
    5137         2847 :                                                state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).GasRadGainRate +
    5138         2847 :                                                state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).HWRadGainRate +
    5139         2847 :                                                state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).SteamRadGainRate +
    5140         2847 :                                                state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).OtherRadGainRate +
    5141         2847 :                                                state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).ElecConGainRate +
    5142         2847 :                                                state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).GasConGainRate +
    5143         2847 :                                                state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).HWConGainRate +
    5144         2847 :                                                state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).SteamConGainRate +
    5145         2847 :                                                state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).OtherConGainRate;
    5146         2847 :             if (state.dataOutRptTab->eqpSensGHGR > 0.0) {
    5147         2435 :                 state.dataHeatBal->BuildingPreDefRep.SHGSClEquipAdd += state.dataOutRptTab->eqpSensGHGR * mult;
    5148              :             } else {
    5149          412 :                 state.dataHeatBal->BuildingPreDefRep.SHGSClEquipRem += state.dataOutRptTab->eqpSensGHGR * mult;
    5150              :             }
    5151              :             // Window Heat Addition
    5152              :             // Window Heat Removal
    5153         2847 :             state.dataHeatBal->BuildingPreDefRep.SHGSClWindAdd += state.dataHeatBal->ZoneWinHeatGainRep(state.dataOutRptTab->iZoneGHGR) * mult;
    5154         2847 :             state.dataHeatBal->BuildingPreDefRep.SHGSClWindRem -= state.dataHeatBal->ZoneWinHeatLossRep(state.dataOutRptTab->iZoneGHGR) * mult;
    5155              :             // mixing object cool addition and removal
    5156         2847 :             if (state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDTzones > 0.0) {
    5157           29 :                 state.dataHeatBal->BuildingPreDefRep.SHGSClIzaAdd += state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDTzones * mult;
    5158              :             } else {
    5159         2818 :                 state.dataHeatBal->BuildingPreDefRep.SHGSClIzaRem += state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDTzones * mult;
    5160              :             }
    5161              :             // Infiltration Heat Addition
    5162              :             // Infiltration Heat Removal
    5163         2847 :             if (state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDtInfil > 00) {
    5164          170 :                 state.dataHeatBal->BuildingPreDefRep.SHGSClInfilAdd +=
    5165          170 :                     state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDtInfil * mult;
    5166              :             } else {
    5167         2677 :                 state.dataHeatBal->BuildingPreDefRep.SHGSClInfilRem +=
    5168         2677 :                     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          618 :         state.dataOutRptTab->totalGHGR = state.dataHeatBal->BuildingPreDefRep.SHGSClPeoplAdd + state.dataHeatBal->BuildingPreDefRep.SHGSClLiteAdd +
    5174          618 :                                          state.dataHeatBal->BuildingPreDefRep.SHGSClHvacHt + state.dataHeatBal->BuildingPreDefRep.SHGSClHvacCl +
    5175          618 :                                          state.dataHeatBal->BuildingPreDefRep.SHGSClIzaAdd + state.dataHeatBal->BuildingPreDefRep.SHGSClIzaRem +
    5176          618 :                                          state.dataHeatBal->BuildingPreDefRep.SHGSClWindAdd + state.dataHeatBal->BuildingPreDefRep.SHGSClWindRem +
    5177          618 :                                          state.dataHeatBal->BuildingPreDefRep.SHGSClInfilAdd + state.dataHeatBal->BuildingPreDefRep.SHGSClInfilRem +
    5178          618 :                                          state.dataHeatBal->BuildingPreDefRep.SHGSClEquipAdd + state.dataHeatBal->BuildingPreDefRep.SHGSClEquipRem +
    5179          618 :                                          state.dataHeatBal->BuildingPreDefRep.SHGSClSurfHt + state.dataHeatBal->BuildingPreDefRep.SHGSClSurfCl;
    5180         1236 :         state.dataOutRptTab->totalGHGR =
    5181          618 :             -state.dataOutRptTab->totalGHGR; // want to know the negative value of the sum since the row should add up to zero
    5182          618 :         if (state.dataOutRptTab->totalGHGR > 0) {
    5183           68 :             state.dataHeatBal->BuildingPreDefRep.SHGSClOtherAdd += state.dataOutRptTab->totalGHGR;
    5184              :         } else {
    5185          550 :             state.dataHeatBal->BuildingPreDefRep.SHGSClOtherRem += state.dataOutRptTab->totalGHGR;
    5186              :         }
    5187              :     }
    5188              : }
    5189              : 
    5190              : //======================================================================================================================
    5191              : //======================================================================================================================
    5192              : 
    5193              : //    WRITE OUTPUT FILE ROUTINES
    5194              : 
    5195              : //======================================================================================================================
    5196              : //======================================================================================================================
    5197              : 
    5198          799 : 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          799 :     FillWeatherPredefinedEntries(state);
    5213          799 :     FillRemainingPredefinedEntries(state);
    5214          799 :     WaterManager::ReportRainfall(state);
    5215          799 :     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          799 :     if (ort->unitsStyle_SQLite == UnitsStyle::NotFound) {
    5220          799 :         ort->unitsStyle_SQLite = ort->unitsStyle; // This is the default UseOutputControlTableStyles
    5221              :     }
    5222              : 
    5223          799 :     if (ort->WriteTabularFiles) {
    5224              : 
    5225              :         // call each type of report in turn
    5226          759 :         WriteBEPSTable(state);
    5227          759 :         WriteTableOfContents(state);
    5228          759 :         WriteVeriSumTable(state);
    5229          759 :         WriteDemandEndUseSummary(state);
    5230          759 :         WriteSourceEnergyEndUseSummary(state);
    5231          759 :         WriteComponentSizing(state);
    5232          759 :         WriteSurfaceShadowing(state);
    5233          759 :         WriteCompCostTable(state);
    5234          759 :         WriteAdaptiveComfortTable(state);
    5235          759 :         WriteEioTables(state);
    5236          759 :         WriteLoadComponentSummaryTables(state);
    5237          759 :         WriteHeatEmissionTable(state);
    5238              : 
    5239          759 :         if (ort->displayThermalResilienceSummary && !state.dataGlobal->DoPureLoadCalc) { // code will crash if pure load calc
    5240          680 :             WriteThermalResilienceTables(state);                                         // code will crash if pure load calc
    5241              :         }
    5242          759 :         if (ort->displayCO2ResilienceSummary && !state.dataGlobal->DoPureLoadCalc) { // code will crash if pure load calc
    5243           15 :             WriteCO2ResilienceTables(state);                                         // code will crash if pure load calc
    5244              :         }
    5245          759 :         if (ort->displayVisualResilienceSummary && !state.dataGlobal->DoPureLoadCalc) { // code will crash if pure load calc
    5246           56 :             WriteVisualResilienceTables(state);                                         // code will crash if pure load calc
    5247              :         }
    5248          759 :         if (state.dataWeather->TotReportPers > 0) {
    5249            4 :             WriteReportPeriodTimeConsumption(state);
    5250              :         }
    5251          764 :         for (int i = 1; i <= state.dataWeather->TotThermalReportPers; i++) {
    5252            5 :             WriteThermalResilienceTablesRepPeriod(state, i);
    5253              :         }
    5254          762 :         for (int i = 1; i <= state.dataWeather->TotCO2ReportPers; i++) {
    5255            3 :             WriteCO2ResilienceTablesRepPeriod(state, i);
    5256              :         }
    5257          762 :         for (int i = 1; i <= state.dataWeather->TotVisualReportPers; i++) {
    5258            3 :             WriteVisualResilienceTablesRepPeriod(state, i);
    5259              :         }
    5260              : 
    5261          759 :         state.dataRptCoilSelection->coilSelectionReportObj->finishCoilSummaryReportTable(
    5262              :             state);                   // call to write out the coil selection summary table data
    5263          759 :         WritePredefinedTables(state); // moved to come after zone load components is finished
    5264              : 
    5265          759 :         if (state.dataGlobal->DoWeathSim) {
    5266            6 :             WriteMonthlyTables(state);
    5267            6 :             WriteTimeBinTables(state);
    5268            6 :             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         1598 :     state.files.audit.ensure_open(state, "WriteTabularReports", state.files.outputControl.audit);
    5275          799 :     print<variable_fmt_syntax>(state.files.audit, variable_fmt, "MonthlyInputCount", ort->MonthlyInputCount);
    5276          799 :     print<variable_fmt_syntax>(state.files.audit, variable_fmt, "sizeMonthlyInput", ort->sizeMonthlyInput);
    5277          799 :     print<variable_fmt_syntax>(state.files.audit, variable_fmt, "MonthlyFieldSetInputCount", ort->MonthlyFieldSetInputCount);
    5278          799 :     print<variable_fmt_syntax>(state.files.audit, variable_fmt, "sizeMonthlyFieldSetInput", ort->sizeMonthlyFieldSetInput);
    5279          799 :     print<variable_fmt_syntax>(state.files.audit, variable_fmt, "MonthlyTablesCount", ort->MonthlyTablesCount);
    5280          799 :     print<variable_fmt_syntax>(state.files.audit, variable_fmt, "MonthlyColumnsCount", ort->MonthlyColumnsCount);
    5281          799 :     print<variable_fmt_syntax>(state.files.audit, variable_fmt, "sizeReportName", state.dataOutRptPredefined->sizeReportName);
    5282          799 :     print<variable_fmt_syntax>(state.files.audit, variable_fmt, "numReportName", state.dataOutRptPredefined->numReportName);
    5283          799 :     print<variable_fmt_syntax>(state.files.audit, variable_fmt, "sizeSubTable", state.dataOutRptPredefined->sizeSubTable);
    5284          799 :     print<variable_fmt_syntax>(state.files.audit, variable_fmt, "numSubTable", state.dataOutRptPredefined->numSubTable);
    5285          799 :     print<variable_fmt_syntax>(state.files.audit, variable_fmt, "sizeColumnTag", state.dataOutRptPredefined->sizeColumnTag);
    5286          799 :     print<variable_fmt_syntax>(state.files.audit, variable_fmt, "numColumnTag", state.dataOutRptPredefined->numColumnTag);
    5287          799 :     print<variable_fmt_syntax>(state.files.audit, variable_fmt, "sizeTableEntry", state.dataOutRptPredefined->sizeTableEntry);
    5288          799 :     print<variable_fmt_syntax>(state.files.audit, variable_fmt, "numTableEntry", state.dataOutRptPredefined->numTableEntry);
    5289          799 :     print<variable_fmt_syntax>(state.files.audit, variable_fmt, "sizeCompSizeTableEntry", state.dataOutRptPredefined->sizeCompSizeTableEntry);
    5290          799 :     print<variable_fmt_syntax>(state.files.audit, variable_fmt, "numCompSizeTableEntry", state.dataOutRptPredefined->numCompSizeTableEntry);
    5291          799 : }
    5292              : 
    5293        11664 : 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        11664 :     bool brkflag(false);
    5308              : 
    5309        11664 :     if (iUnit_Sys == 0) {
    5310         5832 :         unitsStyle_Cur = unitsStyle_Tab;
    5311         5832 :         produce_Tab = true;
    5312         5832 :         if (unitsStyle_Sql == unitsStyle_Tab) {
    5313         5832 :             produce_Sql = true;
    5314              :         } else {
    5315            0 :             produce_Sql = false;
    5316              :         }
    5317              :     } else { // iUnit_Sys == 1
    5318         5832 :         unitsStyle_Cur = unitsStyle_Sql;
    5319         5832 :         produce_Tab = false;
    5320         5832 :         produce_Sql = true;
    5321         5832 :         if (unitsStyle_Sql == unitsStyle_Tab) {
    5322              :             // flag true if a separate SQLite round writing is not needed
    5323         5832 :             brkflag = true;
    5324         5832 :             produce_Sql = false;
    5325              :         }
    5326              :     }
    5327              : 
    5328              :     // False if a separate sqlite round is needed;
    5329              :     // true if not
    5330        11664 :     return brkflag;
    5331              : }
    5332              : 
    5333       430492 : 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       430492 :     if (has_prefix(lineIn, "Statistics")) {
    5343          790 :         lineType = StatLineType::StatisticsLine;
    5344       429702 :     } else if (has_prefix(lineIn, "Location")) {
    5345          790 :         lineType = StatLineType::LocationLine;
    5346       428912 :     } else if (has_prefix(lineIn, "{")) {
    5347          790 :         lineType = StatLineType::LatLongLine;
    5348       428122 :     } else if (has_prefix(lineIn, "Elevation")) {
    5349          790 :         lineType = StatLineType::ElevationLine;
    5350       427332 :     } else if (has_prefix(lineIn, "Standard Pressure")) {
    5351          790 :         lineType = StatLineType::StdPressureLine;
    5352       426542 :     } else if (has_prefix(lineIn, "Data Source")) {
    5353          790 :         lineType = StatLineType::DataSourceLine;
    5354       425752 :     } else if (has_prefix(lineIn, "WMO Station")) {
    5355          790 :         lineType = StatLineType::WMOStationLine;
    5356       424962 :     } else if (has(lineIn, "Design Conditions")) {
    5357         1548 :         if (!desConditionlinepassed) {
    5358          790 :             desConditionlinepassed = true;
    5359          790 :             lineType = StatLineType::DesignConditionsLine;
    5360              :         }
    5361       423414 :     } else if (has_prefix(lineIn, "\tHeating")) {
    5362          786 :         if (!heatingDesignlinepassed) {
    5363          786 :             heatingDesignlinepassed = true;
    5364          786 :             lineType = StatLineType::HeatingConditionsLine;
    5365              :         }
    5366       422628 :     } else if (has_prefix(lineIn, "\tCooling")) {
    5367          786 :         if (!coolingDesignlinepassed) {
    5368          786 :             coolingDesignlinepassed = true;
    5369          786 :             lineType = StatLineType::CoolingConditionsLine;
    5370              :         }
    5371       421842 :     } else if (has(lineIn, "(standard) heating degree-days (18.3")) {
    5372          758 :         lineType = StatLineType::StdHDDLine;
    5373       421084 :     } else if (has(lineIn, "(standard) cooling degree-days (10")) {
    5374          758 :         lineType = StatLineType::StdCDDLine;
    5375              : 
    5376       420326 :     } else if (has(lineIn, "Maximum Dry Bulb")) {
    5377          790 :         lineType = StatLineType::MaxDryBulbLine;
    5378       419536 :     } else if (has(lineIn, "Minimum Dry Bulb")) {
    5379          790 :         lineType = StatLineType::MinDryBulbLine;
    5380       418746 :     } else if (has(lineIn, "Maximum Dew Point")) {
    5381          790 :         lineType = StatLineType::MaxDewPointLine;
    5382       417956 :     } else if (has(lineIn, "Minimum Dew Point")) {
    5383          790 :         lineType = StatLineType::MinDewPointLine;
    5384       417166 :     } else if (has(lineIn, "(wthr file) heating degree-days (18") || has(lineIn, "heating degree-days (18")) {
    5385          790 :         lineType = StatLineType::WithHDDLine;
    5386       416376 :     } else if (has(lineIn, "(wthr file) cooling degree-days (10") || has(lineIn, "cooling degree-days (10")) {
    5387          790 :         lineType = StatLineType::WithCDDLine;
    5388              : 
    5389       415586 :     } else if (has(lineIn, "Statistics for Liquid Precipitation")) {
    5390          783 :         insideLiquidPrecipitation = true;
    5391       414803 :     } else if (insideLiquidPrecipitation && has(lineIn, "Total")) {
    5392          783 :         lineType = StatLineType::MonthlyPrec;
    5393       414020 :     } else if (insideLiquidPrecipitation && has(lineIn, "Max Hourly")) {
    5394          762 :         lineType = StatLineType::MaxHourlyPrec;
    5395          762 :         insideLiquidPrecipitation = false;
    5396              :     }
    5397              : 
    5398              :     // these not part of big if/else because sequential
    5399       430492 :     if (lineType == StatLineType::KoppenDes1Line && isKoppen) {
    5400          790 :         lineType = StatLineType::KoppenDes2Line;
    5401              :     }
    5402       430492 :     if (lineType == StatLineType::KoppenLine && isKoppen) {
    5403          790 :         lineType = StatLineType::KoppenDes1Line;
    5404              :     }
    5405       430492 :     if (has(lineIn, "ppen classification)")) {
    5406          790 :         lineType = StatLineType::KoppenLine;
    5407              :     }
    5408       430492 :     if (lineType == StatLineType::AshStdDes2Line) {
    5409          790 :         lineType = StatLineType::AshStdDes3Line;
    5410              :     }
    5411       430492 :     if (lineType == StatLineType::AshStdDes1Line) {
    5412          790 :         lineType = StatLineType::AshStdDes2Line;
    5413              :     }
    5414       430492 :     if (lineType == StatLineType::AshStdLine) {
    5415          790 :         lineType = StatLineType::AshStdDes1Line;
    5416              :     }
    5417       430492 :     if (has(lineIn, "ASHRAE Standard")) {
    5418          790 :         lineType = StatLineType::AshStdLine;
    5419              :     }
    5420       430492 : }
    5421              : 
    5422          799 : 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         2397 :     static std::string const degChar("°");
    5440              : 
    5441          799 :     if (!FileSystem::fileExists(state.files.inStatFilePath.filePath)) {
    5442            9 :         return;
    5443              :     }
    5444              : 
    5445          790 :     auto const &ort = state.dataOutRptTab;
    5446              : 
    5447              :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
    5448              : 
    5449          790 :     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          790 :     std::string ashDesYear;
    5462          790 :     std::string ashZone; // ashrae climate zone
    5463          790 :     std::string curNameWithSIUnits;
    5464          790 :     std::string curNameAndUnits;
    5465              :     int indexUnitConv;
    5466              : 
    5467          790 :     bool isASHRAE = false;
    5468          790 :     bool iscalc = false;
    5469          790 :     bool isKoppen = false;
    5470          790 :     bool heatingDesignlinepassed = false;
    5471          790 :     bool coolingDesignlinepassed = false;
    5472          790 :     bool desConditionlinepassed = false;
    5473          790 :     bool insideLiquidPrecipitation = false;
    5474          790 :     std::string storeASHRAEHDD;
    5475          790 :     std::string storeASHRAECDD;
    5476              : 
    5477         1580 :     auto statFile = state.files.inStatFilePath.open(state, "FillWeatherPredefinedEntries");
    5478       431282 :     while (statFile.good()) { // end of file, or error
    5479       430492 :         StatLineType lineType = lineTypeinterim;
    5480       430492 :         auto lineIn = statFile.readLine().data;
    5481              :         // reconcile line with different versions of stat file
    5482              :         // v7.1 added version as first line.
    5483       430492 :         strip(lineIn);
    5484       430492 :         parseStatLine(
    5485              :             lineIn, lineType, desConditionlinepassed, heatingDesignlinepassed, coolingDesignlinepassed, isKoppen, insideLiquidPrecipitation);
    5486              : 
    5487       430492 :         switch (lineType) {
    5488          790 :         case StatLineType::StatisticsLine: { // Statistics for USA_CA_San.Francisco_TMY2
    5489          790 :             PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "Reference", lineIn.substr(15));
    5490          790 :         } break;
    5491          790 :         case StatLineType::LocationLine: { // Location -- SAN_FRANCISCO CA USA
    5492          790 :             PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "Site:Location", lineIn.substr(11));
    5493          790 :         } break;
    5494          790 :         case StatLineType::LatLongLine: { //      {N 37° 37'} {W 122° 22'} {GMT -8.0 Hours}
    5495              :             // find the {}
    5496          790 :             sposlt = index(lineIn, '{');
    5497          790 :             eposlt = index(lineIn, '}');
    5498          790 :             if (sposlt != std::string::npos && eposlt != std::string::npos) {
    5499          790 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "Latitude", lineIn.substr(sposlt, eposlt - sposlt + 1));
    5500              :                 // redefine so next scan can go with {}
    5501          790 :                 lineIn[sposlt] = '[';
    5502          790 :                 lineIn[eposlt] = ']';
    5503              :             } else {
    5504            0 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "Latitude", "not found");
    5505              :             }
    5506          790 :             sposlg = index(lineIn, '{');
    5507          790 :             eposlg = index(lineIn, '}');
    5508          790 :             if (sposlg != std::string::npos && eposlg != std::string::npos) {
    5509          790 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "Longitude", lineIn.substr(sposlg, eposlg - sposlg + 1));
    5510              :                 // redefine so next scan can go with {}
    5511          790 :                 lineIn[sposlg] = '[';
    5512          790 :                 lineIn[eposlg] = ']';
    5513              :             } else {
    5514            0 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "Longitude", "not found");
    5515              :             }
    5516          790 :             spostz = index(lineIn, '{');
    5517          790 :             epostz = index(lineIn, '}');
    5518          790 :             if (spostz != std::string::npos && epostz != std::string::npos) {
    5519          790 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "Time Zone", lineIn.substr(spostz, epostz - spostz + 1));
    5520              :                 // redefine so next scan can go with {}
    5521          790 :                 lineIn[spostz] = '[';
    5522          790 :                 lineIn[epostz] = ']';
    5523              :             } else {
    5524            0 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "Time Zone", "not found");
    5525              :             }
    5526          790 :         } break;
    5527          790 :         case StatLineType::ElevationLine: { // Elevation --     5m above sea level
    5528          790 :             lnPtr = index(lineIn.substr(12), 'm');
    5529          790 :             if (lnPtr != std::string::npos) {
    5530          790 :                 curNameWithSIUnits = "Elevation (m) " + lineIn.substr(12 + lnPtr + 2);
    5531          790 :                 if (ort->ip()) {
    5532           11 :                     LookupSItoIP(state, curNameWithSIUnits, indexUnitConv, curNameAndUnits);
    5533           22 :                     PreDefTableEntry(state,
    5534           11 :                                      state.dataOutRptPredefined->pdchWthrVal,
    5535              :                                      curNameAndUnits,
    5536           22 :                                      RealToStr(ConvertIP(state, indexUnitConv, StrToReal(lineIn.substr(12, lnPtr))), 1));
    5537              :                 } else {
    5538          779 :                     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          790 :         } break;
    5544          790 :         case StatLineType::StdPressureLine: { // Standard Pressure at Elevation -- 101265Pa
    5545          790 :             PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "Standard Pressure at Elevation", lineIn.substr(34));
    5546          790 :         } break;
    5547          790 :         case StatLineType::DataSourceLine: { // Data Source -- TMY2-23234
    5548          790 :             PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "Data Source", lineIn.substr(15));
    5549          790 :         } break;
    5550          790 :         case StatLineType::WMOStationLine: { // WMO Station 724940
    5551          790 :             PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "WMO Station", lineIn.substr(12));
    5552          790 :         } break;
    5553          790 :         case StatLineType::DesignConditionsLine: { //  - Using Design Conditions from "Climate Design Data 2005 ASHRAE Handbook"
    5554          790 :             ashPtr = index(lineIn, "ASHRAE");
    5555          790 :             if (ashPtr != std::string::npos) {
    5556          786 :                 isASHRAE = true;
    5557          786 :                 iscalc = true;
    5558          786 :                 if (ashPtr > 4u) { // Autodesk:BoundsViolation IF block added to protect against ashPtr<=5
    5559          786 :                     ashDesYear = lineIn.substr(ashPtr - 5, 5);
    5560              :                 } else {
    5561            0 :                     ashDesYear = "";
    5562              :                 }
    5563         1572 :                 PreDefTableEntry(state,
    5564          786 :                                  state.dataOutRptPredefined->pdchWthrVal,
    5565              :                                  "Weather File Design Conditions",
    5566         1572 :                                  "Climate Design Data " + ashDesYear + "ASHRAE Handbook");
    5567            4 :             } 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            4 :                 isASHRAE = false;
    5573            4 :                 iscalc = true;
    5574            8 :                 PreDefTableEntry(
    5575            4 :                     state, state.dataOutRptPredefined->pdchWthrVal, "Weather File Design Conditions", "Calculated from the weather file");
    5576              :             }
    5577          790 :         } break;
    5578          786 :         case StatLineType::HeatingConditionsLine: { //  winter/heating design conditions
    5579          786 :             if (iscalc) {
    5580          786 :                 if (isASHRAE) {
    5581          786 :                     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          786 :                         if (ort->ip()) {
    5605           11 :                             curNameWithSIUnits = "Heating Design Temperature 99.6% (C)";
    5606           11 :                             LookupSItoIP(state, curNameWithSIUnits, indexUnitConv, curNameAndUnits);
    5607           22 :                             PreDefTableEntry(state,
    5608           11 :                                              state.dataOutRptPredefined->pdchWthrVal,
    5609              :                                              curNameAndUnits,
    5610           22 :                                              RealToStr(ConvertIP(state, indexUnitConv, StrToReal(GetColumnUsingTabs(lineIn, 4))), 1) + degChar);
    5611           22 :                             PreDefTableEntry(state,
    5612           11 :                                              state.dataOutRptPredefined->pdchWthrVal,
    5613              :                                              "Heating Design Temperature 99% (F)",
    5614           22 :                                              RealToStr(ConvertIP(state, indexUnitConv, StrToReal(GetColumnUsingTabs(lineIn, 5))), 1) + degChar);
    5615              :                         } else {
    5616         1550 :                             PreDefTableEntry(state,
    5617          775 :                                              state.dataOutRptPredefined->pdchWthrVal,
    5618              :                                              "Heating Design Temperature 99.6% (C)",
    5619         1550 :                                              GetColumnUsingTabs(lineIn, 4) + degChar);
    5620         1550 :                             PreDefTableEntry(state,
    5621          775 :                                              state.dataOutRptPredefined->pdchWthrVal,
    5622              :                                              "Heating Design Temperature 99% (C)",
    5623         1550 :                                              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          786 :         } break;
    5658          786 :         case StatLineType::CoolingConditionsLine: { //  summer/cooling design conditions
    5659          786 :             if (iscalc) {
    5660          786 :                 if (isASHRAE) {
    5661          786 :                     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          786 :                         if (ort->ip()) {
    5693           11 :                             curNameWithSIUnits = "Cooling Design Temperature 0.4% (C)";
    5694           11 :                             LookupSItoIP(state, curNameWithSIUnits, indexUnitConv, curNameAndUnits);
    5695           22 :                             PreDefTableEntry(state,
    5696           11 :                                              state.dataOutRptPredefined->pdchWthrVal,
    5697              :                                              curNameAndUnits,
    5698           22 :                                              RealToStr(ConvertIP(state, indexUnitConv, StrToReal(GetColumnUsingTabs(lineIn, 5))), 1) + degChar);
    5699           22 :                             PreDefTableEntry(state,
    5700           11 :                                              state.dataOutRptPredefined->pdchWthrVal,
    5701              :                                              "Cooling Design Temperature 1% (F)",
    5702           22 :                                              RealToStr(ConvertIP(state, indexUnitConv, StrToReal(GetColumnUsingTabs(lineIn, 7))), 1) + degChar);
    5703           22 :                             PreDefTableEntry(state,
    5704           11 :                                              state.dataOutRptPredefined->pdchWthrVal,
    5705              :                                              "Cooling Design Temperature 2% (F)",
    5706           22 :                                              RealToStr(ConvertIP(state, indexUnitConv, StrToReal(GetColumnUsingTabs(lineIn, 9))), 1) + degChar);
    5707              :                         } else {
    5708         1550 :                             PreDefTableEntry(state,
    5709          775 :                                              state.dataOutRptPredefined->pdchWthrVal,
    5710              :                                              "Cooling Design Temperature 0.4% (C)",
    5711         1550 :                                              GetColumnUsingTabs(lineIn, 5) + degChar);
    5712         1550 :                             PreDefTableEntry(state,
    5713          775 :                                              state.dataOutRptPredefined->pdchWthrVal,
    5714              :                                              "Cooling Design Temperature 1% (C)",
    5715         1550 :                                              GetColumnUsingTabs(lineIn, 7) + degChar);
    5716         1550 :                             PreDefTableEntry(state,
    5717          775 :                                              state.dataOutRptPredefined->pdchWthrVal,
    5718              :                                              "Cooling Design Temperature 2% (C)",
    5719         1550 :                                              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          786 :         } break;
    5764          758 :         case StatLineType::StdHDDLine: { //  - 1745 annual (standard) heating degree-days (10°C baseline)
    5765          758 :             storeASHRAEHDD = lineIn.substr(2, 4);
    5766          758 :         } break;
    5767          758 :         case StatLineType::StdCDDLine: { //  -  464 annual (standard) cooling degree-days (18.3°C baseline)
    5768          758 :             storeASHRAECDD = lineIn.substr(2, 4);
    5769          758 :         } break;
    5770          790 :         case StatLineType::MaxDryBulbLine: { //   - Maximum Dry Bulb temperature of  35.6°C on Jul  9
    5771          790 :             sposlt = index(lineIn, "of");
    5772          790 :             eposlt = index(lineIn, 'C');
    5773          790 :             sposlt += 2;
    5774          790 :             size_t deg_index = index(lineIn, degChar);
    5775          790 :             if (deg_index != std::string::npos) {
    5776            0 :                 eposlt = deg_index - 1;
    5777              :             } else {
    5778          790 :                 eposlt -= 2;
    5779              :             }
    5780          790 :             if (sposlt != std::string::npos && eposlt != std::string::npos) {
    5781         1580 :                 if (ort->ip()) {
    5782           11 :                     curNameWithSIUnits = "Maximum Dry Bulb Temperature (C)";
    5783           11 :                     LookupSItoIP(state, curNameWithSIUnits, indexUnitConv, curNameAndUnits);
    5784           22 :                     PreDefTableEntry(state,
    5785           11 :                                      state.dataOutRptPredefined->pdchWthrVal,
    5786              :                                      curNameAndUnits,
    5787           22 :                                      RealToStr(ConvertIP(state, indexUnitConv, StrToReal(lineIn.substr(sposlt, eposlt - sposlt + 1))), 1) + degChar);
    5788              :                 } else {
    5789         1558 :                     PreDefTableEntry(state,
    5790          779 :                                      state.dataOutRptPredefined->pdchWthrVal,
    5791              :                                      "Maximum Dry Bulb Temperature (C)",
    5792         1558 :                                      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          790 :             sposlt = index(lineIn, "on");
    5798          790 :             sposlt += 2;
    5799          790 :             if (sposlt != std::string::npos) {
    5800          790 :                 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          790 :         } break;
    5805          790 :         case StatLineType::MinDryBulbLine: { //   - Minimum Dry Bulb temperature of -22.8°C on Jan  7
    5806          790 :             sposlt = index(lineIn, "of");
    5807          790 :             eposlt = index(lineIn, 'C');
    5808          790 :             sposlt += 2;
    5809          790 :             size_t deg_index = index(lineIn, degChar);
    5810          790 :             if (deg_index != std::string::npos) {
    5811            0 :                 eposlt = deg_index - 1;
    5812              :             } else {
    5813          790 :                 eposlt -= 2;
    5814              :             }
    5815          790 :             if (sposlt != std::string::npos && eposlt != std::string::npos) {
    5816         1580 :                 if (ort->ip()) {
    5817           11 :                     curNameWithSIUnits = "Minimum Dry Bulb Temperature (C)";
    5818           11 :                     LookupSItoIP(state, curNameWithSIUnits, indexUnitConv, curNameAndUnits);
    5819           22 :                     PreDefTableEntry(state,
    5820           11 :                                      state.dataOutRptPredefined->pdchWthrVal,
    5821              :                                      curNameAndUnits,
    5822           22 :                                      RealToStr(ConvertIP(state, indexUnitConv, StrToReal(lineIn.substr(sposlt, eposlt - sposlt + 1))), 1) + degChar);
    5823              :                 } else {
    5824         1558 :                     PreDefTableEntry(state,
    5825          779 :                                      state.dataOutRptPredefined->pdchWthrVal,
    5826              :                                      "Minimum Dry Bulb Temperature (C)",
    5827         1558 :                                      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          790 :             sposlt = index(lineIn, "on");
    5833          790 :             sposlt += 2;
    5834          790 :             if (sposlt != std::string::npos) {
    5835          790 :                 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          790 :         } break;
    5840          790 :         case StatLineType::MaxDewPointLine: { //   - Maximum Dew Point temperature of  25.6°C on Aug  4
    5841          790 :             sposlt = index(lineIn, "of");
    5842          790 :             eposlt = index(lineIn, 'C');
    5843          790 :             sposlt += 2;
    5844          790 :             size_t deg_index = index(lineIn, degChar);
    5845          790 :             if (deg_index != std::string::npos) {
    5846            0 :                 eposlt = deg_index - 1;
    5847              :             } else {
    5848          790 :                 eposlt -= 2;
    5849              :             }
    5850          790 :             if (sposlt != std::string::npos && eposlt != std::string::npos) {
    5851         1580 :                 if (ort->ip()) {
    5852           11 :                     curNameWithSIUnits = "Maximum Dew Point Temperature (C)";
    5853           11 :                     LookupSItoIP(state, curNameWithSIUnits, indexUnitConv, curNameAndUnits);
    5854           22 :                     PreDefTableEntry(state,
    5855           11 :                                      state.dataOutRptPredefined->pdchWthrVal,
    5856              :                                      curNameAndUnits,
    5857           22 :                                      RealToStr(ConvertIP(state, indexUnitConv, StrToReal(lineIn.substr(sposlt, eposlt - sposlt + 1))), 1) + degChar);
    5858              :                 } else {
    5859         1558 :                     PreDefTableEntry(state,
    5860          779 :                                      state.dataOutRptPredefined->pdchWthrVal,
    5861              :                                      "Maximum Dew Point Temperature (C)",
    5862         1558 :                                      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          790 :             sposlt = index(lineIn, "on");
    5868          790 :             sposlt += 2;
    5869          790 :             if (sposlt != std::string::npos) {
    5870          790 :                 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          790 :         } break;
    5875          790 :         case StatLineType::MinDewPointLine: { //   - Minimum Dew Point temperature of -28.9°C on Dec 31
    5876          790 :             sposlt = index(lineIn, "of");
    5877          790 :             eposlt = index(lineIn, 'C');
    5878          790 :             sposlt += 2;
    5879          790 :             size_t deg_index = index(lineIn, degChar);
    5880          790 :             if (deg_index != std::string::npos) {
    5881            0 :                 eposlt = deg_index - 1;
    5882              :             } else {
    5883          790 :                 eposlt -= 2;
    5884              :             }
    5885          790 :             if (sposlt != std::string::npos && eposlt != std::string::npos) {
    5886         1580 :                 if (ort->ip()) {
    5887           11 :                     curNameWithSIUnits = "Minimum Dew Point Temperature (C)";
    5888           11 :                     LookupSItoIP(state, curNameWithSIUnits, indexUnitConv, curNameAndUnits);
    5889           22 :                     PreDefTableEntry(state,
    5890           11 :                                      state.dataOutRptPredefined->pdchWthrVal,
    5891              :                                      curNameAndUnits,
    5892           22 :                                      RealToStr(ConvertIP(state, indexUnitConv, StrToReal(lineIn.substr(sposlt, eposlt - sposlt + 1))), 1) + degChar);
    5893              :                 } else {
    5894         1558 :                     PreDefTableEntry(state,
    5895          779 :                                      state.dataOutRptPredefined->pdchWthrVal,
    5896              :                                      "Minimum Dew Point Temperature (C)",
    5897         1558 :                                      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          790 :             sposlt = index(lineIn, "on");
    5903          790 :             sposlt += 2;
    5904          790 :             if (sposlt != std::string::npos) {
    5905          790 :                 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          790 :         } break;
    5910          783 :         case StatLineType::MonthlyPrec: { //   - Monthly precipitation mm
    5911          783 :             std::stringstream ss(lineIn);
    5912          783 :             std::vector<std::string> result;
    5913        12528 :             while (ss.good()) {
    5914        11745 :                 std::string substr;
    5915        11745 :                 getline(ss, substr, '\t');
    5916        11745 :                 substr.erase(remove_if(substr.begin(), substr.end(), isspace), substr.end());
    5917        11745 :                 result.push_back(substr);
    5918        11745 :             }
    5919              :             int monthlyTotalPrecFromStat[12];
    5920          783 :             int annualTotalPrecFromStat = 0;
    5921        10179 :             for (int i = 0; i < 12; i++) {
    5922         9396 :                 monthlyTotalPrecFromStat[i] = std::stoi(result[i + 2]);
    5923              :                 // fixme: add to monthly data structure
    5924         9396 :                 annualTotalPrecFromStat += monthlyTotalPrecFromStat[i];
    5925              :             }
    5926          783 :             PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "Annual Total Precipitation [mm]", annualTotalPrecFromStat);
    5927              :             // fixme: store the monthly data in some data structure
    5928          783 :         } break;
    5929          762 :         case StatLineType::MaxHourlyPrec: { //   - Highest hourly precipitation in each month
    5930              :             // Split string by \t into substrings and remove the space in each substring
    5931          762 :             std::stringstream ss(lineIn);
    5932          762 :             std::vector<std::string> result;
    5933        12192 :             while (ss.good()) {
    5934        11430 :                 std::string substr;
    5935        11430 :                 getline(ss, substr, '\t');
    5936        11430 :                 substr.erase(remove_if(substr.begin(), substr.end(), isspace), substr.end());
    5937        11430 :                 result.push_back(substr);
    5938        11430 :             }
    5939              :             int MaxHourlyPrecEachMonth[12];
    5940          762 :             int MaxHourlyPrec = 0;
    5941          762 :             int MaxHourlyPrecIdx = 0;
    5942         9906 :             for (int i = 0; i < 12; i++) {
    5943         9144 :                 MaxHourlyPrecEachMonth[i] = std::stoi(result[i + 2]);
    5944         9144 :                 if (MaxHourlyPrecEachMonth[i] > MaxHourlyPrec) {
    5945         1151 :                     MaxHourlyPrec = MaxHourlyPrecEachMonth[i];
    5946         1151 :                     MaxHourlyPrecIdx = i;
    5947              :                 }
    5948              :             }
    5949          762 :             constexpr std::array<std::string_view, 12> Months{"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
    5950          762 :             PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "Max Hourly Precipitation [mm]", MaxHourlyPrec);
    5951          762 :             PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "Max Hourly Precipitation Occurs in", Months[MaxHourlyPrecIdx]);
    5952          762 :         } break;
    5953          790 :         case StatLineType::WithHDDLine: { //  - 1745 (wthr file) annual heating degree-days (10°C baseline)
    5954          790 :             if (storeASHRAEHDD != "") {
    5955          758 :                 if (ort->ip()) {
    5956           11 :                     curNameWithSIUnits = "ASHRAE Handbook 2009 Heating Degree-Days - base 65°(C)";
    5957           11 :                     LookupSItoIP(state, curNameWithSIUnits, indexUnitConv, curNameAndUnits);
    5958           22 :                     PreDefTableEntry(state,
    5959           11 :                                      state.dataOutRptPredefined->pdchWthrVal,
    5960              :                                      curNameAndUnits,
    5961           22 :                                      RealToStr(ConvertIPdelta(state, indexUnitConv, StrToReal(storeASHRAEHDD)), 1));
    5962              :                 } else {
    5963         1494 :                     PreDefTableEntry(
    5964          747 :                         state, state.dataOutRptPredefined->pdchWthrVal, "ASHRAE Handbook 2009 Heating Degree-Days (base 18.3°C)", storeASHRAEHDD);
    5965              :                 }
    5966              :             } else {
    5967           32 :                 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           64 :                     PreDefTableEntry(
    5972           32 :                         state, state.dataOutRptPredefined->pdchWthrVal, "ASHRAE Handbook 2009 Heating Degree-Days (base 18.3°C)", "not found");
    5973              :                 }
    5974              :             }
    5975          790 :             if (ort->ip()) {
    5976           11 :                 curNameWithSIUnits = "Weather File Heating Degree-Days - base 65°(C)";
    5977           11 :                 LookupSItoIP(state, curNameWithSIUnits, indexUnitConv, curNameAndUnits);
    5978           22 :                 PreDefTableEntry(state,
    5979           11 :                                  state.dataOutRptPredefined->pdchWthrVal,
    5980              :                                  curNameAndUnits,
    5981           22 :                                  RealToStr(ConvertIPdelta(state, indexUnitConv, StrToReal(lineIn.substr(2, 4))), 1));
    5982           22 :                 PreDefTableEntry(state,
    5983           11 :                                  state.dataOutRptPredefined->pdchLeedGenData,
    5984              :                                  "Heating Degree Days",
    5985           22 :                                  RealToStr(ConvertIPdelta(state, indexUnitConv, StrToReal(lineIn.substr(2, 4))), 1));
    5986              :             } else {
    5987          779 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "Weather File Heating Degree-Days (base 18°C)", lineIn.substr(2, 4));
    5988          779 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchLeedGenData, "Heating Degree Days", lineIn.substr(2, 4));
    5989              :             }
    5990          790 :             PreDefTableEntry(state, state.dataOutRptPredefined->pdchLeedGenData, "HDD and CDD data source", "Weather File Stat");
    5991          790 :         } break;
    5992          790 :         case StatLineType::WithCDDLine: { //  -  464 (wthr file) annual cooling degree-days (18°C baseline)
    5993          790 :             if (storeASHRAECDD != "") {
    5994          758 :                 if (ort->ip()) {
    5995           11 :                     curNameWithSIUnits = "ASHRAE Handbook 2009  Cooling Degree-Days - base 50°(C)";
    5996           11 :                     LookupSItoIP(state, curNameWithSIUnits, indexUnitConv, curNameAndUnits);
    5997           22 :                     PreDefTableEntry(state,
    5998           11 :                                      state.dataOutRptPredefined->pdchWthrVal,
    5999              :                                      curNameAndUnits,
    6000           22 :                                      RealToStr(ConvertIPdelta(state, indexUnitConv, StrToReal(storeASHRAECDD)), 1));
    6001              :                 } else {
    6002         1494 :                     PreDefTableEntry(
    6003          747 :                         state, state.dataOutRptPredefined->pdchWthrVal, "ASHRAE Handbook 2009  Cooling Degree-Days (base 10°C)", storeASHRAECDD);
    6004              :                 }
    6005              :             } else {
    6006           32 :                 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           64 :                     PreDefTableEntry(
    6011           32 :                         state, state.dataOutRptPredefined->pdchWthrVal, "ASHRAE Handbook 2009  Cooling Degree-Days (base 10°C)", "not found");
    6012              :                 }
    6013              :             }
    6014          790 :             if (ort->ip()) {
    6015           11 :                 curNameWithSIUnits = "Weather File Cooling Degree-Days - base 50°(C)";
    6016           11 :                 LookupSItoIP(state, curNameWithSIUnits, indexUnitConv, curNameAndUnits);
    6017           22 :                 PreDefTableEntry(state,
    6018           11 :                                  state.dataOutRptPredefined->pdchWthrVal,
    6019              :                                  curNameAndUnits,
    6020           22 :                                  RealToStr(ConvertIPdelta(state, indexUnitConv, StrToReal(lineIn.substr(2, 4))), 1));
    6021           22 :                 PreDefTableEntry(state,
    6022           11 :                                  state.dataOutRptPredefined->pdchLeedGenData,
    6023              :                                  "Cooling Degree Days",
    6024           22 :                                  RealToStr(ConvertIPdelta(state, indexUnitConv, StrToReal(lineIn.substr(2, 4))), 1));
    6025              :             } else {
    6026          779 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "Weather File Cooling Degree-Days (base 10°C)", lineIn.substr(2, 4));
    6027          779 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchLeedGenData, "Cooling Degree Days", lineIn.substr(2, 4));
    6028              :             }
    6029          790 :         } break;
    6030          790 :         case StatLineType::KoppenLine: { // - Climate type "BSk" (Köppen classification)
    6031          790 :             if (!has(lineIn, "not shown")) {
    6032          790 :                 isKoppen = true;
    6033          790 :                 if (lineIn[18] == '"') { // two character classification
    6034           65 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "Köppen Classification", lineIn.substr(16, 2));
    6035              :                 } else {
    6036          725 :                     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          790 :         } break;
    6043          790 :         case StatLineType::KoppenDes1Line: { // - Tropical monsoonal or tradewind-coastal (short dry season, lat. 5-25°)
    6044          790 :             if (isKoppen) {
    6045          790 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "Köppen Description", lineIn.substr(2));
    6046              :             }
    6047          790 :         } break;
    6048          790 :         case StatLineType::KoppenDes2Line: { // - Unbearably humid periods in summer, but passive cooling is possible
    6049          790 :             if (isKoppen) {
    6050          790 :                 if (len(lineIn) > 3) {                 // avoid blank lines
    6051          790 :                     if (lineIn.substr(2, 2) != "**") { // avoid line with warning
    6052          640 :                         PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "Köppen Recommendation", lineIn.substr(2));
    6053              :                     } else {
    6054          150 :                         PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "Köppen Recommendation", "");
    6055              :                     }
    6056              :                 } else {
    6057            0 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "Köppen Recommendation", "");
    6058              :                 }
    6059              :             }
    6060          790 :         } break;
    6061         3160 :         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         3160 :             if (has(lineIn, "Standard")) {
    6067          790 :                 ashZone = lineIn.substr(16, 2);
    6068          790 :                 if (ashZone[1] == '"') {
    6069            0 :                     ashZone[1] = ' ';
    6070              :                 }
    6071          790 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "ASHRAE Climate Zone", ashZone);
    6072          790 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchLeedGenData, "Climate Zone", ashZone);
    6073          790 :                 if (ashZone == "1A") {
    6074           65 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "ASHRAE Description", "Very Hot-Humid");
    6075          725 :                 } else if (ashZone == "1B") {
    6076           23 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "ASHRAE Description", "Very Hot-Dry");
    6077          702 :                 } else if (ashZone == "2A") {
    6078            8 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "ASHRAE Description", "Hot-Humid");
    6079          694 :                 } else if (ashZone == "2B") {
    6080            3 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "ASHRAE Description", "Hot-Dry");
    6081          691 :                 } else if (ashZone == "3A") {
    6082            5 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "ASHRAE Description", "Warm-Humid");
    6083          686 :                 } else if (ashZone == "3B") {
    6084            3 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "ASHRAE Description", "Warm-Dry");
    6085          683 :                 } else if (ashZone == "3C") {
    6086           10 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "ASHRAE Description", "Warm-Marine");
    6087          673 :                 } else if (ashZone == "4A") {
    6088            1 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "ASHRAE Description", "Mixed-Humid");
    6089          672 :                 } else if (ashZone == "4B") {
    6090            0 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "ASHRAE Description", "Mixed-Dry");
    6091          672 :                 } else if (ashZone == "4C") {
    6092            0 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "ASHRAE Description", "Mixed-Marine");
    6093          672 :                 } else if (ashZone == "5A") {
    6094          588 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "ASHRAE Description", "Cool-Humid");
    6095           84 :                 } else if (ashZone == "5B") {
    6096           84 :                     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         3160 :         } break;
    6110       409269 :         default:
    6111       409269 :             break;
    6112              :         }
    6113       430492 :         lineIn = "";
    6114       430492 :         lineTypeinterim = StatLineType::Initialized;
    6115       430492 :         if (lineType == StatLineType::AshStdDes3Line) {
    6116          790 :             lineTypeinterim = StatLineType::Initialized;
    6117              :         }
    6118       430492 :         if (lineType == StatLineType::AshStdDes2Line) {
    6119          790 :             lineTypeinterim = StatLineType::AshStdDes2Line;
    6120              :         }
    6121       430492 :         if (lineType == StatLineType::AshStdDes1Line) {
    6122          790 :             lineTypeinterim = StatLineType::AshStdDes1Line;
    6123              :         }
    6124       430492 :         if (lineType == StatLineType::AshStdLine) {
    6125          790 :             lineTypeinterim = StatLineType::AshStdLine;
    6126              :         }
    6127       430492 :         if (lineType == StatLineType::KoppenDes2Line) {
    6128          790 :             lineTypeinterim = StatLineType::Initialized;
    6129              :         }
    6130       430492 :         if (lineType == StatLineType::KoppenDes1Line) {
    6131          790 :             lineTypeinterim = StatLineType::KoppenDes1Line;
    6132              :         }
    6133       430492 :         if (lineType == StatLineType::KoppenLine) {
    6134          790 :             lineTypeinterim = StatLineType::KoppenLine;
    6135              :         }
    6136       430492 :     }
    6137          790 : }
    6138              : 
    6139         3990 : 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         3990 :     std::string::size_type startPos = 0;
    6159              : 
    6160         3990 :     size_t endPos = inString.find_first_of(tb);
    6161         3990 :     if (colNum == 1) {
    6162            0 :         if (endPos == std::string::npos) {
    6163            0 :             return inString;
    6164              :         }
    6165            0 :         return inString.substr(startPos, endPos - startPos);
    6166              :     }
    6167         3990 :     if (endPos == std::string::npos) {
    6168            0 :         return "";
    6169              :     }
    6170              : 
    6171         3990 :     int numCols = 1;
    6172        24090 :     while (numCols < colNum) {
    6173        20100 :         startPos = endPos + 1;
    6174        20100 :         endPos = inString.find_first_of(tb, startPos);
    6175        20100 :         ++numCols;
    6176        20100 :         if (endPos == std::string::npos) {
    6177            0 :             break;
    6178              :         }
    6179              :     }
    6180         3990 :     if (colNum > numCols) {
    6181            0 :         return "";
    6182              :     }
    6183         3990 :     if (endPos == std::string::npos) {
    6184            0 :         endPos = inString.size();
    6185              :     }
    6186         3990 :     return inString.substr(startPos, endPos - startPos);
    6187              : }
    6188              : 
    6189          799 : 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          799 :     int NumPrimaryAirSys = state.dataHVACGlobal->NumPrimaryAirSys;
    6203          799 :     int iNumberOfAutoCalcedFields = state.dataOutput->iNumberOfAutoCalcedFields;
    6204          799 :     int iNumberOfAutoSizedFields = state.dataOutput->iNumberOfAutoSizedFields;
    6205          799 :     int iNumberOfDefaultedFields = state.dataOutput->iNumberOfDefaultedFields;
    6206          799 :     int iNumberOfRecords = state.dataOutput->iNumberOfRecords;
    6207          799 :     int iTotalAutoCalculatableFields = state.dataOutput->iTotalAutoCalculatableFields;
    6208          799 :     int iTotalAutoSizableFields = state.dataOutput->iTotalAutoSizableFields;
    6209          799 :     int iTotalFieldsWithDefaults = state.dataOutput->iTotalFieldsWithDefaults;
    6210              : 
    6211              :     Real64 consumptionTotal;
    6212              : 
    6213          799 :     auto const &ort = state.dataOutRptTab;
    6214              : 
    6215          799 :     int StartOfWeek = state.dataEnvrn->RunPeriodStartDayOfWeek;
    6216          799 :     if (StartOfWeek == 0) {
    6217          792 :         StartOfWeek = 2; // if the first day of the week has not been set yet, assume monday
    6218              :     }
    6219              : 
    6220              :     // Interior Connected Lighting Power
    6221          799 :     consumptionTotal = 0.0;
    6222         5260 :     for (int iLight = 1; iLight <= state.dataHeatBal->TotLights; ++iLight) {
    6223         4461 :         auto const &thisLight = state.dataHeatBal->Lights(iLight);
    6224         4461 :         int const iZone = state.dataHeatBal->Lights(iLight).ZonePtr;
    6225         4461 :         auto const &thisZone = state.dataHeatBal->Zone(iZone);
    6226              : 
    6227         4461 :         Real64 const mult = thisZone.Multiplier * thisZone.ListMultiplier;
    6228         4461 :         if (thisZone.SystemZoneNodeNumber > 0) { // conditioned y/n
    6229         4327 :             PreDefTableEntry(state, state.dataOutRptPredefined->pdchInLtCond, thisLight.Name, "Y");
    6230              :         } else {
    6231          134 :             PreDefTableEntry(state, state.dataOutRptPredefined->pdchInLtCond, thisLight.Name, "N");
    6232              :         }
    6233        13383 :         PreDefTableEntry(state,
    6234         4461 :                          state.dataOutRptPredefined->pdchInLtAvgHrSchd,
    6235              :                          thisLight.Name,
    6236         4461 :                          thisLight.sched->getAverageWeeklyHoursFullLoad(state, StartOfWeek, state.dataEnvrn->CurrentYearIsLeapYear));
    6237              :         // average operating hours per week
    6238         4461 :         if (ort->gatherElapsedTimeBEPS > 0) {
    6239           20 :             state.dataOutRptTab->HrsPerWeek = 24 * 7 * thisLight.SumTimeNotZeroCons / ort->gatherElapsedTimeBEPS;
    6240           20 :             PreDefTableEntry(state, state.dataOutRptPredefined->pdchInLtAvgHrOper, thisLight.Name, state.dataOutRptTab->HrsPerWeek);
    6241              :         }
    6242              :         // full load hours per week
    6243         4461 :         if ((thisLight.DesignLevel * ort->gatherElapsedTimeBEPS) > 0) {
    6244           40 :             state.dataOutRptTab->HrsPerWeek =
    6245           20 :                 24 * 7 * thisLight.SumConsumption / (thisLight.DesignLevel * ort->gatherElapsedTimeBEPS * Constant::rSecsInHour);
    6246           20 :             PreDefTableEntry(state, state.dataOutRptPredefined->pdchInLtFullLoadHrs, thisLight.Name, state.dataOutRptTab->HrsPerWeek);
    6247              :         }
    6248         4461 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchInLtConsump, thisLight.Name, thisLight.SumConsumption * mult / 1000000000.0);
    6249         4461 :         consumptionTotal += thisLight.SumConsumption / 1000000000.0;
    6250              :     }
    6251          799 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchInLtConsump, "Interior Lighting Total", consumptionTotal);
    6252              : 
    6253              :     // Exterior Lighting
    6254          799 :     consumptionTotal = 0.0;
    6255          993 :     for (int iLight = 1; iLight <= state.dataExteriorEnergyUse->NumExteriorLights; ++iLight) {
    6256          194 :         auto const &thisLight = state.dataExteriorEnergyUse->ExteriorLights(iLight);
    6257              : 
    6258          194 :         if (thisLight.ControlMode == ExteriorEnergyUse::LightControlType::ScheduleOnly) { // photocell/schedule
    6259           63 :             PreDefTableEntry(state,
    6260           21 :                              state.dataOutRptPredefined->pdchExLtAvgHrSchd,
    6261              :                              thisLight.Name,
    6262           21 :                              thisLight.sched->getAverageWeeklyHoursFullLoad(state, StartOfWeek, state.dataEnvrn->CurrentYearIsLeapYear));
    6263              :         }
    6264              :         // average operating hours per week
    6265          194 :         if (ort->gatherElapsedTimeBEPS > 0) {
    6266            1 :             state.dataOutRptTab->HrsPerWeek = 24 * 7 * thisLight.SumTimeNotZeroCons / ort->gatherElapsedTimeBEPS;
    6267            1 :             PreDefTableEntry(state, state.dataOutRptPredefined->pdchExLtAvgHrOper, thisLight.Name, state.dataOutRptTab->HrsPerWeek);
    6268              :         }
    6269              :         // full load hours per week
    6270          194 :         if ((thisLight.DesignLevel * ort->gatherElapsedTimeBEPS) > 0) {
    6271            2 :             state.dataOutRptTab->HrsPerWeek =
    6272            1 :                 24 * 7 * thisLight.SumConsumption / (thisLight.DesignLevel * ort->gatherElapsedTimeBEPS * Constant::rSecsInHour);
    6273            1 :             PreDefTableEntry(state, state.dataOutRptPredefined->pdchExLtFullLoadHrs, thisLight.Name, state.dataOutRptTab->HrsPerWeek);
    6274              :         }
    6275          194 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchExLtConsump, thisLight.Name, thisLight.SumConsumption / 1000000000.0);
    6276          194 :         consumptionTotal += thisLight.SumConsumption / 1000000000.0;
    6277              :     }
    6278          799 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchExLtConsump, "Exterior Lighting Total", consumptionTotal);
    6279              : 
    6280              :     // outside air ventilation
    6281          799 :     Real64 totalOccupants = 0.;
    6282          799 :     Real64 totalAverageOccupants = 0.;
    6283          799 :     Real64 totalArea = 0.;
    6284          799 :     Real64 totalVozMin = 0;
    6285          799 :     Real64 totalMechVentVol = 0;
    6286          799 :     Real64 totalNatVentVol = 0;
    6287          799 :     Real64 totalInfilVol = 0;
    6288          799 :     Real64 totalVozDyn = 0;
    6289          799 :     Real64 totalMechVentRateOcc = 0;
    6290          799 :     Real64 totalNatVentRateOcc = 0;
    6291          799 :     Real64 totalInfilRateOcc = 0;
    6292          799 :     Real64 totalVozDynOcc = 0;
    6293              : 
    6294              :     // Outdoor Air Summary and Outdoor Air Details
    6295         5988 :     for (int iZone = 1; iZone <= state.dataGlobal->NumOfZones; ++iZone) {
    6296              : 
    6297         5189 :         auto const &thisZone = state.dataHeatBal->Zone(iZone);
    6298              : 
    6299         5189 :         int const zoneMult = thisZone.Multiplier * thisZone.ListMultiplier;
    6300         5189 :         if (thisZone.SystemZoneNodeNumber >= 0) { // conditioned zones only
    6301              : 
    6302         5189 :             auto &thisZonePreDefRep = state.dataHeatBal->ZonePreDefRep(iZone);
    6303              : 
    6304              :             // AFN infiltration -- check that afn sim is being done.
    6305         5189 :             if (!state.afn->multizone_always_simulated) {
    6306         5081 :                 thisZonePreDefRep.AFNInfilVolTotalStdDen = 0.0;
    6307         5081 :                 thisZonePreDefRep.AFNVentVolTotalStdDen = 0.0;
    6308         5081 :                 thisZonePreDefRep.AFNInfilVolTotalOccStdDen = 0.0;
    6309         5081 :                 thisZonePreDefRep.AFNVentVolTotalOccStdDen = 0.0;
    6310         5081 :                 thisZonePreDefRep.AFNInfilVolMin = 0.0;
    6311         5081 :                 thisZonePreDefRep.AFNInfilVolTotalOcc = 0.0;
    6312              :             }
    6313              : 
    6314              :             // air loop name
    6315         5189 :             if (thisZone.IsControlled) {
    6316         4451 :                 std::string airLoopName = "";
    6317         9189 :                 for (int zoneInNode = 1; zoneInNode <= state.dataZoneEquip->ZoneEquipConfig(iZone).NumInletNodes; ++zoneInNode) {
    6318         4738 :                     int airLoopNumber = state.dataZoneEquip->ZoneEquipConfig(iZone).InletNodeAirLoopNum(zoneInNode);
    6319         4738 :                     if (airLoopNumber > 0) {
    6320         3796 :                         if (airLoopName.empty()) {
    6321         3776 :                             airLoopName = state.dataAirSystemsData->PrimaryAirSystems(airLoopNumber).Name;
    6322              :                         } else {
    6323           20 :                             airLoopName += "; " + state.dataAirSystemsData->PrimaryAirSystems(airLoopNumber).Name;
    6324              :                         }
    6325              :                     }
    6326              :                 }
    6327         4451 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaMvAirLpNm, thisZone.Name, airLoopName);
    6328              : 
    6329              :                 // occupants
    6330         4451 :                 if (thisZone.isNominalOccupied) {
    6331         4042 :                     if (thisZonePreDefRep.NumOccAccumTime > 0) {
    6332         3941 :                         Real64 const avgOcc = thisZonePreDefRep.NumOccAccum / thisZonePreDefRep.NumOccAccumTime;
    6333         3941 :                         PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaoAvgNumOcc1, thisZone.Name, avgOcc);
    6334         3941 :                         PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaoAvgNumOcc2, thisZone.Name, avgOcc);
    6335         3941 :                         PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaMvAvgNumOcc, thisZone.Name, avgOcc);
    6336         3941 :                         totalAverageOccupants += avgOcc * zoneMult;
    6337              :                     }
    6338              :                 }
    6339         4451 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaMvNomNumOcc, thisZone.Name, thisZone.TotOccupants);
    6340         4451 :                 totalOccupants += thisZone.TotOccupants * zoneMult;
    6341              : 
    6342              :                 // Zone volume and area
    6343              : 
    6344         4451 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaoZoneVol1, thisZone.Name, thisZone.Volume);
    6345         4451 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaoZoneVol2, thisZone.Name, thisZone.Volume);
    6346         4451 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaMvZoneVol, thisZone.Name, thisZone.Volume);
    6347         4451 :                 state.dataOutRptTab->totalVolume += thisZone.Volume * zoneMult;
    6348         4451 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaMvZoneArea, thisZone.Name, thisZone.FloorArea);
    6349         4451 :                 totalArea += thisZone.FloorArea * zoneMult;
    6350              : 
    6351              :                 // minimum dynamic target ventilation Voz-dyn-min
    6352         4451 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaMvMinDynTrgVent, thisZone.Name, thisZonePreDefRep.VozMin / zoneMult, 3);
    6353         4451 :                 totalVozMin += thisZonePreDefRep.VozMin;
    6354              : 
    6355              :                 // Mechanical ventilation
    6356         4451 :                 if (thisZone.Volume > 0 && thisZonePreDefRep.TotTimeOcc > 0) {
    6357         3917 :                     PreDefTableEntry(state,
    6358         3917 :                                      state.dataOutRptPredefined->pdchOaoAvgMechVent,
    6359              :                                      thisZone.Name,
    6360         3917 :                                      thisZonePreDefRep.MechVentVolTotalOcc / (thisZonePreDefRep.TotTimeOcc * thisZone.Volume * zoneMult),
    6361         3917 :                                      3);
    6362         3917 :                     PreDefTableEntry(state,
    6363         3917 :                                      state.dataOutRptPredefined->pdchOaoMinMechVent,
    6364              :                                      thisZone.Name,
    6365         3917 :                                      thisZonePreDefRep.MechVentVolMin / (thisZone.Volume * zoneMult),
    6366         7834 :                                      3);
    6367              :                 }
    6368         8902 :                 PreDefTableEntry(
    6369         4451 :                     state, state.dataOutRptPredefined->pdchOaTaBzMechVent, thisZone.Name, thisZonePreDefRep.MechVentVolTotalStdDen / zoneMult);
    6370         4451 :                 totalMechVentVol += thisZonePreDefRep.MechVentVolTotalStdDen;
    6371              : 
    6372              :                 // Natural ventilation
    6373         8902 :                 PreDefTableEntry(state,
    6374         4451 :                                  state.dataOutRptPredefined->pdchOaTaBzNatVent,
    6375              :                                  thisZone.Name,
    6376         4451 :                                  thisZonePreDefRep.SimpVentVolTotalStdDen + thisZonePreDefRep.AFNVentVolTotalStdDen);
    6377         4451 :                 totalNatVentVol += (thisZonePreDefRep.SimpVentVolTotalStdDen + thisZonePreDefRep.AFNVentVolTotalStdDen) * zoneMult;
    6378              : 
    6379              :                 // Total ventilation
    6380         8902 :                 PreDefTableEntry(state,
    6381         4451 :                                  state.dataOutRptPredefined->pdchOaTaBzTotVent,
    6382              :                                  thisZone.Name,
    6383         4451 :                                  thisZonePreDefRep.MechVentVolTotalStdDen / zoneMult + thisZonePreDefRep.SimpVentVolTotalStdDen +
    6384         4451 :                                      thisZonePreDefRep.AFNVentVolTotalStdDen);
    6385              : 
    6386              :                 // infiltration
    6387         4451 :                 if (thisZone.Volume > 0 && thisZonePreDefRep.TotTimeOcc > 0) {
    6388         3917 :                     PreDefTableEntry(state,
    6389         3917 :                                      state.dataOutRptPredefined->pdchOaoAvgInfil,
    6390              :                                      thisZone.Name,
    6391         3917 :                                      thisZonePreDefRep.InfilVolTotalOcc / (thisZonePreDefRep.TotTimeOcc * thisZone.Volume),
    6392         3917 :                                      3);
    6393         3917 :                     PreDefTableEntry(
    6394         3917 :                         state, state.dataOutRptPredefined->pdchOaoMinInfil, thisZone.Name, thisZonePreDefRep.InfilVolMin / (thisZone.Volume), 3);
    6395              : 
    6396         3917 :                     PreDefTableEntry(state,
    6397         3917 :                                      state.dataOutRptPredefined->pdchOaoAvgAFNInfil,
    6398              :                                      thisZone.Name,
    6399         3917 :                                      thisZonePreDefRep.AFNInfilVolTotalOcc / (thisZonePreDefRep.TotTimeOcc * thisZone.Volume),
    6400         3917 :                                      3);
    6401              : 
    6402         3917 :                     PreDefTableEntry(state,
    6403         3917 :                                      state.dataOutRptPredefined->pdchOaoMinAFNInfil,
    6404              :                                      thisZone.Name,
    6405         3917 :                                      thisZonePreDefRep.AFNInfilVolMin / (thisZone.Volume),
    6406         3917 :                                      3);
    6407              : 
    6408              :                     // simple 'ZoneVentilation'
    6409         3917 :                     PreDefTableEntry(state,
    6410         3917 :                                      state.dataOutRptPredefined->pdchOaoAvgSimpVent,
    6411              :                                      thisZone.Name,
    6412         3917 :                                      thisZonePreDefRep.SimpVentVolTotalOcc / (thisZonePreDefRep.TotTimeOcc * thisZone.Volume),
    6413         3917 :                                      3);
    6414              : 
    6415         3917 :                     PreDefTableEntry(state,
    6416         3917 :                                      state.dataOutRptPredefined->pdchOaoMinSimpVent,
    6417              :                                      thisZone.Name,
    6418         3917 :                                      thisZonePreDefRep.SimpVentVolMin / (thisZone.Volume),
    6419         7834 :                                      3);
    6420              :                 }
    6421              : 
    6422              :                 // Infiltration
    6423         8902 :                 PreDefTableEntry(state,
    6424         4451 :                                  state.dataOutRptPredefined->pdchOaTaBzInfil,
    6425              :                                  thisZone.Name,
    6426         4451 :                                  thisZonePreDefRep.InfilVolTotalStdDen + thisZonePreDefRep.AFNInfilVolTotalStdDen);
    6427         4451 :                 totalInfilVol += (thisZonePreDefRep.InfilVolTotalStdDen + thisZonePreDefRep.AFNInfilVolTotalStdDen) * zoneMult;
    6428              : 
    6429              :                 // Total ventilation and infiltration
    6430         8902 :                 PreDefTableEntry(state,
    6431         4451 :                                  state.dataOutRptPredefined->pdchOaTaBzTotVentInfil,
    6432              :                                  thisZone.Name,
    6433         4451 :                                  thisZonePreDefRep.MechVentVolTotalStdDen / zoneMult + thisZonePreDefRep.SimpVentVolTotalStdDen +
    6434         4451 :                                      thisZonePreDefRep.AFNVentVolTotalStdDen + thisZonePreDefRep.AFNInfilVolTotalStdDen +
    6435         4451 :                                      thisZonePreDefRep.InfilVolTotalStdDen);
    6436              : 
    6437              :                 // Dynamic target ventilation Voz-dyn
    6438         4451 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaTaBzDynTrgVent, thisZone.Name, thisZonePreDefRep.VozTargetTotal / zoneMult);
    6439         4451 :                 totalVozDyn += thisZonePreDefRep.VozTargetTotal;
    6440         4451 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaTaBzTmBelow, thisZone.Name, thisZonePreDefRep.VozTargetTimeBelow);
    6441         4451 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaTaBzTmAt, thisZone.Name, thisZonePreDefRep.VozTargetTimeAt);
    6442         4451 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaTaBzTmAbove, thisZone.Name, thisZonePreDefRep.VozTargetTimeAbove);
    6443         4451 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaTaBzTmAboveUnocc, thisZone.Name, thisZonePreDefRep.TotVentTimeNonZeroUnocc);
    6444              : 
    6445         4451 :                 if (thisZone.isNominalOccupied && (thisZonePreDefRep.TotTimeOcc > 0.0)) {
    6446         3917 :                     Real64 totTimeOccSec = thisZonePreDefRep.TotTimeOcc * Constant::rSecsInHour;
    6447              :                     // Mechanical ventilation
    6448         3917 :                     Real64 mechVent = thisZonePreDefRep.MechVentVolTotalOccStdDen / totTimeOccSec;
    6449         3917 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaOccBzMechVent, thisZone.Name, mechVent / zoneMult, 4);
    6450         3917 :                     totalMechVentRateOcc += mechVent;
    6451              : 
    6452              :                     // Natural ventilation
    6453         3917 :                     Real64 natVent = (thisZonePreDefRep.SimpVentVolTotalOccStdDen + thisZonePreDefRep.AFNVentVolTotalOccStdDen) / totTimeOccSec;
    6454         3917 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaOccBzNatVent, thisZone.Name, natVent, 4);
    6455         3917 :                     totalNatVentRateOcc += natVent * zoneMult;
    6456              : 
    6457              :                     // Total ventilation
    6458         3917 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaOccBzTotVent, thisZone.Name, mechVent / zoneMult + natVent, 4);
    6459              : 
    6460              :                     // infiltration
    6461         3917 :                     Real64 infil = (thisZonePreDefRep.InfilVolTotalOccStdDen + thisZonePreDefRep.AFNInfilVolTotalOccStdDen) / totTimeOccSec;
    6462         3917 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaOccBzInfil, thisZone.Name, infil, 4);
    6463         3917 :                     totalInfilRateOcc += infil * zoneMult;
    6464              : 
    6465              :                     // Total ventilation and infiltration
    6466         3917 :                     PreDefTableEntry(
    6467         3917 :                         state, state.dataOutRptPredefined->pdchOaOccBzTotVentInfil, thisZone.Name, mechVent / zoneMult + natVent + infil, 4);
    6468              : 
    6469              :                     // Dynamic target ventilation Voz-dyn
    6470         3917 :                     Real64 avgVoz = thisZonePreDefRep.VozTargetTotalOcc / totTimeOccSec;
    6471         3917 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaOccBzDynTrgVent, thisZone.Name, avgVoz / zoneMult, 4);
    6472         3917 :                     totalVozDynOcc += avgVoz;
    6473         3917 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaOccBzTmBelow, thisZone.Name, thisZonePreDefRep.VozTargetTimeBelowOcc);
    6474         3917 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaOccBzTmAt, thisZone.Name, thisZonePreDefRep.VozTargetTimeAtOcc);
    6475         3917 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaOccBzTmAbove, thisZone.Name, thisZonePreDefRep.VozTargetTimeAboveOcc);
    6476              :                 }
    6477         4451 :             }
    6478              :         }
    6479              :     }
    6480              : 
    6481         2015 :     for (int iSys = 1; iSys <= state.dataHVACGlobal->NumPrimaryAirSys; ++iSys) {
    6482         1216 :         auto const &thisPrimaryAirSys = state.dataAirSystemsData->PrimaryAirSystems(iSys);
    6483         1216 :         auto const &thisSysPreDefRep = state.dataSysRpts->SysPreDefRep(iSys);
    6484              : 
    6485              :         // Total Outdoor Air by Airloop
    6486         1216 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaTaAlMechVent, thisPrimaryAirSys.Name, thisSysPreDefRep.MechVentTotal);
    6487         1216 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaTaAlNatVent, thisPrimaryAirSys.Name, thisSysPreDefRep.NatVentTotal);
    6488         2432 :         PreDefTableEntry(state,
    6489         1216 :                          state.dataOutRptPredefined->pdchOaTaAlTotVent,
    6490              :                          thisPrimaryAirSys.Name,
    6491         1216 :                          thisSysPreDefRep.MechVentTotal + thisSysPreDefRep.NatVentTotal);
    6492         1216 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaTaAlSumDynTrgVent, thisPrimaryAirSys.Name, thisSysPreDefRep.TargetVentTotalVoz);
    6493         1216 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaTaAlTmBelow, thisPrimaryAirSys.Name, thisSysPreDefRep.TimeBelowVozDynTotal);
    6494         1216 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaTaAlTmAt, thisPrimaryAirSys.Name, thisSysPreDefRep.TimeAtVozDynTotal);
    6495         1216 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaTaAlTmAbove, thisPrimaryAirSys.Name, thisSysPreDefRep.TimeAboveVozDynTotal);
    6496         1216 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaTaAlTmAboveUnocc, thisPrimaryAirSys.Name, thisSysPreDefRep.TimeVentUnoccTotal);
    6497              : 
    6498              :         // Air loop times at OA limiting factors
    6499         3648 :         PreDefTableEntry(state,
    6500         1216 :                          state.dataOutRptPredefined->pdchOaTmFctNoLimit,
    6501              :                          thisPrimaryAirSys.Name,
    6502         1216 :                          thisSysPreDefRep.TimeAtOALimit[static_cast<int>(MixedAir::OALimitFactor::None)]);
    6503         3648 :         PreDefTableEntry(state,
    6504         1216 :                          state.dataOutRptPredefined->pdchOaTmFctLimit,
    6505              :                          thisPrimaryAirSys.Name,
    6506         1216 :                          thisSysPreDefRep.TimeAtOALimit[static_cast<int>(MixedAir::OALimitFactor::Limits)]);
    6507         3648 :         PreDefTableEntry(state,
    6508         1216 :                          state.dataOutRptPredefined->pdchOaTmFctEcono,
    6509              :                          thisPrimaryAirSys.Name,
    6510         1216 :                          thisSysPreDefRep.TimeAtOALimit[static_cast<int>(MixedAir::OALimitFactor::Economizer)]);
    6511         3648 :         PreDefTableEntry(state,
    6512         1216 :                          state.dataOutRptPredefined->pdchOaTmFctExhaust,
    6513              :                          thisPrimaryAirSys.Name,
    6514         1216 :                          thisSysPreDefRep.TimeAtOALimit[static_cast<int>(MixedAir::OALimitFactor::Exhaust)]);
    6515         3648 :         PreDefTableEntry(state,
    6516         1216 :                          state.dataOutRptPredefined->pdchOaTmFctMixedLimit,
    6517              :                          thisPrimaryAirSys.Name,
    6518         1216 :                          thisSysPreDefRep.TimeAtOALimit[static_cast<int>(MixedAir::OALimitFactor::MixedAir)]);
    6519         3648 :         PreDefTableEntry(state,
    6520         1216 :                          state.dataOutRptPredefined->pdchOaTmFctHiHumid,
    6521              :                          thisPrimaryAirSys.Name,
    6522         1216 :                          thisSysPreDefRep.TimeAtOALimit[static_cast<int>(MixedAir::OALimitFactor::HighHum)]);
    6523         3648 :         PreDefTableEntry(state,
    6524         1216 :                          state.dataOutRptPredefined->pdchOaTmFctDCV,
    6525              :                          thisPrimaryAirSys.Name,
    6526         1216 :                          thisSysPreDefRep.TimeAtOALimit[static_cast<int>(MixedAir::OALimitFactor::DCV)]);
    6527         3648 :         PreDefTableEntry(state,
    6528         1216 :                          state.dataOutRptPredefined->pdchOaTmFctNiteVent,
    6529              :                          thisPrimaryAirSys.Name,
    6530         1216 :                          thisSysPreDefRep.TimeAtOALimit[static_cast<int>(MixedAir::OALimitFactor::NightVent)]);
    6531         3648 :         PreDefTableEntry(state,
    6532         1216 :                          state.dataOutRptPredefined->pdchOaTmFctDemand,
    6533              :                          thisPrimaryAirSys.Name,
    6534         1216 :                          thisSysPreDefRep.TimeAtOALimit[static_cast<int>(MixedAir::OALimitFactor::DemandLimit)]);
    6535         3648 :         PreDefTableEntry(state,
    6536         1216 :                          state.dataOutRptPredefined->pdchOaTmFctEMS,
    6537              :                          thisPrimaryAirSys.Name,
    6538         1216 :                          thisSysPreDefRep.TimeAtOALimit[static_cast<int>(MixedAir::OALimitFactor::EMS)]);
    6539              : 
    6540         1216 :         if (thisSysPreDefRep.TimeOccupiedTotal > 0.0) {
    6541              :             // Average Outdoor Air During Occupancy by Airloop
    6542         1122 :             Real64 totTimeOccSec = thisSysPreDefRep.TimeOccupiedTotal * Constant::rSecsInHour;
    6543         1122 :             PreDefTableEntry(
    6544         1122 :                 state, state.dataOutRptPredefined->pdchOaOccAlMechVent, thisPrimaryAirSys.Name, thisSysPreDefRep.MechVentTotalOcc / totTimeOccSec, 4);
    6545         1122 :             PreDefTableEntry(
    6546         1122 :                 state, state.dataOutRptPredefined->pdchOaOccAlNatVent, thisPrimaryAirSys.Name, thisSysPreDefRep.NatVentTotalOcc / totTimeOccSec, 4);
    6547         1122 :             PreDefTableEntry(state,
    6548         1122 :                              state.dataOutRptPredefined->pdchOaOccAlTotVent,
    6549              :                              thisPrimaryAirSys.Name,
    6550         1122 :                              (thisSysPreDefRep.MechVentTotalOcc + thisSysPreDefRep.NatVentTotalOcc) / totTimeOccSec,
    6551         1122 :                              4);
    6552         1122 :             PreDefTableEntry(state,
    6553         1122 :                              state.dataOutRptPredefined->pdchOaOccAlSumDynTrgVent,
    6554              :                              thisPrimaryAirSys.Name,
    6555         1122 :                              thisSysPreDefRep.TargetVentTotalVozOcc / totTimeOccSec,
    6556         1122 :                              4);
    6557         1122 :             PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaOccAlTmBelow, thisPrimaryAirSys.Name, thisSysPreDefRep.TimeBelowVozDynTotalOcc);
    6558         1122 :             PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaOccAlTmAt, thisPrimaryAirSys.Name, thisSysPreDefRep.TimeAtVozDynTotalOcc);
    6559         1122 :             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        11220 :             auto avgFlowRate = [&state](int sysNum, MixedAir::OALimitFactor limitingFactorType) {
    6564        11220 :                 int time = state.dataSysRpts->SysPreDefRep(sysNum).TimeAtOALimitOcc[static_cast<int>(limitingFactorType)];
    6565        11220 :                 if (time > 0) {
    6566         1118 :                     return state.dataSysRpts->SysPreDefRep(sysNum).MechVentTotAtLimitOcc[static_cast<int>(limitingFactorType)] /
    6567         1118 :                            (time * Constant::rSecsInHour);
    6568              :                 } else {
    6569        10102 :                     return 0.0;
    6570              :                 }
    6571         1122 :             };
    6572         2244 :             PreDefTableEntry(
    6573         2244 :                 state, state.dataOutRptPredefined->pdchOaAvFctNoLimit, thisPrimaryAirSys.Name, avgFlowRate(iSys, MixedAir::OALimitFactor::None), 4);
    6574         2244 :             PreDefTableEntry(
    6575         2244 :                 state, state.dataOutRptPredefined->pdchOaAvFctLimit, thisPrimaryAirSys.Name, avgFlowRate(iSys, MixedAir::OALimitFactor::Limits), 4);
    6576         2244 :             PreDefTableEntry(state,
    6577         1122 :                              state.dataOutRptPredefined->pdchOaAvFctEcono,
    6578              :                              thisPrimaryAirSys.Name,
    6579              :                              avgFlowRate(iSys, MixedAir::OALimitFactor::Economizer),
    6580         1122 :                              4);
    6581         2244 :             PreDefTableEntry(state,
    6582         1122 :                              state.dataOutRptPredefined->pdchOaAvFctExhaust,
    6583              :                              thisPrimaryAirSys.Name,
    6584              :                              avgFlowRate(iSys, MixedAir::OALimitFactor::Exhaust),
    6585         1122 :                              4);
    6586         2244 :             PreDefTableEntry(state,
    6587         1122 :                              state.dataOutRptPredefined->pdchOaAvFctMixedLimit,
    6588              :                              thisPrimaryAirSys.Name,
    6589              :                              avgFlowRate(iSys, MixedAir::OALimitFactor::MixedAir),
    6590         1122 :                              4);
    6591         2244 :             PreDefTableEntry(state,
    6592         1122 :                              state.dataOutRptPredefined->pdchOaAvFctHiHumid,
    6593              :                              thisPrimaryAirSys.Name,
    6594              :                              avgFlowRate(iSys, MixedAir::OALimitFactor::HighHum),
    6595         1122 :                              4);
    6596         2244 :             PreDefTableEntry(
    6597         2244 :                 state, state.dataOutRptPredefined->pdchOaAvFctDCV, thisPrimaryAirSys.Name, avgFlowRate(iSys, MixedAir::OALimitFactor::DCV), 4);
    6598         2244 :             PreDefTableEntry(state,
    6599         1122 :                              state.dataOutRptPredefined->pdchOaAvFctNiteVent,
    6600              :                              thisPrimaryAirSys.Name,
    6601              :                              avgFlowRate(iSys, MixedAir::OALimitFactor::NightVent),
    6602         1122 :                              4);
    6603         2244 :             PreDefTableEntry(state,
    6604         1122 :                              state.dataOutRptPredefined->pdchOaAvFctDemand,
    6605              :                              thisPrimaryAirSys.Name,
    6606              :                              avgFlowRate(iSys, MixedAir::OALimitFactor::DemandLimit),
    6607         1122 :                              4);
    6608         2244 :             PreDefTableEntry(
    6609         3366 :                 state, state.dataOutRptPredefined->pdchOaAvFctEMS, thisPrimaryAirSys.Name, avgFlowRate(iSys, MixedAir::OALimitFactor::EMS), 4);
    6610              :         }
    6611              :     }
    6612              :     // add total rows for outdoor air details
    6613         1598 :     OutputReportPredefined::PreDefTableEntry(
    6614         1598 :         state, state.dataOutRptPredefined->pdchOaMvDesZnOa, "Total Facility", state.dataOutRptPredefined->TotalVozMax, 4);
    6615              : 
    6616          799 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaMvZoneVol, "Total Facility", state.dataOutRptTab->totalVolume);
    6617          799 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaMvZoneArea, "Total Facility", totalArea);
    6618          799 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaMvNomNumOcc, "Total Facility", totalOccupants);
    6619          799 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaMvAvgNumOcc, "Total Facility", totalAverageOccupants);
    6620          799 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaMvMinDynTrgVent, "Total Facility", totalVozMin, 3);
    6621              : 
    6622          799 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaTaBzMechVent, "Total Facility", totalMechVentVol);
    6623          799 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaTaBzNatVent, "Total Facility", totalNatVentVol);
    6624          799 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaTaBzTotVent, "Total Facility", totalMechVentVol + totalNatVentVol);
    6625          799 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaTaBzInfil, "Total Facility", totalInfilVol);
    6626          799 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaTaBzTotVentInfil, "Total Facility", totalMechVentVol + totalNatVentVol + totalInfilVol);
    6627          799 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaTaBzDynTrgVent, "Total Facility", totalVozDyn);
    6628         2397 :     PreDefTableEntry(
    6629         1598 :         state, state.dataOutRptPredefined->pdchOaTaBzTmBelow, "Total Facility", state.dataOutRptPredefined->TotalAnyZoneBelowVozDynForOA);
    6630          799 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaTaBzTmAt, "Total Facility", state.dataOutRptPredefined->TotalAllZonesAtVozDynForOA);
    6631         2397 :     PreDefTableEntry(
    6632         1598 :         state, state.dataOutRptPredefined->pdchOaTaBzTmAbove, "Total Facility", state.dataOutRptPredefined->TotalAnyZoneAboveVozDynForOA);
    6633         2397 :     PreDefTableEntry(
    6634         1598 :         state, state.dataOutRptPredefined->pdchOaTaBzTmAboveUnocc, "Total Facility", state.dataOutRptPredefined->TotalAnyZoneVentUnoccForOA);
    6635              : 
    6636          799 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaOccBzMechVent, "Total Facility", totalMechVentRateOcc, 4);
    6637          799 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaOccBzNatVent, "Total Facility", totalNatVentRateOcc, 4);
    6638          799 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaOccBzTotVent, "Total Facility", totalMechVentRateOcc + totalNatVentRateOcc, 4);
    6639          799 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaOccBzInfil, "Total Facility", totalInfilRateOcc, 4);
    6640          799 :     PreDefTableEntry(state,
    6641          799 :                      state.dataOutRptPredefined->pdchOaOccBzTotVentInfil,
    6642              :                      "Total Facility",
    6643          799 :                      totalMechVentRateOcc + totalNatVentRateOcc + totalInfilRateOcc,
    6644          799 :                      4);
    6645          799 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaOccBzDynTrgVent, "Total Facility", totalVozDynOcc, 4);
    6646         2397 :     PreDefTableEntry(
    6647         1598 :         state, state.dataOutRptPredefined->pdchOaOccBzTmBelow, "Total Facility", state.dataOutRptPredefined->TotalAnyZoneBelowVozDynOccForOA);
    6648          799 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaOccBzTmAt, "Total Facility", state.dataOutRptPredefined->TotalAllZonesAtVozDynOccForOA);
    6649         2397 :     PreDefTableEntry(
    6650         1598 :         state, state.dataOutRptPredefined->pdchOaOccBzTmAbove, "Total Facility", state.dataOutRptPredefined->TotalAnyZoneAboveVozDynOccForOA);
    6651              : 
    6652              :     // Add the number of central air distributions system to the count report
    6653          799 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchHVACcntVal, "HVAC Air Loops", NumPrimaryAirSys);
    6654              :     // Add the number of conditioned and unconditioned zones to the count report
    6655         5988 :     for (int iZone = 1; iZone <= state.dataGlobal->NumOfZones; ++iZone) {
    6656              : 
    6657         5189 :         if (state.dataHeatBal->Zone(iZone).SystemZoneNodeNumber > 0) { // conditioned zones only
    6658         4744 :             ++state.dataOutRptTab->numCondZones;
    6659              :         } else {
    6660          445 :             ++state.dataOutRptTab->numUncondZones;
    6661              :         }
    6662              :     }
    6663          799 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchHVACcntVal, "Conditioned Zones", state.dataOutRptTab->numCondZones);
    6664          799 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchHVACcntVal, "Unconditioned Zones", state.dataOutRptTab->numUncondZones);
    6665              :     // add the number of plenums to the count report
    6666          799 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchHVACcntVal, "Supply Plenums", state.dataZonePlenum->NumZoneSupplyPlenums);
    6667          799 :     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          799 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchFieldCntVal, "IDF Objects", iNumberOfRecords);
    6673          799 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchFieldCntVal, "Defaulted Fields", iNumberOfDefaultedFields);
    6674          799 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchFieldCntVal, "Fields with Defaults", iTotalFieldsWithDefaults);
    6675          799 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchFieldCntVal, "Autosized Fields", iNumberOfAutoSizedFields);
    6676          799 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchFieldCntVal, "Autosizable Fields", iTotalAutoSizableFields);
    6677          799 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchFieldCntVal, "Autocalculated Fields", iNumberOfAutoCalcedFields);
    6678          799 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchFieldCntVal, "Autocalculatable Fields", iTotalAutoCalculatableFields);
    6679              : 
    6680         5988 :     for (int iZone = 1; iZone <= state.dataGlobal->NumOfZones; ++iZone) {
    6681              : 
    6682         5189 :         auto const &thisZone = state.dataHeatBal->Zone(iZone);
    6683         5189 :         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         5189 :         PreDefTableEntry(
    6689         5189 :             state, state.dataOutRptPredefined->pdchSHGSAnZoneEqHt, thisZone.Name, thisZonePreDefRep.SHGSAnZoneEqHt * Constant::convertJtoGJ, 3);
    6690         5189 :         PreDefTableEntry(
    6691         5189 :             state, state.dataOutRptPredefined->pdchSHGSAnZoneEqCl, thisZone.Name, thisZonePreDefRep.SHGSAnZoneEqCl * Constant::convertJtoGJ, 3);
    6692         5189 :         PreDefTableEntry(
    6693         5189 :             state, state.dataOutRptPredefined->pdchSHGSAnHvacATUHt, thisZone.Name, thisZonePreDefRep.SHGSAnHvacATUHt * Constant::convertJtoGJ, 3);
    6694         5189 :         PreDefTableEntry(
    6695         5189 :             state, state.dataOutRptPredefined->pdchSHGSAnHvacATUCl, thisZone.Name, thisZonePreDefRep.SHGSAnHvacATUCl * Constant::convertJtoGJ, 3);
    6696         5189 :         PreDefTableEntry(
    6697         5189 :             state, state.dataOutRptPredefined->pdchSHGSAnSurfHt, thisZone.Name, thisZonePreDefRep.SHGSAnSurfHt * Constant::convertJtoGJ, 3);
    6698         5189 :         PreDefTableEntry(
    6699         5189 :             state, state.dataOutRptPredefined->pdchSHGSAnSurfCl, thisZone.Name, thisZonePreDefRep.SHGSAnSurfCl * Constant::convertJtoGJ, 3);
    6700         5189 :         PreDefTableEntry(
    6701         5189 :             state, state.dataOutRptPredefined->pdchSHGSAnPeoplAdd, thisZone.Name, thisZonePreDefRep.SHGSAnPeoplAdd * Constant::convertJtoGJ, 3);
    6702         5189 :         PreDefTableEntry(
    6703         5189 :             state, state.dataOutRptPredefined->pdchSHGSAnLiteAdd, thisZone.Name, thisZonePreDefRep.SHGSAnLiteAdd * Constant::convertJtoGJ, 3);
    6704         5189 :         PreDefTableEntry(
    6705         5189 :             state, state.dataOutRptPredefined->pdchSHGSAnEquipAdd, thisZone.Name, thisZonePreDefRep.SHGSAnEquipAdd * Constant::convertJtoGJ, 3);
    6706         5189 :         PreDefTableEntry(
    6707         5189 :             state, state.dataOutRptPredefined->pdchSHGSAnWindAdd, thisZone.Name, thisZonePreDefRep.SHGSAnWindAdd * Constant::convertJtoGJ, 3);
    6708         5189 :         PreDefTableEntry(
    6709         5189 :             state, state.dataOutRptPredefined->pdchSHGSAnIzaAdd, thisZone.Name, thisZonePreDefRep.SHGSAnIzaAdd * Constant::convertJtoGJ, 3);
    6710         5189 :         PreDefTableEntry(
    6711         5189 :             state, state.dataOutRptPredefined->pdchSHGSAnInfilAdd, thisZone.Name, thisZonePreDefRep.SHGSAnInfilAdd * Constant::convertJtoGJ, 3);
    6712         5189 :         PreDefTableEntry(
    6713         5189 :             state, state.dataOutRptPredefined->pdchSHGSAnOtherAdd, thisZone.Name, thisZonePreDefRep.SHGSAnOtherAdd * Constant::convertJtoGJ, 3);
    6714         5189 :         PreDefTableEntry(
    6715         5189 :             state, state.dataOutRptPredefined->pdchSHGSAnEquipRem, thisZone.Name, thisZonePreDefRep.SHGSAnEquipRem * Constant::convertJtoGJ, 3);
    6716         5189 :         PreDefTableEntry(
    6717         5189 :             state, state.dataOutRptPredefined->pdchSHGSAnWindRem, thisZone.Name, thisZonePreDefRep.SHGSAnWindRem * Constant::convertJtoGJ, 3);
    6718         5189 :         PreDefTableEntry(
    6719         5189 :             state, state.dataOutRptPredefined->pdchSHGSAnIzaRem, thisZone.Name, thisZonePreDefRep.SHGSAnIzaRem * Constant::convertJtoGJ, 3);
    6720         5189 :         PreDefTableEntry(
    6721         5189 :             state, state.dataOutRptPredefined->pdchSHGSAnInfilRem, thisZone.Name, thisZonePreDefRep.SHGSAnInfilRem * Constant::convertJtoGJ, 3);
    6722         5189 :         PreDefTableEntry(
    6723         5189 :             state, state.dataOutRptPredefined->pdchSHGSAnOtherRem, thisZone.Name, thisZonePreDefRep.SHGSAnOtherRem * Constant::convertJtoGJ, 3);
    6724              :         // peak cooling
    6725         5189 :         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        10378 :         PreDefTableEntry(
    6729         5189 :             state, state.dataOutRptPredefined->pdchSHGSClHvacHt, thisZone.Name, (thisZonePreDefRep.SHGSClHvacHt - thisZonePreDefRep.SHGSClHvacATUHt));
    6730        10378 :         PreDefTableEntry(
    6731         5189 :             state, state.dataOutRptPredefined->pdchSHGSClHvacCl, thisZone.Name, (thisZonePreDefRep.SHGSClHvacCl - thisZonePreDefRep.SHGSClHvacATUCl));
    6732         5189 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSClHvacATUHt, thisZone.Name, thisZonePreDefRep.SHGSClHvacATUHt);
    6733         5189 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSClHvacATUCl, thisZone.Name, thisZonePreDefRep.SHGSClHvacATUCl);
    6734         5189 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSClSurfHt, thisZone.Name, thisZonePreDefRep.SHGSClSurfHt);
    6735         5189 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSClSurfCl, thisZone.Name, thisZonePreDefRep.SHGSClSurfCl);
    6736         5189 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSClPeoplAdd, thisZone.Name, thisZonePreDefRep.SHGSClPeoplAdd);
    6737         5189 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSClLiteAdd, thisZone.Name, thisZonePreDefRep.SHGSClLiteAdd);
    6738         5189 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSClEquipAdd, thisZone.Name, thisZonePreDefRep.SHGSClEquipAdd);
    6739         5189 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSClWindAdd, thisZone.Name, thisZonePreDefRep.SHGSClWindAdd);
    6740         5189 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSClIzaAdd, thisZone.Name, thisZonePreDefRep.SHGSClIzaAdd);
    6741         5189 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSClInfilAdd, thisZone.Name, thisZonePreDefRep.SHGSClInfilAdd);
    6742         5189 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSClOtherAdd, thisZone.Name, thisZonePreDefRep.SHGSClOtherAdd);
    6743         5189 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSClEquipRem, thisZone.Name, thisZonePreDefRep.SHGSClEquipRem);
    6744         5189 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSClWindRem, thisZone.Name, thisZonePreDefRep.SHGSClWindRem);
    6745         5189 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSClIzaRem, thisZone.Name, thisZonePreDefRep.SHGSClIzaRem);
    6746         5189 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSClInfilRem, thisZone.Name, thisZonePreDefRep.SHGSClInfilRem);
    6747         5189 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSClOtherRem, thisZone.Name, thisZonePreDefRep.SHGSClOtherRem);
    6748              :         // peak heating
    6749         5189 :         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        10378 :         PreDefTableEntry(
    6753         5189 :             state, state.dataOutRptPredefined->pdchSHGSHtHvacHt, thisZone.Name, (thisZonePreDefRep.SHGSHtHvacHt - thisZonePreDefRep.SHGSHtHvacATUHt));
    6754        10378 :         PreDefTableEntry(
    6755         5189 :             state, state.dataOutRptPredefined->pdchSHGSHtHvacCl, thisZone.Name, (thisZonePreDefRep.SHGSHtHvacCl - thisZonePreDefRep.SHGSHtHvacATUCl));
    6756         5189 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSHtHvacATUHt, thisZone.Name, thisZonePreDefRep.SHGSHtHvacATUHt);
    6757         5189 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSHtHvacATUCl, thisZone.Name, thisZonePreDefRep.SHGSHtHvacATUCl);
    6758         5189 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSHtSurfHt, thisZone.Name, thisZonePreDefRep.SHGSHtSurfHt);
    6759         5189 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSHtSurfCl, thisZone.Name, thisZonePreDefRep.SHGSHtSurfCl);
    6760         5189 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSHtPeoplAdd, thisZone.Name, thisZonePreDefRep.SHGSHtPeoplAdd);
    6761         5189 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSHtLiteAdd, thisZone.Name, thisZonePreDefRep.SHGSHtLiteAdd);
    6762         5189 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSHtEquipAdd, thisZone.Name, thisZonePreDefRep.SHGSHtEquipAdd);
    6763         5189 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSHtWindAdd, thisZone.Name, thisZonePreDefRep.SHGSHtWindAdd);
    6764         5189 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSHtIzaAdd, thisZone.Name, thisZonePreDefRep.SHGSHtIzaAdd);
    6765         5189 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSHtInfilAdd, thisZone.Name, thisZonePreDefRep.SHGSHtInfilAdd);
    6766         5189 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSHtOtherAdd, thisZone.Name, thisZonePreDefRep.SHGSHtOtherAdd);
    6767         5189 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSHtEquipRem, thisZone.Name, thisZonePreDefRep.SHGSHtEquipRem);
    6768         5189 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSHtWindRem, thisZone.Name, thisZonePreDefRep.SHGSHtWindRem);
    6769         5189 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSHtIzaRem, thisZone.Name, thisZonePreDefRep.SHGSHtIzaRem);
    6770         5189 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSHtInfilRem, thisZone.Name, thisZonePreDefRep.SHGSHtInfilRem);
    6771         5189 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSHtOtherRem, thisZone.Name, thisZonePreDefRep.SHGSHtOtherRem);
    6772              :     }
    6773              :     // totals for annual report
    6774         5988 :     for (int iZone = 1; iZone <= state.dataGlobal->NumOfZones; ++iZone) {
    6775         5189 :         auto const &thisZonePreDefRep = state.dataHeatBal->ZonePreDefRep(iZone);
    6776              : 
    6777         5189 :         state.dataOutRptTab->totalZoneEqHt += thisZonePreDefRep.SHGSAnZoneEqHt;
    6778         5189 :         state.dataOutRptTab->totalZoneEqCl += thisZonePreDefRep.SHGSAnZoneEqCl;
    6779         5189 :         state.dataOutRptTab->totalHvacATUHt += thisZonePreDefRep.SHGSAnHvacATUHt;
    6780         5189 :         state.dataOutRptTab->totalHvacATUCl += thisZonePreDefRep.SHGSAnHvacATUCl;
    6781         5189 :         state.dataOutRptTab->totalSurfHt += thisZonePreDefRep.SHGSAnSurfHt;
    6782         5189 :         state.dataOutRptTab->totalSurfCl += thisZonePreDefRep.SHGSAnSurfCl;
    6783         5189 :         state.dataOutRptTab->totalPeoplAdd += thisZonePreDefRep.SHGSAnPeoplAdd;
    6784         5189 :         state.dataOutRptTab->totalLiteAdd += thisZonePreDefRep.SHGSAnLiteAdd;
    6785         5189 :         state.dataOutRptTab->totalEquipAdd += thisZonePreDefRep.SHGSAnEquipAdd;
    6786         5189 :         state.dataOutRptTab->totalWindAdd += thisZonePreDefRep.SHGSAnWindAdd;
    6787         5189 :         state.dataOutRptTab->totalIzaAdd += thisZonePreDefRep.SHGSAnIzaAdd;
    6788         5189 :         state.dataOutRptTab->totalInfilAdd += thisZonePreDefRep.SHGSAnInfilAdd;
    6789         5189 :         state.dataOutRptTab->totalOtherAdd += thisZonePreDefRep.SHGSAnOtherAdd;
    6790         5189 :         state.dataOutRptTab->totalEquipRem += thisZonePreDefRep.SHGSAnEquipRem;
    6791         5189 :         state.dataOutRptTab->totalWindRem += thisZonePreDefRep.SHGSAnWindRem;
    6792         5189 :         state.dataOutRptTab->totalIzaRem += thisZonePreDefRep.SHGSAnIzaRem;
    6793         5189 :         state.dataOutRptTab->totalInfilRem += thisZonePreDefRep.SHGSAnInfilRem;
    6794         5189 :         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          799 :     PreDefTableEntry(
    6799          799 :         state, state.dataOutRptPredefined->pdchSHGSAnZoneEqHt, "Total Facility", state.dataOutRptTab->totalZoneEqHt * Constant::convertJtoGJ, 3);
    6800          799 :     PreDefTableEntry(
    6801          799 :         state, state.dataOutRptPredefined->pdchSHGSAnZoneEqCl, "Total Facility", state.dataOutRptTab->totalZoneEqCl * Constant::convertJtoGJ, 3);
    6802          799 :     PreDefTableEntry(
    6803          799 :         state, state.dataOutRptPredefined->pdchSHGSAnHvacATUHt, "Total Facility", state.dataOutRptTab->totalHvacATUHt * Constant::convertJtoGJ, 3);
    6804          799 :     PreDefTableEntry(
    6805          799 :         state, state.dataOutRptPredefined->pdchSHGSAnHvacATUCl, "Total Facility", state.dataOutRptTab->totalHvacATUCl * Constant::convertJtoGJ, 3);
    6806          799 :     PreDefTableEntry(
    6807          799 :         state, state.dataOutRptPredefined->pdchSHGSAnSurfHt, "Total Facility", state.dataOutRptTab->totalSurfHt * Constant::convertJtoGJ, 3);
    6808          799 :     PreDefTableEntry(
    6809          799 :         state, state.dataOutRptPredefined->pdchSHGSAnSurfCl, "Total Facility", state.dataOutRptTab->totalSurfCl * Constant::convertJtoGJ, 3);
    6810          799 :     PreDefTableEntry(
    6811          799 :         state, state.dataOutRptPredefined->pdchSHGSAnPeoplAdd, "Total Facility", state.dataOutRptTab->totalPeoplAdd * Constant::convertJtoGJ, 3);
    6812          799 :     PreDefTableEntry(
    6813          799 :         state, state.dataOutRptPredefined->pdchSHGSAnLiteAdd, "Total Facility", state.dataOutRptTab->totalLiteAdd * Constant::convertJtoGJ, 3);
    6814          799 :     PreDefTableEntry(
    6815          799 :         state, state.dataOutRptPredefined->pdchSHGSAnEquipAdd, "Total Facility", state.dataOutRptTab->totalEquipAdd * Constant::convertJtoGJ, 3);
    6816          799 :     PreDefTableEntry(
    6817          799 :         state, state.dataOutRptPredefined->pdchSHGSAnWindAdd, "Total Facility", state.dataOutRptTab->totalWindAdd * Constant::convertJtoGJ, 3);
    6818          799 :     PreDefTableEntry(
    6819          799 :         state, state.dataOutRptPredefined->pdchSHGSAnIzaAdd, "Total Facility", state.dataOutRptTab->totalIzaAdd * Constant::convertJtoGJ, 3);
    6820          799 :     PreDefTableEntry(
    6821          799 :         state, state.dataOutRptPredefined->pdchSHGSAnInfilAdd, "Total Facility", state.dataOutRptTab->totalInfilAdd * Constant::convertJtoGJ, 3);
    6822          799 :     PreDefTableEntry(
    6823          799 :         state, state.dataOutRptPredefined->pdchSHGSAnOtherAdd, "Total Facility", state.dataOutRptTab->totalOtherAdd * Constant::convertJtoGJ, 3);
    6824          799 :     PreDefTableEntry(
    6825          799 :         state, state.dataOutRptPredefined->pdchSHGSAnEquipRem, "Total Facility", state.dataOutRptTab->totalEquipRem * Constant::convertJtoGJ, 3);
    6826          799 :     PreDefTableEntry(
    6827          799 :         state, state.dataOutRptPredefined->pdchSHGSAnWindRem, "Total Facility", state.dataOutRptTab->totalWindRem * Constant::convertJtoGJ, 3);
    6828          799 :     PreDefTableEntry(
    6829          799 :         state, state.dataOutRptPredefined->pdchSHGSAnIzaRem, "Total Facility", state.dataOutRptTab->totalIzaRem * Constant::convertJtoGJ, 3);
    6830          799 :     PreDefTableEntry(
    6831          799 :         state, state.dataOutRptPredefined->pdchSHGSAnInfilRem, "Total Facility", state.dataOutRptTab->totalInfilRem * Constant::convertJtoGJ, 3);
    6832          799 :     PreDefTableEntry(
    6833          799 :         state, state.dataOutRptPredefined->pdchSHGSAnOtherRem, "Total Facility", state.dataOutRptTab->totalOtherRem * Constant::convertJtoGJ, 3);
    6834              :     // building level results for peak cooling
    6835         1598 :     PreDefTableEntry(
    6836         2397 :         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         1598 :     PreDefTableEntry(state,
    6840          799 :                      state.dataOutRptPredefined->pdchSHGSClHvacHt,
    6841              :                      "Total Facility",
    6842          799 :                      (state.dataHeatBal->BuildingPreDefRep.SHGSClHvacHt - state.dataHeatBal->BuildingPreDefRep.SHGSClHvacATUHt));
    6843         1598 :     PreDefTableEntry(state,
    6844          799 :                      state.dataOutRptPredefined->pdchSHGSClHvacCl,
    6845              :                      "Total Facility",
    6846          799 :                      (state.dataHeatBal->BuildingPreDefRep.SHGSClHvacCl - state.dataHeatBal->BuildingPreDefRep.SHGSClHvacATUCl));
    6847          799 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSClHvacATUHt, "Total Facility", state.dataHeatBal->BuildingPreDefRep.SHGSClHvacATUHt);
    6848          799 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSClHvacATUCl, "Total Facility", state.dataHeatBal->BuildingPreDefRep.SHGSClHvacATUCl);
    6849          799 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSClSurfHt, "Total Facility", state.dataHeatBal->BuildingPreDefRep.SHGSClSurfHt);
    6850          799 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSClSurfCl, "Total Facility", state.dataHeatBal->BuildingPreDefRep.SHGSClSurfCl);
    6851          799 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSClPeoplAdd, "Total Facility", state.dataHeatBal->BuildingPreDefRep.SHGSClPeoplAdd);
    6852          799 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSClLiteAdd, "Total Facility", state.dataHeatBal->BuildingPreDefRep.SHGSClLiteAdd);
    6853          799 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSClEquipAdd, "Total Facility", state.dataHeatBal->BuildingPreDefRep.SHGSClEquipAdd);
    6854          799 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSClWindAdd, "Total Facility", state.dataHeatBal->BuildingPreDefRep.SHGSClWindAdd);
    6855          799 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSClIzaAdd, "Total Facility", state.dataHeatBal->BuildingPreDefRep.SHGSClIzaAdd);
    6856          799 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSClInfilAdd, "Total Facility", state.dataHeatBal->BuildingPreDefRep.SHGSClInfilAdd);
    6857          799 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSClOtherAdd, "Total Facility", state.dataHeatBal->BuildingPreDefRep.SHGSClOtherAdd);
    6858          799 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSClEquipRem, "Total Facility", state.dataHeatBal->BuildingPreDefRep.SHGSClEquipRem);
    6859          799 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSClWindRem, "Total Facility", state.dataHeatBal->BuildingPreDefRep.SHGSClWindRem);
    6860          799 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSClIzaRem, "Total Facility", state.dataHeatBal->BuildingPreDefRep.SHGSClIzaRem);
    6861          799 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSClInfilRem, "Total Facility", state.dataHeatBal->BuildingPreDefRep.SHGSClInfilRem);
    6862          799 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSClOtherRem, "Total Facility", state.dataHeatBal->BuildingPreDefRep.SHGSClOtherRem);
    6863              :     // building level results for peak heating
    6864         1598 :     PreDefTableEntry(
    6865         2397 :         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         1598 :     PreDefTableEntry(state,
    6869          799 :                      state.dataOutRptPredefined->pdchSHGSHtHvacHt,
    6870              :                      "Total Facility",
    6871          799 :                      (state.dataHeatBal->BuildingPreDefRep.SHGSHtHvacHt - state.dataHeatBal->BuildingPreDefRep.SHGSHtHvacATUHt));
    6872         1598 :     PreDefTableEntry(state,
    6873          799 :                      state.dataOutRptPredefined->pdchSHGSHtHvacCl,
    6874              :                      "Total Facility",
    6875          799 :                      (state.dataHeatBal->BuildingPreDefRep.SHGSHtHvacCl - state.dataHeatBal->BuildingPreDefRep.SHGSHtHvacATUCl));
    6876          799 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSHtHvacATUHt, "Total Facility", state.dataHeatBal->BuildingPreDefRep.SHGSHtHvacATUHt);
    6877          799 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSHtHvacATUCl, "Total Facility", state.dataHeatBal->BuildingPreDefRep.SHGSHtHvacATUCl);
    6878          799 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSHtSurfHt, "Total Facility", state.dataHeatBal->BuildingPreDefRep.SHGSHtSurfHt);
    6879          799 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSHtSurfCl, "Total Facility", state.dataHeatBal->BuildingPreDefRep.SHGSHtSurfCl);
    6880          799 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSHtPeoplAdd, "Total Facility", state.dataHeatBal->BuildingPreDefRep.SHGSHtPeoplAdd);
    6881          799 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSHtLiteAdd, "Total Facility", state.dataHeatBal->BuildingPreDefRep.SHGSHtLiteAdd);
    6882          799 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSHtEquipAdd, "Total Facility", state.dataHeatBal->BuildingPreDefRep.SHGSHtEquipAdd);
    6883          799 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSHtWindAdd, "Total Facility", state.dataHeatBal->BuildingPreDefRep.SHGSHtWindAdd);
    6884          799 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSHtIzaAdd, "Total Facility", state.dataHeatBal->BuildingPreDefRep.SHGSHtIzaAdd);
    6885          799 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSHtInfilAdd, "Total Facility", state.dataHeatBal->BuildingPreDefRep.SHGSHtInfilAdd);
    6886          799 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSHtOtherAdd, "Total Facility", state.dataHeatBal->BuildingPreDefRep.SHGSHtOtherAdd);
    6887          799 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSHtEquipRem, "Total Facility", state.dataHeatBal->BuildingPreDefRep.SHGSHtEquipRem);
    6888          799 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSHtWindRem, "Total Facility", state.dataHeatBal->BuildingPreDefRep.SHGSHtWindRem);
    6889          799 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSHtIzaRem, "Total Facility", state.dataHeatBal->BuildingPreDefRep.SHGSHtIzaRem);
    6890          799 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSHtInfilRem, "Total Facility", state.dataHeatBal->BuildingPreDefRep.SHGSHtInfilRem);
    6891          799 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSHtOtherRem, "Total Facility", state.dataHeatBal->BuildingPreDefRep.SHGSHtOtherRem);
    6892              : 
    6893              :     // LEED Report
    6894              :     // 1.1A-General Information
    6895          799 :     if (state.dataEnvrn->EnvironmentName == state.dataEnvrn->WeatherFileLocationTitle) {
    6896            0 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchLeedGenData, "Weather File", state.dataEnvrn->EnvironmentName);
    6897              :     } else {
    6898         1598 :         PreDefTableEntry(state,
    6899          799 :                          state.dataOutRptPredefined->pdchLeedGenData,
    6900              :                          "Weather File",
    6901         1598 :                          state.dataEnvrn->EnvironmentName + " ** " + state.dataEnvrn->WeatherFileLocationTitle);
    6902              :     }
    6903              : 
    6904          799 :     if (ort->ip()) {
    6905           11 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchLeedGenData, "Total gross floor area [ft2]", "-");
    6906              :     } else {
    6907          788 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchLeedGenData, "Total gross floor area [m2]", "-");
    6908              :     }
    6909              :     // LEED schedule sub table
    6910        19583 :     for (auto *sched : state.dataSched->schedules) {
    6911        18784 :         if (sched->schedTypeNum == -1) {
    6912         1757 :             continue;
    6913              :         }
    6914        17027 :         if (!Util::SameString(state.dataSched->scheduleTypes[sched->schedTypeNum]->Name, "FRACTION")) {
    6915        10102 :             continue;
    6916              :         }
    6917              : 
    6918        13850 :         PreDefTableEntry(state,
    6919         6925 :                          state.dataOutRptPredefined->pdchLeedEflhEflh,
    6920              :                          sched->Name,
    6921         6925 :                          sched->getAnnualHoursFullLoad(state, StartOfWeek, state.dataEnvrn->CurrentYearIsLeapYear),
    6922         6925 :                          0);
    6923        13850 :         PreDefTableEntry(state,
    6924         6925 :                          state.dataOutRptPredefined->pdchLeedEflhNonZerHrs,
    6925              :                          sched->Name,
    6926         6925 :                          sched->getAnnualHoursGreaterThan1Percent(state, StartOfWeek, state.dataEnvrn->CurrentYearIsLeapYear),
    6927        13850 :                          0);
    6928          799 :     }
    6929              : 
    6930              :     // fill the LEED setpoint table
    6931          799 :     ZoneTempPredictorCorrector::FillPredefinedTableOnThermostatSetpoints(state);
    6932          799 :     ZoneTempPredictorCorrector::FillPredefinedTableOnThermostatSchedules(state);
    6933          799 : }
    6934              : 
    6935            6 : 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            6 :     Array1D_string columnHead;
    6956            6 :     Array1D_int columnWidth;
    6957            6 :     Array1D_string rowHead(16);
    6958            6 :     Array2D_string tableBody;
    6959            6 :     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            6 :     std::string curUnits;
    6976            6 :     std::string energyUnitsString;
    6977              :     Real64 energyUnitsConversionFactor;
    6978              :     int indexUnitConv;
    6979            6 :     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            6 :     rowHead(1) = "January";
    6987            6 :     rowHead(2) = "February";
    6988            6 :     rowHead(3) = "March";
    6989            6 :     rowHead(4) = "April";
    6990            6 :     rowHead(5) = "May";
    6991            6 :     rowHead(6) = "June";
    6992            6 :     rowHead(7) = "July";
    6993            6 :     rowHead(8) = "August";
    6994            6 :     rowHead(9) = "September";
    6995            6 :     rowHead(10) = "October";
    6996            6 :     rowHead(11) = "November";
    6997            6 :     rowHead(12) = "December";
    6998            6 :     rowHead(13) = "";
    6999            6 :     rowHead(14) = "Annual Sum or Average";
    7000            6 :     rowHead(15) = "Minimum of Months";
    7001            6 :     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           90 :     };
    7019              : 
    7020            6 :     veryLarge = 1.0E280;
    7021            6 :     verySmall = -1.0E280;
    7022              : 
    7023            6 :     auto &ort = state.dataOutRptTab;
    7024              : 
    7025           12 :     for (int iUnitSystem = 0; iUnitSystem <= 1; iUnitSystem++) {
    7026           12 :         UnitsStyle unitsStyle_cur = ort->unitsStyle;
    7027           12 :         bool produceTabular = true;
    7028           12 :         bool produceSQLite = false;
    7029           12 :         if (produceDualUnitsFlags(iUnitSystem, ort->unitsStyle, ort->unitsStyle_SQLite, unitsStyle_cur, produceTabular, produceSQLite)) {
    7030            6 :             break;
    7031              :         }
    7032              : 
    7033              :         // set the unit conversion
    7034            6 :         if (unitsStyle_cur == UnitsStyle::None) {
    7035            6 :             energyUnitsString = "J";
    7036            6 :             energyUnitsConversionFactor = 1.0;
    7037            0 :         } else if (unitsStyle_cur == UnitsStyle::JtoKWH) {
    7038            0 :             energyUnitsString = "kWh";
    7039            0 :             energyUnitsConversionFactor = 1.0 / 3600000.0;
    7040            0 :         } else if (unitsStyle_cur == UnitsStyle::JtoMJ) {
    7041            0 :             energyUnitsString = "MJ";
    7042            0 :             energyUnitsConversionFactor = 1.0 / 1000000.0;
    7043            0 :         } 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            0 :             energyUnitsString = "J";
    7048            0 :             energyUnitsConversionFactor = 1.0;
    7049              :         }
    7050              : 
    7051              :         // loop through each input to get the name of the tables
    7052           11 :         for (iInput = 1; iInput <= ort->MonthlyInputCount; ++iInput) {
    7053              :             // loop through each report and
    7054            5 :             digitsShown = ort->MonthlyInput(iInput).showDigits;
    7055           10 :             for (jTable = 1; jTable <= ort->MonthlyInput(iInput).numTables; ++jTable) {
    7056            5 :                 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            5 :                 columnUsedCount = 0;
    7061           10 :                 for (kColumn = 1; kColumn <= ort->MonthlyTables(curTable).numColumns; ++kColumn) {
    7062            5 :                     curCol = kColumn + ort->MonthlyTables(curTable).firstColumn - 1;
    7063            5 :                     switch (ort->MonthlyColumns(curCol).aggType) {
    7064            0 :                     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            0 :                         ++columnUsedCount;
    7074            0 :                     } break;
    7075            5 :                     case AggType::Maximum:
    7076              :                     case AggType::Minimum:
    7077              :                     case AggType::MaximumDuringHoursShown:
    7078              :                     case AggType::MinimumDuringHoursShown: {
    7079            5 :                         columnUsedCount += 2;
    7080            5 :                     } break;
    7081            0 :                     default:
    7082            0 :                         break;
    7083              :                     }
    7084              :                 } // jColumn
    7085            5 :                 columnHead.allocate(columnUsedCount);
    7086            5 :                 columnWidth.dimension(columnUsedCount, 14); // array assignment - same for all columns
    7087            5 :                 tableBody.allocate(columnUsedCount, 16);
    7088            5 :                 tableBody = ""; // set entire table to blank as default
    7089            5 :                 columnRecount = 0;
    7090           10 :                 for (kColumn = 1; kColumn <= ort->MonthlyTables(curTable).numColumns; ++kColumn) {
    7091            5 :                     curCol = kColumn + ort->MonthlyTables(curTable).firstColumn - 1;
    7092            5 :                     curAggString = aggString.at(ort->MonthlyColumns(curCol).aggType);
    7093            5 :                     if (len(curAggString) > 0) {
    7094            5 :                         curAggString = " {" + stripped(curAggString) + '}';
    7095              :                     }
    7096              :                     // do the unit conversions
    7097            5 :                     if (unitsStyle_cur == OutputReportTabular::UnitsStyle::InchPound ||
    7098            5 :                         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            5 :                     } else if (Util::SameString(Constant::unitNames[(int)ort->MonthlyColumns(curCol).units], "J")) {
    7104            5 :                         curUnits = energyUnitsString;
    7105            5 :                         curConversionFactor = energyUnitsConversionFactor;
    7106            5 :                         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            5 :                     switch (ort->MonthlyColumns(curCol).aggType) {
    7113            0 :                     case AggType::SumOrAvg:
    7114              :                     case AggType::SumOrAverageHoursShown: {
    7115            0 :                         ++columnRecount;
    7116              :                         // put in the name of the variable for the column
    7117            0 :                         columnHead(columnRecount) = ort->MonthlyColumns(curCol).varName + curAggString + " [" + curUnits + ']';
    7118            0 :                         sumVal = 0.0;
    7119            0 :                         sumDuration = 0.0;
    7120            0 :                         minVal = storedMaxVal;
    7121            0 :                         maxVal = storedMinVal;
    7122            0 :                         for (lMonth = 1; lMonth <= 12; ++lMonth) {
    7123            0 :                             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            0 :                                 curVal = (ort->MonthlyColumns(curCol).reslt(lMonth) * curConversionFactor) + state.dataOutRptTab->curConversionOffset;
    7137            0 :                                 sumVal += curVal;
    7138              :                             }
    7139            0 :                             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            0 :                                 tableBody(columnRecount, lMonth) = "-";
    7149              :                             }
    7150              :                         } // lMonth
    7151              :                         // add the summary to bottom
    7152            0 :                         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            0 :                             tableBody(columnRecount, 14) = RealToStr(sumVal, digitsShown);
    7161              :                         }
    7162            0 :                         if (minVal != storedMaxVal) {
    7163            0 :                             tableBody(columnRecount, 15) = RealToStr(minVal, digitsShown);
    7164              :                         }
    7165            0 :                         if (maxVal != storedMinVal) {
    7166            0 :                             tableBody(columnRecount, 16) = RealToStr(maxVal, digitsShown);
    7167              :                         }
    7168            0 :                     } break;
    7169            0 :                     case AggType::HoursZero:
    7170              :                     case AggType::HoursNonZero:
    7171              :                     case AggType::HoursPositive:
    7172              :                     case AggType::HoursNonPositive:
    7173              :                     case AggType::HoursNegative:
    7174              :                     case AggType::HoursNonNegative: {
    7175            0 :                         ++columnRecount;
    7176              :                         // put in the name of the variable for the column
    7177            0 :                         columnHead(columnRecount) = ort->MonthlyColumns(curCol).varName + curAggString + " [HOURS]";
    7178            0 :                         sumVal = 0.0;
    7179            0 :                         minVal = storedMaxVal;
    7180            0 :                         maxVal = storedMinVal;
    7181            0 :                         for (lMonth = 1; lMonth <= 12; ++lMonth) {
    7182            0 :                             curVal = ort->MonthlyColumns(curCol).reslt(lMonth);
    7183            0 :                             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            0 :                                 tableBody(columnRecount, lMonth) = "-";
    7194              :                             }
    7195              :                         } // lMonth
    7196              :                         // add the summary to bottom
    7197            0 :                         tableBody(columnRecount, 14) = RealToStr(sumVal, digitsShown);
    7198            0 :                         if (minVal != storedMaxVal) {
    7199            0 :                             tableBody(columnRecount, 15) = RealToStr(minVal, digitsShown);
    7200              :                         }
    7201            0 :                         if (maxVal != storedMinVal) {
    7202            0 :                             tableBody(columnRecount, 16) = RealToStr(maxVal, digitsShown);
    7203              :                         }
    7204            0 :                     } break;
    7205            0 :                     case AggType::ValueWhenMaxMin: {
    7206            0 :                         ++columnRecount;
    7207            0 :                         if (ort->MonthlyColumns(curCol).avgSum == OutputProcessor::StoreType::Sum) {
    7208            0 :                             curUnits += "/s";
    7209              :                         }
    7210            0 :                         if (Util::SameString(curUnits, "J/s")) {
    7211            0 :                             curUnits = "W";
    7212              :                         }
    7213              :                         // CR7783 fix
    7214            0 :                         if (Util::SameString(curUnits, "kWh/s")) {
    7215            0 :                             curUnits = "W";
    7216            0 :                             curConversionFactor *= 3600000.0;
    7217              :                         }
    7218            0 :                         if (Util::SameString(curUnits, "GJ/s")) {
    7219            0 :                             curUnits = "kW";
    7220            0 :                             curConversionFactor *= 1000000.0;
    7221              :                         }
    7222            0 :                         if (Util::SameString(curUnits, "MJ/s")) {
    7223            0 :                             curUnits = "kW";
    7224            0 :                             curConversionFactor *= 1000.0;
    7225              :                         }
    7226            0 :                         if (Util::SameString(curUnits, "therm/s")) {
    7227            0 :                             curUnits = "kBtu/h";
    7228            0 :                             curConversionFactor *= 360000.0;
    7229              :                         }
    7230            0 :                         if (Util::SameString(curUnits, "kBtu/s")) {
    7231            0 :                             curUnits = "kBtu/h";
    7232            0 :                             curConversionFactor *= 3600.0;
    7233              :                         }
    7234            0 :                         if (Util::SameString(curUnits, "ton-hrs/s")) {
    7235            0 :                             curUnits = "ton";
    7236            0 :                             curConversionFactor *= 3600.0;
    7237              :                         }
    7238            0 :                         columnHead(columnRecount) = ort->MonthlyColumns(curCol).varName + curAggString + " [" + curUnits + ']';
    7239            0 :                         minVal = storedMaxVal;
    7240            0 :                         maxVal = storedMinVal;
    7241            0 :                         for (lMonth = 1; lMonth <= 12; ++lMonth) {
    7242            0 :                             curVal = ort->MonthlyColumns(curCol).reslt(lMonth) * curConversionFactor + state.dataOutRptTab->curConversionOffset;
    7243            0 :                             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            0 :                                 tableBody(columnRecount, lMonth) = "-";
    7253              :                             }
    7254              :                         } // lMonth
    7255              :                         // add the summary to bottom
    7256            0 :                         if (minVal != storedMaxVal) {
    7257            0 :                             tableBody(columnRecount, 15) = RealToStr(minVal, digitsShown);
    7258              :                         }
    7259            0 :                         if (maxVal != storedMinVal) {
    7260            0 :                             tableBody(columnRecount, 16) = RealToStr(maxVal, digitsShown);
    7261              :                         }
    7262            0 :                     } break;
    7263            5 :                     case AggType::Maximum:
    7264              :                     case AggType::Minimum:
    7265              :                     case AggType::MaximumDuringHoursShown:
    7266              :                     case AggType::MinimumDuringHoursShown: {
    7267            5 :                         columnRecount += 2;
    7268              :                         // put in the name of the variable for the column
    7269            5 :                         if (ort->MonthlyColumns(curCol).avgSum == OutputProcessor::StoreType::Sum) { // if it is a summed variable
    7270            5 :                             curUnits += "/s";
    7271              :                         }
    7272            5 :                         if (Util::SameString(curUnits, "J/s")) {
    7273            5 :                             curUnits = "W";
    7274              :                         }
    7275              :                         // CR7783 fix
    7276            5 :                         if (Util::SameString(curUnits, "kWh/s")) {
    7277            0 :                             curUnits = "W";
    7278            0 :                             curConversionFactor *= 3600000.0;
    7279              :                         }
    7280            5 :                         if (Util::SameString(curUnits, "GJ/s")) {
    7281            0 :                             curUnits = "kW";
    7282            0 :                             curConversionFactor *= 1000000.0;
    7283              :                         }
    7284            5 :                         if (Util::SameString(curUnits, "MJ/s")) {
    7285            0 :                             curUnits = "kW";
    7286            0 :                             curConversionFactor *= 1000.0;
    7287              :                         }
    7288            5 :                         if (Util::SameString(curUnits, "therm/s")) {
    7289            0 :                             curUnits = "kBtu/h";
    7290            0 :                             curConversionFactor *= 360000.0;
    7291              :                         }
    7292            5 :                         if (Util::SameString(curUnits, "kBtu/s")) {
    7293            0 :                             curUnits = "kBtu/h";
    7294            0 :                             curConversionFactor *= 3600.0;
    7295              :                         }
    7296            5 :                         if (Util::SameString(curUnits, "ton-hrs/s")) {
    7297            0 :                             curUnits = "ton";
    7298            0 :                             curConversionFactor *= 3600.0;
    7299              :                         }
    7300            5 :                         columnHead(columnRecount - 1) = ort->MonthlyColumns(curCol).varName + curAggString + " [" + curUnits + ']';
    7301            5 :                         columnHead(columnRecount) = ort->MonthlyColumns(curCol).varName + " {TIMESTAMP}";
    7302            5 :                         minVal = storedMaxVal;
    7303            5 :                         maxVal = storedMinVal;
    7304           65 :                         for (lMonth = 1; lMonth <= 12; ++lMonth) {
    7305           60 :                             if (ort->IsMonthGathered(lMonth)) {
    7306           60 :                                 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           60 :                                 if ((curVal < veryLarge) && (curVal > verySmall)) {
    7311           60 :                                     curVal = curVal * curConversionFactor + state.dataOutRptTab->curConversionOffset;
    7312           60 :                                     if (curVal > maxVal) {
    7313           12 :                                         maxVal = curVal;
    7314              :                                     }
    7315           60 :                                     if (curVal < minVal) {
    7316           22 :                                         minVal = curVal;
    7317              :                                     }
    7318           60 :                                     if (curVal < veryLarge && curVal > verySmall) {
    7319           60 :                                         tableBody(columnRecount - 1, lMonth) = RealToStr(curVal, digitsShown);
    7320              :                                     } else {
    7321            0 :                                         tableBody(columnRecount - 1, lMonth) = "-";
    7322              :                                     }
    7323           60 :                                     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            0 :                                 tableBody(columnRecount - 1, lMonth) = "-";
    7330            0 :                                 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            5 :                         if (minVal < veryLarge) {
    7336            5 :                             tableBody(columnRecount - 1, 15) = RealToStr(minVal, digitsShown);
    7337              :                         } else {
    7338            0 :                             tableBody(columnRecount - 1, 15) = "-";
    7339              :                         }
    7340            5 :                         if (maxVal > verySmall) {
    7341            5 :                             tableBody(columnRecount - 1, 16) = RealToStr(maxVal, digitsShown);
    7342              :                         } else {
    7343            0 :                             tableBody(columnRecount - 1, 15) = "-";
    7344              :                         }
    7345            5 :                     } break;
    7346            0 :                     default:
    7347            0 :                         break;
    7348              :                     }
    7349              :                 } // KColumn
    7350            5 :                 if (produceTabular) {
    7351            5 :                     WriteReportHeaders(
    7352            5 :                         state, ort->MonthlyInput(iInput).name, ort->MonthlyTables(curTable).keyValue, OutputProcessor::StoreType::Average);
    7353            5 :                     WriteSubtitle(state, "Custom Monthly Report");
    7354            5 :                     WriteTable(state, tableBody, rowHead, columnHead, columnWidth, true); // transpose monthly XML tables.
    7355              :                 }
    7356            5 :                 if (produceSQLite) {
    7357            5 :                     if (state.dataSQLiteProcedures->sqlite) {
    7358            0 :                         state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(tableBody,
    7359              :                                                                                            rowHead,
    7360              :                                                                                            columnHead,
    7361            0 :                                                                                            ort->MonthlyInput(iInput).name,
    7362            0 :                                                                                            ort->MonthlyTables(curTable).keyValue,
    7363              :                                                                                            "Custom Monthly Report");
    7364              :                     }
    7365              :                 }
    7366            5 :                 if (produceTabular) {
    7367            5 :                     if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
    7368           20 :                         state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(tableBody,
    7369              :                                                                                                               rowHead,
    7370              :                                                                                                               columnHead,
    7371            5 :                                                                                                               ort->MonthlyInput(iInput).name,
    7372            5 :                                                                                                               ort->MonthlyTables(curTable).keyValue,
    7373              :                                                                                                               "Custom Monthly Report");
    7374              :                     }
    7375              :                 }
    7376              :             } // jTables
    7377              :         } // iInput
    7378              :     }
    7379           12 : }
    7380              : 
    7381            6 : 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            6 :     Array1D_string columnHead;
    7401            6 :     Array1D_int columnWidth;
    7402            6 :     Array1D_string rowHead(39);
    7403            6 :     Array2D_string tableBody;
    7404              :     // stat table
    7405            6 :     Array1D_string columnHeadStat(1);
    7406            6 :     Array1D_int columnWidthStat(1);
    7407            6 :     Array1D_string rowHeadStat(6);
    7408            6 :     Array2D_string tableBodyStat(1, 6);
    7409              : 
    7410            6 :     std::string repNameWithUnitsandscheduleName;
    7411            6 :     std::string curNameWithSIUnits;
    7412            6 :     std::string curNameAndUnits;
    7413              : 
    7414            6 :     auto &ort = state.dataOutRptTab;
    7415              : 
    7416           12 :     for (int iUnitSystem = 0; iUnitSystem <= 1; iUnitSystem++) {
    7417           12 :         UnitsStyle unitsStyle_cur = ort->unitsStyle;
    7418           12 :         bool produceTabular = true;
    7419           12 :         bool produceSQLite = false;
    7420           12 :         if (produceDualUnitsFlags(iUnitSystem, ort->unitsStyle, ort->unitsStyle_SQLite, unitsStyle_cur, produceTabular, produceSQLite)) {
    7421            6 :             break;
    7422              :         }
    7423              : 
    7424            6 :         rowHead(1) = "Interval Start";
    7425            6 :         rowHead(2) = "Interval End";
    7426            6 :         rowHead(3) = "January";
    7427            6 :         rowHead(4) = "February";
    7428            6 :         rowHead(5) = "March";
    7429            6 :         rowHead(6) = "April";
    7430            6 :         rowHead(7) = "May";
    7431            6 :         rowHead(8) = "June";
    7432            6 :         rowHead(9) = "July";
    7433            6 :         rowHead(10) = "August";
    7434            6 :         rowHead(11) = "September";
    7435            6 :         rowHead(12) = "October";
    7436            6 :         rowHead(13) = "November";
    7437            6 :         rowHead(14) = "December";
    7438            6 :         rowHead(15) = "12:01 to  1:00 am";
    7439            6 :         rowHead(16) = " 1:01 to  2:00 am";
    7440            6 :         rowHead(17) = " 2:01 to  3:00 am";
    7441            6 :         rowHead(18) = " 3:01 to  4:00 am";
    7442            6 :         rowHead(19) = " 4:01 to  5:00 am";
    7443            6 :         rowHead(20) = " 5:01 to  6:00 am";
    7444            6 :         rowHead(21) = " 6:01 to  7:00 am";
    7445            6 :         rowHead(22) = " 7:01 to  8:00 am";
    7446            6 :         rowHead(23) = " 8:01 to  9:00 am";
    7447            6 :         rowHead(24) = " 9:01 to 10:00 am";
    7448            6 :         rowHead(25) = "10:01 to 11:00 am";
    7449            6 :         rowHead(26) = "11:01 to 12:00 pm";
    7450            6 :         rowHead(27) = "12:01 to  1:00 pm";
    7451            6 :         rowHead(28) = " 1:01 to  2:00 pm";
    7452            6 :         rowHead(29) = " 2:01 to  3:00 pm";
    7453            6 :         rowHead(30) = " 3:01 to  4:00 pm";
    7454            6 :         rowHead(31) = " 4:01 to  5:00 pm";
    7455            6 :         rowHead(32) = " 5:01 to  6:00 pm";
    7456            6 :         rowHead(33) = " 6:01 to  7:00 pm";
    7457            6 :         rowHead(34) = " 7:01 to  8:00 pm";
    7458            6 :         rowHead(35) = " 8:01 to  9:00 pm";
    7459            6 :         rowHead(36) = " 9:01 to 10:00 pm";
    7460            6 :         rowHead(37) = "10:01 to 11:00 pm";
    7461            6 :         rowHead(38) = "11:01 to 12:00 am";
    7462            6 :         rowHead(39) = "Total";
    7463              : 
    7464            6 :         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            6 : }
    7653              : 
    7654          759 : 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          759 :     int constexpr colElectricity(1);
    7675          759 :     int constexpr colGas(2);
    7676          759 :     int constexpr colGasoline(3);
    7677          759 :     int constexpr colDiesel(4);
    7678          759 :     int constexpr colCoal(5);
    7679          759 :     int constexpr colFuelOilNo1(6);
    7680          759 :     int constexpr colFuelOilNo2(7);
    7681          759 :     int constexpr colPropane(8);
    7682          759 :     int constexpr colOtherFuel1(9);
    7683          759 :     int constexpr colOtherFuel2(10);
    7684          759 :     int constexpr colPurchCool(11);
    7685          759 :     int constexpr colPurchHeatWtr(12);
    7686          759 :     int constexpr colPurchHeatSt(13);
    7687              : 
    7688          759 :     Real64 constexpr SmallValue(1.e-14);
    7689          759 :     auto &ort = state.dataOutRptTab;
    7690          759 :     auto &op = state.dataOutputProcessor;
    7691              : 
    7692          759 :     if (!ort->displayTabularBEPS && !ort->displayLEEDSummary) {
    7693            2 :         return;
    7694              :     }
    7695              : 
    7696              :     // all arrays are in the format: (row, column)
    7697          757 :     Array1D_string columnHead;
    7698          757 :     Array1D_int columnWidth;
    7699          757 :     Array1D_string rowHead;
    7700          757 :     Array2D_string tableBody;
    7701              : 
    7702          757 :     Array2D<Real64> useVal(14, 15);
    7703          757 :     Array2D<Real64> normalVal(14, 4);
    7704          757 :     Array1D<Real64> collapsedTotal(14);
    7705          757 :     Array2D<Real64> collapsedEndUse(14, static_cast<int>(Constant::EndUse::Num));
    7706          757 :     Array3D<Real64> collapsedEndUseSub(state.dataOutputProcessor->MaxNumSubcategories, static_cast<int>(Constant::EndUse::Num), 14);
    7707          757 :     Array2D<Real64> endUseSubOther(14, static_cast<int>(Constant::EndUse::Num));
    7708          757 :     Array3D<Real64> collapsedEndUseSpType(state.dataOutputProcessor->maxNumEndUseSpaceTypes, static_cast<int>(Constant::EndUse::Num), 14);
    7709              : 
    7710              :     // Jan 2021: Added temp storage
    7711          757 :     Real64 gtPowerFuelFireGen = ort->gatherPowerFuelFireGen;
    7712          757 :     Real64 gtPowerPV = ort->gatherPowerPV;
    7713          757 :     Real64 gtPowerWind = ort->gatherPowerWind;
    7714          757 :     Real64 gtPowerHTGeothermal = ort->gatherPowerHTGeothermal;
    7715          757 :     Real64 gtPowerConversion = ort->gatherPowerConversion;
    7716          757 :     Real64 gtElecProduced = ort->gatherElecProduced;
    7717          757 :     Real64 gtElecPUrchased = ort->gatherElecPurchased;
    7718          757 :     Real64 gtElecSurplusSold = ort->gatherElecSurplusSold;
    7719              : 
    7720          757 :     Real64 gtWaterHeatRecovery = ort->gatherWaterHeatRecovery;
    7721          757 :     Real64 gtAirHeatRecoveryCool = ort->gatherAirHeatRecoveryCool;
    7722          757 :     Real64 gtAirHeatRecoveryHeat = ort->gatherAirHeatRecoveryHeat;
    7723          757 :     Real64 gtHeatHTGeothermal = ort->gatherHeatHTGeothermal;
    7724          757 :     Real64 gtHeatSolarWater = ort->gatherHeatSolarWater;
    7725          757 :     Real64 gtHeatSolarAir = ort->gatherHeatSolarAir;
    7726              : 
    7727              :     // show the headers of the report
    7728          757 :     if (ort->displayTabularBEPS) {
    7729         2271 :         WriteReportHeaders(state, "Annual Building Utility Performance Summary", "Entire Facility", OutputProcessor::StoreType::Average);
    7730              :         // show the number of hours that the table applies to
    7731          757 :         WriteTextLine(state, "Values gathered over " + RealToStr(ort->gatherElapsedTimeBEPS, 2) + " hours", true);
    7732          757 :         if (ort->gatherElapsedTimeBEPS < 8759.0) { // might not add up to 8760 exactly but can't be more than 1 hour diff.
    7733         1502 :             WriteTextLine(state, "WARNING: THE REPORT DOES NOT REPRESENT A FULL ANNUAL SIMULATION.", true);
    7734              :         }
    7735         1514 :         WriteTextLine(state, "", true);
    7736              :     }
    7737              : 
    7738         1514 :     for (int iUnitSystem = 0; iUnitSystem <= 1; iUnitSystem++) {
    7739         1514 :         UnitsStyle unitsStyle_cur = ort->unitsStyle;
    7740         1514 :         bool produceTabular = true;
    7741         1514 :         bool produceSQLite = false;
    7742         1514 :         if (produceDualUnitsFlags(iUnitSystem, ort->unitsStyle, ort->unitsStyle_SQLite, unitsStyle_cur, produceTabular, produceSQLite)) {
    7743          757 :             break;
    7744              :         }
    7745              : 
    7746              :         // determine building floor areas
    7747          757 :         DetermineBuildingFloorArea(state);
    7748              :         // collapse the gatherEndUseBEPS array to the resource groups displayed
    7749        11355 :         for (int jEndUse = 1; jEndUse <= static_cast<int>(Constant::EndUse::Num); ++jEndUse) {
    7750        10598 :             collapsedEndUse(1, jEndUse) = ort->gatherEndUseBEPS(1, jEndUse);   // electricity
    7751        10598 :             collapsedEndUse(2, jEndUse) = ort->gatherEndUseBEPS(2, jEndUse);   // natural gas
    7752        10598 :             collapsedEndUse(3, jEndUse) = ort->gatherEndUseBEPS(6, jEndUse);   // gasoline
    7753        10598 :             collapsedEndUse(4, jEndUse) = ort->gatherEndUseBEPS(8, jEndUse);   // diesel
    7754        10598 :             collapsedEndUse(5, jEndUse) = ort->gatherEndUseBEPS(9, jEndUse);   // coal
    7755        10598 :             collapsedEndUse(6, jEndUse) = ort->gatherEndUseBEPS(10, jEndUse);  // Fuel Oil No1
    7756        10598 :             collapsedEndUse(7, jEndUse) = ort->gatherEndUseBEPS(11, jEndUse);  // Fuel Oil No2
    7757        10598 :             collapsedEndUse(8, jEndUse) = ort->gatherEndUseBEPS(12, jEndUse);  // propane
    7758        10598 :             collapsedEndUse(9, jEndUse) = ort->gatherEndUseBEPS(13, jEndUse);  // otherfuel1
    7759        10598 :             collapsedEndUse(10, jEndUse) = ort->gatherEndUseBEPS(14, jEndUse); // otherfuel2
    7760        10598 :             collapsedEndUse(11, jEndUse) = ort->gatherEndUseBEPS(3, jEndUse);  // district cooling <- purchased cooling
    7761        10598 :             collapsedEndUse(12, jEndUse) = ort->gatherEndUseBEPS(4, jEndUse);  // district heating water <- purchased heating
    7762        10598 :             collapsedEndUse(13, jEndUse) = ort->gatherEndUseBEPS(5, jEndUse);  // district heating steam  <- purchased heating
    7763        10598 :             collapsedEndUse(14, jEndUse) = ort->gatherEndUseBEPS(7, jEndUse);  // water
    7764              :         }
    7765              :         // repeat with totals
    7766          757 :         collapsedTotal(1) = ort->gatherTotalsBEPS(1);   // electricity
    7767          757 :         collapsedTotal(2) = ort->gatherTotalsBEPS(2);   // natural gas
    7768          757 :         collapsedTotal(3) = ort->gatherTotalsBEPS(6);   // gasoline
    7769          757 :         collapsedTotal(4) = ort->gatherTotalsBEPS(8);   // diesel
    7770          757 :         collapsedTotal(5) = ort->gatherTotalsBEPS(9);   // coal
    7771          757 :         collapsedTotal(6) = ort->gatherTotalsBEPS(10);  // Fuel Oil No1
    7772          757 :         collapsedTotal(7) = ort->gatherTotalsBEPS(11);  // Fuel Oil No2
    7773          757 :         collapsedTotal(8) = ort->gatherTotalsBEPS(12);  // propane
    7774          757 :         collapsedTotal(9) = ort->gatherTotalsBEPS(13);  // other fuel 1
    7775          757 :         collapsedTotal(10) = ort->gatherTotalsBEPS(14); // other fuel 2
    7776          757 :         collapsedTotal(11) = ort->gatherTotalsBEPS(3);  // district cooling <- purchased cooling
    7777          757 :         collapsedTotal(12) = ort->gatherTotalsBEPS(4);  // district heating water <- purchased heating
    7778          757 :         collapsedTotal(13) = ort->gatherTotalsBEPS(5);  // district heating steam  <- purchased heating
    7779          757 :         collapsedTotal(14) = ort->gatherTotalsBEPS(7);  // water
    7780              : 
    7781          757 :         if (produceTabular) {
    7782          757 :             if (state.dataGlobal->createPerfLog) {
    7783           15 :                 Util::appendPerfLog(state, "Electricity ABUPS Total [J]", format("{:.3R}", collapsedTotal(1)));
    7784           15 :                 Util::appendPerfLog(state, "Natural Gas ABUPS Total [J]", format("{:.3R}", collapsedTotal(2)));
    7785           15 :                 Util::appendPerfLog(state, "Gasoline ABUPS Total [J]", format("{:.3R}", collapsedTotal(3)));
    7786           15 :                 Util::appendPerfLog(state, "Diesel ABUPS Total [J]", format("{:.3R}", collapsedTotal(4)));
    7787           15 :                 Util::appendPerfLog(state, "Coal ABUPS Total [J]", format("{:.3R}", collapsedTotal(5)));
    7788           15 :                 Util::appendPerfLog(state, "Fuel Oil No 1 ABUPS Total [J]", format("{:.3R}", collapsedTotal(6)));
    7789           15 :                 Util::appendPerfLog(state, "Fuel Oil No 2 ABUPS Total [J]", format("{:.3R}", collapsedTotal(7)));
    7790           15 :                 Util::appendPerfLog(state, "Propane ABUPS Total [J]", format("{:.3R}", collapsedTotal(8)));
    7791           15 :                 Util::appendPerfLog(state, "Other Fuel 1 ABUPS Total [J]", format("{:.3R}", collapsedTotal(9)));
    7792           15 :                 Util::appendPerfLog(state, "Other Fuel 2 ABUPS Total [J]", format("{:.3R}", collapsedTotal(10)));
    7793           15 :                 Util::appendPerfLog(state, "District Cooling ABUPS Total [J]", format("{:.3R}", collapsedTotal(11)));
    7794           15 :                 Util::appendPerfLog(state, "District Heating Water ABUPS Total [J]", format("{:.3R}", collapsedTotal(12)));
    7795           15 :                 Util::appendPerfLog(state, "District Heating Steam ABUPS Total [J]", format("{:.3R}", collapsedTotal(13)));
    7796           15 :                 Util::appendPerfLog(state, "Water ABUPS Total [m3]", format("{:.3R}", collapsedTotal(14)));
    7797           15 :                 Util::appendPerfLog(state, "Values Gathered Over [hours]", format("{:.2R}", ort->gatherElapsedTimeBEPS));
    7798            5 :                 Util::appendPerfLog(state,
    7799              :                                     "Facility Any Zone Oscillating Temperatures Time [hours]",
    7800           10 :                                     format("{:.2R}", state.dataZoneTempPredictorCorrector->AnnualAnyZoneTempOscillate));
    7801            5 :                 Util::appendPerfLog(state,
    7802              :                                     "Facility Any Zone Oscillating Temperatures During Occupancy Time [hours]",
    7803           10 :                                     format("{:.2R}", state.dataZoneTempPredictorCorrector->AnnualAnyZoneTempOscillateDuringOccupancy));
    7804            5 :                 Util::appendPerfLog(state,
    7805              :                                     "Facility Any Zone Oscillating Temperatures in Deadband Time [hours]",
    7806           10 :                                     format("{:.2R}", state.dataZoneTempPredictorCorrector->AnnualAnyZoneTempOscillateInDeadband));
    7807              :             }
    7808              :         }
    7809        11355 :         for (int jEndUse = 1; jEndUse <= static_cast<int>(Constant::EndUse::Num); ++jEndUse) {
    7810        16914 :             for (int kEndUseSub = 1; kEndUseSub <= op->EndUseCategory(jEndUse).NumSubcategories; ++kEndUseSub) {
    7811         6316 :                 collapsedEndUseSub(kEndUseSub, jEndUse, 1) = ort->gatherEndUseSubBEPS(kEndUseSub, jEndUse, 1);   // electricity
    7812         6316 :                 collapsedEndUseSub(kEndUseSub, jEndUse, 2) = ort->gatherEndUseSubBEPS(kEndUseSub, jEndUse, 2);   // natural gas
    7813         6316 :                 collapsedEndUseSub(kEndUseSub, jEndUse, 3) = ort->gatherEndUseSubBEPS(kEndUseSub, jEndUse, 6);   // gasoline
    7814         6316 :                 collapsedEndUseSub(kEndUseSub, jEndUse, 4) = ort->gatherEndUseSubBEPS(kEndUseSub, jEndUse, 8);   // diesel
    7815         6316 :                 collapsedEndUseSub(kEndUseSub, jEndUse, 5) = ort->gatherEndUseSubBEPS(kEndUseSub, jEndUse, 9);   // coal
    7816         6316 :                 collapsedEndUseSub(kEndUseSub, jEndUse, 6) = ort->gatherEndUseSubBEPS(kEndUseSub, jEndUse, 10);  // Fuel Oil No1
    7817         6316 :                 collapsedEndUseSub(kEndUseSub, jEndUse, 7) = ort->gatherEndUseSubBEPS(kEndUseSub, jEndUse, 11);  // Fuel Oil No2
    7818         6316 :                 collapsedEndUseSub(kEndUseSub, jEndUse, 8) = ort->gatherEndUseSubBEPS(kEndUseSub, jEndUse, 12);  // propane
    7819         6316 :                 collapsedEndUseSub(kEndUseSub, jEndUse, 9) = ort->gatherEndUseSubBEPS(kEndUseSub, jEndUse, 13);  // otherfuel1
    7820         6316 :                 collapsedEndUseSub(kEndUseSub, jEndUse, 10) = ort->gatherEndUseSubBEPS(kEndUseSub, jEndUse, 14); // otherfuel2
    7821         6316 :                 collapsedEndUseSub(kEndUseSub, jEndUse, 11) = ort->gatherEndUseSubBEPS(kEndUseSub, jEndUse, 3);  // district cooling <- purch cooling
    7822        12632 :                 collapsedEndUseSub(kEndUseSub, jEndUse, 12) =
    7823         6316 :                     ort->gatherEndUseSubBEPS(kEndUseSub, jEndUse, 4); // district heating water <- purch heating
    7824        12632 :                 collapsedEndUseSub(kEndUseSub, jEndUse, 13) =
    7825         6316 :                     ort->gatherEndUseSubBEPS(kEndUseSub, jEndUse, 5); // district heating steam <- purch heating
    7826         6316 :                 collapsedEndUseSub(kEndUseSub, jEndUse, 14) = ort->gatherEndUseSubBEPS(kEndUseSub, jEndUse, 7); // water
    7827              :             }
    7828              : 
    7829        11917 :             for (int kEndUseSpType = 1; kEndUseSpType <= op->EndUseCategory(jEndUse).numSpaceTypes; ++kEndUseSpType) {
    7830         1319 :                 collapsedEndUseSpType(kEndUseSpType, jEndUse, 1) = ort->gatherEndUseSpTypeBEPS(kEndUseSpType, jEndUse, 1);   // electricity
    7831         1319 :                 collapsedEndUseSpType(kEndUseSpType, jEndUse, 2) = ort->gatherEndUseSpTypeBEPS(kEndUseSpType, jEndUse, 2);   // natural gas
    7832         1319 :                 collapsedEndUseSpType(kEndUseSpType, jEndUse, 3) = ort->gatherEndUseSpTypeBEPS(kEndUseSpType, jEndUse, 6);   // gasoline
    7833         1319 :                 collapsedEndUseSpType(kEndUseSpType, jEndUse, 4) = ort->gatherEndUseSpTypeBEPS(kEndUseSpType, jEndUse, 8);   // diesel
    7834         1319 :                 collapsedEndUseSpType(kEndUseSpType, jEndUse, 5) = ort->gatherEndUseSpTypeBEPS(kEndUseSpType, jEndUse, 9);   // coal
    7835         1319 :                 collapsedEndUseSpType(kEndUseSpType, jEndUse, 6) = ort->gatherEndUseSpTypeBEPS(kEndUseSpType, jEndUse, 10);  // Fuel Oil No1
    7836         1319 :                 collapsedEndUseSpType(kEndUseSpType, jEndUse, 7) = ort->gatherEndUseSpTypeBEPS(kEndUseSpType, jEndUse, 11);  // Fuel Oil No2
    7837         1319 :                 collapsedEndUseSpType(kEndUseSpType, jEndUse, 8) = ort->gatherEndUseSpTypeBEPS(kEndUseSpType, jEndUse, 12);  // propane
    7838         1319 :                 collapsedEndUseSpType(kEndUseSpType, jEndUse, 9) = ort->gatherEndUseSpTypeBEPS(kEndUseSpType, jEndUse, 13);  // otherfuel1
    7839         1319 :                 collapsedEndUseSpType(kEndUseSpType, jEndUse, 10) = ort->gatherEndUseSpTypeBEPS(kEndUseSpType, jEndUse, 14); // otherfuel2
    7840         2638 :                 collapsedEndUseSpType(kEndUseSpType, jEndUse, 11) =
    7841         1319 :                     ort->gatherEndUseSpTypeBEPS(kEndUseSpType, jEndUse, 3); // district cooling <- purch cooling
    7842         2638 :                 collapsedEndUseSpType(kEndUseSpType, jEndUse, 12) =
    7843         1319 :                     ort->gatherEndUseSpTypeBEPS(kEndUseSpType, jEndUse, 4); // district heating water <- purch heating
    7844         2638 :                 collapsedEndUseSpType(kEndUseSpType, jEndUse, 13) =
    7845         1319 :                     ort->gatherEndUseSpTypeBEPS(kEndUseSpType, jEndUse, 5); // district heating steam <- purch heating
    7846         1319 :                 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          757 :         Real64 ipElectricityConversionFactor = 1.0;
    7855          757 :         switch (unitsStyle_cur) {
    7856            6 :         case UnitsStyle::JtoKWH: {
    7857            6 :             largeConversionFactor = 3600000.0;
    7858            6 :             kConversionFactor = 1.0;
    7859            6 :             waterConversionFactor = 1.0;
    7860            6 :             areaConversionFactor = 1.0;
    7861            6 :         } break;
    7862           11 :         case UnitsStyle::InchPound: {
    7863           33 :             largeConversionFactor = getSpecificUnitDivider(state, "J", "kBtu"); // 1054351.84 J to kBtu
    7864           11 :             kConversionFactor = 1.0;
    7865           44 :             waterConversionFactor = getSpecificUnitDivider(state, "m3", "gal"); // 0.003785413 m3 to gal
    7866           33 :             areaConversionFactor = getSpecificUnitDivider(state, "m2", "ft2");  // 0.092893973 m2 to ft2
    7867           11 :         } break;
    7868            0 :         case UnitsStyle::InchPoundExceptElectricity: {
    7869            0 :             largeConversionFactor = getSpecificUnitDivider(state, "J", "kBtu"); // 1054351.84 J to kBtu
    7870            0 :             kConversionFactor = 1.0;
    7871            0 :             waterConversionFactor = getSpecificUnitDivider(state, "m3", "gal"); // 0.003785413 m3 to gal
    7872            0 :             areaConversionFactor = getSpecificUnitDivider(state, "m2", "ft2");  // 0.092893973 m2 to ft2
    7873            0 :             ipElectricityConversionFactor = largeConversionFactor / (1000.0 * 3600.0);
    7874            0 :         } break;
    7875          740 :         default: {
    7876          740 :             largeConversionFactor = 1000000000.0;
    7877          740 :             kConversionFactor = 1000.0;
    7878          740 :             waterConversionFactor = 1.0;
    7879          740 :             areaConversionFactor = 1.0;
    7880          740 :         } break;
    7881              :         }
    7882              : 
    7883              :         // convert units into GJ (divide by 1,000,000,000) if J otherwise kWh
    7884        10598 :         for (int iResource = 1; iResource <= 13; ++iResource) { // don't do water
    7885         9841 :             Real64 ipElectricityAdjust = (iResource == 1) ? ipElectricityConversionFactor : 1.0;
    7886       147615 :             for (int jEndUse = 1; jEndUse <= static_cast<int>(Constant::EndUse::Num); ++jEndUse) {
    7887       137774 :                 collapsedEndUse(iResource, jEndUse) /= (largeConversionFactor / ipElectricityAdjust);
    7888       219882 :                 for (int kEndUseSub = 1; kEndUseSub <= op->EndUseCategory(jEndUse).NumSubcategories; ++kEndUseSub) {
    7889        82108 :                     collapsedEndUseSub(kEndUseSub, jEndUse, iResource) /= (largeConversionFactor / ipElectricityAdjust);
    7890              :                 }
    7891       154921 :                 for (int kEndUseSpType = 1; kEndUseSpType <= op->EndUseCategory(jEndUse).numSpaceTypes; ++kEndUseSpType) {
    7892        17147 :                     collapsedEndUseSpType(kEndUseSpType, jEndUse, iResource) /= (largeConversionFactor / ipElectricityAdjust);
    7893              :                 }
    7894              :             }
    7895         9841 :             collapsedTotal(iResource) /= (largeConversionFactor / ipElectricityAdjust);
    7896              :         }
    7897              :         // do water
    7898        11355 :         for (int jEndUse = 1; jEndUse <= static_cast<int>(Constant::EndUse::Num); ++jEndUse) {
    7899        10598 :             collapsedEndUse(14, jEndUse) /= waterConversionFactor;
    7900        16914 :             for (int kEndUseSub = 1; kEndUseSub <= state.dataOutputProcessor->EndUseCategory(jEndUse).NumSubcategories; ++kEndUseSub) {
    7901         6316 :                 collapsedEndUseSub(kEndUseSub, jEndUse, 14) /= waterConversionFactor;
    7902              :             }
    7903        11917 :             for (int kEndUseSpType = 1; kEndUseSpType <= state.dataOutputProcessor->EndUseCategory(jEndUse).numSpaceTypes; ++kEndUseSpType) {
    7904         1319 :                 collapsedEndUseSpType(kEndUseSpType, jEndUse, 14) /= waterConversionFactor;
    7905              :             }
    7906              :         }
    7907              : 
    7908          757 :         collapsedTotal(14) = WaterConversionFunct(collapsedTotal(14), waterConversionFactor);
    7909              : 
    7910          757 :         if (iUnitSystem == 0) {
    7911          757 :             gtPowerFuelFireGen = ort->gatherPowerFuelFireGen;
    7912          757 :             gtPowerPV = ort->gatherPowerPV;
    7913          757 :             gtPowerWind = ort->gatherPowerWind;
    7914          757 :             gtPowerHTGeothermal = ort->gatherPowerHTGeothermal;
    7915          757 :             gtPowerConversion = ort->gatherPowerConversion;
    7916          757 :             gtElecProduced = ort->gatherElecProduced;
    7917          757 :             gtElecPUrchased = ort->gatherElecPurchased;
    7918          757 :             gtElecSurplusSold = ort->gatherElecSurplusSold;
    7919              :         } else { // if(iUnitSystem == 1)
    7920            0 :             ort->gatherPowerFuelFireGen = gtPowerFuelFireGen;
    7921            0 :             ort->gatherPowerPV = gtPowerPV;
    7922            0 :             ort->gatherPowerWind = gtPowerWind;
    7923            0 :             ort->gatherPowerHTGeothermal = gtPowerHTGeothermal;
    7924            0 :             ort->gatherPowerConversion = gtPowerConversion;
    7925            0 :             ort->gatherElecProduced = gtElecProduced;
    7926            0 :             ort->gatherElecPurchased = gtElecPUrchased;
    7927            0 :             ort->gatherElecSurplusSold = gtElecSurplusSold;
    7928              :         }
    7929              :         // convert to GJ
    7930          757 :         Real64 convFactorMulti = ipElectricityConversionFactor / largeConversionFactor;
    7931          757 :         ort->gatherPowerFuelFireGen *= convFactorMulti;
    7932          757 :         ort->gatherPowerPV *= convFactorMulti;
    7933          757 :         ort->gatherPowerWind *= convFactorMulti;
    7934          757 :         ort->gatherPowerHTGeothermal *= convFactorMulti;
    7935          757 :         ort->gatherPowerConversion *= convFactorMulti;
    7936          757 :         ort->gatherElecProduced *= convFactorMulti;
    7937          757 :         ort->gatherElecPurchased *= convFactorMulti;
    7938          757 :         ort->gatherElecSurplusSold *= convFactorMulti;
    7939              : 
    7940              :         // get change in overall state of charge for electrical storage devices.
    7941          757 :         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            9 :             ort->OverallNetEnergyFromStorage = ort->gatherElecStorage;
    7946            9 :             ort->OverallNetEnergyFromStorage *= convFactorMulti;
    7947              :         } else {
    7948          748 :             ort->OverallNetEnergyFromStorage = 0.0;
    7949              :         }
    7950              :         // determine which resource is the primary heating resource
    7951          757 :         int resourcePrimaryHeating = 0;
    7952          757 :         Real64 heatingMaximum = 0.0;
    7953        10598 :         for (int iResource = 1; iResource <= 13; ++iResource) { // don't do water
    7954         9841 :             if (collapsedEndUse(iResource, static_cast<int>(Constant::EndUse::Heating) + 1) > heatingMaximum) {
    7955            7 :                 heatingMaximum = collapsedEndUse(iResource, static_cast<int>(Constant::EndUse::Heating) + 1); // +1 because enum is 0-based
    7956            7 :                 resourcePrimaryHeating = iResource;
    7957              :             }
    7958              :         }
    7959              : 
    7960              :         //---- Source and Site Energy Sub-Table
    7961          757 :         rowHead.allocate(4);
    7962          757 :         columnHead.allocate(3);
    7963          757 :         columnWidth.allocate(3);
    7964          757 :         columnWidth = 14; // array assignment - same for all columns
    7965          757 :         tableBody.allocate(3, 4);
    7966              : 
    7967          757 :         switch (unitsStyle_cur) {
    7968            6 :         case UnitsStyle::JtoKWH: {
    7969            6 :             columnHead(1) = "Total Energy [kWh]";
    7970            6 :             columnHead(2) = "Energy Per Total Building Area [kWh/m2]";
    7971            6 :             columnHead(3) = "Energy Per Conditioned Building Area [kWh/m2]";
    7972            6 :         } break;
    7973           11 :         case UnitsStyle::InchPound: {
    7974           11 :             columnHead(1) = "Total Energy [kBtu]";
    7975           11 :             columnHead(2) = "Energy Per Total Building Area [kBtu/ft2]";
    7976           11 :             columnHead(3) = "Energy Per Conditioned Building Area [kBtu/ft2]";
    7977           11 :         } break;
    7978            0 :         case UnitsStyle::InchPoundExceptElectricity: {
    7979            0 :             columnHead(1) = "Total Energy [kBtu]";
    7980            0 :             columnHead(2) = "Energy Per Total Building Area [kBtu/ft2]";
    7981            0 :             columnHead(3) = "Energy Per Conditioned Building Area [kBtu/ft2]";
    7982            0 :         } break;
    7983          740 :         default: {
    7984          740 :             columnHead(1) = "Total Energy [GJ]";
    7985          740 :             columnHead(2) = "Energy Per Total Building Area [MJ/m2]";
    7986          740 :             columnHead(3) = "Energy Per Conditioned Building Area [MJ/m2]";
    7987          740 :         } break;
    7988              :         }
    7989              : 
    7990          757 :         rowHead(1) = "Total Site Energy";
    7991          757 :         rowHead(2) = "Net Site Energy";
    7992          757 :         rowHead(3) = "Total Source Energy";
    7993          757 :         rowHead(4) = "Net Source Energy";
    7994              : 
    7995          757 :         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          757 :             (ort->gatherTotalsBEPS(1) + ort->gatherTotalsBEPS(2) + ort->gatherTotalsBEPS(3) + ort->gatherTotalsBEPS(4) + ort->gatherTotalsBEPS(5) +
    8004          757 :              ort->gatherTotalsBEPS(6) + ort->gatherTotalsBEPS(8) + ort->gatherTotalsBEPS(9) + ort->gatherTotalsBEPS(10) + ort->gatherTotalsBEPS(11) +
    8005          757 :              ort->gatherTotalsBEPS(12) + ort->gatherTotalsBEPS(13) + ort->gatherTotalsBEPS(14)) /
    8006          757 :             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          757 :         Real64 const netElecPurchasedSold = ort->gatherElecPurchased - ort->gatherElecSurplusSold;
    8010              : 
    8011              :         // water is not included   gatherTotalsBEPS(7)    !water
    8012              :         Real64 const netSiteEnergyUse =
    8013          757 :             netElecPurchasedSold + (ort->gatherTotalsBEPS(2) + ort->gatherTotalsBEPS(3) + ort->gatherTotalsBEPS(4) + ort->gatherTotalsBEPS(5) +
    8014          757 :                                     ort->gatherTotalsBEPS(6) + ort->gatherTotalsBEPS(8) + ort->gatherTotalsBEPS(9) + ort->gatherTotalsBEPS(10) +
    8015          757 :                                     ort->gatherTotalsBEPS(11) + ort->gatherTotalsBEPS(12) + ort->gatherTotalsBEPS(13) + ort->gatherTotalsBEPS(14)) /
    8016          757 :                                        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          757 :         if (ort->efficiencyDistrictCooling == 0) {
    8021            0 :             ort->efficiencyDistrictCooling = 1.0;
    8022              :         }
    8023          757 :         if (ort->efficiencyDistrictHeatingWater == 0) {
    8024            0 :             ort->efficiencyDistrictHeatingWater = 1.0;
    8025              :         }
    8026              : 
    8027              :         // source emissions already have the source factors included in the calcs.
    8028          757 :         Real64 totalSourceEnergyUse = 0.0;
    8029              :         //  electricity
    8030          757 :         if (ort->fuelfactorsused(1)) {
    8031           87 :             totalSourceEnergyUse += ort->gatherTotalsSource(1);
    8032              :         } else {
    8033          670 :             totalSourceEnergyUse += ort->gatherTotalsBEPS(1) * ort->sourceFactorElectric;
    8034              :         }
    8035              :         //  natural gas
    8036          757 :         if (ort->fuelfactorsused(2)) {
    8037           78 :             totalSourceEnergyUse += ort->gatherTotalsSource(2);
    8038              :         } else {
    8039          679 :             totalSourceEnergyUse += ort->gatherTotalsBEPS(2) * ort->sourceFactorNaturalGas;
    8040              :         }
    8041              :         // gasoline
    8042          757 :         if (ort->fuelfactorsused(3)) {
    8043            0 :             totalSourceEnergyUse += ort->gatherTotalsSource(3);
    8044              :         } else {
    8045          757 :             totalSourceEnergyUse += ort->gatherTotalsBEPS(6) * ort->sourceFactorGasoline;
    8046              :         }
    8047              :         // diesel
    8048          757 :         if (ort->fuelfactorsused(4)) {
    8049            2 :             totalSourceEnergyUse += ort->gatherTotalsSource(4);
    8050              :         } else {
    8051          755 :             totalSourceEnergyUse += ort->gatherTotalsBEPS(8) * ort->sourceFactorDiesel;
    8052              :         }
    8053              :         // coal
    8054          757 :         if (ort->fuelfactorsused(5)) {
    8055            0 :             totalSourceEnergyUse += ort->gatherTotalsSource(5);
    8056              :         } else {
    8057          757 :             totalSourceEnergyUse += ort->gatherTotalsBEPS(9) * ort->sourceFactorCoal;
    8058              :         }
    8059              :         // Fuel Oil No1
    8060          757 :         if (ort->fuelfactorsused(6)) {
    8061           22 :             totalSourceEnergyUse += ort->gatherTotalsSource(6);
    8062              :         } else {
    8063          735 :             totalSourceEnergyUse += ort->gatherTotalsBEPS(10) * ort->sourceFactorFuelOil1;
    8064              :         }
    8065              :         // Fuel Oil No2
    8066          757 :         if (ort->fuelfactorsused(7)) {
    8067            0 :             totalSourceEnergyUse += ort->gatherTotalsSource(7);
    8068              :         } else {
    8069          757 :             totalSourceEnergyUse += ort->gatherTotalsBEPS(11) * ort->sourceFactorFuelOil2;
    8070              :         }
    8071              :         // propane
    8072          757 :         if (ort->fuelfactorsused(8)) {
    8073           22 :             totalSourceEnergyUse += ort->gatherTotalsSource(8);
    8074              :         } else {
    8075          735 :             totalSourceEnergyUse += ort->gatherTotalsBEPS(12) * ort->sourceFactorPropane;
    8076              :         }
    8077              :         // otherfuel1
    8078          757 :         if (ort->fuelfactorsused(11)) {
    8079            1 :             totalSourceEnergyUse += ort->gatherTotalsSource(11);
    8080              :         } else {
    8081          756 :             totalSourceEnergyUse += ort->gatherTotalsBEPS(13) * ort->sourceFactorOtherFuel1;
    8082              :         }
    8083              :         // otherfuel2
    8084          757 :         if (ort->fuelfactorsused(12)) {
    8085            0 :             totalSourceEnergyUse += ort->gatherTotalsSource(12);
    8086              :         } else {
    8087          757 :             totalSourceEnergyUse += ort->gatherTotalsBEPS(14) * ort->sourceFactorOtherFuel2;
    8088              :         }
    8089              : 
    8090          757 :         totalSourceEnergyUse = (totalSourceEnergyUse + ort->gatherTotalsBEPS(3) * ort->sourceFactorElectric / ort->efficiencyDistrictCooling +
    8091          757 :                                 ort->gatherTotalsBEPS(4) * ort->sourceFactorNaturalGas / ort->efficiencyDistrictHeatingWater +
    8092          757 :                                 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          757 :         if (ort->fuelfactorsused(1)) {
    8099           87 :             netSourceElecPurchasedSold = ort->gatherTotalsSource(9) - ort->gatherTotalsSource(10);
    8100              :         } else {
    8101          670 :             netSourceElecPurchasedSold = netElecPurchasedSold * ort->sourceFactorElectric * largeConversionFactor; // back to J
    8102              :         }
    8103              : 
    8104          757 :         Real64 netSourceEnergyUse = 0.0;
    8105              :         //  natural gas
    8106          757 :         if (ort->fuelfactorsused(2)) {
    8107           78 :             netSourceEnergyUse += ort->gatherTotalsSource(2);
    8108              :         } else {
    8109          679 :             netSourceEnergyUse += ort->gatherTotalsBEPS(2) * ort->sourceFactorNaturalGas;
    8110              :         }
    8111              :         // gasoline
    8112          757 :         if (ort->fuelfactorsused(3)) {
    8113            0 :             netSourceEnergyUse += ort->gatherTotalsSource(3);
    8114              :         } else {
    8115          757 :             netSourceEnergyUse += ort->gatherTotalsBEPS(6) * ort->sourceFactorGasoline;
    8116              :         }
    8117              :         // diesel
    8118          757 :         if (ort->fuelfactorsused(4)) {
    8119            2 :             netSourceEnergyUse += ort->gatherTotalsSource(4);
    8120              :         } else {
    8121          755 :             netSourceEnergyUse += ort->gatherTotalsBEPS(8) * ort->sourceFactorDiesel;
    8122              :         }
    8123              :         // coal
    8124          757 :         if (ort->fuelfactorsused(5)) {
    8125            0 :             netSourceEnergyUse += ort->gatherTotalsSource(5);
    8126              :         } else {
    8127          757 :             netSourceEnergyUse += ort->gatherTotalsBEPS(9) * ort->sourceFactorCoal;
    8128              :         }
    8129              :         // Fuel Oil No1
    8130          757 :         if (ort->fuelfactorsused(6)) {
    8131           22 :             netSourceEnergyUse += ort->gatherTotalsSource(6);
    8132              :         } else {
    8133          735 :             netSourceEnergyUse += ort->gatherTotalsBEPS(10) * ort->sourceFactorFuelOil1;
    8134              :         }
    8135              :         // Fuel Oil No2
    8136          757 :         if (ort->fuelfactorsused(7)) {
    8137            0 :             netSourceEnergyUse += ort->gatherTotalsSource(7);
    8138              :         } else {
    8139          757 :             netSourceEnergyUse += ort->gatherTotalsBEPS(11) * ort->sourceFactorFuelOil2;
    8140              :         }
    8141              :         // propane
    8142          757 :         if (ort->fuelfactorsused(8)) {
    8143           22 :             netSourceEnergyUse += ort->gatherTotalsSource(8);
    8144              :         } else {
    8145          735 :             netSourceEnergyUse += ort->gatherTotalsBEPS(12) * ort->sourceFactorPropane;
    8146              :         }
    8147              :         // otherfuel1
    8148          757 :         if (ort->fuelfactorsused(11)) {
    8149            1 :             netSourceEnergyUse += ort->gatherTotalsSource(11);
    8150              :         } else {
    8151          756 :             netSourceEnergyUse += ort->gatherTotalsBEPS(13) * ort->sourceFactorOtherFuel1;
    8152              :         }
    8153              :         // otherfuel2
    8154          757 :         if (ort->fuelfactorsused(12)) {
    8155            0 :             netSourceEnergyUse += ort->gatherTotalsSource(12);
    8156              :         } else {
    8157          757 :             netSourceEnergyUse += ort->gatherTotalsBEPS(14) * ort->sourceFactorOtherFuel2;
    8158              :         }
    8159              : 
    8160          757 :         netSourceEnergyUse =
    8161          757 :             (netSourceEnergyUse + netSourceElecPurchasedSold + ort->gatherTotalsBEPS(3) * ort->sourceFactorElectric / ort->efficiencyDistrictCooling +
    8162          757 :              ort->gatherTotalsBEPS(4) * ort->sourceFactorNaturalGas / ort->efficiencyDistrictHeatingWater +
    8163          757 :              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          757 :         tableBody(1, 1) = RealToStr(totalSiteEnergyUse, 2);
    8169          757 :         tableBody(1, 2) = RealToStr(netSiteEnergyUse, 2);
    8170          757 :         tableBody(1, 3) = RealToStr(totalSourceEnergyUse, 2);
    8171          757 :         tableBody(1, 4) = RealToStr(netSourceEnergyUse, 2);
    8172              : 
    8173              :         // convert floor areas
    8174          757 :         Real64 const convBldgGrossFloorArea = ort->buildingGrossFloorArea / areaConversionFactor;
    8175          757 :         Real64 const convBldgCondFloorArea = ort->buildingConditionedFloorArea / areaConversionFactor;
    8176              : 
    8177              :         // show  per building area
    8178          757 :         if (convBldgGrossFloorArea > 0) {
    8179          728 :             tableBody(2, 1) = RealToStr(totalSiteEnergyUse * kConversionFactor / convBldgGrossFloorArea, 2);
    8180          728 :             tableBody(2, 2) = RealToStr(netSiteEnergyUse * kConversionFactor / convBldgGrossFloorArea, 2);
    8181          728 :             tableBody(2, 3) = RealToStr(totalSourceEnergyUse * kConversionFactor / convBldgGrossFloorArea, 2);
    8182          728 :             tableBody(2, 4) = RealToStr(netSourceEnergyUse * kConversionFactor / convBldgGrossFloorArea, 2);
    8183              :         }
    8184              :         // show  per conditioned building area
    8185          757 :         if (convBldgCondFloorArea > 0) {
    8186          675 :             tableBody(3, 1) = RealToStr(totalSiteEnergyUse * kConversionFactor / convBldgCondFloorArea, 2);
    8187          675 :             tableBody(3, 2) = RealToStr(netSiteEnergyUse * kConversionFactor / convBldgCondFloorArea, 2);
    8188          675 :             tableBody(3, 3) = RealToStr(totalSourceEnergyUse * kConversionFactor / convBldgCondFloorArea, 2);
    8189          675 :             tableBody(3, 4) = RealToStr(netSourceEnergyUse * kConversionFactor / convBldgCondFloorArea, 2);
    8190              :         }
    8191              : 
    8192              :         // heading for the entire sub-table
    8193          757 :         if (ort->displayTabularBEPS) {
    8194          757 :             if (produceTabular) {
    8195          757 :                 WriteSubtitle(state, "Site and Source Energy");
    8196          757 :                 WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
    8197              :             }
    8198          757 :             if (produceSQLite) {
    8199          757 :                 if (state.dataSQLiteProcedures->sqlite) {
    8200          123 :                     state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
    8201              :                         tableBody, rowHead, columnHead, "AnnualBuildingUtilityPerformanceSummary", "Entire Facility", "Site and Source Energy");
    8202              :                 }
    8203              :             }
    8204          757 :             if (produceTabular) {
    8205          757 :                 if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
    8206           63 :                     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          757 :         rowHead.allocate(13);
    8214          757 :         columnHead.allocate(1);
    8215          757 :         columnWidth.allocate(1);
    8216          757 :         columnWidth = 50; // array assignment
    8217          757 :         tableBody.allocate(1, 13);
    8218              : 
    8219          757 :         columnHead(1) = "Site=>Source Conversion Factor";
    8220              : 
    8221          757 :         rowHead(1) = "Electricity";
    8222          757 :         rowHead(2) = "Natural Gas";
    8223          757 :         rowHead(3) = "District Cooling";
    8224          757 :         rowHead(4) = "District Heating Water";
    8225          757 :         rowHead(5) = "District Heating Steam";
    8226          757 :         rowHead(6) = "Gasoline";
    8227          757 :         rowHead(7) = "Diesel";
    8228          757 :         rowHead(8) = "Coal";
    8229          757 :         rowHead(9) = "Fuel Oil No 1";
    8230          757 :         rowHead(10) = "Fuel Oil No 2";
    8231          757 :         rowHead(11) = "Propane";
    8232          757 :         rowHead(12) = "Other Fuel 1";
    8233          757 :         rowHead(13) = "Other Fuel 2";
    8234              : 
    8235          757 :         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          757 :         if (!ort->ffSchedUsed(1)) {
    8252          756 :             tableBody(1, 1) = RealToStr(ort->sourceFactorElectric, 3);
    8253            1 :         } 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            1 :             tableBody(1, 1) = "N/A";
    8258              :         }
    8259              : 
    8260          757 :         if (!ort->ffSchedUsed(2)) {
    8261          756 :             tableBody(1, 2) = RealToStr(ort->sourceFactorNaturalGas, 3);
    8262            1 :         } 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            1 :             tableBody(1, 2) = "N/A";
    8267              :         }
    8268              : 
    8269          757 :         tableBody(1, 3) = RealToStr(ort->sourceFactorElectric / ort->efficiencyDistrictCooling, 3); // District Cooling
    8270              : 
    8271          757 :         tableBody(1, 4) = RealToStr(ort->sourceFactorNaturalGas / ort->efficiencyDistrictHeatingWater, 3); // District Heating Water
    8272              : 
    8273          757 :         tableBody(1, 5) = RealToStr(ort->sourceFactorDistrictHeatingSteam, 3); // District Heating Steam
    8274              : 
    8275          757 :         if (!ort->ffSchedUsed(6)) {
    8276          757 :             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          757 :         if (!ort->ffSchedUsed(8)) {
    8285          757 :             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          757 :         if (!ort->ffSchedUsed(9)) {
    8294          757 :             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          757 :         if (!ort->ffSchedUsed(10)) {
    8303          757 :             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          757 :         if (!ort->ffSchedUsed(11)) {
    8312          757 :             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          757 :         if (!ort->ffSchedUsed(12)) {
    8321          757 :             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          757 :         if (!ort->ffSchedUsed(13)) {
    8330          757 :             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          757 :         if (!ort->ffSchedUsed(14)) {
    8339          757 :             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          757 :         if (ort->displayTabularBEPS) {
    8349          757 :             if (produceTabular) {
    8350          757 :                 WriteSubtitle(state, "Site to Source Energy Conversion Factors");
    8351          757 :                 WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
    8352              :             }
    8353          757 :             if (produceSQLite) {
    8354          757 :                 if (state.dataSQLiteProcedures->sqlite) {
    8355          123 :                     state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(tableBody,
    8356              :                                                                                        rowHead,
    8357              :                                                                                        columnHead,
    8358              :                                                                                        "AnnualBuildingUtilityPerformanceSummary",
    8359              :                                                                                        "Entire Facility",
    8360              :                                                                                        "Site to Source Energy Conversion Factors");
    8361              :                 }
    8362              :             }
    8363          757 :             if (produceTabular) {
    8364          757 :                 if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
    8365           63 :                     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          757 :         rowHead.allocate(3);
    8377          757 :         columnHead.allocate(1);
    8378          757 :         columnWidth.allocate(1);
    8379          757 :         columnWidth = 14; // array assignment - same for all columns
    8380          757 :         tableBody.allocate(1, 3);
    8381              : 
    8382          757 :         switch (unitsStyle_cur) {
    8383            6 :         case UnitsStyle::JtoKWH: {
    8384            6 :             columnHead(1) = "Area [m2]";
    8385            6 :         } break;
    8386           11 :         case UnitsStyle::InchPound: {
    8387           11 :             columnHead(1) = "Area [ft2]";
    8388           11 :         } break;
    8389            0 :         case UnitsStyle::InchPoundExceptElectricity: {
    8390            0 :             columnHead(1) = "Area [ft2]";
    8391            0 :         } break;
    8392          740 :         default: {
    8393          740 :             columnHead(1) = "Area [m2]";
    8394          740 :         } break;
    8395              :         }
    8396              : 
    8397          757 :         rowHead(1) = "Total Building Area";
    8398          757 :         rowHead(2) = "Net Conditioned Building Area";
    8399          757 :         rowHead(3) = "Unconditioned Building Area";
    8400              : 
    8401          757 :         tableBody = "";
    8402          757 :         tableBody(1, 1) = RealToStr(convBldgGrossFloorArea, 2);
    8403              : 
    8404          757 :         if (unitsStyle_cur == OutputReportTabular::UnitsStyle::InchPound ||
    8405          746 :             unitsStyle_cur == OutputReportTabular::UnitsStyle::InchPoundExceptElectricity) {
    8406           11 :             if (produceTabular) {
    8407           22 :                 PreDefTableEntry(
    8408           33 :                     state, state.dataOutRptPredefined->pdchLeedGenData, "Total gross floor area [ft2]", RealToStr(convBldgGrossFloorArea, 2));
    8409              :             }
    8410              :         } else {
    8411          746 :             if (produceTabular) {
    8412         1492 :                 PreDefTableEntry(
    8413         2238 :                     state, state.dataOutRptPredefined->pdchLeedGenData, "Total gross floor area [m2]", RealToStr(convBldgGrossFloorArea, 2));
    8414              :             }
    8415              :         }
    8416              : 
    8417          757 :         tableBody(1, 2) = RealToStr(convBldgCondFloorArea, 2);
    8418          757 :         tableBody(1, 3) = RealToStr(convBldgGrossFloorArea - convBldgCondFloorArea, 2);
    8419              : 
    8420              :         // heading for the entire sub-table
    8421          757 :         if (ort->displayTabularBEPS) {
    8422          757 :             if (produceTabular) {
    8423          757 :                 WriteSubtitle(state, "Building Area");
    8424          757 :                 WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
    8425              :             }
    8426          757 :             if (produceSQLite) {
    8427          757 :                 if (state.dataSQLiteProcedures->sqlite) {
    8428          123 :                     state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
    8429              :                         tableBody, rowHead, columnHead, "AnnualBuildingUtilityPerformanceSummary", "Entire Facility", "Building Area");
    8430              :                 }
    8431              :             }
    8432          757 :             if (produceTabular) {
    8433          757 :                 if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
    8434           63 :                     state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(
    8435              :                         tableBody, rowHead, columnHead, "AnnualBuildingUtilityPerformanceSummary", "Entire Facility", "Building Area");
    8436              :                 }
    8437              :             }
    8438              :         }
    8439              : 
    8440              :         //---- End Use Sub-Table
    8441          757 :         rowHead.allocate(16);
    8442          757 :         columnHead.allocate(14);
    8443          757 :         columnWidth.allocate(14);
    8444          757 :         columnWidth = 10; // array assignment - same for all columns
    8445          757 :         tableBody.allocate(14, 16);
    8446        11355 :         for (int iResource = 1; iResource <= 14; ++iResource) {
    8447       158970 :             for (int iEndUse = 0; iEndUse < static_cast<int>(Constant::EndUse::Num); ++iEndUse) {
    8448       148372 :                 useVal(iResource, iEndUse + 1) = collapsedEndUse(iResource, iEndUse + 1);
    8449              :             }
    8450        10598 :             useVal(iResource, 15) = collapsedTotal(iResource); // totals
    8451              :         }
    8452              : 
    8453          757 :         rowHead(static_cast<int>(Constant::EndUse::Heating) + 1) = "Heating";
    8454          757 :         rowHead(static_cast<int>(Constant::EndUse::Cooling) + 1) = "Cooling";
    8455          757 :         rowHead(static_cast<int>(Constant::EndUse::InteriorLights) + 1) = "Interior Lighting";
    8456          757 :         rowHead(static_cast<int>(Constant::EndUse::ExteriorLights) + 1) = "Exterior Lighting";
    8457          757 :         rowHead(static_cast<int>(Constant::EndUse::InteriorEquipment) + 1) = "Interior Equipment";
    8458          757 :         rowHead(static_cast<int>(Constant::EndUse::ExteriorEquipment) + 1) = "Exterior Equipment";
    8459          757 :         rowHead(static_cast<int>(Constant::EndUse::Fans) + 1) = "Fans";
    8460          757 :         rowHead(static_cast<int>(Constant::EndUse::Pumps) + 1) = "Pumps";
    8461          757 :         rowHead(static_cast<int>(Constant::EndUse::HeatRejection) + 1) = "Heat Rejection";
    8462          757 :         rowHead(static_cast<int>(Constant::EndUse::Humidification) + 1) = "Humidification";
    8463          757 :         rowHead(static_cast<int>(Constant::EndUse::HeatRecovery) + 1) = "Heat Recovery";
    8464          757 :         rowHead(static_cast<int>(Constant::EndUse::WaterSystem) + 1) = "Water Systems";
    8465          757 :         rowHead(static_cast<int>(Constant::EndUse::Refrigeration) + 1) = "Refrigeration";
    8466          757 :         rowHead(static_cast<int>(Constant::EndUse::Cogeneration) + 1) = "Generators";
    8467          757 :         rowHead(15) = "";
    8468          757 :         rowHead(16) = "Total End Uses";
    8469              : 
    8470          757 :         switch (unitsStyle_cur) {
    8471            6 :         case UnitsStyle::JtoKWH: {
    8472            6 :             columnHead(1) = "Electricity [kWh]";
    8473            6 :             columnHead(2) = "Natural Gas [kWh]";
    8474            6 :             columnHead(3) = "Gasoline [kWh]";
    8475            6 :             columnHead(4) = "Diesel [kWh]";
    8476            6 :             columnHead(5) = "Coal [kWh]";
    8477            6 :             columnHead(6) = "Fuel Oil No 1 [kWh]";
    8478            6 :             columnHead(7) = "Fuel Oil No 2 [kWh]";
    8479            6 :             columnHead(8) = "Propane [kWh]";
    8480            6 :             columnHead(9) = "Other Fuel 1 [kWh]";
    8481            6 :             columnHead(10) = "Other Fuel 2 [kWh]";
    8482            6 :             columnHead(11) = "District Cooling [kWh]";
    8483            6 :             columnHead(12) = "District Heating Water [kWh]";
    8484            6 :             columnHead(13) = "District Heating Steam [kWh]";
    8485            6 :             columnHead(14) = "Water [m3]";
    8486            6 :         } break;
    8487           11 :         case UnitsStyle::InchPound: {
    8488           11 :             columnHead(1) = "Electricity [kBtu]";
    8489           11 :             columnHead(2) = "Natural Gas [kBtu]";
    8490           11 :             columnHead(3) = "Gasoline [kBtu]";
    8491           11 :             columnHead(4) = "Diesel [kBtu]";
    8492           11 :             columnHead(5) = "Coal [kBtu]";
    8493           11 :             columnHead(6) = "Fuel Oil No 1 [kBtu]";
    8494           11 :             columnHead(7) = "Fuel Oil No 2 [kBtu]";
    8495           11 :             columnHead(8) = "Propane [kBtu]";
    8496           11 :             columnHead(9) = "Other Fuel 1 [kBtu]";
    8497           11 :             columnHead(10) = "Other Fuel 2 [kBtu]";
    8498           11 :             columnHead(11) = "District Cooling [kBtu]";
    8499           11 :             columnHead(12) = "District Heating Water [kBtu]";
    8500           11 :             columnHead(13) = "District Heating Steam [kBtu]";
    8501           11 :             columnHead(14) = "Water [gal]";
    8502           11 :         } break;
    8503            0 :         case UnitsStyle::InchPoundExceptElectricity: {
    8504            0 :             columnHead(1) = "Electricity [kWh]";
    8505            0 :             columnHead(2) = "Natural Gas [kBtu]";
    8506            0 :             columnHead(3) = "Gasoline [kBtu]";
    8507            0 :             columnHead(4) = "Diesel [kBtu]";
    8508            0 :             columnHead(5) = "Coal [kBtu]";
    8509            0 :             columnHead(6) = "Fuel Oil No 1 [kBtu]";
    8510            0 :             columnHead(7) = "Fuel Oil No 2 [kBtu]";
    8511            0 :             columnHead(8) = "Propane [kBtu]";
    8512            0 :             columnHead(9) = "Other Fuel 1 [kBtu]";
    8513            0 :             columnHead(10) = "Other Fuel 2 [kBtu]";
    8514            0 :             columnHead(11) = "District Cooling [kBtu]";
    8515            0 :             columnHead(12) = "District Heating Water [kBtu]";
    8516            0 :             columnHead(13) = "District Heating Steam [kBtu]";
    8517            0 :             columnHead(14) = "Water [gal]";
    8518            0 :         } break;
    8519          740 :         default: {
    8520          740 :             columnHead(1) = "Electricity [GJ]";
    8521          740 :             columnHead(2) = "Natural Gas [GJ]";
    8522          740 :             columnHead(3) = "Gasoline [GJ]";
    8523          740 :             columnHead(4) = "Diesel [GJ]";
    8524          740 :             columnHead(5) = "Coal [GJ]";
    8525          740 :             columnHead(6) = "Fuel Oil No 1 [GJ]";
    8526          740 :             columnHead(7) = "Fuel Oil No 2 [GJ]";
    8527          740 :             columnHead(8) = "Propane [GJ]";
    8528          740 :             columnHead(9) = "Other Fuel 1 [GJ]";
    8529          740 :             columnHead(10) = "Other Fuel 2 [GJ]";
    8530          740 :             columnHead(11) = "District Cooling [GJ]";
    8531          740 :             columnHead(12) = "District Heating Water [GJ]";
    8532          740 :             columnHead(13) = "District Heating Steam [GJ]";
    8533          740 :             columnHead(14) = "Water [m3]";
    8534          740 :         } break;
    8535              :         }
    8536              : 
    8537          757 :         tableBody = "";
    8538        11355 :         for (int iResource = 1; iResource <= 14; ++iResource) {
    8539       158970 :             for (int jEndUse = 1; jEndUse <= 14; ++jEndUse) {
    8540       148372 :                 tableBody(iResource, jEndUse) = RealToStr(useVal(iResource, jEndUse), 2);
    8541              :             }
    8542        10598 :             tableBody(iResource, 16) = RealToStr(useVal(iResource, 15), 2);
    8543              :         }
    8544              :         // add warning message if end use values do not add up to total
    8545        11355 :         for (int iResource = 1; iResource <= 14; ++iResource) {
    8546        10598 :             Real64 curTotal = 0.0;
    8547       158970 :             for (int jUse = 1; jUse <= 14; ++jUse) {
    8548       148372 :                 curTotal += useVal(iResource, jUse);
    8549              :             }
    8550        10598 :             if (std::abs(curTotal - collapsedTotal(iResource)) > (collapsedTotal(iResource) * 0.001)) {
    8551            0 :                 ShowWarningError(state, ResourceWarningMessage(columnHead(iResource)));
    8552              :             }
    8553              :         }
    8554              : 
    8555          757 :         Real64 const unconvert = largeConversionFactor / 1000000000.0; // to avoid double converting, the values for the LEED report should be in GJ
    8556          757 :         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          757 :         if (ort->buildingGrossFloorArea > 0) {
    8561          728 :             if (produceTabular) {
    8562          728 :                 PreDefTableEntry(state,
    8563          728 :                                  state.dataOutRptPredefined->pdchLeedEuiElec,
    8564              :                                  "Interior Lighting (All)",
    8565          728 :                                  unconvert_ipExceptElec * 1000 * useVal(colElectricity, 3) / ort->buildingGrossFloorArea,
    8566          728 :                                  2);
    8567          728 :                 PreDefTableEntry(state,
    8568          728 :                                  state.dataOutRptPredefined->pdchLeedEuiElec,
    8569              :                                  "Space Heating",
    8570          728 :                                  unconvert_ipExceptElec * 1000 * useVal(colElectricity, 1) / ort->buildingGrossFloorArea,
    8571          728 :                                  2);
    8572          728 :                 PreDefTableEntry(state,
    8573          728 :                                  state.dataOutRptPredefined->pdchLeedEuiElec,
    8574              :                                  "Space Cooling",
    8575          728 :                                  unconvert_ipExceptElec * 1000 * useVal(colElectricity, 2) / ort->buildingGrossFloorArea,
    8576          728 :                                  2);
    8577          728 :                 PreDefTableEntry(state,
    8578          728 :                                  state.dataOutRptPredefined->pdchLeedEuiElec,
    8579              :                                  "Fans (All)",
    8580          728 :                                  unconvert_ipExceptElec * 1000 * useVal(colElectricity, 7) / ort->buildingGrossFloorArea,
    8581          728 :                                  2);
    8582          728 :                 PreDefTableEntry(state,
    8583          728 :                                  state.dataOutRptPredefined->pdchLeedEuiElec,
    8584              :                                  "Service Water Heating",
    8585          728 :                                  unconvert_ipExceptElec * 1000 * useVal(colElectricity, 12) / ort->buildingGrossFloorArea,
    8586          728 :                                  2);
    8587          728 :                 PreDefTableEntry(state,
    8588          728 :                                  state.dataOutRptPredefined->pdchLeedEuiElec,
    8589              :                                  "Receptacle Equipment",
    8590          728 :                                  unconvert_ipExceptElec * 1000 * useVal(colElectricity, 5) / ort->buildingGrossFloorArea,
    8591          728 :                                  2);
    8592          728 :                 PreDefTableEntry(state,
    8593          728 :                                  state.dataOutRptPredefined->pdchLeedEuiElec,
    8594              :                                  "Miscellaneous (All)",
    8595          728 :                                  unconvert_ipExceptElec * 1000 * (useVal(colElectricity, 15)) / ort->buildingGrossFloorArea,
    8596          728 :                                  2);
    8597          728 :                 PreDefTableEntry(state,
    8598          728 :                                  state.dataOutRptPredefined->pdchLeedEuiElec,
    8599              :                                  "Subtotal",
    8600          728 :                                  unconvert_ipExceptElec * 1000 * useVal(colElectricity, 15) / ort->buildingGrossFloorArea,
    8601         1456 :                                  2);
    8602              :             }
    8603              :         }
    8604              : 
    8605          757 :         if (produceTabular) {
    8606          757 :             PreDefTableEntry(
    8607          757 :                 state, state.dataOutRptPredefined->pdchLeedEusTotal, "Electricity", unconvert_ipExceptElec * useVal(colElectricity, 15), 2);
    8608          757 :             PreDefTableEntry(state,
    8609          757 :                              state.dataOutRptPredefined->pdchLeedEusProc,
    8610              :                              "Electricity",
    8611          757 :                              unconvert_ipExceptElec * (useVal(colElectricity, 5) + useVal(colElectricity, 13)),
    8612         1514 :                              2);
    8613              :         }
    8614              : 
    8615          757 :         Real64 processElecCost = 0.0;
    8616          757 :         if (useVal(colElectricity, 15) != 0) {
    8617            6 :             Real64 const processFraction = (useVal(colElectricity, 5) + useVal(colElectricity, 13)) / useVal(colElectricity, 15);
    8618            6 :             processElecCost = state.dataOutRptPredefined->LEEDelecCostTotal * processFraction;
    8619              :         }
    8620          757 :         if (produceTabular) {
    8621          757 :             PreDefTableEntry(state, state.dataOutRptPredefined->pdchLeedEcsProc, "Electricity", processElecCost, 2);
    8622         1514 :             addFootNoteSubTable(
    8623          757 :                 state, state.dataOutRptPredefined->pdstLeedEneCostSum, "Process energy cost based on ratio of process to total energy.");
    8624              :         }
    8625              : 
    8626              :         //  Energy Use Intensities- Natural Gas
    8627          757 :         if (ort->buildingGrossFloorArea > 0) {
    8628          728 :             if (produceTabular) {
    8629          728 :                 PreDefTableEntry(state,
    8630          728 :                                  state.dataOutRptPredefined->pdchLeedEuiNatG,
    8631              :                                  "Space Heating",
    8632          728 :                                  unconvert * 1000 * useVal(colGas, 1) / ort->buildingGrossFloorArea,
    8633          728 :                                  2);
    8634          728 :                 PreDefTableEntry(state,
    8635          728 :                                  state.dataOutRptPredefined->pdchLeedEuiNatG,
    8636              :                                  "Service Water Heating",
    8637          728 :                                  unconvert * 1000 * useVal(colGas, 12) / ort->buildingGrossFloorArea,
    8638          728 :                                  2);
    8639          728 :                 PreDefTableEntry(state,
    8640          728 :                                  state.dataOutRptPredefined->pdchLeedEuiNatG,
    8641              :                                  "Miscellaneous (All)",
    8642          728 :                                  unconvert * 1000 * useVal(colGas, 15) / ort->buildingGrossFloorArea,
    8643          728 :                                  2);
    8644          728 :                 PreDefTableEntry(state,
    8645          728 :                                  state.dataOutRptPredefined->pdchLeedEuiNatG,
    8646              :                                  "Subtotal",
    8647          728 :                                  unconvert * 1000 * useVal(colGas, 15) / ort->buildingGrossFloorArea,
    8648         1456 :                                  2);
    8649              :             }
    8650              :         }
    8651          757 :         if (produceTabular) {
    8652          757 :             PreDefTableEntry(state, state.dataOutRptPredefined->pdchLeedEusTotal, "Natural Gas", unconvert * useVal(colGas, 15), 2);
    8653          757 :             PreDefTableEntry(
    8654         1514 :                 state, state.dataOutRptPredefined->pdchLeedEusProc, "Natural Gas", unconvert * (useVal(colGas, 5) + useVal(colGas, 13)), 2);
    8655              :         }
    8656              : 
    8657          757 :         Real64 processGasCost = 0.0;
    8658          757 :         if (useVal(colGas, 15) != 0) {
    8659            4 :             Real64 const processFraction = (useVal(colGas, 5) + useVal(colGas, 13)) / useVal(colGas, 15);
    8660            4 :             processGasCost = state.dataOutRptPredefined->LEEDgasCostTotal * processFraction;
    8661              :         }
    8662          757 :         if (produceTabular) {
    8663          757 :             PreDefTableEntry(state, state.dataOutRptPredefined->pdchLeedEcsProc, "Natural Gas", processGasCost, 2);
    8664              :         }
    8665              :         //  Energy Use Intensities  - Additional Fuel
    8666              :         Real64 const useValColAddFuel15 =
    8667          757 :             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          757 :             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          757 :             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          757 :         if (ort->buildingGrossFloorArea > 0) {
    8673          728 :             if (produceTabular) {
    8674          728 :                 PreDefTableEntry(state,
    8675          728 :                                  state.dataOutRptPredefined->pdchLeedEuiOthr,
    8676              :                                  "Miscellaneous",
    8677          728 :                                  unconvert * 1000 * useValColAddFuel15 / ort->buildingGrossFloorArea,
    8678          728 :                                  2);
    8679          728 :                 PreDefTableEntry(state,
    8680          728 :                                  state.dataOutRptPredefined->pdchLeedEuiOthr,
    8681              :                                  "Subtotal",
    8682          728 :                                  unconvert * 1000 * useValColAddFuel15 / ort->buildingGrossFloorArea,
    8683         1456 :                                  2);
    8684              :             }
    8685              :         }
    8686          757 :         if (produceTabular) {
    8687          757 :             PreDefTableEntry(state,
    8688          757 :                              state.dataOutRptPredefined->pdchLeedEusTotal,
    8689              :                              "Additional",
    8690          757 :                              (useValColAddFuel15 + useVal(colPurchCool, 15) + useVal(colPurchHeatWtr, 15) + useVal(colPurchHeatSt, 15)),
    8691          757 :                              2);
    8692          757 :             PreDefTableEntry(state,
    8693          757 :                              state.dataOutRptPredefined->pdchLeedEusProc,
    8694              :                              "Additional",
    8695              :                              unconvert *
    8696          757 :                                  (useValColAddFuel5 + useValColAddFuel13 + useVal(colPurchCool, 5) + useVal(colPurchCool, 13) +
    8697          757 :                                   useVal(colPurchHeatWtr, 5) + useVal(colPurchHeatWtr, 13) + useVal(colPurchHeatSt, 5) + useVal(colPurchHeatSt, 13)),
    8698         1514 :                              2);
    8699              :         }
    8700              : 
    8701          757 :         Real64 processOthrCost = 0.0;
    8702          757 :         if ((useValColAddFuel15 + useVal(colPurchCool, 15) + useVal(colPurchHeatWtr, 15) + useVal(colPurchHeatSt, 15)) > 0.001) {
    8703              :             Real64 const processFraction =
    8704            2 :                 (useValColAddFuel5 + useValColAddFuel13 + useVal(colPurchCool, 5) + useVal(colPurchCool, 13) + useVal(colPurchHeatWtr, 5) +
    8705            2 :                  useVal(colPurchHeatWtr, 13) + useVal(colPurchHeatSt, 5) + useVal(colPurchHeatSt, 13)) /
    8706            2 :                 (useValColAddFuel15 + useVal(colPurchCool, 15) + useVal(colPurchHeatWtr, 15) + useVal(colPurchHeatSt, 15));
    8707            2 :             processOthrCost = state.dataOutRptPredefined->LEEDothrCostTotal * processFraction;
    8708              :         }
    8709          757 :         if (produceTabular) {
    8710          757 :             PreDefTableEntry(state, state.dataOutRptPredefined->pdchLeedEcsProc, "Additional", processOthrCost, 2);
    8711          757 :             PreDefTableEntry(state, state.dataOutRptPredefined->pdchLeedEcsProc, "Total", processElecCost + processGasCost + processOthrCost, 2);
    8712              :         }
    8713              :         // accumulate for percentage table
    8714          757 :         state.dataOutRptTab->leedSiteIntLite = 0.0;
    8715          757 :         state.dataOutRptTab->leedSiteSpHeat = 0.0;
    8716          757 :         state.dataOutRptTab->leedSiteSpCool = 0.0;
    8717          757 :         state.dataOutRptTab->leedSiteFanInt = 0.0;
    8718          757 :         state.dataOutRptTab->leedSiteSrvWatr = 0.0;
    8719          757 :         state.dataOutRptTab->leedSiteRecept = 0.0;
    8720          757 :         state.dataOutRptTab->leedSiteTotal = 0.0;
    8721        10598 :         for (int iResource = 1; iResource <= 13; ++iResource) { // don't bother with water
    8722         9841 :             state.dataOutRptTab->leedSiteIntLite += useVal(iResource, 3);
    8723         9841 :             state.dataOutRptTab->leedSiteSpHeat += useVal(iResource, 1);
    8724         9841 :             state.dataOutRptTab->leedSiteSpCool += useVal(iResource, 2);
    8725         9841 :             state.dataOutRptTab->leedSiteFanInt += useVal(iResource, 7);
    8726         9841 :             state.dataOutRptTab->leedSiteSrvWatr += useVal(iResource, 12);
    8727         9841 :             state.dataOutRptTab->leedSiteRecept += useVal(iResource, 5);
    8728         9841 :             state.dataOutRptTab->leedSiteTotal += useVal(iResource, 15);
    8729              :         }
    8730          757 :         if (state.dataOutRptTab->leedSiteTotal != 0) {
    8731            6 :             if (produceTabular) {
    8732            6 :                 PreDefTableEntry(state,
    8733            6 :                                  state.dataOutRptPredefined->pdchLeedEupPerc,
    8734              :                                  "Interior Lighting (All)",
    8735            6 :                                  100 * state.dataOutRptTab->leedSiteIntLite / state.dataOutRptTab->leedSiteTotal,
    8736            6 :                                  2);
    8737            6 :                 PreDefTableEntry(state,
    8738            6 :                                  state.dataOutRptPredefined->pdchLeedEupPerc,
    8739              :                                  "Space Heating",
    8740            6 :                                  100 * state.dataOutRptTab->leedSiteSpHeat / state.dataOutRptTab->leedSiteTotal,
    8741            6 :                                  2);
    8742            6 :                 PreDefTableEntry(state,
    8743            6 :                                  state.dataOutRptPredefined->pdchLeedEupPerc,
    8744              :                                  "Space Cooling",
    8745            6 :                                  100 * state.dataOutRptTab->leedSiteSpCool / state.dataOutRptTab->leedSiteTotal,
    8746            6 :                                  2);
    8747            6 :                 PreDefTableEntry(state,
    8748            6 :                                  state.dataOutRptPredefined->pdchLeedEupPerc,
    8749              :                                  "Fans (All)",
    8750            6 :                                  100 * state.dataOutRptTab->leedSiteFanInt / state.dataOutRptTab->leedSiteTotal,
    8751            6 :                                  2);
    8752            6 :                 PreDefTableEntry(state,
    8753            6 :                                  state.dataOutRptPredefined->pdchLeedEupPerc,
    8754              :                                  "Service Water Heating",
    8755            6 :                                  100 * state.dataOutRptTab->leedSiteSrvWatr / state.dataOutRptTab->leedSiteTotal,
    8756            6 :                                  2);
    8757            6 :                 PreDefTableEntry(state,
    8758            6 :                                  state.dataOutRptPredefined->pdchLeedEupPerc,
    8759              :                                  "Receptacle Equipment",
    8760            6 :                                  100 * state.dataOutRptTab->leedSiteRecept / state.dataOutRptTab->leedSiteTotal,
    8761            6 :                                  2);
    8762            6 :                 PreDefTableEntry(
    8763              :                     state,
    8764            6 :                     state.dataOutRptPredefined->pdchLeedEupPerc,
    8765              :                     "Miscellaneous",
    8766            6 :                     100 *
    8767            6 :                         (state.dataOutRptTab->leedSiteTotal -
    8768            6 :                          (state.dataOutRptTab->leedSiteIntLite + state.dataOutRptTab->leedSiteSpHeat + state.dataOutRptTab->leedSiteSpCool +
    8769            6 :                           state.dataOutRptTab->leedSiteFanInt + state.dataOutRptTab->leedSiteSrvWatr + state.dataOutRptTab->leedSiteRecept)) /
    8770            6 :                         state.dataOutRptTab->leedSiteTotal,
    8771           12 :                     2);
    8772              :             }
    8773              :         }
    8774              :         // totals across energy source
    8775          757 :         if (produceTabular) {
    8776          757 :             PreDefTableEntry(state,
    8777          757 :                              state.dataOutRptPredefined->pdchLeedEusTotal,
    8778              :                              "Total",
    8779          757 :                              unconvert_ipExceptElec * useVal(colElectricity, 15) +
    8780          757 :                                  unconvert * (useValColAddFuel15 + useVal(colPurchCool, 15) + useVal(colPurchHeatWtr, 15) +
    8781          757 :                                               useVal(colPurchHeatSt, 15) + +useVal(colGas, 15)),
    8782          757 :                              2);
    8783          757 :             PreDefTableEntry(state,
    8784          757 :                              state.dataOutRptPredefined->pdchLeedEusProc,
    8785              :                              "Total",
    8786          757 :                              unconvert_ipExceptElec * (useVal(colElectricity, 5) + useVal(colElectricity, 13)) +
    8787          757 :                                  unconvert * (useValColAddFuel5 + useValColAddFuel13 + useVal(colPurchCool, 5) + useVal(colPurchCool, 13) +
    8788          757 :                                               useVal(colPurchHeatWtr, 5) + useVal(colPurchHeatWtr, 13) + useVal(colPurchHeatSt, 5) +
    8789          757 :                                               useVal(colPurchHeatSt, 13) + +useVal(colGas, 5) + useVal(colGas, 13)),
    8790         1514 :                              2);
    8791              :         }
    8792              : 
    8793         1514 :         std::string footnote;
    8794          757 :         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            4 :         case colGas: {
    8802            4 :             if (produceTabular) {
    8803            4 :                 footnote = "Note: Natural gas appears to be the principal heating source based on energy usage.";
    8804            4 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchLeedGenData, "Principal Heating Source", "Natural Gas");
    8805              :             }
    8806            4 :         } break;
    8807            0 :         case colGasoline:
    8808              :         case colDiesel:
    8809              :         case colCoal:
    8810              :         case colFuelOilNo1:
    8811              :         case colFuelOilNo2:
    8812              :         case colPropane:
    8813              :         case colOtherFuel1:
    8814              :         case colOtherFuel2: {
    8815            0 :             if (produceTabular) {
    8816            0 :                 footnote = "Note: Additional fuel appears to be the principal heating source based on energy usage.";
    8817            0 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchLeedGenData, "Principal Heating Source", "Additional Fuel");
    8818              :             }
    8819            0 :         } break;
    8820            2 :         case colPurchHeatWtr: {
    8821            2 :             if (produceTabular) {
    8822            2 :                 footnote = "Note: District heating water appears to be the principal heating source based on energy usage.";
    8823            2 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchLeedGenData, "Principal Heating Source", "District Heating Water");
    8824              :             }
    8825            2 :         } 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          757 :         if (ort->displayTabularBEPS) {
    8835          757 :             if (produceTabular) {
    8836          757 :                 WriteSubtitle(state, "End Uses");
    8837          757 :                 WriteTable(state, tableBody, rowHead, columnHead, columnWidth, false, footnote);
    8838              :             }
    8839          757 :             if (produceSQLite) {
    8840          757 :                 if (state.dataSQLiteProcedures->sqlite) {
    8841          123 :                     state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
    8842              :                         tableBody, rowHead, columnHead, "AnnualBuildingUtilityPerformanceSummary", "Entire Facility", "End Uses");
    8843              :                 }
    8844              :             }
    8845          757 :             if (produceTabular) {
    8846          757 :                 if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
    8847           63 :                     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         1514 :         writeBEPSEndUseBySubCatOrSpaceType(state,
    8855              :                                            EndUseSubTableType::BySubCategory,
    8856              :                                            endUseSubOther,
    8857              :                                            collapsedEndUse,
    8858              :                                            collapsedEndUseSub,
    8859          757 :                                            ort->needOtherRowLEED45,
    8860              :                                            unitsStyle_cur,
    8861              :                                            produceTabular,
    8862              :                                            produceSQLite);
    8863              : 
    8864         1514 :         writeBEPSEndUseBySubCatOrSpaceType(state,
    8865              :                                            EndUseSubTableType::BySpaceType,
    8866              :                                            endUseSubOther,
    8867              :                                            collapsedEndUse,
    8868              :                                            collapsedEndUseSpType,
    8869          757 :                                            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         1514 :         Array1D_int resource_entry_map;
    8878          757 :         resource_entry_map.allocate(13);
    8879          757 :         resource_entry_map(1) = state.dataOutRptPredefined->pdchLeedPerfElEneUse;          // electricity
    8880          757 :         resource_entry_map(2) = state.dataOutRptPredefined->pdchLeedPerfGasEneUse;         // natural gas
    8881          757 :         resource_entry_map(3) = state.dataOutRptPredefined->pdchLeedPerfGasolineEneUse;    // gasoline
    8882          757 :         resource_entry_map(4) = state.dataOutRptPredefined->pdchLeedPerfDieselEneUse;      // diesel
    8883          757 :         resource_entry_map(5) = state.dataOutRptPredefined->pdchLeedPerfCoalEneUse;        // coal
    8884          757 :         resource_entry_map(6) = state.dataOutRptPredefined->pdchLeedPerfFuelOil1EneUse;    // fuel oil no 1
    8885          757 :         resource_entry_map(7) = state.dataOutRptPredefined->pdchLeedPerfFuelOil2EneUse;    // fuel oil no 2
    8886          757 :         resource_entry_map(8) = state.dataOutRptPredefined->pdchLeedPerfPropaneEneUse;     // propane
    8887          757 :         resource_entry_map(9) = state.dataOutRptPredefined->pdchLeedPerfOtherFuel1EneUse;  // other fuel 1
    8888          757 :         resource_entry_map(10) = state.dataOutRptPredefined->pdchLeedPerfOtherFuel2EneUse; // other fuel 2
    8889          757 :         resource_entry_map(11) = state.dataOutRptPredefined->pdchLeedPerfDisClEneUse;      // district cooling
    8890          757 :         resource_entry_map(12) = state.dataOutRptPredefined->pdchLeedPerfDisHtWtrEneUse;   // district heating Water
    8891          757 :         resource_entry_map(13) = state.dataOutRptPredefined->pdchLeedPerfDisHtStEneUse;    // district heating Steam
    8892              : 
    8893        10598 :         for (int iResource = 1; iResource <= 13; ++iResource) {
    8894         9841 :             int i = 1;
    8895         9841 :             Real64 localUnconvert = (iResource == 1) ? unconvert_ipExceptElec : unconvert;
    8896       147615 :             for (int jEndUse = 1; jEndUse <= static_cast<int>(Constant::EndUse::Num); ++jEndUse) {
    8897       137774 :                 if (op->EndUseCategory(jEndUse).NumSubcategories > 0) {
    8898       151112 :                     for (int kEndUseSub = 1; kEndUseSub <= op->EndUseCategory(jEndUse).NumSubcategories; ++kEndUseSub) {
    8899        82108 :                         if (produceTabular) {
    8900       246324 :                             PreDefTableEntry(state,
    8901        82108 :                                              resource_entry_map(iResource),
    8902       164216 :                                              op->EndUseCategory(jEndUse).DisplayName + " -- " +
    8903        82108 :                                                  op->EndUseCategory(jEndUse).SubcategoryName(kEndUseSub),
    8904        82108 :                                              localUnconvert * collapsedEndUseSub(kEndUseSub, jEndUse, iResource));
    8905              :                         }
    8906        82108 :                         ++i;
    8907              :                     }
    8908              :                     // put other
    8909        69004 :                     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        68770 :                     if (produceTabular) {
    8920       206310 :                         PreDefTableEntry(state,
    8921        68770 :                                          resource_entry_map(iResource),
    8922       137540 :                                          op->EndUseCategory(jEndUse).DisplayName + " -- Not Subdivided",
    8923        68770 :                                          localUnconvert * collapsedEndUse(iResource, jEndUse));
    8924              :                     }
    8925        68770 :                     ++i;
    8926              :                 }
    8927              :             }
    8928              :         }
    8929              : 
    8930              :         //---- Normalized by Conditioned Area Sub-Table
    8931              :         // Calculations for both normalized tables are first
    8932          757 :         rowHead.allocate(4);
    8933          757 :         columnHead.allocate(14);
    8934          757 :         columnWidth.allocate(14);
    8935          757 :         columnWidth = 7; // array assignment - same for all columns
    8936          757 :         tableBody.allocate(14, 4);
    8937        11355 :         for (int iResource = 1; iResource <= 14; ++iResource) {
    8938              :             // Lights     <- InteriorLights | <- ExteriorLights
    8939        10598 :             normalVal(iResource, 1) = collapsedEndUse(iResource, static_cast<int>(Constant::EndUse::InteriorLights) + 1) +
    8940        10598 :                                       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        10598 :             normalVal(iResource, 2) = collapsedEndUse(iResource, static_cast<int>(Constant::EndUse::Fans) + 1) +
    8945        10598 :                                       collapsedEndUse(iResource, static_cast<int>(Constant::EndUse::Pumps) + 1) +
    8946        10598 :                                       collapsedEndUse(iResource, static_cast<int>(Constant::EndUse::Heating) + 1) +
    8947        10598 :                                       collapsedEndUse(iResource, static_cast<int>(Constant::EndUse::Cooling) + 1) +
    8948        10598 :                                       collapsedEndUse(iResource, static_cast<int>(Constant::EndUse::HeatRejection) + 1) +
    8949        10598 :                                       collapsedEndUse(iResource, static_cast<int>(Constant::EndUse::Humidification) + 1) +
    8950        10598 :                                       collapsedEndUse(iResource, static_cast<int>(Constant::EndUse::WaterSystem) + 1);
    8951              : 
    8952              :             // Other <- InteriorEquipment | <- ExteriorEquipment | <- generator fuel | <- Heat Recovery (parasitics) | <- Refrigeration
    8953        10598 :             normalVal(iResource, 3) = collapsedEndUse(iResource, static_cast<int>(Constant::EndUse::InteriorEquipment) + 1) +
    8954        10598 :                                       collapsedEndUse(iResource, static_cast<int>(Constant::EndUse::ExteriorEquipment) + 1) +
    8955        10598 :                                       collapsedEndUse(iResource, static_cast<int>(Constant::EndUse::Cogeneration) + 1) +
    8956        10598 :                                       collapsedEndUse(iResource, static_cast<int>(Constant::EndUse::HeatRecovery) + 1) +
    8957        10598 :                                       collapsedEndUse(iResource, static_cast<int>(Constant::EndUse::Refrigeration) + 1);
    8958              : 
    8959        10598 :             normalVal(iResource, 4) = collapsedTotal(iResource); // totals
    8960              :         }
    8961              :         // convert the normalized end use values to MJ from GJ if using J
    8962        10598 :         for (int iResource = 1; iResource <= 13; ++iResource) { // not including resource=14 water
    8963        49205 :             for (int jEndUse = 1; jEndUse <= 4; ++jEndUse) {
    8964        39364 :                 normalVal(iResource, jEndUse) *= kConversionFactor;
    8965              :             }
    8966              :         }
    8967              : 
    8968          757 :         rowHead(1) = "Lighting"; // typo fixed 5-17-04 BTG
    8969          757 :         rowHead(2) = "HVAC";
    8970          757 :         rowHead(3) = "Other";
    8971          757 :         rowHead(4) = "Total";
    8972              : 
    8973          757 :         switch (unitsStyle_cur) {
    8974            6 :         case UnitsStyle::JtoKWH: {
    8975            6 :             columnHead(1) = "Electricity Intensity [kWh/m2]";
    8976            6 :             columnHead(2) = "Natural Gas Intensity [kWh/m2]";
    8977            6 :             columnHead(3) = "Gasoline Intensity [kWh/m2]";
    8978            6 :             columnHead(4) = "Diesel Intensity [kWh/m2]";
    8979            6 :             columnHead(5) = "Coal Intensity [kWh/m2]";
    8980            6 :             columnHead(6) = "Fuel Oil No 1 Intensity [kWh/m2]";
    8981            6 :             columnHead(7) = "Fuel Oil No 2 Intensity [kWh/m2]";
    8982            6 :             columnHead(8) = "Propane Intensity [kWh/m2]";
    8983            6 :             columnHead(9) = "Other Fuel 1 Intensity [kWh/m2]";
    8984            6 :             columnHead(10) = "Other Fuel 2 Intensity [kWh/m2]";
    8985            6 :             columnHead(11) = "District Cooling Intensity [kWh/m2]";
    8986            6 :             columnHead(12) = "District Heating Water Intensity [kWh/m2]";
    8987            6 :             columnHead(13) = "District Heating Steam Intensity [kWh/m2]";
    8988            6 :             columnHead(14) = "Water Intensity [m3/m2]";
    8989            6 :         } break;
    8990           11 :         case UnitsStyle::InchPound: {
    8991           11 :             columnHead(1) = "Electricity Intensity [kBtu/ft2]";
    8992           11 :             columnHead(2) = "Natural Gas Intensity [kBtu/ft2]";
    8993           11 :             columnHead(3) = "Gasoline Intensity [kBtu/ft2]";
    8994           11 :             columnHead(4) = "Diesel Intensity [kBtu/ft2]";
    8995           11 :             columnHead(5) = "Coal Intensity [kBtu/ft2]";
    8996           11 :             columnHead(6) = "Fuel Oil No 1 Intensity [kBtu/ft2]";
    8997           11 :             columnHead(7) = "Fuel Oil No 2 Intensity [kBtu/ft2]";
    8998           11 :             columnHead(8) = "Propane Intensity [kBtu/ft2]";
    8999           11 :             columnHead(9) = "Other Fuel 1 Intensity [kBtu/ft2]";
    9000           11 :             columnHead(10) = "Other Fuel 2 Intensity [kBtu/ft2]";
    9001           11 :             columnHead(11) = "District Cooling Intensity [kBtu/ft2]";
    9002           11 :             columnHead(12) = "District Heating Water Intensity [kBtu/ft2]";
    9003           11 :             columnHead(13) = "District Heating Steam Intensity [kBtu/ft2]";
    9004           11 :             columnHead(14) = "Water Intensity [gal/ft2]";
    9005           11 :         } break;
    9006            0 :         case UnitsStyle::InchPoundExceptElectricity: {
    9007            0 :             columnHead(1) = "Electricity Intensity [kWh/ft2]";
    9008            0 :             columnHead(2) = "Natural Gas Intensity [kBtu/ft2]";
    9009            0 :             columnHead(3) = "Gasoline Intensity [kBtu/ft2]";
    9010            0 :             columnHead(4) = "Diesel Intensity [kBtu/ft2]";
    9011            0 :             columnHead(5) = "Coal Intensity [kBtu/ft2]";
    9012            0 :             columnHead(6) = "Fuel Oil No 1 Intensity [kBtu/ft2]";
    9013            0 :             columnHead(7) = "Fuel Oil No 2 Intensity [kBtu/ft2]";
    9014            0 :             columnHead(8) = "Propane Intensity [kBtu/ft2]";
    9015            0 :             columnHead(9) = "Other Fuel 1 Intensity [kBtu/ft2]";
    9016            0 :             columnHead(10) = "Other Fuel 2 Intensity [kBtu/ft2]";
    9017            0 :             columnHead(11) = "District Cooling Intensity [kBtu/ft2]";
    9018            0 :             columnHead(12) = "District Heating Water Intensity [kBtu/ft2]";
    9019            0 :             columnHead(13) = "District Heating Steam Intensity [kBtu/ft2]";
    9020            0 :             columnHead(14) = "Water Intensity [gal/ft2]";
    9021            0 :         } break;
    9022          740 :         default: {
    9023          740 :             columnHead(1) = "Electricity Intensity [MJ/m2]";
    9024          740 :             columnHead(2) = "Natural Gas Intensity [MJ/m2]";
    9025          740 :             columnHead(3) = "Gasoline Intensity [MJ/m2]";
    9026          740 :             columnHead(4) = "Diesel Intensity [MJ/m2]";
    9027          740 :             columnHead(5) = "Coal Intensity [MJ/m2]";
    9028          740 :             columnHead(6) = "Fuel Oil No 1 Intensity [MJ/m2]";
    9029          740 :             columnHead(7) = "Fuel Oil No 2 Intensity [MJ/m2]";
    9030          740 :             columnHead(8) = "Propane Intensity [MJ/m2]";
    9031          740 :             columnHead(9) = "Other Fuel 1 Intensity [MJ/m2]";
    9032          740 :             columnHead(10) = "Other Fuel 2 Intensity [MJ/m2]";
    9033          740 :             columnHead(11) = "District Cooling Intensity [MJ/m2]";
    9034          740 :             columnHead(12) = "District Heating Water Intensity [MJ/m2]";
    9035          740 :             columnHead(13) = "District Heating Steam Intensity [MJ/m2]";
    9036          740 :             columnHead(14) = "Water Intensity [m3/m2]";
    9037          740 :         } break;
    9038              :         }
    9039              : 
    9040          757 :         if (produceTabular) {
    9041         1514 :             WriteTextLine(state, "Normalized Metrics", true);
    9042              :         }
    9043              : 
    9044              :         // write the conditioned area based table
    9045          757 :         tableBody = "";
    9046          757 :         if (convBldgCondFloorArea > 0) {
    9047        10125 :             for (int iResource = 1; iResource <= 14; ++iResource) {
    9048        47250 :                 for (int jEndUse = 1; jEndUse <= 4; ++jEndUse) {
    9049        37800 :                     tableBody(iResource, jEndUse) = RealToStr(normalVal(iResource, jEndUse) / convBldgCondFloorArea, 2);
    9050              :                 }
    9051              :             }
    9052              :         }
    9053              :         // heading for the entire sub-table
    9054          757 :         if (ort->displayTabularBEPS) {
    9055          757 :             if (produceTabular) {
    9056          757 :                 WriteSubtitle(state, "Utility Use Per Conditioned Floor Area");
    9057          757 :                 WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
    9058              :             }
    9059          757 :             if (produceSQLite) {
    9060          757 :                 if (state.dataSQLiteProcedures->sqlite) {
    9061          123 :                     state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(tableBody,
    9062              :                                                                                        rowHead,
    9063              :                                                                                        columnHead,
    9064              :                                                                                        "AnnualBuildingUtilityPerformanceSummary",
    9065              :                                                                                        "Entire Facility",
    9066              :                                                                                        "Utility Use Per Conditioned Floor Area");
    9067              :                 }
    9068              :             }
    9069          757 :             if (produceTabular) {
    9070          757 :                 if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
    9071           63 :                     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          757 :         tableBody = "";
    9082          757 :         if (convBldgGrossFloorArea > 0) {
    9083        10192 :             for (int iResource = 1; iResource <= 13; ++iResource) {
    9084        47320 :                 for (int jEndUse = 1; jEndUse <= 4; ++jEndUse) {
    9085        37856 :                     tableBody(iResource, jEndUse) = RealToStr(normalVal(iResource, jEndUse) / convBldgGrossFloorArea, 2);
    9086              :                 }
    9087              :             }
    9088              :         }
    9089              :         // heading for the entire sub-table
    9090          757 :         if (ort->displayTabularBEPS) {
    9091          757 :             if (produceTabular) {
    9092          757 :                 WriteSubtitle(state, "Utility Use Per Total Floor Area");
    9093          757 :                 WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
    9094              :             }
    9095          757 :             if (produceSQLite) {
    9096          757 :                 if (state.dataSQLiteProcedures->sqlite) {
    9097          123 :                     state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(tableBody,
    9098              :                                                                                        rowHead,
    9099              :                                                                                        columnHead,
    9100              :                                                                                        "AnnualBuildingUtilityPerformanceSummary",
    9101              :                                                                                        "Entire Facility",
    9102              :                                                                                        "Utility Use Per Total Floor Area");
    9103              :                 }
    9104              :             }
    9105          757 :             if (produceTabular) {
    9106          757 :                 if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
    9107           63 :                     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          757 :         rowHead.allocate(14);
    9119          757 :         columnHead.allocate(2);
    9120          757 :         columnWidth.allocate(2);
    9121          757 :         columnWidth = 14; // array assignment - same for all columns
    9122          757 :         tableBody.allocate(2, 14);
    9123              : 
    9124          757 :         switch (unitsStyle_cur) {
    9125            6 :         case UnitsStyle::JtoKWH: {
    9126            6 :             columnHead(1) = "Electricity [kWh]";
    9127            6 :         } break;
    9128           11 :         case UnitsStyle::InchPound: {
    9129           11 :             columnHead(1) = "Electricity [kBtu]";
    9130           11 :         } break;
    9131            0 :         case UnitsStyle::InchPoundExceptElectricity: {
    9132            0 :             columnHead(1) = "Electricity [kWh]";
    9133            0 :         } break;
    9134          740 :         default: {
    9135          740 :             columnHead(1) = "Electricity [GJ]";
    9136          740 :         } break;
    9137              :         }
    9138          757 :         columnHead(2) = "Percent Electricity [%]";
    9139              : 
    9140          757 :         rowHead(1) = "Fuel-Fired Power Generation";
    9141          757 :         rowHead(2) = "High Temperature Geothermal*";
    9142          757 :         rowHead(3) = "Photovoltaic Power";
    9143          757 :         rowHead(4) = "Wind Power";
    9144          757 :         rowHead(5) = "Power Conversion";
    9145          757 :         rowHead(6) = "Net Decrease in On-Site Storage";
    9146          757 :         rowHead(7) = "Total On-Site Electric Sources";
    9147          757 :         rowHead(8) = "";
    9148          757 :         rowHead(9) = "Electricity Coming From Utility";
    9149          757 :         rowHead(10) = "Surplus Electricity Going To Utility";
    9150          757 :         rowHead(11) = "Net Electricity From Utility";
    9151          757 :         rowHead(12) = "";
    9152          757 :         rowHead(13) = "Total On-Site and Utility Electric Sources";
    9153          757 :         rowHead(14) = "Total Electricity End Uses";
    9154              : 
    9155          757 :         tableBody = "";
    9156              : 
    9157              :         // show annual values
    9158          757 :         tableBody(1, 1) = RealToStr(ort->gatherPowerFuelFireGen, 3);
    9159          757 :         tableBody(1, 2) = RealToStr(ort->gatherPowerHTGeothermal, 3);
    9160          757 :         tableBody(1, 3) = RealToStr(ort->gatherPowerPV, 3);
    9161          757 :         if (produceTabular) {
    9162          757 :             PreDefTableEntry(state, state.dataOutRptPredefined->pdchLeedRenAnGen, "Photovoltaic", unconvert_ipExceptElec * ort->gatherPowerPV, 2);
    9163              :         }
    9164          757 :         tableBody(1, 4) = RealToStr(ort->gatherPowerWind, 3);
    9165          757 :         if (produceTabular) {
    9166          757 :             PreDefTableEntry(state, state.dataOutRptPredefined->pdchLeedRenAnGen, "Wind", unconvert_ipExceptElec * ort->gatherPowerWind, 2);
    9167              :         }
    9168          757 :         tableBody(1, 5) = RealToStr(ort->gatherPowerConversion, 3);
    9169          757 :         tableBody(1, 6) = RealToStr(ort->OverallNetEnergyFromStorage, 3);
    9170          757 :         tableBody(1, 7) = RealToStr(ort->gatherElecProduced, 3);
    9171          757 :         tableBody(1, 9) = RealToStr(ort->gatherElecPurchased, 3);
    9172          757 :         tableBody(1, 10) = RealToStr(ort->gatherElecSurplusSold, 3);
    9173          757 :         tableBody(1, 11) = RealToStr(ort->gatherElecPurchased - ort->gatherElecSurplusSold, 3);
    9174          757 :         tableBody(1, 13) = RealToStr(ort->gatherElecProduced + (ort->gatherElecPurchased - ort->gatherElecSurplusSold), 3);
    9175          757 :         tableBody(1, 14) = RealToStr(collapsedTotal(1), 3);
    9176              : 
    9177              :         // show annual percentages
    9178          757 :         if (collapsedTotal(1) > 0) {
    9179            6 :             tableBody(2, 1) = RealToStr(100.0 * ort->gatherPowerFuelFireGen / collapsedTotal(1), 2);
    9180            6 :             tableBody(2, 2) = RealToStr(100.0 * ort->gatherPowerHTGeothermal / collapsedTotal(1), 2);
    9181            6 :             tableBody(2, 3) = RealToStr(100.0 * ort->gatherPowerPV / collapsedTotal(1), 2);
    9182            6 :             tableBody(2, 4) = RealToStr(100.0 * ort->gatherPowerWind / collapsedTotal(1), 2);
    9183            6 :             tableBody(2, 5) = RealToStr(100.0 * ort->gatherPowerConversion / collapsedTotal(1), 2);
    9184            6 :             tableBody(2, 6) = RealToStr(100.0 * ort->OverallNetEnergyFromStorage / collapsedTotal(1), 2);
    9185            6 :             tableBody(2, 7) = RealToStr(100.0 * ort->gatherElecProduced / collapsedTotal(1), 2);
    9186            6 :             tableBody(2, 9) = RealToStr(100.0 * ort->gatherElecPurchased / collapsedTotal(1), 2);
    9187            6 :             tableBody(2, 10) = RealToStr(100.0 * ort->gatherElecSurplusSold / collapsedTotal(1), 2);
    9188            6 :             tableBody(2, 11) = RealToStr(100.0 * (ort->gatherElecPurchased - ort->gatherElecSurplusSold) / collapsedTotal(1), 2);
    9189            6 :             tableBody(2, 13) =
    9190           12 :                 RealToStr(100.0 * (ort->gatherElecProduced + (ort->gatherElecPurchased - ort->gatherElecSurplusSold)) / collapsedTotal(1), 2);
    9191            6 :             tableBody(2, 14) = RealToStr(100.0, 2);
    9192              :         }
    9193              : 
    9194              :         // heading for the entire sub-table
    9195          757 :         if (ort->displayTabularBEPS) {
    9196          757 :             if (produceTabular) {
    9197          757 :                 WriteSubtitle(state, "Electric Loads Satisfied");
    9198          757 :                 WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
    9199              :             }
    9200          757 :             if (produceSQLite) {
    9201          757 :                 if (state.dataSQLiteProcedures->sqlite) {
    9202          123 :                     state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
    9203              :                         tableBody, rowHead, columnHead, "AnnualBuildingUtilityPerformanceSummary", "Entire Facility", "Electric Loads Satisfied");
    9204              :                 }
    9205              :             }
    9206          757 :             if (produceTabular) {
    9207          757 :                 if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
    9208           63 :                     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          757 :         rowHead.allocate(7);
    9216          757 :         columnHead.allocate(2);
    9217          757 :         columnWidth.allocate(2);
    9218          757 :         columnWidth = 14; // array assignment - same for all columns
    9219          757 :         tableBody.allocate(2, 7);
    9220              : 
    9221          757 :         switch (unitsStyle_cur) {
    9222            6 :         case UnitsStyle::JtoKWH: {
    9223            6 :             columnHead(1) = "Heat [kWh]";
    9224            6 :         } break;
    9225           11 :         case UnitsStyle::InchPound: {
    9226           11 :             columnHead(1) = "Heat [kBtu]";
    9227           11 :         } break;
    9228            0 :         case UnitsStyle::InchPoundExceptElectricity: {
    9229            0 :             columnHead(1) = "Heat [kBtu]";
    9230            0 :         } break;
    9231          740 :         default: {
    9232          740 :             columnHead(1) = "Heat [GJ]";
    9233          740 :         } break;
    9234              :         }
    9235              : 
    9236          757 :         columnHead(2) = "Percent Heat [%]";
    9237              : 
    9238          757 :         rowHead(1) = "Water-Side Heat Recovery";
    9239          757 :         rowHead(2) = "Air to Air Heat Recovery for Cooling";
    9240          757 :         rowHead(3) = "Air to Air Heat Recovery for Heating";
    9241          757 :         rowHead(4) = "High-Temperature Geothermal*";
    9242          757 :         rowHead(5) = "Solar Water Thermal";
    9243          757 :         rowHead(6) = "Solar Air Thermal";
    9244          757 :         rowHead(7) = "Total On-Site Thermal Sources";
    9245              : 
    9246          757 :         tableBody = "";
    9247              : 
    9248          757 :         if (iUnitSystem == 0) {
    9249          757 :             gtWaterHeatRecovery = ort->gatherWaterHeatRecovery;
    9250          757 :             gtAirHeatRecoveryCool = ort->gatherAirHeatRecoveryCool;
    9251          757 :             gtAirHeatRecoveryHeat = ort->gatherAirHeatRecoveryHeat;
    9252          757 :             gtHeatHTGeothermal = ort->gatherHeatHTGeothermal;
    9253          757 :             gtHeatSolarWater = ort->gatherHeatSolarWater;
    9254          757 :             gtHeatSolarAir = ort->gatherHeatSolarAir;
    9255              :         } else {
    9256            0 :             ort->gatherWaterHeatRecovery = gtWaterHeatRecovery;
    9257            0 :             ort->gatherAirHeatRecoveryCool = gtAirHeatRecoveryCool;
    9258            0 :             ort->gatherAirHeatRecoveryHeat = gtAirHeatRecoveryHeat;
    9259            0 :             ort->gatherHeatHTGeothermal = gtHeatHTGeothermal;
    9260            0 :             ort->gatherHeatSolarWater = gtHeatSolarWater;
    9261            0 :             ort->gatherHeatSolarAir = gtHeatSolarAir;
    9262              :         }
    9263              : 
    9264              :         // convert to GJ
    9265          757 :         ort->gatherWaterHeatRecovery /= largeConversionFactor;
    9266          757 :         ort->gatherAirHeatRecoveryCool /= largeConversionFactor;
    9267          757 :         ort->gatherAirHeatRecoveryHeat /= largeConversionFactor;
    9268          757 :         ort->gatherHeatHTGeothermal /= largeConversionFactor;
    9269          757 :         ort->gatherHeatSolarWater /= largeConversionFactor;
    9270          757 :         ort->gatherHeatSolarAir /= largeConversionFactor;
    9271              : 
    9272              :         // determine total on site heat
    9273          757 :         Real64 const totalOnsiteHeat = ort->gatherWaterHeatRecovery + ort->gatherAirHeatRecoveryCool + ort->gatherAirHeatRecoveryHeat +
    9274          757 :                                        ort->gatherHeatHTGeothermal + ort->gatherHeatSolarWater + ort->gatherHeatSolarAir;
    9275              : 
    9276              :         // show annual values
    9277          757 :         tableBody(1, 1) = RealToStr(ort->gatherWaterHeatRecovery, 2);
    9278          757 :         tableBody(1, 2) = RealToStr(ort->gatherAirHeatRecoveryCool, 2);
    9279          757 :         tableBody(1, 3) = RealToStr(ort->gatherAirHeatRecoveryHeat, 2);
    9280          757 :         tableBody(1, 4) = RealToStr(ort->gatherHeatHTGeothermal, 2);
    9281          757 :         tableBody(1, 5) = RealToStr(ort->gatherHeatSolarWater, 2);
    9282          757 :         tableBody(1, 6) = RealToStr(ort->gatherHeatSolarAir, 2);
    9283          757 :         tableBody(1, 7) = RealToStr(totalOnsiteHeat, 2);
    9284              : 
    9285          757 :         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          757 :         if (ort->displayTabularBEPS) {
    9297          757 :             if (produceTabular) {
    9298          757 :                 WriteSubtitle(state, "On-Site Thermal Sources");
    9299          757 :                 WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
    9300              :             }
    9301          757 :             if (produceSQLite) {
    9302          757 :                 if (state.dataSQLiteProcedures->sqlite) {
    9303          123 :                     state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
    9304              :                         tableBody, rowHead, columnHead, "AnnualBuildingUtilityPerformanceSummary", "Entire Facility", "On-Site Thermal Sources");
    9305              :                 }
    9306              :             }
    9307          757 :             if (produceTabular) {
    9308          757 :                 if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
    9309           63 :                     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          757 :         rowHead.allocate(13);
    9324          757 :         columnHead.allocate(2);
    9325          757 :         columnWidth.allocate(2);
    9326          757 :         columnWidth = 14; // array assignment - same for all columns
    9327          757 :         tableBody.allocate(2, 13);
    9328          757 :         switch (unitsStyle_cur) {
    9329            6 :         case UnitsStyle::JtoKWH: {
    9330            6 :             columnHead(1) = "Water [m3]";
    9331            6 :         } break;
    9332           11 :         case UnitsStyle::InchPound: {
    9333           11 :             columnHead(1) = "Water [gal]";
    9334           11 :         } break;
    9335            0 :         case UnitsStyle::InchPoundExceptElectricity: {
    9336            0 :             columnHead(1) = "Water [gal]";
    9337            0 :         } break;
    9338          740 :         default: {
    9339          740 :             columnHead(1) = "Water [m3]";
    9340          740 :         } break;
    9341              :         }
    9342              : 
    9343          757 :         columnHead(2) = "Percent Water [%]";
    9344          757 :         rowHead(1) = "Rainwater Collection";
    9345          757 :         rowHead(2) = "Condensate Collection";
    9346          757 :         rowHead(3) = "Groundwater Well";
    9347          757 :         rowHead(4) = "Total On Site Water Sources";
    9348          757 :         rowHead(5) = "-";
    9349          757 :         rowHead(6) = "Initial Storage";
    9350          757 :         rowHead(7) = "Final Storage";
    9351          757 :         rowHead(8) = "Change in Storage";
    9352          757 :         rowHead(9) = "-";
    9353          757 :         rowHead(10) = "Water Supplied by Utility";
    9354          757 :         rowHead(11) = "-";
    9355          757 :         rowHead(12) = "Total On Site, Change in Storage, and Utility Water Sources";
    9356          757 :         rowHead(13) = "Total Water End Uses";
    9357          757 :         tableBody = "-";
    9358              : 
    9359          757 :         Real64 const totalOnsiteWater = ort->gatherRainWater + ort->gatherCondensate + ort->gatherWellwater;
    9360              : 
    9361              :         //  ! show annual values
    9362          757 :         tableBody(1, 1) = RealToStr(ort->gatherRainWater / waterConversionFactor, 2);
    9363          757 :         tableBody(1, 2) = RealToStr(ort->gatherCondensate / waterConversionFactor, 2);
    9364          757 :         tableBody(1, 3) = RealToStr(ort->gatherWellwater / waterConversionFactor, 2);
    9365          757 :         tableBody(1, 4) = RealToStr(totalOnsiteWater / waterConversionFactor, 2);
    9366              : 
    9367          757 :         Real64 initialStorage = 0.0;
    9368          757 :         Real64 finalStorage = 0.0;
    9369          757 :         Real64 StorageChange = 0.0;
    9370          757 :         if (allocated(state.dataWaterData->WaterStorage)) {
    9371            5 :             initialStorage = sum(state.dataWaterData->WaterStorage, &DataWater::StorageTankDataStruct::InitialVolume);
    9372            5 :             finalStorage = sum(state.dataWaterData->WaterStorage, &DataWater::StorageTankDataStruct::ThisTimeStepVolume);
    9373            5 :             StorageChange = initialStorage - finalStorage;
    9374              :         }
    9375          757 :         tableBody(1, 6) = RealToStr(initialStorage / waterConversionFactor, 2);
    9376          757 :         tableBody(1, 7) = RealToStr(finalStorage / waterConversionFactor, 2);
    9377          757 :         tableBody(1, 8) = RealToStr(StorageChange / waterConversionFactor, 2);
    9378              : 
    9379          757 :         Real64 const totalWater = totalOnsiteWater + ort->gatherMains + StorageChange;
    9380              : 
    9381          757 :         tableBody(1, 10) = RealToStr(ort->gatherMains / waterConversionFactor, 2);
    9382          757 :         tableBody(1, 12) = RealToStr(totalWater / waterConversionFactor, 2);
    9383          757 :         tableBody(1, 13) = RealToStr(ort->gatherWaterEndUseTotal / waterConversionFactor, 2);
    9384              : 
    9385          757 :         if (ort->gatherWaterEndUseTotal > 0) {
    9386            1 :             tableBody(2, 1) = RealToStr(100.0 * ort->gatherRainWater / ort->gatherWaterEndUseTotal, 2);
    9387            1 :             tableBody(2, 2) = RealToStr(100.0 * ort->gatherCondensate / ort->gatherWaterEndUseTotal, 2);
    9388            1 :             tableBody(2, 3) = RealToStr(100.0 * ort->gatherWellwater / ort->gatherWaterEndUseTotal, 2);
    9389            1 :             tableBody(2, 4) = RealToStr(100.0 * totalOnsiteWater / ort->gatherWaterEndUseTotal, 2);
    9390            1 :             tableBody(2, 6) = RealToStr(100.0 * initialStorage / ort->gatherWaterEndUseTotal, 2);
    9391            1 :             tableBody(2, 7) = RealToStr(100.0 * finalStorage / ort->gatherWaterEndUseTotal, 2);
    9392            1 :             tableBody(2, 8) = RealToStr(100.0 * StorageChange / ort->gatherWaterEndUseTotal, 2);
    9393              : 
    9394            1 :             tableBody(2, 10) = RealToStr(100.0 * ort->gatherMains / ort->gatherWaterEndUseTotal, 2);
    9395              : 
    9396            1 :             tableBody(2, 12) = RealToStr(100.0 * totalWater / ort->gatherWaterEndUseTotal, 2);
    9397            1 :             tableBody(2, 13) = RealToStr(100.0, 2);
    9398              :         }
    9399              : 
    9400              :         //  ! heading for the entire sub-table
    9401          757 :         if (ort->displayTabularBEPS) {
    9402          757 :             if (produceTabular) {
    9403          757 :                 WriteSubtitle(state, "Water Source Summary");
    9404          757 :                 WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
    9405              :             }
    9406          757 :             if (produceSQLite) {
    9407          757 :                 if (state.dataSQLiteProcedures->sqlite) {
    9408          123 :                     state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
    9409              :                         tableBody, rowHead, columnHead, "AnnualBuildingUtilityPerformanceSummary", "Entire Facility", "Water Source Summary");
    9410              :                 }
    9411              :             }
    9412          757 :             if (produceTabular) {
    9413          757 :                 if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
    9414           63 :                     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          757 :             rowHead.allocate(2);
    9421          757 :             columnHead.allocate(1);
    9422          757 :             columnWidth.allocate(1);
    9423          757 :             columnWidth = 14; // array assignment - same for all columns
    9424          757 :             tableBody.allocate(1, 2);
    9425              : 
    9426          757 :             if (produceTabular) {
    9427         1514 :                 WriteSubtitle(state, "Setpoint Not Met Criteria");
    9428              :             }
    9429              : 
    9430          757 :             std::string const curNameWithSIUnits = "Degrees [deltaC]";
    9431          757 :             if (unitsStyle_cur == OutputReportTabular::UnitsStyle::InchPound ||
    9432          746 :                 unitsStyle_cur == OutputReportTabular::UnitsStyle::InchPoundExceptElectricity) {
    9433           11 :                 int indexUnitConv = -1;
    9434           11 :                 std::string curNameAndUnits;
    9435           11 :                 LookupSItoIP(state, curNameWithSIUnits, indexUnitConv, curNameAndUnits);
    9436           11 :                 columnHead(1) = curNameAndUnits;
    9437           11 :             } else {
    9438          746 :                 columnHead(1) = curNameWithSIUnits;
    9439              :             }
    9440              : 
    9441          757 :             rowHead(1) = "Tolerance for Zone Heating Setpoint Not Met Time";
    9442          757 :             rowHead(2) = "Tolerance for Zone Cooling Setpoint Not Met Time";
    9443              : 
    9444          757 :             if (!(unitsStyle_cur == OutputReportTabular::UnitsStyle::InchPound ||
    9445          746 :                   unitsStyle_cur == OutputReportTabular::UnitsStyle::InchPoundExceptElectricity)) {
    9446          746 :                 tableBody(1, 1) = RealToStr(std::abs(state.dataHVACGlobal->deviationFromSetPtThresholdHtg), 2);
    9447          746 :                 tableBody(1, 2) = RealToStr(state.dataHVACGlobal->deviationFromSetPtThresholdClg, 2);
    9448              :             } else {
    9449           11 :                 int indexUnitConv = -1;
    9450           11 :                 std::string curNameAndUnits;
    9451           11 :                 LookupSItoIP(state, curNameWithSIUnits, indexUnitConv, curNameAndUnits);
    9452           11 :                 tableBody(1, 1) = RealToStr(ConvertIPdelta(state, indexUnitConv, std::abs(state.dataHVACGlobal->deviationFromSetPtThresholdHtg)), 2);
    9453           11 :                 tableBody(1, 2) = RealToStr(ConvertIPdelta(state, indexUnitConv, state.dataHVACGlobal->deviationFromSetPtThresholdClg), 2);
    9454           11 :             }
    9455              : 
    9456          757 :             if (produceTabular) {
    9457          757 :                 WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
    9458              :             }
    9459          757 :             if (produceSQLite) {
    9460          757 :                 if (state.dataSQLiteProcedures->sqlite) {
    9461          123 :                     state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
    9462              :                         tableBody, rowHead, columnHead, "AnnualBuildingUtilityPerformanceSummary", "Entire Facility", "Setpoint Not Met Criteria");
    9463              :                 }
    9464              :             }
    9465          757 :             if (produceTabular) {
    9466          757 :                 if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
    9467           63 :                     state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(
    9468              :                         tableBody, rowHead, columnHead, "AnnualBuildingUtilityPerformanceSummary", "Entire Facility", "Setpoint Not Met Criteria");
    9469              :                 }
    9470              :             }
    9471          757 :         }
    9472              : 
    9473          757 :         rowHead.allocate(3);
    9474          757 :         columnHead.allocate(1);
    9475          757 :         columnWidth.allocate(1);
    9476          757 :         columnWidth = 14; // array assignment - same for all columns
    9477          757 :         tableBody.allocate(1, 3);
    9478              : 
    9479          757 :         if (ort->displayTabularBEPS) {
    9480          757 :             if (produceTabular) {
    9481         1514 :                 WriteSubtitle(state, "Comfort and Setpoint Not Met Summary");
    9482              :             }
    9483              :         }
    9484              : 
    9485          757 :         columnHead(1) = "Facility [Hours]";
    9486              : 
    9487          757 :         rowHead(1) = "Time Setpoint Not Met During Occupied Heating";
    9488          757 :         rowHead(2) = "Time Setpoint Not Met During Occupied Cooling";
    9489          757 :         rowHead(3) = "Time Not Comfortable Based on Simple ASHRAE 55-2004";
    9490              : 
    9491          757 :         tableBody(1, 1) = RealToStr(state.dataOutRptPredefined->TotalNotMetHeatingOccupiedForABUPS, 2);
    9492          757 :         tableBody(1, 2) = RealToStr(state.dataOutRptPredefined->TotalNotMetCoolingOccupiedForABUPS, 2);
    9493          757 :         if (produceTabular) {
    9494         1514 :             PreDefTableEntry(state,
    9495          757 :                              state.dataOutRptPredefined->pdchLeedAmData,
    9496              :                              "Number of hours heating loads not met",
    9497         1514 :                              RealToStr(state.dataOutRptPredefined->TotalNotMetHeatingOccupiedForABUPS, 2));
    9498         1514 :             PreDefTableEntry(state,
    9499          757 :                              state.dataOutRptPredefined->pdchLeedAmData,
    9500              :                              "Number of hours cooling loads not met",
    9501         1514 :                              RealToStr(state.dataOutRptPredefined->TotalNotMetCoolingOccupiedForABUPS, 2));
    9502         1514 :             PreDefTableEntry(state,
    9503          757 :                              state.dataOutRptPredefined->pdchLeedAmData,
    9504              :                              "Number of hours not met",
    9505         1514 :                              RealToStr(state.dataOutRptPredefined->TotalNotMetOccupiedForABUPS, 2));
    9506              :         }
    9507          757 :         tableBody(1, 3) = RealToStr(state.dataOutRptPredefined->TotalTimeNotSimpleASH55EitherForABUPS, 2);
    9508              : 
    9509          757 :         if (ort->displayTabularBEPS) {
    9510          757 :             if (produceTabular) {
    9511          757 :                 WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
    9512              :             }
    9513          757 :             if (produceSQLite) {
    9514          757 :                 if (state.dataSQLiteProcedures->sqlite) {
    9515          123 :                     state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(tableBody,
    9516              :                                                                                        rowHead,
    9517              :                                                                                        columnHead,
    9518              :                                                                                        "AnnualBuildingUtilityPerformanceSummary",
    9519              :                                                                                        "Entire Facility",
    9520              :                                                                                        "Comfort and Setpoint Not Met Summary");
    9521              :                 }
    9522              :             }
    9523          757 :             if (produceTabular) {
    9524          757 :                 if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
    9525           63 :                     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          757 :     if (ort->displayTabularBEPS) {
    9539         1514 :         WriteTextLine(state, "Note 1: An asterisk (*) indicates that the feature is not yet implemented.");
    9540              :     }
    9541          757 : }
    9542              : 
    9543            0 : std::string ResourceWarningMessage(std::string const &resource)
    9544              : {
    9545            0 :     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          757 : Real64 WaterConversionFunct(Real64 WaterTotal, Real64 ConversionFactor)
    9549              : {
    9550          757 :     return WaterTotal / ConversionFactor;
    9551              : }
    9552              : 
    9553         1514 : 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         1514 :     auto const &ort = state.dataOutRptTab;
    9564         1514 :     auto &op = state.dataOutputProcessor;
    9565         1514 :     constexpr int numCol = 15;
    9566         1514 :     Array1D_string columnHead;
    9567         1514 :     Array1D_int columnWidth;
    9568         1514 :     columnHead.allocate(numCol);
    9569         1514 :     columnWidth.allocate(numCol);
    9570        24224 :     for (int col = 1; col <= numCol; ++col) {
    9571        22710 :         columnWidth(col) = 10; // array assignment - same for all columns
    9572              :     }
    9573         1514 :     switch (unitsStyle_cur) {
    9574           12 :     case UnitsStyle::JtoKWH: {
    9575           12 :         columnHead(2) = "Electricity [kWh]";
    9576           12 :         columnHead(3) = "Natural Gas [kWh]";
    9577           12 :         columnHead(4) = "Gasoline [kWh]";
    9578           12 :         columnHead(5) = "Diesel [kWh]";
    9579           12 :         columnHead(6) = "Coal [kWh]";
    9580           12 :         columnHead(7) = "Fuel Oil No 1 [kWh]";
    9581           12 :         columnHead(8) = "Fuel Oil No 2 [kWh]";
    9582           12 :         columnHead(9) = "Propane [kWh]";
    9583           12 :         columnHead(10) = "Other Fuel 1 [kWh]";
    9584           12 :         columnHead(11) = "Other Fuel 2 [kWh]";
    9585           12 :         columnHead(12) = "District Cooling [kWh]";
    9586           12 :         columnHead(13) = "District Heating Water [kWh]";
    9587           12 :         columnHead(14) = "District Heating Steam [kWh]";
    9588           12 :         columnHead(15) = "Water [m3]";
    9589           12 :     } break;
    9590           22 :     case UnitsStyle::InchPound: {
    9591           22 :         columnHead(2) = "Electricity [kBtu]";
    9592           22 :         columnHead(3) = "Natural Gas [kBtu]";
    9593           22 :         columnHead(4) = "Gasoline [kBtu]";
    9594           22 :         columnHead(5) = "Diesel [kBtu]";
    9595           22 :         columnHead(6) = "Coal [kBtu]";
    9596           22 :         columnHead(7) = "Fuel Oil No 1 [kBtu]";
    9597           22 :         columnHead(8) = "Fuel Oil No 2 [kBtu]";
    9598           22 :         columnHead(9) = "Propane [kBtu]";
    9599           22 :         columnHead(10) = "Other Fuel 1 [kBtu]";
    9600           22 :         columnHead(11) = "Other Fuel 2 [kBtu]";
    9601           22 :         columnHead(12) = "District Cooling [kBtu]";
    9602           22 :         columnHead(13) = "District Heating Water [kBtu]";
    9603           22 :         columnHead(14) = "District Heating Steam [kBtu]";
    9604           22 :         columnHead(15) = "Water [gal]";
    9605           22 :     } break;
    9606            0 :     case UnitsStyle::InchPoundExceptElectricity: {
    9607            0 :         columnHead(2) = "Electricity [kWh]";
    9608            0 :         columnHead(3) = "Natural Gas [kBtu]";
    9609            0 :         columnHead(4) = "Gasoline [kBtu]";
    9610            0 :         columnHead(5) = "Diesel [kBtu]";
    9611            0 :         columnHead(6) = "Coal [kBtu]";
    9612            0 :         columnHead(7) = "Fuel Oil No 1 [kBtu]";
    9613            0 :         columnHead(8) = "Fuel Oil No 2 [kBtu]";
    9614            0 :         columnHead(9) = "Propane [kBtu]";
    9615            0 :         columnHead(10) = "Other Fuel 1 [kBtu]";
    9616            0 :         columnHead(11) = "Other Fuel 2 [kBtu]";
    9617            0 :         columnHead(12) = "District Cooling [kBtu]";
    9618            0 :         columnHead(13) = "District Heating Water [kBtu]";
    9619            0 :         columnHead(14) = "District Heating Steam [kBtu]";
    9620            0 :         columnHead(15) = "Water [gal]";
    9621            0 :     } break;
    9622         1480 :     default: {
    9623         1480 :         columnHead(2) = "Electricity [GJ]";
    9624         1480 :         columnHead(3) = "Natural Gas [GJ]";
    9625         1480 :         columnHead(4) = "Gasoline [GJ]";
    9626         1480 :         columnHead(5) = "Diesel [GJ]";
    9627         1480 :         columnHead(6) = "Coal [GJ]";
    9628         1480 :         columnHead(7) = "Fuel Oil No 1 [GJ]";
    9629         1480 :         columnHead(8) = "Fuel Oil No 2 [GJ]";
    9630         1480 :         columnHead(9) = "Propane [GJ]";
    9631         1480 :         columnHead(10) = "Other Fuel 1 [GJ]";
    9632         1480 :         columnHead(11) = "Other Fuel 2 [GJ]";
    9633         1480 :         columnHead(12) = "District Cooling [GJ]";
    9634         1480 :         columnHead(13) = "District Heating Water [GJ]";
    9635         1480 :         columnHead(14) = "District Heating Steam [GJ]";
    9636         1480 :         columnHead(15) = "Water [m3]";
    9637         1480 :     } break;
    9638              :     }
    9639              : 
    9640         1514 :     int numSubCatOrTypes = 0;
    9641         1514 :     int numRows = 0;
    9642         1514 :     if (tableType == EndUseSubTableType::BySubCategory) {
    9643          757 :         columnHead(1) = "Subcategory";
    9644          757 :     } else if (tableType == EndUseSubTableType::BySpaceType) {
    9645          757 :         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        22710 :     for (int i = 1; i <= static_cast<int>(Constant::EndUse::Num); ++i) {
    9651        21196 :         needOtherRow(i) = false; // set array to all false assuming no other rows are needed
    9652              :     }
    9653        22710 :     for (int iResource = 1; iResource <= 14; ++iResource) {
    9654       317940 :         for (int jEndUse = 1; jEndUse <= static_cast<int>(Constant::EndUse::Num); ++jEndUse) {
    9655       296744 :             if (tableType == EndUseSubTableType::BySubCategory) {
    9656       148372 :                 numSubCatOrTypes = op->EndUseCategory(jEndUse).NumSubcategories;
    9657       148372 :             } else if (tableType == EndUseSubTableType::BySpaceType) {
    9658       148372 :                 numSubCatOrTypes = op->EndUseCategory(jEndUse).numSpaceTypes;
    9659              :             }
    9660       296744 :             if (numSubCatOrTypes > 0) {
    9661              :                 // set the value to the total for the end use
    9662        92484 :                 endUseSubOther(iResource, jEndUse) = collapsedEndUse(iResource, jEndUse);
    9663              :                 // subtract off each sub end use category value
    9664       199374 :                 for (int kEndUseSub = 1; kEndUseSub <= numSubCatOrTypes; ++kEndUseSub) {
    9665       106890 :                     endUseSubOther(iResource, jEndUse) -= collapsedEndUseSubTable(kEndUseSub, jEndUse, iResource);
    9666              :                 }
    9667              :                 // if just a small value remains set it to zero
    9668        92484 :                 if (std::abs(endUseSubOther(iResource, jEndUse)) > 0.01) {
    9669            0 :                     needOtherRow(jEndUse) = true;
    9670              :                 } else {
    9671        92484 :                     endUseSubOther(iResource, jEndUse) = 0.0;
    9672              :                 }
    9673              :             } else {
    9674       204260 :                 endUseSubOther(iResource, jEndUse) = 0.0;
    9675              :             }
    9676              :         }
    9677              :     }
    9678              : 
    9679        22710 :     for (int jEndUse = 1; jEndUse <= static_cast<int>(Constant::EndUse::Num); ++jEndUse) {
    9680        21196 :         if (tableType == EndUseSubTableType::BySubCategory) {
    9681        10598 :             numSubCatOrTypes = op->EndUseCategory(jEndUse).NumSubcategories;
    9682        10598 :         } else if (tableType == EndUseSubTableType::BySpaceType) {
    9683        10598 :             numSubCatOrTypes = op->EndUseCategory(jEndUse).numSpaceTypes;
    9684              :         }
    9685        21196 :         if (numSubCatOrTypes > 0) {
    9686        14241 :             for (int kEndUseSub = 1; kEndUseSub <= numSubCatOrTypes; ++kEndUseSub) {
    9687         7635 :                 ++numRows;
    9688              :             }
    9689         6606 :             if (needOtherRow(jEndUse)) {
    9690            0 :                 ++numRows;
    9691              :             }
    9692              :         } else {
    9693        14590 :             ++numRows;
    9694              :         }
    9695              :     }
    9696              :     // all arrays are in the format: (row, column)
    9697         3028 :     Array1D_string rowHead;
    9698         3028 :     Array2D_string tableBody;
    9699         1514 :     rowHead.allocate(numRows);
    9700         1514 :     tableBody.allocate(numCol, numRows); // TODO: this appears to be (column, row)...
    9701        24224 :     for (int col = 1; col <= numCol; ++col) {
    9702       356085 :         for (int row = 1; row <= numRows; ++row) {
    9703       333375 :             rowHead(row) = "";
    9704       333375 :             tableBody(col, row) = "";
    9705              :         }
    9706              :     }
    9707              : 
    9708              :     // Build row head and subcategories columns
    9709              :     {
    9710         1514 :         int i = 1;
    9711        22710 :         for (int jEndUse = 1; jEndUse <= static_cast<int>(Constant::EndUse::Num); ++jEndUse) {
    9712        21196 :             if (tableType == EndUseSubTableType::BySubCategory) {
    9713        10598 :                 numSubCatOrTypes = op->EndUseCategory(jEndUse).NumSubcategories;
    9714        10598 :             } else if (tableType == EndUseSubTableType::BySpaceType) {
    9715        10598 :                 numSubCatOrTypes = op->EndUseCategory(jEndUse).numSpaceTypes;
    9716              :             }
    9717        21196 :             rowHead(i) = op->EndUseCategory(jEndUse).DisplayName;
    9718        21196 :             if (numSubCatOrTypes > 0) {
    9719        14241 :                 for (int kEndUseSub = 1; kEndUseSub <= numSubCatOrTypes; ++kEndUseSub) {
    9720         7635 :                     if (tableType == EndUseSubTableType::BySubCategory) {
    9721         6316 :                         tableBody(1, i) = op->EndUseCategory(jEndUse).SubcategoryName(kEndUseSub);
    9722         1319 :                     } else if (tableType == EndUseSubTableType::BySpaceType) {
    9723         1319 :                         tableBody(1, i) = op->EndUseCategory(jEndUse).spaceTypeName(kEndUseSub);
    9724              :                     }
    9725         7635 :                     ++i;
    9726              :                 }
    9727              :                 // check if an 'other' row is needed
    9728         6606 :                 if (needOtherRow(jEndUse)) {
    9729            0 :                     tableBody(1, i) = "Other";
    9730            0 :                     ++i;
    9731              :                 }
    9732              :             } else {
    9733        14590 :                 if (tableType == EndUseSubTableType::BySubCategory) {
    9734         5290 :                     tableBody(1, i) = "General";
    9735         9300 :                 } else if (tableType == EndUseSubTableType::BySpaceType) {
    9736         9300 :                     tableBody(1, i) = "Unassigned";
    9737              :                 }
    9738        14590 :                 ++i;
    9739              :             }
    9740              :         }
    9741              :     }
    9742              : 
    9743        22710 :     for (int iResource = 1; iResource <= 14; ++iResource) {
    9744        21196 :         int i = 1;
    9745       317940 :         for (int jEndUse = 1; jEndUse <= static_cast<int>(Constant::EndUse::Num); ++jEndUse) {
    9746       296744 :             if (tableType == EndUseSubTableType::BySubCategory) {
    9747       148372 :                 numSubCatOrTypes = op->EndUseCategory(jEndUse).NumSubcategories;
    9748       148372 :             } else if (tableType == EndUseSubTableType::BySpaceType) {
    9749       148372 :                 numSubCatOrTypes = op->EndUseCategory(jEndUse).numSpaceTypes;
    9750              :             }
    9751       296744 :             if (numSubCatOrTypes > 0) {
    9752       199374 :                 for (int kEndUseSub = 1; kEndUseSub <= numSubCatOrTypes; ++kEndUseSub) {
    9753       106890 :                     tableBody(iResource + 1, i) = RealToStr(collapsedEndUseSubTable(kEndUseSub, jEndUse, iResource), 2);
    9754       106890 :                     ++i;
    9755              :                 }
    9756              :                 // put other
    9757        92484 :                 if (needOtherRow(jEndUse)) {
    9758            0 :                     tableBody(iResource + 1, i) = RealToStr(endUseSubOther(iResource, jEndUse), 2);
    9759            0 :                     ++i;
    9760              :                 }
    9761              :             } else {
    9762       204260 :                 tableBody(iResource + 1, i) = RealToStr(collapsedEndUse(iResource, jEndUse), 2);
    9763       204260 :                 ++i;
    9764              :             }
    9765              :         }
    9766              :     }
    9767              : 
    9768              :     // heading for the entire sub-table
    9769         1514 :     if (ort->displayTabularBEPS) {
    9770         1514 :         std::string subTableTitle;
    9771         1514 :         if (tableType == EndUseSubTableType::BySubCategory) {
    9772          757 :             subTableTitle = "End Uses By Subcategory";
    9773          757 :         } else if (tableType == EndUseSubTableType::BySpaceType) {
    9774          757 :             subTableTitle = "End Uses By Space Type";
    9775              :         }
    9776         1514 :         if (produceTabular) {
    9777         1514 :             WriteSubtitle(state, subTableTitle);
    9778         1514 :             WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
    9779              :         }
    9780         1514 :         Array1D_string rowHeadTemp(rowHead);
    9781              :         // Before outputting to SQL, we forward fill the End use column (rowHead)
    9782              :         // for better sql queries
    9783         1514 :         FillRowHead(rowHeadTemp);
    9784              : 
    9785        23739 :         for (int i = 1; i <= numRows; ++i) {
    9786        22225 :             rowHeadTemp(i) = rowHeadTemp(i) + ":" + tableBody(1, i);
    9787              :         }
    9788              : 
    9789              :         // Erase the SubCategory (first column), using slicing
    9790        10598 :         Array2D_string tableBodyTemp(tableBody({2, _, _}, {_, _, _}));
    9791         6056 :         Array1D_string columnHeadTemp(columnHead({2, _, _}));
    9792         1514 :         if (produceSQLite) {
    9793         1514 :             if (state.dataSQLiteProcedures->sqlite) {
    9794          246 :                 state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
    9795              :                     tableBodyTemp, rowHeadTemp, columnHeadTemp, "AnnualBuildingUtilityPerformanceSummary", "Entire Facility", subTableTitle);
    9796              :             }
    9797              :         }
    9798         1514 :         if (produceTabular) {
    9799         1514 :             if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
    9800           90 :                 state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(
    9801              :                     tableBodyTemp, rowHeadTemp, columnHeadTemp, "AnnualBuildingUtilityPerformanceSummary", "Entire Facility", subTableTitle);
    9802              :             }
    9803              :         }
    9804         1514 :         rowHeadTemp.deallocate();
    9805         1514 :         tableBodyTemp.deallocate();
    9806         1514 :         columnHeadTemp.deallocate();
    9807         1514 :     }
    9808         4542 : }
    9809          759 : 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          759 :     auto &ort = state.dataOutRptTab;
    9825              : 
    9826          759 :     if (!ort->displaySourceEnergyEndUseSummary) {
    9827           82 :         return;
    9828              :     }
    9829              : 
    9830              :     // all arrays are in the format: (row, column)
    9831          677 :     Array1D_string columnHead;
    9832          677 :     Array1D_int columnWidth;
    9833          677 :     Array1D_string rowHead;
    9834          677 :     Array2D_string tableBody;
    9835              : 
    9836              :     // all arrays are in the format: (row, columnm)
    9837          677 :     Array2D<Real64> useVal(14, 15);
    9838          677 :     Array1D<Real64> collapsedTotal(14);
    9839          677 :     Array2D<Real64> collapsedEndUse(14, static_cast<int>(Constant::EndUse::Num));
    9840          677 :     Array3D<Real64> collapsedEndUseSub(state.dataOutputProcessor->MaxNumSubcategories, static_cast<int>(Constant::EndUse::Num), 14);
    9841              : 
    9842              :     // show the headers of the report
    9843         2031 :     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          677 :     WriteTextLine(state, "Values gathered over " + RealToStr(ort->gatherElapsedTimeBEPS, 2) + " hours", true);
    9846          677 :     if (ort->gatherElapsedTimeBEPS < 8759.0) { // might not add up to 8760 exactly but can't be more than 1 hour diff.
    9847         1342 :         WriteTextLine(state, "WARNING: THE REPORT DOES NOT REPRESENT A FULL ANNUAL SIMULATION.", true);
    9848              :     }
    9849          677 :     WriteTextLine(state, "", true);
    9850              : 
    9851              :     // determine building floor areas
    9852          677 :     DetermineBuildingFloorArea(state);
    9853              : 
    9854         1354 :     for (int iUnitSystem = 0; iUnitSystem <= 1; iUnitSystem++) {
    9855         1354 :         UnitsStyle unitsStyle_cur = ort->unitsStyle;
    9856         1354 :         bool produceTabular = true;
    9857         1354 :         bool produceSQLite = false;
    9858         1354 :         if (produceDualUnitsFlags(iUnitSystem, ort->unitsStyle, ort->unitsStyle_SQLite, unitsStyle_cur, produceTabular, produceSQLite)) {
    9859          677 :             break;
    9860              :         }
    9861              : 
    9862              :         // collapse the gatherEndUseBEPS array to the resource groups displayed
    9863        10155 :         for (int jEndUse = 1; jEndUse <= static_cast<int>(Constant::EndUse::Num); ++jEndUse) {
    9864         9478 :             collapsedEndUse(1, jEndUse) = ort->gatherEndUseBySourceBEPS(1, jEndUse);   // electricity
    9865         9478 :             collapsedEndUse(2, jEndUse) = ort->gatherEndUseBySourceBEPS(2, jEndUse);   // natural gas
    9866         9478 :             collapsedEndUse(3, jEndUse) = ort->gatherEndUseBySourceBEPS(6, jEndUse);   // gasoline
    9867         9478 :             collapsedEndUse(4, jEndUse) = ort->gatherEndUseBySourceBEPS(8, jEndUse);   // diesel
    9868         9478 :             collapsedEndUse(5, jEndUse) = ort->gatherEndUseBySourceBEPS(9, jEndUse);   // coal
    9869         9478 :             collapsedEndUse(6, jEndUse) = ort->gatherEndUseBySourceBEPS(10, jEndUse);  // Fuel Oil No1
    9870         9478 :             collapsedEndUse(7, jEndUse) = ort->gatherEndUseBySourceBEPS(11, jEndUse);  // Fuel Oil No2
    9871         9478 :             collapsedEndUse(8, jEndUse) = ort->gatherEndUseBySourceBEPS(12, jEndUse);  // propane
    9872         9478 :             collapsedEndUse(9, jEndUse) = ort->gatherEndUseBySourceBEPS(13, jEndUse);  // otherfuel1
    9873         9478 :             collapsedEndUse(10, jEndUse) = ort->gatherEndUseBySourceBEPS(14, jEndUse); // otherfuel2
    9874         9478 :             collapsedEndUse(11, jEndUse) = ort->gatherEndUseBySourceBEPS(3, jEndUse);  // district cooling <- purchased cooling
    9875         9478 :             collapsedEndUse(12, jEndUse) = ort->gatherEndUseBySourceBEPS(4, jEndUse);  // district heating water <- purchased heating
    9876         9478 :             collapsedEndUse(13, jEndUse) = ort->gatherEndUseBySourceBEPS(5, jEndUse);  // district heating steam <- purchased heating
    9877         9478 :             collapsedEndUse(14, jEndUse) = ort->gatherEndUseBySourceBEPS(7, jEndUse);  // water
    9878              :         }
    9879              :         // repeat with totals
    9880          677 :         collapsedTotal(1) = ort->gatherTotalsBySourceBEPS(1);   // electricity
    9881          677 :         collapsedTotal(2) = ort->gatherTotalsBySourceBEPS(2);   // natural gas
    9882          677 :         collapsedTotal(3) = ort->gatherTotalsBySourceBEPS(6);   // gasoline
    9883          677 :         collapsedTotal(4) = ort->gatherTotalsBySourceBEPS(8);   // diesel
    9884          677 :         collapsedTotal(5) = ort->gatherTotalsBySourceBEPS(9);   // coal
    9885          677 :         collapsedTotal(6) = ort->gatherTotalsBySourceBEPS(10);  // Fuel Oil No1
    9886          677 :         collapsedTotal(7) = ort->gatherTotalsBySourceBEPS(11);  // Fuel Oil No2
    9887          677 :         collapsedTotal(8) = ort->gatherTotalsBySourceBEPS(12);  // propane
    9888          677 :         collapsedTotal(9) = ort->gatherTotalsBySourceBEPS(13);  // otherfuel1
    9889          677 :         collapsedTotal(10) = ort->gatherTotalsBySourceBEPS(14); // otherfuel2
    9890          677 :         collapsedTotal(11) = ort->gatherTotalsBySourceBEPS(3);  // district cooling <- purchased cooling
    9891          677 :         collapsedTotal(12) = ort->gatherTotalsBySourceBEPS(4);  // district heating water <- purchased heating
    9892          677 :         collapsedTotal(13) = ort->gatherTotalsBySourceBEPS(5);  // district heating steam <- purchased heating
    9893          677 :         collapsedTotal(14) = ort->gatherTotalsBySourceBEPS(7);  // water
    9894              : 
    9895              :         // unit conversion - all values are used as divisors
    9896              :         Real64 largeConversionFactor;
    9897              :         Real64 areaConversionFactor;
    9898          677 :         Real64 ipElectricityConversionFactor = 1.0;
    9899          677 :         switch (unitsStyle_cur) {
    9900            6 :         case UnitsStyle::JtoKWH: {
    9901            6 :             largeConversionFactor = 3600000.0;
    9902            6 :             areaConversionFactor = 1.0;
    9903            6 :         } break;
    9904           11 :         case UnitsStyle::InchPound: {
    9905           44 :             largeConversionFactor = getSpecificUnitDivider(state, "J", "kBtu"); // 1054351.84 J to kBtu
    9906           33 :             areaConversionFactor = getSpecificUnitDivider(state, "m2", "ft2");  // 0.092893973 m2 to ft2
    9907           11 :         } break;
    9908            0 :         case UnitsStyle::InchPoundExceptElectricity: {
    9909            0 :             largeConversionFactor = getSpecificUnitDivider(state, "J", "kBtu"); // 1054351.84 J to kBtu
    9910            0 :             areaConversionFactor = getSpecificUnitDivider(state, "m2", "ft2");  // 0.092893973 m2 to ft2
    9911            0 :             ipElectricityConversionFactor = largeConversionFactor / (1000.0 * 3600.0);
    9912            0 :         } break;
    9913          660 :         default: {
    9914          660 :             largeConversionFactor = 1000000.0; // to MJ
    9915          660 :             areaConversionFactor = 1.0;
    9916          660 :         } break;
    9917              :         }
    9918              : 
    9919              :         // convert units into MJ (divide by 1,000,000) if J otherwise kWh
    9920         9478 :         for (int iResource = 1; iResource <= 13; ++iResource) { // don't do water
    9921         8801 :             Real64 ipElectricityAdjust = (iResource == 1) ? ipElectricityConversionFactor : 1.0;
    9922       132015 :             for (int jEndUse = 1; jEndUse <= static_cast<int>(Constant::EndUse::Num); ++jEndUse) {
    9923       123214 :                 collapsedEndUse(iResource, jEndUse) /= (largeConversionFactor / ipElectricityAdjust);
    9924              :             }
    9925         8801 :             collapsedTotal(iResource) /= (largeConversionFactor / ipElectricityAdjust);
    9926              :         }
    9927              : 
    9928          677 :         rowHead.allocate(16);
    9929          677 :         columnHead.allocate(13);
    9930          677 :         columnWidth.allocate(13);
    9931          677 :         columnWidth = 10; // array assignment - same for all columns
    9932          677 :         tableBody.allocate(13, 16);
    9933        10155 :         for (int iResource = 1; iResource <= 14; ++iResource) {
    9934       142170 :             for (int iEndUse = 0; iEndUse < static_cast<int>(Constant::EndUse::Num); ++iEndUse) {
    9935       132692 :                 useVal(iResource, iEndUse + 1) = collapsedEndUse(iResource, iEndUse + 1);
    9936              :             }
    9937         9478 :             useVal(iResource, 15) = collapsedTotal(iResource); // totals
    9938              :         }
    9939              : 
    9940          677 :         rowHead(static_cast<int>(Constant::EndUse::Heating) + 1) = "Heating";
    9941          677 :         rowHead(static_cast<int>(Constant::EndUse::Cooling) + 1) = "Cooling";
    9942          677 :         rowHead(static_cast<int>(Constant::EndUse::InteriorLights) + 1) = "Interior Lighting";
    9943          677 :         rowHead(static_cast<int>(Constant::EndUse::ExteriorLights) + 1) = "Exterior Lighting";
    9944          677 :         rowHead(static_cast<int>(Constant::EndUse::InteriorEquipment) + 1) = "Interior Equipment";
    9945          677 :         rowHead(static_cast<int>(Constant::EndUse::ExteriorEquipment) + 1) = "Exterior Equipment";
    9946          677 :         rowHead(static_cast<int>(Constant::EndUse::Fans) + 1) = "Fans";
    9947          677 :         rowHead(static_cast<int>(Constant::EndUse::Pumps) + 1) = "Pumps";
    9948          677 :         rowHead(static_cast<int>(Constant::EndUse::HeatRejection) + 1) = "Heat Rejection";
    9949          677 :         rowHead(static_cast<int>(Constant::EndUse::Humidification) + 1) = "Humidification";
    9950          677 :         rowHead(static_cast<int>(Constant::EndUse::HeatRecovery) + 1) = "Heat Recovery";
    9951          677 :         rowHead(static_cast<int>(Constant::EndUse::WaterSystem) + 1) = "Water Systems";
    9952          677 :         rowHead(static_cast<int>(Constant::EndUse::Refrigeration) + 1) = "Refrigeration";
    9953          677 :         rowHead(static_cast<int>(Constant::EndUse::Cogeneration) + 1) = "Generators";
    9954          677 :         rowHead(15) = "";
    9955          677 :         rowHead(16) = "Total Source Energy End Use Components";
    9956              : 
    9957          677 :         largeConversionFactor = 1.0;
    9958              : 
    9959          677 :         switch (unitsStyle_cur) {
    9960            6 :         case UnitsStyle::JtoKWH: {
    9961            6 :             columnHead(1) = "Source Electricity [kWh]";
    9962            6 :             columnHead(2) = "Source Natural Gas [kWh]";
    9963            6 :             columnHead(3) = "Source Gasoline [kWh]";
    9964            6 :             columnHead(4) = "Source Diesel [kWh]";
    9965            6 :             columnHead(5) = "Source Coal [kWh]";
    9966            6 :             columnHead(6) = "Source Fuel Oil No 1 [kWh]";
    9967            6 :             columnHead(7) = "Source Fuel Oil No 2 [kWh]";
    9968            6 :             columnHead(8) = "Source Propane [kWh]";
    9969            6 :             columnHead(9) = "Source Other Fuel 1 [kWh]";
    9970            6 :             columnHead(10) = "Source Other Fuel 2 [kWh]";
    9971            6 :             columnHead(11) = "Source District Cooling [kWh]";
    9972            6 :             columnHead(12) = "Source District Heating Water [kWh]";
    9973            6 :             columnHead(13) = "Source District Heating Steam [kWh]";
    9974            6 :         } break;
    9975           11 :         case UnitsStyle::InchPound: {
    9976           11 :             columnHead(1) = "Source Electricity [kBtu]";
    9977           11 :             columnHead(2) = "Source Natural Gas [kBtu]";
    9978           11 :             columnHead(3) = "Source Gasoline [kBtu]";
    9979           11 :             columnHead(4) = "Source Diesel [kBtu]";
    9980           11 :             columnHead(5) = "Source Coal [kBtu]";
    9981           11 :             columnHead(6) = "Source Fuel Oil No 1 [kBtu]";
    9982           11 :             columnHead(7) = "Source Fuel Oil No 2 [kBtu]";
    9983           11 :             columnHead(8) = "Source Propane [kBtu]";
    9984           11 :             columnHead(9) = "Source Other Fuel 1 [kBtu]";
    9985           11 :             columnHead(10) = "Source Other Fuel 2 [kBtu]";
    9986           11 :             columnHead(11) = "Source District Cooling [kBtu]";
    9987           11 :             columnHead(12) = "Source District Heating Water [kBtu]";
    9988           11 :             columnHead(13) = "Source District Heating Steam [kBtu]";
    9989           11 :         } break;
    9990            0 :         case UnitsStyle::InchPoundExceptElectricity: {
    9991            0 :             columnHead(1) = "Source Electricity [kWh]";
    9992            0 :             columnHead(2) = "Source Natural Gas [kBtu]";
    9993            0 :             columnHead(3) = "Source Gasoline [kBtu]";
    9994            0 :             columnHead(4) = "Source Diesel [kBtu]";
    9995            0 :             columnHead(5) = "Source Coal [kBtu]";
    9996            0 :             columnHead(6) = "Source Fuel Oil No 1 [kBtu]";
    9997            0 :             columnHead(7) = "Source Fuel Oil No 2 [kBtu]";
    9998            0 :             columnHead(8) = "Source Propane [kBtu]";
    9999            0 :             columnHead(9) = "Source Other Fuel 1 [kBtu]";
   10000            0 :             columnHead(10) = "Source Other Fuel 2 [kBtu]";
   10001            0 :             columnHead(11) = "Source District Cooling [kBtu]";
   10002            0 :             columnHead(12) = "Source District Heating Water [kBtu]";
   10003            0 :             columnHead(13) = "Source District Heating Steam [kBtu]";
   10004            0 :         } break;
   10005          660 :         default: {
   10006          660 :             columnHead(1) = "Source Electricity [GJ]";
   10007          660 :             columnHead(2) = "Source Natural Gas [GJ]";
   10008          660 :             columnHead(3) = "Source Gasoline [GJ]";
   10009          660 :             columnHead(4) = "Source Diesel [GJ]";
   10010          660 :             columnHead(5) = "Source Coal [GJ]";
   10011          660 :             columnHead(6) = "Source Fuel Oil No 1 [GJ]";
   10012          660 :             columnHead(7) = "Source Fuel Oil No 2 [GJ]";
   10013          660 :             columnHead(8) = "Source Propane [GJ]";
   10014          660 :             columnHead(9) = "Source Other Fuel 1 [GJ]";
   10015          660 :             columnHead(10) = "Source Other Fuel 2 [GJ]";
   10016          660 :             columnHead(11) = "Source District Cooling [GJ]";
   10017          660 :             columnHead(12) = "Source District Heating Water [GJ]";
   10018          660 :             columnHead(13) = "Source District Heating Steam [GJ]";
   10019          660 :             largeConversionFactor = 1000.0; // for converting MJ to GJ
   10020          660 :         } break;
   10021              :         }
   10022              : 
   10023              :         //---- End Uses by Source Energy Sub-Table
   10024              : 
   10025          677 :         tableBody = "";
   10026         9478 :         for (int iResource = 1; iResource <= 13; ++iResource) {
   10027       132015 :             for (int jEndUse = 1; jEndUse <= static_cast<int>(Constant::EndUse::Num); ++jEndUse) {
   10028       123214 :                 tableBody(iResource, jEndUse) = RealToStr(useVal(iResource, jEndUse) / largeConversionFactor, 2);
   10029              :             }
   10030         8801 :             tableBody(iResource, 16) = RealToStr(useVal(iResource, 15) / largeConversionFactor, 2);
   10031              :         }
   10032              : 
   10033              :         // heading for the entire sub-table
   10034          677 :         if (produceTabular) {
   10035          677 :             WriteSubtitle(state, "Source Energy End Use Components Summary");
   10036          677 :             WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
   10037              :         }
   10038          677 :         if (produceSQLite) {
   10039          677 :             if (state.dataSQLiteProcedures->sqlite) {
   10040           75 :                 state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(tableBody,
   10041              :                                                                                    rowHead,
   10042              :                                                                                    columnHead,
   10043              :                                                                                    "SourceEnergyEndUseComponentsSummary",
   10044              :                                                                                    "Entire Facility",
   10045              :                                                                                    "Source Energy End Use Components Summary");
   10046              :             }
   10047              :         }
   10048          677 :         if (produceTabular) {
   10049          677 :             if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
   10050           56 :                 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          677 :         switch (unitsStyle_cur) {
   10062            6 :         case UnitsStyle::JtoKWH: {
   10063            6 :             columnHead(1) = "Source Electricity [kWh/m2]";
   10064            6 :             columnHead(2) = "Source Natural Gas [kWh/m2]";
   10065            6 :             columnHead(3) = "Source Gasoline [kWh/m2]";
   10066            6 :             columnHead(4) = "Source Diesel [kWh/m2]";
   10067            6 :             columnHead(5) = "Source Coal [kWh/m2]";
   10068            6 :             columnHead(6) = "Source Fuel Oil No 1 [kWh/m2]";
   10069            6 :             columnHead(7) = "Source Fuel Oil No 2 [kWh/m2]";
   10070            6 :             columnHead(8) = "Source Propane [kWh/m2]";
   10071            6 :             columnHead(9) = "Source Other Fuel 1 [kWh/m2]";
   10072            6 :             columnHead(10) = "Source Other Fuel 2 [kWh/m2]";
   10073            6 :             columnHead(11) = "Source District Cooling [kWh/m2]";
   10074            6 :             columnHead(12) = "Source District Heating Water [kWh/m2]";
   10075            6 :             columnHead(13) = "Source District Heating Steam [kWh/m2]";
   10076            6 :         } break;
   10077           11 :         case UnitsStyle::InchPound: {
   10078           11 :             columnHead(1) = "Source Electricity [kBtu/ft2]";
   10079           11 :             columnHead(2) = "Source Natural Gas [kBtu/ft2]";
   10080           11 :             columnHead(3) = "Source Gasoline [kBtu/ft2]";
   10081           11 :             columnHead(4) = "Source Diesel [kBtu/ft2]";
   10082           11 :             columnHead(5) = "Source Coal [kBtu/ft2]";
   10083           11 :             columnHead(6) = "Source Fuel Oil No 1 [kBtu/ft2]";
   10084           11 :             columnHead(7) = "Source Fuel Oil No 2 [kBtu/ft2]";
   10085           11 :             columnHead(8) = "Source Propane [kBtu/ft2]";
   10086           11 :             columnHead(9) = "Source Other Fuel 1 [kBtu/ft2]";
   10087           11 :             columnHead(10) = "Source Other Fuel 2 [kBtu/ft2]";
   10088           11 :             columnHead(11) = "Source District Cooling [kBtu/ft2]";
   10089           11 :             columnHead(12) = "Source District Heating Water [kBtu/ft2]";
   10090           11 :             columnHead(13) = "Source District Heating Steam [kBtu/ft2]";
   10091           11 :         } break;
   10092            0 :         case UnitsStyle::InchPoundExceptElectricity: {
   10093            0 :             columnHead(1) = "Source Electricity [kWh/ft2]";
   10094            0 :             columnHead(2) = "Source Natural Gas [kBtu/ft2]";
   10095            0 :             columnHead(3) = "Source Gasoline [kBtu/ft2]";
   10096            0 :             columnHead(4) = "Source Diesel [kBtu/ft2]";
   10097            0 :             columnHead(5) = "Source Coal [kBtu/ft2]";
   10098            0 :             columnHead(6) = "Source Fuel Oil No 1 [kBtu/ft2]";
   10099            0 :             columnHead(7) = "Source Fuel Oil No 2 [kBtu/ft2]";
   10100            0 :             columnHead(8) = "Source Propane [kBtu/ft2]";
   10101            0 :             columnHead(9) = "Source Other Fuel 1 [kBtu/ft2]";
   10102            0 :             columnHead(10) = "Source Other Fuel 2 [kBtu/ft2]";
   10103            0 :             columnHead(11) = "Source District Cooling [kBtu/ft2]";
   10104            0 :             columnHead(12) = "Source District Heating Water [kBtu/ft2]";
   10105            0 :             columnHead(13) = "Source District Heating Steam [kBtu/ft2]";
   10106            0 :         } break;
   10107          660 :         default: {
   10108          660 :             columnHead(1) = "Source Electricity [MJ/m2]";
   10109          660 :             columnHead(2) = "Source Natural Gas [MJ/m2]";
   10110          660 :             columnHead(3) = "Source Gasoline [MJ/m2]";
   10111          660 :             columnHead(4) = "Source Diesel [MJ/m2]";
   10112          660 :             columnHead(5) = "Source Coal [MJ/m2]";
   10113          660 :             columnHead(6) = "Source Fuel Oil No 1 [MJ/m2]";
   10114          660 :             columnHead(7) = "Source Fuel Oil No 2 [MJ/m2]";
   10115          660 :             columnHead(8) = "Source Propane [MJ/m2]";
   10116          660 :             columnHead(9) = "Source Other Fuel 1 [MJ/m2]";
   10117          660 :             columnHead(10) = "Source Other Fuel 2 [MJ/m2]";
   10118          660 :             columnHead(11) = "Source District Cooling [MJ/m2]";
   10119          660 :             columnHead(12) = "Source District Heating Water [MJ/m2]";
   10120          660 :             columnHead(13) = "Source District Heating Steam [MJ/m2]";
   10121          660 :         } break;
   10122              :         }
   10123              : 
   10124              :         //---- Normalized by Conditioned Area Sub-Table
   10125              :         {
   10126          677 :             tableBody = "";
   10127              :             // convert floor area
   10128          677 :             Real64 convBldgCondFloorArea = ort->buildingConditionedFloorArea / areaConversionFactor;
   10129          677 :             if (convBldgCondFloorArea > 0) {
   10130         8400 :                 for (int iResource = 1; iResource <= 13; ++iResource) {
   10131       117000 :                     for (int jEndUse = 1; jEndUse <= static_cast<int>(Constant::EndUse::Num); ++jEndUse) {
   10132       109200 :                         tableBody(iResource, jEndUse) = RealToStr(useVal(iResource, jEndUse) / convBldgCondFloorArea, 2);
   10133              :                     }
   10134         7800 :                     tableBody(iResource, 16) = RealToStr(useVal(iResource, 15) / convBldgCondFloorArea, 2);
   10135              :                 }
   10136              :             }
   10137              : 
   10138          677 :             if (produceTabular) {
   10139         1354 :                 WriteTextLine(state, "Normalized Metrics", true);
   10140              : 
   10141              :                 // heading for the entire sub-table
   10142          677 :                 WriteSubtitle(state, "Source Energy End Use Components Per Conditioned Floor Area");
   10143          677 :                 WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
   10144              :             }
   10145          677 :             if (produceSQLite) {
   10146          677 :                 if (state.dataSQLiteProcedures->sqlite) {
   10147           75 :                     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          677 :             if (produceTabular) {
   10156          677 :                 if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
   10157           56 :                     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          677 :             tableBody = "";
   10171          677 :             Real64 convBldgGrossFloorArea = ort->buildingGrossFloorArea / areaConversionFactor;
   10172              : 
   10173          677 :             if (convBldgGrossFloorArea > 0) {
   10174         9072 :                 for (int iResource = 1; iResource <= 13; ++iResource) {
   10175       126360 :                     for (int jEndUse = 1; jEndUse <= static_cast<int>(Constant::EndUse::Num); ++jEndUse) {
   10176       117936 :                         tableBody(iResource, jEndUse) = RealToStr(useVal(iResource, jEndUse) / convBldgGrossFloorArea, 2);
   10177              :                     }
   10178         8424 :                     tableBody(iResource, 16) = RealToStr(useVal(iResource, 15) / convBldgGrossFloorArea, 2);
   10179              :                 }
   10180              :             }
   10181              : 
   10182              :             // heading for the entire sub-table
   10183          677 :             if (produceTabular) {
   10184          677 :                 WriteSubtitle(state, "Source Energy End Use Components Per Total Floor Area");
   10185          677 :                 WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
   10186              :             }
   10187          677 :             if (produceSQLite) {
   10188          677 :                 if (state.dataSQLiteProcedures->sqlite) {
   10189           75 :                     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          677 :             if (produceTabular) {
   10198          677 :                 if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
   10199           56 :                     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          677 : }
   10211              : 
   10212          759 : 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          759 :     auto &ort = state.dataOutRptTab;
   10231          759 :     auto &op = state.dataOutputProcessor;
   10232              : 
   10233          759 :     if (!ort->displayDemandEndUse) {
   10234           79 :         return;
   10235              :     }
   10236              : 
   10237              :     // all arrays are in the format: (row, column)
   10238          680 :     Array1D_string columnHead;
   10239          680 :     Array1D_int columnWidth;
   10240          680 :     Array1D_string rowHead;
   10241          680 :     Array2D_string tableBody;
   10242              : 
   10243              :     // all arrays are in the format: (row, column)
   10244          680 :     Array2D<Real64> useVal(14, 15);
   10245          680 :     Array1D<Real64> collapsedTotal(14);
   10246          680 :     Array2D<Real64> collapsedEndUse(14, static_cast<int>(Constant::EndUse::Num));
   10247          680 :     Array2D<Real64> collapsedIndEndUse(14, static_cast<int>(Constant::EndUse::Num));
   10248          680 :     Array1D_int collapsedTimeStep(14);
   10249          680 :     Array3D<Real64> collapsedEndUseSub(state.dataOutputProcessor->MaxNumSubcategories, static_cast<int>(Constant::EndUse::Num), 14);
   10250          680 :     Array3D<Real64> collapsedIndEndUseSub(state.dataOutputProcessor->MaxNumSubcategories, static_cast<int>(Constant::EndUse::Num), 14);
   10251          680 :     Array2D<Real64> endUseSubOther(14, static_cast<int>(Constant::EndUse::Num));
   10252              : 
   10253              :     // show the headers of the report
   10254         2040 :     WriteReportHeaders(state, "Demand End Use Components Summary", "Entire Facility", OutputProcessor::StoreType::Average);
   10255              : 
   10256          680 :     Real64 ipElectricityConversion = 1.0; // declare here so that last one used is correct for LEED section
   10257         1360 :     for (int iUnitSystem = 0; iUnitSystem <= 1; iUnitSystem++) {
   10258         1360 :         UnitsStyle unitsStyle_cur = ort->unitsStyle;
   10259         1360 :         bool produceTabular = true;
   10260         1360 :         bool produceSQLite = false;
   10261         1360 :         if (produceDualUnitsFlags(iUnitSystem, ort->unitsStyle, ort->unitsStyle_SQLite, unitsStyle_cur, produceTabular, produceSQLite)) {
   10262          680 :             break;
   10263              :         }
   10264              : 
   10265              :         // totals - select which additional fuel to display
   10266          680 :         collapsedTotal = 0.0;
   10267          680 :         collapsedTotal(1) = ort->gatherDemandTotal(1); // electricity
   10268          680 :         collapsedTimeStep(1) = ort->gatherDemandTimeStamp(1);
   10269          680 :         collapsedTotal(2) = ort->gatherDemandTotal(2); // natural gas
   10270          680 :         collapsedTimeStep(2) = ort->gatherDemandTimeStamp(2);
   10271          680 :         collapsedTotal(3) = ort->gatherDemandTotal(6); // gasoline
   10272          680 :         collapsedTimeStep(3) = ort->gatherDemandTimeStamp(6);
   10273          680 :         collapsedTotal(4) = ort->gatherDemandTotal(8); // diesel
   10274          680 :         collapsedTimeStep(4) = ort->gatherDemandTimeStamp(8);
   10275          680 :         collapsedTotal(5) = ort->gatherDemandTotal(9); // coal
   10276          680 :         collapsedTimeStep(5) = ort->gatherDemandTimeStamp(9);
   10277          680 :         collapsedTotal(6) = ort->gatherDemandTotal(10); // fuel oil no 1
   10278          680 :         collapsedTimeStep(6) = ort->gatherDemandTimeStamp(10);
   10279          680 :         collapsedTotal(7) = ort->gatherDemandTotal(11); // fuel oil no 2
   10280          680 :         collapsedTimeStep(7) = ort->gatherDemandTimeStamp(11);
   10281          680 :         collapsedTotal(8) = ort->gatherDemandTotal(12); // propane
   10282          680 :         collapsedTimeStep(8) = ort->gatherDemandTimeStamp(12);
   10283          680 :         collapsedTotal(9) = ort->gatherDemandTotal(13); // other fuel 1
   10284          680 :         collapsedTimeStep(9) = ort->gatherDemandTimeStamp(13);
   10285          680 :         collapsedTotal(10) = ort->gatherDemandTotal(14); // other fuel 2
   10286          680 :         collapsedTimeStep(10) = ort->gatherDemandTimeStamp(14);
   10287          680 :         collapsedTotal(11) = ort->gatherDemandTotal(3); // district cooling <- purchased cooling
   10288          680 :         collapsedTimeStep(11) = ort->gatherDemandTimeStamp(3);
   10289          680 :         collapsedTotal(12) = ort->gatherDemandTotal(4); // district heating water <- purchased heating
   10290          680 :         collapsedTimeStep(12) = ort->gatherDemandTimeStamp(4);
   10291          680 :         collapsedTotal(13) = ort->gatherDemandTotal(5); // district heating steam <- purchased heating
   10292          680 :         collapsedTimeStep(13) = ort->gatherDemandTimeStamp(5);
   10293          680 :         collapsedTotal(14) = ort->gatherDemandTotal(7); // water
   10294          680 :         collapsedTimeStep(14) = ort->gatherDemandTimeStamp(7);
   10295              : 
   10296          680 :         Real64 powerConversion = 1.0;
   10297          680 :         Real64 flowConversion = 1.0;
   10298          680 :         ipElectricityConversion = 1.0;
   10299              : 
   10300              :         // establish unit conversion factors
   10301          680 :         if (unitsStyle_cur == UnitsStyle::InchPound) {
   10302           44 :             powerConversion = getSpecificUnitMultiplier(state, "W", "kBtuh");
   10303           44 :             flowConversion = getSpecificUnitMultiplier(state, "m3/s", "gal/min");
   10304          669 :         } else if (unitsStyle_cur == UnitsStyle::InchPoundExceptElectricity) {
   10305            0 :             powerConversion = getSpecificUnitMultiplier(state, "W", "kBtuh");
   10306            0 :             flowConversion = getSpecificUnitMultiplier(state, "m3/s", "gal/min");
   10307            0 :             ipElectricityConversion = powerConversion * 1000.0; // W to kW adjustment
   10308              :         }
   10309              : 
   10310              :         // collapse the gatherEndUseBEPS array to the resource groups displayed
   10311          680 :         collapsedEndUse = 0.0;
   10312        10200 :         for (int jEndUse = 1; jEndUse <= static_cast<int>(Constant::EndUse::Num); ++jEndUse) {
   10313         9520 :             collapsedEndUse(1, jEndUse) = ort->gatherDemandEndUse(1, jEndUse) * (powerConversion / ipElectricityConversion); // electricity
   10314         9520 :             collapsedEndUse(2, jEndUse) = ort->gatherDemandEndUse(2, jEndUse) * powerConversion;                             // natural gas
   10315         9520 :             collapsedEndUse(3, jEndUse) = ort->gatherDemandEndUse(6, jEndUse) * powerConversion;                             // gasoline
   10316         9520 :             collapsedEndUse(4, jEndUse) = ort->gatherDemandEndUse(8, jEndUse) * powerConversion;                             // diesel
   10317         9520 :             collapsedEndUse(5, jEndUse) = ort->gatherDemandEndUse(9, jEndUse) * powerConversion;                             // coal
   10318         9520 :             collapsedEndUse(6, jEndUse) = ort->gatherDemandEndUse(10, jEndUse) * powerConversion;                            // fuel oil no 1
   10319         9520 :             collapsedEndUse(7, jEndUse) = ort->gatherDemandEndUse(11, jEndUse) * powerConversion;                            // fuel oil no 2
   10320         9520 :             collapsedEndUse(8, jEndUse) = ort->gatherDemandEndUse(12, jEndUse) * powerConversion;                            // propane
   10321         9520 :             collapsedEndUse(9, jEndUse) = ort->gatherDemandEndUse(13, jEndUse) * powerConversion;                            // otherfuel1
   10322         9520 :             collapsedEndUse(10, jEndUse) = ort->gatherDemandEndUse(14, jEndUse) * powerConversion;                           // otherfuel2
   10323         9520 :             collapsedEndUse(11, jEndUse) = ort->gatherDemandEndUse(3, jEndUse) * powerConversion;                            // purchased cooling
   10324         9520 :             collapsedEndUse(12, jEndUse) = ort->gatherDemandEndUse(4, jEndUse) * powerConversion;                            // district heating water
   10325         9520 :             collapsedEndUse(13, jEndUse) = ort->gatherDemandEndUse(5, jEndUse) * powerConversion;                            // district heating steam
   10326         9520 :             collapsedEndUse(14, jEndUse) = ort->gatherDemandEndUse(7, jEndUse) * flowConversion;                             // water
   10327              :         }
   10328        10200 :         for (int jEndUse = 1; jEndUse <= static_cast<int>(Constant::EndUse::Num); ++jEndUse) {
   10329        14858 :             for (int kEndUseSub = 1; kEndUseSub <= op->EndUseCategory(jEndUse).NumSubcategories; ++kEndUseSub) {
   10330        10676 :                 collapsedEndUseSub(kEndUseSub, jEndUse, 1) =
   10331         5338 :                     ort->gatherDemandEndUseSub(kEndUseSub, jEndUse, 1) * (powerConversion / ipElectricityConversion);                // electricity
   10332         5338 :                 collapsedEndUseSub(kEndUseSub, jEndUse, 2) = ort->gatherDemandEndUseSub(kEndUseSub, jEndUse, 2) * powerConversion;   // natural gas
   10333         5338 :                 collapsedEndUseSub(kEndUseSub, jEndUse, 3) = ort->gatherDemandEndUseSub(kEndUseSub, jEndUse, 6) * powerConversion;   // gasoline
   10334         5338 :                 collapsedEndUseSub(kEndUseSub, jEndUse, 4) = ort->gatherDemandEndUseSub(kEndUseSub, jEndUse, 8) * powerConversion;   // diesel
   10335         5338 :                 collapsedEndUseSub(kEndUseSub, jEndUse, 5) = ort->gatherDemandEndUseSub(kEndUseSub, jEndUse, 9) * powerConversion;   // coal
   10336         5338 :                 collapsedEndUseSub(kEndUseSub, jEndUse, 6) = ort->gatherDemandEndUseSub(kEndUseSub, jEndUse, 10) * powerConversion;  // fuel oil no 1
   10337         5338 :                 collapsedEndUseSub(kEndUseSub, jEndUse, 7) = ort->gatherDemandEndUseSub(kEndUseSub, jEndUse, 11) * powerConversion;  // fuel oil no 2
   10338         5338 :                 collapsedEndUseSub(kEndUseSub, jEndUse, 8) = ort->gatherDemandEndUseSub(kEndUseSub, jEndUse, 12) * powerConversion;  // propane
   10339         5338 :                 collapsedEndUseSub(kEndUseSub, jEndUse, 9) = ort->gatherDemandEndUseSub(kEndUseSub, jEndUse, 13) * powerConversion;  // otherfuel1
   10340         5338 :                 collapsedEndUseSub(kEndUseSub, jEndUse, 10) = ort->gatherDemandEndUseSub(kEndUseSub, jEndUse, 14) * powerConversion; // otherfuel2
   10341         5338 :                 collapsedEndUseSub(kEndUseSub, jEndUse, 11) = ort->gatherDemandEndUseSub(kEndUseSub, jEndUse, 3) * powerConversion;  // purch cooling
   10342        10676 :                 collapsedEndUseSub(kEndUseSub, jEndUse, 12) =
   10343         5338 :                     ort->gatherDemandEndUseSub(kEndUseSub, jEndUse, 4) * powerConversion; // district heating water
   10344        10676 :                 collapsedEndUseSub(kEndUseSub, jEndUse, 13) =
   10345         5338 :                     ort->gatherDemandEndUseSub(kEndUseSub, jEndUse, 5) * powerConversion; // district heating steam
   10346         5338 :                 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          680 :         collapsedIndEndUse = 0.0;
   10353        10200 :         for (int jEndUse = 1; jEndUse <= static_cast<int>(Constant::EndUse::Num); ++jEndUse) {
   10354         9520 :             collapsedIndEndUse(1, jEndUse) = ort->gatherDemandIndEndUse(1, jEndUse) * (1.0 / ipElectricityConversion); // electricity
   10355         9520 :             collapsedIndEndUse(2, jEndUse) = ort->gatherDemandIndEndUse(2, jEndUse);                                   // natural gas
   10356         9520 :             collapsedIndEndUse(3, jEndUse) = ort->gatherDemandIndEndUse(6, jEndUse);                                   // gasoline
   10357         9520 :             collapsedIndEndUse(4, jEndUse) = ort->gatherDemandIndEndUse(8, jEndUse);                                   // diesel
   10358         9520 :             collapsedIndEndUse(5, jEndUse) = ort->gatherDemandIndEndUse(9, jEndUse);                                   // coal
   10359         9520 :             collapsedIndEndUse(6, jEndUse) = ort->gatherDemandIndEndUse(10, jEndUse);                                  // fuel oil no 1
   10360         9520 :             collapsedIndEndUse(7, jEndUse) = ort->gatherDemandIndEndUse(11, jEndUse);                                  // fuel oil no 2
   10361         9520 :             collapsedIndEndUse(8, jEndUse) = ort->gatherDemandIndEndUse(12, jEndUse);                                  // propane
   10362         9520 :             collapsedIndEndUse(9, jEndUse) = ort->gatherDemandIndEndUse(13, jEndUse);                                  // otherfuel1
   10363         9520 :             collapsedIndEndUse(10, jEndUse) = ort->gatherDemandIndEndUse(14, jEndUse);                                 // otherfuel2
   10364         9520 :             collapsedIndEndUse(11, jEndUse) = ort->gatherDemandIndEndUse(3, jEndUse);                                  // purchased cooling
   10365         9520 :             collapsedIndEndUse(12, jEndUse) = ort->gatherDemandIndEndUse(4, jEndUse);                                  // district heating water
   10366         9520 :             collapsedIndEndUse(13, jEndUse) = ort->gatherDemandIndEndUse(5, jEndUse);                                  // district heating steam
   10367         9520 :             collapsedIndEndUse(14, jEndUse) = ort->gatherDemandIndEndUse(7, jEndUse);                                  // water
   10368              :         }
   10369        10200 :         for (int jEndUse = 1; jEndUse <= static_cast<int>(Constant::EndUse::Num); ++jEndUse) {
   10370        14858 :             for (int kEndUseSub = 1; kEndUseSub <= op->EndUseCategory(jEndUse).NumSubcategories; ++kEndUseSub) {
   10371        10676 :                 collapsedIndEndUseSub(kEndUseSub, jEndUse, 1) =
   10372         5338 :                     ort->gatherDemandIndEndUseSub(kEndUseSub, jEndUse, 1) * (1.0 / ipElectricityConversion);             // electricity
   10373         5338 :                 collapsedIndEndUseSub(kEndUseSub, jEndUse, 2) = ort->gatherDemandIndEndUseSub(kEndUseSub, jEndUse, 2);   // natural gas
   10374         5338 :                 collapsedIndEndUseSub(kEndUseSub, jEndUse, 3) = ort->gatherDemandIndEndUseSub(kEndUseSub, jEndUse, 6);   // gasoline
   10375         5338 :                 collapsedIndEndUseSub(kEndUseSub, jEndUse, 4) = ort->gatherDemandIndEndUseSub(kEndUseSub, jEndUse, 8);   // diesel
   10376         5338 :                 collapsedIndEndUseSub(kEndUseSub, jEndUse, 5) = ort->gatherDemandIndEndUseSub(kEndUseSub, jEndUse, 9);   // coal
   10377         5338 :                 collapsedIndEndUseSub(kEndUseSub, jEndUse, 6) = ort->gatherDemandIndEndUseSub(kEndUseSub, jEndUse, 10);  // fuel oil no 1
   10378         5338 :                 collapsedIndEndUseSub(kEndUseSub, jEndUse, 7) = ort->gatherDemandIndEndUseSub(kEndUseSub, jEndUse, 11);  // fuel oil no 2
   10379         5338 :                 collapsedIndEndUseSub(kEndUseSub, jEndUse, 8) = ort->gatherDemandIndEndUseSub(kEndUseSub, jEndUse, 12);  // propane
   10380         5338 :                 collapsedIndEndUseSub(kEndUseSub, jEndUse, 9) = ort->gatherDemandIndEndUseSub(kEndUseSub, jEndUse, 13);  // otherfuel1
   10381         5338 :                 collapsedIndEndUseSub(kEndUseSub, jEndUse, 10) = ort->gatherDemandIndEndUseSub(kEndUseSub, jEndUse, 14); // otherfuel2
   10382         5338 :                 collapsedIndEndUseSub(kEndUseSub, jEndUse, 11) = ort->gatherDemandIndEndUseSub(kEndUseSub, jEndUse, 3);  // purch cooling
   10383         5338 :                 collapsedIndEndUseSub(kEndUseSub, jEndUse, 12) = ort->gatherDemandIndEndUseSub(kEndUseSub, jEndUse, 4);  // district heating water
   10384         5338 :                 collapsedIndEndUseSub(kEndUseSub, jEndUse, 13) = ort->gatherDemandIndEndUseSub(kEndUseSub, jEndUse, 5);  // district heating steam
   10385         5338 :                 collapsedIndEndUseSub(kEndUseSub, jEndUse, 14) = ort->gatherDemandIndEndUseSub(kEndUseSub, jEndUse, 7);  // water
   10386              :             }
   10387              :         }
   10388              : 
   10389              :         // convert totals
   10390          680 :         collapsedTotal(1) *= (powerConversion / ipElectricityConversion); // electricity
   10391          680 :         collapsedTotal(2) *= powerConversion;                             // natural gas
   10392          680 :         collapsedTotal(3) *= powerConversion;                             // gasoline
   10393          680 :         collapsedTotal(4) *= powerConversion;                             // diesel
   10394          680 :         collapsedTotal(5) *= powerConversion;                             // coal
   10395          680 :         collapsedTotal(6) *= powerConversion;                             // fuel oil no 1
   10396          680 :         collapsedTotal(7) *= powerConversion;                             // fuel oil no 2
   10397          680 :         collapsedTotal(8) *= powerConversion;                             // propane
   10398          680 :         collapsedTotal(9) *= powerConversion;                             // otherfuel1
   10399          680 :         collapsedTotal(10) *= powerConversion;                            // otherfuel2
   10400          680 :         collapsedTotal(11) *= powerConversion;                            // purchased cooling
   10401          680 :         collapsedTotal(12) *= powerConversion;                            // district heating water
   10402          680 :         collapsedTotal(13) *= powerConversion;                            // district heating steam
   10403          680 :         collapsedTotal(14) *= flowConversion;                             // water
   10404              :         //---- End Use Sub-Table
   10405          680 :         rowHead.allocate(17);
   10406          680 :         columnHead.allocate(14);
   10407          680 :         columnWidth.allocate(14);
   10408          680 :         columnWidth = 10; // array assignment - same for all columns
   10409          680 :         tableBody.allocate(14, 17);
   10410        10200 :         for (int iResource = 1; iResource <= 14; ++iResource) {
   10411       142800 :             for (int iEndUse = 0; iEndUse < static_cast<int>(Constant::EndUse::Num); ++iEndUse) {
   10412       133280 :                 useVal(iResource, iEndUse + 1) = collapsedEndUse(iResource, iEndUse + 1);
   10413              :             }
   10414         9520 :             useVal(iResource, 15) = collapsedTotal(iResource); // totals
   10415              :         }
   10416              : 
   10417          680 :         rowHead(1) = "Time of Peak";
   10418          680 :         rowHead(static_cast<int>(Constant::EndUse::Heating) + 2) = "Heating";
   10419          680 :         rowHead(static_cast<int>(Constant::EndUse::Cooling) + 2) = "Cooling";
   10420          680 :         rowHead(static_cast<int>(Constant::EndUse::InteriorLights) + 2) = "Interior Lighting";
   10421          680 :         rowHead(static_cast<int>(Constant::EndUse::ExteriorLights) + 2) = "Exterior Lighting";
   10422          680 :         rowHead(static_cast<int>(Constant::EndUse::InteriorEquipment) + 2) = "Interior Equipment";
   10423          680 :         rowHead(static_cast<int>(Constant::EndUse::ExteriorEquipment) + 2) = "Exterior Equipment";
   10424          680 :         rowHead(static_cast<int>(Constant::EndUse::Fans) + 2) = "Fans";
   10425          680 :         rowHead(static_cast<int>(Constant::EndUse::Pumps) + 2) = "Pumps";
   10426          680 :         rowHead(static_cast<int>(Constant::EndUse::HeatRejection) + 2) = "Heat Rejection";
   10427          680 :         rowHead(static_cast<int>(Constant::EndUse::Humidification) + 2) = "Humidification";
   10428          680 :         rowHead(static_cast<int>(Constant::EndUse::HeatRecovery) + 2) = "Heat Recovery";
   10429          680 :         rowHead(static_cast<int>(Constant::EndUse::WaterSystem) + 2) = "Water Systems";
   10430          680 :         rowHead(static_cast<int>(Constant::EndUse::Refrigeration) + 2) = "Refrigeration";
   10431          680 :         rowHead(static_cast<int>(Constant::EndUse::Cogeneration) + 2) = "Generators";
   10432          680 :         rowHead(16) = "";
   10433          680 :         rowHead(17) = "Total End Uses";
   10434              : 
   10435          680 :         if (unitsStyle_cur == UnitsStyle::InchPound) {
   10436           11 :             columnHead(1) = "Electricity [kBtuh]";
   10437           11 :             columnHead(2) = "Natural Gas [kBtuh]";
   10438           11 :             columnHead(3) = "Gasoline [kBtuh]";
   10439           11 :             columnHead(4) = "Diesel [kBtuh]";
   10440           11 :             columnHead(5) = "Coal [kBtuh]";
   10441           11 :             columnHead(6) = "Fuel Oil No 1 [kBtuh]";
   10442           11 :             columnHead(7) = "Fuel Oil No 2 [kBtuh]";
   10443           11 :             columnHead(8) = "Propane [kBtuh]";
   10444           11 :             columnHead(9) = "Other Fuel 1 [kBtuh]";
   10445           11 :             columnHead(10) = "Other Fuel 2 [kBtuh]";
   10446           11 :             columnHead(11) = "District Cooling [kBtuh]";
   10447           11 :             columnHead(12) = "District Heating Water [kBtuh]";
   10448           11 :             columnHead(13) = "District Heating Steam [kBtuh]";
   10449           11 :             columnHead(14) = "Water [gal/min]";
   10450          669 :         } else if (unitsStyle_cur == UnitsStyle::InchPoundExceptElectricity) {
   10451            0 :             columnHead(1) = "Electricity [kW]";
   10452            0 :             columnHead(2) = "Natural Gas [kBtuh]";
   10453            0 :             columnHead(3) = "Gasoline [kBtuh]";
   10454            0 :             columnHead(4) = "Diesel [kBtuh]";
   10455            0 :             columnHead(5) = "Coal [kBtuh]";
   10456            0 :             columnHead(6) = "Fuel Oil No 1 [kBtuh]";
   10457            0 :             columnHead(7) = "Fuel Oil No 2 [kBtuh]";
   10458            0 :             columnHead(8) = "Propane [kBtuh]";
   10459            0 :             columnHead(9) = "Other Fuel 1 [kBtuh]";
   10460            0 :             columnHead(10) = "Other Fuel 2 [kBtuh]";
   10461            0 :             columnHead(11) = "District Cooling [kBtuh]";
   10462            0 :             columnHead(12) = "District Heating Water [kBtuh]";
   10463            0 :             columnHead(13) = "District Heating Steam [kBtuh]";
   10464            0 :             columnHead(14) = "Water [gal/min]";
   10465              :         } else {
   10466          669 :             columnHead(1) = "Electricity [W]";
   10467          669 :             columnHead(2) = "Natural Gas [W]";
   10468          669 :             columnHead(3) = "Gasoline [W]";
   10469          669 :             columnHead(4) = "Diesel [W]";
   10470          669 :             columnHead(5) = "Coal [W]";
   10471          669 :             columnHead(6) = "Fuel Oil No 1 [W]";
   10472          669 :             columnHead(7) = "Fuel Oil No 2 [W]";
   10473          669 :             columnHead(8) = "Propane [W]";
   10474          669 :             columnHead(9) = "Other Fuel 1 [W]";
   10475          669 :             columnHead(10) = "Other Fuel 2 [W]";
   10476          669 :             columnHead(11) = "District Cooling [W]";
   10477          669 :             columnHead(12) = "District Heating Water [W]";
   10478          669 :             columnHead(13) = "District Heating Steam [W]";
   10479          669 :             columnHead(14) = "Water [m3/s]";
   10480              :         }
   10481              : 
   10482          680 :         tableBody = "";
   10483        10200 :         for (int iResource = 1; iResource <= 14; ++iResource) {
   10484       142800 :             for (int jEndUse = 1; jEndUse <= static_cast<int>(Constant::EndUse::Num); ++jEndUse) {
   10485       133280 :                 tableBody(iResource, 1 + jEndUse) = RealToStr(useVal(iResource, jEndUse), 2);
   10486              :             }
   10487         9520 :             tableBody(iResource, 1) = DateToString(collapsedTimeStep(iResource));
   10488         9520 :             tableBody(iResource, 17) = RealToStr(collapsedTotal(iResource), 2);
   10489              :         }
   10490              : 
   10491              :         // complete the LEED end use table using the same values
   10492              : 
   10493          680 :         if (produceTabular) {
   10494          680 :             WriteSubtitle(state, "End Uses");
   10495          680 :             WriteTable(state, tableBody, rowHead, columnHead, columnWidth, false, state.dataOutRptTab->footnote);
   10496              :         }
   10497          680 :         if (produceSQLite) {
   10498          680 :             if (state.dataSQLiteProcedures->sqlite) {
   10499           75 :                 state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
   10500              :                     tableBody, rowHead, columnHead, "DemandEndUseComponentsSummary", "Entire Facility", "End Uses");
   10501              :             }
   10502              :         }
   10503          680 :         if (produceTabular) {
   10504          680 :             if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
   10505           56 :                 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          680 :         int numRows = 0;
   10512        10200 :         for (int jEndUse = 1; jEndUse <= static_cast<int>(Constant::EndUse::Num); ++jEndUse) {
   10513         9520 :             if (op->EndUseCategory(jEndUse).NumSubcategories > 0) {
   10514         9927 :                 for (int kEndUseSub = 1; kEndUseSub <= op->EndUseCategory(jEndUse).NumSubcategories; ++kEndUseSub) {
   10515         5338 :                     ++numRows;
   10516              :                 }
   10517              :             } else {
   10518         4931 :                 ++numRows;
   10519              :             }
   10520              :         }
   10521              : 
   10522          680 :         rowHead.allocate(numRows);
   10523          680 :         columnHead.allocate(15);
   10524          680 :         columnWidth.allocate(15);
   10525          680 :         columnWidth = 10; // array assignment - same for all columns
   10526          680 :         tableBody.allocate(15, numRows);
   10527              : 
   10528         1360 :         rowHead = "";
   10529          680 :         tableBody = "";
   10530              : 
   10531              :         // Build row head and subcategories columns
   10532              :         {
   10533          680 :             int i = 1;
   10534        10200 :             for (int jEndUse = 1; jEndUse <= static_cast<int>(Constant::EndUse::Num); ++jEndUse) {
   10535         9520 :                 rowHead(i) = op->EndUseCategory(jEndUse).DisplayName;
   10536         9520 :                 if (op->EndUseCategory(jEndUse).NumSubcategories > 0) {
   10537         9927 :                     for (int kEndUseSub = 1; kEndUseSub <= op->EndUseCategory(jEndUse).NumSubcategories; ++kEndUseSub) {
   10538         5338 :                         tableBody(1, i) = op->EndUseCategory(jEndUse).SubcategoryName(kEndUseSub);
   10539         5338 :                         ++i;
   10540              :                     }
   10541              :                 } else {
   10542         4931 :                     tableBody(1, i) = "General";
   10543         4931 :                     ++i;
   10544              :                 }
   10545              :             }
   10546              :         }
   10547              : 
   10548          680 :         if (unitsStyle_cur == UnitsStyle::InchPound) {
   10549           11 :             columnHead(1) = "Subcategory";
   10550           11 :             columnHead(2) = "Electricity [kBtuh]";
   10551           11 :             columnHead(3) = "Natural Gas [kBtuh]";
   10552           11 :             columnHead(4) = "Gasoline [kBtuh]";
   10553           11 :             columnHead(5) = "Diesel [kBtuh]";
   10554           11 :             columnHead(6) = "Coal [kBtuh]";
   10555           11 :             columnHead(7) = "Fuel Oil No 1 [kBtuh]";
   10556           11 :             columnHead(8) = "Fuel Oil No 2 [kBtuh]";
   10557           11 :             columnHead(9) = "Propane [kBtuh]";
   10558           11 :             columnHead(10) = "Other Fuel 1 [kBtuh]";
   10559           11 :             columnHead(11) = "Other Fuel 2 [kBtuh]";
   10560           11 :             columnHead(12) = "District Cooling [kBtuh]";
   10561           11 :             columnHead(13) = "District Heating Water [kBtuh]";
   10562           11 :             columnHead(14) = "District Heating Steam [kBtuh]";
   10563           11 :             columnHead(15) = "Water [gal/min]";
   10564          669 :         } else if (unitsStyle_cur == UnitsStyle::InchPoundExceptElectricity) {
   10565            0 :             columnHead(1) = "Subcategory";
   10566            0 :             columnHead(2) = "Electricity [kW]";
   10567            0 :             columnHead(3) = "Natural Gas [kBtuh]";
   10568            0 :             columnHead(4) = "Gasoline [kBtuh]";
   10569            0 :             columnHead(5) = "Diesel [kBtuh]";
   10570            0 :             columnHead(6) = "Coal [kBtuh]";
   10571            0 :             columnHead(7) = "Fuel Oil No 1 [kBtuh]";
   10572            0 :             columnHead(8) = "Fuel Oil No 2 [kBtuh]";
   10573            0 :             columnHead(9) = "Propane [kBtuh]";
   10574            0 :             columnHead(10) = "Other Fuel 1 [kBtuh]";
   10575            0 :             columnHead(11) = "Other Fuel 2 [kBtuh]";
   10576            0 :             columnHead(12) = "District Cooling [kBtuh]";
   10577            0 :             columnHead(13) = "District Heating Water [kBtuh]";
   10578            0 :             columnHead(14) = "District Heating Steam [kBtuh]";
   10579            0 :             columnHead(15) = "Water [gal/min]";
   10580              :         } else {
   10581          669 :             columnHead(1) = "Subcategory";
   10582          669 :             columnHead(2) = "Electricity [W]";
   10583          669 :             columnHead(3) = "Natural Gas [W]";
   10584          669 :             columnHead(4) = "Gasoline [W]";
   10585          669 :             columnHead(5) = "Diesel [W]";
   10586          669 :             columnHead(6) = "Coal [W]";
   10587          669 :             columnHead(7) = "Fuel Oil No 1 [W]";
   10588          669 :             columnHead(8) = "Fuel Oil No 2 [W]";
   10589          669 :             columnHead(9) = "Propane [W]";
   10590          669 :             columnHead(10) = "Other Fuel 1 [W]";
   10591          669 :             columnHead(11) = "Other Fuel 2 [W]";
   10592          669 :             columnHead(12) = "District Cooling [W]";
   10593          669 :             columnHead(13) = "District Heating Water [W]";
   10594          669 :             columnHead(14) = "District Heating Steam [W]";
   10595          669 :             columnHead(15) = "Water [m3/s]";
   10596              :         }
   10597              : 
   10598        10200 :         for (int iResource = 1; iResource <= 14; ++iResource) {
   10599         9520 :             int i = 1;
   10600       142800 :             for (int jEndUse = 1; jEndUse <= static_cast<int>(Constant::EndUse::Num); ++jEndUse) {
   10601       133280 :                 if (op->EndUseCategory(jEndUse).NumSubcategories > 0) {
   10602       138978 :                     for (int kEndUseSub = 1; kEndUseSub <= op->EndUseCategory(jEndUse).NumSubcategories; ++kEndUseSub) {
   10603        74732 :                         tableBody(iResource + 1, i) = RealToStr(collapsedEndUseSub(kEndUseSub, jEndUse, iResource), 2);
   10604        74732 :                         ++i;
   10605              :                     }
   10606              :                 } else {
   10607        69034 :                     tableBody(iResource + 1, i) = RealToStr(collapsedEndUse(iResource, jEndUse), 2);
   10608        69034 :                     ++i;
   10609              :                 }
   10610              :             }
   10611              :         }
   10612              : 
   10613              :         // heading for the entire sub-table
   10614          680 :         if (produceTabular) {
   10615          680 :             WriteSubtitle(state, "End Uses By Subcategory");
   10616          680 :             WriteTable(state, tableBody, rowHead, columnHead, columnWidth, false, state.dataOutRptTab->footnote);
   10617              :         }
   10618              : 
   10619          680 :         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          680 :         FillRowHead(rowHeadTemp);
   10623              : 
   10624        10949 :         for (int i = 1; i <= numRows; ++i) {
   10625        10269 :             rowHeadTemp(i) = rowHeadTemp(i) + ":" + tableBody(1, i);
   10626              :         }
   10627              : 
   10628              :         // Erase the SubCategory (first column), using slicing
   10629         4760 :         Array2D_string tableBodyTemp(tableBody({2, _, _}, {_, _, _}));
   10630         2720 :         Array1D_string columnHeadTemp(columnHead({2, _, _}));
   10631              : 
   10632          680 :         if (produceSQLite) {
   10633          680 :             if (state.dataSQLiteProcedures->sqlite) {
   10634           75 :                 state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
   10635              :                     tableBodyTemp, rowHeadTemp, columnHeadTemp, "DemandEndUseComponentsSummary", "Entire Facility", "End Uses By Subcategory");
   10636              :             }
   10637              :         }
   10638              : 
   10639          680 :         if (produceTabular) {
   10640          680 :             if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
   10641           56 :                 state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(
   10642              :                     tableBodyTemp, rowHeadTemp, columnHeadTemp, "DemandEndUseComponentsSummary", "Entire Facility", "End Uses By Subcategory");
   10643              :             }
   10644              :         }
   10645          680 :         rowHeadTemp.deallocate();
   10646          680 :         tableBodyTemp.deallocate();
   10647          680 :         columnHeadTemp.deallocate();
   10648          680 :     }
   10649              : 
   10650              :     // EAp2-4/5. Performance Rating Method Compliance
   10651        10200 :     for (int iResource = 1; iResource <= 14; ++iResource) {
   10652       142800 :         for (int jEndUse = 1; jEndUse <= static_cast<int>(Constant::EndUse::Num); ++jEndUse) {
   10653       133280 :             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          680 :     Array1D_int resource_entry_map;
   10671          680 :     resource_entry_map.allocate(13);
   10672          680 :     resource_entry_map(1) = state.dataOutRptPredefined->pdchLeedPerfElDem;          // electricity
   10673          680 :     resource_entry_map(2) = state.dataOutRptPredefined->pdchLeedPerfGasDem;         // natural gas
   10674          680 :     resource_entry_map(3) = state.dataOutRptPredefined->pdchLeedPerfGasolineDem;    // gasoline
   10675          680 :     resource_entry_map(4) = state.dataOutRptPredefined->pdchLeedPerfDieselDem;      // diesel
   10676          680 :     resource_entry_map(5) = state.dataOutRptPredefined->pdchLeedPerfCoalDem;        // coal
   10677          680 :     resource_entry_map(6) = state.dataOutRptPredefined->pdchLeedPerfFuelOil1Dem;    // fuel oil no 1
   10678          680 :     resource_entry_map(7) = state.dataOutRptPredefined->pdchLeedPerfFuelOil2Dem;    // fuel oil no 2
   10679          680 :     resource_entry_map(8) = state.dataOutRptPredefined->pdchLeedPerfPropaneDem;     // propane
   10680          680 :     resource_entry_map(9) = state.dataOutRptPredefined->pdchLeedPerfOtherFuel1Dem;  // other fuel 1
   10681          680 :     resource_entry_map(10) = state.dataOutRptPredefined->pdchLeedPerfOtherFuel2Dem; // other fuel 2
   10682          680 :     resource_entry_map(11) = state.dataOutRptPredefined->pdchLeedPerfDisClDem;      // district cooling
   10683          680 :     resource_entry_map(12) = state.dataOutRptPredefined->pdchLeedPerfDisHtWtrDem;   // district heating water
   10684          680 :     resource_entry_map(13) = state.dataOutRptPredefined->pdchLeedPerfDisHtStDem;    // district heating steam
   10685              : 
   10686         9520 :     for (int iResource = 1; iResource <= 13; ++iResource) {
   10687         8840 :         int i = 1;
   10688         8840 :         Real64 localUnconvert = (iResource == 1) ? ipElectricityConversion : 1.0;
   10689       132600 :         for (int jEndUse = 1; jEndUse <= static_cast<int>(Constant::EndUse::Num); ++jEndUse) {
   10690       123760 :             if (op->EndUseCategory(jEndUse).NumSubcategories > 0) {
   10691       129051 :                 for (int kEndUseSub = 1; kEndUseSub <= op->EndUseCategory(jEndUse).NumSubcategories; ++kEndUseSub) {
   10692       138788 :                     PreDefTableEntry(state,
   10693        69394 :                                      resource_entry_map(iResource),
   10694       138788 :                                      op->EndUseCategory(jEndUse).DisplayName + " -- " + op->EndUseCategory(jEndUse).SubcategoryName(kEndUseSub),
   10695        69394 :                                      localUnconvert * collapsedIndEndUseSub(kEndUseSub, jEndUse, iResource));
   10696        69394 :                     ++i;
   10697              :                 }
   10698              :                 // put other
   10699        59657 :                 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       128206 :                 PreDefTableEntry(state,
   10708        64103 :                                  resource_entry_map(iResource),
   10709       128206 :                                  op->EndUseCategory(jEndUse).DisplayName + " -- Not Subdivided",
   10710        64103 :                                  localUnconvert * collapsedIndEndUse(iResource, jEndUse));
   10711        64103 :                 ++i;
   10712              :             }
   10713              :         }
   10714              :     }
   10715         2040 : }
   10716              : 
   10717          759 : 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          759 :     auto const &ort = state.dataOutRptTab;
   10753              : 
   10754          759 :     if (!state.dataCostEstimateManager->DoCostEstimate) {
   10755          719 :         return;
   10756              :     }
   10757              : 
   10758           40 :     Array2D<Real64> TableBodyData(3, 10);
   10759           40 :     Array1D_string columnHead;
   10760           40 :     Array1D_int columnWidth;
   10761           40 :     Array1D_string rowHead;
   10762           40 :     Array2D_string tableBody;
   10763              : 
   10764          120 :     WriteReportHeaders(state, "Component Cost Economics Summary", "Entire Facility", OutputProcessor::StoreType::Average);
   10765              : 
   10766              :     // compute floor area if no ABUPS
   10767           40 :     if (ort->buildingConditionedFloorArea == 0.0) {
   10768            1 :         DetermineBuildingFloorArea(state);
   10769              :     }
   10770              : 
   10771           80 :     for (int iUnitSystem = 0; iUnitSystem <= 1; iUnitSystem++) {
   10772           80 :         UnitsStyle unitsStyle_cur = ort->unitsStyle;
   10773           80 :         bool produceTabular = true;
   10774           80 :         bool produceSQLite = false;
   10775           80 :         if (produceDualUnitsFlags(iUnitSystem, ort->unitsStyle, ort->unitsStyle_SQLite, unitsStyle_cur, produceTabular, produceSQLite)) {
   10776           40 :             break;
   10777              :         }
   10778              : 
   10779              :         // 1st sub-table with total Costs and normalized with area
   10780           40 :         rowHead.allocate(10);
   10781           40 :         columnHead.allocate(3);
   10782           40 :         columnWidth.allocate(3);
   10783           40 :         columnWidth = 14; // array assignment - same for all columns
   10784           40 :         tableBody.allocate(3, 10);
   10785              : 
   10786           40 :         columnHead(1) = "Reference Bldg.";
   10787           40 :         columnHead(2) = "Current Bldg. Model";
   10788           40 :         columnHead(3) = "Difference";
   10789              : 
   10790           40 :         rowHead(1) = "Line Item SubTotal (~~$~~)";
   10791           40 :         rowHead(2) = "Misc. Costs (~~$~~)";
   10792           40 :         rowHead(3) = "Regional Adjustment (~~$~~)";
   10793           40 :         rowHead(4) = "Design Fee (~~$~~)";
   10794           40 :         rowHead(5) = "Contractor Fee (~~$~~)";
   10795           40 :         rowHead(6) = "Contingency (~~$~~)";
   10796           40 :         rowHead(7) = "Permits, Bonds, Insurance (~~$~~)";
   10797           40 :         rowHead(8) = "Commissioning (~~$~~)";
   10798           40 :         rowHead(9) = "Cost Estimate Total (~~$~~)";
   10799           40 :         if (unitsStyle_cur == OutputReportTabular::UnitsStyle::InchPound ||
   10800           40 :             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           40 :             rowHead(10) = "Cost Per Conditioned Building Area (~~$~~/m2)";
   10808           40 :             state.dataOutRptTab->m2_unitConv = 1.0;
   10809              :         }
   10810           40 :         TableBodyData = 0.0;
   10811           40 :         tableBody = "";
   10812              : 
   10813           40 :         TableBodyData(1, 1) = state.dataCostEstimateManager->RefrncBldg.LineItemTot;
   10814           40 :         tableBody(1, 1) = RealToStr(TableBodyData(1, 1), 2);
   10815           40 :         TableBodyData(1, 2) = state.dataCostEstimateManager->RefrncBldg.MiscCostperSqMeter * ort->buildingConditionedFloorArea;
   10816           40 :         tableBody(1, 2) = RealToStr(TableBodyData(1, 2), 2);
   10817              : 
   10818           40 :         if (state.dataCostEstimateManager->RefrncBldg.RegionalModifier != 1.0) {
   10819            2 :             TableBodyData(1, 3) = (state.dataCostEstimateManager->RefrncBldg.LineItemTot +
   10820            1 :                                    state.dataCostEstimateManager->RefrncBldg.MiscCostperSqMeter * ort->buildingConditionedFloorArea) *
   10821            1 :                                   (state.dataCostEstimateManager->RefrncBldg.RegionalModifier - 1.0);
   10822              :         } else {
   10823           39 :             TableBodyData(1, 3) = 0.0;
   10824              :         }
   10825              : 
   10826              :         // holds interim value for construction component costs: reference bldg.
   10827           40 :         Real64 const RefBldgConstCost = sum(TableBodyData(1, {1, 3}));
   10828              : 
   10829           40 :         tableBody(1, 3) = RealToStr(TableBodyData(1, 3), 2);
   10830           40 :         TableBodyData(1, 4) = RefBldgConstCost * state.dataCostEstimateManager->RefrncBldg.DesignFeeFrac;
   10831           40 :         tableBody(1, 4) = RealToStr(TableBodyData(1, 4), 2);
   10832           40 :         TableBodyData(1, 5) = RefBldgConstCost * state.dataCostEstimateManager->RefrncBldg.ContractorFeeFrac;
   10833           40 :         tableBody(1, 5) = RealToStr(TableBodyData(1, 5), 2);
   10834           40 :         TableBodyData(1, 6) = RefBldgConstCost * state.dataCostEstimateManager->RefrncBldg.ContingencyFrac;
   10835           40 :         tableBody(1, 6) = RealToStr(TableBodyData(1, 6), 2);
   10836           40 :         TableBodyData(1, 7) = RefBldgConstCost * state.dataCostEstimateManager->RefrncBldg.BondCostFrac;
   10837           40 :         tableBody(1, 7) = RealToStr(TableBodyData(1, 7), 2);
   10838           40 :         TableBodyData(1, 8) = RefBldgConstCost * state.dataCostEstimateManager->RefrncBldg.CommissioningFrac;
   10839           40 :         tableBody(1, 8) = RealToStr(TableBodyData(1, 8), 2);
   10840           40 :         state.dataCostEstimateManager->RefrncBldg.GrandTotal = sum(TableBodyData(1, {1, 8}));
   10841           40 :         TableBodyData(1, 9) = state.dataCostEstimateManager->RefrncBldg.GrandTotal;
   10842           40 :         tableBody(1, 9) = RealToStr(TableBodyData(1, 9), 2);
   10843           40 :         if (ort->buildingConditionedFloorArea > 0.0) {
   10844           40 :             TableBodyData(1, 10) = TableBodyData(1, 9) / (ort->buildingConditionedFloorArea * state.dataOutRptTab->m2_unitConv);
   10845              :         }
   10846           40 :         tableBody(1, 10) = RealToStr(TableBodyData(1, 10), 2);
   10847              : 
   10848           40 :         TableBodyData(2, 1) = state.dataCostEstimateManager->CurntBldg.LineItemTot;
   10849           40 :         tableBody(2, 1) = RealToStr(TableBodyData(2, 1), 2);
   10850           40 :         TableBodyData(2, 2) = state.dataCostEstimateManager->CurntBldg.MiscCostperSqMeter * ort->buildingConditionedFloorArea;
   10851           40 :         tableBody(2, 2) = RealToStr(TableBodyData(2, 2), 2);
   10852           40 :         if (state.dataCostEstimateManager->CurntBldg.RegionalModifier != 1.0) {
   10853            2 :             TableBodyData(2, 3) = (state.dataCostEstimateManager->CurntBldg.LineItemTot +
   10854            1 :                                    state.dataCostEstimateManager->CurntBldg.MiscCostperSqMeter * ort->buildingConditionedFloorArea) *
   10855            1 :                                   (state.dataCostEstimateManager->CurntBldg.RegionalModifier - 1.0);
   10856              :         } else {
   10857           39 :             TableBodyData(2, 3) = 0.0;
   10858              :         }
   10859           40 :         tableBody(2, 3) = RealToStr(TableBodyData(2, 3), 2);
   10860              : 
   10861              :         // holds interim value for construction component costs: current bldg.
   10862           40 :         Real64 const CurntBldgConstCost = sum(TableBodyData(2, {1, 3}));
   10863              : 
   10864           40 :         TableBodyData(2, 4) = CurntBldgConstCost * state.dataCostEstimateManager->CurntBldg.DesignFeeFrac;
   10865           40 :         tableBody(2, 4) = RealToStr(TableBodyData(2, 4), 2);
   10866              : 
   10867           40 :         TableBodyData(2, 5) = CurntBldgConstCost * state.dataCostEstimateManager->CurntBldg.ContractorFeeFrac;
   10868           40 :         tableBody(2, 5) = RealToStr(TableBodyData(2, 5), 2);
   10869           40 :         TableBodyData(2, 6) = CurntBldgConstCost * state.dataCostEstimateManager->CurntBldg.ContingencyFrac;
   10870           40 :         tableBody(2, 6) = RealToStr(TableBodyData(2, 6), 2);
   10871           40 :         TableBodyData(2, 7) = CurntBldgConstCost * state.dataCostEstimateManager->CurntBldg.BondCostFrac;
   10872           40 :         tableBody(2, 7) = RealToStr(TableBodyData(2, 7), 2);
   10873           40 :         TableBodyData(2, 8) = CurntBldgConstCost * state.dataCostEstimateManager->CurntBldg.CommissioningFrac;
   10874           40 :         tableBody(2, 8) = RealToStr(TableBodyData(2, 8), 2);
   10875              : 
   10876           40 :         state.dataCostEstimateManager->CurntBldg.GrandTotal = sum(TableBodyData(2, {1, 8}));
   10877           40 :         TableBodyData(2, 9) = state.dataCostEstimateManager->CurntBldg.GrandTotal;
   10878           40 :         tableBody(2, 9) = RealToStr(TableBodyData(2, 9), 2);
   10879           40 :         if (ort->buildingConditionedFloorArea > 0) {
   10880           40 :             TableBodyData(2, 10) = TableBodyData(2, 9) / (ort->buildingConditionedFloorArea * state.dataOutRptTab->m2_unitConv);
   10881              :         }
   10882           40 :         tableBody(2, 10) = RealToStr(TableBodyData(2, 10), 2);
   10883              : 
   10884           40 :         TableBodyData(3, {1, 10}) = TableBodyData(2, {1, 10}) - TableBodyData(1, {1, 10});
   10885           40 :         tableBody(3, 1) = RealToStr(TableBodyData(3, 1), 2);
   10886           40 :         tableBody(3, 2) = RealToStr(TableBodyData(3, 2), 2);
   10887           40 :         tableBody(3, 3) = RealToStr(TableBodyData(3, 3), 2);
   10888           40 :         tableBody(3, 4) = RealToStr(TableBodyData(3, 4), 2);
   10889           40 :         tableBody(3, 5) = RealToStr(TableBodyData(3, 5), 2);
   10890           40 :         tableBody(3, 6) = RealToStr(TableBodyData(3, 6), 2);
   10891           40 :         tableBody(3, 7) = RealToStr(TableBodyData(3, 7), 2);
   10892           40 :         tableBody(3, 8) = RealToStr(TableBodyData(3, 8), 2);
   10893           40 :         tableBody(3, 9) = RealToStr(TableBodyData(3, 9), 2);
   10894           40 :         tableBody(3, 10) = RealToStr(TableBodyData(3, 10), 2);
   10895              : 
   10896           40 :         if (produceTabular) {
   10897           40 :             WriteSubtitle(state, "Construction Cost Estimate Summary");
   10898           40 :             WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
   10899              :         }
   10900           40 :         if (produceSQLite) {
   10901           40 :             if (state.dataSQLiteProcedures->sqlite) {
   10902            6 :                 state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
   10903              :                     tableBody, rowHead, columnHead, "Construction Cost Estimate Summary", "Entire Facility", "Construction Cost Estimate Summary");
   10904              :             }
   10905              :         }
   10906           40 :         if (produceTabular) {
   10907           40 :             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           40 :         int const NumRows = static_cast<int>(state.dataCostEstimateManager->CostLineItem.size()) + 1; // body will have the total and line items
   10914           40 :         int const NumCols = 6; // Line no., Line name, Qty, Units, ValperQty, Subtotal
   10915           40 :         rowHead.allocate(NumRows);
   10916           40 :         columnHead.allocate(NumCols);
   10917           40 :         columnWidth.dimension(NumCols, 14); // array assignment - same for all columns
   10918           40 :         tableBody.allocate(NumCols, NumRows);
   10919           80 :         tableBody = "--";                        // array init
   10920           40 :         rowHead = "--";                          // array init
   10921           40 :         rowHead(NumRows) = "Line Item SubTotal"; // last line in table will be a total
   10922              :         // setup up column headers
   10923           40 :         columnHead(1) = "Line No.";
   10924           40 :         columnHead(2) = "Item Name";
   10925           40 :         columnHead(3) = "Quantity.";
   10926           40 :         columnHead(4) = "Units";
   10927           40 :         columnHead(5) = "~~$~~ per Qty.";
   10928           40 :         columnHead(6) = "SubTotal ~~$~~";
   10929              : 
   10930           40 :         columnWidth = {7, 30, 16, 10, 16, 16}; // array assignment - for all columns
   10931              : 
   10932         2937 :         for (int item = 1; item <= (int)state.dataCostEstimateManager->CostLineItem.size(); ++item) {
   10933         2897 :             tableBody(1, item) = fmt::to_string(state.dataCostEstimateManager->CostLineItem(item).LineNumber);
   10934         2897 :             tableBody(2, item) = state.dataCostEstimateManager->CostLineItem(item).LineName;
   10935         2897 :             if (unitsStyle_cur == OutputReportTabular::UnitsStyle::InchPound ||
   10936         2897 :                 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         2897 :                 tableBody(3, item) = RealToStr(state.dataCostEstimateManager->CostLineItem(item).Qty, 2);
   10956         2897 :                 tableBody(4, item) = state.dataCostEstimateManager->CostLineItem(item).Units;
   10957         2897 :                 tableBody(5, item) = RealToStr(state.dataCostEstimateManager->CostLineItem(item).ValuePer, 2);
   10958              :             }
   10959         2897 :             tableBody(6, item) = RealToStr(state.dataCostEstimateManager->CostLineItem(item).LineSubTotal, 2);
   10960              :         }
   10961           40 :         tableBody(6, NumRows) = RealToStr(state.dataCostEstimateManager->CurntBldg.LineItemTot, 2);
   10962           40 :         if (produceTabular) {
   10963           40 :             WriteSubtitle(state, "Cost Line Item Details"); //: '//TRIM(RealToStr(CostEstimateTotal, 2)))
   10964           40 :             WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
   10965              :         }
   10966           40 :         if (produceSQLite) {
   10967           40 :             if (state.dataSQLiteProcedures->sqlite) {
   10968            6 :                 state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
   10969              :                     tableBody, rowHead, columnHead, "Construction Cost Estimate Summary", "Entire Facility", "Cost Line Item Details");
   10970              :             }
   10971              :         }
   10972           40 :         if (produceTabular) {
   10973           40 :             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           40 : }
   10980              : 
   10981              : // modify the ith row in the reportingperiod input verification table
   10982           11 : 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           11 :     tableBody(1, rowid) = reportType;
   10989           11 :     tableBody(2, rowid) = std::to_string(periodIdx);
   10990           11 :     tableBody(3, rowid) = ReportPeriodInputData(periodIdx).title;
   10991           22 :     tableBody(4, rowid) = formatReportPeriodTimestamp(ReportPeriodInputData(periodIdx).startYear,
   10992           11 :                                                       ReportPeriodInputData(periodIdx).startMonth,
   10993           11 :                                                       ReportPeriodInputData(periodIdx).startDay,
   10994           22 :                                                       ReportPeriodInputData(periodIdx).startHour);
   10995           22 :     tableBody(5, rowid) = formatReportPeriodTimestamp(ReportPeriodInputData(periodIdx).endYear,
   10996           11 :                                                       ReportPeriodInputData(periodIdx).endMonth,
   10997           11 :                                                       ReportPeriodInputData(periodIdx).endDay,
   10998           22 :                                                       ReportPeriodInputData(periodIdx).endHour);
   10999           11 :     tableBody(6, rowid) = RealToStr(ReportPeriodInputData(periodIdx).totalElectricityUse / 3600000.0, 2);
   11000           11 : }
   11001              : 
   11002          759 : 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          759 :     auto const &ort = state.dataOutRptTab;
   11031              : 
   11032              :     // all arrays are in the format: (row, column)
   11033          759 :     if (!ort->displayTabularVeriSum) {
   11034           10 :         return;
   11035              :     }
   11036              : 
   11037              :     // SUBROUTINE PARAMETER DEFINITIONS:
   11038          749 :     int constexpr wwrcTotal(1);
   11039          749 :     int constexpr wwrcNorth(2);
   11040          749 :     int constexpr wwrcEast(3);
   11041          749 :     int constexpr wwrcSouth(4);
   11042          749 :     int constexpr wwrcWest(5);
   11043          749 :     int constexpr wwrrWall(1);
   11044          749 :     int constexpr wwrrAbvGndWall(2);
   11045          749 :     int constexpr wwrrWindow(3);
   11046          749 :     int constexpr wwrrWWR(4);
   11047          749 :     int constexpr wwrrAbvGndWWR(5);
   11048              : 
   11049              :     // all arrays are in the format: (row, column)
   11050          749 :     Array1D_string columnHead;
   11051          749 :     Array1D_int columnWidth;
   11052          749 :     Array1D_string rowHead;
   11053          749 :     Array2D_string tableBody;
   11054              : 
   11055          749 :     Array1D<Real64> zoneOpeningArea;
   11056          749 :     zoneOpeningArea.allocate(state.dataGlobal->NumOfZones);
   11057              :     // zoneOpeningArea = 0.0;
   11058              : 
   11059          749 :     Array1D<Real64> zoneGlassArea;
   11060          749 :     zoneGlassArea.allocate(state.dataGlobal->NumOfZones);
   11061              :     // zoneGlassArea = 0.0;
   11062              : 
   11063         1498 :     for (int iUnitSystem = 0; iUnitSystem <= 1; iUnitSystem++) {
   11064         1498 :         UnitsStyle unitsStyle_cur = ort->unitsStyle;
   11065         1498 :         bool produceTabular = true;
   11066         1498 :         bool produceSQLite = false;
   11067         1498 :         if (produceDualUnitsFlags(iUnitSystem, ort->unitsStyle, ort->unitsStyle_SQLite, unitsStyle_cur, produceTabular, produceSQLite)) {
   11068          749 :             break;
   11069              :         }
   11070              : 
   11071              :         // show the headers of the report
   11072          749 :         if (produceTabular) {
   11073         2996 :             WriteReportHeaders(state, "Input Verification and Results Summary", "Entire Facility", OutputProcessor::StoreType::Average);
   11074              :         }
   11075              : 
   11076              :         // Moved these initializations into the loop
   11077          749 :         state.dataOutRptTab->zstArea = 0.0;
   11078          749 :         state.dataOutRptTab->zstVolume = 0.0;
   11079          749 :         state.dataOutRptTab->zstWallArea = 0.0;
   11080          749 :         state.dataOutRptTab->zstUndWallArea = 0.0;
   11081          749 :         state.dataOutRptTab->zstWindowArea = 0.0;
   11082          749 :         state.dataOutRptTab->zstOpeningArea = 0.0;
   11083          749 :         state.dataOutRptTab->zstLight = 0.0;
   11084          749 :         state.dataOutRptTab->zstPeople = 0.0;
   11085          749 :         state.dataOutRptTab->zstPlug = 0.0;
   11086              : 
   11087          749 :         zoneOpeningArea = 0.0;
   11088          749 :         zoneGlassArea = 0.0;
   11089              : 
   11090              :         // do unit conversions if necessary
   11091          749 :         if (unitsStyle_cur == UnitsStyle::InchPound) {
   11092           11 :             std::string SIunit;
   11093           11 :             SIunit = "[m]";
   11094           11 :             LookupSItoIP(state, SIunit, state.dataOutRptTab->unitConvIndexWVST, state.dataOutRptTab->m_unitName);
   11095           11 :             state.dataOutRptTab->m_unitConv = ConvertIP(state, state.dataOutRptTab->unitConvIndexWVST, 1.0);
   11096           11 :             SIunit = "[m2]";
   11097           11 :             LookupSItoIP(state, SIunit, state.dataOutRptTab->unitConvIndexWVST, state.dataOutRptTab->m2_unitName);
   11098           11 :             state.dataOutRptTab->m2_unitConvWVST = ConvertIP(state, state.dataOutRptTab->unitConvIndexWVST, 1.0);
   11099           11 :             SIunit = "[m3]";
   11100           11 :             LookupSItoIP(state, SIunit, state.dataOutRptTab->unitConvIndexWVST, state.dataOutRptTab->m3_unitName);
   11101           11 :             state.dataOutRptTab->m3_unitConv = ConvertIP(state, state.dataOutRptTab->unitConvIndexWVST, 1.0);
   11102           11 :             SIunit = "[W/m2]";
   11103           11 :             LookupSItoIP(state, SIunit, state.dataOutRptTab->unitConvIndexWVST, state.dataOutRptTab->Wm2_unitName);
   11104           11 :             state.dataOutRptTab->Wm2_unitConv = ConvertIP(state, state.dataOutRptTab->unitConvIndexWVST, 1.0);
   11105          749 :         } 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          738 :             state.dataOutRptTab->m_unitName = "[m]";
   11122          738 :             state.dataOutRptTab->m_unitConv = 1.0;
   11123          738 :             state.dataOutRptTab->m2_unitName = "[m2]";
   11124          738 :             state.dataOutRptTab->m2_unitConvWVST = 1.0;
   11125          738 :             state.dataOutRptTab->m3_unitName = "[m3]";
   11126          738 :             state.dataOutRptTab->m3_unitConv = 1.0;
   11127          738 :             state.dataOutRptTab->Wm2_unitName = "[W/m2]";
   11128          738 :             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          749 :         rowHead.allocate(10);
   11134          749 :         columnHead.allocate(1);
   11135          749 :         columnWidth.allocate(1);
   11136          749 :         columnWidth = 14; // array assignment - same for all columns
   11137          749 :         tableBody.allocate(1, 10);
   11138              : 
   11139          749 :         columnHead(1) = "Value";
   11140          749 :         rowHead(1) = "Program Version and Build";
   11141          749 :         rowHead(2) = "RunPeriod";
   11142          749 :         rowHead(3) = "Weather File";
   11143          749 :         rowHead(4) = "Latitude [deg]";
   11144          749 :         rowHead(5) = "Longitude [deg]";
   11145              : 
   11146          749 :         rowHead(6) = "Elevation " + state.dataOutRptTab->m_unitName;
   11147          749 :         rowHead(7) = "Time Zone";
   11148          749 :         rowHead(8) = "North Axis Angle [deg]";
   11149          749 :         rowHead(9) = "Rotation for Appendix G [deg]";
   11150          749 :         rowHead(10) = "Hours Simulated [hrs]";
   11151              :         //  rowHead(9)  = 'Num Table Entries' !used for debugging
   11152              : 
   11153          749 :         tableBody = "";
   11154              : 
   11155          749 :         tableBody(1, 1) = state.dataStrGlobals->VerStringVar;                                         // program
   11156          749 :         tableBody(1, 2) = state.dataEnvrn->EnvironmentName;                                           // runperiod name
   11157          749 :         tableBody(1, 3) = state.dataEnvrn->WeatherFileLocationTitle;                                  // weather
   11158          749 :         tableBody(1, 4) = RealToStr(state.dataEnvrn->Latitude, 2);                                    // latitude
   11159          749 :         tableBody(1, 5) = RealToStr(state.dataEnvrn->Longitude, 2);                                   // longitude
   11160          749 :         tableBody(1, 6) = RealToStr(state.dataEnvrn->Elevation * state.dataOutRptTab->m_unitConv, 2); // Elevation
   11161          749 :         tableBody(1, 7) = RealToStr(state.dataEnvrn->TimeZoneNumber, 2);                              // Time Zone
   11162          749 :         tableBody(1, 8) = RealToStr(state.dataHeatBal->BuildingAzimuth, 2);                           // north axis angle
   11163          749 :         tableBody(1, 9) = RealToStr(state.dataHeatBal->BuildingRotationAppendixG, 2);                 // Rotation for Appendix G
   11164          749 :         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          749 :         if (produceTabular) {
   11168          749 :             WriteSubtitle(state, "General");
   11169          749 :             WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
   11170              :         }
   11171          749 :         if (produceSQLite) {
   11172          749 :             if (state.dataSQLiteProcedures->sqlite) {
   11173          122 :                 state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
   11174              :                     tableBody, rowHead, columnHead, "InputVerificationandResultsSummary", "Entire Facility", "General");
   11175              :             }
   11176              :         }
   11177          749 :         if (produceTabular) {
   11178          749 :             if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
   11179           63 :                 state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(
   11180              :                     tableBody, rowHead, columnHead, "InputVerificationandResultsSummary", "Entire Facility", "General");
   11181              :             }
   11182              : 
   11183              :             //---- Window Wall Ratio Sub-Table
   11184         1498 :             WriteTextLine(state, "ENVELOPE", true);
   11185              :         }
   11186              : 
   11187          749 :         rowHead.allocate(5);
   11188          749 :         columnHead.allocate(5);
   11189          749 :         columnWidth.allocate(5);
   11190          749 :         columnWidth = 14; // array assignment - same for all columns
   11191          749 :         tableBody.allocate(5, 5);
   11192              : 
   11193          749 :         columnHead(wwrcTotal) = "Total";
   11194          749 :         columnHead(wwrcNorth) = "North (315 to 45 deg)";
   11195          749 :         columnHead(wwrcEast) = "East (45 to 135 deg)";
   11196          749 :         columnHead(wwrcSouth) = "South (135 to 225 deg)";
   11197          749 :         columnHead(wwrcWest) = "West (225 to 315 deg)";
   11198              : 
   11199          749 :         rowHead(wwrrWall) = "Gross Wall Area " + state.dataOutRptTab->m2_unitName;
   11200          749 :         rowHead(wwrrAbvGndWall) = "Above Ground Wall Area " + state.dataOutRptTab->m2_unitName;
   11201          749 :         rowHead(wwrrWindow) = "Window Opening Area " + state.dataOutRptTab->m2_unitName;
   11202          749 :         rowHead(wwrrWWR) = "Gross Window-Wall Ratio [%]";
   11203          749 :         rowHead(wwrrAbvGndWWR) = "Above Ground Window-Wall Ratio [%]";
   11204              : 
   11205          749 :         Real64 wallAreaN = 0.0;
   11206          749 :         Real64 wallAreaS = 0.0;
   11207          749 :         Real64 wallAreaE = 0.0;
   11208          749 :         Real64 wallAreaW = 0.0;
   11209          749 :         Real64 aboveGroundWallAreaN = 0.0;
   11210          749 :         Real64 aboveGroundWallAreaS = 0.0;
   11211          749 :         Real64 aboveGroundWallAreaE = 0.0;
   11212          749 :         Real64 aboveGroundWallAreaW = 0.0;
   11213          749 :         Real64 windowAreaN = 0.0;
   11214          749 :         Real64 windowAreaS = 0.0;
   11215          749 :         Real64 windowAreaE = 0.0;
   11216          749 :         Real64 windowAreaW = 0.0;
   11217              :         // wall and window areas attached to conditioned zones
   11218          749 :         Real64 wallAreaNcond = 0.0;
   11219          749 :         Real64 wallAreaScond = 0.0;
   11220          749 :         Real64 wallAreaEcond = 0.0;
   11221          749 :         Real64 wallAreaWcond = 0.0;
   11222          749 :         Real64 aboveGroundWallAreaNcond = 0.0;
   11223          749 :         Real64 aboveGroundWallAreaScond = 0.0;
   11224          749 :         Real64 aboveGroundWallAreaEcond = 0.0;
   11225          749 :         Real64 aboveGroundWallAreaWcond = 0.0;
   11226          749 :         Real64 windowAreaNcond = 0.0;
   11227          749 :         Real64 windowAreaScond = 0.0;
   11228          749 :         Real64 windowAreaEcond = 0.0;
   11229          749 :         Real64 windowAreaWcond = 0.0;
   11230              : 
   11231          749 :         Real64 roofArea = 0.0;
   11232          749 :         Real64 skylightArea = 0.0;
   11233              : 
   11234         1498 :         bool DetailedWWR = (state.dataInputProcessing->inputProcessor->getNumSectionsFound("DETAILEDWWR_DEBUG") > 0);
   11235          749 :         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        46051 :         for (int iSurf = 1; iSurf <= state.dataSurface->TotSurfaces; ++iSurf) {
   11243              :             // only exterior surfaces including underground
   11244        45302 :             auto const &thisSurf = state.dataSurface->Surface(iSurf);
   11245        45302 :             if (!thisSurf.HeatTransSurf) {
   11246         1537 :                 continue;
   11247              :             }
   11248        43765 :             bool const isAboveGround = (thisSurf.ExtBoundCond == ExternalEnvironment) || (thisSurf.ExtBoundCond == OtherSideCondModeledExt);
   11249        43765 :             if (isAboveGround || (thisSurf.ExtBoundCond == Ground) || (thisSurf.ExtBoundCond == GroundFCfactorMethod) ||
   11250        23996 :                 (thisSurf.ExtBoundCond == KivaFoundation)) {
   11251        19809 :                 Real64 curAzimuth = thisSurf.Azimuth;
   11252              :                 // Round to two decimals, like the display in tables
   11253        19809 :                 curAzimuth = round(curAzimuth * 100.0) / 100.0;
   11254        19809 :                 Real64 curArea = thisSurf.GrossArea;
   11255        19809 :                 if (thisSurf.FrameDivider != 0) {
   11256          376 :                     Real64 const frameWidth = state.dataSurface->FrameDivider(thisSurf.FrameDivider).FrameWidth;
   11257          376 :                     Real64 const frameArea =
   11258          376 :                         (thisSurf.Height + 2.0 * frameWidth) * (thisSurf.Width + 2.0 * frameWidth) - (thisSurf.Height * thisSurf.Width);
   11259          376 :                     curArea += frameArea;
   11260              :                 }
   11261        19809 :                 int const zonePt = thisSurf.Zone;
   11262              : 
   11263        19809 :                 bool const isConditioned = (zonePt > 0) && (state.dataHeatBal->Zone(zonePt).SystemZoneNodeNumber > 0);
   11264        19809 :                 if ((thisSurf.Tilt >= 60.0) && (thisSurf.Tilt <= 120.0)) {
   11265              :                     // vertical walls and windows
   11266        14918 :                     switch (thisSurf.Class) {
   11267         8822 :                     case SurfaceClass::Wall:
   11268              :                     case SurfaceClass::Floor:
   11269              :                     case SurfaceClass::Roof: {
   11270         8822 :                         auto const &thisZone = state.dataHeatBal->Zone(zonePt);
   11271         8822 :                         Real64 const mult = thisZone.Multiplier * thisZone.ListMultiplier;
   11272         8822 :                         if ((curAzimuth >= 315.0) || (curAzimuth < 45.0)) {
   11273         2282 :                             wallAreaN += curArea * mult;
   11274         2282 :                             if (isConditioned) {
   11275         1950 :                                 wallAreaNcond += curArea * mult;
   11276              :                             }
   11277         2282 :                             if (isAboveGround) {
   11278         2235 :                                 aboveGroundWallAreaN += curArea * mult;
   11279         2235 :                                 if (isConditioned) {
   11280         1912 :                                     aboveGroundWallAreaNcond += curArea * mult;
   11281              :                                 }
   11282              :                             }
   11283         6540 :                         } else if ((curAzimuth >= 45.0) && (curAzimuth < 135.0)) {
   11284         2096 :                             wallAreaE += curArea * mult;
   11285         2096 :                             if (isConditioned) {
   11286         1721 :                                 wallAreaEcond += curArea * mult;
   11287              :                             }
   11288         2096 :                             if (isAboveGround) {
   11289         2051 :                                 aboveGroundWallAreaE += curArea * mult;
   11290         2051 :                                 if (isConditioned) {
   11291         1688 :                                     aboveGroundWallAreaEcond += curArea * mult;
   11292              :                                 }
   11293              :                             }
   11294         4444 :                         } else if ((curAzimuth >= 135.0) && (curAzimuth < 225.0)) {
   11295         2279 :                             wallAreaS += curArea * mult;
   11296         2279 :                             if (isConditioned) {
   11297         1933 :                                 wallAreaScond += curArea * mult;
   11298              :                             }
   11299         2279 :                             if (isAboveGround) {
   11300         2233 :                                 aboveGroundWallAreaS += curArea * mult;
   11301         2233 :                                 if (isConditioned) {
   11302         1896 :                                     aboveGroundWallAreaScond += curArea * mult;
   11303              :                                 }
   11304              :                             }
   11305         2165 :                         } else if ((curAzimuth >= 225.0) && (curAzimuth < 315.0)) {
   11306         2165 :                             wallAreaW += curArea * mult;
   11307         2165 :                             if (isConditioned) {
   11308         1782 :                                 wallAreaWcond += curArea * mult;
   11309              :                             }
   11310         2165 :                             if (isAboveGround) {
   11311         2121 :                                 aboveGroundWallAreaW += curArea * mult;
   11312         2121 :                                 if (isConditioned) {
   11313         1749 :                                     aboveGroundWallAreaWcond += curArea * mult;
   11314              :                                 }
   11315              :                             }
   11316              :                         }
   11317         8822 :                         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         8822 :                     } break;
   11323         5697 :                     case SurfaceClass::Window:
   11324              :                     case SurfaceClass::TDD_Dome: {
   11325         5697 :                         auto const &thisZone = state.dataHeatBal->Zone(zonePt);
   11326         5697 :                         Real64 const mult = thisZone.Multiplier * thisZone.ListMultiplier * thisSurf.Multiplier;
   11327         5697 :                         if ((curAzimuth >= 315.0) || (curAzimuth < 45.0)) {
   11328         1426 :                             windowAreaN += curArea * mult;
   11329         1426 :                             if (isConditioned) {
   11330         1333 :                                 windowAreaNcond += curArea * mult;
   11331              :                             }
   11332         4271 :                         } else if ((curAzimuth >= 45.0) && (curAzimuth < 135.0)) {
   11333         1048 :                             windowAreaE += curArea * mult;
   11334         1048 :                             if (isConditioned) {
   11335          963 :                                 windowAreaEcond += curArea * mult;
   11336              :                             }
   11337         3223 :                         } else if ((curAzimuth >= 135.0) && (curAzimuth < 225.0)) {
   11338         2180 :                             windowAreaS += curArea * mult;
   11339         2180 :                             if (isConditioned) {
   11340         2023 :                                 windowAreaScond += curArea * mult;
   11341              :                             }
   11342         1043 :                         } else if ((curAzimuth >= 225.0) && (curAzimuth < 315.0)) {
   11343         1043 :                             windowAreaW += curArea * mult;
   11344         1043 :                             if (isConditioned) {
   11345          963 :                                 windowAreaWcond += curArea * mult;
   11346              :                             }
   11347              :                         }
   11348         5697 :                         zoneOpeningArea(zonePt) += curArea * thisSurf.Multiplier; // total window opening area for each zone (glass plus frame area)
   11349         5697 :                         zoneGlassArea(zonePt) += thisSurf.GrossArea * thisSurf.Multiplier;
   11350         5697 :                         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         5697 :                     } break;
   11356          399 :                     default:
   11357          399 :                         break;
   11358              :                     }
   11359        19809 :                 } else if (thisSurf.Tilt < 60.0) { // roof and skylights
   11360         2596 :                     switch (thisSurf.Class) {
   11361         2206 :                     case SurfaceClass::Wall:
   11362              :                     case SurfaceClass::Floor:
   11363              :                     case SurfaceClass::Roof: {
   11364         2206 :                         auto const &thisZone = state.dataHeatBal->Zone(zonePt);
   11365         2206 :                         Real64 const mult = thisZone.Multiplier * thisZone.ListMultiplier;
   11366         2206 :                         roofArea += curArea * mult;
   11367         2206 :                         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         2206 :                     } break;
   11373          389 :                     case SurfaceClass::Window:
   11374              :                     case SurfaceClass::TDD_Dome: {
   11375          389 :                         auto const &thisZone = state.dataHeatBal->Zone(zonePt);
   11376          389 :                         Real64 const mult = thisZone.Multiplier * thisZone.ListMultiplier * thisSurf.Multiplier;
   11377          389 :                         skylightArea += curArea * mult;
   11378          389 :                         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          389 :                     } break;
   11384            1 :                     default:
   11385            1 :                         break;
   11386              :                     }
   11387              :                 } else { // floors
   11388              :                          // ignored
   11389              :                 }
   11390              :             }
   11391              :         }
   11392              : 
   11393          749 :         Real64 TotalWallArea = wallAreaN + wallAreaS + wallAreaE + wallAreaW;
   11394          749 :         Real64 TotalAboveGroundWallArea = aboveGroundWallAreaN + aboveGroundWallAreaS + aboveGroundWallAreaE + aboveGroundWallAreaW;
   11395          749 :         Real64 TotalWindowArea = windowAreaN + windowAreaS + windowAreaE + windowAreaW;
   11396          749 :         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          749 :         tableBody = "";
   11407              : 
   11408          749 :         tableBody(wwrcNorth, wwrrWall) = RealToStr(wallAreaN * state.dataOutRptTab->m2_unitConvWVST, 2);
   11409          749 :         tableBody(wwrcSouth, wwrrWall) = RealToStr(wallAreaS * state.dataOutRptTab->m2_unitConvWVST, 2);
   11410          749 :         tableBody(wwrcEast, wwrrWall) = RealToStr(wallAreaE * state.dataOutRptTab->m2_unitConvWVST, 2);
   11411          749 :         tableBody(wwrcWest, wwrrWall) = RealToStr(wallAreaW * state.dataOutRptTab->m2_unitConvWVST, 2);
   11412          749 :         tableBody(wwrcTotal, wwrrWall) = RealToStr(TotalWallArea * state.dataOutRptTab->m2_unitConvWVST, 2);
   11413              : 
   11414          749 :         tableBody(wwrcNorth, wwrrAbvGndWall) = RealToStr(aboveGroundWallAreaN * state.dataOutRptTab->m2_unitConvWVST, 2);
   11415          749 :         tableBody(wwrcSouth, wwrrAbvGndWall) = RealToStr(aboveGroundWallAreaS * state.dataOutRptTab->m2_unitConvWVST, 2);
   11416          749 :         tableBody(wwrcEast, wwrrAbvGndWall) = RealToStr(aboveGroundWallAreaE * state.dataOutRptTab->m2_unitConvWVST, 2);
   11417          749 :         tableBody(wwrcWest, wwrrAbvGndWall) = RealToStr(aboveGroundWallAreaW * state.dataOutRptTab->m2_unitConvWVST, 2);
   11418          749 :         tableBody(wwrcTotal, wwrrAbvGndWall) = RealToStr(TotalAboveGroundWallArea * state.dataOutRptTab->m2_unitConvWVST, 2);
   11419              : 
   11420          749 :         tableBody(wwrcNorth, wwrrWindow) = RealToStr(windowAreaN * state.dataOutRptTab->m2_unitConvWVST, 2);
   11421          749 :         tableBody(wwrcSouth, wwrrWindow) = RealToStr(windowAreaS * state.dataOutRptTab->m2_unitConvWVST, 2);
   11422          749 :         tableBody(wwrcEast, wwrrWindow) = RealToStr(windowAreaE * state.dataOutRptTab->m2_unitConvWVST, 2);
   11423          749 :         tableBody(wwrcWest, wwrrWindow) = RealToStr(windowAreaW * state.dataOutRptTab->m2_unitConvWVST, 2);
   11424          749 :         tableBody(wwrcTotal, wwrrWindow) = RealToStr(TotalWindowArea * state.dataOutRptTab->m2_unitConvWVST, 2);
   11425              : 
   11426          749 :         tableBody(wwrcNorth, wwrrWWR) = RealToStr(100.0 * SafeDivide(windowAreaN, wallAreaN), 2);
   11427          749 :         tableBody(wwrcSouth, wwrrWWR) = RealToStr(100.0 * SafeDivide(windowAreaS, wallAreaS), 2);
   11428          749 :         tableBody(wwrcEast, wwrrWWR) = RealToStr(100.0 * SafeDivide(windowAreaE, wallAreaE), 2);
   11429          749 :         tableBody(wwrcWest, wwrrWWR) = RealToStr(100.0 * SafeDivide(windowAreaW, wallAreaW), 2);
   11430          749 :         tableBody(wwrcTotal, wwrrWWR) = RealToStr(100.0 * SafeDivide(TotalWindowArea, TotalWallArea), 2);
   11431              : 
   11432          749 :         tableBody(wwrcNorth, wwrrAbvGndWWR) = RealToStr(100.0 * SafeDivide(windowAreaN, aboveGroundWallAreaN), 2);
   11433          749 :         tableBody(wwrcSouth, wwrrAbvGndWWR) = RealToStr(100.0 * SafeDivide(windowAreaS, aboveGroundWallAreaS), 2);
   11434          749 :         tableBody(wwrcEast, wwrrAbvGndWWR) = RealToStr(100.0 * SafeDivide(windowAreaE, aboveGroundWallAreaE), 2);
   11435          749 :         tableBody(wwrcWest, wwrrAbvGndWWR) = RealToStr(100.0 * SafeDivide(windowAreaW, aboveGroundWallAreaW), 2);
   11436          749 :         tableBody(wwrcTotal, wwrrAbvGndWWR) = RealToStr(100.0 * SafeDivide(TotalWindowArea, TotalAboveGroundWallArea), 2);
   11437              : 
   11438          749 :         if (produceTabular) {
   11439          749 :             WriteSubtitle(state, "Window-Wall Ratio");
   11440          749 :             WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
   11441              :         }
   11442          749 :         if (produceSQLite) {
   11443          749 :             if (state.dataSQLiteProcedures->sqlite) {
   11444          122 :                 state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
   11445              :                     tableBody, rowHead, columnHead, "InputVerificationandResultsSummary", "Entire Facility", "Window-Wall Ratio");
   11446              :             }
   11447              :         }
   11448          749 :         if (produceTabular) {
   11449          749 :             if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
   11450           63 :                 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          749 :         rowHead.allocate(5);
   11457          749 :         columnHead.allocate(5);
   11458          749 :         columnWidth.allocate(5);
   11459          749 :         columnWidth = 14; // array assignment - same for all columns
   11460          749 :         tableBody.allocate(5, 5);
   11461              : 
   11462          749 :         columnHead(wwrcTotal) = "Total";
   11463          749 :         columnHead(wwrcNorth) = "North (315 to 45 deg)";
   11464          749 :         columnHead(wwrcEast) = "East (45 to 135 deg)";
   11465          749 :         columnHead(wwrcSouth) = "South (135 to 225 deg)";
   11466          749 :         columnHead(wwrcWest) = "West (225 to 315 deg)";
   11467              : 
   11468          749 :         rowHead(wwrrWall) = "Gross Wall Area " + state.dataOutRptTab->m2_unitName;
   11469          749 :         rowHead(wwrrAbvGndWall) = "Above Ground Wall Area " + state.dataOutRptTab->m2_unitName;
   11470          749 :         rowHead(wwrrWindow) = "Window Opening Area " + state.dataOutRptTab->m2_unitName;
   11471          749 :         rowHead(wwrrWWR) = "Gross Window-Wall Ratio [%]";
   11472          749 :         rowHead(wwrrAbvGndWWR) = "Above Ground Window-Wall Ratio [%]";
   11473              : 
   11474              :         // calculations appear in last block with normal window-wall ratio table
   11475              : 
   11476          749 :         TotalWallArea = wallAreaNcond + wallAreaScond + wallAreaEcond + wallAreaWcond;
   11477          749 :         TotalAboveGroundWallArea = aboveGroundWallAreaNcond + aboveGroundWallAreaScond + aboveGroundWallAreaEcond + aboveGroundWallAreaWcond;
   11478          749 :         TotalWindowArea = windowAreaNcond + windowAreaScond + windowAreaEcond + windowAreaWcond;
   11479              : 
   11480          749 :         tableBody = "";
   11481              : 
   11482          749 :         tableBody(wwrcNorth, wwrrWall) = RealToStr(wallAreaNcond * state.dataOutRptTab->m2_unitConvWVST, 2);
   11483          749 :         tableBody(wwrcSouth, wwrrWall) = RealToStr(wallAreaScond * state.dataOutRptTab->m2_unitConvWVST, 2);
   11484          749 :         tableBody(wwrcEast, wwrrWall) = RealToStr(wallAreaEcond * state.dataOutRptTab->m2_unitConvWVST, 2);
   11485          749 :         tableBody(wwrcWest, wwrrWall) = RealToStr(wallAreaWcond * state.dataOutRptTab->m2_unitConvWVST, 2);
   11486          749 :         tableBody(wwrcTotal, wwrrWall) = RealToStr(TotalWallArea * state.dataOutRptTab->m2_unitConvWVST, 2);
   11487              : 
   11488          749 :         tableBody(wwrcNorth, wwrrAbvGndWall) = RealToStr(aboveGroundWallAreaNcond * state.dataOutRptTab->m2_unitConvWVST, 2);
   11489          749 :         tableBody(wwrcSouth, wwrrAbvGndWall) = RealToStr(aboveGroundWallAreaScond * state.dataOutRptTab->m2_unitConvWVST, 2);
   11490          749 :         tableBody(wwrcEast, wwrrAbvGndWall) = RealToStr(aboveGroundWallAreaEcond * state.dataOutRptTab->m2_unitConvWVST, 2);
   11491          749 :         tableBody(wwrcWest, wwrrAbvGndWall) = RealToStr(aboveGroundWallAreaWcond * state.dataOutRptTab->m2_unitConvWVST, 2);
   11492          749 :         tableBody(wwrcTotal, wwrrAbvGndWall) = RealToStr(TotalAboveGroundWallArea * state.dataOutRptTab->m2_unitConvWVST, 2);
   11493              : 
   11494          749 :         tableBody(wwrcNorth, wwrrWindow) = RealToStr(windowAreaNcond * state.dataOutRptTab->m2_unitConvWVST, 2);
   11495          749 :         tableBody(wwrcSouth, wwrrWindow) = RealToStr(windowAreaScond * state.dataOutRptTab->m2_unitConvWVST, 2);
   11496          749 :         tableBody(wwrcEast, wwrrWindow) = RealToStr(windowAreaEcond * state.dataOutRptTab->m2_unitConvWVST, 2);
   11497          749 :         tableBody(wwrcWest, wwrrWindow) = RealToStr(windowAreaWcond * state.dataOutRptTab->m2_unitConvWVST, 2);
   11498          749 :         tableBody(wwrcTotal, wwrrWindow) = RealToStr(TotalWindowArea * state.dataOutRptTab->m2_unitConvWVST, 2);
   11499              : 
   11500          749 :         tableBody(wwrcNorth, wwrrWWR) = RealToStr(100.0 * SafeDivide(windowAreaNcond, wallAreaNcond), 2);
   11501          749 :         tableBody(wwrcSouth, wwrrWWR) = RealToStr(100.0 * SafeDivide(windowAreaScond, wallAreaScond), 2);
   11502          749 :         tableBody(wwrcEast, wwrrWWR) = RealToStr(100.0 * SafeDivide(windowAreaEcond, wallAreaEcond), 2);
   11503          749 :         tableBody(wwrcWest, wwrrWWR) = RealToStr(100.0 * SafeDivide(windowAreaWcond, wallAreaWcond), 2);
   11504          749 :         tableBody(wwrcTotal, wwrrWWR) = RealToStr(100.0 * SafeDivide(TotalWindowArea, TotalWallArea), 2);
   11505              : 
   11506          749 :         tableBody(wwrcNorth, wwrrAbvGndWWR) = RealToStr(100.0 * SafeDivide(windowAreaNcond, aboveGroundWallAreaNcond), 2);
   11507          749 :         tableBody(wwrcSouth, wwrrAbvGndWWR) = RealToStr(100.0 * SafeDivide(windowAreaScond, aboveGroundWallAreaScond), 2);
   11508          749 :         tableBody(wwrcEast, wwrrAbvGndWWR) = RealToStr(100.0 * SafeDivide(windowAreaEcond, aboveGroundWallAreaEcond), 2);
   11509          749 :         tableBody(wwrcWest, wwrrAbvGndWWR) = RealToStr(100.0 * SafeDivide(windowAreaWcond, aboveGroundWallAreaWcond), 2);
   11510          749 :         tableBody(wwrcTotal, wwrrAbvGndWWR) = RealToStr(100.0 * SafeDivide(TotalWindowArea, TotalAboveGroundWallArea), 2);
   11511              : 
   11512          749 :         if (produceTabular) {
   11513          749 :             WriteSubtitle(state, "Conditioned Window-Wall Ratio");
   11514          749 :             WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
   11515              :         }
   11516          749 :         if (produceSQLite) {
   11517          749 :             if (state.dataSQLiteProcedures->sqlite) {
   11518          122 :                 state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
   11519              :                     tableBody, rowHead, columnHead, "InputVerificationandResultsSummary", "Entire Facility", "Conditioned Window-Wall Ratio");
   11520              :             }
   11521              :         }
   11522          749 :         if (produceTabular) {
   11523          749 :             if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
   11524           63 :                 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          749 :         rowHead.allocate(3);
   11531          749 :         columnHead.allocate(1);
   11532          749 :         columnWidth.allocate(1);
   11533          749 :         columnWidth = 14; // array assignment - same for all columns
   11534          749 :         tableBody.allocate(1, 3);
   11535              : 
   11536          749 :         columnHead(1) = "Total";
   11537              : 
   11538          749 :         rowHead(1) = "Gross Roof Area " + state.dataOutRptTab->m2_unitName;
   11539          749 :         rowHead(2) = "Skylight Area " + state.dataOutRptTab->m2_unitName;
   11540          749 :         rowHead(3) = "Skylight-Roof Ratio [%]";
   11541              : 
   11542          749 :         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          749 :         tableBody(1, 1) = RealToStr(roofArea * state.dataOutRptTab->m2_unitConvWVST, 2);
   11551          749 :         tableBody(1, 2) = RealToStr(skylightArea * state.dataOutRptTab->m2_unitConvWVST, 2);
   11552          749 :         tableBody(1, 3) = RealToStr(100.0 * SafeDivide(skylightArea, roofArea), 2);
   11553              : 
   11554          749 :         if (produceTabular) {
   11555          749 :             WriteSubtitle(state, "Skylight-Roof Ratio");
   11556          749 :             WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
   11557              :         }
   11558          749 :         if (produceSQLite) {
   11559          749 :             if (state.dataSQLiteProcedures->sqlite) {
   11560          122 :                 state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
   11561              :                     tableBody, rowHead, columnHead, "InputVerificationandResultsSummary", "Entire Facility", "Skylight-Roof Ratio");
   11562              :             }
   11563              :         }
   11564          749 :         if (produceTabular) {
   11565          749 :             if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
   11566           63 :                 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          749 :         if (state.dataHybridModel->FlagHybridModel_TM) {
   11573            1 :             rowHead.allocate(state.dataGlobal->NumOfZones);
   11574            1 :             int const NumOfCol = 2;
   11575            1 :             columnHead.allocate(NumOfCol);
   11576            1 :             columnWidth.allocate(NumOfCol);
   11577            1 :             columnWidth = 14; // array assignment - same for all columns
   11578            1 :             tableBody.allocate(NumOfCol, state.dataGlobal->NumOfZones);
   11579              : 
   11580            1 :             columnHead(1) = "Hybrid Modeling (Y/N)";
   11581            1 :             columnHead(2) = "Temperature Capacitance Multiplier ";
   11582              : 
   11583            2 :             rowHead = "";
   11584            1 :             tableBody = "";
   11585              : 
   11586            5 :             for (int iZone = 1; iZone <= state.dataGlobal->NumOfZones; ++iZone) {
   11587            4 :                 auto const &thisZone = state.dataHeatBal->Zone(iZone);
   11588              : 
   11589            4 :                 rowHead(iZone) = thisZone.Name;
   11590            4 :                 if (state.dataHybridModel->hybridModelZones(iZone).InternalThermalMassCalc_T) {
   11591            3 :                     tableBody(1, iZone) = "Yes";
   11592              :                 } else {
   11593            1 :                     tableBody(1, iZone) = "No";
   11594              :                 }
   11595            4 :                 tableBody(2, iZone) = RealToStr(thisZone.ZoneVolCapMultpSensHMAverage, 2);
   11596              :             }
   11597              : 
   11598            1 :             if (produceTabular) {
   11599            1 :                 WriteSubtitle(state, "Hybrid Model: Internal Thermal Mass");
   11600            1 :                 WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
   11601              :             }
   11602            1 :             if (produceSQLite) {
   11603            1 :                 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          749 :         Real64 const totExtGrossWallArea_Multiplied = sum(state.dataHeatBal->Zone, &ZoneData::ExtGrossWallArea_Multiplied);
   11615          749 :         Real64 const totExtGrossGroundWallArea_Multiplied = sum(state.dataHeatBal->Zone, &ZoneData::ExtGrossGroundWallArea_Multiplied);
   11616          749 :         if (totExtGrossWallArea_Multiplied > 0.0 || totExtGrossGroundWallArea_Multiplied > 0.0) {
   11617              :             Real64 const pdiff =
   11618          722 :                 std::abs((wallAreaN + wallAreaS + wallAreaE + wallAreaW) - (totExtGrossWallArea_Multiplied + totExtGrossGroundWallArea_Multiplied)) /
   11619          722 :                 (totExtGrossWallArea_Multiplied + totExtGrossGroundWallArea_Multiplied);
   11620          722 :             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          749 :         if (produceTabular) {
   11647         1498 :             WriteTextLine(state, "PERFORMANCE", true);
   11648              :         }
   11649              : 
   11650          749 :         rowHead.allocate(state.dataGlobal->NumOfZones + 4);
   11651              : 
   11652          749 :         int const NumOfCol = 12;
   11653          749 :         columnHead.allocate(NumOfCol);
   11654          749 :         columnWidth.allocate(NumOfCol);
   11655          749 :         columnWidth = 14; // array assignment - same for all columns
   11656          749 :         tableBody.allocate(NumOfCol, state.dataGlobal->NumOfZones + 4);
   11657              : 
   11658          749 :         columnHead(1) = "Area " + state.dataOutRptTab->m2_unitName;
   11659          749 :         columnHead(2) = "Conditioned (Y/N)";
   11660          749 :         columnHead(3) = "Part of Total Floor Area (Y/N)";
   11661          749 :         columnHead(4) = "Volume " + state.dataOutRptTab->m3_unitName;
   11662          749 :         columnHead(5) = "Multipliers";
   11663          749 :         columnHead(6) = "Above Ground Gross Wall Area " + state.dataOutRptTab->m2_unitName;
   11664          749 :         columnHead(7) = "Underground Gross Wall Area " + state.dataOutRptTab->m2_unitName;
   11665          749 :         columnHead(8) = "Window Glass Area " + state.dataOutRptTab->m2_unitName;
   11666          749 :         columnHead(9) = "Opening Area " + state.dataOutRptTab->m2_unitName;
   11667          749 :         columnHead(10) = "Lighting " + state.dataOutRptTab->Wm2_unitName;
   11668         1498 :         columnHead(11) = "People " + state.dataOutRptTab->m2_unitName.substr(0, len(state.dataOutRptTab->m2_unitName) - 1) + " per person" +
   11669         1498 :                          state.dataOutRptTab->m2_unitName[len(state.dataOutRptTab->m2_unitName) - 1];
   11670          749 :         columnHead(12) = "Plug and Process " + state.dataOutRptTab->Wm2_unitName;
   11671              : 
   11672          749 :         rowHead = "";
   11673          749 :         rowHead(state.dataGlobal->NumOfZones + state.dataOutRptTab->grandTotal) = "Total";
   11674          749 :         rowHead(state.dataGlobal->NumOfZones + state.dataOutRptTab->condTotal) = "Conditioned Total";
   11675          749 :         rowHead(state.dataGlobal->NumOfZones + state.dataOutRptTab->uncondTotal) = "Unconditioned Total";
   11676          749 :         rowHead(state.dataGlobal->NumOfZones + state.dataOutRptTab->notpartTotal) = "Not Part of Total";
   11677              : 
   11678          749 :         tableBody = "";
   11679              : 
   11680         5754 :         for (int iZone = 1; iZone <= state.dataGlobal->NumOfZones; ++iZone) {
   11681         5005 :             auto const &thisZone = state.dataHeatBal->Zone(iZone);
   11682              : 
   11683         5005 :             Real64 const mult = thisZone.Multiplier * thisZone.ListMultiplier;
   11684         5005 :             rowHead(iZone) = thisZone.Name;
   11685              :             // Conditioned or not
   11686         5005 :             bool zoneIsCond = false;
   11687         5005 :             if (thisZone.SystemZoneNodeNumber > 0) {
   11688         4597 :                 tableBody(2, iZone) = "Yes";
   11689         4597 :                 zoneIsCond = true;
   11690              :             } else {
   11691          408 :                 tableBody(2, iZone) = "No";
   11692          408 :                 zoneIsCond = false;
   11693              :             }
   11694              :             // Part of Total Floor Area or not
   11695         5005 :             bool usezoneFloorArea = false;
   11696         5005 :             if (thisZone.isPartOfTotalArea) {
   11697         4868 :                 tableBody(3, iZone) = "Yes";
   11698         4868 :                 usezoneFloorArea = true;
   11699              :             } else {
   11700          137 :                 tableBody(3, iZone) = "No";
   11701          137 :                 usezoneFloorArea = false;
   11702              :             }
   11703         5005 :             tableBody(1, iZone) = RealToStr(thisZone.FloorArea * state.dataOutRptTab->m2_unitConvWVST, 2);
   11704         5005 :             tableBody(4, iZone) = RealToStr(thisZone.Volume * state.dataOutRptTab->m3_unitConv, 2);
   11705              :             // no unit conversion necessary since done automatically
   11706         5005 :             if (produceTabular) {
   11707         5005 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchLeedSutSpArea, thisZone.Name, thisZone.FloorArea, 2);
   11708              :             }
   11709         5005 :             if (zoneIsCond) {
   11710         4597 :                 if (produceTabular) {
   11711         4597 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchLeedSutOcArea, thisZone.Name, thisZone.FloorArea, 2);
   11712         4597 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchLeedSutUnArea, thisZone.Name, "0.00");
   11713              :                 }
   11714              :             } else {
   11715          408 :                 if (produceTabular) {
   11716          408 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchLeedSutOcArea, thisZone.Name, "0.00");
   11717          408 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchLeedSutUnArea, thisZone.Name, thisZone.FloorArea, 2);
   11718              :                 }
   11719              :             }
   11720         5005 :             tableBody(5, iZone) = RealToStr(mult, 2);
   11721         5005 :             tableBody(6, iZone) = RealToStr(thisZone.ExtGrossWallArea * state.dataOutRptTab->m2_unitConvWVST, 2);
   11722         5005 :             tableBody(7, iZone) = RealToStr(thisZone.ExtGrossGroundWallArea * state.dataOutRptTab->m2_unitConvWVST, 2);
   11723         5005 :             tableBody(8, iZone) = RealToStr(zoneGlassArea(iZone) * state.dataOutRptTab->m2_unitConvWVST, 2);
   11724         5005 :             tableBody(9, iZone) = RealToStr(zoneOpeningArea(iZone) * state.dataOutRptTab->m2_unitConvWVST, 2);
   11725              :             // lighting density
   11726         5005 :             Real64 totLightPower = 0.0;
   11727       159466 :             for (int iLight = 1; iLight <= state.dataHeatBal->TotLights; ++iLight) {
   11728       154461 :                 if (iZone == state.dataHeatBal->Lights(iLight).ZonePtr) {
   11729         4327 :                     totLightPower += state.dataHeatBal->Lights(iLight).DesignLevel;
   11730              :                 }
   11731              :             }
   11732         5005 :             if (thisZone.FloorArea > 0) {
   11733         5003 :                 tableBody(10, iZone) = RealToStr(state.dataOutRptTab->Wm2_unitConv * totLightPower / thisZone.FloorArea, 4);
   11734              :             }
   11735              :             // people density
   11736         5005 :             Real64 totNumPeople = 0.0;
   11737       123127 :             for (int iPeople = 1; iPeople <= state.dataHeatBal->TotPeople; ++iPeople) {
   11738       118122 :                 if (iZone == state.dataHeatBal->People(iPeople).ZonePtr) {
   11739         4088 :                     totNumPeople += state.dataHeatBal->People(iPeople).NumberOfPeople;
   11740              :                 }
   11741              :             }
   11742         5005 :             if (totNumPeople > 0) {
   11743         3986 :                 tableBody(11, iZone) = RealToStr(thisZone.FloorArea * state.dataOutRptTab->m2_unitConvWVST / totNumPeople, 2);
   11744              :             }
   11745              :             // plug and process density
   11746         5005 :             Real64 totPlugProcess = 0.0;
   11747       152778 :             for (int iPlugProc = 1; iPlugProc <= state.dataHeatBal->TotElecEquip; ++iPlugProc) {
   11748       147773 :                 if (iZone == state.dataHeatBal->ZoneElectric(iPlugProc).ZonePtr) {
   11749         4440 :                     totPlugProcess += state.dataHeatBal->ZoneElectric(iPlugProc).DesignLevel;
   11750              :                 }
   11751              :             }
   11752         8128 :             for (int iPlugProc = 1; iPlugProc <= state.dataHeatBal->TotGasEquip; ++iPlugProc) {
   11753         3123 :                 if (iZone == state.dataHeatBal->ZoneGas(iPlugProc).ZonePtr) {
   11754           86 :                     totPlugProcess += state.dataHeatBal->ZoneGas(iPlugProc).DesignLevel;
   11755              :                 }
   11756              :             }
   11757         5218 :             for (int iPlugProc = 1; iPlugProc <= state.dataHeatBal->TotOthEquip; ++iPlugProc) {
   11758          213 :                 if (iZone == state.dataHeatBal->ZoneOtherEq(iPlugProc).ZonePtr) {
   11759           77 :                     totPlugProcess += state.dataHeatBal->ZoneOtherEq(iPlugProc).DesignLevel;
   11760              :                 }
   11761              :             }
   11762         5116 :             for (int iPlugProc = 1; iPlugProc <= state.dataHeatBal->TotHWEquip; ++iPlugProc) {
   11763          111 :                 if (iZone == state.dataHeatBal->ZoneHWEq(iPlugProc).ZonePtr) {
   11764           14 :                     totPlugProcess += state.dataHeatBal->ZoneHWEq(iPlugProc).DesignLevel;
   11765              :                 }
   11766              :             }
   11767         5024 :             for (int iPlugProc = 1; iPlugProc <= state.dataHeatBal->TotITEquip; ++iPlugProc) {
   11768           19 :                 if (iZone == state.dataHeatBal->ZoneITEq(iPlugProc).ZonePtr) {
   11769            7 :                     totPlugProcess += state.dataHeatBal->ZoneITEq(iPlugProc).DesignTotalPower;
   11770              :                 }
   11771              :             }
   11772         5005 :             if (thisZone.FloorArea > 0) {
   11773         5003 :                 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         5005 :             if (!usezoneFloorArea) {
   11781          137 :                 state.dataOutRptTab->zstArea(state.dataOutRptTab->notpartTotal) += mult * thisZone.FloorArea;
   11782          137 :                 state.dataOutRptTab->zstVolume(state.dataOutRptTab->notpartTotal) += mult * thisZone.Volume;
   11783          137 :                 state.dataOutRptTab->zstWallArea(state.dataOutRptTab->notpartTotal) += mult * thisZone.ExtGrossWallArea;
   11784          137 :                 state.dataOutRptTab->zstUndWallArea(state.dataOutRptTab->notpartTotal) += mult * thisZone.ExtGrossGroundWallArea;
   11785          137 :                 state.dataOutRptTab->zstWindowArea(state.dataOutRptTab->notpartTotal) += mult * zoneGlassArea(iZone);
   11786          137 :                 state.dataOutRptTab->zstOpeningArea(state.dataOutRptTab->notpartTotal) += mult * zoneOpeningArea(iZone);
   11787          137 :                 state.dataOutRptTab->zstLight(state.dataOutRptTab->notpartTotal) += mult * totLightPower;
   11788          137 :                 state.dataOutRptTab->zstPeople(state.dataOutRptTab->notpartTotal) += mult * totNumPeople;
   11789          137 :                 state.dataOutRptTab->zstPlug(state.dataOutRptTab->notpartTotal) += mult * totPlugProcess;
   11790              :             } else {
   11791              :                 // Add it to the 'Total'
   11792         4868 :                 state.dataOutRptTab->zstArea(state.dataOutRptTab->grandTotal) += mult * thisZone.FloorArea;
   11793         4868 :                 state.dataOutRptTab->zstVolume(state.dataOutRptTab->grandTotal) += mult * thisZone.Volume;
   11794         4868 :                 state.dataOutRptTab->zstWallArea(state.dataOutRptTab->grandTotal) += mult * thisZone.ExtGrossWallArea;
   11795         4868 :                 state.dataOutRptTab->zstUndWallArea(state.dataOutRptTab->grandTotal) += mult * thisZone.ExtGrossGroundWallArea;
   11796         4868 :                 state.dataOutRptTab->zstWindowArea(state.dataOutRptTab->grandTotal) += mult * zoneGlassArea(iZone);
   11797         4868 :                 state.dataOutRptTab->zstOpeningArea(state.dataOutRptTab->grandTotal) += mult * zoneOpeningArea(iZone);
   11798         4868 :                 state.dataOutRptTab->zstLight(state.dataOutRptTab->grandTotal) += mult * totLightPower;
   11799         4868 :                 state.dataOutRptTab->zstPeople(state.dataOutRptTab->grandTotal) += mult * totNumPeople;
   11800         4868 :                 state.dataOutRptTab->zstPlug(state.dataOutRptTab->grandTotal) += mult * totPlugProcess;
   11801              : 
   11802              :                 // Subtotal between cond/unconditioned
   11803         4868 :                 int const condUncondTotal = zoneIsCond ? state.dataOutRptTab->condTotal : state.dataOutRptTab->uncondTotal;
   11804         4868 :                 state.dataOutRptTab->zstArea(condUncondTotal) += mult * thisZone.FloorArea;
   11805         4868 :                 state.dataOutRptTab->zstVolume(condUncondTotal) += mult * thisZone.Volume;
   11806         4868 :                 state.dataOutRptTab->zstWallArea(condUncondTotal) += mult * thisZone.ExtGrossWallArea;
   11807         4868 :                 state.dataOutRptTab->zstUndWallArea(condUncondTotal) += mult * thisZone.ExtGrossGroundWallArea;
   11808         4868 :                 state.dataOutRptTab->zstWindowArea(condUncondTotal) += mult * zoneGlassArea(iZone);
   11809         4868 :                 state.dataOutRptTab->zstOpeningArea(condUncondTotal) += mult * zoneOpeningArea(iZone);
   11810         4868 :                 state.dataOutRptTab->zstLight(condUncondTotal) += mult * totLightPower;
   11811         4868 :                 state.dataOutRptTab->zstPeople(condUncondTotal) += mult * totNumPeople;
   11812         4868 :                 state.dataOutRptTab->zstPlug(condUncondTotal) += mult * totPlugProcess;
   11813              :             }
   11814              :         }
   11815         3745 :         for (int iTotal = 1; iTotal <= 4; ++iTotal) {
   11816         2996 :             tableBody(1, state.dataGlobal->NumOfZones + iTotal) =
   11817         5992 :                 RealToStr(state.dataOutRptTab->zstArea(iTotal) * state.dataOutRptTab->m2_unitConvWVST, 2);
   11818         2996 :             tableBody(4, state.dataGlobal->NumOfZones + iTotal) =
   11819         5992 :                 RealToStr(state.dataOutRptTab->zstVolume(iTotal) * state.dataOutRptTab->m3_unitConv, 2);
   11820         2996 :             tableBody(6, state.dataGlobal->NumOfZones + iTotal) =
   11821         5992 :                 RealToStr(state.dataOutRptTab->zstWallArea(iTotal) * state.dataOutRptTab->m2_unitConvWVST, 2);
   11822         2996 :             tableBody(7, state.dataGlobal->NumOfZones + iTotal) =
   11823         5992 :                 RealToStr(state.dataOutRptTab->zstUndWallArea(iTotal) * state.dataOutRptTab->m2_unitConvWVST, 2);
   11824         2996 :             tableBody(8, state.dataGlobal->NumOfZones + iTotal) =
   11825         5992 :                 RealToStr(state.dataOutRptTab->zstWindowArea(iTotal) * state.dataOutRptTab->m2_unitConvWVST, 2);
   11826         2996 :             tableBody(9, state.dataGlobal->NumOfZones + iTotal) =
   11827         5992 :                 RealToStr(state.dataOutRptTab->zstOpeningArea(iTotal) * state.dataOutRptTab->m2_unitConvWVST, 2);
   11828         2996 :             if (state.dataOutRptTab->zstArea(iTotal) != 0) {
   11829         1637 :                 tableBody(10, state.dataGlobal->NumOfZones + iTotal) =
   11830         3274 :                     RealToStr(state.dataOutRptTab->zstLight(iTotal) * state.dataOutRptTab->Wm2_unitConv / state.dataOutRptTab->zstArea(iTotal), 4);
   11831         1637 :                 tableBody(12, state.dataGlobal->NumOfZones + iTotal) =
   11832         3274 :                     RealToStr(state.dataOutRptTab->zstPlug(iTotal) * state.dataOutRptTab->Wm2_unitConv / state.dataOutRptTab->zstArea(iTotal), 4);
   11833              :             }
   11834         2996 :             if (state.dataOutRptTab->zstPeople(iTotal) != 0) {
   11835         2582 :                 tableBody(11, state.dataGlobal->NumOfZones + iTotal) = RealToStr(
   11836         2582 :                     state.dataOutRptTab->zstArea(iTotal) * state.dataOutRptTab->m2_unitConvWVST / state.dataOutRptTab->zstPeople(iTotal), 2);
   11837              :             }
   11838              :         }
   11839          749 :         if (produceTabular) {
   11840          749 :             PreDefTableEntry(
   11841          749 :                 state, state.dataOutRptPredefined->pdchLeedSutSpArea, "Totals", state.dataOutRptTab->zstArea(state.dataOutRptTab->grandTotal), 2);
   11842          749 :             PreDefTableEntry(
   11843          749 :                 state, state.dataOutRptPredefined->pdchLeedSutOcArea, "Totals", state.dataOutRptTab->zstArea(state.dataOutRptTab->condTotal), 2);
   11844          749 :             PreDefTableEntry(
   11845         1498 :                 state, state.dataOutRptPredefined->pdchLeedSutUnArea, "Totals", state.dataOutRptTab->zstArea(state.dataOutRptTab->uncondTotal), 2);
   11846              : 
   11847          749 :             WriteSubtitle(state, "Zone Summary");
   11848          749 :             WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
   11849              :         }
   11850          749 :         if (produceSQLite) {
   11851          749 :             if (state.dataSQLiteProcedures->sqlite) {
   11852          122 :                 state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
   11853              :                     tableBody, rowHead, columnHead, "InputVerificationandResultsSummary", "Entire Facility", "Zone Summary");
   11854              :             }
   11855              :         }
   11856          749 :         if (produceTabular) {
   11857          749 :             if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
   11858           63 :                 state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(
   11859              :                     tableBody, rowHead, columnHead, "InputVerificationandResultsSummary", "Entire Facility", "Zone Summary");
   11860              :             }
   11861              :         }
   11862              : 
   11863          749 :         writeVeriSumSpaceTables(state, produceTabular, produceSQLite);
   11864              :     }
   11865          749 : }
   11866              : 
   11867          749 : void writeVeriSumSpaceTables(EnergyPlusData &state, bool produceTabular, bool produceSQLite)
   11868              : {
   11869              : 
   11870              :     // Write Space and SpaceType sub-tables for Input Verification and Results Summary
   11871          749 :     Array1D_string spaceRowHead;
   11872          749 :     Array1D_string spaceColumnHead;
   11873          749 :     Array1D_int spaceColumnWidth;
   11874          749 :     Array2D_string spaceTableBody;
   11875          749 :     int spaceNumCol = 11;
   11876          749 :     spaceRowHead.allocate(state.dataGlobal->numSpaces + 4); // Extra rows for totals
   11877          749 :     spaceColumnHead.allocate(spaceNumCol);
   11878          749 :     spaceColumnWidth.allocate(spaceNumCol);
   11879          749 :     spaceTableBody.allocate(spaceNumCol, state.dataGlobal->numSpaces + 4); // Extra rows for totals
   11880         8988 :     for (int iCol = 1; iCol <= spaceNumCol; ++iCol) {
   11881         8239 :         spaceColumnWidth(iCol) = 14;
   11882              :     }
   11883              : 
   11884          749 :     spaceColumnHead(1) = "Area " + state.dataOutRptTab->m2_unitName;
   11885          749 :     spaceColumnHead(2) = "Conditioned (Y/N)";
   11886          749 :     spaceColumnHead(3) = "Part of Total Floor Area (Y/N)";
   11887          749 :     spaceColumnHead(4) = "Multipliers";
   11888          749 :     spaceColumnHead(5) = "Zone Name";
   11889          749 :     spaceColumnHead(6) = "Space Type";
   11890          749 :     spaceColumnHead(7) = "Radiant/Solar Enclosure Name";
   11891          749 :     spaceColumnHead(8) = "Lighting " + state.dataOutRptTab->Wm2_unitName;
   11892         1498 :     spaceColumnHead(9) = "People " + state.dataOutRptTab->m2_unitName.substr(0, len(state.dataOutRptTab->m2_unitName) - 1) + " per person" +
   11893         1498 :                          state.dataOutRptTab->m2_unitName[len(state.dataOutRptTab->m2_unitName) - 1];
   11894          749 :     spaceColumnHead(10) = "Plug and Process " + state.dataOutRptTab->Wm2_unitName;
   11895          749 :     spaceColumnHead(11) = "Tags";
   11896              : 
   11897          749 :     int constexpr colSpaceArea(1);
   11898          749 :     int constexpr colConditioned(2);
   11899          749 :     int constexpr colPartOfTotal(3);
   11900          749 :     int constexpr colMultipliers(4);
   11901          749 :     int constexpr colZoneName(5);
   11902          749 :     int constexpr colSpaceType(6);
   11903          749 :     int constexpr colEnclName(7);
   11904          749 :     int constexpr colSpaceLighting(8);
   11905          749 :     int constexpr colSpacePeople(9);
   11906          749 :     int constexpr colSpacePlugProcess(10);
   11907          749 :     int constexpr colSpaceTags(11);
   11908              : 
   11909          749 :     spaceRowHead(state.dataGlobal->numSpaces + state.dataOutRptTab->grandTotal) = "Total";
   11910          749 :     spaceRowHead(state.dataGlobal->numSpaces + state.dataOutRptTab->condTotal) = "Conditioned Total";
   11911          749 :     spaceRowHead(state.dataGlobal->numSpaces + state.dataOutRptTab->uncondTotal) = "Unconditioned Total";
   11912          749 :     spaceRowHead(state.dataGlobal->numSpaces + state.dataOutRptTab->notpartTotal) = "Not Part of Total";
   11913              : 
   11914          749 :     EPVector<Real64> spaceTotLighting;
   11915          749 :     EPVector<Real64> spaceTotPeople;
   11916          749 :     EPVector<Real64> spaceTotPlugProcess;
   11917          749 :     spaceTotLighting.allocate(state.dataGlobal->numSpaces);
   11918          749 :     spaceTotPeople.allocate(state.dataGlobal->numSpaces);
   11919          749 :     spaceTotPlugProcess.allocate(state.dataGlobal->numSpaces);
   11920         5766 :     for (int iSpace = 1; iSpace <= state.dataGlobal->numSpaces; ++iSpace) {
   11921         5017 :         spaceTotLighting(iSpace) = 0.0;
   11922         5017 :         spaceTotPeople(iSpace) = 0.0;
   11923         5017 :         spaceTotPlugProcess(iSpace) = 0.0;
   11924              :     }
   11925              : 
   11926          749 :     Array1D_string spaceTypeRowHead;
   11927          749 :     Array1D_string spaceTypeColumnHead;
   11928          749 :     Array1D_int spaceTypeColumnWidth;
   11929          749 :     Array2D_string spaceTypeTableBody;
   11930          749 :     int spaceTypeNumCol = 7;
   11931          749 :     spaceTypeRowHead.allocate(state.dataGlobal->numSpaceTypes + 1); // Extra row for total
   11932          749 :     spaceTypeColumnHead.allocate(spaceTypeNumCol);
   11933          749 :     spaceTypeColumnWidth.allocate(spaceTypeNumCol);
   11934          749 :     spaceTypeTableBody.allocate(spaceTypeNumCol, state.dataGlobal->numSpaceTypes + 1); // Extra row for total
   11935         5992 :     for (int iCol = 1; iCol <= spaceTypeNumCol; ++iCol) {
   11936         5243 :         spaceTypeColumnWidth(iCol) = 14;
   11937              :     }
   11938          749 :     spaceTypeColumnHead(1) = "Total Area " + state.dataOutRptTab->m2_unitName;
   11939          749 :     spaceTypeColumnHead(2) = "Conditioned Area " + state.dataOutRptTab->m2_unitName;
   11940          749 :     spaceTypeColumnHead(3) = "Unconditioned Area " + state.dataOutRptTab->m2_unitName;
   11941          749 :     spaceTypeColumnHead(4) = "Not Part of Total Area " + state.dataOutRptTab->m2_unitName;
   11942          749 :     spaceTypeColumnHead(5) = "Lighting " + state.dataOutRptTab->Wm2_unitName;
   11943         1498 :     spaceTypeColumnHead(6) = "People " + state.dataOutRptTab->m2_unitName.substr(0, len(state.dataOutRptTab->m2_unitName) - 1) + " per person" +
   11944         1498 :                              state.dataOutRptTab->m2_unitName[len(state.dataOutRptTab->m2_unitName) - 1];
   11945          749 :     spaceTypeColumnHead(7) = "Plug and Process " + state.dataOutRptTab->Wm2_unitName;
   11946              : 
   11947          749 :     int constexpr colSpaceTypeTotArea(1);
   11948          749 :     int constexpr colSpaceTypeCondArea(2);
   11949          749 :     int constexpr colSpaceTypeUncondArea(3);
   11950          749 :     int constexpr colSpaceTypeNotTotArea(4);
   11951          749 :     int constexpr colSpaceTypeLighting(5);
   11952          749 :     int constexpr colSpaceTypePeople(6);
   11953          749 :     int constexpr colSpaceTypePlugProcess(7);
   11954              : 
   11955          749 :     spaceTypeRowHead(state.dataGlobal->numSpaceTypes + state.dataOutRptTab->grandTotal) = "Total";
   11956              : 
   11957          749 :     EPVector<Real64> spaceTypeTotArea;
   11958          749 :     EPVector<Real64> spaceTypeCondArea;
   11959          749 :     EPVector<Real64> spaceTypeUncondArea;
   11960          749 :     EPVector<Real64> spaceTypeNotTotArea;
   11961          749 :     EPVector<Real64> spaceTypeTotLighting;
   11962          749 :     EPVector<Real64> spaceTypeTotPeople;
   11963          749 :     EPVector<Real64> spaceTypeTotPlugProcess;
   11964          749 :     spaceTypeTotArea.allocate(state.dataGlobal->numSpaceTypes);
   11965          749 :     spaceTypeCondArea.allocate(state.dataGlobal->numSpaceTypes);
   11966          749 :     spaceTypeUncondArea.allocate(state.dataGlobal->numSpaceTypes);
   11967          749 :     spaceTypeNotTotArea.allocate(state.dataGlobal->numSpaceTypes);
   11968          749 :     spaceTypeTotLighting.allocate(state.dataGlobal->numSpaceTypes);
   11969          749 :     spaceTypeTotPeople.allocate(state.dataGlobal->numSpaceTypes);
   11970          749 :     spaceTypeTotPlugProcess.allocate(state.dataGlobal->numSpaceTypes);
   11971         1484 :     for (int iSpaceType = 1; iSpaceType <= state.dataGlobal->numSpaceTypes; ++iSpaceType) {
   11972          735 :         spaceTypeTotArea(iSpaceType) = 0.0;
   11973          735 :         spaceTypeCondArea(iSpaceType) = 0.0;
   11974          735 :         spaceTypeUncondArea(iSpaceType) = 0.0;
   11975          735 :         spaceTypeNotTotArea(iSpaceType) = 0.0;
   11976          735 :         spaceTypeTotLighting(iSpaceType) = 0.0;
   11977          735 :         spaceTypeTotPeople(iSpaceType) = 0.0;
   11978          735 :         spaceTypeTotPlugProcess(iSpaceType) = 0.0;
   11979              :     }
   11980              : 
   11981              :     // Accumulate internal gain totals by space and space type
   11982         4837 :     for (int iPeople = 1; iPeople <= state.dataHeatBal->TotPeople; ++iPeople) {
   11983         4088 :         auto const &curPeople = state.dataHeatBal->People(iPeople);
   11984         4088 :         int const spaceNum = curPeople.spaceIndex;
   11985         4088 :         Real64 const people = curPeople.NumberOfPeople;
   11986         4088 :         spaceTotPeople(spaceNum) += people;
   11987         4088 :         spaceTypeTotPeople(state.dataHeatBal->space(spaceNum).spaceTypeNum) += people;
   11988              :     }
   11989         5076 :     for (int iLights = 1; iLights <= state.dataHeatBal->TotLights; ++iLights) {
   11990         4327 :         auto const &curLighting = state.dataHeatBal->Lights(iLights);
   11991         4327 :         int const spaceNum = curLighting.spaceIndex;
   11992         4327 :         Real64 const lighting = curLighting.DesignLevel;
   11993         4327 :         spaceTotLighting(spaceNum) += lighting;
   11994         4327 :         spaceTypeTotLighting(state.dataHeatBal->space(spaceNum).spaceTypeNum) += lighting;
   11995              :     }
   11996         5189 :     for (int iElecEquip = 1; iElecEquip <= state.dataHeatBal->TotElecEquip; ++iElecEquip) {
   11997         4440 :         auto const &curElecEquip = state.dataHeatBal->ZoneElectric(iElecEquip);
   11998         4440 :         int const spaceNum = curElecEquip.spaceIndex;
   11999         4440 :         Real64 const elecEquip = curElecEquip.DesignLevel;
   12000         4440 :         spaceTotPlugProcess(spaceNum) += elecEquip;
   12001         4440 :         spaceTypeTotPlugProcess(state.dataHeatBal->space(spaceNum).spaceTypeNum) += elecEquip;
   12002              :     }
   12003          835 :     for (int iGasEquip = 1; iGasEquip <= state.dataHeatBal->TotGasEquip; ++iGasEquip) {
   12004           86 :         auto const &curGasEquip = state.dataHeatBal->ZoneGas(iGasEquip);
   12005           86 :         int const spaceNum = curGasEquip.spaceIndex;
   12006           86 :         Real64 const gasEquip = curGasEquip.DesignLevel;
   12007           86 :         spaceTotPlugProcess(spaceNum) += gasEquip;
   12008           86 :         spaceTypeTotPlugProcess(state.dataHeatBal->space(spaceNum).spaceTypeNum) += gasEquip;
   12009              :     }
   12010          826 :     for (int iOthEquip = 1; iOthEquip <= state.dataHeatBal->TotOthEquip; ++iOthEquip) {
   12011           77 :         auto const &curOthEquip = state.dataHeatBal->ZoneOtherEq(iOthEquip);
   12012           77 :         int const spaceNum = curOthEquip.spaceIndex;
   12013           77 :         Real64 const othEquip = curOthEquip.DesignLevel;
   12014           77 :         spaceTotPlugProcess(spaceNum) += othEquip;
   12015           77 :         spaceTypeTotPlugProcess(state.dataHeatBal->space(spaceNum).spaceTypeNum) += othEquip;
   12016              :     }
   12017          763 :     for (int iHWEquip = 1; iHWEquip <= state.dataHeatBal->TotHWEquip; ++iHWEquip) {
   12018           14 :         auto const &curHWEquip = state.dataHeatBal->ZoneHWEq(iHWEquip);
   12019           14 :         int const spaceNum = curHWEquip.spaceIndex;
   12020           14 :         Real64 const hwEquip = curHWEquip.DesignLevel;
   12021           14 :         spaceTotPlugProcess(spaceNum) += hwEquip;
   12022           14 :         spaceTypeTotPlugProcess(state.dataHeatBal->space(spaceNum).spaceTypeNum) += hwEquip;
   12023              :     }
   12024          754 :     for (int iSteamEquip = 1; iSteamEquip <= state.dataHeatBal->TotStmEquip; ++iSteamEquip) {
   12025            5 :         auto const &curSteamEquip = state.dataHeatBal->ZoneSteamEq(iSteamEquip);
   12026            5 :         int const spaceNum = curSteamEquip.spaceIndex;
   12027            5 :         Real64 const steamEquip = curSteamEquip.DesignLevel;
   12028            5 :         spaceTotPlugProcess(spaceNum) += steamEquip;
   12029            5 :         spaceTypeTotPlugProcess(state.dataHeatBal->space(spaceNum).spaceTypeNum) += steamEquip;
   12030              :     }
   12031          756 :     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         3745 :     for (int iTotal = 1; iTotal <= 4; ++iTotal) {
   12041         2996 :         state.dataOutRptTab->zstArea(iTotal) = 0.0;
   12042         2996 :         state.dataOutRptTab->zstLight(iTotal) = 0.0;
   12043         2996 :         state.dataOutRptTab->zstPlug(iTotal) = 0.0;
   12044         2996 :         state.dataOutRptTab->zstPeople(iTotal) = 0.0;
   12045              :     }
   12046              : 
   12047          749 :     int spaceTableRowNum = 0;
   12048         5754 :     for (int iZone = 1; iZone <= state.dataGlobal->NumOfZones; ++iZone) {
   12049         5005 :         auto const &curZone = state.dataHeatBal->Zone(iZone);
   12050         5005 :         Real64 const mult = Real64(curZone.Multiplier) * Real64(curZone.ListMultiplier);
   12051        10022 :         for (int const spaceNum : curZone.spaceIndexes) {
   12052         5017 :             auto &curSpace = state.dataHeatBal->space(spaceNum);
   12053         5017 :             bool spaceIsCond = false;
   12054         5017 :             bool useSpaceFloorArea = false;
   12055         5017 :             ++spaceTableRowNum;
   12056         5017 :             spaceRowHead(spaceTableRowNum) = curSpace.Name;
   12057         5017 :             spaceTableBody(colZoneName, spaceTableRowNum) = curZone.Name;
   12058         5017 :             spaceTableBody(colSpaceType, spaceTableRowNum) = curSpace.spaceType;
   12059         5017 :             spaceTableBody(colEnclName, spaceTableRowNum) = state.dataViewFactor->EnclSolInfo(curSpace.solarEnclosureNum).Name;
   12060         5017 :             spaceTableBody(colSpaceArea, spaceTableRowNum) = RealToStr(curSpace.FloorArea * state.dataOutRptTab->m2_unitConvWVST, 2);
   12061              :             // Conditioned or not
   12062         5017 :             if (curZone.SystemZoneNodeNumber > 0) {
   12063         4609 :                 spaceTableBody(colConditioned, spaceTableRowNum) = "Yes";
   12064         4609 :                 spaceIsCond = true;
   12065              :             } else {
   12066          408 :                 spaceTableBody(colConditioned, spaceTableRowNum) = "No";
   12067          408 :                 spaceIsCond = false;
   12068              :             }
   12069              :             // Part of Total Floor Area or not
   12070         5017 :             if (curZone.isPartOfTotalArea) {
   12071         4880 :                 spaceTableBody(colPartOfTotal, spaceTableRowNum) = "Yes";
   12072         4880 :                 useSpaceFloorArea = true;
   12073              :             } else {
   12074          137 :                 spaceTableBody(colPartOfTotal, spaceTableRowNum) = "No";
   12075          137 :                 useSpaceFloorArea = false;
   12076              :             }
   12077              :             // lighting density
   12078         5017 :             spaceTableBody(colMultipliers, spaceTableRowNum) = RealToStr(mult, 2);
   12079         5017 :             if (curSpace.FloorArea > 0) {
   12080         5012 :                 spaceTableBody(colSpaceLighting, spaceTableRowNum) =
   12081        10024 :                     RealToStr(state.dataOutRptTab->Wm2_unitConv * spaceTotLighting(spaceNum) / curSpace.FloorArea, 4);
   12082              :             } else {
   12083            5 :                 spaceTableBody(colSpaceLighting, spaceTableRowNum) = RealToStr(0.0, 4);
   12084              :             }
   12085              :             // people density
   12086         5017 :             if (spaceTotPeople(spaceNum) > 0) {
   12087         3995 :                 spaceTableBody(colSpacePeople, spaceTableRowNum) =
   12088         7990 :                     RealToStr(curSpace.FloorArea * state.dataOutRptTab->m2_unitConvWVST / spaceTotPeople(spaceNum), 2);
   12089              :             } else {
   12090         1022 :                 spaceTableBody(colSpacePeople, spaceTableRowNum) = RealToStr(0.0, 2);
   12091              :             }
   12092              :             // plug and process density
   12093         5017 :             if (curSpace.FloorArea > 0) {
   12094         5012 :                 spaceTableBody(colSpacePlugProcess, spaceTableRowNum) =
   12095        10024 :                     RealToStr(spaceTotPlugProcess(spaceNum) * state.dataOutRptTab->Wm2_unitConv / curSpace.FloorArea, 4);
   12096              :             } else {
   12097            5 :                 spaceTableBody(colSpacePlugProcess, spaceTableRowNum) = RealToStr(0.0, 4);
   12098              :             }
   12099              : 
   12100        10034 :             spaceTableBody(colSpaceTags, spaceTableRowNum) = fmt::format("{}", fmt::join(curSpace.tags, ", "));
   12101              : 
   12102              :             // If not part of total, goes directly to this row
   12103         5017 :             if (!useSpaceFloorArea) {
   12104          137 :                 spaceTypeNotTotArea(curSpace.spaceTypeNum) += curSpace.FloorArea * mult;
   12105          137 :                 state.dataOutRptTab->zstArea(state.dataOutRptTab->notpartTotal) += mult * curSpace.FloorArea;
   12106          137 :                 state.dataOutRptTab->zstLight(state.dataOutRptTab->notpartTotal) += mult * spaceTotLighting(spaceNum);
   12107          137 :                 state.dataOutRptTab->zstPeople(state.dataOutRptTab->notpartTotal) += mult * spaceTotPeople(spaceNum);
   12108          137 :                 state.dataOutRptTab->zstPlug(state.dataOutRptTab->notpartTotal) += mult * spaceTotPlugProcess(spaceNum);
   12109              :             } else {
   12110              :                 // Add it to the 'Total'
   12111         4880 :                 spaceTypeTotArea(curSpace.spaceTypeNum) += curSpace.FloorArea * mult;
   12112         4880 :                 state.dataOutRptTab->zstArea(state.dataOutRptTab->grandTotal) += mult * curSpace.FloorArea;
   12113         4880 :                 state.dataOutRptTab->zstLight(state.dataOutRptTab->grandTotal) += mult * spaceTotLighting(spaceNum);
   12114         4880 :                 state.dataOutRptTab->zstPeople(state.dataOutRptTab->grandTotal) += mult * spaceTotPeople(spaceNum);
   12115         4880 :                 state.dataOutRptTab->zstPlug(state.dataOutRptTab->grandTotal) += mult * spaceTotPlugProcess(spaceNum);
   12116              : 
   12117              :                 // Subtotal between cond/unconditioned
   12118              :                 int condUncondTotalIndex;
   12119         4880 :                 if (spaceIsCond) {
   12120         4499 :                     spaceTypeCondArea(curSpace.spaceTypeNum) += curSpace.FloorArea * mult;
   12121         4499 :                     condUncondTotalIndex = state.dataOutRptTab->condTotal;
   12122              : 
   12123              :                 } else {
   12124          381 :                     spaceTypeUncondArea(curSpace.spaceTypeNum) += curSpace.FloorArea * mult;
   12125          381 :                     condUncondTotalIndex = state.dataOutRptTab->uncondTotal;
   12126              :                 }
   12127         4880 :                 state.dataOutRptTab->zstArea(condUncondTotalIndex) += mult * curSpace.FloorArea;
   12128         4880 :                 state.dataOutRptTab->zstLight(condUncondTotalIndex) += mult * spaceTotLighting(spaceNum);
   12129         4880 :                 state.dataOutRptTab->zstPeople(condUncondTotalIndex) += mult * spaceTotPeople(spaceNum);
   12130         4880 :                 state.dataOutRptTab->zstPlug(condUncondTotalIndex) += mult * spaceTotPlugProcess(spaceNum);
   12131              :             }
   12132         5005 :         }
   12133              :     }
   12134              :     // total rows for Total / Not Part of Total
   12135              :     // In "Total": break between conditioned/unconditioned
   12136         3745 :     for (int iTotal = 1; iTotal <= 4; ++iTotal) {
   12137         2996 :         spaceTableBody(colSpaceArea, state.dataGlobal->numSpaces + iTotal) =
   12138         5992 :             RealToStr(state.dataOutRptTab->zstArea(iTotal) * state.dataOutRptTab->m2_unitConvWVST, 2);
   12139         2996 :         if (state.dataOutRptTab->zstArea(iTotal) != 0) {
   12140         1637 :             spaceTableBody(colSpaceLighting, state.dataGlobal->numSpaces + iTotal) =
   12141         3274 :                 RealToStr(state.dataOutRptTab->zstLight(iTotal) * state.dataOutRptTab->Wm2_unitConv / state.dataOutRptTab->zstArea(iTotal), 4);
   12142         1637 :             spaceTableBody(colSpacePlugProcess, state.dataGlobal->numSpaces + iTotal) =
   12143         3274 :                 RealToStr(state.dataOutRptTab->zstPlug(iTotal) * state.dataOutRptTab->Wm2_unitConv / state.dataOutRptTab->zstArea(iTotal), 4);
   12144              :         } else {
   12145         1359 :             spaceTableBody(colSpaceLighting, state.dataGlobal->numSpaces + iTotal) = RealToStr(0.0, 4);
   12146         1359 :             spaceTableBody(colSpacePlugProcess, state.dataGlobal->numSpaces + iTotal) = RealToStr(0.0, 4);
   12147              :         }
   12148         2996 :         if (state.dataOutRptTab->zstPeople(iTotal) != 0) {
   12149         1291 :             spaceTableBody(colSpacePeople, state.dataGlobal->numSpaces + iTotal) =
   12150         2582 :                 RealToStr(state.dataOutRptTab->zstArea(iTotal) * state.dataOutRptTab->m2_unitConvWVST / state.dataOutRptTab->zstPeople(iTotal), 2);
   12151              :         } else {
   12152         1705 :             spaceTableBody(colSpacePeople, state.dataGlobal->numSpaces + iTotal) = RealToStr(0.0, 2);
   12153              :         }
   12154              :     }
   12155              : 
   12156          749 :     Real64 totalArea = 0.0;
   12157          749 :     Real64 condArea = 0.0;
   12158          749 :     Real64 uncondArea = 0.0;
   12159          749 :     Real64 notTotalArea = 0.0;
   12160         1484 :     for (int iSpaceType = 1; iSpaceType <= state.dataGlobal->numSpaceTypes; ++iSpaceType) {
   12161          735 :         spaceTypeRowHead(iSpaceType) = state.dataHeatBal->spaceTypes(iSpaceType);
   12162          735 :         spaceTypeTableBody(colSpaceTypeTotArea, iSpaceType) = RealToStr(spaceTypeTotArea(iSpaceType) * state.dataOutRptTab->m2_unitConvWVST, 2);
   12163          735 :         spaceTypeTableBody(colSpaceTypeCondArea, iSpaceType) = RealToStr(spaceTypeCondArea(iSpaceType) * state.dataOutRptTab->m2_unitConvWVST, 2);
   12164          735 :         spaceTypeTableBody(colSpaceTypeUncondArea, iSpaceType) = RealToStr(spaceTypeUncondArea(iSpaceType) * state.dataOutRptTab->m2_unitConvWVST, 2);
   12165          735 :         spaceTypeTableBody(colSpaceTypeNotTotArea, iSpaceType) = RealToStr(spaceTypeNotTotArea(iSpaceType) * state.dataOutRptTab->m2_unitConvWVST, 2);
   12166          735 :         totalArea += spaceTypeTotArea(iSpaceType);
   12167          735 :         condArea += spaceTypeCondArea(iSpaceType);
   12168          735 :         uncondArea += spaceTypeUncondArea(iSpaceType);
   12169          735 :         notTotalArea += spaceTypeNotTotArea(iSpaceType);
   12170              :         // lighting density
   12171          735 :         if (spaceTypeTotArea(iSpaceType) > 0) {
   12172          729 :             spaceTypeTableBody(colSpaceTypeLighting, iSpaceType) =
   12173         1458 :                 RealToStr(state.dataOutRptTab->Wm2_unitConv * spaceTypeTotLighting(iSpaceType) / spaceTypeTotArea(iSpaceType), 4);
   12174              :         } else {
   12175            6 :             spaceTypeTableBody(colSpaceTypeLighting, iSpaceType) = RealToStr(0.0, 4);
   12176              :         }
   12177              :         // people density
   12178          735 :         if (spaceTypeTotPeople(iSpaceType) > 0) {
   12179          651 :             spaceTypeTableBody(colSpaceTypePeople, iSpaceType) =
   12180         1302 :                 RealToStr(spaceTypeTotArea(iSpaceType) * state.dataOutRptTab->m2_unitConvWVST / spaceTypeTotPeople(iSpaceType), 2);
   12181              :         } else {
   12182           84 :             spaceTypeTableBody(colSpaceTypePeople, iSpaceType) = RealToStr(0.0, 2);
   12183              :         }
   12184              :         // plug and process density
   12185          735 :         if (spaceTypeTotArea(iSpaceType) > 0) {
   12186          729 :             spaceTypeTableBody(colSpaceTypePlugProcess, iSpaceType) =
   12187         1458 :                 RealToStr(spaceTypeTotPlugProcess(iSpaceType) * state.dataOutRptTab->Wm2_unitConv / spaceTypeTotArea(iSpaceType), 4);
   12188              :         } else {
   12189            6 :             spaceTypeTableBody(colSpaceTypePlugProcess, iSpaceType) = RealToStr(0.0, 4);
   12190              :         }
   12191              :     }
   12192              :     // Total Area
   12193          749 :     spaceTypeTableBody(colSpaceTypeTotArea, state.dataGlobal->numSpaceTypes + 1) = RealToStr(totalArea * state.dataOutRptTab->m2_unitConvWVST, 2);
   12194          749 :     spaceTypeTableBody(colSpaceTypeCondArea, state.dataGlobal->numSpaceTypes + 1) = RealToStr(condArea * state.dataOutRptTab->m2_unitConvWVST, 2);
   12195          749 :     spaceTypeTableBody(colSpaceTypeUncondArea, state.dataGlobal->numSpaceTypes + 1) = RealToStr(uncondArea * state.dataOutRptTab->m2_unitConvWVST, 2);
   12196          749 :     spaceTypeTableBody(colSpaceTypeNotTotArea, state.dataGlobal->numSpaceTypes + 1) =
   12197         1498 :         RealToStr(notTotalArea * state.dataOutRptTab->m2_unitConvWVST, 2);
   12198              : 
   12199          749 :     if (produceTabular) {
   12200          749 :         WriteSubtitle(state, "Space Summary");
   12201          749 :         WriteTable(state, spaceTableBody, spaceRowHead, spaceColumnHead, spaceColumnWidth);
   12202              : 
   12203          749 :         WriteSubtitle(state, "Space Type Summary");
   12204          749 :         WriteTable(state, spaceTypeTableBody, spaceTypeRowHead, spaceTypeColumnHead, spaceTypeColumnWidth);
   12205              : 
   12206          749 :         if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
   12207           54 :             state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(
   12208              :                 spaceTableBody, spaceRowHead, spaceColumnHead, "InputVerificationandResultsSummary", "Entire Facility", "Space Summary");
   12209              : 
   12210           63 :             state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(spaceTypeTableBody,
   12211              :                                                                                                   spaceTypeRowHead,
   12212              :                                                                                                   spaceTypeColumnHead,
   12213              :                                                                                                   "InputVerificationandResultsSummary",
   12214              :                                                                                                   "Entire Facility",
   12215              :                                                                                                   "Space Type Summary");
   12216              :         }
   12217              :     }
   12218              : 
   12219          749 :     if (produceSQLite) {
   12220          749 :         if (state.dataSQLiteProcedures->sqlite) {
   12221          122 :             state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
   12222              :                 spaceTableBody, spaceRowHead, spaceColumnHead, "InputVerificationandResultsSummary", "Entire Facility", "Space Summary");
   12223              : 
   12224          122 :             state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(spaceTypeTableBody,
   12225              :                                                                                spaceTypeRowHead,
   12226              :                                                                                spaceTypeColumnHead,
   12227              :                                                                                "InputVerificationandResultsSummary",
   12228              :                                                                                "Entire Facility",
   12229              :                                                                                "Space Type Summary");
   12230              :         }
   12231              :     }
   12232          749 : }
   12233              : 
   12234          759 : 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          759 :     auto &ort = state.dataOutRptTab;
   12248          759 :     if (!ort->displayAdaptiveComfort || state.dataHeatBal->TotPeople <= 0) {
   12249          185 :         return;
   12250              :     }
   12251              : 
   12252          574 :     Array1D_int peopleInd; // Index the relevant people
   12253          574 :     peopleInd.allocate(state.dataHeatBal->TotPeople);
   12254              : 
   12255              :     // Should deallocate after writing table. - LKL
   12256              : 
   12257         3589 :     for (int i = 1; i <= state.dataHeatBal->TotPeople; ++i) {
   12258         3015 :         if (state.dataHeatBal->People(i).AdaptiveASH55 || state.dataHeatBal->People(i).AdaptiveCEN15251) {
   12259            6 :             ++ort->numPeopleAdaptive;
   12260            6 :             peopleInd(ort->numPeopleAdaptive) = i;
   12261              :         }
   12262              :     }
   12263              : 
   12264          574 :     Array1D_string rowHead;
   12265          574 :     Array2D_string tableBody;
   12266          574 :     rowHead.allocate(ort->numPeopleAdaptive);
   12267          574 :     tableBody.allocate(5, ort->numPeopleAdaptive);
   12268              : 
   12269         2296 :     WriteReportHeaders(state, "Adaptive Comfort Summary", "Entire Facility", OutputProcessor::StoreType::Average);
   12270          574 :     WriteSubtitle(state, "Time Not Meeting the Adaptive Comfort Models during Occupied Hours");
   12271              : 
   12272          574 :     Array1D_int columnWidth;
   12273          574 :     columnWidth.allocate(5);
   12274          574 :     columnWidth = 10;
   12275              : 
   12276          574 :     Array1D_string columnHead(5);
   12277          574 :     columnHead(1) = "ASHRAE55 90% Acceptability Limits [Hours]";
   12278          574 :     columnHead(2) = "ASHRAE55 80% Acceptability Limits  [Hours]";
   12279          574 :     columnHead(3) = "CEN15251 Category I Acceptability Limits [Hours]";
   12280          574 :     columnHead(4) = "CEN15251 Category II Acceptability Limits [Hours]";
   12281          574 :     columnHead(5) = "CEN15251 Category III Acceptability Limits [Hours]";
   12282              : 
   12283          574 :     tableBody = "";
   12284          580 :     for (int i = 1; i <= ort->numPeopleAdaptive; ++i) {
   12285            6 :         rowHead(i) = state.dataHeatBal->People(i).Name;
   12286            6 :         if (state.dataHeatBal->People(i).AdaptiveASH55) {
   12287            6 :             tableBody(1, i) = RealToStr(state.dataHeatBal->People(peopleInd(i)).TimeNotMetASH5590, 2);
   12288            6 :             tableBody(2, i) = RealToStr(state.dataHeatBal->People(peopleInd(i)).TimeNotMetASH5580, 2);
   12289              :         }
   12290            6 :         if (state.dataHeatBal->People(i).AdaptiveCEN15251) {
   12291            1 :             tableBody(3, i) = RealToStr(state.dataHeatBal->People(peopleInd(i)).TimeNotMetCEN15251CatI, 2);
   12292            1 :             tableBody(4, i) = RealToStr(state.dataHeatBal->People(peopleInd(i)).TimeNotMetCEN15251CatII, 2);
   12293            1 :             tableBody(5, i) = RealToStr(state.dataHeatBal->People(peopleInd(i)).TimeNotMetCEN15251CatIII, 2);
   12294              :         }
   12295              :     }
   12296              : 
   12297          574 :     WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
   12298          574 :     if (state.dataSQLiteProcedures->sqlite) {
   12299           56 :         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          574 :     if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
   12307           56 :         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          574 : }
   12316              : 
   12317           38 : std::string formatReportPeriodTimestamp(const int year, const int month, const int day, const int hour)
   12318              : {
   12319           38 :     if (year != 0) {
   12320            0 :         return fmt::format("{}/{}/{} {}:00", year, month, day, hour);
   12321              :     } else {
   12322           38 :         return fmt::format("{}/{} {}:00", month, day, hour);
   12323              :     }
   12324              : }
   12325              : 
   12326            8 : void WriteReportHeaderReportingPeriod(EnergyPlusData &state,
   12327              :                                       const std::string &reportKeyWord,
   12328              :                                       const int periodIdx,
   12329              :                                       const Array1D<Weather::ReportPeriodData> &ReportPeriodInputData)
   12330              : {
   12331            8 :     WriteReportHeaders(
   12332              :         state,
   12333           16 :         fmt::format("{} Resilience Summary for Reporting Period {}: {}", reportKeyWord, periodIdx, ReportPeriodInputData(periodIdx).title),
   12334              :         "Entire Facility",
   12335              :         OutputProcessor::StoreType::Average);
   12336              : 
   12337            8 :     WriteSubtitle(state,
   12338           16 :                   format("Reporting period: {} -- {}, Total Electricity Usage: {:.2R} kWh",
   12339           16 :                          formatReportPeriodTimestamp(ReportPeriodInputData(periodIdx).startYear,
   12340            8 :                                                      ReportPeriodInputData(periodIdx).startMonth,
   12341            8 :                                                      ReportPeriodInputData(periodIdx).startDay,
   12342            8 :                                                      ReportPeriodInputData(periodIdx).startHour),
   12343           16 :                          formatReportPeriodTimestamp(ReportPeriodInputData(periodIdx).endYear,
   12344            8 :                                                      ReportPeriodInputData(periodIdx).endMonth,
   12345            8 :                                                      ReportPeriodInputData(periodIdx).endDay,
   12346            8 :                                                      ReportPeriodInputData(periodIdx).endHour),
   12347            8 :                          ReportPeriodInputData(periodIdx).totalElectricityUse / 3600000.0));
   12348            8 : }
   12349              : 
   12350            4 : 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            4 :     Array1D_string columnHead;
   12355            4 :     Array1D_int columnWidth;
   12356            4 :     Array1D_string rowHead;
   12357            4 :     Array2D_string tableBody;
   12358            4 :     int numRowsReportPeriod = state.dataWeather->TotThermalReportPers + state.dataWeather->TotCO2ReportPers + state.dataWeather->TotVisualReportPers;
   12359            4 :     rowHead.allocate(numRowsReportPeriod);
   12360            4 :     columnHead.allocate(6);
   12361            4 :     columnWidth.allocate(6);
   12362            4 :     columnWidth = 14; // array assignment - same for all columns
   12363            4 :     tableBody.allocate(6, numRowsReportPeriod);
   12364              : 
   12365            4 :     int constexpr reportperiodType(1);
   12366            4 :     int constexpr reportperiodId(2);
   12367            4 :     int constexpr reportperiodTitle(3);
   12368            4 :     int constexpr reportperiodStart(4);
   12369            4 :     int constexpr reportperiodEnd(5);
   12370            4 :     int constexpr reportperiodElectricity(6);
   12371              : 
   12372           12 :     WriteReportHeaders(state, "Reporting Period Summary", "Entire Facility", OutputProcessor::StoreType::Average);
   12373              : 
   12374            4 :     columnHead(reportperiodType) = "Report Type";
   12375            4 :     columnHead(reportperiodId) = "Report Index";
   12376            4 :     columnHead(reportperiodTitle) = "Title";
   12377            4 :     columnHead(reportperiodStart) = "Start Time";
   12378            4 :     columnHead(reportperiodEnd) = "End Time";
   12379            4 :     columnHead(reportperiodElectricity) = "Total Electricity (kWh)";
   12380           15 :     for (int i = 1; i <= numRowsReportPeriod; i++) {
   12381           11 :         rowHead(i) = std::to_string(i);
   12382              :     }
   12383              :     // loop through rows
   12384            4 :     int rowid = 1;
   12385            9 :     for (int periodIdx = 1; periodIdx <= state.dataWeather->TotThermalReportPers; periodIdx++) {
   12386           10 :         writeRowReportPeriodInputVeri("Thermal", tableBody, rowid, periodIdx, state.dataWeather->ThermalReportPeriodInput);
   12387            5 :         rowid += 1;
   12388              :     }
   12389            7 :     for (int periodIdx = 1; periodIdx <= state.dataWeather->TotCO2ReportPers; periodIdx++) {
   12390            6 :         writeRowReportPeriodInputVeri("CO2", tableBody, rowid, periodIdx, state.dataWeather->CO2ReportPeriodInput);
   12391            3 :         rowid += 1;
   12392              :     }
   12393            7 :     for (int periodIdx = 1; periodIdx <= state.dataWeather->TotVisualReportPers; periodIdx++) {
   12394            6 :         writeRowReportPeriodInputVeri("Visual", tableBody, rowid, periodIdx, state.dataWeather->VisualReportPeriodInput);
   12395            3 :         rowid += 1;
   12396              :     }
   12397              : 
   12398            4 :     std::string tableName = "Reporting Period Time and Consumption";
   12399            4 :     WriteSubtitle(state, tableName);
   12400            4 :     WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
   12401            4 :     if (state.dataSQLiteProcedures->sqlite) {
   12402            0 :         state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
   12403              :             tableBody, rowHead, columnHead, "ReportingPeriodSummary", "Entire Facility", tableName);
   12404              :     }
   12405            4 :     if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
   12406            0 :         state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(
   12407              :             tableBody, rowHead, columnHead, "Reporting Period Summary", "Entire Facility", tableName);
   12408              :     }
   12409            4 : }
   12410              : 
   12411            5 : void WriteThermalResilienceTablesRepPeriod(EnergyPlusData &state, int const periodIdx)
   12412              : {
   12413              : 
   12414            5 :     auto const &ort = state.dataOutRptTab;
   12415            5 :     if (!ort->WriteTabularFiles) {
   12416            0 :         return;
   12417              :     }
   12418              : 
   12419              :     Real64 degreeHourConversion;
   12420            5 :     UnitsStyle unitsStyle_cur = ort->unitsStyle;
   12421              : 
   12422            5 :     if (unitsStyle_cur == OutputReportTabular::UnitsStyle::InchPound ||
   12423              :         unitsStyle_cur == OutputReportTabular::UnitsStyle::InchPoundExceptElectricity) {
   12424            0 :         degreeHourConversion = getSpecificUnitMultiplier(state, "°C·hr", "°F·hr");
   12425              :     } else {
   12426            5 :         degreeHourConversion = 1.0;
   12427              :     }
   12428              : 
   12429            5 :     std::string tableType = "Thermal";
   12430            5 :     WriteReportHeaderReportingPeriod(state, tableType, periodIdx, state.dataWeather->ThermalReportPeriodInput);
   12431            5 :     std::string periodTitle = state.dataWeather->ThermalReportPeriodInput(periodIdx).title;
   12432              : 
   12433            5 :     int columnNum = 5;
   12434            5 :     Array1D_int columnWidth;
   12435            5 :     columnWidth.allocate(columnNum);
   12436            5 :     columnWidth = 10;
   12437            5 :     Array1D_string columnHead(5);
   12438            5 :     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            5 :         columnHead(1) = "Safe (≤ 26.7°C) [hr]";
   12447            5 :         columnHead(2) = "Caution (> 26.7°C, ≤ 32.2°C) [hr]";
   12448            5 :         columnHead(3) = "Extreme Caution (> 32.2°C, ≤ 39.4°C) [hr]";
   12449            5 :         columnHead(4) = "Danger (> 39.4°C, ≤ 51.7°C) [hr]";
   12450            5 :         columnHead(5) = "Extreme Danger (> 51.7°C) [hr]";
   12451              :     }
   12452              : 
   12453            5 :     Array1D_string rowHead;
   12454            5 :     Array2D_string tableBody;
   12455            5 :     rowHead.allocate(state.dataGlobal->NumOfZones + 4);
   12456            5 :     tableBody.allocate(columnNum, state.dataGlobal->NumOfZones + 4);
   12457              : 
   12458            5 :     std::string tableName = "Heat Index Hours";
   12459            5 :     WriteResilienceBinsTableReportingPeriod(state,
   12460              :                                             tableType,
   12461              :                                             columnNum,
   12462              :                                             periodIdx,
   12463              :                                             periodTitle,
   12464              :                                             tableName,
   12465              :                                             columnHead,
   12466              :                                             columnWidth,
   12467            5 :                                             state.dataHeatBalFanSys->ZoneHeatIndexHourBinsRepPeriod,
   12468              :                                             rowHead,
   12469              :                                             tableBody);
   12470              : 
   12471            5 :     tableName = "Heat Index OccupantHours";
   12472            5 :     WriteResilienceBinsTableReportingPeriod(state,
   12473              :                                             tableType,
   12474              :                                             columnNum,
   12475              :                                             periodIdx,
   12476              :                                             periodTitle,
   12477              :                                             tableName,
   12478              :                                             columnHead,
   12479              :                                             columnWidth,
   12480            5 :                                             state.dataHeatBalFanSys->ZoneHeatIndexOccuHourBinsRepPeriod,
   12481              :                                             rowHead,
   12482              :                                             tableBody);
   12483              : 
   12484            5 :     tableName = "Heat Index OccupiedHours";
   12485            5 :     WriteResilienceBinsTableReportingPeriod(state,
   12486              :                                             tableType,
   12487              :                                             columnNum,
   12488              :                                             periodIdx,
   12489              :                                             periodTitle,
   12490              :                                             tableName,
   12491              :                                             columnHead,
   12492              :                                             columnWidth,
   12493            5 :                                             state.dataHeatBalFanSys->ZoneHeatIndexOccupiedHourBinsRepPeriod,
   12494              :                                             rowHead,
   12495              :                                             tableBody);
   12496              : 
   12497            5 :     columnHead(1) = "Little to no Discomfort (≤ 29) [hr]";
   12498            5 :     columnHead(2) = "Some Discomfort (> 29, ≤ 40) [hr]";
   12499            5 :     columnHead(3) = "Great Discomfort; Avoid Exertion (> 40, ≤ 45) [hr]";
   12500            5 :     columnHead(4) = "Dangerous (> 45, ≤ 50) [hr]";
   12501            5 :     columnHead(5) = "Heat Stroke Quite Possible (> 50) [hr]";
   12502            5 :     tableName = "Humidex Hours";
   12503            5 :     WriteResilienceBinsTableReportingPeriod(state,
   12504              :                                             tableType,
   12505              :                                             columnNum,
   12506              :                                             periodIdx,
   12507              :                                             periodTitle,
   12508              :                                             tableName,
   12509              :                                             columnHead,
   12510              :                                             columnWidth,
   12511            5 :                                             state.dataHeatBalFanSys->ZoneHumidexHourBinsRepPeriod,
   12512              :                                             rowHead,
   12513              :                                             tableBody);
   12514              : 
   12515            5 :     tableName = "Humidex OccupantHours";
   12516            5 :     WriteResilienceBinsTableReportingPeriod(state,
   12517              :                                             tableType,
   12518              :                                             columnNum,
   12519              :                                             periodIdx,
   12520              :                                             periodTitle,
   12521              :                                             tableName,
   12522              :                                             columnHead,
   12523              :                                             columnWidth,
   12524            5 :                                             state.dataHeatBalFanSys->ZoneHumidexOccuHourBinsRepPeriod,
   12525              :                                             rowHead,
   12526              :                                             tableBody);
   12527              : 
   12528            5 :     tableName = "Humidex OccupiedHours";
   12529            5 :     WriteResilienceBinsTableReportingPeriod(state,
   12530              :                                             tableType,
   12531              :                                             columnNum,
   12532              :                                             periodIdx,
   12533              :                                             periodTitle,
   12534              :                                             tableName,
   12535              :                                             columnHead,
   12536              :                                             columnWidth,
   12537            5 :                                             state.dataHeatBalFanSys->ZoneHumidexOccupiedHourBinsRepPeriod,
   12538              :                                             rowHead,
   12539              :                                             tableBody);
   12540              : 
   12541            5 :     bool hasPierceSET = true;
   12542            5 :     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           13 :     for (int iPeople = 1; iPeople <= state.dataHeatBal->TotPeople; ++iPeople) {
   12552            8 :         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            5 :     if (hasPierceSET) {
   12564            5 :         columnHead(1) = "SET ≤ 12.2°C Degree-Hours [°C·hr]";
   12565            5 :         columnHead(2) = "SET ≤ 12.2°C Occupant-Weighted Degree-Hours [°C·hr]";
   12566            5 :         columnHead(3) = "SET ≤ 12.2°C Occupied Degree-Hours [°C·hr]";
   12567            5 :         columnHead(4) = "Longest SET ≤ 12.2°C Duration for Occupied Period [hr]";
   12568            5 :         columnHead(5) = "Start Time of the Longest SET ≤ 12.2°C Duration for Occupied Period ";
   12569              : 
   12570            5 :         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            5 :             columnHead(1) = "SET ≤ 12.2°C Degree-Hours [°C·hr]";
   12579            5 :             columnHead(2) = "SET ≤ 12.2°C Occupant-Weighted Degree-Hours [°C·hr]";
   12580            5 :             columnHead(3) = "SET ≤ 12.2°C Occupied Degree-Hours [°C·hr]";
   12581            5 :             columnHead(4) = "Longest SET ≤ 12.2°C Duration for Occupied Period [hr]";
   12582            5 :             columnHead(5) = "Start Time of the Longest SET ≤ 12.2°C Duration for Occupied Period ";
   12583              :         }
   12584              : 
   12585            5 :         tableName = "Heating SET Degree-Hours";
   12586            5 :         Array1D_string rowHeadSET;
   12587            5 :         Array2D_string tableBodySET;
   12588            5 :         rowHeadSET.allocate(state.dataGlobal->NumOfZones + 3);
   12589            5 :         tableBodySET.allocate(columnNum, state.dataGlobal->NumOfZones + 3);
   12590            5 :         WriteSETHoursTableReportingPeriod(state,
   12591              :                                           columnNum,
   12592              :                                           periodIdx,
   12593              :                                           periodTitle,
   12594              :                                           tableName,
   12595              :                                           columnHead,
   12596              :                                           columnWidth,
   12597            5 :                                           state.dataHeatBalFanSys->ZoneLowSETHoursRepPeriod,
   12598              :                                           rowHeadSET,
   12599              :                                           tableBodySET,
   12600              :                                           degreeHourConversion);
   12601              : 
   12602            5 :         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            5 :             columnHead(1) = "SET > 30°C Degree-Hours [°C·hr]";
   12611            5 :             columnHead(2) = "SET > 30°C Occupant-Weighted Degree-Hours [°C·hr]";
   12612            5 :             columnHead(3) = "SET > 30°C Occupied Degree-Hours [°C·hr]";
   12613            5 :             columnHead(4) = "Longest SET > 30°C Duration for Occupied Period [hr]";
   12614            5 :             columnHead(5) = "Start Time of the Longest SET > 30°C Duration for Occupied Period";
   12615              :         }
   12616              : 
   12617            5 :         tableName = "Cooling SET Degree-Hours";
   12618            5 :         WriteSETHoursTableReportingPeriod(state,
   12619              :                                           columnNum,
   12620              :                                           periodIdx,
   12621              :                                           periodTitle,
   12622              :                                           tableName,
   12623              :                                           columnHead,
   12624              :                                           columnWidth,
   12625            5 :                                           state.dataHeatBalFanSys->ZoneHighSETHoursRepPeriod,
   12626              :                                           rowHeadSET,
   12627              :                                           tableBodySET,
   12628              :                                           degreeHourConversion);
   12629            5 :     }
   12630              : 
   12631            5 :     columnHead(1) = "Hours of Safety [hr]";
   12632            5 :     columnHead(2) = "End Time of the Safety Duration";
   12633            5 :     columnHead(3) = "Safe Temperature Exceedance Hours [hr]";
   12634            5 :     columnHead(4) = "Safe Temperature Exceedance OccupantHours [hr]";
   12635            5 :     columnHead(5) = "Safe Temperature Exceedance OccupiedHours [hr]";
   12636            5 :     tableName = "Hours of Safety for Cold Events";
   12637            5 :     WriteHourOfSafetyTableReportingPeriod(state,
   12638              :                                           columnNum,
   12639              :                                           periodIdx,
   12640              :                                           periodTitle,
   12641              :                                           tableName,
   12642              :                                           columnHead,
   12643              :                                           columnWidth,
   12644            5 :                                           state.dataHeatBalFanSys->ZoneColdHourOfSafetyBinsRepPeriod,
   12645              :                                           rowHead,
   12646              :                                           tableBody,
   12647              :                                           2);
   12648              : 
   12649            5 :     tableName = "Hours of Safety for Heat Events";
   12650            5 :     WriteHourOfSafetyTableReportingPeriod(state,
   12651              :                                           columnNum,
   12652              :                                           periodIdx,
   12653              :                                           periodTitle,
   12654              :                                           tableName,
   12655              :                                           columnHead,
   12656              :                                           columnWidth,
   12657            5 :                                           state.dataHeatBalFanSys->ZoneHeatHourOfSafetyBinsRepPeriod,
   12658              :                                           rowHead,
   12659              :                                           tableBody,
   12660              :                                           2);
   12661              : 
   12662            5 :     int columnNumUnmetDegHr = 6;
   12663            5 :     Array1D_string columnHeadUnmetDegHr(6);
   12664              :     // must initialize this otherwise it will only output 5 columns
   12665            5 :     Array1D_int columnWidthUnmetDegHr;
   12666            5 :     columnWidthUnmetDegHr.allocate(columnNumUnmetDegHr);
   12667            5 :     columnWidthUnmetDegHr = 10;
   12668            5 :     columnHeadUnmetDegHr(1) = "Cooling Setpoint Unmet Degree-Hours [°C·hr]";
   12669            5 :     columnHeadUnmetDegHr(2) = "Cooling Setpoint Unmet Occupant-Weighted Degree-Hours [°C·hr]";
   12670            5 :     columnHeadUnmetDegHr(3) = "Cooling Setpoint Unmet Occupied Degree-Hours [°C·hr]";
   12671            5 :     columnHeadUnmetDegHr(4) = "Heating Setpoint Unmet Degree-Hours [°C·hr]";
   12672            5 :     columnHeadUnmetDegHr(5) = "Heating Setpoint Unmet Occupant-Weighted Degree-Hours [°C·hr]";
   12673            5 :     columnHeadUnmetDegHr(6) = "Heating Setpoint Unmet Occupied Degree-Hours [°C·hr]";
   12674            5 :     tableName = "Unmet Degree-Hours";
   12675              : 
   12676            5 :     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            5 :     Array2D_string tableBodyUnmetDegHr;
   12687            5 :     tableBodyUnmetDegHr.allocate(columnNumUnmetDegHr, state.dataGlobal->NumOfZones + 4);
   12688            5 :     WriteResilienceBinsTableReportingPeriod(state,
   12689              :                                             tableType,
   12690              :                                             columnNumUnmetDegHr,
   12691              :                                             periodIdx,
   12692              :                                             periodTitle,
   12693              :                                             tableName,
   12694              :                                             columnHeadUnmetDegHr,
   12695              :                                             columnWidthUnmetDegHr,
   12696            5 :                                             state.dataHeatBalFanSys->ZoneUnmetDegreeHourBinsRepPeriod,
   12697              :                                             rowHead,
   12698              :                                             tableBodyUnmetDegHr,
   12699              :                                             degreeHourConversion);
   12700              : 
   12701            5 :     int columnNumDiscomfortWt = 4;
   12702            5 :     Array1D_string columnHeadDiscomfortWt(columnNumDiscomfortWt);
   12703            5 :     columnHeadDiscomfortWt(1) = "Very-cold Exceedance OccupiedHours [hr]";
   12704            5 :     columnHeadDiscomfortWt(2) = "Cool Exceedance OccupiedHours [hr]";
   12705            5 :     columnHeadDiscomfortWt(3) = "Warm Exceedance OccupiedHours [hr]";
   12706            5 :     columnHeadDiscomfortWt(4) = "Very-hot Exceedance OccupiedHours [hr]";
   12707            5 :     tableName = "Discomfort-weighted Exceedance OccupantHours";
   12708            5 :     Array1D_int columnWidthDiscomfortWt;
   12709            5 :     columnWidthDiscomfortWt.allocate(columnNumDiscomfortWt);
   12710            5 :     columnWidth = 10;
   12711            5 :     Array2D_string tableBodyDiscomfortWt;
   12712            5 :     tableBodyDiscomfortWt.allocate(columnNumDiscomfortWt, state.dataGlobal->NumOfZones + 4);
   12713            5 :     WriteResilienceBinsTableReportingPeriod(state,
   12714              :                                             tableType,
   12715              :                                             columnNumDiscomfortWt,
   12716              :                                             periodIdx,
   12717              :                                             periodTitle,
   12718              :                                             tableName,
   12719              :                                             columnHeadDiscomfortWt,
   12720              :                                             columnWidthDiscomfortWt,
   12721            5 :                                             state.dataHeatBalFanSys->ZoneDiscomfortWtExceedOccuHourBinsRepPeriod,
   12722              :                                             rowHead,
   12723              :                                             tableBodyDiscomfortWt);
   12724            5 :     tableName = "Discomfort-weighted Exceedance OccupiedHours";
   12725            5 :     WriteResilienceBinsTableReportingPeriod(state,
   12726              :                                             tableType,
   12727              :                                             columnNumDiscomfortWt,
   12728              :                                             periodIdx,
   12729              :                                             periodTitle,
   12730              :                                             tableName,
   12731              :                                             columnHeadDiscomfortWt,
   12732              :                                             columnWidthDiscomfortWt,
   12733            5 :                                             state.dataHeatBalFanSys->ZoneDiscomfortWtExceedOccupiedHourBinsRepPeriod,
   12734              :                                             rowHead,
   12735              :                                             tableBodyDiscomfortWt);
   12736            5 :     columnHead.deallocate();
   12737            5 :     columnWidth.deallocate();
   12738            5 :     tableBody.deallocate();
   12739            5 :     columnHeadUnmetDegHr.deallocate();
   12740            5 :     columnWidthUnmetDegHr.deallocate();
   12741            5 :     tableBodyUnmetDegHr.deallocate();
   12742            5 :     columnHeadDiscomfortWt.deallocate();
   12743            5 :     columnWidthDiscomfortWt.deallocate();
   12744            5 :     tableBodyDiscomfortWt.deallocate();
   12745            5 : }
   12746              : 
   12747              : template <int columnNum>
   12748          213 : 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          213 :     std::array<Real64, columnNum> columnMax = {0.0};
   12754          213 :     std::array<Real64, columnNum> columnMin = {0.0};
   12755          213 :     std::array<Real64, columnNum> columnSum = {0.0};
   12756         1020 :     for (int j = 0; j < columnNum; j++) {
   12757          807 :         columnMin[j] = (state.dataHeatBal->Resilience(1).*memberPtr)[j] * unitConvMultiplier;
   12758              :     }
   12759         2658 :     for (int i = 1; i <= state.dataGlobal->NumOfZones; ++i) {
   12760         2445 :         const std::string &ZoneName = state.dataHeatBal->Zone(i).Name;
   12761        12054 :         for (int j = 0; j < columnNum; j++) {
   12762         9609 :             Real64 curValue = (state.dataHeatBal->Resilience(i).*memberPtr)[j] * unitConvMultiplier;
   12763         9609 :             if (curValue > columnMax[j]) {
   12764            0 :                 columnMax[j] = curValue;
   12765              :             }
   12766         9609 :             if (curValue < columnMin[j]) {
   12767            0 :                 columnMin[j] = curValue;
   12768              :             }
   12769         9609 :             columnSum[j] += curValue;
   12770         9609 :             PreDefTableEntry(state, columnHead[j], ZoneName, RealToStr(curValue, 2));
   12771              :         }
   12772              :     }
   12773         1020 :     for (int j = 0; j < columnNum; j++) {
   12774          807 :         PreDefTableEntry(state, columnHead[j], "Min", RealToStr(columnMin[j], 2));
   12775          807 :         PreDefTableEntry(state, columnHead[j], "Max", RealToStr(columnMax[j], 2));
   12776          807 :         PreDefTableEntry(state, columnHead[j], "Average", RealToStr(columnSum[j] / state.dataGlobal->NumOfZones, 2));
   12777          807 :         PreDefTableEntry(state, columnHead[j], "Sum", RealToStr(columnSum[j], 2));
   12778              :     }
   12779          213 : }
   12780              : 
   12781              : template <int columnNum>
   12782         5877 : 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         5877 :     WriteSubtitle(state, tableName);
   12792              : 
   12793         5877 :     std::array<Real64, columnNum> columnMax = {0.0};
   12794         5877 :     std::array<Real64, columnNum> columnMin = {0.0};
   12795         5877 :     std::array<Real64, columnNum> columnSum = {0.0};
   12796              : 
   12797        34609 :     for (int j = 0; j < columnNum; j++) {
   12798        28732 :         columnMin.at(j) = (state.dataHeatBal->Resilience(1).*memberPtr).at(j) * unitConvMultiplier;
   12799              :     }
   12800        39042 :     for (int ZoneNum = 1; ZoneNum <= state.dataGlobal->NumOfZones; ZoneNum++) {
   12801        33165 :         std::string const &ZoneName = state.dataHeatBal->Zone(ZoneNum).Name;
   12802        33165 :         rowHead(ZoneNum) = ZoneName;
   12803       195305 :         for (int j = 0; j < columnNum; j++) {
   12804       162140 :             Real64 curValue = (state.dataHeatBal->Resilience(ZoneNum).*memberPtr).at(j) * unitConvMultiplier;
   12805       162140 :             if (curValue > columnMax.at(j)) {
   12806          246 :                 columnMax.at(j) = curValue;
   12807              :             }
   12808       162140 :             if (curValue < columnMin.at(j)) {
   12809          143 :                 columnMin.at(j) = curValue;
   12810              :             }
   12811       162140 :             columnSum.at(j) += curValue;
   12812       162140 :             tableBody(j + 1, ZoneNum) = RealToStr(curValue, 2);
   12813              :         }
   12814              :     }
   12815              : 
   12816         5877 :     rowHead(state.dataGlobal->NumOfZones + 1) = "Min";
   12817         5877 :     rowHead(state.dataGlobal->NumOfZones + 2) = "Max";
   12818         5877 :     rowHead(state.dataGlobal->NumOfZones + 3) = "Average";
   12819         5877 :     rowHead(state.dataGlobal->NumOfZones + 4) = "Sum";
   12820              : 
   12821        34609 :     for (int j = 0; j < columnNum; j++) {
   12822        28732 :         tableBody(j + 1, state.dataGlobal->NumOfZones + 1) = RealToStr(columnMin.at(j), 2);
   12823        28732 :         tableBody(j + 1, state.dataGlobal->NumOfZones + 2) = RealToStr(columnMax.at(j), 2);
   12824        28732 :         tableBody(j + 1, state.dataGlobal->NumOfZones + 3) = RealToStr(columnSum.at(j) / state.dataGlobal->NumOfZones, 2);
   12825        28732 :         tableBody(j + 1, state.dataGlobal->NumOfZones + 4) = RealToStr(columnSum.at(j), 2);
   12826              :     }
   12827              : 
   12828         5877 :     WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
   12829         5877 :     if (state.dataSQLiteProcedures->sqlite) {
   12830          585 :         state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
   12831              :             tableBody, rowHead, columnHead, "AnnualThermalResilienceSummary", "Entire Facility", tableName);
   12832              :     }
   12833         5877 :     if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
   12834          360 :         state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(
   12835              :             tableBody, rowHead, columnHead, "AnnualThermalResilienceSummary", "Entire Facility", tableName);
   12836              :     }
   12837         5877 : }
   12838              : 
   12839           54 : 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           54 :     WriteSubtitle(state, tableName);
   12853              : 
   12854           54 :     std::vector<Real64> columnMax(columnNum, 0);
   12855           54 :     std::vector<Real64> columnMin(columnNum, 0);
   12856           54 :     std::vector<Real64> columnSum(columnNum, 0);
   12857              : 
   12858          310 :     for (int j = 0; j < columnNum; j++) {
   12859          256 :         columnMin.at(j) = ZoneBins(1, periodIdx).at(j) * unitConvMultiplier;
   12860              :     }
   12861          108 :     for (int ZoneNum = 1; ZoneNum <= state.dataGlobal->NumOfZones; ZoneNum++) {
   12862           54 :         std::string const &ZoneName = state.dataHeatBal->Zone(ZoneNum).Name;
   12863           54 :         rowHead(ZoneNum) = ZoneName;
   12864          310 :         for (int j = 0; j < columnNum; j++) {
   12865          256 :             Real64 curValue = ZoneBins(ZoneNum, periodIdx).at(j) * unitConvMultiplier;
   12866          256 :             if (curValue > columnMax.at(j)) {
   12867            0 :                 columnMax.at(j) = curValue;
   12868              :             }
   12869          256 :             if (curValue < columnMin.at(j)) {
   12870            0 :                 columnMin.at(j) = curValue;
   12871              :             }
   12872          256 :             columnSum.at(j) += curValue;
   12873          256 :             tableBody(j + 1, ZoneNum) = RealToStr(curValue, 2);
   12874              :         }
   12875              :     }
   12876              : 
   12877           54 :     rowHead(state.dataGlobal->NumOfZones + 1) = "Min";
   12878           54 :     rowHead(state.dataGlobal->NumOfZones + 2) = "Max";
   12879           54 :     rowHead(state.dataGlobal->NumOfZones + 3) = "Average";
   12880           54 :     rowHead(state.dataGlobal->NumOfZones + 4) = "Sum";
   12881              : 
   12882          310 :     for (int j = 0; j < columnNum; j++) {
   12883          256 :         tableBody(j + 1, state.dataGlobal->NumOfZones + 1) = RealToStr(columnMin.at(j), 2);
   12884          256 :         tableBody(j + 1, state.dataGlobal->NumOfZones + 2) = RealToStr(columnMax.at(j), 2);
   12885          256 :         tableBody(j + 1, state.dataGlobal->NumOfZones + 3) = RealToStr(columnSum.at(j) / state.dataGlobal->NumOfZones, 2);
   12886          256 :         tableBody(j + 1, state.dataGlobal->NumOfZones + 4) = RealToStr(columnSum.at(j), 2);
   12887              :     }
   12888              : 
   12889           54 :     WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
   12890           54 :     if (state.dataSQLiteProcedures->sqlite) {
   12891            0 :         state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
   12892            0 :             tableBody, rowHead, columnHead, "ReportingPeriod-" + periodTitle + "-" + tableType + "ResilienceSummary", "Entire Facility", tableName);
   12893              :     }
   12894           54 :     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           54 : }
   12899              : 
   12900           12 : 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           12 :     WriteSubtitle(state, tableName);
   12912              : 
   12913           12 :     std::vector<Real64> columnMax(columnNum - 1, 0);
   12914           12 :     std::vector<Real64> columnMin(columnNum - 1, 0);
   12915           12 :     std::vector<Real64> columnSum(columnNum - 1, 0);
   12916           12 :     std::vector<Real64> multiplier(columnNum - 1, unitConvMultiplier);
   12917           12 :     multiplier[columnNum - 2] = 1.0;
   12918              : 
   12919           60 :     for (int j = 0; j < columnNum - 1; j++) {
   12920           48 :         columnMin.at(j) = (state.dataHeatBal->Resilience(1).*memberPtr).at(j) * multiplier.at(j);
   12921              :     }
   12922           24 :     for (int ZoneNum = 1; ZoneNum <= state.dataGlobal->NumOfZones; ZoneNum++) {
   12923           12 :         std::string const &ZoneName = state.dataHeatBal->Zone(ZoneNum).Name;
   12924           12 :         rowHead(ZoneNum) = ZoneName;
   12925           60 :         for (int j = 0; j < columnNum - 1; j++) {
   12926           48 :             Real64 curValue = (state.dataHeatBal->Resilience(ZoneNum).*memberPtr).at(j) * multiplier.at(j);
   12927           48 :             if (curValue > columnMax.at(j)) {
   12928            0 :                 columnMax.at(j) = curValue;
   12929              :             }
   12930           48 :             if (curValue < columnMin.at(j)) {
   12931            0 :                 columnMin.at(j) = curValue;
   12932              :             }
   12933           48 :             columnSum.at(j) += curValue;
   12934           48 :             tableBody(j + 1, ZoneNum) = RealToStr(curValue, 2);
   12935              :         }
   12936           12 :         tableBody(columnNum, ZoneNum) = DateToString((state.dataHeatBal->Resilience(ZoneNum).*memberPtr).at(columnNum - 1));
   12937              :     }
   12938              : 
   12939           12 :     rowHead(state.dataGlobal->NumOfZones + 1) = "Min";
   12940           12 :     rowHead(state.dataGlobal->NumOfZones + 2) = "Max";
   12941           12 :     rowHead(state.dataGlobal->NumOfZones + 3) = "Average";
   12942              : 
   12943           60 :     for (int j = 0; j < columnNum - 1; j++) {
   12944           48 :         tableBody(j + 1, state.dataGlobal->NumOfZones + 1) = RealToStr(columnMin.at(j), 2);
   12945           48 :         tableBody(j + 1, state.dataGlobal->NumOfZones + 2) = RealToStr(columnMax.at(j), 2);
   12946           48 :         tableBody(j + 1, state.dataGlobal->NumOfZones + 3) = RealToStr(columnSum.at(j) / state.dataGlobal->NumOfZones, 2);
   12947              :     }
   12948           12 :     tableBody(columnNum, state.dataGlobal->NumOfZones + 1) = "-";
   12949           12 :     tableBody(columnNum, state.dataGlobal->NumOfZones + 2) = "-";
   12950           12 :     tableBody(columnNum, state.dataGlobal->NumOfZones + 3) = "-";
   12951              : 
   12952           12 :     WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
   12953           12 :     if (state.dataSQLiteProcedures->sqlite) {
   12954            0 :         state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
   12955              :             tableBody, rowHead, columnHead, "AnnualThermalResilienceSummary", "Entire Facility", tableName);
   12956              :     }
   12957           12 :     if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
   12958            0 :         state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(
   12959              :             tableBody, rowHead, columnHead, "AnnualThermalResilienceSummary", "Entire Facility", tableName);
   12960              :     }
   12961           12 : }
   12962              : 
   12963           10 : 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           10 :     WriteSubtitle(state, tableName);
   12977              : 
   12978           10 :     std::vector<Real64> columnMax(columnNum - 1, 0);
   12979           10 :     std::vector<Real64> columnMin(columnNum - 1, 0);
   12980           10 :     std::vector<Real64> columnSum(columnNum - 1, 0);
   12981           10 :     std::vector<Real64> multiplier(columnNum - 1, unitConvMultiplier);
   12982           10 :     multiplier[columnNum - 2] = 1.0;
   12983              : 
   12984           50 :     for (int j = 0; j < columnNum - 1; j++) {
   12985           40 :         columnMin.at(j) = ZoneBins(1, periodIdx).at(j) * multiplier.at(j);
   12986              :     }
   12987           20 :     for (int ZoneNum = 1; ZoneNum <= state.dataGlobal->NumOfZones; ZoneNum++) {
   12988           10 :         std::string const &ZoneName = state.dataHeatBal->Zone(ZoneNum).Name;
   12989           10 :         rowHead(ZoneNum) = ZoneName;
   12990           50 :         for (int j = 0; j < columnNum - 1; j++) {
   12991           40 :             Real64 curValue = ZoneBins(ZoneNum, periodIdx).at(j) * multiplier.at(j);
   12992           40 :             if (curValue > columnMax.at(j)) {
   12993            0 :                 columnMax.at(j) = curValue;
   12994              :             }
   12995           40 :             if (curValue < columnMin.at(j)) {
   12996            0 :                 columnMin.at(j) = curValue;
   12997              :             }
   12998           40 :             columnSum.at(j) += curValue;
   12999           40 :             tableBody(j + 1, ZoneNum) = RealToStr(curValue, 2);
   13000              :         }
   13001           10 :         tableBody(columnNum, ZoneNum) = DateToString(ZoneBins(ZoneNum, periodIdx)[columnNum - 1]);
   13002              :     }
   13003              : 
   13004           10 :     rowHead(state.dataGlobal->NumOfZones + 1) = "Min";
   13005           10 :     rowHead(state.dataGlobal->NumOfZones + 2) = "Max";
   13006           10 :     rowHead(state.dataGlobal->NumOfZones + 3) = "Average";
   13007              : 
   13008           50 :     for (int j = 0; j < columnNum - 1; j++) {
   13009           40 :         tableBody(j + 1, state.dataGlobal->NumOfZones + 1) = RealToStr(columnMin.at(j), 2);
   13010           40 :         tableBody(j + 1, state.dataGlobal->NumOfZones + 2) = RealToStr(columnMax.at(j), 2);
   13011           40 :         tableBody(j + 1, state.dataGlobal->NumOfZones + 3) = RealToStr(columnSum.at(j) / state.dataGlobal->NumOfZones, 2);
   13012              :     }
   13013           10 :     tableBody(columnNum, state.dataGlobal->NumOfZones + 1) = "-";
   13014           10 :     tableBody(columnNum, state.dataGlobal->NumOfZones + 2) = "-";
   13015           10 :     tableBody(columnNum, state.dataGlobal->NumOfZones + 3) = "-";
   13016              : 
   13017           10 :     WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
   13018           10 :     if (state.dataSQLiteProcedures->sqlite) {
   13019            0 :         state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
   13020            0 :             tableBody, rowHead, columnHead, "ReportingPeriod-" + periodTitle + "-ThermalResilienceSummary", "Entire Facility", tableName);
   13021              :     }
   13022           10 :     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           10 : }
   13027              : 
   13028            0 : std::string RetrieveEntryFromTableBody(Array2D_string const &tableBody, int const rowIndex, int const columnIndex)
   13029              : {
   13030            0 :     return trimmed(ljustified(tableBody(columnIndex, rowIndex)));
   13031              : }
   13032              : 
   13033         1306 : 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         1306 :     WriteSubtitle(state, tableName);
   13045         8676 :     for (int ZoneNum = 1; ZoneNum <= state.dataGlobal->NumOfZones; ++ZoneNum) {
   13046         7370 :         rowHead(ZoneNum) = state.dataHeatBal->Zone(ZoneNum).Name;
   13047        44220 :         for (int j = 1; j <= columnNum; j++) {
   13048        36850 :             tableBody(j, ZoneNum) = RealToStr((state.dataHeatBal->Resilience(ZoneNum).*memberPtr).at(j - 1), 2);
   13049              :         }
   13050         7370 :         tableBody(dateColIdx, ZoneNum) = DateToString((state.dataHeatBal->Resilience(ZoneNum).*memberPtr).at(dateColIdx - 1));
   13051              :     }
   13052              : 
   13053         1306 :     std::vector<Real64> columnMax(columnNum, 0);
   13054         1306 :     std::vector<Real64> columnMin(columnNum, 0);
   13055         1306 :     std::vector<Real64> columnSum(columnNum, 0);
   13056              : 
   13057         7836 :     for (int j = 0; j < columnNum; j++) {
   13058         6530 :         columnMin.at(j) = (state.dataHeatBal->Resilience(1).*memberPtr).at(j);
   13059              :     }
   13060         8676 :     for (int ZoneNum = 1; ZoneNum <= state.dataGlobal->NumOfZones; ++ZoneNum) {
   13061        44220 :         for (int j = 0; j < columnNum; j++) {
   13062        36850 :             Real64 curValue = (state.dataHeatBal->Resilience(ZoneNum).*memberPtr).at(j);
   13063        36850 :             if (curValue > columnMax.at(j)) {
   13064           56 :                 columnMax.at(j) = curValue;
   13065              :             }
   13066        36850 :             if (curValue < columnMin.at(j)) {
   13067           18 :                 columnMin.at(j) = curValue;
   13068              :             }
   13069        36850 :             columnSum.at(j) += curValue;
   13070              :         }
   13071              :     }
   13072              : 
   13073         1306 :     rowHead(state.dataGlobal->NumOfZones + 1) = "Min";
   13074         1306 :     rowHead(state.dataGlobal->NumOfZones + 2) = "Max";
   13075         1306 :     rowHead(state.dataGlobal->NumOfZones + 3) = "Average";
   13076         1306 :     rowHead(state.dataGlobal->NumOfZones + 4) = "Sum";
   13077              : 
   13078         7836 :     for (int j = 0; j < columnNum; j++) {
   13079         6530 :         tableBody(j + 1, state.dataGlobal->NumOfZones + 1) = RealToStr(columnMin.at(j), 2);
   13080         6530 :         tableBody(j + 1, state.dataGlobal->NumOfZones + 2) = RealToStr(columnMax.at(j), 2);
   13081         6530 :         tableBody(j + 1, state.dataGlobal->NumOfZones + 3) = RealToStr(columnSum.at(j) / state.dataGlobal->NumOfZones, 2);
   13082         6530 :         tableBody(j + 1, state.dataGlobal->NumOfZones + 4) = RealToStr(columnSum.at(j), 2);
   13083              :     }
   13084              : 
   13085         6530 :     for (int i = 1; i < 5; i++) {
   13086         5224 :         tableBody(dateColIdx, state.dataGlobal->NumOfZones + i) = "-";
   13087              :     }
   13088              : 
   13089         1306 :     WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
   13090         1306 :     if (state.dataSQLiteProcedures->sqlite) {
   13091          130 :         state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
   13092              :             tableBody, rowHead, columnHead, "AnnualThermalResilienceSummary", "Entire Facility", tableName);
   13093              :     }
   13094         1306 :     if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
   13095           80 :         state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(
   13096              :             tableBody, rowHead, columnHead, "AnnualThermalResilienceSummary", "Entire Facility", tableName);
   13097              :     }
   13098         1306 : }
   13099              : 
   13100           10 : 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           10 :     WriteSubtitle(state, tableName);
   13114           20 :     for (int ZoneNum = 1; ZoneNum <= state.dataGlobal->NumOfZones; ++ZoneNum) {
   13115           10 :         rowHead(ZoneNum) = state.dataHeatBal->Zone(ZoneNum).Name;
   13116           60 :         for (int j = 1; j <= columnNum; j++) {
   13117           50 :             tableBody(j, ZoneNum) = RealToStr(ZoneBins(ZoneNum, periodIdx).at(j - 1), 2);
   13118              :         }
   13119           10 :         tableBody(dateColIdx, ZoneNum) = DateToString(ZoneBins(ZoneNum, periodIdx).at(dateColIdx - 1));
   13120              :     }
   13121              : 
   13122           10 :     std::vector<Real64> columnMax(columnNum, 0);
   13123           10 :     std::vector<Real64> columnMin(columnNum, 0);
   13124           10 :     std::vector<Real64> columnSum(columnNum, 0);
   13125              : 
   13126           60 :     for (int j = 0; j < columnNum; j++) {
   13127           50 :         columnMin.at(j) = ZoneBins(1, periodIdx).at(j);
   13128              :     }
   13129           20 :     for (int i = 1; i <= state.dataGlobal->NumOfZones; ++i) {
   13130           60 :         for (int j = 0; j < columnNum; j++) {
   13131           50 :             Real64 curValue = ZoneBins(i, periodIdx).at(j);
   13132           50 :             if (curValue > columnMax.at(j)) {
   13133            0 :                 columnMax.at(j) = curValue;
   13134              :             }
   13135           50 :             if (curValue < columnMin.at(j)) {
   13136            0 :                 columnMin.at(j) = curValue;
   13137              :             }
   13138           50 :             columnSum.at(j) += curValue;
   13139              :         }
   13140              :     }
   13141              : 
   13142           10 :     rowHead(state.dataGlobal->NumOfZones + 1) = "Min";
   13143           10 :     rowHead(state.dataGlobal->NumOfZones + 2) = "Max";
   13144           10 :     rowHead(state.dataGlobal->NumOfZones + 3) = "Average";
   13145           10 :     rowHead(state.dataGlobal->NumOfZones + 4) = "Sum";
   13146              : 
   13147           60 :     for (int j = 0; j < columnNum; j++) {
   13148           50 :         tableBody(j + 1, state.dataGlobal->NumOfZones + 1) = RealToStr(columnMin.at(j), 2);
   13149           50 :         tableBody(j + 1, state.dataGlobal->NumOfZones + 2) = RealToStr(columnMax.at(j), 2);
   13150           50 :         tableBody(j + 1, state.dataGlobal->NumOfZones + 3) = RealToStr(columnSum.at(j) / state.dataGlobal->NumOfZones, 2);
   13151           50 :         tableBody(j + 1, state.dataGlobal->NumOfZones + 4) = RealToStr(columnSum.at(j), 2);
   13152              :     }
   13153              : 
   13154           50 :     for (int i = 1; i < 5; i++) {
   13155           40 :         tableBody(dateColIdx, state.dataGlobal->NumOfZones + i) = "-";
   13156              :     }
   13157              : 
   13158           10 :     WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
   13159           10 :     if (state.dataSQLiteProcedures->sqlite) {
   13160            0 :         state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
   13161            0 :             tableBody, rowHead, columnHead, "ReportingPeriod-" + periodTitle + "-ThermalResilienceSummary", "Entire Facility", tableName);
   13162              :     }
   13163           10 :     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           10 : }
   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          680 : void WriteThermalResilienceTables(EnergyPlusData &state)
   13216              : {
   13217              : 
   13218              :     // Using/Aliasing
   13219          680 :     auto const &ort = state.dataOutRptTab;
   13220              : 
   13221          680 :     if (state.dataGlobal->NumOfZones <= 0) {
   13222           27 :         return;
   13223              :     }
   13224              : 
   13225              :     Real64 degreeHourConversion;
   13226          653 :     UnitsStyle unitsStyle_cur = ort->unitsStyle;
   13227          653 :     if (unitsStyle_cur == OutputReportTabular::UnitsStyle::InchPound ||
   13228              :         unitsStyle_cur == OutputReportTabular::UnitsStyle::InchPoundExceptElectricity) {
   13229           44 :         degreeHourConversion = getSpecificUnitMultiplier(state, "°C·hr", "°F·hr");
   13230              :     } else {
   13231          642 :         degreeHourConversion = 1.0;
   13232              :     }
   13233              : 
   13234         1959 :     WriteReportHeaders(state, "Annual Thermal Resilience Summary", "Entire Facility", OutputProcessor::StoreType::Average);
   13235              : 
   13236          653 :     Array1D_int columnWidth;
   13237          653 :     columnWidth.allocate(numColumnThermalTbl);
   13238          653 :     columnWidth = 10;
   13239          653 :     Array1D_string rowHead;
   13240          653 :     Array2D_string tableBody;
   13241          653 :     rowHead.allocate(state.dataGlobal->NumOfZones + 4);
   13242          653 :     tableBody.allocate(numColumnThermalTbl, state.dataGlobal->NumOfZones + 4);
   13243          653 :     Array1D_string columnHeadStr(numColumnThermalTbl);
   13244              : 
   13245          653 :     if (unitsStyle_cur == OutputReportTabular::UnitsStyle::InchPound ||
   13246              :         unitsStyle_cur == OutputReportTabular::UnitsStyle::InchPoundExceptElectricity) {
   13247           11 :         columnHeadStr(1) = "Safe (≤ 80.1°F) [hr]";
   13248           11 :         columnHeadStr(2) = "Caution (> 80.1°F, ≤ 90.0°F) [hr]";
   13249           11 :         columnHeadStr(3) = "Extreme Caution (> 90.0°F, ≤ 102.9°F) [hr]";
   13250           11 :         columnHeadStr(4) = "Danger (> 102.9, ≤ 125.1°F) [hr]";
   13251           11 :         columnHeadStr(5) = "Extreme Danger (> 125.1°F) [hr]";
   13252              :     } else {
   13253          642 :         columnHeadStr(1) = "Safe (≤ 26.7°C) [hr]";
   13254          642 :         columnHeadStr(2) = "Caution (> 26.7°C, ≤ 32.2°C) [hr]";
   13255          642 :         columnHeadStr(3) = "Extreme Caution (> 32.2°C, ≤ 39.4°C) [hr]";
   13256          642 :         columnHeadStr(4) = "Danger (> 39.4°C, ≤ 51.7°C) [hr]";
   13257          642 :         columnHeadStr(5) = "Extreme Danger (> 51.7°C) [hr]";
   13258              :     }
   13259              : 
   13260          653 :     std::array<Real64, numColumnThermalTbl> DataHeatBalance::ZoneResilience::*ptrHeatIndex = &DataHeatBalance::ZoneResilience::ZoneHeatIndexHourBins;
   13261          653 :     std::array<Real64, numColumnThermalTbl> DataHeatBalance::ZoneResilience::*ptrHeatIndexOccuHour =
   13262              :         &DataHeatBalance::ZoneResilience::ZoneHeatIndexOccuHourBins;
   13263          653 :     std::array<Real64, numColumnThermalTbl> DataHeatBalance::ZoneResilience::*ptrHeatIndexOccupiedHour =
   13264              :         &DataHeatBalance::ZoneResilience::ZoneHeatIndexOccupiedHourBins;
   13265          653 :     std::string tableName = "Heat Index Hours";
   13266          653 :     WriteResilienceBinsTableNonPreDefUseZoneData<numColumnThermalTbl>(state, tableName, columnHeadStr, columnWidth, ptrHeatIndex, rowHead, tableBody);
   13267          653 :     tableName = "Heat Index OccupantHours";
   13268          653 :     WriteResilienceBinsTableNonPreDefUseZoneData<numColumnThermalTbl>(
   13269              :         state, tableName, columnHeadStr, columnWidth, ptrHeatIndexOccuHour, rowHead, tableBody);
   13270          653 :     tableName = "Heat Index OccupiedHours";
   13271          653 :     WriteResilienceBinsTableNonPreDefUseZoneData<numColumnThermalTbl>(
   13272              :         state, tableName, columnHeadStr, columnWidth, ptrHeatIndexOccupiedHour, rowHead, tableBody);
   13273              : 
   13274          653 :     columnHeadStr(1) = "Little to no Discomfort (≤ 29) [hr]";
   13275          653 :     columnHeadStr(2) = "Some Discomfort (> 29, ≤ 40) [hr]";
   13276          653 :     columnHeadStr(3) = "Great Discomfort; Avoid Exertion (> 40, ≤ 45) [hr]";
   13277          653 :     columnHeadStr(4) = "Dangerous (> 45, ≤ 50) [hr]";
   13278          653 :     columnHeadStr(5) = "Heat Stroke Quite Possible (> 50) [hr]";
   13279              : 
   13280          653 :     std::array<Real64, numColumnThermalTbl> DataHeatBalance::ZoneResilience::*ptrHumidex = &DataHeatBalance::ZoneResilience::ZoneHumidexHourBins;
   13281          653 :     std::array<Real64, numColumnThermalTbl> DataHeatBalance::ZoneResilience::*ptrHumidexOccuHour =
   13282              :         &DataHeatBalance::ZoneResilience::ZoneHumidexOccuHourBins;
   13283          653 :     std::array<Real64, numColumnThermalTbl> DataHeatBalance::ZoneResilience::*ptrHumidexOccupiedHour =
   13284              :         &DataHeatBalance::ZoneResilience::ZoneHumidexOccupiedHourBins;
   13285          653 :     tableName = "Humidex Hours";
   13286          653 :     WriteResilienceBinsTableNonPreDefUseZoneData<numColumnThermalTbl>(state, tableName, columnHeadStr, columnWidth, ptrHumidex, rowHead, tableBody);
   13287          653 :     tableName = "Humidex OccupantHours";
   13288          653 :     WriteResilienceBinsTableNonPreDefUseZoneData<numColumnThermalTbl>(
   13289              :         state, tableName, columnHeadStr, columnWidth, ptrHumidexOccuHour, rowHead, tableBody);
   13290          653 :     tableName = "Humidex OccupiedHours";
   13291          653 :     WriteResilienceBinsTableNonPreDefUseZoneData<numColumnThermalTbl>(
   13292              :         state, tableName, columnHeadStr, columnWidth, ptrHumidexOccupiedHour, rowHead, tableBody);
   13293              : 
   13294          653 :     bool hasPierceSET = true;
   13295          653 :     if (state.dataHeatBal->TotPeople == 0) {
   13296           76 :         hasPierceSET = false;
   13297           76 :         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         3673 :     for (int iPeople = 1; iPeople <= state.dataHeatBal->TotPeople; ++iPeople) {
   13305         3020 :         if (!state.dataHeatBal->People(iPeople).Pierce) {
   13306         3009 :             hasPierceSET = false;
   13307         3009 :             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          653 :     if (hasPierceSET) {
   13317            6 :         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            6 :             columnHeadStr(1) = "SET > 30°C Degree-Hours [°C·hr]";
   13326            6 :             columnHeadStr(2) = "SET > 30°C Occupant-Weighted Degree-Hours [°C·hr]";
   13327            6 :             columnHeadStr(3) = "SET > 30°C Occupied Degree-Hours [°C·hr]";
   13328            6 :             columnHeadStr(4) = "Longest SET > 30°C Duration for Occupied Period [hr]";
   13329            6 :             columnHeadStr(5) = "Start Time of the Longest SET > 30°C Duration for Occupied Period";
   13330              :         }
   13331              : 
   13332            6 :         std::array<Real64, numColumnThermalTbl> DataHeatBalance::ZoneResilience::*ptrLowSETHours = &DataHeatBalance::ZoneResilience::ZoneLowSETHours;
   13333            6 :         std::array<Real64, numColumnThermalTbl> DataHeatBalance::ZoneResilience::*ptrHighSETHours =
   13334              :             &DataHeatBalance::ZoneResilience::ZoneHighSETHours;
   13335            6 :         Array1D_string rowHeadSET;
   13336            6 :         Array2D_string tableBodySET;
   13337            6 :         rowHeadSET.allocate(state.dataGlobal->NumOfZones + 3);
   13338            6 :         tableBodySET.allocate(numColumnThermalTbl, state.dataGlobal->NumOfZones + 3);
   13339            6 :         tableName = "Heating SET Degree-Hours";
   13340            6 :         WriteSETHoursTableNonPreDefUseZoneData(
   13341              :             state, numColumnThermalTbl, tableName, columnHeadStr, columnWidth, ptrLowSETHours, rowHeadSET, tableBodySET, degreeHourConversion);
   13342            6 :         tableName = "Cooling SET Degree-Hours";
   13343            6 :         WriteSETHoursTableNonPreDefUseZoneData(
   13344              :             state, numColumnThermalTbl, tableName, columnHeadStr, columnWidth, ptrHighSETHours, rowHeadSET, tableBodySET, degreeHourConversion);
   13345            6 :     }
   13346              : 
   13347          653 :     std::array<Real64, numColumnThermalTbl> DataHeatBalance::ZoneResilience::*ptrColdHourOfSafetyBins =
   13348              :         &DataHeatBalance::ZoneResilience::ZoneColdHourOfSafetyBins;
   13349          653 :     std::array<Real64, numColumnThermalTbl> DataHeatBalance::ZoneResilience::*ptrHeatHourOfSafetyBins =
   13350              :         &DataHeatBalance::ZoneResilience::ZoneHeatHourOfSafetyBins;
   13351          653 :     tableName = "Hours of Safety for Cold Events";
   13352          653 :     columnHeadStr(1) = "Hours of Safety [hr]";
   13353          653 :     columnHeadStr(2) = "End Time of the Safety Duration";
   13354          653 :     columnHeadStr(3) = "Safe Temperature Exceedance Hours [hr]";
   13355          653 :     columnHeadStr(4) = "Safe Temperature Exceedance OccupantHours [hr]";
   13356          653 :     columnHeadStr(5) = "Safe Temperature Exceedance OccupiedHours [hr]";
   13357          653 :     WriteHourOfSafetyTableNonPreDefUseZoneData(
   13358              :         state, numColumnThermalTbl, tableName, columnHeadStr, columnWidth, ptrColdHourOfSafetyBins, rowHead, tableBody, 2);
   13359          653 :     tableName = "Hours of Safety for Heat Events";
   13360          653 :     WriteHourOfSafetyTableNonPreDefUseZoneData(
   13361              :         state, numColumnThermalTbl, tableName, columnHeadStr, columnWidth, ptrHeatHourOfSafetyBins, rowHead, tableBody, 2);
   13362              : 
   13363          653 :     Array1D_int columnWidthUnmetDegHr;
   13364          653 :     columnWidthUnmetDegHr.allocate(numColumnUnmetDegreeHourTbl);
   13365          653 :     columnWidthUnmetDegHr = 10;
   13366          653 :     Array1D_string columnHeadUnmetDegHr;
   13367          653 :     columnHeadUnmetDegHr.allocate(numColumnUnmetDegreeHourTbl);
   13368          653 :     Array2D_string tableBodyUnmetDegHr;
   13369          653 :     tableBodyUnmetDegHr.allocate(numColumnUnmetDegreeHourTbl, state.dataGlobal->NumOfZones + 4);
   13370          653 :     tableName = "Unmet Degree-Hours";
   13371          653 :     columnHeadUnmetDegHr(1) = "Cooling Setpoint Unmet Degree-Hours [°C·hr]";
   13372          653 :     columnHeadUnmetDegHr(2) = "Cooling Setpoint Unmet Occupant-Weighted Degree-Hours [°C·hr]";
   13373          653 :     columnHeadUnmetDegHr(3) = "Cooling Setpoint Unmet Occupied Degree-Hours [°C·hr]";
   13374          653 :     columnHeadUnmetDegHr(4) = "Heating Setpoint Unmet Degree-Hours [°C·hr]";
   13375          653 :     columnHeadUnmetDegHr(5) = "Heating Setpoint Unmet Occupant-Weighted Degree-Hours [°C·hr]";
   13376          653 :     columnHeadUnmetDegHr(6) = "Heating Setpoint Unmet Occupied Degree-Hours [°C·hr]";
   13377              : 
   13378          653 :     if (unitsStyle_cur == UnitsStyle::InchPound) {
   13379              :         int indexUnitConv;
   13380           11 :         std::string curUnits;
   13381           66 :         for (int i = 1; i < numColumnUnmetDegreeHourTbl; i++) {
   13382           55 :             LookupSItoIP(state, columnHeadUnmetDegHr(i), indexUnitConv, curUnits);
   13383           55 :             columnHeadUnmetDegHr(i) = curUnits;
   13384              :         }
   13385          653 :     } 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          653 :     std::array<Real64, numColumnUnmetDegreeHourTbl> DataHeatBalance::ZoneResilience::*ptrUnmetDegreeHourBins =
   13395              :         &DataHeatBalance::ZoneResilience::ZoneUnmetDegreeHourBins;
   13396          653 :     WriteResilienceBinsTableNonPreDefUseZoneData<numColumnUnmetDegreeHourTbl>(
   13397              :         state, tableName, columnHeadUnmetDegHr, columnWidthUnmetDegHr, ptrUnmetDegreeHourBins, rowHead, tableBodyUnmetDegHr, degreeHourConversion);
   13398              : 
   13399          653 :     columnHeadStr.allocate(numColumnDiscomfortWtExceedHourTbl);
   13400          653 :     columnWidth.allocate(numColumnDiscomfortWtExceedHourTbl);
   13401          653 :     columnWidth = 10;
   13402          653 :     tableBody.allocate(numColumnDiscomfortWtExceedHourTbl, state.dataGlobal->NumOfZones + 4);
   13403          653 :     columnHeadStr(1) = "Very-cold Exceedance OccupantHours [hr]";
   13404          653 :     columnHeadStr(2) = "Cool Exceedance OccupantHours [hr]";
   13405          653 :     columnHeadStr(3) = "Warm Exceedance OccupantHours [hr]";
   13406          653 :     columnHeadStr(4) = "Very-hot Exceedance OccupantHours [hr]";
   13407              : 
   13408          653 :     std::array<Real64, numColumnDiscomfortWtExceedHourTbl> DataHeatBalance::ZoneResilience::*ptrDiscomfortWtExceedOccuHourBins =
   13409              :         &DataHeatBalance::ZoneResilience::ZoneDiscomfortWtExceedOccuHourBins;
   13410          653 :     std::array<Real64, numColumnDiscomfortWtExceedHourTbl> DataHeatBalance::ZoneResilience::*ptrDiscomfortWtExceedOccupiedHourBins =
   13411              :         &DataHeatBalance::ZoneResilience::ZoneDiscomfortWtExceedOccupiedHourBins;
   13412          653 :     tableName = "Discomfort-weighted Exceedance OccupantHours";
   13413          653 :     WriteResilienceBinsTableNonPreDefUseZoneData<numColumnDiscomfortWtExceedHourTbl>(
   13414              :         state, tableName, columnHeadStr, columnWidth, ptrDiscomfortWtExceedOccuHourBins, rowHead, tableBody);
   13415          653 :     tableName = "Discomfort-weighted Exceedance OccupiedHours";
   13416          653 :     WriteResilienceBinsTableNonPreDefUseZoneData<numColumnDiscomfortWtExceedHourTbl>(
   13417              :         state, tableName, columnHeadStr, columnWidth, ptrDiscomfortWtExceedOccupiedHourBins, rowHead, tableBody);
   13418          653 :     rowHead.deallocate();
   13419          653 :     columnHeadStr.deallocate();
   13420          653 :     tableBody.deallocate();
   13421          653 :     tableBodyUnmetDegHr.deallocate();
   13422          653 :     columnWidth.deallocate();
   13423          653 :     columnHeadUnmetDegHr.deallocate();
   13424          653 :     columnWidthUnmetDegHr.deallocate();
   13425          653 : }
   13426              : 
   13427           15 : void WriteCO2ResilienceTables(EnergyPlusData &state)
   13428              : {
   13429              : 
   13430           15 :     if (state.dataGlobal->NumOfZones <= 0) {
   13431            0 :         return;
   13432              :     }
   13433              :     std::array<int, numColumnCO2Tbl> columnHead = {
   13434           15 :         state.dataOutRptPredefined->pdchCO2HourSafe, state.dataOutRptPredefined->pdchCO2HourCaution, state.dataOutRptPredefined->pdchCO2HourHazard};
   13435              : 
   13436           15 :     std::array<Real64, numColumnCO2Tbl> DataHeatBalance::ZoneResilience::*ptrCO2LevelHourBins =
   13437              :         &DataHeatBalance::ZoneResilience::ZoneCO2LevelHourBins;
   13438           15 :     std::array<Real64, numColumnCO2Tbl> DataHeatBalance::ZoneResilience::*ptrCO2LevelOccuHourBins =
   13439              :         &DataHeatBalance::ZoneResilience::ZoneCO2LevelOccuHourBins;
   13440           15 :     std::array<Real64, numColumnCO2Tbl> DataHeatBalance::ZoneResilience::*ptrCO2LevelOccupiedHourBins =
   13441              :         &DataHeatBalance::ZoneResilience::ZoneCO2LevelOccupiedHourBins;
   13442           15 :     WriteResilienceBinsTable<numColumnCO2Tbl>(state, columnHead, ptrCO2LevelHourBins);
   13443              : 
   13444           15 :     columnHead = {state.dataOutRptPredefined->pdchCO2OccuHourSafe,
   13445           15 :                   state.dataOutRptPredefined->pdchCO2OccuHourCaution,
   13446           15 :                   state.dataOutRptPredefined->pdchCO2OccuHourHazard};
   13447           15 :     WriteResilienceBinsTable<numColumnCO2Tbl>(state, columnHead, ptrCO2LevelOccuHourBins);
   13448              : 
   13449           15 :     columnHead = {state.dataOutRptPredefined->pdchCO2OccupiedHourSafe,
   13450           15 :                   state.dataOutRptPredefined->pdchCO2OccupiedHourCaution,
   13451           15 :                   state.dataOutRptPredefined->pdchCO2OccupiedHourHazard};
   13452           15 :     WriteResilienceBinsTable<numColumnCO2Tbl>(state, columnHead, ptrCO2LevelOccupiedHourBins);
   13453              : }
   13454              : 
   13455            3 : void WriteCO2ResilienceTablesRepPeriod(EnergyPlusData &state, const int periodIdx)
   13456              : {
   13457            3 :     auto const &ort = state.dataOutRptTab;
   13458              :     // TODO: this is wrong. This function is called only when ort->WriteTabularFiles is true already. Missing a '!'
   13459            3 :     if (ort->WriteTabularFiles) {
   13460            3 :         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           56 : void WriteVisualResilienceTables(EnergyPlusData &state)
   13520              : {
   13521          814 :     for (int ZoneNum = 1; ZoneNum <= state.dataGlobal->NumOfZones; ++ZoneNum) {
   13522          758 :         if (state.dataDayltg->ZoneDaylight(ZoneNum).totRefPts == 0) {
   13523          492 :             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           56 :     if (state.dataGlobal->NumOfZones <= 0) {
   13533            0 :         return;
   13534              :     }
   13535           56 :     std::array<int, numColumnVisualTbl> columnHead = {state.dataOutRptPredefined->pdchIllumHourDark,
   13536          112 :                                                       state.dataOutRptPredefined->pdchIllumHourDim,
   13537          112 :                                                       state.dataOutRptPredefined->pdchIllumHourAdequate,
   13538           56 :                                                       state.dataOutRptPredefined->pdchIllumHourBright};
   13539              : 
   13540           56 :     std::array<Real64, numColumnVisualTbl> DataHeatBalance::ZoneResilience::*ptrLightingLevelHourBins =
   13541              :         &DataHeatBalance::ZoneResilience::ZoneLightingLevelHourBins;
   13542           56 :     std::array<Real64, numColumnVisualTbl> DataHeatBalance::ZoneResilience::*ptrLightingLevelOccuHourBins =
   13543              :         &DataHeatBalance::ZoneResilience::ZoneLightingLevelOccuHourBins;
   13544           56 :     std::array<Real64, numColumnVisualTbl> DataHeatBalance::ZoneResilience::*ptrLightingLevelOccupiedHourBins =
   13545              :         &DataHeatBalance::ZoneResilience::ZoneLightingLevelOccupiedHourBins;
   13546           56 :     WriteResilienceBinsTable<numColumnVisualTbl>(state, columnHead, ptrLightingLevelHourBins);
   13547              : 
   13548           56 :     columnHead = {state.dataOutRptPredefined->pdchIllumOccuHourDark,
   13549           56 :                   state.dataOutRptPredefined->pdchIllumOccuHourDim,
   13550           56 :                   state.dataOutRptPredefined->pdchIllumOccuHourAdequate,
   13551           56 :                   state.dataOutRptPredefined->pdchIllumOccuHourBright};
   13552           56 :     WriteResilienceBinsTable<numColumnVisualTbl>(state, columnHead, ptrLightingLevelOccuHourBins);
   13553              : 
   13554           56 :     columnHead = {state.dataOutRptPredefined->pdchIllumOccupiedHourDark,
   13555           56 :                   state.dataOutRptPredefined->pdchIllumOccupiedHourDim,
   13556           56 :                   state.dataOutRptPredefined->pdchIllumOccupiedHourAdequate,
   13557           56 :                   state.dataOutRptPredefined->pdchIllumOccupiedHourBright};
   13558           56 :     WriteResilienceBinsTable<numColumnVisualTbl>(state, columnHead, ptrLightingLevelOccupiedHourBins);
   13559              : }
   13560              : 
   13561            3 : void WriteVisualResilienceTablesRepPeriod(EnergyPlusData &state, const int periodIdx)
   13562              : {
   13563            3 :     auto const &ort = state.dataOutRptTab;
   13564            3 :     if (!ort->WriteTabularFiles) {
   13565            0 :         return;
   13566              :     }
   13567              : 
   13568            6 :     WriteReportHeaderReportingPeriod(state, "Visual", periodIdx, state.dataWeather->VisualReportPeriodInput);
   13569            3 :     std::string periodTitle = state.dataWeather->VisualReportPeriodInput(periodIdx).title;
   13570              : 
   13571            3 :     Array1D_int columnWidth;
   13572            3 :     columnWidth.allocate(numColumnVisualTbl);
   13573            3 :     columnWidth = 10;
   13574            3 :     Array1D_string columnHead(numColumnVisualTbl);
   13575            3 :     columnHead(1) = "A Bit Dark (<= 100 lux) [hr]";
   13576            3 :     columnHead(2) = "Dim (> 100, <= 300 lux) [hr]";
   13577            3 :     columnHead(3) = "Adequate (> 300, <= 500 lux) [hr]";
   13578            3 :     columnHead(4) = "Bright (>500 lux) [hr]";
   13579              : 
   13580            3 :     Array1D_string rowHead;
   13581            3 :     Array2D_string tableBody;
   13582            3 :     rowHead.allocate(state.dataGlobal->NumOfZones + 4);
   13583            3 :     tableBody.allocate(numColumnVisualTbl, state.dataGlobal->NumOfZones + 4);
   13584              : 
   13585            6 :     std::string tableName = "Illuminance Level Hours";
   13586            3 :     std::string tableType = "Visual";
   13587            3 :     WriteResilienceBinsTableReportingPeriod(state,
   13588              :                                             tableType,
   13589              :                                             numColumnVisualTbl,
   13590              :                                             periodIdx,
   13591              :                                             periodTitle,
   13592              :                                             tableName,
   13593              :                                             columnHead,
   13594              :                                             columnWidth,
   13595            3 :                                             state.dataHeatBalFanSys->ZoneLightingLevelHourBinsRepPeriod,
   13596              :                                             rowHead,
   13597              :                                             tableBody);
   13598              : 
   13599            3 :     tableName = "Illuminance Level OccupantHours";
   13600            3 :     WriteResilienceBinsTableReportingPeriod(state,
   13601              :                                             tableType,
   13602              :                                             numColumnVisualTbl,
   13603              :                                             periodIdx,
   13604              :                                             periodTitle,
   13605              :                                             tableName,
   13606              :                                             columnHead,
   13607              :                                             columnWidth,
   13608            3 :                                             state.dataHeatBalFanSys->ZoneLightingLevelOccuHourBinsRepPeriod,
   13609              :                                             rowHead,
   13610              :                                             tableBody);
   13611              : 
   13612            3 :     tableName = "Illuminance Level OccupiedHours";
   13613            3 :     WriteResilienceBinsTableReportingPeriod(state,
   13614              :                                             tableType,
   13615              :                                             numColumnVisualTbl,
   13616              :                                             periodIdx,
   13617              :                                             periodTitle,
   13618              :                                             tableName,
   13619              :                                             columnHead,
   13620              :                                             columnWidth,
   13621            3 :                                             state.dataHeatBalFanSys->ZoneLightingLevelOccupiedHourBinsRepPeriod,
   13622              :                                             rowHead,
   13623              :                                             tableBody);
   13624            3 : }
   13625              : 
   13626          759 : void WriteHeatEmissionTable(EnergyPlusData &state)
   13627              : {
   13628              : 
   13629          759 :     Array1D_string columnHead(6);
   13630          759 :     Array1D_int columnWidth;
   13631          759 :     Array1D_string rowHead;
   13632          759 :     Array2D_string tableBody;
   13633          759 :     auto const &ort = state.dataOutRptTab;
   13634              : 
   13635          759 :     if (state.dataOutRptTab->displayHeatEmissionsSummary) {
   13636              : 
   13637         1356 :         for (int iUnitSystem = 0; iUnitSystem <= 1; iUnitSystem++) {
   13638         1356 :             UnitsStyle unitsStyle_cur = ort->unitsStyle;
   13639         1356 :             bool produceTabular = true;
   13640         1356 :             bool produceSQLite = false;
   13641         1356 :             if (produceDualUnitsFlags(iUnitSystem, ort->unitsStyle, ort->unitsStyle_SQLite, unitsStyle_cur, produceTabular, produceSQLite)) {
   13642          678 :                 break;
   13643              :             }
   13644              : 
   13645          678 :             if (produceTabular) {
   13646         2712 :                 WriteReportHeaders(state, "Annual Heat Emissions Report", "Entire Facility", OutputProcessor::StoreType::Average);
   13647         1356 :                 WriteSubtitle(state, "Annual Heat Emissions Summary");
   13648              :             }
   13649              : 
   13650          678 :             columnWidth.allocate(6);
   13651          678 :             columnWidth = 10;
   13652              : 
   13653          678 :             rowHead.allocate(1);
   13654          678 :             tableBody.allocate(6, 1);
   13655              : 
   13656          678 :             Real64 energyconversion = 1.0;
   13657          678 :             if (unitsStyle_cur == OutputReportTabular::UnitsStyle::InchPound ||
   13658          667 :                 unitsStyle_cur == OutputReportTabular::UnitsStyle::InchPoundExceptElectricity) {
   13659           11 :                 rowHead(1) = "Heat Emissions [kBtu]";
   13660           44 :                 energyconversion = 1.0 / getSpecificUnitDivider(state, "GJ", "kBtu"); // 1054351.84 J to kBtu
   13661          667 :             } else if (unitsStyle_cur == UnitsStyle::JtoGJ) {
   13662            0 :                 rowHead(1) = "Heat Emissions [GJ]";
   13663            0 :                 energyconversion = 1.0;
   13664          667 :             } else if (unitsStyle_cur == UnitsStyle::JtoKWH) {
   13665            6 :                 rowHead(1) = "Heat Emissions [kWh]";
   13666            6 :                 energyconversion = 1.0e3 / 3.6;
   13667          661 :             } else if (unitsStyle_cur == UnitsStyle::JtoMJ) {
   13668            0 :                 rowHead(1) = "Heat Emissions [MJ]";
   13669            0 :                 energyconversion = 1.0e3;
   13670          661 :             } else if (unitsStyle_cur == UnitsStyle::None) {
   13671          661 :                 rowHead(1) = "Heat Emissions [GJ]";
   13672          661 :                 energyconversion = 1.0;
   13673              :             } else {
   13674            0 :                 rowHead(1) = "Heat Emissions [GJ]";
   13675            0 :                 energyconversion = 1.0;
   13676              :             }
   13677              : 
   13678          678 :             columnHead(1) = "Envelope Convection";
   13679          678 :             columnHead(2) = "Zone Exfiltration";
   13680          678 :             columnHead(3) = "Zone Exhaust Air";
   13681          678 :             columnHead(4) = "HVAC Relief Air";
   13682          678 :             columnHead(5) = "HVAC Reject Heat";
   13683          678 :             columnHead(6) = "Total";
   13684              : 
   13685          678 :             tableBody = "";
   13686          678 :             tableBody(1, 1) = RealToStr(state.dataHeatBal->BuildingPreDefRep.emiEnvelopConv * energyconversion, 2);
   13687          678 :             tableBody(2, 1) = RealToStr(state.dataHeatBal->BuildingPreDefRep.emiZoneExfiltration * energyconversion, 2);
   13688          678 :             tableBody(3, 1) = RealToStr(state.dataHeatBal->BuildingPreDefRep.emiZoneExhaust * energyconversion, 2);
   13689          678 :             tableBody(4, 1) = RealToStr(state.dataHeatBal->BuildingPreDefRep.emiHVACRelief * energyconversion, 2);
   13690          678 :             tableBody(5, 1) = RealToStr(state.dataHeatBal->BuildingPreDefRep.emiHVACReject * energyconversion, 2);
   13691          678 :             tableBody(6, 1) = RealToStr(state.dataHeatBal->BuildingPreDefRep.emiTotHeat * energyconversion, 2);
   13692              : 
   13693          678 :             if (produceTabular) {
   13694          678 :                 WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
   13695          678 :                 if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
   13696           56 :                     state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(
   13697              :                         tableBody, rowHead, columnHead, "AnnualHeatEmissionsReport", "Entire Facility", "Annual Heat Emissions Summary");
   13698              :                 }
   13699              :             }
   13700          678 :             if (produceSQLite) {
   13701          678 :                 if (state.dataSQLiteProcedures->sqlite) {
   13702           76 :                     state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
   13703              :                         tableBody, rowHead, columnHead, "AnnualHeatEmissionsReport", "Entire Facility", "Annual Heat Emissions Summary");
   13704              :                 }
   13705              :             }
   13706              :         }
   13707              :     }
   13708          759 : }
   13709              : 
   13710          759 : 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          759 :     Array1D_string columnHead;
   13735          759 :     Array1D_int columnWidth;
   13736          759 :     Array1D_string rowHead;
   13737          759 :     Array2D_string tableBody;
   13738          759 :     Array1D_int rowToUnqObjName;
   13739          759 :     Array1D_int colHeadToColTag;
   13740          759 :     Array1D_string uniqueObjectName;
   13741          759 :     Array1D_bool useUniqueObjectName;
   13742          759 :     int colCurrent(0);
   13743          759 :     int rowCurrent(0);
   13744          759 :     Array1D_int colUnitConv;
   13745          759 :     auto const &ort = state.dataOutRptTab;
   13746              : 
   13747         1518 :     for (int iUnitSystem = 0; iUnitSystem <= 1; iUnitSystem++) {
   13748         1518 :         UnitsStyle unitsStyle_cur = ort->unitsStyle;
   13749         1518 :         bool produceTabular = true;
   13750         1518 :         bool produceSQLite = false;
   13751         1518 :         if (produceDualUnitsFlags(iUnitSystem, ort->unitsStyle, ort->unitsStyle_SQLite, unitsStyle_cur, produceTabular, produceSQLite)) {
   13752          759 :             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          759 :         uniqueObjectName.allocate(state.dataOutRptPredefined->numTableEntry);
   13760          759 :         useUniqueObjectName.allocate(state.dataOutRptPredefined->numTableEntry);
   13761          759 :         int numUnqObjName = 0;
   13762      3906318 :         for (int lTableEntry = 1; lTableEntry <= state.dataOutRptPredefined->numTableEntry; ++lTableEntry) {
   13763              :             // associate the subtable with each column
   13764      3905559 :             int const curColumn = state.dataOutRptPredefined->tableEntry(lTableEntry).indexColumn;
   13765      3905559 :             if ((curColumn >= 1) && (curColumn <= state.dataOutRptPredefined->numColumnTag)) {
   13766      3905559 :                 state.dataOutRptPredefined->tableEntry(lTableEntry).subTableIndex = state.dataOutRptPredefined->columnTag(curColumn).indexSubTable;
   13767              :             }
   13768              :             // make a list of unique object names
   13769      3905559 :             std::string const &curObjectName = state.dataOutRptPredefined->tableEntry(lTableEntry).objectName;
   13770      3905559 :             int found = 0;
   13771   1608310189 :             for (int mUnqObjNames = 1; mUnqObjNames <= numUnqObjName; ++mUnqObjNames) {
   13772   1608010678 :                 if (curObjectName == uniqueObjectName(mUnqObjNames)) {
   13773      3606048 :                     found = mUnqObjNames;
   13774      3606048 :                     break;
   13775              :                 }
   13776              :             }
   13777              :             // if found then point to the unique object
   13778      3905559 :             if (found > 0) {
   13779      3606048 :                 state.dataOutRptPredefined->tableEntry(lTableEntry).uniqueObjName = found;
   13780              :                 // if not found add to the unique object list
   13781              :             } else {
   13782       299511 :                 ++numUnqObjName;
   13783       299511 :                 uniqueObjectName(numUnqObjName) = curObjectName;
   13784       299511 :                 state.dataOutRptPredefined->tableEntry(lTableEntry).uniqueObjName = numUnqObjName;
   13785              :             }
   13786              :         }
   13787              :         // loop through all reports and include those that have been flagged as 'show'
   13788        14084 :         for (int iReportName = 1; iReportName <= state.dataOutRptPredefined->numReportName; ++iReportName) {
   13789        13325 :             if (state.dataOutRptPredefined->reportName(iReportName).show) {
   13790        12199 :                 if (produceTabular) {
   13791        36597 :                     WriteReportHeaders(state,
   13792        12199 :                                        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      1224008 :                 for (int jSubTable = 1, jSubTable_end = state.dataOutRptPredefined->numSubTable; jSubTable <= jSubTable_end; ++jSubTable) {
   13798      1211809 :                     if (state.dataOutRptPredefined->subTable(jSubTable).indexReportName == iReportName) {
   13799              :                         // determine how many columns
   13800        69929 :                         int curNumColumns = 0;
   13801     61832905 :                         for (int kColumnTag = 1; kColumnTag <= state.dataOutRptPredefined->numColumnTag; ++kColumnTag) {
   13802     61762976 :                             if (state.dataOutRptPredefined->columnTag(kColumnTag).indexSubTable == jSubTable) {
   13803       623969 :                                 ++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        69929 :                         useUniqueObjectName = false; // array assignment
   13809    336892069 :                         for (int lTableEntry = 1; lTableEntry <= state.dataOutRptPredefined->numTableEntry; ++lTableEntry) {
   13810    336822140 :                             if (state.dataOutRptPredefined->tableEntry(lTableEntry).subTableIndex == jSubTable) {
   13811      3293436 :                                 useUniqueObjectName(state.dataOutRptPredefined->tableEntry(lTableEntry).uniqueObjName) = true;
   13812              :                             }
   13813              :                         }
   13814        69929 :                         int curNumRows = 0;
   13815     26342151 :                         for (int mUnqObjNames = 1; mUnqObjNames <= numUnqObjName; ++mUnqObjNames) {
   13816     26272222 :                             if (useUniqueObjectName(mUnqObjNames)) {
   13817       373596 :                                 ++curNumRows;
   13818              :                             }
   13819              :                         }
   13820        69929 :                         if (curNumRows == 0) {
   13821        28147 :                             curNumRows = 1;
   13822              :                         }
   13823              :                         // now create the arrays that are filled with values
   13824        69929 :                         rowHead.allocate(curNumRows);
   13825        69929 :                         columnHead.allocate(curNumColumns);
   13826        69929 :                         columnWidth.dimension(curNumColumns, 14); // array assignment - same for all columns
   13827        69929 :                         tableBody.allocate(curNumColumns, curNumRows);
   13828       139858 :                         rowHead = "";
   13829       139858 :                         columnHead = "";
   13830        69929 :                         tableBody = "";
   13831              :                         // this array stores the unique object name index for each row
   13832        69929 :                         rowToUnqObjName.allocate(curNumRows);
   13833              :                         // this array stores the columnHead index for each column
   13834        69929 :                         colHeadToColTag.allocate(curNumColumns);
   13835        69929 :                         colUnitConv.allocate(curNumColumns);
   13836              :                         // set row headings
   13837        69929 :                         int countRow = 0;
   13838        69929 :                         rowHead(1) = "None";
   13839     26342151 :                         for (int mUnqObjNames = 1; mUnqObjNames <= numUnqObjName; ++mUnqObjNames) {
   13840     26272222 :                             if (useUniqueObjectName(mUnqObjNames)) {
   13841       373596 :                                 ++countRow;
   13842       373596 :                                 rowHead(countRow) = uniqueObjectName(mUnqObjNames);
   13843       373596 :                                 rowToUnqObjName(countRow) = mUnqObjNames;
   13844              :                             }
   13845              :                         }
   13846              :                         // set column headings
   13847        69929 :                         int countColumn = 0;
   13848     61832905 :                         for (int kColumnTag = 1; kColumnTag <= state.dataOutRptPredefined->numColumnTag; ++kColumnTag) {
   13849     61762976 :                             if (state.dataOutRptPredefined->columnTag(kColumnTag).indexSubTable == jSubTable) {
   13850       623969 :                                 ++countColumn;
   13851              :                                 // do the unit conversions
   13852       623969 :                                 std::string const &colTagWithSI = state.dataOutRptPredefined->columnTag(kColumnTag).heading;
   13853              :                                 int indexUnitConv;
   13854       623969 :                                 std::string curColTag;
   13855       623969 :                                 if (unitsStyle_cur == UnitsStyle::InchPound) {
   13856         9961 :                                     LookupSItoIP(state, colTagWithSI, indexUnitConv, curColTag);
   13857         9961 :                                     colUnitConv(countColumn) = indexUnitConv;
   13858       614008 :                                 } else if (unitsStyle_cur == UnitsStyle::InchPoundExceptElectricity) {
   13859            0 :                                     LookupSItoIP(state, colTagWithSI, indexUnitConv, curColTag);
   13860            0 :                                     colUnitConv(countColumn) = indexUnitConv;
   13861       614008 :                                 } else if (unitsStyle_cur == UnitsStyle::JtoKWH) {
   13862         5526 :                                     LookupJtokWH(state, colTagWithSI, indexUnitConv, curColTag);
   13863         5526 :                                     colUnitConv(countColumn) = indexUnitConv;
   13864              :                                 } else {
   13865       608482 :                                     curColTag = colTagWithSI;
   13866       608482 :                                     colUnitConv(countColumn) = 0;
   13867              :                                 }
   13868       623969 :                                 columnHead(countColumn) = curColTag;
   13869       623969 :                                 colHeadToColTag(countColumn) = kColumnTag;
   13870       623969 :                             }
   13871              :                         }
   13872              :                         // fill the body of the table from the entries
   13873              :                         // find the entries associated with the current subtable
   13874    336892069 :                         for (int lTableEntry = 1; lTableEntry <= state.dataOutRptPredefined->numTableEntry; ++lTableEntry) {
   13875    336822140 :                             if (state.dataOutRptPredefined->tableEntry(lTableEntry).subTableIndex == jSubTable) {
   13876              :                                 // determine what column the current entry is in
   13877      3293436 :                                 int const curColTagIndex = state.dataOutRptPredefined->tableEntry(lTableEntry).indexColumn;
   13878     39233179 :                                 for (int nColHead = 1; nColHead <= curNumColumns; ++nColHead) {
   13879     39233179 :                                     if (curColTagIndex == colHeadToColTag(nColHead)) {
   13880      3293436 :                                         colCurrent = nColHead;
   13881      3293436 :                                         break;
   13882              :                                     }
   13883              :                                 }
   13884              :                                 // determine what row the current entry is in
   13885      3293436 :                                 int const curRowUnqObjIndex = state.dataOutRptPredefined->tableEntry(lTableEntry).uniqueObjName;
   13886    118842599 :                                 for (int oRowHead = 1; oRowHead <= curNumRows; ++oRowHead) {
   13887    118842599 :                                     if (curRowUnqObjIndex == rowToUnqObjName(oRowHead)) {
   13888      3293436 :                                         rowCurrent = oRowHead;
   13889      3293436 :                                         break;
   13890              :                                     }
   13891              :                                 }
   13892              :                                 // finally assign the entry to the place in the table body
   13893      3293436 :                                 if (unitsStyle_cur == OutputReportTabular::UnitsStyle::InchPound ||
   13894      3249850 :                                     unitsStyle_cur == OutputReportTabular::UnitsStyle::InchPoundExceptElectricity ||
   13895      3249850 :                                     unitsStyle_cur == UnitsStyle::JtoKWH) {
   13896        67774 :                                     int columnUnitConv = colUnitConv(colCurrent);
   13897        68074 :                                     if (Util::SameString(state.dataOutRptPredefined->subTable(jSubTable).name, "SizingPeriod:DesignDay") &&
   13898          300 :                                         (unitsStyle_cur == OutputReportTabular::UnitsStyle::InchPound ||
   13899           72 :                                          unitsStyle_cur == OutputReportTabular::UnitsStyle::InchPoundExceptElectricity)) {
   13900          228 :                                         if (Util::SameString(columnHead(colCurrent), "Humidity Value")) {
   13901           38 :                                             std::string repTableTag;
   13902           38 :                                             LookupSItoIP(state,
   13903           38 :                                                          state.dataOutRptPredefined->tableEntry(lTableEntry + 1).charEntry,
   13904              :                                                          columnUnitConv,
   13905              :                                                          repTableTag);
   13906           38 :                                             state.dataOutRptPredefined->tableEntry(lTableEntry + 1).charEntry = repTableTag;
   13907           38 :                                         }
   13908              :                                     }
   13909        67774 :                                     if (state.dataOutRptPredefined->tableEntry(lTableEntry).origEntryIsReal && (columnUnitConv != 0)) {
   13910              :                                         Real64 const IPvalue =
   13911        30612 :                                             ConvertIP(state, columnUnitConv, state.dataOutRptPredefined->tableEntry(lTableEntry).origRealEntry);
   13912        30612 :                                         tableBody(colCurrent, rowCurrent) =
   13913        61224 :                                             RealToStr(IPvalue, state.dataOutRptPredefined->tableEntry(lTableEntry).significantDigits);
   13914              :                                     } else {
   13915        37162 :                                         tableBody(colCurrent, rowCurrent) = state.dataOutRptPredefined->tableEntry(lTableEntry).charEntry;
   13916              :                                     }
   13917        67774 :                                 } else {
   13918      3225662 :                                     tableBody(colCurrent, rowCurrent) = state.dataOutRptPredefined->tableEntry(lTableEntry).charEntry;
   13919              :                                 }
   13920              :                             }
   13921              :                         }
   13922              :                         // create the actual output table
   13923        69929 :                         if (produceTabular) {
   13924        69929 :                             WriteSubtitle(state, state.dataOutRptPredefined->subTable(jSubTable).name);
   13925        69929 :                             WriteTable(
   13926        69929 :                                 state, tableBody, rowHead, columnHead, columnWidth, false, state.dataOutRptPredefined->subTable(jSubTable).footnote);
   13927              :                         }
   13928        69929 :                         if (produceSQLite) {
   13929        69929 :                             if (state.dataSQLiteProcedures->sqlite) {
   13930        28107 :                                 state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
   13931              :                                     tableBody,
   13932              :                                     rowHead,
   13933              :                                     columnHead,
   13934         9369 :                                     state.dataOutRptPredefined->reportName(iReportName).name,
   13935              :                                     "Entire Facility",
   13936         9369 :                                     state.dataOutRptPredefined->subTable(jSubTable).name);
   13937              :                             }
   13938              :                         }
   13939        69929 :                         if (produceTabular) {
   13940        69929 :                             if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
   13941         3368 :                                 state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(
   13942              :                                     tableBody,
   13943              :                                     rowHead,
   13944              :                                     columnHead,
   13945          842 :                                     state.dataOutRptPredefined->reportName(iReportName).name,
   13946              :                                     "Entire Facility",
   13947          842 :                                     state.dataOutRptPredefined->subTable(jSubTable).name);
   13948              :                             }
   13949              :                         }
   13950              :                     }
   13951              :                 }
   13952              :             }
   13953              :         }
   13954              :     }
   13955          759 : }
   13956              : 
   13957          759 : 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          759 :     auto const &ort = state.dataOutRptTab;
   13980          759 :     if (!ort->displayComponentSizing) {
   13981           22 :         return;
   13982              :     }
   13983              : 
   13984              :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
   13985              :     // all arrays are in the format: (row, column)
   13986          737 :     Array1D_string columnHead;
   13987          737 :     Array1D_int columnWidth;
   13988          737 :     Array1D_int colUnitConv;
   13989          737 :     Array1D_string rowHead;
   13990          737 :     Array2D_string tableBody;
   13991          737 :     Array1D_string uniqueDesc;
   13992          737 :     Array1D_string uniqueObj;
   13993              :     int numUniqueObj;
   13994          737 :     std::string curDesc;
   13995          737 :     std::string curObj;
   13996              :     int foundEntry;
   13997              :     int foundDesc;
   13998              :     int foundObj;
   13999              :     int iTableEntry;
   14000              :     int jUnique;
   14001              : 
   14002         2211 :     WriteReportHeaders(state, "Component Sizing Summary", "Entire Facility", OutputProcessor::StoreType::Average);
   14003              : 
   14004         1474 :     for (int iUnitSystem = 0; iUnitSystem <= 1; iUnitSystem++) {
   14005         1474 :         UnitsStyle unitsStyle_cur = ort->unitsStyle;
   14006         1474 :         bool produceTabular = true;
   14007         1474 :         bool produceSQLite = false;
   14008         1474 :         if (produceDualUnitsFlags(iUnitSystem, ort->unitsStyle, ort->unitsStyle_SQLite, unitsStyle_cur, produceTabular, produceSQLite)) {
   14009          737 :             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          737 :         uniqueDesc.allocate(state.dataOutRptPredefined->numCompSizeTableEntry);
   14017          737 :         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          737 :         int loopLimit = 0;
   14025         6622 :         while (loopLimit <= 100) { // put a maximum count since complex loop that could run indefinitely if error
   14026         6622 :             foundEntry = 0;
   14027         6622 :             ++loopLimit;
   14028       690000 :             for (iTableEntry = 1; iTableEntry <= state.dataOutRptPredefined->numCompSizeTableEntry; ++iTableEntry) {
   14029       689263 :                 if (!state.dataOutRptPredefined->CompSizeTableEntry(iTableEntry).written) {
   14030         5885 :                     foundEntry = iTableEntry;
   14031         5885 :                     break;
   14032              :                 }
   14033              :             }
   14034         6622 :             if (foundEntry == 0) {
   14035          737 :                 break; // leave main loop - all items put into tables
   14036              :             }
   14037              :             // clear active items
   14038      1540185 :             for (auto &e : state.dataOutRptPredefined->CompSizeTableEntry) {
   14039      1534300 :                 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      1012572 :             for (iTableEntry = 1; iTableEntry <= state.dataOutRptPredefined->numCompSizeTableEntry; ++iTableEntry) {
   14044      1006687 :                 if (!state.dataOutRptPredefined->CompSizeTableEntry(iTableEntry).written) {
   14045       307758 :                     if (Util::SameString(state.dataOutRptPredefined->CompSizeTableEntry(iTableEntry).typeField,
   14046       307758 :                                          state.dataOutRptPredefined->CompSizeTableEntry(foundEntry).typeField)) {
   14047        73816 :                         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         5885 :             int numUniqueDesc = 0;
   14055         5885 :             numUniqueObj = 0;
   14056      1012572 :             for (iTableEntry = 1; iTableEntry <= state.dataOutRptPredefined->numCompSizeTableEntry; ++iTableEntry) {
   14057              :                 // search for descriptions
   14058      1006687 :                 foundDesc = 0;
   14059      1006687 :                 if (state.dataOutRptPredefined->CompSizeTableEntry(iTableEntry).active) {
   14060        73816 :                     curDesc = state.dataOutRptPredefined->CompSizeTableEntry(iTableEntry).description;
   14061              :                     // look through the list of unique items to see if it matches
   14062       268112 :                     for (jUnique = 1; jUnique <= numUniqueDesc; ++jUnique) {
   14063       246425 :                         if (Util::SameString(curDesc, uniqueDesc(jUnique))) {
   14064        52129 :                             foundDesc = jUnique;
   14065        52129 :                             break;
   14066              :                         }
   14067              :                     }
   14068              :                     // if not found add to the list
   14069        73816 :                     if (foundDesc == 0) {
   14070        21687 :                         ++numUniqueDesc;
   14071        21687 :                         uniqueDesc(numUniqueDesc) = curDesc;
   14072              :                     }
   14073              :                     // search for objects
   14074        73816 :                     foundObj = 0;
   14075        73816 :                     curObj = state.dataOutRptPredefined->CompSizeTableEntry(iTableEntry).nameField;
   14076       954306 :                     for (jUnique = 1; jUnique <= numUniqueObj; ++jUnique) {
   14077       935161 :                         if (Util::SameString(curObj, uniqueObj(jUnique))) {
   14078        54671 :                             foundObj = jUnique;
   14079        54671 :                             break;
   14080              :                         }
   14081              :                     }
   14082              :                     // if not found add to the list
   14083        73816 :                     if (foundObj == 0) {
   14084        19145 :                         ++numUniqueObj;
   14085        19145 :                         uniqueObj(numUniqueObj) = curObj;
   14086              :                     }
   14087              :                 }
   14088              :             }
   14089              :             // make sure the table has at least one row and columns
   14090         5885 :             if (numUniqueDesc == 0) {
   14091            0 :                 numUniqueDesc = 1;
   14092              :             }
   14093         5885 :             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         5885 :             rowHead.allocate(numUniqueObj);
   14099         5885 :             columnHead.allocate(numUniqueDesc);
   14100         5885 :             columnWidth.dimension(numUniqueDesc, 14); // array assignment - same for all columns
   14101         5885 :             colUnitConv.allocate(numUniqueDesc);
   14102         5885 :             tableBody.allocate(numUniqueDesc, numUniqueObj);
   14103              :             // initialize table body to blanks (in case entries are incomplete)
   14104         5885 :             tableBody = "";
   14105              :             // transfer the row and column headings first
   14106        27572 :             for (jUnique = 1; jUnique <= numUniqueDesc; ++jUnique) {
   14107              :                 // do the unit conversions
   14108        21687 :                 state.dataOutRptTab->curColHeadWithSI = uniqueDesc(jUnique);
   14109        21687 :                 if (unitsStyle_cur == UnitsStyle::InchPound) {
   14110          362 :                     LookupSItoIP(
   14111          362 :                         state, state.dataOutRptTab->curColHeadWithSI, state.dataOutRptTab->indexUnitConvWCS, state.dataOutRptTab->curColHead);
   14112          362 :                     colUnitConv(jUnique) = state.dataOutRptTab->indexUnitConvWCS;
   14113        21325 :                 } 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        21325 :                     state.dataOutRptTab->curColHead = state.dataOutRptTab->curColHeadWithSI;
   14119        21325 :                     colUnitConv(jUnique) = 0;
   14120              :                 }
   14121        21687 :                 columnHead(jUnique) = state.dataOutRptTab->curColHead;
   14122              :             }
   14123        25030 :             for (jUnique = 1; jUnique <= numUniqueObj; ++jUnique) {
   14124        19145 :                 rowHead(jUnique) = uniqueObj(jUnique);
   14125              :             }
   14126              :             // fill the table
   14127      1012572 :             for (iTableEntry = 1; iTableEntry <= state.dataOutRptPredefined->numCompSizeTableEntry; ++iTableEntry) {
   14128              :                 // find the row and column for the specific entry
   14129      1006687 :                 if (state.dataOutRptPredefined->CompSizeTableEntry(iTableEntry).active) {
   14130        73816 :                     curDesc = state.dataOutRptPredefined->CompSizeTableEntry(iTableEntry).description;
   14131        73816 :                     foundDesc = 0;
   14132       268112 :                     for (jUnique = 1; jUnique <= numUniqueDesc; ++jUnique) {
   14133       268112 :                         if (Util::SameString(uniqueDesc(jUnique), curDesc)) {
   14134        73816 :                             foundDesc = jUnique;
   14135        73816 :                             break;
   14136              :                         }
   14137              :                     }
   14138        73816 :                     curObj = state.dataOutRptPredefined->CompSizeTableEntry(iTableEntry).nameField;
   14139        73816 :                     foundObj = 0;
   14140       954306 :                     for (jUnique = 1; jUnique <= numUniqueObj; ++jUnique) {
   14141       954306 :                         if (Util::SameString(rowHead(jUnique), curObj)) {
   14142        73816 :                             foundObj = jUnique;
   14143        73816 :                             break;
   14144              :                         }
   14145              :                     }
   14146        73816 :                     if ((foundDesc >= 1) && (foundObj >= 1)) {
   14147        73816 :                         state.dataOutRptTab->curValueSIWCS = state.dataOutRptPredefined->CompSizeTableEntry(iTableEntry).valField;
   14148        73816 :                         if (unitsStyle_cur == UnitsStyle::InchPound) {
   14149          639 :                             if (colUnitConv(foundDesc) != 0) {
   14150          567 :                                 state.dataOutRptTab->curValueWCS = ConvertIP(state, colUnitConv(foundDesc), state.dataOutRptTab->curValueSIWCS);
   14151              :                             } else {
   14152           72 :                                 state.dataOutRptTab->curValueWCS = state.dataOutRptTab->curValueSIWCS;
   14153              :                             }
   14154        73177 :                         } 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        73177 :                             state.dataOutRptTab->curValueWCS = state.dataOutRptTab->curValueSIWCS;
   14162              :                         }
   14163        73816 :                         if (std::abs(state.dataOutRptTab->curValueWCS) >= 1.0) {
   14164        32537 :                             tableBody(foundDesc, foundObj) = RealToStr(state.dataOutRptTab->curValueWCS, 2);
   14165              :                         } else {
   14166        41279 :                             tableBody(foundDesc, foundObj) = RealToStr(state.dataOutRptTab->curValueWCS, 6);
   14167              :                         }
   14168        73816 :                         state.dataOutRptPredefined->CompSizeTableEntry(iTableEntry).written = true;
   14169              :                     }
   14170              :                 }
   14171              :             }
   14172              :             // write the table
   14173         5885 :             if (produceTabular) {
   14174         5885 :                 WriteSubtitle(state, state.dataOutRptPredefined->CompSizeTableEntry(foundEntry).typeField);
   14175              :             }
   14176              : 
   14177        11564 :             if (state.dataOutRptPredefined->CompSizeTableEntry(foundEntry).typeField == "AirTerminal:SingleDuct:VAV:Reheat" ||
   14178         5679 :                 state.dataOutRptPredefined->CompSizeTableEntry(foundEntry).typeField == "AirTerminal:SingleDuct:VAV:NoReheat") {
   14179          235 :                 if (produceTabular) {
   14180          235 :                     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         5650 :                 if (produceTabular) {
   14192         5650 :                     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         5885 :             if (produceSQLite) {
   14203         5885 :                 if (state.dataSQLiteProcedures->sqlite) {
   14204         2194 :                     state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
   14205              :                         tableBody,
   14206              :                         rowHead,
   14207              :                         columnHead,
   14208              :                         "ComponentSizingSummary",
   14209              :                         "Entire Facility",
   14210         1097 :                         state.dataOutRptPredefined->CompSizeTableEntry(foundEntry).typeField);
   14211              :                 }
   14212              :             }
   14213         5885 :             if (produceTabular) {
   14214         5885 :                 if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
   14215          609 :                     state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(
   14216              :                         tableBody,
   14217              :                         rowHead,
   14218              :                         columnHead,
   14219              :                         "ComponentSizingSummary",
   14220              :                         "Entire Facility",
   14221           87 :                         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          737 : }
   14228              : 
   14229          759 : 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          759 :     auto const &ort = state.dataOutRptTab;
   14249              : 
   14250              :     // displaySurfaceShadowing = false  for debugging
   14251          759 :     if (!ort->displaySurfaceShadowing) {
   14252           82 :         return;
   14253              :     }
   14254              : 
   14255              :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
   14256              :     // all arrays are in the format: (row, column)
   14257          677 :     Array1D_string columnHead(1);
   14258          677 :     Array1D_int columnWidth(1);
   14259          677 :     Array1D_string rowHead;
   14260          677 :     Array2D_string tableBody;
   14261          677 :     Array1D_int unique;
   14262              : 
   14263          677 :     int numreceivingfields = 0;
   14264        33779 :     for (int HTS = 1; HTS <= state.dataSurface->TotSurfaces; ++HTS) {
   14265        33102 :         numreceivingfields += state.dataShadowComb->ShadowComb(HTS).NumGenSurf;
   14266        33102 :         numreceivingfields += state.dataShadowComb->ShadowComb(HTS).NumSubSurf;
   14267              :     }
   14268              : 
   14269          677 :     state.dataOutRptPredefined->ShadowRelate.allocate(numreceivingfields);
   14270          677 :     state.dataOutRptPredefined->numShadowRelate = 0;
   14271        33779 :     for (int HTS = 1; HTS <= state.dataSurface->TotSurfaces; ++HTS) {
   14272        57795 :         for (int NGSS = 1; NGSS <= state.dataShadowComb->ShadowComb(HTS).NumGenSurf; ++NGSS) {
   14273        24693 :             ++state.dataOutRptPredefined->numShadowRelate;
   14274        24693 :             state.dataOutRptPredefined->ShadowRelate(state.dataOutRptPredefined->numShadowRelate).castSurf =
   14275        24693 :                 state.dataShadowComb->ShadowComb(HTS).GenSurf(NGSS);
   14276        24693 :             state.dataOutRptPredefined->ShadowRelate(state.dataOutRptPredefined->numShadowRelate).recSurf = HTS;
   14277        24693 :             state.dataOutRptPredefined->ShadowRelate(state.dataOutRptPredefined->numShadowRelate).recKind = recKindSurface;
   14278              :         }
   14279        37810 :         for (int NGSS = 1; NGSS <= state.dataShadowComb->ShadowComb(HTS).NumSubSurf; ++NGSS) {
   14280         4708 :             ++state.dataOutRptPredefined->numShadowRelate;
   14281         4708 :             state.dataOutRptPredefined->ShadowRelate(state.dataOutRptPredefined->numShadowRelate).castSurf =
   14282         4708 :                 state.dataShadowComb->ShadowComb(HTS).SubSurf(NGSS);
   14283         4708 :             state.dataOutRptPredefined->ShadowRelate(state.dataOutRptPredefined->numShadowRelate).recSurf = HTS;
   14284         4708 :             state.dataOutRptPredefined->ShadowRelate(state.dataOutRptPredefined->numShadowRelate).recKind = recKindSubsurface;
   14285              :         }
   14286              :     }
   14287          677 :     assert(numreceivingfields == state.dataOutRptPredefined->numShadowRelate);
   14288              : 
   14289         2031 :     WriteReportHeaders(state, "Surface Shadowing Summary", "Entire Facility", OutputProcessor::StoreType::Average);
   14290          677 :     unique.allocate(state.dataOutRptPredefined->numShadowRelate);
   14291              :     // do entire process twice, once with surfaces receiving, once with subsurfaces receiving
   14292         2031 :     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         1354 :         ShadowMap shadow_map;
   14297        60156 :         for (int iShadRel = 1; iShadRel <= state.dataOutRptPredefined->numShadowRelate; ++iShadRel) {
   14298        58802 :             if (state.dataOutRptPredefined->ShadowRelate(iShadRel).recKind == iKindRec) {
   14299        29401 :                 int const curRecSurf = state.dataOutRptPredefined->ShadowRelate(iShadRel).recSurf;
   14300        29401 :                 std::string const &name(state.dataSurface->Surface(state.dataOutRptPredefined->ShadowRelate(iShadRel).castSurf).Name);
   14301        29401 :                 auto &elem(shadow_map[curRecSurf]);            // Creates the entry if not present (and zero-initializes the int in the pair)
   14302        29401 :                 elem.first += static_cast<int>(name.length()); // Accumulate total of name lengths
   14303        29401 :                 elem.second.push_back(&name);                  // Add this name
   14304              :             }
   14305              :         }
   14306         1354 :         int const numUnique = static_cast<int>(shadow_map.size());
   14307         1354 :         if (numUnique == 0) {
   14308          266 :             columnHead(1) = "None";
   14309              :         } else {
   14310         1088 :             columnHead(1) = "Possible Shadow Receivers";
   14311              :         }
   14312         1354 :         columnWidth = 14; // array assignment - same for all columns
   14313         1354 :         rowHead.allocate(numUnique);
   14314         1354 :         tableBody.allocate(1, numUnique);
   14315         1354 :         int jUnique = 0;
   14316         7976 :         for (auto const &elem : shadow_map) {
   14317         6622 :             ++jUnique;
   14318         6622 :             int const curRecSurf = elem.first;
   14319         6622 :             rowHead(jUnique) = state.dataSurface->Surface(curRecSurf).Name;
   14320              : 
   14321         6622 :             std::string listOfSurf;
   14322         6622 :             listOfSurf.reserve(elem.second.first + (3 * numUnique)); // To avoid string allocations during appends
   14323        36023 :             for (auto const *p : elem.second.second) {
   14324        29401 :                 listOfSurf += *p;
   14325        29401 :                 listOfSurf += " | "; //'<br>' // Separate append to avoid string temporary
   14326         6622 :             }
   14327         6622 :             tableBody(1, jUnique) = listOfSurf;
   14328         7976 :         }
   14329              : 
   14330              :         // write the table
   14331         1354 :         if (iKindRec == recKindSurface) {
   14332          677 :             WriteSubtitle(state, "Surfaces (Walls, Roofs, etc) that may be Shadowed by Other Surfaces");
   14333          677 :             if (state.dataSQLiteProcedures->sqlite) {
   14334           75 :                 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          677 :             if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
   14343           56 :                 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          677 :         } else if (iKindRec == recKindSubsurface) {
   14352          677 :             WriteSubtitle(state, "Subsurfaces (Windows and Doors) that may be Shadowed by Surfaces");
   14353          677 :             if (state.dataSQLiteProcedures->sqlite) {
   14354           75 :                 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          677 :             if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
   14363           56 :                 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         1354 :         WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
   14373         1354 :     }
   14374          677 : }
   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          759 : void WriteEioTables(EnergyPlusData &state)
   14379              : {
   14380              : 
   14381          759 :     auto const &ort = state.dataOutRptTab;
   14382              : 
   14383          759 :     if (!ort->displayEioSummary) {
   14384           81 :         return;
   14385              :     }
   14386              : 
   14387          678 :     Array1D_string columnHead;
   14388          678 :     Array1D_int columnWidth;
   14389          678 :     Array1D_string rowHead;
   14390          678 :     Array2D_string tableBody; // in the format: (row, column)
   14391          678 :     Array1D_int colUnitConv;
   14392              : 
   14393              :     // setting up  report header
   14394         2034 :     WriteReportHeaders(state, "Initialization Summary", "Entire Facility", OutputProcessor::StoreType::Average);
   14395              : 
   14396          678 :     std::vector<std::string> headerLines; // holds the lines that describe each type of records - each starts with ! symbol
   14397          678 :     std::vector<std::string> bodyLines;   // holds the data records only
   14398       225499 :     for (auto const &line : state.files.eio.getLines()) {
   14399       224821 :         if (line.at(0) == '!') {
   14400        38360 :             headerLines.push_back(line);
   14401              :         } else {
   14402       186461 :             if (line.at(0) == ' ') {
   14403       131948 :                 bodyLines.push_back(line.substr(1)); // remove leading space
   14404              :             } else {
   14405        54513 :                 bodyLines.push_back(line);
   14406              :             }
   14407              :         }
   14408          678 :     }
   14409              : 
   14410         1356 :     for (int iUnitSystem = 0; iUnitSystem <= 1; iUnitSystem++) {
   14411         1356 :         UnitsStyle unitsStyle_cur = ort->unitsStyle;
   14412         1356 :         bool produceTabular = true;
   14413         1356 :         bool produceSQLite = false;
   14414         1356 :         if (produceDualUnitsFlags(iUnitSystem, ort->unitsStyle, ort->unitsStyle_SQLite, unitsStyle_cur, produceTabular, produceSQLite)) {
   14415          678 :             break;
   14416              :         }
   14417              : 
   14418              :         // now go through each header and create a report for each one
   14419        39038 :         for (std::string const &headerLine : headerLines) {
   14420        38360 :             std::vector<std::string> headerFields = splitCommaString(headerLine);
   14421        38360 :             std::string tableNameWithSigns = headerFields.at(0);
   14422              :             std::string tableName =
   14423        38360 :                 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        38360 :             int countOfMatchingLines = 0;
   14426     12215386 :             for (std::string const &bodyLine : bodyLines) {
   14427     12177026 :                 if (bodyLine.size() > tableName.size()) {
   14428     11884482 :                     if (bodyLine.substr(0, tableName.size() + 1) ==
   14429     23768964 :                         tableName + ",") { // this needs to match the test used to populate the body of table below
   14430       184630 :                         ++countOfMatchingLines;
   14431              :                     }
   14432              :                 }
   14433        38360 :             }
   14434        38360 :             int numRows = countOfMatchingLines;
   14435        38360 :             int numCols = headerFields.size() - 1;
   14436              : 
   14437        38360 :             if (numRows >= 1) {
   14438        36942 :                 rowHead.allocate(numRows);
   14439        36942 :                 columnHead.allocate(numCols);
   14440        36942 :                 columnWidth.allocate(numCols);
   14441        36942 :                 columnWidth = 14; // array assignment - same for all columns
   14442        36942 :                 tableBody.allocate(numCols, numRows);
   14443        36942 :                 tableBody = ""; // make sure everything is blank
   14444        36942 :                 colUnitConv.allocate(numCols);
   14445              :                 // transfer the header row into column headings
   14446       312917 :                 for (int iCol = 1; iCol <= numCols; ++iCol) {
   14447       275975 :                     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       275975 :                     colUnitConv(iCol) = unitsFromHeading(state, columnHead(iCol), unitsStyle_cur);
   14452              :                 }
   14453              :                 // look for data lines
   14454        36942 :                 int rowNum = 0;
   14455     11519389 :                 for (std::string const &bodyLine : bodyLines) {
   14456     11482447 :                     if (bodyLine.size() > tableName.size()) {
   14457     11196485 :                         if (bodyLine.substr(0, tableName.size() + 1) ==
   14458     22392970 :                             tableName + ",") { // this needs to match the test used in the original counting
   14459       184630 :                             ++rowNum;
   14460       184630 :                             if (rowNum > countOfMatchingLines) {
   14461            0 :                                 break; // should never happen since same test as original could
   14462              :                             }
   14463       184630 :                             std::vector<std::string> dataFields = splitCommaString(bodyLine);
   14464       184630 :                             rowHead(rowNum) = fmt::to_string(rowNum);
   14465      2029918 :                             for (int iCol = 1; iCol <= numCols && iCol < int(dataFields.size()); ++iCol) {
   14466      1845288 :                                 if (unitsStyle_cur == OutputReportTabular::UnitsStyle::InchPound ||
   14467      1826700 :                                     unitsStyle_cur == OutputReportTabular::UnitsStyle::InchPoundExceptElectricity ||
   14468      1826700 :                                     unitsStyle_cur == UnitsStyle::JtoKWH) {
   14469        28400 :                                     if (isNumber(dataFields[iCol]) && colUnitConv(iCol) > 0) { // if it is a number that has a conversion
   14470         6312 :                                         int numDecimalDigits = digitsAferDecimal(dataFields[iCol]);
   14471         6312 :                                         Real64 convertedVal = ConvertIP(state, colUnitConv(iCol), StrToReal(dataFields[iCol]));
   14472         6312 :                                         tableBody(iCol, rowNum) = RealToStr(convertedVal, numDecimalDigits);
   14473        22088 :                                     } 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         1138 :                                             unitsFromHeading(state, tableBody(iCol - 1, rowNum), unitsStyle_cur); // base units on previous column
   14481              : 
   14482         1138 :                                         int numDecimalDigits = digitsAferDecimal(dataFields[iCol]);
   14483         1138 :                                         Real64 convertedVal = ConvertIP(state, indexUnitConv, StrToReal(dataFields[iCol]));
   14484         1138 :                                         tableBody(iCol, rowNum) = RealToStr(convertedVal, numDecimalDigits);
   14485              :                                     } else {
   14486        20950 :                                         tableBody(iCol, rowNum) = dataFields[iCol];
   14487              :                                     }
   14488        28400 :                                 } else {
   14489      1816888 :                                     tableBody(iCol, rowNum) = dataFields[iCol];
   14490              :                                 }
   14491              :                             }
   14492       184630 :                         }
   14493              :                     }
   14494        36942 :                 }
   14495              : 
   14496        36942 :                 if (produceTabular) {
   14497        36942 :                     WriteSubtitle(state, tableName);
   14498        36942 :                     std::string footnote;
   14499        36942 :                     WriteTable(state, tableBody, rowHead, columnHead, columnWidth, false, footnote);
   14500        36942 :                     if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
   14501         1125 :                         state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(
   14502              :                             tableBody, rowHead, columnHead, "InitializationSummary", "Entire Facility", tableName);
   14503              :                     }
   14504        36942 :                 }
   14505        36942 :                 if (produceSQLite) {
   14506        36942 :                     if (state.dataSQLiteProcedures->sqlite) {
   14507         4012 :                         state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
   14508              :                             tableBody, rowHead, columnHead, "InitializationSummary", "Entire Facility", tableName);
   14509              :                     }
   14510              :                 }
   14511              :             }
   14512        39038 :         }
   14513              :     }
   14514              : 
   14515              :     // as of Oct 2016 only the <Program Control Information:Threads/Parallel Sims> section is written after this point
   14516          678 : }
   14517              : 
   14518              : // changes the heading that contains and SI to IP as well as providing the unit conversion index
   14519              : // Glazer Nov 2016
   14520            0 : int unitsFromHeading(EnergyPlusData &state, std::string &heading)
   14521              : {
   14522            0 :     auto const &ort = state.dataOutRptTab;
   14523              : 
   14524            0 :     std::string curHeading;
   14525            0 :     int unitConv = 0;
   14526            0 :     if (ort->unitsStyle == UnitsStyle::InchPound) {
   14527            0 :         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            0 :     heading = curHeading;
   14536            0 :     return (unitConv);
   14537            0 : }
   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       277113 : int unitsFromHeading(EnergyPlusData &state, std::string &heading, UnitsStyle unitsStyle_para)
   14543              : {
   14544       277113 :     std::string curHeading = "";
   14545       277113 :     int unitConv = 0;
   14546       277113 :     if (unitsStyle_para == UnitsStyle::InchPound) {
   14547         5092 :         LookupSItoIP(state, heading, unitConv, curHeading);
   14548       272021 :     } else if (unitsStyle_para == UnitsStyle::InchPoundExceptElectricity) {
   14549            0 :         LookupSItoIP(state, heading, unitConv, curHeading);
   14550       272021 :     } else if (unitsStyle_para == UnitsStyle::JtoKWH) {
   14551         3063 :         LookupJtokWH(state, heading, unitConv, curHeading);
   14552              :     } else {
   14553       268958 :         curHeading = heading;
   14554              :     }
   14555       277113 :     heading = curHeading;
   14556       277113 :     return (unitConv);
   14557       277113 : }
   14558              : 
   14559              : // function that returns a vector of strings when given a string with comma delimiters
   14560              : // Glazer Nov 2016
   14561       222990 : std::vector<std::string> splitCommaString(std::string const &inputString)
   14562              : {
   14563       222990 :     std::vector<std::string> fields;
   14564       222990 :     std::string field;
   14565       222990 :     std::stringstream inputSS(inputString);
   14566      2596209 :     while (std::getline(inputSS, field, ',')) {
   14567      2373219 :         fields.push_back(stripped(field));
   14568              :     }
   14569       445980 :     return fields;
   14570       222990 : }
   14571              : 
   14572          799 : 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          799 :     auto const &ort = state.dataOutRptTab;
   14588              : 
   14589          799 :     if (state.dataGlobal->CompLoadReportIsReq) {
   14590           27 :         if (ort->displayZoneComponentLoadSummary) {
   14591           27 :             if (state.dataHeatBal->doSpaceHeatBalanceSizing) {
   14592           14 :                 for (int iSpace = 1; iSpace <= state.dataGlobal->NumOfZones; ++iSpace) {
   14593           12 :                     if (!state.dataZoneEquip->ZoneEquipConfig(state.dataHeatBal->space(iSpace).zoneNum).IsControlled) {
   14594            1 :                         continue;
   14595              :                     }
   14596           33 :                     AddTOCEntry(state, "Space Component Load Summary", state.dataHeatBal->space(iSpace).Name);
   14597              :                 }
   14598              :             }
   14599          242 :             for (int iZone = 1; iZone <= state.dataGlobal->NumOfZones; ++iZone) {
   14600          215 :                 if (!state.dataZoneEquip->ZoneEquipConfig(iZone).IsControlled) {
   14601           30 :                     continue;
   14602              :                 }
   14603          555 :                 AddTOCEntry(state, "Zone Component Load Summary", state.dataHeatBal->Zone(iZone).Name);
   14604              :             }
   14605              :         }
   14606           27 :         if (ort->displayAirLoopComponentLoadSummary) {
   14607            4 :             for (int AirLoopNum = 1; AirLoopNum <= state.dataHVACGlobal->NumPrimaryAirSys; ++AirLoopNum) {
   14608            6 :                 AddTOCEntry(state, "AirLoop Component Load Summary", state.dataSize->FinalSysSizing(AirLoopNum).AirPriLoopName);
   14609              :             }
   14610              :         }
   14611           27 :         if (ort->displayFacilityComponentLoadSummary) {
   14612            8 :             AddTOCEntry(state, "Facility Component Load Summary", "Facility");
   14613              :         }
   14614              :     }
   14615          799 : }
   14616              : 
   14617       178743 : 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       178743 :     auto const &ort = state.dataOutRptTab;
   14627              : 
   14628       178743 :     if (!ort->AllocateLoadComponentArraysDoAllocate) {
   14629       178716 :         return;
   14630              :     }
   14631              : 
   14632           27 :     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           27 :     ort->radiantPulseTimestep.allocate({0, state.dataEnvrn->TotDesDays + state.dataEnvrn->TotRunDesPersDays}, state.dataGlobal->NumOfZones);
   14636           27 :     ort->radiantPulseTimestep = 0;
   14637           27 :     ort->radiantPulseReceived.allocate({0, state.dataEnvrn->TotDesDays + state.dataEnvrn->TotRunDesPersDays}, state.dataSurface->TotSurfaces);
   14638           27 :     ort->radiantPulseReceived = 0.0;
   14639           27 :     ort->decayCurveCool.allocate(timeStepsInDay, state.dataSurface->TotSurfaces);
   14640           27 :     ort->decayCurveCool = 0.0;
   14641           27 :     ort->decayCurveHeat.allocate(timeStepsInDay, state.dataSurface->TotSurfaces);
   14642           27 :     ort->decayCurveHeat = 0.0;
   14643              : 
   14644           27 :     Real64 const numTSinDay = state.dataGlobal->TimeStepsInHour * Constant::rHoursInDay;
   14645              : 
   14646           27 :     ort->surfCompLoads.resize(state.dataEnvrn->TotDesDays + state.dataEnvrn->TotRunDesPersDays);
   14647           81 :     for (auto &day : ort->surfCompLoads) {
   14648           54 :         day.ts.resize(numTSinDay);
   14649         5238 :         for (auto &ts : day.ts) {
   14650         5184 :             ts.surf.resize(state.dataSurface->TotSurfaces);
   14651           54 :         }
   14652           27 :     }
   14653              : 
   14654           27 :     ort->enclCompLoads.resize(state.dataEnvrn->TotDesDays + state.dataEnvrn->TotRunDesPersDays);
   14655           81 :     for (auto &day : ort->enclCompLoads) {
   14656           54 :         day.ts.resize(numTSinDay);
   14657         5238 :         for (auto &ts : day.ts) {
   14658         5184 :             ts.encl.resize(state.dataViewFactor->NumOfRadiantEnclosures);
   14659           54 :         }
   14660           27 :     }
   14661              : 
   14662           27 :     ort->znCompLoads.resize(state.dataEnvrn->TotDesDays + state.dataEnvrn->TotRunDesPersDays);
   14663           81 :     for (auto &day : ort->znCompLoads) {
   14664           54 :         day.ts.resize(numTSinDay);
   14665         5238 :         for (auto &ts : day.ts) {
   14666         5184 :             ts.spacezone.resize(state.dataGlobal->NumOfZones);
   14667           54 :         }
   14668           27 :     }
   14669           27 :     if (state.dataHeatBal->doSpaceHeatBalanceSizing) {
   14670            2 :         ort->spCompLoads.resize(state.dataEnvrn->TotDesDays + state.dataEnvrn->TotRunDesPersDays);
   14671            6 :         for (auto &day : ort->spCompLoads) {
   14672            4 :             day.ts.resize(numTSinDay);
   14673          388 :             for (auto &ts : day.ts) {
   14674          384 :                 ts.spacezone.resize(state.dataGlobal->numSpaces);
   14675            4 :             }
   14676            2 :         }
   14677              :     }
   14678              : 
   14679           27 :     ort->AllocateLoadComponentArraysDoAllocate = false;
   14680              : }
   14681              : 
   14682           27 : 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           27 :     auto const &ort = state.dataOutRptTab;
   14693           27 :     ort->radiantPulseTimestep.deallocate();
   14694           27 :     ort->radiantPulseReceived.deallocate();
   14695           27 : }
   14696              : 
   14697           27 : 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           27 :     auto const &ort = state.dataOutRptTab;
   14713              : 
   14714         1913 :     for (int surfNum = 1; surfNum <= state.dataSurface->TotSurfaces; ++surfNum) {
   14715         1886 :         int const zoneNum = state.dataSurface->Surface(surfNum).Zone;
   14716         1886 :         if (zoneNum == 0) {
   14717          104 :             continue;
   14718              :         }
   14719         1782 :         if (!state.dataZoneEquip->ZoneEquipConfig(zoneNum).IsControlled) {
   14720          417 :             continue;
   14721              :         }
   14722         1365 :         int const spaceNum = state.dataSurface->Surface(surfNum).spaceNum;
   14723         1365 :         int coolDesSelected = state.dataSize->CalcFinalZoneSizing(zoneNum).CoolDDNum;
   14724              :         // loop over timesteps after pulse occurred
   14725         1365 :         if (coolDesSelected != 0) {
   14726         1365 :             auto &surfCLClDay = ort->surfCompLoads[coolDesSelected - 1];
   14727         1365 :             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         1365 :             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         1365 :             if (timeOfPulse == 0) {
   14740            0 :                 timeOfPulse = 1;
   14741              :             }
   14742        83265 :             for (int timeStep = timeOfPulse; timeStep <= state.dataGlobal->TimeStepsInHour * Constant::rHoursInDay; ++timeStep) {
   14743        81900 :                 if (ort->radiantPulseReceived(coolDesSelected, surfNum) != 0.0) {
   14744        80820 :                     auto &surfClDayTS = surfCLClDay.ts[timeStep - 1].surf[surfNum - 1];
   14745        80820 :                     diff = surfClDayTS.loadConvectedWithPulse - surfClDayTS.loadConvectedNormal;
   14746        80820 :                     ort->decayCurveCool(timeStep - timeOfPulse + 1, surfNum) = -diff / ort->radiantPulseReceived(coolDesSelected, surfNum);
   14747              :                 } else {
   14748         1080 :                     ort->decayCurveCool(timeStep - timeOfPulse + 1, surfNum) = 0.0;
   14749              :                 }
   14750              :             }
   14751              :         }
   14752         1365 :         int const heatDesSelected = state.dataSize->CalcFinalZoneSizing(zoneNum).HeatDDNum;
   14753         1365 :         if (heatDesSelected != 0) {
   14754         1365 :             auto &surfCLHtDay = ort->surfCompLoads[heatDesSelected - 1];
   14755         1365 :             int timeOfPulse = ort->radiantPulseTimestep(heatDesSelected, zoneNum);
   14756              :             // scan back to the day that the heating pulse occurs, if necessary
   14757         1365 :             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         1365 :             if (timeOfPulse == 0) {
   14766            0 :                 timeOfPulse = 1;
   14767              :             }
   14768        83265 :             for (int timeStep = timeOfPulse; timeStep <= state.dataGlobal->TimeStepsInHour * Constant::rHoursInDay; ++timeStep) {
   14769        81900 :                 if (ort->radiantPulseReceived(heatDesSelected, surfNum) != 0.0) {
   14770        80820 :                     auto &surfHtDayTS = surfCLHtDay.ts[timeStep - 1].surf[surfNum - 1];
   14771        80820 :                     diff = surfHtDayTS.loadConvectedWithPulse - surfHtDayTS.loadConvectedNormal;
   14772        80820 :                     ort->decayCurveHeat(timeStep - timeOfPulse + 1, surfNum) = -diff / ort->radiantPulseReceived(heatDesSelected, surfNum);
   14773              :                 } else {
   14774         1080 :                     ort->decayCurveHeat(timeStep - timeOfPulse + 1, surfNum) = 0.0;
   14775              :                 }
   14776              :             }
   14777              :         }
   14778              :     }
   14779              : 
   14780           27 :     if (state.dataGlobal->ShowDecayCurvesInEIO) {
   14781              :         // show the line definition for the decay curves
   14782            8 :         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            8 :         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           56 :         for (int iZone = 1; iZone <= state.dataGlobal->NumOfZones; ++iZone) {
   14790           48 :             auto &thisZone = state.dataHeatBal->Zone(iZone);
   14791         2814 :             for (int kSurf : state.dataSurface->AllSurfaceListReportOrder) {
   14792         2766 :                 if (state.dataSurface->Surface(kSurf).Zone != iZone) {
   14793         2337 :                     continue;
   14794              :                 }
   14795          429 :                 print(state.files.eio,
   14796              :                       "{},{},{}",
   14797              :                       "Radiant to Convective Decay Curves for Cooling",
   14798          429 :                       thisZone.Name,
   14799          429 :                       state.dataSurface->Surface(kSurf).Name);
   14800        15873 :                 for (int jTime = 1; jTime <= min(int(state.dataGlobal->TimeStepsInHour * Constant::iHoursInDay), 36); ++jTime) {
   14801        15444 :                     print(state.files.eio, ",{:6.3F}", ort->decayCurveCool(jTime, kSurf));
   14802              :                 }
   14803              :                 // put a line feed at the end of the line
   14804          429 :                 print(state.files.eio, "\n");
   14805           48 :             }
   14806              : 
   14807         2814 :             for (int kSurf : state.dataSurface->AllSurfaceListReportOrder) {
   14808         2766 :                 if (state.dataSurface->Surface(kSurf).Zone != iZone) {
   14809         2337 :                     continue;
   14810              :                 }
   14811          429 :                 print(state.files.eio,
   14812              :                       "{},{},{}",
   14813              :                       "Radiant to Convective Decay Curves for Heating",
   14814          429 :                       thisZone.Name,
   14815          429 :                       state.dataSurface->Surface(kSurf).Name);
   14816        15873 :                 for (int jTime = 1; jTime <= min(int(state.dataGlobal->TimeStepsInHour * Constant::iHoursInDay), 36); ++jTime) {
   14817        15444 :                     print(state.files.eio, ",{:6.3F}", ort->decayCurveHeat(jTime, kSurf));
   14818              :                 }
   14819              :                 // put a line feed at the end of the line
   14820          429 :                 print(state.files.eio, "\n");
   14821           48 :             }
   14822              :         }
   14823              :     }
   14824           27 : }
   14825              : 
   14826       830322 : 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       830322 :     auto const &ort = state.dataOutRptTab;
   14840              : 
   14841       830322 :     if (state.dataGlobal->CompLoadReportIsReq && !state.dataGlobal->isPulseZoneSizing) {
   14842        36642 :         int timeStepInDayGCLS = (state.dataGlobal->HourOfDay - 1) * state.dataGlobal->TimeStepsInHour + state.dataGlobal->TimeStep;
   14843        36642 :         auto &znCLDayTS = ort->znCompLoads[state.dataSize->CurOverallSimDay - 1].ts[timeStepInDayGCLS - 1];
   14844       338220 :         for (auto &zone : znCLDayTS.spacezone) {
   14845       301578 :             zone.feneCondInstantSeq = 0.0;
   14846        36642 :         }
   14847        36642 :         if (state.dataHeatBal->doSpaceHeatBalanceSizing) {
   14848         2700 :             auto &spCLDayTS = ort->spCompLoads[state.dataSize->CurOverallSimDay - 1].ts[timeStepInDayGCLS - 1];
   14849        24300 :             for (auto &space : spCLDayTS.spacezone) {
   14850        21600 :                 space.feneCondInstantSeq = 0.0;
   14851         2700 :             }
   14852              :         }
   14853      2683542 :         for (int iSurfGCLS = 1; iSurfGCLS <= state.dataSurface->TotSurfaces; ++iSurfGCLS) {
   14854      2646900 :             int zoneNumGCLS = state.dataSurface->Surface(iSurfGCLS).Zone;
   14855      2646900 :             if (zoneNumGCLS == 0) {
   14856       140400 :                 continue;
   14857              :             }
   14858      2506500 :             if (state.dataSurface->Surface(iSurfGCLS).Class != DataSurfaces::SurfaceClass::Window) {
   14859      2228052 :                 continue;
   14860              :             }
   14861              :             // IF (.not. ZoneEquipConfig(ZoneNum)%IsControlled) CYCLE
   14862       278448 :             Real64 surfCond = state.dataSurface->SurfWinGainConvGlazToZoneRep(iSurfGCLS) + state.dataSurface->SurfWinConvHeatFlowNatural(iSurfGCLS) +
   14863       278448 :                               state.dataSurface->SurfWinGainConvShadeToZoneRep(iSurfGCLS) +
   14864       278448 :                               state.dataSurface->SurfWinGainFrameDividerToZoneRep(iSurfGCLS);
   14865       278448 :             znCLDayTS.spacezone[zoneNumGCLS - 1].feneCondInstantSeq += surfCond;
   14866              : 
   14867       278448 :             if (state.dataHeatBal->doSpaceHeatBalanceSizing) {
   14868        16200 :                 int spaceNum = state.dataSurface->Surface(iSurfGCLS).spaceNum;
   14869        16200 :                 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       338220 :         for (int izone = 1; izone <= state.dataGlobal->NumOfZones; ++izone) {
   14880       301578 :             Real64 tubularGain = 0.0;
   14881       301578 :             tubularGain = InternalHeatGains::SumInternalConvectionGainsByTypes(state, izone, OutputReportTabular::IntGainTypesTubularGCLS);
   14882       301578 :             znCLDayTS.spacezone[izone - 1].feneCondInstantSeq += tubularGain;
   14883              :         }
   14884        36642 :         if (state.dataHeatBal->doSpaceHeatBalanceSizing) {
   14885         2700 :             auto &spCLDayTS = ort->spCompLoads[state.dataSize->CurOverallSimDay - 1].ts[timeStepInDayGCLS - 1];
   14886        18900 :             for (int ispace = 1; ispace <= state.dataGlobal->NumOfZones; ++ispace) {
   14887        16200 :                 Real64 tubularGain = 0.0;
   14888        16200 :                 int zone = state.dataHeatBal->space(ispace).zoneNum;
   14889        16200 :                 tubularGain = InternalHeatGains::SumInternalConvectionGainsByTypes(state, zone, OutputReportTabular::IntGainTypesTubularGCLS, ispace);
   14890        16200 :                 spCLDayTS.spacezone[ispace - 1].feneCondInstantSeq += tubularGain;
   14891              :             }
   14892              :         }
   14893              :     }
   14894       830322 : }
   14895              : 
   14896        12032 : 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        12032 :     if (!(state.dataGlobal->CompLoadReportIsReq && !state.dataGlobal->isPulseZoneSizing)) {
   14909         6016 :         return;
   14910              :     }
   14911         6016 :     int timeStepInDayGCLH = (state.dataGlobal->HourOfDay - 1) * state.dataGlobal->TimeStepsInHour + state.dataGlobal->TimeStep;
   14912         6016 :     auto &znCompLoadDayTS = state.dataOutRptTab->znCompLoads[state.dataSize->CurOverallSimDay - 1].ts[timeStepInDayGCLH - 1];
   14913        55256 :     for (int iZoneGCLH = 1; iZoneGCLH <= state.dataGlobal->NumOfZones; ++iZoneGCLH) {
   14914        49240 :         auto &znCompLoadDayTSZone = znCompLoadDayTS.spacezone[iZoneGCLH - 1];
   14915        49240 :         auto &zoneAirRpt = state.dataHeatBal->ZnAirRpt(iZoneGCLH);
   14916        49240 :         gatherSpaceZoneCompLoadsHVAC(znCompLoadDayTSZone, zoneAirRpt, state.dataHVACGlobal->TimeStepSysSec);
   14917        49240 :         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         6016 :     if (state.dataHeatBal->doSpaceHeatBalanceSizing) {
   14933          449 :         auto &spCompLoadDayTS = state.dataOutRptTab->spCompLoads[state.dataSize->CurOverallSimDay - 1].ts[timeStepInDayGCLH - 1];
   14934         4091 :         for (int iSpace = 1; iSpace <= state.dataGlobal->numSpaces; ++iSpace) {
   14935         3642 :             auto &spCompLoadDayTSSpace = spCompLoadDayTS.spacezone[iSpace - 1];
   14936         3642 :             auto &spaceAirRpt = state.dataHeatBal->spaceAirRpt(iSpace);
   14937         3642 :             gatherSpaceZoneCompLoadsHVAC(spCompLoadDayTSSpace, spaceAirRpt, state.dataHVACGlobal->TimeStepSysSec);
   14938         3642 :             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        52882 : void gatherSpaceZoneCompLoadsHVAC(OutputReportTabular::compLoadsSpaceZone &szCompLoadDayTS,
   14953              :                                   DataHeatBalance::AirReportVars const &szAirRpt,
   14954              :                                   Real64 const timeStepSysSec)
   14955              : {
   14956        52882 :     szCompLoadDayTS.infilInstantSeq = ((szAirRpt.InfilHeatGain - szAirRpt.InfilHeatLoss) / timeStepSysSec);         // zone infiltration
   14957        52882 :     szCompLoadDayTS.infilLatentSeq = ((szAirRpt.InfilLatentGain - szAirRpt.InfilLatentLoss) / timeStepSysSec);      // zone infiltration
   14958        52882 :     szCompLoadDayTS.zoneVentInstantSeq = ((szAirRpt.VentilHeatGain - szAirRpt.VentilHeatLoss) / timeStepSysSec);    // zone ventilation
   14959        52882 :     szCompLoadDayTS.zoneVentLatentSeq = ((szAirRpt.VentilLatentGain - szAirRpt.VentilLatentLoss) / timeStepSysSec); // zone ventilation
   14960        52882 :     szCompLoadDayTS.interZoneMixInstantSeq = ((szAirRpt.MixHeatGain - szAirRpt.MixHeatLoss) / timeStepSysSec);      // zone mixing
   14961        52882 :     szCompLoadDayTS.interZoneMixLatentSeq = ((szAirRpt.MixLatentGain - szAirRpt.MixLatentLoss) / timeStepSysSec);   // zone mixing
   14962        52882 : }
   14963              : 
   14964          759 : 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          759 :     auto &ort = state.dataOutRptTab;
   15021          786 :     if (!((ort->displayZoneComponentLoadSummary || ort->displayAirLoopComponentLoadSummary || ort->displayFacilityComponentLoadSummary) &&
   15022           27 :           state.dataGlobal->CompLoadReportIsReq)) {
   15023          732 :         return;
   15024              :     }
   15025              : 
   15026           27 :     auto &NumPrimaryAirSys = state.dataHVACGlobal->NumPrimaryAirSys;
   15027              : 
   15028           27 :     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           27 :     Array1D<Real64> peopleDelaySeq;
   15038           27 :     Array1D<Real64> lightDelaySeq;
   15039           27 :     Array1D<Real64> equipDelaySeq;
   15040           27 :     Array1D<Real64> hvacLossDelaySeq;
   15041           27 :     Array1D<Real64> powerGenDelaySeq;
   15042           27 :     Array1D<Real64> feneSolarDelaySeq;
   15043           27 :     Array2D<Real64> surfDelaySeq;
   15044              : 
   15045           27 :     Array1D<CompLoadTablesType> SpaceHeatCompLoadTables; // for space level component load summary output tables
   15046           27 :     Array1D<CompLoadTablesType> SpaceCoolCompLoadTables;
   15047              : 
   15048           27 :     Array1D<CompLoadTablesType> ZoneHeatCompLoadTables; // for zone level component load summary output tables
   15049           27 :     Array1D<CompLoadTablesType> ZoneCoolCompLoadTables;
   15050              : 
   15051           27 :     Array1D<CompLoadTablesType> AirLoopHeatCompLoadTables; // for airloop level component load summary output tables
   15052           27 :     Array1D<CompLoadTablesType> AirLoopCoolCompLoadTables;
   15053           27 :     Array1D<CompLoadTablesType> AirLoopZonesHeatCompLoadTables; // zone results used for airloop report - never directly output
   15054           27 :     Array1D<CompLoadTablesType> AirLoopZonesCoolCompLoadTables;
   15055              : 
   15056           27 :     CompLoadTablesType FacilityHeatCompLoadTables; // for facility level component load summary output tables
   15057           27 :     CompLoadTablesType FacilityCoolCompLoadTables;
   15058           27 :     Array1D<CompLoadTablesType> FacilityZonesHeatCompLoadTables; // zone results used for facility report - never directly output
   15059           27 :     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           54 :     for (int iUnitSystem = 0; iUnitSystem <= 1; iUnitSystem++) {
   15065           54 :         UnitsStyle unitsStyle_cur = ort->unitsStyle;
   15066           54 :         bool produceTabular = true;
   15067           54 :         bool produceSQLite = false;
   15068           54 :         if (produceDualUnitsFlags(iUnitSystem, ort->unitsStyle, ort->unitsStyle_SQLite, unitsStyle_cur, produceTabular, produceSQLite)) {
   15069           27 :             break;
   15070              :         }
   15071              : 
   15072           27 :         Real64 timeStepsInDay = state.dataGlobal->TimeStepsInHour * Constant::rHoursInDay;
   15073              : 
   15074              :         // adjusted initialization location to after variable declaration for loops 2021-01-11
   15075           27 :         peopleDelaySeq.dimension(timeStepsInDay, 0.0);
   15076           27 :         peopleDelaySeq = 0.0;
   15077           27 :         lightDelaySeq.allocate(timeStepsInDay);
   15078           27 :         lightDelaySeq = 0.0;
   15079           27 :         equipDelaySeq.allocate(timeStepsInDay);
   15080           27 :         equipDelaySeq = 0.0;
   15081           27 :         hvacLossDelaySeq.allocate(timeStepsInDay);
   15082           27 :         hvacLossDelaySeq = 0.0;
   15083           27 :         powerGenDelaySeq.allocate(timeStepsInDay);
   15084           27 :         powerGenDelaySeq = 0.0;
   15085           27 :         feneSolarDelaySeq.allocate(timeStepsInDay);
   15086           27 :         feneSolarDelaySeq = 0.0;
   15087           27 :         surfDelaySeq.allocate(timeStepsInDay, state.dataSurface->TotSurfaces);
   15088           27 :         surfDelaySeq = 0.0;
   15089              : 
   15090              :         // initialize arrays
   15091           27 :         if (ort->displayZoneComponentLoadSummary) {
   15092           27 :             if (state.dataHeatBal->doSpaceHeatBalanceSizing) {
   15093            2 :                 SpaceHeatCompLoadTables.allocate(state.dataGlobal->numSpaces);
   15094           18 :                 for (auto &e : SpaceHeatCompLoadTables) {
   15095           16 :                     e.cells.allocate(LoadCompCol::PerArea, LoadCompRow::GrdTot);
   15096           16 :                     e.cells = 0.;
   15097           16 :                     e.cellUsed.allocate(LoadCompCol::PerArea, LoadCompRow::GrdTot);
   15098           16 :                     e.cellUsed = false;
   15099              :                 }
   15100            2 :                 SpaceCoolCompLoadTables.allocate(state.dataGlobal->numSpaces);
   15101           18 :                 for (auto &e : SpaceCoolCompLoadTables) {
   15102           16 :                     e.cells.allocate(LoadCompCol::PerArea, LoadCompRow::GrdTot);
   15103           16 :                     e.cells = 0.;
   15104           16 :                     e.cellUsed.allocate(LoadCompCol::PerArea, LoadCompRow::GrdTot);
   15105           16 :                     e.cellUsed = false;
   15106              :                 }
   15107              :             }
   15108           27 :             ZoneHeatCompLoadTables.allocate(state.dataGlobal->NumOfZones);
   15109          242 :             for (auto &e : ZoneHeatCompLoadTables) {
   15110          215 :                 e.cells.allocate(LoadCompCol::PerArea, LoadCompRow::GrdTot);
   15111          215 :                 e.cells = 0.;
   15112          215 :                 e.cellUsed.allocate(LoadCompCol::PerArea, LoadCompRow::GrdTot);
   15113          215 :                 e.cellUsed = false;
   15114              :             }
   15115           27 :             ZoneCoolCompLoadTables.allocate(state.dataGlobal->NumOfZones);
   15116          242 :             for (auto &e : ZoneCoolCompLoadTables) {
   15117          215 :                 e.cells.allocate(LoadCompCol::PerArea, LoadCompRow::GrdTot);
   15118          215 :                 e.cells = 0.;
   15119          215 :                 e.cellUsed.allocate(LoadCompCol::PerArea, LoadCompRow::GrdTot);
   15120          215 :                 e.cellUsed = false;
   15121              :             }
   15122              :         }
   15123           27 :         if (ort->displayAirLoopComponentLoadSummary) {
   15124            2 :             AirLoopHeatCompLoadTables.allocate(NumPrimaryAirSys);
   15125            4 :             for (auto &e : AirLoopHeatCompLoadTables) {
   15126            2 :                 e.cells.allocate(LoadCompCol::PerArea, LoadCompRow::GrdTot);
   15127            2 :                 e.cells = 0.;
   15128            2 :                 e.cellUsed.allocate(LoadCompCol::PerArea, LoadCompRow::GrdTot);
   15129            2 :                 e.cellUsed = false;
   15130            2 :                 e.zoneIndices.allocate(state.dataGlobal->NumOfZones); // only need to allocate this for the AirLoop
   15131            2 :                 e.zoneIndices = 0;
   15132              :             }
   15133            2 :             AirLoopCoolCompLoadTables.allocate(NumPrimaryAirSys);
   15134            4 :             for (auto &e : AirLoopCoolCompLoadTables) {
   15135            2 :                 e.cells.allocate(LoadCompCol::PerArea, LoadCompRow::GrdTot);
   15136            2 :                 e.cells = 0.;
   15137            2 :                 e.cellUsed.allocate(LoadCompCol::PerArea, LoadCompRow::GrdTot);
   15138            2 :                 e.cellUsed = false;
   15139            2 :                 e.zoneIndices.allocate(state.dataGlobal->NumOfZones); // only need to allocate this for the AirLoop
   15140            2 :                 e.zoneIndices = 0;
   15141              :             }
   15142            2 :             AirLoopZonesHeatCompLoadTables.allocate(state.dataGlobal->NumOfZones);
   15143           14 :             for (auto &e : AirLoopZonesHeatCompLoadTables) {
   15144           12 :                 e.cells.allocate(LoadCompCol::PerArea, LoadCompRow::GrdTot);
   15145           12 :                 e.cells = 0.;
   15146           12 :                 e.cellUsed.allocate(LoadCompCol::PerArea, LoadCompRow::GrdTot);
   15147           12 :                 e.cellUsed = false;
   15148              :             }
   15149            2 :             AirLoopZonesCoolCompLoadTables.allocate(state.dataGlobal->NumOfZones);
   15150           14 :             for (auto &e : AirLoopZonesCoolCompLoadTables) {
   15151           12 :                 e.cells.allocate(LoadCompCol::PerArea, LoadCompRow::GrdTot);
   15152           12 :                 e.cells = 0.;
   15153           12 :                 e.cellUsed.allocate(LoadCompCol::PerArea, LoadCompRow::GrdTot);
   15154           12 :                 e.cellUsed = false;
   15155              :             }
   15156              :         }
   15157           27 :         if (ort->displayFacilityComponentLoadSummary) {
   15158            2 :             FacilityHeatCompLoadTables.cells.allocate(LoadCompCol::PerArea, LoadCompRow::GrdTot);
   15159            2 :             FacilityHeatCompLoadTables.cells = 0.;
   15160            2 :             FacilityHeatCompLoadTables.cellUsed.allocate(LoadCompCol::PerArea, LoadCompRow::GrdTot);
   15161            2 :             FacilityHeatCompLoadTables.cellUsed = false;
   15162              : 
   15163            2 :             FacilityCoolCompLoadTables.cells.allocate(LoadCompCol::PerArea, LoadCompRow::GrdTot);
   15164            2 :             FacilityCoolCompLoadTables.cells = 0.;
   15165            2 :             FacilityCoolCompLoadTables.cellUsed.allocate(LoadCompCol::PerArea, LoadCompRow::GrdTot);
   15166            2 :             FacilityCoolCompLoadTables.cellUsed = false;
   15167              : 
   15168            2 :             FacilityZonesHeatCompLoadTables.allocate(state.dataGlobal->NumOfZones);
   15169           14 :             for (auto &e : FacilityZonesHeatCompLoadTables) {
   15170           12 :                 e.cells.allocate(LoadCompCol::PerArea, LoadCompRow::GrdTot);
   15171           12 :                 e.cells = 0.;
   15172           12 :                 e.cellUsed.allocate(LoadCompCol::PerArea, LoadCompRow::GrdTot);
   15173           12 :                 e.cellUsed = false;
   15174              :             }
   15175            2 :             FacilityZonesCoolCompLoadTables.allocate(state.dataGlobal->NumOfZones);
   15176           14 :             for (auto &e : FacilityZonesCoolCompLoadTables) {
   15177           12 :                 e.cells.allocate(LoadCompCol::PerArea, LoadCompRow::GrdTot);
   15178           12 :                 e.cells = 0.;
   15179           12 :                 e.cellUsed.allocate(LoadCompCol::PerArea, LoadCompRow::GrdTot);
   15180           12 :                 e.cellUsed = false;
   15181              :             }
   15182              :         }
   15183              : 
   15184              :         // get the zone areas needed later
   15185           27 :         Array1D<ZompComponentAreasType> spaceComponentAreas;
   15186           27 :         Array1D<ZompComponentAreasType> ZoneComponentAreas;
   15187           27 :         ZoneComponentAreas.allocate(state.dataGlobal->NumOfZones);
   15188           27 :         if (state.dataHeatBal->doSpaceHeatBalanceSizing) {
   15189            2 :             spaceComponentAreas.allocate(state.dataGlobal->numSpaces);
   15190              :         }
   15191           27 :         GetZoneComponentAreas(state, ZoneComponentAreas, spaceComponentAreas);
   15192              : 
   15193              :         // ZoneComponentLoadSummary
   15194           27 :         if (ort->displayZoneComponentLoadSummary) {
   15195           27 :             if (state.dataHeatBal->doSpaceHeatBalanceSizing) {
   15196           18 :                 for (int iSpace = 1; iSpace <= state.dataGlobal->numSpaces; ++iSpace) {
   15197              :                     // Yes, check if the zone is controlled, not the space for this
   15198           16 :                     int zoneNum = state.dataHeatBal->space(iSpace).zoneNum;
   15199           16 :                     if (!state.dataZoneEquip->ZoneEquipConfig(zoneNum).IsControlled) {
   15200            2 :                         continue;
   15201              :                     }
   15202           14 :                     if (allocated(state.dataSize->CalcFinalSpaceSizing)) {
   15203           28 :                         computeSpaceZoneCompLoads(state,
   15204           14 :                                                   state.dataSize->CalcFinalSpaceSizing(iSpace),
   15205              :                                                   SpaceCoolCompLoadTables(iSpace),
   15206              :                                                   SpaceHeatCompLoadTables(iSpace),
   15207              :                                                   peopleDelaySeq,
   15208              :                                                   equipDelaySeq,
   15209              :                                                   hvacLossDelaySeq,
   15210              :                                                   powerGenDelaySeq,
   15211              :                                                   lightDelaySeq,
   15212              :                                                   feneSolarDelaySeq,
   15213           14 :                                                   ort->spCompLoads,
   15214              :                                                   surfDelaySeq,
   15215              :                                                   spaceComponentAreas(iSpace),
   15216              :                                                   zoneNum,
   15217              :                                                   iSpace);
   15218              :                     }
   15219              :                 }
   15220              :             }
   15221          242 :             for (int iZone = 1; iZone <= state.dataGlobal->NumOfZones; ++iZone) {
   15222          215 :                 if (!state.dataZoneEquip->ZoneEquipConfig(iZone).IsControlled) {
   15223           30 :                     continue;
   15224              :                 }
   15225          185 :                 if (allocated(state.dataSize->CalcFinalZoneSizing)) {
   15226          370 :                     computeSpaceZoneCompLoads(state,
   15227          185 :                                               state.dataSize->CalcFinalZoneSizing(iZone),
   15228              :                                               ZoneCoolCompLoadTables(iZone),
   15229              :                                               ZoneHeatCompLoadTables(iZone),
   15230              :                                               peopleDelaySeq,
   15231              :                                               equipDelaySeq,
   15232              :                                               hvacLossDelaySeq,
   15233              :                                               powerGenDelaySeq,
   15234              :                                               lightDelaySeq,
   15235              :                                               feneSolarDelaySeq,
   15236          185 :                                               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           27 :         if (ort->displayAirLoopComponentLoadSummary && NumPrimaryAirSys > 0) {
   15250            2 :             Array1D_int zoneToAirLoopCool;
   15251            2 :             zoneToAirLoopCool.dimension(state.dataGlobal->NumOfZones);
   15252            2 :             Array1D_int zoneToAirLoopHeat;
   15253            2 :             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            4 :             for (int iAirLoop = 1; iAirLoop <= NumPrimaryAirSys; ++iAirLoop) {
   15257            2 :                 auto const &finalSysSizing = state.dataSize->FinalSysSizing(iAirLoop);
   15258            2 :                 auto const &sysSizPeakDDNum = state.dataSize->SysSizPeakDDNum(iAirLoop);
   15259            2 :                 zoneToAirLoopCool = 0;
   15260            2 :                 zoneToAirLoopHeat = 0;
   15261            2 :                 if (finalSysSizing.loadSizingType == DataSizing::LoadSizing::Sensible) {
   15262            2 :                     coolDesSelected = sysSizPeakDDNum.SensCoolPeakDD;
   15263            2 :                     if (coolDesSelected != 0) {
   15264            2 :                         timeCoolMax = sysSizPeakDDNum.TimeStepAtSensCoolPk(coolDesSelected);
   15265              :                     } else {
   15266            0 :                         timeCoolMax = 0;
   15267              :                     }
   15268            0 :                 } else if (finalSysSizing.loadSizingType == DataSizing::LoadSizing::Ventilation) {
   15269            0 :                     coolDesSelected = sysSizPeakDDNum.CoolFlowPeakDD;
   15270            0 :                     if (coolDesSelected != 0) {
   15271            0 :                         timeCoolMax = sysSizPeakDDNum.TimeStepAtCoolFlowPk(coolDesSelected);
   15272              :                     } else {
   15273            0 :                         timeCoolMax = 0;
   15274              :                     }
   15275              :                 } else {
   15276            0 :                     coolDesSelected = sysSizPeakDDNum.TotCoolPeakDD;
   15277            0 :                     if (coolDesSelected != 0) {
   15278            0 :                         timeCoolMax = sysSizPeakDDNum.TimeStepAtTotCoolPk(coolDesSelected);
   15279              :                     } else {
   15280            0 :                         timeCoolMax = 0;
   15281              :                     }
   15282              :                 }
   15283            2 :                 heatDesSelected = sysSizPeakDDNum.HeatPeakDD;
   15284            2 :                 if (heatDesSelected != 0) {
   15285            2 :                     timeHeatMax = sysSizPeakDDNum.TimeStepAtHeatPk(heatDesSelected);
   15286              :                 } else {
   15287            0 :                     timeHeatMax = 0;
   15288              :                 }
   15289              : 
   15290            2 :                 int NumZonesCooled = state.dataAirLoop->AirToZoneNodeInfo(iAirLoop).NumZonesCooled;
   15291           12 :                 for (int ZonesCooledNum = 1; ZonesCooledNum <= NumZonesCooled; ++ZonesCooledNum) { // loop over cooled zones
   15292           10 :                     int CtrlZoneNum = state.dataAirLoop->AirToZoneNodeInfo(iAirLoop).CoolCtrlZoneNums(ZonesCooledNum);
   15293           10 :                     zoneToAirLoopCool(CtrlZoneNum) = iAirLoop;
   15294           10 :                     AirLoopZonesCoolCompLoadTables(CtrlZoneNum).desDayNum = coolDesSelected;
   15295           10 :                     AirLoopZonesCoolCompLoadTables(CtrlZoneNum).timeStepMax = timeCoolMax;
   15296           10 :                     zoneToAirLoopHeat(CtrlZoneNum) = iAirLoop;
   15297           10 :                     AirLoopZonesHeatCompLoadTables(CtrlZoneNum).desDayNum = heatDesSelected;
   15298           10 :                     AirLoopZonesHeatCompLoadTables(CtrlZoneNum).timeStepMax = timeHeatMax;
   15299              :                 }
   15300            2 :                 int NumZonesHeated = state.dataAirLoop->AirToZoneNodeInfo(iAirLoop).NumZonesHeated;
   15301            2 :                 for (int ZonesHeatedNum = 1; ZonesHeatedNum <= NumZonesHeated; ++ZonesHeatedNum) { // loop over heated zones
   15302            0 :                     int CtrlZoneNum = state.dataAirLoop->AirToZoneNodeInfo(iAirLoop).HeatCtrlZoneNums(ZonesHeatedNum);
   15303            0 :                     zoneToAirLoopCool(CtrlZoneNum) = iAirLoop;
   15304            0 :                     AirLoopZonesCoolCompLoadTables(CtrlZoneNum).desDayNum = coolDesSelected;
   15305            0 :                     AirLoopZonesCoolCompLoadTables(CtrlZoneNum).timeStepMax = timeCoolMax;
   15306            0 :                     zoneToAirLoopHeat(CtrlZoneNum) = iAirLoop;
   15307            0 :                     AirLoopZonesHeatCompLoadTables(CtrlZoneNum).desDayNum = heatDesSelected;
   15308            0 :                     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           14 :                 for (int iZone = 1; iZone <= state.dataGlobal->NumOfZones; ++iZone) {
   15314           12 :                     if (!state.dataZoneEquip->ZoneEquipConfig(iZone).IsControlled) {
   15315            2 :                         continue;
   15316              :                     }
   15317           10 :                     auto &airLoopZonesCoolCompLoadTables = AirLoopZonesCoolCompLoadTables(iZone);
   15318           10 :                     auto &airLoopZonesHeatCompLoadTables = AirLoopZonesHeatCompLoadTables(iZone);
   15319              :                     // The ZoneCoolCompLoadTables already hasn't gotten a potential IP conversion yet, so we won't convert it twice.
   15320           10 :                     if (ort->displayZoneComponentLoadSummary &&
   15321           20 :                         (airLoopZonesCoolCompLoadTables.desDayNum == ZoneCoolCompLoadTables(iZone).desDayNum) &&
   15322           10 :                         (airLoopZonesCoolCompLoadTables.timeStepMax == ZoneCoolCompLoadTables(iZone).timeStepMax)) {
   15323            0 :                         airLoopZonesCoolCompLoadTables = ZoneCoolCompLoadTables(iZone);
   15324              :                     } else {
   15325           10 :                         coolDesSelected = airLoopZonesCoolCompLoadTables.desDayNum;
   15326           10 :                         timeCoolMax = airLoopZonesCoolCompLoadTables.timeStepMax;
   15327              : 
   15328           10 :                         GetDelaySequences(state,
   15329              :                                           coolDesSelected,
   15330              :                                           true,
   15331              :                                           iZone,
   15332              :                                           peopleDelaySeq,
   15333              :                                           equipDelaySeq,
   15334              :                                           hvacLossDelaySeq,
   15335              :                                           powerGenDelaySeq,
   15336              :                                           lightDelaySeq,
   15337              :                                           feneSolarDelaySeq,
   15338           10 :                                           ort->znCompLoads,
   15339              :                                           surfDelaySeq);
   15340           10 :                         ComputeTableBodyUsingMovingAvg(state,
   15341           10 :                                                        airLoopZonesCoolCompLoadTables.cells,
   15342           10 :                                                        airLoopZonesCoolCompLoadTables.cellUsed,
   15343              :                                                        coolDesSelected,
   15344              :                                                        timeCoolMax,
   15345              :                                                        iZone,
   15346              :                                                        peopleDelaySeq,
   15347              :                                                        equipDelaySeq,
   15348              :                                                        hvacLossDelaySeq,
   15349              :                                                        powerGenDelaySeq,
   15350              :                                                        lightDelaySeq,
   15351              :                                                        feneSolarDelaySeq,
   15352           10 :                                                        ort->znCompLoads,
   15353              :                                                        surfDelaySeq);
   15354           10 :                         CollectPeakZoneConditions(state, airLoopZonesCoolCompLoadTables, coolDesSelected, timeCoolMax, iZone, true);
   15355           10 :                         AddAreaColumnForZone(ZoneComponentAreas(iZone), airLoopZonesCoolCompLoadTables);
   15356              :                     }
   15357           10 :                     if (ort->displayZoneComponentLoadSummary &&
   15358           20 :                         (airLoopZonesHeatCompLoadTables.desDayNum == ZoneHeatCompLoadTables(iZone).desDayNum) &&
   15359           10 :                         (airLoopZonesHeatCompLoadTables.timeStepMax == ZoneHeatCompLoadTables(iZone).timeStepMax)) {
   15360            0 :                         airLoopZonesHeatCompLoadTables = ZoneHeatCompLoadTables(iZone);
   15361              :                     } else {
   15362           10 :                         heatDesSelected = airLoopZonesHeatCompLoadTables.desDayNum;
   15363           10 :                         timeHeatMax = airLoopZonesHeatCompLoadTables.timeStepMax;
   15364              : 
   15365           10 :                         GetDelaySequences(state,
   15366              :                                           heatDesSelected,
   15367              :                                           false,
   15368              :                                           iZone,
   15369              :                                           peopleDelaySeq,
   15370              :                                           equipDelaySeq,
   15371              :                                           hvacLossDelaySeq,
   15372              :                                           powerGenDelaySeq,
   15373              :                                           lightDelaySeq,
   15374              :                                           feneSolarDelaySeq,
   15375           10 :                                           ort->znCompLoads,
   15376              :                                           surfDelaySeq);
   15377           10 :                         ComputeTableBodyUsingMovingAvg(state,
   15378           10 :                                                        airLoopZonesHeatCompLoadTables.cells,
   15379           10 :                                                        airLoopZonesHeatCompLoadTables.cellUsed,
   15380              :                                                        heatDesSelected,
   15381              :                                                        timeHeatMax,
   15382              :                                                        iZone,
   15383              :                                                        peopleDelaySeq,
   15384              :                                                        equipDelaySeq,
   15385              :                                                        hvacLossDelaySeq,
   15386              :                                                        powerGenDelaySeq,
   15387              :                                                        lightDelaySeq,
   15388              :                                                        feneSolarDelaySeq,
   15389           10 :                                                        ort->znCompLoads,
   15390              :                                                        surfDelaySeq);
   15391           10 :                         CollectPeakZoneConditions(state, airLoopZonesHeatCompLoadTables, heatDesSelected, timeHeatMax, iZone, false);
   15392           10 :                         AddAreaColumnForZone(ZoneComponentAreas(iZone), airLoopZonesHeatCompLoadTables);
   15393              :                     }
   15394              :                 }
   15395              :                 // combine the zones for each air loop
   15396              : 
   15397            2 :                 auto &airLoopCoolTable = AirLoopCoolCompLoadTables(iAirLoop);
   15398            2 :                 auto &airLoopHeatTable = AirLoopHeatCompLoadTables(iAirLoop);
   15399           14 :                 for (int iZone = 1; iZone <= state.dataGlobal->NumOfZones; ++iZone) {
   15400           12 :                     auto const &thisZone = state.dataHeatBal->Zone(iZone);
   15401              : 
   15402           12 :                     if (zoneToAirLoopCool(iZone) == iAirLoop) {
   15403           10 :                         Real64 mult = thisZone.Multiplier * thisZone.ListMultiplier;
   15404           10 :                         if (mult == 0.0) {
   15405            0 :                             mult = 1.0;
   15406              :                         }
   15407           10 :                         CombineLoadCompResults(airLoopCoolTable, AirLoopZonesCoolCompLoadTables(iZone), mult);
   15408              :                     }
   15409           12 :                     if (zoneToAirLoopHeat(iZone) == iAirLoop) {
   15410           10 :                         Real64 mult = thisZone.Multiplier * thisZone.ListMultiplier;
   15411           10 :                         if (mult == 0.0) {
   15412            0 :                             mult = 1.0;
   15413              :                         }
   15414           10 :                         CombineLoadCompResults(airLoopHeatTable, AirLoopZonesHeatCompLoadTables(iZone), mult);
   15415              :                     }
   15416              :                 }
   15417            4 :                 for (int SysSizIndex = 1; SysSizIndex <= state.dataSize->NumSysSizInput; ++SysSizIndex) {
   15418            2 :                     if (state.dataSize->SysSizInput(SysSizIndex).AirLoopNum != iAirLoop) {
   15419            0 :                         continue;
   15420              :                     }
   15421            2 :                     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            2 :                 airLoopCoolTable.mixAirTemp = finalSysSizing.MixTempAtCoolPeak;
   15438            2 :                 airLoopHeatTable.mixAirTemp = finalSysSizing.HeatMixTemp;
   15439              : 
   15440            2 :                 ComputeEngineeringChecks(airLoopCoolTable);
   15441            2 :                 ComputeEngineeringChecks(airLoopHeatTable);
   15442              : 
   15443            2 :                 AddTotalRowsForLoadSummary(airLoopCoolTable);
   15444            2 :                 AddTotalRowsForLoadSummary(airLoopHeatTable);
   15445              : 
   15446            2 :                 ComputePeakDifference(airLoopCoolTable);
   15447            2 :                 ComputePeakDifference(airLoopHeatTable);
   15448              : 
   15449            2 :                 CreateListOfZonesForAirLoop(state, airLoopCoolTable, zoneToAirLoopCool, iAirLoop);
   15450            2 :                 CreateListOfZonesForAirLoop(state, airLoopHeatTable, zoneToAirLoopHeat, iAirLoop);
   15451              : 
   15452            2 :                 LoadSummaryUnitConversion(state, airLoopCoolTable, unitsStyle_cur);
   15453            2 :                 LoadSummaryUnitConversion(state, airLoopHeatTable, unitsStyle_cur);
   15454              : 
   15455            2 :                 OutputCompLoadSummary(
   15456              :                     state, OutputType::AirLoop, airLoopCoolTable, airLoopHeatTable, iAirLoop, unitsStyle_cur, produceTabular, produceSQLite);
   15457              :             }
   15458            2 :         }
   15459              : 
   15460              :         // FacilityComponentLoadSummary
   15461           27 :         if (ort->displayFacilityComponentLoadSummary) {
   15462              : 
   15463            2 :             coolDesSelected = CalcFinalFacilitySizing.CoolDDNum;
   15464            2 :             timeCoolMax = CalcFinalFacilitySizing.TimeStepNumAtCoolMax;
   15465              : 
   15466            2 :             heatDesSelected = CalcFinalFacilitySizing.HeatDDNum;
   15467            2 :             timeHeatMax = CalcFinalFacilitySizing.TimeStepNumAtHeatMax;
   15468              : 
   15469           14 :             for (int iZone = 1; iZone <= state.dataGlobal->NumOfZones; ++iZone) {
   15470           12 :                 if (!state.dataZoneEquip->ZoneEquipConfig(iZone).IsControlled) {
   15471            2 :                     continue;
   15472              :                 }
   15473           10 :                 auto &facilityZonesCoolCompLoadTables = FacilityZonesCoolCompLoadTables(iZone);
   15474           10 :                 auto &facilityZonesHeatCompLoadTables = FacilityZonesHeatCompLoadTables(iZone);
   15475           10 :                 auto const &thisZone = state.dataHeatBal->Zone(iZone);
   15476              : 
   15477           10 :                 Real64 mult = thisZone.Multiplier * thisZone.ListMultiplier;
   15478           10 :                 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           20 :                 if (ort->displayZoneComponentLoadSummary && (coolDesSelected == ZoneCoolCompLoadTables(iZone).desDayNum) &&
   15484           10 :                     (timeCoolMax == ZoneCoolCompLoadTables(iZone).timeStepMax)) {
   15485            0 :                     facilityZonesCoolCompLoadTables = ZoneCoolCompLoadTables(iZone);
   15486              :                 } else {
   15487           10 :                     GetDelaySequences(state,
   15488              :                                       coolDesSelected,
   15489              :                                       true,
   15490              :                                       iZone,
   15491              :                                       peopleDelaySeq,
   15492              :                                       equipDelaySeq,
   15493              :                                       hvacLossDelaySeq,
   15494              :                                       powerGenDelaySeq,
   15495              :                                       lightDelaySeq,
   15496              :                                       feneSolarDelaySeq,
   15497           10 :                                       ort->znCompLoads,
   15498              :                                       surfDelaySeq);
   15499           10 :                     ComputeTableBodyUsingMovingAvg(state,
   15500           10 :                                                    facilityZonesCoolCompLoadTables.cells,
   15501           10 :                                                    facilityZonesCoolCompLoadTables.cellUsed,
   15502              :                                                    coolDesSelected,
   15503              :                                                    timeCoolMax,
   15504              :                                                    iZone,
   15505              :                                                    peopleDelaySeq,
   15506              :                                                    equipDelaySeq,
   15507              :                                                    hvacLossDelaySeq,
   15508              :                                                    powerGenDelaySeq,
   15509              :                                                    lightDelaySeq,
   15510              :                                                    feneSolarDelaySeq,
   15511           10 :                                                    ort->znCompLoads,
   15512              :                                                    surfDelaySeq);
   15513           10 :                     CollectPeakZoneConditions(state, facilityZonesCoolCompLoadTables, coolDesSelected, timeCoolMax, iZone, true);
   15514           10 :                     AddAreaColumnForZone(ZoneComponentAreas(iZone), facilityZonesCoolCompLoadTables);
   15515              :                 }
   15516           10 :                 facilityZonesCoolCompLoadTables.timeStepMax = timeCoolMax;
   15517           10 :                 facilityZonesCoolCompLoadTables.desDayNum = coolDesSelected;
   15518           10 :                 CombineLoadCompResults(FacilityCoolCompLoadTables, facilityZonesCoolCompLoadTables, mult);
   15519              : 
   15520           20 :                 if (ort->displayZoneComponentLoadSummary && (heatDesSelected == ZoneHeatCompLoadTables(iZone).desDayNum) &&
   15521           10 :                     (timeHeatMax == ZoneHeatCompLoadTables(iZone).timeStepMax)) {
   15522           10 :                     facilityZonesHeatCompLoadTables = ZoneHeatCompLoadTables(iZone);
   15523              :                 } else {
   15524            0 :                     GetDelaySequences(state,
   15525              :                                       heatDesSelected,
   15526              :                                       false,
   15527              :                                       iZone,
   15528              :                                       peopleDelaySeq,
   15529              :                                       equipDelaySeq,
   15530              :                                       hvacLossDelaySeq,
   15531              :                                       powerGenDelaySeq,
   15532              :                                       lightDelaySeq,
   15533              :                                       feneSolarDelaySeq,
   15534            0 :                                       ort->znCompLoads,
   15535              :                                       surfDelaySeq);
   15536            0 :                     ComputeTableBodyUsingMovingAvg(state,
   15537            0 :                                                    facilityZonesHeatCompLoadTables.cells,
   15538            0 :                                                    facilityZonesHeatCompLoadTables.cellUsed,
   15539              :                                                    heatDesSelected,
   15540              :                                                    timeHeatMax,
   15541              :                                                    iZone,
   15542              :                                                    peopleDelaySeq,
   15543              :                                                    equipDelaySeq,
   15544              :                                                    hvacLossDelaySeq,
   15545              :                                                    powerGenDelaySeq,
   15546              :                                                    lightDelaySeq,
   15547              :                                                    feneSolarDelaySeq,
   15548            0 :                                                    ort->znCompLoads,
   15549              :                                                    surfDelaySeq);
   15550            0 :                     CollectPeakZoneConditions(state, facilityZonesHeatCompLoadTables, heatDesSelected, timeHeatMax, iZone, false);
   15551            0 :                     AddAreaColumnForZone(ZoneComponentAreas(iZone), facilityZonesHeatCompLoadTables);
   15552              :                 }
   15553           10 :                 facilityZonesHeatCompLoadTables.timeStepMax = timeHeatMax;
   15554           10 :                 facilityZonesHeatCompLoadTables.desDayNum = heatDesSelected;
   15555           10 :                 CombineLoadCompResults(FacilityHeatCompLoadTables, facilityZonesHeatCompLoadTables, mult);
   15556              :             }
   15557              : 
   15558            2 :             auto &facilityCoolTable = FacilityCoolCompLoadTables;
   15559            2 :             auto &facilityHeatTable = FacilityHeatCompLoadTables;
   15560            2 :             facilityCoolTable.peakDesSensLoad = 0.0;
   15561            2 :             facilityCoolTable.designPeakLoad = 0.0;
   15562            2 :             facilityHeatTable.peakDesSensLoad = 0.0;
   15563            2 :             facilityHeatTable.designPeakLoad = 0.0;
   15564            2 :             facilityCoolTable.diffPeakEst = 0.0;
   15565            2 :             facilityHeatTable.diffPeakEst = 0.0;
   15566            2 :             facilityCoolTable.diffDesignPeak = 0.0;
   15567            4 :             for (int iAirLoop = 1; iAirLoop <= NumPrimaryAirSys; ++iAirLoop) {
   15568            2 :                 facilityCoolTable.peakDesSensLoad += AirLoopCoolCompLoadTables(iAirLoop).peakDesSensLoad;
   15569            2 :                 facilityCoolTable.designPeakLoad += AirLoopCoolCompLoadTables(iAirLoop).designPeakLoad;
   15570            2 :                 facilityHeatTable.peakDesSensLoad += AirLoopHeatCompLoadTables(iAirLoop).peakDesSensLoad;
   15571            2 :                 facilityHeatTable.designPeakLoad += AirLoopHeatCompLoadTables(iAirLoop).designPeakLoad;
   15572            2 :                 facilityCoolTable.diffPeakEst += AirLoopCoolCompLoadTables(iAirLoop).diffPeakEst;
   15573            2 :                 facilityCoolTable.diffDesignPeak += AirLoopCoolCompLoadTables(iAirLoop).diffDesignPeak;
   15574            2 :                 facilityHeatTable.diffPeakEst += AirLoopHeatCompLoadTables(iAirLoop).diffPeakEst;
   15575            2 :                 facilityCoolTable.diffDesignPeak += AirLoopHeatCompLoadTables(iAirLoop).diffDesignPeak;
   15576              :             }
   15577              : 
   15578            2 :             ComputeEngineeringChecks(FacilityCoolCompLoadTables);
   15579            2 :             ComputeEngineeringChecks(FacilityHeatCompLoadTables);
   15580              : 
   15581            2 :             AddTotalRowsForLoadSummary(FacilityCoolCompLoadTables);
   15582            2 :             AddTotalRowsForLoadSummary(FacilityHeatCompLoadTables);
   15583              : 
   15584            2 :             ComputePeakDifference(FacilityCoolCompLoadTables);
   15585            2 :             ComputePeakDifference(FacilityHeatCompLoadTables);
   15586              : 
   15587            2 :             LoadSummaryUnitConversion(state, FacilityCoolCompLoadTables, unitsStyle_cur);
   15588            2 :             LoadSummaryUnitConversion(state, FacilityHeatCompLoadTables, unitsStyle_cur);
   15589              : 
   15590            2 :             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           27 :         if (state.dataHeatBal->doSpaceHeatBalanceSizing) {
   15602            2 :             if (ort->displayZoneComponentLoadSummary) {
   15603           18 :                 for (int iSpace = 1; iSpace <= state.dataGlobal->numSpaces; ++iSpace) {
   15604              :                     // Test if *zone* is controlled, not space, for sizing
   15605           16 :                     if (!state.dataZoneEquip->ZoneEquipConfig(state.dataHeatBal->space(iSpace).zoneNum).IsControlled) {
   15606            2 :                         continue;
   15607              :                     }
   15608           14 :                     if (allocated(state.dataSize->CalcFinalSpaceSizing)) {
   15609           14 :                         LoadSummaryUnitConversion(state, SpaceCoolCompLoadTables(iSpace), unitsStyle_cur);
   15610           14 :                         LoadSummaryUnitConversion(state, SpaceHeatCompLoadTables(iSpace), unitsStyle_cur);
   15611              : 
   15612           28 :                         OutputCompLoadSummary(state,
   15613              :                                               OutputType::Space,
   15614           14 :                                               SpaceCoolCompLoadTables(iSpace),
   15615           14 :                                               SpaceHeatCompLoadTables(iSpace),
   15616              :                                               iSpace,
   15617              :                                               unitsStyle_cur,
   15618              :                                               produceTabular,
   15619              :                                               produceSQLite);
   15620              :                     }
   15621              :                 }
   15622              :             }
   15623            2 :             SpaceHeatCompLoadTables.deallocate();
   15624            2 :             SpaceCoolCompLoadTables.deallocate();
   15625              :         }
   15626              : 
   15627              :         // ZoneComponentLoadSummary: Now we convert and Display
   15628           27 :         if (ort->displayZoneComponentLoadSummary) {
   15629          242 :             for (int iZone = 1; iZone <= state.dataGlobal->NumOfZones; ++iZone) {
   15630          215 :                 if (!state.dataZoneEquip->ZoneEquipConfig(iZone).IsControlled) {
   15631           30 :                     continue;
   15632              :                 }
   15633          185 :                 if (allocated(state.dataSize->CalcFinalZoneSizing)) {
   15634          185 :                     LoadSummaryUnitConversion(state, ZoneCoolCompLoadTables(iZone), unitsStyle_cur);
   15635          185 :                     LoadSummaryUnitConversion(state, ZoneHeatCompLoadTables(iZone), unitsStyle_cur);
   15636              : 
   15637          370 :                     OutputCompLoadSummary(state,
   15638              :                                           OutputType::Zone,
   15639          185 :                                           ZoneCoolCompLoadTables(iZone),
   15640          185 :                                           ZoneHeatCompLoadTables(iZone),
   15641              :                                           iZone,
   15642              :                                           unitsStyle_cur,
   15643              :                                           produceTabular,
   15644              :                                           produceSQLite);
   15645              :                 }
   15646              :             }
   15647              :         }
   15648              : 
   15649           27 :         ZoneHeatCompLoadTables.deallocate();
   15650           27 :         ZoneCoolCompLoadTables.deallocate();
   15651           27 :         AirLoopHeatCompLoadTables.deallocate();
   15652           27 :         AirLoopCoolCompLoadTables.deallocate();
   15653           27 :         AirLoopZonesHeatCompLoadTables.deallocate();
   15654           27 :         AirLoopZonesCoolCompLoadTables.deallocate();
   15655              : 
   15656           27 :         FacilityHeatCompLoadTables.cells.deallocate();
   15657           27 :         FacilityHeatCompLoadTables.cellUsed.deallocate();
   15658           27 :         FacilityCoolCompLoadTables.cells.deallocate();
   15659           27 :         FacilityCoolCompLoadTables.cellUsed.deallocate();
   15660              : 
   15661           27 :         FacilityZonesHeatCompLoadTables.deallocate();
   15662           27 :         FacilityZonesCoolCompLoadTables.deallocate();
   15663              : 
   15664           27 :         peopleDelaySeq.deallocate();
   15665           27 :         lightDelaySeq.deallocate();
   15666           27 :         equipDelaySeq.deallocate();
   15667           27 :         hvacLossDelaySeq.deallocate();
   15668           27 :         powerGenDelaySeq.deallocate();
   15669           27 :         feneSolarDelaySeq.deallocate();
   15670           27 :         surfDelaySeq.deallocate();
   15671           27 :     }
   15672           27 : }
   15673              : 
   15674          199 : 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          199 :     int coolDesSelected = calcFinalSizing.CoolDDNum;
   15691          199 :     coolCompLoadTables.desDayNum = coolDesSelected;
   15692          199 :     int timeCoolMax = calcFinalSizing.TimeStepNumAtCoolMax;
   15693          199 :     coolCompLoadTables.timeStepMax = timeCoolMax;
   15694              : 
   15695          199 :     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          199 :     ComputeTableBodyUsingMovingAvg(state,
   15709          199 :                                    coolCompLoadTables.cells,
   15710          199 :                                    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          199 :     CollectPeakZoneConditions(state, coolCompLoadTables, coolDesSelected, timeCoolMax, iZone, true, iSpace);
   15724              :     // send latent load info to coil summary report
   15725          199 :     state.dataRptCoilSelection->coilSelectionReportObj->setZoneLatentLoadCoolingIdealPeak(
   15726          199 :         iZone, coolCompLoadTables.cells(LoadCompCol::Latent, LoadCompRow::GrdTot));
   15727              : 
   15728          199 :     int heatDesSelected = calcFinalSizing.HeatDDNum;
   15729          199 :     heatCompLoadTables.desDayNum = heatDesSelected;
   15730          199 :     int timeHeatMax = calcFinalSizing.TimeStepNumAtHeatMax;
   15731          199 :     heatCompLoadTables.timeStepMax = timeHeatMax;
   15732              : 
   15733          199 :     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          199 :     ComputeTableBodyUsingMovingAvg(state,
   15747          199 :                                    heatCompLoadTables.cells,
   15748          199 :                                    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          199 :     CollectPeakZoneConditions(state, heatCompLoadTables, heatDesSelected, timeHeatMax, iZone, false, iSpace);
   15762              : 
   15763              :     // send latent load info to coil summary report
   15764          199 :     state.dataRptCoilSelection->coilSelectionReportObj->setZoneLatentLoadHeatingIdealPeak(
   15765          199 :         iZone, heatCompLoadTables.cells(LoadCompCol::Latent, LoadCompRow::GrdTot));
   15766              : 
   15767          199 :     AddAreaColumnForZone(componentAreas, coolCompLoadTables);
   15768          199 :     AddAreaColumnForZone(componentAreas, heatCompLoadTables);
   15769              : 
   15770          199 :     AddTotalRowsForLoadSummary(coolCompLoadTables);
   15771          199 :     AddTotalRowsForLoadSummary(heatCompLoadTables);
   15772              : 
   15773          199 :     ComputePeakDifference(coolCompLoadTables);
   15774          199 :     ComputePeakDifference(heatCompLoadTables);
   15775          199 : }
   15776              : // populate the delay sequence arrays for the component load summary table output
   15777          428 : 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          428 :     auto &ort = state.dataOutRptTab;
   15794          428 :     int const szNumMinus1 = (iSpace == 0) ? zoneIndex - 1 : iSpace - 1; // space or zone num minus 1 for vector
   15795              :     // reset to zero
   15796          428 :     surfDelaySeq = 0.0;
   15797              : 
   15798          428 :     if (desDaySelected != 0) {
   15799          428 :         auto const &surfCLDay = ort->surfCompLoads[desDaySelected - 1];
   15800          428 :         auto const &enclCLDay = ort->enclCompLoads[desDaySelected - 1];
   15801          428 :         auto &szCLDay = szCompLoadLoc[desDaySelected - 1];
   15802              : 
   15803          428 :         Array2D<Real64> decayCurve;
   15804          428 :         if (isCooling) {
   15805          219 :             decayCurve = ort->decayCurveCool;
   15806              :         } else {
   15807          209 :             decayCurve = ort->decayCurveHeat;
   15808              :         }
   15809              : 
   15810        41516 :         for (int kTimeStep = 1; kTimeStep <= state.dataGlobal->TimeStepsInHour * Constant::iHoursInDay; ++kTimeStep) {
   15811        41088 :             Real64 peopleConvIntoZone = 0.0;
   15812        41088 :             Real64 equipConvIntoZone = 0.0;
   15813        41088 :             Real64 hvacLossConvIntoZone = 0.0;
   15814        41088 :             Real64 powerGenConvIntoZone = 0.0;
   15815        41088 :             Real64 lightLWConvIntoZone = 0.0;
   15816        41088 :             Real64 lightSWConvIntoZone = 0.0;
   15817        41088 :             Real64 feneSolarConvIntoZone = 0.0;
   15818        41088 :             Real64 adjFeneSurfNetRadSeq = 0.0;
   15819              : 
   15820              :             // code from ComputeDelayedComponents starts
   15821        86784 :             for (int spaceNum : state.dataHeatBal->Zone(zoneIndex).spaceIndexes) {
   15822        45696 :                 if ((iSpace > 0) && (spaceNum != iSpace)) {
   15823         2304 :                     continue;
   15824              :                 }
   15825        43392 :                 auto const &thisSpace = state.dataHeatBal->space(spaceNum);
   15826       338688 :                 for (int jSurf = thisSpace.HTSurfaceFirst; jSurf <= thisSpace.HTSurfaceLast; ++jSurf) {
   15827       295296 :                     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       295296 :                     Real64 peopleConvFromSurf = 0.0;
   15830       295296 :                     Real64 equipConvFromSurf = 0.0;
   15831       295296 :                     Real64 hvacLossConvFromSurf = 0.0;
   15832       295296 :                     Real64 powerGenConvFromSurf = 0.0;
   15833       295296 :                     Real64 lightLWConvFromSurf = 0.0;
   15834       295296 :                     Real64 lightSWConvFromSurf = 0.0;
   15835       295296 :                     Real64 feneSolarConvFromSurf = 0.0;
   15836              : 
   15837     14617152 :                     for (int mStepBack = 1; mStepBack <= kTimeStep; ++mStepBack) {
   15838     14321856 :                         int sourceStep = kTimeStep - mStepBack + 1;
   15839     14321856 :                         auto &compLoadTS = szCLDay.ts[sourceStep - 1].spacezone[szNumMinus1];
   15840     14321856 :                         auto const &surfCLDayTS = surfCLDay.ts[sourceStep - 1].surf[jSurf - 1];
   15841     14321856 :                         auto const &enclCLDayTS = enclCLDay.ts[sourceStep - 1].encl[radEnclosureNum - 1];
   15842              :                         Real64 thisQRadThermInAbsMult =
   15843     14321856 :                             surfCLDayTS.TMULTseq * surfCLDayTS.ITABSFseq * state.dataSurface->Surface(jSurf).Area * decayCurve(mStepBack, jSurf);
   15844     14321856 :                         peopleConvFromSurf += enclCLDayTS.peopleRadSeq * thisQRadThermInAbsMult;
   15845     14321856 :                         equipConvFromSurf += enclCLDayTS.equipRadSeq * thisQRadThermInAbsMult;
   15846     14321856 :                         hvacLossConvFromSurf += enclCLDayTS.hvacLossRadSeq * thisQRadThermInAbsMult;
   15847     14321856 :                         powerGenConvFromSurf += enclCLDayTS.powerGenRadSeq * thisQRadThermInAbsMult;
   15848     14321856 :                         lightLWConvFromSurf += enclCLDayTS.lightLWRadSeq * thisQRadThermInAbsMult;
   15849              :                         // short wave is already accumulated by surface
   15850     14321856 :                         lightSWConvFromSurf += surfCLDayTS.lightSWRadSeq * decayCurve(mStepBack, jSurf);
   15851     14321856 :                         feneSolarConvFromSurf += surfCLDayTS.feneSolarRadSeq * decayCurve(mStepBack, jSurf);
   15852              :                     } // for mStepBack
   15853              : 
   15854       295296 :                     peopleConvIntoZone += peopleConvFromSurf;
   15855       295296 :                     equipConvIntoZone += equipConvFromSurf;
   15856       295296 :                     hvacLossConvIntoZone += hvacLossConvFromSurf;
   15857       295296 :                     powerGenConvIntoZone += powerGenConvFromSurf;
   15858       295296 :                     lightLWConvIntoZone += lightLWConvFromSurf;
   15859       295296 :                     lightSWConvIntoZone += lightSWConvFromSurf;
   15860       295296 :                     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       295296 :                     auto &surfCLDaykTS = surfCLDay.ts[kTimeStep - 1].surf[jSurf - 1];
   15866       590592 :                     surfDelaySeq(kTimeStep, jSurf) =
   15867       295296 :                         -surfCLDaykTS.loadConvectedNormal - surfCLDaykTS.netSurfRadSeq -
   15868       295296 :                         (peopleConvFromSurf + equipConvFromSurf + hvacLossConvFromSurf + powerGenConvFromSurf + lightLWConvFromSurf +
   15869       295296 :                          lightSWConvFromSurf +
   15870              :                          feneSolarConvFromSurf); // remove net radiant for the surface
   15871              :                                                  // also remove the net radiant component on the instantaneous conduction for fenestration
   15872       295296 :                     if (state.dataSurface->Surface(jSurf).Class == DataSurfaces::SurfaceClass::Window) {
   15873        44160 :                         adjFeneSurfNetRadSeq += surfCLDaykTS.netSurfRadSeq;
   15874              :                     }
   15875              :                 } // for jSurf
   15876        41088 :             }
   15877        41088 :             peopleDelaySeq(kTimeStep) = peopleConvIntoZone;
   15878        41088 :             equipDelaySeq(kTimeStep) = equipConvIntoZone;
   15879        41088 :             hvacLossDelaySeq(kTimeStep) = hvacLossConvIntoZone;
   15880        41088 :             powerGenDelaySeq(kTimeStep) = powerGenConvIntoZone;
   15881              :             // combine short wave (visible) and long wave (thermal) impacts
   15882        41088 :             lightDelaySeq(kTimeStep) = lightLWConvIntoZone + lightSWConvIntoZone;
   15883        41088 :             feneSolarDelaySeq(kTimeStep) = feneSolarConvIntoZone;
   15884              :             // also remove the net radiant component on the instantaneous conduction for fenestration
   15885        41088 :             auto &szCompLoadDayTS = szCLDay.ts[kTimeStep - 1].spacezone[szNumMinus1];
   15886        41088 :             if (!szCompLoadDayTS.adjFenDone) {
   15887        38208 :                 szCompLoadDayTS.feneCondInstantSeq -= adjFeneSurfNetRadSeq;
   15888        38208 :                 szCompLoadDayTS.adjFenDone = true;
   15889              :             }
   15890              :         } // for kTimeStep
   15891              : 
   15892          428 :         decayCurve.deallocate();
   15893              : 
   15894          428 :     } // if desDaySelected != 0
   15895          428 : }
   15896              : 
   15897              : // set the load summary table cells based on the load sequences using moving averages to smooth out
   15898          428 : 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          428 :     Array1D<Real64> AvgData;     // sequence data to be averaging
   15915          428 :     Array1D<Real64> delayOpaque; // hold values for report for delayed opaque
   15916              : 
   15917          428 :     resultCells = 0.;
   15918          428 :     resCellsUsd = false;
   15919          428 :     delayOpaque.allocate(LoadCompRow::GrdTot);
   15920          428 :     Real64 numTSinDay = state.dataGlobal->TimeStepsInHour * Constant::iHoursInDay;
   15921          428 :     AvgData.allocate(numTSinDay);
   15922          428 :     int const szNumMinus1 = (iSpace == 0) ? zoneIndex - 1 : iSpace - 1; // space or zone num minus 1 for vector
   15923              : 
   15924          428 :     if (desDaySelected != 0 && timeOfMax != 0) {
   15925              :         // Don't update/average original array data
   15926              :         // PEOPLE
   15927          428 :         auto &compLoadDay = szCompLoadLoc[desDaySelected - 1];
   15928        41516 :         for (int iTS = 1; iTS <= numTSinDay; ++iTS) {
   15929        41088 :             AvgData(iTS) = compLoadDay.ts[iTS - 1].spacezone[szNumMinus1].peopleInstantSeq;
   15930              :         }
   15931          428 :         General::MovingAvg(AvgData, state.dataSize->NumTimeStepsInAvg);
   15932          428 :         resultCells(LoadCompCol::SensInst, LoadCompRow::People) = AvgData(timeOfMax);
   15933          428 :         resCellsUsd(LoadCompCol::SensInst, LoadCompRow::People) = true;
   15934        41516 :         for (int iTS = 1; iTS <= numTSinDay; ++iTS) {
   15935        41088 :             AvgData(iTS) = compLoadDay.ts[iTS - 1].spacezone[szNumMinus1].peopleLatentSeq;
   15936              :         }
   15937          428 :         General::MovingAvg(AvgData, state.dataSize->NumTimeStepsInAvg);
   15938          428 :         resultCells(LoadCompCol::Latent, LoadCompRow::People) = AvgData(timeOfMax);
   15939          428 :         resCellsUsd(LoadCompCol::Latent, LoadCompRow::People) = true;
   15940          428 :         AvgData = peopleDelaySeq(_);
   15941          428 :         General::MovingAvg(AvgData, state.dataSize->NumTimeStepsInAvg);
   15942          428 :         resultCells(LoadCompCol::SensDelay, LoadCompRow::People) = AvgData(timeOfMax);
   15943          428 :         resCellsUsd(LoadCompCol::SensDelay, LoadCompRow::People) = true;
   15944              : 
   15945              :         // LIGHTS
   15946        41516 :         for (int iTS = 1; iTS <= numTSinDay; ++iTS) {
   15947        41088 :             AvgData(iTS) = compLoadDay.ts[iTS - 1].spacezone[szNumMinus1].lightInstantSeq;
   15948              :         }
   15949          428 :         General::MovingAvg(AvgData, state.dataSize->NumTimeStepsInAvg);
   15950          428 :         resultCells(LoadCompCol::SensInst, LoadCompRow::Lights) = AvgData(timeOfMax);
   15951          428 :         resCellsUsd(LoadCompCol::SensInst, LoadCompRow::Lights) = true;
   15952        41516 :         for (int iTS = 1; iTS <= numTSinDay; ++iTS) {
   15953        41088 :             AvgData(iTS) = compLoadDay.ts[iTS - 1].spacezone[szNumMinus1].lightRetAirSeq;
   15954              :         }
   15955          428 :         General::MovingAvg(AvgData, state.dataSize->NumTimeStepsInAvg);
   15956          428 :         resultCells(LoadCompCol::SensRA, LoadCompRow::Lights) = AvgData(timeOfMax);
   15957          428 :         resCellsUsd(LoadCompCol::SensRA, LoadCompRow::Lights) = true;
   15958          428 :         AvgData = lightDelaySeq(_);
   15959          428 :         General::MovingAvg(AvgData, state.dataSize->NumTimeStepsInAvg);
   15960          428 :         resultCells(LoadCompCol::SensDelay, LoadCompRow::Lights) = AvgData(timeOfMax);
   15961          428 :         resCellsUsd(LoadCompCol::SensDelay, LoadCompRow::Lights) = true;
   15962              : 
   15963              :         // EQUIPMENT
   15964        41516 :         for (int iTS = 1; iTS <= numTSinDay; ++iTS) {
   15965        41088 :             AvgData(iTS) = compLoadDay.ts[iTS - 1].spacezone[szNumMinus1].equipInstantSeq;
   15966              :         }
   15967          428 :         General::MovingAvg(AvgData, state.dataSize->NumTimeStepsInAvg);
   15968          428 :         resultCells(LoadCompCol::SensInst, LoadCompRow::Equip) = AvgData(timeOfMax);
   15969          428 :         resCellsUsd(LoadCompCol::SensInst, LoadCompRow::Equip) = true;
   15970        41516 :         for (int iTS = 1; iTS <= numTSinDay; ++iTS) {
   15971        41088 :             AvgData(iTS) = compLoadDay.ts[iTS - 1].spacezone[szNumMinus1].equipLatentSeq;
   15972              :         }
   15973          428 :         General::MovingAvg(AvgData, state.dataSize->NumTimeStepsInAvg);
   15974          428 :         resultCells(LoadCompCol::Latent, LoadCompRow::Equip) = AvgData(timeOfMax);
   15975          428 :         resCellsUsd(LoadCompCol::Latent, LoadCompRow::Equip) = true;
   15976          428 :         AvgData = equipDelaySeq(_);
   15977          428 :         General::MovingAvg(AvgData, state.dataSize->NumTimeStepsInAvg);
   15978          428 :         resultCells(LoadCompCol::SensDelay, LoadCompRow::Equip) = AvgData(timeOfMax);
   15979          428 :         resCellsUsd(LoadCompCol::SensDelay, LoadCompRow::Equip) = true;
   15980              : 
   15981              :         // REFRIGERATION EQUIPMENT
   15982        41516 :         for (int iTS = 1; iTS <= numTSinDay; ++iTS) {
   15983        41088 :             AvgData(iTS) = compLoadDay.ts[iTS - 1].spacezone[szNumMinus1].refrigInstantSeq;
   15984              :         }
   15985          428 :         General::MovingAvg(AvgData, state.dataSize->NumTimeStepsInAvg);
   15986          428 :         resultCells(LoadCompCol::SensInst, LoadCompRow::Refrig) = AvgData(timeOfMax);
   15987          428 :         resCellsUsd(LoadCompCol::SensInst, LoadCompRow::Refrig) = true;
   15988        41516 :         for (int iTS = 1; iTS <= numTSinDay; ++iTS) {
   15989        41088 :             AvgData(iTS) = compLoadDay.ts[iTS - 1].spacezone[szNumMinus1].refrigRetAirSeq;
   15990              :         }
   15991          428 :         General::MovingAvg(AvgData, state.dataSize->NumTimeStepsInAvg);
   15992          428 :         resultCells(LoadCompCol::SensRA, LoadCompRow::Refrig) = AvgData(timeOfMax);
   15993          428 :         resCellsUsd(LoadCompCol::SensRA, LoadCompRow::Refrig) = true;
   15994        41516 :         for (int iTS = 1; iTS <= numTSinDay; ++iTS) {
   15995        41088 :             AvgData(iTS) = compLoadDay.ts[iTS - 1].spacezone[szNumMinus1].refrigLatentSeq;
   15996              :         }
   15997          428 :         General::MovingAvg(AvgData, state.dataSize->NumTimeStepsInAvg);
   15998          428 :         resultCells(LoadCompCol::Latent, LoadCompRow::Refrig) = AvgData(timeOfMax);
   15999          428 :         resCellsUsd(LoadCompCol::Latent, LoadCompRow::Refrig) = true;
   16000              : 
   16001              :         // WATER USE EQUIPMENT
   16002        41516 :         for (int iTS = 1; iTS <= numTSinDay; ++iTS) {
   16003        41088 :             AvgData(iTS) = compLoadDay.ts[iTS - 1].spacezone[szNumMinus1].waterUseInstantSeq;
   16004              :         }
   16005          428 :         General::MovingAvg(AvgData, state.dataSize->NumTimeStepsInAvg);
   16006          428 :         resultCells(LoadCompCol::SensInst, LoadCompRow::WaterUse) = AvgData(timeOfMax);
   16007          428 :         resCellsUsd(LoadCompCol::SensInst, LoadCompRow::WaterUse) = true;
   16008        41516 :         for (int iTS = 1; iTS <= numTSinDay; ++iTS) {
   16009        41088 :             AvgData(iTS) = compLoadDay.ts[iTS - 1].spacezone[szNumMinus1].waterUseLatentSeq;
   16010              :         }
   16011          428 :         General::MovingAvg(AvgData, state.dataSize->NumTimeStepsInAvg);
   16012          428 :         resultCells(LoadCompCol::Latent, LoadCompRow::WaterUse) = AvgData(timeOfMax);
   16013          428 :         resCellsUsd(LoadCompCol::Latent, LoadCompRow::WaterUse) = true;
   16014              : 
   16015              :         // HVAC EQUIPMENT LOSSES
   16016        41516 :         for (int iTS = 1; iTS <= numTSinDay; ++iTS) {
   16017        41088 :             AvgData(iTS) = compLoadDay.ts[iTS - 1].spacezone[szNumMinus1].hvacLossInstantSeq;
   16018              :         }
   16019          428 :         General::MovingAvg(AvgData, state.dataSize->NumTimeStepsInAvg);
   16020          428 :         resultCells(LoadCompCol::SensInst, LoadCompRow::HvacLoss) = AvgData(timeOfMax);
   16021          428 :         resCellsUsd(LoadCompCol::SensInst, LoadCompRow::HvacLoss) = true;
   16022          428 :         AvgData = hvacLossDelaySeq(_);
   16023          428 :         General::MovingAvg(AvgData, state.dataSize->NumTimeStepsInAvg);
   16024          428 :         resultCells(LoadCompCol::SensDelay, LoadCompRow::HvacLoss) = AvgData(timeOfMax);
   16025          428 :         resCellsUsd(LoadCompCol::SensDelay, LoadCompRow::HvacLoss) = true;
   16026              : 
   16027              :         // POWER GENERATION EQUIPMENT
   16028        41516 :         for (int iTS = 1; iTS <= numTSinDay; ++iTS) {
   16029        41088 :             AvgData(iTS) = compLoadDay.ts[iTS - 1].spacezone[szNumMinus1].powerGenInstantSeq;
   16030              :         }
   16031          428 :         General::MovingAvg(AvgData, state.dataSize->NumTimeStepsInAvg);
   16032          428 :         resultCells(LoadCompCol::SensInst, LoadCompRow::PowerGen) = AvgData(timeOfMax);
   16033          428 :         resCellsUsd(LoadCompCol::SensInst, LoadCompRow::PowerGen) = true;
   16034          428 :         AvgData = powerGenDelaySeq(_);
   16035          428 :         General::MovingAvg(AvgData, state.dataSize->NumTimeStepsInAvg);
   16036          428 :         resultCells(LoadCompCol::SensDelay, LoadCompRow::PowerGen) = AvgData(timeOfMax);
   16037          428 :         resCellsUsd(LoadCompCol::SensDelay, LoadCompRow::PowerGen) = true;
   16038              : 
   16039              :         // DOAS
   16040          428 :         Real64 const mult = state.dataHeatBal->Zone(zoneIndex).Multiplier * state.dataHeatBal->Zone(zoneIndex).ListMultiplier;
   16041          856 :         resultCells(LoadCompCol::SensInst, LoadCompRow::DOAS) =
   16042          428 :             state.dataSize->CalcZoneSizing(desDaySelected, zoneIndex).DOASHeatAddSeq(timeOfMax) / mult;
   16043          428 :         resCellsUsd(LoadCompCol::SensInst, LoadCompRow::DOAS) = true;
   16044          856 :         resultCells(LoadCompCol::Latent, LoadCompRow::DOAS) =
   16045          428 :             state.dataSize->CalcZoneSizing(desDaySelected, zoneIndex).DOASLatAddSeq(timeOfMax) / mult;
   16046          428 :         resCellsUsd(LoadCompCol::Latent, LoadCompRow::DOAS) = true;
   16047              : 
   16048              :         // INFILTRATION
   16049        41516 :         for (int iTS = 1; iTS <= numTSinDay; ++iTS) {
   16050        41088 :             AvgData(iTS) = compLoadDay.ts[iTS - 1].spacezone[szNumMinus1].infilInstantSeq;
   16051              :         }
   16052          428 :         General::MovingAvg(AvgData, state.dataSize->NumTimeStepsInAvg);
   16053          428 :         resultCells(LoadCompCol::SensInst, LoadCompRow::Infil) = AvgData(timeOfMax);
   16054          428 :         resCellsUsd(LoadCompCol::SensInst, LoadCompRow::Infil) = true;
   16055        41516 :         for (int iTS = 1; iTS <= numTSinDay; ++iTS) {
   16056        41088 :             AvgData(iTS) = compLoadDay.ts[iTS - 1].spacezone[szNumMinus1].infilLatentSeq;
   16057              :         }
   16058          428 :         General::MovingAvg(AvgData, state.dataSize->NumTimeStepsInAvg);
   16059          428 :         resultCells(LoadCompCol::Latent, LoadCompRow::Infil) = AvgData(timeOfMax);
   16060          428 :         resCellsUsd(LoadCompCol::Latent, LoadCompRow::Infil) = true;
   16061              : 
   16062              :         // ZONE VENTILATION
   16063        41516 :         for (int iTS = 1; iTS <= numTSinDay; ++iTS) {
   16064        41088 :             AvgData(iTS) = compLoadDay.ts[iTS - 1].spacezone[szNumMinus1].zoneVentInstantSeq;
   16065              :         }
   16066          428 :         General::MovingAvg(AvgData, state.dataSize->NumTimeStepsInAvg);
   16067          428 :         resultCells(LoadCompCol::SensInst, LoadCompRow::ZoneVent) = AvgData(timeOfMax);
   16068          428 :         resCellsUsd(LoadCompCol::SensInst, LoadCompRow::ZoneVent) = true;
   16069        41516 :         for (int iTS = 1; iTS <= numTSinDay; ++iTS) {
   16070        41088 :             AvgData(iTS) = compLoadDay.ts[iTS - 1].spacezone[szNumMinus1].zoneVentLatentSeq;
   16071              :         }
   16072          428 :         General::MovingAvg(AvgData, state.dataSize->NumTimeStepsInAvg);
   16073          428 :         resultCells(LoadCompCol::Latent, LoadCompRow::ZoneVent) = AvgData(timeOfMax);
   16074          428 :         resCellsUsd(LoadCompCol::Latent, LoadCompRow::ZoneVent) = true;
   16075              : 
   16076              :         // INTERZONE MIXING
   16077        41516 :         for (int iTS = 1; iTS <= numTSinDay; ++iTS) {
   16078        41088 :             AvgData(iTS) = compLoadDay.ts[iTS - 1].spacezone[szNumMinus1].interZoneMixInstantSeq;
   16079              :         }
   16080          428 :         General::MovingAvg(AvgData, state.dataSize->NumTimeStepsInAvg);
   16081          428 :         resultCells(LoadCompCol::SensInst, LoadCompRow::IntZonMix) = AvgData(timeOfMax);
   16082          428 :         resCellsUsd(LoadCompCol::SensInst, LoadCompRow::IntZonMix) = true;
   16083        41516 :         for (int iTS = 1; iTS <= numTSinDay; ++iTS) {
   16084        41088 :             AvgData(iTS) = compLoadDay.ts[iTS - 1].spacezone[szNumMinus1].interZoneMixLatentSeq;
   16085              :         }
   16086          428 :         General::MovingAvg(AvgData, state.dataSize->NumTimeStepsInAvg);
   16087          428 :         resultCells(LoadCompCol::Latent, LoadCompRow::IntZonMix) = AvgData(timeOfMax);
   16088          428 :         resCellsUsd(LoadCompCol::Latent, LoadCompRow::IntZonMix) = true;
   16089              : 
   16090              :         // FENESTRATION CONDUCTION
   16091        41516 :         for (int iTS = 1; iTS <= numTSinDay; ++iTS) {
   16092        41088 :             AvgData(iTS) = compLoadDay.ts[iTS - 1].spacezone[szNumMinus1].feneCondInstantSeq;
   16093              :         }
   16094          428 :         General::MovingAvg(AvgData, state.dataSize->NumTimeStepsInAvg);
   16095          428 :         resultCells(LoadCompCol::SensInst, LoadCompRow::FeneCond) = AvgData(timeOfMax);
   16096          428 :         resCellsUsd(LoadCompCol::SensInst, LoadCompRow::FeneCond) = true;
   16097              : 
   16098              :         // FENESTRATION SOLAR
   16099          428 :         AvgData = feneSolarDelaySeq(_);
   16100          428 :         General::MovingAvg(AvgData, state.dataSize->NumTimeStepsInAvg);
   16101          428 :         resultCells(LoadCompCol::SensDelay, LoadCompRow::FeneSolr) = AvgData(timeOfMax);
   16102          428 :         resCellsUsd(LoadCompCol::SensDelay, LoadCompRow::FeneSolr) = true;
   16103              : 
   16104              :         // opaque surfaces - must combine individual surfaces by class and other side conditions
   16105          428 :         delayOpaque = 0.0;
   16106          904 :         for (int spaceNum : state.dataHeatBal->Zone(zoneIndex).spaceIndexes) {
   16107          476 :             auto const &thisSpace = state.dataHeatBal->space(spaceNum);
   16108         3652 :             for (int kSurf = thisSpace.HTSurfaceFirst; kSurf <= thisSpace.HTSurfaceLast; ++kSurf) {
   16109              : 
   16110         3176 :                 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         3176 :                 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         3176 :                 AvgData = surfDelaySeq(_, kSurf);
   16119         3176 :                 General::MovingAvg(AvgData, state.dataSize->NumTimeStepsInAvg);
   16120         3176 :                 Real64 singleSurfDelay = AvgData(timeOfMax);
   16121         3176 :                 switch (state.dataSurface->Surface(kSurf).Class) {
   16122         1760 :                 case DataSurfaces::SurfaceClass::Wall: {
   16123         1760 :                     switch (curExtBoundCond) {
   16124          364 :                     case DataSurfaces::ExternalEnvironment: {
   16125          364 :                         delayOpaque(LoadCompRow::ExtWall) += singleSurfDelay;
   16126          364 :                     } 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         1396 :                     default: { // interzone
   16138         1396 :                         delayOpaque(LoadCompRow::IntZonWall) += singleSurfDelay;
   16139         1396 :                     } break;
   16140              :                     }
   16141         1760 :                 } break;
   16142          464 :                 case DataSurfaces::SurfaceClass::Floor: {
   16143          464 :                     switch (curExtBoundCond) {
   16144            0 :                     case DataSurfaces::ExternalEnvironment: {
   16145            0 :                         delayOpaque(LoadCompRow::ExtFlr) += singleSurfDelay;
   16146            0 :                     } break;
   16147          364 :                     case DataSurfaces::Ground:
   16148              :                     case DataSurfaces::GroundFCfactorMethod:
   16149              :                     case DataSurfaces::KivaFoundation: {
   16150          364 :                         delayOpaque(LoadCompRow::GrdFlr) += singleSurfDelay;
   16151          364 :                     } break;
   16152            0 :                     case DataSurfaces::OtherSideCoefNoCalcExt:
   16153              :                     case DataSurfaces::OtherSideCoefCalcExt:
   16154              :                     case DataSurfaces::OtherSideCondModeledExt: {
   16155            0 :                         delayOpaque(LoadCompRow::OtherFlr) += singleSurfDelay;
   16156            0 :                     } break;
   16157          100 :                     default: { // interzone
   16158          100 :                         delayOpaque(LoadCompRow::IntZonFlr) += singleSurfDelay;
   16159          100 :                     } break;
   16160              :                     }
   16161          464 :                 } break;
   16162          452 :                 case DataSurfaces::SurfaceClass::Roof: {
   16163          452 :                     switch (curExtBoundCond) {
   16164            0 :                     case DataSurfaces::ExternalEnvironment: {
   16165            0 :                         delayOpaque(LoadCompRow::Roof) += singleSurfDelay;
   16166            0 :                     } 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          452 :                     default: { // interzone
   16176          452 :                         delayOpaque(LoadCompRow::IntZonCeil) += singleSurfDelay;
   16177          452 :                     } break;
   16178              :                     }
   16179          452 :                 } break;
   16180            0 :                 case DataSurfaces::SurfaceClass::Door: {
   16181            0 :                     delayOpaque(LoadCompRow::OpqDoor) += singleSurfDelay;
   16182            0 :                 } break;
   16183          500 :                 default:
   16184          500 :                     break;
   16185              :                 }
   16186              :             }
   16187          428 :         }
   16188         5136 :         for (int k = LoadCompRow::Roof; k <= LoadCompRow::OtherFlr; ++k) {
   16189         4708 :             resultCells(LoadCompCol::SensDelay, k) = delayOpaque(k);
   16190         4708 :             resCellsUsd(LoadCompCol::SensDelay, k) = true;
   16191              :         }
   16192          428 :         resultCells(LoadCompCol::SensDelay, LoadCompRow::OpqDoor) = delayOpaque(LoadCompRow::OpqDoor);
   16193          428 :         resCellsUsd(LoadCompCol::SensDelay, LoadCompRow::OpqDoor) = true;
   16194              :     }
   16195          428 : }
   16196              : 
   16197              : // for the load summary report add values the peak conditions subtable
   16198          428 : 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          428 :     if (timeOfMax != 0) {
   16208              : 
   16209          428 :         auto const &thisZone = state.dataHeatBal->Zone(zoneIndex);
   16210          428 :         Real64 mult = thisZone.Multiplier * thisZone.ListMultiplier;
   16211              :         auto const &szCalcFinalSizing =
   16212          428 :             (spaceIndex == 0) ? state.dataSize->CalcFinalZoneSizing(zoneIndex) : state.dataSize->CalcFinalSpaceSizing(spaceIndex);
   16213          428 :         auto const &szFinalSizing = (spaceIndex == 0) ? state.dataSize->FinalZoneSizing(zoneIndex) : state.dataSize->FinalSpaceSizing(spaceIndex);
   16214              : 
   16215          428 :         if (mult == 0.0) {
   16216            0 :             mult = 1.0;
   16217              :         }
   16218              : 
   16219          428 :         if (isCooling) {
   16220              :             // Time of Peak Load
   16221          219 :             if ((desDaySelected > 0) && ((size_t)desDaySelected <= state.dataWeather->DesDayInput.size())) {
   16222          657 :                 compLoad.peakDateHrMin = format("{}/{} {}",
   16223          219 :                                                 state.dataWeather->DesDayInput(desDaySelected).Month,
   16224          219 :                                                 state.dataWeather->DesDayInput(desDaySelected).DayOfMonth,
   16225          438 :                                                 state.dataRptCoilSelection->coilSelectionReportObj->getTimeText(state, timeOfMax));
   16226              :             } else {
   16227            0 :                 compLoad.peakDateHrMin = szCalcFinalSizing.CoolPeakDateHrMin;
   16228              :             }
   16229              : 
   16230              :             // Outside Dry Bulb Temperature
   16231          219 :             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          219 :             if (szCalcFinalSizing.CoolOutHumRatSeq(timeOfMax) < 1.0 && szCalcFinalSizing.CoolOutHumRatSeq(timeOfMax) > 0.0) {
   16236          438 :                 compLoad.outsideWetBulb = Psychrometrics::PsyTwbFnTdbWPb(
   16237          219 :                     state, szCalcFinalSizing.CoolOutTempSeq(timeOfMax), szCalcFinalSizing.CoolOutHumRatSeq(timeOfMax), state.dataEnvrn->StdBaroPress);
   16238              :             }
   16239              : 
   16240              :             // Outside Humidity Ratio at Peak
   16241          219 :             compLoad.outsideHumRatio = szCalcFinalSizing.CoolOutHumRatSeq(timeOfMax);
   16242              : 
   16243              :             // Zone Dry Bulb Temperature
   16244          219 :             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          219 :             compLoad.zoneRelHum = Psychrometrics::PsyRhFnTdbWPb(
   16249          219 :                 state, szCalcFinalSizing.CoolZoneTempSeq(timeOfMax), szCalcFinalSizing.CoolZoneHumRatSeq(timeOfMax), state.dataEnvrn->StdBaroPress);
   16250              : 
   16251              :             // Zone Humidity Ratio at Peak
   16252          219 :             compLoad.zoneHumRatio = szCalcFinalSizing.CoolZoneHumRatSeq(timeOfMax);
   16253              : 
   16254              :             // Peak Design Sensible Load
   16255          219 :             compLoad.peakDesSensLoad = szCalcFinalSizing.DesCoolLoad / mult; // change sign
   16256              : 
   16257              :             // Design Peak Load
   16258          219 :             compLoad.designPeakLoad = szFinalSizing.DesCoolLoad / mult;
   16259              : 
   16260              :             // Supply air temperature
   16261          219 :             if (szCalcFinalSizing.ZnCoolDgnSAMethod == DataSizing::SupplyAirTemperature) {
   16262          164 :                 compLoad.supAirTemp = szCalcFinalSizing.CoolDesTemp;
   16263              :             } else {
   16264           55 :                 Real64 DeltaTemp = -std::abs(szCalcFinalSizing.CoolDesTempDiff);
   16265           55 :                 compLoad.supAirTemp = DeltaTemp + szCalcFinalSizing.ZoneTempAtCoolPeak;
   16266              :             }
   16267              : 
   16268              :             // Main fan air flow
   16269          219 :             compLoad.mainFanAirFlow = szCalcFinalSizing.DesCoolVolFlow;
   16270              : 
   16271              :         } else {
   16272              :             // Time of Peak Load
   16273          209 :             if ((size_t)desDaySelected <= state.dataWeather->DesDayInput.size()) {
   16274          627 :                 compLoad.peakDateHrMin = format("{}/{} {}",
   16275          209 :                                                 state.dataWeather->DesDayInput(desDaySelected).Month,
   16276          209 :                                                 state.dataWeather->DesDayInput(desDaySelected).DayOfMonth,
   16277          418 :                                                 state.dataRptCoilSelection->coilSelectionReportObj->getTimeText(state, timeOfMax));
   16278              :             } else {
   16279            0 :                 compLoad.peakDateHrMin = szCalcFinalSizing.HeatPeakDateHrMin;
   16280              :             }
   16281              : 
   16282              :             // Outside Dry Bulb Temperature
   16283          209 :             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          209 :             if (szCalcFinalSizing.HeatOutHumRatSeq(timeOfMax) < 1.0 && szCalcFinalSizing.HeatOutHumRatSeq(timeOfMax) > 0.0) {
   16288          418 :                 compLoad.outsideWetBulb = Psychrometrics::PsyTwbFnTdbWPb(
   16289          209 :                     state, szCalcFinalSizing.HeatOutTempSeq(timeOfMax), szCalcFinalSizing.HeatOutHumRatSeq(timeOfMax), state.dataEnvrn->StdBaroPress);
   16290              :             }
   16291              : 
   16292              :             // Outside Humidity Ratio at Peak
   16293          209 :             compLoad.outsideHumRatio = szCalcFinalSizing.HeatOutHumRatSeq(timeOfMax);
   16294              : 
   16295              :             // Zone Dry Bulb Temperature
   16296          209 :             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          209 :             compLoad.zoneRelHum = Psychrometrics::PsyRhFnTdbWPb(
   16301          209 :                 state, szCalcFinalSizing.HeatZoneTempSeq(timeOfMax), szCalcFinalSizing.HeatZoneHumRatSeq(timeOfMax), state.dataEnvrn->StdBaroPress);
   16302              : 
   16303              :             // Zone Humidity Ratio at Peak
   16304          209 :             compLoad.zoneHumRatio = szCalcFinalSizing.HeatZoneHumRatSeq(timeOfMax);
   16305              : 
   16306              :             // Peak Design Sensible Load
   16307          209 :             compLoad.peakDesSensLoad = -szCalcFinalSizing.DesHeatLoad / mult; // change sign
   16308              : 
   16309              :             // Design Peak Load
   16310          209 :             compLoad.designPeakLoad = -szFinalSizing.DesHeatLoad / mult;
   16311              : 
   16312              :             // Supply air temperature
   16313          209 :             if (szCalcFinalSizing.ZnHeatDgnSAMethod == DataSizing::SupplyAirTemperature) {
   16314          154 :                 compLoad.supAirTemp = szCalcFinalSizing.HeatDesTemp;
   16315              :             } else {
   16316           55 :                 Real64 DeltaTemp = -std::abs(szCalcFinalSizing.HeatDesTempDiff);
   16317           55 :                 compLoad.supAirTemp = DeltaTemp + szCalcFinalSizing.ZoneTempAtHeatPeak;
   16318              :             }
   16319              : 
   16320              :             // Main fan air flow
   16321          209 :             compLoad.mainFanAirFlow = szCalcFinalSizing.DesHeatVolFlow;
   16322              :         }
   16323              : 
   16324              :         // Outside air flow
   16325          428 :         compLoad.outsideAirFlow = szCalcFinalSizing.MinOA;
   16326              : 
   16327              :         // outside air %
   16328          428 :         if (compLoad.mainFanAirFlow != 0.) {
   16329          428 :             compLoad.outsideAirRatio = compLoad.outsideAirFlow / compLoad.mainFanAirFlow;
   16330              :         }
   16331              : 
   16332          428 :         compLoad.floorArea = thisZone.FloorArea;
   16333              : 
   16334          428 :         if (compLoad.floorArea != 0.) {
   16335              :             // airflow per floor area
   16336          428 :             compLoad.airflowPerFlrArea = compLoad.mainFanAirFlow / compLoad.floorArea;
   16337              : 
   16338              :             // capacity per floor area
   16339          428 :             compLoad.totCapPerArea = compLoad.designPeakLoad / compLoad.floorArea;
   16340              :         }
   16341          428 :         if (compLoad.designPeakLoad != 0.) {
   16342              :             // airflow per capacity
   16343          428 :             compLoad.airflowPerTotCap = compLoad.mainFanAirFlow / compLoad.designPeakLoad;
   16344              : 
   16345              :             // floor area per capacity
   16346          428 :             compLoad.areaPerTotCap = thisZone.FloorArea / compLoad.designPeakLoad;
   16347              :         }
   16348              : 
   16349              :         // Number of people
   16350          428 :         Real64 totNumPeople = 0;
   16351          428 :         if (spaceIndex == 0) {
   16352          400 :             totNumPeople = std::accumulate(state.dataHeatBal->People.cbegin(),
   16353          800 :                                            state.dataHeatBal->People.cend(),
   16354              :                                            0.0,
   16355         7890 :                                            [&zoneIndex](const Real64 &sum, const DataHeatBalance::PeopleData &people) {
   16356         7890 :                                                return zoneIndex == people.ZonePtr ? (sum + people.NumberOfPeople) : sum;
   16357              :                                            });
   16358              :         } else {
   16359           28 :             totNumPeople = std::accumulate(state.dataHeatBal->People.cbegin(),
   16360           56 :                                            state.dataHeatBal->People.cend(),
   16361              :                                            0.0,
   16362          374 :                                            [&spaceIndex](const Real64 &sum, const DataHeatBalance::PeopleData &people) {
   16363          374 :                                                return spaceIndex == people.spaceIndex ? (sum + people.NumberOfPeople) : sum;
   16364              :                                            });
   16365              :         }
   16366          428 :         compLoad.numPeople = totNumPeople;
   16367              :     }
   16368          428 : }
   16369              : 
   16370            8 : void ComputeEngineeringChecks(CompLoadTablesType &compLoad)
   16371              : {
   16372              :     // outside air %
   16373            8 :     if (compLoad.mainFanAirFlow != 0.) {
   16374            8 :         compLoad.outsideAirRatio = compLoad.outsideAirFlow / compLoad.mainFanAirFlow;
   16375              :     }
   16376              : 
   16377            8 :     if (compLoad.floorArea != 0.) {
   16378              :         // airflow per floor area
   16379            8 :         compLoad.airflowPerFlrArea = compLoad.mainFanAirFlow / compLoad.floorArea;
   16380              : 
   16381              :         // capacity per floor area
   16382            8 :         compLoad.totCapPerArea = compLoad.designPeakLoad / compLoad.floorArea;
   16383              :     }
   16384            8 :     if (compLoad.designPeakLoad != 0.) {
   16385              :         // airflow per capacity
   16386            8 :         compLoad.airflowPerTotCap = compLoad.mainFanAirFlow / compLoad.designPeakLoad;
   16387              : 
   16388              :         // floor area per capacity
   16389            8 :         compLoad.areaPerTotCap = compLoad.floorArea / compLoad.designPeakLoad;
   16390              :     }
   16391            8 : }
   16392              : 
   16393              : // gather the areas used in the load component tables
   16394           27 : void GetZoneComponentAreas(EnergyPlusData &state, Array1D<ZompComponentAreasType> &znAreas, Array1D<ZompComponentAreasType> &spAreas)
   16395              : {
   16396          242 :     for (int iZone = 1; iZone <= state.dataGlobal->NumOfZones; ++iZone) {
   16397          215 :         znAreas(iZone).floor = state.dataHeatBal->Zone(iZone).FloorArea;
   16398              :     }
   16399           27 :     if (state.dataHeatBal->doSpaceHeatBalanceSizing) {
   16400           18 :         for (int iSpace = 1; iSpace <= state.dataGlobal->numSpaces; ++iSpace) {
   16401           16 :             spAreas(iSpace).floor = state.dataHeatBal->space(iSpace).FloorArea;
   16402              :         }
   16403              :     }
   16404              : 
   16405           27 :     bool isZone = true;
   16406         1913 :     for (auto const &curSurface : state.dataSurface->Surface) {
   16407         1886 :         if (!curSurface.HeatTransSurf) {
   16408          122 :             continue;
   16409              :         }
   16410         1764 :         addSurfaceArea(curSurface, znAreas, isZone);
   16411           27 :     }
   16412           27 :     if (state.dataHeatBal->doSpaceHeatBalanceSizing) {
   16413            2 :         isZone = false;
   16414          117 :         for (auto const &curSurface : state.dataSurface->Surface) {
   16415          115 :             addSurfaceArea(curSurface, spAreas, isZone);
   16416            2 :         }
   16417              :     }
   16418           27 : }
   16419         1879 : void addSurfaceArea(DataSurfaces::SurfaceData const &surf, Array1D<ZompComponentAreasType> &areas, bool isZone)
   16420              : {
   16421         1879 :     bool isExterior = surf.ExtBoundCond == DataSurfaces::ExternalEnvironment || surf.ExtBoundCond == DataSurfaces::OtherSideCondModeledExt;
   16422         3601 :     bool isTouchingGround = surf.ExtBoundCond == DataSurfaces::Ground || surf.ExtBoundCond == DataSurfaces::GroundFCfactorMethod ||
   16423         1722 :                             surf.ExtBoundCond == DataSurfaces::KivaFoundation;
   16424         1879 :     int curIndex = (isZone) ? surf.Zone : surf.spaceNum;
   16425         1879 :     switch (surf.Class) {
   16426          950 :     case DataSurfaces::SurfaceClass::Wall: {
   16427          950 :         if (isExterior) {
   16428          320 :             areas(curIndex).extWall += surf.GrossArea;
   16429          630 :         } else if (isTouchingGround) {
   16430            0 :             areas(curIndex).grndCntWall += surf.GrossArea;
   16431              :         } else {
   16432          630 :             areas(curIndex).intZoneWall += surf.GrossArea;
   16433              :         }
   16434          950 :     } break;
   16435          283 :     case DataSurfaces::SurfaceClass::Roof: {
   16436          283 :         if (isExterior) {
   16437           30 :             areas(curIndex).roof += surf.GrossArea;
   16438              :         } else {
   16439          253 :             areas(curIndex).ceiling += surf.GrossArea;
   16440              :         }
   16441          283 :     } break;
   16442          410 :     case DataSurfaces::SurfaceClass::Floor: {
   16443          410 :         if (isExterior) {
   16444            0 :             areas(curIndex).extFloor += surf.GrossArea;
   16445          410 :         } else if (isTouchingGround) {
   16446          157 :             areas(curIndex).grndCntFloor += surf.GrossArea;
   16447              :         } else {
   16448          253 :             areas(curIndex).intZoneFloor += surf.GrossArea;
   16449              :         }
   16450          410 :     } break;
   16451          212 :     case DataSurfaces::SurfaceClass::Window:
   16452              :     case DataSurfaces::SurfaceClass::TDD_Dome: {
   16453          212 :         areas(curIndex).fenestration += surf.GrossArea;
   16454          212 :     } break;
   16455            0 :     case DataSurfaces::SurfaceClass::Door:
   16456              :     case DataSurfaces::SurfaceClass::GlassDoor: {
   16457            0 :         areas(curIndex).door += surf.GrossArea;
   16458            0 :     } break;
   16459              :     }
   16460         1879 : }
   16461              : 
   16462              : // adds the area column for the load component tables
   16463          428 : void AddAreaColumnForZone(ZompComponentAreasType const &compAreas, CompLoadTablesType &compLoad)
   16464              : {
   16465          428 :     compLoad.cells(LoadCompCol::Area, LoadCompRow::People) = compAreas.floor;
   16466          428 :     compLoad.cellUsed(LoadCompCol::Area, LoadCompRow::People) = true;
   16467              : 
   16468          428 :     compLoad.cells(LoadCompCol::Area, LoadCompRow::Lights) = compAreas.floor;
   16469          428 :     compLoad.cellUsed(LoadCompCol::Area, LoadCompRow::Lights) = true;
   16470              : 
   16471          428 :     compLoad.cells(LoadCompCol::Area, LoadCompRow::Equip) = compAreas.floor;
   16472          428 :     compLoad.cellUsed(LoadCompCol::Area, LoadCompRow::Equip) = true;
   16473              : 
   16474          428 :     compLoad.cells(LoadCompCol::Area, LoadCompRow::Refrig) = compAreas.floor;
   16475          428 :     compLoad.cellUsed(LoadCompCol::Area, LoadCompRow::Refrig) = true;
   16476              : 
   16477          428 :     compLoad.cells(LoadCompCol::Area, LoadCompRow::WaterUse) = compAreas.floor;
   16478          428 :     compLoad.cellUsed(LoadCompCol::Area, LoadCompRow::WaterUse) = true;
   16479              : 
   16480          428 :     compLoad.cells(LoadCompCol::Area, LoadCompRow::Infil) = compAreas.extWall;
   16481          428 :     compLoad.cellUsed(LoadCompCol::Area, LoadCompRow::Infil) = true;
   16482              : 
   16483          428 :     compLoad.cells(LoadCompCol::Area, LoadCompRow::Roof) = compAreas.roof;
   16484          428 :     compLoad.cellUsed(LoadCompCol::Area, LoadCompRow::Roof) = true;
   16485              : 
   16486          428 :     compLoad.cells(LoadCompCol::Area, LoadCompRow::IntZonCeil) = compAreas.ceiling;
   16487          428 :     compLoad.cellUsed(LoadCompCol::Area, LoadCompRow::IntZonCeil) = true;
   16488              : 
   16489          428 :     compLoad.cells(LoadCompCol::Area, LoadCompRow::OtherRoof) = compAreas.roof;
   16490          428 :     compLoad.cellUsed(LoadCompCol::Area, LoadCompRow::OtherRoof) = true;
   16491              : 
   16492          428 :     compLoad.cells(LoadCompCol::Area, LoadCompRow::ExtWall) = compAreas.extWall;
   16493          428 :     compLoad.cellUsed(LoadCompCol::Area, LoadCompRow::ExtWall) = true;
   16494              : 
   16495          428 :     compLoad.cells(LoadCompCol::Area, LoadCompRow::IntZonWall) = compAreas.intZoneWall;
   16496          428 :     compLoad.cellUsed(LoadCompCol::Area, LoadCompRow::IntZonWall) = true;
   16497              : 
   16498          428 :     compLoad.cells(LoadCompCol::Area, LoadCompRow::GrdWall) = compAreas.grndCntWall;
   16499          428 :     compLoad.cellUsed(LoadCompCol::Area, LoadCompRow::GrdWall) = true;
   16500              : 
   16501          428 :     compLoad.cells(LoadCompCol::Area, LoadCompRow::OtherWall) = compAreas.extWall;
   16502          428 :     compLoad.cellUsed(LoadCompCol::Area, LoadCompRow::OtherWall) = true;
   16503              : 
   16504          428 :     compLoad.cells(LoadCompCol::Area, LoadCompRow::ExtFlr) = compAreas.extFloor;
   16505          428 :     compLoad.cellUsed(LoadCompCol::Area, LoadCompRow::ExtFlr) = true;
   16506              : 
   16507          428 :     compLoad.cells(LoadCompCol::Area, LoadCompRow::IntZonFlr) = compAreas.intZoneFloor;
   16508          428 :     compLoad.cellUsed(LoadCompCol::Area, LoadCompRow::IntZonFlr) = true;
   16509              : 
   16510          428 :     compLoad.cells(LoadCompCol::Area, LoadCompRow::GrdFlr) = compAreas.grndCntFloor;
   16511          428 :     compLoad.cellUsed(LoadCompCol::Area, LoadCompRow::GrdFlr) = true;
   16512              : 
   16513          428 :     compLoad.cells(LoadCompCol::Area, LoadCompRow::OtherFlr) = compAreas.intZoneFloor;
   16514          428 :     compLoad.cellUsed(LoadCompCol::Area, LoadCompRow::OtherFlr) = true;
   16515              : 
   16516          428 :     compLoad.cells(LoadCompCol::Area, LoadCompRow::FeneCond) = compAreas.fenestration;
   16517          428 :     compLoad.cellUsed(LoadCompCol::Area, LoadCompRow::FeneCond) = true;
   16518              : 
   16519          428 :     compLoad.cells(LoadCompCol::Area, LoadCompRow::FeneSolr) = compAreas.fenestration;
   16520          428 :     compLoad.cellUsed(LoadCompCol::Area, LoadCompRow::FeneSolr) = true;
   16521              : 
   16522          428 :     compLoad.cells(LoadCompCol::Area, LoadCompRow::OpqDoor) = compAreas.door;
   16523          428 :     compLoad.cellUsed(LoadCompCol::Area, LoadCompRow::OpqDoor) = true;
   16524          428 : }
   16525              : 
   16526              : // Used for the AirLoop and Facility level load component tables to sum the results from individual zones
   16527           40 : void CombineLoadCompResults(CompLoadTablesType &compLoadTotal, CompLoadTablesType const &compLoadPartial, Real64 const multiplier)
   16528              : {
   16529              :     // sum the main results
   16530          360 :     for (int col = 1; col <= LoadCompCol::PerArea; ++col) {
   16531         8640 :         for (int row = 1; row <= LoadCompRow::GrdTot; ++row) {
   16532         8320 :             compLoadTotal.cells(col, row) += compLoadPartial.cells(col, row) * multiplier;
   16533         8320 :             compLoadTotal.cellUsed(col, row) = compLoadTotal.cellUsed(col, row) || compLoadPartial.cellUsed(col, row);
   16534              :         }
   16535              :     }
   16536              : 
   16537              :     // take the partial value for these
   16538           40 :     compLoadTotal.desDayNum = compLoadPartial.desDayNum;
   16539           40 :     compLoadTotal.timeStepMax = compLoadPartial.timeStepMax;
   16540           40 :     compLoadTotal.peakDateHrMin = compLoadPartial.peakDateHrMin;
   16541           40 :     compLoadTotal.outsideDryBulb = compLoadPartial.outsideDryBulb;
   16542           40 :     compLoadTotal.outsideWetBulb = compLoadPartial.outsideWetBulb;
   16543           40 :     compLoadTotal.outsideHumRatio = compLoadPartial.outsideHumRatio;
   16544           40 :     compLoadTotal.zoneDryBulb = compLoadPartial.zoneDryBulb;
   16545           40 :     compLoadTotal.zoneRelHum = compLoadPartial.zoneRelHum;
   16546           40 :     compLoadTotal.zoneHumRatio = compLoadPartial.zoneHumRatio;
   16547           40 :     compLoadTotal.supAirTemp = compLoadPartial.supAirTemp;
   16548              : 
   16549              :     // sum the peak related values
   16550           40 :     compLoadTotal.designPeakLoad += compLoadPartial.designPeakLoad * multiplier;
   16551           40 :     compLoadTotal.diffDesignPeak += compLoadPartial.diffDesignPeak * multiplier;
   16552           40 :     compLoadTotal.peakDesSensLoad += compLoadPartial.peakDesSensLoad * multiplier;
   16553           40 :     compLoadTotal.estInstDelSensLoad += compLoadPartial.estInstDelSensLoad * multiplier;
   16554           40 :     compLoadTotal.diffPeakEst += compLoadPartial.diffPeakEst * multiplier;
   16555           40 :     compLoadTotal.mainFanAirFlow += compLoadPartial.mainFanAirFlow * multiplier;
   16556           40 :     compLoadTotal.outsideAirFlow += compLoadPartial.outsideAirFlow * multiplier;
   16557              : 
   16558              :     // sum the engineering checks
   16559           40 :     compLoadTotal.numPeople += compLoadPartial.numPeople * multiplier;
   16560           40 :     compLoadTotal.floorArea += compLoadPartial.floorArea * multiplier;
   16561           40 : }
   16562              : 
   16563              : // create the total row and total columns for the load summary tables
   16564          406 : void AddTotalRowsForLoadSummary(CompLoadTablesType &compLoadTotal)
   16565              : {
   16566              : 
   16567              :     // zero the grand total -total cell
   16568          406 :     compLoadTotal.cells(LoadCompCol::Total, LoadCompRow::GrdTot) = 0.;
   16569          406 :     compLoadTotal.cellUsed(LoadCompCol::Total, LoadCompRow::GrdTot) = true;
   16570              : 
   16571              :     // zero the grand total row
   16572         2030 :     for (int col = 1; col <= LoadCompCol::Latent; ++col) {
   16573         1624 :         compLoadTotal.cells(col, LoadCompRow::GrdTot) = 0.;
   16574         1624 :         compLoadTotal.cellUsed(col, LoadCompRow::GrdTot) = true;
   16575              :     }
   16576              : 
   16577        10556 :     for (int row = 1; row <= LoadCompRow::OpqDoor; ++row) {
   16578              :         // zero the total column
   16579        10150 :         compLoadTotal.cells(LoadCompCol::Total, row) = 0.;
   16580        10150 :         compLoadTotal.cellUsed(LoadCompCol::Total, row) = true;
   16581        50750 :         for (int col = 1; col <= LoadCompCol::Latent; ++col) {
   16582              :             // add the cell to the grand total row and total column
   16583        40600 :             if (compLoadTotal.cellUsed(col, row)) {
   16584        16240 :                 compLoadTotal.cells(LoadCompCol::Total, row) += compLoadTotal.cells(col, row);
   16585        16240 :                 compLoadTotal.cells(col, LoadCompRow::GrdTot) += compLoadTotal.cells(col, row);
   16586        16240 :                 compLoadTotal.cells(LoadCompCol::Total, LoadCompRow::GrdTot) += compLoadTotal.cells(col, row);
   16587              :             }
   16588              :         }
   16589              :     }
   16590              : 
   16591              :     // compute the % grand total column
   16592          406 :     Real64 grandTotalTotal = compLoadTotal.cells(LoadCompCol::Total, LoadCompRow::GrdTot);
   16593          406 :     if (grandTotalTotal != 0.0) {
   16594        10556 :         for (int row = 1; row <= LoadCompRow::OpqDoor; ++row) {
   16595        10150 :             compLoadTotal.cells(LoadCompCol::Perc, row) = 100 * compLoadTotal.cells(LoadCompCol::Total, row) / grandTotalTotal;
   16596        10150 :             compLoadTotal.cellUsed(LoadCompCol::Perc, row) = true;
   16597              :         }
   16598              :     }
   16599              :     // compute the Total per Area column
   16600        10556 :     for (int row = 1; row <= LoadCompRow::OpqDoor; ++row) {
   16601        10150 :         if (compLoadTotal.cellUsed(LoadCompCol::Total, row) && compLoadTotal.cells(LoadCompCol::Area, row) != 0.) {
   16602         9888 :             compLoadTotal.cells(LoadCompCol::PerArea, row) =
   16603         4944 :                 compLoadTotal.cells(LoadCompCol::Total, row) / compLoadTotal.cells(LoadCompCol::Area, row);
   16604         4944 :             compLoadTotal.cellUsed(LoadCompCol::PerArea, row) = true;
   16605              :         }
   16606              :     }
   16607          406 : }
   16608              : 
   16609              : // compute the peak difference between actual and estimated load in load component summary peak conditions table
   16610          406 : void ComputePeakDifference(CompLoadTablesType &compLoad)
   16611              : {
   16612              :     // Estimated Instant + Delayed Sensible Load
   16613          406 :     compLoad.estInstDelSensLoad =
   16614          406 :         compLoad.cells(LoadCompCol::SensInst, LoadCompRow::GrdTot) + compLoad.cells(LoadCompCol::SensDelay, LoadCompRow::GrdTot);
   16615              : 
   16616              :     // Difference
   16617          406 :     compLoad.diffPeakEst = compLoad.peakDesSensLoad - compLoad.estInstDelSensLoad;
   16618              : 
   16619              :     // Peak Design Diff
   16620          406 :     compLoad.diffDesignPeak = compLoad.designPeakLoad - compLoad.peakDesSensLoad;
   16621          406 : }
   16622              : 
   16623              : // apply unit conversions to the load components summary tables
   16624            0 : void LoadSummaryUnitConversion(EnergyPlusData &state, CompLoadTablesType &compLoadTotal)
   16625              : {
   16626            0 :     auto const &ort = state.dataOutRptTab;
   16627              : 
   16628            0 :     if (!ort->ip()) {
   16629            0 :         return;
   16630              :     }
   16631              : 
   16632            0 :     Real64 const powerConversion = getSpecificUnitMultiplier(state, "W", "Btu/h");
   16633            0 :     Real64 const areaConversion = getSpecificUnitMultiplier(state, "m2", "ft2");
   16634            0 :     Real64 const powerPerAreaConversion = getSpecificUnitMultiplier(state, "W/m2", "Btu/h-ft2");
   16635            0 :     Real64 const airFlowConversion = getSpecificUnitMultiplier(state, "m3/s", "ft3/min");
   16636            0 :     Real64 const airFlowPerAreaConversion = getSpecificUnitMultiplier(state, "m3/s-m2", "ft3/min-ft2");
   16637            0 :     Real64 const powerPerFlowLiquidConversion = getSpecificUnitMultiplier(state, "W-s/m3", "W-min/gal");
   16638            0 :     for (int row = 1; row <= LoadCompRow::GrdTot; ++row) {
   16639            0 :         for (int col = 1; col <= LoadCompCol::Total; ++col) {
   16640            0 :             if (compLoadTotal.cellUsed(col, row)) {
   16641            0 :                 compLoadTotal.cells(col, row) *= powerConversion;
   16642              :             }
   16643              :         }
   16644            0 :         if (compLoadTotal.cellUsed(LoadCompCol::PerArea, row)) {
   16645            0 :             compLoadTotal.cells(LoadCompCol::PerArea, row) *= powerConversion;
   16646              :         }
   16647            0 :         if (compLoadTotal.cellUsed(LoadCompCol::Area, row)) {
   16648            0 :             compLoadTotal.cells(LoadCompCol::Area, row) *= areaConversion;
   16649              :         }
   16650            0 :         if (compLoadTotal.cellUsed(LoadCompCol::PerArea, row)) {
   16651            0 :             compLoadTotal.cells(LoadCompCol::PerArea, row) *= powerPerAreaConversion;
   16652              :         }
   16653              :     }
   16654            0 :     int const tempConvIndx = getSpecificUnitIndex(state, "C", "F");
   16655            0 :     compLoadTotal.outsideDryBulb = ConvertIP(state, tempConvIndx, compLoadTotal.outsideDryBulb);
   16656            0 :     compLoadTotal.outsideWetBulb = ConvertIP(state, tempConvIndx, compLoadTotal.outsideWetBulb);
   16657            0 :     compLoadTotal.zoneDryBulb = ConvertIP(state, tempConvIndx, compLoadTotal.zoneDryBulb);
   16658            0 :     compLoadTotal.peakDesSensLoad *= powerConversion;
   16659              : 
   16660            0 :     compLoadTotal.supAirTemp = ConvertIP(state, tempConvIndx, compLoadTotal.supAirTemp);
   16661            0 :     compLoadTotal.mixAirTemp = ConvertIP(state, tempConvIndx, compLoadTotal.mixAirTemp);
   16662            0 :     compLoadTotal.mainFanAirFlow *= airFlowConversion;
   16663            0 :     compLoadTotal.outsideAirFlow *= airFlowConversion;
   16664            0 :     compLoadTotal.designPeakLoad *= powerConversion;
   16665            0 :     compLoadTotal.diffDesignPeak *= powerConversion;
   16666              : 
   16667            0 :     compLoadTotal.estInstDelSensLoad *= powerConversion;
   16668            0 :     compLoadTotal.diffPeakEst *= powerConversion;
   16669              : 
   16670            0 :     compLoadTotal.airflowPerFlrArea *= airFlowPerAreaConversion;
   16671            0 :     if (powerConversion != 0.) {
   16672            0 :         compLoadTotal.airflowPerTotCap = compLoadTotal.airflowPerTotCap * airFlowPerAreaConversion / powerConversion;
   16673            0 :         compLoadTotal.areaPerTotCap = compLoadTotal.areaPerTotCap * areaConversion / powerConversion;
   16674              :     }
   16675            0 :     if (areaConversion != 0.) {
   16676            0 :         compLoadTotal.totCapPerArea = compLoadTotal.totCapPerArea * powerConversion / areaConversion;
   16677              :     }
   16678            0 :     compLoadTotal.chlPumpPerFlow *= powerPerFlowLiquidConversion;
   16679            0 :     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          406 : void LoadSummaryUnitConversion(EnergyPlusData &state, CompLoadTablesType &compLoadTotal, UnitsStyle unitsStyle_para)
   16686              : {
   16687          406 :     if (unitsStyle_para == OutputReportTabular::UnitsStyle::InchPound ||
   16688              :         unitsStyle_para == OutputReportTabular::UnitsStyle::InchPoundExceptElectricity) {
   16689            0 :         Real64 powerConversion = getSpecificUnitMultiplier(state, "W", "Btu/h");
   16690            0 :         Real64 areaConversion = getSpecificUnitMultiplier(state, "m2", "ft2");
   16691            0 :         Real64 powerPerAreaConversion = getSpecificUnitMultiplier(state, "W/m2", "Btu/h-ft2");
   16692            0 :         Real64 airFlowConversion = getSpecificUnitMultiplier(state, "m3/s", "ft3/min");
   16693            0 :         Real64 airFlowPerAreaConversion = getSpecificUnitMultiplier(state, "m3/s-m2", "ft3/min-ft2");
   16694            0 :         Real64 powerPerFlowLiquidConversion = getSpecificUnitMultiplier(state, "W-s/m3", "W-min/gal");
   16695            0 :         for (int row = 1; row <= LoadCompRow::GrdTot; ++row) {
   16696            0 :             for (int col = 1; col <= LoadCompCol::Total; ++col) {
   16697            0 :                 if (compLoadTotal.cellUsed(col, row)) {
   16698            0 :                     compLoadTotal.cells(col, row) *= powerConversion;
   16699              :                 }
   16700              :             }
   16701            0 :             if (compLoadTotal.cellUsed(LoadCompCol::PerArea, row)) {
   16702            0 :                 compLoadTotal.cells(LoadCompCol::PerArea, row) *= powerConversion;
   16703              :             }
   16704            0 :             if (compLoadTotal.cellUsed(LoadCompCol::Area, row)) {
   16705            0 :                 compLoadTotal.cells(LoadCompCol::Area, row) *= areaConversion;
   16706              :             }
   16707            0 :             if (compLoadTotal.cellUsed(LoadCompCol::PerArea, row)) {
   16708            0 :                 compLoadTotal.cells(LoadCompCol::PerArea, row) *= powerPerAreaConversion;
   16709              :             }
   16710              :         }
   16711            0 :         int tempConvIndx = getSpecificUnitIndex(state, "C", "F");
   16712            0 :         compLoadTotal.outsideDryBulb = ConvertIP(state, tempConvIndx, compLoadTotal.outsideDryBulb);
   16713            0 :         compLoadTotal.outsideWetBulb = ConvertIP(state, tempConvIndx, compLoadTotal.outsideWetBulb);
   16714            0 :         compLoadTotal.zoneDryBulb = ConvertIP(state, tempConvIndx, compLoadTotal.zoneDryBulb);
   16715            0 :         compLoadTotal.peakDesSensLoad *= powerConversion;
   16716              : 
   16717            0 :         compLoadTotal.supAirTemp = ConvertIP(state, tempConvIndx, compLoadTotal.supAirTemp);
   16718            0 :         compLoadTotal.mixAirTemp = ConvertIP(state, tempConvIndx, compLoadTotal.mixAirTemp);
   16719            0 :         compLoadTotal.mainFanAirFlow *= airFlowConversion;
   16720            0 :         compLoadTotal.outsideAirFlow *= airFlowConversion;
   16721            0 :         compLoadTotal.designPeakLoad *= powerConversion;
   16722            0 :         compLoadTotal.diffDesignPeak *= powerConversion;
   16723              : 
   16724            0 :         compLoadTotal.estInstDelSensLoad *= powerConversion;
   16725            0 :         compLoadTotal.diffPeakEst *= powerConversion;
   16726              : 
   16727            0 :         compLoadTotal.airflowPerFlrArea *= airFlowPerAreaConversion;
   16728            0 :         if (powerConversion != 0.) {
   16729            0 :             compLoadTotal.airflowPerTotCap = compLoadTotal.airflowPerTotCap * airFlowPerAreaConversion / powerConversion;
   16730            0 :             compLoadTotal.areaPerTotCap = compLoadTotal.areaPerTotCap * areaConversion / powerConversion;
   16731              :         }
   16732            0 :         if (areaConversion != 0.) {
   16733            0 :             compLoadTotal.totCapPerArea = compLoadTotal.totCapPerArea * powerConversion / areaConversion;
   16734              :         }
   16735            0 :         compLoadTotal.chlPumpPerFlow *= powerPerFlowLiquidConversion;
   16736            0 :         compLoadTotal.cndPumpPerFlow *= powerPerFlowLiquidConversion;
   16737              :     }
   16738          406 : }
   16739              : 
   16740              : // make a list of the zones for the airloop component loads report
   16741            4 : void CreateListOfZonesForAirLoop(EnergyPlusData const &state, CompLoadTablesType &compLoad, Array1D_int const &zoneToAirLoop, int const curAirLoop)
   16742              : {
   16743            4 :     int counter = 0;
   16744           28 :     for (int zi = 1; zi <= state.dataGlobal->NumOfZones; ++zi) {
   16745           24 :         if (zoneToAirLoop(zi) == curAirLoop) {
   16746           20 :             ++counter;
   16747           20 :             compLoad.zoneIndices(counter) = zi;
   16748              :         }
   16749              :     }
   16750            4 : }
   16751              : 
   16752              : // Jan 2021: Added additional parameters to accommodate dual-unit reporting
   16753              : // provide output from the load component summary tables
   16754          203 : 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          203 :     auto const &ort = state.dataOutRptTab;
   16765              : 
   16766          203 :     std::string reportName;
   16767          203 :     std::string zoneAirLoopFacilityName;
   16768          203 :     bool writeOutput = false;
   16769              : 
   16770          203 :     if (kind == OutputType::Space && ort->displayZoneComponentLoadSummary) {
   16771           14 :         reportName = "Space Component Load Summary";
   16772           14 :         zoneAirLoopFacilityName = state.dataHeatBal->space(zoneOrAirLoopIndex).Name;
   16773           14 :         writeOutput = true;
   16774          189 :     } else if (kind == OutputType::Zone && ort->displayZoneComponentLoadSummary) {
   16775          185 :         reportName = "Zone Component Load Summary";
   16776          185 :         zoneAirLoopFacilityName = state.dataHeatBal->Zone(zoneOrAirLoopIndex).Name;
   16777          185 :         writeOutput = true;
   16778            4 :     } else if (kind == OutputType::AirLoop && ort->displayAirLoopComponentLoadSummary) {
   16779            2 :         reportName = "AirLoop Component Load Summary";
   16780            2 :         zoneAirLoopFacilityName = state.dataSize->FinalSysSizing(zoneOrAirLoopIndex).AirPriLoopName;
   16781            2 :         writeOutput = true;
   16782            2 :     } else if (kind == OutputType::Facility && ort->displayFacilityComponentLoadSummary) {
   16783            2 :         reportName = "Facility Component Load Summary";
   16784            2 :         zoneAirLoopFacilityName = "Facility";
   16785            2 :         writeOutput = true;
   16786              :     } else {
   16787            0 :         writeOutput = false;
   16788              :     }
   16789              : 
   16790          203 :     if (!writeOutput) {
   16791            0 :         return;
   16792              :     }
   16793              : 
   16794          203 :     CompLoadTablesType curCompLoad;
   16795          203 :     Array1D_string columnHead;
   16796          203 :     Array1D_int columnWidth;
   16797          203 :     Array1D_string rowHead;
   16798          203 :     Array2D_string tableBody; //(row, column)
   16799              : 
   16800          203 :     if (produceTabular_para) {
   16801          203 :         WriteReportHeaders(state, reportName, zoneAirLoopFacilityName, OutputProcessor::StoreType::Average);
   16802              :     }
   16803          203 :     std::string peakLoadCompName;
   16804          203 :     std::string peakCondName;
   16805          203 :     std::string zonesIncludedName;
   16806          203 :     std::string engineeringCheckName;
   16807          609 :     for (int coolHeat = 1; coolHeat <= 2; ++coolHeat) {
   16808          406 :         tableBody.allocate(LoadCompCol::PerArea, LoadCompRow::GrdTot);
   16809          406 :         tableBody = "";
   16810          406 :         if (coolHeat == 1) {
   16811          203 :             curCompLoad = compLoadCool;
   16812          203 :             peakLoadCompName = "Estimated Cooling Peak Load Components";
   16813          203 :             peakCondName = "Cooling Peak Conditions";
   16814          203 :             zonesIncludedName = "Zones Included for Cooling";
   16815          203 :             engineeringCheckName = "Engineering Checks for Cooling";
   16816              :         } else {
   16817          203 :             curCompLoad = compLoadHeat;
   16818          203 :             peakLoadCompName = "Estimated Heating Peak Load Components";
   16819          203 :             peakCondName = "Heating Peak Conditions";
   16820          203 :             zonesIncludedName = "Zones Included for Heating";
   16821          203 :             engineeringCheckName = "Engineering Checks for Heating";
   16822              :         }
   16823              :         // move number array into string array
   16824         3654 :         for (int c = 1; c <= LoadCompCol::PerArea; ++c) {
   16825        87696 :             for (int r = 1; r <= LoadCompRow::GrdTot; ++r) { // to last row before total
   16826        84448 :                 if (curCompLoad.cellUsed(c, r)) {
   16827        51634 :                     tableBody(c, r) = RealToStr(curCompLoad.cells(c, r), 2);
   16828              :                 }
   16829              :             }
   16830              :         }
   16831          406 :         rowHead.allocate(LoadCompRow::GrdTot);
   16832              :         // internal gains
   16833          406 :         rowHead(LoadCompRow::People) = "People";
   16834          406 :         rowHead(LoadCompRow::Lights) = "Lights";
   16835          406 :         rowHead(LoadCompRow::Equip) = "Equipment";
   16836          406 :         rowHead(LoadCompRow::Refrig) = "Refrigeration Equipment";
   16837          406 :         rowHead(LoadCompRow::WaterUse) = "Water Use Equipment";
   16838          406 :         rowHead(LoadCompRow::PowerGen) = "Power Generation Equipment";
   16839          406 :         rowHead(LoadCompRow::HvacLoss) = "HVAC Equipment Losses";
   16840          406 :         rowHead(LoadCompRow::Refrig) = "Refrigeration";
   16841              :         // misc
   16842          406 :         rowHead(LoadCompRow::DOAS) = "DOAS Direct to Zone";
   16843          406 :         rowHead(LoadCompRow::Infil) = "Infiltration";
   16844          406 :         rowHead(LoadCompRow::ZoneVent) = "Zone Ventilation";
   16845          406 :         rowHead(LoadCompRow::IntZonMix) = "Interzone Mixing";
   16846              :         // opaque surfaces
   16847          406 :         rowHead(LoadCompRow::Roof) = "Roof";
   16848          406 :         rowHead(LoadCompRow::IntZonCeil) = "Interzone Ceiling";
   16849          406 :         rowHead(LoadCompRow::OtherRoof) = "Other Roof";
   16850          406 :         rowHead(LoadCompRow::ExtWall) = "Exterior Wall";
   16851          406 :         rowHead(LoadCompRow::IntZonWall) = "Interzone Wall";
   16852          406 :         rowHead(LoadCompRow::GrdWall) = "Ground Contact Wall";
   16853          406 :         rowHead(LoadCompRow::OtherWall) = "Other Wall";
   16854          406 :         rowHead(LoadCompRow::ExtFlr) = "Exterior Floor";
   16855          406 :         rowHead(LoadCompRow::IntZonFlr) = "Interzone Floor";
   16856          406 :         rowHead(LoadCompRow::GrdFlr) = "Ground Contact Floor";
   16857          406 :         rowHead(LoadCompRow::OtherFlr) = "Other Floor";
   16858              :         // subsurfaces
   16859          406 :         rowHead(LoadCompRow::FeneCond) = "Fenestration Conduction";
   16860          406 :         rowHead(LoadCompRow::FeneSolr) = "Fenestration Solar";
   16861          406 :         rowHead(LoadCompRow::OpqDoor) = "Opaque Door";
   16862          406 :         rowHead(LoadCompRow::GrdTot) = "Grand Total";
   16863              : 
   16864          406 :         columnHead.allocate(LoadCompCol::PerArea);
   16865          406 :         if (!(unitsStyle_para == OutputReportTabular::UnitsStyle::InchPound ||
   16866              :               unitsStyle_para == OutputReportTabular::UnitsStyle::InchPoundExceptElectricity)) {
   16867          406 :             columnHead(LoadCompCol::SensInst) = "Sensible - Instant [W]";
   16868          406 :             columnHead(LoadCompCol::SensDelay) = "Sensible - Delayed [W]";
   16869          406 :             columnHead(LoadCompCol::SensRA) = "Sensible - Return Air [W]";
   16870          406 :             columnHead(LoadCompCol::Latent) = "Latent [W]";
   16871          406 :             columnHead(LoadCompCol::Total) = "Total [W]";
   16872          406 :             columnHead(LoadCompCol::Perc) = "%Grand Total";
   16873          406 :             columnHead(LoadCompCol::Area) = "Related Area [m2]";
   16874          406 :             columnHead(LoadCompCol::PerArea) = "Total per Area [W/m2]";
   16875              :         } else {
   16876            0 :             columnHead(LoadCompCol::SensInst) = "Sensible - Instant [Btu/h]";
   16877            0 :             columnHead(LoadCompCol::SensDelay) = "Sensible - Delayed [Btu/h]";
   16878            0 :             columnHead(LoadCompCol::SensRA) = "Sensible - Return Air [Btu/h]";
   16879            0 :             columnHead(LoadCompCol::Latent) = "Latent [Btu/h]";
   16880            0 :             columnHead(LoadCompCol::Total) = "Total [Btu/h]";
   16881            0 :             columnHead(LoadCompCol::Perc) = "%Grand Total";
   16882            0 :             columnHead(LoadCompCol::Area) = "Related Area [ft2]";
   16883            0 :             columnHead(LoadCompCol::PerArea) = "Total per Area [Btu/h-ft2]";
   16884              :         }
   16885          406 :         columnWidth.dimension(LoadCompCol::PerArea, 14); // array assignment - same for all columns
   16886              : 
   16887          406 :         if (produceTabular_para) {
   16888          406 :             WriteSubtitle(state, peakLoadCompName);
   16889          406 :             WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
   16890              :         }
   16891          406 :         if (produceSQLite_para) {
   16892          406 :             if (state.dataSQLiteProcedures->sqlite) {
   16893          120 :                 state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
   16894              :                     tableBody, rowHead, columnHead, reportName, zoneAirLoopFacilityName, peakLoadCompName);
   16895              :             }
   16896              :         }
   16897          406 :         if (produceTabular_para) {
   16898          406 :             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          406 :         rowHead.allocate(16);
   16907          406 :         columnHead.allocate(1);
   16908          406 :         columnWidth.allocate(1);
   16909          406 :         columnWidth = 14; // array assignment - same for all columns
   16910              : 
   16911          406 :         tableBody.allocate(1, 16);
   16912          406 :         tableBody = "";
   16913              : 
   16914          406 :         columnHead(1) = "Value";
   16915          406 :         if (!(unitsStyle_para == OutputReportTabular::UnitsStyle::InchPound ||
   16916              :               unitsStyle_para == OutputReportTabular::UnitsStyle::InchPoundExceptElectricity)) {
   16917          406 :             rowHead(1) = "Time of Peak Load";
   16918          406 :             rowHead(2) = "Outside Dry Bulb Temperature [C]";
   16919          406 :             rowHead(3) = "Outside Wet Bulb Temperature [C]";
   16920          406 :             rowHead(4) = "Outside Humidity Ratio at Peak [kgWater/kgDryAir]";
   16921          406 :             rowHead(5) = "Zone Dry Bulb Temperature [C]";
   16922          406 :             rowHead(6) = "Zone Relative Humidity [%]";
   16923          406 :             rowHead(7) = "Zone Humidity Ratio at Peak [kgWater/kgDryAir]";
   16924              : 
   16925          406 :             rowHead(8) = "Supply Air Temperature [C]";
   16926          406 :             rowHead(9) = "Mixed Air Temperature [C]";
   16927          406 :             rowHead(10) = "Main Fan Air Flow [m3/s]";
   16928          406 :             rowHead(11) = "Outside Air Flow [m3/s]";
   16929          406 :             rowHead(12) = "Peak Sensible Load with Sizing Factor [W]";
   16930          406 :             rowHead(13) = "Difference Due to Sizing Factor [W]";
   16931              : 
   16932          406 :             rowHead(14) = "Peak Sensible Load [W]";
   16933          406 :             rowHead(15) = "Estimated Instant + Delayed Sensible Load [W]";
   16934          406 :             rowHead(16) = "Difference Between Peak and Estimated Sensible Load [W]";
   16935              :         } else {
   16936            0 :             rowHead(1) = "Time of Peak Load";
   16937            0 :             rowHead(2) = "Outside Dry Bulb Temperature [F]";
   16938            0 :             rowHead(3) = "Outside Wet Bulb Temperature [F]";
   16939            0 :             rowHead(4) = "Outside Humidity Ratio at Peak [lbWater/lbAir]";
   16940            0 :             rowHead(5) = "Zone Dry Bulb Temperature [F]";
   16941            0 :             rowHead(6) = "Zone Relative Humidity [%]";
   16942            0 :             rowHead(7) = "Zone Humidity Ratio at Peak [lbWater/lbAir]";
   16943              : 
   16944            0 :             rowHead(8) = "Supply Air Temperature [F]";
   16945            0 :             rowHead(9) = "Mixed Air Temperature [F]";
   16946            0 :             rowHead(10) = "Main Fan Air Flow [ft3/min]";
   16947            0 :             rowHead(11) = "Outside Air Flow [ft3/min]";
   16948            0 :             rowHead(12) = "Peak Sensible Load with Sizing Factor [Btu/h]";
   16949            0 :             rowHead(13) = "Difference Due to Sizing Factor [Btu/h]";
   16950              : 
   16951            0 :             rowHead(14) = "Peak Sensible Load  [Btu/h]";
   16952            0 :             rowHead(15) = "Estimated Instant + Delayed Sensible Load [Btu/h]";
   16953            0 :             rowHead(16) = "Difference Between Peak and Estimated Sensible Load [Btu/h]";
   16954              :         }
   16955              : 
   16956          406 :         if (curCompLoad.timeStepMax != 0) {
   16957          406 :             tableBody(1, 1) = curCompLoad.peakDateHrMin;                  // Time of Peak Load
   16958          406 :             tableBody(1, 2) = RealToStr(curCompLoad.outsideDryBulb, 2);   // Outside Dry Bulb Temperature
   16959          406 :             tableBody(1, 3) = RealToStr(curCompLoad.outsideWetBulb, 2);   // Outside Wet Bulb Temperature
   16960          406 :             tableBody(1, 4) = RealToStr(curCompLoad.outsideHumRatio, 5);  // Outside Humidity Ratio at Peak
   16961          406 :             tableBody(1, 5) = RealToStr(curCompLoad.zoneDryBulb, 2);      // Zone Dry Bulb Temperature
   16962          406 :             tableBody(1, 6) = RealToStr(100 * curCompLoad.zoneRelHum, 2); // Zone Relative Humidity
   16963          406 :             tableBody(1, 7) = RealToStr(curCompLoad.zoneHumRatio, 5);     // Zone Humidity Ratio at Peak
   16964              :         }
   16965          406 :         tableBody(1, 8) = RealToStr(curCompLoad.supAirTemp, 2); // supply air temperature
   16966          406 :         if (kind == OutputType::AirLoop) {
   16967            4 :             tableBody(1, 9) = RealToStr(curCompLoad.mixAirTemp, 2); // mixed air temperature - not for zone or facility
   16968              :         }
   16969          406 :         tableBody(1, 10) = RealToStr(curCompLoad.mainFanAirFlow, 4);     // main fan air flow
   16970          406 :         tableBody(1, 11) = RealToStr(curCompLoad.outsideAirFlow, 4);     // outside air flow
   16971          406 :         tableBody(1, 12) = RealToStr(curCompLoad.designPeakLoad, 2);     // design peak load
   16972          406 :         tableBody(1, 13) = RealToStr(curCompLoad.diffDesignPeak, 2);     // difference between Design and Peak Load
   16973          406 :         tableBody(1, 14) = RealToStr(curCompLoad.peakDesSensLoad, 2);    // Peak Design Sensible Load
   16974          406 :         tableBody(1, 15) = RealToStr(curCompLoad.estInstDelSensLoad, 2); // Estimated Instant + Delayed Sensible Load
   16975          406 :         tableBody(1, 16) = RealToStr(curCompLoad.diffPeakEst, 2);        // Difference
   16976              : 
   16977          406 :         if (produceTabular_para) {
   16978          406 :             WriteSubtitle(state, peakCondName);
   16979          406 :             WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
   16980              :         }
   16981          406 :         if (produceSQLite_para) {
   16982          406 :             if (state.dataSQLiteProcedures->sqlite) {
   16983          120 :                 state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
   16984              :                     tableBody, rowHead, columnHead, reportName, zoneAirLoopFacilityName, peakCondName);
   16985              :             }
   16986              :         }
   16987          406 :         if (produceTabular_para) {
   16988          406 :             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          406 :         rowHead.allocate(6);
   16997          406 :         columnHead.allocate(1);
   16998          406 :         columnWidth.allocate(1);
   16999          406 :         columnWidth = 14; // array assignment - same for all columns
   17000              : 
   17001          406 :         tableBody.allocate(1, 6);
   17002          406 :         tableBody = "";
   17003              : 
   17004          406 :         columnHead(1) = "Value";
   17005          406 :         if (!(unitsStyle_para == OutputReportTabular::UnitsStyle::InchPound ||
   17006              :               unitsStyle_para == OutputReportTabular::UnitsStyle::InchPoundExceptElectricity)) {
   17007          406 :             rowHead(1) = "Outside Air Fraction [fraction]";
   17008          406 :             rowHead(2) = "Airflow per Floor Area [m3/s-m2]";
   17009          406 :             rowHead(3) = "Airflow per Total Capacity [m3/s-W]";
   17010          406 :             rowHead(4) = "Floor Area per Total Capacity [m2/W]";
   17011          406 :             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          406 :             rowHead(6) = "Number of People";
   17015              :         } else {
   17016            0 :             rowHead(1) = "Outside Air Fraction [fraction]";
   17017            0 :             rowHead(2) = "Airflow per Floor Area [ft3/min-ft2]";
   17018            0 :             rowHead(3) = "Airflow per Total Capacity [ft3-h/min-Btu]";
   17019            0 :             rowHead(4) = "Floor Area per Total Capacity [ft2-h/Btu]";
   17020            0 :             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            0 :             rowHead(6) = "Number of People";
   17024              :         }
   17025              : 
   17026          812 :         tableBody(1, 1) = fmt::format("{:.{}f}", curCompLoad.outsideAirRatio, 4); // outside Air
   17027          406 :         tableBody(1, 2) = fmt::format("{:0.3E}", curCompLoad.airflowPerFlrArea);  // airflow per floor area
   17028          406 :         tableBody(1, 3) = fmt::format("{:0.3E}", curCompLoad.airflowPerTotCap);   // airflow per total capacity
   17029          406 :         tableBody(1, 4) = fmt::format("{:0.3E}", curCompLoad.areaPerTotCap);      // area per total capacity
   17030          406 :         tableBody(1, 5) = fmt::format("{:0.3E}", curCompLoad.totCapPerArea);      // total capacity per area
   17031          812 :         tableBody(1, 6) = fmt::format("{:.{}f}", curCompLoad.numPeople, 1);       // number of people
   17032              : 
   17033          406 :         if (produceTabular_para) {
   17034          406 :             WriteSubtitle(state, engineeringCheckName);
   17035          406 :             WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
   17036              :         }
   17037          406 :         if (produceSQLite_para) {
   17038          406 :             if (state.dataSQLiteProcedures->sqlite) {
   17039          120 :                 state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
   17040              :                     tableBody, rowHead, columnHead, reportName, zoneAirLoopFacilityName, engineeringCheckName);
   17041              :             }
   17042              :         }
   17043          406 :         if (produceTabular_para) {
   17044          406 :             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          406 :         if (kind == OutputType::AirLoop && curCompLoad.zoneIndices.allocated()) {
   17052            4 :             int maxRow = 0;
   17053           28 :             for (size_t zi = 1; zi <= curCompLoad.zoneIndices.size(); ++zi) {
   17054           24 :                 if (curCompLoad.zoneIndices(zi) > 0) {
   17055           20 :                     maxRow = zi;
   17056              :                 }
   17057              :             }
   17058              : 
   17059            4 :             rowHead.allocate(maxRow);
   17060            4 :             columnHead.allocate(1);
   17061            4 :             columnWidth.allocate(1);
   17062            4 :             columnWidth = 14; // array assignment - same for all columns
   17063            4 :             tableBody.allocate(1, maxRow);
   17064            4 :             tableBody = "";
   17065              : 
   17066            4 :             columnHead(1) = "Zone Name";
   17067           24 :             for (int zi = 1; zi <= maxRow; ++zi) {
   17068           20 :                 rowHead(zi) = fmt::to_string(zi);
   17069           20 :                 if (curCompLoad.zoneIndices(zi) > 0) {
   17070           20 :                     tableBody(1, zi) = state.dataHeatBal->Zone(curCompLoad.zoneIndices(zi)).Name;
   17071              :                 }
   17072              :             }
   17073              : 
   17074            4 :             if (produceTabular_para) {
   17075            4 :                 WriteSubtitle(state, zonesIncludedName);
   17076            4 :                 WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
   17077              :             }
   17078            4 :             if (produceSQLite_para) {
   17079            4 :                 if (state.dataSQLiteProcedures->sqlite) {
   17080            0 :                     state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
   17081              :                         tableBody, rowHead, columnHead, reportName, zoneAirLoopFacilityName, zonesIncludedName);
   17082              :                 }
   17083              :             }
   17084            4 :             if (produceTabular_para) {
   17085            4 :                 if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
   17086            0 :                     state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(
   17087              :                         tableBody, rowHead, columnHead, reportName, zoneAirLoopFacilityName, zonesIncludedName);
   17088              :                 }
   17089              :             }
   17090              :         }
   17091              :     }
   17092          203 : }
   17093              : 
   17094        19446 : 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        19446 :     std::string const modifiedReportName(reportName + (averageOrSum == OutputProcessor::StoreType::Sum ? " per second" : ""));
   17110        19446 :     auto &ort = state.dataOutRptTab;
   17111              : 
   17112        41818 :     for (int iStyle = 1; iStyle <= ort->numStyles; ++iStyle) {
   17113        22372 :         std::ostream &tbl_stream(*ort->TabularOutputFile(iStyle));
   17114        22372 :         std::string const &curDel(ort->del(iStyle));
   17115        22372 :         TableStyle const style = ort->TableStyle(iStyle);
   17116        22372 :         if ((style == TableStyle::Comma) || (style == TableStyle::Tab)) {
   17117         2177 :             tbl_stream << "----------------------------------------------------------------------------------------------------\n";
   17118         2177 :             tbl_stream << "REPORT:" << curDel << modifiedReportName << '\n';
   17119         2177 :             tbl_stream << "FOR:" << curDel << objectName << '\n';
   17120        20195 :         } else if (style == TableStyle::Fixed) {
   17121          497 :             tbl_stream << "----------------------------------------------------------------------------------------------------\n";
   17122          497 :             tbl_stream << "REPORT:      " << curDel << modifiedReportName << '\n';
   17123          497 :             tbl_stream << "FOR:         " << curDel << objectName << '\n';
   17124        19698 :         } else if (style == TableStyle::HTML) {
   17125        19174 :             tbl_stream << "<hr>\n";
   17126        19174 :             tbl_stream << "<p><a href=\"#toc\" style=\"float: right\">Table of Contents</a></p>\n";
   17127        19174 :             tbl_stream << "<a name=" << MakeAnchorName(reportName, objectName) << "></a>\n";
   17128        19174 :             tbl_stream << "<p>Report:<b>" << curDel << modifiedReportName << "</b></p>\n";
   17129        19174 :             tbl_stream << "<p>For:<b>" << curDel << objectName << "</b></p>\n";
   17130        19174 :             tbl_stream << "<p>Timestamp: <b>" << std::setw(4) << ort->td(1) << '-' << std::setfill('0') << std::setw(2) << ort->td(2) << '-'
   17131        19174 :                        << std::setw(2) << ort->td(3) << '\n';
   17132        19174 :             tbl_stream << "    " << std::setw(2) << ort->td(5) << ':' << std::setw(2) << ort->td(6) << ':' << std::setw(2) << ort->td(7)
   17133        19174 :                        << std::setfill(' ') << "</b></p>\n";
   17134          524 :         } else if (style == TableStyle::XML) {
   17135          524 :             if (len(ort->prevReportName) != 0) {
   17136          504 :                 tbl_stream << "</" << ort->prevReportName << ">\n"; // close the last element if it was used.
   17137              :             }
   17138          524 :             tbl_stream << "<" << ConvertToElementTag(modifiedReportName) << ">\n";
   17139          524 :             tbl_stream << "  <for>" << ConvertToEscaped(objectName) << "</for>\n";
   17140          524 :             ort->prevReportName = ConvertToElementTag(modifiedReportName); // save the name for next time
   17141              :         }
   17142              :     }
   17143              :     // clear the active subtable name for the XML reporting
   17144        19446 :     ort->activeSubTableName = "";
   17145              :     // save the report name if the subtable name is not available during XML processing
   17146        19446 :     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        19446 :     ort->activeForName = objectName;
   17149        19446 : }
   17150              : 
   17151       143255 : 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       143255 :     auto &ort = state.dataOutRptTab;
   17176              : 
   17177       307880 :     for (iStyle = 1; iStyle <= ort->numStyles; ++iStyle) {
   17178       164625 :         TableStyle const style = ort->TableStyle(iStyle);
   17179       164625 :         if ((style == TableStyle::Comma) || (style == TableStyle::Tab) || (style == TableStyle::Fixed)) {
   17180        19636 :             std::ostream &tbl_stream(*ort->TabularOutputFile(iStyle));
   17181        19636 :             tbl_stream << subtitle << "\n\n";
   17182       164625 :         } else if (style == TableStyle::HTML) {
   17183       141310 :             std::ostream &tbl_stream(*ort->TabularOutputFile(iStyle));
   17184       141310 :             tbl_stream << "<b>" << subtitle << "</b><br><br>\n";
   17185       141310 :             tbl_stream << "<!-- FullName:" << ort->activeReportName << '_' << ort->activeForName << '_' << subtitle << "-->\n";
   17186         3679 :         } else if (style == TableStyle::XML) {
   17187              :             // save the active subtable name for the XML reporting
   17188         3679 :             ort->activeSubTableName = subtitle;
   17189              :             // no other output is needed since WriteTable uses the subtable name for each record.
   17190              :         }
   17191              :     }
   17192       143255 : }
   17193              : 
   17194         9070 : 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         9070 :     auto &ort = state.dataOutRptTab;
   17219              : 
   17220        19604 :     for (iStyle = 1; iStyle <= ort->numStyles; ++iStyle) {
   17221        10534 :         TableStyle const style = ort->TableStyle(iStyle);
   17222        10534 :         if ((style == TableStyle::Comma) || (style == TableStyle::Tab) || (style == TableStyle::Fixed)) {
   17223         1356 :             std::ostream &tbl_stream(*ort->TabularOutputFile(iStyle));
   17224         1356 :             tbl_stream << lineOfText << '\n';
   17225        10534 :         } else if (style == TableStyle::HTML) {
   17226         8958 :             std::ostream &tbl_stream(*ort->TabularOutputFile(iStyle));
   17227         8958 :             if (useBold) {
   17228         7214 :                 tbl_stream << "<b>" << lineOfText << "</b><br><br>\n";
   17229              :             } else {
   17230         1744 :                 tbl_stream << lineOfText << "<br>\n";
   17231              :             }
   17232          220 :         } else if (style == TableStyle::XML) {
   17233          220 :             std::ostream &tbl_stream(*ort->TabularOutputFile(iStyle));
   17234          220 :             if (!lineOfText.empty()) {
   17235          180 :                 tbl_stream << "<note>" << lineOfText << "</note>\n";
   17236              :             }
   17237              :         }
   17238              :     }
   17239         9070 : }
   17240              : 
   17241       143247 : 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       143247 :     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       143247 :     Array2D_string colLabelMulti;
   17284       143247 :     std::string workColumn;
   17285       143247 :     Array1D_string rowLabelTags;
   17286       143247 :     Array1D_string columnLabelTags;
   17287       143247 :     Array1D_string rowUnitStrings;
   17288       143247 :     Array1D_string columnUnitStrings;
   17289       143247 :     Array2D_string bodyEsc;
   17290              : 
   17291       143247 :     std::string outputLine;
   17292       143247 :     std::string tagWithAttrib;
   17293              :     std::string::size_type col1start;
   17294       143247 :     auto &ort = state.dataOutRptTab;
   17295              : 
   17296              :     // create blank string
   17297              :     // get sizes of arrays
   17298       143247 :     int rowsBody = isize(body, 2);
   17299       143247 :     int colsBody = isize(body, 1);
   17300       143247 :     int rowsRowLabels = isize(rowLabels);
   17301       143247 :     int colsColumnLabels = isize(columnLabels);
   17302       143247 :     int const colsWidthColumn = isize(widthColumn);
   17303              :     // check size of arrays for consistency and if inconsistent use smaller value
   17304              :     // and display warning
   17305       143247 :     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       143247 :     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       143247 :     rowLabelTags.allocate(rowsBody);
   17317       143247 :     columnLabelTags.allocate(colsBody);
   17318       143247 :     rowUnitStrings.allocate(rowsBody);
   17319       143247 :     columnUnitStrings.allocate(colsBody);
   17320       143247 :     bodyEsc.allocate(colsBody, rowsBody);
   17321              :     // create new array to hold multiple line column labels
   17322       143247 :     colLabelMulti.allocate(colsColumnLabels, 50);
   17323       143247 :     colLabelMulti = blank; // set array to blank
   17324       143247 :     int maxNumColLabelRows = 0;
   17325              : 
   17326       307862 :     for (int iStyle = 1; iStyle <= ort->numStyles; ++iStyle) {
   17327       164615 :         std::ostream &tbl_stream(*ort->TabularOutputFile(iStyle));
   17328       164615 :         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      1452039 :         for (int iCol = 1; iCol <= colsColumnLabels; ++iCol) {
   17333      1287424 :             int numColLabelRows = 0;
   17334      1287424 :             workColumn = columnLabels(iCol);
   17335      1287424 :             widthColumn(iCol) = max(widthColumn(iCol), static_cast<int>(len(columnLabels(iCol))));
   17336              :             while (true) {
   17337      1304584 :                 std::string::size_type const barLoc = index(workColumn, '|');
   17338      1304584 :                 if (barLoc != std::string::npos) {
   17339        17160 :                     ++numColLabelRows;
   17340        17160 :                     colLabelMulti(iCol, numColLabelRows) = workColumn.substr(0, barLoc);
   17341        17160 :                     workColumn.erase(0, barLoc + 1);
   17342              :                 } else {
   17343      1287424 :                     ++numColLabelRows;
   17344      1287424 :                     colLabelMulti(iCol, numColLabelRows) = workColumn;
   17345      1287424 :                     break; // inner do loop
   17346              :                 }
   17347        17160 :             }
   17348      1287424 :             if (numColLabelRows > maxNumColLabelRows) {
   17349       143921 :                 maxNumColLabelRows = numColLabelRows;
   17350              :             }
   17351              :         }
   17352              : 
   17353       164615 :         auto const &thisStyle = ort->TableStyle(iStyle);
   17354              : 
   17355              :         // output depending on style of format
   17356       164615 :         if ((thisStyle == TableStyle::Comma) || (thisStyle == TableStyle::Tab)) {
   17357              :             // column headers
   17358        33735 :             for (int jRow = 1; jRow <= maxNumColLabelRows; ++jRow) {
   17359        17599 :                 outputLine = curDel; // one leading delimiters on column header lines
   17360       145868 :                 for (int iCol = 1; iCol <= colsColumnLabels; ++iCol) {
   17361       128269 :                     outputLine += curDel + stripped(colLabelMulti(iCol, jRow));
   17362              :                 }
   17363        17599 :                 tbl_stream << InsertCurrencySymbol(state, outputLine, false) << '\n';
   17364              :             }
   17365              :             // body with row headers
   17366       172181 :             for (int jRow = 1; jRow <= rowsBody; ++jRow) {
   17367       156045 :                 outputLine = curDel + rowLabels(jRow); // one leading delimiters on table body lines
   17368      1619637 :                 for (int iCol = 1; iCol <= colsBody; ++iCol) {
   17369      1463592 :                     outputLine += curDel + stripped(body(iCol, jRow));
   17370              :                 }
   17371       156045 :                 tbl_stream << InsertCurrencySymbol(state, outputLine, false) << '\n';
   17372              :             }
   17373        16136 :             if (!footnoteText.empty()) {
   17374         2378 :                 tbl_stream << fmt::format("{}\n", footnoteText);
   17375              :             }
   17376        16136 :             tbl_stream << "\n\n";
   17377              : 
   17378       164615 :         } 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        30729 :             for (int iCol = 1; iCol <= colsColumnLabels; ++iCol) {
   17383        27231 :                 int const colWidthLimit = widthColumn(iCol);
   17384        55298 :                 for (int jRow = 1; jRow <= maxNumColLabelRows; ++jRow) {
   17385        28067 :                     pare(colLabelMulti(iCol, jRow), colWidthLimit);
   17386              :                 }
   17387              :             }
   17388         3498 :             std::string::size_type maxWidthRowLabel = 0;
   17389        15741 :             for (int jRow = 1; jRow <= rowsRowLabels; ++jRow) {
   17390        12243 :                 std::string::size_type widthRowLabel = len(rowLabels(jRow));
   17391        12243 :                 if (widthRowLabel > maxWidthRowLabel) {
   17392         5081 :                     maxWidthRowLabel = widthRowLabel;
   17393              :                 }
   17394              :             }
   17395              : 
   17396              :             // column headers
   17397         7357 :             for (int jRow = 1; jRow <= maxNumColLabelRows; ++jRow) {
   17398         3859 :                 outputLine = blank; // spaces(:maxWidthRowLabel+2)  // two extra spaces and leave blank area for row labels
   17399         3859 :                 col1start = max(maxWidthRowLabel + 2u, static_cast<std::string::size_type>(3u));
   17400        31926 :                 for (int iCol = 1; iCol <= colsColumnLabels; ++iCol) {
   17401        28067 :                     if (iCol != 1) {
   17402        24208 :                         outputLine += "  " + rjustified(sized(colLabelMulti(iCol, jRow), widthColumn(iCol)));
   17403              :                     } else {
   17404        11577 :                         outputLine = std::string(col1start - 1, ' ') + "  " + rjustified(sized(colLabelMulti(iCol, jRow), widthColumn(iCol)));
   17405              :                     }
   17406              :                 }
   17407         3859 :                 tbl_stream << InsertCurrencySymbol(state, outputLine, false) << '\n';
   17408              :             }
   17409              :             // body with row headers
   17410        15741 :             for (int jRow = 1; jRow <= rowsBody; ++jRow) {
   17411        12243 :                 outputLine = "  " + rjustified(sized(rowLabels(jRow), maxWidthRowLabel)); // two blank spaces on table body lines
   17412              :                 // col1start = max( len( outputLine ) + 2u, maxWidthRowLabel + 2u );
   17413       107378 :                 for (int iCol = 1; iCol <= colsBody; ++iCol) {
   17414        95135 :                     if (iCol != 1) {
   17415        82892 :                         outputLine += "  " + rjustified(sized(body(iCol, jRow), widthColumn(iCol)));
   17416              :                     } else {
   17417        12243 :                         outputLine += "   " + rjustified(sized(body(iCol, jRow), widthColumn(iCol)));
   17418              :                     }
   17419              :                 }
   17420        12243 :                 tbl_stream << InsertCurrencySymbol(state, outputLine, false) << '\n';
   17421              :             }
   17422         3498 :             if (!footnoteText.empty()) {
   17423          459 :                 tbl_stream << fmt::format("{}\n", footnoteText);
   17424              :             }
   17425         3498 :             tbl_stream << "\n\n";
   17426              : 
   17427       144981 :         } else if (thisStyle == TableStyle::HTML) {
   17428              :             // set up it being a table
   17429       141302 :             tbl_stream << "<table border=\"1\" cellpadding=\"4\" cellspacing=\"0\">\n";
   17430              :             // column headers
   17431       141302 :             tbl_stream << "  <tr><td></td>\n"; // start new row and leave empty cell
   17432      1247848 :             for (int iCol = 1; iCol <= colsColumnLabels; ++iCol) {
   17433      1106546 :                 outputLine = "    <td align=\"right\">";
   17434      2242308 :                 for (int jRow = 1; jRow <= maxNumColLabelRows; ++jRow) {
   17435      1135762 :                     outputLine += ConvertToEscaped(colLabelMulti(iCol, jRow), false);
   17436      1135762 :                     if (jRow < maxNumColLabelRows) {
   17437        29216 :                         outputLine += "<br>";
   17438              :                     }
   17439              :                 }
   17440      1106546 :                 tbl_stream << InsertCurrencySymbol(state, outputLine, true) << "</td>\n";
   17441              :             }
   17442       141302 :             tbl_stream << "  </tr>\n";
   17443              :             // body with row headers
   17444      1018747 :             for (int jRow = 1; jRow <= rowsBody; ++jRow) {
   17445       877445 :                 tbl_stream << "  <tr>\n";
   17446       877445 :                 if (rowLabels(jRow) != "") {
   17447      1741496 :                     tbl_stream << "    <td align=\"right\">" << ConvertToEscaped(InsertCurrencySymbol(state, rowLabels(jRow), true), false)
   17448      1741496 :                                << "</td>\n";
   17449              :                 } else {
   17450         6697 :                     tbl_stream << "    <td align=\"right\">&nbsp;</td>\n";
   17451              :                 }
   17452      8661258 :                 for (int iCol = 1; iCol <= colsBody; ++iCol) {
   17453      7783813 :                     if (body(iCol, jRow) != "") {
   17454     13998548 :                         tbl_stream << "    <td align=\"right\">" << ConvertToEscaped(InsertCurrencySymbol(state, body(iCol, jRow), true), false)
   17455     13998548 :                                    << "</td>\n";
   17456              :                     } else {
   17457       784539 :                         tbl_stream << "    <td align=\"right\">&nbsp;</td>\n";
   17458              :                     }
   17459              :                 }
   17460       877445 :                 tbl_stream << "  </tr>\n";
   17461              :             }
   17462              :             // end the table
   17463       141302 :             tbl_stream << "</table>\n";
   17464       141302 :             if (!footnoteText.empty()) {
   17465        23036 :                 tbl_stream << fmt::format("<div class=\"footnote\" style=\"font-style: italic;\">{}</div>\n", footnoteText);
   17466              :             }
   17467       141302 :             tbl_stream << "<br><br>\n";
   17468         3679 :         } else if (thisStyle == TableStyle::XML) {
   17469              :             // check if entire table is blank and it if is skip generating anything
   17470         3679 :             bool isTableBlank = true;
   17471         5147 :             for (int jRow = 1; jRow <= rowsBody; ++jRow) {
   17472        19593 :                 for (int iCol = 1; iCol <= colsBody; ++iCol) {
   17473        18125 :                     if (len(body(iCol, jRow)) > 0) {
   17474         2463 :                         isTableBlank = false;
   17475         2463 :                         break;
   17476              :                     }
   17477              :                 }
   17478         3931 :                 if (!isTableBlank) {
   17479         2463 :                     break;
   17480              :                 }
   17481              :             }
   17482              :             // if non-blank cells in the table body were found create the table.
   17483         3679 :             if (!isTableBlank) {
   17484              :                 // if report name and subtable name the same add "record" to the end
   17485         2463 :                 ort->activeSubTableName = ConvertToElementTag(ort->activeSubTableName);
   17486         2463 :                 ort->activeReportNameNoSpace = ConvertToElementTag(ort->activeReportName);
   17487         2463 :                 if (Util::SameString(ort->activeSubTableName, ort->activeReportNameNoSpace)) {
   17488           20 :                     ort->activeSubTableName += "Record";
   17489              :                 }
   17490              :                 // if no subtable name use the report name and add "record" to the end
   17491         2463 :                 if (len(ort->activeSubTableName) == 0) {
   17492            0 :                     ort->activeSubTableName = ort->activeReportNameNoSpace + "Record";
   17493              :                 }
   17494              :                 // if a single column table, transpose it automatically
   17495         2463 :                 if ((colsBody == 1) && (rowsBody > 1)) {
   17496          302 :                     transposeXML = true;
   17497              :                 }
   17498              :                 // first convert all row and column headers into tags compatible with XML strings
   17499        14017 :                 for (int jRow = 1; jRow <= rowsBody; ++jRow) {
   17500        11554 :                     rowLabelTags(jRow) = ConvertToElementTag(rowLabels(jRow));
   17501        11554 :                     if (len(rowLabelTags(jRow)) == 0) {
   17502          207 :                         rowLabelTags(jRow) = "none";
   17503              :                     }
   17504        11554 :                     rowUnitStrings(jRow) = GetUnitSubString(rowLabels(jRow));
   17505        11554 :                     if (Util::SameString(rowUnitStrings(jRow), "Invalid/Undefined")) {
   17506            0 :                         rowUnitStrings(jRow) = "";
   17507              :                     }
   17508              :                 }
   17509        19598 :                 for (int iCol = 1; iCol <= colsBody; ++iCol) {
   17510        17135 :                     columnLabelTags(iCol) = ConvertToElementTag(columnLabels(iCol));
   17511        17135 :                     if (len(columnLabelTags(iCol)) == 0) {
   17512            0 :                         columnLabelTags(iCol) = "none";
   17513              :                     }
   17514        17135 :                     columnUnitStrings(iCol) = GetUnitSubString(columnLabels(iCol));
   17515        17135 :                     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        14017 :                 for (int jRow = 1; jRow <= rowsBody; ++jRow) {
   17521        96659 :                     for (int iCol = 1; iCol <= colsBody; ++iCol) {
   17522        85105 :                         bodyEsc(iCol, jRow) = ConvertToEscaped(body(iCol, jRow));
   17523              :                     }
   17524              :                 }
   17525         2463 :                 if (!transposeXML) {
   17526              :                     // body with row headers
   17527        11705 :                     for (int jRow = 1; jRow <= rowsBody; ++jRow) {
   17528              :                         // check if record is blank and it if is skip generating anything
   17529         9544 :                         bool isRecordBlank = true;
   17530        11416 :                         for (int iCol = 1; iCol <= colsBody; ++iCol) {
   17531        11292 :                             if (len(bodyEsc(iCol, jRow)) > 0) {
   17532         9420 :                                 isRecordBlank = false;
   17533         9420 :                                 break;
   17534              :                             }
   17535              :                         }
   17536         9544 :                         if (!isRecordBlank) {
   17537         9420 :                             tbl_stream << "  <" << ort->activeSubTableName << ">\n";
   17538         9420 :                             if (len(rowLabelTags(jRow)) > 0) {
   17539         9420 :                                 tbl_stream << "    <name>" << rowLabelTags(jRow) << "</name>\n";
   17540              :                             }
   17541        91303 :                             for (int iCol = 1; iCol <= colsBody; ++iCol) {
   17542        81883 :                                 if (len(stripped(bodyEsc(iCol, jRow))) > 0) { // skip blank cells
   17543        76667 :                                     tagWithAttrib = "<" + columnLabelTags(iCol);
   17544        76667 :                                     if (len(columnUnitStrings(iCol)) > 0) {
   17545       224084 :                                         tagWithAttrib += std::string(" units=") + char(34) + columnUnitStrings(iCol) + char(34) +
   17546        56021 :                                                          '>'; // if units are present add them as an attribute
   17547              :                                     } else {
   17548        20646 :                                         tagWithAttrib += ">";
   17549              :                                     }
   17550        76667 :                                     tbl_stream << "    " << tagWithAttrib << stripped(bodyEsc(iCol, jRow)) << "</" << columnLabelTags(iCol) << ">\n";
   17551              :                                 }
   17552              :                             }
   17553         9420 :                             tbl_stream << "  </" << ort->activeSubTableName << ">\n";
   17554              :                         }
   17555              :                     }
   17556              :                 } else { // transpose XML table
   17557              :                     // body with row headers
   17558          604 :                     for (int iCol = 1; iCol <= colsBody; ++iCol) {
   17559              :                         // check if record is blank and it if is skip generating anything
   17560          302 :                         bool isRecordBlank = true;
   17561          302 :                         for (int jRow = 1; jRow <= rowsBody; ++jRow) {
   17562          302 :                             if (len(bodyEsc(iCol, jRow)) > 0) {
   17563          302 :                                 isRecordBlank = false;
   17564          302 :                                 break;
   17565              :                             }
   17566              :                         }
   17567          302 :                         if (!isRecordBlank) {
   17568          302 :                             tbl_stream << "  <" << ort->activeSubTableName << ">\n";
   17569              :                             // if the column has units put them into the name tag
   17570          302 :                             if (len(columnLabelTags(iCol)) > 0) {
   17571          302 :                                 if (len(columnUnitStrings(iCol)) > 0) {
   17572          242 :                                     tbl_stream << "    <name units=" << char(34) << columnUnitStrings(iCol) << char(34) << '>'
   17573          121 :                                                << columnLabelTags(iCol) << "</name>\n";
   17574              :                                 } else {
   17575          181 :                                     tbl_stream << "    <name>" << columnLabelTags(iCol) << "</name>\n";
   17576              :                                 }
   17577              :                             }
   17578         2312 :                             for (int jRow = 1; jRow <= rowsBody; ++jRow) {
   17579         2010 :                                 if (len(bodyEsc(iCol, jRow)) > 0) { // skip blank cells
   17580         1992 :                                     tagWithAttrib = "<" + rowLabelTags(jRow);
   17581         1992 :                                     if (len(rowUnitStrings(jRow)) > 0) {
   17582          912 :                                         tagWithAttrib += std::string(" units=") + char(34) + rowUnitStrings(jRow) + char(34) +
   17583          228 :                                                          ">\n"; // if units are present add them as an attribute
   17584              :                                     } else {
   17585         1764 :                                         tagWithAttrib += ">";
   17586              :                                     }
   17587         1992 :                                     tbl_stream << "    " << tagWithAttrib << stripped(bodyEsc(iCol, jRow)) << "</" << rowLabelTags(jRow) << ">\n";
   17588              :                                 }
   17589              :                             }
   17590          302 :                             tbl_stream << "  </" << ort->activeSubTableName << ">\n";
   17591              :                         }
   17592              :                     }
   17593              :                 }
   17594         2463 :                 if (!footnoteText.empty()) {
   17595          218 :                     if (footnoteText.find("<br") != std::string_view::npos) {
   17596            0 :                         tbl_stream << fmt::format("  <footnote><![CDATA[{}]]></footnote>\n", footnoteText);
   17597              :                     } else {
   17598          218 :                         tbl_stream << fmt::format("  <footnote>{}</footnote>\n", footnoteText);
   17599              :                     }
   17600              :                 }
   17601              :             }
   17602              :         } else {
   17603              :         }
   17604              :     }
   17605       143247 : }
   17606              : 
   17607        38477 : 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        38477 :     std::string StringOut;
   17628        38477 :     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       938466 :     for (char const i : reportString) {
   17645       899989 :         if (has(validChars, i)) {
   17646       815708 :             StringOut += i;
   17647              :         }
   17648              :     }
   17649        38477 :     StringOut += "::";
   17650       617279 :     for (char const i : objectString) {
   17651       578802 :         if (has(validChars, i)) {
   17652       540767 :             StringOut += i;
   17653              :         }
   17654              :     }
   17655        38477 :     return StringOut;
   17656            0 : }
   17657              : 
   17658      9166314 : 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      9166314 :     std::string outSt(trimmed(inString)); // Result String
   17693      9166314 :     std::string::size_type loc = index(outSt, "~~$~~");
   17694      9168589 :     while (loc != std::string::npos) {
   17695         2275 :         if (isHTML) {
   17696         3774 :             outSt = inString.substr(0, loc) + state.dataCostEstimateManager->monetaryUnit(state.dataCostEstimateManager->selectedMonetaryUnit).html +
   17697         5661 :                     outSt.substr(loc + 5);
   17698              :         } else {
   17699          776 :             outSt = inString.substr(0, loc) + state.dataCostEstimateManager->monetaryUnit(state.dataCostEstimateManager->selectedMonetaryUnit).txt +
   17700         1164 :                     outSt.substr(loc + 5);
   17701              :         }
   17702         2275 :         loc = index(outSt, "~~$~~");
   17703              :     }
   17704      9166314 :     return outSt;
   17705            0 : }
   17706              : 
   17707        34663 : 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        34663 :     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        34663 :     bool foundOther = true; // flag if character found besides A-Z, a-z, 0-9
   17741       718986 :     for (std::string::size_type iIn = 0, e = inString.length(); iIn < e; ++iIn) {
   17742       692677 :         char const c(inString[iIn]);
   17743       692677 :         int const curCharVal = int(c);
   17744       692677 :         if ((curCharVal >= 65) && (curCharVal <= 90)) { // A-Z upper case
   17745       106320 :             if (foundOther) {
   17746        87577 :                 outString += c; // keep as upper case after finding a space or another character
   17747              :             } else {
   17748        18743 :                 outString += char(curCharVal + 32); // convert to lower case
   17749              :             }
   17750       106320 :             foundOther = false;
   17751       586357 :         } else if ((curCharVal >= 97) && (curCharVal <= 122)) { // A-Z lower case
   17752       476523 :             if (foundOther) {
   17753         7137 :                 outString += char(curCharVal - 32); // convert to upper case
   17754              :             } else {
   17755       469386 :                 outString += c; // leave as lower case
   17756              :             }
   17757       476523 :             foundOther = false;
   17758       109834 :         } else if ((curCharVal >= 48) && (curCharVal <= 57)) { // 0-9 numbers
   17759              :             // if first character is a number then prepend with the letter "t"
   17760        10306 :             if (outString.length() == 0) {
   17761         1914 :                 outString += 't';
   17762              :             }
   17763        10306 :             outString += c;
   17764        10306 :             foundOther = false;
   17765        99528 :         } else if (curCharVal == 91) { // [ bracket
   17766         8354 :             break;                     // stop parsing because unit string was found
   17767              :         } else {
   17768        91174 :             foundOther = true;
   17769              :         }
   17770              :     }
   17771        34663 :     return outString;
   17772            0 : }
   17773              : 
   17774            0 : 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            0 :     std::string s;
   17778            0 :     if (codepoint <= 0x7f) {
   17779            0 :         s.push_back(static_cast<char>(codepoint));
   17780            0 :     } else if (codepoint <= 0x7ff) {
   17781            0 :         s.push_back(static_cast<char>(0xc0 | ((codepoint >> 6) & 0x1f)));
   17782            0 :         s.push_back(static_cast<char>(0x80 | (codepoint & 0x3f)));
   17783            0 :     } else if (codepoint <= 0xffff) {
   17784            0 :         s.push_back(static_cast<char>(0xe0 | ((codepoint >> 12) & 0x0f)));
   17785            0 :         s.push_back(static_cast<char>(0x80 | ((codepoint >> 6) & 0x3f)));
   17786            0 :         s.push_back(static_cast<char>(0x80 | (codepoint & 0x3f)));
   17787            0 :     } else if (codepoint <= 0x10ffff) {
   17788            0 :         s.push_back(static_cast<char>(0xf0 | ((codepoint >> 18) & 0x07)));
   17789            0 :         s.push_back(static_cast<char>(0x80 | ((codepoint >> 12) & 0x3f)));
   17790            0 :         s.push_back(static_cast<char>(0x80 | ((codepoint >> 6) & 0x3f)));
   17791            0 :         s.push_back(static_cast<char>(0x80 | (codepoint & 0x3f)));
   17792              :     }
   17793            0 :     return s;
   17794            0 : }
   17795              : 
   17796      9092929 : 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      9092929 :     if (inString.empty()) {
   17813        42126 :         return "";
   17814              :     };
   17815              : 
   17816      9071866 :     std::string s;
   17817      9071866 :     size_t const inputSize = inString.size();
   17818      9071866 :     s.reserve(inputSize);
   17819      9071866 :     size_t index = 0;
   17820              : 
   17821              :     while (true) {
   17822    130932704 :         if (index == inputSize) {
   17823      9071866 :             break;
   17824              :         }
   17825    121860838 :         char c = inString[index++];
   17826    121860838 :         if ((c == '\"') && isXML) {
   17827            0 :             s += "&quot;";
   17828    121860838 :         } else if (c == '&') {
   17829         4136 :             s += "&amp;";
   17830    121856702 :         } else if ((c == '\'') && isXML) {
   17831           34 :             s += "&apos;";
   17832    121856668 :         } else if (c == '<') {
   17833        10082 :             s += "&lt;";
   17834    121846586 :         } else if (c == '>') {
   17835        40008 :             s += "&gt;";
   17836    121806578 :         } else if (c == char(176) && !isXML) {
   17837         2184 :             s += "&deg;";
   17838    121804394 :         } else if (c == char(226) && char(inString[index]) == char(137) && char(inString[index + 1]) == char(164) && !isXML) { // ≤
   17839        15577 :             s += "&le;";
   17840        15577 :             index += 2;
   17841    121788817 :         } else if (c == char(226) && char(inString[index]) == char(137) && char(inString[index + 1]) == char(165) && !isXML) { // ≥
   17842            0 :             s += "&ge;";
   17843            0 :             index += 2;
   17844    121788817 :         } else if (c == '\xC2') {
   17845        33134 :             if (index == inputSize) {
   17846            0 :                 s += '\xC2';
   17847              :             } else {
   17848        33134 :                 c = inString[index++];
   17849        33134 :                 if (c == '\xB0' && !isXML) {
   17850        29027 :                     s += "&deg;";
   17851              :                 } else {
   17852         4107 :                     s += '\xC2';
   17853         4107 :                     s += c;
   17854              :                 }
   17855              :             }
   17856    121755683 :         } else if (c == '\xB0' && !isXML) {
   17857            0 :             s += "&deg;";
   17858    121755683 :         } else if (c == '\\') {
   17859            0 :             if (index == inputSize) {
   17860            0 :                 break;
   17861              :             };
   17862            0 :             c = inString[index++];
   17863            0 :             if ((c == '"') && isXML) {
   17864            0 :                 s += "&quot;";
   17865            0 :             } else if ((c == '\'') && isXML) {
   17866            0 :                 s += "&apos;";
   17867            0 :             } else if (c == 'u' || c == 'x') {
   17868            0 :                 int remainingLen = inputSize - index;
   17869            0 :                 unsigned long codePoint(0);
   17870            0 :                 if (c == 'u' && remainingLen > 3) {
   17871            0 :                     codePoint = std::stoul(inString.substr(index, 4), nullptr, 16);
   17872            0 :                     index += 4;
   17873            0 :                 } else if (c == 'x' && remainingLen > 1) {
   17874            0 :                     codePoint = std::stoul(inString.substr(index, 2), nullptr, 16);
   17875            0 :                     index += 2;
   17876              :                 }
   17877            0 :                 std::string const unicodeString = ConvertUnicodeToUTF8(codePoint);
   17878            0 :                 if (unicodeString == "\xC2\xB0" && !isXML) { // only check for degree at this point
   17879            0 :                     s += "&deg;";
   17880              :                 } else {
   17881            0 :                     s += unicodeString;
   17882              :                 }
   17883            0 :             } else {
   17884            0 :                 s += c;
   17885              :             }
   17886              :         } else {
   17887    121755683 :             s += c;
   17888              :         }
   17889    121860838 :     }
   17890      9071866 :     return s;
   17891      9071866 : }
   17892              : 
   17893         1558 : 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         1558 :     auto const &ort = state.dataOutRptTab;
   17928              : 
   17929         1558 :     ort->buildingGrossFloorArea = 0.0;
   17930         1558 :     ort->buildingConditionedFloorArea = 0.0;
   17931        10584 :     for (int iZone = 1; iZone <= state.dataGlobal->NumOfZones; ++iZone) {
   17932         9026 :         auto const &thisZone = state.dataHeatBal->Zone(iZone);
   17933         9026 :         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         9026 :         if (thisZone.isPartOfTotalArea) {
   17949         8854 :             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         8854 :             if (thisZone.SystemZoneNodeNumber > 0) {
   17954         7951 :                 ort->buildingConditionedFloorArea += curZoneArea;
   17955              :             }
   17956              :         }
   17957              :     }
   17958         1558 : }
   17959              : 
   17960         2194 : void FillRowHead(Array1D_string &rowHead)
   17961              : {
   17962              :     // Forward fill the blanks in rowHead (eg End use column)
   17963         2194 :     std::string currentEndUseName;
   17964        34688 :     for (size_t i = 1; i <= rowHead.size(); ++i) {
   17965        32494 :         std::string &thisEndUseName = rowHead(i);
   17966        32494 :         if (thisEndUseName.empty()) {
   17967         1778 :             thisEndUseName = currentEndUseName;
   17968              :         } else {
   17969        30716 :             currentEndUseName = thisEndUseName;
   17970              :         }
   17971              :     }
   17972         2194 : }
   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            0 : 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            0 :     auto &ort = state.dataOutRptTab;
   18008              : 
   18009            0 :     for (int iInput = 1; iInput <= ort->MonthlyInputCount; ++iInput) {
   18010            0 :         for (int jTable = 1; jTable <= ort->MonthlyInput(iInput).numTables; ++jTable) {
   18011            0 :             int const curTable = jTable + ort->MonthlyInput(iInput).firstTable - 1;
   18012            0 :             for (int kColumn = 1; kColumn <= ort->MonthlyTables(curTable).numColumns; ++kColumn) {
   18013            0 :                 int const curCol = kColumn + ort->MonthlyTables(curTable).firstColumn - 1;
   18014            0 :                 ort->MonthlyColumns(curCol).timeStamp = 0;
   18015            0 :                 ort->MonthlyColumns(curCol).duration = 0.0;
   18016            0 :                 if (ort->MonthlyColumns(curCol).aggType == AggType::Maximum ||
   18017            0 :                     ort->MonthlyColumns(curCol).aggType == AggType::MaximumDuringHoursShown) {
   18018            0 :                     ort->MonthlyColumns(curCol).reslt = -HUGE_(state.dataOutRptTab->BigNumRMG);
   18019            0 :                 } else if (ort->MonthlyColumns(curCol).aggType == AggType::Minimum ||
   18020            0 :                            ort->MonthlyColumns(curCol).aggType == AggType::MinimumDuringHoursShown) {
   18021            0 :                     ort->MonthlyColumns(curCol).reslt = HUGE_(state.dataOutRptTab->BigNumRMG);
   18022              :                 } else {
   18023            0 :                     ort->MonthlyColumns(curCol).reslt = 0.0;
   18024              :                 }
   18025              :             }
   18026              :         }
   18027              :     }
   18028            0 : }
   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            0 : 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            0 :     auto const &ort = state.dataOutRptTab;
   18068            0 :     ort->gatherTotalsBEPS = 0.0;
   18069            0 :     ort->gatherEndUseBEPS = 0.0;
   18070            0 :     ort->gatherEndUseSubBEPS = 0.0;
   18071            0 :     ort->gatherTotalsSource = 0.0;
   18072              :     // reset the specific components being gathered
   18073            0 :     ort->gatherPowerFuelFireGen = 0.0;
   18074            0 :     ort->gatherPowerPV = 0.0;
   18075            0 :     ort->gatherPowerWind = 0.0;
   18076            0 :     ort->gatherPowerHTGeothermal = 0.0;
   18077            0 :     ort->gatherElecProduced = 0.0;
   18078            0 :     ort->gatherElecPurchased = 0.0;
   18079            0 :     ort->gatherElecSurplusSold = 0.0;
   18080            0 :     ort->gatherElecStorage = 0.0;
   18081            0 :     ort->gatherPowerConversion = 0.0;
   18082            0 :     ort->gatherWaterHeatRecovery = 0.0;
   18083            0 :     ort->gatherAirHeatRecoveryCool = 0.0;
   18084            0 :     ort->gatherAirHeatRecoveryHeat = 0.0;
   18085            0 :     ort->gatherHeatHTGeothermal = 0.0;
   18086            0 :     ort->gatherHeatSolarWater = 0.0;
   18087            0 :     ort->gatherHeatSolarAir = 0.0;
   18088            0 :     ort->gatherRainWater = 0.0;
   18089            0 :     ort->gatherCondensate = 0.0;
   18090            0 :     ort->gatherWellwater = 0.0;
   18091            0 :     ort->gatherMains = 0.0;
   18092            0 :     ort->gatherWaterEndUseTotal = 0.0;
   18093            0 : }
   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      3516512 : 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      3516512 :     Real64 const fAB = (qy - y1) * (x2 - x1) - (qx - x1) * (y2 - y1);
   18320      3516512 :     Real64 const fCA = (qy - y3) * (x1 - x3) - (qx - x3) * (y1 - y3);
   18321      3516512 :     Real64 const fBC = (qy - y2) * (x3 - x2) - (qx - x2) * (y3 - y2);
   18322      3516512 :     return ((fAB * fBC) >= 0.0 && (fBC * fCA) >= 0.0);
   18323              : }
   18324              : 
   18325      1758256 : 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      1758256 :     bool const inABC = isInTriangle(qx, qy, ax, ay, bx, by, cx, cy);
   18355      1758256 :     bool const inCDA = isInTriangle(qx, qy, cx, cy, dx, dy, ax, ay);
   18356      1758256 :     return (inABC || inCDA);
   18357              : }
   18358              : 
   18359              : //======================================================================================================================
   18360              : //======================================================================================================================
   18361              : 
   18362              : //    SUPPORT ROUTINES
   18363              : 
   18364              : //======================================================================================================================
   18365              : //======================================================================================================================
   18366              : 
   18367      2033140 : 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      2033140 :     int nDigits = numDigits;
   18386      2033140 :     if (RealIn < 0.0) {
   18387        13681 :         --nDigits;
   18388              :     }
   18389      2033140 :     if (nDigits > 9) {
   18390          608 :         nDigits = 9;
   18391              :     }
   18392      2033140 :     if (nDigits < 0) {
   18393            0 :         nDigits = 0;
   18394              :     }
   18395              : 
   18396      2033140 :     if (std::abs(RealIn) > maxvalDigitsA.at(nDigits)) {
   18397           88 :         return format("{:12.6Z}", RealIn);
   18398              :     } else {
   18399      2033052 :         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        16614 : 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        16614 :     size_t first_char = stringIn.find_first_not_of(' ');
   18422        16614 :     if (first_char != std::string_view::npos) {
   18423        16613 :         stringIn.remove_prefix(first_char);
   18424              :     }
   18425              : 
   18426        16614 :     Real64 realValue = -99999.0;
   18427        16614 :     auto answer = fast_float::from_chars(stringIn.data(), stringIn.data() + stringIn.size(), realValue); // (AUTO_OK_OBJ)
   18428        16614 :     if (answer.ec != std::errc()) {
   18429            1 :         return -99999.0;
   18430              :     }
   18431        16613 :     return realValue;
   18432              : }
   18433              : 
   18434        28958 : 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        28958 :     if (codedDate == 0) {
   18453        57596 :         return "-";
   18454              :     }
   18455              : 
   18456          160 :     General::DecodeMonDayHrMin(codedDate, Month, Day, Hour, Minute);
   18457          160 :     if (Month < 1 || Month > 12) {
   18458            0 :         return "-";
   18459              :     }
   18460              : 
   18461          160 :     --Hour;
   18462          160 :     if (Minute == 60) {
   18463           63 :         ++Hour;
   18464           63 :         Minute = 0;
   18465              :     }
   18466              : 
   18467          320 :     return fmt::format("{:02}-{:3}-{:02}:{:02}", Day, Months[Month - 1], Hour, Minute);
   18468              : }
   18469              : 
   18470        28400 : bool isNumber(std::string const &s)
   18471              : {
   18472              :     char *p;
   18473        28400 :     strtod(s.c_str(), &p);
   18474        28407 :     for (; isspace(*p); ++p) {
   18475              :         ; // handle trailing whitespace
   18476              :     }
   18477        28400 :     return *p == 0;
   18478              : }
   18479              : 
   18480              : // return the number of digits after the decimal point
   18481              : // Glazer - November 2016
   18482         7450 : int digitsAferDecimal(std::string const &s)
   18483              : {
   18484         7450 :     std::size_t decimalpos = s.find('.');
   18485              :     std::size_t numDigits;
   18486         7450 :     if (decimalpos == s.npos) {
   18487           68 :         numDigits = 0;
   18488              :     } else {
   18489         7382 :         std::size_t epos = s.find('E');
   18490         7382 :         if (epos == s.npos) {
   18491         6709 :             epos = s.find('e');
   18492              :         }
   18493         7382 :         if (epos == s.npos) {
   18494         6709 :             numDigits = s.length() - (decimalpos + 1);
   18495              :         } else {
   18496          673 :             numDigits = epos - (decimalpos + 1);
   18497              :         }
   18498              :     }
   18499         7450 :     return int(numDigits);
   18500              : }
   18501              : 
   18502          327 : 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          327 :     auto &ort = state.dataOutRptTab;
   18539              : 
   18540          327 :     if (!allocated(ort->TOCEntries)) {
   18541           58 :         ort->TOCEntriesSize = 20;
   18542           58 :         ort->TOCEntries.allocate(ort->TOCEntriesSize);
   18543           58 :         ort->TOCEntriesCount = 1;
   18544              :     } else {
   18545          269 :         ++ort->TOCEntriesCount;
   18546              :         // if larger than current size grow the array
   18547          269 :         if (ort->TOCEntriesCount > ort->TOCEntriesSize) {
   18548            2 :             ort->TOCEntries.redimension(ort->TOCEntriesSize += 20);
   18549              :         }
   18550              :     }
   18551          327 :     ort->TOCEntries(ort->TOCEntriesCount).reportName = nameReport;
   18552          327 :     ort->TOCEntries(ort->TOCEntriesCount).sectionName = nameSection;
   18553          327 : }
   18554              : 
   18555          799 : 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          799 :     auto &ort = state.dataOutRptTab;
   18589              : 
   18590          799 :     ort->UnitConvSize = 118;
   18591          799 :     ort->UnitConv.allocate(ort->UnitConvSize);
   18592          799 :     ort->UnitConv(1).siName = "%";
   18593          799 :     ort->UnitConv(2).siName = "°C";
   18594          799 :     ort->UnitConv(3).siName = "0=OFF 1=ON";
   18595          799 :     ort->UnitConv(4).siName = "0-NO  1-YES";
   18596          799 :     ort->UnitConv(5).siName = "1-YES 0-NO";
   18597          799 :     ort->UnitConv(6).siName = "A";
   18598          799 :     ort->UnitConv(7).siName = "ACH";
   18599          799 :     ort->UnitConv(8).siName = "ACH";
   18600          799 :     ort->UnitConv(9).siName = "BASE 10C";
   18601          799 :     ort->UnitConv(10).siName = "BASE 18C";
   18602          799 :     ort->UnitConv(11).siName = "C";
   18603          799 :     ort->UnitConv(12).siName = "CD/M2";
   18604          799 :     ort->UnitConv(13).siName = "DEG";
   18605          799 :     ort->UnitConv(14).siName = "FRAC";
   18606          799 :     ort->UnitConv(15).siName = "HOUR";
   18607          799 :     ort->UnitConv(16).siName = "HOURS";
   18608          799 :     ort->UnitConv(17).siName = "HR";
   18609          799 :     ort->UnitConv(18).siName = "HRS";
   18610          799 :     ort->UnitConv(19).siName = "J";
   18611          799 :     ort->UnitConv(20).siName = "J";
   18612          799 :     ort->UnitConv(21).siName = "J";
   18613          799 :     ort->UnitConv(22).siName = "J";
   18614          799 :     ort->UnitConv(23).siName = "J";
   18615          799 :     ort->UnitConv(24).siName = "J";
   18616          799 :     ort->UnitConv(25).siName = "J/KG";
   18617          799 :     ort->UnitConv(26).siName = "J/KGWATER";
   18618          799 :     ort->UnitConv(27).siName = "J/M2";
   18619          799 :     ort->UnitConv(28).siName = "K/M";
   18620          799 :     ort->UnitConv(29).siName = "KG";
   18621          799 :     ort->UnitConv(30).siName = "KG/KG";
   18622          799 :     ort->UnitConv(31).siName = "KG/M3";
   18623          799 :     ort->UnitConv(32).siName = "KG/S";
   18624          799 :     ort->UnitConv(33).siName = "KGWATER/KGDRYAIR";
   18625          799 :     ort->UnitConv(34).siName = "KGWATER/SEC";
   18626          799 :     ort->UnitConv(35).siName = "KMOL/S";
   18627          799 :     ort->UnitConv(36).siName = "KMOL/SEC";
   18628          799 :     ort->UnitConv(37).siName = "KWH";
   18629          799 :     ort->UnitConv(38).siName = "L";
   18630          799 :     ort->UnitConv(39).siName = "L";
   18631          799 :     ort->UnitConv(40).siName = "LUM/W";
   18632          799 :     ort->UnitConv(41).siName = "LUX";
   18633          799 :     ort->UnitConv(42).siName = "M";
   18634          799 :     ort->UnitConv(43).siName = "M";
   18635          799 :     ort->UnitConv(44).siName = "M/S";
   18636          799 :     ort->UnitConv(45).siName = "M/S";
   18637          799 :     ort->UnitConv(46).siName = "M2";
   18638          799 :     ort->UnitConv(47).siName = "M2/PERSON";
   18639          799 :     ort->UnitConv(48).siName = "M3";
   18640          799 :     ort->UnitConv(49).siName = "M3";
   18641          799 :     ort->UnitConv(50).siName = "M3/M2";
   18642          799 :     ort->UnitConv(51).siName = "M3/S";
   18643          799 :     ort->UnitConv(52).siName = "M3/S";
   18644          799 :     ort->UnitConv(53).siName = "M3/S-M2";
   18645          799 :     ort->UnitConv(54).siName = "M3/S-PERSON";
   18646          799 :     ort->UnitConv(55).siName = "M3/S-PERSON";
   18647          799 :     ort->UnitConv(56).siName = "PA";
   18648          799 :     ort->UnitConv(57).siName = "PA";
   18649          799 :     ort->UnitConv(58).siName = "PA";
   18650          799 :     ort->UnitConv(59).siName = "PA";
   18651          799 :     ort->UnitConv(60).siName = "PA";
   18652          799 :     ort->UnitConv(61).siName = "PA";
   18653          799 :     ort->UnitConv(62).siName = "PA";
   18654          799 :     ort->UnitConv(63).siName = "PA";
   18655          799 :     ort->UnitConv(64).siName = "S";
   18656          799 :     ort->UnitConv(65).siName = "V";
   18657          799 :     ort->UnitConv(66).siName = "W";
   18658          799 :     ort->UnitConv(67).siName = "W";
   18659          799 :     ort->UnitConv(68).siName = "W";
   18660          799 :     ort->UnitConv(69).siName = "W";
   18661          799 :     ort->UnitConv(70).siName = "W";
   18662          799 :     ort->UnitConv(71).siName = "W/KG";
   18663          799 :     ort->UnitConv(72).siName = "W/KG H2O"; // TODO: replace with W/kgWater? or rather just remove
   18664          799 :     ort->UnitConv(73).siName = "W/K";
   18665          799 :     ort->UnitConv(74).siName = "W/M2";
   18666          799 :     ort->UnitConv(75).siName = "W/M2";
   18667          799 :     ort->UnitConv(76).siName = "W/M2-C";
   18668          799 :     ort->UnitConv(77).siName = "W/M2-K";
   18669          799 :     ort->UnitConv(78).siName = "W/W";
   18670          799 :     ort->UnitConv(79).siName = "W/W";
   18671          799 :     ort->UnitConv(80).siName = "deltaC";
   18672          799 :     ort->UnitConv(81).siName = "KJ/KG";
   18673          799 :     ort->UnitConv(82).siName = "W-S/M3";
   18674          799 :     ort->UnitConv(83).siName = "W-S/M3";
   18675          799 :     ort->UnitConv(84).siName = "~~$~~/m2";
   18676          799 :     ort->UnitConv(85).siName = "GJ";
   18677          799 :     ort->UnitConv(86).siName = "GJ";
   18678          799 :     ort->UnitConv(87).siName = "GJ";
   18679          799 :     ort->UnitConv(88).siName = "GJ";
   18680          799 :     ort->UnitConv(89).siName = "GJ";
   18681          799 :     ort->UnitConv(90).siName = "GJ";
   18682          799 :     ort->UnitConv(91).siName = "GJ";
   18683          799 :     ort->UnitConv(92).siName = "MJ/m2";
   18684          799 :     ort->UnitConv(93).siName = "MJ/m2";
   18685          799 :     ort->UnitConv(94).siName = "MJ/m2";
   18686          799 :     ort->UnitConv(95).siName = "MJ/m2";
   18687          799 :     ort->UnitConv(96).siName = "Invalid/Undefined";
   18688          799 :     ort->UnitConv(97).siName = "";
   18689          799 :     ort->UnitConv(98).siName = "W/C";
   18690          799 :     ort->UnitConv(99).siName = "DAY";
   18691          799 :     ort->UnitConv(100).siName = "MIN";
   18692          799 :     ort->UnitConv(101).siName = "HR/WK";
   18693          799 :     ort->UnitConv(102).siName = "$";
   18694          799 :     ort->UnitConv(103).siName = "$/UNIT ENERGY";
   18695          799 :     ort->UnitConv(104).siName = "KW";
   18696          799 :     ort->UnitConv(105).siName = " ";
   18697          799 :     ort->UnitConv(106).siName = "AH";
   18698          799 :     ort->UnitConv(107).siName = "CLO";
   18699          799 :     ort->UnitConv(108).siName = "J/KG-K";
   18700          799 :     ort->UnitConv(109).siName = "KGWATER/S";
   18701          799 :     ort->UnitConv(110).siName = "PPM";
   18702          799 :     ort->UnitConv(111).siName = "RAD";
   18703          799 :     ort->UnitConv(112).siName = "REV/MIN";
   18704          799 :     ort->UnitConv(113).siName = "NM";
   18705          799 :     ort->UnitConv(114).siName = "BTU/W-H"; // Used for AHRI rating metrics (e.g. SEER)
   18706          799 :     ort->UnitConv(115).siName = "PERSON/M2";
   18707          799 :     ort->UnitConv(116).siName = "MM";
   18708          799 :     ort->UnitConv(117).siName = "MM";
   18709          799 :     ort->UnitConv(118).siName = "°C·hr";
   18710              : 
   18711          799 :     ort->UnitConv(1).ipName = "%";
   18712          799 :     ort->UnitConv(2).ipName = "F";
   18713          799 :     ort->UnitConv(3).ipName = "0=Off 1=On";
   18714          799 :     ort->UnitConv(4).ipName = "0-No  1-Yes";
   18715          799 :     ort->UnitConv(5).ipName = "1-Yes 0-No";
   18716          799 :     ort->UnitConv(6).ipName = "A";
   18717          799 :     ort->UnitConv(7).ipName = "ACH";
   18718          799 :     ort->UnitConv(8).ipName = "ach";
   18719          799 :     ort->UnitConv(9).ipName = "base 50F";
   18720          799 :     ort->UnitConv(10).ipName = "base 65F";
   18721          799 :     ort->UnitConv(11).ipName = "F";
   18722          799 :     ort->UnitConv(12).ipName = "cd/in2";
   18723          799 :     ort->UnitConv(13).ipName = "deg";
   18724          799 :     ort->UnitConv(14).ipName = "Frac";
   18725          799 :     ort->UnitConv(15).ipName = "Hour";
   18726          799 :     ort->UnitConv(16).ipName = "Hours";
   18727          799 :     ort->UnitConv(17).ipName = "hr";
   18728          799 :     ort->UnitConv(18).ipName = "hrs";
   18729          799 :     ort->UnitConv(19).ipName = "kBtu";
   18730          799 :     ort->UnitConv(20).ipName = "kWh";
   18731          799 :     ort->UnitConv(21).ipName = "therm";
   18732          799 :     ort->UnitConv(22).ipName = "MMBtu";
   18733          799 :     ort->UnitConv(23).ipName = "Wh";
   18734          799 :     ort->UnitConv(24).ipName = "ton-hrs";
   18735          799 :     ort->UnitConv(25).ipName = "Btu/lb";
   18736          799 :     ort->UnitConv(26).ipName = "Btu/lbWater";
   18737          799 :     ort->UnitConv(27).ipName = "kBtu/sqft";
   18738          799 :     ort->UnitConv(28).ipName = "F/ft";
   18739          799 :     ort->UnitConv(29).ipName = "lb";
   18740          799 :     ort->UnitConv(30).ipName = "lb/lb";
   18741          799 :     ort->UnitConv(31).ipName = "lb/ft3";
   18742          799 :     ort->UnitConv(32).ipName = "lb/s";
   18743          799 :     ort->UnitConv(33).ipName = "lbWater/lbDryAir";
   18744          799 :     ort->UnitConv(34).ipName = "lbWater/s";
   18745          799 :     ort->UnitConv(35).ipName = "kmol/s";
   18746          799 :     ort->UnitConv(36).ipName = "kmol/sec";
   18747          799 :     ort->UnitConv(37).ipName = "kWh";
   18748          799 :     ort->UnitConv(38).ipName = "gal";
   18749          799 :     ort->UnitConv(39).ipName = "ft3";
   18750          799 :     ort->UnitConv(40).ipName = "lum/W";
   18751          799 :     ort->UnitConv(41).ipName = "foot-candles";
   18752          799 :     ort->UnitConv(42).ipName = "ft";
   18753          799 :     ort->UnitConv(43).ipName = "in";
   18754          799 :     ort->UnitConv(44).ipName = "ft/min";
   18755          799 :     ort->UnitConv(45).ipName = "miles/hr";
   18756          799 :     ort->UnitConv(46).ipName = "ft2";
   18757          799 :     ort->UnitConv(47).ipName = "ft2/person";
   18758          799 :     ort->UnitConv(48).ipName = "ft3";
   18759          799 :     ort->UnitConv(49).ipName = "gal";
   18760          799 :     ort->UnitConv(50).ipName = "f3/f2";
   18761          799 :     ort->UnitConv(51).ipName = "ft3/min";
   18762          799 :     ort->UnitConv(52).ipName = "gal/min";
   18763          799 :     ort->UnitConv(53).ipName = "ft3/min-ft2";
   18764          799 :     ort->UnitConv(54).ipName = "ft3/min-person";
   18765          799 :     ort->UnitConv(55).ipName = "gal/min-person";
   18766          799 :     ort->UnitConv(56).ipName = "psi";
   18767          799 :     ort->UnitConv(57).ipName = "inHg";
   18768          799 :     ort->UnitConv(58).ipName = "inH2O";
   18769          799 :     ort->UnitConv(59).ipName = "ftH2O";
   18770          799 :     ort->UnitConv(60).ipName = "psi";
   18771          799 :     ort->UnitConv(61).ipName = "inHg";
   18772          799 :     ort->UnitConv(62).ipName = "inH2O";
   18773          799 :     ort->UnitConv(63).ipName = "ftH2O";
   18774          799 :     ort->UnitConv(64).ipName = "s";
   18775          799 :     ort->UnitConv(65).ipName = "V";
   18776          799 :     ort->UnitConv(66).ipName = "Btu/h";
   18777          799 :     ort->UnitConv(67).ipName = "W";
   18778          799 :     ort->UnitConv(68).ipName = "kW";
   18779          799 :     ort->UnitConv(69).ipName = "kBtuh";
   18780          799 :     ort->UnitConv(70).ipName = "ton";
   18781          799 :     ort->UnitConv(71).ipName = "kBtuh/lb";
   18782          799 :     ort->UnitConv(72).ipName = "kBtuh/lb";
   18783          799 :     ort->UnitConv(73).ipName = "Btu/h-F";
   18784          799 :     ort->UnitConv(74).ipName = "Btu/h-ft2";
   18785          799 :     ort->UnitConv(75).ipName = "kBtuh/ft2";
   18786          799 :     ort->UnitConv(76).ipName = "Btu/h-ft2-F";
   18787          799 :     ort->UnitConv(77).ipName = "Btu/h-ft2-F";
   18788          799 :     ort->UnitConv(78).ipName = "Btuh/Btuh";
   18789          799 :     ort->UnitConv(79).ipName = "W/W";
   18790          799 :     ort->UnitConv(80).ipName = "deltaF";
   18791          799 :     ort->UnitConv(81).ipName = "Btu/lb";
   18792          799 :     ort->UnitConv(82).ipName = "W-min/ft3";
   18793          799 :     ort->UnitConv(83).ipName = "W-min/gal";
   18794          799 :     ort->UnitConv(84).ipName = "~~$~~/ft2";
   18795          799 :     ort->UnitConv(85).ipName = "kBtu";
   18796          799 :     ort->UnitConv(86).ipName = "kWh";
   18797          799 :     ort->UnitConv(87).ipName = "kWh";
   18798          799 :     ort->UnitConv(88).ipName = "therm";
   18799          799 :     ort->UnitConv(89).ipName = "MMBtu";
   18800          799 :     ort->UnitConv(90).ipName = "Wh";
   18801          799 :     ort->UnitConv(91).ipName = "ton-hrs";
   18802          799 :     ort->UnitConv(92).ipName = "kWh/ft2";
   18803          799 :     ort->UnitConv(93).ipName = "kBtu/ft2";
   18804          799 :     ort->UnitConv(94).ipName = "kBtu/ft2";
   18805          799 :     ort->UnitConv(95).ipName = "kWh/m2";
   18806          799 :     ort->UnitConv(96).ipName = "Invalid/Undefined";
   18807          799 :     ort->UnitConv(97).ipName = "";
   18808          799 :     ort->UnitConv(98).ipName = "Btu/h-F";
   18809          799 :     ort->UnitConv(99).ipName = "day";
   18810          799 :     ort->UnitConv(100).ipName = "min";
   18811          799 :     ort->UnitConv(101).ipName = "hr/wk";
   18812          799 :     ort->UnitConv(102).ipName = "$";
   18813          799 :     ort->UnitConv(103).ipName = "$/unit energy";
   18814          799 :     ort->UnitConv(104).ipName = "kW";
   18815          799 :     ort->UnitConv(105).ipName = " ";
   18816          799 :     ort->UnitConv(106).ipName = "Ah";
   18817          799 :     ort->UnitConv(107).ipName = "clo";
   18818          799 :     ort->UnitConv(108).ipName = "Btu/lbm-R";
   18819          799 :     ort->UnitConv(109).ipName = "lbWater/s";
   18820          799 :     ort->UnitConv(110).ipName = "ppm";
   18821          799 :     ort->UnitConv(111).ipName = "rad";
   18822          799 :     ort->UnitConv(112).ipName = "rev/min";
   18823          799 :     ort->UnitConv(113).ipName = "lbf-ft";
   18824          799 :     ort->UnitConv(114).ipName = "Btu/W-h";
   18825          799 :     ort->UnitConv(115).ipName = "person/ft2";
   18826          799 :     ort->UnitConv(116).ipName = "in";
   18827          799 :     ort->UnitConv(117).ipName = "ft";
   18828          799 :     ort->UnitConv(118).ipName = "°F·hr";
   18829              : 
   18830          799 :     ort->UnitConv(1).mult = 1.0;
   18831          799 :     ort->UnitConv(2).mult = 1.8;
   18832          799 :     ort->UnitConv(3).mult = 1.0;
   18833          799 :     ort->UnitConv(4).mult = 1.0;
   18834          799 :     ort->UnitConv(5).mult = 1.0;
   18835          799 :     ort->UnitConv(6).mult = 1.0;
   18836          799 :     ort->UnitConv(7).mult = 1.0;
   18837          799 :     ort->UnitConv(8).mult = 1.0;
   18838          799 :     ort->UnitConv(9).mult = 1.8;
   18839          799 :     ort->UnitConv(10).mult = 1.8;
   18840          799 :     ort->UnitConv(11).mult = 1.8;
   18841          799 :     ort->UnitConv(12).mult = 0.000645160041625726;
   18842          799 :     ort->UnitConv(13).mult = 1.0;
   18843          799 :     ort->UnitConv(14).mult = 1.0;
   18844          799 :     ort->UnitConv(15).mult = 1.0;
   18845          799 :     ort->UnitConv(16).mult = 1.0;
   18846          799 :     ort->UnitConv(17).mult = 1.0;
   18847          799 :     ort->UnitConv(18).mult = 1.0;
   18848          799 :     ort->UnitConv(19).mult = 0.00000094845;
   18849          799 :     ort->UnitConv(20).mult = 0.000000277778;
   18850          799 :     ort->UnitConv(21).mult = 0.0000000094845;
   18851          799 :     ort->UnitConv(22).mult = 0.00000000094845;
   18852          799 :     ort->UnitConv(23).mult = 0.000277777777777778;
   18853          799 :     ort->UnitConv(24).mult = 0.0000000789847;
   18854          799 :     ort->UnitConv(25).mult = 0.00042956;
   18855          799 :     ort->UnitConv(26).mult = 0.0000004302105;
   18856          799 :     ort->UnitConv(27).mult = 0.00000008811404;
   18857          799 :     ort->UnitConv(28).mult = 0.54861322767449;
   18858          799 :     ort->UnitConv(29).mult = 2.2046;
   18859          799 :     ort->UnitConv(30).mult = 1.0;
   18860          799 :     ort->UnitConv(31).mult = 0.062428;
   18861          799 :     ort->UnitConv(32).mult = 2.2046;
   18862          799 :     ort->UnitConv(33).mult = 1.0;
   18863          799 :     ort->UnitConv(34).mult = 2.2046;
   18864          799 :     ort->UnitConv(35).mult = 1.0;
   18865          799 :     ort->UnitConv(36).mult = 1.0;
   18866          799 :     ort->UnitConv(37).mult = 1.0;
   18867          799 :     ort->UnitConv(38).mult = 0.264172037284185;
   18868          799 :     ort->UnitConv(39).mult = 0.0353146624712848;
   18869          799 :     ort->UnitConv(40).mult = 1.0;
   18870          799 :     ort->UnitConv(41).mult = 0.092902267;
   18871          799 :     ort->UnitConv(42).mult = 3.281;
   18872          799 :     ort->UnitConv(43).mult = 39.37;
   18873          799 :     ort->UnitConv(44).mult = 196.86;
   18874          799 :     ort->UnitConv(45).mult = 2.2369;
   18875          799 :     ort->UnitConv(46).mult = 10.764961;
   18876          799 :     ort->UnitConv(47).mult = 10.764961;
   18877          799 :     ort->UnitConv(48).mult = 35.319837041;
   18878          799 :     ort->UnitConv(49).mult = 264.172;
   18879          799 :     ort->UnitConv(50).mult = 3.281;
   18880          799 :     ort->UnitConv(51).mult = 2118.6438;
   18881          799 :     ort->UnitConv(52).mult = 15852.0;
   18882          799 :     ort->UnitConv(53).mult = 196.85;
   18883          799 :     ort->UnitConv(54).mult = 2118.6438;
   18884          799 :     ort->UnitConv(55).mult = 15852.0;
   18885          799 :     ort->UnitConv(56).mult = 0.0001450377;
   18886          799 :     ort->UnitConv(57).mult = 0.00029613;
   18887          799 :     ort->UnitConv(58).mult = 0.00401463;
   18888          799 :     ort->UnitConv(59).mult = 0.00033455;
   18889          799 :     ort->UnitConv(60).mult = 0.0001450377;
   18890          799 :     ort->UnitConv(61).mult = 0.00029613;
   18891          799 :     ort->UnitConv(62).mult = 0.00401463;
   18892          799 :     ort->UnitConv(63).mult = 0.00033455;
   18893          799 :     ort->UnitConv(64).mult = 1.0;
   18894          799 :     ort->UnitConv(65).mult = 1.0;
   18895          799 :     ort->UnitConv(66).mult = 3.412;
   18896          799 :     ort->UnitConv(67).mult = 1.0;
   18897          799 :     ort->UnitConv(68).mult = 0.001;
   18898          799 :     ort->UnitConv(69).mult = 0.00341442;
   18899          799 :     ort->UnitConv(70).mult = 0.0002843333;
   18900          799 :     ort->UnitConv(71).mult = 0.001547673;
   18901          799 :     ort->UnitConv(72).mult = 0.001547673;
   18902          799 :     ort->UnitConv(73).mult = 1.8987;
   18903          799 :     ort->UnitConv(74).mult = 0.316954237;
   18904          799 :     ort->UnitConv(75).mult = 0.000316954237;
   18905          799 :     ort->UnitConv(76).mult = 0.176085687;
   18906          799 :     ort->UnitConv(77).mult = 0.176085687;
   18907          799 :     ort->UnitConv(78).mult = 1.0;
   18908          799 :     ort->UnitConv(79).mult = 1.0;
   18909          799 :     ort->UnitConv(80).mult = 1.8;
   18910          799 :     ort->UnitConv(81).mult = 0.42956;
   18911          799 :     ort->UnitConv(82).mult = 1.0 / 2118.6438;
   18912          799 :     ort->UnitConv(83).mult = 1.0 / 15852;
   18913          799 :     ort->UnitConv(84).mult = 1.0 / 10.764961;
   18914          799 :     ort->UnitConv(85).mult = 0.00000094845 * 1000000000;
   18915          799 :     ort->UnitConv(86).mult = 0.000000277778 * 1000000000;
   18916          799 :     ort->UnitConv(87).mult = 0.000000277778 * 1000000000;
   18917          799 :     ort->UnitConv(88).mult = 0.0000000094845 * 1000000000;
   18918          799 :     ort->UnitConv(89).mult = 0.00000000094845 * 1000000000;
   18919          799 :     ort->UnitConv(90).mult = 0.000277777777777778 * 1000000000;
   18920          799 :     ort->UnitConv(91).mult = 0.0000000789847 * 1000000000;
   18921          799 :     ort->UnitConv(92).mult = 0.277777777777778 / 10.764961;
   18922          799 :     ort->UnitConv(93).mult = 0.94708628903179 / 10.764961;
   18923          799 :     ort->UnitConv(94).mult = 0.94708628903179 / 10.764961;
   18924          799 :     ort->UnitConv(95).mult = 0.27777777777778;
   18925          799 :     ort->UnitConv(96).mult = 1.0;
   18926          799 :     ort->UnitConv(97).mult = 1.0;
   18927          799 :     ort->UnitConv(98).mult = 1.8987;
   18928          799 :     ort->UnitConv(99).mult = 1.0;
   18929          799 :     ort->UnitConv(100).mult = 1.0;
   18930          799 :     ort->UnitConv(101).mult = 1.0;
   18931          799 :     ort->UnitConv(102).mult = 1.0;
   18932          799 :     ort->UnitConv(103).mult = 1.0;
   18933          799 :     ort->UnitConv(104).mult = 1.0;
   18934          799 :     ort->UnitConv(105).mult = 1.0;
   18935          799 :     ort->UnitConv(106).mult = 1.0;
   18936          799 :     ort->UnitConv(107).mult = 1.0;
   18937          799 :     ort->UnitConv(108).mult = 0.000238845896627;
   18938          799 :     ort->UnitConv(109).mult = 2.2046;
   18939          799 :     ort->UnitConv(110).mult = 1.0;
   18940          799 :     ort->UnitConv(111).mult = 1.0;
   18941          799 :     ort->UnitConv(112).mult = 1.0;
   18942          799 :     ort->UnitConv(113).mult = 0.737562149277;
   18943          799 :     ort->UnitConv(114).mult = 1.0;
   18944          799 :     ort->UnitConv(115).mult = 0.09290304;
   18945          799 :     ort->UnitConv(116).mult = 0.03937;
   18946          799 :     ort->UnitConv(117).mult = 0.003281;
   18947          799 :     ort->UnitConv(118).mult = 1.8;
   18948              : 
   18949          799 :     ort->UnitConv(2).offset = 32.0;
   18950          799 :     ort->UnitConv(11).offset = 32.0;
   18951          799 :     ort->UnitConv(25).offset = 7.6736;
   18952          799 :     ort->UnitConv(81).offset = 7.6736; // 80 is KJ/KG -- should this be multiplied by 1000?
   18953              : 
   18954          799 :     ort->UnitConv(20).hint = "ELEC";
   18955          799 :     ort->UnitConv(21).hint = "GAS";
   18956          799 :     ort->UnitConv(24).hint = "COOL";
   18957          799 :     ort->UnitConv(38).hint = "WATER";
   18958          799 :     ort->UnitConv(49).hint = "WATER";
   18959          799 :     ort->UnitConv(52).hint = "WATER";
   18960          799 :     ort->UnitConv(67).hint = "ELEC";
   18961          799 :     ort->UnitConv(70).hint = "COOL";
   18962          799 :     ort->UnitConv(79).hint = "SI";
   18963          799 :     ort->UnitConv(83).hint = "WATER";
   18964          799 :     ort->UnitConv(86).hint = "CONSUMP";
   18965          799 :     ort->UnitConv(87).hint = "ELEC";
   18966          799 :     ort->UnitConv(88).hint = "GAS";
   18967          799 :     ort->UnitConv(91).hint = "COOL";
   18968          799 :     ort->UnitConv(92).hint = "ELEC";
   18969          799 :     ort->UnitConv(93).hint = "GAS";
   18970          799 :     ort->UnitConv(94).hint = "ADDITIONAL";
   18971              : 
   18972          799 :     ort->UnitConv(19).several = true;
   18973          799 :     ort->UnitConv(20).several = true;
   18974          799 :     ort->UnitConv(21).several = true;
   18975          799 :     ort->UnitConv(22).several = true;
   18976          799 :     ort->UnitConv(23).several = true;
   18977          799 :     ort->UnitConv(24).several = true;
   18978          799 :     ort->UnitConv(38).several = true;
   18979          799 :     ort->UnitConv(39).several = true;
   18980          799 :     ort->UnitConv(42).several = true;
   18981          799 :     ort->UnitConv(43).several = true;
   18982          799 :     ort->UnitConv(44).several = true;
   18983          799 :     ort->UnitConv(45).several = true;
   18984          799 :     ort->UnitConv(48).several = true;
   18985          799 :     ort->UnitConv(49).several = true;
   18986          799 :     ort->UnitConv(51).several = true;
   18987          799 :     ort->UnitConv(52).several = true;
   18988          799 :     ort->UnitConv(54).several = true;
   18989          799 :     ort->UnitConv(55).several = true;
   18990          799 :     ort->UnitConv(56).several = true;
   18991          799 :     ort->UnitConv(57).several = true;
   18992          799 :     ort->UnitConv(58).several = true;
   18993          799 :     ort->UnitConv(59).several = true;
   18994          799 :     ort->UnitConv(60).several = true;
   18995          799 :     ort->UnitConv(61).several = true;
   18996          799 :     ort->UnitConv(62).several = true;
   18997          799 :     ort->UnitConv(63).several = true;
   18998          799 :     ort->UnitConv(66).several = true;
   18999          799 :     ort->UnitConv(67).several = true;
   19000          799 :     ort->UnitConv(68).several = true;
   19001          799 :     ort->UnitConv(69).several = true;
   19002          799 :     ort->UnitConv(70).several = true;
   19003          799 :     ort->UnitConv(74).several = true;
   19004          799 :     ort->UnitConv(75).several = true;
   19005          799 :     ort->UnitConv(78).several = true;
   19006          799 :     ort->UnitConv(79).several = true;
   19007          799 :     ort->UnitConv(82).several = true;
   19008          799 :     ort->UnitConv(83).several = true;
   19009          799 :     ort->UnitConv(85).several = true;
   19010          799 :     ort->UnitConv(86).several = true;
   19011          799 :     ort->UnitConv(87).several = true;
   19012          799 :     ort->UnitConv(88).several = true;
   19013          799 :     ort->UnitConv(89).several = true;
   19014          799 :     ort->UnitConv(90).several = true;
   19015          799 :     ort->UnitConv(91).several = true;
   19016          799 :     ort->UnitConv(92).several = true;
   19017          799 :     ort->UnitConv(93).several = true;
   19018          799 :     ort->UnitConv(94).several = true;
   19019          799 :     ort->UnitConv(95).several = true;
   19020          799 :     ort->UnitConv(116).several = true;
   19021          799 :     ort->UnitConv(117).several = true;
   19022          799 : }
   19023              : 
   19024        28689 : 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        28689 :     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        28689 :     std::string::size_type const posLBrac = index(inString, '['); // left bracket
   19058        28689 :     std::string::size_type const posRBrac = index(inString, ']'); // right bracket
   19059              :     // extract the substring with the units
   19060        28689 :     if ((posLBrac != std::string::npos) && (posRBrac != std::string::npos) && (posRBrac - posLBrac >= 1)) {
   19061         8354 :         outUnit = inString.substr(posLBrac + 1, posRBrac - posLBrac - 1);
   19062              :     }
   19063        28689 :     return outUnit;
   19064            0 : }
   19065              : 
   19066        15695 : 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        15695 :     std::string unitSIOnly;
   19086              :     int modeInString;
   19087        15695 :     int constexpr misBrac(1);
   19088        15695 :     int constexpr misParen(2);
   19089        15695 :     int constexpr misBrce(3);
   19090        15695 :     int constexpr misNoHint(4);
   19091        15695 :     std::string const stringInUpper(Util::makeUPPER(stringInWithSI));
   19092        15695 :     auto &ort = state.dataOutRptTab;
   19093              : 
   19094        15695 :     stringOutWithIP = "";
   19095              :     // check if string has brackets or parentheses
   19096        15695 :     std::string::size_type posLBrac = index(stringInUpper, '[');  // left bracket
   19097        15695 :     std::string::size_type posRBrac = index(stringInUpper, ']');  // right bracket
   19098        15695 :     std::string::size_type posLParen = index(stringInUpper, '('); // left parenthesis
   19099        15695 :     std::string::size_type posRParen = index(stringInUpper, ')'); // right parenthesis
   19100        15695 :     std::string::size_type posLBrce = index(stringInUpper, '{');  // left brace
   19101        15695 :     std::string::size_type posRBrce = index(stringInUpper, '}');  // right brace
   19102        15695 :     bool noBrackets = true;
   19103              :     // extract the substring with the units
   19104        15695 :     if ((posLBrac != std::string::npos) && (posRBrac != std::string::npos) && (posRBrac - posLBrac >= 1)) {
   19105         7200 :         unitSIOnly = stringInUpper.substr(posLBrac + 1, posRBrac - posLBrac - 1);
   19106         7200 :         modeInString = misBrac;
   19107         7200 :         noBrackets = false;
   19108         8495 :     } else if ((posLBrce != std::string::npos) && (posRBrce != std::string::npos) && (posRBrce - posLBrce >= 1)) {
   19109         2617 :         unitSIOnly = stringInUpper.substr(posLBrce + 1, posRBrce - posLBrce - 1);
   19110         2617 :         modeInString = misBrce;
   19111         5878 :     } else if ((posLParen != std::string::npos) && (posRParen != std::string::npos) && (posRParen - posLParen >= 1)) {
   19112          202 :         unitSIOnly = stringInUpper.substr(posLParen + 1, posRParen - posLParen - 1);
   19113          202 :         modeInString = misParen;
   19114              :     } else {
   19115         5676 :         unitSIOnly = stringInUpper;
   19116         5676 :         modeInString = misNoHint;
   19117              :     }
   19118        15695 :     unitSIOnly = stripped(unitSIOnly);
   19119        15695 :     int defaultConv = 0;
   19120        15695 :     int foundConv = 0;
   19121        15695 :     int firstOfSeveral = 0;
   19122      1503559 :     for (int iUnit = 1; iUnit <= ort->UnitConvSize; ++iUnit) {
   19123      1492565 :         if (Util::SameString(ort->UnitConv(iUnit).siName, unitSIOnly)) {
   19124        21501 :             if (ort->UnitConv(iUnit).several) {
   19125        17406 :                 if (firstOfSeveral == 0) {
   19126         4948 :                     firstOfSeveral = iUnit;
   19127              :                 }
   19128        17406 :                 if (ort->UnitConv(iUnit).is_default) {
   19129            0 :                     defaultConv = iUnit;
   19130              :                 }
   19131              :                 // look for the hint string
   19132        17406 :                 if (len(ort->UnitConv(iUnit).hint) > 0) {
   19133         7406 :                     if (has(stringInUpper, ort->UnitConv(iUnit).hint)) {
   19134          606 :                         foundConv = iUnit;
   19135          606 :                         break;
   19136              :                     }
   19137              :                 }
   19138              :             } else { // not several possibilities so don't bother with rest of array
   19139         4095 :                 foundConv = iUnit;
   19140         4095 :                 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        15695 :     int selectedConv(0);
   19148        15695 :     if (foundConv > 0) {
   19149         4701 :         selectedConv = foundConv;
   19150              :     } else {
   19151              :         // not found - see if in a group it should be default or first.
   19152        10994 :         if (firstOfSeveral == 0) {
   19153         6652 :             selectedConv = 0;
   19154              :         } else {
   19155         4342 :             if (defaultConv != 0) {
   19156            0 :                 selectedConv = defaultConv;
   19157              :             } else {
   19158         4342 :                 selectedConv = firstOfSeveral;
   19159              :             }
   19160              :         }
   19161              :     }
   19162              :     // if one was selected substitute the units into the output string
   19163        15695 :     if (selectedConv > 0) {
   19164         9043 :         if (modeInString == misBrac) {
   19165         7200 :             stringOutWithIP = stringInWithSI.substr(0, posLBrac + 1) + ort->UnitConv(selectedConv).ipName + stringInWithSI.substr(posRBrac);
   19166         1843 :         } else if (modeInString == misParen) {
   19167          143 :             stringOutWithIP = stringInWithSI.substr(0, posLParen + 1) + ort->UnitConv(selectedConv).ipName + stringInWithSI.substr(posRParen);
   19168         1700 :         } else if (modeInString == misBrce) {
   19169         1700 :             stringOutWithIP = stringInWithSI.substr(0, posLBrce + 1) + ort->UnitConv(selectedConv).ipName + stringInWithSI.substr(posRBrce);
   19170            0 :         } else if (modeInString == misNoHint) {
   19171            0 :             stringOutWithIP = ort->UnitConv(selectedConv).ipName;
   19172              :         }
   19173              :     } else {
   19174              :         // if no conversion just output the input string
   19175         6652 :         stringOutWithIP = stringInWithSI;
   19176              :     }
   19177              : 
   19178        15695 :     unitConvIndex = selectedConv;
   19179              : 
   19180              :     // Add warning if units not found.
   19181        15695 :     if (unitConvIndex == 0 && !noBrackets) {
   19182            0 :         ShowWarningError(state, format("Unable to find a unit conversion from {} into IP units", stringInWithSI));
   19183            0 :         ShowContinueError(state, "Applying default conversion factor of 1.0");
   19184              :     }
   19185        15695 : }
   19186              : 
   19187         8589 : 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         8589 :     stringOutWithKWH = stringInWithJ;
   19197         8589 :     std::string::size_type gjPos = stringOutWithKWH.find("[GJ]");
   19198         8589 :     std::string::size_type mjm2Pos = stringOutWithKWH.find("[MJ/m2]");
   19199         8589 :     if (gjPos != std::string::npos) {
   19200          240 :         stringOutWithKWH.replace(gjPos, 4, "[kWh]");
   19201          960 :         unitConvIndex = getSpecificUnitIndex(state, "GJ", "kWh");
   19202         8349 :     } else if (mjm2Pos != std::string::npos) {
   19203           18 :         stringOutWithKWH.replace(mjm2Pos, 7, "[kWh/m2]");
   19204           72 :         unitConvIndex = getSpecificUnitIndex(state, "MJ/m2", "kWh/m2");
   19205              :     } else {
   19206         8331 :         unitConvIndex = 0;
   19207              :     }
   19208         8589 : }
   19209              : 
   19210        38783 : 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        38783 :     auto &ort = state.dataOutRptTab;
   19250              : 
   19251        38783 :     if (unitConvIndex == 0 || SIvalue == -999.0 || SIvalue == -99999.0) { // don't convert unknown data to IP
   19252         3122 :         ConvertIP = SIvalue;
   19253        35661 :     } else if ((unitConvIndex > 0) && (unitConvIndex <= ort->UnitConvSize)) {
   19254        35661 :         ConvertIP = (SIvalue * ort->UnitConv(unitConvIndex).mult) + ort->UnitConv(unitConvIndex).offset;
   19255              :     } else {
   19256            0 :         ConvertIP = SIvalue;
   19257              :     }
   19258        38783 :     return ConvertIP;
   19259              : }
   19260              : 
   19261           88 : 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           88 :     auto &ort = state.dataOutRptTab;
   19302              : 
   19303           88 :     if (unitConvIndex == 0) {
   19304            0 :         ConvertIPdelta = SIvalue;
   19305           88 :     } else if ((unitConvIndex > 0) && (unitConvIndex <= ort->UnitConvSize)) {
   19306           88 :         ConvertIPdelta = SIvalue * ort->UnitConv(unitConvIndex).mult;
   19307              :     } else {
   19308            0 :         ConvertIPdelta = SIvalue;
   19309              :     }
   19310           88 :     return ConvertIPdelta;
   19311              : }
   19312              : 
   19313            0 : 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            0 :     auto &ort = state.dataOutRptTab;
   19352              : 
   19353            0 :     if ((unitConvIndex > 0) && (unitConvIndex <= ort->UnitConvSize)) {
   19354            0 :         multiplier = ort->UnitConv(unitConvIndex).mult;
   19355            0 :         offset = ort->UnitConv(unitConvIndex).offset;
   19356            0 :         IPunit = ort->UnitConv(unitConvIndex).ipName;
   19357              :     } else {
   19358            0 :         multiplier = 1.0;
   19359            0 :         offset = 0.0;
   19360            0 :         IPunit = "";
   19361              :     }
   19362            0 : }
   19363              : 
   19364           99 : 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           99 :     auto &ort = state.dataOutRptTab;
   19407              : 
   19408         5533 :     for (state.dataOutRptTab->iUnitGsum = 1; state.dataOutRptTab->iUnitGsum <= ort->UnitConvSize; ++state.dataOutRptTab->iUnitGsum) {
   19409         5533 :         if (Util::SameString(ort->UnitConv(state.dataOutRptTab->iUnitGsum).siName, SIunit)) {
   19410          154 :             if (Util::SameString(ort->UnitConv(state.dataOutRptTab->iUnitGsum).ipName, IPunit)) {
   19411           99 :                 state.dataOutRptTab->foundGsum = state.dataOutRptTab->iUnitGsum;
   19412           99 :                 break;
   19413              :             }
   19414              :         }
   19415              :     }
   19416           99 :     if (state.dataOutRptTab->foundGsum != 0) {
   19417           99 :         getSpecificUnitMultiplier = ort->UnitConv(state.dataOutRptTab->foundGsum).mult;
   19418              :     } else {
   19419            0 :         ShowWarningError(state, format("Unable to find a unit conversion from {} to {}", SIunit, IPunit));
   19420            0 :         ShowContinueError(state, "Applying default conversion factor of 1.0");
   19421            0 :         getSpecificUnitMultiplier = 1.0;
   19422              :     }
   19423           99 :     return getSpecificUnitMultiplier;
   19424              : }
   19425              : 
   19426           66 : 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           66 :     mult = getSpecificUnitMultiplier(state, SIunit, IPunit);
   19471           66 :     if (mult != 0) {
   19472           66 :         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           66 :     return getSpecificUnitDivider;
   19479              : }
   19480              : 
   19481          258 : 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          258 :     auto &ort = state.dataOutRptTab;
   19521              : 
   19522        22350 :     for (state.dataOutRptTab->iUnitGsui = 1; state.dataOutRptTab->iUnitGsui <= ort->UnitConvSize; ++state.dataOutRptTab->iUnitGsui) {
   19523        22350 :         if (Util::SameString(ort->UnitConv(state.dataOutRptTab->iUnitGsui).siName, SIunit)) {
   19524          552 :             if (Util::SameString(ort->UnitConv(state.dataOutRptTab->iUnitGsui).ipName, IPunit)) {
   19525          258 :                 state.dataOutRptTab->foundGsui = state.dataOutRptTab->iUnitGsui;
   19526          258 :                 break;
   19527              :             }
   19528              :         }
   19529              :     }
   19530          258 :     if (state.dataOutRptTab->foundGsui != 0) {
   19531          258 :         getSpecificUnitIndex = state.dataOutRptTab->foundGsui;
   19532              :     } else {
   19533            0 :         getSpecificUnitIndex = 0.0;
   19534              :     }
   19535          258 :     return getSpecificUnitIndex;
   19536              : }
   19537              : 
   19538              : } // namespace EnergyPlus::OutputReportTabular
        

Generated by: LCOV version 2.0-1