LCOV - code coverage report
Current view: top level - EnergyPlus - OutputReportTabular.cc (source / functions) Hit Total Coverage
Test: lcov.output.filtered Lines: 9608 11756 81.7 %
Date: 2023-01-17 19:17:23 Functions: 121 138 87.7 %

          Line data    Source code
       1             : // EnergyPlus, Copyright (c) 1996-2023, 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 <cassert>
      51             : #include <cmath>
      52             : #include <iomanip>
      53             : #include <map>
      54             : #include <unordered_map>
      55             : #include <utility>
      56             : #include <vector>
      57             : 
      58             : // ObjexxFCL Headers
      59             : #include <ObjexxFCL/Array.functions.hh>
      60             : #include <ObjexxFCL/ArrayS.functions.hh>
      61             : #include <ObjexxFCL/Fmath.hh>
      62             : #include <ObjexxFCL/member.functions.hh>
      63             : #include <ObjexxFCL/numeric.hh>
      64             : #include <ObjexxFCL/string.functions.hh>
      65             : #include <ObjexxFCL/time.hh>
      66             : 
      67             : // Third-party Headers
      68             : #include <fast_float/fast_float.h>
      69             : #include <fmt/format.h>
      70             : 
      71             : // EnergyPlus Headers
      72             : #include <AirflowNetwork/Solver.hpp>
      73             : #include <EnergyPlus/Boilers.hh>
      74             : #include <EnergyPlus/ChillerElectricEIR.hh>
      75             : #include <EnergyPlus/ChillerReformulatedEIR.hh>
      76             : #include <EnergyPlus/CondenserLoopTowers.hh>
      77             : #include <EnergyPlus/CostEstimateManager.hh>
      78             : #include <EnergyPlus/DXCoils.hh>
      79             : #include <EnergyPlus/Data/EnergyPlusData.hh>
      80             : #include <EnergyPlus/DataAirLoop.hh>
      81             : #include <EnergyPlus/DataAirSystems.hh>
      82             : #include <EnergyPlus/DataDaylighting.hh>
      83             : #include <EnergyPlus/DataDefineEquip.hh>
      84             : #include <EnergyPlus/DataGlobalConstants.hh>
      85             : #include <EnergyPlus/DataHVACGlobals.hh>
      86             : #include <EnergyPlus/DataHeatBalFanSys.hh>
      87             : #include <EnergyPlus/DataHeatBalSurface.hh>
      88             : #include <EnergyPlus/DataHeatBalance.hh>
      89             : #include <EnergyPlus/DataIPShortCuts.hh>
      90             : #include <EnergyPlus/DataOutputs.hh>
      91             : #include <EnergyPlus/DataShadowingCombinations.hh>
      92             : #include <EnergyPlus/DataSizing.hh>
      93             : #include <EnergyPlus/DataStringGlobals.hh>
      94             : #include <EnergyPlus/DataSurfaces.hh>
      95             : #include <EnergyPlus/DataViewFactorInformation.hh>
      96             : #include <EnergyPlus/DataWater.hh>
      97             : #include <EnergyPlus/DisplayRoutines.hh>
      98             : #include <EnergyPlus/EconomicLifeCycleCost.hh>
      99             : #include <EnergyPlus/ElectricPowerServiceManager.hh>
     100             : #include <EnergyPlus/EvaporativeCoolers.hh>
     101             : #include <EnergyPlus/EvaporativeFluidCoolers.hh>
     102             : #include <EnergyPlus/FileSystem.hh>
     103             : #include <EnergyPlus/FluidCoolers.hh>
     104             : #include <EnergyPlus/General.hh>
     105             : #include <EnergyPlus/HVACVariableRefrigerantFlow.hh>
     106             : #include <EnergyPlus/HeatingCoils.hh>
     107             : #include <EnergyPlus/HybridModel.hh>
     108             : #include <EnergyPlus/InputProcessing/InputProcessor.hh>
     109             : #include <EnergyPlus/InternalHeatGains.hh>
     110             : #include <EnergyPlus/LowTempRadiantSystem.hh>
     111             : #include <EnergyPlus/MixedAir.hh>
     112             : #include <EnergyPlus/OutputProcessor.hh>
     113             : #include <EnergyPlus/OutputReportPredefined.hh>
     114             : #include <EnergyPlus/OutputReportTabular.hh>
     115             : #include <EnergyPlus/OutputReportTabularAnnual.hh>
     116             : #include <EnergyPlus/PackagedThermalStorageCoil.hh>
     117             : #include <EnergyPlus/PlantChillers.hh>
     118             : #include <EnergyPlus/PollutionModule.hh>
     119             : #include <EnergyPlus/Psychrometrics.hh>
     120             : #include <EnergyPlus/RefrigeratedCase.hh>
     121             : #include <EnergyPlus/ReportCoilSelection.hh>
     122             : #include <EnergyPlus/ResultsFramework.hh>
     123             : #include <EnergyPlus/SQLiteProcedures.hh>
     124             : #include <EnergyPlus/ScheduleManager.hh>
     125             : #include <EnergyPlus/ThermalComfort.hh>
     126             : #include <EnergyPlus/UtilityRoutines.hh>
     127             : #include <EnergyPlus/VentilatedSlab.hh>
     128             : #include <EnergyPlus/WaterManager.hh>
     129             : #include <EnergyPlus/WaterThermalTanks.hh>
     130             : #include <EnergyPlus/WeatherManager.hh>
     131             : #include <EnergyPlus/ZonePlenum.hh>
     132             : #include <EnergyPlus/ZoneTempPredictorCorrector.hh>
     133             : 
     134             : namespace EnergyPlus::OutputReportTabular {
     135             : 
     136             : // MODULE INFORMATION:
     137             : //    AUTHOR         Jason Glazer of GARD Analytics, Inc.
     138             : //    DATE WRITTEN   July 2003
     139             : //    MODIFIED       na
     140             : //    RE-ENGINEERED  na
     141             : // PURPOSE OF THIS MODULE:
     142             : //    This module allows the user to define several different tabular
     143             : //    report that have a specific format.
     144             : // METHODOLOGY EMPLOYED:
     145             : //    Generally aggregation. Specifically, the IDF objects are read into data
     146             : //    structures on the first call to update the data.  The data structures
     147             : //    include not only ones to hold the IDF data but also that initialize
     148             : //    the structure used to gather data each iteration. The report:table:binned
     149             : //    object is stored in OutputTableBinned.
     150             : //    During initialization the TableResults data structure is created which contains
     151             : //    all the information needed to perform the aggregation on a timestep basis.
     152             : //    After the end of the simulation the original Output data structures
     153             : //    are scanned and actual tables are created doing any scaling as necessary
     154             : //    and placing all the results into an output table.  The output table
     155             : //    is written in the selected format for each of the tables defined.
     156             : // REFERENCES:
     157             : //    None.
     158             : // OTHER NOTES:.
     159             : //                                      |--> BinResults
     160             : //                                      |
     161             : //                                      |--> BinResultsAbove
     162             : //   OutputTableBinned ---------------->|
     163             : //                                      |--> BinResultsBelow
     164             : //                                      |
     165             : //                                      |--> BinObjVarID
     166             : //
     167             : //                                      |--> MonthlyFieldSetInput
     168             : //   MonthlyInput --------------------->|
     169             : //                                      |--> MonthlyTable --> MonthlyColumns
     170             : 
     171             : // Using/Aliasing
     172             : using namespace DataGlobalConstants;
     173             : using namespace OutputReportPredefined;
     174             : using namespace DataHeatBalance;
     175             : using namespace HybridModel;
     176             : 
     177         828 : std::ofstream &open_tbl_stream(EnergyPlusData &state, int const iStyle, fs::path const &filePath, bool output_to_file)
     178             : {
     179         828 :     std::ofstream &tbl_stream(*state.dataOutRptTab->TabularOutputFile(iStyle));
     180         828 :     if (output_to_file) {
     181         828 :         tbl_stream.open(filePath);
     182         828 :         if (!tbl_stream) {
     183           0 :             ShowFatalError(state, "OpenOutputTabularFile: Could not open file \"" + filePath.string() + "\" for output (write).");
     184             :         }
     185             :     } else {
     186           0 :         tbl_stream.setstate(std::ios_base::badbit);
     187             :     }
     188         828 :     return tbl_stream;
     189             : }
     190             : 
     191      690474 : void UpdateTabularReports(EnergyPlusData &state, OutputProcessor::TimeStepType t_timeStepType) // What kind of data to update (Zone, HVAC)
     192             : {
     193             :     // SUBROUTINE INFORMATION:
     194             :     //       AUTHOR         Jason Glazer
     195             :     //       DATE WRITTEN   July 2003
     196             :     //       MODIFIED       na
     197             :     //       RE-ENGINEERED  na
     198             : 
     199             :     // PURPOSE OF THIS SUBROUTINE:
     200             :     // This is the routine that is called at the end of the time step
     201             :     // loop and updates the arrays of data that will later being put
     202             :     // into the tabular reports.
     203             : 
     204      690474 :     auto &ort(state.dataOutRptTab);
     205             : 
     206      690474 :     if (t_timeStepType != OutputProcessor::TimeStepType::Zone && t_timeStepType != OutputProcessor::TimeStepType::System) {
     207           0 :         ShowFatalError(state, "Invalid reporting requested -- UpdateTabularReports");
     208             :     }
     209             : 
     210      690474 :     if (ort->UpdateTabularReportsGetInput) {
     211         769 :         GetInputTabularMonthly(state);
     212         769 :         OutputReportTabularAnnual::GetInputTabularAnnual(state);
     213         769 :         OutputReportTabularAnnual::checkAggregationOrderForAnnual(state);
     214         769 :         GetInputTabularTimeBins(state);
     215         769 :         GetInputTabularStyle(state);
     216         769 :         GetInputOutputTableSummaryReports(state);
     217         769 :         if (state.dataOutRptTab->displayThermalResilienceSummary) {
     218             :             // check whether multiple people have different threshold for a zone
     219         656 :             Real64 valueNotInit = -999.0;
     220         656 :             Real64 nearThreshold = 1.0;
     221        4109 :             for (int ZoneNum = 1; ZoneNum <= state.dataGlobal->NumOfZones; ++ZoneNum) {
     222        3453 :                 state.dataHeatBal->Resilience(ZoneNum).ColdStressTempThresh = valueNotInit;
     223        3453 :                 state.dataHeatBal->Resilience(ZoneNum).HeatStressTempThresh = valueNotInit;
     224             :             }
     225        3453 :             for (int iPeople = 1; iPeople <= state.dataHeatBal->TotPeople; ++iPeople) {
     226        2797 :                 int ZoneNum = state.dataHeatBal->People(iPeople).ZonePtr;
     227             : 
     228        2797 :                 Real64 ColdTempThresh = state.dataHeatBal->People(iPeople).ColdStressTempThresh;
     229        2797 :                 if (state.dataHeatBal->Resilience(ZoneNum).ColdStressTempThresh < valueNotInit + nearThreshold) {
     230        2778 :                     state.dataHeatBal->Resilience(ZoneNum).ColdStressTempThresh = ColdTempThresh;
     231             :                 } else {
     232          19 :                     if (state.dataHeatBal->Resilience(ZoneNum).ColdStressTempThresh != ColdTempThresh) {
     233           0 :                         ShowWarningMessage(
     234           0 :                             state, fmt::format("Zone {} has multiple people objects with different Cold Stress Temperature Threshold.", ZoneNum));
     235             :                     }
     236             :                 }
     237             : 
     238        2797 :                 Real64 HeatTempThresh = state.dataHeatBal->People(iPeople).HeatStressTempThresh;
     239        2797 :                 if (state.dataHeatBal->Resilience(ZoneNum).HeatStressTempThresh < valueNotInit + nearThreshold) {
     240        2778 :                     state.dataHeatBal->Resilience(ZoneNum).HeatStressTempThresh = HeatTempThresh;
     241             :                 } else {
     242          19 :                     if (state.dataHeatBal->Resilience(ZoneNum).HeatStressTempThresh != HeatTempThresh) {
     243           0 :                         ShowWarningMessage(
     244           0 :                             state, fmt::format("Zone {} has multiple people objects with different Heat Stress Temperature Threshold.", ZoneNum));
     245             :                     }
     246             :                 }
     247             :             }
     248             :         }
     249             :         // noel -- noticed this was called once and very slow -- sped up a little by caching keys
     250         769 :         InitializeTabularMonthly(state);
     251         769 :         if (isInvalidAggregationOrder(state)) {
     252           0 :             ShowFatalError(state, "OutputReportTabular: Invalid aggregations detected, no simulation performed.");
     253             :         }
     254         769 :         GetInputFuelAndPollutionFactors(state);
     255         769 :         SetupUnitConversions(state);
     256         769 :         AddTOCLoadComponentTableSummaries(state);
     257         769 :         ort->UpdateTabularReportsGetInput = false;
     258         769 :         date_and_time(_, _, _, ort->td);
     259             :     }
     260     1360686 :     if (state.dataGlobal->DoOutputReporting && ort->WriteTabularFiles &&
     261      670212 :         (state.dataGlobal->KindOfSim == DataGlobalConstants::KindOfSim::RunPeriodWeather)) {
     262      161715 :         if (t_timeStepType == OutputProcessor::TimeStepType::Zone) {
     263       70176 :             ort->gatherElapsedTimeBEPS += state.dataGlobal->TimeStepZone;
     264             :         }
     265      161715 :         if (state.dataGlobal->DoWeathSim) {
     266      161715 :             GatherMonthlyResultsForTimestep(state, t_timeStepType);
     267      161715 :             OutputReportTabularAnnual::GatherAnnualResultsForTimeStep(state, t_timeStepType);
     268      161715 :             GatherBinResultsForTimestep(state, t_timeStepType);
     269      161715 :             GatherBEPSResultsForTimestep(state, t_timeStepType);
     270      161715 :             GatherSourceEnergyEndUseResultsForTimestep(state, t_timeStepType);
     271      161715 :             GatherPeakDemandForTimestep(state, t_timeStepType);
     272      161715 :             GatherHeatGainReport(state, t_timeStepType);
     273      161715 :             GatherHeatEmissionReport(state, t_timeStepType);
     274             :         }
     275             :     }
     276      690474 : }
     277             : 
     278             : //======================================================================================================================
     279             : //======================================================================================================================
     280             : 
     281             : //    GET INPUT ROUTINES
     282             : 
     283             : //======================================================================================================================
     284             : //======================================================================================================================
     285             : 
     286         769 : void GetInputTabularMonthly(EnergyPlusData &state)
     287             : {
     288             :     // SUBROUTINE INFORMATION:
     289             :     //       AUTHOR         Jason Glazer
     290             :     //       DATE WRITTEN   July 2003
     291             :     //       MODIFIED       na
     292             :     //       RE-ENGINEERED  na
     293             : 
     294             :     // PURPOSE OF THIS SUBROUTINE:
     295             :     //   The routine assigns the input information for
     296             :     //   REPORT:TABLE:MONTHLY also known as tabular monthly
     297             :     //   reports that are defined by the user. The input
     298             :     //   information is assigned to a data structure that
     299             :     //   is used for both user defined monthly reports and
     300             :     //   predefined monthly reports.
     301             : 
     302             :     // METHODOLOGY EMPLOYED:
     303             :     //   Uses get input structure and call to build up
     304             :     //   data on monthly reports.
     305             : 
     306             :     // REFERENCES:
     307             :     // na
     308             : 
     309             :     // USE STATEMENTS:
     310             :     // na
     311             : 
     312             :     // Locals
     313             :     // SUBROUTINE ARGUMENT DEFINITIONS:
     314             :     // na
     315             : 
     316             :     // SUBROUTINE PARAMETER DEFINITIONS:
     317         769 :     static std::string const CurrentModuleObject("Output:Table:Monthly");
     318             : 
     319             :     // INTERFACE BLOCK SPECIFICATIONS:
     320             :     // na
     321             : 
     322             :     // DERIVED TYPE DEFINITIONS:
     323             :     // na
     324             : 
     325             :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
     326             :     int curTable;             // index of the current table being processed in MonthlyInput
     327             :     AggType curAggType;       // kind of aggregation identified (see AggType parameters)
     328        1403 :     std::string curAggString; // Current aggregation sting
     329             :     int jField;
     330             :     int NumParams;            // Number of elements combined
     331             :     int NumAlphas;            // Number of elements in the alpha array
     332             :     int NumNums;              // Number of elements in the numeric array
     333        1403 :     Array1D_string AlphArray; // character string data
     334        1403 :     Array1D<Real64> NumArray; // numeric data
     335             :     int IOStat;               // IO Status when calling get input subroutine
     336         769 :     bool ErrorsFound(false);
     337         769 :     auto &ort(state.dataOutRptTab);
     338             : 
     339         769 :     if (!(state.files.outputControl.tabular || state.files.outputControl.sqlite)) {
     340           1 :         ort->WriteTabularFiles = false;
     341           1 :         return;
     342             :     }
     343             : 
     344         768 :     ort->MonthlyInputCount = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, CurrentModuleObject);
     345         768 :     if (ort->MonthlyInputCount > 0) {
     346         134 :         ort->WriteTabularFiles = true;
     347             :         // if not a run period using weather do not create reports
     348         134 :         if (!state.dataGlobal->DoWeathSim) {
     349         402 :             ShowWarningError(state,
     350         268 :                              CurrentModuleObject + " requested with SimulationControl Run Simulation for Weather File Run Periods set to No so " +
     351         268 :                                  CurrentModuleObject + " will not be generated");
     352         134 :             return;
     353             :         }
     354             :     }
     355         634 :     state.dataInputProcessing->inputProcessor->getObjectDefMaxArgs(state, CurrentModuleObject, NumParams, NumAlphas, NumNums);
     356         634 :     AlphArray.allocate(NumAlphas);
     357         634 :     NumArray.dimension(NumNums, 0.0);
     358         634 :     for (int TabNum = 1, TabNum_end = ort->MonthlyInputCount; TabNum <= TabNum_end; ++TabNum) { // MonthlyInputCount is modified in the loop
     359           0 :         state.dataInputProcessing->inputProcessor->getObjectItem(state, CurrentModuleObject, TabNum, AlphArray, NumAlphas, NumArray, NumNums, IOStat);
     360             : 
     361           0 :         if (TabNum - 1 > 0) {
     362           0 :             UtilityRoutines::IsNameEmpty(state, AlphArray(1), CurrentModuleObject, ErrorsFound);
     363             :         }
     364           0 :         if (NumAlphas < 2) {
     365           0 :             ShowSevereError(state, CurrentModuleObject + ": No fields specified.");
     366             :         }
     367             :         // add to the data structure
     368           0 :         curTable = AddMonthlyReport(state, AlphArray(1), int(NumArray(1)));
     369           0 :         for (jField = 2; jField <= NumAlphas; jField += 2) {
     370           0 :             if (AlphArray(jField).empty()) {
     371           0 :                 ShowFatalError(state, "Blank report name in Output:Table:Monthly");
     372             :             }
     373           0 :             curAggString = AlphArray(jField + 1);
     374             :             // set accumulator values to default as appropriate for aggregation type
     375           0 :             if (UtilityRoutines::SameString(curAggString, "SumOrAverage")) {
     376           0 :                 curAggType = AggType::SumOrAvg;
     377           0 :             } else if (UtilityRoutines::SameString(curAggString, "Maximum")) {
     378           0 :                 curAggType = AggType::Maximum;
     379           0 :             } else if (UtilityRoutines::SameString(curAggString, "Minimum")) {
     380           0 :                 curAggType = AggType::Minimum;
     381           0 :             } else if (UtilityRoutines::SameString(curAggString, "ValueWhenMaximumOrMinimum")) {
     382           0 :                 curAggType = AggType::ValueWhenMaxMin;
     383           0 :             } else if (UtilityRoutines::SameString(curAggString, "HoursZero")) {
     384           0 :                 curAggType = AggType::HoursZero;
     385           0 :             } else if (UtilityRoutines::SameString(curAggString, "HoursNonzero")) {
     386           0 :                 curAggType = AggType::HoursNonZero;
     387           0 :             } else if (UtilityRoutines::SameString(curAggString, "HoursPositive")) {
     388           0 :                 curAggType = AggType::HoursPositive;
     389           0 :             } else if (UtilityRoutines::SameString(curAggString, "HoursNonpositive")) {
     390           0 :                 curAggType = AggType::HoursNonPositive;
     391           0 :             } else if (UtilityRoutines::SameString(curAggString, "HoursNegative")) {
     392           0 :                 curAggType = AggType::HoursNegative;
     393           0 :             } else if (UtilityRoutines::SameString(curAggString, "HoursNonnegative")) {
     394           0 :                 curAggType = AggType::HoursNonNegative;
     395           0 :             } else if (UtilityRoutines::SameString(curAggString, "SumOrAverageDuringHoursShown")) {
     396           0 :                 curAggType = AggType::SumOrAverageHoursShown;
     397           0 :             } else if (UtilityRoutines::SameString(curAggString, "MaximumDuringHoursShown")) {
     398           0 :                 curAggType = AggType::MaximumDuringHoursShown;
     399           0 :             } else if (UtilityRoutines::SameString(curAggString, "MinimumDuringHoursShown")) {
     400           0 :                 curAggType = AggType::MinimumDuringHoursShown;
     401             :             } else {
     402           0 :                 curAggType = AggType::SumOrAvg;
     403           0 :                 ShowWarningError(state, CurrentModuleObject + '=' + ort->MonthlyInput(TabNum).name + ", Variable name=" + AlphArray(jField));
     404           0 :                 ShowContinueError(state, "Invalid aggregation type=\"" + curAggString + "\"  Defaulting to SumOrAverage.");
     405             :             }
     406           0 :             AddMonthlyFieldSetInput(state, curTable, AlphArray(jField), "", curAggType);
     407             :         }
     408             :     }
     409             : }
     410             : 
     411        1513 : int AddMonthlyReport(EnergyPlusData &state, std::string const &inReportName, int const inNumDigitsShown)
     412             : {
     413             :     // SUBROUTINE INFORMATION:
     414             :     //       AUTHOR         Jason Glazer
     415             :     //       DATE WRITTEN   August 2008
     416             :     //       MODIFIED
     417             :     //       RE-ENGINEERED  na
     418             : 
     419             :     // PURPOSE OF THIS SUBROUTINE:
     420             :     //   Creates a monthly report
     421             : 
     422             :     // METHODOLOGY EMPLOYED:
     423             :     // na
     424             : 
     425             :     // REFERENCES:
     426             :     // na
     427             : 
     428             :     // USE STATEMENTS:
     429             : 
     430             :     // Return value
     431             : 
     432             :     // Locals
     433             :     // SUBROUTINE ARGUMENT DEFINITIONS:
     434             :     // na
     435             : 
     436             :     // SUBROUTINE PARAMETER DEFINITIONS:
     437             : 
     438             :     // INTERFACE BLOCK SPECIFICATIONS:
     439             :     // na
     440             : 
     441             :     // DERIVED TYPE DEFINITIONS:
     442             :     // na
     443             : 
     444             :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
     445        1513 :     int constexpr SizeAdder(25);
     446        1513 :     auto &ort(state.dataOutRptTab);
     447             : 
     448        1513 :     if (!allocated(ort->MonthlyInput)) {
     449          25 :         ort->MonthlyInput.allocate(SizeAdder);
     450          25 :         ort->sizeMonthlyInput = SizeAdder;
     451          25 :         ort->MonthlyInputCount = 1;
     452             :     } else {
     453        1488 :         ++ort->MonthlyInputCount;
     454             :         // if larger than current size grow the array
     455        1488 :         if (ort->MonthlyInputCount > ort->sizeMonthlyInput) {
     456          48 :             ort->MonthlyInput.redimension(ort->sizeMonthlyInput += SizeAdder);
     457             :         }
     458             :     }
     459             :     // initialize new record
     460        1513 :     ort->MonthlyInput(ort->MonthlyInputCount).name = inReportName;
     461        1513 :     ort->MonthlyInput(ort->MonthlyInputCount).showDigits = inNumDigitsShown;
     462        1513 :     return ort->MonthlyInputCount;
     463             : }
     464             : 
     465       10493 : void AddMonthlyFieldSetInput(
     466             :     EnergyPlusData &state, int const inMonthReport, std::string const &inVariMeter, std::string const &inColHead, AggType const inAggregate)
     467             : {
     468             :     // SUBROUTINE INFORMATION:
     469             :     //       AUTHOR         Jason Glazer
     470             :     //       DATE WRITTEN   August 2008
     471             :     //       MODIFIED
     472             :     //       RE-ENGINEERED  na
     473             : 
     474             :     // PURPOSE OF THIS SUBROUTINE:
     475             :     //   Assigns the column information for predefined
     476             :     //   monthly reports
     477             : 
     478             :     // METHODOLOGY EMPLOYED:
     479             :     //   Simple assignments to public variables.
     480             : 
     481             :     // REFERENCES:
     482             :     // na
     483             : 
     484             :     // USE STATEMENTS:
     485             : 
     486             :     // Locals
     487             :     // SUBROUTINE ARGUMENT DEFINITIONS:
     488             : 
     489             :     // SUBROUTINE PARAMETER DEFINITIONS:
     490       10493 :     int constexpr sizeIncrement(50);
     491       10493 :     auto &ort(state.dataOutRptTab);
     492             : 
     493             :     // INTERFACE BLOCK SPECIFICATIONS:
     494             :     // na
     495             : 
     496             :     // DERIVED TYPE DEFINITIONS:
     497             :     // na
     498             : 
     499             :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
     500             :     // na
     501             : 
     502       10493 :     if (!allocated(ort->MonthlyFieldSetInput)) {
     503          25 :         ort->MonthlyFieldSetInput.allocate(sizeIncrement);
     504          25 :         ort->sizeMonthlyFieldSetInput = sizeIncrement;
     505          25 :         ort->MonthlyFieldSetInputCount = 1;
     506             :     } else {
     507       10468 :         ++ort->MonthlyFieldSetInputCount;
     508             :         // if larger than current size grow the array
     509       10468 :         if (ort->MonthlyFieldSetInputCount > ort->sizeMonthlyFieldSetInput) {
     510         288 :             ort->MonthlyFieldSetInput.redimension(ort->sizeMonthlyFieldSetInput *=
     511         288 :                                                   2); // Tuned Changed += sizeIncrement to *= 2 for reduced heap allocations (at some space cost)
     512             :         }
     513             :     }
     514             :     // initialize new record)
     515       10493 :     ort->MonthlyFieldSetInput(ort->MonthlyFieldSetInputCount).variMeter = inVariMeter;
     516       10493 :     ort->MonthlyFieldSetInput(ort->MonthlyFieldSetInputCount).colHead = inColHead;
     517       10493 :     ort->MonthlyFieldSetInput(ort->MonthlyFieldSetInputCount).aggregate = inAggregate;
     518             :     // update the references from the MonthlyInput array
     519       10493 :     if ((inMonthReport > 0) && (inMonthReport <= ort->MonthlyInputCount)) {
     520       10493 :         if (ort->MonthlyInput(inMonthReport).firstFieldSet == 0) {
     521        1513 :             ort->MonthlyInput(inMonthReport).firstFieldSet = ort->MonthlyFieldSetInputCount;
     522        1513 :             ort->MonthlyInput(inMonthReport).numFieldSet = 1;
     523             :         } else {
     524        8980 :             ++ort->MonthlyInput(inMonthReport).numFieldSet;
     525             :         }
     526             :     }
     527       10493 : }
     528             : 
     529         769 : void InitializeTabularMonthly(EnergyPlusData &state)
     530             : {
     531             :     // SUBROUTINE INFORMATION:
     532             :     //       AUTHOR         Jason Glazer
     533             :     //       DATE WRITTEN   July 2008
     534             :     //       MODIFIED       na
     535             :     //       RE-ENGINEERED  na
     536             : 
     537             :     // PURPOSE OF THIS SUBROUTINE:
     538             :     //   This routine initializes the data structures based
     539             :     //   on input from either the IDF file or from the predefined
     540             :     //   monthly reports.  The data structures follow the IDD
     541             :     //   closely.  The routine initializes many of the arrays
     542             :     //   for monthly tables.
     543             : 
     544             :     // METHODOLOGY EMPLOYED:
     545             :     //   Process the data structures that define monthly tabular
     546             :     //   reports
     547             : 
     548             :     // NOTE:
     549             :     //   The bulk of this routine used to be part of the the
     550             :     //   GetInputTabularMonthly routine but when predefined
     551             :     //   monthly reports were added this routine was seperated
     552             :     //   from input.
     553             : 
     554             :     // REFERENCES:
     555             :     // na
     556             : 
     557             :     // USE STATEMENTS:
     558             :     // na
     559             : 
     560             :     // Locals
     561             :     // SUBROUTINE ARGUMENT DEFINITIONS:
     562             :     // na
     563             : 
     564             :     // SUBROUTINE PARAMETER DEFINITIONS:
     565             :     // na
     566             : 
     567             :     // INTERFACE BLOCK SPECIFICATIONS:
     568             :     // na
     569             : 
     570             :     // DERIVED TYPE DEFINITIONS:
     571             :     // na
     572             : 
     573             :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
     574             :     int TabNum;               // index when cycling through each table
     575             :     int NumColumns;           // number of columns specified in the input for an object
     576             :     int FirstColumn;          // the first column of the monthly input
     577         771 :     std::string curVariMeter; // current variable or meter
     578             :     int colNum;               // loop index for columns
     579             :     int KeyCount;
     580             :     OutputProcessor::VariableType TypeVar;
     581             :     OutputProcessor::StoreType AvgSumVar;
     582             :     OutputProcessor::TimeStepType StepTypeVar;
     583         769 :     OutputProcessor::Unit UnitsVar(OutputProcessor::Unit::None); // Units enum
     584         771 :     Array1D_string UniqueKeyNames;
     585             :     int UniqueKeyCount;
     586             :     int iKey;
     587             :     int jUnique;
     588             :     int found;
     589             :     int kUniqueKey;
     590             :     int lTable;
     591             :     int mColumn;
     592             :     int ColumnsRecount;
     593             :     int TablesRecount;
     594             :     bool environmentKeyFound;
     595         769 :     auto &ort(state.dataOutRptTab);
     596             : 
     597             :     // if not a running a weather simulation do not create reports
     598         769 :     if (!state.dataGlobal->DoWeathSim) return;
     599           2 :     ort->maxUniqueKeyCount = 1500;
     600           2 :     UniqueKeyNames.allocate(ort->maxUniqueKeyCount);
     601             :     // First pass through the input objects is to put the name of the report
     602             :     // into the array and count the number of unique keys found to allocate
     603             :     // the monthlyTables and monthlyColumns
     604             :     // This approach seems inefficient but I know of no other way to size
     605             :     // the arrays prior to filling them and to size the arrays basically
     606             :     // the same steps must be gone through as with filling the arrays.
     607             : 
     608             :     //#ifdef ITM_KEYCACHE
     609             :     // Noel comment:  How about allocating these variables once for the whole routine?
     610             :     //    Again, if a max value for key count can be agreed upon, we could use it here --
     611             :     //    otherwise, will have to have re-allocate logic.
     612             :     // maxKeyCount=1500 ! ?
     613             :     // ALLOCATE(NamesOfKeys(maxKeyCount))
     614             :     // ALLOCATE(IndexesForKeyVar(maxKeyCount))
     615             :     //#endif
     616             : 
     617           2 :     ort->MonthlyColumnsCount = 0;
     618           2 :     ort->MonthlyTablesCount = 0;
     619           2 :     for (TabNum = 1; TabNum <= ort->MonthlyInputCount; ++TabNum) {
     620             :         // the number of columns based on number of alpha fields
     621           0 :         NumColumns = ort->MonthlyInput(TabNum).numFieldSet;
     622           0 :         FirstColumn = ort->MonthlyInput(TabNum).firstFieldSet;
     623           0 :         environmentKeyFound = false;
     624           0 :         UniqueKeyCount = 0;
     625           0 :         for (colNum = 1; colNum <= NumColumns; ++colNum) {
     626             : 
     627             :             //#ifdef ITM_KEYCACHE
     628             :             // Noel comment:  First time in this TabNum/ColNum loop, let's save the results
     629             :             //  of GetVariableKeyCountandType & GetVariableKeys.
     630           0 :             curVariMeter = UtilityRoutines::MakeUPPERCase(ort->MonthlyFieldSetInput(FirstColumn + colNum - 1).variMeter);
     631             :             // call the key count function but only need count during this pass
     632           0 :             GetVariableKeyCountandType(state, curVariMeter, KeyCount, TypeVar, AvgSumVar, StepTypeVar, UnitsVar);
     633           0 :             if (TypeVar == OutputProcessor::VariableType::NotFound) {
     634           0 :                 ShowWarningError(
     635           0 :                     state, "In Output:Table:Monthly '" + ort->MonthlyInput(TabNum).name + "' invalid Variable or Meter Name '" + curVariMeter + "'");
     636             :             }
     637             :             //    IF (KeyCount > maxKeyCount) THEN
     638             :             //      DEALLOCATE(NamesOfKeys)
     639             :             //      DEALLOCATE(IndexesForKeyVar)
     640             :             //      maxKeyCount=KeyCount
     641             :             //      ALLOCATE(NamesOfKeys(maxKeyCount))
     642             :             //      ALLOCATE(IndexesForKeyVar(maxKeyCount))
     643             :             //    ENDIF
     644           0 :             ort->MonthlyFieldSetInput(FirstColumn + colNum - 1).NamesOfKeys.allocate(KeyCount);
     645           0 :             ort->MonthlyFieldSetInput(FirstColumn + colNum - 1).IndexesForKeyVar.allocate(KeyCount);
     646             : 
     647             :             // fill keys?
     648           0 :             GetVariableKeys(state,
     649             :                             curVariMeter,
     650             :                             TypeVar,
     651           0 :                             ort->MonthlyFieldSetInput(FirstColumn + colNum - 1).NamesOfKeys,
     652           0 :                             ort->MonthlyFieldSetInput(FirstColumn + colNum - 1).IndexesForKeyVar);
     653             : 
     654             :             // save these values to use later -- noel
     655           0 :             ort->MonthlyFieldSetInput(FirstColumn + colNum - 1).variMeterUpper = curVariMeter;
     656           0 :             ort->MonthlyFieldSetInput(FirstColumn + colNum - 1).typeOfVar = TypeVar;
     657           0 :             ort->MonthlyFieldSetInput(FirstColumn + colNum - 1).keyCount = KeyCount;
     658           0 :             ort->MonthlyFieldSetInput(FirstColumn + colNum - 1).varAvgSum = AvgSumVar;
     659           0 :             ort->MonthlyFieldSetInput(FirstColumn + colNum - 1).varStepType = StepTypeVar;
     660           0 :             ort->MonthlyFieldSetInput(FirstColumn + colNum - 1).varUnits = UnitsVar;
     661             :             //    DO iKey = 1, KeyCount
     662             :             //      MonthlyFieldSetInput(FirstColumn + ColNum - 1)%NamesOfKeys(iKey) = NamesOfKeys(iKey)  !noel
     663             :             //      MonthlyFieldSetInput(FirstColumn + ColNum - 1)%IndexesForKeyVar(iKey) = IndexesForKeyVar(iKey)  !noel
     664             :             //    ENDDO
     665             :             //#else
     666             :             //    curVariMeter = UtilityRoutines::MakeUPPERCase(MonthlyFieldSetInput(FirstColumn + ColNum - 1)%variMeter)
     667             :             //    ! call the key count function but only need count during this pass
     668             :             //    CALL GetVariableKeyCountandType(state, curVariMeter,KeyCount,TypeVar,AvgSumVar,StepTypeVar,UnitsVar)
     669             :             //    ALLOCATE(NamesOfKeys(KeyCount))
     670             :             //    ALLOCATE(IndexesForKeyVar(KeyCount))
     671             :             //    CALL GetVariableKeys(state, curVariMeter,TypeVar,NamesOfKeys,IndexesForKeyVar)
     672             :             //#endif
     673             : 
     674           0 :             for (iKey = 1; iKey <= KeyCount; ++iKey) {
     675           0 :                 found = 0;
     676             :                 // set a flag if environment variables are found
     677           0 :                 if (UtilityRoutines::SameString(ort->MonthlyFieldSetInput(FirstColumn + colNum - 1).NamesOfKeys(iKey), "ENVIRONMENT")) {
     678           0 :                     environmentKeyFound = true;
     679           0 :                     found = -1; // so not counted in list of unique keys
     680             :                 }
     681           0 :                 for (jUnique = 1; jUnique <= UniqueKeyCount; ++jUnique) {
     682           0 :                     if (UtilityRoutines::SameString(UniqueKeyNames(jUnique), ort->MonthlyFieldSetInput(FirstColumn + colNum - 1).NamesOfKeys(iKey))) {
     683           0 :                         found = jUnique;
     684           0 :                         break;
     685             :                     }
     686             :                 }
     687           0 :                 if (found == 0) {
     688           0 :                     ++UniqueKeyCount;
     689           0 :                     if (UniqueKeyCount > ort->maxUniqueKeyCount) {
     690           0 :                         UniqueKeyNames.redimension(ort->maxUniqueKeyCount += 500);
     691             :                     }
     692           0 :                     UniqueKeyNames(UniqueKeyCount) = ort->MonthlyFieldSetInput(FirstColumn + colNum - 1).NamesOfKeys(iKey);
     693             :                 }
     694             :             }
     695             :             //#ifdef ITM_KEYCACHE
     696             :             //    ! Don't deallocate here, only allocating/deallocating once for the whole routine
     697             :             //#else
     698             :             //    DEALLOCATE(NamesOfKeys)
     699             :             //    DEALLOCATE(IndexesForKeyVar)
     700             :             //#endif
     701             :         } // colNum
     702             :         // fix for CR8285 - when monthly report is only environmental variables
     703           0 :         if (environmentKeyFound && UniqueKeyCount == 0) {
     704           0 :             UniqueKeyCount = 1;
     705             :         }
     706             :         // increment the number of tables based on the number of unique keys
     707           0 :         ort->MonthlyTablesCount += UniqueKeyCount;
     708           0 :         ort->MonthlyColumnsCount += UniqueKeyCount * NumColumns;
     709             :     } // TabNum the end of the loop through the inputs objects
     710             :     // Now that we have the maximum size of the number of tables (each table is
     711             :     // repeated for the number of keys found) and the number of total columns
     712             :     // of all of the tables, allocate the arrays to store this information.
     713           2 :     ort->MonthlyTables.allocate(ort->MonthlyTablesCount);
     714           2 :     ort->MonthlyColumns.allocate(ort->MonthlyColumnsCount);
     715             :     // Initialize tables and results
     716           2 :     for (auto &e : ort->MonthlyTables) {
     717           0 :         e.keyValue.clear();
     718           0 :         e.firstColumn = 0;
     719           0 :         e.numColumns = 0;
     720             :     }
     721             : 
     722           2 :     for (auto &e : ort->MonthlyColumns) {
     723           0 :         e.varName.clear();
     724           0 :         e.varNum = 0;
     725           0 :         e.typeOfVar = OutputProcessor::VariableType::NotFound;
     726           0 :         e.avgSum = OutputProcessor::StoreType::Averaged;
     727           0 :         e.stepType = OutputProcessor::TimeStepType::Zone;
     728           0 :         e.units = OutputProcessor::Unit::None;
     729           0 :         e.aggType = AggType::Invalid;
     730             :     }
     731           2 :     for (colNum = 1; colNum <= ort->MonthlyColumnsCount; ++colNum) {
     732           0 :         ort->MonthlyColumns(colNum).reslt = 0.0;
     733           0 :         ort->MonthlyColumns(colNum).timeStamp = 0;
     734           0 :         ort->MonthlyColumns(colNum).duration = 0.0;
     735             :     }
     736             : 
     737           2 :     ColumnsRecount = 0;
     738           2 :     TablesRecount = 0;
     739           2 :     for (TabNum = 1; TabNum <= ort->MonthlyInputCount; ++TabNum) {
     740             :         // the number of columns based on number of alpha fields
     741           0 :         NumColumns = ort->MonthlyInput(TabNum).numFieldSet;
     742           0 :         FirstColumn = ort->MonthlyInput(TabNum).firstFieldSet;
     743           0 :         UniqueKeyCount = 0;
     744           0 :         environmentKeyFound = false;
     745           0 :         for (colNum = 1; colNum <= NumColumns; ++colNum) {
     746             :             //#ifdef ITM_KEYCACHE
     747             :             // Noel comment:  Here is where we could use the saved values
     748           0 :             curVariMeter = ort->MonthlyFieldSetInput(FirstColumn + colNum - 1).variMeterUpper;
     749           0 :             KeyCount = ort->MonthlyFieldSetInput(FirstColumn + colNum - 1).keyCount;
     750           0 :             TypeVar = ort->MonthlyFieldSetInput(FirstColumn + colNum - 1).typeOfVar;
     751           0 :             AvgSumVar = ort->MonthlyFieldSetInput(FirstColumn + colNum - 1).varAvgSum;
     752           0 :             StepTypeVar = ort->MonthlyFieldSetInput(FirstColumn + colNum - 1).varStepType;
     753           0 :             UnitsVar = ort->MonthlyFieldSetInput(FirstColumn + colNum - 1).varUnits;
     754             :             //    DO iKey = 1, KeyCount  !noel
     755             :             //       NamesOfKeys(iKey) = MonthlyFieldSetInput(FirstColumn + ColNum - 1)%NamesOfKeys(iKey)  !noel
     756             :             //       IndexesForKeyVar(iKey) = MonthlyFieldSetInput(FirstColumn + ColNum - 1)%IndexesForKeyVar(iKey) !noel
     757             :             //    ENDDO
     758             :             //#else
     759             :             //    curVariMeter = UtilityRoutines::MakeUPPERCase(MonthlyFieldSetInput(FirstColumn + ColNum - 1)%variMeter)
     760             :             //    ! call the key count function but only need count during this pass
     761             :             //    CALL GetVariableKeyCountandType(state, curVariMeter,KeyCount,TypeVar,AvgSumVar,StepTypeVar,UnitsVar)
     762             :             //    ALLOCATE(NamesOfKeys(KeyCount))
     763             :             //    ALLOCATE(IndexesForKeyVar(KeyCount))
     764             :             //    CALL GetVariableKeys(state, curVariMeter,TypeVar,NamesOfKeys,IndexesForKeyVar)
     765             :             //#endif
     766             : 
     767           0 :             if (KeyCount == 0) {
     768           0 :                 ++state.dataOutRptTab->ErrCount1;
     769           0 :                 if (state.dataOutRptTab->ErrCount1 == 1 && !state.dataGlobal->DisplayExtraWarnings &&
     770           0 :                     state.dataGlobal->KindOfSim == DataGlobalConstants::KindOfSim::RunPeriodWeather) {
     771           0 :                     ShowWarningError(state, "Processing Monthly Tabular Reports: Variable names not valid for this simulation");
     772           0 :                     ShowContinueError(state, "...use Output:Diagnostics,DisplayExtraWarnings; to show more details on individual variables.");
     773             :                 }
     774             :                 // fixing CR5878 removed the showing of the warning once about a specific variable.
     775           0 :                 if (state.dataGlobal->DisplayExtraWarnings && state.dataGlobal->KindOfSim == DataGlobalConstants::KindOfSim::RunPeriodWeather) {
     776           0 :                     ShowWarningError(state, "Processing Monthly Tabular Reports: " + ort->MonthlyInput(TabNum).name);
     777           0 :                     ShowContinueError(state, "..Variable name=" + curVariMeter + " not valid for this simulation.");
     778           0 :                     if (state.dataOutRptTab->VarWarning) {
     779           0 :                         ShowContinueError(state,
     780             :                                           "..Variables not valid for this simulation will have \"[Invalid/Undefined]\" in the Units Column of "
     781             :                                           "the Table Report.");
     782           0 :                         state.dataOutRptTab->VarWarning = false;
     783             :                     }
     784             :                 }
     785             :             }
     786           0 :             for (iKey = 1; iKey <= KeyCount; ++iKey) {
     787           0 :                 found = 0;
     788             :                 // set a flag if environment variables are found
     789           0 :                 if (UtilityRoutines::SameString(ort->MonthlyFieldSetInput(FirstColumn + colNum - 1).NamesOfKeys(iKey), "ENVIRONMENT")) {
     790           0 :                     environmentKeyFound = true;
     791           0 :                     found = -1; // so not counted in list of unique keys
     792             :                 }
     793           0 :                 for (jUnique = 1; jUnique <= UniqueKeyCount; ++jUnique) {
     794           0 :                     if (UtilityRoutines::SameString(UniqueKeyNames(jUnique), ort->MonthlyFieldSetInput(FirstColumn + colNum - 1).NamesOfKeys(iKey))) {
     795           0 :                         found = jUnique;
     796           0 :                         break;
     797             :                     }
     798             :                 }
     799           0 :                 if (found == 0) {
     800           0 :                     ++UniqueKeyCount;
     801           0 :                     UniqueKeyNames(UniqueKeyCount) = ort->MonthlyFieldSetInput(FirstColumn + colNum - 1).NamesOfKeys(iKey);
     802             :                 }
     803             :             }
     804             :             //#ifdef ITM_KEYCACHE
     805             :             //    ! Don't deallocate here, only allocating/deallocating once for the whole routine
     806             :             //#else
     807             :             //    DEALLOCATE(NamesOfKeys)
     808             :             //    DEALLOCATE(IndexesForKeyVar)
     809             :             //#endif
     810             :         }
     811             :         // fix for CR8285 - when monthly report is only environmental variables
     812           0 :         if (environmentKeyFound && UniqueKeyCount == 0) {
     813           0 :             UniqueKeyCount = 1;
     814             :         }
     815             :         // increment the number of tables based on the number of unique keys
     816           0 :         ort->MonthlyInput(TabNum).firstTable = TablesRecount + 1;
     817           0 :         ort->MonthlyInput(TabNum).numTables = UniqueKeyCount;
     818           0 :         TablesRecount += UniqueKeyCount;
     819             :         // loop through the different unique keys since each user defined table
     820             :         // has that many instances - one for each unique key.
     821             :         // It is unusual that this loop is about 'keys' and an inner loop is also
     822             :         // about 'keys' but for this loop the keys are really instances of tables.
     823           0 :         for (kUniqueKey = 1; kUniqueKey <= UniqueKeyCount; ++kUniqueKey) {
     824           0 :             lTable = kUniqueKey + ort->MonthlyInput(TabNum).firstTable - 1;
     825             :             // use the term 'environment' for identifying the report if
     826           0 :             if (environmentKeyFound && UniqueKeyCount == 1) {
     827           0 :                 ort->MonthlyTables(lTable).keyValue = "Environment";
     828             :             } else { // this is the most common case is to use the unique key for the report
     829           0 :                 ort->MonthlyTables(lTable).keyValue = UniqueKeyNames(kUniqueKey);
     830             :             }
     831           0 :             ort->MonthlyTables(lTable).firstColumn = ColumnsRecount + 1;
     832           0 :             ort->MonthlyTables(lTable).numColumns = NumColumns;
     833           0 :             ColumnsRecount += NumColumns;
     834           0 :             FirstColumn = ort->MonthlyInput(TabNum).firstFieldSet;
     835           0 :             for (colNum = 1; colNum <= NumColumns; ++colNum) {
     836           0 :                 environmentKeyFound = false;
     837           0 :                 mColumn = colNum + ort->MonthlyTables(lTable).firstColumn - 1;
     838             :                 // when going through the columns this time, not all columns may have
     839             :                 // a EP variable that corresponds to it.  In no variable is found
     840             :                 // then set it to 0 to be skipped during data gathering
     841             : 
     842             :                 //#ifdef ITM_KEYCACHE
     843             :                 // Noel comment:  Here is where we could use the saved values
     844           0 :                 curVariMeter = ort->MonthlyFieldSetInput(FirstColumn + colNum - 1).variMeterUpper;
     845           0 :                 KeyCount = ort->MonthlyFieldSetInput(FirstColumn + colNum - 1).keyCount;
     846           0 :                 TypeVar = ort->MonthlyFieldSetInput(FirstColumn + colNum - 1).typeOfVar;
     847           0 :                 AvgSumVar = ort->MonthlyFieldSetInput(FirstColumn + colNum - 1).varAvgSum;
     848           0 :                 StepTypeVar = ort->MonthlyFieldSetInput(FirstColumn + colNum - 1).varStepType;
     849           0 :                 UnitsVar = ort->MonthlyFieldSetInput(FirstColumn + colNum - 1).varUnits;
     850             :                 //    DO iKey = 1, KeyCount  !noel
     851             :                 //       NamesOfKeys(iKey) = MonthlyFieldSetInput(FirstColumn + ColNum - 1)%NamesOfKeys(iKey)  !noel
     852             :                 //       IndexesForKeyVar(iKey) = MonthlyFieldSetInput(FirstColumn + ColNum - 1)%IndexesForKeyVar(iKey) !noel
     853             :                 //    ENDDO
     854             :                 //#else
     855             :                 //    curVariMeter = UtilityRoutines::MakeUPPERCase(MonthlyFieldSetInput(FirstColumn + ColNum - 1)%variMeter)
     856             :                 //    ! call the key count function but only need count during this pass
     857             :                 //    CALL GetVariableKeyCountandType(state, curVariMeter,KeyCount,TypeVar,AvgSumVar,StepTypeVar,UnitsVar)
     858             :                 //    ALLOCATE(NamesOfKeys(KeyCount))
     859             :                 //    ALLOCATE(IndexesForKeyVar(KeyCount))
     860             :                 //    CALL GetVariableKeys(state, curVariMeter,TypeVar,NamesOfKeys,IndexesForKeyVar)
     861             :                 //#endif
     862             : 
     863           0 :                 if (KeyCount == 1) { // first test if KeyCount is one to avoid referencing a zero element array
     864           0 :                     if (UtilityRoutines::SameString(ort->MonthlyFieldSetInput(FirstColumn + colNum - 1).NamesOfKeys(1), "ENVIRONMENT")) {
     865           0 :                         environmentKeyFound = true;
     866             :                     }
     867             :                 }
     868             :                 // if this is an environment variable - don't bother searching
     869           0 :                 if (environmentKeyFound) {
     870           0 :                     found = 1; // only one instance of environment variables so use it.
     871             :                 } else {
     872             :                     // search through the keys for the currently active key "UniqueKeyNames(kUniqueKey)"
     873           0 :                     found = 0;
     874           0 :                     for (iKey = 1; iKey <= KeyCount; ++iKey) {
     875           0 :                         if (UtilityRoutines::SameString(ort->MonthlyFieldSetInput(FirstColumn + colNum - 1).NamesOfKeys(iKey),
     876           0 :                                                         UniqueKeyNames(kUniqueKey))) {
     877           0 :                             found = iKey;
     878           0 :                             break;
     879             :                         }
     880             :                     }
     881             :                 }
     882           0 :                 if ((found > 0) && (KeyCount >= 1)) {
     883           0 :                     ort->MonthlyColumns(mColumn).varName = curVariMeter;
     884           0 :                     ort->MonthlyColumns(mColumn).varNum = ort->MonthlyFieldSetInput(FirstColumn + colNum - 1).IndexesForKeyVar(found);
     885           0 :                     ort->MonthlyColumns(mColumn).typeOfVar = TypeVar;
     886           0 :                     ort->MonthlyColumns(mColumn).avgSum = AvgSumVar;
     887           0 :                     ort->MonthlyColumns(mColumn).stepType = StepTypeVar;
     888           0 :                     ort->MonthlyColumns(mColumn).units = UnitsVar;
     889           0 :                     ort->MonthlyColumns(mColumn).aggType = ort->MonthlyFieldSetInput(FirstColumn + colNum - 1).aggregate;
     890             :                     // set accumulator values to default as appropriate for aggregation type
     891           0 :                     switch (ort->MonthlyColumns(mColumn).aggType) {
     892           0 :                     case AggType::SumOrAvg: {
     893           0 :                         ort->MonthlyColumns(mColumn).reslt = 0.0;
     894           0 :                         ort->MonthlyColumns(mColumn).duration = 0.0;
     895           0 :                     } break;
     896           0 :                     case AggType::Maximum: {
     897           0 :                         ort->MonthlyColumns(mColumn).reslt = -HUGE_(state.dataOutRptTab->BigNum);
     898           0 :                         ort->MonthlyColumns(mColumn).timeStamp = 0;
     899           0 :                     } break;
     900           0 :                     case AggType::Minimum: {
     901           0 :                         ort->MonthlyColumns(mColumn).reslt = HUGE_(state.dataOutRptTab->BigNum);
     902           0 :                         ort->MonthlyColumns(mColumn).timeStamp = 0;
     903           0 :                     } break;
     904           0 :                     case AggType::ValueWhenMaxMin: {
     905           0 :                         ort->MonthlyColumns(mColumn).reslt = 0.0;
     906           0 :                     } break;
     907           0 :                     case AggType::HoursZero: {
     908           0 :                         ort->MonthlyColumns(mColumn).reslt = 0.0;
     909           0 :                     } break;
     910           0 :                     case AggType::HoursNonZero: {
     911           0 :                         ort->MonthlyColumns(mColumn).reslt = 0.0;
     912           0 :                     } break;
     913           0 :                     case AggType::HoursPositive: {
     914           0 :                         ort->MonthlyColumns(mColumn).reslt = 0.0;
     915           0 :                     } break;
     916           0 :                     case AggType::HoursNonPositive: {
     917           0 :                         ort->MonthlyColumns(mColumn).reslt = 0.0;
     918           0 :                     } break;
     919           0 :                     case AggType::HoursNegative: {
     920           0 :                         ort->MonthlyColumns(mColumn).reslt = 0.0;
     921           0 :                     } break;
     922           0 :                     case AggType::HoursNonNegative: {
     923           0 :                         ort->MonthlyColumns(mColumn).reslt = 0.0;
     924           0 :                     } break;
     925           0 :                     case AggType::SumOrAverageHoursShown: {
     926           0 :                         ort->MonthlyColumns(mColumn).reslt = 0.0;
     927           0 :                         ort->MonthlyColumns(mColumn).duration = 0.0;
     928           0 :                     } break;
     929           0 :                     case AggType::MaximumDuringHoursShown: {
     930           0 :                         ort->MonthlyColumns(mColumn).reslt = -HUGE_(state.dataOutRptTab->BigNum);
     931           0 :                         ort->MonthlyColumns(mColumn).timeStamp = 0;
     932           0 :                     } break;
     933           0 :                     case AggType::MinimumDuringHoursShown: {
     934           0 :                         ort->MonthlyColumns(mColumn).reslt = HUGE_(state.dataOutRptTab->BigNum);
     935           0 :                         ort->MonthlyColumns(mColumn).timeStamp = 0;
     936           0 :                     } break;
     937           0 :                     default:
     938           0 :                         break;
     939             :                     }
     940             :                 } else { // if no key corresponds to this instance of the report
     941             :                     // fixing CR5878 removed the showing of the warning once about a specific variable.
     942           0 :                     if (state.dataGlobal->DisplayExtraWarnings && state.dataGlobal->KindOfSim == DataGlobalConstants::KindOfSim::RunPeriodWeather) {
     943           0 :                         ShowWarningError(state, "Processing Monthly Tabular Reports: " + ort->MonthlyInput(TabNum).name);
     944           0 :                         ShowContinueError(state, "..Variable name=" + curVariMeter + " not valid for this simulation.");
     945           0 :                         ShowContinueError(
     946           0 :                             state, "..i.e., Variable name=" + UniqueKeyNames(kUniqueKey) + ':' + curVariMeter + " not valid for this simulation.");
     947           0 :                         if (state.dataOutRptTab->VarWarning) {
     948           0 :                             ShowContinueError(state,
     949             :                                               "..Variables not valid for this simulation will have \"[Invalid/Undefined]\" in the Units Column "
     950             :                                               "of the Table Report.");
     951           0 :                             state.dataOutRptTab->VarWarning = false;
     952             :                         }
     953             :                     }
     954           0 :                     ort->MonthlyColumns(mColumn).varName = curVariMeter;
     955           0 :                     ort->MonthlyColumns(mColumn).varNum = 0;
     956           0 :                     ort->MonthlyColumns(mColumn).typeOfVar = OutputProcessor::VariableType::NotFound;
     957           0 :                     ort->MonthlyColumns(mColumn).avgSum = OutputProcessor::StoreType::Averaged;
     958           0 :                     ort->MonthlyColumns(mColumn).stepType = OutputProcessor::TimeStepType::Zone;
     959           0 :                     ort->MonthlyColumns(mColumn).units = OutputProcessor::Unit::None;
     960           0 :                     ort->MonthlyColumns(mColumn).aggType = AggType::SumOrAvg;
     961             :                 }
     962             :                 //#ifdef ITM_KEYCACHE
     963             :                 //#else
     964             :                 //    DEALLOCATE(NamesOfKeys)
     965             :                 //    DEALLOCATE(IndexesForKeyVar)
     966             :                 //#endif
     967             :             } // ColNum
     968             :         }     // kUniqueKey
     969             :     }         // TabNum the end of the loop through the inputs objects
     970             : 
     971             :     //#ifdef ITM_KEYCACHE
     972             :     // DEALLOCATE(NamesOfKeys)
     973             :     // DEALLOCATE(IndexesForKeyVar)
     974             :     //#endif
     975             : }
     976             : 
     977         769 : bool isInvalidAggregationOrder(EnergyPlusData &state)
     978             : {
     979         769 :     auto &ort(state.dataOutRptTab);
     980         769 :     bool foundError = false;
     981         769 :     if (!state.dataGlobal->DoWeathSim) { // if no weather simulation than no reading of MonthlyInput array
     982         767 :         return foundError;
     983             :     }
     984           2 :     for (int iInput = 1; iInput <= ort->MonthlyInputCount; ++iInput) {
     985           0 :         bool foundMinOrMax = false;
     986           0 :         bool foundHourAgg = false;
     987           0 :         bool missingMaxOrMinError = false;
     988           0 :         bool missingHourAggError = false;
     989           0 :         for (int jTable = 1; jTable <= ort->MonthlyInput(iInput).numTables; ++jTable) {
     990           0 :             int curTable = jTable + ort->MonthlyInput(iInput).firstTable - 1;
     991             :             // test if the aggregation types are in the correct order
     992           0 :             for (int kColumn = 1; kColumn <= ort->MonthlyTables(curTable).numColumns; ++kColumn) {
     993           0 :                 int curCol = kColumn + ort->MonthlyTables(curTable).firstColumn - 1;
     994           0 :                 if (ort->MonthlyColumns(curCol).varNum == 0) break; // if no variable was ever found than stop checking
     995           0 :                 AggType curAggType = ort->MonthlyColumns(curCol).aggType;
     996           0 :                 if ((curAggType == AggType::Maximum) || (curAggType == AggType::Minimum)) {
     997           0 :                     foundMinOrMax = true;
     998           0 :                 } else if ((curAggType == AggType::HoursNonZero) || (curAggType == AggType::HoursZero) || (curAggType == AggType::HoursPositive) ||
     999           0 :                            (curAggType == AggType::HoursNonPositive) || (curAggType == AggType::HoursNegative) ||
    1000             :                            (curAggType == AggType::HoursNonNegative)) {
    1001           0 :                     foundHourAgg = true;
    1002           0 :                 } else if (curAggType == AggType::ValueWhenMaxMin) {
    1003           0 :                     if (!foundMinOrMax) {
    1004           0 :                         missingMaxOrMinError = true;
    1005             :                     }
    1006           0 :                 } else if ((curAggType == AggType::SumOrAverageHoursShown) || (curAggType == AggType::MaximumDuringHoursShown) ||
    1007             :                            (curAggType == AggType::MinimumDuringHoursShown)) {
    1008           0 :                     if (!foundHourAgg) {
    1009           0 :                         missingHourAggError = true;
    1010             :                     }
    1011             :                 }
    1012             :             }
    1013             :         }
    1014           0 :         if (missingMaxOrMinError) {
    1015           0 :             ShowSevereError(state,
    1016           0 :                             "The Output:Table:Monthly report named=\"" + ort->MonthlyInput(iInput).name +
    1017             :                                 "\" has a valueWhenMaxMin aggregation type for a column without a previous column that uses either the minimum or "
    1018             :                                 "maximum aggregation types. The report will not be generated.");
    1019           0 :             foundError = true;
    1020             :         }
    1021           0 :         if (missingHourAggError) {
    1022           0 :             ShowSevereError(state,
    1023           0 :                             "The Output:Table:Monthly report named=\"" + ort->MonthlyInput(iInput).name +
    1024             :                                 "\" has a --DuringHoursShown aggregation type for a column without a previous field that uses one of the Hour-- "
    1025             :                                 "aggregation types. The report will not be generated.");
    1026           0 :             foundError = true;
    1027             :         }
    1028             :     }
    1029           2 :     return foundError;
    1030             : }
    1031             : 
    1032         769 : void GetInputTabularTimeBins(EnergyPlusData &state)
    1033             : {
    1034             :     // SUBROUTINE INFORMATION:
    1035             :     //       AUTHOR         Jason Glazer
    1036             :     //       DATE WRITTEN   July 2003
    1037             :     //       MODIFIED       na
    1038             :     //       RE-ENGINEERED  na
    1039             : 
    1040             :     // PURPOSE OF THIS SUBROUTINE:
    1041             :     //   This routine initializes the data structures based
    1042             :     //   on input from in the IDF file.  The data structures
    1043             :     //   follow the IDD closely.
    1044             : 
    1045             :     // METHODOLOGY EMPLOYED:
    1046             :     //   Uses get input structure similar to other objects
    1047             : 
    1048             :     // REFERENCES:
    1049             :     // na
    1050             : 
    1051             :     // Using/Aliasing
    1052             :     using ScheduleManager::GetScheduleIndex;
    1053             : 
    1054             :     // Locals
    1055             :     // SUBROUTINE ARGUMENT DEFINITIONS:
    1056             :     // na
    1057             : 
    1058             :     // SUBROUTINE PARAMETER DEFINITIONS:
    1059         769 :     static std::string const CurrentModuleObject("Output:Table:TimeBins");
    1060             : 
    1061             :     // INTERFACE BLOCK SPECIFICATIONS:
    1062             :     // na
    1063             : 
    1064             :     // DERIVED TYPE DEFINITIONS:
    1065             :     // na
    1066             : 
    1067             :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
    1068             :     int iInObj;               // index when cycling through each idf input object
    1069             :     int NumParams;            // Number of elements combined
    1070             :     int NumAlphas;            // Number of elements in the alpha array
    1071             :     int NumNums;              // Number of elements in the numeric array
    1072        1481 :     Array1D_string AlphArray; // character string data
    1073        1481 :     Array1D<Real64> NumArray; // numeric data
    1074             :     int IOStat;               // IO Status when calling get input subroutine
    1075             :     int iTable;
    1076             :     int firstReport;
    1077             :     int repIndex;
    1078             :     int found;
    1079         769 :     Real64 constexpr bigVal(0.0); // used with HUGE: Value doesn't matter, only type: Initialize so compiler doesn't warn about use uninitialized
    1080             : 
    1081        1481 :     Array1D_string objNames;
    1082        1481 :     Array1D_int objVarIDs;
    1083         769 :     auto &ort(state.dataOutRptTab);
    1084             : 
    1085         769 :     if (!(state.files.outputControl.tabular || state.files.outputControl.sqlite)) {
    1086           1 :         ort->WriteTabularFiles = false;
    1087           1 :         return;
    1088             :     }
    1089             : 
    1090         768 :     state.dataInputProcessing->inputProcessor->getObjectDefMaxArgs(state, CurrentModuleObject, NumParams, NumAlphas, NumNums);
    1091         768 :     AlphArray.allocate(NumAlphas);
    1092         768 :     NumArray.dimension(NumNums, 0.0);
    1093             : 
    1094         768 :     ort->timeInYear = 0.0; // initialize the time in year counter
    1095             :     // determine size of array that holds the IDF description
    1096         768 :     ort->OutputTableBinnedCount = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, CurrentModuleObject);
    1097         768 :     ort->OutputTableBinned.allocate(ort->OutputTableBinnedCount);
    1098         768 :     if (ort->OutputTableBinnedCount > 0) {
    1099          56 :         ort->WriteTabularFiles = true;
    1100             :         // if not a run period using weather do not create reports
    1101          56 :         if (!state.dataGlobal->DoWeathSim) {
    1102         168 :             ShowWarningError(state,
    1103         112 :                              CurrentModuleObject + " requested with SimulationControl Run Simulation for Weather File Run Periods set to No so " +
    1104         112 :                                  CurrentModuleObject + " will not be generated");
    1105          56 :             return;
    1106             :         }
    1107             :     }
    1108             :     // looking for maximum number of intervals for sizing
    1109         712 :     ort->BinResultsIntervalCount = 0;
    1110         712 :     ort->BinResultsTableCount = 0;
    1111         712 :     for (iInObj = 1; iInObj <= ort->OutputTableBinnedCount; ++iInObj) {
    1112           0 :         state.dataInputProcessing->inputProcessor->getObjectItem(state,
    1113             :                                                                  CurrentModuleObject,
    1114             :                                                                  iInObj,
    1115             :                                                                  AlphArray,
    1116             :                                                                  NumAlphas,
    1117             :                                                                  NumArray,
    1118             :                                                                  NumNums,
    1119             :                                                                  IOStat,
    1120           0 :                                                                  state.dataIPShortCut->lNumericFieldBlanks,
    1121           0 :                                                                  state.dataIPShortCut->lAlphaFieldBlanks,
    1122           0 :                                                                  state.dataIPShortCut->cAlphaFieldNames,
    1123           0 :                                                                  state.dataIPShortCut->cNumericFieldNames);
    1124           0 :         ort->OutputTableBinned(iInObj).keyValue = AlphArray(1);
    1125           0 :         ort->OutputTableBinned(iInObj).varOrMeter = AlphArray(2);
    1126             :         // if a schedule has been specified assign
    1127           0 :         if (len(AlphArray(3)) > 0) {
    1128           0 :             ort->OutputTableBinned(iInObj).ScheduleName = AlphArray(3);
    1129           0 :             ort->OutputTableBinned(iInObj).scheduleIndex = GetScheduleIndex(state, AlphArray(3));
    1130           0 :             if (ort->OutputTableBinned(iInObj).scheduleIndex == 0) {
    1131           0 :                 ShowWarningError(
    1132           0 :                     state, CurrentModuleObject + ": invalid " + state.dataIPShortCut->cAlphaFieldNames(3) + "=\"" + AlphArray(3) + "\" - not found.");
    1133             :             }
    1134             :         } else {
    1135           0 :             ort->OutputTableBinned(iInObj).scheduleIndex = 0; // flag value for no schedule used
    1136             :         }
    1137             :         // validate the kind of variable - not used internally except for validation
    1138           0 :         if (len(AlphArray(4)) > 0) {
    1139           0 :             if (!(UtilityRoutines::SameString(AlphArray(4), "ENERGY") || UtilityRoutines::SameString(AlphArray(4), "DEMAND") ||
    1140           0 :                   UtilityRoutines::SameString(AlphArray(4), "TEMPERATURE") || UtilityRoutines::SameString(AlphArray(4), "FLOWRATE"))) {
    1141           0 :                 ShowWarningError(state,
    1142           0 :                                  "In " + CurrentModuleObject + " named " + AlphArray(1) +
    1143             :                                      " the Variable Type was not energy, demand, temperature, or flowrate.");
    1144             :             }
    1145             :         }
    1146           0 :         ort->OutputTableBinned(iInObj).intervalStart = NumArray(1);
    1147           0 :         ort->OutputTableBinned(iInObj).intervalSize = NumArray(2);
    1148           0 :         ort->OutputTableBinned(iInObj).intervalCount = int(NumArray(3));
    1149             :         // valid range checking on inputs
    1150           0 :         if (ort->OutputTableBinned(iInObj).intervalCount < 1) {
    1151           0 :             ort->OutputTableBinned(iInObj).intervalCount = 1;
    1152             :         }
    1153           0 :         if (ort->OutputTableBinned(iInObj).intervalCount > 20) {
    1154           0 :             ort->OutputTableBinned(iInObj).intervalCount = 20;
    1155             :         }
    1156           0 :         if (ort->OutputTableBinned(iInObj).intervalSize < 0) {
    1157           0 :             ort->OutputTableBinned(iInObj).intervalSize = 1000.0;
    1158             :         }
    1159           0 :         ort->OutputTableBinned(iInObj).resIndex = ort->BinResultsTableCount + 1; // the next results report
    1160             :         // find maximum number of intervals
    1161           0 :         if (ort->OutputTableBinned(iInObj).intervalCount > ort->BinResultsIntervalCount) {
    1162           0 :             ort->BinResultsIntervalCount = ort->OutputTableBinned(iInObj).intervalCount;
    1163             :         }
    1164           0 :         GetVariableKeyCountandType(state,
    1165           0 :                                    ort->OutputTableBinned(iInObj).varOrMeter,
    1166           0 :                                    ort->OutputTableBinned(iInObj).numTables,
    1167           0 :                                    ort->OutputTableBinned(iInObj).typeOfVar,
    1168           0 :                                    ort->OutputTableBinned(iInObj).avgSum,
    1169           0 :                                    ort->OutputTableBinned(iInObj).stepType,
    1170           0 :                                    ort->OutputTableBinned(iInObj).units);
    1171           0 :         if (ort->OutputTableBinned(iInObj).typeOfVar == OutputProcessor::VariableType::NotFound) {
    1172           0 :             ShowWarningError(state,
    1173           0 :                              CurrentModuleObject + ": User specified meter or variable not found: " + ort->OutputTableBinned(iInObj).varOrMeter);
    1174             :         }
    1175             :         // If only a single table key is requested than only one should be counted
    1176             :         // later will reset the numTables array pointer but for now use it to know
    1177             :         // how many items to scan through
    1178           0 :         if (ort->OutputTableBinned(iInObj).keyValue == "*") {
    1179           0 :             ort->BinResultsTableCount += ort->OutputTableBinned(iInObj).numTables;
    1180             :         } else {
    1181           0 :             ++ort->BinResultsTableCount; // if a particular key is requested then only one more report
    1182             :         }
    1183             :     }
    1184             :     // size the arrays that holds the bin results
    1185         712 :     ort->BinResults.allocate(ort->BinResultsIntervalCount, ort->BinResultsTableCount);
    1186         712 :     ort->BinResultsBelow.allocate(ort->BinResultsTableCount);
    1187         712 :     ort->BinResultsAbove.allocate(ort->BinResultsTableCount);
    1188         712 :     ort->BinStatistics.allocate(ort->BinResultsTableCount);
    1189         712 :     ort->BinObjVarID.allocate(ort->BinResultsTableCount);
    1190             :     // now that the arrays are sized go back and fill in
    1191             :     // what ID numbers are used for each table
    1192         712 :     for (iInObj = 1; iInObj <= ort->OutputTableBinnedCount; ++iInObj) {
    1193           0 :         firstReport = ort->OutputTableBinned(iInObj).resIndex;
    1194             :         // allocate the arrays to the number of objects
    1195           0 :         objNames.allocate(ort->OutputTableBinned(iInObj).numTables);
    1196           0 :         objVarIDs.allocate(ort->OutputTableBinned(iInObj).numTables);
    1197           0 :         GetVariableKeys(state, ort->OutputTableBinned(iInObj).varOrMeter, ort->OutputTableBinned(iInObj).typeOfVar, objNames, objVarIDs);
    1198           0 :         if (ort->OutputTableBinned(iInObj).keyValue == "*") {
    1199           0 :             for (iTable = 1; iTable <= ort->OutputTableBinned(iInObj).numTables; ++iTable) {
    1200           0 :                 repIndex = firstReport + (iTable - 1);
    1201           0 :                 ort->BinObjVarID(repIndex).namesOfObj = objNames(iTable);
    1202           0 :                 ort->BinObjVarID(repIndex).varMeterNum = objVarIDs(iTable);
    1203             :                 // check if valid meter or number
    1204           0 :                 if (objVarIDs(iTable) == 0) {
    1205           0 :                     ShowWarningError(state, CurrentModuleObject + ": Specified variable or meter not found: " + objNames(iTable));
    1206             :                 }
    1207             :             }
    1208             :         } else {
    1209             :             // scan through the keys and look for the user specified key
    1210           0 :             found = 0;
    1211           0 :             for (iTable = 1; iTable <= ort->OutputTableBinned(iInObj).numTables; ++iTable) {
    1212           0 :                 if (UtilityRoutines::SameString(objNames(iTable), ort->OutputTableBinned(iInObj).keyValue)) {
    1213           0 :                     found = iTable;
    1214           0 :                     break;
    1215             :                 }
    1216             :             }
    1217             :             // the first and only report is assigned to the found object name
    1218           0 :             if (!warningAboutKeyNotFound(state, found, iInObj, CurrentModuleObject)) {
    1219           0 :                 ort->BinObjVarID(firstReport).namesOfObj = objNames(found);
    1220           0 :                 ort->BinObjVarID(firstReport).varMeterNum = objVarIDs(found);
    1221             :             }
    1222             :             // reset the number of tables to one
    1223           0 :             ort->OutputTableBinned(iInObj).numTables = 1;
    1224             :         }
    1225             :     }
    1226             :     // clear the binning arrays to zeros
    1227         712 :     for (auto &e : ort->BinResults) {
    1228           0 :         e.mnth = 0.0;
    1229           0 :         e.hrly = 0.0;
    1230             :     }
    1231         712 :     for (auto &e : ort->BinResultsBelow) {
    1232           0 :         e.mnth = 0.0;
    1233           0 :         e.hrly = 0.0;
    1234             :     }
    1235         712 :     for (auto &e : ort->BinResultsAbove) {
    1236           0 :         e.mnth = 0.0;
    1237           0 :         e.hrly = 0.0;
    1238             :     }
    1239             : 
    1240             :     // initialize statistics counters
    1241         712 :     for (auto &e : ort->BinStatistics) {
    1242           0 :         e.minimum = HUGE_(bigVal);
    1243           0 :         e.maximum = -HUGE_(bigVal);
    1244           0 :         e.n = 0;
    1245           0 :         e.sum = 0.0;
    1246           0 :         e.sum2 = 0.0;
    1247             :     }
    1248             : }
    1249             : 
    1250           0 : bool warningAboutKeyNotFound(EnergyPlusData &state, int foundIndex, int inObjIndex, std::string const &moduleName)
    1251             : {
    1252           0 :     if (foundIndex == 0) {
    1253           0 :         ShowWarningError(state,
    1254           0 :                          moduleName + ": Specified key not found: " + state.dataOutRptTab->OutputTableBinned(inObjIndex).keyValue +
    1255           0 :                              " for variable: " + state.dataOutRptTab->OutputTableBinned(inObjIndex).varOrMeter);
    1256           0 :         return true;
    1257             :     } else {
    1258           0 :         return false;
    1259             :     }
    1260             : }
    1261             : 
    1262         769 : void GetInputTabularStyle(EnergyPlusData &state)
    1263             : {
    1264             :     // SUBROUTINE INFORMATION:
    1265             :     //       AUTHOR         Jason Glazer
    1266             :     //       DATE WRITTEN   July 2003
    1267             :     //       MODIFIED       na
    1268             :     //       RE-ENGINEERED  na
    1269             : 
    1270             :     // PURPOSE OF THIS SUBROUTINE:
    1271             :     //   This routine set a flag for the output format for
    1272             :     //   all tabular reports. This is a "unique" object.
    1273             : 
    1274             :     // METHODOLOGY EMPLOYED:
    1275             :     //   Uses get input structure similar to other objects
    1276             : 
    1277             :     // REFERENCES:
    1278             :     // na
    1279             : 
    1280             :     // Using/Aliasing
    1281             :     using DataStringGlobals::CharComma;
    1282             :     using DataStringGlobals::CharSpace;
    1283             :     using DataStringGlobals::CharTab;
    1284             : 
    1285             :     // Locals
    1286             :     // SUBROUTINE ARGUMENT DEFINITIONS:
    1287             :     // na
    1288             : 
    1289             :     // SUBROUTINE PARAMETER DEFINITIONS:
    1290         769 :     static std::string const CurrentModuleObject("OutputControl:Table:Style");
    1291             : 
    1292             :     // INTERFACE BLOCK SPECIFICATIONS:
    1293             :     // na
    1294             : 
    1295             :     // DERIVED TYPE DEFINITIONS:
    1296             :     // na
    1297             : 
    1298             :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
    1299             :     int NumTabularStyle;
    1300             :     int NumParams;            // Number of elements combined
    1301             :     int NumAlphas;            // Number of elements in the alpha array
    1302             :     int NumNums;              // Number of elements in the numeric array
    1303        1538 :     Array1D_string AlphArray; // character string data
    1304        1538 :     Array1D<Real64> NumArray; // numeric data
    1305             :     int IOStat;               // IO Status when calling get input subroutine
    1306         769 :     auto &ort(state.dataOutRptTab);
    1307             : 
    1308         769 :     state.dataInputProcessing->inputProcessor->getObjectDefMaxArgs(state, CurrentModuleObject, NumParams, NumAlphas, NumNums);
    1309         769 :     AlphArray.allocate(NumAlphas);
    1310         769 :     NumArray.dimension(NumNums, 0.0);
    1311             : 
    1312         769 :     NumTabularStyle = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, CurrentModuleObject);
    1313             : 
    1314         769 :     if (NumTabularStyle == 0) {
    1315          35 :         AlphArray(1) = "COMMA";
    1316          35 :         ort->numStyles = 1;
    1317          35 :         ort->TableStyle(1) = TableStyle::Comma;
    1318          35 :         ort->del(1) = CharComma; // comma
    1319          35 :         ort->unitsStyle = UnitsStyle::None;
    1320         734 :     } else if (NumTabularStyle == 1) {
    1321        3670 :         state.dataInputProcessing->inputProcessor->getObjectItem(state,
    1322             :                                                                  CurrentModuleObject,
    1323             :                                                                  1,
    1324             :                                                                  AlphArray,
    1325             :                                                                  NumAlphas,
    1326             :                                                                  NumArray,
    1327             :                                                                  NumNums,
    1328             :                                                                  IOStat,
    1329         734 :                                                                  state.dataIPShortCut->lNumericFieldBlanks,
    1330         734 :                                                                  state.dataIPShortCut->lAlphaFieldBlanks,
    1331         734 :                                                                  state.dataIPShortCut->cAlphaFieldNames,
    1332         734 :                                                                  state.dataIPShortCut->cNumericFieldNames);
    1333             :         // ColumnSeparator
    1334         734 :         if (UtilityRoutines::SameString(AlphArray(1), "Comma")) {
    1335           9 :             ort->numStyles = 1;
    1336           9 :             ort->TableStyle(1) = TableStyle::Comma;
    1337           9 :             ort->del(1) = CharComma; // comma
    1338         725 :         } else if (UtilityRoutines::SameString(AlphArray(1), "Tab")) {
    1339           1 :             ort->numStyles = 1;
    1340           1 :             ort->TableStyle(1) = TableStyle::Tab;
    1341           1 :             ort->del(1) = CharTab; // tab
    1342         724 :         } else if (UtilityRoutines::SameString(AlphArray(1), "Fixed")) {
    1343           1 :             ort->numStyles = 1;
    1344           1 :             ort->TableStyle(1) = TableStyle::Fixed;
    1345           1 :             ort->del(1) = CharSpace; // space
    1346         723 :         } else if (UtilityRoutines::SameString(AlphArray(1), "HTML")) {
    1347         674 :             ort->numStyles = 1;
    1348         674 :             ort->TableStyle(1) = TableStyle::HTML;
    1349         674 :             ort->del(1) = CharSpace; // space - this is not used much for HTML output
    1350          49 :         } else if (UtilityRoutines::SameString(AlphArray(1), "XML")) {
    1351           0 :             ort->numStyles = 1;
    1352           0 :             ort->TableStyle(1) = TableStyle::XML;
    1353           0 :             ort->del(1) = CharSpace; // space - this is not used much for XML output
    1354          49 :         } else if (UtilityRoutines::SameString(AlphArray(1), "CommaAndHTML")) {
    1355          26 :             ort->numStyles = 2;
    1356          26 :             ort->TableStyle(1) = TableStyle::Comma;
    1357          26 :             ort->del(1) = CharComma; // comma
    1358          26 :             ort->TableStyle(2) = TableStyle::HTML;
    1359          26 :             ort->del(2) = CharSpace; // space - this is not used much for HTML output
    1360          23 :         } else if (UtilityRoutines::SameString(AlphArray(1), "CommaAndXML")) {
    1361           0 :             ort->numStyles = 2;
    1362           0 :             ort->TableStyle(1) = TableStyle::Comma;
    1363           0 :             ort->del(1) = CharComma; // comma
    1364           0 :             ort->TableStyle(2) = TableStyle::XML;
    1365           0 :             ort->del(2) = CharSpace; // space - this is not used much for XML output
    1366          23 :         } else if (UtilityRoutines::SameString(AlphArray(1), "TabAndHTML")) {
    1367           5 :             ort->numStyles = 2;
    1368           5 :             ort->TableStyle(1) = TableStyle::Tab;
    1369           5 :             ort->del(1) = CharTab; // tab
    1370           5 :             ort->TableStyle(2) = TableStyle::HTML;
    1371           5 :             ort->del(2) = CharSpace; // space - this is not used much for HTML output
    1372          18 :         } else if (UtilityRoutines::SameString(AlphArray(1), "XMLandHTML")) {
    1373           2 :             ort->numStyles = 2;
    1374           2 :             ort->TableStyle(1) = TableStyle::XML;
    1375           2 :             ort->del(1) = CharSpace; // space - this is not used much for XML output
    1376           2 :             ort->TableStyle(2) = TableStyle::HTML;
    1377           2 :             ort->del(2) = CharSpace; // space - this is not used much for HTML output
    1378          16 :         } else if (UtilityRoutines::SameString(AlphArray(1), "All")) {
    1379          16 :             ort->numStyles = 5;
    1380          16 :             ort->TableStyle(1) = TableStyle::Comma;
    1381          16 :             ort->del(1) = CharComma; // comma
    1382          16 :             ort->TableStyle(2) = TableStyle::Tab;
    1383          16 :             ort->del(2) = CharTab; // tab
    1384          16 :             ort->TableStyle(3) = TableStyle::Fixed;
    1385          16 :             ort->del(3) = CharSpace; // space
    1386          16 :             ort->TableStyle(4) = TableStyle::HTML;
    1387          16 :             ort->del(4) = CharSpace; // space - this is not used much for HTML output
    1388          16 :             ort->TableStyle(5) = TableStyle::XML;
    1389          16 :             ort->del(5) = CharSpace; // space - this is not used much for XML output
    1390             :         } else {
    1391           0 :             ShowWarningError(state,
    1392           0 :                              CurrentModuleObject + ": Invalid " + state.dataIPShortCut->cAlphaFieldNames(1) + "=\"" + AlphArray(1) +
    1393             :                                  "\". Commas will be used.");
    1394           0 :             ort->numStyles = 1;
    1395           0 :             ort->TableStyle(1) = TableStyle::Comma;
    1396           0 :             ort->del(1) = CharComma; // comma
    1397           0 :             AlphArray(1) = "COMMA";
    1398             :         }
    1399             :         // MonthlyUnitConversion
    1400         734 :         if (NumAlphas >= 2) {
    1401          17 :             ort->unitsStyle = SetUnitsStyleFromString(AlphArray(2));
    1402          17 :             if (ort->unitsStyle == UnitsStyle::NotFound) {
    1403           0 :                 ShowWarningError(state,
    1404           0 :                                  CurrentModuleObject + ": Invalid " + state.dataIPShortCut->cAlphaFieldNames(2) + "=\"" + AlphArray(2) +
    1405             :                                      "\". No unit conversion will be performed. Normal SI units will be shown.");
    1406             :             }
    1407             :         } else {
    1408         717 :             ort->unitsStyle = UnitsStyle::None;
    1409         717 :             AlphArray(2) = "None";
    1410             :         }
    1411           0 :     } else if (NumTabularStyle > 1) {
    1412           0 :         ShowWarningError(state, CurrentModuleObject + ": Only one instance of this object is allowed. Commas will be used.");
    1413           0 :         ort->TableStyle = TableStyle::Comma;
    1414           0 :         ort->del = std::string(1, CharComma); // comma
    1415           0 :         AlphArray(1) = "COMMA";
    1416           0 :         ort->unitsStyle = UnitsStyle::None;
    1417           0 :         AlphArray(2) = "None";
    1418             :     }
    1419             : 
    1420         769 :     if (ort->WriteTabularFiles) {
    1421         141 :         print(state.files.eio, "! <Tabular Report>,Style,Unit Conversion\n");
    1422         141 :         if (AlphArray(1) != "HTML") {
    1423          28 :             ConvertCaseToLower(AlphArray(1), AlphArray(2));
    1424          28 :             AlphArray(1).erase(1);
    1425          28 :             AlphArray(1) += AlphArray(2).substr(1);
    1426             :         }
    1427         141 :         print(state.files.eio, "Tabular Report,{},{}\n", AlphArray(1), AlphArray(2));
    1428             :     }
    1429         769 : }
    1430             : 
    1431          17 : UnitsStyle SetUnitsStyleFromString(std::string const &unitStringIn)
    1432             : {
    1433             :     UnitsStyle unitsStyleReturn;
    1434          17 :     if (UtilityRoutines::SameString(unitStringIn, "None")) {
    1435           1 :         unitsStyleReturn = UnitsStyle::None;
    1436          16 :     } else if (UtilityRoutines::SameString(unitStringIn, "JTOKWH")) {
    1437           5 :         unitsStyleReturn = UnitsStyle::JtoKWH;
    1438          11 :     } else if (UtilityRoutines::SameString(unitStringIn, "JTOMJ")) {
    1439           0 :         unitsStyleReturn = UnitsStyle::JtoMJ;
    1440          11 :     } else if (UtilityRoutines::SameString(unitStringIn, "JTOGJ")) {
    1441           0 :         unitsStyleReturn = UnitsStyle::JtoGJ;
    1442          11 :     } else if (UtilityRoutines::SameString(unitStringIn, "INCHPOUND")) {
    1443          11 :         unitsStyleReturn = UnitsStyle::InchPound;
    1444             :     } else {
    1445           0 :         unitsStyleReturn = UnitsStyle::NotFound;
    1446             :     }
    1447          17 :     return unitsStyleReturn;
    1448             : }
    1449             : 
    1450         769 : void GetInputOutputTableSummaryReports(EnergyPlusData &state)
    1451             : {
    1452             :     // SUBROUTINE INFORMATION:
    1453             :     //       AUTHOR         Jason Glazer
    1454             :     //       DATE WRITTEN   November 2003
    1455             :     //       MODIFIED       na
    1456             :     //       RE-ENGINEERED  na
    1457             : 
    1458             :     // PURPOSE OF THIS SUBROUTINE:
    1459             :     //   This routine flags if any of the predefined reports
    1460             :     //   are requested by the user
    1461             : 
    1462             :     // METHODOLOGY EMPLOYED:
    1463             :     //   Uses get input structure similar to other objects
    1464             : 
    1465             :     // REFERENCES:
    1466             :     // na
    1467             : 
    1468             :     // Using/Aliasing
    1469             :     using DataStringGlobals::CharComma;
    1470             :     using DataStringGlobals::CharSpace;
    1471             :     using DataStringGlobals::CharTab;
    1472             : 
    1473             :     // SUBROUTINE PARAMETER DEFINITIONS:
    1474         769 :     static std::string const CurrentModuleObject("Output:Table:SummaryReports");
    1475             : 
    1476             :     // INTERFACE BLOCK SPECIFICATIONS:
    1477             :     // na
    1478             : 
    1479             :     // DERIVED TYPE DEFINITIONS:
    1480             : 
    1481             :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
    1482             : 
    1483             :     int NumTabularPredefined;
    1484             :     int NumParams;
    1485             :     int NumAlphas; // Number of elements in the alpha array
    1486             :     int NumNums;   // Number of elements in the numeric array
    1487        1537 :     Array1D_string AlphArray;
    1488        1537 :     Array1D<Real64> NumArray;
    1489             :     int IOStat; // IO Status when calling get input subroutine
    1490             :     int iReport;
    1491        1537 :     std::string meterName;
    1492             :     int meterNumber;
    1493             :     int iResource;
    1494             :     int kEndUseSub;
    1495             :     int jReport;
    1496             :     bool nameFound;
    1497             :     bool ErrorsFound;
    1498         769 :     auto &ort(state.dataOutRptTab);
    1499             : 
    1500         769 :     if (!(state.files.outputControl.tabular || state.files.outputControl.sqlite)) {
    1501           1 :         ort->WriteTabularFiles = false;
    1502           1 :         return;
    1503             :     }
    1504             : 
    1505         768 :     ErrorsFound = false;
    1506         768 :     NumTabularPredefined = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, CurrentModuleObject);
    1507         768 :     if (NumTabularPredefined == 1) {
    1508             :         // find out how many fields since the object is extensible
    1509         730 :         state.dataInputProcessing->inputProcessor->getObjectDefMaxArgs(state, CurrentModuleObject, NumParams, NumAlphas, NumNums);
    1510             :         // allocate the temporary arrays for the call to get the filed
    1511         730 :         AlphArray.allocate(NumAlphas);
    1512             :         // don't really need the NumArray since not expecting any numbers but the call requires it
    1513         730 :         NumArray.dimension(NumNums, 0.0);
    1514             :         // get the object
    1515         730 :         state.dataInputProcessing->inputProcessor->getObjectItem(state, CurrentModuleObject, 1, AlphArray, NumAlphas, NumArray, NumNums, IOStat);
    1516             :         // default all report flags to false (do not get produced)
    1517         730 :         ort->displayTabularBEPS = false;
    1518             :         // initialize the names of the predefined monthly report titles
    1519         730 :         InitializePredefinedMonthlyTitles(state);
    1520             :         // loop through the fields looking for matching report titles
    1521        1973 :         for (iReport = 1; iReport <= NumAlphas; ++iReport) {
    1522        1243 :             nameFound = false;
    1523        1243 :             if (AlphArray(iReport).empty()) {
    1524           0 :                 ShowFatalError(state, "Blank report name in Output:Table:SummaryReports");
    1525        1243 :             } else if (UtilityRoutines::SameString(AlphArray(iReport), "AnnualBuildingUtilityPerformanceSummary")) {
    1526          77 :                 ort->displayTabularBEPS = true;
    1527          77 :                 ort->WriteTabularFiles = true;
    1528          77 :                 nameFound = true;
    1529        1166 :             } else if (UtilityRoutines::SameString(AlphArray(iReport), "ComponentCostEconomicsSummary")) {
    1530           9 :                 ort->displayTabularCompCosts = true;
    1531           9 :                 ort->WriteTabularFiles = true;
    1532           9 :                 nameFound = true;
    1533        1157 :             } else if (UtilityRoutines::SameString(AlphArray(iReport), "InputVerificationandResultsSummary")) {
    1534          70 :                 ort->displayTabularVeriSum = true;
    1535          70 :                 ort->WriteTabularFiles = true;
    1536          70 :                 nameFound = true;
    1537        1087 :             } else if (UtilityRoutines::SameString(AlphArray(iReport), "ComponentSizingSummary")) {
    1538          58 :                 ort->displayComponentSizing = true;
    1539          58 :                 ort->WriteTabularFiles = true;
    1540          58 :                 nameFound = true;
    1541        1029 :             } else if (UtilityRoutines::SameString(AlphArray(iReport), "SurfaceShadowingSummary")) {
    1542           0 :                 ort->displaySurfaceShadowing = true;
    1543           0 :                 ort->WriteTabularFiles = true;
    1544           0 :                 nameFound = true;
    1545        1029 :             } else if (UtilityRoutines::SameString(AlphArray(iReport), "DemandEndUseComponentsSummary")) {
    1546           3 :                 ort->displayDemandEndUse = true;
    1547           3 :                 ort->WriteTabularFiles = true;
    1548           3 :                 nameFound = true;
    1549        1026 :             } else if (UtilityRoutines::SameString(AlphArray(iReport), "AdaptiveComfortSummary")) {
    1550           0 :                 ort->displayAdaptiveComfort = true;
    1551           0 :                 ort->WriteTabularFiles = true;
    1552           0 :                 nameFound = true;
    1553        1026 :             } else if (UtilityRoutines::SameString(AlphArray(iReport), "SourceEnergyEndUseComponentsSummary")) {
    1554           0 :                 ort->displaySourceEnergyEndUseSummary = true;
    1555           0 :                 ort->WriteTabularFiles = true;
    1556           0 :                 nameFound = true;
    1557        1026 :             } else if (UtilityRoutines::SameString(AlphArray(iReport), "ZoneComponentLoadSummary")) {
    1558          22 :                 ort->displayZoneComponentLoadSummary = true;
    1559          22 :                 ort->WriteTabularFiles = true;
    1560          22 :                 nameFound = true;
    1561        1004 :             } else if (UtilityRoutines::SameString(AlphArray(iReport), "AirLoopComponentLoadSummary")) {
    1562           0 :                 ort->displayAirLoopComponentLoadSummary = true;
    1563           0 :                 ort->WriteTabularFiles = true;
    1564           0 :                 nameFound = true;
    1565        1004 :             } else if (UtilityRoutines::SameString(AlphArray(iReport), "FacilityComponentLoadSummary")) {
    1566           0 :                 ort->displayFacilityComponentLoadSummary = true;
    1567           0 :                 ort->WriteTabularFiles = true;
    1568           0 :                 nameFound = true;
    1569        1004 :             } else if (UtilityRoutines::SameString(AlphArray(iReport), "LEEDSummary")) {
    1570           0 :                 ort->displayLEEDSummary = true;
    1571           0 :                 ort->WriteTabularFiles = true;
    1572           0 :                 nameFound = true;
    1573        1004 :             } else if (UtilityRoutines::SameString(AlphArray(iReport), "LifeCycleCostReport")) {
    1574           0 :                 ort->displayLifeCycleCostReport = true;
    1575           0 :                 ort->WriteTabularFiles = true;
    1576           0 :                 nameFound = true;
    1577        1004 :             } else if (UtilityRoutines::SameString(AlphArray(iReport), "TariffReport")) {
    1578           0 :                 ort->displayTariffReport = true;
    1579           0 :                 ort->WriteTabularFiles = true;
    1580           0 :                 nameFound = true;
    1581        1004 :             } else if (UtilityRoutines::SameString(AlphArray(iReport), "EconomicResultSummary")) {
    1582           0 :                 ort->displayEconomicResultSummary = true;
    1583           0 :                 ort->WriteTabularFiles = true;
    1584           0 :                 nameFound = true;
    1585        1004 :             } else if (UtilityRoutines::SameString(AlphArray(iReport), "HeatEmissionsSummary")) {
    1586           1 :                 ort->displayHeatEmissionsSummary = true;
    1587           1 :                 ort->WriteTabularFiles = true;
    1588           1 :                 nameFound = true;
    1589        1003 :             } else if (UtilityRoutines::SameString(AlphArray(iReport), "ThermalResilienceSummary")) {
    1590           3 :                 ort->displayThermalResilienceSummary = true;
    1591           3 :                 ort->displayThermalResilienceSummaryExplicitly = true;
    1592           3 :                 ort->WriteTabularFiles = true;
    1593           3 :                 nameFound = true;
    1594        1000 :             } else if (UtilityRoutines::SameString(AlphArray(iReport), "CO2ResilienceSummary")) {
    1595           3 :                 ort->displayCO2ResilienceSummary = true;
    1596           3 :                 ort->displayCO2ResilienceSummaryExplicitly = true;
    1597           3 :                 ort->WriteTabularFiles = true;
    1598           3 :                 nameFound = true;
    1599         997 :             } else if (UtilityRoutines::SameString(AlphArray(iReport), "VisualResilienceSummary")) {
    1600           3 :                 ort->displayVisualResilienceSummary = true;
    1601           3 :                 ort->displayVisualResilienceSummaryExplicitly = true;
    1602           3 :                 ort->WriteTabularFiles = true;
    1603           3 :                 nameFound = true;
    1604         994 :             } else if (UtilityRoutines::SameString(AlphArray(iReport), "EnergyMeters")) {
    1605           0 :                 ort->WriteTabularFiles = true;
    1606           0 :                 nameFound = true;
    1607         994 :             } else if (UtilityRoutines::SameString(AlphArray(iReport), "InitializationSummary")) {
    1608           1 :                 ort->WriteTabularFiles = true;
    1609           1 :                 ort->displayEioSummary = true;
    1610           1 :                 nameFound = true;
    1611         993 :             } else if (UtilityRoutines::SameString(AlphArray(iReport), "AllSummary")) {
    1612         629 :                 ort->WriteTabularFiles = true;
    1613         629 :                 ort->displayTabularBEPS = true;
    1614         629 :                 ort->displayTabularVeriSum = true;
    1615         629 :                 ort->displayTabularCompCosts = true;
    1616         629 :                 ort->displaySurfaceShadowing = true;
    1617         629 :                 ort->displayComponentSizing = true;
    1618         629 :                 ort->displayDemandEndUse = true;
    1619         629 :                 ort->displayAdaptiveComfort = true;
    1620         629 :                 ort->displaySourceEnergyEndUseSummary = true;
    1621         629 :                 ort->displayLifeCycleCostReport = true;
    1622         629 :                 ort->displayTariffReport = true;
    1623         629 :                 ort->displayEconomicResultSummary = true;
    1624         629 :                 ort->displayEioSummary = true;
    1625         629 :                 ort->displayLEEDSummary = true;
    1626         629 :                 ort->displayHeatEmissionsSummary = true;
    1627         629 :                 ort->displayThermalResilienceSummary = true;
    1628         629 :                 ort->displayCO2ResilienceSummary = true;
    1629         629 :                 ort->displayVisualResilienceSummary = true;
    1630         629 :                 nameFound = true;
    1631       11000 :                 for (jReport = 1; jReport <= state.dataOutRptPredefined->numReportName; ++jReport) {
    1632       10371 :                     state.dataOutRptPredefined->reportName(jReport).show = true;
    1633             :                 }
    1634         364 :             } else if (UtilityRoutines::SameString(AlphArray(iReport), "AllSummaryAndSizingPeriod")) {
    1635           1 :                 ort->WriteTabularFiles = true;
    1636           1 :                 ort->displayTabularBEPS = true;
    1637           1 :                 ort->displayTabularVeriSum = true;
    1638           1 :                 ort->displayTabularCompCosts = true;
    1639           1 :                 ort->displaySurfaceShadowing = true;
    1640           1 :                 ort->displayComponentSizing = true;
    1641           1 :                 ort->displayDemandEndUse = true;
    1642           1 :                 ort->displayAdaptiveComfort = true;
    1643           1 :                 ort->displaySourceEnergyEndUseSummary = true;
    1644           1 :                 ort->displayLifeCycleCostReport = true;
    1645           1 :                 ort->displayTariffReport = true;
    1646           1 :                 ort->displayEconomicResultSummary = true;
    1647           1 :                 ort->displayEioSummary = true;
    1648           1 :                 ort->displayLEEDSummary = true;
    1649           1 :                 ort->displayHeatEmissionsSummary = true;
    1650           1 :                 ort->displayThermalResilienceSummary = true;
    1651           1 :                 ort->displayCO2ResilienceSummary = true;
    1652           1 :                 ort->displayVisualResilienceSummary = true;
    1653           1 :                 nameFound = true;
    1654          18 :                 for (jReport = 1; jReport <= state.dataOutRptPredefined->numReportName; ++jReport) {
    1655          17 :                     state.dataOutRptPredefined->reportName(jReport).show = true;
    1656             :                 }
    1657             :                 // the sizing period reports
    1658           1 :                 ort->displayZoneComponentLoadSummary = true;
    1659           1 :                 ort->displayAirLoopComponentLoadSummary = true;
    1660           1 :                 ort->displayFacilityComponentLoadSummary = true;
    1661         363 :             } else if (UtilityRoutines::SameString(AlphArray(iReport), "AllMonthly")) {
    1662           1 :                 ort->WriteTabularFiles = true;
    1663          64 :                 for (jReport = 1; jReport <= numNamedMonthly; ++jReport) {
    1664          63 :                     ort->namedMonthly(jReport).show = true;
    1665             :                 }
    1666           1 :                 nameFound = true;
    1667         362 :             } else if (UtilityRoutines::SameString(AlphArray(iReport), "AllSummaryAndMonthly")) {
    1668          23 :                 ort->WriteTabularFiles = true;
    1669          23 :                 ort->displayTabularBEPS = true;
    1670          23 :                 ort->displayTabularVeriSum = true;
    1671          23 :                 ort->displayTabularCompCosts = true;
    1672          23 :                 ort->displaySurfaceShadowing = true;
    1673          23 :                 ort->displayComponentSizing = true;
    1674          23 :                 ort->displayDemandEndUse = true;
    1675          23 :                 ort->displayAdaptiveComfort = true;
    1676          23 :                 ort->displaySourceEnergyEndUseSummary = true;
    1677          23 :                 ort->displayLifeCycleCostReport = true;
    1678          23 :                 ort->displayTariffReport = true;
    1679          23 :                 ort->displayEconomicResultSummary = true;
    1680          23 :                 ort->displayEioSummary = true;
    1681          23 :                 ort->displayLEEDSummary = true;
    1682          23 :                 ort->displayHeatEmissionsSummary = true;
    1683          23 :                 ort->displayThermalResilienceSummary = true;
    1684          23 :                 ort->displayCO2ResilienceSummary = true;
    1685          23 :                 ort->displayVisualResilienceSummary = true;
    1686          23 :                 nameFound = true;
    1687         412 :                 for (jReport = 1; jReport <= state.dataOutRptPredefined->numReportName; ++jReport) {
    1688         389 :                     state.dataOutRptPredefined->reportName(jReport).show = true;
    1689             :                 }
    1690        1472 :                 for (jReport = 1; jReport <= numNamedMonthly; ++jReport) {
    1691        1449 :                     ort->namedMonthly(jReport).show = true;
    1692             :                 }
    1693         339 :             } else if (UtilityRoutines::SameString(AlphArray(iReport), "AllSummaryMonthlyAndSizingPeriod")) {
    1694           0 :                 ort->WriteTabularFiles = true;
    1695           0 :                 ort->displayTabularBEPS = true;
    1696           0 :                 ort->displayTabularVeriSum = true;
    1697           0 :                 ort->displayTabularCompCosts = true;
    1698           0 :                 ort->displaySurfaceShadowing = true;
    1699           0 :                 ort->displayComponentSizing = true;
    1700           0 :                 ort->displayDemandEndUse = true;
    1701           0 :                 ort->displayAdaptiveComfort = true;
    1702           0 :                 ort->displaySourceEnergyEndUseSummary = true;
    1703           0 :                 ort->displayLifeCycleCostReport = true;
    1704           0 :                 ort->displayTariffReport = true;
    1705           0 :                 ort->displayEconomicResultSummary = true;
    1706           0 :                 ort->displayEioSummary = true;
    1707           0 :                 ort->displayLEEDSummary = true;
    1708           0 :                 ort->displayHeatEmissionsSummary = true;
    1709           0 :                 ort->displayThermalResilienceSummary = true;
    1710           0 :                 ort->displayCO2ResilienceSummary = true;
    1711           0 :                 ort->displayVisualResilienceSummary = true;
    1712           0 :                 nameFound = true;
    1713           0 :                 for (jReport = 1; jReport <= state.dataOutRptPredefined->numReportName; ++jReport) {
    1714           0 :                     state.dataOutRptPredefined->reportName(jReport).show = true;
    1715             :                 }
    1716           0 :                 for (jReport = 1; jReport <= numNamedMonthly; ++jReport) {
    1717           0 :                     ort->namedMonthly(jReport).show = true;
    1718             :                 }
    1719             :                 // the sizing period reports
    1720           0 :                 ort->displayZoneComponentLoadSummary = true;
    1721           0 :                 ort->displayAirLoopComponentLoadSummary = true;
    1722           0 :                 ort->displayFacilityComponentLoadSummary = true;
    1723             :             }
    1724             :             // check the reports that are predefined and are created by OutputReportPredefined
    1725       22027 :             for (jReport = 1; jReport <= state.dataOutRptPredefined->numReportName; ++jReport) {
    1726       20784 :                 if (UtilityRoutines::SameString(AlphArray(iReport), state.dataOutRptPredefined->reportName(jReport).name)) {
    1727         344 :                     ort->WriteTabularFiles = true;
    1728         344 :                     state.dataOutRptPredefined->reportName(jReport).show = true;
    1729         344 :                     nameFound = true;
    1730             :                 }
    1731       20784 :                 if (UtilityRoutines::SameString(AlphArray(iReport), state.dataOutRptPredefined->reportName(jReport).abrev)) {
    1732           0 :                     ort->WriteTabularFiles = true;
    1733           0 :                     state.dataOutRptPredefined->reportName(jReport).show = true;
    1734           0 :                     nameFound = true;
    1735             :                 }
    1736             :             }
    1737             :             // check if the predefined monthly reports are used
    1738       79552 :             for (jReport = 1; jReport <= numNamedMonthly; ++jReport) {
    1739       78309 :                 if (UtilityRoutines::SameString(AlphArray(iReport), ort->namedMonthly(jReport).title)) {
    1740           1 :                     ort->namedMonthly(jReport).show = true;
    1741           1 :                     ort->WriteTabularFiles = true;
    1742           1 :                     nameFound = true;
    1743             :                 }
    1744             :             }
    1745        1243 :             if (!nameFound) {
    1746           0 :                 if (UtilityRoutines::SameString(AlphArray(iReport), "Standard62.1Summary")) {
    1747           0 :                     ShowWarningError(state, format("{} Field[{}]=\"Standard62.1Summary\", Report is not enabled.", CurrentModuleObject, iReport));
    1748           0 :                     ShowContinueError(state, "Do Zone Sizing or Do System Sizing must be enabled in SimulationControl.");
    1749             : 
    1750             :                 } else {
    1751           0 :                     ShowSevereError(
    1752             :                         state,
    1753           0 :                         format(
    1754           0 :                             "{} Field[{}]=\"{}\", invalid report name -- will not be reported.", CurrentModuleObject, iReport, AlphArray(iReport)));
    1755             :                     //      ErrorsFound=.TRUE.
    1756             :                 }
    1757             :             }
    1758             :         }
    1759         730 :         CreatePredefinedMonthlyReports(state);
    1760          38 :     } else if (NumTabularPredefined > 1) {
    1761           0 :         ShowSevereError(state, CurrentModuleObject + ": Only one instance of this object is allowed.");
    1762           0 :         ErrorsFound = true;
    1763             :     }
    1764         768 :     if (ErrorsFound) {
    1765           0 :         ShowFatalError(state, CurrentModuleObject + ": Preceding errors cause termination.");
    1766             :     }
    1767             :     // if the BEPS report has been called for than initialize its arrays
    1768         768 :     if (ort->displayTabularBEPS || ort->displayDemandEndUse || ort->displaySourceEnergyEndUseSummary || ort->displayLEEDSummary) {
    1769             :         // initialize the resource type names
    1770         730 :         ort->resourceTypeNames(1) = "Electricity";
    1771         730 :         ort->resourceTypeNames(2) = "NaturalGas";
    1772         730 :         ort->resourceTypeNames(3) = "DistrictCooling";
    1773         730 :         ort->resourceTypeNames(4) = "DistrictHeating";
    1774         730 :         ort->resourceTypeNames(5) = "Steam";
    1775         730 :         ort->resourceTypeNames(6) = "Gasoline";
    1776         730 :         ort->resourceTypeNames(7) = "Water";
    1777         730 :         ort->resourceTypeNames(8) = "Diesel";
    1778         730 :         ort->resourceTypeNames(9) = "Coal";
    1779         730 :         ort->resourceTypeNames(10) = "FuelOilNo1";
    1780         730 :         ort->resourceTypeNames(11) = "FuelOilNo2";
    1781         730 :         ort->resourceTypeNames(12) = "Propane";
    1782         730 :         ort->resourceTypeNames(13) = "OtherFuel1";
    1783         730 :         ort->resourceTypeNames(14) = "OtherFuel2";
    1784             : 
    1785         730 :         ort->sourceTypeNames(1) = "Electricity";
    1786         730 :         ort->sourceTypeNames(2) = "NaturalGas";
    1787         730 :         ort->sourceTypeNames(3) = "Gasoline";
    1788         730 :         ort->sourceTypeNames(4) = "Diesel";
    1789         730 :         ort->sourceTypeNames(5) = "Coal";
    1790         730 :         ort->sourceTypeNames(6) = "FuelOilNo1";
    1791         730 :         ort->sourceTypeNames(7) = "FuelOilNo2";
    1792         730 :         ort->sourceTypeNames(8) = "Propane";
    1793         730 :         ort->sourceTypeNames(9) = "PurchasedElectricity";
    1794         730 :         ort->sourceTypeNames(10) = "SoldElectricity";
    1795         730 :         ort->sourceTypeNames(11) = "OtherFuel1";
    1796         730 :         ort->sourceTypeNames(12) = "OtherFuel2";
    1797             : 
    1798             :         // initialize the end use names
    1799         730 :         ort->endUseNames(state.dataGlobalConst->iEndUse.at(DataGlobalConstants::EndUse::Heating)) = "Heating";
    1800         730 :         ort->endUseNames(state.dataGlobalConst->iEndUse.at(DataGlobalConstants::EndUse::Cooling)) = "Cooling";
    1801         730 :         ort->endUseNames(state.dataGlobalConst->iEndUse.at(DataGlobalConstants::EndUse::InteriorLights)) = "InteriorLights";
    1802         730 :         ort->endUseNames(state.dataGlobalConst->iEndUse.at(DataGlobalConstants::EndUse::ExteriorLights)) = "ExteriorLights";
    1803         730 :         ort->endUseNames(state.dataGlobalConst->iEndUse.at(DataGlobalConstants::EndUse::InteriorEquipment)) = "InteriorEquipment";
    1804         730 :         ort->endUseNames(state.dataGlobalConst->iEndUse.at(DataGlobalConstants::EndUse::ExteriorEquipment)) = "ExteriorEquipment";
    1805         730 :         ort->endUseNames(state.dataGlobalConst->iEndUse.at(DataGlobalConstants::EndUse::Fans)) = "Fans";
    1806         730 :         ort->endUseNames(state.dataGlobalConst->iEndUse.at(DataGlobalConstants::EndUse::Pumps)) = "Pumps";
    1807         730 :         ort->endUseNames(state.dataGlobalConst->iEndUse.at(DataGlobalConstants::EndUse::HeatRejection)) = "HeatRejection";
    1808         730 :         ort->endUseNames(state.dataGlobalConst->iEndUse.at(DataGlobalConstants::EndUse::Humidification)) = "Humidifier";
    1809         730 :         ort->endUseNames(state.dataGlobalConst->iEndUse.at(DataGlobalConstants::EndUse::HeatRecovery)) = "HeatRecovery";
    1810         730 :         ort->endUseNames(state.dataGlobalConst->iEndUse.at(DataGlobalConstants::EndUse::WaterSystem)) = "WaterSystems";
    1811         730 :         ort->endUseNames(state.dataGlobalConst->iEndUse.at(DataGlobalConstants::EndUse::Refrigeration)) = "Refrigeration";
    1812         730 :         ort->endUseNames(state.dataGlobalConst->iEndUse.at(DataGlobalConstants::EndUse::Cogeneration)) = "Cogeneration";
    1813             : 
    1814             :         // End use subs must be dynamically allocated to accomodate the end use with the most subcategories
    1815         730 :         ort->meterNumEndUseSubBEPS.allocate(state.dataOutputProcessor->MaxNumSubcategories, DataGlobalConstantsData::iEndUseSize, numResourceTypes);
    1816        1460 :         ort->meterNumEndUseSpTypeBEPS.allocate(
    1817        1460 :             state.dataOutputProcessor->maxNumEndUseSpaceTypes, DataGlobalConstantsData::iEndUseSize, numResourceTypes);
    1818       10950 :         for (int endUse = 1; endUse <= DataGlobalConstantsData::iEndUseSize; ++endUse) {
    1819      153300 :             for (int resType = 1; resType <= numResourceTypes; ++resType) {
    1820      412384 :                 for (int subCat = 1; subCat <= state.dataOutputProcessor->MaxNumSubcategories; ++subCat) {
    1821      269304 :                     ort->meterNumEndUseSubBEPS(subCat, endUse, resType) = 0;
    1822             :                 }
    1823      286944 :                 for (int spType = 1; spType <= state.dataOutputProcessor->maxNumEndUseSpaceTypes; ++spType) {
    1824      143864 :                     ort->meterNumEndUseSpTypeBEPS(spType, endUse, resType) = 0;
    1825             :                 }
    1826             :             }
    1827             :         }
    1828             : 
    1829             :         // loop through all of the resources and end uses and sub end uses for the entire facility
    1830       10950 :         for (iResource = 1; iResource <= numResourceTypes; ++iResource) {
    1831       10220 :             meterName = ort->resourceTypeNames(iResource) + ":FACILITY";
    1832       10220 :             meterNumber = GetMeterIndex(state, meterName);
    1833       10220 :             ort->meterNumTotalsBEPS(iResource) = meterNumber;
    1834             : 
    1835      153300 :             for (int jEndUse = 1; jEndUse <= DataGlobalConstantsData::iEndUseSize; ++jEndUse) {
    1836      143080 :                 meterName = ort->endUseNames(jEndUse) + ':' + ort->resourceTypeNames(iResource); //// ':FACILITY'
    1837      143080 :                 meterNumber = GetMeterIndex(state, meterName);
    1838      143080 :                 ort->meterNumEndUseBEPS(iResource, jEndUse) = meterNumber;
    1839             : 
    1840      227626 :                 for (kEndUseSub = 1; kEndUseSub <= state.dataOutputProcessor->EndUseCategory(jEndUse).NumSubcategories; ++kEndUseSub) {
    1841      253638 :                     meterName = state.dataOutputProcessor->EndUseCategory(jEndUse).SubcategoryName(kEndUseSub) + ':' + ort->endUseNames(jEndUse) +
    1842      253638 :                                 ':' + ort->resourceTypeNames(iResource);
    1843       84546 :                     meterNumber = GetMeterIndex(state, meterName);
    1844       84546 :                     ort->meterNumEndUseSubBEPS(kEndUseSub, jEndUse, iResource) = meterNumber;
    1845             :                 }
    1846      160678 :                 for (int kEndUseSpType = 1; kEndUseSpType <= state.dataOutputProcessor->EndUseCategory(jEndUse).numSpaceTypes; ++kEndUseSpType) {
    1847       52794 :                     meterName = ort->endUseNames(jEndUse) + ':' + ort->resourceTypeNames(iResource) +
    1848       52794 :                                 ":SpaceType:" + state.dataOutputProcessor->EndUseCategory(jEndUse).spaceTypeName(kEndUseSpType);
    1849       17598 :                     meterNumber = GetMeterIndex(state, meterName);
    1850       17598 :                     ort->meterNumEndUseSpTypeBEPS(kEndUseSpType, jEndUse, iResource) = meterNumber;
    1851             :                 }
    1852             :             }
    1853             :         }
    1854             : 
    1855        9490 :         for (iResource = 1; iResource <= numSourceTypes; ++iResource) {
    1856        8760 :             meterNumber = GetMeterIndex(state, ort->sourceTypeNames(iResource) + "Emissions:Source");
    1857        8760 :             ort->meterNumTotalsSource(iResource) = meterNumber;
    1858             :         }
    1859             : 
    1860             :         // initialize the gathering arrays to zero
    1861         730 :         ort->gatherTotalsBEPS = 0.0;
    1862         730 :         ort->gatherTotalsBySourceBEPS = 0.0;
    1863         730 :         ort->gatherTotalsSource = 0.0;
    1864         730 :         ort->gatherTotalsBySource = 0.0;
    1865         730 :         ort->gatherEndUseBEPS = 0.0;
    1866         730 :         ort->gatherEndUseBySourceBEPS = 0.0;
    1867             :         // End use subs must be dynamically allocated to accommodate the end use with the most subcategories
    1868         730 :         ort->gatherEndUseSubBEPS.allocate(state.dataOutputProcessor->MaxNumSubcategories, DataGlobalConstantsData::iEndUseSize, numResourceTypes);
    1869         730 :         ort->gatherEndUseSubBEPS = 0.0;
    1870        1460 :         ort->gatherEndUseSpTypeBEPS.allocate(
    1871        1460 :             state.dataOutputProcessor->maxNumEndUseSpaceTypes, DataGlobalConstantsData::iEndUseSize, numResourceTypes);
    1872         730 :         ort->gatherEndUseSpTypeBEPS = 0.0;
    1873         730 :         ort->gatherDemandEndUseSub.allocate(state.dataOutputProcessor->MaxNumSubcategories, DataGlobalConstantsData::iEndUseSize, numResourceTypes);
    1874         730 :         ort->gatherDemandEndUseSub = 0.0;
    1875        1460 :         ort->gatherDemandIndEndUseSub.allocate(
    1876        1460 :             state.dataOutputProcessor->MaxNumSubcategories, DataGlobalConstantsData::iEndUseSize, numResourceTypes);
    1877         730 :         ort->gatherDemandIndEndUseSub = 0.0;
    1878             : 
    1879             :         // get meter numbers for other meters relating to electric load components
    1880         730 :         ort->meterNumPowerFuelFireGen = GetMeterIndex(state, "Cogeneration:ElectricityProduced");
    1881         730 :         ort->meterNumPowerPV = GetMeterIndex(state, "Photovoltaic:ElectricityProduced");
    1882         730 :         ort->meterNumPowerWind = GetMeterIndex(state, "WindTurbine:ElectricityProduced");
    1883         730 :         ort->meterNumPowerHTGeothermal = GetMeterIndex(state, "HTGeothermal:ElectricityProduced");
    1884         730 :         ort->meterNumElecStorage = GetMeterIndex(state, "ElectricStorage:ElectricityProduced");
    1885         730 :         ort->meterNumPowerConversion = GetMeterIndex(state, "PowerConversion:ElectricityProduced");
    1886         730 :         ort->meterNumElecProduced = GetMeterIndex(state, "ElectricityProduced:Facility");
    1887         730 :         ort->meterNumElecPurchased = GetMeterIndex(state, "ElectricityPurchased:Facility");
    1888         730 :         ort->meterNumElecSurplusSold = GetMeterIndex(state, "ElectricitySurplusSold:Facility");
    1889             :         // if no ElectricityPurchased:Facility meter is defined then no electric load center
    1890             :         // was created by the user and no power generation will occur in the plant. The amount
    1891             :         // purchased would be the total end use.
    1892         730 :         if (ort->meterNumElecPurchased == 0) {
    1893          46 :             ort->meterNumElecPurchased = GetMeterIndex(state, "Electricity:Facility");
    1894             :         }
    1895             : 
    1896             :         // initialize the gathering variables for the electric load components
    1897         730 :         ort->gatherPowerFuelFireGen = 0.0;
    1898         730 :         ort->gatherPowerPV = 0.0;
    1899         730 :         ort->gatherPowerWind = 0.0;
    1900         730 :         ort->gatherPowerHTGeothermal = 0.0;
    1901         730 :         ort->gatherElecProduced = 0.0;
    1902         730 :         ort->gatherElecPurchased = 0.0;
    1903         730 :         ort->gatherElecSurplusSold = 0.0;
    1904         730 :         ort->gatherElecStorage = 0.0;
    1905         730 :         ort->gatherPowerConversion = 0.0;
    1906             : 
    1907             :         // get meter numbers for onsite thermal components on BEPS report
    1908         730 :         ort->meterNumWaterHeatRecovery = GetMeterIndex(state, "HeatRecovery:EnergyTransfer");
    1909         730 :         ort->meterNumAirHeatRecoveryCool = GetMeterIndex(state, "HeatRecoveryForCooling:EnergyTransfer");
    1910         730 :         ort->meterNumAirHeatRecoveryHeat = GetMeterIndex(state, "HeatRecoveryForHeating:EnergyTransfer");
    1911         730 :         ort->meterNumHeatHTGeothermal = GetMeterIndex(state, "HTGeothermal:HeatProduced");
    1912         730 :         ort->meterNumHeatSolarWater = GetMeterIndex(state, "SolarWater:Facility");
    1913         730 :         ort->meterNumHeatSolarAir = GetMeterIndex(state, "HeatProduced:SolarAir");
    1914             :         // initialize the gathering variables for onsite thermal components on BEPS report
    1915         730 :         ort->gatherWaterHeatRecovery = 0.0;
    1916         730 :         ort->gatherAirHeatRecoveryCool = 0.0;
    1917         730 :         ort->gatherAirHeatRecoveryHeat = 0.0;
    1918         730 :         ort->gatherHeatHTGeothermal = 0.0;
    1919         730 :         ort->gatherHeatSolarWater = 0.0;
    1920         730 :         ort->gatherHeatSolarAir = 0.0;
    1921             : 
    1922             :         // get meter numbers for water components on BEPS report
    1923         730 :         ort->meterNumRainWater = GetMeterIndex(state, "Rainwater:OnSiteWater");
    1924         730 :         ort->meterNumCondensate = GetMeterIndex(state, "Condensate:OnSiteWater");
    1925         730 :         ort->meterNumGroundwater = GetMeterIndex(state, "Wellwater:OnSiteWater");
    1926         730 :         ort->meterNumMains = GetMeterIndex(state, "MainsWater:Facility");
    1927         730 :         ort->meterNumWaterEndUseTotal = GetMeterIndex(state, "Water:Facility");
    1928             : 
    1929             :         // initialize the gathering variables for water components on BEPS report
    1930         730 :         ort->gatherRainWater = 0.0;
    1931         730 :         ort->gatherCondensate = 0.0;
    1932         730 :         ort->gatherWellwater = 0.0;
    1933         730 :         ort->gatherMains = 0.0;
    1934         730 :         ort->gatherWaterEndUseTotal = 0.0;
    1935             :     }
    1936             : }
    1937             : 
    1938         771 : bool isCompLoadRepReq(EnergyPlusData &state)
    1939             : {
    1940             :     // SUBROUTINE INFORMATION:
    1941             :     //       AUTHOR         Jason Glazer
    1942             :     //       DATE WRITTEN   November 2003
    1943             :     //       MODIFIED       na
    1944             :     //       RE-ENGINEERED  na
    1945             : 
    1946             :     // PURPOSE OF THIS SUBROUTINE:
    1947             :     //   Determine if the ZoneComponentLoadSummary or
    1948             :     //   ZoneComponentLoadDetail reports are requested.
    1949             : 
    1950             :     // METHODOLOGY EMPLOYED:
    1951             :     //   Uses get input structure similar to other objects
    1952             : 
    1953             :     // REFERENCES:
    1954             :     // na
    1955             : 
    1956             :     // USE STATEMENTS:
    1957             :     // na
    1958             : 
    1959             :     // Return value
    1960             :     bool isCompLoadRepReq;
    1961             : 
    1962             :     // Locals
    1963             :     // SUBROUTINE ARGUMENT DEFINITIONS:
    1964             :     // na
    1965             : 
    1966             :     // SUBROUTINE PARAMETER DEFINITIONS:
    1967         771 :     static std::string const CurrentModuleObject("Output:Table:SummaryReports");
    1968             : 
    1969             :     // INTERFACE BLOCK SPECIFICATIONS:
    1970             :     // na
    1971             : 
    1972             :     // DERIVED TYPE DEFINITIONS:
    1973             : 
    1974             :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
    1975             :     int NumTabularPredefined;
    1976             :     int NumParams;
    1977             :     int NumAlphas; // Number of elements in the alpha array
    1978             :     int NumNums;   // Number of elements in the numeric array
    1979        1542 :     Array1D_string AlphArray;
    1980        1542 :     Array1D<Real64> NumArray;
    1981             :     int IOStat; // IO Status when calling get input subroutine
    1982             :     int iReport;
    1983             :     bool isFound;
    1984             : 
    1985         771 :     isFound = false;
    1986         771 :     NumTabularPredefined = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, CurrentModuleObject);
    1987         771 :     if (NumTabularPredefined == 1) {
    1988             :         // find out how many fields since the object is extensible
    1989         733 :         state.dataInputProcessing->inputProcessor->getObjectDefMaxArgs(state, CurrentModuleObject, NumParams, NumAlphas, NumNums);
    1990             :         // allocate the temporary arrays for the call to get the filed
    1991         733 :         AlphArray.allocate(NumAlphas);
    1992             :         // don't really need the NumArray since not expecting any numbers but the call requires it
    1993         733 :         NumArray.dimension(NumNums, 0.0);
    1994             :         // get the object
    1995         733 :         state.dataInputProcessing->inputProcessor->getObjectItem(state, CurrentModuleObject, 1, AlphArray, NumAlphas, NumArray, NumNums, IOStat);
    1996             :         // loop through the fields looking for matching report titles
    1997        2000 :         for (iReport = 1; iReport <= NumAlphas; ++iReport) {
    1998        1267 :             if (UtilityRoutines::SameString(AlphArray(iReport), "ZoneComponentLoadSummary")) {
    1999          22 :                 isFound = true;
    2000             :             }
    2001        1267 :             if (UtilityRoutines::SameString(AlphArray(iReport), "AirLoopComponentLoadSummary")) {
    2002           0 :                 isFound = true;
    2003             :             }
    2004        1267 :             if (UtilityRoutines::SameString(AlphArray(iReport), "FacilityComponentLoadSummary")) {
    2005           0 :                 isFound = true;
    2006             :             }
    2007        1267 :             if (UtilityRoutines::SameString(AlphArray(iReport), "AllSummaryAndSizingPeriod")) {
    2008           1 :                 isFound = true;
    2009             :             }
    2010        1267 :             if (UtilityRoutines::SameString(AlphArray(iReport), "AllSummaryMonthlyAndSizingPeriod")) {
    2011           0 :                 isFound = true;
    2012             :             }
    2013             :         }
    2014             :     }
    2015         771 :     isCompLoadRepReq = isFound; // return true if either report was found
    2016        1542 :     return isCompLoadRepReq;
    2017             : }
    2018             : 
    2019         771 : bool hasSizingPeriodsDays(EnergyPlusData &state)
    2020             : {
    2021         771 :     int sizePerDesDays = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "SizingPeriod:DesignDay");
    2022         771 :     int sizePerWeathFileDays = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "SizingPeriod:WeatherFileDays");
    2023         771 :     return ((sizePerDesDays + sizePerWeathFileDays) > 0);
    2024             : }
    2025             : 
    2026         730 : void InitializePredefinedMonthlyTitles(EnergyPlusData &state)
    2027             : {
    2028             :     // SUBROUTINE INFORMATION:
    2029             :     //       AUTHOR         Jason Glazer
    2030             :     //       DATE WRITTEN   September 2008
    2031             :     //       MODIFIED       na
    2032             :     //       RE-ENGINEERED  na
    2033             : 
    2034             :     // PURPOSE OF THIS SUBROUTINE:
    2035             :     //   Initialize the NamedMonthly array for the titles
    2036             :     //   of the monthly predefined reports
    2037             : 
    2038             :     // METHODOLOGY EMPLOYED:
    2039             :     // REFERENCES:
    2040             :     // na
    2041             : 
    2042             :     // Using/Aliasing
    2043             :     using namespace DataOutputs;
    2044             : 
    2045             :     // Locals
    2046             :     // SUBROUTINE ARGUMENT DEFINITIONS:
    2047             :     // na
    2048             : 
    2049             :     // SUBROUTINE PARAMETER DEFINITIONS:
    2050             :     // na
    2051             : 
    2052             :     // INTERFACE BLOCK SPECIFICATIONS:
    2053             :     // na
    2054             : 
    2055             :     // DERIVED TYPE DEFINITIONS:
    2056             :     // na
    2057             : 
    2058             :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
    2059             :     int xcount;
    2060         730 :     auto &ort(state.dataOutRptTab);
    2061             : 
    2062         730 :     ort->namedMonthly.allocate(numNamedMonthly);
    2063         730 :     ort->namedMonthly(1).title = "ZoneCoolingSummaryMonthly";
    2064         730 :     ort->namedMonthly(2).title = "ZoneHeatingSummaryMonthly";
    2065         730 :     ort->namedMonthly(3).title = "ZoneElectricSummaryMonthly";
    2066         730 :     ort->namedMonthly(4).title = "SpaceGainsMonthly";
    2067         730 :     ort->namedMonthly(5).title = "PeakSpaceGainsMonthly";
    2068         730 :     ort->namedMonthly(6).title = "SpaceGainComponentsAtCoolingPeakMonthly";
    2069         730 :     ort->namedMonthly(7).title = "EnergyConsumptionElectricityNaturalGasMonthly";
    2070         730 :     ort->namedMonthly(8).title = "EnergyConsumptionElectricityGeneratedPropaneMonthly";
    2071         730 :     ort->namedMonthly(9).title = "EnergyConsumptionDieselFuelOilMonthly";
    2072         730 :     ort->namedMonthly(10).title = "EnergyConsumptionDistrictHeatingCoolingMonthly";
    2073         730 :     ort->namedMonthly(11).title = "EnergyConsumptionCoalGasolineMonthly";
    2074         730 :     ort->namedMonthly(12).title = "EnergyConsumptionOtherFuelsMonthly";
    2075         730 :     ort->namedMonthly(13).title = "EndUseEnergyConsumptionElectricityMonthly";
    2076         730 :     ort->namedMonthly(14).title = "EndUseEnergyConsumptionNaturalGasMonthly";
    2077         730 :     ort->namedMonthly(15).title = "EndUseEnergyConsumptionDieselMonthly";
    2078         730 :     ort->namedMonthly(16).title = "EndUseEnergyConsumptionFuelOilMonthly";
    2079         730 :     ort->namedMonthly(17).title = "EndUseEnergyConsumptionCoalMonthly";
    2080         730 :     ort->namedMonthly(18).title = "EndUseEnergyConsumptionPropaneMonthly";
    2081         730 :     ort->namedMonthly(19).title = "EndUseEnergyConsumptionGasolineMonthly";
    2082         730 :     ort->namedMonthly(20).title = "EndUseEnergyConsumptionOtherFuelsMonthly";
    2083         730 :     ort->namedMonthly(21).title = "PeakEnergyEndUseElectricityPart1Monthly";
    2084         730 :     ort->namedMonthly(22).title = "PeakEnergyEndUseElectricityPart2Monthly";
    2085         730 :     ort->namedMonthly(23).title = "ElectricComponentsOfPeakDemandMonthly";
    2086         730 :     ort->namedMonthly(24).title = "PeakEnergyEndUseNaturalGasMonthly";
    2087         730 :     ort->namedMonthly(25).title = "PeakEnergyEndUseDieselMonthly";
    2088         730 :     ort->namedMonthly(26).title = "PeakEnergyEndUseFuelOilMonthly";
    2089         730 :     ort->namedMonthly(27).title = "PeakEnergyEndUseCoalMonthly";
    2090         730 :     ort->namedMonthly(28).title = "PeakEnergyEndUsePropaneMonthly";
    2091         730 :     ort->namedMonthly(29).title = "PeakEnergyEndUseGasolineMonthly";
    2092         730 :     ort->namedMonthly(30).title = "PeakEnergyEndUseOtherFuelsMonthly";
    2093         730 :     ort->namedMonthly(31).title = "SetpointsNotMetWithTemperaturesMonthly";
    2094         730 :     ort->namedMonthly(32).title = "ComfortReportSimple55Monthly";
    2095         730 :     ort->namedMonthly(33).title = "UnglazedTranspiredSolarCollectorSummaryMonthly";
    2096         730 :     ort->namedMonthly(34).title = "OccupantComfortDataSummaryMonthly";
    2097         730 :     ort->namedMonthly(35).title = "ChillerReportMonthly";
    2098         730 :     ort->namedMonthly(36).title = "TowerReportMonthly";
    2099         730 :     ort->namedMonthly(37).title = "BoilerReportMonthly";
    2100         730 :     ort->namedMonthly(38).title = "DXReportMonthly";
    2101         730 :     ort->namedMonthly(39).title = "WindowReportMonthly";
    2102         730 :     ort->namedMonthly(40).title = "WindowEnergyReportMonthly";
    2103         730 :     ort->namedMonthly(41).title = "WindowZoneSummaryMonthly";
    2104         730 :     ort->namedMonthly(42).title = "WindowEnergyZoneSummaryMonthly";
    2105         730 :     ort->namedMonthly(43).title = "AverageOutdoorConditionsMonthly";
    2106         730 :     ort->namedMonthly(44).title = "OutdoorConditionsMaximumDryBulbMonthly";
    2107         730 :     ort->namedMonthly(45).title = "OutdoorConditionsMinimumDryBulbMonthly";
    2108         730 :     ort->namedMonthly(46).title = "OutdoorConditionsMaximumWetBulbMonthly";
    2109         730 :     ort->namedMonthly(47).title = "OutdoorConditionsMaximumDewPointMonthly";
    2110         730 :     ort->namedMonthly(48).title = "OutdoorGroundConditionsMonthly";
    2111         730 :     ort->namedMonthly(49).title = "WindowACReportMonthly";
    2112         730 :     ort->namedMonthly(50).title = "WaterHeaterReportMonthly";
    2113         730 :     ort->namedMonthly(51).title = "GeneratorReportMonthly";
    2114         730 :     ort->namedMonthly(52).title = "DaylightingReportMonthly";
    2115         730 :     ort->namedMonthly(53).title = "CoilReportMonthly";
    2116         730 :     ort->namedMonthly(54).title = "PlantLoopDemandReportMonthly";
    2117         730 :     ort->namedMonthly(55).title = "FanReportMonthly";
    2118         730 :     ort->namedMonthly(56).title = "PumpReportMonthly";
    2119         730 :     ort->namedMonthly(57).title = "CondLoopDemandReportMonthly";
    2120         730 :     ort->namedMonthly(58).title = "ZoneTemperatureOscillationReportMonthly";
    2121         730 :     ort->namedMonthly(59).title = "AirLoopSystemEnergyAndWaterUseMonthly";
    2122         730 :     ort->namedMonthly(60).title = "AirLoopSystemComponentLoadsMonthly";
    2123         730 :     ort->namedMonthly(61).title = "AirLoopSystemComponentEnergyUseMonthly";
    2124         730 :     ort->namedMonthly(62).title = "MechanicalVentilationLoadsMonthly";
    2125         730 :     ort->namedMonthly(63).title = "HeatEmissionsReportMonthly";
    2126             : 
    2127             :     if (numNamedMonthly != NumMonthlyReports) {
    2128             :         ShowFatalError(state,
    2129             :                        format("InitializePredefinedMonthlyTitles: Number of Monthly Reports in OutputReportTabular=[{}] does not match number in "
    2130             :                               "DataOutputs=[{}].",
    2131             :                               numNamedMonthly,
    2132             :                               NumMonthlyReports));
    2133             :     } else {
    2134       46720 :         for (xcount = 1; xcount <= numNamedMonthly; ++xcount) {
    2135       45990 :             if (!UtilityRoutines::SameString(MonthlyNamedReports(xcount), ort->namedMonthly(xcount).title)) {
    2136           0 :                 ShowSevereError(state,
    2137             :                                 "InitializePredefinedMonthlyTitles: Monthly Report Titles in OutputReportTabular do not match titles in DataOutput.");
    2138           0 :                 ShowContinueError(state, format("first mismatch at ORT [{}] =\"{}\".", numNamedMonthly, ort->namedMonthly(xcount).title));
    2139           0 :                 ShowContinueError(state, "same location in DO =\"" + MonthlyNamedReports(xcount) + "\".");
    2140           0 :                 ShowFatalError(state, "Preceding condition causes termination.");
    2141             :             }
    2142             :         }
    2143             :     }
    2144         730 : }
    2145             : 
    2146         730 : void CreatePredefinedMonthlyReports(EnergyPlusData &state)
    2147             : {
    2148             :     // SUBROUTINE INFORMATION:
    2149             :     //       AUTHOR         Jason Glazer
    2150             :     //       DATE WRITTEN   September 2008
    2151             :     //       MODIFIED       na
    2152             :     //       RE-ENGINEERED  na
    2153             : 
    2154             :     // PURPOSE OF THIS SUBROUTINE:
    2155             :     //   For any predefined monthly reports that have been
    2156             :     //   called out, define the individual columns.
    2157             : 
    2158             :     // METHODOLOGY EMPLOYED:
    2159             :     // REFERENCES:
    2160             :     // na
    2161             : 
    2162             :     // USE STATEMENTS:
    2163             : 
    2164             :     // Locals
    2165             :     // SUBROUTINE ARGUMENT DEFINITIONS:
    2166             :     // na
    2167             : 
    2168             :     // SUBROUTINE PARAMETER DEFINITIONS:
    2169             :     // na
    2170             : 
    2171             :     // INTERFACE BLOCK SPECIFICATIONS:
    2172             :     // na
    2173             : 
    2174             :     // DERIVED TYPE DEFINITIONS:
    2175             :     // na
    2176             : 
    2177             :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
    2178             :     int curReport;
    2179         730 :     auto &ort(state.dataOutRptTab);
    2180             : 
    2181             :     // ----------------------------------------------------------------------------------------
    2182             :     // If any variable are added to these reports they also need to be added to the
    2183             :     // AddVariablesForMonthlyReport routine in InputProcessor.
    2184             :     // ----------------------------------------------------------------------------------------
    2185             : 
    2186         730 :     if (ort->namedMonthly(1).show) {
    2187          24 :         curReport = AddMonthlyReport(state, "ZoneCoolingSummaryMonthly", 2);
    2188          24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Air System Sensible Cooling Energy", "", AggType::SumOrAvg);
    2189          24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Air System Sensible Cooling Rate", "", AggType::Maximum);
    2190          24 :         AddMonthlyFieldSetInput(state, curReport, "Site Outdoor Air Drybulb Temperature", "", AggType::ValueWhenMaxMin);
    2191          24 :         AddMonthlyFieldSetInput(state, curReport, "Site Outdoor Air Wetbulb Temperature", "", AggType::ValueWhenMaxMin);
    2192          24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Total Internal Latent Gain Energy", "", AggType::SumOrAvg);
    2193          24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Total Internal Latent Gain Rate", "", AggType::Maximum);
    2194          24 :         AddMonthlyFieldSetInput(state, curReport, "Site Outdoor Air Drybulb Temperature", "", AggType::ValueWhenMaxMin);
    2195          24 :         AddMonthlyFieldSetInput(state, curReport, "Site Outdoor Air Wetbulb Temperature", "", AggType::ValueWhenMaxMin);
    2196             :     }
    2197         730 :     if (ort->namedMonthly(2).show) {
    2198          24 :         curReport = AddMonthlyReport(state, "ZoneHeatingSummaryMonthly", 2);
    2199          24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Air System Sensible Heating Energy", "", AggType::SumOrAvg);
    2200          24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Air System Sensible Heating Rate", "", AggType::Maximum);
    2201          24 :         AddMonthlyFieldSetInput(state, curReport, "Site Outdoor Air Drybulb Temperature", "", AggType::ValueWhenMaxMin);
    2202             :     }
    2203         730 :     if (ort->namedMonthly(3).show) {
    2204          24 :         curReport = AddMonthlyReport(state, "ZoneElectricSummaryMonthly", 2);
    2205          24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Lights Electricity Energy", "", AggType::SumOrAvg);
    2206          24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Lights Electricity Energy", "", AggType::Maximum);
    2207          24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Electric Equipment Electricity Energy", "", AggType::SumOrAvg);
    2208          24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Electric Equipment Electricity Energy", "", AggType::Maximum);
    2209             :     }
    2210         730 :     if (ort->namedMonthly(4).show) {
    2211          24 :         curReport = AddMonthlyReport(state, "SpaceGainsMonthly", 2);
    2212          24 :         AddMonthlyFieldSetInput(state, curReport, "Zone People Total Heating Energy", "", AggType::SumOrAvg);
    2213          24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Lights Total Heating Energy", "", AggType::SumOrAvg);
    2214          24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Electric Equipment Total Heating Energy", "", AggType::SumOrAvg);
    2215          24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Gas Equipment Total Heating Energy", "", AggType::SumOrAvg);
    2216          24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Hot Water Equipment Total Heating Energy", "", AggType::SumOrAvg);
    2217          24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Steam Equipment Total Heating Energy", "", AggType::SumOrAvg);
    2218          24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Other Equipment Total Heating Energy", "", AggType::SumOrAvg);
    2219          24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Infiltration Sensible Heat Gain Energy", "", AggType::SumOrAvg);
    2220          24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Infiltration Sensible Heat Loss Energy", "", AggType::SumOrAvg);
    2221             :     }
    2222         730 :     if (ort->namedMonthly(5).show) {
    2223          24 :         curReport = AddMonthlyReport(state, "PeakSpaceGainsMonthly", 2);
    2224          24 :         AddMonthlyFieldSetInput(state, curReport, "Zone People Total Heating Energy", "", AggType::Maximum);
    2225          24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Lights Total Heating Energy", "", AggType::Maximum);
    2226          24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Electric Equipment Total Heating Energy", "", AggType::Maximum);
    2227          24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Gas Equipment Total Heating Energy", "", AggType::Maximum);
    2228          24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Hot Water Equipment Total Heating Energy", "", AggType::Maximum);
    2229          24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Steam Equipment Total Heating Energy", "", AggType::Maximum);
    2230          24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Other Equipment Total Heating Energy", "", AggType::Maximum);
    2231          24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Infiltration Sensible Heat Gain Energy", "", AggType::Maximum);
    2232          24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Infiltration Sensible Heat Loss Energy", "", AggType::Maximum);
    2233             :     }
    2234         730 :     if (ort->namedMonthly(6).show) {
    2235          24 :         curReport = AddMonthlyReport(state, "SpaceGainComponentsAtCoolingPeakMonthly", 2);
    2236          24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Air System Sensible Cooling Rate", "", AggType::Maximum);
    2237          24 :         AddMonthlyFieldSetInput(state, curReport, "Zone People Total Heating Energy", "", AggType::ValueWhenMaxMin);
    2238          24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Lights Total Heating Energy", "", AggType::ValueWhenMaxMin);
    2239          24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Electric Equipment Total Heating Energy", "", AggType::ValueWhenMaxMin);
    2240          24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Gas Equipment Total Heating Energy", "", AggType::ValueWhenMaxMin);
    2241          24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Hot Water Equipment Total Heating Energy", "", AggType::ValueWhenMaxMin);
    2242          24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Steam Equipment Total Heating Energy", "", AggType::ValueWhenMaxMin);
    2243          24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Other Equipment Total Heating Energy", "", AggType::ValueWhenMaxMin);
    2244          24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Infiltration Sensible Heat Gain Energy", "", AggType::ValueWhenMaxMin);
    2245          24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Infiltration Sensible Heat Loss Energy", "", AggType::ValueWhenMaxMin);
    2246             :     }
    2247         730 :     if (ort->namedMonthly(7).show) {
    2248          24 :         curReport = AddMonthlyReport(state, "EnergyConsumptionElectricityNaturalGasMonthly", 2);
    2249          24 :         AddMonthlyFieldSetInput(state, curReport, "Electricity:Facility", "", AggType::SumOrAvg);
    2250          24 :         AddMonthlyFieldSetInput(state, curReport, "Electricity:Facility", "", AggType::Maximum);
    2251          24 :         AddMonthlyFieldSetInput(state, curReport, "NaturalGas:Facility", "", AggType::SumOrAvg);
    2252          24 :         AddMonthlyFieldSetInput(state, curReport, "NaturalGas:Facility", "", AggType::Maximum);
    2253             :     }
    2254         730 :     if (ort->namedMonthly(8).show) {
    2255          24 :         curReport = AddMonthlyReport(state, "EnergyConsumptionElectricityGeneratedPropaneMonthly", 2);
    2256          24 :         AddMonthlyFieldSetInput(state, curReport, "ElectricityProduced:Facility", "", AggType::SumOrAvg);
    2257          24 :         AddMonthlyFieldSetInput(state, curReport, "ElectricityProduced:Facility", "", AggType::Maximum);
    2258          24 :         AddMonthlyFieldSetInput(state, curReport, "Propane:Facility", "", AggType::SumOrAvg);
    2259          24 :         AddMonthlyFieldSetInput(state, curReport, "Propane:Facility", "", AggType::Maximum);
    2260             :     }
    2261         730 :     if (ort->namedMonthly(9).show) {
    2262          24 :         curReport = AddMonthlyReport(state, "EnergyConsumptionDieselFuelOilMonthly", 2);
    2263          24 :         AddMonthlyFieldSetInput(state, curReport, "Diesel:Facility", "", AggType::SumOrAvg);
    2264          24 :         AddMonthlyFieldSetInput(state, curReport, "Diesel:Facility", "", AggType::Maximum);
    2265          24 :         AddMonthlyFieldSetInput(state, curReport, "FuelOilNo1:Facility", "", AggType::SumOrAvg);
    2266          24 :         AddMonthlyFieldSetInput(state, curReport, "FuelOilNo1:Facility", "", AggType::Maximum);
    2267          24 :         AddMonthlyFieldSetInput(state, curReport, "FuelOilNo2:Facility", "", AggType::SumOrAvg);
    2268          24 :         AddMonthlyFieldSetInput(state, curReport, "FuelOilNo2:Facility", "", AggType::Maximum);
    2269             :     }
    2270         730 :     if (ort->namedMonthly(10).show) {
    2271          24 :         curReport = AddMonthlyReport(state, "EnergyConsumptionDistrictHeatingCoolingMonthly", 2);
    2272          24 :         AddMonthlyFieldSetInput(state, curReport, "DistrictCooling:Facility", "", AggType::SumOrAvg);
    2273          24 :         AddMonthlyFieldSetInput(state, curReport, "DistrictCooling:Facility", "", AggType::Maximum);
    2274          24 :         AddMonthlyFieldSetInput(state, curReport, "DistrictHeating:Facility", "", AggType::SumOrAvg);
    2275          24 :         AddMonthlyFieldSetInput(state, curReport, "DistrictHeating:Facility", "", AggType::Maximum);
    2276             :     }
    2277         730 :     if (ort->namedMonthly(11).show) {
    2278          24 :         curReport = AddMonthlyReport(state, "EnergyConsumptionCoalGasolineMonthly", 2);
    2279          24 :         AddMonthlyFieldSetInput(state, curReport, "Coal:Facility", "", AggType::SumOrAvg);
    2280          24 :         AddMonthlyFieldSetInput(state, curReport, "Coal:Facility", "", AggType::Maximum);
    2281          24 :         AddMonthlyFieldSetInput(state, curReport, "Gasoline:Facility", "", AggType::SumOrAvg);
    2282          24 :         AddMonthlyFieldSetInput(state, curReport, "Gasoline:Facility", "", AggType::Maximum);
    2283             :     }
    2284         730 :     if (ort->namedMonthly(12).show) {
    2285          24 :         curReport = AddMonthlyReport(state, "EnergyConsumptionOtherFuelsMonthly", 2);
    2286          24 :         AddMonthlyFieldSetInput(state, curReport, "OtherFuel1:Facility", "", AggType::SumOrAvg);
    2287          24 :         AddMonthlyFieldSetInput(state, curReport, "OtherFuel1:Facility", "", AggType::Maximum);
    2288          24 :         AddMonthlyFieldSetInput(state, curReport, "OtherFuel2:Facility", "", AggType::SumOrAvg);
    2289          24 :         AddMonthlyFieldSetInput(state, curReport, "OtherFuel2:Facility", "", AggType::Maximum);
    2290             :     }
    2291         730 :     if (ort->namedMonthly(13).show) {
    2292          24 :         curReport = AddMonthlyReport(state, "EndUseEnergyConsumptionElectricityMonthly", 2);
    2293          24 :         AddMonthlyFieldSetInput(state, curReport, "InteriorLights:Electricity", "", AggType::SumOrAvg);
    2294          24 :         AddMonthlyFieldSetInput(state, curReport, "ExteriorLights:Electricity", "", AggType::SumOrAvg);
    2295          24 :         AddMonthlyFieldSetInput(state, curReport, "InteriorEquipment:Electricity", "", AggType::SumOrAvg);
    2296          24 :         AddMonthlyFieldSetInput(state, curReport, "ExteriorEquipment:Electricity", "", AggType::SumOrAvg);
    2297          24 :         AddMonthlyFieldSetInput(state, curReport, "Fans:Electricity", "", AggType::SumOrAvg);
    2298          24 :         AddMonthlyFieldSetInput(state, curReport, "Pumps:Electricity", "", AggType::SumOrAvg);
    2299          24 :         AddMonthlyFieldSetInput(state, curReport, "Heating:Electricity", "", AggType::SumOrAvg);
    2300          24 :         AddMonthlyFieldSetInput(state, curReport, "Cooling:Electricity", "", AggType::SumOrAvg);
    2301          24 :         AddMonthlyFieldSetInput(state, curReport, "HeatRejection:Electricity", "", AggType::SumOrAvg);
    2302          24 :         AddMonthlyFieldSetInput(state, curReport, "Humidifier:Electricity", "", AggType::SumOrAvg);
    2303          24 :         AddMonthlyFieldSetInput(state, curReport, "HeatRecovery:Electricity", "", AggType::SumOrAvg);
    2304          24 :         AddMonthlyFieldSetInput(state, curReport, "WaterSystems:Electricity", "", AggType::SumOrAvg);
    2305          24 :         AddMonthlyFieldSetInput(state, curReport, "Cogeneration:Electricity", "", AggType::SumOrAvg);
    2306             :     }
    2307         730 :     if (ort->namedMonthly(14).show) {
    2308          24 :         curReport = AddMonthlyReport(state, "EndUseEnergyConsumptionNaturalGasMonthly", 2);
    2309          24 :         AddMonthlyFieldSetInput(state, curReport, "InteriorEquipment:NaturalGas", "", AggType::SumOrAvg);
    2310          24 :         AddMonthlyFieldSetInput(state, curReport, "ExteriorEquipment:NaturalGas", "", AggType::SumOrAvg);
    2311          24 :         AddMonthlyFieldSetInput(state, curReport, "Heating:NaturalGas", "", AggType::SumOrAvg);
    2312          24 :         AddMonthlyFieldSetInput(state, curReport, "Cooling:NaturalGas", "", AggType::SumOrAvg);
    2313          24 :         AddMonthlyFieldSetInput(state, curReport, "WaterSystems:NaturalGas", "", AggType::SumOrAvg);
    2314          24 :         AddMonthlyFieldSetInput(state, curReport, "Cogeneration:NaturalGas", "", AggType::SumOrAvg);
    2315          24 :         AddMonthlyFieldSetInput(state, curReport, "Humidifier:NaturalGas", "", AggType::SumOrAvg);
    2316             :     }
    2317         730 :     if (ort->namedMonthly(15).show) {
    2318          24 :         curReport = AddMonthlyReport(state, "EndUseEnergyConsumptionDieselMonthly", 2);
    2319          24 :         AddMonthlyFieldSetInput(state, curReport, "ExteriorEquipment:Diesel", "", AggType::SumOrAvg);
    2320          24 :         AddMonthlyFieldSetInput(state, curReport, "Cooling:Diesel", "", AggType::SumOrAvg);
    2321          24 :         AddMonthlyFieldSetInput(state, curReport, "Heating:Diesel", "", AggType::SumOrAvg);
    2322          24 :         AddMonthlyFieldSetInput(state, curReport, "WaterSystems:Diesel", "", AggType::SumOrAvg);
    2323          24 :         AddMonthlyFieldSetInput(state, curReport, "Cogeneration:Diesel", "", AggType::SumOrAvg);
    2324             :     }
    2325         730 :     if (ort->namedMonthly(16).show) {
    2326          24 :         curReport = AddMonthlyReport(state, "EndUseEnergyConsumptionFuelOilMonthly", 2);
    2327          24 :         AddMonthlyFieldSetInput(state, curReport, "ExteriorEquipment:FuelOilNo1", "", AggType::SumOrAvg);
    2328          24 :         AddMonthlyFieldSetInput(state, curReport, "Cooling:FuelOilNo1", "", AggType::SumOrAvg);
    2329          24 :         AddMonthlyFieldSetInput(state, curReport, "Heating:FuelOilNo1", "", AggType::SumOrAvg);
    2330          24 :         AddMonthlyFieldSetInput(state, curReport, "WaterSystems:FuelOilNo1", "", AggType::SumOrAvg);
    2331          24 :         AddMonthlyFieldSetInput(state, curReport, "Cogeneration:FuelOilNo1", "", AggType::SumOrAvg);
    2332          24 :         AddMonthlyFieldSetInput(state, curReport, "ExteriorEquipment:FuelOilNo2", "", AggType::SumOrAvg);
    2333          24 :         AddMonthlyFieldSetInput(state, curReport, "Cooling:FuelOilNo2", "", AggType::SumOrAvg);
    2334          24 :         AddMonthlyFieldSetInput(state, curReport, "Heating:FuelOilNo2", "", AggType::SumOrAvg);
    2335          24 :         AddMonthlyFieldSetInput(state, curReport, "WaterSystems:FuelOilNo2", "", AggType::SumOrAvg);
    2336          24 :         AddMonthlyFieldSetInput(state, curReport, "Cogeneration:FuelOilNo2", "", AggType::SumOrAvg);
    2337             :     }
    2338         730 :     if (ort->namedMonthly(17).show) {
    2339          24 :         curReport = AddMonthlyReport(state, "EndUseEnergyConsumptionCoalMonthly", 2);
    2340          24 :         AddMonthlyFieldSetInput(state, curReport, "ExteriorEquipment:Coal", "", AggType::SumOrAvg);
    2341          24 :         AddMonthlyFieldSetInput(state, curReport, "Heating:Coal", "", AggType::SumOrAvg);
    2342          24 :         AddMonthlyFieldSetInput(state, curReport, "WaterSystems:Coal", "", AggType::SumOrAvg);
    2343             :     }
    2344         730 :     if (ort->namedMonthly(18).show) {
    2345          24 :         curReport = AddMonthlyReport(state, "EndUseEnergyConsumptionPropaneMonthly", 2);
    2346          24 :         AddMonthlyFieldSetInput(state, curReport, "ExteriorEquipment:Propane", "", AggType::SumOrAvg);
    2347          24 :         AddMonthlyFieldSetInput(state, curReport, "Cooling:Propane", "", AggType::SumOrAvg);
    2348          24 :         AddMonthlyFieldSetInput(state, curReport, "Heating:Propane", "", AggType::SumOrAvg);
    2349          24 :         AddMonthlyFieldSetInput(state, curReport, "WaterSystems:Propane", "", AggType::SumOrAvg);
    2350          24 :         AddMonthlyFieldSetInput(state, curReport, "Cogeneration:Propane", "", AggType::SumOrAvg);
    2351          24 :         AddMonthlyFieldSetInput(state, curReport, "Humidifier:Propane", "", AggType::SumOrAvg);
    2352             :     }
    2353         730 :     if (ort->namedMonthly(19).show) {
    2354          24 :         curReport = AddMonthlyReport(state, "EndUseEnergyConsumptionGasolineMonthly", 2);
    2355          24 :         AddMonthlyFieldSetInput(state, curReport, "ExteriorEquipment:Gasoline", "", AggType::SumOrAvg);
    2356          24 :         AddMonthlyFieldSetInput(state, curReport, "Cooling:Gasoline", "", AggType::SumOrAvg);
    2357          24 :         AddMonthlyFieldSetInput(state, curReport, "Heating:Gasoline", "", AggType::SumOrAvg);
    2358          24 :         AddMonthlyFieldSetInput(state, curReport, "WaterSystems:Gasoline", "", AggType::SumOrAvg);
    2359          24 :         AddMonthlyFieldSetInput(state, curReport, "Cogeneration:Gasoline", "", AggType::SumOrAvg);
    2360             :     }
    2361         730 :     if (ort->namedMonthly(20).show) {
    2362          24 :         curReport = AddMonthlyReport(state, "EndUseEnergyConsumptionOtherFuelsMonthly", 2);
    2363          24 :         AddMonthlyFieldSetInput(state, curReport, "ExteriorEquipment:OtherFuel1", "", AggType::SumOrAvg);
    2364          24 :         AddMonthlyFieldSetInput(state, curReport, "Cooling:OtherFuel1", "", AggType::SumOrAvg);
    2365          24 :         AddMonthlyFieldSetInput(state, curReport, "Heating:OtherFuel1", "", AggType::SumOrAvg);
    2366          24 :         AddMonthlyFieldSetInput(state, curReport, "WaterSystems:OtherFuel1", "", AggType::SumOrAvg);
    2367          24 :         AddMonthlyFieldSetInput(state, curReport, "Cogeneration:OtherFuel1", "", AggType::SumOrAvg);
    2368          24 :         AddMonthlyFieldSetInput(state, curReport, "ExteriorEquipment:OtherFuel2", "", AggType::SumOrAvg);
    2369          24 :         AddMonthlyFieldSetInput(state, curReport, "Cooling:OtherFuel2", "", AggType::SumOrAvg);
    2370          24 :         AddMonthlyFieldSetInput(state, curReport, "Heating:OtherFuel2", "", AggType::SumOrAvg);
    2371          24 :         AddMonthlyFieldSetInput(state, curReport, "WaterSystems:OtherFuel2", "", AggType::SumOrAvg);
    2372          24 :         AddMonthlyFieldSetInput(state, curReport, "Cogeneration:OtherFuel2", "", AggType::SumOrAvg);
    2373             :     }
    2374         730 :     if (ort->namedMonthly(21).show) {
    2375          24 :         curReport = AddMonthlyReport(state, "PeakEnergyEndUseElectricityPart1Monthly", 2);
    2376          24 :         AddMonthlyFieldSetInput(state, curReport, "InteriorLights:Electricity", "", AggType::Maximum);
    2377          24 :         AddMonthlyFieldSetInput(state, curReport, "ExteriorLights:Electricity", "", AggType::Maximum);
    2378          24 :         AddMonthlyFieldSetInput(state, curReport, "InteriorEquipment:Electricity", "", AggType::Maximum);
    2379          24 :         AddMonthlyFieldSetInput(state, curReport, "ExteriorEquipment:Electricity", "", AggType::Maximum);
    2380          24 :         AddMonthlyFieldSetInput(state, curReport, "Fans:Electricity", "", AggType::Maximum);
    2381          24 :         AddMonthlyFieldSetInput(state, curReport, "Pumps:Electricity", "", AggType::Maximum);
    2382          24 :         AddMonthlyFieldSetInput(state, curReport, "Heating:Electricity", "", AggType::Maximum);
    2383             :     }
    2384         730 :     if (ort->namedMonthly(22).show) {
    2385          24 :         curReport = AddMonthlyReport(state, "PeakEnergyEndUseElectricityPart2Monthly", 2);
    2386          24 :         AddMonthlyFieldSetInput(state, curReport, "Cooling:Electricity", "", AggType::Maximum);
    2387          24 :         AddMonthlyFieldSetInput(state, curReport, "HeatRejection:Electricity", "", AggType::Maximum);
    2388          24 :         AddMonthlyFieldSetInput(state, curReport, "Humidifier:Electricity", "", AggType::Maximum);
    2389          24 :         AddMonthlyFieldSetInput(state, curReport, "HeatRecovery:Electricity", "", AggType::Maximum);
    2390          24 :         AddMonthlyFieldSetInput(state, curReport, "WaterSystems:Electricity", "", AggType::Maximum);
    2391          24 :         AddMonthlyFieldSetInput(state, curReport, "Cogeneration:Electricity", "", AggType::Maximum);
    2392             :     }
    2393         730 :     if (ort->namedMonthly(23).show) {
    2394          24 :         curReport = AddMonthlyReport(state, "ElectricComponentsOfPeakDemandMonthly", 2);
    2395          24 :         AddMonthlyFieldSetInput(state, curReport, "Electricity:Facility", "", AggType::Maximum);
    2396          24 :         AddMonthlyFieldSetInput(state, curReport, "InteriorLights:Electricity", "", AggType::ValueWhenMaxMin);
    2397          24 :         AddMonthlyFieldSetInput(state, curReport, "InteriorEquipment:Electricity", "", AggType::ValueWhenMaxMin);
    2398          24 :         AddMonthlyFieldSetInput(state, curReport, "ExteriorLights:Electricity", "", AggType::ValueWhenMaxMin);
    2399          24 :         AddMonthlyFieldSetInput(state, curReport, "ExteriorEquipment:Electricity", "", AggType::ValueWhenMaxMin);
    2400          24 :         AddMonthlyFieldSetInput(state, curReport, "Fans:Electricity", "", AggType::ValueWhenMaxMin);
    2401          24 :         AddMonthlyFieldSetInput(state, curReport, "Pumps:Electricity", "", AggType::ValueWhenMaxMin);
    2402          24 :         AddMonthlyFieldSetInput(state, curReport, "Heating:Electricity", "", AggType::ValueWhenMaxMin);
    2403          24 :         AddMonthlyFieldSetInput(state, curReport, "Cooling:Electricity", "", AggType::ValueWhenMaxMin);
    2404          24 :         AddMonthlyFieldSetInput(state, curReport, "HeatRejection:Electricity", "", AggType::ValueWhenMaxMin);
    2405             :     }
    2406         730 :     if (ort->namedMonthly(24).show) {
    2407          24 :         curReport = AddMonthlyReport(state, "PeakEnergyEndUseNaturalGasMonthly", 2);
    2408          24 :         AddMonthlyFieldSetInput(state, curReport, "InteriorEquipment:NaturalGas", "", AggType::Maximum);
    2409          24 :         AddMonthlyFieldSetInput(state, curReport, "ExteriorEquipment:NaturalGas", "", AggType::Maximum);
    2410          24 :         AddMonthlyFieldSetInput(state, curReport, "Heating:NaturalGas", "", AggType::Maximum);
    2411          24 :         AddMonthlyFieldSetInput(state, curReport, "Cooling:NaturalGas", "", AggType::Maximum);
    2412          24 :         AddMonthlyFieldSetInput(state, curReport, "WaterSystems:NaturalGas", "", AggType::Maximum);
    2413          24 :         AddMonthlyFieldSetInput(state, curReport, "Cogeneration:NaturalGas", "", AggType::Maximum);
    2414             :     }
    2415         730 :     if (ort->namedMonthly(25).show) {
    2416          24 :         curReport = AddMonthlyReport(state, "PeakEnergyEndUseDieselMonthly", 2);
    2417          24 :         AddMonthlyFieldSetInput(state, curReport, "ExteriorEquipment:Diesel", "", AggType::Maximum);
    2418          24 :         AddMonthlyFieldSetInput(state, curReport, "Cooling:Diesel", "", AggType::Maximum);
    2419          24 :         AddMonthlyFieldSetInput(state, curReport, "Heating:Diesel", "", AggType::Maximum);
    2420          24 :         AddMonthlyFieldSetInput(state, curReport, "WaterSystems:Diesel", "", AggType::Maximum);
    2421          24 :         AddMonthlyFieldSetInput(state, curReport, "Cogeneration:Diesel", "", AggType::Maximum);
    2422             :     }
    2423         730 :     if (ort->namedMonthly(26).show) {
    2424          24 :         curReport = AddMonthlyReport(state, "PeakEnergyEndUseFuelOilMonthly", 2);
    2425          24 :         AddMonthlyFieldSetInput(state, curReport, "ExteriorEquipment:FuelOilNo1", "", AggType::Maximum);
    2426          24 :         AddMonthlyFieldSetInput(state, curReport, "Cooling:FuelOilNo1", "", AggType::Maximum);
    2427          24 :         AddMonthlyFieldSetInput(state, curReport, "Heating:FuelOilNo1", "", AggType::Maximum);
    2428          24 :         AddMonthlyFieldSetInput(state, curReport, "WaterSystems:FuelOilNo1", "", AggType::Maximum);
    2429          24 :         AddMonthlyFieldSetInput(state, curReport, "Cogeneration:FuelOilNo1", "", AggType::Maximum);
    2430          24 :         AddMonthlyFieldSetInput(state, curReport, "ExteriorEquipment:FuelOilNo2", "", AggType::Maximum);
    2431          24 :         AddMonthlyFieldSetInput(state, curReport, "Cooling:FuelOilNo2", "", AggType::Maximum);
    2432          24 :         AddMonthlyFieldSetInput(state, curReport, "Heating:FuelOilNo2", "", AggType::Maximum);
    2433          24 :         AddMonthlyFieldSetInput(state, curReport, "WaterSystems:FuelOilNo2", "", AggType::Maximum);
    2434          24 :         AddMonthlyFieldSetInput(state, curReport, "Cogeneration:FuelOilNo2", "", AggType::Maximum);
    2435             :     }
    2436         730 :     if (ort->namedMonthly(27).show) {
    2437          24 :         curReport = AddMonthlyReport(state, "PeakEnergyEndUseCoalMonthly", 2);
    2438          24 :         AddMonthlyFieldSetInput(state, curReport, "ExteriorEquipment:Coal", "", AggType::Maximum);
    2439          24 :         AddMonthlyFieldSetInput(state, curReport, "Heating:Coal", "", AggType::Maximum);
    2440          24 :         AddMonthlyFieldSetInput(state, curReport, "WaterSystems:Coal", "", AggType::Maximum);
    2441             :     }
    2442         730 :     if (ort->namedMonthly(28).show) {
    2443          24 :         curReport = AddMonthlyReport(state, "PeakEnergyEndUsePropaneMonthly", 2);
    2444          24 :         AddMonthlyFieldSetInput(state, curReport, "ExteriorEquipment:Propane", "", AggType::Maximum);
    2445          24 :         AddMonthlyFieldSetInput(state, curReport, "Cooling:Propane", "", AggType::Maximum);
    2446          24 :         AddMonthlyFieldSetInput(state, curReport, "Heating:Propane", "", AggType::Maximum);
    2447          24 :         AddMonthlyFieldSetInput(state, curReport, "WaterSystems:Propane", "", AggType::Maximum);
    2448          24 :         AddMonthlyFieldSetInput(state, curReport, "Cogeneration:Propane", "", AggType::Maximum);
    2449             :     }
    2450         730 :     if (ort->namedMonthly(29).show) {
    2451          24 :         curReport = AddMonthlyReport(state, "PeakEnergyEndUseGasolineMonthly", 2);
    2452          24 :         AddMonthlyFieldSetInput(state, curReport, "ExteriorEquipment:Gasoline", "", AggType::Maximum);
    2453          24 :         AddMonthlyFieldSetInput(state, curReport, "Cooling:Gasoline", "", AggType::Maximum);
    2454          24 :         AddMonthlyFieldSetInput(state, curReport, "Heating:Gasoline", "", AggType::Maximum);
    2455          24 :         AddMonthlyFieldSetInput(state, curReport, "WaterSystems:Gasoline", "", AggType::Maximum);
    2456          24 :         AddMonthlyFieldSetInput(state, curReport, "Cogeneration:Gasoline", "", AggType::Maximum);
    2457             :     }
    2458         730 :     if (ort->namedMonthly(30).show) {
    2459          24 :         curReport = AddMonthlyReport(state, "PeakEnergyEndUseOtherFuelsMonthly", 2);
    2460          24 :         AddMonthlyFieldSetInput(state, curReport, "ExteriorEquipment:OtherFuel1", "", AggType::Maximum);
    2461          24 :         AddMonthlyFieldSetInput(state, curReport, "Cooling:OtherFuel1", "", AggType::Maximum);
    2462          24 :         AddMonthlyFieldSetInput(state, curReport, "Heating:OtherFuel1", "", AggType::Maximum);
    2463          24 :         AddMonthlyFieldSetInput(state, curReport, "WaterSystems:OtherFuel1", "", AggType::Maximum);
    2464          24 :         AddMonthlyFieldSetInput(state, curReport, "Cogeneration:OtherFuel1", "", AggType::Maximum);
    2465          24 :         AddMonthlyFieldSetInput(state, curReport, "ExteriorEquipment:OtherFuel2", "", AggType::Maximum);
    2466          24 :         AddMonthlyFieldSetInput(state, curReport, "Cooling:OtherFuel2", "", AggType::Maximum);
    2467          24 :         AddMonthlyFieldSetInput(state, curReport, "Heating:OtherFuel2", "", AggType::Maximum);
    2468          24 :         AddMonthlyFieldSetInput(state, curReport, "WaterSystems:OtherFuel2", "", AggType::Maximum);
    2469          24 :         AddMonthlyFieldSetInput(state, curReport, "Cogeneration:OtherFuel2", "", AggType::Maximum);
    2470             :     }
    2471         730 :     if (ort->namedMonthly(31).show) {
    2472          24 :         curReport = AddMonthlyReport(state, "SetpointsNotMetWithTemperaturesMonthly", 2);
    2473          24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Heating Setpoint Not Met Time", "", AggType::HoursNonZero);
    2474          24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Mean Air Temperature", "", AggType::SumOrAverageHoursShown);
    2475          24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Heating Setpoint Not Met While Occupied Time", "", AggType::HoursNonZero);
    2476          24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Mean Air Temperature", "", AggType::SumOrAverageHoursShown);
    2477          24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Cooling Setpoint Not Met Time", "", AggType::HoursNonZero);
    2478          24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Mean Air Temperature", "", AggType::SumOrAverageHoursShown);
    2479          24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Cooling Setpoint Not Met While Occupied Time", "", AggType::HoursNonZero);
    2480          24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Mean Air Temperature", "", AggType::SumOrAverageHoursShown);
    2481             :     }
    2482         730 :     if (ort->namedMonthly(32).show) {
    2483          24 :         curReport = AddMonthlyReport(state, "ComfortReportSimple55Monthly", 2);
    2484          24 :         AddMonthlyFieldSetInput(
    2485             :             state, curReport, "Zone Thermal Comfort ASHRAE 55 Simple Model Summer Clothes Not Comfortable Time", "", AggType::HoursNonZero);
    2486          24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Mean Air Temperature", "", AggType::SumOrAverageHoursShown);
    2487          24 :         AddMonthlyFieldSetInput(
    2488             :             state, curReport, "Zone Thermal Comfort ASHRAE 55 Simple Model Winter Clothes Not Comfortable Time", "", AggType::HoursNonZero);
    2489          24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Mean Air Temperature", "", AggType::SumOrAverageHoursShown);
    2490          24 :         AddMonthlyFieldSetInput(
    2491             :             state, curReport, "Zone Thermal Comfort ASHRAE 55 Simple Model Summer or Winter Clothes Not Comfortable Time", "", AggType::HoursNonZero);
    2492          24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Mean Air Temperature", "", AggType::SumOrAverageHoursShown);
    2493             :     }
    2494         730 :     if (ort->namedMonthly(33).show) {
    2495          24 :         curReport = AddMonthlyReport(state, "UnglazedTranspiredSolarCollectorSummaryMonthly", 5);
    2496          24 :         AddMonthlyFieldSetInput(state, curReport, "Solar Collector System Efficiency", "", AggType::HoursNonZero);
    2497          24 :         AddMonthlyFieldSetInput(state, curReport, "Solar Collector System Efficiency", "", AggType::SumOrAverageHoursShown);
    2498          24 :         AddMonthlyFieldSetInput(state, curReport, "Solar Collector Outside Face Suction Velocity", "", AggType::SumOrAverageHoursShown);
    2499          24 :         AddMonthlyFieldSetInput(state, curReport, "Solar Collector Sensible Heating Rate", "", AggType::SumOrAverageHoursShown);
    2500             :     }
    2501         730 :     if (ort->namedMonthly(34).show) {
    2502          24 :         curReport = AddMonthlyReport(state, "OccupantComfortDataSummaryMonthly", 5);
    2503          24 :         AddMonthlyFieldSetInput(state, curReport, "People Occupant Count", "", AggType::HoursNonZero);
    2504          24 :         AddMonthlyFieldSetInput(state, curReport, "People Air Temperature", "", AggType::SumOrAverageHoursShown);
    2505          24 :         AddMonthlyFieldSetInput(state, curReport, "People Air Relative Humidity", "", AggType::SumOrAverageHoursShown);
    2506          24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Thermal Comfort Fanger Model PMV", "", AggType::SumOrAverageHoursShown);
    2507          24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Thermal Comfort Fanger Model PPD", "", AggType::SumOrAverageHoursShown);
    2508             :     }
    2509         730 :     if (ort->namedMonthly(35).show) {
    2510          24 :         curReport = AddMonthlyReport(state, "ChillerReportMonthly", 2);
    2511          24 :         AddMonthlyFieldSetInput(state, curReport, "Chiller Electricity Energy", "", AggType::SumOrAvg);
    2512          24 :         AddMonthlyFieldSetInput(state, curReport, "Chiller Electricity Rate", "", AggType::Maximum);
    2513          24 :         AddMonthlyFieldSetInput(state, curReport, "Chiller Electricity Energy", "", AggType::HoursNonZero);
    2514          24 :         AddMonthlyFieldSetInput(state, curReport, "Chiller Evaporator Cooling Energy", "", AggType::SumOrAvg);
    2515          24 :         AddMonthlyFieldSetInput(state, curReport, "Chiller Evaporator Cooling Rate", "", AggType::Maximum);
    2516          24 :         AddMonthlyFieldSetInput(state, curReport, "Chiller Condenser Heat Transfer Energy", "", AggType::SumOrAvg);
    2517          24 :         AddMonthlyFieldSetInput(state, curReport, "Chiller COP", "", AggType::SumOrAvg);
    2518          24 :         AddMonthlyFieldSetInput(state, curReport, "Chiller COP", "", AggType::Maximum);
    2519          24 :         AddMonthlyFieldSetInput(state, curReport, "Chiller Part Load Ratio", "", AggType::SumOrAvg);
    2520          24 :         AddMonthlyFieldSetInput(state, curReport, "Chiller Part Load Ratio", "", AggType::Maximum);
    2521             :     }
    2522         730 :     if (ort->namedMonthly(36).show) {
    2523          24 :         curReport = AddMonthlyReport(state, "TowerReportMonthly", 2);
    2524          24 :         AddMonthlyFieldSetInput(state, curReport, "Cooling Tower Fan Electricity Energy", "", AggType::SumOrAvg);
    2525          24 :         AddMonthlyFieldSetInput(state, curReport, "Cooling Tower Fan Electricity Energy", "", AggType::HoursNonZero);
    2526          24 :         AddMonthlyFieldSetInput(state, curReport, "Cooling Tower Fan Electricity Rate", "", AggType::Maximum);
    2527          24 :         AddMonthlyFieldSetInput(state, curReport, "Cooling Tower Heat Transfer Rate", "", AggType::Maximum);
    2528          24 :         AddMonthlyFieldSetInput(state, curReport, "Cooling Tower Inlet Temperature", "", AggType::SumOrAvg);
    2529          24 :         AddMonthlyFieldSetInput(state, curReport, "Cooling Tower Outlet Temperature", "", AggType::SumOrAvg);
    2530          24 :         AddMonthlyFieldSetInput(state, curReport, "Cooling Tower Mass Flow Rate", "", AggType::SumOrAvg);
    2531             :     }
    2532         730 :     if (ort->namedMonthly(37).show) {
    2533          24 :         curReport = AddMonthlyReport(state, "BoilerReportMonthly", 2);
    2534          24 :         AddMonthlyFieldSetInput(state, curReport, "Boiler Heating Energy", "", AggType::SumOrAvg);
    2535          24 :         AddMonthlyFieldSetInput(state, curReport, "Boiler Gas Consumption", "", AggType::SumOrAvg);
    2536          24 :         AddMonthlyFieldSetInput(state, curReport, "Boiler Heating Energy", "", AggType::HoursNonZero);
    2537          24 :         AddMonthlyFieldSetInput(state, curReport, "Boiler Heating Rate", "", AggType::Maximum);
    2538          24 :         AddMonthlyFieldSetInput(state, curReport, "Boiler Gas Consumption Rate", "", AggType::Maximum);
    2539          24 :         AddMonthlyFieldSetInput(state, curReport, "Boiler Inlet Temperature", "", AggType::SumOrAvg);
    2540          24 :         AddMonthlyFieldSetInput(state, curReport, "Boiler Outlet Temperature", "", AggType::SumOrAvg);
    2541          24 :         AddMonthlyFieldSetInput(state, curReport, "Boiler Mass Flow Rate", "", AggType::SumOrAvg);
    2542          24 :         AddMonthlyFieldSetInput(state, curReport, "Boiler Ancillary Electricity Rate", "", AggType::SumOrAvg);
    2543          24 :         AddMonthlyFieldSetInput(state, curReport, "Boiler Part Load Ratio", "", AggType::SumOrAvg);
    2544          24 :         AddMonthlyFieldSetInput(state, curReport, "Boiler Part Load Ratio", "", AggType::Maximum);
    2545             :     }
    2546         730 :     if (ort->namedMonthly(38).show) {
    2547          24 :         curReport = AddMonthlyReport(state, "DXReportMonthly", 2);
    2548          24 :         AddMonthlyFieldSetInput(state, curReport, "Cooling Coil Total Cooling Energy", "", AggType::SumOrAvg);
    2549          24 :         AddMonthlyFieldSetInput(state, curReport, "Cooling Coil Electricity Energy", "", AggType::SumOrAvg);
    2550          24 :         AddMonthlyFieldSetInput(state, curReport, "Cooling Coil Total Cooling Energy", "", AggType::HoursNonZero);
    2551          24 :         AddMonthlyFieldSetInput(state, curReport, "Cooling Coil Sensible Cooling Energy", "", AggType::SumOrAvg);
    2552          24 :         AddMonthlyFieldSetInput(state, curReport, "Cooling Coil Latent Cooling Energy", "", AggType::SumOrAvg);
    2553          24 :         AddMonthlyFieldSetInput(state, curReport, "Cooling Coil Crankcase Heater Electricity Energy", "", AggType::SumOrAvg);
    2554          24 :         AddMonthlyFieldSetInput(state, curReport, "Cooling Coil Runtime Fraction", "", AggType::Maximum);
    2555          24 :         AddMonthlyFieldSetInput(state, curReport, "Cooling Coil Runtime Fraction", "", AggType::Minimum);
    2556          24 :         AddMonthlyFieldSetInput(state, curReport, "Cooling Coil Total Cooling Rate", "", AggType::Maximum);
    2557          24 :         AddMonthlyFieldSetInput(state, curReport, "Cooling Coil Sensible Cooling Rate", "", AggType::Maximum);
    2558          24 :         AddMonthlyFieldSetInput(state, curReport, "Cooling Coil Latent Cooling Rate", "", AggType::Maximum);
    2559          24 :         AddMonthlyFieldSetInput(state, curReport, "Cooling Coil Electricity Rate", "", AggType::Maximum);
    2560          24 :         AddMonthlyFieldSetInput(state, curReport, "Cooling Coil Crankcase Heater Electricity Rate", "", AggType::Maximum);
    2561             :     }
    2562         730 :     if (ort->namedMonthly(39).show) {
    2563          24 :         curReport = AddMonthlyReport(state, "WindowReportMonthly", 2);
    2564          24 :         AddMonthlyFieldSetInput(state, curReport, "Surface Window Transmitted Solar Radiation Rate", "", AggType::SumOrAvg);
    2565          24 :         AddMonthlyFieldSetInput(state, curReport, "Surface Window Transmitted Beam Solar Radiation Rate", "", AggType::SumOrAvg);
    2566          24 :         AddMonthlyFieldSetInput(state, curReport, "Surface Window Transmitted Diffuse Solar Radiation Rate", "", AggType::SumOrAvg);
    2567          24 :         AddMonthlyFieldSetInput(state, curReport, "Surface Window Heat Gain Rate", "", AggType::SumOrAvg);
    2568          24 :         AddMonthlyFieldSetInput(state, curReport, "Surface Window Heat Loss Rate", "", AggType::SumOrAvg);
    2569          24 :         AddMonthlyFieldSetInput(state, curReport, "Surface Window Inside Face Glazing Condensation Status", "", AggType::HoursNonZero);
    2570          24 :         AddMonthlyFieldSetInput(state, curReport, "Surface Shading Device Is On Time Fraction", "", AggType::HoursNonZero);
    2571          24 :         AddMonthlyFieldSetInput(state, curReport, "Surface Storm Window On Off Status", "", AggType::HoursNonZero);
    2572             :     }
    2573         730 :     if (ort->namedMonthly(40).show) {
    2574          24 :         curReport = AddMonthlyReport(state, "WindowEnergyReportMonthly", 2);
    2575          24 :         AddMonthlyFieldSetInput(state, curReport, "Surface Window Transmitted Solar Radiation Energy", "", AggType::SumOrAvg);
    2576          24 :         AddMonthlyFieldSetInput(state, curReport, "Surface Window Transmitted Beam Solar Radiation Energy", "", AggType::SumOrAvg);
    2577          24 :         AddMonthlyFieldSetInput(state, curReport, "Surface Window Transmitted Diffuse Solar Radiation Energy", "", AggType::SumOrAvg);
    2578          24 :         AddMonthlyFieldSetInput(state, curReport, "Surface Window Heat Gain Energy", "", AggType::SumOrAvg);
    2579          24 :         AddMonthlyFieldSetInput(state, curReport, "Surface Window Heat Loss Energy", "", AggType::SumOrAvg);
    2580             :     }
    2581         730 :     if (ort->namedMonthly(41).show) {
    2582          24 :         curReport = AddMonthlyReport(state, "WindowZoneSummaryMonthly", 2);
    2583          24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Windows Total Heat Gain Rate", "", AggType::SumOrAvg);
    2584          24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Windows Total Heat Loss Rate", "", AggType::SumOrAvg);
    2585          24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Windows Total Transmitted Solar Radiation Rate", "", AggType::SumOrAvg);
    2586          24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Exterior Windows Total Transmitted Beam Solar Radiation Rate", "", AggType::SumOrAvg);
    2587          24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Exterior Windows Total Transmitted Diffuse Solar Radiation Rate", "", AggType::SumOrAvg);
    2588          24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Interior Windows Total Transmitted Diffuse Solar Radiation Rate", "", AggType::SumOrAvg);
    2589          24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Interior Windows Total Transmitted Beam Solar Radiation Rate", "", AggType::SumOrAvg);
    2590             :     }
    2591         730 :     if (ort->namedMonthly(42).show) {
    2592          24 :         curReport = AddMonthlyReport(state, "WindowEnergyZoneSummaryMonthly", 2);
    2593          24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Windows Total Heat Gain Energy", "", AggType::SumOrAvg);
    2594          24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Windows Total Heat Loss Energy", "", AggType::SumOrAvg);
    2595          24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Windows Total Transmitted Solar Radiation Energy", "", AggType::SumOrAvg);
    2596          24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Exterior Windows Total Transmitted Beam Solar Radiation Energy", "", AggType::SumOrAvg);
    2597          24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Exterior Windows Total Transmitted Diffuse Solar Radiation Energy", "", AggType::SumOrAvg);
    2598          24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Interior Windows Total Transmitted Diffuse Solar Radiation Energy", "", AggType::SumOrAvg);
    2599          24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Interior Windows Total Transmitted Beam Solar Radiation Energy", "", AggType::SumOrAvg);
    2600             :     }
    2601         730 :     if (ort->namedMonthly(43).show) {
    2602          24 :         curReport = AddMonthlyReport(state, "AverageOutdoorConditionsMonthly", 2);
    2603          24 :         AddMonthlyFieldSetInput(state, curReport, "Site Outdoor Air Drybulb Temperature", "", AggType::SumOrAvg);
    2604          24 :         AddMonthlyFieldSetInput(state, curReport, "Site Outdoor Air Wetbulb Temperature", "", AggType::SumOrAvg);
    2605          24 :         AddMonthlyFieldSetInput(state, curReport, "Site Outdoor Air Dewpoint Temperature", "", AggType::SumOrAvg);
    2606          24 :         AddMonthlyFieldSetInput(state, curReport, "Site Wind Speed", "", AggType::SumOrAvg);
    2607          24 :         AddMonthlyFieldSetInput(state, curReport, "Site Sky Temperature", "", AggType::SumOrAvg);
    2608          24 :         AddMonthlyFieldSetInput(state, curReport, "Site Diffuse Solar Radiation Rate per Area", "", AggType::SumOrAvg);
    2609          24 :         AddMonthlyFieldSetInput(state, curReport, "Site Direct Solar Radiation Rate per Area", "", AggType::SumOrAvg);
    2610          24 :         AddMonthlyFieldSetInput(state, curReport, "Site Rain Status", "", AggType::SumOrAvg);
    2611             :     }
    2612         730 :     if (ort->namedMonthly(44).show) {
    2613          24 :         curReport = AddMonthlyReport(state, "OutdoorConditionsMaximumDryBulbMonthly", 2);
    2614          24 :         AddMonthlyFieldSetInput(state, curReport, "Site Outdoor Air Drybulb Temperature", "", AggType::Maximum);
    2615          24 :         AddMonthlyFieldSetInput(state, curReport, "Site Outdoor Air Wetbulb Temperature", "", AggType::ValueWhenMaxMin);
    2616          24 :         AddMonthlyFieldSetInput(state, curReport, "Site Outdoor Air Dewpoint Temperature", "", AggType::ValueWhenMaxMin);
    2617          24 :         AddMonthlyFieldSetInput(state, curReport, "Site Wind Speed", "", AggType::ValueWhenMaxMin);
    2618          24 :         AddMonthlyFieldSetInput(state, curReport, "Site Sky Temperature", "", AggType::ValueWhenMaxMin);
    2619          24 :         AddMonthlyFieldSetInput(state, curReport, "Site Diffuse Solar Radiation Rate per Area", "", AggType::ValueWhenMaxMin);
    2620          24 :         AddMonthlyFieldSetInput(state, curReport, "Site Direct Solar Radiation Rate per Area", "", AggType::ValueWhenMaxMin);
    2621             :     }
    2622         730 :     if (ort->namedMonthly(45).show) {
    2623          24 :         curReport = AddMonthlyReport(state, "OutdoorConditionsMinimumDryBulbMonthly", 2);
    2624          24 :         AddMonthlyFieldSetInput(state, curReport, "Site Outdoor Air Drybulb Temperature", "", AggType::Minimum);
    2625          24 :         AddMonthlyFieldSetInput(state, curReport, "Site Outdoor Air Wetbulb Temperature", "", AggType::ValueWhenMaxMin);
    2626          24 :         AddMonthlyFieldSetInput(state, curReport, "Site Outdoor Air Dewpoint Temperature", "", AggType::ValueWhenMaxMin);
    2627          24 :         AddMonthlyFieldSetInput(state, curReport, "Site Wind Speed", "", AggType::ValueWhenMaxMin);
    2628          24 :         AddMonthlyFieldSetInput(state, curReport, "Site Sky Temperature", "", AggType::ValueWhenMaxMin);
    2629          24 :         AddMonthlyFieldSetInput(state, curReport, "Site Diffuse Solar Radiation Rate per Area", "", AggType::ValueWhenMaxMin);
    2630          24 :         AddMonthlyFieldSetInput(state, curReport, "Site Direct Solar Radiation Rate per Area", "", AggType::ValueWhenMaxMin);
    2631             :     }
    2632         730 :     if (ort->namedMonthly(46).show) {
    2633          24 :         curReport = AddMonthlyReport(state, "OutdoorConditionsMaximumWetBulbMonthly", 2);
    2634          24 :         AddMonthlyFieldSetInput(state, curReport, "Site Outdoor Air Wetbulb Temperature", "", AggType::Maximum);
    2635          24 :         AddMonthlyFieldSetInput(state, curReport, "Site Outdoor Air Drybulb Temperature", "", AggType::ValueWhenMaxMin);
    2636          24 :         AddMonthlyFieldSetInput(state, curReport, "Site Outdoor Air Dewpoint Temperature", "", AggType::ValueWhenMaxMin);
    2637          24 :         AddMonthlyFieldSetInput(state, curReport, "Site Wind Speed", "", AggType::ValueWhenMaxMin);
    2638          24 :         AddMonthlyFieldSetInput(state, curReport, "Site Sky Temperature", "", AggType::ValueWhenMaxMin);
    2639          24 :         AddMonthlyFieldSetInput(state, curReport, "Site Diffuse Solar Radiation Rate per Area", "", AggType::ValueWhenMaxMin);
    2640          24 :         AddMonthlyFieldSetInput(state, curReport, "Site Direct Solar Radiation Rate per Area", "", AggType::ValueWhenMaxMin);
    2641             :     }
    2642         730 :     if (ort->namedMonthly(47).show) {
    2643          24 :         curReport = AddMonthlyReport(state, "OutdoorConditionsMaximumDewPointMonthly", 2);
    2644          24 :         AddMonthlyFieldSetInput(state, curReport, "Site Outdoor Air Dewpoint Temperature", "", AggType::Maximum);
    2645          24 :         AddMonthlyFieldSetInput(state, curReport, "Site Outdoor Air Drybulb Temperature", "", AggType::ValueWhenMaxMin);
    2646          24 :         AddMonthlyFieldSetInput(state, curReport, "Site Outdoor Air Wetbulb Temperature", "", AggType::ValueWhenMaxMin);
    2647          24 :         AddMonthlyFieldSetInput(state, curReport, "Site Wind Speed", "", AggType::ValueWhenMaxMin);
    2648          24 :         AddMonthlyFieldSetInput(state, curReport, "Site Sky Temperature", "", AggType::ValueWhenMaxMin);
    2649          24 :         AddMonthlyFieldSetInput(state, curReport, "Site Diffuse Solar Radiation Rate per Area", "", AggType::ValueWhenMaxMin);
    2650          24 :         AddMonthlyFieldSetInput(state, curReport, "Site Direct Solar Radiation Rate per Area", "", AggType::ValueWhenMaxMin);
    2651             :     }
    2652         730 :     if (ort->namedMonthly(48).show) {
    2653          24 :         curReport = AddMonthlyReport(state, "OutdoorGroundConditionsMonthly", 2);
    2654          24 :         AddMonthlyFieldSetInput(state, curReport, "Site Ground Temperature", "", AggType::SumOrAvg);
    2655          24 :         AddMonthlyFieldSetInput(state, curReport, "Site Surface Ground Temperature", "", AggType::SumOrAvg);
    2656          24 :         AddMonthlyFieldSetInput(state, curReport, "Site Deep Ground Temperature", "", AggType::SumOrAvg);
    2657          24 :         AddMonthlyFieldSetInput(state, curReport, "Site Mains Water Temperature", "", AggType::SumOrAvg);
    2658          24 :         AddMonthlyFieldSetInput(state, curReport, "Site Ground Reflected Solar Radiation Rate per Area", "", AggType::SumOrAvg);
    2659          24 :         AddMonthlyFieldSetInput(state, curReport, "Site Snow on Ground Status", "", AggType::SumOrAvg);
    2660             :     }
    2661         730 :     if (ort->namedMonthly(49).show) {
    2662          24 :         curReport = AddMonthlyReport(state, "WindowACReportMonthly", 2);
    2663          24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Window Air Conditioner Total Cooling Energy", "", AggType::SumOrAvg);
    2664          24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Window Air Conditioner Electricity Energy", "", AggType::SumOrAvg);
    2665          24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Window Air Conditioner Total Cooling Energy", "", AggType::HoursNonZero);
    2666          24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Window Air Conditioner Sensible Cooling Energy", "", AggType::SumOrAvg);
    2667          24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Window Air Conditioner Latent Cooling Energy", "", AggType::SumOrAvg);
    2668          24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Window Air Conditioner Total Cooling Rate", "", AggType::Maximum);
    2669          24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Window Air Conditioner Sensible Cooling Rate", "", AggType::ValueWhenMaxMin);
    2670          24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Window Air Conditioner Latent Cooling Rate", "", AggType::ValueWhenMaxMin);
    2671          24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Window Air Conditioner Electricity Rate", "", AggType::ValueWhenMaxMin);
    2672             :     }
    2673         730 :     if (ort->namedMonthly(50).show) {
    2674          24 :         curReport = AddMonthlyReport(state, "WaterHeaterReportMonthly", 2);
    2675          24 :         AddMonthlyFieldSetInput(state, curReport, "Water Heater Total Demand Heat Transfer Energy", "", AggType::SumOrAvg);
    2676          24 :         AddMonthlyFieldSetInput(state, curReport, "Water Heater Use Side Heat Transfer Energy", "", AggType::SumOrAvg);
    2677          24 :         AddMonthlyFieldSetInput(state, curReport, "Water Heater Burner Heating Energy", "", AggType::SumOrAvg);
    2678          24 :         AddMonthlyFieldSetInput(state, curReport, "Water Heater Gas Consumption", "", AggType::SumOrAvg);
    2679          24 :         AddMonthlyFieldSetInput(state, curReport, "Water Heater Total Demand Heat Transfer Energy", "", AggType::HoursNonZero);
    2680          24 :         AddMonthlyFieldSetInput(state, curReport, "Water Heater Loss Demand Energy", "", AggType::SumOrAvg);
    2681          24 :         AddMonthlyFieldSetInput(state, curReport, "Water Heater Heat Loss Energy", "", AggType::SumOrAvg);
    2682          24 :         AddMonthlyFieldSetInput(state, curReport, "Water Heater Tank Temperature", "", AggType::SumOrAvg);
    2683          24 :         AddMonthlyFieldSetInput(state, curReport, "Water Heater Heat Recovery Supply Energy", "", AggType::SumOrAvg);
    2684          24 :         AddMonthlyFieldSetInput(state, curReport, "Water Heater Source Energy", "", AggType::SumOrAvg);
    2685             :     }
    2686         730 :     if (ort->namedMonthly(51).show) {
    2687          24 :         curReport = AddMonthlyReport(state, "GeneratorReportMonthly", 2);
    2688          24 :         AddMonthlyFieldSetInput(state, curReport, "Generator Produced AC Electricity Energy", "", AggType::SumOrAvg);
    2689          24 :         AddMonthlyFieldSetInput(state, curReport, "Generator Diesel Consumption", "", AggType::SumOrAvg);
    2690          24 :         AddMonthlyFieldSetInput(state, curReport, "Generator Gas Consumption", "", AggType::SumOrAvg);
    2691          24 :         AddMonthlyFieldSetInput(state, curReport, "Generator Produced AC Electricity Energy", "", AggType::HoursNonZero);
    2692          24 :         AddMonthlyFieldSetInput(state, curReport, "Generator Total Heat Recovery", "", AggType::SumOrAvg);
    2693          24 :         AddMonthlyFieldSetInput(state, curReport, "Generator Jacket Heat Recovery Energy", "", AggType::SumOrAvg);
    2694          24 :         AddMonthlyFieldSetInput(state, curReport, "Generator Lube Heat Recovery", "", AggType::SumOrAvg);
    2695          24 :         AddMonthlyFieldSetInput(state, curReport, "Generator Exhaust Heat Recovery Energy", "", AggType::SumOrAvg);
    2696          24 :         AddMonthlyFieldSetInput(state, curReport, "Generator Exhaust Air Temperature", "", AggType::SumOrAvg);
    2697             :     }
    2698         730 :     if (ort->namedMonthly(52).show) {
    2699          24 :         curReport = AddMonthlyReport(state, "DaylightingReportMonthly", 2);
    2700          24 :         AddMonthlyFieldSetInput(state, curReport, "Site Exterior Beam Normal Illuminance", "", AggType::HoursNonZero);
    2701          24 :         AddMonthlyFieldSetInput(state, curReport, "Daylighting Lighting Power Multiplier", "", AggType::SumOrAverageHoursShown);
    2702          24 :         AddMonthlyFieldSetInput(state, curReport, "Daylighting Lighting Power Multiplier", "", AggType::MinimumDuringHoursShown);
    2703          24 :         AddMonthlyFieldSetInput(state, curReport, "Daylighting Reference Point 1 Illuminance", "", AggType::SumOrAverageHoursShown);
    2704          24 :         AddMonthlyFieldSetInput(state, curReport, "Daylighting Reference Point 1 Glare Index", "", AggType::SumOrAverageHoursShown);
    2705          24 :         AddMonthlyFieldSetInput(state, curReport, "Daylighting Reference Point 1 Glare Index Setpoint Exceeded Time", "", AggType::SumOrAvg);
    2706          24 :         AddMonthlyFieldSetInput(state, curReport, "Daylighting Reference Point 1 Daylight Illuminance Setpoint Exceeded Time", "", AggType::SumOrAvg);
    2707          24 :         AddMonthlyFieldSetInput(state, curReport, "Daylighting Reference Point 2 Illuminance", "", AggType::SumOrAverageHoursShown);
    2708          24 :         AddMonthlyFieldSetInput(state, curReport, "Daylighting Reference Point 2 Glare Index", "", AggType::SumOrAverageHoursShown);
    2709          24 :         AddMonthlyFieldSetInput(state, curReport, "Daylighting Reference Point 2 Glare Index Setpoint Exceeded Time", "", AggType::SumOrAvg);
    2710          24 :         AddMonthlyFieldSetInput(state, curReport, "Daylighting Reference Point 2 Daylight Illuminance Setpoint Exceeded Time", "", AggType::SumOrAvg);
    2711             :     }
    2712         730 :     if (ort->namedMonthly(53).show) {
    2713          24 :         curReport = AddMonthlyReport(state, "CoilReportMonthly", 2);
    2714          24 :         AddMonthlyFieldSetInput(state, curReport, "Heating Coil Heating Energy", "", AggType::SumOrAvg);
    2715          24 :         AddMonthlyFieldSetInput(state, curReport, "Heating Coil Heating Rate", "", AggType::Maximum);
    2716          24 :         AddMonthlyFieldSetInput(state, curReport, "Cooling Coil Total Cooling Energy", "", AggType::SumOrAvg);
    2717          24 :         AddMonthlyFieldSetInput(state, curReport, "Cooling Coil Sensible Cooling Energy", "", AggType::SumOrAvg);
    2718          24 :         AddMonthlyFieldSetInput(state, curReport, "Cooling Coil Total Cooling Rate", "", AggType::Maximum);
    2719          24 :         AddMonthlyFieldSetInput(state, curReport, "Cooling Coil Sensible Cooling Rate", "", AggType::ValueWhenMaxMin);
    2720          24 :         AddMonthlyFieldSetInput(state, curReport, "Cooling Coil Wetted Area Fraction", "", AggType::SumOrAvg);
    2721             :     }
    2722         730 :     if (ort->namedMonthly(54).show) {
    2723          24 :         curReport = AddMonthlyReport(state, "PlantLoopDemandReportMonthly", 2);
    2724          24 :         AddMonthlyFieldSetInput(state, curReport, "Plant Supply Side Cooling Demand Rate", "", AggType::SumOrAvg);
    2725          24 :         AddMonthlyFieldSetInput(state, curReport, "Plant Supply Side Cooling Demand Rate", "", AggType::Maximum);
    2726          24 :         AddMonthlyFieldSetInput(state, curReport, "Plant Supply Side Heating Demand Rate", "", AggType::SumOrAvg);
    2727          24 :         AddMonthlyFieldSetInput(state, curReport, "Plant Supply Side Heating Demand Rate", "", AggType::Maximum);
    2728             :     }
    2729         730 :     if (ort->namedMonthly(55).show) {
    2730          24 :         curReport = AddMonthlyReport(state, "FanReportMonthly", 2);
    2731          24 :         AddMonthlyFieldSetInput(state, curReport, "Fan Electricity Energy", "", AggType::SumOrAvg);
    2732          24 :         AddMonthlyFieldSetInput(state, curReport, "Fan Rise in Air Temperature", "", AggType::SumOrAvg);
    2733          24 :         AddMonthlyFieldSetInput(state, curReport, "Fan Electricity Rate", "", AggType::Maximum);
    2734          24 :         AddMonthlyFieldSetInput(state, curReport, "Fan Rise in Air Temperature", "", AggType::ValueWhenMaxMin);
    2735             :     }
    2736         730 :     if (ort->namedMonthly(56).show) {
    2737          24 :         curReport = AddMonthlyReport(state, "PumpReportMonthly", 2);
    2738          24 :         AddMonthlyFieldSetInput(state, curReport, "Pump Electricity Energy", "", AggType::SumOrAvg);
    2739          24 :         AddMonthlyFieldSetInput(state, curReport, "Pump Fluid Heat Gain Energy", "", AggType::SumOrAvg);
    2740          24 :         AddMonthlyFieldSetInput(state, curReport, "Pump Electricity Rate", "", AggType::Maximum);
    2741          24 :         AddMonthlyFieldSetInput(state, curReport, "Pump Shaft Power", "", AggType::ValueWhenMaxMin);
    2742          24 :         AddMonthlyFieldSetInput(state, curReport, "Pump Fluid Heat Gain Rate", "", AggType::ValueWhenMaxMin);
    2743          24 :         AddMonthlyFieldSetInput(state, curReport, "Pump Outlet Temperature", "", AggType::ValueWhenMaxMin);
    2744          24 :         AddMonthlyFieldSetInput(state, curReport, "Pump Mass Flow Rate", "", AggType::ValueWhenMaxMin);
    2745             :     }
    2746         730 :     if (ort->namedMonthly(57).show) {
    2747          24 :         curReport = AddMonthlyReport(state, "CondLoopDemandReportMonthly", 2);
    2748          24 :         AddMonthlyFieldSetInput(state, curReport, "Plant Supply Side Cooling Demand Rate", "", AggType::SumOrAvg);
    2749          24 :         AddMonthlyFieldSetInput(state, curReport, "Plant Supply Side Cooling Demand Rate", "", AggType::Maximum);
    2750          24 :         AddMonthlyFieldSetInput(state, curReport, "Plant Supply Side Inlet Temperature", "", AggType::ValueWhenMaxMin);
    2751          24 :         AddMonthlyFieldSetInput(state, curReport, "Plant Supply Side Outlet Temperature", "", AggType::ValueWhenMaxMin);
    2752          24 :         AddMonthlyFieldSetInput(state, curReport, "Plant Supply Side Heating Demand Rate", "", AggType::SumOrAvg);
    2753          24 :         AddMonthlyFieldSetInput(state, curReport, "Plant Supply Side Heating Demand Rate", "", AggType::Maximum);
    2754             :     }
    2755         730 :     if (ort->namedMonthly(58).show) {
    2756          24 :         curReport = AddMonthlyReport(state, "ZoneTemperatureOscillationReportMonthly", 2);
    2757          24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Oscillating Temperatures Time", "", AggType::HoursNonZero);
    2758          24 :         AddMonthlyFieldSetInput(state, curReport, "Zone People Occupant Count", "", AggType::SumOrAverageHoursShown);
    2759             :     }
    2760         730 :     if (ort->namedMonthly(59).show) {
    2761          24 :         curReport = AddMonthlyReport(state, "AirLoopSystemEnergyAndWaterUseMonthly", 2);
    2762          24 :         AddMonthlyFieldSetInput(state, curReport, "Air System Hot Water Energy", "", AggType::SumOrAvg);
    2763          24 :         AddMonthlyFieldSetInput(state, curReport, "Air System Steam Energy", "", AggType::SumOrAvg);
    2764          24 :         AddMonthlyFieldSetInput(state, curReport, "Air System Chilled Water Energy", "", AggType::SumOrAvg);
    2765          24 :         AddMonthlyFieldSetInput(state, curReport, "Air System Electricity Energy", "", AggType::SumOrAvg);
    2766          24 :         AddMonthlyFieldSetInput(state, curReport, "Air System Natural Gas Energy", "", AggType::SumOrAvg);
    2767          24 :         AddMonthlyFieldSetInput(state, curReport, "Air System Water Volume", "", AggType::SumOrAvg);
    2768             :     }
    2769             : 
    2770         730 :     if (ort->namedMonthly(60).show) {
    2771          24 :         curReport = AddMonthlyReport(state, "AirLoopSystemComponentLoadsMonthly", 2);
    2772          24 :         AddMonthlyFieldSetInput(state, curReport, "Air System Fan Air Heating Energy", "", AggType::SumOrAvg);
    2773          24 :         AddMonthlyFieldSetInput(state, curReport, "Air System Cooling Coil Total Cooling Energy", "", AggType::SumOrAvg);
    2774          24 :         AddMonthlyFieldSetInput(state, curReport, "Air System Heating Coil Total Heating Energy", "", AggType::SumOrAvg);
    2775          24 :         AddMonthlyFieldSetInput(state, curReport, "Air System Heat Exchanger Total Heating Energy", "", AggType::SumOrAvg);
    2776          24 :         AddMonthlyFieldSetInput(state, curReport, "Air System Heat Exchanger Total Cooling Energy", "", AggType::SumOrAvg);
    2777          24 :         AddMonthlyFieldSetInput(state, curReport, "Air System Humidifier Total Heating Energy", "", AggType::SumOrAvg);
    2778          24 :         AddMonthlyFieldSetInput(state, curReport, "Air System Evaporative Cooler Total Cooling Energy", "", AggType::SumOrAvg);
    2779          24 :         AddMonthlyFieldSetInput(state, curReport, "Air System Desiccant Dehumidifier Total Cooling Energy", "", AggType::SumOrAvg);
    2780             :     }
    2781         730 :     if (ort->namedMonthly(61).show) {
    2782          24 :         curReport = AddMonthlyReport(state, "AirLoopSystemComponentEnergyUseMonthly", 2);
    2783          24 :         AddMonthlyFieldSetInput(state, curReport, "Air System Fan Electricity Energy", "", AggType::SumOrAvg);
    2784          24 :         AddMonthlyFieldSetInput(state, curReport, "Air System Heating Coil Hot Water Energy", "", AggType::SumOrAvg);
    2785          24 :         AddMonthlyFieldSetInput(state, curReport, "Air System Cooling Coil Chilled Water Energy", "", AggType::SumOrAvg);
    2786          24 :         AddMonthlyFieldSetInput(state, curReport, "Air System DX Heating Coil Electricity Energy", "", AggType::SumOrAvg);
    2787          24 :         AddMonthlyFieldSetInput(state, curReport, "Air System DX Cooling Coil Electricity Energy", "", AggType::SumOrAvg);
    2788          24 :         AddMonthlyFieldSetInput(state, curReport, "Air System Heating Coil Electricity Energy", "", AggType::SumOrAvg);
    2789          24 :         AddMonthlyFieldSetInput(state, curReport, "Air System Heating Coil Natural Gas Energy", "", AggType::SumOrAvg);
    2790          24 :         AddMonthlyFieldSetInput(state, curReport, "Air System Heating Coil Steam Energy", "", AggType::SumOrAvg);
    2791          24 :         AddMonthlyFieldSetInput(state, curReport, "Air System Humidifier Electricity Energy", "", AggType::SumOrAvg);
    2792          24 :         AddMonthlyFieldSetInput(state, curReport, "Air System Humidifier Natural Gas Energy", "", AggType::SumOrAvg);
    2793          24 :         AddMonthlyFieldSetInput(state, curReport, "Air System Evaporative Cooler Electricity Energy", "", AggType::SumOrAvg);
    2794          24 :         AddMonthlyFieldSetInput(state, curReport, "Air System Desiccant Dehumidifier Electricity Energy", "", AggType::SumOrAvg);
    2795             :     }
    2796         730 :     if (ort->namedMonthly(62).show) {
    2797          24 :         curReport = AddMonthlyReport(state, "MechanicalVentilationLoadsMonthly", 2);
    2798          24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Mechanical Ventilation No Load Heat Removal Energy", "", AggType::SumOrAvg);
    2799          24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Mechanical Ventilation Cooling Load Increase Energy", "", AggType::SumOrAvg);
    2800          24 :         AddMonthlyFieldSetInput(
    2801             :             state, curReport, "Zone Mechanical Ventilation Cooling Load Increase Due to Overheating Energy", "", AggType::SumOrAvg);
    2802          24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Mechanical Ventilation Cooling Load Decrease Energy", "", AggType::SumOrAvg);
    2803          24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Mechanical Ventilation No Load Heat Addition Energy", "", AggType::SumOrAvg);
    2804          24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Mechanical Ventilation Heating Load Increase Energy", "", AggType::SumOrAvg);
    2805          24 :         AddMonthlyFieldSetInput(
    2806             :             state, curReport, "Zone Mechanical Ventilation Heating Load Increase Due to Overcooling Energy", "", AggType::SumOrAvg);
    2807          24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Mechanical Ventilation Heating Load Decrease Energy", "", AggType::SumOrAvg);
    2808          24 :         AddMonthlyFieldSetInput(state, curReport, "Zone Mechanical Ventilation Air Changes per Hour", "", AggType::SumOrAvg);
    2809             :     }
    2810         730 :     if (ort->namedMonthly(63).show) {
    2811          25 :         curReport = AddMonthlyReport(state, "HeatEmissionsReportMonthly", 2);
    2812             :         // Place holder
    2813          25 :         AddMonthlyFieldSetInput(state, curReport, "Site Total Surface Heat Emission to Air", "", AggType::SumOrAvg);
    2814          25 :         AddMonthlyFieldSetInput(state, curReport, "Site Total Zone Exfiltration Heat Loss", "", AggType::SumOrAvg);
    2815          25 :         AddMonthlyFieldSetInput(state, curReport, "Site Total Zone Exhaust Air Heat Loss", "", AggType::SumOrAvg);
    2816          25 :         AddMonthlyFieldSetInput(state, curReport, "Air System Relief Air Total Heat Loss Energy", "", AggType::SumOrAvg);
    2817          25 :         AddMonthlyFieldSetInput(state, curReport, "HVAC System Total Heat Rejection Energy", "", AggType::SumOrAvg);
    2818             :     }
    2819         730 : }
    2820             : 
    2821         769 : void GetInputFuelAndPollutionFactors(EnergyPlusData &state)
    2822             : {
    2823             :     // SUBROUTINE INFORMATION:
    2824             :     //       AUTHOR         Jason Glazer
    2825             :     //       DATE WRITTEN   January 2004
    2826             :     //       MODIFIED       na
    2827             :     //       RE-ENGINEERED  na
    2828             : 
    2829             :     // PURPOSE OF THIS SUBROUTINE:
    2830             :     //   Read the Fuel Factor inputs by the user to
    2831             :     //   get the source energy conversion factors
    2832             :     //   Also reads PolutionCalculationFactors to
    2833             :     //   get information on district cooling and heating
    2834             : 
    2835             :     // METHODOLOGY EMPLOYED:
    2836             :     //   Uses get input structure similar to other objects
    2837             : 
    2838             :     // REFERENCES:
    2839             :     // na
    2840             : 
    2841             :     // Using/Aliasing
    2842             :     using PollutionModule::GetEnvironmentalImpactFactorInfo;
    2843             :     using PollutionModule::GetFuelFactorInfo;
    2844             : 
    2845             :     // Locals
    2846             :     // SUBROUTINE ARGUMENT DEFINITIONS:
    2847             :     // na
    2848             : 
    2849             :     // SUBROUTINE PARAMETER DEFINITIONS:
    2850             :     // na
    2851             : 
    2852             :     // INTERFACE BLOCK SPECIFICATIONS:
    2853             :     // na
    2854             : 
    2855             :     // DERIVED TYPE DEFINITIONS:
    2856             :     // na
    2857             : 
    2858             :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
    2859             :     Real64 curSourceFactor;
    2860             :     bool fuelFactorUsed;
    2861             :     bool fFScheduleUsed;
    2862             :     int ffScheduleIndex;
    2863         769 :     auto &ort(state.dataOutRptTab);
    2864             : 
    2865             :     // set the default factors for source energy - they will be overwritten if the user sets any values
    2866         769 :     ort->sourceFactorElectric = 3.167;
    2867         769 :     ort->sourceFactorNaturalGas = 1.084;
    2868         769 :     ort->sourceFactorSteam = 1.20;
    2869         769 :     ort->sourceFactorGasoline = 1.05;
    2870         769 :     ort->sourceFactorDiesel = 1.05;
    2871         769 :     ort->sourceFactorCoal = 1.05;
    2872         769 :     ort->sourceFactorFuelOil1 = 1.05;
    2873         769 :     ort->sourceFactorFuelOil2 = 1.05;
    2874         769 :     ort->sourceFactorPropane = 1.05;
    2875         769 :     ort->sourceFactorOtherFuel1 = 1.0;
    2876         769 :     ort->sourceFactorOtherFuel2 = 1.0;
    2877             :     // the following should be kept consistent with the assumptions in the pollution calculation routines
    2878         769 :     ort->efficiencyDistrictCooling = 3.0;
    2879         769 :     ort->efficiencyDistrictHeating = 0.3;
    2880             : 
    2881             :     //  TotalSourceEnergyUse = (gatherTotalsSource(1) & !total source from electricity
    2882             :     //                  +  gatherTotalsSource(2)   & !natural gas
    2883             :     //                  + gatherTotalsSource(3)    & !gasoline
    2884             :     //                  + gatherTotalsSource(4)    & !diesel
    2885             :     //                  + gatherTotalsSource(5)    & !coal
    2886             :     //                  + gatherTotalsSource(6)    & !Fuel Oil No1
    2887             :     //                  + gatherTotalsSource(7)    & !Fuel Oil No2
    2888             :     //                  + gatherTotalsSource(8)    &  !propane
    2889             :     //                  + gatherTotalsBEPS(3)*sourceFactorElectric/efficiencyDistrictCooling  & !district cooling
    2890             :     //                  + gatherTotalsBEPS(4)*sourceFactorNaturalGas/efficiencyDistrictHeating  & !district heating
    2891             :     //                  + gatherTotalsBEPS(5)*sourceFactorSteam  & !steam
    2892             :     //                                          ) / largeConversionFactor
    2893             : 
    2894         769 :     GetFuelFactorInfo(state, "NaturalGas", fuelFactorUsed, curSourceFactor, fFScheduleUsed, ffScheduleIndex);
    2895         769 :     if (fuelFactorUsed) {
    2896          76 :         ort->sourceFactorNaturalGas = curSourceFactor;
    2897          76 :         ort->fuelfactorsused(2) = true;
    2898          76 :         ort->ffUsed(2) = true;
    2899             :     }
    2900         769 :     ort->SourceFactors(2) = curSourceFactor;
    2901         769 :     if (fFScheduleUsed) {
    2902           1 :         ort->fuelFactorSchedulesUsed = true;
    2903           1 :         ort->ffSchedUsed(2) = true;
    2904           1 :         ort->ffSchedIndex(2) = ffScheduleIndex;
    2905             :     }
    2906             : 
    2907         769 :     GetFuelFactorInfo(state, "FuelOilNo2", fuelFactorUsed, curSourceFactor, fFScheduleUsed, ffScheduleIndex);
    2908         769 :     if (fuelFactorUsed) {
    2909           0 :         ort->sourceFactorFuelOil2 = curSourceFactor;
    2910           0 :         ort->fuelfactorsused(7) = true;
    2911           0 :         ort->ffUsed(11) = true;
    2912             :     }
    2913         769 :     ort->SourceFactors(11) = curSourceFactor;
    2914         769 :     if (fFScheduleUsed) {
    2915           0 :         ort->fuelFactorSchedulesUsed = true;
    2916           0 :         ort->ffSchedUsed(11) = true;
    2917           0 :         ort->ffSchedIndex(11) = ffScheduleIndex;
    2918             :     }
    2919             : 
    2920         769 :     GetFuelFactorInfo(state, "FuelOilNo1", fuelFactorUsed, curSourceFactor, fFScheduleUsed, ffScheduleIndex);
    2921         769 :     if (fuelFactorUsed) {
    2922          21 :         ort->sourceFactorFuelOil1 = curSourceFactor;
    2923          21 :         ort->fuelfactorsused(6) = true;
    2924          21 :         ort->ffUsed(10) = true;
    2925             :     }
    2926         769 :     ort->SourceFactors(10) = curSourceFactor;
    2927         769 :     if (fFScheduleUsed) {
    2928           0 :         ort->fuelFactorSchedulesUsed = true;
    2929           0 :         ort->ffSchedUsed(10) = true;
    2930           0 :         ort->ffSchedIndex(10) = ffScheduleIndex;
    2931             :     }
    2932             : 
    2933         769 :     GetFuelFactorInfo(state, "Coal", fuelFactorUsed, curSourceFactor, fFScheduleUsed, ffScheduleIndex);
    2934         769 :     if (fuelFactorUsed) {
    2935           0 :         ort->sourceFactorCoal = curSourceFactor;
    2936           0 :         ort->fuelfactorsused(5) = true;
    2937           0 :         ort->ffUsed(9) = true;
    2938             :     }
    2939         769 :     ort->SourceFactors(9) = curSourceFactor;
    2940         769 :     if (fFScheduleUsed) {
    2941           0 :         ort->fuelFactorSchedulesUsed = true;
    2942           0 :         ort->ffSchedUsed(9) = true;
    2943           0 :         ort->ffSchedIndex(9) = ffScheduleIndex;
    2944             :     }
    2945             : 
    2946         769 :     GetFuelFactorInfo(state, "Electricity", fuelFactorUsed, curSourceFactor, fFScheduleUsed, ffScheduleIndex);
    2947         769 :     if (fuelFactorUsed) {
    2948          83 :         ort->sourceFactorElectric = curSourceFactor;
    2949          83 :         ort->fuelfactorsused(1) = true;
    2950          83 :         ort->ffUsed(1) = true;
    2951             :     }
    2952         769 :     ort->SourceFactors(1) = curSourceFactor;
    2953         769 :     if (fFScheduleUsed) {
    2954           1 :         ort->fuelFactorSchedulesUsed = true;
    2955           1 :         ort->ffSchedUsed(1) = true;
    2956           1 :         ort->ffSchedIndex(1) = ffScheduleIndex;
    2957             :     }
    2958             : 
    2959         769 :     GetFuelFactorInfo(state, "Gasoline", fuelFactorUsed, curSourceFactor, fFScheduleUsed, ffScheduleIndex);
    2960         769 :     if (fuelFactorUsed) {
    2961           0 :         ort->sourceFactorGasoline = curSourceFactor;
    2962           0 :         ort->fuelfactorsused(3) = true;
    2963           0 :         ort->ffUsed(6) = true;
    2964             :     }
    2965         769 :     ort->SourceFactors(6) = curSourceFactor;
    2966         769 :     if (fFScheduleUsed) {
    2967           0 :         ort->fuelFactorSchedulesUsed = true;
    2968           0 :         ort->ffSchedUsed(6) = true;
    2969           0 :         ort->ffSchedIndex(6) = ffScheduleIndex;
    2970             :     }
    2971             : 
    2972         769 :     GetFuelFactorInfo(state, "Propane", fuelFactorUsed, curSourceFactor, fFScheduleUsed, ffScheduleIndex);
    2973         769 :     if (fuelFactorUsed) {
    2974          21 :         ort->sourceFactorPropane = curSourceFactor;
    2975          21 :         ort->fuelfactorsused(8) = true;
    2976          21 :         ort->ffUsed(12) = true;
    2977             :     }
    2978         769 :     ort->SourceFactors(12) = curSourceFactor;
    2979         769 :     if (fFScheduleUsed) {
    2980           0 :         ort->fuelFactorSchedulesUsed = true;
    2981           0 :         ort->ffSchedUsed(12) = true;
    2982           0 :         ort->ffSchedIndex(12) = ffScheduleIndex;
    2983             :     }
    2984             : 
    2985         769 :     GetFuelFactorInfo(state, "Diesel", fuelFactorUsed, curSourceFactor, fFScheduleUsed, ffScheduleIndex);
    2986         769 :     if (fuelFactorUsed) {
    2987           2 :         ort->sourceFactorDiesel = curSourceFactor;
    2988           2 :         ort->fuelfactorsused(4) = true;
    2989           2 :         ort->ffUsed(8) = true;
    2990             :     }
    2991         769 :     ort->SourceFactors(8) = curSourceFactor;
    2992         769 :     if (fFScheduleUsed) {
    2993           0 :         ort->fuelFactorSchedulesUsed = true;
    2994           0 :         ort->ffSchedUsed(8) = true;
    2995           0 :         ort->ffSchedIndex(8) = ffScheduleIndex;
    2996             :     }
    2997             : 
    2998         769 :     GetFuelFactorInfo(state, "DistrictCooling", fuelFactorUsed, curSourceFactor, fFScheduleUsed, ffScheduleIndex);
    2999         769 :     if (fuelFactorUsed) {
    3000          83 :         ort->ffUsed(3) = true;
    3001             :     }
    3002         769 :     ort->SourceFactors(3) = curSourceFactor;
    3003         769 :     if (fFScheduleUsed) {
    3004           1 :         ort->ffSchedUsed(3) = true;
    3005           1 :         ort->ffSchedIndex(3) = ffScheduleIndex;
    3006             :     }
    3007             : 
    3008         769 :     GetFuelFactorInfo(state, "DistrictHeating", fuelFactorUsed, curSourceFactor, fFScheduleUsed, ffScheduleIndex);
    3009         769 :     if (fuelFactorUsed) {
    3010          76 :         ort->ffUsed(4) = true;
    3011             :     }
    3012         769 :     ort->SourceFactors(4) = curSourceFactor;
    3013         769 :     if (fFScheduleUsed) {
    3014           1 :         ort->ffSchedUsed(4) = true;
    3015           1 :         ort->ffSchedIndex(4) = ffScheduleIndex;
    3016             :     }
    3017             : 
    3018         769 :     GetFuelFactorInfo(state, "Steam", fuelFactorUsed, curSourceFactor, fFScheduleUsed, ffScheduleIndex);
    3019         769 :     if (fuelFactorUsed) {
    3020           0 :         ort->ffUsed(5) = true;
    3021             :     }
    3022         769 :     ort->SourceFactors(5) = curSourceFactor;
    3023         769 :     if (fFScheduleUsed) {
    3024           0 :         ort->ffSchedUsed(5) = true;
    3025           0 :         ort->ffSchedIndex(5) = ffScheduleIndex;
    3026             :     }
    3027             : 
    3028         769 :     GetFuelFactorInfo(state, "OtherFuel1", fuelFactorUsed, curSourceFactor, fFScheduleUsed, ffScheduleIndex);
    3029         769 :     if (fuelFactorUsed) {
    3030           1 :         ort->sourceFactorOtherFuel1 = curSourceFactor;
    3031           1 :         ort->fuelfactorsused(11) = true; // should be source number
    3032           1 :         ort->ffUsed(13) = true;
    3033             :     }
    3034         769 :     ort->SourceFactors(13) = curSourceFactor;
    3035         769 :     if (fFScheduleUsed) {
    3036           0 :         ort->fuelFactorSchedulesUsed = true;
    3037           0 :         ort->ffSchedUsed(13) = true;
    3038           0 :         ort->ffSchedIndex(13) = ffScheduleIndex;
    3039             :     }
    3040             : 
    3041         769 :     GetFuelFactorInfo(state, "OtherFuel2", fuelFactorUsed, curSourceFactor, fFScheduleUsed, ffScheduleIndex);
    3042         769 :     if (fuelFactorUsed) {
    3043           0 :         ort->sourceFactorOtherFuel2 = curSourceFactor;
    3044           0 :         ort->fuelfactorsused(12) = true; // should be source number
    3045           0 :         ort->ffUsed(14) = true;
    3046             :     }
    3047         769 :     ort->SourceFactors(14) = curSourceFactor;
    3048         769 :     if (fFScheduleUsed) {
    3049           0 :         ort->fuelFactorSchedulesUsed = true;
    3050           0 :         ort->ffSchedUsed(14) = true;
    3051           0 :         ort->ffSchedIndex(14) = ffScheduleIndex;
    3052             :     }
    3053             : 
    3054         769 :     GetEnvironmentalImpactFactorInfo(state, ort->efficiencyDistrictHeating, ort->efficiencyDistrictCooling, ort->sourceFactorSteam);
    3055         769 : }
    3056             : 
    3057             : //======================================================================================================================
    3058             : //======================================================================================================================
    3059             : 
    3060             : //    OTHER INITIALIZATION ROUTINES
    3061             : 
    3062             : //======================================================================================================================
    3063             : //======================================================================================================================
    3064             : 
    3065         769 : void OpenOutputTabularFile(EnergyPlusData &state)
    3066             : {
    3067             :     // SUBROUTINE INFORMATION:
    3068             :     //       AUTHOR         Jason Glazer
    3069             :     //       DATE WRITTEN   July 2003
    3070             :     //       MODIFIED       na
    3071             :     //       RE-ENGINEERED  na
    3072             : 
    3073             :     // PURPOSE OF THIS SUBROUTINE:
    3074             :     //   Create a file that holds the output from the tabular reports
    3075             :     //   the output is in a CSV file if it is comma delimited otherwise
    3076             :     //   it is in a TXT file.
    3077             : 
    3078             :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
    3079             :     int iStyle;
    3080        1538 :     std::string curDel;
    3081         769 :     auto &ort(state.dataOutRptTab);
    3082             : 
    3083             :     // get a new file unit number
    3084             :     // create a file to hold the results
    3085             :     // Use a CSV file if comma separated but otherwise use TXT file
    3086             :     // extension.
    3087         769 :     if (ort->WriteTabularFiles && state.files.outputControl.tabular) {
    3088        1559 :         for (iStyle = 1; iStyle <= ort->numStyles; ++iStyle) {
    3089         828 :             curDel = ort->del(iStyle);
    3090         828 :             if (ort->TableStyle(iStyle) == TableStyle::Comma) {
    3091          50 :                 DisplayString(state, "Writing tabular output file results using comma format.");
    3092             :                 std::ofstream &tbl_stream =
    3093          50 :                     open_tbl_stream(state, iStyle, state.dataStrGlobals->outputTblCsvFilePath, state.files.outputControl.tabular);
    3094          50 :                 tbl_stream << "Program Version:" << curDel << state.dataStrGlobals->VerStringVar << '\n';
    3095          50 :                 tbl_stream << "Tabular Output Report in Format: " << curDel << "Comma\n";
    3096          50 :                 tbl_stream << '\n';
    3097          50 :                 tbl_stream << "Building:" << curDel << state.dataHeatBal->BuildingName << '\n';
    3098          50 :                 if (state.dataEnvrn->EnvironmentName == state.dataEnvrn->WeatherFileLocationTitle) {
    3099           0 :                     tbl_stream << "Environment:" << curDel << state.dataEnvrn->EnvironmentName << '\n';
    3100             :                 } else {
    3101         100 :                     tbl_stream << "Environment:" << curDel << state.dataEnvrn->EnvironmentName << " ** " << state.dataEnvrn->WeatherFileLocationTitle
    3102         150 :                                << '\n';
    3103             :                 }
    3104          50 :                 tbl_stream << '\n';
    3105         778 :             } else if (ort->TableStyle(iStyle) == TableStyle::Tab) {
    3106          22 :                 DisplayString(state, "Writing tabular output file results using tab format.");
    3107             :                 std::ofstream &tbl_stream =
    3108          22 :                     open_tbl_stream(state, iStyle, state.dataStrGlobals->outputTblTabFilePath, state.files.outputControl.tabular);
    3109          22 :                 tbl_stream << "Program Version" << curDel << state.dataStrGlobals->VerStringVar << '\n';
    3110          22 :                 tbl_stream << "Tabular Output Report in Format: " << curDel << "Tab\n";
    3111          22 :                 tbl_stream << '\n';
    3112          22 :                 tbl_stream << "Building:" << curDel << state.dataHeatBal->BuildingName << '\n';
    3113          22 :                 if (state.dataEnvrn->EnvironmentName == state.dataEnvrn->WeatherFileLocationTitle) {
    3114           0 :                     tbl_stream << "Environment:" << curDel << state.dataEnvrn->EnvironmentName << '\n';
    3115             :                 } else {
    3116          44 :                     tbl_stream << "Environment:" << curDel << state.dataEnvrn->EnvironmentName << " ** " << state.dataEnvrn->WeatherFileLocationTitle
    3117          66 :                                << '\n';
    3118             :                 }
    3119          22 :                 tbl_stream << '\n';
    3120         756 :             } else if (ort->TableStyle(iStyle) == TableStyle::HTML) {
    3121         721 :                 DisplayString(state, "Writing tabular output file results using HTML format.");
    3122             :                 std::ofstream &tbl_stream =
    3123         721 :                     open_tbl_stream(state, iStyle, state.dataStrGlobals->outputTblHtmFilePath, state.files.outputControl.tabular);
    3124         721 :                 tbl_stream << "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"\"http://www.w3.org/TR/html4/loose.dtd\">\n";
    3125         721 :                 tbl_stream << "<html>\n";
    3126         721 :                 tbl_stream << "<head>\n";
    3127         721 :                 if (state.dataEnvrn->EnvironmentName == state.dataEnvrn->WeatherFileLocationTitle) {
    3128           0 :                     tbl_stream << "<title> " << state.dataHeatBal->BuildingName << ' ' << state.dataEnvrn->EnvironmentName << '\n';
    3129             :                 } else {
    3130        1442 :                     tbl_stream << "<title> " << state.dataHeatBal->BuildingName << ' ' << state.dataEnvrn->EnvironmentName << " ** "
    3131        2163 :                                << state.dataEnvrn->WeatherFileLocationTitle << '\n';
    3132             :                 }
    3133         721 :                 tbl_stream << "  " << std::setw(4) << ort->td(1) << '-' << std::setfill('0') << std::setw(2) << ort->td(2) << '-' << std::setw(2)
    3134         721 :                            << ort->td(3) << '\n';
    3135         721 :                 tbl_stream << "  " << std::setw(2) << ort->td(5) << ':' << std::setw(2) << ort->td(6) << ':' << std::setw(2) << ort->td(7)
    3136         721 :                            << std::setfill(' ') << '\n';
    3137         721 :                 tbl_stream << " - EnergyPlus</title>\n";
    3138         721 :                 tbl_stream << "</head>\n";
    3139         721 :                 tbl_stream << "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">\n";
    3140         721 :                 tbl_stream << "<body>\n";
    3141         721 :                 tbl_stream << "<p><a href=\"#toc\" style=\"float: right\">Table of Contents</a></p>\n";
    3142         721 :                 tbl_stream << "<a name=top></a>\n";
    3143         721 :                 tbl_stream << "<p>Program Version:<b>" << state.dataStrGlobals->VerStringVar << "</b></p>\n";
    3144         721 :                 tbl_stream << "<p>Tabular Output Report in Format: <b>HTML</b></p>\n";
    3145         721 :                 tbl_stream << "<p>Building: <b>" << state.dataHeatBal->BuildingName << "</b></p>\n";
    3146         721 :                 if (state.dataEnvrn->EnvironmentName == state.dataEnvrn->WeatherFileLocationTitle) {
    3147           0 :                     tbl_stream << "<p>Environment: <b>" << ConvertToEscaped(state.dataEnvrn->EnvironmentName, false) << "</b></p>\n";
    3148             :                 } else {
    3149        1442 :                     tbl_stream << "<p>Environment: <b>" << ConvertToEscaped(state.dataEnvrn->EnvironmentName, false) << " ** "
    3150        1442 :                                << ConvertToEscaped(state.dataEnvrn->WeatherFileLocationTitle, false) << "</b></p>\n";
    3151             :                 }
    3152         721 :                 tbl_stream << "<p>Simulation Timestamp: <b>" << std::setw(4) << ort->td(1) << '-' << std::setfill('0') << std::setw(2) << ort->td(2)
    3153         721 :                            << '-' << std::setw(2) << ort->td(3) << '\n';
    3154         721 :                 tbl_stream << "  " << std::setw(2) << ort->td(5) << ':' << std::setw(2) << ort->td(6) << ':' << std::setw(2) << ort->td(7)
    3155         721 :                            << std::setfill(' ') << "</b></p>\n";
    3156          35 :             } else if (ort->TableStyle(iStyle) == TableStyle::XML) {
    3157          18 :                 DisplayString(state, "Writing tabular output file results using XML format.");
    3158             :                 std::ofstream &tbl_stream =
    3159          18 :                     open_tbl_stream(state, iStyle, state.dataStrGlobals->outputTblXmlFilePath, state.files.outputControl.tabular);
    3160          18 :                 tbl_stream << "<?xml version=\"1.0\"?>\n";
    3161          18 :                 tbl_stream << "<EnergyPlusTabularReports>\n";
    3162          18 :                 tbl_stream << "  <state.dataHeatBal->BuildingName>" << state.dataHeatBal->BuildingName << "</state.dataHeatBal->BuildingName>\n";
    3163          18 :                 tbl_stream << "  <EnvironmentName>" << state.dataEnvrn->EnvironmentName << "</EnvironmentName>\n";
    3164          18 :                 tbl_stream << "  <WeatherFileLocationTitle>" << state.dataEnvrn->WeatherFileLocationTitle << "</WeatherFileLocationTitle>\n";
    3165          18 :                 tbl_stream << "  <ProgramVersion>" << state.dataStrGlobals->VerStringVar << "</ProgramVersion>\n";
    3166          18 :                 tbl_stream << "  <SimulationTimestamp>\n";
    3167          18 :                 tbl_stream << "    <Date>\n";
    3168          18 :                 tbl_stream << "      " << std::setw(4) << ort->td(1) << '-' << std::setfill('0') << std::setw(2) << ort->td(2) << '-' << std::setw(2)
    3169          18 :                            << ort->td(3) << '\n';
    3170          18 :                 tbl_stream << "    </Date>\n";
    3171          18 :                 tbl_stream << "    <Time>\n";
    3172          18 :                 tbl_stream << "      " << std::setw(2) << ort->td(5) << ':' << std::setw(2) << ort->td(6) << ':' << std::setw(2) << ort->td(7)
    3173          18 :                            << std::setfill(' ') << '\n';
    3174          18 :                 tbl_stream << "    </Time>\n";
    3175          18 :                 tbl_stream << "  </SimulationTimestamp>\n";
    3176          18 :                 tbl_stream << '\n';
    3177             :             } else {
    3178          17 :                 DisplayString(state, "Writing tabular output file results using text format.");
    3179             :                 std::ofstream &tbl_stream =
    3180          17 :                     open_tbl_stream(state, iStyle, state.dataStrGlobals->outputTblTxtFilePath, state.files.outputControl.tabular);
    3181          17 :                 tbl_stream << "Program Version: " << state.dataStrGlobals->VerStringVar << '\n';
    3182          17 :                 tbl_stream << "Tabular Output Report in Format: " << curDel << "Fixed\n";
    3183          17 :                 tbl_stream << '\n';
    3184          17 :                 tbl_stream << "Building:        " << state.dataHeatBal->BuildingName << '\n';
    3185          17 :                 if (state.dataEnvrn->EnvironmentName == state.dataEnvrn->WeatherFileLocationTitle) {
    3186           0 :                     tbl_stream << "Environment:     " << state.dataEnvrn->EnvironmentName << '\n';
    3187             :                 } else {
    3188          34 :                     tbl_stream << "Environment:     " << state.dataEnvrn->EnvironmentName << " ** " << state.dataEnvrn->WeatherFileLocationTitle
    3189          51 :                                << '\n';
    3190             :                 }
    3191          17 :                 tbl_stream << '\n';
    3192             :             }
    3193             :         }
    3194             :     }
    3195         769 : }
    3196             : 
    3197         769 : void CloseOutputTabularFile(EnergyPlusData &state)
    3198             : {
    3199             :     // SUBROUTINE INFORMATION:
    3200             :     //       AUTHOR         Jason Glazer
    3201             :     //       DATE WRITTEN   July 2003
    3202             :     //       MODIFIED       na
    3203             :     //       RE-ENGINEERED  na
    3204             : 
    3205             :     // PURPOSE OF THIS SUBROUTINE:
    3206             :     //   Create a file that holds the output from the tabular reports
    3207             :     //   the output is in a CSV file if it is comma delimited otherwise
    3208             :     //   it is in a TXT file.
    3209             : 
    3210             :     // METHODOLOGY EMPLOYED:
    3211             :     //   Uses get input structure similar to other objects
    3212             : 
    3213             :     // REFERENCES:
    3214             :     // na
    3215             : 
    3216             :     // USE STATEMENTS:
    3217             :     // na
    3218             : 
    3219             :     // Locals
    3220             :     // SUBROUTINE ARGUMENT DEFINITIONS:
    3221             :     // na
    3222             : 
    3223             :     // SUBROUTINE PARAMETER DEFINITIONS:
    3224             : 
    3225             :     // INTERFACE BLOCK SPECIFICATIONS:
    3226             :     // na
    3227             : 
    3228             :     // DERIVED TYPE DEFINITIONS:
    3229             :     // na
    3230             : 
    3231             :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
    3232             :     int iStyle;
    3233         769 :     auto &ort(state.dataOutRptTab);
    3234             : 
    3235         769 :     if (ort->WriteTabularFiles) {
    3236        1559 :         for (iStyle = 1; iStyle <= ort->numStyles; ++iStyle) {
    3237         828 :             std::ofstream &tbl_stream(*ort->TabularOutputFile(iStyle));
    3238         828 :             if (ort->TableStyle(iStyle) == TableStyle::HTML) { // if HTML file put ending info
    3239         721 :                 tbl_stream << "</body>\n";
    3240         721 :                 tbl_stream << "</html>\n";
    3241         107 :             } else if (ort->TableStyle(iStyle) == TableStyle::XML) {
    3242          18 :                 if (!ort->prevReportName.empty()) {
    3243          18 :                     tbl_stream << "</" << ort->prevReportName << ">\n"; // close the last element if it was used.
    3244             :                 }
    3245          18 :                 tbl_stream << "</EnergyPlusTabularReports>\n";
    3246             :             }
    3247         828 :             tbl_stream.close();
    3248             :         }
    3249             :     }
    3250         769 : }
    3251             : 
    3252         731 : void WriteTableOfContents(EnergyPlusData &state)
    3253             : {
    3254             :     // SUBROUTINE INFORMATION:
    3255             :     //       AUTHOR         Jason Glazer
    3256             :     //       DATE WRITTEN   June 2005
    3257             :     //       MODIFIED       na
    3258             :     //       RE-ENGINEERED  na
    3259             : 
    3260             :     // PURPOSE OF THIS SUBROUTINE:
    3261             :     //   Creates hyperlinks for table of contents
    3262             : 
    3263             :     // METHODOLOGY EMPLOYED:
    3264             :     //   Go through the reports and create links
    3265             : 
    3266             :     // SUBROUTINE PARAMETER DEFINITIONS:
    3267         731 :     static std::string const Entire_Facility("Entire Facility");
    3268         731 :     static std::string const Annual_Building_Utility_Performance_Summary("Annual Building Utility Performance Summary");
    3269         731 :     static std::string const Input_Verification_and_Results_Summary("Input Verification and Results Summary");
    3270         731 :     static std::string const Demand_End_Use_Components_Summary("Demand End Use Components Summary");
    3271         731 :     static std::string const Source_Energy_End_Use_Components_Summary("Source Energy End Use Components Summary");
    3272         731 :     static std::string const Component_Cost_Economics_Summary("Component Cost Economics Summary");
    3273         731 :     static std::string const Component_Sizing_Summary("Component Sizing Summary");
    3274         731 :     static std::string const Surface_Shadowing_Summary("Surface Shadowing Summary");
    3275         731 :     static std::string const Adaptive_Comfort_Summary("Adaptive Comfort Summary");
    3276         731 :     static std::string const Initialization_Summary("Initialization Summary");
    3277         731 :     static std::string const Annual_Heat_Emissions_Summary("Annual Heat Emissions Summary");
    3278         731 :     static std::string const Annual_Thermal_Resilience_Summary("Annual Thermal Resilience Summary");
    3279         731 :     static std::string const Annual_CO2_Resilience_Summary("Annual CO2 Resilience Summary");
    3280         731 :     static std::string const Annual_Visual_Resilience_Summary("Annual Visual Resilience Summary");
    3281             : 
    3282             :     // INTERFACE BLOCK SPECIFICATIONS:
    3283             :     // na
    3284             : 
    3285             :     // DERIVED TYPE DEFINITIONS:
    3286             :     // na
    3287             : 
    3288             :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
    3289             :     int iInput;
    3290             :     int jTable;
    3291             :     int curTable;
    3292             :     int iEntry;
    3293             :     int jEntry;
    3294             :     int kReport;
    3295        1462 :     std::string curSection;
    3296             :     int iStyle;
    3297        1462 :     std::string origName;
    3298        1462 :     std::string curName;
    3299             :     int indexUnitConv;
    3300         731 :     auto &ort(state.dataOutRptTab);
    3301             : 
    3302             :     // normally do not add to the table of contents here but the order of calls is different for the life-cycle costs
    3303         731 :     if (ort->displayLifeCycleCostReport && state.dataEconLifeCycleCost->LCCparamPresent) {
    3304           1 :         AddTOCEntry(state, "Life-Cycle Cost Report", "Entire Facility");
    3305             :     }
    3306             : 
    3307        1559 :     for (iStyle = 1; iStyle <= ort->numStyles; ++iStyle) {
    3308         828 :         if (ort->TableStyle(iStyle) == TableStyle::HTML) {
    3309         721 :             std::ostream &tbl_stream(*ort->TabularOutputFile(iStyle));
    3310         721 :             tbl_stream << "<hr>\n";
    3311         721 :             tbl_stream << "<a name=toc></a>\n";
    3312         721 :             tbl_stream << "<p><b>Table of Contents</b></p>\n";
    3313         721 :             tbl_stream << "<a href=\"#top\">Top</a>\n";
    3314         721 :             if (ort->displayTabularBEPS) {
    3315        1440 :                 tbl_stream << "<br><a href=\"#" << MakeAnchorName(Annual_Building_Utility_Performance_Summary, Entire_Facility)
    3316        1440 :                            << "\">Annual Building Utility Performance Summary</a>\n";
    3317             :             }
    3318         721 :             if (ort->displayTabularVeriSum) {
    3319        1422 :                 tbl_stream << "<br><a href=\"#" << MakeAnchorName(Input_Verification_and_Results_Summary, Entire_Facility)
    3320        1422 :                            << "\">Input Verification and Results Summary</a>\n";
    3321             :             }
    3322         721 :             if (ort->displayDemandEndUse) {
    3323        1292 :                 tbl_stream << "<br><a href=\"#" << MakeAnchorName(Demand_End_Use_Components_Summary, Entire_Facility)
    3324        1292 :                            << "\">Demand End Use Components Summary</a>\n";
    3325             :             }
    3326         721 :             if (ort->displaySourceEnergyEndUseSummary) {
    3327        1286 :                 tbl_stream << "<br><a href=\"#" << MakeAnchorName(Source_Energy_End_Use_Components_Summary, Entire_Facility)
    3328        1286 :                            << "\">Source Energy End Use Components Summary</a>\n";
    3329             :             }
    3330         721 :             if (state.dataCostEstimateManager->DoCostEstimate) {
    3331          76 :                 tbl_stream << "<br><a href=\"#" << MakeAnchorName(Component_Cost_Economics_Summary, Entire_Facility)
    3332          76 :                            << "\">Component Cost Economics Summary</a>\n";
    3333             :             }
    3334         721 :             if (ort->displayComponentSizing) {
    3335         701 :                 tbl_stream << "<br><a href=\"#" << MakeAnchorName(Component_Sizing_Summary, Entire_Facility) << "\">Component Sizing Summary</a>\n";
    3336             :             }
    3337         721 :             if (ort->displaySurfaceShadowing) {
    3338         643 :                 tbl_stream << "<br><a href=\"#" << MakeAnchorName(Surface_Shadowing_Summary, Entire_Facility) << "\">Surface Shadowing Summary</a>\n";
    3339             :             }
    3340         721 :             if (ort->displayAdaptiveComfort) {
    3341         643 :                 tbl_stream << "<br><a href=\"#" << MakeAnchorName(Adaptive_Comfort_Summary, Entire_Facility) << "\">Adaptive Comfort Summary</a>\n";
    3342             :             }
    3343         721 :             if (ort->displayEioSummary) {
    3344         644 :                 tbl_stream << "<br><a href=\"#" << MakeAnchorName(Initialization_Summary, Entire_Facility) << "\">Initialization Summary</a>\n";
    3345             :             }
    3346         721 :             if (ort->displayHeatEmissionsSummary) {
    3347        1288 :                 tbl_stream << "<br><a href=\"#" << MakeAnchorName(Annual_Heat_Emissions_Summary, Entire_Facility)
    3348        1288 :                            << "\">Annual Heat Emissions Summary</a>\n";
    3349             :             }
    3350         721 :             if (ort->displayThermalResilienceSummary) {
    3351        1292 :                 tbl_stream << "<br><a href=\"#" << MakeAnchorName(Annual_Thermal_Resilience_Summary, Entire_Facility)
    3352        1292 :                            << "\">Annual Thermal Resilience Summary</a>\n";
    3353             :             }
    3354             :             //                if (displayCO2ResilienceSummary) {
    3355             :             //                    tbl_stream << "<br><a href=\"#" << MakeAnchorName(Annual_CO2_Resilience_Summary, Entire_Facility)
    3356             :             //                               << "\">Annual CO2 Resilience Summary</a>\n";
    3357             :             //                }
    3358             :             //                if (displayVisualResilienceSummary) {
    3359             :             //                    tbl_stream << "<br><a href=\"#" << MakeAnchorName(Annual_Visual_Resilience_Summary, Entire_Facility)
    3360             :             //                               << "\">Annual Visual Resilience Summary</a>\n";
    3361             :             //                }
    3362       12656 :             for (kReport = 1; kReport <= state.dataOutRptPredefined->numReportName; ++kReport) {
    3363       11935 :                 if (state.dataOutRptPredefined->reportName(kReport).show) {
    3364       21886 :                     tbl_stream << "<br><a href=\"#" << MakeAnchorName(state.dataOutRptPredefined->reportName(kReport).namewithspaces, Entire_Facility)
    3365       21886 :                                << "\">" << state.dataOutRptPredefined->reportName(kReport).namewithspaces << "</a>\n";
    3366             :                 }
    3367             :             }
    3368         721 :             if (state.dataGlobal->DoWeathSim) {
    3369           2 :                 for (iInput = 1; iInput <= ort->MonthlyInputCount; ++iInput) {
    3370           0 :                     if (ort->MonthlyInput(iInput).numTables > 0) {
    3371           0 :                         tbl_stream << "<p><b>" << ort->MonthlyInput(iInput).name << "</b></p> |\n";
    3372           0 :                         for (jTable = 1; jTable <= ort->MonthlyInput(iInput).numTables; ++jTable) {
    3373           0 :                             curTable = jTable + ort->MonthlyInput(iInput).firstTable - 1;
    3374           0 :                             tbl_stream << "<a href=\"#" << MakeAnchorName(ort->MonthlyInput(iInput).name, ort->MonthlyTables(curTable).keyValue)
    3375           0 :                                        << "\">" << ort->MonthlyTables(curTable).keyValue << "</a>    |   \n";
    3376             :                         }
    3377             :                     }
    3378             :                 }
    3379           2 :                 for (iInput = 1; iInput <= ort->OutputTableBinnedCount; ++iInput) {
    3380           0 :                     if (ort->OutputTableBinned(iInput).numTables > 0) {
    3381           0 :                         if (ort->OutputTableBinned(iInput).scheduleIndex == 0) {
    3382           0 :                             tbl_stream << "<p><b>" << ort->OutputTableBinned(iInput).varOrMeter << "</b></p> |\n";
    3383             :                         } else {
    3384           0 :                             tbl_stream << "<p><b>" << ort->OutputTableBinned(iInput).varOrMeter << " [" << ort->OutputTableBinned(iInput).ScheduleName
    3385           0 :                                        << "]</b></p> |\n";
    3386             :                         }
    3387           0 :                         for (jTable = 1; jTable <= ort->OutputTableBinned(iInput).numTables; ++jTable) {
    3388           0 :                             curTable = ort->OutputTableBinned(iInput).resIndex + (jTable - 1);
    3389           0 :                             curName = "";
    3390           0 :                             if (ort->unitsStyle == UnitsStyle::InchPound) {
    3391           0 :                                 origName = ort->OutputTableBinned(iInput).varOrMeter + unitEnumToStringBrackets(ort->OutputTableBinned(iInput).units);
    3392           0 :                                 LookupSItoIP(state, origName, indexUnitConv, curName);
    3393             :                             } else {
    3394           0 :                                 curName = ort->OutputTableBinned(iInput).varOrMeter + unitEnumToStringBrackets(ort->OutputTableBinned(iInput).units);
    3395             :                             }
    3396           0 :                             if (ort->OutputTableBinned(iInput).scheduleIndex == 0) {
    3397           0 :                                 tbl_stream << "<a href=\"#" << MakeAnchorName(curName, ort->BinObjVarID(curTable).namesOfObj) << "\">"
    3398           0 :                                            << ort->BinObjVarID(curTable).namesOfObj << "</a>   |  \n";
    3399             :                             } else {
    3400             :                                 tbl_stream << "<a href=\"#"
    3401           0 :                                            << MakeAnchorName(curName + ort->OutputTableBinned(iInput).ScheduleName,
    3402           0 :                                                              ort->BinObjVarID(curTable).namesOfObj)
    3403           0 :                                            << "\">" << ort->BinObjVarID(curTable).namesOfObj << "</a>   |  \n";
    3404             :                             }
    3405             :                         }
    3406             :                     }
    3407             :                 }
    3408           2 :                 OutputReportTabularAnnual::AddAnnualTableOfContents(state, tbl_stream);
    3409             :             }
    3410             :             // add entries specifically added using AddTOCEntry
    3411         952 :             for (iEntry = 1; iEntry <= ort->TOCEntriesCount; ++iEntry) {
    3412         231 :                 if (!ort->TOCEntries(iEntry).isWritten) {
    3413          82 :                     curSection = ort->TOCEntries(iEntry).sectionName;
    3414          82 :                     tbl_stream << "<p><b>" << curSection << "</b></p> |\n";
    3415         346 :                     for (jEntry = iEntry; jEntry <= ort->TOCEntriesCount; ++jEntry) {
    3416         264 :                         if (!ort->TOCEntries(jEntry).isWritten) {
    3417         264 :                             if (ort->TOCEntries(jEntry).sectionName == curSection) {
    3418         462 :                                 tbl_stream << "<a href=\"#" << MakeAnchorName(ort->TOCEntries(jEntry).sectionName, ort->TOCEntries(jEntry).reportName)
    3419         462 :                                            << "\">" << ort->TOCEntries(jEntry).reportName << "</a>   |  \n";
    3420         231 :                                 ort->TOCEntries(jEntry).isWritten = true;
    3421             :                             }
    3422             :                         }
    3423             :                     }
    3424             :                 }
    3425             :             }
    3426             : 
    3427         721 :             if (state.dataWeatherManager->TotReportPers > 0) {
    3428           8 :                 std::string ReportPeriodSummary = "Reporting Period Summary";
    3429           8 :                 tbl_stream << "<br><a href=\"#" << MakeAnchorName(ReportPeriodSummary, Entire_Facility) << "\">"
    3430             :                            << "Reporting Period Summary"
    3431           8 :                            << "</a>\n";
    3432           8 :                 AddTOCReportPeriod(
    3433           8 :                     state.dataWeatherManager->TotThermalReportPers, "Thermal", state.dataWeatherManager->ThermalReportPeriodInput, tbl_stream);
    3434           4 :                 AddTOCReportPeriod(state.dataWeatherManager->TotCO2ReportPers, "CO2", state.dataWeatherManager->CO2ReportPeriodInput, tbl_stream);
    3435           8 :                 AddTOCReportPeriod(
    3436           8 :                     state.dataWeatherManager->TotVisualReportPers, "Visual", state.dataWeatherManager->VisualReportPeriodInput, tbl_stream);
    3437             :             }
    3438             :         }
    3439             :     }
    3440         731 : }
    3441             : 
    3442          12 : void AddTOCReportPeriod(const int nReportPeriods,
    3443             :                         const std::string kw,
    3444             :                         const Array1D<WeatherManager::ReportPeriodData> &ReportPeriodInputData,
    3445             :                         std::ostream &tbl_stream)
    3446             : {
    3447          12 :     static std::string const Entire_Facility("Entire Facility");
    3448          23 :     for (int i = 1; i <= nReportPeriods; i++) {
    3449             :         std::string ReportPeriod_Resilience_Summary = fmt::format(
    3450          33 :             "{} Resilience Summary for Reporting Period {}: {}", kw, i, ReportPeriodInputData(i).title, ReportPeriodInputData(i).totalElectricityUse);
    3451          22 :         tbl_stream << "<br><a href=\"#" << MakeAnchorName(ReportPeriod_Resilience_Summary, Entire_Facility) << "\">" << kw
    3452          22 :                    << " Resilience Summary for Reporting Period " << i << ": " << ReportPeriodInputData(i).title << "</a>\n";
    3453             :     }
    3454          12 : }
    3455             : 
    3456             : //======================================================================================================================
    3457             : //======================================================================================================================
    3458             : 
    3459             : //    GATHER DATA EACH TIME STEP ROUTINES
    3460             : 
    3461             : //======================================================================================================================
    3462             : //======================================================================================================================
    3463             : 
    3464      161715 : void GatherBinResultsForTimestep(EnergyPlusData &state, OutputProcessor::TimeStepType t_timeStepType) // What kind of data to update (Zone, HVAC)
    3465             : {
    3466             :     // SUBROUTINE INFORMATION:
    3467             :     //       AUTHOR         Jason Glazer
    3468             :     //       DATE WRITTEN   August 2003
    3469             :     //       MODIFIED       na
    3470             :     //       RE-ENGINEERED  na
    3471             : 
    3472             :     // PURPOSE OF THIS SUBROUTINE:
    3473             :     //   Gathers the data each timesetp and adds the length of the
    3474             :     //   timestep to the appropriate bin.
    3475             : 
    3476             :     // Using/Aliasing
    3477      161715 :     auto &TimeStepSys = state.dataHVACGlobal->TimeStepSys;
    3478             :     using ScheduleManager::GetCurrentScheduleValue;
    3479             : 
    3480             :     // Locals
    3481             :     // SUBROUTINE ARGUMENT DEFINITIONS:
    3482             : 
    3483             :     // SUBROUTINE PARAMETER DEFINITIONS:
    3484             :     // na
    3485             : 
    3486             :     // INTERFACE BLOCK SPECIFICATIONS:
    3487             :     // na
    3488             : 
    3489             :     // DERIVED TYPE DEFINITIONS:
    3490             :     // na
    3491             : 
    3492             :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
    3493             :     int iInObj;
    3494             :     int jTable;
    3495             :     Real64 curValue;
    3496             :     // values of OutputTableBinned array for current index
    3497             :     Real64 curIntervalStart;
    3498             :     Real64 curIntervalSize;
    3499             :     int curIntervalCount;
    3500             :     int curResIndex;
    3501             :     int curNumTables;
    3502             :     OutputProcessor::VariableType curTypeOfVar;
    3503             :     int curScheduleIndex;
    3504             :     Real64 elapsedTime;
    3505             :     bool gatherThisTime;
    3506             :     Real64 topValue;
    3507             :     int binNum;
    3508             :     int repIndex;
    3509             :     OutputProcessor::TimeStepType curStepType;
    3510      161715 :     auto &ort(state.dataOutRptTab);
    3511             : 
    3512      161715 :     if (!state.dataGlobal->DoWeathSim) return;
    3513      161715 :     elapsedTime = TimeStepSys;
    3514      161715 :     ort->timeInYear += elapsedTime;
    3515      161715 :     for (iInObj = 1; iInObj <= ort->OutputTableBinnedCount; ++iInObj) {
    3516             :         // get values of array for current object being referenced
    3517           0 :         curIntervalStart = ort->OutputTableBinned(iInObj).intervalStart;
    3518           0 :         curIntervalSize = ort->OutputTableBinned(iInObj).intervalSize;
    3519           0 :         curIntervalCount = ort->OutputTableBinned(iInObj).intervalCount;
    3520           0 :         curResIndex = ort->OutputTableBinned(iInObj).resIndex;
    3521           0 :         curNumTables = ort->OutputTableBinned(iInObj).numTables;
    3522           0 :         topValue = curIntervalStart + curIntervalSize * curIntervalCount;
    3523           0 :         curTypeOfVar = ort->OutputTableBinned(iInObj).typeOfVar;
    3524           0 :         curStepType = ort->OutputTableBinned(iInObj).stepType;
    3525           0 :         curScheduleIndex = ort->OutputTableBinned(iInObj).scheduleIndex;
    3526             :         // if a schedule was used, check if it was non-zero value
    3527           0 :         if (curScheduleIndex != 0) {
    3528           0 :             if (GetCurrentScheduleValue(state, curScheduleIndex) != 0.0) {
    3529           0 :                 gatherThisTime = true;
    3530             :             } else {
    3531           0 :                 gatherThisTime = false;
    3532             :             }
    3533             :         } else {
    3534           0 :             gatherThisTime = true;
    3535             :         }
    3536           0 :         if (gatherThisTime) {
    3537           0 :             for (jTable = 1; jTable <= curNumTables; ++jTable) {
    3538           0 :                 repIndex = curResIndex + (jTable - 1);
    3539           0 :                 if (((curStepType == OutputProcessor::TimeStepType::Zone) && (t_timeStepType == OutputProcessor::TimeStepType::Zone)) ||
    3540           0 :                     ((curStepType == OutputProcessor::TimeStepType::System) && (t_timeStepType == OutputProcessor::TimeStepType::System))) {
    3541             :                     // put actual value from OutputProcesser arrays
    3542           0 :                     curValue = GetInternalVariableValue(state, curTypeOfVar, ort->BinObjVarID(repIndex).varMeterNum);
    3543             :                     // per MJW when a summed variable is used divide it by the length of the time step
    3544           0 :                     if (t_timeStepType == OutputProcessor::TimeStepType::System) {
    3545           0 :                         elapsedTime = TimeStepSys;
    3546             :                     } else {
    3547           0 :                         elapsedTime = state.dataGlobal->TimeStepZone;
    3548             :                     }
    3549           0 :                     if (ort->OutputTableBinned(iInObj).avgSum == OutputProcessor::StoreType::Summed) { // if it is a summed variable
    3550           0 :                         curValue /= (elapsedTime * DataGlobalConstants::SecInHour);
    3551             :                     }
    3552             :                     // round the value to the number of signficant digits used in the final output report
    3553           0 :                     if (curIntervalSize < 1) {
    3554           0 :                         curValue = round(curValue * 10000.0) / 10000.0; // four significant digits
    3555           0 :                     } else if (curIntervalSize >= 10) {
    3556           0 :                         curValue = round(curValue); // zero significant digits
    3557             :                     } else {
    3558           0 :                         curValue = round(curValue * 100.0) / 100.0; // two significant digits
    3559             :                     }
    3560             :                     // check if the value is above the maximum or below the minimum value
    3561             :                     // first before binning the value within the range.
    3562           0 :                     if (curValue < curIntervalStart) {
    3563           0 :                         ort->BinResultsBelow(repIndex).mnth(state.dataEnvrn->Month) += elapsedTime;
    3564           0 :                         ort->BinResultsBelow(repIndex).hrly(state.dataGlobal->HourOfDay) += elapsedTime;
    3565           0 :                     } else if (curValue >= topValue) {
    3566           0 :                         ort->BinResultsAbove(repIndex).mnth(state.dataEnvrn->Month) += elapsedTime;
    3567           0 :                         ort->BinResultsAbove(repIndex).hrly(state.dataGlobal->HourOfDay) += elapsedTime;
    3568             :                     } else {
    3569             :                         // determine which bin the results are in
    3570           0 :                         binNum = int((curValue - curIntervalStart) / curIntervalSize) + 1;
    3571           0 :                         ort->BinResults(binNum, repIndex).mnth(state.dataEnvrn->Month) += elapsedTime;
    3572           0 :                         ort->BinResults(binNum, repIndex).hrly(state.dataGlobal->HourOfDay) += elapsedTime;
    3573             :                     }
    3574             :                     // add to statistics array
    3575           0 :                     ++ort->BinStatistics(repIndex).n;
    3576           0 :                     ort->BinStatistics(repIndex).sum += curValue;
    3577           0 :                     ort->BinStatistics(repIndex).sum2 += curValue * curValue;
    3578           0 :                     if (curValue < ort->BinStatistics(repIndex).minimum) {
    3579           0 :                         ort->BinStatistics(repIndex).minimum = curValue;
    3580             :                     }
    3581           0 :                     if (curValue > ort->BinStatistics(repIndex).maximum) {
    3582           0 :                         ort->BinStatistics(repIndex).maximum = curValue;
    3583             :                     }
    3584             :                 }
    3585             :             }
    3586             :         }
    3587             :     }
    3588             : }
    3589             : 
    3590      161715 : void GatherMonthlyResultsForTimestep(EnergyPlusData &state, OutputProcessor::TimeStepType t_timeStepType) // What kind of data to update (Zone, HVAC)
    3591             : {
    3592             :     // SUBROUTINE INFORMATION:
    3593             :     //       AUTHOR         Jason Glazer
    3594             :     //       DATE WRITTEN   September 2003
    3595             :     //       MODIFIED       na
    3596             :     //       RE-ENGINEERED  na
    3597             : 
    3598             :     // PURPOSE OF THIS SUBROUTINE:
    3599             :     //   Gathers the data each timestep and updates the arrays
    3600             :     //   holding the data that will be reported later.
    3601             : 
    3602             :     // Using/Aliasing
    3603      161715 :     auto &TimeStepSys = state.dataHVACGlobal->TimeStepSys;
    3604             :     using General::DetermineMinuteForReporting;
    3605             :     using General::EncodeMonDayHrMin;
    3606             : 
    3607             :     // Locals
    3608             :     // SUBROUTINE ARGUMENT DEFINITIONS:
    3609             : 
    3610             :     // SUBROUTINE PARAMETER DEFINITIONS:
    3611             :     // na
    3612             : 
    3613             :     // INTERFACE BLOCK SPECIFICATIONS:
    3614             :     // na
    3615             : 
    3616             :     // DERIVED TYPE DEFINITIONS:
    3617             :     // na
    3618             : 
    3619             :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
    3620             :     int iTable;  // loop variable for monthlyTables
    3621             :     int jColumn; // loop variable for monthlyColumns
    3622             :     int curCol;
    3623             :     Real64 curValue;
    3624             :     OutputProcessor::VariableType curTypeOfVar;
    3625             :     int curVarNum;
    3626             :     Real64 elapsedTime;
    3627             :     Real64 oldResultValue;
    3628             :     int oldTimeStamp;
    3629             :     Real64 oldDuration;
    3630             :     Real64 newResultValue;
    3631             :     int newTimeStamp;
    3632             :     Real64 newDuration;
    3633             :     int timestepTimeStamp;
    3634             :     bool activeMinMax;
    3635             :     // LOGICAL,SAVE  :: activeHoursShown=.FALSE.  !fix by LKL addressing CR6482
    3636             :     bool activeHoursShown;
    3637             :     bool activeNewValue;
    3638             :     OutputProcessor::TimeStepType curStepType;
    3639             :     int minuteCalculated;
    3640             :     int kOtherColumn; // variable used in loop to scan through additional columns
    3641             :     int scanColumn;
    3642             :     Real64 scanValue;
    3643             :     OutputProcessor::VariableType scanTypeOfVar;
    3644             :     int scanVarNum;
    3645             :     Real64 oldScanValue;
    3646             :     // local copies of some of the MonthlyColumns array references since
    3647             :     // profiling showed that they were slow.
    3648             : 
    3649      161715 :     if (!state.dataGlobal->DoWeathSim) return;
    3650      161715 :     auto &ort(state.dataOutRptTab);
    3651      161715 :     assert(state.dataGlobal->TimeStepZoneSec > 0.0);
    3652             : 
    3653             :     // create temporary arrays to speed processing of these arrays
    3654      161715 :     if (ort->GatherMonthlyResultsForTimestepRunOnce) {
    3655             :         // MonthlyColumns
    3656           2 :         state.dataOutRptTab->MonthlyColumnsTypeOfVar.allocate(ort->MonthlyColumns.I());
    3657           2 :         state.dataOutRptTab->MonthlyColumnsStepType.allocate(ort->MonthlyColumns.I());
    3658           2 :         state.dataOutRptTab->MonthlyColumnsAggType.allocate(ort->MonthlyColumns.I());
    3659           2 :         state.dataOutRptTab->MonthlyColumnsVarNum.allocate(ort->MonthlyColumns.I());
    3660           2 :         for (int i = ort->MonthlyColumns.l(), e = ort->MonthlyColumns.u(); i <= e; ++i) {
    3661           0 :             auto const &col(ort->MonthlyColumns(i));
    3662           0 :             state.dataOutRptTab->MonthlyColumnsTypeOfVar(i) = col.typeOfVar;
    3663           0 :             state.dataOutRptTab->MonthlyColumnsStepType(i) = col.stepType;
    3664           0 :             state.dataOutRptTab->MonthlyColumnsAggType(i) = col.aggType;
    3665           0 :             state.dataOutRptTab->MonthlyColumnsVarNum(i) = col.varNum;
    3666             :         }
    3667             : 
    3668             :         // MonthlyTables
    3669           2 :         state.dataOutRptTab->MonthlyTablesNumColumns.allocate(ort->MonthlyTables.I());
    3670           2 :         for (int i = ort->MonthlyTables.l(), e = ort->MonthlyTables.u(); i <= e; ++i) {
    3671           0 :             state.dataOutRptTab->MonthlyTablesNumColumns(i) = ort->MonthlyTables(i).numColumns;
    3672             :         }
    3673             : 
    3674             :         // set flag so this block is only executed once
    3675           2 :         ort->GatherMonthlyResultsForTimestepRunOnce = false;
    3676             :     }
    3677             : 
    3678      161715 :     elapsedTime = TimeStepSys;
    3679      161715 :     if (t_timeStepType == OutputProcessor::TimeStepType::System) {
    3680       91539 :         elapsedTime = TimeStepSys;
    3681             :     } else {
    3682       70176 :         elapsedTime = state.dataGlobal->TimeStepZone;
    3683             :     }
    3684      161715 :     ort->IsMonthGathered(state.dataEnvrn->Month) = true;
    3685      161715 :     for (iTable = 1; iTable <= ort->MonthlyTablesCount; ++iTable) {
    3686           0 :         activeMinMax = false;     // at the beginning of the new timestep
    3687           0 :         activeHoursShown = false; // fix by JG addressing CR6482
    3688           0 :         state.dataOutRptTab->curFirstColumn = ort->MonthlyTables(iTable).firstColumn;
    3689           0 :         for (jColumn = 1; jColumn <= state.dataOutRptTab->MonthlyTablesNumColumns(iTable); ++jColumn) {
    3690           0 :             curCol = jColumn + state.dataOutRptTab->curFirstColumn - 1;
    3691           0 :             curTypeOfVar = state.dataOutRptTab->MonthlyColumnsTypeOfVar(curCol);
    3692           0 :             curStepType = state.dataOutRptTab->MonthlyColumnsStepType(curCol);
    3693           0 :             if (((curStepType == OutputProcessor::TimeStepType::Zone) && (t_timeStepType == OutputProcessor::TimeStepType::Zone)) ||
    3694           0 :                 ((curStepType == OutputProcessor::TimeStepType::System) && (t_timeStepType == OutputProcessor::TimeStepType::System))) {
    3695             :                 //  the above condition used to include the following prior to new scan method
    3696             :                 //  (MonthlyColumns(curCol)%aggType .EQ. AggType::ValueWhenMaxMin)
    3697           0 :                 curVarNum = state.dataOutRptTab->MonthlyColumnsVarNum(curCol);
    3698           0 :                 curValue = GetInternalVariableValue(state, curTypeOfVar, curVarNum);
    3699             :                 // Get the value from the result array
    3700           0 :                 oldResultValue = ort->MonthlyColumns(curCol).reslt(state.dataEnvrn->Month);
    3701           0 :                 oldTimeStamp = ort->MonthlyColumns(curCol).timeStamp(state.dataEnvrn->Month);
    3702           0 :                 oldDuration = ort->MonthlyColumns(curCol).duration(state.dataEnvrn->Month);
    3703             :                 // Zero the revised values (as default if not set later in SELECT)
    3704           0 :                 newResultValue = 0.0;
    3705           0 :                 newTimeStamp = 0;
    3706           0 :                 newDuration = 0.0;
    3707           0 :                 activeNewValue = false;
    3708             :                 // the current timestamp
    3709           0 :                 minuteCalculated = DetermineMinuteForReporting(state, t_timeStepType);
    3710             :                 //      minuteCalculated = (CurrentTime - INT(CurrentTime))*60
    3711             :                 //      IF (t_timeStepType .EQ. OutputProcessor::TimeStepType::TimeStepSystem) minuteCalculated = minuteCalculated +
    3712             :                 //      SysTimeElapsed * 60 minuteCalculated = INT((TimeStep-1) * TimeStepZone * 60) + INT((SysTimeElapsed + TimeStepSys) * 60)
    3713           0 :                 EncodeMonDayHrMin(
    3714           0 :                     timestepTimeStamp, state.dataEnvrn->Month, state.dataEnvrn->DayOfMonth, state.dataGlobal->HourOfDay, minuteCalculated);
    3715             :                 // perform the selected aggregation type
    3716             :                 // use next lines since it is faster was: SELECT CASE (MonthlyColumns(curCol)%aggType)
    3717           0 :                 switch (state.dataOutRptTab->MonthlyColumnsAggType(curCol)) {
    3718           0 :                 case AggType::SumOrAvg: {
    3719           0 :                     if (ort->MonthlyColumns(curCol).avgSum == OutputProcessor::StoreType::Summed) { // if it is a summed variable
    3720           0 :                         newResultValue = oldResultValue + curValue;
    3721             :                     } else {
    3722           0 :                         newResultValue = oldResultValue + curValue * elapsedTime; // for averaging - weight by elapsed time
    3723             :                     }
    3724           0 :                     newDuration = oldDuration + elapsedTime;
    3725           0 :                     activeNewValue = true;
    3726           0 :                 } break;
    3727           0 :                 case AggType::Maximum: {
    3728             :                     // per MJW when a summed variable is used divide it by the length of the time step
    3729           0 :                     if (ort->MonthlyColumns(curCol).avgSum == OutputProcessor::StoreType::Summed) { // if it is a summed variable
    3730           0 :                         if (t_timeStepType == OutputProcessor::TimeStepType::System) {
    3731           0 :                             curValue /= (TimeStepSys * DataGlobalConstants::SecInHour);
    3732             :                         } else {
    3733           0 :                             curValue /= state.dataGlobal->TimeStepZoneSec;
    3734             :                         }
    3735             :                     }
    3736           0 :                     if (curValue > oldResultValue) {
    3737           0 :                         newResultValue = curValue;
    3738           0 :                         newTimeStamp = timestepTimeStamp;
    3739           0 :                         activeMinMax = true;
    3740           0 :                         activeNewValue = true;
    3741             :                     } else {
    3742           0 :                         activeMinMax = false; // reset this
    3743             :                     }
    3744           0 :                 } break;
    3745           0 :                 case AggType::Minimum: {
    3746             :                     // per MJW when a summed variable is used divide it by the length of the time step
    3747           0 :                     if (ort->MonthlyColumns(curCol).avgSum == OutputProcessor::StoreType::Summed) { // if it is a summed variable
    3748           0 :                         if (t_timeStepType == OutputProcessor::TimeStepType::System) {
    3749           0 :                             curValue /= (TimeStepSys * DataGlobalConstants::SecInHour);
    3750             :                         } else {
    3751           0 :                             curValue /= state.dataGlobal->TimeStepZoneSec;
    3752             :                         }
    3753             :                     }
    3754           0 :                     if (curValue < oldResultValue) {
    3755           0 :                         newResultValue = curValue;
    3756           0 :                         newTimeStamp = timestepTimeStamp;
    3757           0 :                         activeMinMax = true;
    3758           0 :                         activeNewValue = true;
    3759             :                     } else {
    3760           0 :                         activeMinMax = false; // reset this
    3761             :                     }
    3762           0 :                 } break;
    3763           0 :                 case AggType::HoursZero: {
    3764           0 :                     if (curValue == 0) {
    3765           0 :                         newResultValue = oldResultValue + elapsedTime;
    3766           0 :                         activeHoursShown = true;
    3767           0 :                         activeNewValue = true;
    3768             :                     } else {
    3769           0 :                         activeHoursShown = false;
    3770             :                     }
    3771           0 :                 } break;
    3772           0 :                 case AggType::HoursNonZero: {
    3773           0 :                     if (curValue != 0) {
    3774           0 :                         newResultValue = oldResultValue + elapsedTime;
    3775           0 :                         activeHoursShown = true;
    3776           0 :                         activeNewValue = true;
    3777             :                     } else {
    3778           0 :                         activeHoursShown = false;
    3779             :                     }
    3780           0 :                 } break;
    3781           0 :                 case AggType::HoursPositive: {
    3782           0 :                     if (curValue > 0) {
    3783           0 :                         newResultValue = oldResultValue + elapsedTime;
    3784           0 :                         activeHoursShown = true;
    3785           0 :                         activeNewValue = true;
    3786             :                     } else {
    3787           0 :                         activeHoursShown = false;
    3788             :                     }
    3789           0 :                 } break;
    3790           0 :                 case AggType::HoursNonPositive: {
    3791           0 :                     if (curValue <= 0) {
    3792           0 :                         newResultValue = oldResultValue + elapsedTime;
    3793           0 :                         activeHoursShown = true;
    3794           0 :                         activeNewValue = true;
    3795             :                     } else {
    3796           0 :                         activeHoursShown = false;
    3797             :                     }
    3798           0 :                 } break;
    3799           0 :                 case AggType::HoursNegative: {
    3800           0 :                     if (curValue < 0) {
    3801           0 :                         newResultValue = oldResultValue + elapsedTime;
    3802           0 :                         activeHoursShown = true;
    3803           0 :                         activeNewValue = true;
    3804             :                     } else {
    3805           0 :                         activeHoursShown = false;
    3806             :                     }
    3807           0 :                 } break;
    3808           0 :                 case AggType::HoursNonNegative: {
    3809           0 :                     if (curValue >= 0) {
    3810           0 :                         newResultValue = oldResultValue + elapsedTime;
    3811           0 :                         activeHoursShown = true;
    3812           0 :                         activeNewValue = true;
    3813             :                     } else {
    3814           0 :                         activeHoursShown = false;
    3815             :                     }
    3816             :                     // The valueWhenMaxMin is picked up now during the activeMinMax if block below.
    3817             :                     // CASE (iAggType::ValueWhenMaxMin)
    3818             :                     // CASE (iAggType::SumOrAverageHoursShown)
    3819             :                     // CASE (iAggType::MaximumDuringHoursShown)
    3820             :                     // CASE (iAggType::MinimumDuringHoursShown)
    3821           0 :                 } break;
    3822           0 :                 default:
    3823           0 :                     break;
    3824             :                 }
    3825             :                 // if the new value has been set then set the monthly values to the
    3826             :                 // new columns. This skips the aggregation types that don't even get
    3827             :                 // triggered now such as valueWhenMinMax and all the agg*HoursShown
    3828           0 :                 if (activeNewValue) {
    3829           0 :                     ort->MonthlyColumns(curCol).reslt(state.dataEnvrn->Month) = newResultValue;
    3830           0 :                     ort->MonthlyColumns(curCol).timeStamp(state.dataEnvrn->Month) = newTimeStamp;
    3831           0 :                     ort->MonthlyColumns(curCol).duration(state.dataEnvrn->Month) = newDuration;
    3832             :                 }
    3833             :                 // if a minimum or maximum value was set this timeStep then
    3834             :                 // scan the remaining columns of the table looking for values
    3835             :                 // that are aggregation type "ValueWhenMaxMin" and set their values
    3836             :                 // if another minimum or maximum column is found then end
    3837             :                 // the scan (it will be taken care of when that column is done)
    3838           0 :                 if (activeMinMax) {
    3839           0 :                     for (kOtherColumn = jColumn + 1; kOtherColumn <= ort->MonthlyTables(iTable).numColumns; ++kOtherColumn) {
    3840           0 :                         scanColumn = kOtherColumn + ort->MonthlyTables(iTable).firstColumn - 1;
    3841           0 :                         switch (ort->MonthlyColumns(scanColumn).aggType) {
    3842           0 :                         case AggType::Maximum:
    3843             :                         case AggType::Minimum:
    3844             :                             // end scanning since these might reset
    3845           0 :                             break; // do
    3846           0 :                         case AggType::ValueWhenMaxMin: {
    3847             :                             // this case is when the value should be set
    3848           0 :                             scanTypeOfVar = ort->MonthlyColumns(scanColumn).typeOfVar;
    3849           0 :                             scanVarNum = ort->MonthlyColumns(scanColumn).varNum;
    3850           0 :                             scanValue = GetInternalVariableValue(state, scanTypeOfVar, scanVarNum);
    3851             :                             // When a summed variable is used divide it by the length of the time step
    3852           0 :                             if (ort->MonthlyColumns(scanColumn).avgSum == OutputProcessor::StoreType::Summed) { // if it is a summed variable
    3853           0 :                                 if (t_timeStepType == OutputProcessor::TimeStepType::System) {
    3854           0 :                                     scanValue /= (TimeStepSys * DataGlobalConstants::SecInHour);
    3855             :                                 } else {
    3856           0 :                                     scanValue /= state.dataGlobal->TimeStepZoneSec;
    3857             :                                 }
    3858             :                             }
    3859           0 :                             ort->MonthlyColumns(scanColumn).reslt(state.dataEnvrn->Month) = scanValue;
    3860           0 :                         } break;
    3861           0 :                         default:
    3862           0 :                             break;
    3863             :                         }
    3864             :                     }
    3865             :                 }
    3866             :                 // If the hours variable is active then scan through the rest of the variables
    3867             :                 // and accumulate
    3868           0 :                 if (activeHoursShown) {
    3869           0 :                     for (kOtherColumn = jColumn + 1; kOtherColumn <= ort->MonthlyTables(iTable).numColumns; ++kOtherColumn) {
    3870           0 :                         scanColumn = kOtherColumn + ort->MonthlyTables(iTable).firstColumn - 1;
    3871           0 :                         scanTypeOfVar = ort->MonthlyColumns(scanColumn).typeOfVar;
    3872           0 :                         scanVarNum = ort->MonthlyColumns(scanColumn).varNum;
    3873           0 :                         scanValue = GetInternalVariableValue(state, scanTypeOfVar, scanVarNum);
    3874           0 :                         oldScanValue = ort->MonthlyColumns(scanColumn).reslt(state.dataEnvrn->Month);
    3875           0 :                         switch (ort->MonthlyColumns(scanColumn).aggType) {
    3876           0 :                         case AggType::HoursZero:
    3877             :                         case AggType::HoursNonZero:
    3878             :                         case AggType::HoursPositive:
    3879             :                         case AggType::HoursNonPositive:
    3880             :                         case AggType::HoursNegative:
    3881             :                         case AggType::HoursNonNegative:
    3882             :                             // end scanning since these might reset
    3883           0 :                             break; // do
    3884           0 :                         case AggType::SumOrAverageHoursShown: {
    3885             :                             // this case is when the value should be set
    3886           0 :                             if (ort->MonthlyColumns(scanColumn).avgSum == OutputProcessor::StoreType::Summed) { // if it is a summed variable
    3887           0 :                                 ort->MonthlyColumns(scanColumn).reslt(state.dataEnvrn->Month) = oldScanValue + scanValue;
    3888             :                             } else {
    3889             :                                 // for averaging - weight by elapsed time
    3890           0 :                                 ort->MonthlyColumns(scanColumn).reslt(state.dataEnvrn->Month) = oldScanValue + scanValue * elapsedTime;
    3891             :                             }
    3892           0 :                             ort->MonthlyColumns(scanColumn).duration(state.dataEnvrn->Month) += elapsedTime;
    3893           0 :                         } break;
    3894           0 :                         case AggType::MaximumDuringHoursShown: {
    3895           0 :                             if (ort->MonthlyColumns(scanColumn).avgSum == OutputProcessor::StoreType::Summed) { // if it is a summed variable
    3896           0 :                                 if (t_timeStepType == OutputProcessor::TimeStepType::System) {
    3897           0 :                                     scanValue /= (TimeStepSys * DataGlobalConstants::SecInHour);
    3898             :                                 } else {
    3899           0 :                                     scanValue /= state.dataGlobal->TimeStepZoneSec;
    3900             :                                 }
    3901             :                             }
    3902           0 :                             if (scanValue > oldScanValue) {
    3903           0 :                                 ort->MonthlyColumns(scanColumn).reslt(state.dataEnvrn->Month) = scanValue;
    3904           0 :                                 ort->MonthlyColumns(scanColumn).timeStamp(state.dataEnvrn->Month) = timestepTimeStamp;
    3905             :                             }
    3906           0 :                         } break;
    3907           0 :                         case AggType::MinimumDuringHoursShown: {
    3908           0 :                             if (ort->MonthlyColumns(scanColumn).avgSum == OutputProcessor::StoreType::Summed) { // if it is a summed variable
    3909           0 :                                 if (t_timeStepType == OutputProcessor::TimeStepType::System) {
    3910           0 :                                     scanValue /= (TimeStepSys * DataGlobalConstants::SecInHour);
    3911             :                                 } else {
    3912           0 :                                     scanValue /= state.dataGlobal->TimeStepZoneSec;
    3913             :                                 }
    3914             :                             }
    3915           0 :                             if (scanValue < oldScanValue) {
    3916           0 :                                 ort->MonthlyColumns(scanColumn).reslt(state.dataEnvrn->Month) = scanValue;
    3917           0 :                                 ort->MonthlyColumns(scanColumn).timeStamp(state.dataEnvrn->Month) = timestepTimeStamp;
    3918             :                             }
    3919           0 :                         } break;
    3920           0 :                         default:
    3921           0 :                             break;
    3922             :                         }
    3923           0 :                         activeHoursShown = false; // fixed CR8317
    3924             :                     }
    3925             :                 }
    3926             :             }
    3927             :         }
    3928             :     }
    3929             : }
    3930             : 
    3931      161715 : void GatherBEPSResultsForTimestep(EnergyPlusData &state, OutputProcessor::TimeStepType t_timeStepType) // What kind of data to update (Zone, HVAC)
    3932             : {
    3933             :     // SUBROUTINE INFORMATION:
    3934             :     //       AUTHOR         Jason Glazer
    3935             :     //       DATE WRITTEN   November 2003
    3936             :     //       MODIFIED       na
    3937             :     //       RE-ENGINEERED  na
    3938             : 
    3939             :     // PURPOSE OF THIS SUBROUTINE:
    3940             :     //   This routine gathers data for producing the BEPS report
    3941             : 
    3942             :     // METHODOLOGY EMPLOYED:
    3943             :     //   Uses get input structure similar to other objects
    3944             :     //   Meter names are of two forms:
    3945             :     //         <ResourceType>:<name>
    3946             :     //   or
    3947             :     //         <EndUseType>:<ResourceType>
    3948             :     //   For the purposes of this routine, only the facility <name>
    3949             :     //   is used.  Remember that 'Building' is actually the sum of
    3950             :     //   the zones only without system,plant and exterior. The only
    3951             :     //   way to get them all is to use 'facility'
    3952             :     //   The <EndUseType> are:
    3953             :     //          Heating
    3954             :     //          Cooling
    3955             :     //          InteriorLights
    3956             :     //          ExteriorLights
    3957             :     //          InteriorEquipment
    3958             :     //          ExteriorEquipment
    3959             :     //          Fans
    3960             :     //          Pumps
    3961             :     //          HeatRejection
    3962             :     //          Humidifier
    3963             :     //          HeatRecovery
    3964             :     //          DHW
    3965             :     //          Refrigeration
    3966             :     //          Cogeneration
    3967             :     //   The <ResourceType> are:
    3968             :     //          Electricity
    3969             :     //          Gas
    3970             :     //          Gasoline
    3971             :     //          Diesel
    3972             :     //          Coal
    3973             :     //          FuelOilNo1
    3974             :     //          FuelOilNo2
    3975             :     //          Propane
    3976             :     //          Water
    3977             :     //          Steam
    3978             :     //          DistrictCooling
    3979             :     //          DistrictHeating
    3980             : 
    3981             :     using DataStringGlobals::CharComma;
    3982             :     using DataStringGlobals::CharSpace;
    3983             :     using DataStringGlobals::CharTab;
    3984             : 
    3985      161715 :     auto &ort(state.dataOutRptTab);
    3986             : 
    3987             :     // if no beps report is called then skip
    3988             : 
    3989      161715 :     if ((ort->displayTabularBEPS || ort->displayLEEDSummary) && (t_timeStepType == OutputProcessor::TimeStepType::Zone)) {
    3990             :         // add the current time to the total elapsed time
    3991             :         // FOLLOWING LINE MOVED TO UPDATETABULARREPORTS because used even when beps is not called
    3992             :         // gatherElapsedTimeBEPS = gatherElapsedTimeBEPS + TimeStepZone
    3993             :         // loop through all of the resource types for the entire facility
    3994             :         //  DO iResource = 1, numResourceTypes
    3995             :         //    curMeterNumber = meterNumTotalsBEPS(iResource)
    3996             :         //    IF (curMeterNumber .GT. 0) THEN
    3997             :         //      curMeterValue = GetCurrentMeterValue(curMeterNumber)
    3998             :         //      gatherTotalsBEPS(iResource) = gatherTotalsBEPS(iResource) + curMeterValue
    3999             :         //    END IF
    4000             :         //  END DO
    4001             : 
    4002             :         // loop through all of the resources and end uses for the entire facility
    4003     1052640 :         for (int iResource = 1; iResource <= numResourceTypes; ++iResource) {
    4004      982464 :             int curResMeterNumber = ort->meterNumTotalsBEPS(iResource);
    4005      982464 :             if (curResMeterNumber > 0) {
    4006      140352 :                 Real64 curResMeterValue = GetCurrentMeterValue(state, curResMeterNumber);
    4007      140352 :                 ort->gatherTotalsBEPS(iResource) += curResMeterValue;
    4008             :             }
    4009             : 
    4010    14736960 :             for (int jEndUse = 1; jEndUse <= DataGlobalConstantsData::iEndUseSize; ++jEndUse) {
    4011    13754496 :                 int curEndUseMeterNumber = ort->meterNumEndUseBEPS(iResource, jEndUse);
    4012    13754496 :                 if (curEndUseMeterNumber > 0) {
    4013      491232 :                     Real64 curEndUseMeterValue = GetCurrentMeterValue(state, curEndUseMeterNumber);
    4014      491232 :                     ort->gatherEndUseBEPS(iResource, jEndUse) += curEndUseMeterValue;
    4015             : 
    4016     1263168 :                     for (int kEndUseSub = 1; kEndUseSub <= state.dataOutputProcessor->EndUseCategory(jEndUse).NumSubcategories; ++kEndUseSub) {
    4017      771936 :                         int curSubMeterNumber = ort->meterNumEndUseSubBEPS(kEndUseSub, jEndUse, iResource);
    4018      771936 :                         if (curSubMeterNumber > 0) {
    4019      491232 :                             Real64 curSubMeterValue = GetCurrentMeterValue(state, curSubMeterNumber);
    4020      491232 :                             ort->gatherEndUseSubBEPS(kEndUseSub, jEndUse, iResource) += curSubMeterValue;
    4021             :                         }
    4022             :                     }
    4023      631584 :                     for (int kEndUseSpType = 1; kEndUseSpType <= state.dataOutputProcessor->EndUseCategory(jEndUse).numSpaceTypes; ++kEndUseSpType) {
    4024      140352 :                         int curSpTypeMeterNumber = ort->meterNumEndUseSpTypeBEPS(kEndUseSpType, jEndUse, iResource);
    4025      140352 :                         if (curSpTypeMeterNumber > 0) {
    4026      140352 :                             Real64 curSpTypeMeterValue = GetCurrentMeterValue(state, curSpTypeMeterNumber);
    4027      140352 :                             ort->gatherEndUseSpTypeBEPS(kEndUseSpType, jEndUse, iResource) += curSpTypeMeterValue;
    4028             :                         }
    4029             :                     }
    4030             :                 }
    4031             :             }
    4032             :         }
    4033             : 
    4034      912288 :         for (int iResource = 1; iResource <= numSourceTypes; ++iResource) {
    4035      842112 :             int curResMeterNumber = ort->meterNumTotalsSource(iResource);
    4036      842112 :             if (curResMeterNumber > 0) {
    4037           0 :                 Real64 curResMeterValue = GetCurrentMeterValue(state, curResMeterNumber);
    4038           0 :                 ort->gatherTotalsSource(iResource) += curResMeterValue;
    4039             :             }
    4040             :         }
    4041             : 
    4042             :         // gather the electric load components
    4043       70176 :         ort->gatherPowerFuelFireGen += GetCurrentMeterValue(state, ort->meterNumPowerFuelFireGen);
    4044       70176 :         ort->gatherPowerPV += GetCurrentMeterValue(state, ort->meterNumPowerPV);
    4045       70176 :         ort->gatherPowerWind += GetCurrentMeterValue(state, ort->meterNumPowerWind);
    4046       70176 :         ort->gatherPowerHTGeothermal += GetCurrentMeterValue(state, ort->meterNumPowerHTGeothermal);
    4047       70176 :         ort->gatherElecProduced += GetCurrentMeterValue(state, ort->meterNumElecProduced);
    4048       70176 :         ort->gatherElecPurchased += GetCurrentMeterValue(state, ort->meterNumElecPurchased);
    4049       70176 :         ort->gatherElecSurplusSold += GetCurrentMeterValue(state, ort->meterNumElecSurplusSold);
    4050       70176 :         ort->gatherElecStorage += GetCurrentMeterValue(state, ort->meterNumElecStorage);
    4051       70176 :         ort->gatherPowerConversion += GetCurrentMeterValue(state, ort->meterNumPowerConversion);
    4052             :         // gather the onsite thermal components
    4053       70176 :         ort->gatherWaterHeatRecovery += GetCurrentMeterValue(state, ort->meterNumWaterHeatRecovery);
    4054       70176 :         ort->gatherAirHeatRecoveryCool += GetCurrentMeterValue(state, ort->meterNumAirHeatRecoveryCool);
    4055       70176 :         ort->gatherAirHeatRecoveryHeat += GetCurrentMeterValue(state, ort->meterNumAirHeatRecoveryHeat);
    4056       70176 :         ort->gatherHeatHTGeothermal += GetCurrentMeterValue(state, ort->meterNumHeatHTGeothermal);
    4057       70176 :         ort->gatherHeatSolarWater += GetCurrentMeterValue(state, ort->meterNumHeatSolarWater);
    4058       70176 :         ort->gatherHeatSolarAir += GetCurrentMeterValue(state, ort->meterNumHeatSolarAir);
    4059             :         // gather the water supply components
    4060       70176 :         ort->gatherRainWater += GetCurrentMeterValue(state, ort->meterNumRainWater);
    4061       70176 :         ort->gatherCondensate += GetCurrentMeterValue(state, ort->meterNumCondensate);
    4062       70176 :         ort->gatherWellwater += GetCurrentMeterValue(state, ort->meterNumGroundwater);
    4063       70176 :         ort->gatherMains += GetCurrentMeterValue(state, ort->meterNumMains);
    4064       70176 :         ort->gatherWaterEndUseTotal += GetCurrentMeterValue(state, ort->meterNumWaterEndUseTotal);
    4065             :     }
    4066      161715 : }
    4067             : 
    4068      161715 : void GatherSourceEnergyEndUseResultsForTimestep(EnergyPlusData &state,
    4069             :                                                 OutputProcessor::TimeStepType t_timeStepType) // What kind of data to update (Zone, HVAC)
    4070             : {
    4071             :     // SUBROUTINE INFORMATION:
    4072             :     //       AUTHOR         Mangesh Basarkar
    4073             :     //       DATE WRITTEN   September 2011
    4074             :     //       MODIFIED       na
    4075             :     //       RE-ENGINEERED  na
    4076             : 
    4077             :     // PURPOSE OF THIS SUBROUTINE:
    4078             :     //   This routine gathers data for producing the end uses report in source energy
    4079             : 
    4080             :     // METHODOLOGY EMPLOYED:
    4081             :     //   Uses get input structure similar to other objects
    4082             :     //   Meter names are of two forms:
    4083             :     //         <ResourceType>:<name>
    4084             :     //   or
    4085             :     //         <EndUseType>:<ResourceType>
    4086             :     //   The <EndUseType> are:
    4087             :     //          Heating
    4088             :     //          Cooling
    4089             :     //          InteriorLights
    4090             :     //          ExteriorLights
    4091             :     //          InteriorEquipment
    4092             :     //          ExteriorEquipment
    4093             :     //          Fans
    4094             :     //          Pumps
    4095             :     //          HeatRejection
    4096             :     //          Humidifier
    4097             :     //          HeatRecovery
    4098             :     //          DHW
    4099             :     //          Refrigeration
    4100             :     //          Cogeneration
    4101             :     //   The <ResourceType> are:
    4102             :     //          Electricity 1
    4103             :     //          Gas 2
    4104             :     //          Gasoline 6
    4105             :     //          Diesel 8
    4106             :     //          Coal 9
    4107             :     //          FuelOilNo1 10
    4108             :     //          FuelOilNo2 11
    4109             :     //          Propane 12
    4110             :     //          Water 7
    4111             :     //          Steam 5
    4112             :     //          DistrictCooling 3
    4113             :     //          DistrictHeating 4
    4114             : 
    4115             :     //          sourceTypeNames(1)='Electric'
    4116             :     //          sourceTypeNames(2)='NaturalGas'
    4117             :     //          sourceTypeNames(3)='Gasoline'
    4118             :     //          sourceTypeNames(4)='Diesel'
    4119             :     //          sourceTypeNames(5)='Coal'
    4120             :     //          sourceTypeNames(6)='FuelOilNo1'
    4121             :     //          sourceTypeNames(7)='FuelOilNo2'
    4122             :     //          sourceTypeNames(8)='Propane'
    4123             :     //          sourceTypeNames(9)='PurchasedElectricity'
    4124             :     //          sourceTypeNames(10)='SoldElectricity'
    4125             :     //          sourceTypeNames(11)='OtherFuel1'
    4126             :     //          sourceTypeNames(12)='OtherFuel2'
    4127             : 
    4128             :     // REFERENCES:
    4129             :     // na
    4130             : 
    4131             :     // Using/Aliasing
    4132             :     using DataStringGlobals::CharComma;
    4133             :     using DataStringGlobals::CharSpace;
    4134             :     using DataStringGlobals::CharTab;
    4135             :     using ScheduleManager::GetCurrentScheduleValue;
    4136             : 
    4137             :     // Locals
    4138             :     // SUBROUTINE ARGUMENT DEFINITIONS:
    4139             : 
    4140             :     // SUBROUTINE PARAMETER DEFINITIONS:
    4141             :     // na
    4142             : 
    4143             :     // INTERFACE BLOCK SPECIFICATIONS:
    4144             :     // na
    4145             : 
    4146             :     // DERIVED TYPE DEFINITIONS:
    4147             :     // na
    4148             : 
    4149             :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
    4150             :     int iResource;
    4151             :     Real64 curMeterValue;
    4152             :     int curMeterNumber;
    4153      161715 :     auto &ort(state.dataOutRptTab);
    4154             : 
    4155             :     // if no beps by source report is called then skip
    4156             : 
    4157      161715 :     if ((ort->displaySourceEnergyEndUseSummary) && (t_timeStepType == OutputProcessor::TimeStepType::Zone)) {
    4158             :         // loop through all of the resources and end uses for the entire facility
    4159     1052640 :         for (iResource = 1; iResource <= numResourceTypes; ++iResource) {
    4160             : 
    4161      982464 :             if (ort->ffSchedUsed(iResource)) {
    4162           0 :                 curMeterNumber = ort->meterNumTotalsBEPS(iResource);
    4163           0 :                 if (curMeterNumber > 0) {
    4164           0 :                     curMeterValue = GetCurrentMeterValue(state, curMeterNumber) * GetCurrentScheduleValue(state, ort->ffSchedIndex(iResource)) *
    4165           0 :                                     ort->SourceFactors(iResource);
    4166           0 :                     ort->gatherTotalsBySourceBEPS(iResource) += curMeterValue;
    4167             :                 }
    4168             :             } else {
    4169      982464 :                 curMeterNumber = ort->meterNumTotalsBEPS(iResource);
    4170      982464 :                 if (curMeterNumber > 0) {
    4171      140352 :                     curMeterValue = GetCurrentMeterValue(state, curMeterNumber) * ort->SourceFactors(iResource);
    4172      140352 :                     ort->gatherTotalsBySourceBEPS(iResource) += curMeterValue;
    4173             :                 }
    4174             :             }
    4175             : 
    4176    14736960 :             for (int jEndUse = 1; jEndUse <= DataGlobalConstantsData::iEndUseSize; ++jEndUse) {
    4177    13754496 :                 if (ort->ffSchedUsed(iResource)) {
    4178           0 :                     curMeterNumber = ort->meterNumEndUseBEPS(iResource, jEndUse);
    4179           0 :                     if (curMeterNumber > 0) {
    4180           0 :                         curMeterValue = GetCurrentMeterValue(state, curMeterNumber) * GetCurrentScheduleValue(state, ort->ffSchedIndex(iResource)) *
    4181           0 :                                         ort->SourceFactors(iResource);
    4182           0 :                         ort->gatherEndUseBySourceBEPS(iResource, jEndUse) += curMeterValue;
    4183             :                     }
    4184             :                 } else {
    4185    13754496 :                     curMeterNumber = ort->meterNumEndUseBEPS(iResource, jEndUse);
    4186    13754496 :                     if (curMeterNumber > 0) {
    4187      491232 :                         curMeterValue = GetCurrentMeterValue(state, curMeterNumber) * ort->SourceFactors(iResource);
    4188      491232 :                         ort->gatherEndUseBySourceBEPS(iResource, jEndUse) += curMeterValue;
    4189             :                     }
    4190             :                 }
    4191             :             }
    4192             :         }
    4193             :     }
    4194      161715 : }
    4195             : 
    4196      161715 : void GatherPeakDemandForTimestep(EnergyPlusData &state, OutputProcessor::TimeStepType t_timeStepType) // What kind of data to update (Zone, HVAC)
    4197             : {
    4198             :     // SUBROUTINE INFORMATION:
    4199             :     //       AUTHOR         Jason Glazer
    4200             :     //       DATE WRITTEN   January 2009
    4201             :     //       MODIFIED       na
    4202             :     //       RE-ENGINEERED  na
    4203             : 
    4204             :     // PURPOSE OF THIS SUBROUTINE:
    4205             :     //   This routine gathers data for producing the Peak Demand
    4206             :     //   by end-use report
    4207             : 
    4208             :     // METHODOLOGY EMPLOYED:
    4209             :     //   Uses get input structure similar to other objects
    4210             :     //   Meter names are of two forms:
    4211             :     //         <ResourceType>:<name>
    4212             :     //   or
    4213             :     //         <EndUseType>:<ResourceType>
    4214             :     //   For the purposes of this routine, only the facility <name>
    4215             :     //   is used.  Remember that 'Building' is actually the sum of
    4216             :     //   the zones only without system,plant and exterior. The only
    4217             :     //   way to get them all is to use 'facility'
    4218             :     //   The <EndUseType> are:
    4219             :     //          Heating
    4220             :     //          Cooling
    4221             :     //          InteriorLights
    4222             :     //          ExteriorLights
    4223             :     //          InteriorEquipment
    4224             :     //          ExteriorEquipment
    4225             :     //          Fans
    4226             :     //          Pumps
    4227             :     //          HeatRejection
    4228             :     //          Humidifier
    4229             :     //          HeatRecovery
    4230             :     //          DHW
    4231             :     //          Refrigeration
    4232             :     //          Cogeneration
    4233             :     //   The <ResourceType> are:
    4234             :     //          Electricity
    4235             :     //          Gas
    4236             :     //          Gasoline
    4237             :     //          Diesel
    4238             :     //          Coal
    4239             :     //          FuelOilNo1
    4240             :     //          FuelOilNo2
    4241             :     //          Propane
    4242             :     //          Water
    4243             :     //          Steam
    4244             :     //          DistrictCooling
    4245             :     //          DistrictHeating
    4246             : 
    4247             :     // REFERENCES:
    4248             :     // na
    4249             : 
    4250             :     // Using/Aliasing
    4251             :     using DataStringGlobals::CharComma;
    4252             :     using DataStringGlobals::CharSpace;
    4253             :     using DataStringGlobals::CharTab;
    4254             :     using General::DetermineMinuteForReporting;
    4255             :     using General::EncodeMonDayHrMin;
    4256             : 
    4257             :     // Locals
    4258             :     // SUBROUTINE ARGUMENT DEFINITIONS:
    4259             : 
    4260             :     // SUBROUTINE PARAMETER DEFINITIONS:
    4261             :     // na
    4262             : 
    4263             :     // INTERFACE BLOCK SPECIFICATIONS:
    4264             :     // na
    4265             : 
    4266             :     // DERIVED TYPE DEFINITIONS:
    4267             :     // na
    4268             : 
    4269             :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
    4270             :     int iResource;
    4271             :     int kEndUseSub;
    4272             :     Real64 curDemandValue;
    4273             :     int curMeterNumber;
    4274             :     int minuteCalculated;
    4275             :     int timestepTimeStamp;
    4276      161715 :     assert(state.dataGlobal->TimeStepZoneSec > 0.0);
    4277      161715 :     auto &ort(state.dataOutRptTab);
    4278             : 
    4279      161715 :     if ((ort->displayDemandEndUse) && (t_timeStepType == OutputProcessor::TimeStepType::Zone)) {
    4280             :         // loop through all of the resources and end uses for the entire facility
    4281     1052640 :         for (iResource = 1; iResource <= numResourceTypes; ++iResource) {
    4282      982464 :             curMeterNumber = ort->meterNumTotalsBEPS(iResource);
    4283      982464 :             if (curMeterNumber > 0) {
    4284      140352 :                 curDemandValue = GetCurrentMeterValue(state, curMeterNumber) / state.dataGlobal->TimeStepZoneSec;
    4285             :                 // check if current value is greater than existing peak demand value
    4286      140352 :                 if (curDemandValue > ort->gatherDemandTotal(iResource)) {
    4287         202 :                     ort->gatherDemandTotal(iResource) = curDemandValue;
    4288             :                     // save the time that the peak demand occurred
    4289             :                     //        minuteCalculated = (CurrentTime - INT(CurrentTime))*60
    4290         202 :                     minuteCalculated = DetermineMinuteForReporting(state, t_timeStepType);
    4291         606 :                     EncodeMonDayHrMin(
    4292         606 :                         timestepTimeStamp, state.dataEnvrn->Month, state.dataEnvrn->DayOfMonth, state.dataGlobal->HourOfDay, minuteCalculated);
    4293         202 :                     ort->gatherDemandTimeStamp(iResource) = timestepTimeStamp;
    4294             :                     // if new peak demand is set, then gather all of the end use values at this particular
    4295             :                     // time to find the components of the peak demand
    4296        3030 :                     for (int jEndUse = 1; jEndUse <= DataGlobalConstantsData::iEndUseSize; ++jEndUse) {
    4297        2828 :                         curMeterNumber = ort->meterNumEndUseBEPS(iResource, jEndUse);
    4298        2828 :                         if (curMeterNumber > 0) {
    4299        1052 :                             curDemandValue = GetCurrentMeterValue(state, curMeterNumber) / state.dataGlobal->TimeStepZoneSec;
    4300        1052 :                             ort->gatherDemandEndUse(iResource, jEndUse) = curDemandValue;
    4301        2508 :                             for (kEndUseSub = 1; kEndUseSub <= state.dataOutputProcessor->EndUseCategory(jEndUse).NumSubcategories; ++kEndUseSub) {
    4302        1456 :                                 curMeterNumber = ort->meterNumEndUseSubBEPS(kEndUseSub, jEndUse, iResource);
    4303        1456 :                                 if (curMeterNumber > 0) {
    4304        1052 :                                     curDemandValue = GetCurrentMeterValue(state, curMeterNumber) / state.dataGlobal->TimeStepZoneSec;
    4305        1052 :                                     ort->gatherDemandEndUseSub(kEndUseSub, jEndUse, iResource) = curDemandValue;
    4306             :                                 }
    4307             :                             }
    4308             :                         }
    4309             :                     }
    4310             :                 }
    4311             :             }
    4312             :         }
    4313             :     }
    4314             : 
    4315             :     // gather the peak demands of each individual enduse subcategory for the LEED report
    4316      161715 :     if ((ort->displayLEEDSummary) && (t_timeStepType == OutputProcessor::TimeStepType::Zone)) {
    4317             :         // loop through all of the resources and end uses for the entire facility
    4318     1052640 :         for (iResource = 1; iResource <= numResourceTypes; ++iResource) {
    4319    14736960 :             for (int jEndUse = 1; jEndUse <= DataGlobalConstantsData::iEndUseSize; ++jEndUse) {
    4320    13754496 :                 curMeterNumber = ort->meterNumEndUseBEPS(iResource, jEndUse);
    4321    13754496 :                 if (curMeterNumber > 0) {
    4322      491232 :                     curDemandValue = GetCurrentMeterValue(state, curMeterNumber) / state.dataGlobal->TimeStepZoneSec;
    4323      491232 :                     if (curDemandValue > ort->gatherDemandIndEndUse(iResource, jEndUse)) {
    4324         565 :                         ort->gatherDemandIndEndUse(iResource, jEndUse) = curDemandValue;
    4325             :                     }
    4326     1263168 :                     for (kEndUseSub = 1; kEndUseSub <= state.dataOutputProcessor->EndUseCategory(jEndUse).NumSubcategories; ++kEndUseSub) {
    4327      771936 :                         curMeterNumber = ort->meterNumEndUseSubBEPS(kEndUseSub, jEndUse, iResource);
    4328      771936 :                         if (curMeterNumber > 0) {
    4329      491232 :                             curDemandValue = GetCurrentMeterValue(state, curMeterNumber) / state.dataGlobal->TimeStepZoneSec;
    4330             :                             // check if current value is greater than existing peak demand value
    4331      491232 :                             if (curDemandValue > ort->gatherDemandIndEndUseSub(kEndUseSub, jEndUse, iResource)) {
    4332         565 :                                 ort->gatherDemandIndEndUseSub(kEndUseSub, jEndUse, iResource) = curDemandValue;
    4333             :                             }
    4334             :                         }
    4335             :                     }
    4336             :                 }
    4337             :             }
    4338             :         }
    4339             :     }
    4340      161715 : }
    4341             : 
    4342      161715 : void GatherHeatEmissionReport(EnergyPlusData &state, OutputProcessor::TimeStepType t_timeStepType)
    4343             : {
    4344             :     // PURPOSE OF THIS SUBROUTINE:
    4345             :     // Gathers the data each zone timestep for the heat gain report.
    4346             :     // The routine generates an annual table with the following columns which correspond to
    4347             :     // the output variables and data structures shown.
    4348             : 
    4349      161715 :     state.dataHeatBal->SysTotalHVACReliefHeatLoss = 0;
    4350      161715 :     state.dataHeatBal->SysTotalHVACRejectHeatLoss = 0;
    4351      161715 :     auto &ort(state.dataOutRptTab);
    4352             : 
    4353      161715 :     if (!ort->displayHeatEmissionsSummary) return; // don't gather data if report isn't requested
    4354             : 
    4355             :     // Only gather zone report at zone time steps
    4356      161715 :     if (t_timeStepType == OutputProcessor::TimeStepType::Zone) {
    4357       70176 :         state.dataHeatBal->BuildingPreDefRep.emiEnvelopConv += state.dataHeatBalSurf->SumSurfaceHeatEmission * DataGlobalConstants::convertJtoGJ;
    4358       70176 :         return;
    4359             :     }
    4360             : 
    4361       91539 :     CalcHeatEmissionReport(state);
    4362       91539 :     state.dataHeatBal->BuildingPreDefRep.emiZoneExfiltration += state.dataHeatBal->ZoneTotalExfiltrationHeatLoss * DataGlobalConstants::convertJtoGJ;
    4363       91539 :     state.dataHeatBal->BuildingPreDefRep.emiZoneExhaust += state.dataHeatBal->ZoneTotalExhaustHeatLoss * DataGlobalConstants::convertJtoGJ;
    4364       91539 :     state.dataHeatBal->BuildingPreDefRep.emiHVACRelief += state.dataHeatBal->SysTotalHVACReliefHeatLoss * DataGlobalConstants::convertJtoGJ;
    4365       91539 :     state.dataHeatBal->BuildingPreDefRep.emiHVACReject += state.dataHeatBal->SysTotalHVACRejectHeatLoss * DataGlobalConstants::convertJtoGJ;
    4366             : 
    4367       91539 :     state.dataHeatBal->BuildingPreDefRep.emiTotHeat =
    4368      183078 :         state.dataHeatBal->BuildingPreDefRep.emiEnvelopConv + state.dataHeatBal->BuildingPreDefRep.emiZoneExfiltration +
    4369      274617 :         state.dataHeatBal->BuildingPreDefRep.emiZoneExhaust + state.dataHeatBal->BuildingPreDefRep.emiHVACRelief +
    4370       91539 :         state.dataHeatBal->BuildingPreDefRep.emiHVACReject;
    4371             : }
    4372             : 
    4373     1357935 : void CalcHeatEmissionReport(EnergyPlusData &state)
    4374             : {
    4375             :     // PURPOSE OF THIS SUBROUTINE:
    4376             :     // Gathers the data each zone timestep for the heat gain report.
    4377             :     // The routine generates an annual table with the following columns which correspond to
    4378             :     // the output variables and data structures shown.
    4379             : 
    4380             :     // Using/Aliasing
    4381     1357935 :     auto &TimeStepSys = state.dataHVACGlobal->TimeStepSys;
    4382             : 
    4383     1357935 :     Real64 H2OHtOfVap_HVAC = Psychrometrics::PsyHgAirFnWTdb(state.dataEnvrn->OutHumRat, state.dataEnvrn->OutDryBulbTemp);
    4384     1357935 :     Real64 RhoWater = Psychrometrics::RhoH2O(state.dataEnvrn->OutDryBulbTemp);
    4385     1357935 :     Real64 TimeStepSysSec = TimeStepSys * DataGlobalConstants::SecInHour;
    4386     1357935 :     state.dataHeatBal->SysTotalHVACReliefHeatLoss = 0;
    4387     1357935 :     state.dataHeatBal->SysTotalHVACRejectHeatLoss = 0;
    4388             : 
    4389             :     // HVAC relief air
    4390     2712993 :     for (int iOACtrl = 1; iOACtrl <= state.dataMixedAir->NumOAControllers; ++iOACtrl) {
    4391     1355058 :         state.dataHeatBal->SysTotalHVACReliefHeatLoss += state.dataMixedAir->OAController(iOACtrl).RelTotalLossRate * TimeStepSysSec;
    4392             :     }
    4393             : 
    4394             :     // Airloop HVAC Exhaust System
    4395     1358904 :     for (int iExhSys = 1; iExhSys < state.dataZoneEquip->NumExhaustAirSystems; ++iExhSys) {
    4396         969 :         state.dataHeatBal->SysTotalHVACReliefHeatLoss += state.dataZoneEquip->ExhaustAirSystem(iExhSys).exhTotalHVACReliefHeatLoss;
    4397             :     }
    4398             : 
    4399             :     // Condenser water loop
    4400     1758710 :     for (int iCooler = 1; iCooler <= (int)state.dataCondenserLoopTowers->towers.size(); ++iCooler) {
    4401     1202325 :         state.dataHeatBal->SysTotalHVACRejectHeatLoss += state.dataCondenserLoopTowers->towers(iCooler).Qactual * TimeStepSysSec +
    4402      801550 :                                                          state.dataCondenserLoopTowers->towers(iCooler).FanEnergy +
    4403      400775 :                                                          state.dataCondenserLoopTowers->towers(iCooler).BasinHeaterConsumption;
    4404             :     }
    4405     1362126 :     for (auto &thisCooler : state.dataEvapFluidCoolers->SimpleEvapFluidCooler) {
    4406        4191 :         state.dataHeatBal->SysTotalHVACRejectHeatLoss += thisCooler.Qactual * TimeStepSysSec + thisCooler.FanEnergy;
    4407             :     }
    4408     1364619 :     for (auto &cooler : state.dataFluidCoolers->SimpleFluidCooler) {
    4409        6684 :         state.dataHeatBal->SysTotalHVACRejectHeatLoss += cooler.Qactual * TimeStepSysSec + cooler.FanEnergy;
    4410             :     }
    4411             : 
    4412             :     // Air- and Evap-cooled chiller
    4413     1357935 :     auto &ElectricChiller(state.dataPlantChillers->ElectricChiller);
    4414     1857632 :     for (int iChiller = 1; iChiller <= state.dataPlantChillers->NumElectricChillers; ++iChiller) {
    4415      499697 :         if (ElectricChiller(iChiller).CondenserType != DataPlant::CondenserType::WaterCooled) {
    4416      230270 :             state.dataHeatBal->SysTotalHVACRejectHeatLoss += ElectricChiller(iChiller).CondenserEnergy;
    4417             :         }
    4418             :     }
    4419     1357935 :     auto &EngineDrivenChiller(state.dataPlantChillers->EngineDrivenChiller);
    4420     1374427 :     for (int iChiller = 1; iChiller <= state.dataPlantChillers->NumEngineDrivenChillers; ++iChiller) {
    4421       16492 :         if (EngineDrivenChiller(iChiller).CondenserType != DataPlant::CondenserType::WaterCooled) {
    4422           0 :             state.dataHeatBal->SysTotalHVACRejectHeatLoss += EngineDrivenChiller(iChiller).CondenserEnergy;
    4423             :         }
    4424             :     }
    4425     1357935 :     auto &GTChiller(state.dataPlantChillers->GTChiller);
    4426     1360908 :     for (int iChiller = 1; iChiller <= state.dataPlantChillers->NumGTChillers; ++iChiller) {
    4427        2973 :         if (GTChiller(iChiller).CondenserType != DataPlant::CondenserType::WaterCooled) {
    4428           0 :             state.dataHeatBal->SysTotalHVACRejectHeatLoss += GTChiller(iChiller).CondenserEnergy;
    4429             :         }
    4430             :     }
    4431     1357935 :     auto &ConstCOPChiller(state.dataPlantChillers->ConstCOPChiller);
    4432     1528528 :     for (int iChiller = 1; iChiller <= state.dataPlantChillers->NumConstCOPChillers; ++iChiller) {
    4433      170593 :         if (ConstCOPChiller(iChiller).CondenserType != DataPlant::CondenserType::WaterCooled) {
    4434        3455 :             state.dataHeatBal->SysTotalHVACRejectHeatLoss += ConstCOPChiller(iChiller).CondenserEnergy;
    4435             :         }
    4436             :     }
    4437     1357935 :     auto &ElectricEIRChiller(state.dataChillerElectricEIR->ElectricEIRChiller);
    4438     1394823 :     for (int iChiller = 1; iChiller <= (int)state.dataChillerElectricEIR->ElectricEIRChiller.size(); ++iChiller) {
    4439       36888 :         if (ElectricEIRChiller(iChiller).CondenserType != DataPlant::CondenserType::WaterCooled) {
    4440        6692 :             state.dataHeatBal->SysTotalHVACRejectHeatLoss += ElectricEIRChiller(iChiller).CondEnergy;
    4441             :         }
    4442             :     }
    4443     1357935 :     auto &ElecReformEIRChiller(state.dataChillerReformulatedEIR->ElecReformEIRChiller);
    4444     1367175 :     for (int iChiller = 1; iChiller <= (int)state.dataChillerReformulatedEIR->ElecReformEIRChiller.size(); ++iChiller) {
    4445        9240 :         if (ElecReformEIRChiller(iChiller).CondenserType != DataPlant::CondenserType::WaterCooled) {
    4446           0 :             state.dataHeatBal->SysTotalHVACRejectHeatLoss += ElecReformEIRChiller(iChiller).CondEnergy;
    4447             :         }
    4448             :     }
    4449             : 
    4450             :     // Water / steam boiler
    4451     1743489 :     for (int iBoiler = 1; iBoiler <= (int)state.dataBoilers->Boiler.size(); ++iBoiler) {
    4452     1156662 :         state.dataHeatBal->SysTotalHVACRejectHeatLoss += state.dataBoilers->Boiler(iBoiler).FuelConsumed +
    4453      771108 :                                                          state.dataBoilers->Boiler(iBoiler).ParasiticElecConsumption -
    4454      385554 :                                                          state.dataBoilers->Boiler(iBoiler).BoilerEnergy;
    4455             :     }
    4456             : 
    4457             :     // DX Coils air to air
    4458     1357935 :     auto &DXCoil(state.dataDXCoils->DXCoil);
    4459     2614615 :     for (int iCoil = 1; iCoil <= state.dataDXCoils->NumDXCoils; ++iCoil) {
    4460     3001404 :         if (DXCoil(iCoil).DXCoilType_Num == DataHVACGlobals::CoilDX_CoolingSingleSpeed ||
    4461      951678 :             DXCoil(iCoil).DXCoilType_Num == DataHVACGlobals::CoilDX_CoolingTwoSpeed ||
    4462     2072411 :             DXCoil(iCoil).DXCoilType_Num == DataHVACGlobals::CoilDX_MultiSpeedCooling ||
    4463      352097 :             DXCoil(iCoil).DXCoilType_Num == DataHVACGlobals::CoilDX_CoolingTwoStageWHumControl) {
    4464      916932 :             if (DXCoil(iCoil).CondenserType(1) == DataHeatBalance::RefrigCondenserType::Air) {
    4465     2743326 :                 state.dataHeatBal->SysTotalHVACRejectHeatLoss += DXCoil(iCoil).ElecCoolingConsumption + DXCoil(iCoil).DefrostConsumption +
    4466     1828884 :                                                                  DXCoil(iCoil).CrankcaseHeaterConsumption + DXCoil(iCoil).TotalCoolingEnergy;
    4467        2490 :             } else if (DXCoil(iCoil).CondenserType(1) == DataHeatBalance::RefrigCondenserType::Evap) {
    4468        4980 :                 state.dataHeatBal->SysTotalHVACRejectHeatLoss += DXCoil(iCoil).EvapCondPumpElecConsumption + DXCoil(iCoil).BasinHeaterConsumption +
    4469        2490 :                                                                  DXCoil(iCoil).EvapWaterConsump * RhoWater * H2OHtOfVap_HVAC;
    4470             :             }
    4471      916932 :             if (DXCoil(iCoil).FuelTypeNum != DataGlobalConstants::ResourceType::Electricity) {
    4472      816210 :                 state.dataHeatBal->SysTotalHVACRejectHeatLoss += DXCoil(iCoil).MSFuelWasteHeat * TimeStepSysSec;
    4473             :             }
    4474      584467 :         } else if (DXCoil(iCoil).DXCoilType_Num == DataHVACGlobals::CoilDX_HeatingEmpirical ||
    4475      244719 :                    DXCoil(iCoil).DXCoilType_Num == DataHVACGlobals::CoilDX_MultiSpeedHeating) {
    4476      547878 :             state.dataHeatBal->SysTotalHVACRejectHeatLoss += DXCoil(iCoil).ElecHeatingConsumption + DXCoil(iCoil).DefrostConsumption +
    4477      547878 :                                                              DXCoil(iCoil).FuelConsumed + DXCoil(iCoil).CrankcaseHeaterConsumption -
    4478      182626 :                                                              DXCoil(iCoil).TotalHeatingEnergy;
    4479             :         }
    4480             :     }
    4481             :     // VAV coils - air to air
    4482     1357935 :     auto &VarSpeedCoil(state.dataVariableSpeedCoils->VarSpeedCoil);
    4483     1432227 :     for (int iCoil = 1; iCoil <= state.dataVariableSpeedCoils->NumVarSpeedCoils; ++iCoil) {
    4484       74292 :         if (VarSpeedCoil(iCoil).VSCoilType == DataHVACGlobals::Coil_CoolingAirToAirVariableSpeed) {
    4485       18230 :             if (VarSpeedCoil(iCoil).CondenserType == DataHeatBalance::RefrigCondenserType::Air) {
    4486       54690 :                 state.dataHeatBal->SysTotalHVACRejectHeatLoss += VarSpeedCoil(iCoil).Energy + VarSpeedCoil(iCoil).CrankcaseHeaterConsumption +
    4487       36460 :                                                                  VarSpeedCoil(iCoil).DefrostConsumption + VarSpeedCoil(iCoil).EnergyLoadTotal;
    4488           0 :             } else if (VarSpeedCoil(iCoil).CondenserType == DataHeatBalance::RefrigCondenserType::Evap) {
    4489           0 :                 state.dataHeatBal->SysTotalHVACRejectHeatLoss += VarSpeedCoil(iCoil).EvapCondPumpElecConsumption +
    4490           0 :                                                                  VarSpeedCoil(iCoil).BasinHeaterConsumption +
    4491           0 :                                                                  VarSpeedCoil(iCoil).EvapWaterConsump * RhoWater * H2OHtOfVap_HVAC;
    4492             :             }
    4493       56062 :         } else if (VarSpeedCoil(iCoil).VSCoilType == DataHVACGlobals::Coil_HeatingAirToAirVariableSpeed) {
    4494       27288 :             state.dataHeatBal->SysTotalHVACRejectHeatLoss += VarSpeedCoil(iCoil).Energy + VarSpeedCoil(iCoil).CrankcaseHeaterConsumption +
    4495       18192 :                                                              VarSpeedCoil(iCoil).DefrostConsumption - VarSpeedCoil(iCoil).EnergyLoadTotal;
    4496             :         }
    4497             :     }
    4498             : 
    4499             :     // Heating coils - fuel
    4500     3047758 :     for (int iCoil = 1; iCoil <= state.dataHeatingCoils->NumHeatingCoils; ++iCoil) {
    4501     3378018 :         if (state.dataHeatingCoils->HeatingCoil(iCoil).HCoilType_Num == DataHVACGlobals::Coil_HeatingGas_MultiStage ||
    4502     1688195 :             state.dataHeatingCoils->HeatingCoil(iCoil).HCoilType_Num == DataHVACGlobals::Coil_HeatingGasOrOtherFuel) {
    4503     3805494 :             state.dataHeatBal->SysTotalHVACRejectHeatLoss += state.dataHeatingCoils->HeatingCoil(iCoil).FuelUseLoad +
    4504     2536996 :                                                              state.dataHeatingCoils->HeatingCoil(iCoil).ParasiticFuelLoad -
    4505     1268498 :                                                              state.dataHeatingCoils->HeatingCoil(iCoil).HeatingCoilLoad;
    4506             :         }
    4507             :     }
    4508             : 
    4509             :     // Packaged TES
    4510     1357935 :     auto &TESCoil(state.dataPackagedThermalStorageCoil->TESCoil);
    4511     1363695 :     for (int iCoil = 1; iCoil <= state.dataPackagedThermalStorageCoil->NumTESCoils; ++iCoil) {
    4512        5760 :         if (TESCoil(iCoil).CondenserType == PackagedThermalStorageCoil::TESCondenserType::Air) {
    4513       12960 :             state.dataHeatBal->SysTotalHVACRejectHeatLoss += TESCoil(iCoil).EvapTotCoolingEnergy + TESCoil(iCoil).ElecCoolingEnergy +
    4514        8640 :                                                              TESCoil(iCoil).ElectColdWeatherEnergy - TESCoil(iCoil).Q_Ambient;
    4515        1440 :         } else if (TESCoil(iCoil).CondenserType == PackagedThermalStorageCoil::TESCondenserType::Evap) {
    4516        4320 :             state.dataHeatBal->SysTotalHVACRejectHeatLoss += TESCoil(iCoil).EvapCondPumpElecConsumption +
    4517        2880 :                                                              TESCoil(iCoil).ElectEvapCondBasinHeaterEnergy +
    4518        2880 :                                                              TESCoil(iCoil).EvapWaterConsump * RhoWater * H2OHtOfVap_HVAC - TESCoil(iCoil).Q_Ambient;
    4519             :         }
    4520             :     }
    4521             : 
    4522             :     // Water heater and thermal storage
    4523     1357935 :     auto &WaterThermalTank(state.dataWaterThermalTanks->WaterThermalTank);
    4524     1558310 :     for (int iTank = 1; iTank <= state.dataWaterThermalTanks->numWaterThermalTank; ++iTank) {
    4525      200375 :         if (WaterThermalTank(iTank).AmbientTempIndicator == WaterThermalTanks::WTTAmbientTemp::OutsideAir) {
    4526       10725 :             state.dataHeatBal->SysTotalHVACRejectHeatLoss += WaterThermalTank(iTank).FuelEnergy - WaterThermalTank(iTank).TotalDemandEnergy;
    4527             :         }
    4528             :     }
    4529             : 
    4530             :     // Variable Refrigerant Flow
    4531     1357935 :     auto &VRF(state.dataHVACVarRefFlow->VRF);
    4532     1371028 :     for (int iCoil = 1; iCoil <= state.dataHVACVarRefFlow->NumVRFCond; ++iCoil) {
    4533       13093 :         if (VRF(iCoil).CondenserType == DataHeatBalance::RefrigCondenserType::Air) {
    4534       36264 :             state.dataHeatBal->SysTotalHVACRejectHeatLoss += VRF(iCoil).CoolElecConsumption + VRF(iCoil).HeatElecConsumption +
    4535       36264 :                                                              VRF(iCoil).CrankCaseHeaterElecConsumption + VRF(iCoil).DefrostConsumption +
    4536       12088 :                                                              (VRF(iCoil).TotalCoolingCapacity - VRF(iCoil).TotalHeatingCapacity) * TimeStepSysSec;
    4537        1005 :         } else if (VRF(iCoil).CondenserType == DataHeatBalance::RefrigCondenserType::Evap) {
    4538           0 :             state.dataHeatBal->SysTotalHVACRejectHeatLoss += VRF(iCoil).EvapCondPumpElecConsumption + VRF(iCoil).BasinHeaterConsumption +
    4539           0 :                                                              VRF(iCoil).EvapWaterConsumpRate * TimeStepSysSec * RhoWater * H2OHtOfVap_HVAC;
    4540        1005 :         } else if (VRF(iCoil).CondenserType == DataHeatBalance::RefrigCondenserType::Water) {
    4541        1005 :             state.dataHeatBal->SysTotalHVACRejectHeatLoss += VRF(iCoil).QCondEnergy;
    4542             :         }
    4543             :     }
    4544             : 
    4545             :     // Refrigerated Rack
    4546     1357935 :     auto &RefrigRack(state.dataRefrigCase->RefrigRack);
    4547     1460350 :     for (int iRef = 1; iRef <= state.dataRefrigCase->NumRefrigeratedRacks; ++iRef) {
    4548      102415 :         if (RefrigRack(iRef).CondenserType == DataHeatBalance::RefrigCondenserType::Air) {
    4549       98854 :             state.dataHeatBal->SysTotalHVACRejectHeatLoss += RefrigRack(iRef).RackElecConsumption + RefrigRack(iRef).RackCoolingEnergy;
    4550        3561 :         } else if (RefrigRack(iRef).CondenserType == DataHeatBalance::RefrigCondenserType::Evap) {
    4551        4612 :             state.dataHeatBal->SysTotalHVACRejectHeatLoss += RefrigRack(iRef).EvapPumpConsumption + RefrigRack(iRef).BasinHeaterConsumption +
    4552        2306 :                                                              RefrigRack(iRef).EvapWaterConsumption * RhoWater * H2OHtOfVap_HVAC;
    4553        1255 :         } else if (RefrigRack(iRef).CondenserType == DataHeatBalance::RefrigCondenserType::Water) {
    4554        1255 :             state.dataHeatBal->SysTotalHVACRejectHeatLoss += RefrigRack(iRef).CondEnergy;
    4555             :         }
    4556             :     }
    4557             : 
    4558             :     // Refrigerated Case - Condenser
    4559     1442636 :     for (int iRef = 1; iRef <= state.dataRefrigCase->NumRefrigCondensers; ++iRef) {
    4560       84701 :         state.dataHeatBal->SysTotalHVACRejectHeatLoss += state.dataRefrigCase->Condenser(iRef).CondEnergy;
    4561             :     }
    4562             : 
    4563             :     // Evaporative coolers
    4564     1454210 :     for (int iCooler = 1; iCooler <= state.dataEvapCoolers->NumEvapCool; ++iCooler) {
    4565      192550 :         state.dataHeatBal->SysTotalHVACRejectHeatLoss += state.dataEvapCoolers->EvapCond(iCooler).EvapWaterConsump * RhoWater * H2OHtOfVap_HVAC +
    4566       96275 :                                                          state.dataEvapCoolers->EvapCond(iCooler).EvapCoolerEnergy;
    4567             :     }
    4568     1357935 : }
    4569             : 
    4570      161715 : void GatherHeatGainReport(EnergyPlusData &state, OutputProcessor::TimeStepType t_timeStepType) // What kind of data to update (Zone, HVAC)
    4571             : {
    4572             :     // SUBROUTINE INFORMATION:
    4573             :     //       AUTHOR         Jason Glazer
    4574             :     //       DATE WRITTEN   August 2011
    4575             :     //       MODIFIED       na
    4576             :     //       RE-ENGINEERED  na
    4577             : 
    4578             :     // PURPOSE OF THIS SUBROUTINE:
    4579             :     //   Gathers the data each zone timestep for the heat gain report.
    4580             :     // The routine generates an annual table with the following columns which correspond to
    4581             :     // the output variables and data structures shown:
    4582             :     // Column                               Output Variable                                Internal Data Structure      Timestep Type
    4583             :     // ------                               ---------------                                -----------------------      -------- -----
    4584             :     // HVAC Input Sensible Air Heating      Zone Air Heat Balance System Air Transfer Rate ZnAirRpt()%SumMCpDTsystem    HVAC     Rate
    4585             :     //                                   Zone Air Heat Balance System Convective Heat Gain Rate ZnAirRpt()%SumNonAirSystem HVAC   Rate
    4586             :     // HVAC Input Sensible Air Cooling      Zone Air Heat Balance System Air Transfer Rate ZnAirRpt()%SumMCpDTsystem    HVAC     Rate
    4587             :     // HVAC sensible heating by ATU         sensible heating by the air terminal unit                                   HVAC     Rate
    4588             :     // HVAC sensible cooling by ATU         sensible cooling by the air terminal unit                                   HVAC     Rate
    4589             :     //                                    Zone Air Heat Balance System Convective Heat Gain Rate ZnAirRpt()%SumNonAirSystem HVAC  Rate
    4590             :     // HVAC Input Heated Surface Heating    Electric Low Temp Radiant Heating Energy       ElecRadSys()%HeatEnergy      HVAC     Energy
    4591             :     //                                      Zone Ventilated Slab Radiant Heating Energy    VentSlab()%RadHeatingEnergy  HVAC     Energy
    4592             :     //                                      Hydronic Low Temp Radiant Heating Energy       HydrRadSys()%HeatEnergy      HVAC     Energy
    4593             :     //                                      Constant Flow Low Temp Radiant Heating Energy  CFloRadSys()%HeatEnergy      HVAC     Energy
    4594             :     // HVAC Input Cooled Surface Cooling    Zone Ventilated Slab Radiant Cooling Energy    -VentSlab()%RadCoolingEnergy HVAC     Energy
    4595             :     //                                      Hydronic Low Temp Radiant Cooling Energy       -HydrRadSys()%CoolEnergy     HVAC     Energy
    4596             :     //                                      Constant Flow Low Temp Radiant Cooling Energy  -CFloRadSys()%CoolEnergy     HVAC     Energy
    4597             :     // People Sensible Heat Addition        Zone People Sensible Heating Energy            ZoneRpt()%PeopleSenGain        Zone     Energy
    4598             :     // Lights Sensible Heat Addition        Zone Lights Total Heating Energy               ZoneRpt()%LtsTotGain           Zone     Energy
    4599             :     // Equipment Sensible Heat Addition     Zone Electric Equipment Radiant Heating Energy ZoneRpt()%ElecRadGain          Zone     Energy
    4600             :     //                                      Zone Gas Equipment Radiant Heating Energy      ZoneRpt()%GasRadGain           Zone     Energy
    4601             :     //                                      Zone Steam Equipment Radiant Heating Energy    ZoneRpt()%SteamRadGain         Zone     Energy
    4602             :     //                                      Zone Hot Water Equipment Radiant Heating Energy ZoneRpt()%HWRadGain           Zone     Energy
    4603             :     //                                      Zone Other Equipment Radiant Heating Energy    ZoneRpt()%OtherRadGain         Zone     Energy
    4604             :     //                                   Zone Electric Equipment Convective Heating Energy ZoneRpt()%ElecConGain          Zone     Energy
    4605             :     //                                      Zone Gas Equipment Convective Heating Energy   ZoneRpt()%GasConGain           Zone     Energy
    4606             :     //                                      Zone Steam Equipment Convective Heating Energy ZoneRpt()%SteamConGain         Zone     Energy
    4607             :     //                                    Zone Hot Water Equipment Convective Heating Energy ZoneRpt()%HWConGain          Zone     Energy
    4608             :     //                                      Zone Other Equipment Convective Heating Energy ZoneRpt()%OtherConGain         Zone     Energy
    4609             :     // Window Heat Addition                 Zone Windows Total Heat Gain Energy            ZoneWinHeatGainRepEnergy()   Zone     Energy
    4610             :     // Interzone Air Transfer Heat Addition Zone Air Heat Balance Interzone Air Transfer Rate  ZnAirRpt()%SumMCpDTzones HVAC     Rate
    4611             :     // Infiltration Heat Addition           Zone Air Heat Balance Outdoor Air Transfer Rate ZnAirRpt()%SumMCpDtInfil     HVAC     Rate
    4612             :     // Equipment Sensible Heat Removal      Zone Electric Equipment Radiant Heating Energy ZoneRpt()%ElecRadGain          Zone     Energy
    4613             :     //                                      Zone Gas Equipment Radiant Heating Energy      ZoneRpt()%GasRadGain           Zone     Energy
    4614             :     //                                      Zone Steam Equipment Radiant Heating Energy    ZoneRpt()%SteamRadGain         Zone     Energy
    4615             :     //                                      Zone Hot Water Equipment Radiant Heating Energy ZoneRpt()%HWRadGain           Zone     Energy
    4616             :     //                                      Zone Other Equipment Radiant Heating Energy    ZoneRpt()%OtherRadGain         Zone     Energy
    4617             :     //                                   Zone Electric Equipment Convective Heating Energy ZoneRpt()%ElecConGain          Zone     Energy
    4618             :     //                                      Zone Gas Equipment Convective Heating Energy   ZoneRpt()%GasConGain           Zone     Energy
    4619             :     //                                      Zone Steam Equipment Convective Heating Energy ZoneRpt()%SteamConGain         Zone     Energy
    4620             :     //                                     Zone Hot Water Equipment Convective Heating Energy ZoneRpt()%HWConGain         Zone     Energy
    4621             :     //                                      Zone Other Equipment Convective Heating Energy ZoneRpt()%OtherConGain         Zone     Energy
    4622             :     // Window Heat Removal                  Zone Windows Total Heat Loss Energy            -ZoneWinHeatLossRepEnergy()  Zone     Energy
    4623             :     // Interzone Air Transfer Heat Removal  Zone Air Heat Balance Interzone Air Transfer Rate ZnAirRpt()%SumMCpDTzones  HVAC     Rate
    4624             :     // Infiltration Heat Removal            Zone Air Heat Balance Outdoor Air Transfer Rate ZnAirRpt()%SumMCpDtInfil     HVAC     Rate
    4625             :     // The following two columns are derived based on the values of the other columns and need to be computed on every HVAC timestep.
    4626             :     //   Opaque Surface Conduction and Other Heat Addition
    4627             :     //   Opaque Surface Conduction and Other Heat Removal
    4628             :     // For variables that are updated on a zone timestep basis, the values are used on the HVAC timestep but are ratioed by the
    4629             :     // timestep lengths.
    4630             :     // The peak reports follow a similar example.
    4631             : 
    4632             :     // Using/Aliasing
    4633      161715 :     auto &TimeStepSys = state.dataHVACGlobal->TimeStepSys;
    4634             :     using General::DetermineMinuteForReporting;
    4635             :     using General::EncodeMonDayHrMin;
    4636             : 
    4637      161715 :     auto &Zone(state.dataHeatBal->Zone);
    4638      161715 :     auto &ZonePreDefRep(state.dataHeatBal->ZonePreDefRep);
    4639             : 
    4640             :     Real64 mult; // zone list and group multipliers
    4641             : 
    4642             :     int ActualTimeMin;
    4643             : 
    4644      161715 :     if (!state.dataGlobal->DoWeathSim) return;
    4645             : 
    4646      161715 :     if (!state.dataOutRptPredefined->reportName(state.dataOutRptPredefined->pdrSensibleGain).show)
    4647           0 :         return; // don't gather data if report isn't requested
    4648             : 
    4649      161715 :     if (t_timeStepType == OutputProcessor::TimeStepType::Zone) return; // only add values over the HVAC timestep basis
    4650             : 
    4651       91539 :     auto &ort(state.dataOutRptTab);
    4652             : 
    4653       91539 :     if (ort->GatherHeatGainReportfirstTime) {
    4654           2 :         state.dataOutRptTab->radiantHeat.allocate(state.dataGlobal->NumOfZones);
    4655           2 :         state.dataOutRptTab->radiantCool.allocate(state.dataGlobal->NumOfZones);
    4656           2 :         state.dataOutRptTab->ATUHeat.allocate(state.dataGlobal->NumOfZones);
    4657           2 :         state.dataOutRptTab->ATUCool.allocate(state.dataGlobal->NumOfZones);
    4658           2 :         ort->GatherHeatGainReportfirstTime = false;
    4659             :     }
    4660             :     // clear the radiant surface accumulation variables
    4661       91539 :     state.dataOutRptTab->radiantHeat = 0.0;
    4662       91539 :     state.dataOutRptTab->radiantCool = 0.0;
    4663             :     // clear the ATU accumulation variables
    4664       91539 :     state.dataOutRptTab->ATUHeat = 0.0;
    4665       91539 :     state.dataOutRptTab->ATUCool = 0.0;
    4666             :     //--------------------
    4667             :     //     ANNUAL
    4668             :     //--------------------
    4669             :     // HVAC annual heating by ATU
    4670             :     // HVAC annual cooling by ATU
    4671      549234 :     for (state.dataOutRptTab->iunitGHGR = 1; state.dataOutRptTab->iunitGHGR <= (int)state.dataDefineEquipment->AirDistUnit.size();
    4672      457695 :          ++state.dataOutRptTab->iunitGHGR) {
    4673             :         // HVAC equipment should already have the multipliers included, no "* mult" needed (assumes autosized or multiplied hard-sized air flow).
    4674      457695 :         state.dataOutRptTab->curZoneGHGR = state.dataDefineEquipment->AirDistUnit(state.dataOutRptTab->iunitGHGR).ZoneNum;
    4675      457695 :         if ((state.dataOutRptTab->curZoneGHGR > 0) && (state.dataOutRptTab->curZoneGHGR <= state.dataGlobal->NumOfZones)) {
    4676      457695 :             ZonePreDefRep(state.dataOutRptTab->curZoneGHGR).SHGSAnHvacATUHt +=
    4677      457695 :                 state.dataDefineEquipment->AirDistUnit(state.dataOutRptTab->iunitGHGR).HeatGain;
    4678      457695 :             ZonePreDefRep(state.dataOutRptTab->curZoneGHGR).SHGSAnHvacATUCl -=
    4679      457695 :                 state.dataDefineEquipment->AirDistUnit(state.dataOutRptTab->iunitGHGR).CoolGain;
    4680      457695 :             state.dataOutRptTab->ATUHeat(state.dataOutRptTab->curZoneGHGR) +=
    4681      457695 :                 state.dataDefineEquipment->AirDistUnit(state.dataOutRptTab->iunitGHGR).HeatRate;
    4682      457695 :             state.dataOutRptTab->ATUCool(state.dataOutRptTab->curZoneGHGR) -=
    4683      457695 :                 state.dataDefineEquipment->AirDistUnit(state.dataOutRptTab->iunitGHGR).CoolRate;
    4684             :         }
    4685             :     }
    4686       91539 :     state.dataOutRptTab->timeStepRatio =
    4687       91539 :         TimeStepSys / state.dataGlobal->TimeStepZone; // the fraction of the zone time step used by the system timestep
    4688      640773 :     for (state.dataOutRptTab->iZoneGHGR = 1; state.dataOutRptTab->iZoneGHGR <= state.dataGlobal->NumOfZones; ++state.dataOutRptTab->iZoneGHGR) {
    4689      549234 :         mult = Zone(state.dataOutRptTab->iZoneGHGR).Multiplier * Zone(state.dataOutRptTab->iZoneGHGR).ListMultiplier;
    4690             :         // People Sensible Heat Addition
    4691      549234 :         ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSAnPeoplAdd +=
    4692      549234 :             state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).PeopleSenGain * mult * state.dataOutRptTab->timeStepRatio;
    4693             :         // Lights Sensible Heat Addition
    4694      549234 :         ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSAnLiteAdd +=
    4695      549234 :             state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).LtsTotGain * mult * state.dataOutRptTab->timeStepRatio;
    4696             :         // HVAC Input Sensible Air Heating
    4697             :         // HVAC Input Sensible Air Cooling
    4698     1098468 :         Real64 ZoneEqHeatorCool = state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDTsystem +
    4699     1098468 :                                   state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumNonAirSystem * mult -
    4700      549234 :                                   state.dataOutRptTab->ATUHeat(state.dataOutRptTab->iZoneGHGR) -
    4701      549234 :                                   state.dataOutRptTab->ATUCool(state.dataOutRptTab->iZoneGHGR);
    4702      549234 :         if (ZoneEqHeatorCool > 0.0) {
    4703       43658 :             ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSAnZoneEqHt += ZoneEqHeatorCool * TimeStepSys * DataGlobalConstants::SecInHour;
    4704             :         } else {
    4705      505576 :             ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSAnZoneEqCl += ZoneEqHeatorCool * TimeStepSys * DataGlobalConstants::SecInHour;
    4706             :         }
    4707             :         // Interzone Air Transfer Heat Addition
    4708             :         // Interzone Air Transfer Heat Removal
    4709      549234 :         if (state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDTzones > 0.0) {
    4710           0 :             ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSAnIzaAdd +=
    4711           0 :                 state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDTzones * mult * TimeStepSys * DataGlobalConstants::SecInHour;
    4712             :         } else {
    4713      549234 :             ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSAnIzaRem +=
    4714      549234 :                 state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDTzones * mult * TimeStepSys * DataGlobalConstants::SecInHour;
    4715             :         }
    4716             :         // Window Heat Addition
    4717             :         // Window Heat Removal
    4718      549234 :         ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSAnWindAdd +=
    4719      549234 :             state.dataHeatBal->ZoneWinHeatGainRepEnergy(state.dataOutRptTab->iZoneGHGR) * mult * state.dataOutRptTab->timeStepRatio;
    4720      549234 :         ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSAnWindRem -=
    4721      549234 :             state.dataHeatBal->ZoneWinHeatLossRepEnergy(state.dataOutRptTab->iZoneGHGR) * mult * state.dataOutRptTab->timeStepRatio;
    4722             :         // Infiltration Heat Addition
    4723             :         // Infiltration Heat Removal
    4724      549234 :         if (state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDtInfil > 0.0) {
    4725       11260 :             ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSAnInfilAdd +=
    4726       11260 :                 state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDtInfil * mult * TimeStepSys * DataGlobalConstants::SecInHour;
    4727             :         } else {
    4728      537974 :             ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSAnInfilRem +=
    4729      537974 :                 state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDtInfil * mult * TimeStepSys * DataGlobalConstants::SecInHour;
    4730             :         }
    4731             :         // Equipment Sensible Heat Addition
    4732             :         // Equipment Sensible Heat Removal
    4733             :         // the following variables are already gains so they do not need to be converted by multiplying by time.
    4734     1647702 :         state.dataOutRptTab->eqpSensGHGR = (state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).ElecRadGain +
    4735     1098468 :                                             state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).GasRadGain +
    4736     1098468 :                                             state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).HWRadGain +
    4737     1098468 :                                             state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).SteamRadGain +
    4738     1098468 :                                             state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).OtherRadGain +
    4739     1098468 :                                             state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).ElecConGain +
    4740     1098468 :                                             state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).GasConGain +
    4741     1098468 :                                             state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).HWConGain +
    4742     1098468 :                                             state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).SteamConGain +
    4743     1098468 :                                             state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).OtherConGain) *
    4744      549234 :                                            state.dataOutRptTab->timeStepRatio;
    4745      549234 :         if (state.dataOutRptTab->eqpSensGHGR > 0.0) {
    4746      457695 :             ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSAnEquipAdd += state.dataOutRptTab->eqpSensGHGR * mult;
    4747             :         } else {
    4748       91539 :             ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSAnEquipRem += state.dataOutRptTab->eqpSensGHGR * mult;
    4749             :         }
    4750             :     }
    4751       91539 :     state.dataOutRptTab->curZoneGHGR = 0;
    4752             :     // HVAC Input Heated Surface Heating
    4753             :     // HVAC Input Cooled Surface Cooling
    4754       91539 :     for (state.dataOutRptTab->iRadiantGHGR = 1; state.dataOutRptTab->iRadiantGHGR <= state.dataVentilatedSlab->NumOfVentSlabs;
    4755           0 :          ++state.dataOutRptTab->iRadiantGHGR) {
    4756           0 :         state.dataOutRptTab->curZoneGHGR = state.dataVentilatedSlab->VentSlab(state.dataOutRptTab->iRadiantGHGR).ZonePtr;
    4757           0 :         mult = Zone(state.dataOutRptTab->curZoneGHGR).Multiplier * Zone(state.dataOutRptTab->curZoneGHGR).ListMultiplier;
    4758           0 :         if ((state.dataOutRptTab->curZoneGHGR > 0) && (state.dataOutRptTab->curZoneGHGR <= state.dataGlobal->NumOfZones)) {
    4759           0 :             ZonePreDefRep(state.dataOutRptTab->curZoneGHGR).SHGSAnSurfHt +=
    4760           0 :                 state.dataVentilatedSlab->VentSlab(state.dataOutRptTab->iRadiantGHGR).RadHeatingEnergy * mult;
    4761           0 :             ZonePreDefRep(state.dataOutRptTab->curZoneGHGR).SHGSAnSurfCl -=
    4762           0 :                 state.dataVentilatedSlab->VentSlab(state.dataOutRptTab->iRadiantGHGR).RadCoolingEnergy * mult;
    4763           0 :             state.dataOutRptTab->radiantHeat(state.dataOutRptTab->curZoneGHGR) =
    4764           0 :                 state.dataVentilatedSlab->VentSlab(state.dataOutRptTab->iRadiantGHGR).RadHeatingPower * mult;
    4765           0 :             state.dataOutRptTab->radiantCool(state.dataOutRptTab->curZoneGHGR) =
    4766           0 :                 -state.dataVentilatedSlab->VentSlab(state.dataOutRptTab->iRadiantGHGR).RadCoolingPower * mult;
    4767             :         }
    4768             :     }
    4769       91539 :     for (state.dataOutRptTab->iRadiantGHGR = 1; state.dataOutRptTab->iRadiantGHGR <= state.dataLowTempRadSys->NumOfHydrLowTempRadSys;
    4770           0 :          ++state.dataOutRptTab->iRadiantGHGR) {
    4771           0 :         state.dataOutRptTab->curZoneGHGR = state.dataLowTempRadSys->HydrRadSys(state.dataOutRptTab->iRadiantGHGR).ZonePtr;
    4772           0 :         mult = Zone(state.dataOutRptTab->curZoneGHGR).Multiplier * Zone(state.dataOutRptTab->curZoneGHGR).ListMultiplier;
    4773           0 :         if ((state.dataOutRptTab->curZoneGHGR > 0) && (state.dataOutRptTab->curZoneGHGR <= state.dataGlobal->NumOfZones)) {
    4774           0 :             ZonePreDefRep(state.dataOutRptTab->curZoneGHGR).SHGSAnSurfHt +=
    4775           0 :                 state.dataLowTempRadSys->HydrRadSys(state.dataOutRptTab->iRadiantGHGR).HeatEnergy * mult;
    4776           0 :             ZonePreDefRep(state.dataOutRptTab->curZoneGHGR).SHGSAnSurfCl -=
    4777           0 :                 state.dataLowTempRadSys->HydrRadSys(state.dataOutRptTab->iRadiantGHGR).CoolEnergy * mult;
    4778           0 :             state.dataOutRptTab->radiantHeat(state.dataOutRptTab->curZoneGHGR) +=
    4779           0 :                 state.dataLowTempRadSys->HydrRadSys(state.dataOutRptTab->iRadiantGHGR).HeatPower * mult;
    4780           0 :             state.dataOutRptTab->radiantCool(state.dataOutRptTab->curZoneGHGR) -=
    4781           0 :                 state.dataLowTempRadSys->HydrRadSys(state.dataOutRptTab->iRadiantGHGR).CoolPower * mult;
    4782             :         }
    4783             :     }
    4784       91539 :     for (state.dataOutRptTab->iRadiantGHGR = 1; state.dataOutRptTab->iRadiantGHGR <= state.dataLowTempRadSys->NumOfCFloLowTempRadSys;
    4785           0 :          ++state.dataOutRptTab->iRadiantGHGR) {
    4786           0 :         state.dataOutRptTab->curZoneGHGR = state.dataLowTempRadSys->CFloRadSys(state.dataOutRptTab->iRadiantGHGR).ZonePtr;
    4787           0 :         mult = Zone(state.dataOutRptTab->curZoneGHGR).Multiplier * Zone(state.dataOutRptTab->curZoneGHGR).ListMultiplier;
    4788           0 :         if ((state.dataOutRptTab->curZoneGHGR > 0) && (state.dataOutRptTab->curZoneGHGR <= state.dataGlobal->NumOfZones)) {
    4789           0 :             ZonePreDefRep(state.dataOutRptTab->curZoneGHGR).SHGSAnSurfHt +=
    4790           0 :                 state.dataLowTempRadSys->CFloRadSys(state.dataOutRptTab->iRadiantGHGR).HeatEnergy * mult;
    4791           0 :             ZonePreDefRep(state.dataOutRptTab->curZoneGHGR).SHGSAnSurfCl -=
    4792           0 :                 state.dataLowTempRadSys->CFloRadSys(state.dataOutRptTab->iRadiantGHGR).CoolEnergy * mult;
    4793           0 :             state.dataOutRptTab->radiantHeat(state.dataOutRptTab->curZoneGHGR) +=
    4794           0 :                 state.dataLowTempRadSys->CFloRadSys(state.dataOutRptTab->iRadiantGHGR).HeatPower * mult;
    4795           0 :             state.dataOutRptTab->radiantCool(state.dataOutRptTab->curZoneGHGR) -=
    4796           0 :                 state.dataLowTempRadSys->CFloRadSys(state.dataOutRptTab->iRadiantGHGR).CoolPower * mult;
    4797             :         }
    4798             :     }
    4799       91539 :     for (state.dataOutRptTab->iRadiantGHGR = 1; state.dataOutRptTab->iRadiantGHGR <= state.dataLowTempRadSys->NumOfElecLowTempRadSys;
    4800           0 :          ++state.dataOutRptTab->iRadiantGHGR) {
    4801           0 :         state.dataOutRptTab->curZoneGHGR = state.dataLowTempRadSys->ElecRadSys(state.dataOutRptTab->iRadiantGHGR).ZonePtr;
    4802           0 :         mult = Zone(state.dataOutRptTab->curZoneGHGR).Multiplier * Zone(state.dataOutRptTab->curZoneGHGR).ListMultiplier;
    4803           0 :         if ((state.dataOutRptTab->curZoneGHGR > 0) && (state.dataOutRptTab->curZoneGHGR <= state.dataGlobal->NumOfZones)) {
    4804           0 :             ZonePreDefRep(state.dataOutRptTab->curZoneGHGR).SHGSAnSurfHt +=
    4805           0 :                 state.dataLowTempRadSys->ElecRadSys(state.dataOutRptTab->iRadiantGHGR).HeatEnergy * mult;
    4806           0 :             state.dataOutRptTab->radiantHeat(state.dataOutRptTab->curZoneGHGR) +=
    4807           0 :                 state.dataLowTempRadSys->ElecRadSys(state.dataOutRptTab->iRadiantGHGR).HeatPower * mult;
    4808             :         }
    4809             :     }
    4810             :     // Opaque Surface Conduction and Other Heat Addition
    4811             :     // Opaque Surface Conduction and Other Heat Removal
    4812      640773 :     for (state.dataOutRptTab->iZoneGHGR = 1; state.dataOutRptTab->iZoneGHGR <= state.dataGlobal->NumOfZones; ++state.dataOutRptTab->iZoneGHGR) {
    4813             :         // ZonePreDefRep variables above already inlude zone list and group multipliers
    4814      549234 :         state.dataOutRptTab->totalGHGR =
    4815     1098468 :             ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSAnPeoplAdd + ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSAnLiteAdd +
    4816     1647702 :             ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSAnZoneEqHt + ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSAnZoneEqCl +
    4817     1647702 :             ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSAnHvacATUHt + ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSAnHvacATUCl +
    4818     1647702 :             ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSAnIzaAdd + ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSAnIzaRem +
    4819     1647702 :             ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSAnWindAdd + ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSAnWindRem +
    4820     1647702 :             ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSAnInfilAdd + ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSAnInfilRem +
    4821     1647702 :             ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSAnEquipAdd + ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSAnEquipRem +
    4822     1098468 :             ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSAnSurfHt + ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSAnSurfCl;
    4823      549234 :         state.dataOutRptTab->totalGHGR =
    4824      549234 :             -state.dataOutRptTab->totalGHGR; // want to know the negative value of the sum since the row should add up to zero
    4825      549234 :         if (state.dataOutRptTab->totalGHGR > 0) {
    4826       29965 :             ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSAnOtherAdd = state.dataOutRptTab->totalGHGR;
    4827             :         } else {
    4828      519269 :             ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSAnOtherRem = state.dataOutRptTab->totalGHGR;
    4829             :         }
    4830             :     }
    4831             :     //--------------------------------
    4832             :     // ZONE PEAK COOLING AND HEATING
    4833             :     //--------------------------------
    4834      640773 :     for (state.dataOutRptTab->iZoneGHGR = 1; state.dataOutRptTab->iZoneGHGR <= state.dataGlobal->NumOfZones; ++state.dataOutRptTab->iZoneGHGR) {
    4835      549234 :         mult = Zone(state.dataOutRptTab->iZoneGHGR).Multiplier * Zone(state.dataOutRptTab->iZoneGHGR).ListMultiplier;
    4836             :         // RR I can't get the Infiltration Heat Addition/Removal columns to add up.
    4837             :         // THis is the only suspect line, mixing MCpDt terms and a power term looks fishy.
    4838     1647702 :         if ((state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDTsystem +
    4839     1098468 :              state.dataOutRptTab->radiantHeat(state.dataOutRptTab->iZoneGHGR) +
    4840     1098468 :              state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumNonAirSystem * mult) > 0) {
    4841      547587 :             if ((state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDTsystem +
    4842      365058 :                  state.dataOutRptTab->radiantHeat(state.dataOutRptTab->iZoneGHGR) +
    4843      365058 :                  state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumNonAirSystem * mult) >
    4844      182529 :                 ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).htPeak) {
    4845         360 :                 ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).htPeak =
    4846         720 :                     state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDTsystem +
    4847         720 :                     state.dataOutRptTab->radiantHeat(state.dataOutRptTab->iZoneGHGR) +
    4848         360 :                     state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumNonAirSystem * mult;
    4849             :                 // determine timestamp
    4850             :                 //      ActualTimeS = CurrentTime-TimeStepZone+SysTimeElapsed
    4851             :                 //      ActualtimeE = ActualTimeS+TimeStepSys
    4852             :                 //      ActualTimeHrS=INT(ActualTimeS)
    4853             :                 //      ActualTimeMin=NINT((ActualtimeE - ActualTimeHrS)*FracToMin)
    4854         360 :                 ActualTimeMin = DetermineMinuteForReporting(state, t_timeStepType);
    4855        1080 :                 EncodeMonDayHrMin(state.dataOutRptTab->timestepTimeStampGHGR,
    4856         360 :                                   state.dataEnvrn->Month,
    4857         360 :                                   state.dataEnvrn->DayOfMonth,
    4858         360 :                                   state.dataGlobal->HourOfDay,
    4859             :                                   ActualTimeMin);
    4860         360 :                 ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).htPtTimeStamp = state.dataOutRptTab->timestepTimeStampGHGR;
    4861             :                 // HVAC Input Sensible Air Heating
    4862             :                 // HVAC Input Sensible Air Cooling
    4863             :                 // non-HVAC ZnAirRpt variables DO NOT include zone multipliers
    4864         360 :                 ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtHvacHt =
    4865         720 :                     state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDTsystem +
    4866         360 :                     state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumNonAirSystem * mult;
    4867         360 :                 ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtHvacCl = 0.0;
    4868             :                 // HVAC Input Heated Surface Heating
    4869             :                 // HVAC Input Cooled Surface Cooling
    4870         360 :                 ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtSurfHt =
    4871         360 :                     state.dataOutRptTab->radiantHeat(state.dataOutRptTab->iZoneGHGR); // multipliers included above
    4872         360 :                 ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtSurfCl =
    4873         360 :                     state.dataOutRptTab->radiantCool(state.dataOutRptTab->iZoneGHGR); // multipliers included above
    4874             :                 // HVAC ATU Heating at Heat Peak
    4875             :                 // HVAC ATU Cooling at Heat Peak
    4876         360 :                 ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtHvacATUHt =
    4877         360 :                     state.dataOutRptTab->ATUHeat(state.dataOutRptTab->iZoneGHGR); // multipliers included above
    4878         360 :                 ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtHvacATUCl =
    4879         360 :                     state.dataOutRptTab->ATUCool(state.dataOutRptTab->iZoneGHGR); // multipliers included above
    4880             :                 // People Sensible Heat Addition
    4881         360 :                 ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtPeoplAdd =
    4882         360 :                     state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).PeopleSenGainRate * mult;
    4883             :                 // Lights Sensible Heat Addition
    4884         360 :                 ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtLiteAdd =
    4885         360 :                     state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).LtsTotGainRate * mult;
    4886             :                 // Equipment Sensible Heat Addition
    4887             :                 // Equipment Sensible Heat Removal
    4888             :                 // non-HVAC ZnAirRpt variables DO NOT include zone multipliers
    4889        1080 :                 state.dataOutRptTab->eqpSensGHGR = state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).ElecRadGainRate +
    4890         720 :                                                    state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).GasRadGainRate +
    4891         720 :                                                    state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).HWRadGainRate +
    4892         720 :                                                    state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).SteamRadGainRate +
    4893         720 :                                                    state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).OtherRadGainRate +
    4894         720 :                                                    state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).ElecConGainRate +
    4895         720 :                                                    state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).GasConGainRate +
    4896         720 :                                                    state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).HWConGainRate +
    4897         720 :                                                    state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).SteamConGainRate +
    4898         360 :                                                    state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).OtherConGainRate;
    4899         360 :                 if (state.dataOutRptTab->eqpSensGHGR > 0.0) {
    4900         243 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtEquipAdd = state.dataOutRptTab->eqpSensGHGR * mult;
    4901         243 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtEquipRem = 0.0;
    4902             :                 } else {
    4903         117 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtEquipAdd = 0.0;
    4904         117 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtEquipRem = state.dataOutRptTab->eqpSensGHGR * mult;
    4905             :                 }
    4906             :                 // Window Heat Addition
    4907             :                 // Window Heat Removal
    4908         360 :                 ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtWindAdd =
    4909         360 :                     state.dataHeatBal->ZoneWinHeatGainRep(state.dataOutRptTab->iZoneGHGR) * mult;
    4910         360 :                 ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtWindRem =
    4911         360 :                     -state.dataHeatBal->ZoneWinHeatLossRep(state.dataOutRptTab->iZoneGHGR) * mult;
    4912             :                 // mixing object heat addition and removal
    4913         360 :                 if (state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDTzones > 0.0) {
    4914           0 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtIzaAdd =
    4915           0 :                         state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDTzones * mult;
    4916           0 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtIzaRem = 0.0;
    4917             :                 } else {
    4918         360 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtIzaAdd = 0.0;
    4919         360 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtIzaRem =
    4920         360 :                         state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDTzones * mult;
    4921             :                 }
    4922             :                 // Infiltration Heat Addition
    4923             :                 // Infiltration Heat Removal
    4924         360 :                 if (state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDtInfil > 0.0) {
    4925           0 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtInfilAdd =
    4926           0 :                         state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDtInfil * mult;
    4927           0 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtInfilRem = 0.0;
    4928             :                 } else {
    4929         360 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtInfilAdd = 0.0;
    4930         360 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtInfilRem =
    4931         360 :                         state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDtInfil * mult;
    4932             :                 }
    4933             :                 // Opaque Surface Conduction and Other Heat Addition
    4934             :                 // Opaque Surface Conduction and Other Heat Removal
    4935         360 :                 state.dataOutRptTab->totalGHGR =
    4936         720 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtPeoplAdd + ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtLiteAdd +
    4937        1080 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtHvacHt + ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtHvacCl +
    4938        1080 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtIzaAdd + ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtIzaRem +
    4939        1080 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtWindAdd + ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtWindRem +
    4940        1080 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtInfilAdd + ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtInfilRem +
    4941        1080 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtEquipAdd + ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtEquipRem +
    4942         720 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtSurfHt + ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtSurfCl;
    4943         360 :                 state.dataOutRptTab->totalGHGR =
    4944         360 :                     -state.dataOutRptTab->totalGHGR; // want to know the negative value of the sum since the row should add up to zero
    4945         360 :                 if (state.dataOutRptTab->totalGHGR > 0) {
    4946         130 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtOtherAdd = state.dataOutRptTab->totalGHGR;
    4947         130 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtOtherRem = 0.0;
    4948             :                 } else {
    4949         230 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtOtherAdd = 0.0;
    4950         230 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSHtOtherRem = state.dataOutRptTab->totalGHGR;
    4951             :                 }
    4952             :             }
    4953             :         } else {
    4954     1100115 :             if ((state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDTsystem +
    4955      733410 :                  state.dataOutRptTab->radiantCool(state.dataOutRptTab->iZoneGHGR) +
    4956      733410 :                  state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumNonAirSystem * mult) <
    4957      366705 :                 ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).clPeak) {
    4958        1211 :                 ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).clPeak =
    4959        2422 :                     state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDTsystem +
    4960        2422 :                     state.dataOutRptTab->radiantCool(state.dataOutRptTab->iZoneGHGR) +
    4961        1211 :                     state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumNonAirSystem * mult;
    4962             :                 // determine timestamp
    4963             :                 //      ActualTimeS = CurrentTime-TimeStepZone+SysTimeElapsed
    4964             :                 //      ActualtimeE = ActualTimeS+TimeStepSys
    4965             :                 //      ActualTimeHrS=INT(ActualTimeS)
    4966             :                 //      ActualTimeMin=NINT((ActualtimeE - ActualTimeHrS)*FracToMin)
    4967        1211 :                 ActualTimeMin = DetermineMinuteForReporting(state, t_timeStepType);
    4968        3633 :                 EncodeMonDayHrMin(state.dataOutRptTab->timestepTimeStampGHGR,
    4969        1211 :                                   state.dataEnvrn->Month,
    4970        1211 :                                   state.dataEnvrn->DayOfMonth,
    4971        1211 :                                   state.dataGlobal->HourOfDay,
    4972             :                                   ActualTimeMin);
    4973        1211 :                 ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).clPtTimeStamp = state.dataOutRptTab->timestepTimeStampGHGR;
    4974             :                 // HVAC Input Sensible Air Heating
    4975             :                 // HVAC Input Sensible Air Cooling
    4976        1211 :                 ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClHvacHt = 0.0;
    4977        1211 :                 ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClHvacCl =
    4978        2422 :                     state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDTsystem +
    4979        1211 :                     state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumNonAirSystem * mult;
    4980             :                 // HVAC Input Heated Surface Heating
    4981             :                 // HVAC Input Cooled Surface Cooling
    4982        1211 :                 ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClSurfHt = state.dataOutRptTab->radiantHeat(state.dataOutRptTab->iZoneGHGR);
    4983        1211 :                 ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClSurfCl = state.dataOutRptTab->radiantCool(state.dataOutRptTab->iZoneGHGR);
    4984             :                 // HVAC heating by ATU at cool peak
    4985             :                 // HVAC cooling by ATU at cool peak
    4986        1211 :                 ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClHvacATUHt = state.dataOutRptTab->ATUHeat(state.dataOutRptTab->iZoneGHGR);
    4987        1211 :                 ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClHvacATUCl = state.dataOutRptTab->ATUCool(state.dataOutRptTab->iZoneGHGR);
    4988             :                 // People Sensible Heat Addition
    4989        1211 :                 ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClPeoplAdd =
    4990        1211 :                     state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).PeopleSenGainRate * mult;
    4991             :                 // Lights Sensible Heat Addition
    4992        1211 :                 ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClLiteAdd =
    4993        1211 :                     state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).LtsTotGainRate * mult;
    4994             :                 // Equipment Sensible Heat Addition
    4995             :                 // Equipment Sensible Heat Removal
    4996        3633 :                 state.dataOutRptTab->eqpSensGHGR = state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).ElecRadGainRate +
    4997        2422 :                                                    state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).GasRadGainRate +
    4998        2422 :                                                    state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).HWRadGainRate +
    4999        2422 :                                                    state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).SteamRadGainRate +
    5000        2422 :                                                    state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).OtherRadGainRate +
    5001        2422 :                                                    state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).ElecConGainRate +
    5002        2422 :                                                    state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).GasConGainRate +
    5003        2422 :                                                    state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).HWConGainRate +
    5004        2422 :                                                    state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).SteamConGainRate +
    5005        1211 :                                                    state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).OtherConGainRate;
    5006        1211 :                 if (state.dataOutRptTab->eqpSensGHGR > 0.0) {
    5007        1077 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClEquipAdd = state.dataOutRptTab->eqpSensGHGR * mult;
    5008        1077 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClEquipRem = 0.0;
    5009             :                 } else {
    5010         134 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClEquipAdd = 0.0;
    5011         134 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClEquipRem = state.dataOutRptTab->eqpSensGHGR * mult;
    5012             :                 }
    5013             :                 // Window Heat Addition
    5014             :                 // Window Heat Removal
    5015        1211 :                 ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClWindAdd =
    5016        1211 :                     state.dataHeatBal->ZoneWinHeatGainRep(state.dataOutRptTab->iZoneGHGR) * mult;
    5017        1211 :                 ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClWindRem =
    5018        1211 :                     -state.dataHeatBal->ZoneWinHeatLossRep(state.dataOutRptTab->iZoneGHGR) * mult;
    5019             :                 // mixing object cool addition and removal
    5020        1211 :                 if (state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDTzones > 0.0) {
    5021           0 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClIzaAdd =
    5022           0 :                         state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDTzones * mult;
    5023           0 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClIzaRem = 0.0;
    5024             :                 } else {
    5025        1211 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClIzaAdd = 0.0;
    5026        1211 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClIzaRem =
    5027        1211 :                         state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDTzones * mult;
    5028             :                 }
    5029             :                 // Infiltration Heat Addition
    5030             :                 // Infiltration Heat Removal
    5031        1211 :                 if (state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDtInfil > 0.0) {
    5032          71 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClInfilAdd =
    5033          71 :                         state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDtInfil * mult;
    5034          71 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClInfilRem = 0.0;
    5035             :                 } else {
    5036        1140 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClInfilAdd = 0.0;
    5037        1140 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClInfilRem =
    5038        1140 :                         state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDtInfil * mult;
    5039             :                 }
    5040             :                 // Opaque Surface Conduction and Other Heat Addition
    5041             :                 // Opaque Surface Conduction and Other Heat Removal
    5042        1211 :                 state.dataOutRptTab->totalGHGR =
    5043        2422 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClPeoplAdd + ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClLiteAdd +
    5044        3633 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClHvacHt + ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClHvacCl +
    5045        3633 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClIzaAdd + ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClIzaRem +
    5046        3633 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClWindAdd + ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClWindRem +
    5047        3633 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClInfilAdd + ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClInfilRem +
    5048        3633 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClEquipAdd + ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClEquipRem +
    5049        2422 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClSurfHt + ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClSurfCl;
    5050        1211 :                 state.dataOutRptTab->totalGHGR =
    5051        1211 :                     -state.dataOutRptTab->totalGHGR; // want to know the negative value of the sum since the row should add up to zero
    5052        1211 :                 if (state.dataOutRptTab->totalGHGR > 0) {
    5053         172 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClOtherAdd = state.dataOutRptTab->totalGHGR;
    5054         172 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClOtherRem = 0.0;
    5055             :                 } else {
    5056        1039 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClOtherAdd = 0.0;
    5057        1039 :                     ZonePreDefRep(state.dataOutRptTab->iZoneGHGR).SHGSClOtherRem = state.dataOutRptTab->totalGHGR;
    5058             :                 }
    5059             :             }
    5060             :         }
    5061             :     }
    5062             :     //------------------------------------
    5063             :     // BUILDING PEAK COOLING AND HEATING
    5064             :     //------------------------------------
    5065       91539 :     state.dataOutRptTab->bldgHtPk = 0.0;
    5066       91539 :     state.dataOutRptTab->bldgClPk = 0.0;
    5067      640773 :     for (state.dataOutRptTab->iZoneGHGR = 1; state.dataOutRptTab->iZoneGHGR <= state.dataGlobal->NumOfZones; ++state.dataOutRptTab->iZoneGHGR) {
    5068      549234 :         mult = Zone(state.dataOutRptTab->iZoneGHGR).Multiplier * Zone(state.dataOutRptTab->iZoneGHGR).ListMultiplier;
    5069     1647702 :         if ((state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDTsystem +
    5070     1098468 :              state.dataOutRptTab->radiantHeat(state.dataOutRptTab->iZoneGHGR) +
    5071     1098468 :              state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumNonAirSystem * mult) > 0) {
    5072      547587 :             state.dataOutRptTab->bldgHtPk += state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDTsystem +
    5073      365058 :                                              state.dataOutRptTab->radiantHeat(state.dataOutRptTab->iZoneGHGR) +
    5074      182529 :                                              state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumNonAirSystem * mult;
    5075             :         } else {
    5076     1100115 :             state.dataOutRptTab->bldgClPk += state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDTsystem +
    5077      733410 :                                              state.dataOutRptTab->radiantCool(state.dataOutRptTab->iZoneGHGR) +
    5078      366705 :                                              state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumNonAirSystem * mult;
    5079             :         }
    5080             :     }
    5081       91539 :     if (state.dataOutRptTab->bldgHtPk > state.dataHeatBal->BuildingPreDefRep.htPeak) {
    5082          93 :         state.dataHeatBal->BuildingPreDefRep.htPeak = state.dataOutRptTab->bldgHtPk;
    5083             :         // determine timestamp
    5084             :         //  ActualTimeS = CurrentTime-TimeStepZone+SysTimeElapsed
    5085             :         //  ActualtimeE = ActualTimeS+TimeStepSys
    5086             :         //  ActualTimeHrS=INT(ActualTimeS)
    5087             :         //  ActualTimeMin=NINT((ActualtimeE - ActualTimeHrS)*FracToMin)
    5088          93 :         ActualTimeMin = DetermineMinuteForReporting(state, t_timeStepType);
    5089         279 :         EncodeMonDayHrMin(state.dataOutRptTab->timestepTimeStampGHGR,
    5090          93 :                           state.dataEnvrn->Month,
    5091          93 :                           state.dataEnvrn->DayOfMonth,
    5092          93 :                           state.dataGlobal->HourOfDay,
    5093             :                           ActualTimeMin);
    5094          93 :         state.dataHeatBal->BuildingPreDefRep.htPtTimeStamp = state.dataOutRptTab->timestepTimeStampGHGR;
    5095             :         // reset building level results to zero prior to accumulating across zones
    5096          93 :         state.dataHeatBal->BuildingPreDefRep.SHGSHtHvacHt = 0.0;
    5097          93 :         state.dataHeatBal->BuildingPreDefRep.SHGSHtHvacCl = 0.0;
    5098          93 :         state.dataHeatBal->BuildingPreDefRep.SHGSHtHvacATUHt = 0.0;
    5099          93 :         state.dataHeatBal->BuildingPreDefRep.SHGSHtHvacATUCl = 0.0;
    5100          93 :         state.dataHeatBal->BuildingPreDefRep.SHGSHtSurfHt = 0.0;
    5101          93 :         state.dataHeatBal->BuildingPreDefRep.SHGSHtSurfCl = 0.0;
    5102          93 :         state.dataHeatBal->BuildingPreDefRep.SHGSHtPeoplAdd = 0.0;
    5103          93 :         state.dataHeatBal->BuildingPreDefRep.SHGSHtLiteAdd = 0.0;
    5104          93 :         state.dataHeatBal->BuildingPreDefRep.SHGSHtEquipAdd = 0.0;
    5105          93 :         state.dataHeatBal->BuildingPreDefRep.SHGSHtWindAdd = 0.0;
    5106          93 :         state.dataHeatBal->BuildingPreDefRep.SHGSHtIzaAdd = 0.0;
    5107          93 :         state.dataHeatBal->BuildingPreDefRep.SHGSHtInfilAdd = 0.0;
    5108          93 :         state.dataHeatBal->BuildingPreDefRep.SHGSHtOtherAdd = 0.0;
    5109          93 :         state.dataHeatBal->BuildingPreDefRep.SHGSHtEquipRem = 0.0;
    5110          93 :         state.dataHeatBal->BuildingPreDefRep.SHGSHtWindRem = 0.0;
    5111          93 :         state.dataHeatBal->BuildingPreDefRep.SHGSHtIzaRem = 0.0;
    5112          93 :         state.dataHeatBal->BuildingPreDefRep.SHGSHtInfilRem = 0.0;
    5113          93 :         state.dataHeatBal->BuildingPreDefRep.SHGSHtOtherRem = 0.0;
    5114         651 :         for (state.dataOutRptTab->iZoneGHGR = 1; state.dataOutRptTab->iZoneGHGR <= state.dataGlobal->NumOfZones; ++state.dataOutRptTab->iZoneGHGR) {
    5115         558 :             mult = Zone(state.dataOutRptTab->iZoneGHGR).Multiplier * Zone(state.dataOutRptTab->iZoneGHGR).ListMultiplier;
    5116             :             // HVAC Input Sensible Air Heating
    5117             :             // HVAC Input Sensible Air Cooling
    5118        1116 :             state.dataHeatBal->BuildingPreDefRep.SHGSHtHvacHt += state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDTsystem +
    5119         558 :                                                                  state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumNonAirSystem * mult;
    5120             :             // HVAC Input Heated Surface Heating
    5121             :             // HVAC Input Cooled Surface Cooling
    5122         558 :             state.dataHeatBal->BuildingPreDefRep.SHGSHtSurfHt += state.dataOutRptTab->radiantHeat(state.dataOutRptTab->iZoneGHGR);
    5123         558 :             state.dataHeatBal->BuildingPreDefRep.SHGSHtSurfCl += state.dataOutRptTab->radiantCool(state.dataOutRptTab->iZoneGHGR);
    5124             :             // HVAC ATU Heating
    5125             :             // HVAC ATU Cooling
    5126         558 :             state.dataHeatBal->BuildingPreDefRep.SHGSHtHvacATUHt += state.dataOutRptTab->ATUHeat(state.dataOutRptTab->iZoneGHGR);
    5127         558 :             state.dataHeatBal->BuildingPreDefRep.SHGSHtHvacATUCl += state.dataOutRptTab->ATUCool(state.dataOutRptTab->iZoneGHGR);
    5128             :             // People Sensible Heat Addition
    5129         558 :             state.dataHeatBal->BuildingPreDefRep.SHGSHtPeoplAdd +=
    5130         558 :                 state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).PeopleSenGainRate * mult;
    5131             :             // Lights Sensible Heat Addition
    5132         558 :             state.dataHeatBal->BuildingPreDefRep.SHGSHtLiteAdd += state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).LtsTotGainRate * mult;
    5133             :             // Equipment Sensible Heat Addition
    5134             :             // Equipment Sensible Heat Removal
    5135        1674 :             state.dataOutRptTab->eqpSensGHGR = state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).ElecRadGainRate +
    5136        1116 :                                                state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).GasRadGainRate +
    5137        1116 :                                                state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).HWRadGainRate +
    5138        1116 :                                                state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).SteamRadGainRate +
    5139        1116 :                                                state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).OtherRadGainRate +
    5140        1116 :                                                state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).ElecConGainRate +
    5141        1116 :                                                state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).GasConGainRate +
    5142        1116 :                                                state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).HWConGainRate +
    5143        1116 :                                                state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).SteamConGainRate +
    5144         558 :                                                state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).OtherConGainRate;
    5145         558 :             if (state.dataOutRptTab->eqpSensGHGR > 0.0) {
    5146         465 :                 state.dataHeatBal->BuildingPreDefRep.SHGSHtEquipAdd += state.dataOutRptTab->eqpSensGHGR * mult;
    5147             :             } else {
    5148          93 :                 state.dataHeatBal->BuildingPreDefRep.SHGSHtEquipRem += state.dataOutRptTab->eqpSensGHGR * mult;
    5149             :             }
    5150             :             // Window Heat Addition
    5151             :             // Window Heat Removal
    5152         558 :             state.dataHeatBal->BuildingPreDefRep.SHGSHtWindAdd += state.dataHeatBal->ZoneWinHeatGainRep(state.dataOutRptTab->iZoneGHGR) * mult;
    5153         558 :             state.dataHeatBal->BuildingPreDefRep.SHGSHtWindRem -= state.dataHeatBal->ZoneWinHeatLossRep(state.dataOutRptTab->iZoneGHGR) * mult;
    5154             :             // mixing object heat addition and removal
    5155         558 :             if (state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDTzones > 0.0) {
    5156           0 :                 state.dataHeatBal->BuildingPreDefRep.SHGSHtIzaAdd += state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDTzones * mult;
    5157             :             } else {
    5158         558 :                 state.dataHeatBal->BuildingPreDefRep.SHGSHtIzaRem += state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDTzones * mult;
    5159             :             }
    5160             :             // Infiltration Heat Addition
    5161             :             // Infiltration Heat Removal
    5162         558 :             if (state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDtInfil > 00) {
    5163           0 :                 state.dataHeatBal->BuildingPreDefRep.SHGSHtInfilAdd +=
    5164           0 :                     state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDtInfil * mult;
    5165             :             } else {
    5166         558 :                 state.dataHeatBal->BuildingPreDefRep.SHGSHtInfilRem +=
    5167         558 :                     state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDtInfil * mult;
    5168             :             }
    5169             :         }
    5170             :         // Opaque Surface Conduction and Other Heat Addition
    5171             :         // Opaque Surface Conduction and Other Heat Removal
    5172         279 :         state.dataOutRptTab->totalGHGR = state.dataHeatBal->BuildingPreDefRep.SHGSHtPeoplAdd + state.dataHeatBal->BuildingPreDefRep.SHGSHtLiteAdd +
    5173         279 :                                          state.dataHeatBal->BuildingPreDefRep.SHGSHtHvacHt + state.dataHeatBal->BuildingPreDefRep.SHGSHtHvacCl +
    5174         279 :                                          state.dataHeatBal->BuildingPreDefRep.SHGSHtIzaAdd + state.dataHeatBal->BuildingPreDefRep.SHGSHtIzaRem +
    5175         279 :                                          state.dataHeatBal->BuildingPreDefRep.SHGSHtWindAdd + state.dataHeatBal->BuildingPreDefRep.SHGSHtWindRem +
    5176         279 :                                          state.dataHeatBal->BuildingPreDefRep.SHGSHtInfilAdd + state.dataHeatBal->BuildingPreDefRep.SHGSHtInfilRem +
    5177         279 :                                          state.dataHeatBal->BuildingPreDefRep.SHGSHtEquipAdd + state.dataHeatBal->BuildingPreDefRep.SHGSHtEquipRem +
    5178         186 :                                          state.dataHeatBal->BuildingPreDefRep.SHGSHtSurfHt + state.dataHeatBal->BuildingPreDefRep.SHGSHtSurfCl;
    5179          93 :         state.dataOutRptTab->totalGHGR =
    5180          93 :             -state.dataOutRptTab->totalGHGR; // want to know the negative value of the sum since the row should add up to zero
    5181          93 :         if (state.dataOutRptTab->totalGHGR > 0) {
    5182          40 :             state.dataHeatBal->BuildingPreDefRep.SHGSHtOtherAdd += state.dataOutRptTab->totalGHGR;
    5183             :         } else {
    5184          53 :             state.dataHeatBal->BuildingPreDefRep.SHGSHtOtherRem += state.dataOutRptTab->totalGHGR;
    5185             :         }
    5186             :     }
    5187       91539 :     if (state.dataOutRptTab->bldgClPk < state.dataHeatBal->BuildingPreDefRep.clPeak) {
    5188         267 :         state.dataHeatBal->BuildingPreDefRep.clPeak = state.dataOutRptTab->bldgClPk;
    5189             :         // determine timestamp
    5190             :         //  ActualTimeS = CurrentTime-TimeStepZone+SysTimeElapsed
    5191             :         //  ActualtimeE = ActualTimeS+TimeStepSys
    5192             :         //  ActualTimeHrS=INT(ActualTimeS)
    5193             :         //  ActualTimeMin=NINT((ActualtimeE - ActualTimeHrS)*FracToMin)
    5194         267 :         ActualTimeMin = DetermineMinuteForReporting(state, t_timeStepType);
    5195         801 :         EncodeMonDayHrMin(state.dataOutRptTab->timestepTimeStampGHGR,
    5196         267 :                           state.dataEnvrn->Month,
    5197         267 :                           state.dataEnvrn->DayOfMonth,
    5198         267 :                           state.dataGlobal->HourOfDay,
    5199             :                           ActualTimeMin);
    5200         267 :         state.dataHeatBal->BuildingPreDefRep.clPtTimeStamp = state.dataOutRptTab->timestepTimeStampGHGR;
    5201             :         // reset building level results to zero prior to accumulating across zones
    5202         267 :         state.dataHeatBal->BuildingPreDefRep.SHGSClHvacHt = 0.0;
    5203         267 :         state.dataHeatBal->BuildingPreDefRep.SHGSClHvacCl = 0.0;
    5204         267 :         state.dataHeatBal->BuildingPreDefRep.SHGSClSurfHt = 0.0;
    5205         267 :         state.dataHeatBal->BuildingPreDefRep.SHGSClSurfCl = 0.0;
    5206         267 :         state.dataHeatBal->BuildingPreDefRep.SHGSClHvacATUHt = 0.0;
    5207         267 :         state.dataHeatBal->BuildingPreDefRep.SHGSClHvacATUCl = 0.0;
    5208         267 :         state.dataHeatBal->BuildingPreDefRep.SHGSClPeoplAdd = 0.0;
    5209         267 :         state.dataHeatBal->BuildingPreDefRep.SHGSClLiteAdd = 0.0;
    5210         267 :         state.dataHeatBal->BuildingPreDefRep.SHGSClEquipAdd = 0.0;
    5211         267 :         state.dataHeatBal->BuildingPreDefRep.SHGSClWindAdd = 0.0;
    5212         267 :         state.dataHeatBal->BuildingPreDefRep.SHGSClIzaAdd = 0.0;
    5213         267 :         state.dataHeatBal->BuildingPreDefRep.SHGSClInfilAdd = 0.0;
    5214         267 :         state.dataHeatBal->BuildingPreDefRep.SHGSClOtherAdd = 0.0;
    5215         267 :         state.dataHeatBal->BuildingPreDefRep.SHGSClEquipRem = 0.0;
    5216         267 :         state.dataHeatBal->BuildingPreDefRep.SHGSClWindRem = 0.0;
    5217         267 :         state.dataHeatBal->BuildingPreDefRep.SHGSClIzaRem = 0.0;
    5218         267 :         state.dataHeatBal->BuildingPreDefRep.SHGSClInfilRem = 0.0;
    5219         267 :         state.dataHeatBal->BuildingPreDefRep.SHGSClOtherRem = 0.0;
    5220        1869 :         for (state.dataOutRptTab->iZoneGHGR = 1; state.dataOutRptTab->iZoneGHGR <= state.dataGlobal->NumOfZones; ++state.dataOutRptTab->iZoneGHGR) {
    5221        1602 :             mult = Zone(state.dataOutRptTab->iZoneGHGR).Multiplier * Zone(state.dataOutRptTab->iZoneGHGR).ListMultiplier;
    5222             :             // HVAC Input Sensible Air Heating
    5223             :             // HVAC Input Sensible Air Cooling
    5224        3204 :             state.dataHeatBal->BuildingPreDefRep.SHGSClHvacCl += state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDTsystem +
    5225        1602 :                                                                  state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumNonAirSystem * mult;
    5226             :             // HVAC Input Heated Surface Heating
    5227             :             // HVAC Input Cooled Surface Cooling
    5228        1602 :             state.dataHeatBal->BuildingPreDefRep.SHGSClSurfHt += state.dataOutRptTab->radiantHeat(state.dataOutRptTab->iZoneGHGR);
    5229        1602 :             state.dataHeatBal->BuildingPreDefRep.SHGSClSurfCl += state.dataOutRptTab->radiantCool(state.dataOutRptTab->iZoneGHGR);
    5230             :             // HVAC ATU Heating
    5231             :             // HVAC ATU Cooling
    5232        1602 :             state.dataHeatBal->BuildingPreDefRep.SHGSClHvacATUHt += state.dataOutRptTab->ATUHeat(state.dataOutRptTab->iZoneGHGR);
    5233        1602 :             state.dataHeatBal->BuildingPreDefRep.SHGSClHvacATUCl += state.dataOutRptTab->ATUCool(state.dataOutRptTab->iZoneGHGR);
    5234             :             // People Sensible Heat Addition
    5235        1602 :             state.dataHeatBal->BuildingPreDefRep.SHGSClPeoplAdd +=
    5236        1602 :                 state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).PeopleSenGainRate * mult;
    5237             :             // Lights Sensible Heat Addition
    5238        1602 :             state.dataHeatBal->BuildingPreDefRep.SHGSClLiteAdd += state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).LtsTotGainRate * mult;
    5239             :             // Equipment Sensible Heat Addition
    5240             :             // Equipment Sensible Heat Removal
    5241        4806 :             state.dataOutRptTab->eqpSensGHGR = state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).ElecRadGainRate +
    5242        3204 :                                                state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).GasRadGainRate +
    5243        3204 :                                                state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).HWRadGainRate +
    5244        3204 :                                                state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).SteamRadGainRate +
    5245        3204 :                                                state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).OtherRadGainRate +
    5246        3204 :                                                state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).ElecConGainRate +
    5247        3204 :                                                state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).GasConGainRate +
    5248        3204 :                                                state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).HWConGainRate +
    5249        3204 :                                                state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).SteamConGainRate +
    5250        1602 :                                                state.dataHeatBal->ZoneRpt(state.dataOutRptTab->iZoneGHGR).OtherConGainRate;
    5251        1602 :             if (state.dataOutRptTab->eqpSensGHGR > 0.0) {
    5252        1335 :                 state.dataHeatBal->BuildingPreDefRep.SHGSClEquipAdd += state.dataOutRptTab->eqpSensGHGR * mult;
    5253             :             } else {
    5254         267 :                 state.dataHeatBal->BuildingPreDefRep.SHGSClEquipRem += state.dataOutRptTab->eqpSensGHGR * mult;
    5255             :             }
    5256             :             // Window Heat Addition
    5257             :             // Window Heat Removal
    5258        1602 :             state.dataHeatBal->BuildingPreDefRep.SHGSClWindAdd += state.dataHeatBal->ZoneWinHeatGainRep(state.dataOutRptTab->iZoneGHGR) * mult;
    5259        1602 :             state.dataHeatBal->BuildingPreDefRep.SHGSClWindRem -= state.dataHeatBal->ZoneWinHeatLossRep(state.dataOutRptTab->iZoneGHGR) * mult;
    5260             :             // mixing object cool addition and removal
    5261        1602 :             if (state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDTzones > 0.0) {
    5262           0 :                 state.dataHeatBal->BuildingPreDefRep.SHGSClIzaAdd += state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDTzones * mult;
    5263             :             } else {
    5264        1602 :                 state.dataHeatBal->BuildingPreDefRep.SHGSClIzaRem += state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDTzones * mult;
    5265             :             }
    5266             :             // Infiltration Heat Addition
    5267             :             // Infiltration Heat Removal
    5268        1602 :             if (state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDtInfil > 00) {
    5269         140 :                 state.dataHeatBal->BuildingPreDefRep.SHGSClInfilAdd +=
    5270         140 :                     state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDtInfil * mult;
    5271             :             } else {
    5272        1462 :                 state.dataHeatBal->BuildingPreDefRep.SHGSClInfilRem +=
    5273        1462 :                     state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGHGR).SumMCpDtInfil * mult;
    5274             :             }
    5275             :         }
    5276             :         // Opaque Surface Conduction and Other Heat Addition
    5277             :         // Opaque Surface Conduction and Other Heat Removal
    5278         801 :         state.dataOutRptTab->totalGHGR = state.dataHeatBal->BuildingPreDefRep.SHGSClPeoplAdd + state.dataHeatBal->BuildingPreDefRep.SHGSClLiteAdd +
    5279         801 :                                          state.dataHeatBal->BuildingPreDefRep.SHGSClHvacHt + state.dataHeatBal->BuildingPreDefRep.SHGSClHvacCl +
    5280         801 :                                          state.dataHeatBal->BuildingPreDefRep.SHGSClIzaAdd + state.dataHeatBal->BuildingPreDefRep.SHGSClIzaRem +
    5281         801 :                                          state.dataHeatBal->BuildingPreDefRep.SHGSClWindAdd + state.dataHeatBal->BuildingPreDefRep.SHGSClWindRem +
    5282         801 :                                          state.dataHeatBal->BuildingPreDefRep.SHGSClInfilAdd + state.dataHeatBal->BuildingPreDefRep.SHGSClInfilRem +
    5283         801 :                                          state.dataHeatBal->BuildingPreDefRep.SHGSClEquipAdd + state.dataHeatBal->BuildingPreDefRep.SHGSClEquipRem +
    5284         534 :                                          state.dataHeatBal->BuildingPreDefRep.SHGSClSurfHt + state.dataHeatBal->BuildingPreDefRep.SHGSClSurfCl;
    5285         267 :         state.dataOutRptTab->totalGHGR =
    5286         267 :             -state.dataOutRptTab->totalGHGR; // want to know the negative value of the sum since the row should add up to zero
    5287         267 :         if (state.dataOutRptTab->totalGHGR > 0) {
    5288          24 :             state.dataHeatBal->BuildingPreDefRep.SHGSClOtherAdd += state.dataOutRptTab->totalGHGR;
    5289             :         } else {
    5290         243 :             state.dataHeatBal->BuildingPreDefRep.SHGSClOtherRem += state.dataOutRptTab->totalGHGR;
    5291             :         }
    5292             :     }
    5293             : }
    5294             : 
    5295             : //======================================================================================================================
    5296             : //======================================================================================================================
    5297             : 
    5298             : //    WRITE OUTPUT FILE ROUTINES
    5299             : 
    5300             : //======================================================================================================================
    5301             : //======================================================================================================================
    5302             : 
    5303         769 : void WriteTabularReports(EnergyPlusData &state)
    5304             : {
    5305             :     // SUBROUTINE INFORMATION:
    5306             :     //       AUTHOR         Jason Glazer
    5307             :     //       DATE WRITTEN   August 2003
    5308             :     //       MODIFIED       January 2021, J. Yuan
    5309             :     //                      Modified to accommodate dual-unit reporting
    5310             :     //       RE-ENGINEERED  na
    5311             : 
    5312             :     // PURPOSE OF THIS SUBROUTINE:
    5313             :     //   This routine hides from the main simulation that four specific
    5314             :     //   types of tabular reports are each created. If another type of
    5315             :     //   report is added it can be added to the list here.
    5316             : 
    5317         769 :     FillWeatherPredefinedEntries(state);
    5318         769 :     FillRemainingPredefinedEntries(state);
    5319         769 :     WaterManager::ReportRainfall(state);
    5320         769 :     auto &ort(state.dataOutRptTab);
    5321             : 
    5322             :     // Here to it is ready to assign ort->unitStyle_SQLite (not in SQLiteProcedures.cc)
    5323             :     // when ort->unitsStyle inputs should have been concretely processed and assigned.
    5324         769 :     if (ort->unitsStyle_SQLite == UnitsStyle::NotFound) {
    5325         769 :         ort->unitsStyle_SQLite = ort->unitsStyle; // This is the default UseOutputControlTableStyles
    5326             :     }
    5327             : 
    5328         769 :     if (ort->WriteTabularFiles) {
    5329             : 
    5330             :         // call each type of report in turn
    5331         731 :         WriteBEPSTable(state);
    5332         731 :         WriteTableOfContents(state);
    5333         731 :         WriteVeriSumTable(state);
    5334         731 :         WriteDemandEndUseSummary(state);
    5335         731 :         WriteSourceEnergyEndUseSummary(state);
    5336         731 :         WriteComponentSizing(state);
    5337         731 :         WriteSurfaceShadowing(state);
    5338         731 :         WriteCompCostTable(state);
    5339         731 :         WriteAdaptiveComfortTable(state);
    5340         731 :         WriteEioTables(state);
    5341         731 :         WriteLoadComponentSummaryTables(state);
    5342         731 :         WriteHeatEmissionTable(state);
    5343             : 
    5344         731 :         if (ort->displayThermalResilienceSummary && !state.dataGlobal->DoPureLoadCalc) // code will crash if pure load calc
    5345         656 :             WriteThermalResilienceTables(state);                                       // code will crash if pure load calc
    5346         731 :         if (ort->displayCO2ResilienceSummary && !state.dataGlobal->DoPureLoadCalc)     // code will crash if pure load calc
    5347          14 :             WriteCO2ResilienceTables(state);                                           // code will crash if pure load calc
    5348         731 :         if (ort->displayVisualResilienceSummary && !state.dataGlobal->DoPureLoadCalc)  // code will crash if pure load calc
    5349          53 :             WriteVisualResilienceTables(state);                                        // code will crash if pure load calc
    5350         731 :         if (state.dataWeatherManager->TotReportPers > 0) WriteReportPeriodTimeConsumption(state);
    5351         736 :         for (int i = 1; i <= state.dataWeatherManager->TotThermalReportPers; i++) {
    5352           5 :             WriteThermalResilienceTablesRepPeriod(state, i);
    5353             :         }
    5354         734 :         for (int i = 1; i <= state.dataWeatherManager->TotCO2ReportPers; i++) {
    5355           3 :             WriteCO2ResilienceTablesRepPeriod(state, i);
    5356             :         }
    5357         734 :         for (int i = 1; i <= state.dataWeatherManager->TotVisualReportPers; i++) {
    5358           3 :             WriteVisualResilienceTablesRepPeriod(state, i);
    5359             :         }
    5360             : 
    5361         731 :         state.dataRptCoilSelection->coilSelectionReportObj->finishCoilSummaryReportTable(
    5362             :             state);                   // call to write out the coil selection summary table data
    5363         731 :         WritePredefinedTables(state); // moved to come after zone load components is finished
    5364             : 
    5365         731 :         if (state.dataGlobal->DoWeathSim) {
    5366           2 :             WriteMonthlyTables(state);
    5367           2 :             WriteTimeBinTables(state);
    5368           2 :             OutputReportTabularAnnual::WriteAnnualTables(state);
    5369             :         }
    5370             :     }
    5371             : 
    5372             :     constexpr static auto variable_fmt{" {}={:12}\n"};
    5373             :     constexpr static auto variable_fmt_syntax = check_syntax(variable_fmt);
    5374         769 :     state.files.audit.ensure_open(state, "WriteTabularReports", state.files.outputControl.audit);
    5375         769 :     print<variable_fmt_syntax>(state.files.audit, variable_fmt, "MonthlyInputCount", ort->MonthlyInputCount);
    5376         769 :     print<variable_fmt_syntax>(state.files.audit, variable_fmt, "sizeMonthlyInput", ort->sizeMonthlyInput);
    5377         769 :     print<variable_fmt_syntax>(state.files.audit, variable_fmt, "MonthlyFieldSetInputCount", ort->MonthlyFieldSetInputCount);
    5378         769 :     print<variable_fmt_syntax>(state.files.audit, variable_fmt, "sizeMonthlyFieldSetInput", ort->sizeMonthlyFieldSetInput);
    5379         769 :     print<variable_fmt_syntax>(state.files.audit, variable_fmt, "MonthlyTablesCount", ort->MonthlyTablesCount);
    5380         769 :     print<variable_fmt_syntax>(state.files.audit, variable_fmt, "MonthlyColumnsCount", ort->MonthlyColumnsCount);
    5381         769 :     print<variable_fmt_syntax>(state.files.audit, variable_fmt, "sizeReportName", state.dataOutRptPredefined->sizeReportName);
    5382         769 :     print<variable_fmt_syntax>(state.files.audit, variable_fmt, "numReportName", state.dataOutRptPredefined->numReportName);
    5383         769 :     print<variable_fmt_syntax>(state.files.audit, variable_fmt, "sizeSubTable", state.dataOutRptPredefined->sizeSubTable);
    5384         769 :     print<variable_fmt_syntax>(state.files.audit, variable_fmt, "numSubTable", state.dataOutRptPredefined->numSubTable);
    5385         769 :     print<variable_fmt_syntax>(state.files.audit, variable_fmt, "sizeColumnTag", state.dataOutRptPredefined->sizeColumnTag);
    5386         769 :     print<variable_fmt_syntax>(state.files.audit, variable_fmt, "numColumnTag", state.dataOutRptPredefined->numColumnTag);
    5387         769 :     print<variable_fmt_syntax>(state.files.audit, variable_fmt, "sizeTableEntry", state.dataOutRptPredefined->sizeTableEntry);
    5388         769 :     print<variable_fmt_syntax>(state.files.audit, variable_fmt, "numTableEntry", state.dataOutRptPredefined->numTableEntry);
    5389         769 :     print<variable_fmt_syntax>(state.files.audit, variable_fmt, "sizeCompSizeTableEntry", state.dataOutRptPredefined->sizeCompSizeTableEntry);
    5390         769 :     print<variable_fmt_syntax>(state.files.audit, variable_fmt, "numCompSizeTableEntry", state.dataOutRptPredefined->numCompSizeTableEntry);
    5391         769 : }
    5392             : 
    5393       11210 : bool produceDualUnitsFlags(const int iUnit_Sys,
    5394             :                            const UnitsStyle unitsStyle_Tab,
    5395             :                            const UnitsStyle unitsStyle_Sql,
    5396             :                            UnitsStyle &unitsStyle_Cur,
    5397             :                            bool &produce_Tab,
    5398             :                            bool &produce_Sql)
    5399             : {
    5400             :     // January 2021:
    5401             :     // PURPOSE OF THIS SUBROUTINE:
    5402             :     // This routine sets the order and flags for tabular data and sqlite writing for a Dual-Unit reporting.
    5403             :     // It will set the unit styles to used, a flag for tabular data writing, and a flag for sqlite writing.
    5404             :     // The function will return a false flag if only a second round of (SQLite) writing is needed
    5405             :     // and will return a true flag if a second round SQLite writing is not needed.
    5406             : 
    5407       11210 :     bool brkflag(false);
    5408             : 
    5409       11210 :     if (iUnit_Sys == 0) {
    5410        5605 :         unitsStyle_Cur = unitsStyle_Tab;
    5411        5605 :         produce_Tab = true;
    5412        5605 :         if (unitsStyle_Sql == unitsStyle_Tab) {
    5413        5605 :             produce_Sql = true;
    5414             :         } else {
    5415           0 :             produce_Sql = false;
    5416             :         }
    5417             :     } else { // iUnit_Sys == 1
    5418        5605 :         unitsStyle_Cur = unitsStyle_Sql;
    5419        5605 :         produce_Tab = false;
    5420        5605 :         produce_Sql = true;
    5421        5605 :         if (unitsStyle_Sql == unitsStyle_Tab) {
    5422             :             // flag true if a separate SQLite round writing is not needed
    5423        5605 :             brkflag = true;
    5424        5605 :             produce_Sql = false;
    5425             :         }
    5426             :     }
    5427             : 
    5428             :     // False if a separate sqlite round is needed;
    5429             :     // true if not
    5430       11210 :     return brkflag;
    5431             : }
    5432             : 
    5433      413890 : void parseStatLine(const std::string &lineIn,
    5434             :                    StatLineType &lineType,
    5435             :                    bool &desConditionlinepassed,
    5436             :                    bool &heatingDesignlinepassed,
    5437             :                    bool &coolingDesignlinepassed,
    5438             :                    bool &isKoppen,
    5439             :                    bool &insideLiquidPrecipitation)
    5440             : {
    5441             :     // assumes that all the variables are initialized outside of this routine -- it does not re-initialize them
    5442      413890 :     if (has_prefix(lineIn, "Statistics")) {
    5443         759 :         lineType = StatLineType::StatisticsLine;
    5444      413131 :     } else if (has_prefix(lineIn, "Location")) {
    5445         759 :         lineType = StatLineType::LocationLine;
    5446      412372 :     } else if (has_prefix(lineIn, "{")) {
    5447         759 :         lineType = StatLineType::LatLongLine;
    5448      411613 :     } else if (has_prefix(lineIn, "Elevation")) {
    5449         759 :         lineType = StatLineType::ElevationLine;
    5450      410854 :     } else if (has_prefix(lineIn, "Standard Pressure")) {
    5451         759 :         lineType = StatLineType::StdPressureLine;
    5452      410095 :     } else if (has_prefix(lineIn, "Data Source")) {
    5453         759 :         lineType = StatLineType::DataSourceLine;
    5454      409336 :     } else if (has_prefix(lineIn, "WMO Station")) {
    5455         759 :         lineType = StatLineType::WMOStationLine;
    5456      408577 :     } else if (has(lineIn, "Design Conditions")) {
    5457        1489 :         if (!desConditionlinepassed) {
    5458         759 :             desConditionlinepassed = true;
    5459         759 :             lineType = StatLineType::DesignConditionsLine;
    5460             :         }
    5461      407088 :     } else if (has_prefix(lineIn, "\tHeating")) {
    5462         756 :         if (!heatingDesignlinepassed) {
    5463         756 :             heatingDesignlinepassed = true;
    5464         756 :             lineType = StatLineType::HeatingConditionsLine;
    5465             :         }
    5466      406332 :     } else if (has_prefix(lineIn, "\tCooling")) {
    5467         756 :         if (!coolingDesignlinepassed) {
    5468         756 :             coolingDesignlinepassed = true;
    5469         756 :             lineType = StatLineType::CoolingConditionsLine;
    5470             :         }
    5471      405576 :     } else if (has(lineIn, "(standard) heating degree-days (18.3")) {
    5472         730 :         lineType = StatLineType::StdHDDLine;
    5473      404846 :     } else if (has(lineIn, "(standard) cooling degree-days (10")) {
    5474         730 :         lineType = StatLineType::StdCDDLine;
    5475             : 
    5476      404116 :     } else if (has(lineIn, "Maximum Dry Bulb")) {
    5477         759 :         lineType = StatLineType::MaxDryBulbLine;
    5478      403357 :     } else if (has(lineIn, "Minimum Dry Bulb")) {
    5479         759 :         lineType = StatLineType::MinDryBulbLine;
    5480      402598 :     } else if (has(lineIn, "Maximum Dew Point")) {
    5481         759 :         lineType = StatLineType::MaxDewPointLine;
    5482      401839 :     } else if (has(lineIn, "Minimum Dew Point")) {
    5483         759 :         lineType = StatLineType::MinDewPointLine;
    5484      401080 :     } else if (has(lineIn, "(wthr file) heating degree-days (18") || has(lineIn, "heating degree-days (18")) {
    5485         759 :         lineType = StatLineType::WithHDDLine;
    5486      400321 :     } else if (has(lineIn, "(wthr file) cooling degree-days (10") || has(lineIn, "cooling degree-days (10")) {
    5487         759 :         lineType = StatLineType::WithCDDLine;
    5488             : 
    5489      399562 :     } else if (has(lineIn, "Statistics for Liquid Precipitation")) {
    5490         752 :         insideLiquidPrecipitation = true;
    5491      398810 :     } else if (insideLiquidPrecipitation && has(lineIn, "Total")) {
    5492         752 :         lineType = StatLineType::MonthlyPrec;
    5493      398058 :     } else if (insideLiquidPrecipitation && has(lineIn, "Max Hourly")) {
    5494         733 :         lineType = StatLineType::MaxHourlyPrec;
    5495         733 :         insideLiquidPrecipitation = false;
    5496             :     }
    5497             : 
    5498             :     // these not part of big if/else because sequential
    5499      413890 :     if (lineType == StatLineType::KoppenDes1Line && isKoppen) lineType = StatLineType::KoppenDes2Line;
    5500      413890 :     if (lineType == StatLineType::KoppenLine && isKoppen) lineType = StatLineType::KoppenDes1Line;
    5501      413890 :     if (has(lineIn, "ppen classification)")) lineType = StatLineType::KoppenLine;
    5502      413890 :     if (lineType == StatLineType::AshStdDes2Line) lineType = StatLineType::AshStdDes3Line;
    5503      413890 :     if (lineType == StatLineType::AshStdDes1Line) lineType = StatLineType::AshStdDes2Line;
    5504      413890 :     if (lineType == StatLineType::AshStdLine) lineType = StatLineType::AshStdDes1Line;
    5505      413890 :     if (has(lineIn, "ASHRAE Standard")) lineType = StatLineType::AshStdLine;
    5506      413890 : }
    5507             : 
    5508         769 : void FillWeatherPredefinedEntries(EnergyPlusData &state)
    5509             : {
    5510             :     // SUBROUTINE INFORMATION:
    5511             :     //       AUTHOR         Jason Glazer
    5512             :     //       DATE WRITTEN   Feb 2008
    5513             :     //       MODIFIED       na
    5514             :     //       RE-ENGINEERED  na
    5515             : 
    5516             :     // PURPOSE OF THIS SUBROUTINE:
    5517             :     //   Read the STAT file for the active weather file and summarize in a predefined report.
    5518             :     //   The stat file that is attached may have several formats -- from evolution of the
    5519             :     //   stat file from the weather converter (or others that produce a similar stat file).
    5520             : 
    5521             :     // Using/Aliasing
    5522             :     using namespace OutputReportPredefined;
    5523             : 
    5524             :     // SUBROUTINE PARAMETER DEFINITIONS:
    5525         769 :     static std::string const degChar("°");
    5526             : 
    5527         769 :     auto &ort(state.dataOutRptTab);
    5528             : 
    5529             :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
    5530             : 
    5531         769 :     StatLineType lineType = StatLineType::Initialized;
    5532         769 :     StatLineType lineTypeinterim = StatLineType::Initialized;
    5533             :     std::string::size_type ashPtr;
    5534             :     std::string::size_type lnPtr;
    5535             :     int col1;
    5536             :     int col2;
    5537             :     int col3;
    5538             :     std::string::size_type sposlt;
    5539             :     std::string::size_type eposlt;
    5540             :     std::string::size_type sposlg;
    5541             :     std::string::size_type eposlg;
    5542             :     std::string::size_type spostz;
    5543             :     std::string::size_type epostz;
    5544        1538 :     std::string ashDesYear;
    5545        1538 :     std::string ashZone; // ashrae climate zone
    5546        1538 :     std::string curNameWithSIUnits;
    5547        1538 :     std::string curNameAndUnits;
    5548             :     int indexUnitConv;
    5549             : 
    5550         769 :     bool isASHRAE = false;
    5551         769 :     bool iscalc = false;
    5552         769 :     bool isKoppen = false;
    5553         769 :     bool heatingDesignlinepassed = false;
    5554         769 :     bool coolingDesignlinepassed = false;
    5555         769 :     bool desConditionlinepassed = false;
    5556         769 :     bool insideLiquidPrecipitation = false;
    5557        1538 :     std::string storeASHRAEHDD;
    5558        1538 :     std::string storeASHRAECDD;
    5559             : 
    5560         769 :     lineTypeinterim = StatLineType::Initialized;
    5561         769 :     if (FileSystem::fileExists(state.files.inStatFilePath.filePath)) {
    5562        1518 :         auto statFile = state.files.inStatFilePath.open(state, "FillWeatherPredefinedEntries");
    5563      828539 :         while (statFile.good()) { // end of file, or error
    5564      413890 :             lineType = lineTypeinterim;
    5565      827780 :             auto lineIn = statFile.readLine().data;
    5566             :             // reconcile line with different versions of stat file
    5567             :             // v7.1 added version as first line.
    5568      413890 :             strip(lineIn);
    5569      413890 :             parseStatLine(
    5570             :                 lineIn, lineType, desConditionlinepassed, heatingDesignlinepassed, coolingDesignlinepassed, isKoppen, insideLiquidPrecipitation);
    5571             : 
    5572      413890 :             switch (lineType) {
    5573         759 :             case StatLineType::StatisticsLine: { // Statistics for USA_CA_San.Francisco_TMY2
    5574         759 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "Reference", lineIn.substr(15));
    5575         759 :             } break;
    5576         759 :             case StatLineType::LocationLine: { // Location -- SAN_FRANCISCO CA USA
    5577         759 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "Site:Location", lineIn.substr(11));
    5578         759 :             } break;
    5579         759 :             case StatLineType::LatLongLine: { //      {N 37° 37'} {W 122° 22'} {GMT -8.0 Hours}
    5580             :                 // find the {}
    5581         759 :                 sposlt = index(lineIn, '{');
    5582         759 :                 eposlt = index(lineIn, '}');
    5583         759 :                 if (sposlt != std::string::npos && eposlt != std::string::npos) {
    5584         759 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "Latitude", lineIn.substr(sposlt, eposlt - sposlt + 1));
    5585             :                     // redefine so next scan can go with {}
    5586         759 :                     lineIn[sposlt] = '[';
    5587         759 :                     lineIn[eposlt] = ']';
    5588             :                 } else {
    5589           0 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "Latitude", "not found");
    5590             :                 }
    5591         759 :                 sposlg = index(lineIn, '{');
    5592         759 :                 eposlg = index(lineIn, '}');
    5593         759 :                 if (sposlg != std::string::npos && eposlg != std::string::npos) {
    5594         759 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "Longitude", lineIn.substr(sposlg, eposlg - sposlg + 1));
    5595             :                     // redefine so next scan can go with {}
    5596         759 :                     lineIn[sposlg] = '[';
    5597         759 :                     lineIn[eposlg] = ']';
    5598             :                 } else {
    5599           0 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "Longitude", "not found");
    5600             :                 }
    5601         759 :                 spostz = index(lineIn, '{');
    5602         759 :                 epostz = index(lineIn, '}');
    5603         759 :                 if (spostz != std::string::npos && epostz != std::string::npos) {
    5604         759 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "Time Zone", lineIn.substr(spostz, epostz - spostz + 1));
    5605             :                     // redefine so next scan can go with {}
    5606         759 :                     lineIn[spostz] = '[';
    5607         759 :                     lineIn[epostz] = ']';
    5608             :                 } else {
    5609           0 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "Time Zone", "not found");
    5610             :                 }
    5611         759 :             } break;
    5612         759 :             case StatLineType::ElevationLine: { // Elevation --     5m above sea level
    5613         759 :                 lnPtr = index(lineIn.substr(12), 'm');
    5614         759 :                 if (lnPtr != std::string::npos) {
    5615         759 :                     curNameWithSIUnits = "Elevation (m) " + lineIn.substr(12 + lnPtr + 2);
    5616         759 :                     if (ort->unitsStyle == UnitsStyle::InchPound) {
    5617          11 :                         LookupSItoIP(state, curNameWithSIUnits, indexUnitConv, curNameAndUnits);
    5618          22 :                         PreDefTableEntry(state,
    5619          11 :                                          state.dataOutRptPredefined->pdchWthrVal,
    5620             :                                          curNameAndUnits,
    5621          22 :                                          RealToStr(ConvertIP(state, indexUnitConv, StrToReal(lineIn.substr(12, lnPtr))), 1));
    5622             :                     } else {
    5623         748 :                         PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, curNameWithSIUnits, lineIn.substr(12, lnPtr));
    5624             :                     }
    5625             :                 } else {
    5626           0 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "Elevation", "not found");
    5627             :                 }
    5628         759 :             } break;
    5629         759 :             case StatLineType::StdPressureLine: { // Standard Pressure at Elevation -- 101265Pa
    5630         759 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "Standard Pressure at Elevation", lineIn.substr(34));
    5631         759 :             } break;
    5632         759 :             case StatLineType::DataSourceLine: { // Data Source -- TMY2-23234
    5633         759 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "Data Source", lineIn.substr(15));
    5634         759 :             } break;
    5635         759 :             case StatLineType::WMOStationLine: { // WMO Station 724940
    5636         759 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "WMO Station", lineIn.substr(12));
    5637         759 :             } break;
    5638         759 :             case StatLineType::DesignConditionsLine: { //  - Using Design Conditions from "Climate Design Data 2005 ASHRAE Handbook"
    5639         759 :                 ashPtr = index(lineIn, "ASHRAE");
    5640         759 :                 if (ashPtr != std::string::npos) {
    5641         756 :                     isASHRAE = true;
    5642         756 :                     iscalc = true;
    5643         756 :                     if (ashPtr > 4u) { // Autodesk:BoundsViolation IF block added to protect against ashPtr<=5
    5644         756 :                         ashDesYear = lineIn.substr(ashPtr - 5, 5);
    5645             :                     } else {
    5646           0 :                         ashDesYear = "";
    5647             :                     }
    5648        1512 :                     PreDefTableEntry(state,
    5649         756 :                                      state.dataOutRptPredefined->pdchWthrVal,
    5650             :                                      "Weather File Design Conditions",
    5651        2268 :                                      "Climate Design Data " + ashDesYear + "ASHRAE Handbook");
    5652           3 :                 } else if (has(lineIn, "not calculated") || lineIn == "") {
    5653           0 :                     iscalc = false;
    5654           0 :                     PreDefTableEntry(
    5655           0 :                         state, state.dataOutRptPredefined->pdchWthrVal, "Weather File Design Conditions", "not calculated, Number of days < 1 year");
    5656             :                 } else {
    5657           3 :                     isASHRAE = false;
    5658           3 :                     iscalc = true;
    5659           3 :                     PreDefTableEntry(
    5660           3 :                         state, state.dataOutRptPredefined->pdchWthrVal, "Weather File Design Conditions", "Calculated from the weather file");
    5661             :                 }
    5662         759 :             } break;
    5663         756 :             case StatLineType::HeatingConditionsLine: { //  winter/heating design conditions
    5664         756 :                 if (iscalc) {
    5665         756 :                     if (isASHRAE) {
    5666         756 :                         if (ashDesYear == "2001") {
    5667           0 :                             if (ort->unitsStyle == UnitsStyle::InchPound) {
    5668           0 :                                 curNameWithSIUnits = "Heating Design Temperature 99.6% (C)";
    5669           0 :                                 LookupSItoIP(state, curNameWithSIUnits, indexUnitConv, curNameAndUnits);
    5670           0 :                                 PreDefTableEntry(state,
    5671           0 :                                                  state.dataOutRptPredefined->pdchWthrVal,
    5672             :                                                  curNameAndUnits,
    5673           0 :                                                  RealToStr(ConvertIP(state, indexUnitConv, StrToReal(GetColumnUsingTabs(lineIn, 2))), 1) + degChar);
    5674           0 :                                 PreDefTableEntry(state,
    5675           0 :                                                  state.dataOutRptPredefined->pdchWthrVal,
    5676             :                                                  "Heating Design Temperature 99% (F)",
    5677           0 :                                                  RealToStr(ConvertIP(state, indexUnitConv, StrToReal(GetColumnUsingTabs(lineIn, 3))), 1) + degChar);
    5678             :                             } else {
    5679           0 :                                 PreDefTableEntry(state,
    5680           0 :                                                  state.dataOutRptPredefined->pdchWthrVal,
    5681             :                                                  "Heating Design Temperature 99.6% (C)",
    5682           0 :                                                  GetColumnUsingTabs(lineIn, 2) + degChar);
    5683           0 :                                 PreDefTableEntry(state,
    5684           0 :                                                  state.dataOutRptPredefined->pdchWthrVal,
    5685             :                                                  "Heating Design Temperature 99% (C)",
    5686           0 :                                                  GetColumnUsingTabs(lineIn, 3) + degChar);
    5687             :                             }
    5688             :                         } else { // 2005 and 2009 are the same
    5689         756 :                             if (ort->unitsStyle == UnitsStyle::InchPound) {
    5690          11 :                                 curNameWithSIUnits = "Heating Design Temperature 99.6% (C)";
    5691          11 :                                 LookupSItoIP(state, curNameWithSIUnits, indexUnitConv, curNameAndUnits);
    5692          22 :                                 PreDefTableEntry(state,
    5693          11 :                                                  state.dataOutRptPredefined->pdchWthrVal,
    5694             :                                                  curNameAndUnits,
    5695          22 :                                                  RealToStr(ConvertIP(state, indexUnitConv, StrToReal(GetColumnUsingTabs(lineIn, 4))), 1) + degChar);
    5696          22 :                                 PreDefTableEntry(state,
    5697          11 :                                                  state.dataOutRptPredefined->pdchWthrVal,
    5698             :                                                  "Heating Design Temperature 99% (F)",
    5699          33 :                                                  RealToStr(ConvertIP(state, indexUnitConv, StrToReal(GetColumnUsingTabs(lineIn, 5))), 1) + degChar);
    5700             :                             } else {
    5701        1490 :                                 PreDefTableEntry(state,
    5702         745 :                                                  state.dataOutRptPredefined->pdchWthrVal,
    5703             :                                                  "Heating Design Temperature 99.6% (C)",
    5704        2235 :                                                  GetColumnUsingTabs(lineIn, 4) + degChar);
    5705        1490 :                                 PreDefTableEntry(state,
    5706         745 :                                                  state.dataOutRptPredefined->pdchWthrVal,
    5707             :                                                  "Heating Design Temperature 99% (C)",
    5708        2235 :                                                  GetColumnUsingTabs(lineIn, 5) + degChar);
    5709             :                             }
    5710             :                         }
    5711             :                     } else { // from weather file
    5712           0 :                         if (is_blank(GetColumnUsingTabs(lineIn, 5))) {
    5713           0 :                             col1 = 3;
    5714           0 :                             col2 = 4;
    5715             :                         } else {
    5716           0 :                             col1 = 4;
    5717           0 :                             col2 = 5;
    5718             :                         }
    5719           0 :                         if (ort->unitsStyle == UnitsStyle::InchPound) {
    5720           0 :                             curNameWithSIUnits = "Heating Design Temperature 99.6% (C)";
    5721           0 :                             LookupSItoIP(state, curNameWithSIUnits, indexUnitConv, curNameAndUnits);
    5722           0 :                             PreDefTableEntry(state,
    5723           0 :                                              state.dataOutRptPredefined->pdchWthrVal,
    5724             :                                              curNameAndUnits,
    5725           0 :                                              RealToStr(ConvertIP(state, indexUnitConv, StrToReal(GetColumnUsingTabs(lineIn, col1))), 1) + degChar);
    5726           0 :                             PreDefTableEntry(state,
    5727           0 :                                              state.dataOutRptPredefined->pdchWthrVal,
    5728             :                                              "Heating Design Temperature 99% (F)",
    5729           0 :                                              RealToStr(ConvertIP(state, indexUnitConv, StrToReal(GetColumnUsingTabs(lineIn, col2))), 1) + degChar);
    5730             :                         } else {
    5731           0 :                             PreDefTableEntry(state,
    5732           0 :                                              state.dataOutRptPredefined->pdchWthrVal,
    5733             :                                              "Heating Design Temperature 99.6% (C)",
    5734           0 :                                              GetColumnUsingTabs(lineIn, col1) + degChar);
    5735           0 :                             PreDefTableEntry(state,
    5736           0 :                                              state.dataOutRptPredefined->pdchWthrVal,
    5737             :                                              "Heating Design Temperature 99% (C)",
    5738           0 :                                              GetColumnUsingTabs(lineIn, col2) + degChar);
    5739             :                         }
    5740             :                     }
    5741             :                 }
    5742         756 :             } break;
    5743         756 :             case StatLineType::CoolingConditionsLine: { //  summer/cooling design conditions
    5744         756 :                 if (iscalc) {
    5745         756 :                     if (isASHRAE) {
    5746         756 :                         if (ashDesYear == "2001") {
    5747           0 :                             if (ort->unitsStyle == UnitsStyle::InchPound) {
    5748           0 :                                 curNameWithSIUnits = "Cooling Design Temperature 0.4% (C)";
    5749           0 :                                 LookupSItoIP(state, curNameWithSIUnits, indexUnitConv, curNameAndUnits);
    5750           0 :                                 PreDefTableEntry(state,
    5751           0 :                                                  state.dataOutRptPredefined->pdchWthrVal,
    5752             :                                                  curNameAndUnits,
    5753           0 :                                                  RealToStr(ConvertIP(state, indexUnitConv, StrToReal(GetColumnUsingTabs(lineIn, 2))), 1) + degChar);
    5754           0 :                                 PreDefTableEntry(state,
    5755           0 :                                                  state.dataOutRptPredefined->pdchWthrVal,
    5756             :                                                  "Cooling Design Temperature 1% (F)",
    5757           0 :                                                  RealToStr(ConvertIP(state, indexUnitConv, StrToReal(GetColumnUsingTabs(lineIn, 4))), 1) + degChar);
    5758           0 :                                 PreDefTableEntry(state,
    5759           0 :                                                  state.dataOutRptPredefined->pdchWthrVal,
    5760             :                                                  "Cooling Design Temperature 2% (F)",
    5761           0 :                                                  RealToStr(ConvertIP(state, indexUnitConv, StrToReal(GetColumnUsingTabs(lineIn, 6))), 1) + degChar);
    5762             :                             } else {
    5763           0 :                                 PreDefTableEntry(state,
    5764           0 :                                                  state.dataOutRptPredefined->pdchWthrVal,
    5765             :                                                  "Cooling Design Temperature 0.4% (C)",
    5766           0 :                                                  GetColumnUsingTabs(lineIn, 2) + degChar);
    5767           0 :                                 PreDefTableEntry(state,
    5768           0 :                                                  state.dataOutRptPredefined->pdchWthrVal,
    5769             :                                                  "Cooling Design Temperature 1% (C)",
    5770           0 :                                                  GetColumnUsingTabs(lineIn, 4) + degChar);
    5771           0 :                                 PreDefTableEntry(state,
    5772           0 :                                                  state.dataOutRptPredefined->pdchWthrVal,
    5773             :                                                  "Cooling Design Temperature 2% (C)",
    5774           0 :                                                  GetColumnUsingTabs(lineIn, 6) + degChar);
    5775             :                             }
    5776             :                         } else { // 2005 and 2009 are the same
    5777         756 :                             if (ort->unitsStyle == UnitsStyle::InchPound) {
    5778          11 :                                 curNameWithSIUnits = "Cooling Design Temperature 0.4% (C)";
    5779          11 :                                 LookupSItoIP(state, curNameWithSIUnits, indexUnitConv, curNameAndUnits);
    5780          22 :                                 PreDefTableEntry(state,
    5781          11 :                                                  state.dataOutRptPredefined->pdchWthrVal,
    5782             :                                                  curNameAndUnits,
    5783          22 :                                                  RealToStr(ConvertIP(state, indexUnitConv, StrToReal(GetColumnUsingTabs(lineIn, 5))), 1) + degChar);
    5784          22 :                                 PreDefTableEntry(state,
    5785          11 :                                                  state.dataOutRptPredefined->pdchWthrVal,
    5786             :                                                  "Cooling Design Temperature 1% (F)",
    5787          33 :                                                  RealToStr(ConvertIP(state, indexUnitConv, StrToReal(GetColumnUsingTabs(lineIn, 7))), 1) + degChar);
    5788          22 :                                 PreDefTableEntry(state,
    5789          11 :                                                  state.dataOutRptPredefined->pdchWthrVal,
    5790             :                                                  "Cooling Design Temperature 2% (F)",
    5791          33 :                                                  RealToStr(ConvertIP(state, indexUnitConv, StrToReal(GetColumnUsingTabs(lineIn, 9))), 1) + degChar);
    5792             :                             } else {
    5793        1490 :                                 PreDefTableEntry(state,
    5794         745 :                                                  state.dataOutRptPredefined->pdchWthrVal,
    5795             :                                                  "Cooling Design Temperature 0.4% (C)",
    5796        2235 :                                                  GetColumnUsingTabs(lineIn, 5) + degChar);
    5797        1490 :                                 PreDefTableEntry(state,
    5798         745 :                                                  state.dataOutRptPredefined->pdchWthrVal,
    5799             :                                                  "Cooling Design Temperature 1% (C)",
    5800        2235 :                                                  GetColumnUsingTabs(lineIn, 7) + degChar);
    5801        1490 :                                 PreDefTableEntry(state,
    5802         745 :                                                  state.dataOutRptPredefined->pdchWthrVal,
    5803             :                                                  "Cooling Design Temperature 2% (C)",
    5804        2235 :                                                  GetColumnUsingTabs(lineIn, 9) + degChar);
    5805             :                             }
    5806             :                         }
    5807             :                     } else { // from weather file
    5808           0 :                         if (is_blank(GetColumnUsingTabs(lineIn, 6))) {
    5809           0 :                             col1 = 3;
    5810           0 :                             col2 = 4;
    5811           0 :                             col3 = 5;
    5812             :                         } else {
    5813           0 :                             col1 = 4;
    5814           0 :                             col2 = 5;
    5815           0 :                             col3 = 6;
    5816             :                         }
    5817           0 :                         if (ort->unitsStyle == UnitsStyle::InchPound) {
    5818           0 :                             curNameWithSIUnits = "Cooling Design Temperature 0.4% (C)";
    5819           0 :                             LookupSItoIP(state, curNameWithSIUnits, indexUnitConv, curNameAndUnits);
    5820           0 :                             PreDefTableEntry(state,
    5821           0 :                                              state.dataOutRptPredefined->pdchWthrVal,
    5822             :                                              curNameAndUnits,
    5823           0 :                                              RealToStr(ConvertIP(state, indexUnitConv, StrToReal(GetColumnUsingTabs(lineIn, col1))), 1) + degChar);
    5824           0 :                             PreDefTableEntry(state,
    5825           0 :                                              state.dataOutRptPredefined->pdchWthrVal,
    5826             :                                              "Cooling Design Temperature 1% (F)",
    5827           0 :                                              RealToStr(ConvertIP(state, indexUnitConv, StrToReal(GetColumnUsingTabs(lineIn, col2))), 1) + degChar);
    5828           0 :                             PreDefTableEntry(state,
    5829           0 :                                              state.dataOutRptPredefined->pdchWthrVal,
    5830             :                                              "Cooling Design Temperature 2% (F)",
    5831           0 :                                              RealToStr(ConvertIP(state, indexUnitConv, StrToReal(GetColumnUsingTabs(lineIn, col3))), 1) + degChar);
    5832             :                         } else {
    5833           0 :                             PreDefTableEntry(state,
    5834           0 :                                              state.dataOutRptPredefined->pdchWthrVal,
    5835             :                                              "Cooling Design Temperature 0.4% (C)",
    5836           0 :                                              GetColumnUsingTabs(lineIn, col1) + degChar);
    5837           0 :                             PreDefTableEntry(state,
    5838           0 :                                              state.dataOutRptPredefined->pdchWthrVal,
    5839             :                                              "Cooling Design Temperature 1% (C)",
    5840           0 :                                              GetColumnUsingTabs(lineIn, col2) + degChar);
    5841           0 :                             PreDefTableEntry(state,
    5842           0 :                                              state.dataOutRptPredefined->pdchWthrVal,
    5843             :                                              "Cooling Design Temperature 2% (C)",
    5844           0 :                                              GetColumnUsingTabs(lineIn, col3) + degChar);
    5845             :                         }
    5846             :                     }
    5847             :                 }
    5848         756 :             } break;
    5849         730 :             case StatLineType::StdHDDLine: { //  - 1745 annual (standard) heating degree-days (10°C baseline)
    5850         730 :                 storeASHRAEHDD = lineIn.substr(2, 4);
    5851         730 :             } break;
    5852         730 :             case StatLineType::StdCDDLine: { //  -  464 annual (standard) cooling degree-days (18.3°C baseline)
    5853         730 :                 storeASHRAECDD = lineIn.substr(2, 4);
    5854         730 :             } break;
    5855         759 :             case StatLineType::MaxDryBulbLine: { //   - Maximum Dry Bulb temperature of  35.6°C on Jul  9
    5856         759 :                 sposlt = index(lineIn, "of");
    5857         759 :                 eposlt = index(lineIn, 'C');
    5858         759 :                 sposlt += 2;
    5859         759 :                 auto deg_index = index(lineIn, degChar);
    5860         759 :                 if (deg_index != std::string::npos) {
    5861           0 :                     eposlt = deg_index - 1;
    5862             :                 } else {
    5863         759 :                     eposlt -= 2;
    5864             :                 }
    5865         759 :                 if (sposlt != std::string::npos && eposlt != std::string::npos) {
    5866        1518 :                     if (ort->unitsStyle == UnitsStyle::InchPound) {
    5867          11 :                         curNameWithSIUnits = "Maximum Dry Bulb Temperature (C)";
    5868          11 :                         LookupSItoIP(state, curNameWithSIUnits, indexUnitConv, curNameAndUnits);
    5869          22 :                         PreDefTableEntry(state,
    5870          11 :                                          state.dataOutRptPredefined->pdchWthrVal,
    5871             :                                          curNameAndUnits,
    5872          22 :                                          RealToStr(ConvertIP(state, indexUnitConv, StrToReal(lineIn.substr(sposlt, eposlt - sposlt + 1))), 1) +
    5873             :                                              degChar);
    5874             :                     } else {
    5875        1496 :                         PreDefTableEntry(state,
    5876         748 :                                          state.dataOutRptPredefined->pdchWthrVal,
    5877             :                                          "Maximum Dry Bulb Temperature (C)",
    5878        2244 :                                          lineIn.substr(sposlt, eposlt - sposlt + 1) + degChar);
    5879             :                     }
    5880             :                 } else {
    5881           0 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "Maximum Dry Bulb Temperature", "not found");
    5882             :                 }
    5883         759 :                 sposlt = index(lineIn, "on");
    5884         759 :                 sposlt += 2;
    5885         759 :                 if (sposlt != std::string::npos) {
    5886         759 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "Maximum Dry Bulb Occurs on", lineIn.substr(sposlt));
    5887             :                 } else {
    5888           0 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "Maximum Dry Bulb Occurs on", "not found");
    5889             :                 }
    5890         759 :             } break;
    5891         759 :             case StatLineType::MinDryBulbLine: { //   - Minimum Dry Bulb temperature of -22.8°C on Jan  7
    5892         759 :                 sposlt = index(lineIn, "of");
    5893         759 :                 eposlt = index(lineIn, 'C');
    5894         759 :                 sposlt += 2;
    5895         759 :                 auto deg_index = index(lineIn, degChar);
    5896         759 :                 if (deg_index != std::string::npos) {
    5897           0 :                     eposlt = deg_index - 1;
    5898             :                 } else {
    5899         759 :                     eposlt -= 2;
    5900             :                 }
    5901         759 :                 if (sposlt != std::string::npos && eposlt != std::string::npos) {
    5902        1518 :                     if (ort->unitsStyle == UnitsStyle::InchPound) {
    5903          11 :                         curNameWithSIUnits = "Minimum Dry Bulb Temperature (C)";
    5904          11 :                         LookupSItoIP(state, curNameWithSIUnits, indexUnitConv, curNameAndUnits);
    5905          22 :                         PreDefTableEntry(state,
    5906          11 :                                          state.dataOutRptPredefined->pdchWthrVal,
    5907             :                                          curNameAndUnits,
    5908          22 :                                          RealToStr(ConvertIP(state, indexUnitConv, StrToReal(lineIn.substr(sposlt, eposlt - sposlt + 1))), 1) +
    5909             :                                              degChar);
    5910             :                     } else {
    5911        1496 :                         PreDefTableEntry(state,
    5912         748 :                                          state.dataOutRptPredefined->pdchWthrVal,
    5913             :                                          "Minimum Dry Bulb Temperature (C)",
    5914        2244 :                                          lineIn.substr(sposlt, eposlt - sposlt + 1) + degChar);
    5915             :                     }
    5916             :                 } else {
    5917           0 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "Minimum Dry Bulb Temperature", "not found");
    5918             :                 }
    5919         759 :                 sposlt = index(lineIn, "on");
    5920         759 :                 sposlt += 2;
    5921         759 :                 if (sposlt != std::string::npos) {
    5922         759 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "Minimum Dry Bulb Occurs on", lineIn.substr(sposlt));
    5923             :                 } else {
    5924           0 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "Minimum Dry Bulb Occurs on", "not found");
    5925             :                 }
    5926         759 :             } break;
    5927         759 :             case StatLineType::MaxDewPointLine: { //   - Maximum Dew Point temperature of  25.6°C on Aug  4
    5928         759 :                 sposlt = index(lineIn, "of");
    5929         759 :                 eposlt = index(lineIn, 'C');
    5930         759 :                 sposlt += 2;
    5931         759 :                 auto deg_index = index(lineIn, degChar);
    5932         759 :                 if (deg_index != std::string::npos) {
    5933           0 :                     eposlt = deg_index - 1;
    5934             :                 } else {
    5935         759 :                     eposlt -= 2;
    5936             :                 }
    5937         759 :                 if (sposlt != std::string::npos && eposlt != std::string::npos) {
    5938        1518 :                     if (ort->unitsStyle == UnitsStyle::InchPound) {
    5939          11 :                         curNameWithSIUnits = "Maximum Dew Point Temperature (C)";
    5940          11 :                         LookupSItoIP(state, curNameWithSIUnits, indexUnitConv, curNameAndUnits);
    5941          22 :                         PreDefTableEntry(state,
    5942          11 :                                          state.dataOutRptPredefined->pdchWthrVal,
    5943             :                                          curNameAndUnits,
    5944          22 :                                          RealToStr(ConvertIP(state, indexUnitConv, StrToReal(lineIn.substr(sposlt, eposlt - sposlt + 1))), 1) +
    5945             :                                              degChar);
    5946             :                     } else {
    5947        1496 :                         PreDefTableEntry(state,
    5948         748 :                                          state.dataOutRptPredefined->pdchWthrVal,
    5949             :                                          "Maximum Dew Point Temperature (C)",
    5950        2244 :                                          lineIn.substr(sposlt, eposlt - sposlt + 1) + degChar);
    5951             :                     }
    5952             :                 } else {
    5953           0 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "Maximum Dew Point Temperature", "not found");
    5954             :                 }
    5955         759 :                 sposlt = index(lineIn, "on");
    5956         759 :                 sposlt += 2;
    5957         759 :                 if (sposlt != std::string::npos) {
    5958         759 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "Maximum Dew Point Occurs on", lineIn.substr(sposlt));
    5959             :                 } else {
    5960           0 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "Maximum Dew Point Occurs on", "not found");
    5961             :                 }
    5962         759 :             } break;
    5963         759 :             case StatLineType::MinDewPointLine: { //   - Minimum Dew Point temperature of -28.9°C on Dec 31
    5964         759 :                 sposlt = index(lineIn, "of");
    5965         759 :                 eposlt = index(lineIn, 'C');
    5966         759 :                 sposlt += 2;
    5967         759 :                 auto deg_index = index(lineIn, degChar);
    5968         759 :                 if (deg_index != std::string::npos) {
    5969           0 :                     eposlt = deg_index - 1;
    5970             :                 } else {
    5971         759 :                     eposlt -= 2;
    5972             :                 }
    5973         759 :                 if (sposlt != std::string::npos && eposlt != std::string::npos) {
    5974        1518 :                     if (ort->unitsStyle == UnitsStyle::InchPound) {
    5975          11 :                         curNameWithSIUnits = "Minimum Dew Point Temperature (C)";
    5976          11 :                         LookupSItoIP(state, curNameWithSIUnits, indexUnitConv, curNameAndUnits);
    5977          22 :                         PreDefTableEntry(state,
    5978          11 :                                          state.dataOutRptPredefined->pdchWthrVal,
    5979             :                                          curNameAndUnits,
    5980          22 :                                          RealToStr(ConvertIP(state, indexUnitConv, StrToReal(lineIn.substr(sposlt, eposlt - sposlt + 1))), 1) +
    5981             :                                              degChar);
    5982             :                     } else {
    5983        1496 :                         PreDefTableEntry(state,
    5984         748 :                                          state.dataOutRptPredefined->pdchWthrVal,
    5985             :                                          "Minimum Dew Point Temperature (C)",
    5986        2244 :                                          lineIn.substr(sposlt, eposlt - sposlt + 1) + degChar);
    5987             :                     }
    5988             :                 } else {
    5989           0 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "Minimum Dew Point Temperature", "not found");
    5990             :                 }
    5991         759 :                 sposlt = index(lineIn, "on");
    5992         759 :                 sposlt += 2;
    5993         759 :                 if (sposlt != std::string::npos) {
    5994         759 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "Minimum Dew Point Occurs on", lineIn.substr(sposlt));
    5995             :                 } else {
    5996           0 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "Minimum Dew Point Occurs on", "not found");
    5997             :                 }
    5998         759 :             } break;
    5999         752 :             case StatLineType::MonthlyPrec: { //   - Monthly precipitation mm
    6000        1504 :                 std::stringstream ss(lineIn);
    6001        1504 :                 std::vector<std::string> result;
    6002       23312 :                 while (ss.good()) {
    6003       22560 :                     std::string substr;
    6004       11280 :                     getline(ss, substr, '\t');
    6005       11280 :                     substr.erase(remove_if(substr.begin(), substr.end(), isspace), substr.end());
    6006       11280 :                     result.push_back(substr);
    6007             :                 }
    6008             :                 int monthlyTotalPrecFromStat[12];
    6009         752 :                 int annualTotalPrecFromStat = 0;
    6010        9776 :                 for (int i = 0; i < 12; i++) {
    6011        9024 :                     monthlyTotalPrecFromStat[i] = std::stoi(result[i + 2]);
    6012             :                     // fixme: add to monthly data structure
    6013        9024 :                     annualTotalPrecFromStat += monthlyTotalPrecFromStat[i];
    6014             :                 }
    6015        1504 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "Annual Total Precipitation [mm]", annualTotalPrecFromStat);
    6016             :                 // fixme: store the monthly data in some data structure
    6017         752 :             } break;
    6018         733 :             case StatLineType::MaxHourlyPrec: { //   - Highest hourly precipitation in each month
    6019             :                 // Split string by \t into substrings and remove the space in each substring
    6020        1466 :                 std::stringstream ss(lineIn);
    6021        1466 :                 std::vector<std::string> result;
    6022       22723 :                 while (ss.good()) {
    6023       21990 :                     std::string substr;
    6024       10995 :                     getline(ss, substr, '\t');
    6025       10995 :                     substr.erase(remove_if(substr.begin(), substr.end(), isspace), substr.end());
    6026       10995 :                     result.push_back(substr);
    6027             :                 }
    6028             :                 int MaxHourlyPrecEachMonth[12];
    6029         733 :                 int MaxHourlyPrec = 0;
    6030         733 :                 int MaxHourlyPrecIdx = 0;
    6031        9529 :                 for (int i = 0; i < 12; i++) {
    6032        8796 :                     MaxHourlyPrecEachMonth[i] = std::stoi(result[i + 2]);
    6033        8796 :                     if (MaxHourlyPrecEachMonth[i] > MaxHourlyPrec) {
    6034        1111 :                         MaxHourlyPrec = MaxHourlyPrecEachMonth[i];
    6035        1111 :                         MaxHourlyPrecIdx = i;
    6036             :                     }
    6037             :                 }
    6038         733 :                 constexpr std::array<std::string_view, 12> Months{"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
    6039         733 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "Max Hourly Precipitation [mm]", MaxHourlyPrec);
    6040        1466 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "Max Hourly Precipitation Occurs in", Months[MaxHourlyPrecIdx]);
    6041         733 :             } break;
    6042         759 :             case StatLineType::WithHDDLine: { //  - 1745 (wthr file) annual heating degree-days (10°C baseline)
    6043         759 :                 if (storeASHRAEHDD != "") {
    6044         730 :                     if (ort->unitsStyle == UnitsStyle::InchPound) {
    6045          11 :                         curNameWithSIUnits = "ASHRAE Handbook 2009 Heating Degree-Days - base 65°(C)";
    6046          11 :                         LookupSItoIP(state, curNameWithSIUnits, indexUnitConv, curNameAndUnits);
    6047          22 :                         PreDefTableEntry(state,
    6048          11 :                                          state.dataOutRptPredefined->pdchWthrVal,
    6049             :                                          curNameAndUnits,
    6050          22 :                                          RealToStr(ConvertIPdelta(state, indexUnitConv, StrToReal(storeASHRAEHDD)), 1));
    6051             :                     } else {
    6052        1438 :                         PreDefTableEntry(
    6053         719 :                             state, state.dataOutRptPredefined->pdchWthrVal, "ASHRAE Handbook 2009 Heating Degree-Days (base 18.3°C)", storeASHRAEHDD);
    6054             :                     }
    6055             :                 } else {
    6056          29 :                     if (ort->unitsStyle == UnitsStyle::InchPound) {
    6057           0 :                         PreDefTableEntry(
    6058           0 :                             state, state.dataOutRptPredefined->pdchWthrVal, "ASHRAE Handbook 2009 Heating Degree-Days (base 65°F)", "not found");
    6059             :                     } else {
    6060          29 :                         PreDefTableEntry(
    6061          29 :                             state, state.dataOutRptPredefined->pdchWthrVal, "ASHRAE Handbook 2009 Heating Degree-Days (base 18.3°C)", "not found");
    6062             :                     }
    6063             :                 }
    6064         759 :                 if (ort->unitsStyle == UnitsStyle::InchPound) {
    6065          11 :                     curNameWithSIUnits = "Weather File Heating Degree-Days - base 65°(C)";
    6066          11 :                     LookupSItoIP(state, curNameWithSIUnits, indexUnitConv, curNameAndUnits);
    6067          22 :                     PreDefTableEntry(state,
    6068          11 :                                      state.dataOutRptPredefined->pdchWthrVal,
    6069             :                                      curNameAndUnits,
    6070          22 :                                      RealToStr(ConvertIPdelta(state, indexUnitConv, StrToReal(lineIn.substr(2, 4))), 1));
    6071          22 :                     PreDefTableEntry(state,
    6072          11 :                                      state.dataOutRptPredefined->pdchLeedGenData,
    6073             :                                      "Heating Degree Days",
    6074          33 :                                      RealToStr(ConvertIPdelta(state, indexUnitConv, StrToReal(lineIn.substr(2, 4))), 1));
    6075             :                 } else {
    6076        1496 :                     PreDefTableEntry(
    6077        2244 :                         state, state.dataOutRptPredefined->pdchWthrVal, "Weather File Heating Degree-Days (base 18°C)", lineIn.substr(2, 4));
    6078         748 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchLeedGenData, "Heating Degree Days", lineIn.substr(2, 4));
    6079             :                 }
    6080         759 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchLeedGenData, "HDD and CDD data source", "Weather File Stat");
    6081         759 :             } break;
    6082         759 :             case StatLineType::WithCDDLine: { //  -  464 (wthr file) annual cooling degree-days (18°C baseline)
    6083         759 :                 if (storeASHRAECDD != "") {
    6084         730 :                     if (ort->unitsStyle == UnitsStyle::InchPound) {
    6085          11 :                         curNameWithSIUnits = "ASHRAE Handbook 2009  Cooling Degree-Days - base 50°(C)";
    6086          11 :                         LookupSItoIP(state, curNameWithSIUnits, indexUnitConv, curNameAndUnits);
    6087          22 :                         PreDefTableEntry(state,
    6088          11 :                                          state.dataOutRptPredefined->pdchWthrVal,
    6089             :                                          curNameAndUnits,
    6090          22 :                                          RealToStr(ConvertIPdelta(state, indexUnitConv, StrToReal(storeASHRAECDD)), 1));
    6091             :                     } else {
    6092        1438 :                         PreDefTableEntry(
    6093         719 :                             state, state.dataOutRptPredefined->pdchWthrVal, "ASHRAE Handbook 2009  Cooling Degree-Days (base 10°C)", storeASHRAECDD);
    6094             :                     }
    6095             :                 } else {
    6096          29 :                     if (ort->unitsStyle == UnitsStyle::InchPound) {
    6097           0 :                         PreDefTableEntry(
    6098           0 :                             state, state.dataOutRptPredefined->pdchWthrVal, "ASHRAE Handbook 2009  Cooling Degree-Days (base 50°F)", "not found");
    6099             :                     } else {
    6100          29 :                         PreDefTableEntry(
    6101          29 :                             state, state.dataOutRptPredefined->pdchWthrVal, "ASHRAE Handbook 2009  Cooling Degree-Days (base 10°C)", "not found");
    6102             :                     }
    6103             :                 }
    6104         759 :                 if (ort->unitsStyle == UnitsStyle::InchPound) {
    6105          11 :                     curNameWithSIUnits = "Weather File Cooling Degree-Days - base 50°(C)";
    6106          11 :                     LookupSItoIP(state, curNameWithSIUnits, indexUnitConv, curNameAndUnits);
    6107          22 :                     PreDefTableEntry(state,
    6108          11 :                                      state.dataOutRptPredefined->pdchWthrVal,
    6109             :                                      curNameAndUnits,
    6110          22 :                                      RealToStr(ConvertIPdelta(state, indexUnitConv, StrToReal(lineIn.substr(2, 4))), 1));
    6111          22 :                     PreDefTableEntry(state,
    6112          11 :                                      state.dataOutRptPredefined->pdchLeedGenData,
    6113             :                                      "Cooling Degree Days",
    6114          33 :                                      RealToStr(ConvertIPdelta(state, indexUnitConv, StrToReal(lineIn.substr(2, 4))), 1));
    6115             :                 } else {
    6116        1496 :                     PreDefTableEntry(
    6117        2244 :                         state, state.dataOutRptPredefined->pdchWthrVal, "Weather File Cooling Degree-Days (base 10°C)", lineIn.substr(2, 4));
    6118         748 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchLeedGenData, "Cooling Degree Days", lineIn.substr(2, 4));
    6119             :                 }
    6120         759 :             } break;
    6121         759 :             case StatLineType::KoppenLine: { // - Climate type "BSk" (Köppen classification)
    6122         759 :                 if (!has(lineIn, "not shown")) {
    6123         759 :                     isKoppen = true;
    6124         759 :                     if (lineIn[18] == '"') { // two character classification
    6125          65 :                         PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "Köppen Classification", lineIn.substr(16, 2));
    6126             :                     } else {
    6127         694 :                         PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "Köppen Classification", lineIn.substr(16, 3));
    6128             :                     }
    6129             :                 } else {
    6130           0 :                     isKoppen = false;
    6131           0 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "Köppen Recommendation", lineIn.substr(2));
    6132             :                 }
    6133         759 :             } break;
    6134         759 :             case StatLineType::KoppenDes1Line: { // - Tropical monsoonal or tradewind-coastal (short dry season, lat. 5-25°)
    6135         759 :                 if (isKoppen) {
    6136         759 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "Köppen Description", lineIn.substr(2));
    6137             :                 }
    6138         759 :             } break;
    6139         759 :             case StatLineType::KoppenDes2Line: { // - Unbearably humid periods in summer, but passive cooling is possible
    6140         759 :                 if (isKoppen) {
    6141         759 :                     if (len(lineIn) > 3) {                 // avoid blank lines
    6142         759 :                         if (lineIn.substr(2, 2) != "**") { // avoid line with warning
    6143         613 :                             PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "Köppen Recommendation", lineIn.substr(2));
    6144             :                         } else {
    6145         146 :                             PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "Köppen Recommendation", "");
    6146             :                         }
    6147             :                     } else {
    6148           0 :                         PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "Köppen Recommendation", "");
    6149             :                     }
    6150             :                 }
    6151         759 :             } break;
    6152        3036 :             case StatLineType::AshStdLine:
    6153             :             case StatLineType::AshStdDes1Line:
    6154             :             case StatLineType::AshStdDes2Line:
    6155             :             case StatLineType::AshStdDes3Line: {
    6156             :                 //  - Climate type "1A" (ASHRAE Standards 90.1-2004 and 90.2-2004 Climate Zone)**
    6157        3036 :                 if (has(lineIn, "Standard")) {
    6158         759 :                     ashZone = lineIn.substr(16, 2);
    6159         759 :                     if (ashZone[1] == '"') ashZone[1] = ' ';
    6160         759 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "ASHRAE Climate Zone", ashZone);
    6161         759 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchLeedGenData, "Climate Zone", ashZone);
    6162         759 :                     if (ashZone == "1A") {
    6163          65 :                         PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "ASHRAE Description", "Very Hot-Humid");
    6164         694 :                     } else if (ashZone == "1B") {
    6165          22 :                         PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "ASHRAE Description", "Very Hot-Dry");
    6166         672 :                     } else if (ashZone == "2A") {
    6167           8 :                         PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "ASHRAE Description", "Hot-Humid");
    6168         664 :                     } else if (ashZone == "2B") {
    6169           3 :                         PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "ASHRAE Description", "Hot-Dry");
    6170         661 :                     } else if (ashZone == "3A") {
    6171           4 :                         PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "ASHRAE Description", "Warm-Humid");
    6172         657 :                     } else if (ashZone == "3B") {
    6173           3 :                         PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "ASHRAE Description", "Warm-Dry");
    6174         654 :                     } else if (ashZone == "3C") {
    6175          10 :                         PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "ASHRAE Description", "Warm-Marine");
    6176         644 :                     } else if (ashZone == "4A") {
    6177           1 :                         PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "ASHRAE Description", "Mixed-Humid");
    6178         643 :                     } else if (ashZone == "4B") {
    6179           0 :                         PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "ASHRAE Description", "Mixed-Dry");
    6180         643 :                     } else if (ashZone == "4C") {
    6181           0 :                         PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "ASHRAE Description", "Mixed-Marine");
    6182         643 :                     } else if (ashZone == "5A") {
    6183         565 :                         PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "ASHRAE Description", "Cool-Humid");
    6184          78 :                     } else if (ashZone == "5B") {
    6185          78 :                         PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "ASHRAE Description", "Cool-Dry");
    6186           0 :                     } else if (ashZone == "5C") {
    6187           0 :                         PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "ASHRAE Description", "Cool-Marine");
    6188           0 :                     } else if (ashZone == "6A") {
    6189           0 :                         PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "ASHRAE Description", "Cold-Humid");
    6190           0 :                     } else if (ashZone == "6B") {
    6191           0 :                         PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "ASHRAE Description", "Cold-Dry");
    6192           0 :                     } else if (ashZone == "7 ") {
    6193           0 :                         PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "ASHRAE Description", "Very Cold");
    6194           0 :                     } else if (ashZone == "8 ") {
    6195           0 :                         PreDefTableEntry(state, state.dataOutRptPredefined->pdchWthrVal, "ASHRAE Description", "Subarctic");
    6196             :                     }
    6197             :                 }
    6198        3036 :             } break;
    6199      393494 :             default:
    6200      393494 :                 break;
    6201             :             }
    6202      413890 :             lineIn = "";
    6203      413890 :             lineTypeinterim = StatLineType::Initialized;
    6204      413890 :             if (lineType == StatLineType::AshStdDes3Line) lineTypeinterim = StatLineType::Initialized;
    6205      413890 :             if (lineType == StatLineType::AshStdDes2Line) lineTypeinterim = StatLineType::AshStdDes2Line;
    6206      413890 :             if (lineType == StatLineType::AshStdDes1Line) lineTypeinterim = StatLineType::AshStdDes1Line;
    6207      413890 :             if (lineType == StatLineType::AshStdLine) lineTypeinterim = StatLineType::AshStdLine;
    6208      413890 :             if (lineType == StatLineType::KoppenDes2Line) lineTypeinterim = StatLineType::Initialized;
    6209      413890 :             if (lineType == StatLineType::KoppenDes1Line) lineTypeinterim = StatLineType::KoppenDes1Line;
    6210      413890 :             if (lineType == StatLineType::KoppenLine) lineTypeinterim = StatLineType::KoppenLine;
    6211             :         }
    6212             :     }
    6213         769 : }
    6214             : 
    6215        3840 : std::string GetColumnUsingTabs(std::string const &inString, // Input String
    6216             :                                int const colNum             // Column number
    6217             : )
    6218             : {
    6219             :     // SUBROUTINE INFORMATION:
    6220             :     //       AUTHOR         Jason Glazer
    6221             :     //       DATE WRITTEN   March 2008
    6222             :     //       MODIFIED       na
    6223             :     //       RE-ENGINEERED  na
    6224             : 
    6225             :     // PURPOSE OF THIS SUBROUTINE:
    6226             :     //   Assumes that the input string contains tabs that mark the
    6227             :     //   separation between columns. Returns the string that appears
    6228             :     //   in the column specified.
    6229             : 
    6230             :     // SUBROUTINE PARAMETER DEFINITIONS:
    6231             :     static char const tb('\t'); // tab character
    6232             : 
    6233             :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
    6234        3840 :     std::string::size_type startPos = 0;
    6235             : 
    6236        3840 :     auto endPos = inString.find_first_of(tb);
    6237        3840 :     if (colNum == 1) {
    6238           0 :         if (endPos == std::string::npos) return inString;
    6239           0 :         return inString.substr(startPos, endPos - startPos);
    6240             :     }
    6241        3840 :     if (endPos == std::string::npos) return "";
    6242             : 
    6243        3840 :     int numCols = 1;
    6244       42540 :     while (numCols < colNum) {
    6245       19350 :         startPos = endPos + 1;
    6246       19350 :         endPos = inString.find_first_of(tb, startPos);
    6247       19350 :         ++numCols;
    6248       19350 :         if (endPos == std::string::npos) break;
    6249             :     }
    6250        3840 :     if (colNum > numCols) return "";
    6251        3840 :     if (endPos == std::string::npos) endPos = inString.size();
    6252        3840 :     return inString.substr(startPos, endPos - startPos);
    6253             : }
    6254             : 
    6255         769 : void FillRemainingPredefinedEntries(EnergyPlusData &state)
    6256             : {
    6257             :     // SUBROUTINE INFORMATION:
    6258             :     //       AUTHOR         Jason Glazer
    6259             :     //       DATE WRITTEN   May 2007
    6260             :     //       MODIFIED       na
    6261             :     //       RE-ENGINEERED  na
    6262             : 
    6263             :     // PURPOSE OF THIS SUBROUTINE:
    6264             :     //   Just before writing the output reports, will gather up
    6265             :     //   any additional report entries for the predefined reports.
    6266             : 
    6267             :     // Using/Aliasing
    6268         769 :     auto &NumPrimaryAirSys = state.dataHVACGlobal->NumPrimaryAirSys;
    6269         769 :     auto &iNumberOfAutoCalcedFields = state.dataOutput->iNumberOfAutoCalcedFields;
    6270         769 :     auto &iNumberOfAutoSizedFields = state.dataOutput->iNumberOfAutoSizedFields;
    6271         769 :     auto &iNumberOfDefaultedFields = state.dataOutput->iNumberOfDefaultedFields;
    6272         769 :     auto &iNumberOfRecords = state.dataOutput->iNumberOfRecords;
    6273         769 :     auto &iTotalAutoCalculatableFields = state.dataOutput->iTotalAutoCalculatableFields;
    6274         769 :     auto &iTotalAutoSizableFields = state.dataOutput->iTotalAutoSizableFields;
    6275         769 :     auto &iTotalFieldsWithDefaults = state.dataOutput->iTotalFieldsWithDefaults;
    6276             : 
    6277             :     using ScheduleManager::GetScheduleName;
    6278             :     using ScheduleManager::ScheduleAverageHoursPerWeek;
    6279             : 
    6280             :     int iLight;
    6281             :     int zonePt;
    6282             :     int iZone;
    6283             :     Real64 mult; // zone list and group multipliers
    6284             :     int StartOfWeek;
    6285             :     Real64 consumptionTotal;
    6286             : 
    6287         769 :     auto &Zone(state.dataHeatBal->Zone);
    6288         769 :     auto &ZonePreDefRep(state.dataHeatBal->ZonePreDefRep);
    6289             : 
    6290         769 :     auto &ort(state.dataOutRptTab);
    6291             : 
    6292         769 :     StartOfWeek = state.dataEnvrn->RunPeriodStartDayOfWeek;
    6293         769 :     if (StartOfWeek == 0) StartOfWeek = 2; // if the first day of the week has not been set yet, assume monday
    6294             : 
    6295             :     // Interior Connected Lighting Power
    6296         769 :     consumptionTotal = 0.0;
    6297        4810 :     for (iLight = 1; iLight <= state.dataHeatBal->TotLights; ++iLight) {
    6298        4041 :         zonePt = state.dataHeatBal->Lights(iLight).ZonePtr;
    6299        4041 :         mult = Zone(zonePt).Multiplier * Zone(zonePt).ListMultiplier;
    6300        4041 :         if (Zone(zonePt).SystemZoneNodeNumber > 0) { // conditioned y/n
    6301        3910 :             PreDefTableEntry(state, state.dataOutRptPredefined->pdchInLtCond, state.dataHeatBal->Lights(iLight).Name, "Y");
    6302             :         } else {
    6303         131 :             PreDefTableEntry(state, state.dataOutRptPredefined->pdchInLtCond, state.dataHeatBal->Lights(iLight).Name, "N");
    6304             :         }
    6305       20205 :         PreDefTableEntry(
    6306             :             state,
    6307        4041 :             state.dataOutRptPredefined->pdchInLtAvgHrSchd,
    6308        4041 :             state.dataHeatBal->Lights(iLight).Name,
    6309        8082 :             ScheduleAverageHoursPerWeek(state, state.dataHeatBal->Lights(iLight).SchedPtr, StartOfWeek, state.dataEnvrn->CurrentYearIsLeapYear));
    6310             :         // average operating hours per week
    6311        4041 :         if (ort->gatherElapsedTimeBEPS > 0) {
    6312          10 :             state.dataOutRptTab->HrsPerWeek = 24 * 7 * state.dataHeatBal->Lights(iLight).SumTimeNotZeroCons / ort->gatherElapsedTimeBEPS;
    6313          40 :             PreDefTableEntry(
    6314          30 :                 state, state.dataOutRptPredefined->pdchInLtAvgHrOper, state.dataHeatBal->Lights(iLight).Name, state.dataOutRptTab->HrsPerWeek);
    6315             :         }
    6316             :         // full load hours per week
    6317        4041 :         if ((state.dataHeatBal->Lights(iLight).DesignLevel * ort->gatherElapsedTimeBEPS) > 0) {
    6318          10 :             state.dataOutRptTab->HrsPerWeek =
    6319          20 :                 24 * 7 * state.dataHeatBal->Lights(iLight).SumConsumption /
    6320          10 :                 (state.dataHeatBal->Lights(iLight).DesignLevel * ort->gatherElapsedTimeBEPS * DataGlobalConstants::SecInHour);
    6321          40 :             PreDefTableEntry(
    6322          30 :                 state, state.dataOutRptPredefined->pdchInLtFullLoadHrs, state.dataHeatBal->Lights(iLight).Name, state.dataOutRptTab->HrsPerWeek);
    6323             :         }
    6324       16164 :         PreDefTableEntry(state,
    6325        4041 :                          state.dataOutRptPredefined->pdchInLtConsump,
    6326        4041 :                          state.dataHeatBal->Lights(iLight).Name,
    6327        4041 :                          state.dataHeatBal->Lights(iLight).SumConsumption * mult / 1000000000.0);
    6328        4041 :         consumptionTotal += state.dataHeatBal->Lights(iLight).SumConsumption / 1000000000.0;
    6329             :     }
    6330         769 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchInLtConsump, "Interior Lighting Total", consumptionTotal);
    6331             : 
    6332             :     // Exterior Lighting
    6333         769 :     consumptionTotal = 0.0;
    6334         951 :     for (iLight = 1; iLight <= state.dataExteriorEnergyUse->NumExteriorLights; ++iLight) {
    6335         182 :         if (state.dataExteriorEnergyUse->ExteriorLights(iLight).ControlMode ==
    6336             :             ExteriorEnergyUse::LightControlType::ScheduleOnly) { // photocell/schedule
    6337          85 :             PreDefTableEntry(
    6338             :                 state,
    6339          17 :                 state.dataOutRptPredefined->pdchExLtAvgHrSchd,
    6340          17 :                 state.dataExteriorEnergyUse->ExteriorLights(iLight).Name,
    6341             :                 ScheduleAverageHoursPerWeek(
    6342          34 :                     state, state.dataExteriorEnergyUse->ExteriorLights(iLight).SchedPtr, StartOfWeek, state.dataEnvrn->CurrentYearIsLeapYear));
    6343             :         }
    6344             :         // average operating hours per week
    6345         182 :         if (ort->gatherElapsedTimeBEPS > 0) {
    6346           0 :             state.dataOutRptTab->HrsPerWeek =
    6347           0 :                 24 * 7 * state.dataExteriorEnergyUse->ExteriorLights(iLight).SumTimeNotZeroCons / ort->gatherElapsedTimeBEPS;
    6348           0 :             PreDefTableEntry(state,
    6349           0 :                              state.dataOutRptPredefined->pdchExLtAvgHrOper,
    6350           0 :                              state.dataExteriorEnergyUse->ExteriorLights(iLight).Name,
    6351           0 :                              state.dataOutRptTab->HrsPerWeek);
    6352             :         }
    6353             :         // full load hours per week
    6354         182 :         if ((state.dataExteriorEnergyUse->ExteriorLights(iLight).DesignLevel * ort->gatherElapsedTimeBEPS) > 0) {
    6355           0 :             state.dataOutRptTab->HrsPerWeek =
    6356           0 :                 24 * 7 * state.dataExteriorEnergyUse->ExteriorLights(iLight).SumConsumption /
    6357           0 :                 (state.dataExteriorEnergyUse->ExteriorLights(iLight).DesignLevel * ort->gatherElapsedTimeBEPS * DataGlobalConstants::SecInHour);
    6358           0 :             PreDefTableEntry(state,
    6359           0 :                              state.dataOutRptPredefined->pdchExLtFullLoadHrs,
    6360           0 :                              state.dataExteriorEnergyUse->ExteriorLights(iLight).Name,
    6361           0 :                              state.dataOutRptTab->HrsPerWeek);
    6362             :         }
    6363         728 :         PreDefTableEntry(state,
    6364         182 :                          state.dataOutRptPredefined->pdchExLtConsump,
    6365         182 :                          state.dataExteriorEnergyUse->ExteriorLights(iLight).Name,
    6366         182 :                          state.dataExteriorEnergyUse->ExteriorLights(iLight).SumConsumption / 1000000000.0);
    6367         182 :         consumptionTotal += state.dataExteriorEnergyUse->ExteriorLights(iLight).SumConsumption / 1000000000.0;
    6368             :     }
    6369         769 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchExLtConsump, "Exterior Lighting Total", consumptionTotal);
    6370             : 
    6371             :     // outside air ventilation
    6372         769 :     Real64 totalOccupants = 0.;
    6373         769 :     Real64 totalAverageOccupants = 0.;
    6374         769 :     Real64 totalArea = 0.;
    6375         769 :     Real64 totalVozMin = 0;
    6376         769 :     Real64 totalMechVentVol = 0;
    6377         769 :     Real64 totalNatVentVol = 0;
    6378         769 :     Real64 totalInfilVol = 0;
    6379         769 :     Real64 totalVozDyn = 0;
    6380         769 :     Real64 totalMechVentRateOcc = 0;
    6381         769 :     Real64 totalNatVentRateOcc = 0;
    6382         769 :     Real64 totalInfilRateOcc = 0;
    6383         769 :     Real64 totalVozDynOcc = 0;
    6384             : 
    6385             :     // Outdoor Air Summary and Outdoor Air Details
    6386        5571 :     for (iZone = 1; iZone <= state.dataGlobal->NumOfZones; ++iZone) {
    6387        4802 :         int const zoneMult = Zone(iZone).Multiplier * Zone(iZone).ListMultiplier;
    6388        4802 :         if (Zone(iZone).SystemZoneNodeNumber >= 0) { // conditioned zones only
    6389             : 
    6390             :             // AFN infiltration -- check that afn sim is being done.
    6391        4802 :             if (!state.afn->multizone_always_simulated) {
    6392        4697 :                 ZonePreDefRep(iZone).AFNInfilVolTotalStdDen = 0.0;
    6393        4697 :                 ZonePreDefRep(iZone).AFNVentVolTotalStdDen = 0.0;
    6394        4697 :                 ZonePreDefRep(iZone).AFNInfilVolTotalOccStdDen = 0.0;
    6395        4697 :                 ZonePreDefRep(iZone).AFNVentVolTotalOccStdDen = 0.0;
    6396        4697 :                 ZonePreDefRep(iZone).AFNInfilVolMin = 0.0;
    6397        4697 :                 ZonePreDefRep(iZone).AFNInfilVolTotalOcc = 0.0;
    6398             :             }
    6399             : 
    6400             :             // air loop name
    6401        9604 :             std::string airLoopName = "";
    6402        4802 :             if (Zone(iZone).IsControlled) {
    6403        8327 :                 for (int zoneInNode = 1; zoneInNode <= state.dataZoneEquip->ZoneEquipConfig(iZone).NumInletNodes; ++zoneInNode) {
    6404        4233 :                     int airLoopNumber = state.dataZoneEquip->ZoneEquipConfig(iZone).InletNodeAirLoopNum(zoneInNode);
    6405        4233 :                     if (airLoopNumber > 0) {
    6406        3455 :                         if (airLoopName.empty()) {
    6407        3435 :                             airLoopName = state.dataAirSystemsData->PrimaryAirSystems(airLoopNumber).Name;
    6408             :                         } else {
    6409          20 :                             airLoopName += "; " + state.dataAirSystemsData->PrimaryAirSystems(airLoopNumber).Name;
    6410             :                         }
    6411             :                     }
    6412             :                 }
    6413        4094 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaMvAirLpNm, Zone(iZone).Name, airLoopName);
    6414             : 
    6415             :                 // occupants
    6416        4094 :                 if (Zone(iZone).isNominalOccupied) {
    6417        3703 :                     if (ZonePreDefRep(iZone).NumOccAccumTime > 0) {
    6418        3602 :                         Real64 const avgOcc = ZonePreDefRep(iZone).NumOccAccum / ZonePreDefRep(iZone).NumOccAccumTime;
    6419        3602 :                         PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaoAvgNumOcc1, Zone(iZone).Name, avgOcc);
    6420        3602 :                         PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaoAvgNumOcc2, Zone(iZone).Name, avgOcc);
    6421        3602 :                         PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaMvAvgNumOcc, Zone(iZone).Name, avgOcc);
    6422        3602 :                         totalAverageOccupants += avgOcc * zoneMult;
    6423             :                     }
    6424             :                 }
    6425        4094 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaMvNomNumOcc, Zone(iZone).Name, Zone(iZone).TotOccupants);
    6426        4094 :                 totalOccupants += Zone(iZone).TotOccupants * zoneMult;
    6427             : 
    6428             :                 // Zone volume and area
    6429             : 
    6430        4094 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaoZoneVol1, Zone(iZone).Name, Zone(iZone).Volume);
    6431        4094 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaoZoneVol2, Zone(iZone).Name, Zone(iZone).Volume);
    6432        4094 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaMvZoneVol, Zone(iZone).Name, Zone(iZone).Volume);
    6433        4094 :                 state.dataOutRptTab->totalVolume += Zone(iZone).Volume * zoneMult;
    6434        4094 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaMvZoneArea, Zone(iZone).Name, Zone(iZone).FloorArea);
    6435        4094 :                 totalArea += Zone(iZone).FloorArea * zoneMult;
    6436             : 
    6437             :                 // minimum dynamic target ventilation Voz-dyn-min
    6438        4094 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaMvMinDynTrgVent, Zone(iZone).Name, ZonePreDefRep(iZone).VozMin, 3);
    6439        4094 :                 totalVozMin += ZonePreDefRep(iZone).VozMin * zoneMult;
    6440             : 
    6441             :                 // Mechanical ventilation
    6442        4094 :                 if (Zone(iZone).Volume > 0 && ZonePreDefRep(iZone).TotTimeOcc > 0) {
    6443       14324 :                     PreDefTableEntry(state,
    6444        3581 :                                      state.dataOutRptPredefined->pdchOaoAvgMechVent,
    6445        3581 :                                      Zone(iZone).Name,
    6446        3581 :                                      ZonePreDefRep(iZone).MechVentVolTotalOcc / (ZonePreDefRep(iZone).TotTimeOcc * Zone(iZone).Volume * zoneMult),
    6447             :                                      3);
    6448             :                 }
    6449        4094 :                 if ((Zone(iZone).Volume > 0) && (ZonePreDefRep(iZone).TotTimeOcc > 0)) {
    6450       14324 :                     PreDefTableEntry(state,
    6451        3581 :                                      state.dataOutRptPredefined->pdchOaoMinMechVent,
    6452        3581 :                                      Zone(iZone).Name,
    6453        3581 :                                      ZonePreDefRep(iZone).MechVentVolMin / (Zone(iZone).Volume * zoneMult),
    6454             :                                      3);
    6455             :                 }
    6456       16376 :                 PreDefTableEntry(
    6457       12282 :                     state, state.dataOutRptPredefined->pdchOaTaBzMechVent, Zone(iZone).Name, ZonePreDefRep(iZone).MechVentVolTotalStdDen);
    6458        4094 :                 totalMechVentVol += ZonePreDefRep(iZone).MechVentVolTotalStdDen * zoneMult;
    6459             : 
    6460             :                 // Natural ventilation
    6461       16376 :                 PreDefTableEntry(state,
    6462        4094 :                                  state.dataOutRptPredefined->pdchOaTaBzNatVent,
    6463        4094 :                                  Zone(iZone).Name,
    6464        4094 :                                  ZonePreDefRep(iZone).SimpVentVolTotalStdDen + ZonePreDefRep(iZone).AFNVentVolTotalStdDen);
    6465        4094 :                 totalNatVentVol += (ZonePreDefRep(iZone).SimpVentVolTotalStdDen + ZonePreDefRep(iZone).AFNVentVolTotalStdDen) * zoneMult;
    6466             : 
    6467             :                 // Total ventilation
    6468       16376 :                 PreDefTableEntry(state,
    6469        4094 :                                  state.dataOutRptPredefined->pdchOaTaBzTotVent,
    6470        4094 :                                  Zone(iZone).Name,
    6471        4094 :                                  ZonePreDefRep(iZone).MechVentVolTotalStdDen + ZonePreDefRep(iZone).SimpVentVolTotalStdDen +
    6472        4094 :                                      ZonePreDefRep(iZone).AFNVentVolTotalStdDen);
    6473             : 
    6474             :                 // infiltration
    6475        4094 :                 if (Zone(iZone).Volume > 0 && ZonePreDefRep(iZone).TotTimeOcc > 0) {
    6476       14324 :                     PreDefTableEntry(state,
    6477        3581 :                                      state.dataOutRptPredefined->pdchOaoAvgInfil,
    6478        3581 :                                      Zone(iZone).Name,
    6479        3581 :                                      ZonePreDefRep(iZone).InfilVolTotalOcc / (ZonePreDefRep(iZone).TotTimeOcc * Zone(iZone).Volume),
    6480             :                                      3);
    6481             :                 }
    6482        4094 :                 if ((Zone(iZone).Volume > 0) && (ZonePreDefRep(iZone).TotTimeOcc > 0)) {
    6483       14324 :                     PreDefTableEntry(state,
    6484        3581 :                                      state.dataOutRptPredefined->pdchOaoMinInfil,
    6485        3581 :                                      Zone(iZone).Name,
    6486        3581 :                                      ZonePreDefRep(iZone).InfilVolMin / (Zone(iZone).Volume),
    6487             :                                      3);
    6488             :                 }
    6489        4094 :                 if (Zone(iZone).Volume > 0 && ZonePreDefRep(iZone).TotTimeOcc > 0) {
    6490       14324 :                     PreDefTableEntry(state,
    6491        3581 :                                      state.dataOutRptPredefined->pdchOaoAvgAFNInfil,
    6492        3581 :                                      Zone(iZone).Name,
    6493        3581 :                                      ZonePreDefRep(iZone).AFNInfilVolTotalOcc / (ZonePreDefRep(iZone).TotTimeOcc * Zone(iZone).Volume),
    6494             :                                      3);
    6495             :                 }
    6496        4094 :                 if ((Zone(iZone).Volume > 0) && (ZonePreDefRep(iZone).TotTimeOcc > 0)) {
    6497       14324 :                     PreDefTableEntry(state,
    6498        3581 :                                      state.dataOutRptPredefined->pdchOaoMinAFNInfil,
    6499        3581 :                                      Zone(iZone).Name,
    6500        3581 :                                      ZonePreDefRep(iZone).AFNInfilVolMin / (Zone(iZone).Volume),
    6501             :                                      3);
    6502             :                 }
    6503             :                 // simple 'ZoneVentilation'
    6504        4094 :                 if (Zone(iZone).Volume > 0 && ZonePreDefRep(iZone).TotTimeOcc > 0) {
    6505       14324 :                     PreDefTableEntry(state,
    6506        3581 :                                      state.dataOutRptPredefined->pdchOaoAvgSimpVent,
    6507        3581 :                                      Zone(iZone).Name,
    6508        3581 :                                      ZonePreDefRep(iZone).SimpVentVolTotalOcc / (ZonePreDefRep(iZone).TotTimeOcc * Zone(iZone).Volume),
    6509             :                                      3);
    6510             :                 }
    6511        4094 :                 if ((Zone(iZone).Volume > 0) && (ZonePreDefRep(iZone).TotTimeOcc > 0)) {
    6512       14324 :                     PreDefTableEntry(state,
    6513        3581 :                                      state.dataOutRptPredefined->pdchOaoMinSimpVent,
    6514        3581 :                                      Zone(iZone).Name,
    6515        3581 :                                      ZonePreDefRep(iZone).SimpVentVolMin / (Zone(iZone).Volume),
    6516             :                                      3);
    6517             :                 }
    6518             : 
    6519             :                 // Infiltration
    6520       16376 :                 PreDefTableEntry(state,
    6521        4094 :                                  state.dataOutRptPredefined->pdchOaTaBzInfil,
    6522        4094 :                                  Zone(iZone).Name,
    6523        4094 :                                  ZonePreDefRep(iZone).InfilVolTotalStdDen + ZonePreDefRep(iZone).AFNInfilVolTotalStdDen);
    6524        4094 :                 totalInfilVol += (ZonePreDefRep(iZone).InfilVolTotalStdDen + ZonePreDefRep(iZone).AFNInfilVolTotalStdDen) * zoneMult;
    6525             : 
    6526             :                 // Total ventilation and infiltration
    6527       16376 :                 PreDefTableEntry(state,
    6528        4094 :                                  state.dataOutRptPredefined->pdchOaTaBzTotVentInfil,
    6529        4094 :                                  Zone(iZone).Name,
    6530        8188 :                                  ZonePreDefRep(iZone).MechVentVolTotalStdDen + ZonePreDefRep(iZone).SimpVentVolTotalStdDen +
    6531        8188 :                                      ZonePreDefRep(iZone).AFNVentVolTotalStdDen + ZonePreDefRep(iZone).AFNInfilVolTotalStdDen +
    6532        4094 :                                      ZonePreDefRep(iZone).InfilVolTotalStdDen);
    6533             : 
    6534             :                 // Dynamic target ventilation Voz-dyn
    6535        4094 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaTaBzDynTrgVent, Zone(iZone).Name, ZonePreDefRep(iZone).VozTargetTotal);
    6536        4094 :                 totalVozDyn += ZonePreDefRep(iZone).VozTargetTotal * zoneMult;
    6537        4094 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaTaBzTmBelow, Zone(iZone).Name, ZonePreDefRep(iZone).VozTargetTimeBelow);
    6538        4094 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaTaBzTmAt, Zone(iZone).Name, ZonePreDefRep(iZone).VozTargetTimeAt);
    6539        4094 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaTaBzTmAbove, Zone(iZone).Name, ZonePreDefRep(iZone).VozTargetTimeAbove);
    6540       16376 :                 PreDefTableEntry(
    6541       12282 :                     state, state.dataOutRptPredefined->pdchOaTaBzTmAboveUnocc, Zone(iZone).Name, ZonePreDefRep(iZone).TotVentTimeNonZeroUnocc);
    6542             : 
    6543        4094 :                 if (Zone(iZone).isNominalOccupied && (ZonePreDefRep(iZone).TotTimeOcc > 0.0)) {
    6544        3581 :                     Real64 totTimeOccSec = ZonePreDefRep(iZone).TotTimeOcc * SecInHour;
    6545             :                     // Mechanical ventilation
    6546        3581 :                     Real64 mechVent = ZonePreDefRep(iZone).MechVentVolTotalOccStdDen / totTimeOccSec;
    6547        3581 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaOccBzMechVent, Zone(iZone).Name, mechVent, 4);
    6548        3581 :                     totalMechVentRateOcc += mechVent * zoneMult;
    6549             : 
    6550             :                     // Natural ventilation
    6551        3581 :                     Real64 natVent = (ZonePreDefRep(iZone).SimpVentVolTotalOccStdDen + ZonePreDefRep(iZone).AFNVentVolTotalOccStdDen) / totTimeOccSec;
    6552        3581 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaOccBzNatVent, Zone(iZone).Name, natVent, 4);
    6553        3581 :                     totalNatVentRateOcc += natVent * zoneMult;
    6554             : 
    6555             :                     // Total ventilation
    6556        3581 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaOccBzTotVent, Zone(iZone).Name, mechVent + natVent, 4);
    6557             : 
    6558             :                     // infiltration
    6559        3581 :                     Real64 infil = (ZonePreDefRep(iZone).InfilVolTotalOccStdDen + ZonePreDefRep(iZone).AFNInfilVolTotalOccStdDen) / totTimeOccSec;
    6560        3581 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaOccBzInfil, Zone(iZone).Name, infil, 4);
    6561        3581 :                     totalInfilRateOcc += infil * zoneMult;
    6562             : 
    6563             :                     // Total ventilation and infiltration
    6564        3581 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaOccBzTotVentInfil, Zone(iZone).Name, mechVent + natVent + infil, 4);
    6565             : 
    6566             :                     // Dynamic target ventilation Voz-dyn
    6567        3581 :                     Real64 avgVoz = ZonePreDefRep(iZone).VozTargetTotalOcc / totTimeOccSec;
    6568        3581 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaOccBzDynTrgVent, Zone(iZone).Name, avgVoz, 4);
    6569        3581 :                     totalVozDynOcc += avgVoz * zoneMult;
    6570       14324 :                     PreDefTableEntry(
    6571       10743 :                         state, state.dataOutRptPredefined->pdchOaOccBzTmBelow, Zone(iZone).Name, ZonePreDefRep(iZone).VozTargetTimeBelowOcc);
    6572        3581 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaOccBzTmAt, Zone(iZone).Name, ZonePreDefRep(iZone).VozTargetTimeAtOcc);
    6573       14324 :                     PreDefTableEntry(
    6574       10743 :                         state, state.dataOutRptPredefined->pdchOaOccBzTmAbove, Zone(iZone).Name, ZonePreDefRep(iZone).VozTargetTimeAboveOcc);
    6575             :                 }
    6576             :             }
    6577             :         }
    6578             :     }
    6579             : 
    6580        1941 :     for (int iSys = 1; iSys <= state.dataHVACGlobal->NumPrimaryAirSys; ++iSys) {
    6581             :         // Total Outdoor Air by Airloop
    6582        4688 :         PreDefTableEntry(state,
    6583        1172 :                          state.dataOutRptPredefined->pdchOaTaAlMechVent,
    6584        1172 :                          state.dataAirSystemsData->PrimaryAirSystems(iSys).Name,
    6585        1172 :                          state.dataSysRpts->SysPreDefRep(iSys).MechVentTotal);
    6586        4688 :         PreDefTableEntry(state,
    6587        1172 :                          state.dataOutRptPredefined->pdchOaTaAlNatVent,
    6588        1172 :                          state.dataAirSystemsData->PrimaryAirSystems(iSys).Name,
    6589        1172 :                          state.dataSysRpts->SysPreDefRep(iSys).NatVentTotal);
    6590        4688 :         PreDefTableEntry(state,
    6591        1172 :                          state.dataOutRptPredefined->pdchOaTaAlTotVent,
    6592        1172 :                          state.dataAirSystemsData->PrimaryAirSystems(iSys).Name,
    6593        1172 :                          state.dataSysRpts->SysPreDefRep(iSys).MechVentTotal + state.dataSysRpts->SysPreDefRep(iSys).NatVentTotal);
    6594        4688 :         PreDefTableEntry(state,
    6595        1172 :                          state.dataOutRptPredefined->pdchOaTaAlSumDynTrgVent,
    6596        1172 :                          state.dataAirSystemsData->PrimaryAirSystems(iSys).Name,
    6597        1172 :                          state.dataSysRpts->SysPreDefRep(iSys).TargetVentTotalVoz);
    6598        4688 :         PreDefTableEntry(state,
    6599        1172 :                          state.dataOutRptPredefined->pdchOaTaAlTmBelow,
    6600        1172 :                          state.dataAirSystemsData->PrimaryAirSystems(iSys).Name,
    6601        1172 :                          state.dataSysRpts->SysPreDefRep(iSys).TimeBelowVozDynTotal);
    6602        4688 :         PreDefTableEntry(state,
    6603        1172 :                          state.dataOutRptPredefined->pdchOaTaAlTmAt,
    6604        1172 :                          state.dataAirSystemsData->PrimaryAirSystems(iSys).Name,
    6605        1172 :                          state.dataSysRpts->SysPreDefRep(iSys).TimeAtVozDynTotal);
    6606        4688 :         PreDefTableEntry(state,
    6607        1172 :                          state.dataOutRptPredefined->pdchOaTaAlTmAbove,
    6608        1172 :                          state.dataAirSystemsData->PrimaryAirSystems(iSys).Name,
    6609        1172 :                          state.dataSysRpts->SysPreDefRep(iSys).TimeAboveVozDynTotal);
    6610        4688 :         PreDefTableEntry(state,
    6611        1172 :                          state.dataOutRptPredefined->pdchOaTaAlTmAboveUnocc,
    6612        1172 :                          state.dataAirSystemsData->PrimaryAirSystems(iSys).Name,
    6613        1172 :                          state.dataSysRpts->SysPreDefRep(iSys).TimeVentUnoccTotal);
    6614             : 
    6615             :         // Air loop times at OA limiting factors
    6616        4688 :         PreDefTableEntry(state,
    6617        1172 :                          state.dataOutRptPredefined->pdchOaTmFctNoLimit,
    6618        1172 :                          state.dataAirSystemsData->PrimaryAirSystems(iSys).Name,
    6619        1172 :                          state.dataSysRpts->SysPreDefRep(iSys).TimeAtOALimit[MixedAir::limitFactorNone]);
    6620        4688 :         PreDefTableEntry(state,
    6621        1172 :                          state.dataOutRptPredefined->pdchOaTmFctLimit,
    6622        1172 :                          state.dataAirSystemsData->PrimaryAirSystems(iSys).Name,
    6623        1172 :                          state.dataSysRpts->SysPreDefRep(iSys).TimeAtOALimit[MixedAir::limitFactorLimits]);
    6624        4688 :         PreDefTableEntry(state,
    6625        1172 :                          state.dataOutRptPredefined->pdchOaTmFctEcono,
    6626        1172 :                          state.dataAirSystemsData->PrimaryAirSystems(iSys).Name,
    6627        1172 :                          state.dataSysRpts->SysPreDefRep(iSys).TimeAtOALimit[MixedAir::limitFactorEconomizer]);
    6628        4688 :         PreDefTableEntry(state,
    6629        1172 :                          state.dataOutRptPredefined->pdchOaTmFctExhaust,
    6630        1172 :                          state.dataAirSystemsData->PrimaryAirSystems(iSys).Name,
    6631        1172 :                          state.dataSysRpts->SysPreDefRep(iSys).TimeAtOALimit[MixedAir::limitFactorExhaust]);
    6632        4688 :         PreDefTableEntry(state,
    6633        1172 :                          state.dataOutRptPredefined->pdchOaTmFctMixedLimit,
    6634        1172 :                          state.dataAirSystemsData->PrimaryAirSystems(iSys).Name,
    6635        1172 :                          state.dataSysRpts->SysPreDefRep(iSys).TimeAtOALimit[MixedAir::limitFactorMixedAir]);
    6636        4688 :         PreDefTableEntry(state,
    6637        1172 :                          state.dataOutRptPredefined->pdchOaTmFctHiHumid,
    6638        1172 :                          state.dataAirSystemsData->PrimaryAirSystems(iSys).Name,
    6639        1172 :                          state.dataSysRpts->SysPreDefRep(iSys).TimeAtOALimit[MixedAir::limitFactorHighHum]);
    6640        4688 :         PreDefTableEntry(state,
    6641        1172 :                          state.dataOutRptPredefined->pdchOaTmFctDCV,
    6642        1172 :                          state.dataAirSystemsData->PrimaryAirSystems(iSys).Name,
    6643        1172 :                          state.dataSysRpts->SysPreDefRep(iSys).TimeAtOALimit[MixedAir::limitFactorDCV]);
    6644        4688 :         PreDefTableEntry(state,
    6645        1172 :                          state.dataOutRptPredefined->pdchOaTmFctNiteVent,
    6646        1172 :                          state.dataAirSystemsData->PrimaryAirSystems(iSys).Name,
    6647        1172 :                          state.dataSysRpts->SysPreDefRep(iSys).TimeAtOALimit[MixedAir::limitFactorNightVent]);
    6648        4688 :         PreDefTableEntry(state,
    6649        1172 :                          state.dataOutRptPredefined->pdchOaTmFctDemand,
    6650        1172 :                          state.dataAirSystemsData->PrimaryAirSystems(iSys).Name,
    6651        1172 :                          state.dataSysRpts->SysPreDefRep(iSys).TimeAtOALimit[MixedAir::limitFactorDemandLimit]);
    6652        4688 :         PreDefTableEntry(state,
    6653        1172 :                          state.dataOutRptPredefined->pdchOaTmFctEMS,
    6654        1172 :                          state.dataAirSystemsData->PrimaryAirSystems(iSys).Name,
    6655        1172 :                          state.dataSysRpts->SysPreDefRep(iSys).TimeAtOALimit[MixedAir::limitFactorEMS]);
    6656             : 
    6657        1172 :         if (state.dataSysRpts->SysPreDefRep(iSys).TimeOccupiedTotal > 0.0) {
    6658             :             // Average Outdoor Air During Occupancy by Airloop
    6659        1079 :             Real64 totTimeOccSec = state.dataSysRpts->SysPreDefRep(iSys).TimeOccupiedTotal * SecInHour;
    6660        4316 :             PreDefTableEntry(state,
    6661        1079 :                              state.dataOutRptPredefined->pdchOaOccAlMechVent,
    6662        1079 :                              state.dataAirSystemsData->PrimaryAirSystems(iSys).Name,
    6663        1079 :                              state.dataSysRpts->SysPreDefRep(iSys).MechVentTotalOcc / totTimeOccSec,
    6664             :                              4);
    6665        4316 :             PreDefTableEntry(state,
    6666        1079 :                              state.dataOutRptPredefined->pdchOaOccAlNatVent,
    6667        1079 :                              state.dataAirSystemsData->PrimaryAirSystems(iSys).Name,
    6668        1079 :                              state.dataSysRpts->SysPreDefRep(iSys).NatVentTotalOcc / totTimeOccSec,
    6669             :                              4);
    6670        4316 :             PreDefTableEntry(state,
    6671        1079 :                              state.dataOutRptPredefined->pdchOaOccAlTotVent,
    6672        1079 :                              state.dataAirSystemsData->PrimaryAirSystems(iSys).Name,
    6673        1079 :                              (state.dataSysRpts->SysPreDefRep(iSys).MechVentTotalOcc + state.dataSysRpts->SysPreDefRep(iSys).NatVentTotalOcc) /
    6674             :                                  totTimeOccSec,
    6675             :                              4);
    6676        4316 :             PreDefTableEntry(state,
    6677        1079 :                              state.dataOutRptPredefined->pdchOaOccAlSumDynTrgVent,
    6678        1079 :                              state.dataAirSystemsData->PrimaryAirSystems(iSys).Name,
    6679        1079 :                              state.dataSysRpts->SysPreDefRep(iSys).TargetVentTotalVozOcc / totTimeOccSec,
    6680             :                              4);
    6681        4316 :             PreDefTableEntry(state,
    6682        1079 :                              state.dataOutRptPredefined->pdchOaOccAlTmBelow,
    6683        1079 :                              state.dataAirSystemsData->PrimaryAirSystems(iSys).Name,
    6684        1079 :                              state.dataSysRpts->SysPreDefRep(iSys).TimeBelowVozDynTotalOcc);
    6685        4316 :             PreDefTableEntry(state,
    6686        1079 :                              state.dataOutRptPredefined->pdchOaOccAlTmAt,
    6687        1079 :                              state.dataAirSystemsData->PrimaryAirSystems(iSys).Name,
    6688        1079 :                              state.dataSysRpts->SysPreDefRep(iSys).TimeAtVozDynTotalOcc);
    6689        4316 :             PreDefTableEntry(state,
    6690        1079 :                              state.dataOutRptPredefined->pdchOaOccAlTmAbove,
    6691        1079 :                              state.dataAirSystemsData->PrimaryAirSystems(iSys).Name,
    6692        1079 :                              state.dataSysRpts->SysPreDefRep(iSys).TimeAboveVozDynTotalOcc);
    6693             : 
    6694             :             // Average Outdoor Air at OA Limiting Factors During Occupancy by Airloop
    6695             :             // lambda to set avgFlow during occupancy for a given airloop and limiting factor type
    6696       22638 :             auto avgFlowRate = [&state](int sysNum, int limitingFactorType) {
    6697       10790 :                 Real64 avgFlow = 0.0;
    6698       10790 :                 int time = state.dataSysRpts->SysPreDefRep(sysNum).TimeAtOALimitOcc[limitingFactorType];
    6699       10790 :                 if (time > 0) {
    6700        1058 :                     avgFlow = state.dataSysRpts->SysPreDefRep(sysNum).MechVentTotAtLimitOcc[limitingFactorType] / (time * SecInHour);
    6701             :                 } else {
    6702        9732 :                     avgFlow = 0.0;
    6703             :                 }
    6704       10790 :                 return avgFlow;
    6705        1079 :             };
    6706        3237 :             PreDefTableEntry(state,
    6707        1079 :                              state.dataOutRptPredefined->pdchOaAvFctNoLimit,
    6708        1079 :                              state.dataAirSystemsData->PrimaryAirSystems(iSys).Name,
    6709             :                              avgFlowRate(iSys, MixedAir::limitFactorNone),
    6710             :                              4);
    6711        3237 :             PreDefTableEntry(state,
    6712        1079 :                              state.dataOutRptPredefined->pdchOaAvFctLimit,
    6713        1079 :                              state.dataAirSystemsData->PrimaryAirSystems(iSys).Name,
    6714             :                              avgFlowRate(iSys, MixedAir::limitFactorLimits),
    6715             :                              4);
    6716        3237 :             PreDefTableEntry(state,
    6717        1079 :                              state.dataOutRptPredefined->pdchOaAvFctEcono,
    6718        1079 :                              state.dataAirSystemsData->PrimaryAirSystems(iSys).Name,
    6719             :                              avgFlowRate(iSys, MixedAir::limitFactorEconomizer),
    6720             :                              4);
    6721        3237 :             PreDefTableEntry(state,
    6722        1079 :                              state.dataOutRptPredefined->pdchOaAvFctExhaust,
    6723        1079 :                              state.dataAirSystemsData->PrimaryAirSystems(iSys).Name,
    6724             :                              avgFlowRate(iSys, MixedAir::limitFactorExhaust),
    6725             :                              4);
    6726        3237 :             PreDefTableEntry(state,
    6727        1079 :                              state.dataOutRptPredefined->pdchOaAvFctMixedLimit,
    6728        1079 :                              state.dataAirSystemsData->PrimaryAirSystems(iSys).Name,
    6729             :                              avgFlowRate(iSys, MixedAir::limitFactorMixedAir),
    6730             :                              4);
    6731        3237 :             PreDefTableEntry(state,
    6732        1079 :                              state.dataOutRptPredefined->pdchOaAvFctHiHumid,
    6733        1079 :                              state.dataAirSystemsData->PrimaryAirSystems(iSys).Name,
    6734             :                              avgFlowRate(iSys, MixedAir::limitFactorHighHum),
    6735             :                              4);
    6736        3237 :             PreDefTableEntry(state,
    6737        1079 :                              state.dataOutRptPredefined->pdchOaAvFctDCV,
    6738        1079 :                              state.dataAirSystemsData->PrimaryAirSystems(iSys).Name,
    6739             :                              avgFlowRate(iSys, MixedAir::limitFactorDCV),
    6740             :                              4);
    6741        3237 :             PreDefTableEntry(state,
    6742        1079 :                              state.dataOutRptPredefined->pdchOaAvFctNiteVent,
    6743        1079 :                              state.dataAirSystemsData->PrimaryAirSystems(iSys).Name,
    6744             :                              avgFlowRate(iSys, MixedAir::limitFactorNightVent),
    6745             :                              4);
    6746        3237 :             PreDefTableEntry(state,
    6747        1079 :                              state.dataOutRptPredefined->pdchOaAvFctDemand,
    6748        1079 :                              state.dataAirSystemsData->PrimaryAirSystems(iSys).Name,
    6749             :                              avgFlowRate(iSys, MixedAir::limitFactorDemandLimit),
    6750             :                              4);
    6751        3237 :             PreDefTableEntry(state,
    6752        1079 :                              state.dataOutRptPredefined->pdchOaAvFctEMS,
    6753        1079 :                              state.dataAirSystemsData->PrimaryAirSystems(iSys).Name,
    6754             :                              avgFlowRate(iSys, MixedAir::limitFactorEMS),
    6755             :                              4);
    6756             :         }
    6757             :     }
    6758             :     // add total rows for outdoor air details
    6759        2307 :     OutputReportPredefined::PreDefTableEntry(
    6760        1538 :         state, state.dataOutRptPredefined->pdchOaMvDesZnOa, "Total Facility", state.dataOutRptPredefined->TotalVozMax, 4);
    6761             : 
    6762         769 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaMvZoneVol, "Total Facility", state.dataOutRptTab->totalVolume);
    6763         769 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaMvZoneArea, "Total Facility", totalArea);
    6764         769 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaMvNomNumOcc, "Total Facility", totalOccupants);
    6765         769 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaMvAvgNumOcc, "Total Facility", totalAverageOccupants);
    6766         769 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaMvMinDynTrgVent, "Total Facility", totalVozMin, 3);
    6767             : 
    6768         769 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaTaBzMechVent, "Total Facility", totalMechVentVol);
    6769         769 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaTaBzNatVent, "Total Facility", totalNatVentVol);
    6770         769 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaTaBzTotVent, "Total Facility", totalMechVentVol + totalNatVentVol);
    6771         769 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaTaBzInfil, "Total Facility", totalInfilVol);
    6772         769 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaTaBzTotVentInfil, "Total Facility", totalMechVentVol + totalNatVentVol + totalInfilVol);
    6773         769 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaTaBzDynTrgVent, "Total Facility", totalVozDyn);
    6774        2307 :     PreDefTableEntry(
    6775        1538 :         state, state.dataOutRptPredefined->pdchOaTaBzTmBelow, "Total Facility", state.dataOutRptPredefined->TotalAnyZoneBelowVozDynForOA);
    6776         769 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaTaBzTmAt, "Total Facility", state.dataOutRptPredefined->TotalAllZonesAtVozDynForOA);
    6777        2307 :     PreDefTableEntry(
    6778        1538 :         state, state.dataOutRptPredefined->pdchOaTaBzTmAbove, "Total Facility", state.dataOutRptPredefined->TotalAnyZoneAboveVozDynForOA);
    6779        2307 :     PreDefTableEntry(
    6780        1538 :         state, state.dataOutRptPredefined->pdchOaTaBzTmAboveUnocc, "Total Facility", state.dataOutRptPredefined->TotalAnyZoneVentUnoccForOA);
    6781             : 
    6782         769 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaOccBzMechVent, "Total Facility", totalMechVentRateOcc, 4);
    6783         769 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaOccBzNatVent, "Total Facility", totalNatVentRateOcc, 4);
    6784         769 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaOccBzTotVent, "Total Facility", totalMechVentRateOcc + totalNatVentRateOcc, 4);
    6785         769 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaOccBzInfil, "Total Facility", totalInfilRateOcc, 4);
    6786        2307 :     PreDefTableEntry(state,
    6787         769 :                      state.dataOutRptPredefined->pdchOaOccBzTotVentInfil,
    6788             :                      "Total Facility",
    6789         769 :                      totalMechVentRateOcc + totalNatVentRateOcc + totalInfilRateOcc,
    6790         769 :                      4);
    6791         769 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaOccBzDynTrgVent, "Total Facility", totalVozDynOcc, 4);
    6792        2307 :     PreDefTableEntry(
    6793        1538 :         state, state.dataOutRptPredefined->pdchOaOccBzTmBelow, "Total Facility", state.dataOutRptPredefined->TotalAnyZoneBelowVozDynOccForOA);
    6794         769 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchOaOccBzTmAt, "Total Facility", state.dataOutRptPredefined->TotalAllZonesAtVozDynOccForOA);
    6795        2307 :     PreDefTableEntry(
    6796        1538 :         state, state.dataOutRptPredefined->pdchOaOccBzTmAbove, "Total Facility", state.dataOutRptPredefined->TotalAnyZoneAboveVozDynOccForOA);
    6797             : 
    6798             :     // Add the number of central air distributions system to the count report
    6799         769 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchHVACcntVal, "HVAC Air Loops", NumPrimaryAirSys);
    6800             :     // Add the number of conditioned and unconditioned zones to the count report
    6801        5571 :     for (iZone = 1; iZone <= state.dataGlobal->NumOfZones; ++iZone) {
    6802        4802 :         if (Zone(iZone).SystemZoneNodeNumber > 0) { // conditioned zones only
    6803        4374 :             ++state.dataOutRptTab->numCondZones;
    6804             :         } else {
    6805         428 :             ++state.dataOutRptTab->numUncondZones;
    6806             :         }
    6807             :     }
    6808         769 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchHVACcntVal, "Conditioned Zones", state.dataOutRptTab->numCondZones);
    6809         769 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchHVACcntVal, "Unconditioned Zones", state.dataOutRptTab->numUncondZones);
    6810             :     // add the number of plenums to the count report
    6811         769 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchHVACcntVal, "Supply Plenums", state.dataZonePlenum->NumZoneSupplyPlenums);
    6812         769 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchHVACcntVal, "Return Plenums", state.dataZonePlenum->NumZoneReturnPlenums);
    6813             : 
    6814             :     // Add footnote saying if it is a design day or other kind of environment
    6815             : 
    6816             :     // Field counts
    6817         769 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchFieldCntVal, "IDF Objects", iNumberOfRecords);
    6818         769 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchFieldCntVal, "Defaulted Fields", iNumberOfDefaultedFields);
    6819         769 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchFieldCntVal, "Fields with Defaults", iTotalFieldsWithDefaults);
    6820         769 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchFieldCntVal, "Autosized Fields", iNumberOfAutoSizedFields);
    6821         769 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchFieldCntVal, "Autosizable Fields", iTotalAutoSizableFields);
    6822         769 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchFieldCntVal, "Autocalculated Fields", iNumberOfAutoCalcedFields);
    6823         769 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchFieldCntVal, "Autocalculatable Fields", iTotalAutoCalculatableFields);
    6824             : 
    6825        5571 :     for (iZone = 1; iZone <= state.dataGlobal->NumOfZones; ++iZone) {
    6826             :         // annual
    6827             :         // PreDefTableEntry(state,  pdchSHGSAnHvacHt, Zone( iZone ).Name, ZonePreDefRep( iZone ).SHGSAnHvacHt * convertJtoGJ, 3 );
    6828             :         // PreDefTableEntry(state,  pdchSHGSAnHvacCl, Zone( iZone ).Name, ZonePreDefRep( iZone ).SHGSAnHvacCl * convertJtoGJ, 3 );
    6829       19208 :         PreDefTableEntry(state,
    6830        4802 :                          state.dataOutRptPredefined->pdchSHGSAnZoneEqHt,
    6831        4802 :                          Zone(iZone).Name,
    6832        4802 :                          ZonePreDefRep(iZone).SHGSAnZoneEqHt * DataGlobalConstants::convertJtoGJ,
    6833             :                          3);
    6834       19208 :         PreDefTableEntry(state,
    6835        4802 :                          state.dataOutRptPredefined->pdchSHGSAnZoneEqCl,
    6836        4802 :                          Zone(iZone).Name,
    6837        4802 :                          ZonePreDefRep(iZone).SHGSAnZoneEqCl * DataGlobalConstants::convertJtoGJ,
    6838             :                          3);
    6839       19208 :         PreDefTableEntry(state,
    6840        4802 :                          state.dataOutRptPredefined->pdchSHGSAnHvacATUHt,
    6841        4802 :                          Zone(iZone).Name,
    6842        4802 :                          ZonePreDefRep(iZone).SHGSAnHvacATUHt * DataGlobalConstants::convertJtoGJ,
    6843             :                          3);
    6844       19208 :         PreDefTableEntry(state,
    6845        4802 :                          state.dataOutRptPredefined->pdchSHGSAnHvacATUCl,
    6846        4802 :                          Zone(iZone).Name,
    6847        4802 :                          ZonePreDefRep(iZone).SHGSAnHvacATUCl * DataGlobalConstants::convertJtoGJ,
    6848             :                          3);
    6849       19208 :         PreDefTableEntry(state,
    6850        4802 :                          state.dataOutRptPredefined->pdchSHGSAnSurfHt,
    6851        4802 :                          Zone(iZone).Name,
    6852        4802 :                          ZonePreDefRep(iZone).SHGSAnSurfHt * DataGlobalConstants::convertJtoGJ,
    6853             :                          3);
    6854       19208 :         PreDefTableEntry(state,
    6855        4802 :                          state.dataOutRptPredefined->pdchSHGSAnSurfCl,
    6856        4802 :                          Zone(iZone).Name,
    6857        4802 :                          ZonePreDefRep(iZone).SHGSAnSurfCl * DataGlobalConstants::convertJtoGJ,
    6858             :                          3);
    6859       19208 :         PreDefTableEntry(state,
    6860        4802 :                          state.dataOutRptPredefined->pdchSHGSAnPeoplAdd,
    6861        4802 :                          Zone(iZone).Name,
    6862        4802 :                          ZonePreDefRep(iZone).SHGSAnPeoplAdd * DataGlobalConstants::convertJtoGJ,
    6863             :                          3);
    6864       19208 :         PreDefTableEntry(state,
    6865        4802 :                          state.dataOutRptPredefined->pdchSHGSAnLiteAdd,
    6866        4802 :                          Zone(iZone).Name,
    6867        4802 :                          ZonePreDefRep(iZone).SHGSAnLiteAdd * DataGlobalConstants::convertJtoGJ,
    6868             :                          3);
    6869       19208 :         PreDefTableEntry(state,
    6870        4802 :                          state.dataOutRptPredefined->pdchSHGSAnEquipAdd,
    6871        4802 :                          Zone(iZone).Name,
    6872        4802 :                          ZonePreDefRep(iZone).SHGSAnEquipAdd * DataGlobalConstants::convertJtoGJ,
    6873             :                          3);
    6874       19208 :         PreDefTableEntry(state,
    6875        4802 :                          state.dataOutRptPredefined->pdchSHGSAnWindAdd,
    6876        4802 :                          Zone(iZone).Name,
    6877        4802 :                          ZonePreDefRep(iZone).SHGSAnWindAdd * DataGlobalConstants::convertJtoGJ,
    6878             :                          3);
    6879       19208 :         PreDefTableEntry(state,
    6880        4802 :                          state.dataOutRptPredefined->pdchSHGSAnIzaAdd,
    6881        4802 :                          Zone(iZone).Name,
    6882        4802 :                          ZonePreDefRep(iZone).SHGSAnIzaAdd * DataGlobalConstants::convertJtoGJ,
    6883             :                          3);
    6884       19208 :         PreDefTableEntry(state,
    6885        4802 :                          state.dataOutRptPredefined->pdchSHGSAnInfilAdd,
    6886        4802 :                          Zone(iZone).Name,
    6887        4802 :                          ZonePreDefRep(iZone).SHGSAnInfilAdd * DataGlobalConstants::convertJtoGJ,
    6888             :                          3);
    6889       19208 :         PreDefTableEntry(state,
    6890        4802 :                          state.dataOutRptPredefined->pdchSHGSAnOtherAdd,
    6891        4802 :                          Zone(iZone).Name,
    6892        4802 :                          ZonePreDefRep(iZone).SHGSAnOtherAdd * DataGlobalConstants::convertJtoGJ,
    6893             :                          3);
    6894       19208 :         PreDefTableEntry(state,
    6895        4802 :                          state.dataOutRptPredefined->pdchSHGSAnEquipRem,
    6896        4802 :                          Zone(iZone).Name,
    6897        4802 :                          ZonePreDefRep(iZone).SHGSAnEquipRem * DataGlobalConstants::convertJtoGJ,
    6898             :                          3);
    6899       19208 :         PreDefTableEntry(state,
    6900        4802 :                          state.dataOutRptPredefined->pdchSHGSAnWindRem,
    6901        4802 :                          Zone(iZone).Name,
    6902        4802 :                          ZonePreDefRep(iZone).SHGSAnWindRem * DataGlobalConstants::convertJtoGJ,
    6903             :                          3);
    6904       19208 :         PreDefTableEntry(state,
    6905        4802 :                          state.dataOutRptPredefined->pdchSHGSAnIzaRem,
    6906        4802 :                          Zone(iZone).Name,
    6907        4802 :                          ZonePreDefRep(iZone).SHGSAnIzaRem * DataGlobalConstants::convertJtoGJ,
    6908             :                          3);
    6909       19208 :         PreDefTableEntry(state,
    6910        4802 :                          state.dataOutRptPredefined->pdchSHGSAnInfilRem,
    6911        4802 :                          Zone(iZone).Name,
    6912        4802 :                          ZonePreDefRep(iZone).SHGSAnInfilRem * DataGlobalConstants::convertJtoGJ,
    6913             :                          3);
    6914       19208 :         PreDefTableEntry(state,
    6915        4802 :                          state.dataOutRptPredefined->pdchSHGSAnOtherRem,
    6916        4802 :                          Zone(iZone).Name,
    6917        4802 :                          ZonePreDefRep(iZone).SHGSAnOtherRem * DataGlobalConstants::convertJtoGJ,
    6918             :                          3);
    6919             :         // peak cooling
    6920        4802 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSClTimePeak, Zone(iZone).Name, DateToString(ZonePreDefRep(iZone).clPtTimeStamp));
    6921             :         // PreDefTableEntry(state,  pdchSHGSClHvacHt, Zone( iZone ).Name, ZonePreDefRep( iZone ).SHGSClHvacHt );
    6922             :         // PreDefTableEntry(state,  pdchSHGSClHvacCl, Zone( iZone ).Name, ZonePreDefRep( iZone ).SHGSClHvacCl );
    6923       19208 :         PreDefTableEntry(state,
    6924        4802 :                          state.dataOutRptPredefined->pdchSHGSClHvacHt,
    6925        4802 :                          Zone(iZone).Name,
    6926        4802 :                          (ZonePreDefRep(iZone).SHGSClHvacHt - ZonePreDefRep(iZone).SHGSClHvacATUHt));
    6927       19208 :         PreDefTableEntry(state,
    6928        4802 :                          state.dataOutRptPredefined->pdchSHGSClHvacCl,
    6929        4802 :                          Zone(iZone).Name,
    6930        4802 :                          (ZonePreDefRep(iZone).SHGSClHvacCl - ZonePreDefRep(iZone).SHGSClHvacATUCl));
    6931        4802 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSClHvacATUHt, Zone(iZone).Name, ZonePreDefRep(iZone).SHGSClHvacATUHt);
    6932        4802 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSClHvacATUCl, Zone(iZone).Name, ZonePreDefRep(iZone).SHGSClHvacATUCl);
    6933        4802 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSClSurfHt, Zone(iZone).Name, ZonePreDefRep(iZone).SHGSClSurfHt);
    6934        4802 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSClSurfCl, Zone(iZone).Name, ZonePreDefRep(iZone).SHGSClSurfCl);
    6935        4802 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSClPeoplAdd, Zone(iZone).Name, ZonePreDefRep(iZone).SHGSClPeoplAdd);
    6936        4802 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSClLiteAdd, Zone(iZone).Name, ZonePreDefRep(iZone).SHGSClLiteAdd);
    6937        4802 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSClEquipAdd, Zone(iZone).Name, ZonePreDefRep(iZone).SHGSClEquipAdd);
    6938        4802 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSClWindAdd, Zone(iZone).Name, ZonePreDefRep(iZone).SHGSClWindAdd);
    6939        4802 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSClIzaAdd, Zone(iZone).Name, ZonePreDefRep(iZone).SHGSClIzaAdd);
    6940        4802 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSClInfilAdd, Zone(iZone).Name, ZonePreDefRep(iZone).SHGSClInfilAdd);
    6941        4802 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSClOtherAdd, Zone(iZone).Name, ZonePreDefRep(iZone).SHGSClOtherAdd);
    6942        4802 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSClEquipRem, Zone(iZone).Name, ZonePreDefRep(iZone).SHGSClEquipRem);
    6943        4802 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSClWindRem, Zone(iZone).Name, ZonePreDefRep(iZone).SHGSClWindRem);
    6944        4802 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSClIzaRem, Zone(iZone).Name, ZonePreDefRep(iZone).SHGSClIzaRem);
    6945        4802 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSClInfilRem, Zone(iZone).Name, ZonePreDefRep(iZone).SHGSClInfilRem);
    6946        4802 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSClOtherRem, Zone(iZone).Name, ZonePreDefRep(iZone).SHGSClOtherRem);
    6947             :         // peak heating
    6948        4802 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSHtTimePeak, Zone(iZone).Name, DateToString(ZonePreDefRep(iZone).htPtTimeStamp));
    6949             :         // PreDefTableEntry(state,  pdchSHGSHtHvacHt, Zone( iZone ).Name, ZonePreDefRep( iZone ).SHGSHtHvacHt );
    6950             :         // PreDefTableEntry(state,  pdchSHGSHtHvacCl, Zone( iZone ).Name, ZonePreDefRep( iZone ).SHGSHtHvacCl );
    6951       19208 :         PreDefTableEntry(state,
    6952        4802 :                          state.dataOutRptPredefined->pdchSHGSHtHvacHt,
    6953        4802 :                          Zone(iZone).Name,
    6954        4802 :                          (ZonePreDefRep(iZone).SHGSHtHvacHt - ZonePreDefRep(iZone).SHGSHtHvacATUHt));
    6955       19208 :         PreDefTableEntry(state,
    6956        4802 :                          state.dataOutRptPredefined->pdchSHGSHtHvacCl,
    6957        4802 :                          Zone(iZone).Name,
    6958        4802 :                          (ZonePreDefRep(iZone).SHGSHtHvacCl - ZonePreDefRep(iZone).SHGSHtHvacATUCl));
    6959        4802 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSHtHvacATUHt, Zone(iZone).Name, ZonePreDefRep(iZone).SHGSHtHvacATUHt);
    6960        4802 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSHtHvacATUCl, Zone(iZone).Name, ZonePreDefRep(iZone).SHGSHtHvacATUCl);
    6961        4802 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSHtSurfHt, Zone(iZone).Name, ZonePreDefRep(iZone).SHGSHtSurfHt);
    6962        4802 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSHtSurfCl, Zone(iZone).Name, ZonePreDefRep(iZone).SHGSHtSurfCl);
    6963        4802 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSHtPeoplAdd, Zone(iZone).Name, ZonePreDefRep(iZone).SHGSHtPeoplAdd);
    6964        4802 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSHtLiteAdd, Zone(iZone).Name, ZonePreDefRep(iZone).SHGSHtLiteAdd);
    6965        4802 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSHtEquipAdd, Zone(iZone).Name, ZonePreDefRep(iZone).SHGSHtEquipAdd);
    6966        4802 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSHtWindAdd, Zone(iZone).Name, ZonePreDefRep(iZone).SHGSHtWindAdd);
    6967        4802 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSHtIzaAdd, Zone(iZone).Name, ZonePreDefRep(iZone).SHGSHtIzaAdd);
    6968        4802 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSHtInfilAdd, Zone(iZone).Name, ZonePreDefRep(iZone).SHGSHtInfilAdd);
    6969        4802 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSHtOtherAdd, Zone(iZone).Name, ZonePreDefRep(iZone).SHGSHtOtherAdd);
    6970        4802 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSHtEquipRem, Zone(iZone).Name, ZonePreDefRep(iZone).SHGSHtEquipRem);
    6971        4802 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSHtWindRem, Zone(iZone).Name, ZonePreDefRep(iZone).SHGSHtWindRem);
    6972        4802 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSHtIzaRem, Zone(iZone).Name, ZonePreDefRep(iZone).SHGSHtIzaRem);
    6973        4802 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSHtInfilRem, Zone(iZone).Name, ZonePreDefRep(iZone).SHGSHtInfilRem);
    6974        4802 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSHtOtherRem, Zone(iZone).Name, ZonePreDefRep(iZone).SHGSHtOtherRem);
    6975             :     }
    6976             :     // totals for annual report
    6977        5571 :     for (iZone = 1; iZone <= state.dataGlobal->NumOfZones; ++iZone) {
    6978        4802 :         state.dataOutRptTab->totalZoneEqHt += ZonePreDefRep(iZone).SHGSAnZoneEqHt;
    6979        4802 :         state.dataOutRptTab->totalZoneEqCl += ZonePreDefRep(iZone).SHGSAnZoneEqCl;
    6980        4802 :         state.dataOutRptTab->totalHvacATUHt += ZonePreDefRep(iZone).SHGSAnHvacATUHt;
    6981        4802 :         state.dataOutRptTab->totalHvacATUCl += ZonePreDefRep(iZone).SHGSAnHvacATUCl;
    6982        4802 :         state.dataOutRptTab->totalSurfHt += ZonePreDefRep(iZone).SHGSAnSurfHt;
    6983        4802 :         state.dataOutRptTab->totalSurfCl += ZonePreDefRep(iZone).SHGSAnSurfCl;
    6984        4802 :         state.dataOutRptTab->totalPeoplAdd += ZonePreDefRep(iZone).SHGSAnPeoplAdd;
    6985        4802 :         state.dataOutRptTab->totalLiteAdd += ZonePreDefRep(iZone).SHGSAnLiteAdd;
    6986        4802 :         state.dataOutRptTab->totalEquipAdd += ZonePreDefRep(iZone).SHGSAnEquipAdd;
    6987        4802 :         state.dataOutRptTab->totalWindAdd += ZonePreDefRep(iZone).SHGSAnWindAdd;
    6988        4802 :         state.dataOutRptTab->totalIzaAdd += ZonePreDefRep(iZone).SHGSAnIzaAdd;
    6989        4802 :         state.dataOutRptTab->totalInfilAdd += ZonePreDefRep(iZone).SHGSAnInfilAdd;
    6990        4802 :         state.dataOutRptTab->totalOtherAdd += ZonePreDefRep(iZone).SHGSAnOtherAdd;
    6991        4802 :         state.dataOutRptTab->totalEquipRem += ZonePreDefRep(iZone).SHGSAnEquipRem;
    6992        4802 :         state.dataOutRptTab->totalWindRem += ZonePreDefRep(iZone).SHGSAnWindRem;
    6993        4802 :         state.dataOutRptTab->totalIzaRem += ZonePreDefRep(iZone).SHGSAnIzaRem;
    6994        4802 :         state.dataOutRptTab->totalInfilRem += ZonePreDefRep(iZone).SHGSAnInfilRem;
    6995        4802 :         state.dataOutRptTab->totalOtherRem += ZonePreDefRep(iZone).SHGSAnOtherRem;
    6996             :     }
    6997             :     // PreDefTableEntry(state,  pdchSHGSAnHvacHt, "Total Facility", totalHvacHt * convertJtoGJ, 3 );
    6998             :     // PreDefTableEntry(state,  pdchSHGSAnHvacCl, "Total Facility", totalHvacCl * convertJtoGJ, 3 );
    6999        2307 :     PreDefTableEntry(state,
    7000         769 :                      state.dataOutRptPredefined->pdchSHGSAnZoneEqHt,
    7001             :                      "Total Facility",
    7002         769 :                      state.dataOutRptTab->totalZoneEqHt * DataGlobalConstants::convertJtoGJ,
    7003         769 :                      3);
    7004        2307 :     PreDefTableEntry(state,
    7005         769 :                      state.dataOutRptPredefined->pdchSHGSAnZoneEqCl,
    7006             :                      "Total Facility",
    7007         769 :                      state.dataOutRptTab->totalZoneEqCl * DataGlobalConstants::convertJtoGJ,
    7008         769 :                      3);
    7009        2307 :     PreDefTableEntry(state,
    7010         769 :                      state.dataOutRptPredefined->pdchSHGSAnHvacATUHt,
    7011             :                      "Total Facility",
    7012         769 :                      state.dataOutRptTab->totalHvacATUHt * DataGlobalConstants::convertJtoGJ,
    7013         769 :                      3);
    7014        2307 :     PreDefTableEntry(state,
    7015         769 :                      state.dataOutRptPredefined->pdchSHGSAnHvacATUCl,
    7016             :                      "Total Facility",
    7017         769 :                      state.dataOutRptTab->totalHvacATUCl * DataGlobalConstants::convertJtoGJ,
    7018         769 :                      3);
    7019        2307 :     PreDefTableEntry(state,
    7020         769 :                      state.dataOutRptPredefined->pdchSHGSAnSurfHt,
    7021             :                      "Total Facility",
    7022         769 :                      state.dataOutRptTab->totalSurfHt * DataGlobalConstants::convertJtoGJ,
    7023         769 :                      3);
    7024        2307 :     PreDefTableEntry(state,
    7025         769 :                      state.dataOutRptPredefined->pdchSHGSAnSurfCl,
    7026             :                      "Total Facility",
    7027         769 :                      state.dataOutRptTab->totalSurfCl * DataGlobalConstants::convertJtoGJ,
    7028         769 :                      3);
    7029        2307 :     PreDefTableEntry(state,
    7030         769 :                      state.dataOutRptPredefined->pdchSHGSAnPeoplAdd,
    7031             :                      "Total Facility",
    7032         769 :                      state.dataOutRptTab->totalPeoplAdd * DataGlobalConstants::convertJtoGJ,
    7033         769 :                      3);
    7034        2307 :     PreDefTableEntry(state,
    7035         769 :                      state.dataOutRptPredefined->pdchSHGSAnLiteAdd,
    7036             :                      "Total Facility",
    7037         769 :                      state.dataOutRptTab->totalLiteAdd * DataGlobalConstants::convertJtoGJ,
    7038         769 :                      3);
    7039        2307 :     PreDefTableEntry(state,
    7040         769 :                      state.dataOutRptPredefined->pdchSHGSAnEquipAdd,
    7041             :                      "Total Facility",
    7042         769 :                      state.dataOutRptTab->totalEquipAdd * DataGlobalConstants::convertJtoGJ,
    7043         769 :                      3);
    7044        2307 :     PreDefTableEntry(state,
    7045         769 :                      state.dataOutRptPredefined->pdchSHGSAnWindAdd,
    7046             :                      "Total Facility",
    7047         769 :                      state.dataOutRptTab->totalWindAdd * DataGlobalConstants::convertJtoGJ,
    7048         769 :                      3);
    7049        2307 :     PreDefTableEntry(state,
    7050         769 :                      state.dataOutRptPredefined->pdchSHGSAnIzaAdd,
    7051             :                      "Total Facility",
    7052         769 :                      state.dataOutRptTab->totalIzaAdd * DataGlobalConstants::convertJtoGJ,
    7053         769 :                      3);
    7054        2307 :     PreDefTableEntry(state,
    7055         769 :                      state.dataOutRptPredefined->pdchSHGSAnInfilAdd,
    7056             :                      "Total Facility",
    7057         769 :                      state.dataOutRptTab->totalInfilAdd * DataGlobalConstants::convertJtoGJ,
    7058         769 :                      3);
    7059        2307 :     PreDefTableEntry(state,
    7060         769 :                      state.dataOutRptPredefined->pdchSHGSAnOtherAdd,
    7061             :                      "Total Facility",
    7062         769 :                      state.dataOutRptTab->totalOtherAdd * DataGlobalConstants::convertJtoGJ,
    7063         769 :                      3);
    7064        2307 :     PreDefTableEntry(state,
    7065         769 :                      state.dataOutRptPredefined->pdchSHGSAnEquipRem,
    7066             :                      "Total Facility",
    7067         769 :                      state.dataOutRptTab->totalEquipRem * DataGlobalConstants::convertJtoGJ,
    7068         769 :                      3);
    7069        2307 :     PreDefTableEntry(state,
    7070         769 :                      state.dataOutRptPredefined->pdchSHGSAnWindRem,
    7071             :                      "Total Facility",
    7072         769 :                      state.dataOutRptTab->totalWindRem * DataGlobalConstants::convertJtoGJ,
    7073         769 :                      3);
    7074        2307 :     PreDefTableEntry(state,
    7075         769 :                      state.dataOutRptPredefined->pdchSHGSAnIzaRem,
    7076             :                      "Total Facility",
    7077         769 :                      state.dataOutRptTab->totalIzaRem * DataGlobalConstants::convertJtoGJ,
    7078         769 :                      3);
    7079        2307 :     PreDefTableEntry(state,
    7080         769 :                      state.dataOutRptPredefined->pdchSHGSAnInfilRem,
    7081             :                      "Total Facility",
    7082         769 :                      state.dataOutRptTab->totalInfilRem * DataGlobalConstants::convertJtoGJ,
    7083         769 :                      3);
    7084        2307 :     PreDefTableEntry(state,
    7085         769 :                      state.dataOutRptPredefined->pdchSHGSAnOtherRem,
    7086             :                      "Total Facility",
    7087         769 :                      state.dataOutRptTab->totalOtherRem * DataGlobalConstants::convertJtoGJ,
    7088         769 :                      3);
    7089             :     // building level results for peak cooling
    7090        1538 :     PreDefTableEntry(
    7091        2307 :         state, state.dataOutRptPredefined->pdchSHGSClTimePeak, "Total Facility", DateToString(state.dataHeatBal->BuildingPreDefRep.clPtTimeStamp));
    7092             :     // PreDefTableEntry(state,  pdchSHGSClHvacHt, "Total Facility", BuildingPreDefRep.SHGSClHvacHt );
    7093             :     // PreDefTableEntry(state,  pdchSHGSClHvacCl, "Total Facility", BuildingPreDefRep.SHGSClHvacCl );
    7094        2307 :     PreDefTableEntry(state,
    7095         769 :                      state.dataOutRptPredefined->pdchSHGSClHvacHt,
    7096             :                      "Total Facility",
    7097        1538 :                      (state.dataHeatBal->BuildingPreDefRep.SHGSClHvacHt - state.dataHeatBal->BuildingPreDefRep.SHGSClHvacATUHt));
    7098        2307 :     PreDefTableEntry(state,
    7099         769 :                      state.dataOutRptPredefined->pdchSHGSClHvacCl,
    7100             :                      "Total Facility",
    7101        1538 :                      (state.dataHeatBal->BuildingPreDefRep.SHGSClHvacCl - state.dataHeatBal->BuildingPreDefRep.SHGSClHvacATUCl));
    7102         769 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSClHvacATUHt, "Total Facility", state.dataHeatBal->BuildingPreDefRep.SHGSClHvacATUHt);
    7103         769 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSClHvacATUCl, "Total Facility", state.dataHeatBal->BuildingPreDefRep.SHGSClHvacATUCl);
    7104         769 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSClSurfHt, "Total Facility", state.dataHeatBal->BuildingPreDefRep.SHGSClSurfHt);
    7105         769 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSClSurfCl, "Total Facility", state.dataHeatBal->BuildingPreDefRep.SHGSClSurfCl);
    7106         769 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSClPeoplAdd, "Total Facility", state.dataHeatBal->BuildingPreDefRep.SHGSClPeoplAdd);
    7107         769 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSClLiteAdd, "Total Facility", state.dataHeatBal->BuildingPreDefRep.SHGSClLiteAdd);
    7108         769 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSClEquipAdd, "Total Facility", state.dataHeatBal->BuildingPreDefRep.SHGSClEquipAdd);
    7109         769 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSClWindAdd, "Total Facility", state.dataHeatBal->BuildingPreDefRep.SHGSClWindAdd);
    7110         769 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSClIzaAdd, "Total Facility", state.dataHeatBal->BuildingPreDefRep.SHGSClIzaAdd);
    7111         769 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSClInfilAdd, "Total Facility", state.dataHeatBal->BuildingPreDefRep.SHGSClInfilAdd);
    7112         769 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSClOtherAdd, "Total Facility", state.dataHeatBal->BuildingPreDefRep.SHGSClOtherAdd);
    7113         769 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSClEquipRem, "Total Facility", state.dataHeatBal->BuildingPreDefRep.SHGSClEquipRem);
    7114         769 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSClWindRem, "Total Facility", state.dataHeatBal->BuildingPreDefRep.SHGSClWindRem);
    7115         769 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSClIzaRem, "Total Facility", state.dataHeatBal->BuildingPreDefRep.SHGSClIzaRem);
    7116         769 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSClInfilRem, "Total Facility", state.dataHeatBal->BuildingPreDefRep.SHGSClInfilRem);
    7117         769 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSClOtherRem, "Total Facility", state.dataHeatBal->BuildingPreDefRep.SHGSClOtherRem);
    7118             :     // building level results for peak heating
    7119        1538 :     PreDefTableEntry(
    7120        2307 :         state, state.dataOutRptPredefined->pdchSHGSHtTimePeak, "Total Facility", DateToString(state.dataHeatBal->BuildingPreDefRep.htPtTimeStamp));
    7121             :     // PreDefTableEntry(state,  pdchSHGSHtHvacHt, "Total Facility", BuildingPreDefRep.SHGSHtHvacHt );
    7122             :     // PreDefTableEntry(state,  pdchSHGSHtHvacCl, "Total Facility", BuildingPreDefRep.SHGSHtHvacCl );
    7123        2307 :     PreDefTableEntry(state,
    7124         769 :                      state.dataOutRptPredefined->pdchSHGSHtHvacHt,
    7125             :                      "Total Facility",
    7126        1538 :                      (state.dataHeatBal->BuildingPreDefRep.SHGSHtHvacHt - state.dataHeatBal->BuildingPreDefRep.SHGSHtHvacATUHt));
    7127        2307 :     PreDefTableEntry(state,
    7128         769 :                      state.dataOutRptPredefined->pdchSHGSHtHvacCl,
    7129             :                      "Total Facility",
    7130        1538 :                      (state.dataHeatBal->BuildingPreDefRep.SHGSHtHvacCl - state.dataHeatBal->BuildingPreDefRep.SHGSHtHvacATUCl));
    7131         769 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSHtHvacATUHt, "Total Facility", state.dataHeatBal->BuildingPreDefRep.SHGSHtHvacATUHt);
    7132         769 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSHtHvacATUCl, "Total Facility", state.dataHeatBal->BuildingPreDefRep.SHGSHtHvacATUCl);
    7133         769 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSHtSurfHt, "Total Facility", state.dataHeatBal->BuildingPreDefRep.SHGSHtSurfHt);
    7134         769 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSHtSurfCl, "Total Facility", state.dataHeatBal->BuildingPreDefRep.SHGSHtSurfCl);
    7135         769 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSHtPeoplAdd, "Total Facility", state.dataHeatBal->BuildingPreDefRep.SHGSHtPeoplAdd);
    7136         769 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSHtLiteAdd, "Total Facility", state.dataHeatBal->BuildingPreDefRep.SHGSHtLiteAdd);
    7137         769 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSHtEquipAdd, "Total Facility", state.dataHeatBal->BuildingPreDefRep.SHGSHtEquipAdd);
    7138         769 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSHtWindAdd, "Total Facility", state.dataHeatBal->BuildingPreDefRep.SHGSHtWindAdd);
    7139         769 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSHtIzaAdd, "Total Facility", state.dataHeatBal->BuildingPreDefRep.SHGSHtIzaAdd);
    7140         769 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSHtInfilAdd, "Total Facility", state.dataHeatBal->BuildingPreDefRep.SHGSHtInfilAdd);
    7141         769 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSHtOtherAdd, "Total Facility", state.dataHeatBal->BuildingPreDefRep.SHGSHtOtherAdd);
    7142         769 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSHtEquipRem, "Total Facility", state.dataHeatBal->BuildingPreDefRep.SHGSHtEquipRem);
    7143         769 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSHtWindRem, "Total Facility", state.dataHeatBal->BuildingPreDefRep.SHGSHtWindRem);
    7144         769 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSHtIzaRem, "Total Facility", state.dataHeatBal->BuildingPreDefRep.SHGSHtIzaRem);
    7145         769 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSHtInfilRem, "Total Facility", state.dataHeatBal->BuildingPreDefRep.SHGSHtInfilRem);
    7146         769 :     PreDefTableEntry(state, state.dataOutRptPredefined->pdchSHGSHtOtherRem, "Total Facility", state.dataHeatBal->BuildingPreDefRep.SHGSHtOtherRem);
    7147             : 
    7148             :     // LEED Report
    7149             :     // 1.1A-General Information
    7150         769 :     if (state.dataEnvrn->EnvironmentName == state.dataEnvrn->WeatherFileLocationTitle) {
    7151           0 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchLeedGenData, "Weather File", state.dataEnvrn->EnvironmentName);
    7152             :     } else {
    7153        1538 :         PreDefTableEntry(state,
    7154         769 :                          state.dataOutRptPredefined->pdchLeedGenData,
    7155             :                          "Weather File",
    7156        2307 :                          state.dataEnvrn->EnvironmentName + " ** " + state.dataEnvrn->WeatherFileLocationTitle);
    7157             :     }
    7158             : 
    7159         769 :     if (ort->unitsStyle == UnitsStyle::InchPound) {
    7160          11 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchLeedGenData, "Total gross floor area [ft2]", "-");
    7161             :     } else {
    7162         758 :         PreDefTableEntry(state, state.dataOutRptPredefined->pdchLeedGenData, "Total gross floor area [m2]", "-");
    7163             :     }
    7164             :     // LEED schedule sub table
    7165       16691 :     for (long iSch = 1; iSch <= state.dataScheduleMgr->NumSchedules; ++iSch) {
    7166       31844 :         std::string curSchName = state.dataScheduleMgr->Schedule(iSch).Name;
    7167       31844 :         std::string curSchType = ScheduleManager::GetScheduleType(state, iSch);
    7168       15922 :         if (UtilityRoutines::SameString(curSchType, "FRACTION")) {
    7169       19212 :             PreDefTableEntry(state,
    7170        6404 :                              state.dataOutRptPredefined->pdchLeedEflhEflh,
    7171             :                              curSchName,
    7172        6404 :                              ScheduleManager::ScheduleAnnualFullLoadHours(state, iSch, StartOfWeek, state.dataEnvrn->CurrentYearIsLeapYear),
    7173             :                              0);
    7174       19212 :             PreDefTableEntry(state,
    7175        6404 :                              state.dataOutRptPredefined->pdchLeedEflhNonZerHrs,
    7176             :                              curSchName,
    7177        6404 :                              ScheduleManager::ScheduleHoursGT1perc(state, iSch, StartOfWeek, state.dataEnvrn->CurrentYearIsLeapYear),
    7178             :                              0);
    7179             :         }
    7180             :     }
    7181             :     // fill the LEED setpoint table
    7182         769 :     ZoneTempPredictorCorrector::FillPredefinedTableOnThermostatSetpoints(state);
    7183         769 : }
    7184             : 
    7185           2 : void WriteMonthlyTables(EnergyPlusData &state)
    7186             : {
    7187             :     // SUBROUTINE INFORMATION:
    7188             :     //       AUTHOR         Jason Glazer
    7189             :     //       DATE WRITTEN   August 2003
    7190             :     //       MODIFIED       January 2010, Kyle Benne
    7191             :     //                      Added SQLite output
    7192             :     //                      January 2021, J. Yuan
    7193             :     //                      Modified to accommodate dual-unit reporting
    7194             :     //       RE-ENGINEERED  na
    7195             : 
    7196             :     // PURPOSE OF THIS SUBROUTINE:
    7197             :     //   Set up the monthly tabular report results
    7198             : 
    7199             :     // METHODOLOGY EMPLOYED:
    7200             :     //   Creates several arrays that are passed to the WriteTable
    7201             :     //   routine.  All arrays are strings so numbers need to be
    7202             :     //   converted prior to calling WriteTable.
    7203             : 
    7204             :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
    7205           4 :     Array1D_string columnHead;
    7206           4 :     Array1D_int columnWidth;
    7207           4 :     Array1D_string rowHead(16);
    7208           4 :     Array2D_string tableBody;
    7209           4 :     std::string curAggString;
    7210             :     int iInput;
    7211             :     int jTable;
    7212             :     int kColumn;
    7213             :     int lMonth;
    7214             :     int curTable;
    7215             :     int curCol;
    7216             :     Real64 curVal;
    7217             :     Real64 curConversionFactor;
    7218             :     int columnUsedCount;
    7219             :     int columnRecount;
    7220             :     int digitsShown;
    7221             :     Real64 minVal;
    7222             :     Real64 maxVal;
    7223             :     Real64 sumVal;
    7224             :     Real64 sumDuration;
    7225           4 :     std::string curUnits;
    7226           4 :     std::string energyUnitsString;
    7227             :     Real64 energyUnitsConversionFactor;
    7228             :     int indexUnitConv;
    7229           4 :     std::string varNameWithUnits;
    7230             :     Real64 veryLarge;
    7231             :     Real64 verySmall;
    7232             : 
    7233             :     static Real64 const storedMaxVal(std::numeric_limits<Real64>::max());
    7234             :     static Real64 const storedMinVal(std::numeric_limits<Real64>::lowest());
    7235             : 
    7236           2 :     rowHead(1) = "January";
    7237           2 :     rowHead(2) = "February";
    7238           2 :     rowHead(3) = "March";
    7239           2 :     rowHead(4) = "April";
    7240           2 :     rowHead(5) = "May";
    7241           2 :     rowHead(6) = "June";
    7242           2 :     rowHead(7) = "July";
    7243           2 :     rowHead(8) = "August";
    7244           2 :     rowHead(9) = "September";
    7245           2 :     rowHead(10) = "October";
    7246           2 :     rowHead(11) = "November";
    7247           2 :     rowHead(12) = "December";
    7248           2 :     rowHead(13) = "";
    7249           2 :     rowHead(14) = "Annual Sum or Average";
    7250           2 :     rowHead(15) = "Minimum of Months";
    7251           2 :     rowHead(16) = "Maximum of Months";
    7252             : 
    7253             :     std::unordered_map<AggType, std::string> aggString = {
    7254             :         {AggType::SumOrAvg, ""},
    7255             :         {AggType::Maximum, " Maximum "},
    7256             :         {AggType::Minimum, " MINIMUM "},
    7257             :         {AggType::ValueWhenMaxMin, " AT MAX/MIN "},
    7258             :         {AggType::HoursZero, " HOURS ZERO "},
    7259             :         {AggType::HoursNonZero, " HOURS NON-ZERO "},
    7260             :         {AggType::HoursPositive, " HOURS POSITIVE "},
    7261             :         {AggType::HoursNonPositive, " HOURS NON-POSITIVE "},
    7262             :         {AggType::HoursNegative, " HOURS NEGATIVE "},
    7263             :         {AggType::HoursNonNegative, " HOURS NON-NEGATIVE "},
    7264             :         {AggType::SumOrAverageHoursShown, " FOR HOURS SHOWN "},
    7265             :         {AggType::MaximumDuringHoursShown, " MAX FOR HOURS SHOWN "},
    7266             :         {AggType::MinimumDuringHoursShown, " MIN FOR HOURS SHOWN "},
    7267           4 :     };
    7268             : 
    7269           2 :     veryLarge = 1.0E280;
    7270           2 :     verySmall = -1.0E280;
    7271             : 
    7272           2 :     auto &ort(state.dataOutRptTab);
    7273             : 
    7274           4 :     for (int iUnitSystem = 0; iUnitSystem <= 1; iUnitSystem++) {
    7275           4 :         UnitsStyle unitsStyle_cur = ort->unitsStyle;
    7276           4 :         bool produceTabular = true;
    7277           4 :         bool produceSQLite = false;
    7278           4 :         if (produceDualUnitsFlags(iUnitSystem, ort->unitsStyle, ort->unitsStyle_SQLite, unitsStyle_cur, produceTabular, produceSQLite)) break;
    7279             : 
    7280             :         // set the unit conversion
    7281           2 :         if (unitsStyle_cur == UnitsStyle::None) {
    7282           2 :             energyUnitsString = "J";
    7283           2 :             energyUnitsConversionFactor = 1.0;
    7284           0 :         } else if (unitsStyle_cur == UnitsStyle::JtoKWH) {
    7285           0 :             energyUnitsString = "kWh";
    7286           0 :             energyUnitsConversionFactor = 1.0 / 3600000.0;
    7287           0 :         } else if (unitsStyle_cur == UnitsStyle::JtoMJ) {
    7288           0 :             energyUnitsString = "MJ";
    7289           0 :             energyUnitsConversionFactor = 1.0 / 1000000.0;
    7290           0 :         } else if (unitsStyle_cur == UnitsStyle::JtoGJ) {
    7291           0 :             energyUnitsString = "GJ";
    7292           0 :             energyUnitsConversionFactor = 1.0 / 1000000000.0;
    7293             :         } else { // Should never happen but assures compilers of initialization
    7294           0 :             energyUnitsString = "J";
    7295           0 :             energyUnitsConversionFactor = 1.0;
    7296             :         }
    7297             : 
    7298             :         // loop through each input to get the name of the tables
    7299           2 :         for (iInput = 1; iInput <= ort->MonthlyInputCount; ++iInput) {
    7300             :             // loop through each report and
    7301           0 :             digitsShown = ort->MonthlyInput(iInput).showDigits;
    7302           0 :             for (jTable = 1; jTable <= ort->MonthlyInput(iInput).numTables; ++jTable) {
    7303           0 :                 curTable = jTable + ort->MonthlyInput(iInput).firstTable - 1;
    7304             :                 // first loop through and count how many 'columns' are defined
    7305             :                 // since max and min actually define two columns (the value
    7306             :                 // and the timestamp).
    7307           0 :                 columnUsedCount = 0;
    7308           0 :                 for (kColumn = 1; kColumn <= ort->MonthlyTables(curTable).numColumns; ++kColumn) {
    7309           0 :                     curCol = kColumn + ort->MonthlyTables(curTable).firstColumn - 1;
    7310           0 :                     switch (ort->MonthlyColumns(curCol).aggType) {
    7311           0 :                     case AggType::SumOrAvg:
    7312             :                     case AggType::ValueWhenMaxMin:
    7313             :                     case AggType::HoursZero:
    7314             :                     case AggType::HoursNonZero:
    7315             :                     case AggType::HoursPositive:
    7316             :                     case AggType::HoursNonPositive:
    7317             :                     case AggType::HoursNegative:
    7318             :                     case AggType::HoursNonNegative:
    7319             :                     case AggType::SumOrAverageHoursShown: {
    7320           0 :                         ++columnUsedCount;
    7321           0 :                     } break;
    7322           0 :                     case AggType::Maximum:
    7323             :                     case AggType::Minimum:
    7324             :                     case AggType::MaximumDuringHoursShown:
    7325             :                     case AggType::MinimumDuringHoursShown: {
    7326           0 :                         columnUsedCount += 2;
    7327           0 :                     } break;
    7328           0 :                     default:
    7329           0 :                         break;
    7330             :                     }
    7331             :                 } // jColumn
    7332           0 :                 columnHead.allocate(columnUsedCount);
    7333           0 :                 columnWidth.dimension(columnUsedCount, 14); // array assignment - same for all columns
    7334           0 :                 tableBody.allocate(columnUsedCount, 16);
    7335           0 :                 tableBody = ""; // set entire table to blank as default
    7336           0 :                 columnRecount = 0;
    7337           0 :                 for (kColumn = 1; kColumn <= ort->MonthlyTables(curTable).numColumns; ++kColumn) {
    7338           0 :                     curCol = kColumn + ort->MonthlyTables(curTable).firstColumn - 1;
    7339           0 :                     curAggString = aggString.at(ort->MonthlyColumns(curCol).aggType);
    7340           0 :                     if (len(curAggString) > 0) {
    7341           0 :                         curAggString = " {" + stripped(curAggString) + '}';
    7342             :                     }
    7343             :                     // do the unit conversions
    7344           0 :                     if (unitsStyle_cur == UnitsStyle::InchPound) {
    7345           0 :                         varNameWithUnits = ort->MonthlyColumns(curCol).varName + unitEnumToStringBrackets(ort->MonthlyColumns(curCol).units);
    7346           0 :                         LookupSItoIP(state, varNameWithUnits, indexUnitConv, curUnits);
    7347           0 :                         GetUnitConversion(state, indexUnitConv, curConversionFactor, state.dataOutRptTab->curConversionOffset, curUnits);
    7348             :                     } else { // just do the Joule conversion
    7349             :                         // if units is in Joules, convert if specified
    7350           0 :                         if (UtilityRoutines::SameString(unitEnumToString(ort->MonthlyColumns(curCol).units), "J")) {
    7351           0 :                             curUnits = energyUnitsString;
    7352           0 :                             curConversionFactor = energyUnitsConversionFactor;
    7353           0 :                             state.dataOutRptTab->curConversionOffset = 0.0;
    7354             :                         } else { // if not joules don't perform conversion
    7355           0 :                             curUnits = unitEnumToString(ort->MonthlyColumns(curCol).units);
    7356           0 :                             curConversionFactor = 1.0;
    7357           0 :                             state.dataOutRptTab->curConversionOffset = 0.0;
    7358             :                         }
    7359             :                     }
    7360           0 :                     switch (ort->MonthlyColumns(curCol).aggType) {
    7361           0 :                     case AggType::SumOrAvg:
    7362             :                     case AggType::SumOrAverageHoursShown: {
    7363           0 :                         ++columnRecount;
    7364             :                         // put in the name of the variable for the column
    7365           0 :                         columnHead(columnRecount) = ort->MonthlyColumns(curCol).varName + curAggString + " [" + curUnits + ']';
    7366           0 :                         sumVal = 0.0;
    7367           0 :                         sumDuration = 0.0;
    7368           0 :                         minVal = storedMaxVal;
    7369           0 :                         maxVal = storedMinVal;
    7370           0 :                         for (lMonth = 1; lMonth <= 12; ++lMonth) {
    7371           0 :                             if (ort->MonthlyColumns(curCol).avgSum ==
    7372             :                                 OutputProcessor::StoreType::Averaged) { // if it is a average variable divide by duration
    7373           0 :                                 if (ort->MonthlyColumns(curCol).duration(lMonth) != 0) {
    7374           0 :                                     curVal = ((ort->MonthlyColumns(curCol).reslt(lMonth) / ort->MonthlyColumns(curCol).duration(lMonth)) *
    7375             :                                               curConversionFactor) +
    7376           0 :                                              state.dataOutRptTab->curConversionOffset;
    7377             :                                 } else {
    7378           0 :                                     curVal = 0.0;
    7379             :                                 }
    7380           0 :                                 sumVal +=
    7381           0 :                                     (ort->MonthlyColumns(curCol).reslt(lMonth) * curConversionFactor) + state.dataOutRptTab->curConversionOffset;
    7382           0 :                                 sumDuration += ort->MonthlyColumns(curCol).duration(lMonth);
    7383             :                             } else {
    7384           0 :                                 curVal = (ort->MonthlyColumns(curCol).reslt(lMonth) * curConversionFactor) + state.dataOutRptTab->curConversionOffset;
    7385           0 :                                 sumVal += curVal;
    7386             :                             }
    7387           0 :                             if (ort->IsMonthGathered(lMonth)) {
    7388           0 :                                 tableBody(columnRecount, lMonth) = RealToStr(curVal, digitsShown);
    7389           0 :                                 if (curVal > maxVal) maxVal = curVal;
    7390           0 :                                 if (curVal < minVal) minVal = curVal;
    7391             :                             } else {
    7392           0 :                                 tableBody(columnRecount, lMonth) = "-";
    7393             :                             }
    7394             :                         } // lMonth
    7395             :                         // add the summary to bottom
    7396           0 :                         if (ort->MonthlyColumns(curCol).avgSum ==
    7397             :                             OutputProcessor::StoreType::Averaged) { // if it is a average variable divide by duration
    7398           0 :                             if (sumDuration > 0) {
    7399           0 :                                 tableBody(columnRecount, 14) = RealToStr(sumVal / sumDuration, digitsShown);
    7400             :                             } else {
    7401           0 :                                 tableBody(columnRecount, 14) = "";
    7402             :                             }
    7403             :                         } else {
    7404           0 :                             tableBody(columnRecount, 14) = RealToStr(sumVal, digitsShown);
    7405             :                         }
    7406           0 :                         if (minVal != storedMaxVal) {
    7407           0 :                             tableBody(columnRecount, 15) = RealToStr(minVal, digitsShown);
    7408             :                         }
    7409           0 :                         if (maxVal != storedMinVal) {
    7410           0 :                             tableBody(columnRecount, 16) = RealToStr(maxVal, digitsShown);
    7411             :                         }
    7412           0 :                     } break;
    7413           0 :                     case AggType::HoursZero:
    7414             :                     case AggType::HoursNonZero:
    7415             :                     case AggType::HoursPositive:
    7416             :                     case AggType::HoursNonPositive:
    7417             :                     case AggType::HoursNegative:
    7418             :                     case AggType::HoursNonNegative: {
    7419           0 :                         ++columnRecount;
    7420             :                         // put in the name of the variable for the column
    7421           0 :                         columnHead(columnRecount) = ort->MonthlyColumns(curCol).varName + curAggString + " [HOURS]";
    7422           0 :                         sumVal = 0.0;
    7423           0 :                         minVal = storedMaxVal;
    7424           0 :                         maxVal = storedMinVal;
    7425           0 :                         for (lMonth = 1; lMonth <= 12; ++lMonth) {
    7426           0 :                             curVal = ort->MonthlyColumns(curCol).reslt(lMonth);
    7427           0 :                             if (ort->IsMonthGathered(lMonth)) {
    7428           0 :                                 tableBody(columnRecount, lMonth) = RealToStr(curVal, digitsShown);
    7429           0 :                                 sumVal += curVal;
    7430           0 :                                 if (curVal > maxVal) maxVal = curVal;
    7431           0 :                                 if (curVal < minVal) minVal = curVal;
    7432             :                             } else {
    7433           0 :                                 tableBody(columnRecount, lMonth) = "-";
    7434             :                             }
    7435             :                         } // lMonth
    7436             :                         // add the summary to bottom
    7437           0 :                         tableBody(columnRecount, 14) = RealToStr(sumVal, digitsShown);
    7438           0 :                         if (minVal != storedMaxVal) {
    7439           0 :                             tableBody(columnRecount, 15) = RealToStr(minVal, digitsShown);
    7440             :                         }
    7441           0 :                         if (maxVal != storedMinVal) {
    7442           0 :                             tableBody(columnRecount, 16) = RealToStr(maxVal, digitsShown);
    7443             :                         }
    7444           0 :                     } break;
    7445           0 :                     case AggType::ValueWhenMaxMin: {
    7446           0 :                         ++columnRecount;
    7447           0 :                         if (ort->MonthlyColumns(curCol).avgSum == OutputProcessor::StoreType::Summed) {
    7448           0 :                             curUnits += "/s";
    7449             :                         }
    7450           0 :                         if (UtilityRoutines::SameString(curUnits, "J/s")) {
    7451           0 :                             curUnits = "W";
    7452             :                         }
    7453             :                         // CR7783 fix
    7454           0 :                         if (UtilityRoutines::SameString(curUnits, "kWh/s")) {
    7455           0 :                             curUnits = "W";
    7456           0 :                             curConversionFactor *= 3600000.0;
    7457             :                         }
    7458           0 :                         if (UtilityRoutines::SameString(curUnits, "GJ/s")) {
    7459           0 :                             curUnits = "kW";
    7460           0 :                             curConversionFactor *= 1000000.0;
    7461             :                         }
    7462           0 :                         if (UtilityRoutines::SameString(curUnits, "MJ/s")) {
    7463           0 :                             curUnits = "kW";
    7464           0 :                             curConversionFactor *= 1000.0;
    7465             :                         }
    7466           0 :                         if (UtilityRoutines::SameString(curUnits, "therm/s")) {
    7467           0 :                             curUnits = "kBtu/h";
    7468           0 :                             curConversionFactor *= 360000.0;
    7469             :                         }
    7470           0 :                         if (UtilityRoutines::SameString(curUnits, "kBtu/s")) {
    7471           0 :                             curUnits = "kBtu/h";
    7472           0 :                             curConversionFactor *= 3600.0;
    7473             :                         }
    7474           0 :                         if (UtilityRoutines::SameString(curUnits, "ton-hrs/s")) {
    7475           0 :                             curUnits = "ton";
    7476           0 :                             curConversionFactor *= 3600.0;
    7477             :                         }
    7478           0 :                         columnHead(columnRecount) = ort->MonthlyColumns(curCol).varName + curAggString + " [" + curUnits + ']';
    7479           0 :                         minVal = storedMaxVal;
    7480           0 :                         maxVal = storedMinVal;
    7481           0 :                         for (lMonth = 1; lMonth <= 12; ++lMonth) {
    7482           0 :                             curVal = ort->MonthlyColumns(curCol).reslt(lMonth) * curConversionFactor + state.dataOutRptTab->curConversionOffset;
    7483           0 :                             if (ort->IsMonthGathered(lMonth)) {
    7484           0 :                                 tableBody(columnRecount, lMonth) = RealToStr(curVal, digitsShown);
    7485           0 :                                 if (curVal > maxVal) maxVal = curVal;
    7486           0 :                                 if (curVal < minVal) minVal = curVal;
    7487             :                             } else {
    7488           0 :                                 tableBody(columnRecount, lMonth) = "-";
    7489             :                             }
    7490             :                         } // lMonth
    7491             :                         // add the summary to bottom
    7492           0 :                         if (minVal != storedMaxVal) {
    7493           0 :                             tableBody(columnRecount, 15) = RealToStr(minVal, digitsShown);
    7494             :                         }
    7495           0 :                         if (maxVal != storedMinVal) {
    7496           0 :                             tableBody(columnRecount, 16) = RealToStr(maxVal, digitsShown);
    7497             :                         }
    7498           0 :                     } break;
    7499           0 :                     case AggType::Maximum:
    7500             :                     case AggType::Minimum:
    7501             :                     case AggType::MaximumDuringHoursShown:
    7502             :                     case AggType::MinimumDuringHoursShown: {
    7503           0 :                         columnRecount += 2;
    7504             :                         // put in the name of the variable for the column
    7505           0 :                         if (ort->MonthlyColumns(curCol).avgSum == OutputProcessor::StoreType::Summed) { // if it is a summed variable
    7506           0 :                             curUnits += "/s";
    7507             :                         }
    7508           0 :                         if (UtilityRoutines::SameString(curUnits, "J/s")) {
    7509           0 :                             curUnits = "W";
    7510             :                         }
    7511             :                         // CR7783 fix
    7512           0 :                         if (UtilityRoutines::SameString(curUnits, "kWh/s")) {
    7513           0 :                             curUnits = "W";
    7514           0 :                             curConversionFactor *= 3600000.0;
    7515             :                         }
    7516           0 :                         if (UtilityRoutines::SameString(curUnits, "GJ/s")) {
    7517           0 :                             curUnits = "kW";
    7518           0 :                             curConversionFactor *= 1000000.0;
    7519             :                         }
    7520           0 :                         if (UtilityRoutines::SameString(curUnits, "MJ/s")) {
    7521           0 :                             curUnits = "kW";
    7522           0 :                             curConversionFactor *= 1000.0;
    7523             :                         }
    7524           0 :                         if (UtilityRoutines::SameString(curUnits, "therm/s")) {
    7525           0 :                             curUnits = "kBtu/h";
    7526           0 :                             curConversionFactor *= 360000.0;
    7527             :                         }
    7528           0 :                         if (UtilityRoutines::SameString(curUnits, "kBtu/s")) {
    7529           0 :                             curUnits = "kBtu/h";
    7530           0 :                             curConversionFactor *= 3600.0;
    7531             :                         }
    7532           0 :                         if (UtilityRoutines::SameString(curUnits, "ton-hrs/s")) {
    7533           0 :                             curUnits = "ton";
    7534           0 :                             curConversionFactor *= 3600.0;
    7535             :                         }
    7536           0 :                         columnHead(columnRecount - 1) = ort->MonthlyColumns(curCol).varName + curAggString + " [" + curUnits + ']';
    7537           0 :                         columnHead(columnRecount) = ort->MonthlyColumns(curCol).varName + " {TIMESTAMP}";
    7538           0 :                         minVal = storedMaxVal;
    7539           0 :                         maxVal = storedMinVal;
    7540           0 :                         for (lMonth = 1; lMonth <= 12; ++lMonth) {
    7541           0 :                             if (ort->IsMonthGathered(lMonth)) {
    7542           0 :                                 curVal = ort->MonthlyColumns(curCol).reslt(lMonth);
    7543             :                                 // CR7788 the conversion factors were causing an overflow for the InchPound case since the
    7544             :                                 // value was very small
    7545             :                                 // restructured the following lines to hide showing HUGE and -HUGE values in output table CR8154 Glazer
    7546           0 :                                 if ((curVal < veryLarge) && (curVal > verySmall)) {
    7547           0 :                                     curVal = curVal * curConversionFactor + state.dataOutRptTab->curConversionOffset;
    7548           0 :                                     if (curVal > maxVal) maxVal = curVal;
    7549           0 :                                     if (curVal < minVal) minVal = curVal;
    7550           0 :                                     if (curVal < veryLarge && curVal > verySmall) {
    7551           0 :                                         tableBody(columnRecount - 1, lMonth) = RealToStr(curVal, digitsShown);
    7552             :                                     } else {
    7553           0 :                                         tableBody(columnRecount - 1, lMonth) = "-";
    7554             :                                     }
    7555           0 :                                     tableBody(columnRecount, lMonth) = DateToString(ort->MonthlyColumns(curCol).timeStamp(lMonth));
    7556             :                                 } else {
    7557           0 :                                     tableBody(columnRecount - 1, lMonth) = "-";
    7558           0 :                                     tableBody(columnRecount, lMonth) = "-";
    7559             :                                 }
    7560             :                             } else {
    7561           0 :                                 tableBody(columnRecount - 1, lMonth) = "-";
    7562           0 :                                 tableBody(columnRecount, lMonth) = "-";
    7563             :                             }
    7564             :                         } // lMonth
    7565             :                         // add the summary to bottom
    7566             :                         // Don't include if the original min and max values are still present
    7567           0 :                         if (minVal < veryLarge) {
    7568           0 :                             tableBody(columnRecount - 1, 15) = RealToStr(minVal, digitsShown);
    7569             :                         } else {
    7570           0 :                             tableBody(columnRecount - 1, 15) = "-";
    7571             :                         }
    7572           0 :                         if (maxVal > verySmall) {
    7573           0 :                             tableBody(columnRecount - 1, 16) = RealToStr(maxVal, digitsShown);
    7574             :                         } else {
    7575           0 :                             tableBody(columnRecount - 1, 15) = "-";
    7576             :                         }
    7577           0 :                     } break;
    7578           0 :                     default:
    7579           0 :                         break;
    7580             :                     }
    7581             :                 } // KColumn
    7582           0 :                 if (produceTabular) {
    7583           0 :                     WriteReportHeaders(
    7584           0 :                         state, ort->MonthlyInput(iInput).name, ort->MonthlyTables(curTable).keyValue, OutputProcessor::StoreType::Averaged);
    7585           0 :                     WriteSubtitle(state, "Custom Monthly Report");
    7586           0 :                     WriteTable(state, tableBody, rowHead, columnHead, columnWidth, true); // transpose monthly XML tables.
    7587             :                 }
    7588           0 :                 if (produceSQLite) {
    7589           0 :                     if (state.dataSQLiteProcedures->sqlite) {
    7590           0 :                         state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(tableBody,
    7591             :                                                                                            rowHead,
    7592             :                                                                                            columnHead,
    7593           0 :                                                                                            ort->MonthlyInput(iInput).name,
    7594           0 :                                                                                            ort->MonthlyTables(curTable).keyValue,
    7595             :                                                                                            "Custom Monthly Report");
    7596             :                     }
    7597             :                 }
    7598           0 :                 if (produceTabular) {
    7599           0 :                     if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
    7600           0 :                         state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(tableBody,
    7601             :                                                                                                               rowHead,
    7602             :                                                                                                               columnHead,
    7603           0 :                                                                                                               ort->MonthlyInput(iInput).name,
    7604           0 :                                                                                                               ort->MonthlyTables(curTable).keyValue,
    7605             :                                                                                                               "Custom Monthly Report");
    7606             :                     }
    7607             :                 }
    7608             :             } // jTables
    7609             :         }     // iInput
    7610             :     }
    7611           2 : }
    7612             : 
    7613           2 : void WriteTimeBinTables(EnergyPlusData &state)
    7614             : {
    7615             :     // SUBROUTINE INFORMATION:
    7616             :     //       AUTHOR         Jason Glazer
    7617             :     //       DATE WRITTEN   August 2003
    7618             :     //       MODIFIED       January 2010, Kyle Benne
    7619             :     //                      Added SQLite output
    7620             :     //       RE-ENGINEERED  na
    7621             : 
    7622             :     // PURPOSE OF THIS SUBROUTINE:
    7623             :     //   Set up the time bin tabular report results
    7624             : 
    7625             :     // METHODOLOGY EMPLOYED:
    7626             :     //   Creates several arrays that are passed to the WriteTable
    7627             :     //   routine.  All arrays are strings so numbers need to be
    7628             :     //   converted prior to calling WriteTable.
    7629             : 
    7630             :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
    7631             :     int iInObj;
    7632             :     int iTable;
    7633             :     int kHour;
    7634             :     int kMonth;
    7635             :     int nCol;
    7636             :     // main table
    7637           4 :     Array1D_string columnHead;
    7638           4 :     Array1D_int columnWidth;
    7639           4 :     Array1D_string rowHead(39);
    7640           4 :     Array2D_string tableBody;
    7641             :     // stat table
    7642           4 :     Array1D_string columnHeadStat(1);
    7643           4 :     Array1D_int columnWidthStat(1);
    7644           4 :     Array1D_string rowHeadStat(6);
    7645           4 :     Array2D_string tableBodyStat(1, 6);
    7646             : 
    7647             :     Real64 curIntervalStart;
    7648             :     Real64 curIntervalSize;
    7649             :     int curIntervalCount;
    7650             :     int curResIndex;
    7651             :     int curNumTables;
    7652             :     int numIntervalDigits;
    7653             :     int firstReport;
    7654             :     Real64 topValue;
    7655             :     int repIndex;
    7656             :     Real64 rowTotal;
    7657             :     Real64 colTotal;
    7658             :     Real64 aboveTotal;
    7659             :     Real64 belowTotal;
    7660             :     Real64 tableTotal;
    7661           4 :     std::string repNameWithUnitsandscheduleName;
    7662             :     Real64 repStDev; // standard deviation
    7663             :     Real64 repMean;
    7664           4 :     std::string curNameWithSIUnits;
    7665           4 :     std::string curNameAndUnits;
    7666             :     int indexUnitConv;
    7667             : 
    7668           2 :     auto &ort(state.dataOutRptTab);
    7669             : 
    7670           4 :     for (int iUnitSystem = 0; iUnitSystem <= 1; iUnitSystem++) {
    7671           4 :         UnitsStyle unitsStyle_cur = ort->unitsStyle;
    7672           4 :         bool produceTabular = true;
    7673           4 :         bool produceSQLite = false;
    7674           4 :         if (produceDualUnitsFlags(iUnitSystem, ort->unitsStyle, ort->unitsStyle_SQLite, unitsStyle_cur, produceTabular, produceSQLite)) break;
    7675             : 
    7676           2 :         rowHead(1) = "Interval Start";
    7677           2 :         rowHead(2) = "Interval End";
    7678           2 :         rowHead(3) = "January";
    7679           2 :         rowHead(4) = "February";
    7680           2 :         rowHead(5) = "March";
    7681           2 :         rowHead(6) = "April";
    7682           2 :         rowHead(7) = "May";
    7683           2 :         rowHead(8) = "June";
    7684           2 :         rowHead(9) = "July";
    7685           2 :         rowHead(10) = "August";
    7686           2 :         rowHead(11) = "September";
    7687           2 :         rowHead(12) = "October";
    7688           2 :         rowHead(13) = "November";
    7689           2 :         rowHead(14) = "December";
    7690           2 :         rowHead(15) = "12:01 to  1:00 am";
    7691           2 :         rowHead(16) = " 1:01 to  2:00 am";
    7692           2 :         rowHead(17) = " 2:01 to  3:00 am";
    7693           2 :         rowHead(18) = " 3:01 to  4:00 am";
    7694           2 :         rowHead(19) = " 4:01 to  5:00 am";
    7695           2 :         rowHead(20) = " 5:01 to  6:00 am";
    7696           2 :         rowHead(21) = " 6:01 to  7:00 am";
    7697           2 :         rowHead(22) = " 7:01 to  8:00 am";
    7698           2 :         rowHead(23) = " 8:01 to  9:00 am";
    7699           2 :         rowHead(24) = " 9:01 to 10:00 am";
    7700           2 :         rowHead(25) = "10:01 to 11:00 am";
    7701           2 :         rowHead(26) = "11:01 to 12:00 pm";
    7702           2 :         rowHead(27) = "12:01 to  1:00 pm";
    7703           2 :         rowHead(28) = " 1:01 to  2:00 pm";
    7704           2 :         rowHead(29) = " 2:01 to  3:00 pm";
    7705           2 :         rowHead(30) = " 3:01 to  4:00 pm";
    7706           2 :         rowHead(31) = " 4:01 to  5:00 pm";
    7707           2 :         rowHead(32) = " 5:01 to  6:00 pm";
    7708           2 :         rowHead(33) = " 6:01 to  7:00 pm";
    7709           2 :         rowHead(34) = " 7:01 to  8:00 pm";
    7710           2 :         rowHead(35) = " 8:01 to  9:00 pm";
    7711           2 :         rowHead(36) = " 9:01 to 10:00 pm";
    7712           2 :         rowHead(37) = "10:01 to 11:00 pm";
    7713           2 :         rowHead(38) = "11:01 to 12:00 am";
    7714           2 :         rowHead(39) = "Total";
    7715             : 
    7716           2 :         for (iInObj = 1; iInObj <= ort->OutputTableBinnedCount; ++iInObj) {
    7717           0 :             firstReport = ort->OutputTableBinned(iInObj).resIndex;
    7718           0 :             curNameWithSIUnits = ort->OutputTableBinned(iInObj).varOrMeter + unitEnumToStringBrackets(ort->OutputTableBinned(iInObj).units);
    7719           0 :             if (unitsStyle_cur == UnitsStyle::InchPound) {
    7720           0 :                 LookupSItoIP(state, curNameWithSIUnits, indexUnitConv, curNameAndUnits);
    7721           0 :                 curIntervalStart = ConvertIP(state, indexUnitConv, ort->OutputTableBinned(iInObj).intervalStart);
    7722           0 :                 curIntervalSize = ConvertIPdelta(state, indexUnitConv, ort->OutputTableBinned(iInObj).intervalSize);
    7723             :             } else {
    7724           0 :                 curNameAndUnits = curNameWithSIUnits;
    7725           0 :                 curIntervalStart = ort->OutputTableBinned(iInObj).intervalStart;
    7726           0 :                 curIntervalSize = ort->OutputTableBinned(iInObj).intervalSize;
    7727             :             }
    7728           0 :             curIntervalCount = ort->OutputTableBinned(iInObj).intervalCount;
    7729           0 :             curResIndex = ort->OutputTableBinned(iInObj).resIndex;
    7730           0 :             curNumTables = ort->OutputTableBinned(iInObj).numTables;
    7731           0 :             topValue = curIntervalStart + curIntervalSize * curIntervalCount;
    7732           0 :             if (curIntervalSize < 1) {
    7733           0 :                 numIntervalDigits = 4;
    7734           0 :             } else if (curIntervalSize >= 10) {
    7735           0 :                 numIntervalDigits = 0;
    7736             :             } else {
    7737           0 :                 numIntervalDigits = 2;
    7738             :             }
    7739             :             // make arrays two columns wider for below and above bin range
    7740           0 :             columnHead.allocate(curIntervalCount + 3);
    7741           0 :             columnWidth.allocate(curIntervalCount + 3);
    7742           0 :             columnWidth = 14; // array assignment - same for all columns
    7743           0 :             tableBody.allocate(curIntervalCount + 3, 39);
    7744           0 :             tableBody = "";
    7745           0 :             columnHead = "- [hr]";
    7746           0 :             tableBody(1, 1) = "less than";
    7747           0 :             tableBody(1, 2) = RealToStr(curIntervalStart, numIntervalDigits);
    7748           0 :             for (nCol = 1; nCol <= curIntervalCount; ++nCol) {
    7749           0 :                 columnHead(nCol + 1) = fmt::format("{} [hr]", nCol);
    7750             :                 // beginning of interval
    7751           0 :                 tableBody(nCol + 1, 1) = RealToStr(curIntervalStart + (nCol - 1) * curIntervalSize, numIntervalDigits) + "<=";
    7752             :                 // end of interval
    7753           0 :                 tableBody(nCol + 1, 2) = RealToStr(curIntervalStart + nCol * curIntervalSize, numIntervalDigits) + '>';
    7754             :             }
    7755           0 :             tableBody(curIntervalCount + 2, 1) = "equal to or more than";
    7756           0 :             tableBody(curIntervalCount + 2, 2) = RealToStr(topValue, numIntervalDigits);
    7757           0 :             tableBody(curIntervalCount + 3, 1) = "Row";
    7758           0 :             tableBody(curIntervalCount + 3, 2) = "Total";
    7759           0 :             for (iTable = 1; iTable <= curNumTables; ++iTable) {
    7760           0 :                 repIndex = firstReport + (iTable - 1);
    7761           0 :                 if (ort->OutputTableBinned(iInObj).scheduleIndex == 0) {
    7762           0 :                     repNameWithUnitsandscheduleName = curNameAndUnits;
    7763             :                 } else {
    7764           0 :                     repNameWithUnitsandscheduleName = curNameAndUnits + " [" + ort->OutputTableBinned(iInObj).ScheduleName + ']';
    7765             :                 }
    7766           0 :                 if (produceTabular) {
    7767           0 :                     WriteReportHeaders(
    7768           0 :                         state, repNameWithUnitsandscheduleName, ort->BinObjVarID(repIndex).namesOfObj, ort->OutputTableBinned(iInObj).avgSum);
    7769             :                 }
    7770           0 :                 for (kHour = 1; kHour <= 24; ++kHour) {
    7771           0 :                     tableBody(1, 14 + kHour) = RealToStr(ort->BinResultsBelow(repIndex).hrly(kHour), 2);
    7772           0 :                     tableBody(curIntervalCount + 2, 14 + kHour) = RealToStr(ort->BinResultsAbove(repIndex).hrly(kHour), 2);
    7773           0 :                     rowTotal = ort->BinResultsBelow(repIndex).hrly(kHour) + ort->BinResultsAbove(repIndex).hrly(kHour);
    7774           0 :                     for (nCol = 1; nCol <= curIntervalCount; ++nCol) {
    7775           0 :                         tableBody(nCol + 1, 14 + kHour) = RealToStr(ort->BinResults(nCol, repIndex).hrly(kHour), 2);
    7776             :                         // sum the total for all columns
    7777           0 :                         rowTotal += ort->BinResults(nCol, repIndex).hrly(kHour);
    7778             :                     }
    7779           0 :                     tableBody(nCol + 2, 14 + kHour) = RealToStr(rowTotal, 2);
    7780             :                 }
    7781           0 :                 tableTotal = 0.0;
    7782           0 :                 for (kMonth = 1; kMonth <= 12; ++kMonth) {
    7783           0 :                     tableBody(1, 2 + kMonth) = RealToStr(ort->BinResultsBelow(repIndex).mnth(kMonth), 2);
    7784           0 :                     tableBody(curIntervalCount + 2, 2 + kMonth) = RealToStr(ort->BinResultsAbove(repIndex).mnth(kMonth), 2);
    7785           0 :                     rowTotal = ort->BinResultsBelow(repIndex).mnth(kMonth) + ort->BinResultsAbove(repIndex).mnth(kMonth);
    7786           0 :                     for (nCol = 1; nCol <= curIntervalCount; ++nCol) {
    7787           0 :                         tableBody(nCol + 1, 2 + kMonth) = RealToStr(ort->BinResults(nCol, repIndex).mnth(kMonth), 2);
    7788             :                         // sum the total for all columns
    7789           0 :                         rowTotal += ort->BinResults(nCol, repIndex).mnth(kMonth);
    7790             :                     }
    7791           0 :                     tableBody(nCol + 2, 2 + kMonth) = RealToStr(rowTotal, 2);
    7792           0 :                     tableTotal += rowTotal;
    7793             :                 }
    7794             :                 // compute total row
    7795           0 :                 for (nCol = 1; nCol <= curIntervalCount; ++nCol) {
    7796           0 :                     colTotal = 0.0;
    7797           0 :                     for (kMonth = 1; kMonth <= 12; ++kMonth) {
    7798           0 :                         colTotal += ort->BinResults(nCol, repIndex).mnth(kMonth);
    7799             :                     }
    7800           0 :                     tableBody(nCol + 1, 39) = RealToStr(colTotal, 2);
    7801             :                 }
    7802           0 :                 aboveTotal = 0.0;
    7803           0 :                 belowTotal = 0.0;
    7804           0 :                 for (kMonth = 1; kMonth <= 12; ++kMonth) {
    7805           0 :                     aboveTotal += ort->BinResultsAbove(repIndex).mnth(kMonth);
    7806           0 :                     belowTotal += ort->BinResultsBelow(repIndex).mnth(kMonth);
    7807             :                 }
    7808           0 :                 tableBody(1, 39) = RealToStr(belowTotal, 2);
    7809           0 :                 tableBody(curIntervalCount + 2, 39) = RealToStr(aboveTotal, 2);
    7810           0 :                 tableBody(curIntervalCount + 3, 39) = RealToStr(tableTotal, 2);
    7811           0 :                 if (produceTabular) {
    7812           0 :                     WriteTextLine(state, "Values in table are in hours.");
    7813           0 :                     WriteTextLine(state, "");
    7814           0 :                     WriteSubtitle(state, "Time Bin Results");
    7815           0 :                     WriteTable(state, tableBody, rowHead, columnHead, columnWidth, true); // transpose XML tables
    7816             :                 }
    7817           0 :                 if (produceSQLite) {
    7818           0 :                     if (state.dataSQLiteProcedures->sqlite) {
    7819           0 :                         state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(tableBody,
    7820             :                                                                                            rowHead,
    7821             :                                                                                            columnHead,
    7822             :                                                                                            repNameWithUnitsandscheduleName,
    7823           0 :                                                                                            ort->BinObjVarID(repIndex).namesOfObj,
    7824             :                                                                                            "Time Bin Results");
    7825             :                     }
    7826             :                 }
    7827           0 :                 if (produceTabular) {
    7828           0 :                     if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
    7829           0 :                         state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(tableBody,
    7830             :                                                                                                               rowHead,
    7831             :                                                                                                               columnHead,
    7832             :                                                                                                               repNameWithUnitsandscheduleName,
    7833           0 :                                                                                                               ort->BinObjVarID(repIndex).namesOfObj,
    7834             :                                                                                                               "Time Bin Results");
    7835             :                     }
    7836             :                 }
    7837             :                 // create statistics table
    7838           0 :                 rowHeadStat(1) = "Minimum";
    7839           0 :                 rowHeadStat(2) = "Mean minus two standard deviations";
    7840           0 :                 rowHeadStat(3) = "Mean";
    7841           0 :                 rowHeadStat(4) = "Mean plus two standard deviations";
    7842           0 :                 rowHeadStat(5) = "Maximum";
    7843           0 :                 rowHeadStat(6) = "Standard deviation";
    7844           0 :                 columnHeadStat(1) = "Statistic";
    7845           0 :                 columnWidthStat(1) = 14;
    7846             :                 // per Applied Regression Analysis and Other Multivariate Methods, Kleinburger/Kupper, 1978
    7847             :                 // first check if very large constant number has caused the second part to be larger than the first
    7848           0 :                 if (ort->BinStatistics(repIndex).n > 1) {
    7849           0 :                     if (ort->BinStatistics(repIndex).sum2 > (pow_2(ort->BinStatistics(repIndex).sum) / ort->BinStatistics(repIndex).n)) {
    7850           0 :                         repStDev = std::sqrt(
    7851           0 :                             (ort->BinStatistics(repIndex).sum2 - (pow_2(ort->BinStatistics(repIndex).sum) / ort->BinStatistics(repIndex).n)) /
    7852           0 :                             (ort->BinStatistics(repIndex).n - 1));
    7853             :                     } else {
    7854           0 :                         repStDev = 0.0;
    7855             :                     }
    7856           0 :                     repMean = ort->BinStatistics(repIndex).sum / ort->BinStatistics(repIndex).n;
    7857             :                 } else {
    7858           0 :                     repStDev = 0.0;
    7859           0 :                     repMean = 0.0;
    7860             :                 }
    7861           0 :                 if (unitsStyle_cur == UnitsStyle::InchPound) {
    7862           0 :                     tableBodyStat(1, 1) = RealToStr(ConvertIP(state, indexUnitConv, ort->BinStatistics(repIndex).minimum), 2);
    7863           0 :                     tableBodyStat(1, 2) = RealToStr(ConvertIP(state, indexUnitConv, repMean - 2 * repStDev), 2);
    7864           0 :                     tableBodyStat(1, 3) = RealToStr(ConvertIP(state, indexUnitConv, repMean), 2);
    7865           0 :                     tableBodyStat(1, 4) = RealToStr(ConvertIP(state, indexUnitConv, repMean + 2 * repStDev), 2);
    7866           0 :                     tableBodyStat(1, 5) = RealToStr(ConvertIP(state, indexUnitConv, ort->BinStatistics(repIndex).maximum), 2);
    7867           0 :                     tableBodyStat(1, 6) = RealToStr(ConvertIPdelta(state, indexUnitConv, repStDev), 2);
    7868             :                 } else {
    7869           0 :                     tableBodyStat(1, 1) = RealToStr(ort->BinStatistics(repIndex).minimum, 2);
    7870           0 :                     tableBodyStat(1, 2) = RealToStr(repMean - 2 * repStDev, 2);
    7871           0 :                     tableBodyStat(1, 3) = RealToStr(repMean, 2);
    7872           0 :                     tableBodyStat(1, 4) = RealToStr(repMean + 2 * repStDev, 2);
    7873           0 :                     tableBodyStat(1, 5) = RealToStr(ort->BinStatistics(repIndex).maximum, 2);
    7874           0 :                     tableBodyStat(1, 6) = RealToStr(repStDev, 2);
    7875             :                 }
    7876           0 :                 if (produceTabular) {
    7877           0 :                     WriteSubtitle(state, "Statistics");
    7878           0 :                     WriteTable(state, tableBodyStat, rowHeadStat, columnHeadStat, columnWidthStat, true); // transpose XML table
    7879             :                 }
    7880           0 :                 if (produceSQLite) {
    7881           0 :                     if (state.dataSQLiteProcedures->sqlite) {
    7882           0 :                         state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
    7883           0 :                             tableBody, rowHead, columnHead, repNameWithUnitsandscheduleName, ort->BinObjVarID(repIndex).namesOfObj, "Statistics");
    7884             :                     }
    7885             :                 }
    7886           0 :                 if (produceTabular) {
    7887           0 :                     if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
    7888           0 :                         state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(
    7889           0 :                             tableBody, rowHead, columnHead, repNameWithUnitsandscheduleName, ort->BinObjVarID(repIndex).namesOfObj, "Statistics");
    7890             :                     }
    7891             :                 }
    7892             :             }
    7893             :         }
    7894             :     }
    7895           2 : }
    7896             : 
    7897         731 : void WriteBEPSTable(EnergyPlusData &state)
    7898             : {
    7899             :     // SUBROUTINE INFORMATION:
    7900             :     //       AUTHOR         Jason Glazer
    7901             :     //       DATE WRITTEN   November 2003
    7902             :     //       MODIFIED       January 2010, Kyle Benne; Added SQLite output
    7903             :     //                      March 2020, Dareum Nam; Disaggregated "Additional Fuel"
    7904             : 
    7905             :     // PURPOSE OF THIS SUBROUTINE:
    7906             :     //   Take the gathered total and enduse meter data and structure
    7907             :     //   the results into a tabular report for output.
    7908             : 
    7909             :     // METHODOLOGY EMPLOYED:
    7910             :     //   Create arrays for the call to WriteTable and then call it.
    7911             :     //   This report actually consists of many sub-tables each with
    7912             :     //   its own call to WriteTable.  Anytime that column headings are
    7913             :     //   desired they are done in a new table because the only place
    7914             :     //   that will split up very long header lines for the fixed width
    7915             :     //   table is the header rows.
    7916             : 
    7917         731 :     int constexpr colElectricity(1);
    7918         731 :     int constexpr colGas(2);
    7919         731 :     int constexpr colGasoline(3);
    7920         731 :     int constexpr colDiesel(4);
    7921         731 :     int constexpr colCoal(5);
    7922         731 :     int constexpr colFuelOilNo1(6);
    7923         731 :     int constexpr colFuelOilNo2(7);
    7924         731 :     int constexpr colPropane(8);
    7925         731 :     int constexpr colOtherFuel1(9);
    7926         731 :     int constexpr colOtherFuel2(10);
    7927         731 :     int constexpr colPurchCool(11);
    7928         731 :     int constexpr colPurchHeat(12);
    7929             : 
    7930         731 :     Real64 constexpr SmallValue(1.e-14);
    7931         731 :     auto &ort(state.dataOutRptTab);
    7932             : 
    7933             :     // all arrays are in the format: (row, column)
    7934        1462 :     Array1D_string columnHead;
    7935        1462 :     Array1D_int columnWidth;
    7936        1462 :     Array1D_string rowHead;
    7937        1462 :     Array2D_string tableBody;
    7938             : 
    7939             :     // all arrays are in the format: (row, columnm)
    7940        1462 :     Array2D<Real64> useVal(13, 15);
    7941        1462 :     Array2D<Real64> normalVal(13, 4);
    7942        1462 :     Array1D<Real64> collapsedTotal(13);
    7943        1462 :     Array2D<Real64> collapsedEndUse(13, DataGlobalConstantsData::iEndUseSize);
    7944        1462 :     Array3D<Real64> collapsedEndUseSub(state.dataOutputProcessor->MaxNumSubcategories, DataGlobalConstantsData::iEndUseSize, 13);
    7945        1462 :     Array2D<Real64> endUseSubOther(13, DataGlobalConstantsData::iEndUseSize);
    7946        1462 :     Array3D<Real64> collapsedEndUseSpType(state.dataOutputProcessor->maxNumEndUseSpaceTypes, DataGlobalConstantsData::iEndUseSize, 13);
    7947             :     Real64 totalOnsiteHeat;
    7948             :     Real64 totalOnsiteWater;
    7949             :     Real64 totalWater;
    7950             :     Real64 netElecPurchasedSold;
    7951             :     Real64 totalSiteEnergyUse;
    7952             :     Real64 netSiteEnergyUse;
    7953             :     Real64 totalSourceEnergyUse;
    7954             :     Real64 netSourceEnergyUse;
    7955             :     Real64 netSourceElecPurchasedSold;
    7956             :     int iResource;
    7957             :     int i;
    7958             :     Real64 largeConversionFactor;
    7959             :     Real64 kConversionFactor;
    7960             :     Real64 initialStorage;
    7961             :     Real64 finalStorage;
    7962             :     Real64 StorageChange;
    7963             :     int resourcePrimaryHeating;
    7964             :     Real64 heatingMaximum;
    7965        1462 :     std::string footnote;
    7966             :     Real64 waterConversionFactor;
    7967             :     Real64 areaConversionFactor;
    7968             :     Real64 convBldgGrossFloorArea;
    7969             :     Real64 convBldgCondFloorArea;
    7970        1462 :     std::string curNameWithSIUnits;
    7971        1462 :     std::string curNameAndUnits;
    7972             :     int indexUnitConv;
    7973             :     Real64 processFraction;
    7974             :     Real64 processElecCost;
    7975             :     Real64 processGasCost;
    7976             :     Real64 processOthrCost;
    7977             :     Real64 useValColAddFuel15;
    7978             :     Real64 useValColAddFuel5;
    7979             :     Real64 useValColAddFuel13;
    7980             : 
    7981        1462 :     std::string subCatName;
    7982             :     Real64 unconvert;
    7983             : 
    7984             :     // Jan 2021: Added temp storage
    7985         731 :     Real64 gtPowerFuelFireGen = ort->gatherPowerFuelFireGen;
    7986         731 :     Real64 gtPowerPV = ort->gatherPowerPV;
    7987         731 :     Real64 gtPowerWind = ort->gatherPowerWind;
    7988         731 :     Real64 gtPowerHTGeothermal = ort->gatherPowerHTGeothermal;
    7989         731 :     Real64 gtPowerConversion = ort->gatherPowerConversion;
    7990         731 :     Real64 gtElecProduced = ort->gatherElecProduced;
    7991         731 :     Real64 gtElecPUrchased = ort->gatherElecPurchased;
    7992         731 :     Real64 gtElecSurplusSold = ort->gatherElecSurplusSold;
    7993             : 
    7994         731 :     Real64 gtWaterHeatRecovery = ort->gatherWaterHeatRecovery;
    7995         731 :     Real64 gtAirHeatRecoveryCool = ort->gatherAirHeatRecoveryCool;
    7996         731 :     Real64 gtAirHeatRecoveryHeat = ort->gatherAirHeatRecoveryHeat;
    7997         731 :     Real64 gtHeatHTGeothermal = ort->gatherHeatHTGeothermal;
    7998         731 :     Real64 gtHeatSolarWater = ort->gatherHeatSolarWater;
    7999         731 :     Real64 gtHeatSolarAir = ort->gatherHeatSolarAir;
    8000             : 
    8001         731 :     if (ort->displayTabularBEPS || ort->displayLEEDSummary) {
    8002             :         // show the headers of the report
    8003         730 :         if (ort->displayTabularBEPS) {
    8004         730 :             WriteReportHeaders(state, "Annual Building Utility Performance Summary", "Entire Facility", OutputProcessor::StoreType::Averaged);
    8005             :             // show the number of hours that the table applies to
    8006         730 :             WriteTextLine(state, "Values gathered over " + RealToStr(ort->gatherElapsedTimeBEPS, 2) + " hours", true);
    8007         730 :             if (ort->gatherElapsedTimeBEPS < 8759.0) { // might not add up to 8760 exactly but can't be more than 1 hour diff.
    8008         728 :                 WriteTextLine(state, "WARNING: THE REPORT DOES NOT REPRESENT A FULL ANNUAL SIMULATION.", true);
    8009             :             }
    8010         730 :             WriteTextLine(state, "", true);
    8011             :         }
    8012             : 
    8013        1460 :         for (int iUnitSystem = 0; iUnitSystem <= 1; iUnitSystem++) {
    8014        1460 :             UnitsStyle unitsStyle_cur = ort->unitsStyle;
    8015        1460 :             bool produceTabular = true;
    8016        1460 :             bool produceSQLite = false;
    8017        1460 :             if (produceDualUnitsFlags(iUnitSystem, ort->unitsStyle, ort->unitsStyle_SQLite, unitsStyle_cur, produceTabular, produceSQLite)) break;
    8018             : 
    8019             :             // determine building floor areas
    8020         730 :             DetermineBuildingFloorArea(state);
    8021             :             // collapse the gatherEndUseBEPS array to the resource groups displayed
    8022       10950 :             for (int jEndUse = 1; jEndUse <= DataGlobalConstantsData::iEndUseSize; ++jEndUse) {
    8023       10220 :                 collapsedEndUse(1, jEndUse) = ort->gatherEndUseBEPS(1, jEndUse);   // electricity
    8024       10220 :                 collapsedEndUse(2, jEndUse) = ort->gatherEndUseBEPS(2, jEndUse);   // natural gas
    8025       10220 :                 collapsedEndUse(3, jEndUse) = ort->gatherEndUseBEPS(6, jEndUse);   // gasoline
    8026       10220 :                 collapsedEndUse(4, jEndUse) = ort->gatherEndUseBEPS(8, jEndUse);   // diesel
    8027       10220 :                 collapsedEndUse(5, jEndUse) = ort->gatherEndUseBEPS(9, jEndUse);   // coal
    8028       10220 :                 collapsedEndUse(6, jEndUse) = ort->gatherEndUseBEPS(10, jEndUse);  // Fuel Oil No1
    8029       10220 :                 collapsedEndUse(7, jEndUse) = ort->gatherEndUseBEPS(11, jEndUse);  // Fuel Oil No2
    8030       10220 :                 collapsedEndUse(8, jEndUse) = ort->gatherEndUseBEPS(12, jEndUse);  // propane
    8031       10220 :                 collapsedEndUse(9, jEndUse) = ort->gatherEndUseBEPS(13, jEndUse);  // otherfuel1
    8032       10220 :                 collapsedEndUse(10, jEndUse) = ort->gatherEndUseBEPS(14, jEndUse); // otherfuel2
    8033       10220 :                 collapsedEndUse(11, jEndUse) = ort->gatherEndUseBEPS(3, jEndUse);  // district cooling <- purchased cooling
    8034       10220 :                 collapsedEndUse(12, jEndUse) =
    8035       10220 :                     ort->gatherEndUseBEPS(4, jEndUse) + ort->gatherEndUseBEPS(5, jEndUse); // district heating <- purchased heating | <- steam
    8036       10220 :                 collapsedEndUse(13, jEndUse) = ort->gatherEndUseBEPS(7, jEndUse);          // water
    8037             :             }
    8038             :             // repeat with totals
    8039         730 :             collapsedTotal(1) = ort->gatherTotalsBEPS(1);                             // electricity
    8040         730 :             collapsedTotal(2) = ort->gatherTotalsBEPS(2);                             // natural gas
    8041         730 :             collapsedTotal(3) = ort->gatherTotalsBEPS(6);                             // gasoline
    8042         730 :             collapsedTotal(4) = ort->gatherTotalsBEPS(8);                             // diesel
    8043         730 :             collapsedTotal(5) = ort->gatherTotalsBEPS(9);                             // coal
    8044         730 :             collapsedTotal(6) = ort->gatherTotalsBEPS(10);                            // Fuel Oil No1
    8045         730 :             collapsedTotal(7) = ort->gatherTotalsBEPS(11);                            // Fuel Oil No2
    8046         730 :             collapsedTotal(8) = ort->gatherTotalsBEPS(12);                            // propane
    8047         730 :             collapsedTotal(9) = ort->gatherTotalsBEPS(13);                            // other fuel 1
    8048         730 :             collapsedTotal(10) = ort->gatherTotalsBEPS(14);                           // other fuel 2
    8049         730 :             collapsedTotal(11) = ort->gatherTotalsBEPS(3);                            // district cooling <- purchased cooling
    8050         730 :             collapsedTotal(12) = ort->gatherTotalsBEPS(4) + ort->gatherTotalsBEPS(5); // district heating <- purchased heating | <- steam
    8051         730 :             collapsedTotal(13) = ort->gatherTotalsBEPS(7);                            // water
    8052             : 
    8053         730 :             if (produceTabular) {
    8054         730 :                 if (state.dataGlobal->createPerfLog) {
    8055           3 :                     UtilityRoutines::appendPerfLog(state, "Electricity ABUPS Total [J]", format("{:.3R}", collapsedTotal(1)));
    8056           3 :                     UtilityRoutines::appendPerfLog(state, "Natural Gas ABUPS Total [J]", format("{:.3R}", collapsedTotal(2)));
    8057           3 :                     UtilityRoutines::appendPerfLog(state, "Gasoline ABUPS Total [J]", format("{:.3R}", collapsedTotal(3)));
    8058           3 :                     UtilityRoutines::appendPerfLog(state, "Diesel ABUPS Total [J]", format("{:.3R}", collapsedTotal(4)));
    8059           3 :                     UtilityRoutines::appendPerfLog(state, "Coal ABUPS Total [J]", format("{:.3R}", collapsedTotal(5)));
    8060           3 :                     UtilityRoutines::appendPerfLog(state, "Fuel Oil No 1 ABUPS Total [J]", format("{:.3R}", collapsedTotal(6)));
    8061           3 :                     UtilityRoutines::appendPerfLog(state, "Fuel Oil No 2 ABUPS Total [J]", format("{:.3R}", collapsedTotal(7)));
    8062           3 :                     UtilityRoutines::appendPerfLog(state, "Propane ABUPS Total [J]", format("{:.3R}", collapsedTotal(8)));
    8063           3 :                     UtilityRoutines::appendPerfLog(state, "Other Fuel 1 ABUPS Total [J]", format("{:.3R}", collapsedTotal(9)));
    8064           3 :                     UtilityRoutines::appendPerfLog(state, "Other Fuel 2 ABUPS Total [J]", format("{:.3R}", collapsedTotal(10)));
    8065           3 :                     UtilityRoutines::appendPerfLog(state, "District Cooling ABUPS Total [J]", format("{:.3R}", collapsedTotal(11)));
    8066           3 :                     UtilityRoutines::appendPerfLog(state, "District Heating ABUPS Total [J]", format("{:.3R}", collapsedTotal(12)));
    8067           3 :                     UtilityRoutines::appendPerfLog(state, "Water ABUPS Total [m3]", format("{:.3R}", collapsedTotal(13)));
    8068           3 :                     UtilityRoutines::appendPerfLog(state, "Values Gathered Over [hours]", format("{:.2R}", ort->gatherElapsedTimeBEPS));
    8069           3 :                     UtilityRoutines::appendPerfLog(state,
    8070             :                                                    "Facility Any Zone Oscillating Temperatures Time [hours]",
    8071           6 :                                                    format("{:.2R}", state.dataZoneTempPredictorCorrector->AnnualAnyZoneTempOscillate));
    8072           3 :                     UtilityRoutines::appendPerfLog(state,
    8073             :                                                    "Facility Any Zone Oscillating Temperatures During Occupancy Time [hours]",
    8074           6 :                                                    format("{:.2R}", state.dataZoneTempPredictorCorrector->AnnualAnyZoneTempOscillateDuringOccupancy));
    8075           3 :                     UtilityRoutines::appendPerfLog(state,
    8076             :                                                    "Facility Any Zone Oscillating Temperatures in Deadband Time [hours]",
    8077           6 :                                                    format("{:.2R}", state.dataZoneTempPredictorCorrector->AnnualAnyZoneTempOscillateInDeadband));
    8078             :                 }
    8079             :             }
    8080       10950 :             for (int jEndUse = 1; jEndUse <= DataGlobalConstantsData::iEndUseSize; ++jEndUse) {
    8081       16259 :                 for (int kEndUseSub = 1; kEndUseSub <= state.dataOutputProcessor->EndUseCategory(jEndUse).NumSubcategories; ++kEndUseSub) {
    8082        6039 :                     collapsedEndUseSub(kEndUseSub, jEndUse, 1) = ort->gatherEndUseSubBEPS(kEndUseSub, jEndUse, 1);   // electricity
    8083        6039 :                     collapsedEndUseSub(kEndUseSub, jEndUse, 2) = ort->gatherEndUseSubBEPS(kEndUseSub, jEndUse, 2);   // natural gas
    8084        6039 :                     collapsedEndUseSub(kEndUseSub, jEndUse, 3) = ort->gatherEndUseSubBEPS(kEndUseSub, jEndUse, 6);   // gasoline
    8085        6039 :                     collapsedEndUseSub(kEndUseSub, jEndUse, 4) = ort->gatherEndUseSubBEPS(kEndUseSub, jEndUse, 8);   // diesel
    8086        6039 :                     collapsedEndUseSub(kEndUseSub, jEndUse, 5) = ort->gatherEndUseSubBEPS(kEndUseSub, jEndUse, 9);   // coal
    8087        6039 :                     collapsedEndUseSub(kEndUseSub, jEndUse, 6) = ort->gatherEndUseSubBEPS(kEndUseSub, jEndUse, 10);  // Fuel Oil No1
    8088        6039 :                     collapsedEndUseSub(kEndUseSub, jEndUse, 7) = ort->gatherEndUseSubBEPS(kEndUseSub, jEndUse, 11);  // Fuel Oil No2
    8089        6039 :                     collapsedEndUseSub(kEndUseSub, jEndUse, 8) = ort->gatherEndUseSubBEPS(kEndUseSub, jEndUse, 12);  // propane
    8090        6039 :                     collapsedEndUseSub(kEndUseSub, jEndUse, 9) = ort->gatherEndUseSubBEPS(kEndUseSub, jEndUse, 13);  // otherfuel1
    8091        6039 :                     collapsedEndUseSub(kEndUseSub, jEndUse, 10) = ort->gatherEndUseSubBEPS(kEndUseSub, jEndUse, 14); // otherfuel2
    8092        6039 :                     collapsedEndUseSub(kEndUseSub, jEndUse, 11) =
    8093        6039 :                         ort->gatherEndUseSubBEPS(kEndUseSub, jEndUse, 3); // district cooling <- purch cooling
    8094        6039 :                     collapsedEndUseSub(kEndUseSub, jEndUse, 12) =
    8095       12078 :                         ort->gatherEndUseSubBEPS(kEndUseSub, jEndUse, 4) +
    8096        6039 :                         ort->gatherEndUseSubBEPS(kEndUseSub, jEndUse, 5); // district heating <- purch heating | <- steam
    8097        6039 :                     collapsedEndUseSub(kEndUseSub, jEndUse, 13) = ort->gatherEndUseSubBEPS(kEndUseSub, jEndUse, 7); // water
    8098             :                 }
    8099             : 
    8100       11477 :                 for (int kEndUseSpType = 1; kEndUseSpType <= state.dataOutputProcessor->EndUseCategory(jEndUse).numSpaceTypes; ++kEndUseSpType) {
    8101        1257 :                     collapsedEndUseSpType(kEndUseSpType, jEndUse, 1) = ort->gatherEndUseSpTypeBEPS(kEndUseSpType, jEndUse, 1);   // electricity
    8102        1257 :                     collapsedEndUseSpType(kEndUseSpType, jEndUse, 2) = ort->gatherEndUseSpTypeBEPS(kEndUseSpType, jEndUse, 2);   // natural gas
    8103        1257 :                     collapsedEndUseSpType(kEndUseSpType, jEndUse, 3) = ort->gatherEndUseSpTypeBEPS(kEndUseSpType, jEndUse, 6);   // gasoline
    8104        1257 :                     collapsedEndUseSpType(kEndUseSpType, jEndUse, 4) = ort->gatherEndUseSpTypeBEPS(kEndUseSpType, jEndUse, 8);   // diesel
    8105        1257 :                     collapsedEndUseSpType(kEndUseSpType, jEndUse, 5) = ort->gatherEndUseSpTypeBEPS(kEndUseSpType, jEndUse, 9);   // coal
    8106        1257 :                     collapsedEndUseSpType(kEndUseSpType, jEndUse, 6) = ort->gatherEndUseSpTypeBEPS(kEndUseSpType, jEndUse, 10);  // Fuel Oil No1
    8107        1257 :                     collapsedEndUseSpType(kEndUseSpType, jEndUse, 7) = ort->gatherEndUseSpTypeBEPS(kEndUseSpType, jEndUse, 11);  // Fuel Oil No2
    8108        1257 :                     collapsedEndUseSpType(kEndUseSpType, jEndUse, 8) = ort->gatherEndUseSpTypeBEPS(kEndUseSpType, jEndUse, 12);  // propane
    8109        1257 :                     collapsedEndUseSpType(kEndUseSpType, jEndUse, 9) = ort->gatherEndUseSpTypeBEPS(kEndUseSpType, jEndUse, 13);  // otherfuel1
    8110        1257 :                     collapsedEndUseSpType(kEndUseSpType, jEndUse, 10) = ort->gatherEndUseSpTypeBEPS(kEndUseSpType, jEndUse, 14); // otherfuel2
    8111        1257 :                     collapsedEndUseSpType(kEndUseSpType, jEndUse, 11) =
    8112        1257 :                         ort->gatherEndUseSpTypeBEPS(kEndUseSpType, jEndUse, 3); // district cooling <- purch cooling
    8113        1257 :                     collapsedEndUseSpType(kEndUseSpType, jEndUse, 12) =
    8114        2514 :                         ort->gatherEndUseSpTypeBEPS(kEndUseSpType, jEndUse, 4) +
    8115        1257 :                         ort->gatherEndUseSpTypeBEPS(kEndUseSpType, jEndUse, 5); // district heating <- purch heating | <- steam
    8116        1257 :                     collapsedEndUseSpType(kEndUseSpType, jEndUse, 13) = ort->gatherEndUseSpTypeBEPS(kEndUseSpType, jEndUse, 7); // water
    8117             :                 }
    8118             :             }
    8119             :             // unit conversion - all values are used as divisors
    8120         730 :             switch (unitsStyle_cur) {
    8121           5 :             case UnitsStyle::JtoKWH: {
    8122           5 :                 largeConversionFactor = 3600000.0;
    8123           5 :                 kConversionFactor = 1.0;
    8124           5 :                 waterConversionFactor = 1.0;
    8125           5 :                 areaConversionFactor = 1.0;
    8126           5 :             } break;
    8127          11 :             case UnitsStyle::InchPound: {
    8128          11 :                 largeConversionFactor = getSpecificUnitDivider(state, "J", "kBtu"); // 1054351.84 J to kBtu
    8129          11 :                 kConversionFactor = 1.0;
    8130          11 :                 waterConversionFactor = getSpecificUnitDivider(state, "m3", "gal"); // 0.003785413 m3 to gal
    8131          11 :                 areaConversionFactor = getSpecificUnitDivider(state, "m2", "ft2");  // 0.092893973 m2 to ft2
    8132          11 :             } break;
    8133         714 :             default: {
    8134         714 :                 largeConversionFactor = 1000000000.0;
    8135         714 :                 kConversionFactor = 1000.0;
    8136         714 :                 waterConversionFactor = 1.0;
    8137         714 :                 areaConversionFactor = 1.0;
    8138         714 :             } break;
    8139             :             }
    8140             : 
    8141             :             // convert floor areas
    8142         730 :             convBldgGrossFloorArea = ort->buildingGrossFloorArea / areaConversionFactor;
    8143         730 :             convBldgCondFloorArea = ort->buildingConditionedFloorArea / areaConversionFactor;
    8144             : 
    8145             :             // convert units into GJ (divide by 1,000,000,000) if J otherwise kWh
    8146        9490 :             for (iResource = 1; iResource <= 12; ++iResource) { // don't do water
    8147      131400 :                 for (int jEndUse = 1; jEndUse <= DataGlobalConstantsData::iEndUseSize; ++jEndUse) {
    8148      122640 :                     collapsedEndUse(iResource, jEndUse) /= largeConversionFactor;
    8149      195108 :                     for (int kEndUseSub = 1; kEndUseSub <= state.dataOutputProcessor->EndUseCategory(jEndUse).NumSubcategories; ++kEndUseSub) {
    8150       72468 :                         collapsedEndUseSub(kEndUseSub, jEndUse, iResource) /= largeConversionFactor;
    8151             :                     }
    8152      137724 :                     for (int kEndUseSpType = 1; kEndUseSpType <= state.dataOutputProcessor->EndUseCategory(jEndUse).numSpaceTypes; ++kEndUseSpType) {
    8153       15084 :                         collapsedEndUseSpType(kEndUseSpType, jEndUse, iResource) /= largeConversionFactor;
    8154             :                     }
    8155             :                 }
    8156        8760 :                 collapsedTotal(iResource) /= largeConversionFactor;
    8157             :             }
    8158             :             // do water
    8159       10950 :             for (int jEndUse = 1; jEndUse <= DataGlobalConstantsData::iEndUseSize; ++jEndUse) {
    8160       10220 :                 collapsedEndUse(13, jEndUse) /= waterConversionFactor;
    8161       16259 :                 for (int kEndUseSub = 1; kEndUseSub <= state.dataOutputProcessor->EndUseCategory(jEndUse).NumSubcategories; ++kEndUseSub) {
    8162        6039 :                     collapsedEndUseSub(kEndUseSub, jEndUse, 13) /= waterConversionFactor;
    8163             :                 }
    8164       11477 :                 for (int kEndUseSpType = 1; kEndUseSpType <= state.dataOutputProcessor->EndUseCategory(jEndUse).numSpaceTypes; ++kEndUseSpType) {
    8165        1257 :                     collapsedEndUseSpType(kEndUseSpType, jEndUse, 13) /= waterConversionFactor;
    8166             :                 }
    8167             :             }
    8168             : 
    8169         730 :             collapsedTotal(13) = WaterConversionFunct(collapsedTotal(13), waterConversionFactor);
    8170             : 
    8171         730 :             if (iUnitSystem == 0) {
    8172         730 :                 gtPowerFuelFireGen = ort->gatherPowerFuelFireGen;
    8173         730 :                 gtPowerPV = ort->gatherPowerPV;
    8174         730 :                 gtPowerWind = ort->gatherPowerWind;
    8175         730 :                 gtPowerHTGeothermal = ort->gatherPowerHTGeothermal;
    8176         730 :                 gtPowerConversion = ort->gatherPowerConversion;
    8177         730 :                 gtElecProduced = ort->gatherElecProduced;
    8178         730 :                 gtElecPUrchased = ort->gatherElecPurchased;
    8179         730 :                 gtElecSurplusSold = ort->gatherElecSurplusSold;
    8180             :             } else { // if(iUnitSystem == 1)
    8181           0 :                 ort->gatherPowerFuelFireGen = gtPowerFuelFireGen;
    8182           0 :                 ort->gatherPowerPV = gtPowerPV;
    8183           0 :                 ort->gatherPowerWind = gtPowerWind;
    8184           0 :                 ort->gatherPowerHTGeothermal = gtPowerHTGeothermal;
    8185           0 :                 ort->gatherPowerConversion = gtPowerConversion;
    8186           0 :                 ort->gatherElecProduced = gtElecProduced;
    8187           0 :                 ort->gatherElecPurchased = gtElecPUrchased;
    8188           0 :                 ort->gatherElecSurplusSold = gtElecSurplusSold;
    8189             :             }
    8190             :             // convert to GJ
    8191         730 :             ort->gatherPowerFuelFireGen /= largeConversionFactor;
    8192         730 :             ort->gatherPowerPV /= largeConversionFactor;
    8193         730 :             ort->gatherPowerWind /= largeConversionFactor;
    8194         730 :             ort->gatherPowerHTGeothermal /= largeConversionFactor;
    8195         730 :             ort->gatherPowerConversion /= largeConversionFactor;
    8196         730 :             ort->gatherElecProduced /= largeConversionFactor;
    8197         730 :             ort->gatherElecPurchased /= largeConversionFactor;
    8198         730 :             ort->gatherElecSurplusSold /= largeConversionFactor;
    8199             : 
    8200             :             // get change in overall state of charge for electrical storage devices.
    8201         730 :             if (state.dataElectPwrSvcMgr->facilityElectricServiceObj->numElecStorageDevices > 0) {
    8202             :                 // All flow in/out of storage is accounted for in gatherElecStorage, so separate calculation of change in state of charge is not
    8203             :                 // necessary OverallNetEnergyFromStorage = ( sum( ElecStorage.StartingEnergyStored() ) - sum(
    8204             :                 // ElecStorage.ThisTimeStepStateOfCharge() ) ) + gatherElecStorage;
    8205           8 :                 ort->OverallNetEnergyFromStorage = ort->gatherElecStorage;
    8206           8 :                 ort->OverallNetEnergyFromStorage /= largeConversionFactor;
    8207             :             } else {
    8208         722 :                 ort->OverallNetEnergyFromStorage = 0.0;
    8209             :             }
    8210             :             // determine which resource is the primary heating resourse
    8211         730 :             resourcePrimaryHeating = 0;
    8212         730 :             heatingMaximum = 0.0;
    8213        9490 :             for (iResource = 1; iResource <= 12; ++iResource) { // don't do water
    8214        8760 :                 if (collapsedEndUse(iResource, state.dataGlobalConst->iEndUse.at(DataGlobalConstants::EndUse::Heating)) > heatingMaximum) {
    8215           2 :                     heatingMaximum = collapsedEndUse(iResource, state.dataGlobalConst->iEndUse.at(DataGlobalConstants::EndUse::Heating));
    8216           2 :                     resourcePrimaryHeating = iResource;
    8217             :                 }
    8218             :             }
    8219             : 
    8220             :             //---- Source and Site Energy Sub-Table
    8221         730 :             rowHead.allocate(4);
    8222         730 :             columnHead.allocate(3);
    8223         730 :             columnWidth.allocate(3);
    8224         730 :             columnWidth = 14; // array assignment - same for all columns
    8225         730 :             tableBody.allocate(3, 4);
    8226             : 
    8227         730 :             switch (unitsStyle_cur) {
    8228           5 :             case UnitsStyle::JtoKWH: {
    8229           5 :                 columnHead(1) = "Total Energy [kWh]";
    8230           5 :                 columnHead(2) = "Energy Per Total Building Area [kWh/m2]";
    8231           5 :                 columnHead(3) = "Energy Per Conditioned Building Area [kWh/m2]";
    8232           5 :             } break;
    8233          11 :             case UnitsStyle::InchPound: {
    8234          11 :                 columnHead(1) = "Total Energy [kBtu]";
    8235          11 :                 columnHead(2) = "Energy Per Total Building Area [kBtu/ft2]";
    8236          11 :                 columnHead(3) = "Energy Per Conditioned Building Area [kBtu/ft2]";
    8237          11 :             } break;
    8238         714 :             default: {
    8239         714 :                 columnHead(1) = "Total Energy [GJ]";
    8240         714 :                 columnHead(2) = "Energy Per Total Building Area [MJ/m2]";
    8241         714 :                 columnHead(3) = "Energy Per Conditioned Building Area [MJ/m2]";
    8242         714 :             } break;
    8243             :             }
    8244             : 
    8245         730 :             rowHead(1) = "Total Site Energy";
    8246         730 :             rowHead(2) = "Net Site Energy";
    8247         730 :             rowHead(3) = "Total Source Energy";
    8248         730 :             rowHead(4) = "Net Source Energy";
    8249             : 
    8250         730 :             tableBody = "";
    8251             : 
    8252             :             // compute the net amount of electricity received from the utility which
    8253             :             // is the amount purchased less the amount sold to the utility. Note that
    8254             :             // previously these variables were converted into GJ so now we don't need
    8255             :             // to do any conversion
    8256             :             // water is not included   gatherTotalsBEPS(7)    !water
    8257        2190 :             totalSiteEnergyUse = (ort->gatherTotalsBEPS(1) + ort->gatherTotalsBEPS(2) + ort->gatherTotalsBEPS(3) + ort->gatherTotalsBEPS(4) +
    8258        2190 :                                   ort->gatherTotalsBEPS(5) + ort->gatherTotalsBEPS(6) + ort->gatherTotalsBEPS(8) + ort->gatherTotalsBEPS(9) +
    8259        2190 :                                   ort->gatherTotalsBEPS(10) + ort->gatherTotalsBEPS(11) + ort->gatherTotalsBEPS(12) + ort->gatherTotalsBEPS(13) +
    8260         730 :                                   ort->gatherTotalsBEPS(14)) /
    8261             :                                  largeConversionFactor; // electricity | natural gas | district cooling | district heating | steam | gasoline |
    8262             :                                                         // diesel | coal | Fuel Oil No1 | Fuel Oil No2 | propane | otherfuel1 | otherfuel2
    8263             : 
    8264         730 :             netElecPurchasedSold = ort->gatherElecPurchased - ort->gatherElecSurplusSold;
    8265             : 
    8266             :             // water is not included   gatherTotalsBEPS(7)    !water
    8267         730 :             netSiteEnergyUse = netElecPurchasedSold +
    8268        1460 :                                (ort->gatherTotalsBEPS(2) + ort->gatherTotalsBEPS(3) + ort->gatherTotalsBEPS(4) + ort->gatherTotalsBEPS(5) +
    8269        2190 :                                 ort->gatherTotalsBEPS(6) + ort->gatherTotalsBEPS(8) + ort->gatherTotalsBEPS(9) + ort->gatherTotalsBEPS(10) +
    8270        1460 :                                 ort->gatherTotalsBEPS(11) + ort->gatherTotalsBEPS(12) + ort->gatherTotalsBEPS(13) + ort->gatherTotalsBEPS(14)) /
    8271             :                                    largeConversionFactor; // electricity (already in GJ) | natural gas | district cooling |
    8272             :                                                           // district heating | steam | gasoline | diesel | coal | Fuel Oil No1
    8273             :                                                           // | Fuel Oil No2 | propane | otherfuel1 | otherfuel2
    8274             : 
    8275         730 :             if (ort->efficiencyDistrictCooling == 0) ort->efficiencyDistrictCooling = 1.0;
    8276         730 :             if (ort->efficiencyDistrictHeating == 0) ort->efficiencyDistrictHeating = 1.0;
    8277             : 
    8278             :             // source emissions already have the source factors included in the calcs.
    8279         730 :             totalSourceEnergyUse = 0.0;
    8280             :             //  electricity
    8281         730 :             if (ort->fuelfactorsused(1)) {
    8282          82 :                 totalSourceEnergyUse += ort->gatherTotalsSource(1);
    8283             :             } else {
    8284         648 :                 totalSourceEnergyUse += ort->gatherTotalsBEPS(1) * ort->sourceFactorElectric;
    8285             :             }
    8286             :             //  natural gas
    8287         730 :             if (ort->fuelfactorsused(2)) {
    8288          75 :                 totalSourceEnergyUse += ort->gatherTotalsSource(2);
    8289             :             } else {
    8290         655 :                 totalSourceEnergyUse += ort->gatherTotalsBEPS(2) * ort->sourceFactorNaturalGas;
    8291             :             }
    8292             :             // gasoline
    8293         730 :             if (ort->fuelfactorsused(3)) {
    8294           0 :                 totalSourceEnergyUse += ort->gatherTotalsSource(3);
    8295             :             } else {
    8296         730 :                 totalSourceEnergyUse += ort->gatherTotalsBEPS(6) * ort->sourceFactorGasoline;
    8297             :             }
    8298             :             // diesel
    8299         730 :             if (ort->fuelfactorsused(4)) {
    8300           2 :                 totalSourceEnergyUse += ort->gatherTotalsSource(4);
    8301             :             } else {
    8302         728 :                 totalSourceEnergyUse += ort->gatherTotalsBEPS(8) * ort->sourceFactorDiesel;
    8303             :             }
    8304             :             // coal
    8305         730 :             if (ort->fuelfactorsused(5)) {
    8306           0 :                 totalSourceEnergyUse += ort->gatherTotalsSource(5);
    8307             :             } else {
    8308         730 :                 totalSourceEnergyUse += ort->gatherTotalsBEPS(9) * ort->sourceFactorCoal;
    8309             :             }
    8310             :             // Fuel Oil No1
    8311         730 :             if (ort->fuelfactorsused(6)) {
    8312          21 :                 totalSourceEnergyUse += ort->gatherTotalsSource(6);
    8313             :             } else {
    8314         709 :                 totalSourceEnergyUse += ort->gatherTotalsBEPS(10) * ort->sourceFactorFuelOil1;
    8315             :             }
    8316             :             // Fuel Oil No2
    8317         730 :             if (ort->fuelfactorsused(7)) {
    8318           0 :                 totalSourceEnergyUse += ort->gatherTotalsSource(7);
    8319             :             } else {
    8320         730 :                 totalSourceEnergyUse += ort->gatherTotalsBEPS(11) * ort->sourceFactorFuelOil2;
    8321             :             }
    8322             :             // propane
    8323         730 :             if (ort->fuelfactorsused(8)) {
    8324          21 :                 totalSourceEnergyUse += ort->gatherTotalsSource(8);
    8325             :             } else {
    8326         709 :                 totalSourceEnergyUse += ort->gatherTotalsBEPS(12) * ort->sourceFactorPropane;
    8327             :             }
    8328             :             // otherfuel1
    8329         730 :             if (ort->fuelfactorsused(11)) {
    8330           1 :                 totalSourceEnergyUse += ort->gatherTotalsSource(11);
    8331             :             } else {
    8332         729 :                 totalSourceEnergyUse += ort->gatherTotalsBEPS(13) * ort->sourceFactorOtherFuel1;
    8333             :             }
    8334             :             // otherfuel2
    8335         730 :             if (ort->fuelfactorsused(12)) {
    8336           0 :                 totalSourceEnergyUse += ort->gatherTotalsSource(12);
    8337             :             } else {
    8338         730 :                 totalSourceEnergyUse += ort->gatherTotalsBEPS(14) * ort->sourceFactorOtherFuel2;
    8339             :             }
    8340             : 
    8341        2190 :             totalSourceEnergyUse = (totalSourceEnergyUse + ort->gatherTotalsBEPS(3) * ort->sourceFactorElectric / ort->efficiencyDistrictCooling +
    8342        1460 :                                     ort->gatherTotalsBEPS(4) * ort->sourceFactorNaturalGas / ort->efficiencyDistrictHeating +
    8343         730 :                                     ort->gatherTotalsBEPS(5) * ort->sourceFactorSteam) /
    8344             :                                    largeConversionFactor; // district cooling | district heating | steam
    8345             : 
    8346             :             // now determine "net" source from purchased and surplus sold (still in J)
    8347             : 
    8348         730 :             if (ort->fuelfactorsused(1)) {
    8349          82 :                 netSourceElecPurchasedSold = ort->gatherTotalsSource(9) - ort->gatherTotalsSource(10);
    8350             :             } else {
    8351         648 :                 netSourceElecPurchasedSold = netElecPurchasedSold * ort->sourceFactorElectric * largeConversionFactor; // back to J
    8352             :             }
    8353             : 
    8354         730 :             netSourceEnergyUse = 0.0;
    8355             :             //  natural gas
    8356         730 :             if (ort->fuelfactorsused(2)) {
    8357          75 :                 netSourceEnergyUse += ort->gatherTotalsSource(2);
    8358             :             } else {
    8359         655 :                 netSourceEnergyUse += ort->gatherTotalsBEPS(2) * ort->sourceFactorNaturalGas;
    8360             :             }
    8361             :             // gasoline
    8362         730 :             if (ort->fuelfactorsused(3)) {
    8363           0 :                 netSourceEnergyUse += ort->gatherTotalsSource(3);
    8364             :             } else {
    8365         730 :                 netSourceEnergyUse += ort->gatherTotalsBEPS(6) * ort->sourceFactorGasoline;
    8366             :             }
    8367             :             // diesel
    8368         730 :             if (ort->fuelfactorsused(4)) {
    8369           2 :                 netSourceEnergyUse += ort->gatherTotalsSource(4);
    8370             :             } else {
    8371         728 :                 netSourceEnergyUse += ort->gatherTotalsBEPS(8) * ort->sourceFactorDiesel;
    8372             :             }
    8373             :             // coal
    8374         730 :             if (ort->fuelfactorsused(5)) {
    8375           0 :                 netSourceEnergyUse += ort->gatherTotalsSource(5);
    8376             :             } else {
    8377         730 :                 netSourceEnergyUse += ort->gatherTotalsBEPS(9) * ort->sourceFactorCoal;
    8378             :             }
    8379             :             // Fuel Oil No1
    8380         730 :             if (ort->fuelfactorsused(6)) {
    8381          21 :                 netSourceEnergyUse += ort->gatherTotalsSource(6);
    8382             :             } else {
    8383         709 :                 netSourceEnergyUse += ort->gatherTotalsBEPS(10) * ort->sourceFactorFuelOil1;
    8384             :             }
    8385             :             // Fuel Oil No2
    8386         730 :             if (ort->fuelfactorsused(7)) {
    8387           0 :                 netSourceEnergyUse += ort->gatherTotalsSource(7);
    8388             :             } else {
    8389         730 :                 netSourceEnergyUse += ort->gatherTotalsBEPS(11) * ort->sourceFactorFuelOil2;
    8390             :             }
    8391             :             // propane
    8392         730 :             if (ort->fuelfactorsused(8)) {
    8393          21 :                 netSourceEnergyUse += ort->gatherTotalsSource(8);
    8394             :             } else {
    8395         709 :                 netSourceEnergyUse += ort->gatherTotalsBEPS(12) * ort->sourceFactorPropane;
    8396             :             }
    8397             :             // otherfuel1
    8398         730 :             if (ort->fuelfactorsused(11)) {
    8399           1 :                 netSourceEnergyUse += ort->gatherTotalsSource(11);
    8400             :             } else {
    8401         729 :                 netSourceEnergyUse += ort->gatherTotalsBEPS(13) * ort->sourceFactorOtherFuel1;
    8402             :             }
    8403             :             // otherfuel2
    8404         730 :             if (ort->fuelfactorsused(12)) {
    8405           0 :                 netSourceEnergyUse += ort->gatherTotalsSource(12);
    8406             :             } else {
    8407         730 :                 netSourceEnergyUse += ort->gatherTotalsBEPS(14) * ort->sourceFactorOtherFuel2;
    8408             :             }
    8409             : 
    8410         730 :             netSourceEnergyUse =
    8411        1460 :                 (netSourceEnergyUse + netSourceElecPurchasedSold +
    8412        1460 :                  ort->gatherTotalsBEPS(3) * ort->sourceFactorElectric / ort->efficiencyDistrictCooling +
    8413        1460 :                  ort->gatherTotalsBEPS(4) * ort->sourceFactorNaturalGas / ort->efficiencyDistrictHeating +
    8414         730 :                  ort->gatherTotalsBEPS(5) * ort->sourceFactorSteam) /
    8415             :                 largeConversionFactor; // from other fuels | net source from electricity | district cooling | district heating | steam
    8416             : 
    8417             :             // show annual values
    8418         730 :             tableBody(1, 1) = RealToStr(totalSiteEnergyUse, 2);
    8419         730 :             tableBody(1, 2) = RealToStr(netSiteEnergyUse, 2);
    8420         730 :             tableBody(1, 3) = RealToStr(totalSourceEnergyUse, 2);
    8421         730 :             tableBody(1, 4) = RealToStr(netSourceEnergyUse, 2);
    8422             :             // show  per building area
    8423         730 :             if (convBldgGrossFloorArea > 0) {
    8424         702 :                 tableBody(2, 1) = RealToStr(totalSiteEnergyUse * kConversionFactor / convBldgGrossFloorArea, 2);
    8425         702 :                 tableBody(2, 2) = RealToStr(netSiteEnergyUse * kConversionFactor / convBldgGrossFloorArea, 2);
    8426         702 :                 tableBody(2, 3) = RealToStr(totalSourceEnergyUse * kConversionFactor / convBldgGrossFloorArea, 2);
    8427         702 :                 tableBody(2, 4) = RealToStr(netSourceEnergyUse * kConversionFactor / convBldgGrossFloorArea, 2);
    8428             :             }
    8429             :             // show  per conditioned building area
    8430         730 :             if (convBldgCondFloorArea > 0) {
    8431         651 :                 tableBody(3, 1) = RealToStr(totalSiteEnergyUse * kConversionFactor / convBldgCondFloorArea, 2);
    8432         651 :                 tableBody(3, 2) = RealToStr(netSiteEnergyUse * kConversionFactor / convBldgCondFloorArea, 2);
    8433         651 :                 tableBody(3, 3) = RealToStr(totalSourceEnergyUse * kConversionFactor / convBldgCondFloorArea, 2);
    8434         651 :                 tableBody(3, 4) = RealToStr(netSourceEnergyUse * kConversionFactor / convBldgCondFloorArea, 2);
    8435             :             }
    8436             : 
    8437             :             // heading for the entire sub-table
    8438         730 :             if (ort->displayTabularBEPS) {
    8439         730 :                 if (produceTabular) {
    8440         730 :                     WriteSubtitle(state, "Site and Source Energy");
    8441         730 :                     WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
    8442             :                 }
    8443         730 :                 if (produceSQLite) {
    8444         730 :                     if (state.dataSQLiteProcedures->sqlite) {
    8445         115 :                         state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
    8446             :                             tableBody, rowHead, columnHead, "AnnualBuildingUtilityPerformanceSummary", "Entire Facility", "Site and Source Energy");
    8447             :                     }
    8448             :                 }
    8449         730 :                 if (produceTabular) {
    8450         730 :                     if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
    8451           5 :                         state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(
    8452             :                             tableBody, rowHead, columnHead, "AnnualBuildingUtilityPerformanceSummary", "Entire Facility", "Site and Source Energy");
    8453             :                     }
    8454             :                 }
    8455             :             }
    8456             : 
    8457             :             //---- Source and Site Energy Sub-Table
    8458         730 :             rowHead.allocate(13);
    8459         730 :             columnHead.allocate(1);
    8460         730 :             columnWidth.allocate(1);
    8461         730 :             columnWidth = 50; // array assignment
    8462         730 :             tableBody.allocate(1, 13);
    8463             : 
    8464         730 :             columnHead(1) = "Site=>Source Conversion Factor";
    8465             : 
    8466         730 :             rowHead(1) = "Electricity";
    8467         730 :             rowHead(2) = "Natural Gas";
    8468         730 :             rowHead(3) = "District Cooling";
    8469         730 :             rowHead(4) = "District Heating";
    8470         730 :             rowHead(5) = "Steam";
    8471         730 :             rowHead(6) = "Gasoline";
    8472         730 :             rowHead(7) = "Diesel";
    8473         730 :             rowHead(8) = "Coal";
    8474         730 :             rowHead(9) = "Fuel Oil No 1";
    8475         730 :             rowHead(10) = "Fuel Oil No 2";
    8476         730 :             rowHead(11) = "Propane";
    8477         730 :             rowHead(12) = "Other Fuel 1";
    8478         730 :             rowHead(13) = "Other Fuel 2";
    8479             : 
    8480         730 :             tableBody = "";
    8481             : 
    8482             :             // set columns to conversion factors
    8483             :             // show values
    8484             :             //  tableBody(1,1)  = TRIM(RealToStr(sourceFactorElectric,3))
    8485             :             //  tableBody(2,1)  = TRIM(RealToStr(sourceFactorNaturalGas, 3))
    8486             :             //  tableBody(3,1)  = TRIM(RealToStr(sourceFactorElectric/ efficiencyDistrictCooling,3))
    8487             :             //  tableBody(4,1)  = TRIM(RealToStr(sourceFactorNaturalGas/ efficiencyDistrictHeating ,3))
    8488             :             //  tableBody(5,1)  = TRIM(RealToStr(sourceFactorSteam ,3))
    8489             :             //  tableBody(6,1)  = TRIM(RealToStr(sourceFactorGasoline ,3))
    8490             :             //  tableBody(7,1)  = TRIM(RealToStr(sourceFactorDiesel ,3))
    8491             :             //  tableBody(8,1)  = TRIM(RealToStr(sourceFactorCoal ,3))
    8492             :             //  tableBody(9,1)  = TRIM(RealToStr(sourceFactorFuelOil1 ,3))
    8493             :             //  tableBody(10,1) = TRIM(RealToStr(sourceFactorFuelOil2 ,3))
    8494             :             //  tableBody(11,1) = TRIM(RealToStr(sourceFactorPropane ,3))
    8495             : 
    8496         730 :             if (!ort->ffSchedUsed(1)) {
    8497         729 :                 tableBody(1, 1) = RealToStr(ort->sourceFactorElectric, 3);
    8498           1 :             } else if (ort->gatherTotalsBEPS(1) > SmallValue) {
    8499           0 :                 tableBody(1, 1) = "Effective Factor = " + RealToStr(ort->gatherTotalsBySourceBEPS(1) / ort->gatherTotalsBEPS(1), 3) +
    8500           0 :                                   " (calculated using schedule \"" + ScheduleManager::GetScheduleName(state, ort->ffSchedIndex(1)) + "\")";
    8501             :             } else {
    8502           1 :                 tableBody(1, 1) = "N/A";
    8503             :             }
    8504             : 
    8505         730 :             if (!ort->ffSchedUsed(2)) {
    8506         729 :                 tableBody(1, 2) = RealToStr(ort->sourceFactorNaturalGas, 3);
    8507           1 :             } else if (ort->gatherTotalsBEPS(2) > SmallValue) {
    8508           0 :                 tableBody(1, 2) = "Effective Factor = " + RealToStr(ort->gatherTotalsBySourceBEPS(2) / ort->gatherTotalsBEPS(2), 3) +
    8509           0 :                                   " (calculated using schedule \"" + ScheduleManager::GetScheduleName(state, ort->ffSchedIndex(2)) + "\")";
    8510             :             } else {
    8511           1 :                 tableBody(1, 2) = "N/A";
    8512             :             }
    8513             : 
    8514         730 :             tableBody(1, 3) = RealToStr(ort->sourceFactorElectric / ort->efficiencyDistrictCooling, 3); // District Cooling
    8515             : 
    8516         730 :             tableBody(1, 4) = RealToStr(ort->sourceFactorNaturalGas / ort->efficiencyDistrictHeating, 3); // District Heating
    8517             : 
    8518         730 :             tableBody(1, 5) = RealToStr(ort->sourceFactorSteam, 3); // Steam
    8519             : 
    8520         730 :             if (!ort->ffSchedUsed(6)) {
    8521         730 :                 tableBody(1, 6) = RealToStr(ort->sourceFactorGasoline, 3);
    8522           0 :             } else if (ort->gatherTotalsBEPS(6) > SmallValue) {
    8523           0 :                 tableBody(1, 6) = "Effective Factor = " + RealToStr(ort->gatherTotalsBySourceBEPS(6) / ort->gatherTotalsBEPS(6), 3) +
    8524           0 :                                   " (calculated using schedule \"" + ScheduleManager::GetScheduleName(state, ort->ffSchedIndex(6)) + "\")";
    8525             :             } else {
    8526           0 :                 tableBody(1, 6) = "N/A";
    8527             :             }
    8528             : 
    8529         730 :             if (!ort->ffSchedUsed(8)) {
    8530         730 :                 tableBody(1, 7) = RealToStr(ort->sourceFactorDiesel, 3);
    8531           0 :             } else if (ort->gatherTotalsBEPS(8) > SmallValue) {
    8532           0 :                 tableBody(1, 7) = "Effective Factor = " + RealToStr(ort->gatherTotalsBySourceBEPS(8) / ort->gatherTotalsBEPS(8), 3) +
    8533           0 :                                   " (calculated using schedule \"" + ScheduleManager::GetScheduleName(state, ort->ffSchedIndex(8)) + "\")";
    8534             :             } else {
    8535           0 :                 tableBody(1, 7) = "N/A";
    8536             :             }
    8537             : 
    8538         730 :             if (!ort->ffSchedUsed(9)) {
    8539         730 :                 tableBody(1, 8) = RealToStr(ort->sourceFactorCoal, 3);
    8540           0 :             } else if (ort->gatherTotalsBEPS(9) > SmallValue) {
    8541           0 :                 tableBody(1, 8) = "Effective Factor = " + RealToStr(ort->gatherTotalsBySourceBEPS(9) / ort->gatherTotalsBEPS(9), 3) +
    8542           0 :                                   " (calculated using schedule \"" + ScheduleManager::GetScheduleName(state, ort->ffSchedIndex(9)) + "\")";
    8543             :             } else {
    8544           0 :                 tableBody(1, 8) = "N/A";
    8545             :             }
    8546             : 
    8547         730 :             if (!ort->ffSchedUsed(10)) {
    8548         730 :                 tableBody(1, 9) = RealToStr(ort->sourceFactorFuelOil1, 3);
    8549           0 :             } else if (ort->gatherTotalsBEPS(10) > SmallValue) {
    8550           0 :                 tableBody(1, 9) = "Effective Factor = " + RealToStr(ort->gatherTotalsBySourceBEPS(10) / ort->gatherTotalsBEPS(10), 3) +
    8551           0 :                                   " (calculated using schedule \"" + ScheduleManager::GetScheduleName(state, ort->ffSchedIndex(10)) + "\")";
    8552             :             } else {
    8553           0 :                 tableBody(1, 9) = "N/A";
    8554             :             }
    8555             : 
    8556         730 :             if (!ort->ffSchedUsed(11)) {
    8557         730 :                 tableBody(1, 10) = RealToStr(ort->sourceFactorFuelOil2, 3);
    8558           0 :             } else if (ort->gatherTotalsBEPS(11) > SmallValue) {
    8559           0 :                 tableBody(1, 10) = "Effective Factor = " + RealToStr(ort->gatherTotalsBySourceBEPS(11) / ort->gatherTotalsBEPS(11), 3) +
    8560           0 :                                    " (calculated using schedule \"" + ScheduleManager::GetScheduleName(state, ort->ffSchedIndex(11)) + "\")";
    8561             :             } else {
    8562           0 :                 tableBody(1, 10) = "N/A";
    8563             :             }
    8564             : 
    8565         730 :             if (!ort->ffSchedUsed(12)) {
    8566         730 :                 tableBody(1, 11) = RealToStr(ort->sourceFactorPropane, 3);
    8567           0 :             } else if (ort->gatherTotalsBEPS(12) > SmallValue) {
    8568           0 :                 tableBody(1, 11) = "Effective Factor = " + RealToStr(ort->gatherTotalsBySourceBEPS(12) / ort->gatherTotalsBEPS(12), 3) +
    8569           0 :                                    " (calculated using schedule \"" + ScheduleManager::GetScheduleName(state, ort->ffSchedIndex(12)) + "\")";
    8570             :             } else {
    8571           0 :                 tableBody(1, 11) = "N/A";
    8572             :             }
    8573             : 
    8574         730 :             if (!ort->ffSchedUsed(13)) {
    8575         730 :                 tableBody(1, 12) = RealToStr(ort->sourceFactorOtherFuel1, 3);
    8576           0 :             } else if (ort->gatherTotalsBEPS(13) > SmallValue) {
    8577           0 :                 tableBody(1, 12) = "Effective Factor = " + RealToStr(ort->gatherTotalsBySourceBEPS(13) / ort->gatherTotalsBEPS(13), 3) +
    8578           0 :                                    " (calculated using schedule \"" + ScheduleManager::GetScheduleName(state, ort->ffSchedIndex(13)) + "\")";
    8579             :             } else {
    8580           0 :                 tableBody(1, 12) = "N/A";
    8581             :             }
    8582             : 
    8583         730 :             if (!ort->ffSchedUsed(14)) {
    8584         730 :                 tableBody(1, 13) = RealToStr(ort->sourceFactorOtherFuel2, 3);
    8585           0 :             } else if (ort->gatherTotalsBEPS(14) > SmallValue) {
    8586           0 :                 tableBody(1, 13) = "Effective Factor = " + RealToStr(ort->gatherTotalsBySourceBEPS(14) / ort->gatherTotalsBEPS(14), 3) +
    8587           0 :                                    " (calculated using schedule \"" + ScheduleManager::GetScheduleName(state, ort->ffSchedIndex(14)) + "\")";
    8588             :             } else {
    8589           0 :                 tableBody(1, 13) = "N/A";
    8590             :             }
    8591             : 
    8592             :             // heading for the entire sub-table
    8593         730 :             if (ort->displayTabularBEPS) {
    8594         730 :                 if (produceTabular) {
    8595         730 :                     WriteSubtitle(state, "Site to Source Energy Conversion Factors");
    8596         730 :                     WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
    8597             :                 }
    8598         730 :                 if (produceSQLite) {
    8599         730 :                     if (state.dataSQLiteProcedures->sqlite) {
    8600         115 :                         state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(tableBody,
    8601             :                                                                                            rowHead,
    8602             :                                                                                            columnHead,
    8603             :                                                                                            "AnnualBuildingUtilityPerformanceSummary",
    8604             :                                                                                            "Entire Facility",
    8605             :                                                                                            "Site to Source Energy Conversion Factors");
    8606             :                     }
    8607             :                 }
    8608         730 :                 if (produceTabular) {
    8609         730 :                     if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
    8610           5 :                         state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(
    8611             :                             tableBody,
    8612             :                             rowHead,
    8613             :                             columnHead,
    8614             :                             "AnnualBuildingUtilityPerformanceSummary",
    8615             :                             "Entire Facility",
    8616             :                             "Site to Source Energy Conversion Factors");
    8617             :                     }
    8618             :                 }
    8619             :             }
    8620             : 
    8621             :             //---- Building Area Sub-Table
    8622         730 :             rowHead.allocate(3);
    8623         730 :             columnHead.allocate(1);
    8624         730 :             columnWidth.allocate(1);
    8625         730 :             columnWidth = 14; // array assignment - same for all columns
    8626         730 :             tableBody.allocate(1, 3);
    8627             : 
    8628         730 :             switch (unitsStyle_cur) {
    8629           5 :             case UnitsStyle::JtoKWH: {
    8630           5 :                 columnHead(1) = "Area [m2]";
    8631           5 :             } break;
    8632          11 :             case UnitsStyle::InchPound: {
    8633          11 :                 columnHead(1) = "Area [ft2]";
    8634          11 :             } break;
    8635         714 :             default: {
    8636         714 :                 columnHead(1) = "Area [m2]";
    8637         714 :             } break;
    8638             :             }
    8639             : 
    8640         730 :             rowHead(1) = "Total Building Area";
    8641         730 :             rowHead(2) = "Net Conditioned Building Area";
    8642         730 :             rowHead(3) = "Unconditioned Building Area";
    8643             : 
    8644         730 :             tableBody = "";
    8645         730 :             tableBody(1, 1) = RealToStr(convBldgGrossFloorArea, 2);
    8646             : 
    8647         730 :             if (unitsStyle_cur == UnitsStyle::InchPound) {
    8648          11 :                 if (produceTabular) {
    8649          22 :                     PreDefTableEntry(
    8650          33 :                         state, state.dataOutRptPredefined->pdchLeedGenData, "Total gross floor area [ft2]", RealToStr(convBldgGrossFloorArea, 2));
    8651             :                 }
    8652             :             } else {
    8653         719 :                 if (produceTabular) {
    8654        1438 :                     PreDefTableEntry(
    8655        2157 :                         state, state.dataOutRptPredefined->pdchLeedGenData, "Total gross floor area [m2]", RealToStr(convBldgGrossFloorArea, 2));
    8656             :                 }
    8657             :             }
    8658             : 
    8659         730 :             tableBody(1, 2) = RealToStr(convBldgCondFloorArea, 2);
    8660         730 :             tableBody(1, 3) = RealToStr(convBldgGrossFloorArea - convBldgCondFloorArea, 2);
    8661             : 
    8662             :             // heading for the entire sub-table
    8663         730 :             if (ort->displayTabularBEPS) {
    8664         730 :                 if (produceTabular) {
    8665         730 :                     WriteSubtitle(state, "Building Area");
    8666         730 :                     WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
    8667             :                 }
    8668         730 :                 if (produceSQLite) {
    8669         730 :                     if (state.dataSQLiteProcedures->sqlite) {
    8670         115 :                         state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
    8671             :                             tableBody, rowHead, columnHead, "AnnualBuildingUtilityPerformanceSummary", "Entire Facility", "Building Area");
    8672             :                     }
    8673             :                 }
    8674         730 :                 if (produceTabular) {
    8675         730 :                     if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
    8676           5 :                         state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(
    8677             :                             tableBody, rowHead, columnHead, "AnnualBuildingUtilityPerformanceSummary", "Entire Facility", "Building Area");
    8678             :                     }
    8679             :                 }
    8680             :             }
    8681             : 
    8682             :             //---- End Use Sub-Table
    8683         730 :             rowHead.allocate(16);
    8684         730 :             columnHead.allocate(13);
    8685         730 :             columnWidth.allocate(13);
    8686         730 :             columnWidth = 10; // array assignment - same for all columns
    8687         730 :             tableBody.allocate(13, 16);
    8688       10220 :             for (iResource = 1; iResource <= 13; ++iResource) {
    8689        9490 :                 useVal(iResource, 1) = collapsedEndUse(iResource, state.dataGlobalConst->iEndUse.at(DataGlobalConstants::EndUse::Heating));
    8690        9490 :                 useVal(iResource, 2) = collapsedEndUse(iResource, state.dataGlobalConst->iEndUse.at(DataGlobalConstants::EndUse::Cooling));
    8691        9490 :                 useVal(iResource, 3) = collapsedEndUse(iResource, state.dataGlobalConst->iEndUse.at(DataGlobalConstants::EndUse::InteriorLights));
    8692        9490 :                 useVal(iResource, 4) = collapsedEndUse(iResource, state.dataGlobalConst->iEndUse.at(DataGlobalConstants::EndUse::ExteriorLights));
    8693        9490 :                 useVal(iResource, 5) = collapsedEndUse(iResource, state.dataGlobalConst->iEndUse.at(DataGlobalConstants::EndUse::InteriorEquipment));
    8694        9490 :                 useVal(iResource, 6) = collapsedEndUse(iResource, state.dataGlobalConst->iEndUse.at(DataGlobalConstants::EndUse::ExteriorEquipment));
    8695        9490 :                 useVal(iResource, 7) = collapsedEndUse(iResource, state.dataGlobalConst->iEndUse.at(DataGlobalConstants::EndUse::Fans));
    8696        9490 :                 useVal(iResource, 8) = collapsedEndUse(iResource, state.dataGlobalConst->iEndUse.at(DataGlobalConstants::EndUse::Pumps));
    8697        9490 :                 useVal(iResource, 9) = collapsedEndUse(iResource, state.dataGlobalConst->iEndUse.at(DataGlobalConstants::EndUse::HeatRejection));
    8698        9490 :                 useVal(iResource, 10) = collapsedEndUse(iResource, state.dataGlobalConst->iEndUse.at(DataGlobalConstants::EndUse::Humidification));
    8699        9490 :                 useVal(iResource, 11) = collapsedEndUse(iResource, state.dataGlobalConst->iEndUse.at(DataGlobalConstants::EndUse::HeatRecovery));
    8700        9490 :                 useVal(iResource, 12) = collapsedEndUse(iResource, state.dataGlobalConst->iEndUse.at(DataGlobalConstants::EndUse::WaterSystem));
    8701        9490 :                 useVal(iResource, 13) = collapsedEndUse(iResource, state.dataGlobalConst->iEndUse.at(DataGlobalConstants::EndUse::Refrigeration));
    8702        9490 :                 useVal(iResource, 14) = collapsedEndUse(iResource, state.dataGlobalConst->iEndUse.at(DataGlobalConstants::EndUse::Cogeneration));
    8703             : 
    8704        9490 :                 useVal(iResource, 15) = collapsedTotal(iResource); // totals
    8705             :             }
    8706             : 
    8707         730 :             rowHead(1) = "Heating";
    8708         730 :             rowHead(2) = "Cooling";
    8709         730 :             rowHead(3) = "Interior Lighting";
    8710         730 :             rowHead(4) = "Exterior Lighting";
    8711         730 :             rowHead(5) = "Interior Equipment";
    8712         730 :             rowHead(6) = "Exterior Equipment";
    8713         730 :             rowHead(7) = "Fans";
    8714         730 :             rowHead(8) = "Pumps";
    8715         730 :             rowHead(9) = "Heat Rejection";
    8716         730 :             rowHead(10) = "Humidification";
    8717         730 :             rowHead(11) = "Heat Recovery";
    8718         730 :             rowHead(12) = "Water Systems";
    8719         730 :             rowHead(13) = "Refrigeration";
    8720         730 :             rowHead(14) = "Generators";
    8721         730 :             rowHead(15) = "";
    8722         730 :             rowHead(16) = "Total End Uses";
    8723             : 
    8724         730 :             switch (unitsStyle_cur) {
    8725           5 :             case UnitsStyle::JtoKWH: {
    8726           5 :                 columnHead(1) = "Electricity [kWh]";
    8727           5 :                 columnHead(2) = "Natural Gas [kWh]";
    8728           5 :                 columnHead(3) = "Gasoline [kWh]";
    8729           5 :                 columnHead(4) = "Diesel [kWh]";
    8730           5 :                 columnHead(5) = "Coal [kWh]";
    8731           5 :                 columnHead(6) = "Fuel Oil No 1 [kWh]";
    8732           5 :                 columnHead(7) = "Fuel Oil No 2 [kWh]";
    8733           5 :                 columnHead(8) = "Propane [kWh]";
    8734           5 :                 columnHead(9) = "Other Fuel 1 [kWh]";
    8735           5 :                 columnHead(10) = "Other Fuel 2 [kWh]";
    8736           5 :                 columnHead(11) = "District Cooling [kWh]";
    8737           5 :                 columnHead(12) = "District Heating [kWh]";
    8738           5 :                 columnHead(13) = "Water [m3]";
    8739           5 :             } break;
    8740          11 :             case UnitsStyle::InchPound: {
    8741          11 :                 columnHead(1) = "Electricity [kBtu]";
    8742          11 :                 columnHead(2) = "Natural Gas [kBtu]";
    8743          11 :                 columnHead(3) = "Gasoline [kBtu]";
    8744          11 :                 columnHead(4) = "Diesel [kBtu]";
    8745          11 :                 columnHead(5) = "Coal [kBtu]";
    8746          11 :                 columnHead(6) = "Fuel Oil No 1 [kBtu]";
    8747          11 :                 columnHead(7) = "Fuel Oil No 2 [kBtu]";
    8748          11 :                 columnHead(8) = "Propane [kBtu]";
    8749          11 :                 columnHead(9) = "Other Fuel 1 [kBtu]";
    8750          11 :                 columnHead(10) = "Other Fuel 2 [kBtu]";
    8751          11 :                 columnHead(11) = "District Cooling [kBtu]";
    8752          11 :                 columnHead(12) = "District Heating [kBtu]";
    8753          11 :                 columnHead(13) = "Water [gal]";
    8754          11 :             } break;
    8755         714 :             default: {
    8756         714 :                 columnHead(1) = "Electricity [GJ]";
    8757         714 :                 columnHead(2) = "Natural Gas [GJ]";
    8758         714 :                 columnHead(3) = "Gasoline [GJ]";
    8759         714 :                 columnHead(4) = "Diesel [GJ]";
    8760         714 :                 columnHead(5) = "Coal [GJ]";
    8761         714 :                 columnHead(6) = "Fuel Oil No 1 [GJ]";
    8762         714 :                 columnHead(7) = "Fuel Oil No 2 [GJ]";
    8763         714 :                 columnHead(8) = "Propane [GJ]";
    8764         714 :                 columnHead(9) = "Other Fuel 1 [GJ]";
    8765         714 :                 columnHead(10) = "Other Fuel 2 [GJ]";
    8766         714 :                 columnHead(11) = "District Cooling [GJ]";
    8767         714 :                 columnHead(12) = "District Heating [GJ]";
    8768         714 :                 columnHead(13) = "Water [m3]";
    8769         714 :             } break;
    8770             :             }
    8771             : 
    8772         730 :             tableBody = "";
    8773       10220 :             for (iResource = 1; iResource <= 13; ++iResource) {
    8774      142350 :                 for (int jEndUse = 1; jEndUse <= 14; ++jEndUse) {
    8775      132860 :                     tableBody(iResource, jEndUse) = RealToStr(useVal(iResource, jEndUse), 2);
    8776             :                 }
    8777        9490 :                 tableBody(iResource, 16) = RealToStr(useVal(iResource, 15), 2);
    8778             :             }
    8779             :             // add warning message if end use values do not add up to total
    8780       10220 :             for (iResource = 1; iResource <= 13; ++iResource) {
    8781        9490 :                 Real64 curTotal = 0.0;
    8782      142350 :                 for (int jUse = 1; jUse <= 14; ++jUse) {
    8783      132860 :                     curTotal += useVal(iResource, jUse);
    8784             :                 }
    8785        9490 :                 if (std::abs(curTotal - collapsedTotal(iResource)) > (collapsedTotal(iResource) * 0.001)) {
    8786           0 :                     ShowWarningError(state, ResourceWarningMessage(columnHead(iResource)));
    8787             :                 }
    8788             :             }
    8789             : 
    8790         730 :             unconvert = largeConversionFactor / 1000000000.0; // to avoid double converting, the values for the LEED report should be in GJ
    8791             :             //  Energy Use Intensities - Electricity
    8792         730 :             if (ort->buildingGrossFloorArea > 0) {
    8793         702 :                 if (produceTabular) {
    8794        2106 :                     PreDefTableEntry(state,
    8795         702 :                                      state.dataOutRptPredefined->pdchLeedEuiElec,
    8796             :                                      "Interior Lighting (All)",
    8797         702 :                                      unconvert * 1000 * useVal(colElectricity, 3) / ort->buildingGrossFloorArea,
    8798         702 :                                      2);
    8799        2106 :                     PreDefTableEntry(state,
    8800         702 :                                      state.dataOutRptPredefined->pdchLeedEuiElec,
    8801             :                                      "Space Heating",
    8802         702 :                                      unconvert * 1000 * useVal(colElectricity, 1) / ort->buildingGrossFloorArea,
    8803         702 :                                      2);
    8804        2106 :                     PreDefTableEntry(state,
    8805         702 :                                      state.dataOutRptPredefined->pdchLeedEuiElec,
    8806             :                                      "Space Cooling",
    8807         702 :                                      unconvert * 1000 * useVal(colElectricity, 2) / ort->buildingGrossFloorArea,
    8808         702 :                                      2);
    8809        2106 :                     PreDefTableEntry(state,
    8810         702 :                                      state.dataOutRptPredefined->pdchLeedEuiElec,
    8811             :                                      "Fans (All)",
    8812         702 :                                      unconvert * 1000 * useVal(colElectricity, 7) / ort->buildingGrossFloorArea,
    8813         702 :                                      2);
    8814        2106 :                     PreDefTableEntry(state,
    8815         702 :                                      state.dataOutRptPredefined->pdchLeedEuiElec,
    8816             :                                      "Service Water Heating",
    8817         702 :                                      unconvert * 1000 * useVal(colElectricity, 12) / ort->buildingGrossFloorArea,
    8818         702 :                                      2);
    8819        2106 :                     PreDefTableEntry(state,
    8820         702 :                                      state.dataOutRptPredefined->pdchLeedEuiElec,
    8821             :                                      "Receptacle Equipment",
    8822         702 :                                      unconvert * 1000 * useVal(colElectricity, 5) / ort->buildingGrossFloorArea,
    8823         702 :                                      2);
    8824        2106 :                     PreDefTableEntry(state,
    8825         702 :                                      state.dataOutRptPredefined->pdchLeedEuiElec,
    8826             :                                      "Miscellaneous (All)",
    8827         702 :                                      unconvert * 1000 * (useVal(colElectricity, 15)) / ort->buildingGrossFloorArea,
    8828         702 :                                      2);
    8829        2106 :                     PreDefTableEntry(state,
    8830         702 :                                      state.dataOutRptPredefined->pdchLeedEuiElec,
    8831             :                                      "Subtotal",
    8832         702 :                                      unconvert * 1000 * useVal(colElectricity, 15) / ort->buildingGrossFloorArea,
    8833         702 :                                      2);
    8834             :                 }
    8835             :             }
    8836             : 
    8837         730 :             if (produceTabular) {
    8838         730 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchLeedEusTotal, "Electricity", unconvert * useVal(colElectricity, 15), 2);
    8839        2190 :                 PreDefTableEntry(state,
    8840         730 :                                  state.dataOutRptPredefined->pdchLeedEusProc,
    8841             :                                  "Electricity",
    8842         730 :                                  unconvert * (useVal(colElectricity, 5) + useVal(colElectricity, 13)),
    8843         730 :                                  2);
    8844             :             }
    8845         730 :             if (useVal(colElectricity, 15) != 0) {
    8846           2 :                 processFraction = (useVal(colElectricity, 5) + useVal(colElectricity, 13)) / useVal(colElectricity, 15);
    8847           2 :                 processElecCost = state.dataOutRptPredefined->LEEDelecCostTotal * processFraction;
    8848             :             } else {
    8849         728 :                 processElecCost = 0.0;
    8850             :             }
    8851         730 :             if (produceTabular) {
    8852         730 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchLeedEcsProc, "Electricity", processElecCost, 2);
    8853             :             }
    8854         730 :             if (produceTabular) {
    8855         730 :                 addFootNoteSubTable(
    8856         730 :                     state, state.dataOutRptPredefined->pdstLeedEneCostSum, "Process energy cost based on ratio of process to total energy.");
    8857             :             }
    8858             : 
    8859             :             //  Energy Use Intensities- Natural Gas
    8860         730 :             if (ort->buildingGrossFloorArea > 0) {
    8861         702 :                 if (produceTabular) {
    8862        2106 :                     PreDefTableEntry(state,
    8863         702 :                                      state.dataOutRptPredefined->pdchLeedEuiNatG,
    8864             :                                      "Space Heating",
    8865         702 :                                      unconvert * 1000 * useVal(colGas, 1) / ort->buildingGrossFloorArea,
    8866         702 :                                      2);
    8867        2106 :                     PreDefTableEntry(state,
    8868         702 :                                      state.dataOutRptPredefined->pdchLeedEuiNatG,
    8869             :                                      "Service Water Heating",
    8870         702 :                                      unconvert * 1000 * useVal(colGas, 12) / ort->buildingGrossFloorArea,
    8871         702 :                                      2);
    8872        2106 :                     PreDefTableEntry(state,
    8873         702 :                                      state.dataOutRptPredefined->pdchLeedEuiNatG,
    8874             :                                      "Miscellaneous (All)",
    8875         702 :                                      unconvert * 1000 * useVal(colGas, 15) / ort->buildingGrossFloorArea,
    8876         702 :                                      2);
    8877        2106 :                     PreDefTableEntry(state,
    8878         702 :                                      state.dataOutRptPredefined->pdchLeedEuiNatG,
    8879             :                                      "Subtotal",
    8880         702 :                                      unconvert * 1000 * useVal(colGas, 15) / ort->buildingGrossFloorArea,
    8881         702 :                                      2);
    8882             :                 }
    8883             :             }
    8884         730 :             if (produceTabular) {
    8885         730 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchLeedEusTotal, "Natural Gas", unconvert * useVal(colGas, 15), 2);
    8886        2190 :                 PreDefTableEntry(
    8887        1460 :                     state, state.dataOutRptPredefined->pdchLeedEusProc, "Natural Gas", unconvert * (useVal(colGas, 5) + useVal(colGas, 13)), 2);
    8888             :             }
    8889         730 :             if (useVal(colGas, 15) != 0) {
    8890           2 :                 processFraction = (useVal(colGas, 5) + useVal(colGas, 13)) / useVal(colGas, 15);
    8891           2 :                 processGasCost = state.dataOutRptPredefined->LEEDgasCostTotal * processFraction;
    8892             :             } else {
    8893         728 :                 processGasCost = 0.0;
    8894             :             }
    8895         730 :             if (produceTabular) {
    8896         730 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchLeedEcsProc, "Natural Gas", processGasCost, 2);
    8897             :             }
    8898             :             //  Energy Use Intensities  - Additional Fuel
    8899         730 :             useValColAddFuel15 =
    8900         730 :                 useVal(3, 15) + useVal(4, 15) + useVal(5, 15) + useVal(6, 15) + useVal(7, 15) + useVal(8, 15) + useVal(9, 15) + useVal(10, 15);
    8901         730 :             useValColAddFuel5 =
    8902         730 :                 useVal(3, 5) + useVal(4, 5) + useVal(5, 5) + useVal(6, 5) + useVal(7, 5) + useVal(8, 5) + useVal(9, 5) + useVal(10, 5);
    8903         730 :             useValColAddFuel13 =
    8904         730 :                 useVal(3, 13) + useVal(4, 13) + useVal(5, 13) + useVal(6, 13) + useVal(7, 13) + useVal(8, 13) + useVal(9, 13) + useVal(10, 13);
    8905         730 :             if (ort->buildingGrossFloorArea > 0) {
    8906         702 :                 if (produceTabular) {
    8907        2106 :                     PreDefTableEntry(state,
    8908         702 :                                      state.dataOutRptPredefined->pdchLeedEuiOthr,
    8909             :                                      "Miscellaneous",
    8910         702 :                                      unconvert * 1000 * useValColAddFuel15 / ort->buildingGrossFloorArea,
    8911         702 :                                      2);
    8912        2106 :                     PreDefTableEntry(state,
    8913         702 :                                      state.dataOutRptPredefined->pdchLeedEuiOthr,
    8914             :                                      "Subtotal",
    8915         702 :                                      unconvert * 1000 * useValColAddFuel15 / ort->buildingGrossFloorArea,
    8916         702 :                                      2);
    8917             :                 }
    8918             :             }
    8919         730 :             if (produceTabular) {
    8920        2190 :                 PreDefTableEntry(state,
    8921         730 :                                  state.dataOutRptPredefined->pdchLeedEusTotal,
    8922             :                                  "Additional",
    8923         730 :                                  unconvert * (useValColAddFuel15 + useVal(colPurchCool, 15) + useVal(colPurchHeat, 15)),
    8924         730 :                                  2);
    8925        2190 :                 PreDefTableEntry(state,
    8926         730 :                                  state.dataOutRptPredefined->pdchLeedEusProc,
    8927             :                                  "Additional",
    8928        1460 :                                  unconvert * (useValColAddFuel5 + useValColAddFuel13 + useVal(colPurchCool, 5) + useVal(colPurchCool, 13) +
    8929        1460 :                                               useVal(colPurchHeat, 5) + useVal(colPurchHeat, 13)),
    8930         730 :                                  2);
    8931             :             }
    8932         730 :             if ((useValColAddFuel15 + useVal(colPurchCool, 15) + useVal(colPurchHeat, 15)) > 0.001) {
    8933           0 :                 processFraction = (useValColAddFuel5 + useValColAddFuel13 + useVal(colPurchCool, 5) + useVal(colPurchCool, 13) +
    8934           0 :                                    useVal(colPurchHeat, 5) + useVal(colPurchHeat, 13)) /
    8935           0 :                                   (useValColAddFuel15 + useVal(colPurchCool, 15) + useVal(colPurchHeat, 15));
    8936             :             } else {
    8937         730 :                 processFraction = 0.0;
    8938             :             }
    8939         730 :             processOthrCost = state.dataOutRptPredefined->LEEDothrCostTotal * processFraction;
    8940         730 :             if (produceTabular) {
    8941         730 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchLeedEcsProc, "Additional", processOthrCost, 2);
    8942         730 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchLeedEcsProc, "Total", processElecCost + processGasCost + processOthrCost, 2);
    8943             :             }
    8944             :             // accumulate for percentage table
    8945         730 :             state.dataOutRptTab->leedSiteIntLite = 0.0;
    8946         730 :             state.dataOutRptTab->leedSiteSpHeat = 0.0;
    8947         730 :             state.dataOutRptTab->leedSiteSpCool = 0.0;
    8948         730 :             state.dataOutRptTab->leedSiteFanInt = 0.0;
    8949         730 :             state.dataOutRptTab->leedSiteSrvWatr = 0.0;
    8950         730 :             state.dataOutRptTab->leedSiteRecept = 0.0;
    8951         730 :             state.dataOutRptTab->leedSiteTotal = 0.0;
    8952        9490 :             for (iResource = 1; iResource <= 12; ++iResource) { // don't bother with water
    8953        8760 :                 state.dataOutRptTab->leedSiteIntLite += useVal(iResource, 3);
    8954        8760 :                 state.dataOutRptTab->leedSiteSpHeat += useVal(iResource, 1);
    8955        8760 :                 state.dataOutRptTab->leedSiteSpCool += useVal(iResource, 2);
    8956        8760 :                 state.dataOutRptTab->leedSiteFanInt += useVal(iResource, 7);
    8957        8760 :                 state.dataOutRptTab->leedSiteSrvWatr += useVal(iResource, 12);
    8958        8760 :                 state.dataOutRptTab->leedSiteRecept += useVal(iResource, 5);
    8959        8760 :                 state.dataOutRptTab->leedSiteTotal += useVal(iResource, 15);
    8960             :             }
    8961         730 :             if (state.dataOutRptTab->leedSiteTotal != 0) {
    8962           2 :                 if (produceTabular) {
    8963           6 :                     PreDefTableEntry(state,
    8964           2 :                                      state.dataOutRptPredefined->pdchLeedEupPerc,
    8965             :                                      "Interior Lighting (All)",
    8966           2 :                                      100 * state.dataOutRptTab->leedSiteIntLite / state.dataOutRptTab->leedSiteTotal,
    8967           2 :                                      2);
    8968           6 :                     PreDefTableEntry(state,
    8969           2 :                                      state.dataOutRptPredefined->pdchLeedEupPerc,
    8970             :                                      "Space Heating",
    8971           2 :                                      100 * state.dataOutRptTab->leedSiteSpHeat / state.dataOutRptTab->leedSiteTotal,
    8972           2 :                                      2);
    8973           6 :                     PreDefTableEntry(state,
    8974           2 :                                      state.dataOutRptPredefined->pdchLeedEupPerc,
    8975             :                                      "Space Cooling",
    8976           2 :                                      100 * state.dataOutRptTab->leedSiteSpCool / state.dataOutRptTab->leedSiteTotal,
    8977           2 :                                      2);
    8978           6 :                     PreDefTableEntry(state,
    8979           2 :                                      state.dataOutRptPredefined->pdchLeedEupPerc,
    8980             :                                      "Fans (All)",
    8981           2 :                                      100 * state.dataOutRptTab->leedSiteFanInt / state.dataOutRptTab->leedSiteTotal,
    8982           2 :                                      2);
    8983           6 :                     PreDefTableEntry(state,
    8984           2 :                                      state.dataOutRptPredefined->pdchLeedEupPerc,
    8985             :                                      "Service Water Heating",
    8986           2 :                                      100 * state.dataOutRptTab->leedSiteSrvWatr / state.dataOutRptTab->leedSiteTotal,
    8987           2 :                                      2);
    8988           6 :                     PreDefTableEntry(state,
    8989           2 :                                      state.dataOutRptPredefined->pdchLeedEupPerc,
    8990             :                                      "Receptacle Equipment",
    8991           2 :                                      100 * state.dataOutRptTab->leedSiteRecept / state.dataOutRptTab->leedSiteTotal,
    8992           2 :                                      2);
    8993           6 :                     PreDefTableEntry(
    8994             :                         state,
    8995           2 :                         state.dataOutRptPredefined->pdchLeedEupPerc,
    8996             :                         "Miscellaneous",
    8997           2 :                         100 *
    8998           4 :                             (state.dataOutRptTab->leedSiteTotal -
    8999           4 :                              (state.dataOutRptTab->leedSiteIntLite + state.dataOutRptTab->leedSiteSpHeat + state.dataOutRptTab->leedSiteSpCool +
    9000           4 :                               state.dataOutRptTab->leedSiteFanInt + state.dataOutRptTab->leedSiteSrvWatr + state.dataOutRptTab->leedSiteRecept)) /
    9001           2 :                             state.dataOutRptTab->leedSiteTotal,
    9002           2 :                         2);
    9003             :                 }
    9004             :             }
    9005             :             // totals across energy source
    9006         730 :             if (produceTabular) {
    9007        2190 :                 PreDefTableEntry(state,
    9008         730 :                                  state.dataOutRptPredefined->pdchLeedEusTotal,
    9009             :                                  "Total",
    9010        1460 :                                  unconvert * (useValColAddFuel15 + useVal(colPurchCool, 15) + useVal(colPurchHeat, 15) + useVal(colElectricity, 15) +
    9011         730 :                                               useVal(colGas, 15)),
    9012         730 :                                  2);
    9013        2190 :                 PreDefTableEntry(state,
    9014         730 :                                  state.dataOutRptPredefined->pdchLeedEusProc,
    9015             :                                  "Total",
    9016        1460 :                                  unconvert * (useValColAddFuel5 + useValColAddFuel13 + useVal(colPurchCool, 5) + useVal(colPurchCool, 13) +
    9017        2190 :                                               useVal(colPurchHeat, 5) + useVal(colPurchHeat, 13) + useVal(colElectricity, 5) +
    9018        1460 :                                               useVal(colElectricity, 13) + useVal(colGas, 5) + useVal(colGas, 13)),
    9019         730 :                                  2);
    9020             :             }
    9021             : 
    9022         730 :             footnote = "";
    9023         730 :             switch (resourcePrimaryHeating) {
    9024           0 :             case colElectricity: {
    9025           0 :                 if (produceTabular) {
    9026           0 :                     footnote = "Note: Electricity appears to be the principal heating source based on energy usage.";
    9027           0 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchLeedGenData, "Principal Heating Source", "Electricity");
    9028             :                 }
    9029           0 :             } break;
    9030           2 :             case colGas: {
    9031           2 :                 if (produceTabular) {
    9032           2 :                     footnote = "Note: Natural gas appears to be the principal heating source based on energy usage.";
    9033           2 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchLeedGenData, "Principal Heating Source", "Natural Gas");
    9034             :                 }
    9035           2 :             } break;
    9036           0 :             case colGasoline:
    9037             :             case colDiesel:
    9038             :             case colCoal:
    9039             :             case colFuelOilNo1:
    9040             :             case colFuelOilNo2:
    9041             :             case colPropane:
    9042             :             case colOtherFuel1:
    9043             :             case colOtherFuel2: {
    9044           0 :                 if (produceTabular) {
    9045           0 :                     footnote = "Note: Additional fuel appears to be the principal heating source based on energy usage.";
    9046           0 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchLeedGenData, "Principal Heating Source", "Additional Fuel");
    9047             :                 }
    9048           0 :             } break;
    9049           0 :             case colPurchHeat: {
    9050           0 :                 if (produceTabular) {
    9051           0 :                     footnote = "Note: District heat appears to be the principal heating source based on energy usage.";
    9052           0 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchLeedGenData, "Principal Heating Source", "District Heat");
    9053             :                 }
    9054           0 :             } break;
    9055             :             }
    9056             :             // heading for the entire sub-table
    9057         730 :             if (ort->displayTabularBEPS) {
    9058         730 :                 if (produceTabular) {
    9059         730 :                     WriteSubtitle(state, "End Uses");
    9060         730 :                     WriteTable(state, tableBody, rowHead, columnHead, columnWidth, false, footnote);
    9061             :                 }
    9062         730 :                 if (produceSQLite) {
    9063         730 :                     if (state.dataSQLiteProcedures->sqlite) {
    9064         115 :                         state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
    9065             :                             tableBody, rowHead, columnHead, "AnnualBuildingUtilityPerformanceSummary", "Entire Facility", "End Uses");
    9066             :                     }
    9067             :                 }
    9068         730 :                 if (produceTabular) {
    9069         730 :                     if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
    9070           5 :                         state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(
    9071             :                             tableBody, rowHead, columnHead, "AnnualBuildingUtilityPerformanceSummary", "Entire Facility", "End Uses");
    9072             :                     }
    9073             :                 }
    9074             :             }
    9075             : 
    9076             :             //---- End Uses By Subcategory Sub-Table
    9077        1460 :             writeBEPSEndUseBySubCatOrSpaceType(state,
    9078             :                                                EndUseSubTableType::BySubCategory,
    9079             :                                                endUseSubOther,
    9080             :                                                collapsedEndUse,
    9081             :                                                collapsedEndUseSub,
    9082         730 :                                                ort->needOtherRowLEED45,
    9083             :                                                unitsStyle_cur,
    9084             :                                                produceTabular,
    9085             :                                                produceSQLite);
    9086             : 
    9087        1460 :             writeBEPSEndUseBySubCatOrSpaceType(state,
    9088             :                                                EndUseSubTableType::BySpaceType,
    9089             :                                                endUseSubOther,
    9090             :                                                collapsedEndUse,
    9091             :                                                collapsedEndUseSpType,
    9092         730 :                                                ort->needOtherRowEndUse,
    9093             :                                                unitsStyle_cur,
    9094             :                                                produceTabular,
    9095             :                                                produceSQLite);
    9096             : 
    9097             :             // EAp2-4/5. Performance Rating Method Compliance
    9098             :             // repeat some of the code for the end use subcategory table but only looping over the energy resources and not including water
    9099             : 
    9100        1460 :             Array1D_int resource_entry_map;
    9101         730 :             resource_entry_map.allocate(12);
    9102         730 :             resource_entry_map(1) = state.dataOutRptPredefined->pdchLeedPerfElEneUse;          // electricity
    9103         730 :             resource_entry_map(2) = state.dataOutRptPredefined->pdchLeedPerfGasEneUse;         // natural gas
    9104         730 :             resource_entry_map(3) = state.dataOutRptPredefined->pdchLeedPerfGasolineEneUse;    // gasoline
    9105         730 :             resource_entry_map(4) = state.dataOutRptPredefined->pdchLeedPerfDieselEneUse;      // diesel
    9106         730 :             resource_entry_map(5) = state.dataOutRptPredefined->pdchLeedPerfCoalEneUse;        // coal
    9107         730 :             resource_entry_map(6) = state.dataOutRptPredefined->pdchLeedPerfFuelOil1EneUse;    // fuel oil no 1
    9108         730 :             resource_entry_map(7) = state.dataOutRptPredefined->pdchLeedPerfFuelOil2EneUse;    // fuel oil no 2
    9109         730 :             resource_entry_map(8) = state.dataOutRptPredefined->pdchLeedPerfPropaneEneUse;     // propane
    9110         730 :             resource_entry_map(9) = state.dataOutRptPredefined->pdchLeedPerfOtherFuel1EneUse;  // other fuel 1
    9111         730 :             resource_entry_map(10) = state.dataOutRptPredefined->pdchLeedPerfOtherFuel2EneUse; // other fuel 2
    9112         730 :             resource_entry_map(11) = state.dataOutRptPredefined->pdchLeedPerfDisClEneUse;      // district cooling
    9113         730 :             resource_entry_map(12) = state.dataOutRptPredefined->pdchLeedPerfDisHtEneUse;      // district heating
    9114             : 
    9115        9490 :             for (iResource = 1; iResource <= 12; ++iResource) {
    9116        8760 :                 i = 1;
    9117      131400 :                 for (int jEndUse = 1; jEndUse <= DataGlobalConstantsData::iEndUseSize; ++jEndUse) {
    9118      122640 :                     if (state.dataOutputProcessor->EndUseCategory(jEndUse).NumSubcategories > 0) {
    9119      133692 :                         for (int kEndUseSub = 1; kEndUseSub <= state.dataOutputProcessor->EndUseCategory(jEndUse).NumSubcategories; ++kEndUseSub) {
    9120       72468 :                             if (produceTabular) {
    9121      362340 :                                 PreDefTableEntry(state,
    9122       72468 :                                                  resource_entry_map(iResource),
    9123      144936 :                                                  state.dataOutputProcessor->EndUseCategory(jEndUse).DisplayName + " -- " +
    9124       72468 :                                                      state.dataOutputProcessor->EndUseCategory(jEndUse).SubcategoryName(kEndUseSub),
    9125       72468 :                                                  unconvert * collapsedEndUseSub(kEndUseSub, jEndUse, iResource));
    9126             :                             }
    9127       72468 :                             ++i;
    9128             :                         }
    9129             :                         // put other
    9130       61224 :                         if (ort->needOtherRowLEED45(jEndUse)) {
    9131           0 :                             if (produceTabular) {
    9132           0 :                                 PreDefTableEntry(state,
    9133           0 :                                                  resource_entry_map(iResource),
    9134           0 :                                                  state.dataOutputProcessor->EndUseCategory(jEndUse).DisplayName + " -- Other",
    9135           0 :                                                  unconvert * endUseSubOther(iResource, jEndUse));
    9136             :                             }
    9137           0 :                             ++i;
    9138             :                         }
    9139             :                     } else {
    9140       61416 :                         if (produceTabular) {
    9141      307080 :                             PreDefTableEntry(state,
    9142       61416 :                                              resource_entry_map(iResource),
    9143      122832 :                                              state.dataOutputProcessor->EndUseCategory(jEndUse).DisplayName + " -- Not Subdivided",
    9144       61416 :                                              unconvert * collapsedEndUse(iResource, jEndUse));
    9145             :                         }
    9146       61416 :                         ++i;
    9147             :                     }
    9148             :                 }
    9149             :             }
    9150             : 
    9151             :             //---- Normalized by Conditioned Area Sub-Table
    9152             :             // Calculations for both normalized tables are first
    9153         730 :             rowHead.allocate(4);
    9154         730 :             columnHead.allocate(13);
    9155         730 :             columnWidth.allocate(13);
    9156         730 :             columnWidth = 7; // array assignment - same for all columns
    9157         730 :             tableBody.allocate(13, 4);
    9158       10220 :             for (iResource = 1; iResource <= 13; ++iResource) {
    9159        9490 :                 normalVal(iResource, 1) =
    9160       28470 :                     collapsedEndUse(iResource, state.dataGlobalConst->iEndUse.at(DataGlobalConstants::EndUse::InteriorLights)) +
    9161        9490 :                     collapsedEndUse(iResource,
    9162        9490 :                                     state.dataGlobalConst->iEndUse.at(
    9163       18980 :                                         DataGlobalConstants::EndUse::ExteriorLights)); // Lights     <- InteriorLights | <- ExteriorLights
    9164             : 
    9165        9490 :                 normalVal(iResource, 2) =
    9166       28470 :                     collapsedEndUse(iResource, state.dataGlobalConst->iEndUse.at(DataGlobalConstants::EndUse::Fans)) +
    9167       28470 :                     collapsedEndUse(iResource, state.dataGlobalConst->iEndUse.at(DataGlobalConstants::EndUse::Pumps)) +
    9168       28470 :                     collapsedEndUse(iResource, state.dataGlobalConst->iEndUse.at(DataGlobalConstants::EndUse::Heating)) +
    9169       28470 :                     collapsedEndUse(iResource, state.dataGlobalConst->iEndUse.at(DataGlobalConstants::EndUse::Cooling)) +
    9170       28470 :                     collapsedEndUse(iResource, state.dataGlobalConst->iEndUse.at(DataGlobalConstants::EndUse::HeatRejection)) +
    9171       28470 :                     collapsedEndUse(iResource, state.dataGlobalConst->iEndUse.at(DataGlobalConstants::EndUse::Humidification)) +
    9172        9490 :                     collapsedEndUse(iResource,
    9173        9490 :                                     state.dataGlobalConst->iEndUse.at(
    9174       18980 :                                         DataGlobalConstants::EndUse::WaterSystem)); // HVAC       <- fans | <- pumps | <- heating | <- cooling |
    9175             :                                                                                     // <- heat rejection | <- humidification | <- water system
    9176             :                                                                                     // domestic hot water
    9177             : 
    9178        9490 :                 normalVal(iResource, 3) =
    9179       28470 :                     collapsedEndUse(iResource, state.dataGlobalConst->iEndUse.at(DataGlobalConstants::EndUse::InteriorEquipment)) +
    9180       28470 :                     collapsedEndUse(iResource, state.dataGlobalConst->iEndUse.at(DataGlobalConstants::EndUse::ExteriorEquipment)) +
    9181       28470 :                     collapsedEndUse(iResource, state.dataGlobalConst->iEndUse.at(DataGlobalConstants::EndUse::Cogeneration)) +
    9182       28470 :                     collapsedEndUse(iResource, state.dataGlobalConst->iEndUse.at(DataGlobalConstants::EndUse::HeatRecovery)) +
    9183        9490 :                     collapsedEndUse(iResource,
    9184        9490 :                                     state.dataGlobalConst->iEndUse.at(
    9185       18980 :                                         DataGlobalConstants::EndUse::Refrigeration)); // Other      <- InteriorEquipment | <- ExteriorEquipment |
    9186             :                                                                                       // <- generator fuel | <- Heat Recovery (parasitics) | <-
    9187             :                                                                                       // Refrigeration
    9188             : 
    9189        9490 :                 normalVal(iResource, 4) = collapsedTotal(iResource); // totals
    9190             :             }
    9191             :             // convert the normalized end use values to MJ from GJ if using J
    9192        9490 :             for (iResource = 1; iResource <= 12; ++iResource) { // not including resource=13 water
    9193       43800 :                 for (int jEndUse = 1; jEndUse <= 4; ++jEndUse) {
    9194       35040 :                     normalVal(iResource, jEndUse) *= kConversionFactor;
    9195             :                 }
    9196             :             }
    9197             : 
    9198         730 :             rowHead(1) = "Lighting"; // typo fixed 5-17-04 BTG
    9199         730 :             rowHead(2) = "HVAC";
    9200         730 :             rowHead(3) = "Other";
    9201         730 :             rowHead(4) = "Total";
    9202             : 
    9203         730 :             switch (unitsStyle_cur) {
    9204           5 :             case UnitsStyle::JtoKWH: {
    9205           5 :                 columnHead(1) = "Electricity Intensity [kWh/m2]";
    9206           5 :                 columnHead(2) = "Natural Gas Intensity [kWh/m2]";
    9207           5 :                 columnHead(3) = "Gasoline Intensity [kWh/m2]";
    9208           5 :                 columnHead(4) = "Diesel Intensity [kWh/m2]";
    9209           5 :                 columnHead(5) = "Coal Intensity [kWh/m2]";
    9210           5 :                 columnHead(6) = "Fuel Oil No 1 Intensity [kWh/m2]";
    9211           5 :                 columnHead(7) = "Fuel Oil No 2 Intensity [kWh/m2]";
    9212           5 :                 columnHead(8) = "Propane Intensity [kWh/m2]";
    9213           5 :                 columnHead(9) = "Other Fuel 1 Intensity [kWh/m2]";
    9214           5 :                 columnHead(10) = "Other Fuel 2 Intensity [kWh/m2]";
    9215           5 :                 columnHead(11) = "District Cooling Intensity [kWh/m2]";
    9216           5 :                 columnHead(12) = "District Heating Intensity [kWh/m2]";
    9217           5 :                 columnHead(13) = "Water Intensity [m3/m2]";
    9218           5 :             } break;
    9219          11 :             case UnitsStyle::InchPound: {
    9220          11 :                 columnHead(1) = "Electricity Intensity [kBtu/ft2]";
    9221          11 :                 columnHead(2) = "Natural Gas Intensity [kBtu/ft2]";
    9222          11 :                 columnHead(3) = "Gasoline Intensity [kBtu/ft2]";
    9223          11 :                 columnHead(4) = "Diesel Intensity [kBtu/ft2]";
    9224          11 :                 columnHead(5) = "Coal Intensity [kBtu/ft2]";
    9225          11 :                 columnHead(6) = "Fuel Oil No 1 Intensity [kBtu/ft2]";
    9226          11 :                 columnHead(7) = "Fuel Oil No 2 Intensity [kBtu/ft2]";
    9227          11 :                 columnHead(8) = "Propane Intensity [kBtu/ft2]";
    9228          11 :                 columnHead(9) = "Other Fuel 1 Intensity [kBtu/ft2]";
    9229          11 :                 columnHead(10) = "Other Fuel 2 Intensity [kBtu/ft2]";
    9230          11 :                 columnHead(11) = "District Cooling Intensity [kBtu/ft2]";
    9231          11 :                 columnHead(12) = "District Heating Intensity [kBtu/ft2]";
    9232          11 :                 columnHead(13) = "Water Intensity [gal/ft2]";
    9233          11 :             } break;
    9234         714 :             default: {
    9235         714 :                 columnHead(1) = "Electricity Intensity [MJ/m2]";
    9236         714 :                 columnHead(2) = "Natural Gas Intensity [MJ/m2]";
    9237         714 :                 columnHead(3) = "Gasoline Intensity [MJ/m2]";
    9238         714 :                 columnHead(4) = "Diesel Intensity [MJ/m2]";
    9239         714 :                 columnHead(5) = "Coal Intensity [MJ/m2]";
    9240         714 :                 columnHead(6) = "Fuel Oil No 1 Intensity [MJ/m2]";
    9241         714 :                 columnHead(7) = "Fuel Oil No 2 Intensity [MJ/m2]";
    9242         714 :                 columnHead(8) = "Propane Intensity [MJ/m2]";
    9243         714 :                 columnHead(9) = "Other Fuel 1 Intensity [MJ/m2]";
    9244         714 :                 columnHead(10) = "Other Fuel 2 Intensity [MJ/m2]";
    9245         714 :                 columnHead(11) = "District Cooling Intensity [MJ/m2]";
    9246         714 :                 columnHead(12) = "District Heating Intensity [MJ/m2]";
    9247         714 :                 columnHead(13) = "Water Intensity [m3/m2]";
    9248         714 :             } break;
    9249             :             }
    9250             : 
    9251         730 :             if (produceTabular) {
    9252         730 :                 WriteTextLine(state, "Normalized Metrics", true);
    9253             :             }
    9254             : 
    9255             :             // write the conditioned area based table
    9256         730 :             tableBody = "";
    9257         730 :             if (convBldgCondFloorArea > 0) {
    9258        9114 :                 for (iResource = 1; iResource <= 13; ++iResource) {
    9259       42315 :                     for (int jEndUse = 1; jEndUse <= 4; ++jEndUse) {
    9260       33852 :                         tableBody(iResource, jEndUse) = RealToStr(normalVal(iResource, jEndUse) / convBldgCondFloorArea, 2);
    9261             :                     }
    9262             :                 }
    9263             :             }
    9264             :             // heading for the entire sub-table
    9265         730 :             if (ort->displayTabularBEPS) {
    9266         730 :                 if (produceTabular) {
    9267         730 :                     WriteSubtitle(state, "Utility Use Per Conditioned Floor Area");
    9268         730 :                     WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
    9269             :                 }
    9270         730 :                 if (produceSQLite) {
    9271         730 :                     if (state.dataSQLiteProcedures->sqlite) {
    9272         115 :                         state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(tableBody,
    9273             :                                                                                            rowHead,
    9274             :                                                                                            columnHead,
    9275             :                                                                                            "AnnualBuildingUtilityPerformanceSummary",
    9276             :                                                                                            "Entire Facility",
    9277             :                                                                                            "Utility Use Per Conditioned Floor Area");
    9278             :                     }
    9279             :                 }
    9280         730 :                 if (produceTabular) {
    9281         730 :                     if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
    9282           5 :                         state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(
    9283             :                             tableBody,
    9284             :                             rowHead,
    9285             :                             columnHead,
    9286             :                             "AnnualBuildingUtilityPerformanceSummary",
    9287             :                             "Entire Facility",
    9288             :                             "Utility Use Per Conditioned Floor Area");
    9289             :                     }
    9290             :                 }
    9291             :             }
    9292             :             //---- Normalized by Total Area Sub-Table
    9293         730 :             tableBody = "";
    9294         730 :             if (convBldgGrossFloorArea > 0) {
    9295        9828 :                 for (iResource = 1; iResource <= 13; ++iResource) {
    9296       45630 :                     for (int jEndUse = 1; jEndUse <= 4; ++jEndUse) {
    9297       36504 :                         tableBody(iResource, jEndUse) = RealToStr(normalVal(iResource, jEndUse) / convBldgGrossFloorArea, 2);
    9298             :                     }
    9299             :                 }
    9300             :             }
    9301             :             // heading for the entire sub-table
    9302         730 :             if (ort->displayTabularBEPS) {
    9303         730 :                 if (produceTabular) {
    9304         730 :                     WriteSubtitle(state, "Utility Use Per Total Floor Area");
    9305         730 :                     WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
    9306             :                 }
    9307         730 :                 if (produceSQLite) {
    9308         730 :                     if (state.dataSQLiteProcedures->sqlite) {
    9309         115 :                         state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(tableBody,
    9310             :                                                                                            rowHead,
    9311             :                                                                                            columnHead,
    9312             :                                                                                            "AnnualBuildingUtilityPerformanceSummary",
    9313             :                                                                                            "Entire Facility",
    9314             :                                                                                            "Utility Use Per Total Floor Area");
    9315             :                     }
    9316             :                 }
    9317         730 :                 if (produceTabular) {
    9318         730 :                     if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
    9319           5 :                         state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(
    9320             :                             tableBody,
    9321             :                             rowHead,
    9322             :                             columnHead,
    9323             :                             "AnnualBuildingUtilityPerformanceSummary",
    9324             :                             "Entire Facility",
    9325             :                             "Utility Use Per Total Floor Area");
    9326             :                     }
    9327             :                 }
    9328             :             }
    9329             : 
    9330             :             //---- Electric Loads Satisfied Sub-Table
    9331         730 :             rowHead.allocate(14);
    9332         730 :             columnHead.allocate(2);
    9333         730 :             columnWidth.allocate(2);
    9334         730 :             columnWidth = 14; // array assignment - same for all columns
    9335         730 :             tableBody.allocate(2, 14);
    9336             : 
    9337         730 :             switch (unitsStyle_cur) {
    9338           5 :             case UnitsStyle::JtoKWH: {
    9339           5 :                 columnHead(1) = "Electricity [kWh]";
    9340           5 :             } break;
    9341          11 :             case UnitsStyle::InchPound: {
    9342          11 :                 columnHead(1) = "Electricity [kBtu]";
    9343          11 :             } break;
    9344         714 :             default: {
    9345         714 :                 columnHead(1) = "Electricity [GJ]";
    9346         714 :             } break;
    9347             :             }
    9348         730 :             columnHead(2) = "Percent Electricity [%]";
    9349             : 
    9350         730 :             rowHead(1) = "Fuel-Fired Power Generation";
    9351         730 :             rowHead(2) = "High Temperature Geothermal*";
    9352         730 :             rowHead(3) = "Photovoltaic Power";
    9353         730 :             rowHead(4) = "Wind Power";
    9354         730 :             rowHead(5) = "Power Conversion";
    9355         730 :             rowHead(6) = "Net Decrease in On-Site Storage";
    9356         730 :             rowHead(7) = "Total On-Site Electric Sources";
    9357         730 :             rowHead(8) = "";
    9358         730 :             rowHead(9) = "Electricity Coming From Utility";
    9359         730 :             rowHead(10) = "Surplus Electricity Going To Utility";
    9360         730 :             rowHead(11) = "Net Electricity From Utility";
    9361         730 :             rowHead(12) = "";
    9362         730 :             rowHead(13) = "Total On-Site and Utility Electric Sources";
    9363         730 :             rowHead(14) = "Total Electricity End Uses";
    9364             : 
    9365         730 :             tableBody = "";
    9366             : 
    9367             :             // show annual values
    9368         730 :             unconvert = largeConversionFactor / 1000000000.0; // to avoid double converting, the values for the LEED report should be in GJ
    9369             : 
    9370         730 :             tableBody(1, 1) = RealToStr(ort->gatherPowerFuelFireGen, 3);
    9371         730 :             tableBody(1, 2) = RealToStr(ort->gatherPowerHTGeothermal, 3);
    9372         730 :             tableBody(1, 3) = RealToStr(ort->gatherPowerPV, 3);
    9373         730 :             if (produceTabular) {
    9374         730 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchLeedRenAnGen, "Photovoltaic", unconvert * ort->gatherPowerPV, 2);
    9375             :             }
    9376         730 :             tableBody(1, 4) = RealToStr(ort->gatherPowerWind, 3);
    9377         730 :             if (produceTabular) {
    9378         730 :                 PreDefTableEntry(state, state.dataOutRptPredefined->pdchLeedRenAnGen, "Wind", unconvert * ort->gatherPowerWind, 2);
    9379             :             }
    9380         730 :             tableBody(1, 5) = RealToStr(ort->gatherPowerConversion, 3);
    9381         730 :             tableBody(1, 6) = RealToStr(ort->OverallNetEnergyFromStorage, 3);
    9382         730 :             tableBody(1, 7) = RealToStr(ort->gatherElecProduced, 3);
    9383         730 :             tableBody(1, 9) = RealToStr(ort->gatherElecPurchased, 3);
    9384         730 :             tableBody(1, 10) = RealToStr(ort->gatherElecSurplusSold, 3);
    9385         730 :             tableBody(1, 11) = RealToStr(ort->gatherElecPurchased - ort->gatherElecSurplusSold, 3);
    9386         730 :             tableBody(1, 13) = RealToStr(ort->gatherElecProduced + (ort->gatherElecPurchased - ort->gatherElecSurplusSold), 3);
    9387         730 :             tableBody(1, 14) = RealToStr(collapsedTotal(1), 3);
    9388             : 
    9389             :             // show annual percentages
    9390         730 :             if (collapsedTotal(1) > 0) {
    9391           2 :                 tableBody(2, 1) = RealToStr(100.0 * ort->gatherPowerFuelFireGen / collapsedTotal(1), 2);
    9392           2 :                 tableBody(2, 2) = RealToStr(100.0 * ort->gatherPowerHTGeothermal / collapsedTotal(1), 2);
    9393           2 :                 tableBody(2, 3) = RealToStr(100.0 * ort->gatherPowerPV / collapsedTotal(1), 2);
    9394           2 :                 tableBody(2, 4) = RealToStr(100.0 * ort->gatherPowerWind / collapsedTotal(1), 2);
    9395           2 :                 tableBody(2, 5) = RealToStr(100.0 * ort->gatherPowerConversion / collapsedTotal(1), 2);
    9396           2 :                 tableBody(2, 6) = RealToStr(100.0 * ort->OverallNetEnergyFromStorage / collapsedTotal(1), 2);
    9397           2 :                 tableBody(2, 7) = RealToStr(100.0 * ort->gatherElecProduced / collapsedTotal(1), 2);
    9398           2 :                 tableBody(2, 9) = RealToStr(100.0 * ort->gatherElecPurchased / collapsedTotal(1), 2);
    9399           2 :                 tableBody(2, 10) = RealToStr(100.0 * ort->gatherElecSurplusSold / collapsedTotal(1), 2);
    9400           2 :                 tableBody(2, 11) = RealToStr(100.0 * (ort->gatherElecPurchased - ort->gatherElecSurplusSold) / collapsedTotal(1), 2);
    9401           2 :                 tableBody(2, 13) =
    9402           4 :                     RealToStr(100.0 * (ort->gatherElecProduced + (ort->gatherElecPurchased - ort->gatherElecSurplusSold)) / collapsedTotal(1), 2);
    9403           2 :                 tableBody(2, 14) = RealToStr(100.0, 2);
    9404             :             }
    9405             : 
    9406             :             // heading for the entire sub-table
    9407         730 :             if (ort->displayTabularBEPS) {
    9408         730 :                 if (produceTabular) {
    9409         730 :                     WriteSubtitle(state, "Electric Loads Satisfied");
    9410         730 :                     WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
    9411             :                 }
    9412         730 :                 if (produceSQLite) {
    9413         730 :                     if (state.dataSQLiteProcedures->sqlite) {
    9414         115 :                         state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
    9415             :                             tableBody, rowHead, columnHead, "AnnualBuildingUtilityPerformanceSummary", "Entire Facility", "Electric Loads Satisfied");
    9416             :                     }
    9417             :                 }
    9418         730 :                 if (produceTabular) {
    9419         730 :                     if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
    9420           5 :                         state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(
    9421             :                             tableBody, rowHead, columnHead, "AnnualBuildingUtilityPerformanceSummary", "Entire Facility", "Electric Loads Satisfied");
    9422             :                     }
    9423             :                 }
    9424             :             }
    9425             : 
    9426             :             //---- On-Site Thermal Sources Sub-Table
    9427         730 :             rowHead.allocate(7);
    9428         730 :             columnHead.allocate(2);
    9429         730 :             columnWidth.allocate(2);
    9430         730 :             columnWidth = 14; // array assignment - same for all columns
    9431         730 :             tableBody.allocate(2, 7);
    9432             : 
    9433         730 :             switch (unitsStyle_cur) {
    9434           5 :             case UnitsStyle::JtoKWH: {
    9435           5 :                 columnHead(1) = "Heat [kWh]";
    9436           5 :             } break;
    9437          11 :             case UnitsStyle::InchPound: {
    9438          11 :                 columnHead(1) = "Heat [kBtu]";
    9439          11 :             } break;
    9440         714 :             default: {
    9441         714 :                 columnHead(1) = "Heat [GJ]";
    9442         714 :             } break;
    9443             :             }
    9444             : 
    9445         730 :             columnHead(2) = "Percent Heat [%]";
    9446             : 
    9447         730 :             rowHead(1) = "Water-Side Heat Recovery";
    9448         730 :             rowHead(2) = "Air to Air Heat Recovery for Cooling";
    9449         730 :             rowHead(3) = "Air to Air Heat Recovery for Heating";
    9450         730 :             rowHead(4) = "High-Temperature Geothermal*";
    9451         730 :             rowHead(5) = "Solar Water Thermal";
    9452         730 :             rowHead(6) = "Solar Air Thermal";
    9453         730 :             rowHead(7) = "Total On-Site Thermal Sources";
    9454             : 
    9455         730 :             tableBody = "";
    9456             : 
    9457         730 :             if (iUnitSystem == 0) {
    9458         730 :                 gtWaterHeatRecovery = ort->gatherWaterHeatRecovery;
    9459         730 :                 gtAirHeatRecoveryCool = ort->gatherAirHeatRecoveryCool;
    9460         730 :                 gtAirHeatRecoveryHeat = ort->gatherAirHeatRecoveryHeat;
    9461         730 :                 gtHeatHTGeothermal = ort->gatherHeatHTGeothermal;
    9462         730 :                 gtHeatSolarWater = ort->gatherHeatSolarWater;
    9463         730 :                 gtHeatSolarAir = ort->gatherHeatSolarAir;
    9464             :             } else {
    9465           0 :                 ort->gatherWaterHeatRecovery = gtWaterHeatRecovery;
    9466           0 :                 ort->gatherAirHeatRecoveryCool = gtAirHeatRecoveryCool;
    9467           0 :                 ort->gatherAirHeatRecoveryHeat = gtAirHeatRecoveryHeat;
    9468           0 :                 ort->gatherHeatHTGeothermal = gtHeatHTGeothermal;
    9469           0 :                 ort->gatherHeatSolarWater = gtHeatSolarWater;
    9470           0 :                 ort->gatherHeatSolarAir = gtHeatSolarAir;
    9471             :             }
    9472             : 
    9473             :             // convert to GJ
    9474         730 :             ort->gatherWaterHeatRecovery /= largeConversionFactor;
    9475         730 :             ort->gatherAirHeatRecoveryCool /= largeConversionFactor;
    9476         730 :             ort->gatherAirHeatRecoveryHeat /= largeConversionFactor;
    9477         730 :             ort->gatherHeatHTGeothermal /= largeConversionFactor;
    9478         730 :             ort->gatherHeatSolarWater /= largeConversionFactor;
    9479         730 :             ort->gatherHeatSolarAir /= largeConversionFactor;
    9480             : 
    9481             :             // determine total on site heat
    9482        2190 :             totalOnsiteHeat = ort->gatherWaterHeatRecovery + ort->gatherAirHeatRecoveryCool + ort->gatherAirHeatRecoveryHeat +
    9483        1460 :                               ort->gatherHeatHTGeothermal + ort->gatherHeatSolarWater + ort->gatherHeatSolarAir;
    9484             : 
    9485             :             // show annual values
    9486         730 :             tableBody(1, 1) = RealToStr(ort->gatherWaterHeatRecovery, 2);
    9487         730 :             tableBody(1, 2) = RealToStr(ort->gatherAirHeatRecoveryCool, 2);
    9488         730 :             tableBody(1, 3) = RealToStr(ort->gatherAirHeatRecoveryHeat, 2);
    9489         730 :             tableBody(1, 4) = RealToStr(ort->gatherHeatHTGeothermal, 2);
    9490         730 :             tableBody(1, 5) = RealToStr(ort->gatherHeatSolarWater, 2);
    9491         730 :             tableBody(1, 6) = RealToStr(ort->gatherHeatSolarAir, 2);
    9492         730 :             tableBody(1, 7) = RealToStr(totalOnsiteHeat, 2);
    9493             : 
    9494         730 :             if (totalOnsiteHeat > 0) {
    9495           0 :                 tableBody(2, 1) = RealToStr(100.0 * ort->gatherWaterHeatRecovery / totalOnsiteHeat, 2);
    9496           0 :                 tableBody(2, 2) = RealToStr(100.0 * ort->gatherAirHeatRecoveryCool / totalOnsiteHeat, 2);
    9497           0 :                 tableBody(2, 3) = RealToStr(100.0 * ort->gatherAirHeatRecoveryHeat / totalOnsiteHeat, 2);
    9498           0 :                 tableBody(2, 4) = RealToStr(100.0 * ort->gatherHeatHTGeothermal / totalOnsiteHeat, 2);
    9499           0 :                 tableBody(2, 5) = RealToStr(100.0 * ort->gatherHeatSolarWater / totalOnsiteHeat, 2);
    9500           0 :                 tableBody(2, 6) = RealToStr(100.0 * ort->gatherHeatSolarAir / totalOnsiteHeat, 2);
    9501           0 :                 tableBody(2, 7) = RealToStr(100.0, 2);
    9502             :             }
    9503             : 
    9504             :             // heading for the entire sub-table
    9505         730 :             if (ort->displayTabularBEPS) {
    9506         730 :                 if (produceTabular) {
    9507         730 :                     WriteSubtitle(state, "On-Site Thermal Sources");
    9508         730 :                     WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
    9509             :                 }
    9510         730 :                 if (produceSQLite) {
    9511         730 :                     if (state.dataSQLiteProcedures->sqlite) {
    9512         115 :                         state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
    9513             :                             tableBody, rowHead, columnHead, "AnnualBuildingUtilityPerformanceSummary", "Entire Facility", "On-Site Thermal Sources");
    9514             :                     }
    9515             :                 }
    9516         730 :                 if (produceTabular) {
    9517         730 :                     if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
    9518           5 :                         state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(
    9519             :                             tableBody, rowHead, columnHead, "AnnualBuildingUtilityPerformanceSummary", "Entire Facility", "On-Site Thermal Sources");
    9520             :                     }
    9521             :                 }
    9522             :             }
    9523             : 
    9524             :             //---- Water Loads Sub-Table
    9525             :             // As of 12/8/2003 decided to not include this sub-table to wait
    9526             :             // until water use is implemented in EnergyPlus before displaying
    9527             :             // the table. Implementing water end-uses makes sense for EnergyPlus
    9528             :             // but since they are not really implemented as of December 2003 the
    9529             :             // table would be all zeros.  Recommendation to exclude this table
    9530             :             // for now made by Glazer and Crawley.
    9531             :             // Aug 2006, adding table in with implementation of water system, BGriffith
    9532         730 :             rowHead.allocate(13);
    9533         730 :             columnHead.allocate(2);
    9534         730 :             columnWidth.allocate(2);
    9535         730 :             columnWidth = 14; // array assignment - same for all columns
    9536         730 :             tableBody.allocate(2, 13);
    9537         730 :             switch (unitsStyle_cur) {
    9538           5 :             case UnitsStyle::JtoKWH: {
    9539           5 :                 columnHead(1) = "Water [m3]";
    9540           5 :             } break;
    9541          11 :             case UnitsStyle::InchPound: {
    9542          11 :                 columnHead(1) = "Water [gal]";
    9543          11 :             } break;
    9544         714 :             default: {
    9545         714 :                 columnHead(1) = "Water [m3]";
    9546         714 :             } break;
    9547             :             }
    9548             : 
    9549         730 :             columnHead(2) = "Percent Water [%]";
    9550         730 :             rowHead(1) = "Rainwater Collection";
    9551         730 :             rowHead(2) = "Condensate Collection";
    9552         730 :             rowHead(3) = "Groundwater Well";
    9553         730 :             rowHead(4) = "Total On Site Water Sources";
    9554         730 :             rowHead(5) = "-";
    9555         730 :             rowHead(6) = "Initial Storage";
    9556         730 :             rowHead(7) = "Final Storage";
    9557         730 :             rowHead(8) = "Change in Storage";
    9558         730 :             rowHead(9) = "-";
    9559         730 :             rowHead(10) = "Water Supplied by Utility";
    9560         730 :             rowHead(11) = "-";
    9561         730 :             rowHead(12) = "Total On Site, Change in Storage, and Utility Water Sources";
    9562         730 :             rowHead(13) = "Total Water End Uses";
    9563         730 :             tableBody = "-";
    9564             : 
    9565         730 :             totalOnsiteWater = ort->gatherRainWater + ort->gatherCondensate + ort->gatherWellwater;
    9566             : 
    9567             :             //  ! show annual values
    9568         730 :             tableBody(1, 1) = RealToStr(ort->gatherRainWater / waterConversionFactor, 2);
    9569         730 :             tableBody(1, 2) = RealToStr(ort->gatherCondensate / waterConversionFactor, 2);
    9570         730 :             tableBody(1, 3) = RealToStr(ort->gatherWellwater / waterConversionFactor, 2);
    9571         730 :             tableBody(1, 4) = RealToStr(totalOnsiteWater / waterConversionFactor, 2);
    9572             : 
    9573         730 :             if (allocated(state.dataWaterData->WaterStorage)) {
    9574           5 :                 initialStorage = sum(state.dataWaterData->WaterStorage, &DataWater::StorageTankDataStruct::InitialVolume);
    9575           5 :                 finalStorage = sum(state.dataWaterData->WaterStorage, &DataWater::StorageTankDataStruct::ThisTimeStepVolume);
    9576           5 :                 StorageChange = initialStorage - finalStorage;
    9577             :             } else {
    9578         725 :                 initialStorage = 0.0;
    9579         725 :                 finalStorage = 0.0;
    9580         725 :                 StorageChange = 0.0;
    9581             :             }
    9582         730 :             tableBody(1, 6) = RealToStr(initialStorage / waterConversionFactor, 2);
    9583         730 :             tableBody(1, 7) = RealToStr(finalStorage / waterConversionFactor, 2);
    9584         730 :             tableBody(1, 8) = RealToStr(StorageChange / waterConversionFactor, 2);
    9585             : 
    9586         730 :             totalWater = totalOnsiteWater + ort->gatherMains + StorageChange;
    9587             : 
    9588         730 :             tableBody(1, 10) = RealToStr(ort->gatherMains / waterConversionFactor, 2);
    9589         730 :             tableBody(1, 12) = RealToStr(totalWater / waterConversionFactor, 2);
    9590         730 :             tableBody(1, 13) = RealToStr(ort->gatherWaterEndUseTotal / waterConversionFactor, 2);
    9591             : 
    9592         730 :             if (ort->gatherWaterEndUseTotal > 0) {
    9593           0 :                 tableBody(2, 1) = RealToStr(100.0 * ort->gatherRainWater / ort->gatherWaterEndUseTotal, 2);
    9594           0 :                 tableBody(2, 2) = RealToStr(100.0 * ort->gatherCondensate / ort->gatherWaterEndUseTotal, 2);
    9595           0 :                 tableBody(2, 3) = RealToStr(100.0 * ort->gatherWellwater / ort->gatherWaterEndUseTotal, 2);
    9596           0 :                 tableBody(2, 4) = RealToStr(100.0 * totalOnsiteWater / ort->gatherWaterEndUseTotal, 2);
    9597           0 :                 tableBody(2, 6) = RealToStr(100.0 * initialStorage / ort->gatherWaterEndUseTotal, 2);
    9598           0 :                 tableBody(2, 7) = RealToStr(100.0 * finalStorage / ort->gatherWaterEndUseTotal, 2);
    9599           0 :                 tableBody(2, 8) = RealToStr(100.0 * StorageChange / ort->gatherWaterEndUseTotal, 2);
    9600             : 
    9601           0 :                 tableBody(2, 10) = RealToStr(100.0 * ort->gatherMains / ort->gatherWaterEndUseTotal, 2);
    9602             : 
    9603           0 :                 tableBody(2, 12) = RealToStr(100.0 * totalWater / ort->gatherWaterEndUseTotal, 2);
    9604           0 :                 tableBody(2, 13) = RealToStr(100.0, 2);
    9605             :             }
    9606             : 
    9607             :             //  ! heading for the entire sub-table
    9608         730 :             if (ort->displayTabularBEPS) {
    9609         730 :                 if (produceTabular) {
    9610         730 :                     WriteSubtitle(state, "Water Source Summary");
    9611         730 :                     WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
    9612             :                 }
    9613         730 :                 if (produceSQLite) {
    9614         730 :                     if (state.dataSQLiteProcedures->sqlite) {
    9615         115 :                         state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
    9616             :                             tableBody, rowHead, columnHead, "AnnualBuildingUtilityPerformanceSummary", "Entire Facility", "Water Source Summary");
    9617             :                     }
    9618             :                 }
    9619         730 :                 if (produceTabular) {
    9620         730 :                     if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
    9621           5 :                         state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(
    9622             :                             tableBody, rowHead, columnHead, "AnnualBuildingUtilityPerformanceSummary", "Entire Facility", "Water Source Summary");
    9623             :                     }
    9624             :                 }
    9625             :             }
    9626             : 
    9627             :             //---- Comfort and Setpoint Not Met Sub-Table
    9628         730 :             if (ort->displayTabularBEPS) {
    9629         730 :                 rowHead.allocate(2);
    9630         730 :                 columnHead.allocate(1);
    9631         730 :                 columnWidth.allocate(1);
    9632         730 :                 columnWidth = 14; // array assignment - same for all columns
    9633         730 :                 tableBody.allocate(1, 2);
    9634             : 
    9635         730 :                 if (produceTabular) {
    9636         730 :                     WriteSubtitle(state, "Setpoint Not Met Criteria");
    9637             :                 }
    9638             : 
    9639         730 :                 curNameWithSIUnits = "Degrees [deltaC]";
    9640         730 :                 curNameAndUnits = curNameWithSIUnits;
    9641         730 :                 if (unitsStyle_cur == UnitsStyle::InchPound) {
    9642          11 :                     LookupSItoIP(state, curNameWithSIUnits, indexUnitConv, curNameAndUnits);
    9643             :                 }
    9644         730 :                 columnHead(1) = curNameAndUnits;
    9645             : 
    9646         730 :                 rowHead(1) = "Tolerance for Zone Heating Setpoint Not Met Time";
    9647         730 :                 rowHead(2) = "Tolerance for Zone Cooling Setpoint Not Met Time";
    9648             : 
    9649         730 :                 if (unitsStyle_cur != UnitsStyle::InchPound) {
    9650         719 :                     tableBody(1, 1) = RealToStr(std::abs(state.dataHVACGlobal->deviationFromSetPtThresholdHtg), 2);
    9651         719 :                     tableBody(1, 2) = RealToStr(state.dataHVACGlobal->deviationFromSetPtThresholdClg, 2);
    9652             :                 } else {
    9653          11 :                     tableBody(1, 1) =
    9654          22 :                         RealToStr(ConvertIPdelta(state, indexUnitConv, std::abs(state.dataHVACGlobal->deviationFromSetPtThresholdHtg)), 2);
    9655          11 :                     tableBody(1, 2) = RealToStr(ConvertIPdelta(state, indexUnitConv, state.dataHVACGlobal->deviationFromSetPtThresholdClg), 2);
    9656             :                 }
    9657             : 
    9658         730 :                 if (produceTabular) {
    9659         730 :                     WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
    9660             :                 }
    9661         730 :                 if (produceSQLite) {
    9662         730 :                     if (state.dataSQLiteProcedures->sqlite) {
    9663         115 :                         state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(tableBody,
    9664             :                                                                                            rowHead,
    9665             :                                                                                            columnHead,
    9666             :                                                                                            "AnnualBuildingUtilityPerformanceSummary",
    9667             :                                                                                            "Entire Facility",
    9668             :                                                                                            "Setpoint Not Met Criteria");
    9669             :                     }
    9670             :                 }
    9671         730 :                 if (produceTabular) {
    9672         730 :                     if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
    9673           5 :                         state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(
    9674             :                             tableBody,
    9675             :                             rowHead,
    9676             :                             columnHead,
    9677             :                             "AnnualBuildingUtilityPerformanceSummary",
    9678             :                             "Entire Facility",
    9679             :                             "Setpoint Not Met Criteria");
    9680             :                     }
    9681             :                 }
    9682             :             }
    9683             : 
    9684         730 :             rowHead.allocate(3);
    9685         730 :             columnHead.allocate(1);
    9686         730 :             columnWidth.allocate(1);
    9687         730 :             columnWidth = 14; // array assignment - same for all columns
    9688         730 :             tableBody.allocate(1, 3);
    9689             : 
    9690         730 :             if (ort->displayTabularBEPS) {
    9691         730 :                 if (produceTabular) {
    9692         730 :                     WriteSubtitle(state, "Comfort and Setpoint Not Met Summary");
    9693             :                 }
    9694             :             }
    9695             : 
    9696         730 :             columnHead(1) = "Facility [Hours]";
    9697             : 
    9698         730 :             rowHead(1) = "Time Setpoint Not Met During Occupied Heating";
    9699         730 :             rowHead(2) = "Time Setpoint Not Met During Occupied Cooling";
    9700         730 :             rowHead(3) = "Time Not Comfortable Based on Simple ASHRAE 55-2004";
    9701             : 
    9702         730 :             tableBody(1, 1) = RealToStr(state.dataOutRptPredefined->TotalNotMetHeatingOccupiedForABUPS, 2);
    9703         730 :             tableBody(1, 2) = RealToStr(state.dataOutRptPredefined->TotalNotMetCoolingOccupiedForABUPS, 2);
    9704         730 :             if (produceTabular) {
    9705        1460 :                 PreDefTableEntry(state,
    9706         730 :                                  state.dataOutRptPredefined->pdchLeedAmData,
    9707             :                                  "Number of hours heating loads not met",
    9708        2190 :                                  RealToStr(state.dataOutRptPredefined->TotalNotMetHeatingOccupiedForABUPS, 2));
    9709        1460 :                 PreDefTableEntry(state,
    9710         730 :                                  state.dataOutRptPredefined->pdchLeedAmData,
    9711             :                                  "Number of hours cooling loads not met",
    9712        2190 :                                  RealToStr(state.dataOutRptPredefined->TotalNotMetCoolingOccupiedForABUPS, 2));
    9713        1460 :                 PreDefTableEntry(state,
    9714         730 :                                  state.dataOutRptPredefined->pdchLeedAmData,
    9715             :                                  "Number of hours not met",
    9716        2190 :                                  RealToStr(state.dataOutRptPredefined->TotalNotMetOccupiedForABUPS, 2));
    9717             :             }
    9718         730 :             tableBody(1, 3) = RealToStr(state.dataOutRptPredefined->TotalTimeNotSimpleASH55EitherForABUPS, 2);
    9719             : 
    9720         730 :             if (ort->displayTabularBEPS) {
    9721         730 :                 if (produceTabular) {
    9722         730 :                     WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
    9723             :                 }
    9724         730 :                 if (produceSQLite) {
    9725         730 :                     if (state.dataSQLiteProcedures->sqlite) {
    9726         115 :                         state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(tableBody,
    9727             :                                                                                            rowHead,
    9728             :                                                                                            columnHead,
    9729             :                                                                                            "AnnualBuildingUtilityPerformanceSummary",
    9730             :                                                                                            "Entire Facility",
    9731             :                                                                                            "Comfort and Setpoint Not Met Summary");
    9732             :                     }
    9733             :                 }
    9734         730 :                 if (produceTabular) {
    9735         730 :                     if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
    9736           5 :                         state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(
    9737             :                             tableBody,
    9738             :                             rowHead,
    9739             :                             columnHead,
    9740             :                             "AnnualBuildingUtilityPerformanceSummary",
    9741             :                             "Entire Facility",
    9742             :                             "Comfort and Setpoint Not Met Summary");
    9743             :                     }
    9744             :                 }
    9745             :             }
    9746             :         }
    9747             :         //---- Control Summary Sub-Table
    9748             : 
    9749             :         //---- End Notes
    9750         730 :         if (ort->displayTabularBEPS) {
    9751         730 :             WriteTextLine(state, "Note 1: An asterisk (*) indicates that the feature is not yet implemented.");
    9752             :         }
    9753             :     }
    9754         731 : }
    9755             : 
    9756           0 : std::string ResourceWarningMessage(std::string const &resource)
    9757             : {
    9758           0 :     return "In the Annual Building Utility Performance Summary Report the total row does not match the sum of the column for: " + resource;
    9759             : }
    9760             : 
    9761         730 : Real64 WaterConversionFunct(Real64 WaterTotal, Real64 ConversionFactor)
    9762             : {
    9763         730 :     return WaterTotal / ConversionFactor;
    9764             : }
    9765             : 
    9766        1460 : void writeBEPSEndUseBySubCatOrSpaceType(EnergyPlusData &state,
    9767             :                                         EndUseSubTableType tableType,
    9768             :                                         Array2D<Real64> &endUseSubOther,
    9769             :                                         Array2D<Real64> &collapsedEndUse,
    9770             :                                         Array3D<Real64> &collapsedEndUseSubTable,
    9771             :                                         Array1D_bool &needOtherRow,
    9772             :                                         const UnitsStyle unitsStyle_cur,
    9773             :                                         const bool produceTabular,
    9774             :                                         const bool produceSQLite)
    9775             : {
    9776        1460 :     auto &ort(state.dataOutRptTab);
    9777        1460 :     int numCol = 14;
    9778        2920 :     Array1D_string columnHead;
    9779        2920 :     Array1D_int columnWidth;
    9780        1460 :     columnHead.allocate(numCol);
    9781        1460 :     columnWidth.allocate(numCol);
    9782       21900 :     for (int col = 1; col <= numCol; ++col) {
    9783       20440 :         columnWidth(col) = 10; // array assignment - same for all columns
    9784             :     }
    9785        1460 :     switch (unitsStyle_cur) {
    9786          10 :     case UnitsStyle::JtoKWH: {
    9787          10 :         columnHead(2) = "Electricity [kWh]";
    9788          10 :         columnHead(3) = "Natural Gas [kWh]";
    9789          10 :         columnHead(4) = "Gasoline [kWh]";
    9790          10 :         columnHead(5) = "Diesel [kWh]";
    9791          10 :         columnHead(6) = "Coal [kWh]";
    9792          10 :         columnHead(7) = "Fuel Oil No 1 [kWh]";
    9793          10 :         columnHead(8) = "Fuel Oil No 2 [kWh]";
    9794          10 :         columnHead(9) = "Propane [kWh]";
    9795          10 :         columnHead(10) = "Other Fuel 1 [kWh]";
    9796          10 :         columnHead(11) = "Other Fuel 2 [kWh]";
    9797          10 :         columnHead(12) = "District Cooling [kWh]";
    9798          10 :         columnHead(13) = "District Heating [kWh]";
    9799          10 :         columnHead(14) = "Water [m3]";
    9800          10 :     } break;
    9801          22 :     case UnitsStyle::InchPound: {
    9802          22 :         columnHead(2) = "Electricity [kBtu]";
    9803          22 :         columnHead(3) = "Natural Gas [kBtu]";
    9804          22 :         columnHead(4) = "Gasoline [kBtu]";
    9805          22 :         columnHead(5) = "Diesel [kBtu]";
    9806          22 :         columnHead(6) = "Coal [kBtu]";
    9807          22 :         columnHead(7) = "Fuel Oil No 1 [kBtu]";
    9808          22 :         columnHead(8) = "Fuel Oil No 2 [kBtu]";
    9809          22 :         columnHead(9) = "Propane [kBtu]";
    9810          22 :         columnHead(10) = "Other Fuel 1 [kBtu]";
    9811          22 :         columnHead(11) = "Other Fuel 2 [kBtu]";
    9812          22 :         columnHead(12) = "District Cooling [kBtu]";
    9813          22 :         columnHead(13) = "District Heating [kBtu]";
    9814          22 :         columnHead(14) = "Water [gal]";
    9815          22 :     } break;
    9816        1428 :     default: {
    9817        1428 :         columnHead(2) = "Electricity [GJ]";
    9818        1428 :         columnHead(3) = "Natural Gas [GJ]";
    9819        1428 :         columnHead(4) = "Gasoline [GJ]";
    9820        1428 :         columnHead(5) = "Diesel [GJ]";
    9821        1428 :         columnHead(6) = "Coal [GJ]";
    9822        1428 :         columnHead(7) = "Fuel Oil No 1 [GJ]";
    9823        1428 :         columnHead(8) = "Fuel Oil No 2 [GJ]";
    9824        1428 :         columnHead(9) = "Propane [GJ]";
    9825        1428 :         columnHead(10) = "Other Fuel 1 [GJ]";
    9826        1428 :         columnHead(11) = "Other Fuel 2 [GJ]";
    9827        1428 :         columnHead(12) = "District Cooling [GJ]";
    9828        1428 :         columnHead(13) = "District Heating [GJ]";
    9829        1428 :         columnHead(14) = "Water [m3]";
    9830        1428 :     } break;
    9831             :     }
    9832             : 
    9833        1460 :     int numSubCatOrTypes = 0;
    9834        1460 :     int numRows = 0;
    9835        1460 :     if (tableType == EndUseSubTableType::BySubCategory) {
    9836         730 :         columnHead(1) = "Subcategory";
    9837         730 :     } else if (tableType == EndUseSubTableType::BySpaceType) {
    9838         730 :         columnHead(1) = "Space Type";
    9839             :     }
    9840             : 
    9841             :     // determine number of rows and if subcategories add up to the total
    9842             :     // if not, determine the difference for the 'other' row
    9843       21900 :     for (int i = 1; i <= DataGlobalConstantsData::iEndUseSize; ++i) {
    9844       20440 :         needOtherRow(i) = false; // set array to all false assuming no other rows are needed
    9845             :     }
    9846       20440 :     for (int iResource = 1; iResource <= 13; ++iResource) {
    9847      284700 :         for (int jEndUse = 1; jEndUse <= DataGlobalConstantsData::iEndUseSize; ++jEndUse) {
    9848      265720 :             if (tableType == EndUseSubTableType::BySubCategory) {
    9849      132860 :                 numSubCatOrTypes = state.dataOutputProcessor->EndUseCategory(jEndUse).NumSubcategories;
    9850      132860 :             } else if (tableType == EndUseSubTableType::BySpaceType) {
    9851      132860 :                 numSubCatOrTypes = state.dataOutputProcessor->EndUseCategory(jEndUse).numSpaceTypes;
    9852             :             }
    9853      265720 :             if (numSubCatOrTypes > 0) {
    9854             :                 // set the value to the total for the end use
    9855       82576 :                 endUseSubOther(iResource, jEndUse) = collapsedEndUse(iResource, jEndUse);
    9856             :                 // subtract off each sub end use category value
    9857      177424 :                 for (int kEndUseSub = 1; kEndUseSub <= numSubCatOrTypes; ++kEndUseSub) {
    9858       94848 :                     endUseSubOther(iResource, jEndUse) -= collapsedEndUseSubTable(kEndUseSub, jEndUse, iResource);
    9859             :                 }
    9860             :                 // if just a small value remains set it to zero
    9861       82576 :                 if (std::abs(endUseSubOther(iResource, jEndUse)) > 0.01) {
    9862           0 :                     needOtherRow(jEndUse) = true;
    9863             :                 } else {
    9864       82576 :                     endUseSubOther(iResource, jEndUse) = 0.0;
    9865             :                 }
    9866             :             } else {
    9867      183144 :                 endUseSubOther(iResource, jEndUse) = 0.0;
    9868             :             }
    9869             :         }
    9870             :     }
    9871             : 
    9872       21900 :     for (int jEndUse = 1; jEndUse <= DataGlobalConstantsData::iEndUseSize; ++jEndUse) {
    9873       20440 :         if (tableType == EndUseSubTableType::BySubCategory) {
    9874       10220 :             numSubCatOrTypes = state.dataOutputProcessor->EndUseCategory(jEndUse).NumSubcategories;
    9875       10220 :         } else if (tableType == EndUseSubTableType::BySpaceType) {
    9876       10220 :             numSubCatOrTypes = state.dataOutputProcessor->EndUseCategory(jEndUse).numSpaceTypes;
    9877             :         }
    9878       20440 :         if (numSubCatOrTypes > 0) {
    9879       13648 :             for (int kEndUseSub = 1; kEndUseSub <= numSubCatOrTypes; ++kEndUseSub) {
    9880        7296 :                 ++numRows;
    9881             :             }
    9882        6352 :             if (needOtherRow(jEndUse)) {
    9883           0 :                 ++numRows;
    9884             :             }
    9885             :         } else {
    9886       14088 :             ++numRows;
    9887             :         }
    9888             :     }
    9889             :     // all arrays are in the format: (row, column)
    9890        2920 :     Array1D_string rowHead;
    9891        2920 :     Array2D_string tableBody;
    9892        1460 :     rowHead.allocate(numRows);
    9893        1460 :     tableBody.allocate(numCol, numRows); // TODO: this appears to be (column, row)...
    9894       21900 :     for (int col = 1; col <= numCol; ++col) {
    9895      319816 :         for (int row = 1; row <= numRows; ++row) {
    9896      299376 :             rowHead(row) = "";
    9897      299376 :             tableBody(col, row) = "";
    9898             :         }
    9899             :     }
    9900             : 
    9901             :     // Build row head and subcategories columns
    9902        1460 :     int i = 1;
    9903       21900 :     for (int jEndUse = 1; jEndUse <= DataGlobalConstantsData::iEndUseSize; ++jEndUse) {
    9904       20440 :         if (tableType == EndUseSubTableType::BySubCategory) {
    9905       10220 :             numSubCatOrTypes = state.dataOutputProcessor->EndUseCategory(jEndUse).NumSubcategories;
    9906       10220 :         } else if (tableType == EndUseSubTableType::BySpaceType) {
    9907       10220 :             numSubCatOrTypes = state.dataOutputProcessor->EndUseCategory(jEndUse).numSpaceTypes;
    9908             :         }
    9909       20440 :         rowHead(i) = state.dataOutputProcessor->EndUseCategory(jEndUse).DisplayName;
    9910       20440 :         if (numSubCatOrTypes > 0) {
    9911       13648 :             for (int kEndUseSub = 1; kEndUseSub <= numSubCatOrTypes; ++kEndUseSub) {
    9912        7296 :                 if (tableType == EndUseSubTableType::BySubCategory) {
    9913        6039 :                     tableBody(1, i) = state.dataOutputProcessor->EndUseCategory(jEndUse).SubcategoryName(kEndUseSub);
    9914        1257 :                 } else if (tableType == EndUseSubTableType::BySpaceType) {
    9915        1257 :                     tableBody(1, i) = state.dataOutputProcessor->EndUseCategory(jEndUse).spaceTypeName(kEndUseSub);
    9916             :                 }
    9917        7296 :                 ++i;
    9918             :             }
    9919             :             // check if an 'other' row is needed
    9920        6352 :             if (needOtherRow(jEndUse)) {
    9921           0 :                 tableBody(1, i) = "Other";
    9922           0 :                 ++i;
    9923             :             }
    9924             :         } else {
    9925       14088 :             if (tableType == EndUseSubTableType::BySubCategory) {
    9926        5118 :                 tableBody(1, i) = "General";
    9927        8970 :             } else if (tableType == EndUseSubTableType::BySpaceType) {
    9928        8970 :                 tableBody(1, i) = "Unassigned";
    9929             :             }
    9930       14088 :             ++i;
    9931             :         }
    9932             :     }
    9933             : 
    9934       20440 :     for (int iResource = 1; iResource <= 13; ++iResource) {
    9935       18980 :         i = 1;
    9936      284700 :         for (int jEndUse = 1; jEndUse <= DataGlobalConstantsData::iEndUseSize; ++jEndUse) {
    9937      265720 :             if (tableType == EndUseSubTableType::BySubCategory) {
    9938      132860 :                 numSubCatOrTypes = state.dataOutputProcessor->EndUseCategory(jEndUse).NumSubcategories;
    9939      132860 :             } else if (tableType == EndUseSubTableType::BySpaceType) {
    9940      132860 :                 numSubCatOrTypes = state.dataOutputProcessor->EndUseCategory(jEndUse).numSpaceTypes;
    9941             :             }
    9942      265720 :             if (numSubCatOrTypes > 0) {
    9943      177424 :                 for (int kEndUseSub = 1; kEndUseSub <= numSubCatOrTypes; ++kEndUseSub) {
    9944       94848 :                     tableBody(iResource + 1, i) = RealToStr(collapsedEndUseSubTable(kEndUseSub, jEndUse, iResource), 2);
    9945       94848 :                     ++i;
    9946             :                 }
    9947             :                 // put other
    9948       82576 :                 if (needOtherRow(jEndUse)) {
    9949           0 :                     tableBody(iResource + 1, i) = RealToStr(endUseSubOther(iResource, jEndUse), 2);
    9950           0 :                     ++i;
    9951             :                 }
    9952             :             } else {
    9953      183144 :                 tableBody(iResource + 1, i) = RealToStr(collapsedEndUse(iResource, jEndUse), 2);
    9954      183144 :                 ++i;
    9955             :             }
    9956             :         }
    9957             :     }
    9958             : 
    9959             :     // heading for the entire sub-table
    9960        2920 :     std::string subTableTitle;
    9961        1460 :     if (ort->displayTabularBEPS) {
    9962        1460 :         if (tableType == EndUseSubTableType::BySubCategory) {
    9963         730 :             subTableTitle = "End Uses By Subcategory";
    9964         730 :         } else if (tableType == EndUseSubTableType::BySpaceType) {
    9965         730 :             subTableTitle = "End Uses By Space Type";
    9966             :         }
    9967        1460 :         if (produceTabular) {
    9968        1460 :             WriteSubtitle(state, subTableTitle);
    9969        1460 :             WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
    9970             :         }
    9971        2920 :         Array1D_string rowHeadTemp(rowHead);
    9972             :         // Before outputing to SQL, we forward fill the End use column (rowHead)
    9973             :         // for better sql queries
    9974        1460 :         FillRowHead(rowHeadTemp);
    9975             : 
    9976       22844 :         for (int i = 1; i <= numRows; ++i) {
    9977       21384 :             rowHeadTemp(i) = rowHeadTemp(i) + ":" + tableBody(1, i);
    9978             :         }
    9979             : 
    9980             :         // Erase the SubCategory (first column), using slicing
    9981        2920 :         Array2D_string tableBodyTemp(tableBody({2, _, _}, {_, _, _}));
    9982        2920 :         Array1D_string columnHeadTemp(columnHead({2, _, _}));
    9983        1460 :         if (produceSQLite) {
    9984        1460 :             if (state.dataSQLiteProcedures->sqlite) {
    9985         230 :                 state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
    9986             :                     tableBodyTemp, rowHeadTemp, columnHeadTemp, "AnnualBuildingUtilityPerformanceSummary", "Entire Facility", subTableTitle);
    9987             :             }
    9988             :         }
    9989        1460 :         if (produceTabular) {
    9990        1460 :             if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
    9991          10 :                 state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(
    9992             :                     tableBodyTemp, rowHeadTemp, columnHeadTemp, "AnnualBuildingUtilityPerformanceSummary", "Entire Facility", subTableTitle);
    9993             :             }
    9994             :         }
    9995        1460 :         rowHeadTemp.deallocate();
    9996        1460 :         tableBodyTemp.deallocate();
    9997        1460 :         columnHeadTemp.deallocate();
    9998             :     }
    9999        1460 : }
   10000         731 : void WriteSourceEnergyEndUseSummary(EnergyPlusData &state)
   10001             : {
   10002             :     // SUBROUTINE INFORMATION:
   10003             :     //       AUTHOR         Mangesh Basarkar
   10004             :     //       DATE WRITTEN   September 2011
   10005             :     //       MODIFIED       March 2020, Dareum Nam; Disaggregated "Additional Fuel"
   10006             :     //       RE-ENGINEERED  na
   10007             : 
   10008             :     // PURPOSE OF THIS SUBROUTINE:
   10009             :     //   Take the gathered total and end use source energy meter data and structure
   10010             :     //   the results into a tabular report for output.
   10011             : 
   10012             :     // METHODOLOGY EMPLOYED:
   10013             :     //   Create arrays for the call to WriteTable and then call it.
   10014             : 
   10015             :     // all arrays are in the format: (row, column)
   10016        1462 :     Array1D_string columnHead;
   10017        1462 :     Array1D_int columnWidth;
   10018        1462 :     Array1D_string rowHead;
   10019        1462 :     Array2D_string tableBody;
   10020             : 
   10021             :     // all arrays are in the format: (row, columnm)
   10022        1462 :     Array2D<Real64> useVal(13, 15);
   10023        1462 :     Array1D<Real64> collapsedTotal(13);
   10024        1462 :     Array2D<Real64> collapsedEndUse(13, DataGlobalConstantsData::iEndUseSize);
   10025        1462 :     Array3D<Real64> collapsedEndUseSub(state.dataOutputProcessor->MaxNumSubcategories, DataGlobalConstantsData::iEndUseSize, 13);
   10026             :     int iResource;
   10027             :     Real64 largeConversionFactor;
   10028             :     Real64 areaConversionFactor;
   10029         731 :     auto &ort(state.dataOutRptTab);
   10030             : 
   10031         731 :     if (ort->displaySourceEnergyEndUseSummary) {
   10032             : 
   10033             :         // show the headers of the report
   10034         653 :         WriteReportHeaders(state, "Source Energy End Use Components Summary", "Entire Facility", OutputProcessor::StoreType::Averaged);
   10035             :         // show the number of hours that the table applies to
   10036         653 :         WriteTextLine(state, "Values gathered over " + RealToStr(ort->gatherElapsedTimeBEPS, 2) + " hours", true);
   10037         653 :         if (ort->gatherElapsedTimeBEPS < 8759.0) { // might not add up to 8760 exactly but can't be more than 1 hour diff.
   10038         651 :             WriteTextLine(state, "WARNING: THE REPORT DOES NOT REPRESENT A FULL ANNUAL SIMULATION.", true);
   10039             :         }
   10040         653 :         WriteTextLine(state, "", true);
   10041             : 
   10042             :         // determine building floor areas
   10043         653 :         DetermineBuildingFloorArea(state);
   10044             : 
   10045        1306 :         for (int iUnitSystem = 0; iUnitSystem <= 1; iUnitSystem++) {
   10046        1306 :             UnitsStyle unitsStyle_cur = ort->unitsStyle;
   10047        1306 :             bool produceTabular = true;
   10048        1306 :             bool produceSQLite = false;
   10049        1306 :             if (produceDualUnitsFlags(iUnitSystem, ort->unitsStyle, ort->unitsStyle_SQLite, unitsStyle_cur, produceTabular, produceSQLite)) break;
   10050             : 
   10051             :             // collapse the gatherEndUseBEPS array to the resource groups displayed
   10052        9795 :             for (int jEndUse = 1; jEndUse <= DataGlobalConstantsData::iEndUseSize; ++jEndUse) {
   10053        9142 :                 collapsedEndUse(1, jEndUse) = ort->gatherEndUseBySourceBEPS(1, jEndUse);   // electricity
   10054        9142 :                 collapsedEndUse(2, jEndUse) = ort->gatherEndUseBySourceBEPS(2, jEndUse);   // natural gas
   10055        9142 :                 collapsedEndUse(3, jEndUse) = ort->gatherEndUseBySourceBEPS(6, jEndUse);   // gasoline
   10056        9142 :                 collapsedEndUse(4, jEndUse) = ort->gatherEndUseBySourceBEPS(8, jEndUse);   // diesel
   10057        9142 :                 collapsedEndUse(5, jEndUse) = ort->gatherEndUseBySourceBEPS(9, jEndUse);   // coal
   10058        9142 :                 collapsedEndUse(6, jEndUse) = ort->gatherEndUseBySourceBEPS(10, jEndUse);  // Fuel Oil No1
   10059        9142 :                 collapsedEndUse(7, jEndUse) = ort->gatherEndUseBySourceBEPS(11, jEndUse);  // Fuel Oil No2
   10060        9142 :                 collapsedEndUse(8, jEndUse) = ort->gatherEndUseBySourceBEPS(12, jEndUse);  // propane
   10061        9142 :                 collapsedEndUse(9, jEndUse) = ort->gatherEndUseBySourceBEPS(13, jEndUse);  // otherfuel1
   10062        9142 :                 collapsedEndUse(10, jEndUse) = ort->gatherEndUseBySourceBEPS(14, jEndUse); // otherfuel2
   10063        9142 :                 collapsedEndUse(11, jEndUse) = ort->gatherEndUseBySourceBEPS(3, jEndUse);  // district cooling <- purchased cooling
   10064       18284 :                 collapsedEndUse(12, jEndUse) = ort->gatherEndUseBySourceBEPS(4, jEndUse) +
   10065        9142 :                                                ort->gatherEndUseBySourceBEPS(5, jEndUse); // district heating <- purchased heating | <- steam
   10066        9142 :                 collapsedEndUse(13, jEndUse) = ort->gatherEndUseBySourceBEPS(7, jEndUse); // water
   10067             :             }
   10068             :             // repeat with totals
   10069         653 :             collapsedTotal(1) = ort->gatherTotalsBySourceBEPS(1);   // electricity
   10070         653 :             collapsedTotal(2) = ort->gatherTotalsBySourceBEPS(2);   // natural gas
   10071         653 :             collapsedTotal(3) = ort->gatherTotalsBySourceBEPS(6);   // gasoline
   10072         653 :             collapsedTotal(4) = ort->gatherTotalsBySourceBEPS(8);   // diesel
   10073         653 :             collapsedTotal(5) = ort->gatherTotalsBySourceBEPS(9);   // coal
   10074         653 :             collapsedTotal(6) = ort->gatherTotalsBySourceBEPS(10);  // Fuel Oil No1
   10075         653 :             collapsedTotal(7) = ort->gatherTotalsBySourceBEPS(11);  // Fuel Oil No2
   10076         653 :             collapsedTotal(8) = ort->gatherTotalsBySourceBEPS(12);  // propane
   10077         653 :             collapsedTotal(9) = ort->gatherTotalsBySourceBEPS(13);  // otherfuel1
   10078         653 :             collapsedTotal(10) = ort->gatherTotalsBySourceBEPS(14); // otherfuel2
   10079         653 :             collapsedTotal(11) = ort->gatherTotalsBySourceBEPS(3);  // district cooling <- purchased cooling
   10080         653 :             collapsedTotal(12) =
   10081         653 :                 ort->gatherTotalsBySourceBEPS(4) + ort->gatherTotalsBySourceBEPS(5); // district heating <- purchased heating | <- steam
   10082         653 :             collapsedTotal(13) = ort->gatherTotalsBySourceBEPS(7);                   // water
   10083             : 
   10084             :             // unit conversion - all values are used as divisors
   10085             : 
   10086         653 :             switch (unitsStyle_cur) {
   10087           5 :             case UnitsStyle::JtoKWH: {
   10088           5 :                 largeConversionFactor = 3600000.0;
   10089           5 :                 areaConversionFactor = 1.0;
   10090           5 :             } break;
   10091          11 :             case UnitsStyle::InchPound: {
   10092          11 :                 largeConversionFactor = getSpecificUnitDivider(state, "J", "kBtu"); // 1054351.84 J to kBtu
   10093          11 :                 areaConversionFactor = getSpecificUnitDivider(state, "m2", "ft2");  // 0.092893973 m2 to ft2
   10094          11 :             } break;
   10095         637 :             default: {
   10096         637 :                 largeConversionFactor = 1000000.0; // to MJ
   10097         637 :                 areaConversionFactor = 1.0;
   10098         637 :             } break;
   10099             :             }
   10100             : 
   10101             :             // convert units into MJ (divide by 1,000,000) if J otherwise kWh
   10102        8489 :             for (iResource = 1; iResource <= 12; ++iResource) { // don't do water
   10103      117540 :                 for (int jEndUse = 1; jEndUse <= DataGlobalConstantsData::iEndUseSize; ++jEndUse) {
   10104      109704 :                     collapsedEndUse(iResource, jEndUse) /= largeConversionFactor;
   10105             :                 }
   10106        7836 :                 collapsedTotal(iResource) /= largeConversionFactor;
   10107             :             }
   10108             : 
   10109         653 :             rowHead.allocate(16);
   10110         653 :             columnHead.allocate(12);
   10111         653 :             columnWidth.allocate(12);
   10112         653 :             columnWidth = 10; // array assignment - same for all columns
   10113         653 :             tableBody.allocate(12, 16);
   10114        9142 :             for (iResource = 1; iResource <= 13; ++iResource) {
   10115        8489 :                 useVal(iResource, 1) = collapsedEndUse(iResource, state.dataGlobalConst->iEndUse.at(DataGlobalConstants::EndUse::Heating));
   10116        8489 :                 useVal(iResource, 2) = collapsedEndUse(iResource, state.dataGlobalConst->iEndUse.at(DataGlobalConstants::EndUse::Cooling));
   10117        8489 :                 useVal(iResource, 3) = collapsedEndUse(iResource, state.dataGlobalConst->iEndUse.at(DataGlobalConstants::EndUse::InteriorLights));
   10118        8489 :                 useVal(iResource, 4) = collapsedEndUse(iResource, state.dataGlobalConst->iEndUse.at(DataGlobalConstants::EndUse::ExteriorLights));
   10119        8489 :                 useVal(iResource, 5) = collapsedEndUse(iResource, state.dataGlobalConst->iEndUse.at(DataGlobalConstants::EndUse::InteriorEquipment));
   10120        8489 :                 useVal(iResource, 6) = collapsedEndUse(iResource, state.dataGlobalConst->iEndUse.at(DataGlobalConstants::EndUse::ExteriorEquipment));
   10121        8489 :                 useVal(iResource, 7) = collapsedEndUse(iResource, state.dataGlobalConst->iEndUse.at(DataGlobalConstants::EndUse::Fans));
   10122        8489 :                 useVal(iResource, 8) = collapsedEndUse(iResource, state.dataGlobalConst->iEndUse.at(DataGlobalConstants::EndUse::Pumps));
   10123        8489 :                 useVal(iResource, 9) = collapsedEndUse(iResource, state.dataGlobalConst->iEndUse.at(DataGlobalConstants::EndUse::HeatRejection));
   10124        8489 :                 useVal(iResource, 10) = collapsedEndUse(iResource, state.dataGlobalConst->iEndUse.at(DataGlobalConstants::EndUse::Humidification));
   10125        8489 :                 useVal(iResource, 11) = collapsedEndUse(iResource, state.dataGlobalConst->iEndUse.at(DataGlobalConstants::EndUse::HeatRecovery));
   10126        8489 :                 useVal(iResource, 12) = collapsedEndUse(iResource, state.dataGlobalConst->iEndUse.at(DataGlobalConstants::EndUse::WaterSystem));
   10127        8489 :                 useVal(iResource, 13) = collapsedEndUse(iResource, state.dataGlobalConst->iEndUse.at(DataGlobalConstants::EndUse::Refrigeration));
   10128        8489 :                 useVal(iResource, 14) = collapsedEndUse(iResource, state.dataGlobalConst->iEndUse.at(DataGlobalConstants::EndUse::Cogeneration));
   10129             : 
   10130        8489 :                 useVal(iResource, 15) = collapsedTotal(iResource); // totals
   10131             :             }
   10132             : 
   10133         653 :             rowHead(1) = "Heating";
   10134         653 :             rowHead(2) = "Cooling";
   10135         653 :             rowHead(3) = "Interior Lighting";
   10136         653 :             rowHead(4) = "Exterior Lighting";
   10137         653 :             rowHead(5) = "Interior Equipment";
   10138         653 :             rowHead(6) = "Exterior Equipment";
   10139         653 :             rowHead(7) = "Fans";
   10140         653 :             rowHead(8) = "Pumps";
   10141         653 :             rowHead(9) = "Heat Rejection";
   10142         653 :             rowHead(10) = "Humidification";
   10143         653 :             rowHead(11) = "Heat Recovery";
   10144         653 :             rowHead(12) = "Water Systems";
   10145         653 :             rowHead(13) = "Refrigeration";
   10146         653 :             rowHead(14) = "Generators";
   10147         653 :             rowHead(15) = "";
   10148         653 :             rowHead(16) = "Total Source Energy End Use Components";
   10149             : 
   10150         653 :             largeConversionFactor = 1.0;
   10151             : 
   10152         653 :             switch (unitsStyle_cur) {
   10153           5 :             case UnitsStyle::JtoKWH: {
   10154           5 :                 columnHead(1) = "Source Electricity [kWh]";
   10155           5 :                 columnHead(2) = "Source Natural Gas [kWh]";
   10156           5 :                 columnHead(3) = "Source Gasoline [kWh]";
   10157           5 :                 columnHead(4) = "Source Diesel [kWh]";
   10158           5 :                 columnHead(5) = "Source Coal [kWh]";
   10159           5 :                 columnHead(6) = "Source Fuel Oil No 1 [kWh]";
   10160           5 :                 columnHead(7) = "Source Fuel Oil No 2 [kWh]";
   10161           5 :                 columnHead(8) = "Source Propane [kWh]";
   10162           5 :                 columnHead(9) = "Source Other Fuel 1 [kWh]";
   10163           5 :                 columnHead(10) = "Source Other Fuel 2 [kWh]";
   10164           5 :                 columnHead(11) = "Source District Cooling [kWh]";
   10165           5 :                 columnHead(12) = "Source District Heating [kWh]";
   10166           5 :             } break;
   10167          11 :             case UnitsStyle::InchPound: {
   10168          11 :                 columnHead(1) = "Source Electricity [kBtu]";
   10169          11 :                 columnHead(2) = "Source Natural Gas [kBtu]";
   10170          11 :                 columnHead(3) = "Source Gasoline [kBtu]";
   10171          11 :                 columnHead(4) = "Source Diesel [kBtu]";
   10172          11 :                 columnHead(5) = "Source Coal [kBtu]";
   10173          11 :                 columnHead(6) = "Source Fuel Oil No 1 [kBtu]";
   10174          11 :                 columnHead(7) = "Source Fuel Oil No 2 [kBtu]";
   10175          11 :                 columnHead(8) = "Source Propane [kBtu]";
   10176          11 :                 columnHead(9) = "Source Other Fuel 1 [kBtu]";
   10177          11 :                 columnHead(10) = "Source Other Fuel 2 [kBtu]";
   10178          11 :                 columnHead(11) = "Source District Cooling [kBtu]";
   10179          11 :                 columnHead(12) = "Source District Heating [kBtu]";
   10180          11 :             } break;
   10181         637 :             default: {
   10182         637 :                 columnHead(1) = "Source Electricity [GJ]";
   10183         637 :                 columnHead(2) = "Source Natural Gas [GJ]";
   10184         637 :                 columnHead(3) = "Source Gasoline [GJ]";
   10185         637 :                 columnHead(4) = "Source Diesel [GJ]";
   10186         637 :                 columnHead(5) = "Source Coal [GJ]";
   10187         637 :                 columnHead(6) = "Source Fuel Oil No 1 [GJ]";
   10188         637 :                 columnHead(7) = "Source Fuel Oil No 2 [GJ]";
   10189         637 :                 columnHead(8) = "Source Propane [GJ]";
   10190         637 :                 columnHead(9) = "Source Other Fuel 1 [GJ]";
   10191         637 :                 columnHead(10) = "Source Other Fuel 2 [GJ]";
   10192         637 :                 columnHead(11) = "Source District Cooling [GJ]";
   10193         637 :                 columnHead(12) = "Source District Heating [GJ]";
   10194         637 :                 largeConversionFactor = 1000.0; // for converting MJ to GJ
   10195         637 :             } break;
   10196             :             }
   10197             : 
   10198             :             //---- End Uses by Source Energy Sub-Table
   10199             : 
   10200         653 :             tableBody = "";
   10201        8489 :             for (iResource = 1; iResource <= 12; ++iResource) {
   10202      117540 :                 for (int jEndUse = 1; jEndUse <= 14; ++jEndUse) {
   10203      109704 :                     tableBody(iResource, jEndUse) = RealToStr(useVal(iResource, jEndUse) / largeConversionFactor, 2);
   10204             :                 }
   10205        7836 :                 tableBody(iResource, 16) = RealToStr(useVal(iResource, 15) / largeConversionFactor, 2);
   10206             :             }
   10207             : 
   10208             :             // heading for the entire sub-table
   10209         653 :             if (produceTabular) {
   10210         653 :                 WriteSubtitle(state, "Source Energy End Use Components Summary");
   10211         653 :                 WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
   10212             :             }
   10213         653 :             if (produceSQLite) {
   10214         653 :                 if (state.dataSQLiteProcedures->sqlite) {
   10215          70 :                     state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(tableBody,
   10216             :                                                                                        rowHead,
   10217             :                                                                                        columnHead,
   10218             :                                                                                        "SourceEnergyEndUseComponentsSummary",
   10219             :                                                                                        "Entire Facility",
   10220             :                                                                                        "Source Energy End Use Components Summary");
   10221             :                 }
   10222             :             }
   10223         653 :             if (produceTabular) {
   10224         653 :                 if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
   10225           4 :                     state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(tableBody,
   10226             :                                                                                                           rowHead,
   10227             :                                                                                                           columnHead,
   10228             :                                                                                                           "SourceEnergyEndUseComponentsSummary",
   10229             :                                                                                                           "Entire Facility",
   10230             :                                                                                                           "Source Energy End Use Components Summary");
   10231             :                 }
   10232             :             }
   10233             : 
   10234             :             // Normalized by Area tables
   10235             : 
   10236         653 :             switch (unitsStyle_cur) {
   10237           5 :             case UnitsStyle::JtoKWH: {
   10238           5 :                 columnHead(1) = "Source Electricity [kWh/m2]";
   10239           5 :                 columnHead(2) = "Source Natural Gas [kWh/m2]";
   10240           5 :                 columnHead(3) = "Source Gasoline [kWh/m2]";
   10241           5 :                 columnHead(4) = "Source Diesel [kWh/m2]";
   10242           5 :                 columnHead(5) = "Source Coal [kWh/m2]";
   10243           5 :                 columnHead(6) = "Source Fuel Oil No 1 [kWh/m2]";
   10244           5 :                 columnHead(7) = "Source Fuel Oil No 2 [kWh/m2]";
   10245           5 :                 columnHead(8) = "Source Propane [kWh/m2]";
   10246           5 :                 columnHead(9) = "Source Other Fuel 1 [kWh/m2]";
   10247           5 :                 columnHead(10) = "Source Other Fuel 2 [kWh/m2]";
   10248           5 :                 columnHead(11) = "Source District Cooling [kWh/m2]";
   10249           5 :                 columnHead(12) = "Source District Heating [kWh/m2]";
   10250           5 :             } break;
   10251          11 :             case UnitsStyle::InchPound: {
   10252          11 :                 columnHead(1) = "Source Electricity [kBtu/ft2]";
   10253          11 :                 columnHead(2) = "Source Natural Gas [kBtu/ft2]";
   10254          11 :                 columnHead(3) = "Source Gasoline [kBtu/ft2]";
   10255          11 :                 columnHead(4) = "Source Diesel [kBtu/ft2]";
   10256          11 :                 columnHead(5) = "Source Coal [kBtu/ft2]";
   10257          11 :                 columnHead(6) = "Source Fuel Oil No 1 [kBtu/ft2]";
   10258          11 :                 columnHead(7) = "Source Fuel Oil No 2 [kBtu/ft2]";
   10259          11 :                 columnHead(8) = "Source Propane [kBtu/ft2]";
   10260          11 :                 columnHead(9) = "Source Other Fuel 1 [kBtu/ft2]";
   10261          11 :                 columnHead(10) = "Source Other Fuel 2 [kBtu/ft2]";
   10262          11 :                 columnHead(11) = "Source District Cooling [kBtu/ft2]";
   10263          11 :                 columnHead(12) = "Source District Heating [kBtu/ft2]";
   10264          11 :             } break;
   10265         637 :             default: {
   10266         637 :                 columnHead(1) = "Source Electricity [MJ/m2]";
   10267         637 :                 columnHead(2) = "Source Natural Gas [MJ/m2]";
   10268         637 :                 columnHead(3) = "Source Gasoline [MJ/m2]";
   10269         637 :                 columnHead(4) = "Source Diesel [MJ/m2]";
   10270         637 :                 columnHead(5) = "Source Coal [MJ/m2]";
   10271         637 :                 columnHead(6) = "Source Fuel Oil No 1 [MJ/m2]";
   10272         637 :                 columnHead(7) = "Source Fuel Oil No 2 [MJ/m2]";
   10273         637 :                 columnHead(8) = "Source Propane [MJ/m2]";
   10274         637 :                 columnHead(9) = "Source Other Fuel 1 [MJ/m2]";
   10275         637 :                 columnHead(10) = "Source Other Fuel 2 [MJ/m2]";
   10276         637 :                 columnHead(11) = "Source District Cooling [MJ/m2]";
   10277         637 :                 columnHead(12) = "Source District Heating [MJ/m2]";
   10278         637 :             } break;
   10279             :             }
   10280             : 
   10281             :             //---- Normalized by Conditioned Area Sub-Table
   10282             :             {
   10283         653 :                 tableBody = "";
   10284             :                 // convert floor area
   10285         653 :                 Real64 convBldgCondFloorArea = ort->buildingConditionedFloorArea / areaConversionFactor;
   10286         653 :                 if (convBldgCondFloorArea > 0) {
   10287        7527 :                     for (iResource = 1; iResource <= 12; ++iResource) {
   10288      104220 :                         for (int jEndUse = 1; jEndUse <= 14; ++jEndUse) {
   10289       97272 :                             tableBody(iResource, jEndUse) = RealToStr(useVal(iResource, jEndUse) / convBldgCondFloorArea, 2);
   10290             :                         }
   10291        6948 :                         tableBody(iResource, 16) = RealToStr(useVal(iResource, 15) / convBldgCondFloorArea, 2);
   10292             :                     }
   10293             :                 }
   10294             : 
   10295         653 :                 if (produceTabular) {
   10296         653 :                     WriteTextLine(state, "Normalized Metrics", true);
   10297             :                 }
   10298             : 
   10299             :                 // heading for the entire sub-table
   10300         653 :                 if (produceTabular) {
   10301         653 :                     WriteSubtitle(state, "Source Energy End Use Components Per Conditioned Floor Area");
   10302         653 :                     WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
   10303             :                 }
   10304         653 :                 if (produceSQLite) {
   10305         653 :                     if (state.dataSQLiteProcedures->sqlite) {
   10306          70 :                         state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
   10307             :                             tableBody,
   10308             :                             rowHead,
   10309             :                             columnHead,
   10310             :                             "SourceEnergyEndUseComponentsSummary",
   10311             :                             "Entire Facility",
   10312             :                             "Source Energy End Use Components Per Conditioned Floor Area");
   10313             :                     }
   10314             :                 }
   10315         653 :                 if (produceTabular) {
   10316         653 :                     if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
   10317           4 :                         state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(
   10318             :                             tableBody,
   10319             :                             rowHead,
   10320             :                             columnHead,
   10321             :                             "SourceEnergyEndUseComponentsSummary",
   10322             :                             "Entire Facility",
   10323             :                             "Source Energy End Use Components Per Conditioned Floor Area");
   10324             :                     }
   10325             :                 }
   10326             :             } // End of Normalized by Conditioned Area
   10327             : 
   10328             :             //---- Normalized by Total Area Sub-Table
   10329             :             {
   10330         653 :                 tableBody = "";
   10331         653 :                 Real64 convBldgGrossFloorArea = ort->buildingGrossFloorArea / areaConversionFactor;
   10332             : 
   10333         653 :                 if (convBldgGrossFloorArea > 0) {
   10334        8125 :                     for (iResource = 1; iResource <= 12; ++iResource) {
   10335      112500 :                         for (int jEndUse = 1; jEndUse <= 14; ++jEndUse) {
   10336      105000 :                             tableBody(iResource, jEndUse) = RealToStr(useVal(iResource, jEndUse) / convBldgGrossFloorArea, 2);
   10337             :                         }
   10338        7500 :                         tableBody(iResource, 16) = RealToStr(useVal(iResource, 15) / convBldgGrossFloorArea, 2);
   10339             :                     }
   10340             :                 }
   10341             : 
   10342             :                 // heading for the entire sub-table
   10343         653 :                 if (produceTabular) {
   10344         653 :                     WriteSubtitle(state, "Source Energy End Use Components Per Total Floor Area");
   10345         653 :                     WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
   10346             :                 }
   10347         653 :                 if (produceSQLite) {
   10348         653 :                     if (state.dataSQLiteProcedures->sqlite) {
   10349          70 :                         state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(tableBody,
   10350             :                                                                                            rowHead,
   10351             :                                                                                            columnHead,
   10352             :                                                                                            "SourceEnergyEndUseComponentsSummary",
   10353             :                                                                                            "Entire Facility",
   10354             :                                                                                            "Source Energy End Use Components Per Total Floor Area");
   10355             :                     }
   10356             :                 }
   10357         653 :                 if (produceTabular) {
   10358         653 :                     if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
   10359           4 :                         state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(
   10360             :                             tableBody,
   10361             :                             rowHead,
   10362             :                             columnHead,
   10363             :                             "SourceEnergyEndUseComponentsSummary",
   10364             :                             "Entire Facility",
   10365             :                             "Source Energy End Use Components Per Total Floor Area");
   10366             :                     }
   10367             :                 }
   10368             :             } // End of Normalized by Total Area
   10369             :         }     // End of Dual Units reporting
   10370             :     }         // end if displaySourceEnergyEndUseSummary
   10371         731 : }
   10372             : 
   10373         731 : void WriteDemandEndUseSummary(EnergyPlusData &state)
   10374             : {
   10375             :     // SUBROUTINE INFORMATION:
   10376             :     //       AUTHOR         Jason Glazer
   10377             :     //       DATE WRITTEN   January 2009
   10378             :     //       MODIFIED       January 2010, Kyle Benne; Added SQLite output
   10379             :     //                      March 2020, Dareum Nam; Disaggregated "Additional Fuel"
   10380             :     //       RE-ENGINEERED  na
   10381             : 
   10382             :     // PURPOSE OF THIS SUBROUTINE:
   10383             :     //   Take the gathered total and enduse meter data and structure
   10384             :     //   the results into a tabular report for output.
   10385             : 
   10386             :     // METHODOLOGY EMPLOYED:
   10387             :     //   Create arrays for the call to WriteTable and then call it.
   10388             :     //   This report actually consists of many sub-tables each with
   10389             :     //   its own call to WriteTable.
   10390             : 
   10391             :     // all arrays are in the format: (row, column)
   10392        1462 :     Array1D_string columnHead;
   10393        1462 :     Array1D_int columnWidth;
   10394        1462 :     Array1D_string rowHead;
   10395        1462 :     Array2D_string tableBody;
   10396             : 
   10397             :     // all arrays are in the format: (row, column)
   10398        1462 :     Array2D<Real64> useVal(13, 15);
   10399        1462 :     Array1D<Real64> collapsedTotal(13);
   10400        1462 :     Array2D<Real64> collapsedEndUse(13, DataGlobalConstantsData::iEndUseSize);
   10401        1462 :     Array2D<Real64> collapsedIndEndUse(13, DataGlobalConstantsData::iEndUseSize);
   10402        1462 :     Array1D_int collapsedTimeStep(13);
   10403        1462 :     Array3D<Real64> collapsedEndUseSub(state.dataOutputProcessor->MaxNumSubcategories, DataGlobalConstantsData::iEndUseSize, 13);
   10404        1462 :     Array3D<Real64> collapsedIndEndUseSub(state.dataOutputProcessor->MaxNumSubcategories, DataGlobalConstantsData::iEndUseSize, 13);
   10405        1462 :     Array2D<Real64> endUseSubOther(13, DataGlobalConstantsData::iEndUseSize);
   10406             :     int iResource;
   10407             :     int kEndUseSub;
   10408             :     int i;
   10409             :     int numRows;
   10410             :     int distrHeatSelected;
   10411             :     bool bothDistrHeatNonZero;
   10412             :     Real64 powerConversion;
   10413             :     Real64 flowConversion;
   10414             : 
   10415             :     Real64 unconvert;
   10416        1462 :     std::string subCatName;
   10417         731 :     auto &ort(state.dataOutRptTab);
   10418             : 
   10419         731 :     if (ort->displayDemandEndUse) {
   10420             :         // show the headers of the report
   10421         656 :         WriteReportHeaders(state, "Demand End Use Components Summary", "Entire Facility", OutputProcessor::StoreType::Averaged);
   10422             : 
   10423        1312 :         for (int iUnitSystem = 0; iUnitSystem <= 1; iUnitSystem++) {
   10424        1312 :             UnitsStyle unitsStyle_cur = ort->unitsStyle;
   10425        1312 :             bool produceTabular = true;
   10426        1312 :             bool produceSQLite = false;
   10427        1312 :             if (produceDualUnitsFlags(iUnitSystem, ort->unitsStyle, ort->unitsStyle_SQLite, unitsStyle_cur, produceTabular, produceSQLite)) break;
   10428             : 
   10429             :             // totals - select which additional fuel to display and which other district heating
   10430         656 :             collapsedTotal = 0.0;
   10431         656 :             collapsedTotal(1) = ort->gatherDemandTotal(1); // electricity
   10432         656 :             collapsedTimeStep(1) = ort->gatherDemandTimeStamp(1);
   10433         656 :             collapsedTotal(2) = ort->gatherDemandTotal(2); // natural gas
   10434         656 :             collapsedTimeStep(2) = ort->gatherDemandTimeStamp(2);
   10435         656 :             collapsedTotal(3) = ort->gatherDemandTotal(6); // gasoline
   10436         656 :             collapsedTimeStep(3) = ort->gatherDemandTimeStamp(6);
   10437         656 :             collapsedTotal(4) = ort->gatherDemandTotal(8); // diesel
   10438         656 :             collapsedTimeStep(4) = ort->gatherDemandTimeStamp(8);
   10439         656 :             collapsedTotal(5) = ort->gatherDemandTotal(9); // coal
   10440         656 :             collapsedTimeStep(5) = ort->gatherDemandTimeStamp(9);
   10441         656 :             collapsedTotal(6) = ort->gatherDemandTotal(10); // fuel oil no 1
   10442         656 :             collapsedTimeStep(6) = ort->gatherDemandTimeStamp(10);
   10443         656 :             collapsedTotal(7) = ort->gatherDemandTotal(11); // fuel oil no 2
   10444         656 :             collapsedTimeStep(7) = ort->gatherDemandTimeStamp(11);
   10445         656 :             collapsedTotal(8) = ort->gatherDemandTotal(12); // propane
   10446         656 :             collapsedTimeStep(8) = ort->gatherDemandTimeStamp(12);
   10447         656 :             collapsedTotal(9) = ort->gatherDemandTotal(13); // other fuel 1
   10448         656 :             collapsedTimeStep(9) = ort->gatherDemandTimeStamp(13);
   10449         656 :             collapsedTotal(10) = ort->gatherDemandTotal(14); // other fuel 2
   10450         656 :             collapsedTimeStep(10) = ort->gatherDemandTimeStamp(14);
   10451         656 :             collapsedTotal(11) = ort->gatherDemandTotal(3); // district cooling <- purchased cooling
   10452         656 :             collapsedTimeStep(11) = ort->gatherDemandTimeStamp(3);
   10453         656 :             collapsedTotal(13) = ort->gatherDemandTotal(7); // water
   10454         656 :             collapsedTimeStep(13) = ort->gatherDemandTimeStamp(7);
   10455             : 
   10456             :             // set flag if both purchased heating and steam both have positive demand
   10457         656 :             bothDistrHeatNonZero = (ort->gatherDemandTotal(4) > 0.0) && (ort->gatherDemandTotal(5) > 0.0);
   10458             :             // select the district heating source that has a larger demand
   10459         656 :             if (ort->gatherDemandTotal(4) > ort->gatherDemandTotal(5)) {
   10460           0 :                 distrHeatSelected = 4; // purchased heating
   10461           0 :                 if (bothDistrHeatNonZero) {
   10462           0 :                     state.dataOutRptTab->footnote += " Steam has non-zero demand but is not shown on this report.";
   10463             :                 }
   10464             :             } else {
   10465         656 :                 distrHeatSelected = 5; // steam
   10466         656 :                 if (bothDistrHeatNonZero) {
   10467           0 :                     state.dataOutRptTab->footnote += " District heating has non-zero demand but is not shown on this report.";
   10468             :                 }
   10469             :             }
   10470             :             // set the time of peak demand and total demand for the purchased heating/steam
   10471         656 :             collapsedTimeStep(12) = ort->gatherDemandTimeStamp(distrHeatSelected);
   10472         656 :             collapsedTotal(12) = ort->gatherDemandTotal(distrHeatSelected);
   10473             : 
   10474             :             // establish unit conversion factors
   10475         656 :             if (unitsStyle_cur == UnitsStyle::InchPound) {
   10476          11 :                 powerConversion = getSpecificUnitMultiplier(state, "W", "kBtuh");
   10477          11 :                 flowConversion = getSpecificUnitMultiplier(state, "m3/s", "gal/min");
   10478             :             } else {
   10479         645 :                 powerConversion = 1.0;
   10480         645 :                 flowConversion = 1.0;
   10481             :             }
   10482             : 
   10483             :             // collapse the gatherEndUseBEPS array to the resource groups displayed
   10484         656 :             collapsedEndUse = 0.0;
   10485        9840 :             for (int jEndUse = 1; jEndUse <= DataGlobalConstantsData::iEndUseSize; ++jEndUse) {
   10486        9184 :                 collapsedEndUse(1, jEndUse) = ort->gatherDemandEndUse(1, jEndUse) * powerConversion;                  // electricity
   10487        9184 :                 collapsedEndUse(2, jEndUse) = ort->gatherDemandEndUse(2, jEndUse) * powerConversion;                  // natural gas
   10488        9184 :                 collapsedEndUse(3, jEndUse) = ort->gatherDemandEndUse(6, jEndUse) * powerConversion;                  // gasoline
   10489        9184 :                 collapsedEndUse(4, jEndUse) = ort->gatherDemandEndUse(8, jEndUse) * powerConversion;                  // diesel
   10490        9184 :                 collapsedEndUse(5, jEndUse) = ort->gatherDemandEndUse(9, jEndUse) * powerConversion;                  // coal
   10491        9184 :                 collapsedEndUse(6, jEndUse) = ort->gatherDemandEndUse(10, jEndUse) * powerConversion;                 // fuel oil no 1
   10492        9184 :                 collapsedEndUse(7, jEndUse) = ort->gatherDemandEndUse(11, jEndUse) * powerConversion;                 // fuel oil no 2
   10493        9184 :                 collapsedEndUse(8, jEndUse) = ort->gatherDemandEndUse(12, jEndUse) * powerConversion;                 // propane
   10494        9184 :                 collapsedEndUse(9, jEndUse) = ort->gatherDemandEndUse(13, jEndUse) * powerConversion;                 // otherfuel1
   10495        9184 :                 collapsedEndUse(10, jEndUse) = ort->gatherDemandEndUse(14, jEndUse) * powerConversion;                // otherfuel2
   10496        9184 :                 collapsedEndUse(11, jEndUse) = ort->gatherDemandEndUse(3, jEndUse) * powerConversion;                 // purchased cooling
   10497        9184 :                 collapsedEndUse(12, jEndUse) = ort->gatherDemandEndUse(distrHeatSelected, jEndUse) * powerConversion; // district heating
   10498        9184 :                 collapsedEndUse(13, jEndUse) = ort->gatherDemandEndUse(7, jEndUse) * flowConversion;                  // water
   10499             :             }
   10500        9840 :             for (int jEndUse = 1; jEndUse <= DataGlobalConstantsData::iEndUseSize; ++jEndUse) {
   10501       14286 :                 for (kEndUseSub = 1; kEndUseSub <= state.dataOutputProcessor->EndUseCategory(jEndUse).NumSubcategories; ++kEndUseSub) {
   10502        5102 :                     collapsedEndUseSub(kEndUseSub, jEndUse, 1) = ort->gatherDemandEndUseSub(kEndUseSub, jEndUse, 1) * powerConversion; // electricity
   10503        5102 :                     collapsedEndUseSub(kEndUseSub, jEndUse, 2) = ort->gatherDemandEndUseSub(kEndUseSub, jEndUse, 2) * powerConversion; // natural gas
   10504        5102 :                     collapsedEndUseSub(kEndUseSub, jEndUse, 3) = ort->gatherDemandEndUseSub(kEndUseSub, jEndUse, 6) * powerConversion; // gasoline
   10505        5102 :                     collapsedEndUseSub(kEndUseSub, jEndUse, 4) = ort->gatherDemandEndUseSub(kEndUseSub, jEndUse, 8) * powerConversion; // diesel
   10506        5102 :                     collapsedEndUseSub(kEndUseSub, jEndUse, 5) = ort->gatherDemandEndUseSub(kEndUseSub, jEndUse, 9) * powerConversion; // coal
   10507        5102 :                     collapsedEndUseSub(kEndUseSub, jEndUse, 6) =
   10508        5102 :                         ort->gatherDemandEndUseSub(kEndUseSub, jEndUse, 10) * powerConversion; // fuel oil no 1
   10509        5102 :                     collapsedEndUseSub(kEndUseSub, jEndUse, 7) =
   10510        5102 :                         ort->gatherDemandEndUseSub(kEndUseSub, jEndUse, 11) * powerConversion; // fuel oil no 2
   10511        5102 :                     collapsedEndUseSub(kEndUseSub, jEndUse, 8) = ort->gatherDemandEndUseSub(kEndUseSub, jEndUse, 12) * powerConversion;  // propane
   10512        5102 :                     collapsedEndUseSub(kEndUseSub, jEndUse, 9) = ort->gatherDemandEndUseSub(kEndUseSub, jEndUse, 13) * powerConversion;  // otherfuel1
   10513        5102 :                     collapsedEndUseSub(kEndUseSub, jEndUse, 10) = ort->gatherDemandEndUseSub(kEndUseSub, jEndUse, 14) * powerConversion; // otherfuel2
   10514        5102 :                     collapsedEndUseSub(kEndUseSub, jEndUse, 11) =
   10515        5102 :                         ort->gatherDemandEndUseSub(kEndUseSub, jEndUse, 3) * powerConversion; // purch cooling
   10516        5102 :                     collapsedEndUseSub(kEndUseSub, jEndUse, 12) =
   10517        5102 :                         ort->gatherDemandEndUseSub(kEndUseSub, jEndUse, distrHeatSelected) * powerConversion; // district heating
   10518        5102 :                     collapsedEndUseSub(kEndUseSub, jEndUse, 13) = ort->gatherDemandEndUseSub(kEndUseSub, jEndUse, 7) * flowConversion; // water
   10519             :                 }
   10520             :             }
   10521             :             // collapse the individual peaks for the end use subcategories for the LEED report
   10522             :             // collapse the gatherEndUseBEPS array to the resource groups displayed
   10523             :             // no unit conversion, it is done at the reporting stage if necessary
   10524         656 :             collapsedIndEndUse = 0.0;
   10525        9840 :             for (int jEndUse = 1; jEndUse <= DataGlobalConstantsData::iEndUseSize; ++jEndUse) {
   10526        9184 :                 collapsedIndEndUse(1, jEndUse) = ort->gatherDemandIndEndUse(1, jEndUse);                  // electricity
   10527        9184 :                 collapsedIndEndUse(2, jEndUse) = ort->gatherDemandIndEndUse(2, jEndUse);                  // natural gas
   10528        9184 :                 collapsedIndEndUse(3, jEndUse) = ort->gatherDemandIndEndUse(6, jEndUse);                  // gasoline
   10529        9184 :                 collapsedIndEndUse(4, jEndUse) = ort->gatherDemandIndEndUse(8, jEndUse);                  // diesel
   10530        9184 :                 collapsedIndEndUse(5, jEndUse) = ort->gatherDemandIndEndUse(9, jEndUse);                  // coal
   10531        9184 :                 collapsedIndEndUse(6, jEndUse) = ort->gatherDemandIndEndUse(10, jEndUse);                 // fuel oil no 1
   10532        9184 :                 collapsedIndEndUse(7, jEndUse) = ort->gatherDemandIndEndUse(11, jEndUse);                 // fuel oil no 2
   10533        9184 :                 collapsedIndEndUse(8, jEndUse) = ort->gatherDemandIndEndUse(12, jEndUse);                 // propane
   10534        9184 :                 collapsedIndEndUse(9, jEndUse) = ort->gatherDemandIndEndUse(13, jEndUse);                 // otherfuel1
   10535        9184 :                 collapsedIndEndUse(10, jEndUse) = ort->gatherDemandIndEndUse(14, jEndUse);                // otherfuel2
   10536        9184 :                 collapsedIndEndUse(11, jEndUse) = ort->gatherDemandIndEndUse(3, jEndUse);                 // purchased cooling
   10537        9184 :                 collapsedIndEndUse(12, jEndUse) = ort->gatherDemandIndEndUse(distrHeatSelected, jEndUse); // district heating
   10538        9184 :                 collapsedIndEndUse(13, jEndUse) = ort->gatherDemandIndEndUse(7, jEndUse);                 // water
   10539             :             }
   10540        9840 :             for (int jEndUse = 1; jEndUse <= DataGlobalConstantsData::iEndUseSize; ++jEndUse) {
   10541       14286 :                 for (kEndUseSub = 1; kEndUseSub <= state.dataOutputProcessor->EndUseCategory(jEndUse).NumSubcategories; ++kEndUseSub) {
   10542        5102 :                     collapsedIndEndUseSub(kEndUseSub, jEndUse, 1) = ort->gatherDemandIndEndUseSub(kEndUseSub, jEndUse, 1);   // electricity
   10543        5102 :                     collapsedIndEndUseSub(kEndUseSub, jEndUse, 2) = ort->gatherDemandIndEndUseSub(kEndUseSub, jEndUse, 2);   // natural gas
   10544        5102 :                     collapsedIndEndUseSub(kEndUseSub, jEndUse, 3) = ort->gatherDemandIndEndUseSub(kEndUseSub, jEndUse, 6);   // gasoline
   10545        5102 :                     collapsedIndEndUseSub(kEndUseSub, jEndUse, 4) = ort->gatherDemandIndEndUseSub(kEndUseSub, jEndUse, 8);   // diesel
   10546        5102 :                     collapsedIndEndUseSub(kEndUseSub, jEndUse, 5) = ort->gatherDemandIndEndUseSub(kEndUseSub, jEndUse, 9);   // coal
   10547        5102 :                     collapsedIndEndUseSub(kEndUseSub, jEndUse, 6) = ort->gatherDemandIndEndUseSub(kEndUseSub, jEndUse, 10);  // fuel oil no 1
   10548        5102 :                     collapsedIndEndUseSub(kEndUseSub, jEndUse, 7) = ort->gatherDemandIndEndUseSub(kEndUseSub, jEndUse, 11);  // fuel oil no 2
   10549        5102 :                     collapsedIndEndUseSub(kEndUseSub, jEndUse, 8) = ort->gatherDemandIndEndUseSub(kEndUseSub, jEndUse, 12);  // propane
   10550        5102 :                     collapsedIndEndUseSub(kEndUseSub, jEndUse, 9) = ort->gatherDemandIndEndUseSub(kEndUseSub, jEndUse, 13);  // otherfuel1
   10551        5102 :                     collapsedIndEndUseSub(kEndUseSub, jEndUse, 10) = ort->gatherDemandIndEndUseSub(kEndUseSub, jEndUse, 14); // otherfuel2
   10552        5102 :                     collapsedIndEndUseSub(kEndUseSub, jEndUse, 11) = ort->gatherDemandIndEndUseSub(kEndUseSub, jEndUse, 3);  // purch cooling
   10553        5102 :                     collapsedIndEndUseSub(kEndUseSub, jEndUse, 12) =
   10554        5102 :                         ort->gatherDemandIndEndUseSub(kEndUseSub, jEndUse, distrHeatSelected);                              // district heating
   10555        5102 :                     collapsedIndEndUseSub(kEndUseSub, jEndUse, 13) = ort->gatherDemandIndEndUseSub(kEndUseSub, jEndUse, 7); // water
   10556             :                 }
   10557             :             }
   10558             : 
   10559             :             // convert totals
   10560         656 :             collapsedTotal(1) *= powerConversion;  // electricity
   10561         656 :             collapsedTotal(2) *= powerConversion;  // natural gas
   10562         656 :             collapsedTotal(3) *= powerConversion;  // gasoline
   10563         656 :             collapsedTotal(4) *= powerConversion;  // diesel
   10564         656 :             collapsedTotal(5) *= powerConversion;  // coal
   10565         656 :             collapsedTotal(6) *= powerConversion;  // fuel oil no 1
   10566         656 :             collapsedTotal(7) *= powerConversion;  // fuel oil no 2
   10567         656 :             collapsedTotal(8) *= powerConversion;  // propane
   10568         656 :             collapsedTotal(9) *= powerConversion;  // otherfuel1
   10569         656 :             collapsedTotal(10) *= powerConversion; // otherfuel2
   10570         656 :             collapsedTotal(11) *= powerConversion; // purchased cooling
   10571         656 :             collapsedTotal(12) *= powerConversion; // district heating
   10572         656 :             collapsedTotal(13) *= flowConversion;  // water
   10573             :             //---- End Use Sub-Table
   10574         656 :             rowHead.allocate(17);
   10575         656 :             columnHead.allocate(13);
   10576         656 :             columnWidth.allocate(13);
   10577         656 :             columnWidth = 10; // array assignment - same for all columns
   10578         656 :             tableBody.allocate(13, 17);
   10579        9184 :             for (iResource = 1; iResource <= 13; ++iResource) {
   10580        8528 :                 useVal(iResource, 1) = collapsedEndUse(iResource, state.dataGlobalConst->iEndUse.at(DataGlobalConstants::EndUse::Heating));
   10581        8528 :                 useVal(iResource, 2) = collapsedEndUse(iResource, state.dataGlobalConst->iEndUse.at(DataGlobalConstants::EndUse::Cooling));
   10582        8528 :                 useVal(iResource, 3) = collapsedEndUse(iResource, state.dataGlobalConst->iEndUse.at(DataGlobalConstants::EndUse::InteriorLights));
   10583        8528 :                 useVal(iResource, 4) = collapsedEndUse(iResource, state.dataGlobalConst->iEndUse.at(DataGlobalConstants::EndUse::ExteriorLights));
   10584        8528 :                 useVal(iResource, 5) = collapsedEndUse(iResource, state.dataGlobalConst->iEndUse.at(DataGlobalConstants::EndUse::InteriorEquipment));
   10585        8528 :                 useVal(iResource, 6) = collapsedEndUse(iResource, state.dataGlobalConst->iEndUse.at(DataGlobalConstants::EndUse::ExteriorEquipment));
   10586        8528 :                 useVal(iResource, 7) = collapsedEndUse(iResource, state.dataGlobalConst->iEndUse.at(DataGlobalConstants::EndUse::Fans));
   10587        8528 :                 useVal(iResource, 8) = collapsedEndUse(iResource, state.dataGlobalConst->iEndUse.at(DataGlobalConstants::EndUse::Pumps));
   10588        8528 :                 useVal(iResource, 9) = collapsedEndUse(iResource, state.dataGlobalConst->iEndUse.at(DataGlobalConstants::EndUse::HeatRejection));
   10589        8528 :                 useVal(iResource, 10) = collapsedEndUse(iResource, state.dataGlobalConst->iEndUse.at(DataGlobalConstants::EndUse::Humidification));
   10590        8528 :                 useVal(iResource, 11) = collapsedEndUse(iResource, state.dataGlobalConst->iEndUse.at(DataGlobalConstants::EndUse::HeatRecovery));
   10591        8528 :                 useVal(iResource, 12) = collapsedEndUse(iResource, state.dataGlobalConst->iEndUse.at(DataGlobalConstants::EndUse::WaterSystem));
   10592        8528 :                 useVal(iResource, 13) = collapsedEndUse(iResource, state.dataGlobalConst->iEndUse.at(DataGlobalConstants::EndUse::Refrigeration));
   10593        8528 :                 useVal(iResource, 14) = collapsedEndUse(iResource, state.dataGlobalConst->iEndUse.at(DataGlobalConstants::EndUse::Cogeneration));
   10594        8528 :                 useVal(iResource, 15) = collapsedTotal(iResource); // totals
   10595             :             }
   10596             : 
   10597         656 :             rowHead(1) = "Time of Peak";
   10598         656 :             rowHead(2) = "Heating";
   10599         656 :             rowHead(3) = "Cooling";
   10600         656 :             rowHead(4) = "Interior Lighting";
   10601         656 :             rowHead(5) = "Exterior Lighting";
   10602         656 :             rowHead(6) = "Interior Equipment";
   10603         656 :             rowHead(7) = "Exterior Equipment";
   10604         656 :             rowHead(8) = "Fans";
   10605         656 :             rowHead(9) = "Pumps";
   10606         656 :             rowHead(10) = "Heat Rejection";
   10607         656 :             rowHead(11) = "Humidification";
   10608         656 :             rowHead(12) = "Heat Recovery";
   10609         656 :             rowHead(13) = "Water Systems";
   10610         656 :             rowHead(14) = "Refrigeration";
   10611         656 :             rowHead(15) = "Generators";
   10612         656 :             rowHead(16) = "";
   10613         656 :             rowHead(17) = "Total End Uses";
   10614             : 
   10615         656 :             if (unitsStyle_cur == UnitsStyle::InchPound) {
   10616          11 :                 columnHead(1) = "Electricity [kBtuh]";
   10617          11 :                 columnHead(2) = "Natural Gas [kBtuh]";
   10618          11 :                 columnHead(3) = "Gasoline [kBtuh]";
   10619          11 :                 columnHead(4) = "Diesel [kBtuh]";
   10620          11 :                 columnHead(5) = "Coal [kBtuh]";
   10621          11 :                 columnHead(6) = "Fuel Oil No 1 [kBtuh]";
   10622          11 :                 columnHead(7) = "Fuel Oil No 2 [kBtuh]";
   10623          11 :                 columnHead(8) = "Propane [kBtuh]";
   10624          11 :                 columnHead(9) = "Other Fuel 1 [kBtuh]";
   10625          11 :                 columnHead(10) = "Other Fuel 2 [kBtuh]";
   10626          11 :                 columnHead(11) = "District Cooling [kBtuh]";
   10627             :                 {
   10628          11 :                     if (distrHeatSelected == 4) {
   10629           0 :                         columnHead(12) = "District Heating [kBtuh]";
   10630          11 :                     } else if (distrHeatSelected == 5) {
   10631          11 :                         columnHead(12) = "Steam [kBtuh]";
   10632             :                     }
   10633             :                 }
   10634          11 :                 columnHead(13) = "Water [gal/min]";
   10635             :             } else {
   10636         645 :                 columnHead(1) = "Electricity [W]";
   10637         645 :                 columnHead(2) = "Natural Gas [W]";
   10638         645 :                 columnHead(3) = "Gasoline [W]";
   10639         645 :                 columnHead(4) = "Diesel [W]";
   10640         645 :                 columnHead(5) = "Coal [W]";
   10641         645 :                 columnHead(6) = "Fuel Oil No 1 [W]";
   10642         645 :                 columnHead(7) = "Fuel Oil No 2 [W]";
   10643         645 :                 columnHead(8) = "Propane [W]";
   10644         645 :                 columnHead(9) = "Other Fuel 1 [W]";
   10645         645 :                 columnHead(10) = "Other Fuel 2 [W]";
   10646         645 :                 columnHead(11) = "District Cooling [W]";
   10647             :                 {
   10648         645 :                     if (distrHeatSelected == 4) {
   10649           0 :                         columnHead(12) = "District Heating [W]";
   10650         645 :                     } else if (distrHeatSelected == 5) {
   10651         645 :                         columnHead(12) = "Steam [W]";
   10652             :                     }
   10653             :                 }
   10654         645 :                 columnHead(13) = "Water [m3/s]";
   10655             :             }
   10656             : 
   10657         656 :             tableBody = "";
   10658        9184 :             for (iResource = 1; iResource <= 13; ++iResource) {
   10659      127920 :                 for (int jEndUse = 1; jEndUse <= 14; ++jEndUse) {
   10660      119392 :                     tableBody(iResource, 1 + jEndUse) = RealToStr(useVal(iResource, jEndUse), 2);
   10661             :                 }
   10662        8528 :                 tableBody(iResource, 1) = DateToString(collapsedTimeStep(iResource));
   10663        8528 :                 tableBody(iResource, 17) = RealToStr(collapsedTotal(iResource), 2);
   10664             :             }
   10665             : 
   10666             :             // complete the LEED end use table using the same values
   10667         656 :             unconvert = 1 / powerConversion;
   10668             : 
   10669         656 :             if (produceTabular) {
   10670         656 :                 WriteSubtitle(state, "End Uses");
   10671         656 :                 WriteTable(state, tableBody, rowHead, columnHead, columnWidth, false, state.dataOutRptTab->footnote);
   10672             :             }
   10673         656 :             if (produceSQLite) {
   10674         656 :                 if (state.dataSQLiteProcedures->sqlite) {
   10675          70 :                     state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
   10676             :                         tableBody, rowHead, columnHead, "DemandEndUseComponentsSummary", "Entire Facility", "End Uses");
   10677             :                 }
   10678             :             }
   10679         656 :             if (produceTabular) {
   10680         656 :                 if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
   10681           4 :                     state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(
   10682             :                         tableBody, rowHead, columnHead, "DemandEndUseComponentsSummary", "Entire Facility", "End Uses");
   10683             :                 }
   10684             :             }
   10685             : 
   10686             :             //---- End Uses By Subcategory Sub-Table
   10687         656 :             numRows = 0;
   10688        9840 :             for (int jEndUse = 1; jEndUse <= DataGlobalConstantsData::iEndUseSize; ++jEndUse) {
   10689        9184 :                 if (state.dataOutputProcessor->EndUseCategory(jEndUse).NumSubcategories > 0) {
   10690        9513 :                     for (kEndUseSub = 1; kEndUseSub <= state.dataOutputProcessor->EndUseCategory(jEndUse).NumSubcategories; ++kEndUseSub) {
   10691        5102 :                         ++numRows;
   10692             :                     }
   10693             :                 } else {
   10694        4773 :                     ++numRows;
   10695             :                 }
   10696             :             }
   10697             : 
   10698         656 :             rowHead.allocate(numRows);
   10699         656 :             columnHead.allocate(14);
   10700         656 :             columnWidth.allocate(14);
   10701         656 :             columnWidth = 10; // array assignment - same for all columns
   10702         656 :             tableBody.allocate(14, numRows);
   10703             : 
   10704         656 :             rowHead = "";
   10705         656 :             tableBody = "";
   10706             : 
   10707             :             // Build row head and subcategories columns
   10708         656 :             i = 1;
   10709        9840 :             for (int jEndUse = 1; jEndUse <= DataGlobalConstantsData::iEndUseSize; ++jEndUse) {
   10710        9184 :                 rowHead(i) = state.dataOutputProcessor->EndUseCategory(jEndUse).DisplayName;
   10711        9184 :                 if (state.dataOutputProcessor->EndUseCategory(jEndUse).NumSubcategories > 0) {
   10712        9513 :                     for (kEndUseSub = 1; kEndUseSub <= state.dataOutputProcessor->EndUseCategory(jEndUse).NumSubcategories; ++kEndUseSub) {
   10713        5102 :                         tableBody(1, i) = state.dataOutputProcessor->EndUseCategory(jEndUse).SubcategoryName(kEndUseSub);
   10714        5102 :                         ++i;
   10715             :                     }
   10716             :                 } else {
   10717        4773 :                     tableBody(1, i) = "General";
   10718        4773 :                     ++i;
   10719             :                 }
   10720             :             }
   10721             : 
   10722         656 :             if (unitsStyle_cur == UnitsStyle::InchPound) {
   10723          11 :                 columnHead(1) = "Subcategory";
   10724          11 :                 columnHead(2) = "Electricity [kBtuh]";
   10725          11 :                 columnHead(3) = "Natural Gas [kBtuh]";
   10726          11 :                 columnHead(4) = "Gasoline [kBtuh]";
   10727          11 :                 columnHead(5) = "Diesel [kBtuh]";
   10728          11 :                 columnHead(6) = "Coal [kBtuh]";
   10729          11 :                 columnHead(7) = "Fuel Oil No 1 [kBtuh]";
   10730          11 :                 columnHead(8) = "Fuel Oil No 2 [kBtuh]";
   10731          11 :                 columnHead(9) = "Propane [kBtuh]";
   10732          11 :                 columnHead(10) = "Other Fuel 1 [kBtuh]";
   10733          11 :                 columnHead(11) = "Other Fuel 2 [kBtuh]";
   10734          11 :                 columnHead(12) = "District Cooling [kBtuh]";
   10735             :                 {
   10736          11 :                     if (distrHeatSelected == 4) {
   10737           0 :                         columnHead(13) = "District Heating [kBtuh]";
   10738          11 :                     } else if (distrHeatSelected == 5) {
   10739          11 :                         columnHead(13) = "Steam [kBtuh]";
   10740             :                     }
   10741             :                 }
   10742          11 :                 columnHead(14) = "Water [gal/min]";
   10743             :             } else {
   10744         645 :                 columnHead(1) = "Subcategory";
   10745         645 :                 columnHead(2) = "Electricity [W]";
   10746         645 :                 columnHead(3) = "Natural Gas [W]";
   10747         645 :                 columnHead(4) = "Gasoline [W]";
   10748         645 :                 columnHead(5) = "Diesel [W]";
   10749         645 :                 columnHead(6) = "Coal [W]";
   10750         645 :                 columnHead(7) = "Fuel Oil No 1 [W]";
   10751         645 :                 columnHead(8) = "Fuel Oil No 2 [W]";
   10752         645 :                 columnHead(9) = "Propane [W]";
   10753         645 :                 columnHead(10) = "Other Fuel 1 [W]";
   10754         645 :                 columnHead(11) = "Other Fuel 2 [W]";
   10755         645 :                 columnHead(12) = "District Cooling [W]";
   10756             :                 {
   10757         645 :                     if (distrHeatSelected == 4) {
   10758           0 :                         columnHead(13) = "District Heating [W]";
   10759         645 :                     } else if (distrHeatSelected == 5) {
   10760         645 :                         columnHead(13) = "Steam [W]";
   10761             :                     }
   10762             :                 }
   10763         645 :                 columnHead(14) = "Water [m3/s]";
   10764             :             }
   10765             : 
   10766        9184 :             for (iResource = 1; iResource <= 13; ++iResource) {
   10767        8528 :                 i = 1;
   10768      127920 :                 for (int jEndUse = 1; jEndUse <= DataGlobalConstantsData::iEndUseSize; ++jEndUse) {
   10769      119392 :                     if (state.dataOutputProcessor->EndUseCategory(jEndUse).NumSubcategories > 0) {
   10770      123669 :                         for (kEndUseSub = 1; kEndUseSub <= state.dataOutputProcessor->EndUseCategory(jEndUse).NumSubcategories; ++kEndUseSub) {
   10771       66326 :                             tableBody(iResource + 1, i) = RealToStr(collapsedEndUseSub(kEndUseSub, jEndUse, iResource), 2);
   10772       66326 :                             ++i;
   10773             :                         }
   10774             :                     } else {
   10775       62049 :                         tableBody(iResource + 1, i) = RealToStr(collapsedEndUse(iResource, jEndUse), 2);
   10776       62049 :                         ++i;
   10777             :                     }
   10778             :                 }
   10779             :             }
   10780             : 
   10781             :             // heading for the entire sub-table
   10782         656 :             if (produceTabular) {
   10783         656 :                 WriteSubtitle(state, "End Uses By Subcategory");
   10784         656 :                 WriteTable(state, tableBody, rowHead, columnHead, columnWidth, false, state.dataOutRptTab->footnote);
   10785             :             }
   10786             : 
   10787        1312 :             Array1D_string rowHeadTemp(rowHead);
   10788             :             // Before outputing to SQL, we forward fill the End use column (rowHead) (cf #7481)
   10789             :             // for better sql queries
   10790         656 :             FillRowHead(rowHeadTemp);
   10791             : 
   10792       10531 :             for (int i = 1; i <= numRows; ++i) {
   10793        9875 :                 rowHeadTemp(i) = rowHeadTemp(i) + ":" + tableBody(1, i);
   10794             :             }
   10795             : 
   10796             :             // Erase the SubCategory (first column), using slicing
   10797        1312 :             Array2D_string tableBodyTemp(tableBody({2, _, _}, {_, _, _}));
   10798        1312 :             Array1D_string columnHeadTemp(columnHead({2, _, _}));
   10799             : 
   10800         656 :             if (produceSQLite) {
   10801         656 :                 if (state.dataSQLiteProcedures->sqlite) {
   10802          70 :                     state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
   10803             :                         tableBodyTemp, rowHeadTemp, columnHeadTemp, "DemandEndUseComponentsSummary", "Entire Facility", "End Uses By Subcategory");
   10804             :                 }
   10805             :             }
   10806             : 
   10807         656 :             if (produceTabular) {
   10808         656 :                 if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
   10809           4 :                     state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(
   10810             :                         tableBodyTemp, rowHeadTemp, columnHeadTemp, "DemandEndUseComponentsSummary", "Entire Facility", "End Uses By Subcategory");
   10811             :                 }
   10812             :             }
   10813         656 :             rowHeadTemp.deallocate();
   10814         656 :             tableBodyTemp.deallocate();
   10815         656 :             columnHeadTemp.deallocate();
   10816             :         }
   10817             : 
   10818             :         // EAp2-4/5. Performance Rating Method Compliance
   10819        9184 :         for (iResource = 1; iResource <= 13; ++iResource) {
   10820      127920 :             for (int jEndUse = 1; jEndUse <= DataGlobalConstantsData::iEndUseSize; ++jEndUse) {
   10821      119392 :                 if (ort->needOtherRowLEED45(jEndUse)) {
   10822           0 :                     if (state.dataOutputProcessor->EndUseCategory(jEndUse).NumSubcategories == 0) {
   10823           0 :                         endUseSubOther(iResource, jEndUse) =
   10824           0 :                             collapsedIndEndUse(iResource, jEndUse); // often the case that no subcategories are defined
   10825             :                     } else {
   10826           0 :                         Real64 sumOfSubcategories = 0.;
   10827           0 :                         for (kEndUseSub = 1; kEndUseSub <= state.dataOutputProcessor->EndUseCategory(jEndUse).NumSubcategories; ++kEndUseSub) {
   10828           0 :                             sumOfSubcategories += collapsedIndEndUseSub(kEndUseSub, jEndUse, iResource);
   10829             :                         }
   10830           0 :                         endUseSubOther(iResource, jEndUse) = collapsedIndEndUse(iResource, jEndUse) - sumOfSubcategories;
   10831           0 :                         if (endUseSubOther(iResource, jEndUse) < 0.) {
   10832           0 :                             endUseSubOther(iResource, jEndUse) = 0.;
   10833             :                         }
   10834             :                     }
   10835             :                 }
   10836             :             }
   10837             :         }
   10838             : 
   10839        1312 :         Array1D_int resource_entry_map;
   10840         656 :         resource_entry_map.allocate(12);
   10841         656 :         resource_entry_map(1) = state.dataOutRptPredefined->pdchLeedPerfElDem;          // electricity
   10842         656 :         resource_entry_map(2) = state.dataOutRptPredefined->pdchLeedPerfGasDem;         // natural gas
   10843         656 :         resource_entry_map(3) = state.dataOutRptPredefined->pdchLeedPerfGasolineDem;    // gasoline
   10844         656 :         resource_entry_map(4) = state.dataOutRptPredefined->pdchLeedPerfDieselDem;      // diesel
   10845         656 :         resource_entry_map(5) = state.dataOutRptPredefined->pdchLeedPerfCoalDem;        // coal
   10846         656 :         resource_entry_map(6) = state.dataOutRptPredefined->pdchLeedPerfFuelOil1Dem;    // fuel oil no 1
   10847         656 :         resource_entry_map(7) = state.dataOutRptPredefined->pdchLeedPerfFuelOil2Dem;    // fuel oil no 2
   10848         656 :         resource_entry_map(8) = state.dataOutRptPredefined->pdchLeedPerfPropaneDem;     // propane
   10849         656 :         resource_entry_map(9) = state.dataOutRptPredefined->pdchLeedPerfOtherFuel1Dem;  // other fuel 1
   10850         656 :         resource_entry_map(10) = state.dataOutRptPredefined->pdchLeedPerfOtherFuel2Dem; // other fuel 2
   10851         656 :         resource_entry_map(11) = state.dataOutRptPredefined->pdchLeedPerfDisClDem;      // district cooling
   10852         656 :         resource_entry_map(12) = state.dataOutRptPredefined->pdchLeedPerfDisHtDem;      // district heating
   10853             : 
   10854        8528 :         for (iResource = 1; iResource <= 12; ++iResource) {
   10855        7872 :             i = 1;
   10856      118080 :             for (int jEndUse = 1; jEndUse <= DataGlobalConstantsData::iEndUseSize; ++jEndUse) {
   10857      110208 :                 if (state.dataOutputProcessor->EndUseCategory(jEndUse).NumSubcategories > 0) {
   10858      114156 :                     for (kEndUseSub = 1; kEndUseSub <= state.dataOutputProcessor->EndUseCategory(jEndUse).NumSubcategories; ++kEndUseSub) {
   10859      306120 :                         PreDefTableEntry(state,
   10860       61224 :                                          resource_entry_map(iResource),
   10861      122448 :                                          state.dataOutputProcessor->EndUseCategory(jEndUse).DisplayName + " -- " +
   10862       61224 :                                              state.dataOutputProcessor->EndUseCategory(jEndUse).SubcategoryName(kEndUseSub),
   10863       61224 :                                          collapsedIndEndUseSub(kEndUseSub, jEndUse, iResource));
   10864       61224 :                         ++i;
   10865             :                     }
   10866             :                     // put other
   10867       52932 :                     if (ort->needOtherRowLEED45(jEndUse)) {
   10868           0 :                         PreDefTableEntry(state,
   10869           0 :                                          resource_entry_map(iResource),
   10870           0 :                                          state.dataOutputProcessor->EndUseCategory(jEndUse).DisplayName + " -- Other",
   10871           0 :                                          endUseSubOther(iResource, jEndUse));
   10872           0 :                         ++i;
   10873             :                     }
   10874             :                 } else {
   10875      286380 :                     PreDefTableEntry(state,
   10876       57276 :                                      resource_entry_map(iResource),
   10877      114552 :                                      state.dataOutputProcessor->EndUseCategory(jEndUse).DisplayName + " -- Not Subdivided",
   10878       57276 :                                      collapsedIndEndUse(iResource, jEndUse));
   10879       57276 :                     ++i;
   10880             :                 }
   10881             :             }
   10882             :         }
   10883             :     }
   10884         731 : }
   10885             : 
   10886         731 : void WriteCompCostTable(EnergyPlusData &state)
   10887             : {
   10888             : 
   10889             :     // SUBROUTINE INFORMATION:
   10890             :     //       AUTHOR         BGriffith
   10891             :     //       DATE WRITTEN   April/May 2004
   10892             :     //       MODIFIED       January 2010, Kyle Benne
   10893             :     //                      Added SQLite output
   10894             :     //       RE-ENGINEERED  na
   10895             : 
   10896             :     // PURPOSE OF THIS SUBROUTINE:
   10897             :     // produce a results table from Cost Estimate Calculations
   10898             : 
   10899             :     // METHODOLOGY EMPLOYED:
   10900             :     // USE data from CostEstimateManager, call JGlazer's subroutines
   10901             : 
   10902             :     // REFERENCES:
   10903             :     // na
   10904             : 
   10905             :     // Using/Aliasing
   10906             : 
   10907             :     // Locals
   10908             :     // SUBROUTINE ARGUMENT DEFINITIONS:
   10909             :     // na
   10910             : 
   10911             :     // SUBROUTINE PARAMETER DEFINITIONS:
   10912             :     // na
   10913             : 
   10914             :     // INTERFACE BLOCK SPECIFICATIONS:
   10915             :     // na
   10916             : 
   10917             :     // DERIVED TYPE DEFINITIONS:
   10918             :     // na
   10919             : 
   10920             :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
   10921         769 :     Array2D<Real64> TableBodyData(3, 10);
   10922             :     Real64 RefBldgConstCost;   // holds interim value for construction component costs: reference bldg.
   10923             :     Real64 CurntBldgConstCost; // holds interim value for construction component costs: current bldg.
   10924         769 :     Array1D_string columnHead;
   10925         769 :     Array1D_int columnWidth;
   10926         769 :     Array1D_string rowHead;
   10927         769 :     Array2D_string tableBody;
   10928             :     int item;    // do-loop counter for line items
   10929             :     int NumRows; // number of rows in report table excluding table header
   10930             :     int NumCols; // number of columns in report table
   10931         769 :     std::string SIunit;
   10932         769 :     std::string m2_unitName;
   10933         769 :     std::string IPunitName;
   10934             :     Real64 IPqty;
   10935             :     Real64 IPsingleValue;
   10936             :     Real64 IPvaluePer;
   10937             : 
   10938         731 :     auto &ort(state.dataOutRptTab);
   10939             : 
   10940         731 :     if (!state.dataCostEstimateManager->DoCostEstimate) return;
   10941             : 
   10942          38 :     WriteReportHeaders(state, "Component Cost Economics Summary", "Entire Facility", OutputProcessor::StoreType::Averaged);
   10943             : 
   10944             :     // compute floor area if no ABUPS
   10945          38 :     if (ort->buildingConditionedFloorArea == 0.0) {
   10946           1 :         DetermineBuildingFloorArea(state);
   10947             :     }
   10948             : 
   10949          76 :     for (int iUnitSystem = 0; iUnitSystem <= 1; iUnitSystem++) {
   10950          76 :         UnitsStyle unitsStyle_cur = ort->unitsStyle;
   10951          76 :         bool produceTabular = true;
   10952          76 :         bool produceSQLite = false;
   10953          76 :         if (produceDualUnitsFlags(iUnitSystem, ort->unitsStyle, ort->unitsStyle_SQLite, unitsStyle_cur, produceTabular, produceSQLite)) break;
   10954             : 
   10955             :         // 1st sub-table with total Costs and normalized with area
   10956          38 :         rowHead.allocate(10);
   10957          38 :         columnHead.allocate(3);
   10958          38 :         columnWidth.allocate(3);
   10959          38 :         columnWidth = 14; // array assignment - same for all columns
   10960          38 :         tableBody.allocate(3, 10);
   10961             : 
   10962          38 :         columnHead(1) = "Reference Bldg.";
   10963          38 :         columnHead(2) = "Current Bldg. Model";
   10964          38 :         columnHead(3) = "Difference";
   10965             : 
   10966          38 :         rowHead(1) = "Line Item SubTotal (~~$~~)";
   10967          38 :         rowHead(2) = "Misc. Costs (~~$~~)";
   10968          38 :         rowHead(3) = "Regional Adjustment (~~$~~)";
   10969          38 :         rowHead(4) = "Design Fee (~~$~~)";
   10970          38 :         rowHead(5) = "Contractor Fee (~~$~~)";
   10971          38 :         rowHead(6) = "Contingency (~~$~~)";
   10972          38 :         rowHead(7) = "Permits, Bonds, Insurance (~~$~~)";
   10973          38 :         rowHead(8) = "Commissioning (~~$~~)";
   10974          38 :         rowHead(9) = "Cost Estimate Total (~~$~~)";
   10975          38 :         if (unitsStyle_cur == UnitsStyle::InchPound) {
   10976           0 :             SIunit = "[m2]";
   10977           0 :             LookupSItoIP(state, SIunit, state.dataOutRptTab->unitConvIndexWCCT, m2_unitName);
   10978           0 :             state.dataOutRptTab->m2_unitConv = ConvertIP(state, state.dataOutRptTab->unitConvIndexWCCT, 1.0);
   10979           0 :             rowHead(10) = "Cost Per Conditioned Building Area (~~$~~/ft2)";
   10980             :         } else {
   10981          38 :             rowHead(10) = "Cost Per Conditioned Building Area (~~$~~/m2)";
   10982          38 :             state.dataOutRptTab->m2_unitConv = 1.0;
   10983             :         }
   10984          38 :         TableBodyData = 0.0;
   10985          38 :         tableBody = "";
   10986             : 
   10987          38 :         TableBodyData(1, 1) = state.dataCostEstimateManager->RefrncBldg.LineItemTot;
   10988          38 :         tableBody(1, 1) = RealToStr(TableBodyData(1, 1), 2);
   10989          38 :         TableBodyData(1, 2) = state.dataCostEstimateManager->RefrncBldg.MiscCostperSqMeter * ort->buildingConditionedFloorArea;
   10990          38 :         tableBody(1, 2) = RealToStr(TableBodyData(1, 2), 2);
   10991             : 
   10992          38 :         if (state.dataCostEstimateManager->RefrncBldg.RegionalModifier != 1.0) {
   10993           3 :             TableBodyData(1, 3) = (state.dataCostEstimateManager->RefrncBldg.LineItemTot +
   10994           2 :                                    state.dataCostEstimateManager->RefrncBldg.MiscCostperSqMeter * ort->buildingConditionedFloorArea) *
   10995           1 :                                   (state.dataCostEstimateManager->RefrncBldg.RegionalModifier - 1.0);
   10996             :         } else {
   10997          37 :             TableBodyData(1, 3) = 0.0;
   10998             :         }
   10999             : 
   11000          38 :         RefBldgConstCost = sum(TableBodyData(1, {1, 3}));
   11001             : 
   11002          38 :         tableBody(1, 3) = RealToStr(TableBodyData(1, 3), 2);
   11003          38 :         TableBodyData(1, 4) = RefBldgConstCost * state.dataCostEstimateManager->RefrncBldg.DesignFeeFrac;
   11004          38 :         tableBody(1, 4) = RealToStr(TableBodyData(1, 4), 2);
   11005          38 :         TableBodyData(1, 5) = RefBldgConstCost * state.dataCostEstimateManager->RefrncBldg.ContractorFeeFrac;
   11006          38 :         tableBody(1, 5) = RealToStr(TableBodyData(1, 5), 2);
   11007          38 :         TableBodyData(1, 6) = RefBldgConstCost * state.dataCostEstimateManager->RefrncBldg.ContingencyFrac;
   11008          38 :         tableBody(1, 6) = RealToStr(TableBodyData(1, 6), 2);
   11009          38 :         TableBodyData(1, 7) = RefBldgConstCost * state.dataCostEstimateManager->RefrncBldg.BondCostFrac;
   11010          38 :         tableBody(1, 7) = RealToStr(TableBodyData(1, 7), 2);
   11011          38 :         TableBodyData(1, 8) = RefBldgConstCost * state.dataCostEstimateManager->RefrncBldg.CommissioningFrac;
   11012          38 :         tableBody(1, 8) = RealToStr(TableBodyData(1, 8), 2);
   11013          38 :         state.dataCostEstimateManager->RefrncBldg.GrandTotal = sum(TableBodyData(1, {1, 8}));
   11014          38 :         TableBodyData(1, 9) = state.dataCostEstimateManager->RefrncBldg.GrandTotal;
   11015          38 :         tableBody(1, 9) = RealToStr(TableBodyData(1, 9), 2);
   11016          38 :         if (ort->buildingConditionedFloorArea > 0.0) {
   11017          38 :             TableBodyData(1, 10) = TableBodyData(1, 9) / (ort->buildingConditionedFloorArea * state.dataOutRptTab->m2_unitConv);
   11018             :         }
   11019          38 :         tableBody(1, 10) = RealToStr(TableBodyData(1, 10), 2);
   11020             : 
   11021          38 :         TableBodyData(2, 1) = state.dataCostEstimateManager->CurntBldg.LineItemTot;
   11022          38 :         tableBody(2, 1) = RealToStr(TableBodyData(2, 1), 2);
   11023          38 :         TableBodyData(2, 2) = state.dataCostEstimateManager->CurntBldg.MiscCostperSqMeter * ort->buildingConditionedFloorArea;
   11024          38 :         tableBody(2, 2) = RealToStr(TableBodyData(2, 2), 2);
   11025          38 :         if (state.dataCostEstimateManager->CurntBldg.RegionalModifier != 1.0) {
   11026           3 :             TableBodyData(2, 3) = (state.dataCostEstimateManager->CurntBldg.LineItemTot +
   11027           2 :                                    state.dataCostEstimateManager->CurntBldg.MiscCostperSqMeter * ort->buildingConditionedFloorArea) *
   11028           1 :                                   (state.dataCostEstimateManager->CurntBldg.RegionalModifier - 1.0);
   11029             :         } else {
   11030          37 :             TableBodyData(2, 3) = 0.0;
   11031             :         }
   11032          38 :         tableBody(2, 3) = RealToStr(TableBodyData(2, 3), 2);
   11033             : 
   11034          38 :         CurntBldgConstCost = sum(TableBodyData(2, {1, 3}));
   11035             : 
   11036          38 :         TableBodyData(2, 4) = CurntBldgConstCost * state.dataCostEstimateManager->CurntBldg.DesignFeeFrac;
   11037          38 :         tableBody(2, 4) = RealToStr(TableBodyData(2, 4), 2);
   11038             : 
   11039          38 :         TableBodyData(2, 5) = CurntBldgConstCost * state.dataCostEstimateManager->CurntBldg.ContractorFeeFrac;
   11040          38 :         tableBody(2, 5) = RealToStr(TableBodyData(2, 5), 2);
   11041          38 :         TableBodyData(2, 6) = CurntBldgConstCost * state.dataCostEstimateManager->CurntBldg.ContingencyFrac;
   11042          38 :         tableBody(2, 6) = RealToStr(TableBodyData(2, 6), 2);
   11043          38 :         TableBodyData(2, 7) = CurntBldgConstCost * state.dataCostEstimateManager->CurntBldg.BondCostFrac;
   11044          38 :         tableBody(2, 7) = RealToStr(TableBodyData(2, 7), 2);
   11045          38 :         TableBodyData(2, 8) = CurntBldgConstCost * state.dataCostEstimateManager->CurntBldg.CommissioningFrac;
   11046          38 :         tableBody(2, 8) = RealToStr(TableBodyData(2, 8), 2);
   11047             : 
   11048          38 :         state.dataCostEstimateManager->CurntBldg.GrandTotal = sum(TableBodyData(2, {1, 8}));
   11049          38 :         TableBodyData(2, 9) = state.dataCostEstimateManager->CurntBldg.GrandTotal;
   11050          38 :         tableBody(2, 9) = RealToStr(TableBodyData(2, 9), 2);
   11051          38 :         if (ort->buildingConditionedFloorArea > 0) {
   11052          38 :             TableBodyData(2, 10) = TableBodyData(2, 9) / (ort->buildingConditionedFloorArea * state.dataOutRptTab->m2_unitConv);
   11053             :         }
   11054          38 :         tableBody(2, 10) = RealToStr(TableBodyData(2, 10), 2);
   11055             : 
   11056          38 :         TableBodyData(3, {1, 10}) = TableBodyData(2, {1, 10}) - TableBodyData(1, {1, 10});
   11057          38 :         tableBody(3, 1) = RealToStr(TableBodyData(3, 1), 2);
   11058          38 :         tableBody(3, 2) = RealToStr(TableBodyData(3, 2), 2);
   11059          38 :         tableBody(3, 3) = RealToStr(TableBodyData(3, 3), 2);
   11060          38 :         tableBody(3, 4) = RealToStr(TableBodyData(3, 4), 2);
   11061          38 :         tableBody(3, 5) = RealToStr(TableBodyData(3, 5), 2);
   11062          38 :         tableBody(3, 6) = RealToStr(TableBodyData(3, 6), 2);
   11063          38 :         tableBody(3, 7) = RealToStr(TableBodyData(3, 7), 2);
   11064          38 :         tableBody(3, 8) = RealToStr(TableBodyData(3, 8), 2);
   11065          38 :         tableBody(3, 9) = RealToStr(TableBodyData(3, 9), 2);
   11066          38 :         tableBody(3, 10) = RealToStr(TableBodyData(3, 10), 2);
   11067             : 
   11068          38 :         if (produceTabular) {
   11069          38 :             WriteSubtitle(state, "Construction Cost Estimate Summary");
   11070          38 :             WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
   11071             :         }
   11072          38 :         if (produceSQLite) {
   11073          38 :             if (state.dataSQLiteProcedures->sqlite) {
   11074           6 :                 state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
   11075             :                     tableBody, rowHead, columnHead, "Construction Cost Estimate Summary", "Entire Facility", "Construction Cost Estimate Summary");
   11076             :             }
   11077             :         }
   11078          38 :         if (produceTabular) {
   11079          38 :             if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
   11080           0 :                 state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(
   11081             :                     tableBody, rowHead, columnHead, "Construction Cost Estimate Summary", "Entire Facility", "Construction Cost Estimate Summary");
   11082             :             }
   11083             :         }
   11084             : 
   11085          38 :         NumRows = (int)state.dataCostEstimateManager->CostLineItem.size() + 1; // body will have the total and line items
   11086          38 :         NumCols = 6;                                                           // Line no., Line name, Qty, Units, ValperQty, Subtotal
   11087          38 :         rowHead.allocate(NumRows);
   11088          38 :         columnHead.allocate(NumCols);
   11089          38 :         columnWidth.dimension(NumCols, 14); // array assignment - same for all columns
   11090          38 :         tableBody.allocate(NumCols, NumRows);
   11091          38 :         tableBody = "--";                        // array init
   11092          38 :         rowHead = "--";                          // array init
   11093          38 :         rowHead(NumRows) = "Line Item SubTotal"; // last line in table will be a total
   11094             :         // setup up column headers
   11095          38 :         columnHead(1) = "Line No.";
   11096          38 :         columnHead(2) = "Item Name";
   11097          38 :         columnHead(3) = "Quantity.";
   11098          38 :         columnHead(4) = "Units";
   11099          38 :         columnHead(5) = "~~$~~ per Qty.";
   11100          38 :         columnHead(6) = "SubTotal ~~$~~";
   11101             : 
   11102          38 :         columnWidth = {7, 30, 16, 10, 16, 16}; // array assignment - for all columns
   11103             : 
   11104        2356 :         for (item = 1; item <= (int)state.dataCostEstimateManager->CostLineItem.size(); ++item) {
   11105        2318 :             tableBody(1, item) = fmt::to_string(state.dataCostEstimateManager->CostLineItem(item).LineNumber);
   11106        2318 :             tableBody(2, item) = state.dataCostEstimateManager->CostLineItem(item).LineName;
   11107        2318 :             if (unitsStyle_cur == UnitsStyle::InchPound) {
   11108           0 :                 LookupSItoIP(state, state.dataCostEstimateManager->CostLineItem(item).Units, state.dataOutRptTab->unitConvIndexWCCT, IPunitName);
   11109           0 :                 if (state.dataOutRptTab->unitConvIndexWCCT != 0) {
   11110           0 :                     IPqty = ConvertIP(state, state.dataOutRptTab->unitConvIndexWCCT, state.dataCostEstimateManager->CostLineItem(item).Qty);
   11111           0 :                     tableBody(3, item) = RealToStr(IPqty, 2);
   11112           0 :                     tableBody(4, item) = IPunitName;
   11113           0 :                     IPsingleValue = ConvertIP(state, state.dataOutRptTab->unitConvIndexWCCT, 1.0);
   11114           0 :                     if (IPsingleValue != 0.0) {
   11115           0 :                         IPvaluePer = state.dataCostEstimateManager->CostLineItem(item).ValuePer / IPsingleValue;
   11116           0 :                         tableBody(5, item) = RealToStr(IPvaluePer, 2);
   11117             :                     }
   11118             :                 } else {
   11119           0 :                     tableBody(3, item) = RealToStr(state.dataCostEstimateManager->CostLineItem(item).Qty, 2);
   11120           0 :                     tableBody(4, item) = state.dataCostEstimateManager->CostLineItem(item).Units;
   11121           0 :                     tableBody(5, item) = RealToStr(state.dataCostEstimateManager->CostLineItem(item).ValuePer, 2);
   11122             :                 }
   11123             :             } else {
   11124        2318 :                 tableBody(3, item) = RealToStr(state.dataCostEstimateManager->CostLineItem(item).Qty, 2);
   11125        2318 :                 tableBody(4, item) = state.dataCostEstimateManager->CostLineItem(item).Units;
   11126        2318 :                 tableBody(5, item) = RealToStr(state.dataCostEstimateManager->CostLineItem(item).ValuePer, 2);
   11127             :             }
   11128        2318 :             tableBody(6, item) = RealToStr(state.dataCostEstimateManager->CostLineItem(item).LineSubTotal, 2);
   11129             :         }
   11130          38 :         tableBody(6, NumRows) = RealToStr(state.dataCostEstimateManager->CurntBldg.LineItemTot, 2);
   11131          38 :         if (produceTabular) {
   11132          38 :             WriteSubtitle(state, "Cost Line Item Details"); //: '//TRIM(RealToStr(CostEstimateTotal, 2)))
   11133          38 :             WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
   11134             :         }
   11135          38 :         if (produceSQLite) {
   11136          38 :             if (state.dataSQLiteProcedures->sqlite) {
   11137           6 :                 state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
   11138             :                     tableBody, rowHead, columnHead, "Construction Cost Estimate Summary", "Entire Facility", "Cost Line Item Details");
   11139             :             }
   11140             :         }
   11141          38 :         if (produceTabular) {
   11142          38 :             if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
   11143           0 :                 state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(
   11144             :                     tableBody, rowHead, columnHead, "Construction Cost Estimate Summary", "Entire Facility", "Cost Line Item Details");
   11145             :             }
   11146             :         }
   11147             :     }
   11148             : }
   11149             : 
   11150             : // modify the ith row in the reportingperiod input verification table
   11151          11 : void writeRowReportPeriodInputVeri(const std::string reportType,
   11152             :                                    Array2D_string &tableBody,
   11153             :                                    const int rowid,
   11154             :                                    const int periodIdx,
   11155             :                                    const Array1D<WeatherManager::ReportPeriodData> &ReportPeriodInputData)
   11156             : {
   11157          11 :     tableBody(1, rowid) = reportType;
   11158          11 :     tableBody(2, rowid) = std::to_string(periodIdx);
   11159          11 :     tableBody(3, rowid) = ReportPeriodInputData(periodIdx).title;
   11160          11 :     tableBody(4, rowid) = formatReportPeriodTimestamp(ReportPeriodInputData(periodIdx).startYear,
   11161          11 :                                                       ReportPeriodInputData(periodIdx).startMonth,
   11162          11 :                                                       ReportPeriodInputData(periodIdx).startDay,
   11163          11 :                                                       ReportPeriodInputData(periodIdx).startHour);
   11164          11 :     tableBody(5, rowid) = formatReportPeriodTimestamp(ReportPeriodInputData(periodIdx).endYear,
   11165          11 :                                                       ReportPeriodInputData(periodIdx).endMonth,
   11166          11 :                                                       ReportPeriodInputData(periodIdx).endDay,
   11167          11 :                                                       ReportPeriodInputData(periodIdx).endHour);
   11168          11 :     tableBody(6, rowid) = RealToStr(ReportPeriodInputData(periodIdx).totalElectricityUse / 3600000.0, 2);
   11169          11 : }
   11170             : 
   11171         731 : void WriteVeriSumTable(EnergyPlusData &state)
   11172             : {
   11173             :     // SUBROUTINE INFORMATION:
   11174             :     //       AUTHOR         Jason Glazer
   11175             :     //       DATE WRITTEN   June 2006
   11176             :     //       MODIFIED       Jan. 2010, Kyle Benne. Added SQLite output
   11177             :     //                      Aug. 2015, Sang Hoon Lee. Added a new table for hybrid modeling multiplier output.
   11178             :     //       RE-ENGINEERED  na
   11179             : 
   11180             :     // PURPOSE OF THIS SUBROUTINE:
   11181             :     //   Summarize inputs and results for use with code and beyond-code
   11182             :     //   compliance into a tabular report for output.
   11183             : 
   11184             :     // METHODOLOGY EMPLOYED:
   11185             :     //   Create arrays for the call to WriteTable and then call it.
   11186             :     //   This report actually consists of many sub-tables each with
   11187             :     //   its own call to WriteTable.
   11188             : 
   11189             :     // Using/Aliasing
   11190             :     using DataHeatBalance::ZoneData;
   11191             :     using DataSurfaces::ExternalEnvironment;
   11192             :     using DataSurfaces::Ground;
   11193             :     using DataSurfaces::GroundFCfactorMethod;
   11194             :     using DataSurfaces::KivaFoundation;
   11195             :     using DataSurfaces::OtherSideCondModeledExt;
   11196             :     using DataSurfaces::SurfaceClass;
   11197             :     using General::SafeDivide;
   11198             :     using ScheduleManager::GetScheduleName;
   11199             :     using ScheduleManager::ScheduleAverageHoursPerWeek;
   11200             : 
   11201             :     // SUBROUTINE PARAMETER DEFINITIONS:
   11202         731 :     int constexpr wwrcTotal(1);
   11203         731 :     int constexpr wwrcNorth(2);
   11204         731 :     int constexpr wwrcEast(3);
   11205         731 :     int constexpr wwrcSouth(4);
   11206         731 :     int constexpr wwrcWest(5);
   11207         731 :     int constexpr wwrrWall(1);
   11208         731 :     int constexpr wwrrAbvGndWall(2);
   11209         731 :     int constexpr wwrrWindow(3);
   11210         731 :     int constexpr wwrrWWR(4);
   11211         731 :     int constexpr wwrrAbvGndWWR(5);
   11212             : 
   11213             :     // all arrays are in the format: (row, column)
   11214        1462 :     Array1D_string columnHead;
   11215        1462 :     Array1D_int columnWidth;
   11216        1462 :     Array1D_string rowHead;
   11217        1462 :     Array2D_string tableBody;
   11218             : 
   11219             :     int iSurf;
   11220             :     int kOpaque;
   11221             :     int zonePt;
   11222             :     int iLight;
   11223             :     int iZone;
   11224             :     int iPeople;
   11225             :     int iPlugProc;
   11226             :     int NumOfCol;
   11227             :     Real64 mult;
   11228             :     Real64 curAzimuth;
   11229             :     Real64 curArea;
   11230             :     Real64 wallAreaN;
   11231             :     Real64 wallAreaS;
   11232             :     Real64 wallAreaE;
   11233             :     Real64 wallAreaW;
   11234             :     Real64 aboveGroundWallAreaN;
   11235             :     Real64 aboveGroundWallAreaS;
   11236             :     Real64 aboveGroundWallAreaE;
   11237             :     Real64 aboveGroundWallAreaW;
   11238             :     Real64 windowAreaN;
   11239             :     Real64 windowAreaS;
   11240             :     Real64 windowAreaE;
   11241             :     Real64 windowAreaW;
   11242             :     // wall and window areas attached to conditioned zones
   11243             :     Real64 wallAreaNcond;
   11244             :     Real64 wallAreaScond;
   11245             :     Real64 wallAreaEcond;
   11246             :     Real64 wallAreaWcond;
   11247             :     Real64 aboveGroundWallAreaNcond;
   11248             :     Real64 aboveGroundWallAreaScond;
   11249             :     Real64 aboveGroundWallAreaEcond;
   11250             :     Real64 aboveGroundWallAreaWcond;
   11251             :     Real64 windowAreaNcond;
   11252             :     Real64 windowAreaScond;
   11253             :     Real64 windowAreaEcond;
   11254             :     Real64 windowAreaWcond;
   11255             :     bool isConditioned;
   11256             :     bool isAboveGround;
   11257             : 
   11258             :     Real64 roofArea;
   11259             :     Real64 skylightArea;
   11260             :     Real64 totLightPower;
   11261             :     Real64 totNumPeople;
   11262             :     Real64 totPlugProcess;
   11263             :     Real64 frameWidth;
   11264             :     Real64 frameArea;
   11265             : 
   11266             :     bool zoneIsCond;
   11267             :     bool usezoneFloorArea;
   11268             : 
   11269             :     int iTotal;
   11270        1462 :     std::string SIunit;
   11271             : 
   11272             :     // zone summary total
   11273             : 
   11274             :     // zstArea = 0.0;
   11275             :     // zstVolume = 0.0;
   11276             :     // zstWallArea = 0.0;
   11277             :     // zstUndWallArea = 0.0;
   11278             :     // zstWindowArea = 0.0;
   11279             :     // zstOpeningArea = 0.0;
   11280             :     // zstLight = 0.0;
   11281             :     // state.dataOutRptTab->zstPeople = 0.0;
   11282             :     // zstPlug = 0.0;
   11283             : 
   11284             :     // misc
   11285             :     Real64 pdiff;
   11286             :     bool DetailedWWR;
   11287             :     Real64 TotalWallArea;
   11288             :     Real64 TotalWindowArea;
   11289             :     Real64 TotalAboveGroundWallArea;
   11290             : 
   11291        1462 :     Array1D<Real64> zoneOpeningArea;
   11292         731 :     zoneOpeningArea.allocate(state.dataGlobal->NumOfZones);
   11293             :     // zoneOpeningArea = 0.0;
   11294             : 
   11295        1462 :     Array1D<Real64> zoneGlassArea;
   11296         731 :     zoneGlassArea.allocate(state.dataGlobal->NumOfZones);
   11297             :     // zoneGlassArea = 0.0;
   11298         731 :     auto &ort(state.dataOutRptTab);
   11299         731 :     auto &Zone(state.dataHeatBal->Zone);
   11300             : 
   11301             :     // all arrays are in the format: (row, columnm)
   11302         731 :     if (ort->displayTabularVeriSum) {
   11303             : 
   11304        1442 :         for (int iUnitSystem = 0; iUnitSystem <= 1; iUnitSystem++) {
   11305        1442 :             UnitsStyle unitsStyle_cur = ort->unitsStyle;
   11306        1442 :             bool produceTabular = true;
   11307        1442 :             bool produceSQLite = false;
   11308        1442 :             if (produceDualUnitsFlags(iUnitSystem, ort->unitsStyle, ort->unitsStyle_SQLite, unitsStyle_cur, produceTabular, produceSQLite)) break;
   11309             : 
   11310             :             // show the headers of the report
   11311         721 :             if (produceTabular) {
   11312         721 :                 WriteReportHeaders(state, "Input Verification and Results Summary", "Entire Facility", OutputProcessor::StoreType::Averaged);
   11313             :             }
   11314             : 
   11315             :             // Moved these initializations into the loop
   11316         721 :             state.dataOutRptTab->zstArea = 0.0;
   11317         721 :             state.dataOutRptTab->zstVolume = 0.0;
   11318         721 :             state.dataOutRptTab->zstWallArea = 0.0;
   11319         721 :             state.dataOutRptTab->zstUndWallArea = 0.0;
   11320         721 :             state.dataOutRptTab->zstWindowArea = 0.0;
   11321         721 :             state.dataOutRptTab->zstOpeningArea = 0.0;
   11322         721 :             state.dataOutRptTab->zstLight = 0.0;
   11323         721 :             state.dataOutRptTab->zstPeople = 0.0;
   11324         721 :             state.dataOutRptTab->zstPlug = 0.0;
   11325             : 
   11326         721 :             zoneOpeningArea = 0.0;
   11327             : 
   11328         721 :             zoneGlassArea = 0.0;
   11329             : 
   11330             :             // do unit conversions if necessary
   11331         721 :             if (unitsStyle_cur == UnitsStyle::InchPound) {
   11332          11 :                 SIunit = "[m]";
   11333          11 :                 LookupSItoIP(state, SIunit, state.dataOutRptTab->unitConvIndexWVST, state.dataOutRptTab->m_unitName);
   11334          11 :                 state.dataOutRptTab->m_unitConv = ConvertIP(state, state.dataOutRptTab->unitConvIndexWVST, 1.0);
   11335          11 :                 SIunit = "[m2]";
   11336          11 :                 LookupSItoIP(state, SIunit, state.dataOutRptTab->unitConvIndexWVST, state.dataOutRptTab->m2_unitName);
   11337          11 :                 state.dataOutRptTab->m2_unitConvWVST = ConvertIP(state, state.dataOutRptTab->unitConvIndexWVST, 1.0);
   11338          11 :                 SIunit = "[m3]";
   11339          11 :                 LookupSItoIP(state, SIunit, state.dataOutRptTab->unitConvIndexWVST, state.dataOutRptTab->m3_unitName);
   11340          11 :                 state.dataOutRptTab->m3_unitConv = ConvertIP(state, state.dataOutRptTab->unitConvIndexWVST, 1.0);
   11341          11 :                 SIunit = "[W/m2]";
   11342          11 :                 LookupSItoIP(state, SIunit, state.dataOutRptTab->unitConvIndexWVST, state.dataOutRptTab->Wm2_unitName);
   11343          11 :                 state.dataOutRptTab->Wm2_unitConv = ConvertIP(state, state.dataOutRptTab->unitConvIndexWVST, 1.0);
   11344             :             } else {
   11345         710 :                 state.dataOutRptTab->m_unitName = "[m]";
   11346         710 :                 state.dataOutRptTab->m_unitConv = 1.0;
   11347         710 :                 state.dataOutRptTab->m2_unitName = "[m2]";
   11348         710 :                 state.dataOutRptTab->m2_unitConvWVST = 1.0;
   11349         710 :                 state.dataOutRptTab->m3_unitName = "[m3]";
   11350         710 :                 state.dataOutRptTab->m3_unitConv = 1.0;
   11351         710 :                 state.dataOutRptTab->Wm2_unitName = "[W/m2]";
   11352         710 :                 state.dataOutRptTab->Wm2_unitConv = 1.0;
   11353             :             }
   11354             :             //---- General Sub-Table
   11355             : 
   11356             :             // since a variable number of design days is possible, first read them before sizing the arrays
   11357         721 :             rowHead.allocate(10);
   11358         721 :             columnHead.allocate(1);
   11359         721 :             columnWidth.allocate(1);
   11360         721 :             columnWidth = 14; // array assignment - same for all columns
   11361         721 :             tableBody.allocate(1, 10);
   11362             : 
   11363         721 :             columnHead(1) = "Value";
   11364         721 :             rowHead(1) = "Program Version and Build";
   11365         721 :             rowHead(2) = "RunPeriod";
   11366         721 :             rowHead(3) = "Weather File";
   11367         721 :             rowHead(4) = "Latitude [deg]";
   11368         721 :             rowHead(5) = "Longitude [deg]";
   11369             : 
   11370         721 :             rowHead(6) = "Elevation " + state.dataOutRptTab->m_unitName;
   11371         721 :             rowHead(7) = "Time Zone";
   11372         721 :             rowHead(8) = "North Axis Angle [deg]";
   11373         721 :             rowHead(9) = "Rotation for Appendix G [deg]";
   11374         721 :             rowHead(10) = "Hours Simulated [hrs]";
   11375             :             //  rowHead(9)  = 'Num Table Entries' !used for debugging
   11376             : 
   11377         721 :             tableBody = "";
   11378             : 
   11379         721 :             tableBody(1, 1) = state.dataStrGlobals->VerStringVar;                                         // program
   11380         721 :             tableBody(1, 2) = state.dataEnvrn->EnvironmentName;                                           // runperiod name
   11381         721 :             tableBody(1, 3) = state.dataEnvrn->WeatherFileLocationTitle;                                  // weather
   11382         721 :             tableBody(1, 4) = RealToStr(state.dataEnvrn->Latitude, 2);                                    // latitude
   11383         721 :             tableBody(1, 5) = RealToStr(state.dataEnvrn->Longitude, 2);                                   // longitude
   11384         721 :             tableBody(1, 6) = RealToStr(state.dataEnvrn->Elevation * state.dataOutRptTab->m_unitConv, 2); // Elevation
   11385         721 :             tableBody(1, 7) = RealToStr(state.dataEnvrn->TimeZoneNumber, 2);                              // Time Zone
   11386         721 :             tableBody(1, 8) = RealToStr(state.dataHeatBal->BuildingAzimuth, 2);                           // north axis angle
   11387         721 :             tableBody(1, 9) = RealToStr(state.dataHeatBal->BuildingRotationAppendixG, 2);                 // Rotation for Appendix G
   11388         721 :             tableBody(1, 10) = RealToStr(ort->gatherElapsedTimeBEPS, 2);                                  // hours simulated
   11389             :             //  tableBody(9,1) = TRIM(fmt::to_string(numTableEntry)) !number of table entries for predefined tables
   11390             : 
   11391         721 :             if (produceTabular) {
   11392         721 :                 WriteSubtitle(state, "General");
   11393         721 :                 WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
   11394             :             }
   11395         721 :             if (produceSQLite) {
   11396         721 :                 if (state.dataSQLiteProcedures->sqlite) {
   11397         114 :                     state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
   11398             :                         tableBody, rowHead, columnHead, "InputVerificationandResultsSummary", "Entire Facility", "General");
   11399             :                 }
   11400             :             }
   11401         721 :             if (produceTabular) {
   11402         721 :                 if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
   11403           5 :                     state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(
   11404             :                         tableBody, rowHead, columnHead, "InputVerificationandResultsSummary", "Entire Facility", "General");
   11405             :                 }
   11406             :             }
   11407             : 
   11408             :             //---- Window Wall Ratio Sub-Table
   11409         721 :             if (produceTabular) {
   11410         721 :                 WriteTextLine(state, "ENVELOPE", true);
   11411             :             }
   11412             : 
   11413         721 :             rowHead.allocate(5);
   11414         721 :             columnHead.allocate(5);
   11415         721 :             columnWidth.allocate(5);
   11416         721 :             columnWidth = 14; // array assignment - same for all columns
   11417         721 :             tableBody.allocate(5, 5);
   11418             : 
   11419         721 :             columnHead(wwrcTotal) = "Total";
   11420         721 :             columnHead(wwrcNorth) = "North (315 to 45 deg)";
   11421         721 :             columnHead(wwrcEast) = "East (45 to 135 deg)";
   11422         721 :             columnHead(wwrcSouth) = "South (135 to 225 deg)";
   11423         721 :             columnHead(wwrcWest) = "West (225 to 315 deg)";
   11424             : 
   11425         721 :             rowHead(wwrrWall) = "Gross Wall Area " + state.dataOutRptTab->m2_unitName;
   11426         721 :             rowHead(wwrrAbvGndWall) = "Above Ground Wall Area " + state.dataOutRptTab->m2_unitName;
   11427         721 :             rowHead(wwrrWindow) = "Window Opening Area " + state.dataOutRptTab->m2_unitName;
   11428         721 :             rowHead(wwrrWWR) = "Gross Window-Wall Ratio [%]";
   11429         721 :             rowHead(wwrrAbvGndWWR) = "Above Ground Window-Wall Ratio [%]";
   11430             : 
   11431         721 :             wallAreaN = 0.0;
   11432         721 :             wallAreaS = 0.0;
   11433         721 :             wallAreaE = 0.0;
   11434         721 :             wallAreaW = 0.0;
   11435         721 :             aboveGroundWallAreaN = 0.0;
   11436         721 :             aboveGroundWallAreaS = 0.0;
   11437         721 :             aboveGroundWallAreaE = 0.0;
   11438         721 :             aboveGroundWallAreaW = 0.0;
   11439         721 :             windowAreaN = 0.0;
   11440         721 :             windowAreaS = 0.0;
   11441         721 :             windowAreaE = 0.0;
   11442         721 :             windowAreaW = 0.0;
   11443         721 :             wallAreaNcond = 0.0;
   11444         721 :             wallAreaScond = 0.0;
   11445         721 :             wallAreaEcond = 0.0;
   11446         721 :             wallAreaWcond = 0.0;
   11447         721 :             aboveGroundWallAreaNcond = 0.0;
   11448         721 :             aboveGroundWallAreaScond = 0.0;
   11449         721 :             aboveGroundWallAreaEcond = 0.0;
   11450         721 :             aboveGroundWallAreaWcond = 0.0;
   11451         721 :             windowAreaNcond = 0.0;
   11452         721 :             windowAreaScond = 0.0;
   11453         721 :             windowAreaEcond = 0.0;
   11454         721 :             windowAreaWcond = 0.0;
   11455         721 :             roofArea = 0.0;
   11456         721 :             skylightArea = 0.0;
   11457         721 :             totLightPower = 0.0;
   11458         721 :             totNumPeople = 0.0;
   11459         721 :             totPlugProcess = 0.0;
   11460         721 :             kOpaque = 0;
   11461             : 
   11462         721 :             DetailedWWR = (state.dataInputProcessing->inputProcessor->getNumSectionsFound("DETAILEDWWR_DEBUG") > 0);
   11463         721 :             if (DetailedWWR) {
   11464           0 :                 if (produceTabular) {
   11465           0 :                     print(state.files.debug, "{}\n", "======90.1 Classification [>=60 & <=120] tilt = wall==================");
   11466           0 :                     print(state.files.debug, "{}\n", "SurfName,Class,Area,Tilt");
   11467             :                 }
   11468             :             }
   11469             : 
   11470       43057 :             for (iSurf = 1; iSurf <= state.dataSurface->TotSurfaces; ++iSurf) {
   11471             :                 // only exterior surfaces including underground
   11472       42336 :                 if (!state.dataSurface->Surface(iSurf).HeatTransSurf) continue;
   11473       65393 :                 isAboveGround = (state.dataSurface->Surface(iSurf).ExtBoundCond == ExternalEnvironment) ||
   11474       24462 :                                 (state.dataSurface->Surface(iSurf).ExtBoundCond == OtherSideCondModeledExt);
   11475       87751 :                 if (isAboveGround || (state.dataSurface->Surface(iSurf).ExtBoundCond == Ground) ||
   11476       85552 :                     (state.dataSurface->Surface(iSurf).ExtBoundCond == GroundFCfactorMethod) ||
   11477       22221 :                     (state.dataSurface->Surface(iSurf).ExtBoundCond == KivaFoundation)) {
   11478       18748 :                     curAzimuth = state.dataSurface->Surface(iSurf).Azimuth;
   11479             :                     // Round to two decimals, like the display in tables
   11480       18748 :                     curAzimuth = round(curAzimuth * 100.0) / 100.0;
   11481       18748 :                     curArea = state.dataSurface->Surface(iSurf).GrossArea;
   11482       18748 :                     if (state.dataSurface->Surface(iSurf).FrameDivider != 0) {
   11483         376 :                         frameWidth = state.dataSurface->FrameDivider(state.dataSurface->Surface(iSurf).FrameDivider).FrameWidth;
   11484        1128 :                         frameArea = (state.dataSurface->Surface(iSurf).Height + 2.0 * frameWidth) *
   11485         376 :                                         (state.dataSurface->Surface(iSurf).Width + 2.0 * frameWidth) -
   11486         376 :                                     (state.dataSurface->Surface(iSurf).Height * state.dataSurface->Surface(iSurf).Width);
   11487         376 :                         curArea += frameArea;
   11488             :                     }
   11489       18748 :                     zonePt = state.dataSurface->Surface(iSurf).Zone;
   11490       18748 :                     isConditioned = false;
   11491       18748 :                     if (zonePt > 0) {
   11492       18747 :                         if (Zone(zonePt).SystemZoneNodeNumber > 0) {
   11493       16292 :                             isConditioned = true;
   11494             :                         }
   11495             :                     }
   11496       18748 :                     if ((state.dataSurface->Surface(iSurf).Tilt >= 60.0) && (state.dataSurface->Surface(iSurf).Tilt <= 120.0)) {
   11497             :                         // vertical walls and windows
   11498       14088 :                         switch (state.dataSurface->Surface(iSurf).Class) {
   11499        8335 :                         case SurfaceClass::Wall:
   11500             :                         case SurfaceClass::Floor:
   11501             :                         case SurfaceClass::Roof: {
   11502        8335 :                             mult = Zone(zonePt).Multiplier * Zone(zonePt).ListMultiplier;
   11503        8335 :                             if ((curAzimuth >= 315.0) || (curAzimuth < 45.0)) {
   11504        2159 :                                 wallAreaN += curArea * mult;
   11505        2159 :                                 if (isConditioned) wallAreaNcond += curArea * mult;
   11506        4318 :                                 if (isAboveGround) {
   11507        2116 :                                     aboveGroundWallAreaN += curArea * mult;
   11508        2116 :                                     if (isConditioned) aboveGroundWallAreaNcond += curArea * mult;
   11509             :                                 }
   11510        6176 :                             } else if ((curAzimuth >= 45.0) && (curAzimuth < 135.0)) {
   11511        1974 :                                 wallAreaE += curArea * mult;
   11512        1974 :                                 if (isConditioned) wallAreaEcond += curArea * mult;
   11513        3948 :                                 if (isAboveGround) {
   11514        1932 :                                     aboveGroundWallAreaE += curArea * mult;
   11515        1932 :                                     if (isConditioned) aboveGroundWallAreaEcond += curArea * mult;
   11516             :                                 }
   11517        4202 :                             } else if ((curAzimuth >= 135.0) && (curAzimuth < 225.0)) {
   11518        2159 :                                 wallAreaS += curArea * mult;
   11519        2159 :                                 if (isConditioned) wallAreaScond += curArea * mult;
   11520        4318 :                                 if (isAboveGround) {
   11521        2116 :                                     aboveGroundWallAreaS += curArea * mult;
   11522        2116 :                                     if (isConditioned) aboveGroundWallAreaScond += curArea * mult;
   11523             :                                 }
   11524        2043 :                             } else if ((curAzimuth >= 225.0) && (curAzimuth < 315.0)) {
   11525        2043 :                                 wallAreaW += curArea * mult;
   11526        2043 :                                 if (isConditioned) wallAreaWcond += curArea * mult;
   11527        2043 :                                 if (isAboveGround) {
   11528        2002 :                                     aboveGroundWallAreaW += curArea * mult;
   11529        2002 :                                     if (isConditioned) aboveGroundWallAreaWcond += curArea * mult;
   11530             :                                 }
   11531             :                             }
   11532        8335 :                             if (DetailedWWR) {
   11533           0 :                                 if (produceTabular) {
   11534           0 :                                     print(state.files.debug,
   11535             :                                           "{},Wall,{:.1R},{:.1R}\n",
   11536           0 :                                           state.dataSurface->Surface(iSurf).Name,
   11537           0 :                                           curArea * mult,
   11538           0 :                                           state.dataSurface->Surface(iSurf).Tilt);
   11539             :                                 }
   11540             :                             }
   11541        8335 :                         } break;
   11542        5370 :                         case SurfaceClass::Window:
   11543             :                         case SurfaceClass::TDD_Dome: {
   11544        5370 :                             mult = Zone(zonePt).Multiplier * Zone(zonePt).ListMultiplier * state.dataSurface->Surface(iSurf).Multiplier;
   11545        5370 :                             if ((curAzimuth >= 315.0) || (curAzimuth < 45.0)) {
   11546        1357 :                                 windowAreaN += curArea * mult;
   11547        1357 :                                 if (isConditioned) windowAreaNcond += curArea * mult;
   11548        4013 :                             } else if ((curAzimuth >= 45.0) && (curAzimuth < 135.0)) {
   11549         976 :                                 windowAreaE += curArea * mult;
   11550         976 :                                 if (isConditioned) windowAreaEcond += curArea * mult;
   11551        3037 :                             } else if ((curAzimuth >= 135.0) && (curAzimuth < 225.0)) {
   11552        2065 :                                 windowAreaS += curArea * mult;
   11553        2065 :                                 if (isConditioned) windowAreaScond += curArea * mult;
   11554         972 :                             } else if ((curAzimuth >= 225.0) && (curAzimuth < 315.0)) {
   11555         972 :                                 windowAreaW += curArea * mult;
   11556         972 :                                 if (isConditioned) windowAreaWcond += curArea * mult;
   11557             :                             }
   11558        5370 :                             zoneOpeningArea(zonePt) +=
   11559        5370 :                                 curArea *
   11560        5370 :                                 state.dataSurface->Surface(iSurf).Multiplier; // total window opening area for each zone (glass plus frame area)
   11561        5370 :                             zoneGlassArea(zonePt) += state.dataSurface->Surface(iSurf).GrossArea * state.dataSurface->Surface(iSurf).Multiplier;
   11562        5370 :                             if (DetailedWWR) {
   11563           0 :                                 if (produceTabular) {
   11564           0 :                                     print(state.files.debug,
   11565             :                                           "{},Window,{:.1R},{:.1R}\n",
   11566           0 :                                           state.dataSurface->Surface(iSurf).Name,
   11567           0 :                                           curArea * mult,
   11568           0 :                                           state.dataSurface->Surface(iSurf).Tilt);
   11569             :                                 }
   11570             :                             }
   11571        5370 :                         } break;
   11572         383 :                         default:
   11573         383 :                             break;
   11574             :                         }
   11575        4660 :                     } else if (state.dataSurface->Surface(iSurf).Tilt < 60.0) { // roof and skylights
   11576        2480 :                         switch (state.dataSurface->Surface(iSurf).Class) {
   11577        2090 :                         case SurfaceClass::Wall:
   11578             :                         case SurfaceClass::Floor:
   11579             :                         case SurfaceClass::Roof: {
   11580        2090 :                             mult = Zone(zonePt).Multiplier * Zone(zonePt).ListMultiplier;
   11581        2090 :                             roofArea += curArea * mult;
   11582        2090 :                             if (DetailedWWR) {
   11583           0 :                                 if (produceTabular) {
   11584           0 :                                     print(state.files.debug,
   11585             :                                           "{},Roof,{:.1R},{:.1R}\n",
   11586           0 :                                           state.dataSurface->Surface(iSurf).Name,
   11587           0 :                                           curArea * mult,
   11588           0 :                                           state.dataSurface->Surface(iSurf).Tilt);
   11589             :                                 }
   11590             :                             }
   11591        2090 :                         } break;
   11592         389 :                         case SurfaceClass::Window:
   11593             :                         case SurfaceClass::TDD_Dome: {
   11594         389 :                             mult = Zone(zonePt).Multiplier * Zone(zonePt).ListMultiplier * state.dataSurface->Surface(iSurf).Multiplier;
   11595         389 :                             skylightArea += curArea * mult;
   11596         389 :                             if (DetailedWWR) {
   11597           0 :                                 if (produceTabular) {
   11598           0 :                                     print(state.files.debug,
   11599             :                                           "{},Skylight,{:.1R},{:.1R}\n",
   11600           0 :                                           state.dataSurface->Surface(iSurf).Name,
   11601           0 :                                           curArea * mult,
   11602           0 :                                           state.dataSurface->Surface(iSurf).Tilt);
   11603             :                                 }
   11604             :                             }
   11605         389 :                         } break;
   11606           1 :                         default:
   11607           1 :                             break;
   11608             :                         }
   11609             :                     } else { // floors
   11610             :                              // ignored
   11611             :                     }
   11612             :                 }
   11613             :             }
   11614             : 
   11615         721 :             TotalWallArea = wallAreaN + wallAreaS + wallAreaE + wallAreaW;
   11616         721 :             TotalAboveGroundWallArea = aboveGroundWallAreaN + aboveGroundWallAreaS + aboveGroundWallAreaE + aboveGroundWallAreaW;
   11617         721 :             TotalWindowArea = windowAreaN + windowAreaS + windowAreaE + windowAreaW;
   11618         721 :             if (DetailedWWR) {
   11619           0 :                 if (produceTabular) {
   11620           0 :                     print(state.files.debug, "{}\n", "========================");
   11621           0 :                     print(state.files.debug, "{}\n", "TotalWallArea,WallAreaN,WallAreaS,WallAreaE,WallAreaW");
   11622           0 :                     print(state.files.debug, "{}\n", "TotalWindowArea,WindowAreaN,WindowAreaS,WindowAreaE,WindowAreaW");
   11623           0 :                     print(state.files.debug, "{:.2R},{:.2R},{:.2R},{:.2R},{:.2R}\n", TotalWallArea, wallAreaN, wallAreaS, wallAreaE, wallAreaW);
   11624           0 :                     print(state.files.debug,
   11625             :                           "{:.2R},{:.2R},{:.2R},{:.2R},{:.2R}\n",
   11626             :                           TotalWindowArea,
   11627             :                           windowAreaN,
   11628             :                           windowAreaS,
   11629             :                           windowAreaE,
   11630           0 :                           windowAreaW);
   11631             :                 }
   11632             :             }
   11633             : 
   11634         721 :             tableBody = "";
   11635             : 
   11636         721 :             tableBody(wwrcNorth, wwrrWall) = RealToStr(wallAreaN * state.dataOutRptTab->m2_unitConvWVST, 2);
   11637         721 :             tableBody(wwrcSouth, wwrrWall) = RealToStr(wallAreaS * state.dataOutRptTab->m2_unitConvWVST, 2);
   11638         721 :             tableBody(wwrcEast, wwrrWall) = RealToStr(wallAreaE * state.dataOutRptTab->m2_unitConvWVST, 2);
   11639         721 :             tableBody(wwrcWest, wwrrWall) = RealToStr(wallAreaW * state.dataOutRptTab->m2_unitConvWVST, 2);
   11640         721 :             tableBody(wwrcTotal, wwrrWall) = RealToStr(TotalWallArea * state.dataOutRptTab->m2_unitConvWVST, 2);
   11641             : 
   11642         721 :             tableBody(wwrcNorth, wwrrAbvGndWall) = RealToStr(aboveGroundWallAreaN * state.dataOutRptTab->m2_unitConvWVST, 2);
   11643         721 :             tableBody(wwrcSouth, wwrrAbvGndWall) = RealToStr(aboveGroundWallAreaS * state.dataOutRptTab->m2_unitConvWVST, 2);
   11644         721 :             tableBody(wwrcEast, wwrrAbvGndWall) = RealToStr(aboveGroundWallAreaE * state.dataOutRptTab->m2_unitConvWVST, 2);
   11645         721 :             tableBody(wwrcWest, wwrrAbvGndWall) = RealToStr(aboveGroundWallAreaW * state.dataOutRptTab->m2_unitConvWVST, 2);
   11646         721 :             tableBody(wwrcTotal, wwrrAbvGndWall) = RealToStr(TotalAboveGroundWallArea * state.dataOutRptTab->m2_unitConvWVST, 2);
   11647             : 
   11648         721 :             tableBody(wwrcNorth, wwrrWindow) = RealToStr(windowAreaN * state.dataOutRptTab->m2_unitConvWVST, 2);
   11649         721 :             tableBody(wwrcSouth, wwrrWindow) = RealToStr(windowAreaS * state.dataOutRptTab->m2_unitConvWVST, 2);
   11650         721 :             tableBody(wwrcEast, wwrrWindow) = RealToStr(windowAreaE * state.dataOutRptTab->m2_unitConvWVST, 2);
   11651         721 :             tableBody(wwrcWest, wwrrWindow) = RealToStr(windowAreaW * state.dataOutRptTab->m2_unitConvWVST, 2);
   11652         721 :             tableBody(wwrcTotal, wwrrWindow) = RealToStr(TotalWindowArea * state.dataOutRptTab->m2_unitConvWVST, 2);
   11653             : 
   11654         721 :             tableBody(wwrcNorth, wwrrWWR) = RealToStr(100.0 * SafeDivide(windowAreaN, wallAreaN), 2);
   11655         721 :             tableBody(wwrcSouth, wwrrWWR) = RealToStr(100.0 * SafeDivide(windowAreaS, wallAreaS), 2);
   11656         721 :             tableBody(wwrcEast, wwrrWWR) = RealToStr(100.0 * SafeDivide(windowAreaE, wallAreaE), 2);
   11657         721 :             tableBody(wwrcWest, wwrrWWR) = RealToStr(100.0 * SafeDivide(windowAreaW, wallAreaW), 2);
   11658         721 :             tableBody(wwrcTotal, wwrrWWR) = RealToStr(100.0 * SafeDivide(TotalWindowArea, TotalWallArea), 2);
   11659             : 
   11660         721 :             tableBody(wwrcNorth, wwrrAbvGndWWR) = RealToStr(100.0 * SafeDivide(windowAreaN, aboveGroundWallAreaN), 2);
   11661         721 :             tableBody(wwrcSouth, wwrrAbvGndWWR) = RealToStr(100.0 * SafeDivide(windowAreaS, aboveGroundWallAreaS), 2);
   11662         721 :             tableBody(wwrcEast, wwrrAbvGndWWR) = RealToStr(100.0 * SafeDivide(windowAreaE, aboveGroundWallAreaE), 2);
   11663         721 :             tableBody(wwrcWest, wwrrAbvGndWWR) = RealToStr(100.0 * SafeDivide(windowAreaW, aboveGroundWallAreaW), 2);
   11664         721 :             tableBody(wwrcTotal, wwrrAbvGndWWR) = RealToStr(100.0 * SafeDivide(TotalWindowArea, TotalAboveGroundWallArea), 2);
   11665             : 
   11666         721 :             if (produceTabular) {
   11667         721 :                 WriteSubtitle(state, "Window-Wall Ratio");
   11668         721 :                 WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
   11669             :             }
   11670         721 :             if (produceSQLite) {
   11671         721 :                 if (state.dataSQLiteProcedures->sqlite) {
   11672         114 :                     state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
   11673             :                         tableBody, rowHead, columnHead, "InputVerificationandResultsSummary", "Entire Facility", "Window-Wall Ratio");
   11674             :                 }
   11675             :             }
   11676         721 :             if (produceTabular) {
   11677         721 :                 if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
   11678           5 :                     state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(
   11679             :                         tableBody, rowHead, columnHead, "InputVerificationandResultsSummary", "Entire Facility", "Window-Wall Ratio");
   11680             :                 }
   11681             :             }
   11682             : 
   11683             :             //---- Conditioned Window Wall Ratio Sub-Table
   11684         721 :             rowHead.allocate(5);
   11685         721 :             columnHead.allocate(5);
   11686         721 :             columnWidth.allocate(5);
   11687         721 :             columnWidth = 14; // array assignment - same for all columns
   11688         721 :             tableBody.allocate(5, 5);
   11689             : 
   11690         721 :             columnHead(wwrcTotal) = "Total";
   11691         721 :             columnHead(wwrcNorth) = "North (315 to 45 deg)";
   11692         721 :             columnHead(wwrcEast) = "East (45 to 135 deg)";
   11693         721 :             columnHead(wwrcSouth) = "South (135 to 225 deg)";
   11694         721 :             columnHead(wwrcWest) = "West (225 to 315 deg)";
   11695             : 
   11696         721 :             rowHead(wwrrWall) = "Gross Wall Area " + state.dataOutRptTab->m2_unitName;
   11697         721 :             rowHead(wwrrAbvGndWall) = "Above Ground Wall Area " + state.dataOutRptTab->m2_unitName;
   11698         721 :             rowHead(wwrrWindow) = "Window Opening Area " + state.dataOutRptTab->m2_unitName;
   11699         721 :             rowHead(wwrrWWR) = "Gross Window-Wall Ratio [%]";
   11700         721 :             rowHead(wwrrAbvGndWWR) = "Above Ground Window-Wall Ratio [%]";
   11701             : 
   11702             :             // calculations appear in last block with normal window-wall ratio table
   11703             : 
   11704         721 :             TotalWallArea = wallAreaNcond + wallAreaScond + wallAreaEcond + wallAreaWcond;
   11705         721 :             TotalAboveGroundWallArea = aboveGroundWallAreaNcond + aboveGroundWallAreaScond + aboveGroundWallAreaEcond + aboveGroundWallAreaWcond;
   11706         721 :             TotalWindowArea = windowAreaNcond + windowAreaScond + windowAreaEcond + windowAreaWcond;
   11707             : 
   11708         721 :             tableBody = "";
   11709             : 
   11710         721 :             tableBody(wwrcNorth, wwrrWall) = RealToStr(wallAreaNcond * state.dataOutRptTab->m2_unitConvWVST, 2);
   11711         721 :             tableBody(wwrcSouth, wwrrWall) = RealToStr(wallAreaScond * state.dataOutRptTab->m2_unitConvWVST, 2);
   11712         721 :             tableBody(wwrcEast, wwrrWall) = RealToStr(wallAreaEcond * state.dataOutRptTab->m2_unitConvWVST, 2);
   11713         721 :             tableBody(wwrcWest, wwrrWall) = RealToStr(wallAreaWcond * state.dataOutRptTab->m2_unitConvWVST, 2);
   11714         721 :             tableBody(wwrcTotal, wwrrWall) = RealToStr(TotalWallArea * state.dataOutRptTab->m2_unitConvWVST, 2);
   11715             : 
   11716         721 :             tableBody(wwrcNorth, wwrrAbvGndWall) = RealToStr(aboveGroundWallAreaNcond * state.dataOutRptTab->m2_unitConvWVST, 2);
   11717         721 :             tableBody(wwrcSouth, wwrrAbvGndWall) = RealToStr(aboveGroundWallAreaScond * state.dataOutRptTab->m2_unitConvWVST, 2);
   11718         721 :             tableBody(wwrcEast, wwrrAbvGndWall) = RealToStr(aboveGroundWallAreaEcond * state.dataOutRptTab->m2_unitConvWVST, 2);
   11719         721 :             tableBody(wwrcWest, wwrrAbvGndWall) = RealToStr(aboveGroundWallAreaWcond * state.dataOutRptTab->m2_unitConvWVST, 2);
   11720         721 :             tableBody(wwrcTotal, wwrrAbvGndWall) = RealToStr(TotalAboveGroundWallArea * state.dataOutRptTab->m2_unitConvWVST, 2);
   11721             : 
   11722         721 :             tableBody(wwrcNorth, wwrrWindow) = RealToStr(windowAreaNcond * state.dataOutRptTab->m2_unitConvWVST, 2);
   11723         721 :             tableBody(wwrcSouth, wwrrWindow) = RealToStr(windowAreaScond * state.dataOutRptTab->m2_unitConvWVST, 2);
   11724         721 :             tableBody(wwrcEast, wwrrWindow) = RealToStr(windowAreaEcond * state.dataOutRptTab->m2_unitConvWVST, 2);
   11725         721 :             tableBody(wwrcWest, wwrrWindow) = RealToStr(windowAreaWcond * state.dataOutRptTab->m2_unitConvWVST, 2);
   11726         721 :             tableBody(wwrcTotal, wwrrWindow) = RealToStr(TotalWindowArea * state.dataOutRptTab->m2_unitConvWVST, 2);
   11727             : 
   11728         721 :             tableBody(wwrcNorth, wwrrWWR) = RealToStr(100.0 * SafeDivide(windowAreaNcond, wallAreaNcond), 2);
   11729         721 :             tableBody(wwrcSouth, wwrrWWR) = RealToStr(100.0 * SafeDivide(windowAreaScond, wallAreaScond), 2);
   11730         721 :             tableBody(wwrcEast, wwrrWWR) = RealToStr(100.0 * SafeDivide(windowAreaEcond, wallAreaEcond), 2);
   11731         721 :             tableBody(wwrcWest, wwrrWWR) = RealToStr(100.0 * SafeDivide(windowAreaWcond, wallAreaWcond), 2);
   11732         721 :             tableBody(wwrcTotal, wwrrWWR) = RealToStr(100.0 * SafeDivide(TotalWindowArea, TotalWallArea), 2);
   11733             : 
   11734         721 :             tableBody(wwrcNorth, wwrrAbvGndWWR) = RealToStr(100.0 * SafeDivide(windowAreaNcond, aboveGroundWallAreaNcond), 2);
   11735         721 :             tableBody(wwrcSouth, wwrrAbvGndWWR) = RealToStr(100.0 * SafeDivide(windowAreaScond, aboveGroundWallAreaScond), 2);
   11736         721 :             tableBody(wwrcEast, wwrrAbvGndWWR) = RealToStr(100.0 * SafeDivide(windowAreaEcond, aboveGroundWallAreaEcond), 2);
   11737         721 :             tableBody(wwrcWest, wwrrAbvGndWWR) = RealToStr(100.0 * SafeDivide(windowAreaWcond, aboveGroundWallAreaWcond), 2);
   11738         721 :             tableBody(wwrcTotal, wwrrAbvGndWWR) = RealToStr(100.0 * SafeDivide(TotalWindowArea, TotalAboveGroundWallArea), 2);
   11739             : 
   11740         721 :             if (produceTabular) {
   11741         721 :                 WriteSubtitle(state, "Conditioned Window-Wall Ratio");
   11742         721 :                 WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
   11743             :             }
   11744         721 :             if (produceSQLite) {
   11745         721 :                 if (state.dataSQLiteProcedures->sqlite) {
   11746         114 :                     state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
   11747             :                         tableBody, rowHead, columnHead, "InputVerificationandResultsSummary", "Entire Facility", "Conditioned Window-Wall Ratio");
   11748             :                 }
   11749             :             }
   11750         721 :             if (produceTabular) {
   11751         721 :                 if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
   11752           5 :                     state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(
   11753             :                         tableBody, rowHead, columnHead, "InputVerificationandResultsSummary", "Entire Facility", "Conditioned Window-Wall Ratio");
   11754             :                 }
   11755             :             }
   11756             : 
   11757             :             //---- Skylight Roof Ratio Sub-Table
   11758         721 :             rowHead.allocate(3);
   11759         721 :             columnHead.allocate(1);
   11760         721 :             columnWidth.allocate(1);
   11761         721 :             columnWidth = 14; // array assignment - same for all columns
   11762         721 :             tableBody.allocate(1, 3);
   11763             : 
   11764         721 :             columnHead(1) = "Total";
   11765             : 
   11766         721 :             rowHead(1) = "Gross Roof Area " + state.dataOutRptTab->m2_unitName;
   11767         721 :             rowHead(2) = "Skylight Area " + state.dataOutRptTab->m2_unitName;
   11768         721 :             rowHead(3) = "Skylight-Roof Ratio [%]";
   11769             : 
   11770         721 :             if (DetailedWWR) {
   11771           0 :                 if (produceTabular) {
   11772           0 :                     print(state.files.debug, "{}\n", "========================");
   11773           0 :                     print(state.files.debug, "{}\n", "TotalRoofArea,SkylightArea");
   11774           0 :                     print(state.files.debug, "{:.2R},{:.2R}\n", roofArea, skylightArea);
   11775             :                 }
   11776             :             }
   11777             : 
   11778         721 :             tableBody(1, 1) = RealToStr(roofArea * state.dataOutRptTab->m2_unitConvWVST, 2);
   11779         721 :             tableBody(1, 2) = RealToStr(skylightArea * state.dataOutRptTab->m2_unitConvWVST, 2);
   11780         721 :             tableBody(1, 3) = RealToStr(100.0 * SafeDivide(skylightArea, roofArea), 2);
   11781             : 
   11782         721 :             if (produceTabular) {
   11783         721 :                 WriteSubtitle(state, "Skylight-Roof Ratio");
   11784         721 :                 WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
   11785             :             }
   11786         721 :             if (produceSQLite) {
   11787         721 :                 if (state.dataSQLiteProcedures->sqlite) {
   11788         114 :                     state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
   11789             :                         tableBody, rowHead, columnHead, "InputVerificationandResultsSummary", "Entire Facility", "Skylight-Roof Ratio");
   11790             :                 }
   11791             :             }
   11792         721 :             if (produceTabular) {
   11793         721 :                 if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
   11794           5 :                     state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(
   11795             :                         tableBody, rowHead, columnHead, "InputVerificationandResultsSummary", "Entire Facility", "Skylight-Roof Ratio");
   11796             :                 }
   11797             :             }
   11798             : 
   11799             :             //---- Hybrid Model: Internal Thermal Mass Sub-Table
   11800         721 :             if (state.dataHybridModel->FlagHybridModel_TM) {
   11801           0 :                 rowHead.allocate(state.dataGlobal->NumOfZones);
   11802           0 :                 NumOfCol = 2;
   11803           0 :                 columnHead.allocate(NumOfCol);
   11804           0 :                 columnWidth.allocate(NumOfCol);
   11805           0 :                 columnWidth = 14; // array assignment - same for all columns
   11806           0 :                 tableBody.allocate(NumOfCol, state.dataGlobal->NumOfZones);
   11807             : 
   11808           0 :                 columnHead(1) = "Hybrid Modeling (Y/N)";
   11809           0 :                 columnHead(2) = "Temperature Capacitance Multiplier ";
   11810             : 
   11811           0 :                 rowHead = "";
   11812           0 :                 tableBody = "";
   11813             : 
   11814           0 :                 for (iZone = 1; iZone <= state.dataGlobal->NumOfZones; ++iZone) {
   11815           0 :                     rowHead(iZone) = Zone(iZone).Name;
   11816           0 :                     if (state.dataHybridModel->HybridModelZone(iZone).InternalThermalMassCalc_T) {
   11817           0 :                         tableBody(1, iZone) = "Yes";
   11818             :                     } else {
   11819           0 :                         tableBody(1, iZone) = "No";
   11820             :                     }
   11821           0 :                     tableBody(2, iZone) = RealToStr(Zone(iZone).ZoneVolCapMultpSensHMAverage, 2);
   11822             :                 }
   11823             : 
   11824           0 :                 if (produceTabular) {
   11825           0 :                     WriteSubtitle(state, "Hybrid Model: Internal Thermal Mass");
   11826           0 :                     WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
   11827             :                 }
   11828           0 :                 if (produceSQLite) {
   11829           0 :                     if (state.dataSQLiteProcedures->sqlite) {
   11830           0 :                         state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(tableBody,
   11831             :                                                                                            rowHead,
   11832             :                                                                                            columnHead,
   11833             :                                                                                            "InputVerificationandResultsSummary",
   11834             :                                                                                            "Entire Facility",
   11835             :                                                                                            "Hybrid Model: Internal Thermal Mass");
   11836             :                     }
   11837             :                 }
   11838             :             }
   11839             : 
   11840         721 :             Real64 const totExtGrossWallArea_Multiplied(sum(Zone, &ZoneData::ExtGrossWallArea_Multiplied));
   11841         721 :             Real64 const totExtGrossGroundWallArea_Multiplied(sum(Zone, &ZoneData::ExtGrossGroundWallArea_Multiplied));
   11842         721 :             if (totExtGrossWallArea_Multiplied > 0.0 || totExtGrossGroundWallArea_Multiplied > 0.0) {
   11843        2085 :                 pdiff = std::abs((wallAreaN + wallAreaS + wallAreaE + wallAreaW) -
   11844         695 :                                  (totExtGrossWallArea_Multiplied + totExtGrossGroundWallArea_Multiplied)) /
   11845         695 :                         (totExtGrossWallArea_Multiplied + totExtGrossGroundWallArea_Multiplied);
   11846         695 :                 if (pdiff > 0.019) {
   11847           0 :                     if (produceTabular) {
   11848           0 :                         ShowWarningError(
   11849             :                             state, "WriteVeriSumTable: InputVerificationsAndResultsSummary: Wall area based on [>=60,<=120] degrees (tilt) as walls");
   11850           0 :                         ShowContinueError(state,
   11851           0 :                                           format("differs ~{:.1R}% from user entered Wall class surfaces. Degree calculation based on ASHRAE "
   11852             :                                                  "90.1 wall definitions.",
   11853           0 :                                                  pdiff * 100.0));
   11854             :                         //      CALL ShowContinueError(state, 'Calculated based on degrees=['//  &
   11855             :                         //         TRIM(ADJUSTL(RealToStr((wallAreaN + wallAreaS + wallAreaE + wallAreaW),3)))//  &
   11856             :                         //         '] m2, Calculated from user entered Wall class surfaces=['//  &
   11857             :                         //         TRIM(ADJUSTL(RealToStr(SUM(Zone(1:NumOfZones)%ExtGrossWallArea_Multiplied),3)))//' m2.')
   11858           0 :                         ShowContinueError(state, "Check classes of surfaces and tilts for discrepancies.");
   11859           0 :                         ShowContinueError(state,
   11860           0 :                                           "Total wall area by ASHRAE 90.1 definition=" +
   11861           0 :                                               stripped(RealToStr((wallAreaN + wallAreaS + wallAreaE + wallAreaW), 3)) + " m2.");
   11862           0 :                         ShowContinueError(
   11863             :                             state,
   11864           0 :                             "Total exterior wall area from user entered classes=" + stripped(RealToStr(totExtGrossWallArea_Multiplied, 3)) + " m2.");
   11865           0 :                         ShowContinueError(state,
   11866           0 :                                           "Total ground contact wall area from user entered classes=" +
   11867           0 :                                               stripped(RealToStr(totExtGrossGroundWallArea_Multiplied, 3)) + " m2.");
   11868             :                     }
   11869             :                 }
   11870             :             }
   11871             :             //---- Space Summary Sub-Table
   11872         721 :             if (produceTabular) {
   11873         721 :                 WriteTextLine(state, "PERFORMANCE", true);
   11874             :             }
   11875             : 
   11876         721 :             rowHead.allocate(state.dataGlobal->NumOfZones + 4);
   11877             : 
   11878         721 :             NumOfCol = 12;
   11879         721 :             columnHead.allocate(NumOfCol);
   11880         721 :             columnWidth.allocate(NumOfCol);
   11881         721 :             columnWidth = 14; // array assignment - same for all columns
   11882         721 :             tableBody.allocate(NumOfCol, state.dataGlobal->NumOfZones + 4);
   11883             : 
   11884         721 :             columnHead(1) = "Area " + state.dataOutRptTab->m2_unitName;
   11885         721 :             columnHead(2) = "Conditioned (Y/N)";
   11886         721 :             columnHead(3) = "Part of Total Floor Area (Y/N)";
   11887         721 :             columnHead(4) = "Volume " + state.dataOutRptTab->m3_unitName;
   11888         721 :             columnHead(5) = "Multipliers";
   11889         721 :             columnHead(6) = "Above Ground Gross Wall Area " + state.dataOutRptTab->m2_unitName;
   11890         721 :             columnHead(7) = "Underground Gross Wall Area " + state.dataOutRptTab->m2_unitName;
   11891         721 :             columnHead(8) = "Window Glass Area " + state.dataOutRptTab->m2_unitName;
   11892         721 :             columnHead(9) = "Opening Area " + state.dataOutRptTab->m2_unitName;
   11893         721 :             columnHead(10) = "Lighting " + state.dataOutRptTab->Wm2_unitName;
   11894         721 :             columnHead(11) = "People " + state.dataOutRptTab->m2_unitName.substr(0, len(state.dataOutRptTab->m2_unitName) - 1) + " per person" +
   11895         721 :                              state.dataOutRptTab->m2_unitName[len(state.dataOutRptTab->m2_unitName) - 1];
   11896         721 :             columnHead(12) = "Plug and Process " + state.dataOutRptTab->Wm2_unitName;
   11897             : 
   11898         721 :             rowHead = "";
   11899         721 :             rowHead(state.dataGlobal->NumOfZones + state.dataOutRptTab->grandTotal) = "Total";
   11900         721 :             rowHead(state.dataGlobal->NumOfZones + state.dataOutRptTab->condTotal) = "Conditioned Total";
   11901         721 :             rowHead(state.dataGlobal->NumOfZones + state.dataOutRptTab->uncondTotal) = "Unconditioned Total";
   11902         721 :             rowHead(state.dataGlobal->NumOfZones + state.dataOutRptTab->notpartTotal) = "Not Part of Total";
   11903             : 
   11904         721 :             tableBody = "";
   11905             : 
   11906        5393 :             for (iZone = 1; iZone <= state.dataGlobal->NumOfZones; ++iZone) {
   11907        4672 :                 mult = Zone(iZone).Multiplier * Zone(iZone).ListMultiplier;
   11908        4672 :                 rowHead(iZone) = Zone(iZone).Name;
   11909             :                 // Conditioned or not
   11910        4672 :                 if (Zone(iZone).SystemZoneNodeNumber > 0) {
   11911        4278 :                     tableBody(2, iZone) = "Yes";
   11912        4278 :                     zoneIsCond = true;
   11913             :                 } else {
   11914         394 :                     tableBody(2, iZone) = "No";
   11915         394 :                     zoneIsCond = false;
   11916             :                 }
   11917             :                 // Part of Total Floor Area or not
   11918        4672 :                 if (Zone(iZone).isPartOfTotalArea) {
   11919        4548 :                     tableBody(3, iZone) = "Yes";
   11920        4548 :                     usezoneFloorArea = true;
   11921             :                 } else {
   11922         124 :                     tableBody(3, iZone) = "No";
   11923         124 :                     usezoneFloorArea = false;
   11924             :                 }
   11925        4672 :                 tableBody(1, iZone) = RealToStr(Zone(iZone).FloorArea * state.dataOutRptTab->m2_unitConvWVST, 2);
   11926        4672 :                 tableBody(4, iZone) = RealToStr(Zone(iZone).Volume * state.dataOutRptTab->m3_unitConv, 2);
   11927             :                 // no unit conversion necessary since done automatically
   11928        4672 :                 if (produceTabular) {
   11929        4672 :                     PreDefTableEntry(state, state.dataOutRptPredefined->pdchLeedSutSpArea, Zone(iZone).Name, Zone(iZone).FloorArea, 2);
   11930             :                 }
   11931        4672 :                 if (zoneIsCond) {
   11932        4278 :                     if (produceTabular) {
   11933        4278 :                         PreDefTableEntry(state, state.dataOutRptPredefined->pdchLeedSutOcArea, Zone(iZone).Name, Zone(iZone).FloorArea, 2);
   11934        4278 :                         PreDefTableEntry(state, state.dataOutRptPredefined->pdchLeedSutUnArea, Zone(iZone).Name, "0.00");
   11935             :                     }
   11936             :                 } else {
   11937         394 :                     if (produceTabular) {
   11938         394 :                         PreDefTableEntry(state, state.dataOutRptPredefined->pdchLeedSutOcArea, Zone(iZone).Name, "0.00");
   11939         394 :                         PreDefTableEntry(state, state.dataOutRptPredefined->pdchLeedSutUnArea, Zone(iZone).Name, Zone(iZone).FloorArea, 2);
   11940             :                     }
   11941             :                 }
   11942        4672 :                 tableBody(5, iZone) = RealToStr(mult, 2);
   11943        4672 :                 tableBody(6, iZone) = RealToStr(Zone(iZone).ExtGrossWallArea * state.dataOutRptTab->m2_unitConvWVST, 2);
   11944        4672 :                 tableBody(7, iZone) = RealToStr(Zone(iZone).ExtGrossGroundWallArea * state.dataOutRptTab->m2_unitConvWVST, 2);
   11945        4672 :                 tableBody(8, iZone) = RealToStr(zoneGlassArea(iZone) * state.dataOutRptTab->m2_unitConvWVST, 2);
   11946        4672 :                 tableBody(9, iZone) = RealToStr(zoneOpeningArea(iZone) * state.dataOutRptTab->m2_unitConvWVST, 2);
   11947             :                 // lighting density
   11948        4672 :                 totLightPower = 0.0;
   11949      134598 :                 for (iLight = 1; iLight <= state.dataHeatBal->TotLights; ++iLight) {
   11950      129926 :                     if (iZone == state.dataHeatBal->Lights(iLight).ZonePtr) {
   11951        3965 :                         totLightPower += state.dataHeatBal->Lights(iLight).DesignLevel;
   11952             :                     }
   11953             :                 }
   11954        4672 :                 if (Zone(iZone).FloorArea > 0) {
   11955        4670 :                     tableBody(10, iZone) = RealToStr(state.dataOutRptTab->Wm2_unitConv * totLightPower / Zone(iZone).FloorArea, 4);
   11956             :                 }
   11957             :                 // people density
   11958        4672 :                 totNumPeople = 0.0;
   11959      103727 :                 for (iPeople = 1; iPeople <= state.dataHeatBal->TotPeople; ++iPeople) {
   11960       99055 :                     if (iZone == state.dataHeatBal->People(iPeople).ZonePtr) {
   11961        3778 :                         totNumPeople += state.dataHeatBal->People(iPeople).NumberOfPeople;
   11962             :                     }
   11963             :                 }
   11964        4672 :                 if (totNumPeople > 0) {
   11965        3702 :                     tableBody(11, iZone) = RealToStr(Zone(iZone).FloorArea * state.dataOutRptTab->m2_unitConvWVST / totNumPeople, 2);
   11966             :                 }
   11967             :                 // plug and process density
   11968        4672 :                 totPlugProcess = 0.0;
   11969      128631 :                 for (iPlugProc = 1; iPlugProc <= state.dataHeatBal->TotElecEquip; ++iPlugProc) {
   11970      123959 :                     if (iZone == state.dataHeatBal->ZoneElectric(iPlugProc).ZonePtr) {
   11971        4088 :                         totPlugProcess += state.dataHeatBal->ZoneElectric(iPlugProc).DesignLevel;
   11972             :                     }
   11973             :                 }
   11974        7250 :                 for (iPlugProc = 1; iPlugProc <= state.dataHeatBal->TotGasEquip; ++iPlugProc) {
   11975        2578 :                     if (iZone == state.dataHeatBal->ZoneGas(iPlugProc).ZonePtr) {
   11976          77 :                         totPlugProcess += state.dataHeatBal->ZoneGas(iPlugProc).DesignLevel;
   11977             :                     }
   11978             :                 }
   11979        4825 :                 for (iPlugProc = 1; iPlugProc <= state.dataHeatBal->TotOthEquip; ++iPlugProc) {
   11980         153 :                     if (iZone == state.dataHeatBal->ZoneOtherEq(iPlugProc).ZonePtr) {
   11981          52 :                         totPlugProcess += state.dataHeatBal->ZoneOtherEq(iPlugProc).DesignLevel;
   11982             :                     }
   11983             :                 }
   11984        4783 :                 for (iPlugProc = 1; iPlugProc <= state.dataHeatBal->TotHWEquip; ++iPlugProc) {
   11985         111 :                     if (iZone == state.dataHeatBal->ZoneHWEq(iPlugProc).ZonePtr) {
   11986          14 :                         totPlugProcess += state.dataHeatBal->ZoneHWEq(iPlugProc).DesignLevel;
   11987             :                     }
   11988             :                 }
   11989        4691 :                 for (iPlugProc = 1; iPlugProc <= state.dataHeatBal->TotITEquip; ++iPlugProc) {
   11990          19 :                     if (iZone == state.dataHeatBal->ZoneITEq(iPlugProc).ZonePtr) {
   11991           7 :                         totPlugProcess += state.dataHeatBal->ZoneITEq(iPlugProc).DesignTotalPower;
   11992             :                     }
   11993             :                 }
   11994        4672 :                 if (Zone(iZone).FloorArea > 0) {
   11995        4670 :                     tableBody(12, iZone) = RealToStr(totPlugProcess * state.dataOutRptTab->Wm2_unitConv / Zone(iZone).FloorArea, 4);
   11996             :                 }
   11997             : 
   11998             :                 // total rows for Total / Not Part of Total
   11999             :                 // In "Total": break between conditioned/unconditioned
   12000             : 
   12001             :                 // If not part of total, goes directly to this row
   12002        4672 :                 if (!usezoneFloorArea) {
   12003         124 :                     state.dataOutRptTab->zstArea(state.dataOutRptTab->notpartTotal) += mult * Zone(iZone).FloorArea;
   12004         124 :                     state.dataOutRptTab->zstVolume(state.dataOutRptTab->notpartTotal) += mult * Zone(iZone).Volume;
   12005         124 :                     state.dataOutRptTab->zstWallArea(state.dataOutRptTab->notpartTotal) += mult * Zone(iZone).ExtGrossWallArea;
   12006         124 :                     state.dataOutRptTab->zstUndWallArea(state.dataOutRptTab->notpartTotal) += mult * Zone(iZone).ExtGrossGroundWallArea;
   12007         124 :                     state.dataOutRptTab->zstWindowArea(state.dataOutRptTab->notpartTotal) += mult * zoneGlassArea(iZone);
   12008         124 :                     state.dataOutRptTab->zstOpeningArea(state.dataOutRptTab->notpartTotal) += mult * zoneOpeningArea(iZone);
   12009         124 :                     state.dataOutRptTab->zstLight(state.dataOutRptTab->notpartTotal) += mult * totLightPower;
   12010         124 :                     state.dataOutRptTab->zstPeople(state.dataOutRptTab->notpartTotal) += mult * totNumPeople;
   12011         124 :                     state.dataOutRptTab->zstPlug(state.dataOutRptTab->notpartTotal) += mult * totPlugProcess;
   12012             :                 } else {
   12013             :                     // Add it to the 'Total'
   12014        4548 :                     state.dataOutRptTab->zstArea(state.dataOutRptTab->grandTotal) += mult * Zone(iZone).FloorArea;
   12015        4548 :                     state.dataOutRptTab->zstVolume(state.dataOutRptTab->grandTotal) += mult * Zone(iZone).Volume;
   12016        4548 :                     state.dataOutRptTab->zstWallArea(state.dataOutRptTab->grandTotal) += mult * Zone(iZone).ExtGrossWallArea;
   12017        4548 :                     state.dataOutRptTab->zstUndWallArea(state.dataOutRptTab->grandTotal) += mult * Zone(iZone).ExtGrossGroundWallArea;
   12018        4548 :                     state.dataOutRptTab->zstWindowArea(state.dataOutRptTab->grandTotal) += mult * zoneGlassArea(iZone);
   12019        4548 :                     state.dataOutRptTab->zstOpeningArea(state.dataOutRptTab->grandTotal) += mult * zoneOpeningArea(iZone);
   12020        4548 :                     state.dataOutRptTab->zstLight(state.dataOutRptTab->grandTotal) += mult * totLightPower;
   12021        4548 :                     state.dataOutRptTab->zstPeople(state.dataOutRptTab->grandTotal) += mult * totNumPeople;
   12022        4548 :                     state.dataOutRptTab->zstPlug(state.dataOutRptTab->grandTotal) += mult * totPlugProcess;
   12023             : 
   12024             :                     // Subtotal between cond/unconditioned
   12025        4548 :                     if (zoneIsCond) {
   12026        4177 :                         state.dataOutRptTab->zstArea(state.dataOutRptTab->condTotal) += mult * Zone(iZone).FloorArea;
   12027        4177 :                         state.dataOutRptTab->zstVolume(state.dataOutRptTab->condTotal) += mult * Zone(iZone).Volume;
   12028        4177 :                         state.dataOutRptTab->zstWallArea(state.dataOutRptTab->condTotal) += mult * Zone(iZone).ExtGrossWallArea;
   12029        4177 :                         state.dataOutRptTab->zstUndWallArea(state.dataOutRptTab->condTotal) += mult * Zone(iZone).ExtGrossGroundWallArea;
   12030        4177 :                         state.dataOutRptTab->zstWindowArea(state.dataOutRptTab->condTotal) += mult * zoneGlassArea(iZone);
   12031        4177 :                         state.dataOutRptTab->zstOpeningArea(state.dataOutRptTab->condTotal) += mult * zoneOpeningArea(iZone);
   12032        4177 :                         state.dataOutRptTab->zstLight(state.dataOutRptTab->condTotal) += mult * totLightPower;
   12033        4177 :                         state.dataOutRptTab->zstPeople(state.dataOutRptTab->condTotal) += mult * totNumPeople;
   12034        4177 :                         state.dataOutRptTab->zstPlug(state.dataOutRptTab->condTotal) += mult * totPlugProcess;
   12035         371 :                     } else if (!zoneIsCond) {
   12036         371 :                         state.dataOutRptTab->zstArea(state.dataOutRptTab->uncondTotal) += mult * Zone(iZone).FloorArea;
   12037         371 :                         state.dataOutRptTab->zstVolume(state.dataOutRptTab->uncondTotal) += mult * Zone(iZone).Volume;
   12038         371 :                         state.dataOutRptTab->zstWallArea(state.dataOutRptTab->uncondTotal) += mult * Zone(iZone).ExtGrossWallArea;
   12039         371 :                         state.dataOutRptTab->zstUndWallArea(state.dataOutRptTab->uncondTotal) += mult * Zone(iZone).ExtGrossGroundWallArea;
   12040         371 :                         state.dataOutRptTab->zstWindowArea(state.dataOutRptTab->uncondTotal) += mult * zoneGlassArea(iZone);
   12041         371 :                         state.dataOutRptTab->zstOpeningArea(state.dataOutRptTab->uncondTotal) += mult * zoneOpeningArea(iZone);
   12042         371 :                         state.dataOutRptTab->zstLight(state.dataOutRptTab->uncondTotal) += mult * totLightPower;
   12043         371 :                         state.dataOutRptTab->zstPeople(state.dataOutRptTab->uncondTotal) += mult * totNumPeople;
   12044         371 :                         state.dataOutRptTab->zstPlug(state.dataOutRptTab->uncondTotal) += mult * totPlugProcess;
   12045             :                     }
   12046             :                 }
   12047             :             }
   12048        3605 :             for (iTotal = 1; iTotal <= 4; ++iTotal) {
   12049        2884 :                 tableBody(1, state.dataGlobal->NumOfZones + iTotal) =
   12050        5768 :                     RealToStr(state.dataOutRptTab->zstArea(iTotal) * state.dataOutRptTab->m2_unitConvWVST, 2);
   12051        2884 :                 tableBody(4, state.dataGlobal->NumOfZones + iTotal) =
   12052        5768 :                     RealToStr(state.dataOutRptTab->zstVolume(iTotal) * state.dataOutRptTab->m3_unitConv, 2);
   12053        2884 :                 tableBody(6, state.dataGlobal->NumOfZones + iTotal) =
   12054        5768 :                     RealToStr(state.dataOutRptTab->zstWallArea(iTotal) * state.dataOutRptTab->m2_unitConvWVST, 2);
   12055        2884 :                 tableBody(7, state.dataGlobal->NumOfZones + iTotal) =
   12056        5768 :                     RealToStr(state.dataOutRptTab->zstUndWallArea(iTotal) * state.dataOutRptTab->m2_unitConvWVST, 2);
   12057        2884 :                 tableBody(8, state.dataGlobal->NumOfZones + iTotal) =
   12058        5768 :                     RealToStr(state.dataOutRptTab->zstWindowArea(iTotal) * state.dataOutRptTab->m2_unitConvWVST, 2);
   12059        2884 :                 tableBody(9, state.dataGlobal->NumOfZones + iTotal) =
   12060        5768 :                     RealToStr(state.dataOutRptTab->zstOpeningArea(iTotal) * state.dataOutRptTab->m2_unitConvWVST, 2);
   12061        2884 :                 if (state.dataOutRptTab->zstArea(iTotal) != 0) {
   12062        1570 :                     tableBody(10, state.dataGlobal->NumOfZones + iTotal) = RealToStr(
   12063        1570 :                         state.dataOutRptTab->zstLight(iTotal) * state.dataOutRptTab->Wm2_unitConv / state.dataOutRptTab->zstArea(iTotal), 4);
   12064        1570 :                     tableBody(12, state.dataGlobal->NumOfZones + iTotal) =
   12065        3140 :                         RealToStr(state.dataOutRptTab->zstPlug(iTotal) * state.dataOutRptTab->Wm2_unitConv / state.dataOutRptTab->zstArea(iTotal), 4);
   12066             :                 }
   12067        2884 :                 if (state.dataOutRptTab->zstPeople(iTotal) != 0) {
   12068        1243 :                     tableBody(11, state.dataGlobal->NumOfZones + iTotal) = RealToStr(
   12069        1243 :                         state.dataOutRptTab->zstArea(iTotal) * state.dataOutRptTab->m2_unitConvWVST / state.dataOutRptTab->zstPeople(iTotal), 2);
   12070             :                 }
   12071             :             }
   12072         721 :             if (produceTabular) {
   12073        2163 :                 PreDefTableEntry(
   12074        1442 :                     state, state.dataOutRptPredefined->pdchLeedSutSpArea, "Totals", state.dataOutRptTab->zstArea(state.dataOutRptTab->grandTotal), 2);
   12075        2163 :                 PreDefTableEntry(
   12076        1442 :                     state, state.dataOutRptPredefined->pdchLeedSutOcArea, "Totals", state.dataOutRptTab->zstArea(state.dataOutRptTab->condTotal), 2);
   12077        2163 :                 PreDefTableEntry(state,
   12078         721 :                                  state.dataOutRptPredefined->pdchLeedSutUnArea,
   12079             :                                  "Totals",
   12080         721 :                                  state.dataOutRptTab->zstArea(state.dataOutRptTab->uncondTotal),
   12081         721 :                                  2);
   12082             :             }
   12083             : 
   12084         721 :             if (produceTabular) {
   12085         721 :                 WriteSubtitle(state, "Zone Summary");
   12086         721 :                 WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
   12087             :             }
   12088         721 :             if (produceSQLite) {
   12089         721 :                 if (state.dataSQLiteProcedures->sqlite) {
   12090         114 :                     state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
   12091             :                         tableBody, rowHead, columnHead, "InputVerificationandResultsSummary", "Entire Facility", "Zone Summary");
   12092             :                 }
   12093             :             }
   12094         721 :             if (produceTabular) {
   12095         721 :                 if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
   12096           5 :                     state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(
   12097             :                         tableBody, rowHead, columnHead, "InputVerificationandResultsSummary", "Entire Facility", "Zone Summary");
   12098             :                 }
   12099             :             }
   12100             : 
   12101         721 :             writeVeriSumSpaceTables(state, produceTabular, produceSQLite);
   12102             :         }
   12103             :     }
   12104         731 : }
   12105             : 
   12106         721 : void writeVeriSumSpaceTables(EnergyPlusData &state, bool produceTabular, bool produceSQLite)
   12107             : {
   12108             : 
   12109             :     // Write Space and SpaceType sub-tables for Input Verification and Results Summary
   12110        1442 :     Array1D_string spaceRowHead;
   12111        1442 :     Array1D_string spaceColumnHead;
   12112        1442 :     Array1D_int spaceColumnWidth;
   12113        1442 :     Array2D_string spaceTableBody;
   12114         721 :     int spaceNumCol = 11;
   12115         721 :     spaceRowHead.allocate(state.dataGlobal->numSpaces + 4); // Extra rows for totals
   12116         721 :     spaceColumnHead.allocate(spaceNumCol);
   12117         721 :     spaceColumnWidth.allocate(spaceNumCol);
   12118         721 :     spaceTableBody.allocate(spaceNumCol, state.dataGlobal->numSpaces + 4); // Extra rows for totals
   12119        8652 :     for (int iCol = 1; iCol <= spaceNumCol; ++iCol) {
   12120        7931 :         spaceColumnWidth(iCol) = 14;
   12121             :     }
   12122             : 
   12123         721 :     spaceColumnHead(1) = "Area " + state.dataOutRptTab->m2_unitName;
   12124         721 :     spaceColumnHead(2) = "Conditioned (Y/N)";
   12125         721 :     spaceColumnHead(3) = "Part of Total Floor Area (Y/N)";
   12126         721 :     spaceColumnHead(4) = "Multipliers";
   12127         721 :     spaceColumnHead(5) = "Zone Name";
   12128         721 :     spaceColumnHead(6) = "Space Type";
   12129         721 :     spaceColumnHead(7) = "Radiant/Solar Enclosure Name";
   12130         721 :     spaceColumnHead(8) = "Lighting " + state.dataOutRptTab->Wm2_unitName;
   12131         721 :     spaceColumnHead(9) = "People " + state.dataOutRptTab->m2_unitName.substr(0, len(state.dataOutRptTab->m2_unitName) - 1) + " per person" +
   12132         721 :                          state.dataOutRptTab->m2_unitName[len(state.dataOutRptTab->m2_unitName) - 1];
   12133         721 :     spaceColumnHead(10) = "Plug and Process " + state.dataOutRptTab->Wm2_unitName;
   12134         721 :     spaceColumnHead(11) = "Tags";
   12135             : 
   12136         721 :     int constexpr colSpaceArea(1);
   12137         721 :     int constexpr colConditioned(2);
   12138         721 :     int constexpr colPartOfTotal(3);
   12139         721 :     int constexpr colMultipliers(4);
   12140         721 :     int constexpr colZoneName(5);
   12141         721 :     int constexpr colSpaceType(6);
   12142         721 :     int constexpr colEnclName(7);
   12143         721 :     int constexpr colSpaceLighting(8);
   12144         721 :     int constexpr colSpacePeople(9);
   12145         721 :     int constexpr colSpacePlugProcess(10);
   12146         721 :     int constexpr colSpaceTags(11);
   12147             : 
   12148         721 :     spaceRowHead(state.dataGlobal->numSpaces + state.dataOutRptTab->grandTotal) = "Total";
   12149         721 :     spaceRowHead(state.dataGlobal->numSpaces + state.dataOutRptTab->condTotal) = "Conditioned Total";
   12150         721 :     spaceRowHead(state.dataGlobal->numSpaces + state.dataOutRptTab->uncondTotal) = "Unconditioned Total";
   12151         721 :     spaceRowHead(state.dataGlobal->numSpaces + state.dataOutRptTab->notpartTotal) = "Not Part of Total";
   12152             : 
   12153        1442 :     EPVector<Real64> spaceTotLighting;
   12154        1442 :     EPVector<Real64> spaceTotPeople;
   12155        1442 :     EPVector<Real64> spaceTotPlugProcess;
   12156         721 :     spaceTotLighting.allocate(state.dataGlobal->numSpaces);
   12157         721 :     spaceTotPeople.allocate(state.dataGlobal->numSpaces);
   12158         721 :     spaceTotPlugProcess.allocate(state.dataGlobal->numSpaces);
   12159        5397 :     for (int iSpace = 1; iSpace <= state.dataGlobal->numSpaces; ++iSpace) {
   12160        4676 :         spaceTotLighting(iSpace) = 0.0;
   12161        4676 :         spaceTotPeople(iSpace) = 0.0;
   12162        4676 :         spaceTotPlugProcess(iSpace) = 0.0;
   12163             :     }
   12164             : 
   12165        1442 :     Array1D_string spaceTypeRowHead;
   12166        1442 :     Array1D_string spaceTypeColumnHead;
   12167        1442 :     Array1D_int spaceTypeColumnWidth;
   12168        1442 :     Array2D_string spaceTypeTableBody;
   12169         721 :     int spaceTypeNumCol = 7;
   12170         721 :     spaceTypeRowHead.allocate(state.dataGlobal->numSpaceTypes + 1); // Extra row for total
   12171         721 :     spaceTypeColumnHead.allocate(spaceTypeNumCol);
   12172         721 :     spaceTypeColumnWidth.allocate(spaceTypeNumCol);
   12173         721 :     spaceTypeTableBody.allocate(spaceTypeNumCol, state.dataGlobal->numSpaceTypes + 1); // Extra row for total
   12174        5768 :     for (int iCol = 1; iCol <= spaceTypeNumCol; ++iCol) {
   12175        5047 :         spaceTypeColumnWidth(iCol) = 14;
   12176             :     }
   12177         721 :     spaceTypeColumnHead(1) = "Total Area " + state.dataOutRptTab->m2_unitName;
   12178         721 :     spaceTypeColumnHead(2) = "Conditioned Area " + state.dataOutRptTab->m2_unitName;
   12179         721 :     spaceTypeColumnHead(3) = "Unconditioned Area " + state.dataOutRptTab->m2_unitName;
   12180         721 :     spaceTypeColumnHead(4) = "Not Part of Total Area " + state.dataOutRptTab->m2_unitName;
   12181         721 :     spaceTypeColumnHead(5) = "Lighting " + state.dataOutRptTab->Wm2_unitName;
   12182         721 :     spaceTypeColumnHead(6) = "People " + state.dataOutRptTab->m2_unitName.substr(0, len(state.dataOutRptTab->m2_unitName) - 1) + " per person" +
   12183         721 :                              state.dataOutRptTab->m2_unitName[len(state.dataOutRptTab->m2_unitName) - 1];
   12184         721 :     spaceTypeColumnHead(7) = "Plug and Process " + state.dataOutRptTab->Wm2_unitName;
   12185             : 
   12186         721 :     int constexpr colSpaceTypeTotArea(1);
   12187         721 :     int constexpr colSpaceTypeCondArea(2);
   12188         721 :     int constexpr colSpaceTypeUncondArea(3);
   12189         721 :     int constexpr colSpaceTypeNotTotArea(4);
   12190         721 :     int constexpr colSpaceTypeLighting(5);
   12191         721 :     int constexpr colSpaceTypePeople(6);
   12192         721 :     int constexpr colSpaceTypePlugProcess(7);
   12193             : 
   12194         721 :     spaceTypeRowHead(state.dataGlobal->numSpaceTypes + state.dataOutRptTab->grandTotal) = "Total";
   12195             : 
   12196        1442 :     EPVector<Real64> spaceTypeTotArea;
   12197        1442 :     EPVector<Real64> spaceTypeCondArea;
   12198        1442 :     EPVector<Real64> spaceTypeUncondArea;
   12199        1442 :     EPVector<Real64> spaceTypeNotTotArea;
   12200        1442 :     EPVector<Real64> spaceTypeTotLighting;
   12201        1442 :     EPVector<Real64> spaceTypeTotPeople;
   12202        1442 :     EPVector<Real64> spaceTypeTotPlugProcess;
   12203         721 :     spaceTypeTotArea.allocate(state.dataGlobal->numSpaceTypes);
   12204         721 :     spaceTypeCondArea.allocate(state.dataGlobal->numSpaceTypes);
   12205         721 :     spaceTypeUncondArea.allocate(state.dataGlobal->numSpaceTypes);
   12206         721 :     spaceTypeNotTotArea.allocate(state.dataGlobal->numSpaceTypes);
   12207         721 :     spaceTypeTotLighting.allocate(state.dataGlobal->numSpaceTypes);
   12208         721 :     spaceTypeTotPeople.allocate(state.dataGlobal->numSpaceTypes);
   12209         721 :     spaceTypeTotPlugProcess.allocate(state.dataGlobal->numSpaceTypes);
   12210        1420 :     for (int iSpaceType = 1; iSpaceType <= state.dataGlobal->numSpaceTypes; ++iSpaceType) {
   12211         699 :         spaceTypeTotArea(iSpaceType) = 0.0;
   12212         699 :         spaceTypeCondArea(iSpaceType) = 0.0;
   12213         699 :         spaceTypeUncondArea(iSpaceType) = 0.0;
   12214         699 :         spaceTypeNotTotArea(iSpaceType) = 0.0;
   12215         699 :         spaceTypeTotLighting(iSpaceType) = 0.0;
   12216         699 :         spaceTypeTotPeople(iSpaceType) = 0.0;
   12217         699 :         spaceTypeTotPlugProcess(iSpaceType) = 0.0;
   12218             :     }
   12219             : 
   12220             :     // Accumulate internal gain totals by space and space type
   12221        4499 :     for (int iPeople = 1; iPeople <= state.dataHeatBal->TotPeople; ++iPeople) {
   12222        3778 :         auto &curPeople = state.dataHeatBal->People(iPeople);
   12223        3778 :         int const spaceNum = curPeople.spaceIndex;
   12224        3778 :         Real64 const people = curPeople.NumberOfPeople;
   12225        3778 :         spaceTotPeople(spaceNum) += people;
   12226        3778 :         spaceTypeTotPeople(state.dataHeatBal->space(spaceNum).spaceTypeNum) += people;
   12227             :     }
   12228        4686 :     for (int iLights = 1; iLights <= state.dataHeatBal->TotLights; ++iLights) {
   12229        3965 :         auto &curLighting = state.dataHeatBal->Lights(iLights);
   12230        3965 :         int const spaceNum = curLighting.spaceIndex;
   12231        3965 :         Real64 const lighting = curLighting.DesignLevel;
   12232        3965 :         spaceTotLighting(spaceNum) += lighting;
   12233        3965 :         spaceTypeTotLighting(state.dataHeatBal->space(spaceNum).spaceTypeNum) += lighting;
   12234             :     }
   12235        4809 :     for (int iElecEquip = 1; iElecEquip <= state.dataHeatBal->TotElecEquip; ++iElecEquip) {
   12236        4088 :         auto &curElecEquip = state.dataHeatBal->ZoneElectric(iElecEquip);
   12237        4088 :         int const spaceNum = curElecEquip.spaceIndex;
   12238        4088 :         Real64 const elecEquip = curElecEquip.DesignLevel;
   12239        4088 :         spaceTotPlugProcess(spaceNum) += elecEquip;
   12240        4088 :         spaceTypeTotPlugProcess(state.dataHeatBal->space(spaceNum).spaceTypeNum) += elecEquip;
   12241             :     }
   12242         798 :     for (int iGasEquip = 1; iGasEquip <= state.dataHeatBal->TotGasEquip; ++iGasEquip) {
   12243          77 :         auto &curGasEquip = state.dataHeatBal->ZoneGas(iGasEquip);
   12244          77 :         int const spaceNum = curGasEquip.spaceIndex;
   12245          77 :         Real64 const gasEquip = curGasEquip.DesignLevel;
   12246          77 :         spaceTotPlugProcess(spaceNum) += gasEquip;
   12247          77 :         spaceTypeTotPlugProcess(state.dataHeatBal->space(spaceNum).spaceTypeNum) += gasEquip;
   12248             :     }
   12249         773 :     for (int iOthEquip = 1; iOthEquip <= state.dataHeatBal->TotOthEquip; ++iOthEquip) {
   12250          52 :         auto &curOthEquip = state.dataHeatBal->ZoneOtherEq(iOthEquip);
   12251          52 :         int const spaceNum = curOthEquip.spaceIndex;
   12252          52 :         Real64 const othEquip = curOthEquip.DesignLevel;
   12253          52 :         spaceTotPlugProcess(spaceNum) += othEquip;
   12254          52 :         spaceTypeTotPlugProcess(state.dataHeatBal->space(spaceNum).spaceTypeNum) += othEquip;
   12255             :     }
   12256         735 :     for (int iHWEquip = 1; iHWEquip <= state.dataHeatBal->TotHWEquip; ++iHWEquip) {
   12257          14 :         auto &curHWEquip = state.dataHeatBal->ZoneHWEq(iHWEquip);
   12258          14 :         int const spaceNum = curHWEquip.spaceIndex;
   12259          14 :         Real64 const hwEquip = curHWEquip.DesignLevel;
   12260          14 :         spaceTotPlugProcess(spaceNum) += hwEquip;
   12261          14 :         spaceTypeTotPlugProcess(state.dataHeatBal->space(spaceNum).spaceTypeNum) += hwEquip;
   12262             :     }
   12263         726 :     for (int iSteamEquip = 1; iSteamEquip <= state.dataHeatBal->TotStmEquip; ++iSteamEquip) {
   12264           5 :         auto &curSteamEquip = state.dataHeatBal->ZoneSteamEq(iSteamEquip);
   12265           5 :         int const spaceNum = curSteamEquip.spaceIndex;
   12266           5 :         Real64 const steamEquip = curSteamEquip.DesignLevel;
   12267           5 :         spaceTotPlugProcess(spaceNum) += steamEquip;
   12268           5 :         spaceTypeTotPlugProcess(state.dataHeatBal->space(spaceNum).spaceTypeNum) += steamEquip;
   12269             :     }
   12270         728 :     for (int iITEquip = 1; iITEquip <= state.dataHeatBal->TotITEquip; ++iITEquip) {
   12271           7 :         auto &curITEquip = state.dataHeatBal->ZoneITEq(iITEquip);
   12272           7 :         int const spaceNum = curITEquip.spaceIndex;
   12273           7 :         Real64 const itEquip = curITEquip.DesignTotalPower;
   12274           7 :         spaceTotPlugProcess(spaceNum) += itEquip;
   12275           7 :         spaceTypeTotPlugProcess(state.dataHeatBal->space(spaceNum).spaceTypeNum) += itEquip;
   12276             :     }
   12277             : 
   12278             :     // re-use existing zone total variables
   12279        3605 :     for (int iTotal = 1; iTotal <= 4; ++iTotal) {
   12280        2884 :         state.dataOutRptTab->zstArea(iTotal) = 0.0;
   12281        2884 :         state.dataOutRptTab->zstLight(iTotal) = 0.0;
   12282        2884 :         state.dataOutRptTab->zstPlug(iTotal) = 0.0;
   12283        2884 :         state.dataOutRptTab->zstPeople(iTotal) = 0.0;
   12284             :     }
   12285             : 
   12286         721 :     int spaceTableRowNum = 0;
   12287        5393 :     for (int iZone = 1; iZone <= state.dataGlobal->NumOfZones; ++iZone) {
   12288        4672 :         auto &curZone = state.dataHeatBal->Zone(iZone);
   12289        4672 :         Real64 const mult = Real64(curZone.Multiplier) * Real64(curZone.ListMultiplier);
   12290        9348 :         for (int const spaceNum : curZone.spaceIndexes) {
   12291        4676 :             auto &curSpace = state.dataHeatBal->space(spaceNum);
   12292        4676 :             bool spaceIsCond = false;
   12293        4676 :             bool useSpaceFloorArea = false;
   12294        4676 :             ++spaceTableRowNum;
   12295        4676 :             spaceRowHead(spaceTableRowNum) = curSpace.Name;
   12296        4676 :             spaceTableBody(colZoneName, spaceTableRowNum) = curZone.Name;
   12297        4676 :             spaceTableBody(colSpaceType, spaceTableRowNum) = curSpace.spaceType;
   12298        4676 :             spaceTableBody(colEnclName, spaceTableRowNum) = state.dataViewFactor->EnclSolInfo(curSpace.solarEnclosureNum).Name;
   12299        4676 :             spaceTableBody(colSpaceArea, spaceTableRowNum) = RealToStr(curSpace.floorArea * state.dataOutRptTab->m2_unitConvWVST, 2);
   12300             :             // Conditioned or not
   12301        4676 :             if (curZone.SystemZoneNodeNumber > 0) {
   12302        4282 :                 spaceTableBody(colConditioned, spaceTableRowNum) = "Yes";
   12303        4282 :                 spaceIsCond = true;
   12304             :             } else {
   12305         394 :                 spaceTableBody(colConditioned, spaceTableRowNum) = "No";
   12306         394 :                 spaceIsCond = false;
   12307             :             }
   12308             :             // Part of Total Floor Area or not
   12309        4676 :             if (curZone.isPartOfTotalArea) {
   12310        4552 :                 spaceTableBody(colPartOfTotal, spaceTableRowNum) = "Yes";
   12311        4552 :                 useSpaceFloorArea = true;
   12312             :             } else {
   12313         124 :                 spaceTableBody(colPartOfTotal, spaceTableRowNum) = "No";
   12314         124 :                 useSpaceFloorArea = false;
   12315             :             }
   12316             :             // lighting density
   12317        4676 :             spaceTableBody(colMultipliers, spaceTableRowNum) = RealToStr(mult, 2);
   12318        4676 :             if (curSpace.floorArea > 0) {
   12319        4673 :                 spaceTableBody(colSpaceLighting, spaceTableRowNum) =
   12320        9346 :                     RealToStr(state.dataOutRptTab->Wm2_unitConv * spaceTotLighting(spaceNum) / curSpace.floorArea, 4);
   12321             :             } else {
   12322           3 :                 spaceTableBody(colSpaceLighting, spaceTableRowNum) = RealToStr(0.0, 4);
   12323             :             }
   12324             :             // people density
   12325        4676 :             if (spaceTotPeople(spaceNum) > 0) {
   12326        3705 :                 spaceTableBody(colSpacePeople, spaceTableRowNum) =
   12327        7410 :                     RealToStr(curSpace.floorArea * state.dataOutRptTab->m2_unitConvWVST / spaceTotPeople(spaceNum), 2);
   12328             :             } else {
   12329         971 :                 spaceTableBody(colSpacePeople, spaceTableRowNum) = RealToStr(0.0, 2);
   12330             :             }
   12331             :             // plug and process density
   12332        4676 :             if (curSpace.floorArea > 0) {
   12333        4673 :                 spaceTableBody(colSpacePlugProcess, spaceTableRowNum) =
   12334        9346 :                     RealToStr(spaceTotPlugProcess(spaceNum) * state.dataOutRptTab->Wm2_unitConv / curSpace.floorArea, 4);
   12335             :             } else {
   12336           3 :                 spaceTableBody(colSpacePlugProcess, spaceTableRowNum) = RealToStr(0.0, 4);
   12337             :             }
   12338             : 
   12339        9352 :             spaceTableBody(colSpaceTags, spaceTableRowNum) = fmt::format("{}", fmt::join(curSpace.tags, ", "));
   12340             : 
   12341             :             // If not part of total, goes directly to this row
   12342        4676 :             if (!useSpaceFloorArea) {
   12343         124 :                 spaceTypeNotTotArea(curSpace.spaceTypeNum) += curSpace.floorArea * mult;
   12344         124 :                 state.dataOutRptTab->zstArea(state.dataOutRptTab->notpartTotal) += mult * curSpace.floorArea;
   12345         124 :                 state.dataOutRptTab->zstLight(state.dataOutRptTab->notpartTotal) += mult * spaceTotLighting(spaceNum);
   12346         124 :                 state.dataOutRptTab->zstPeople(state.dataOutRptTab->notpartTotal) += mult * spaceTotPeople(spaceNum);
   12347         124 :                 state.dataOutRptTab->zstPlug(state.dataOutRptTab->notpartTotal) += mult * spaceTotPlugProcess(spaceNum);
   12348             :             } else {
   12349             :                 // Add it to the 'Total'
   12350        4552 :                 spaceTypeTotArea(curSpace.spaceTypeNum) += curSpace.floorArea * mult;
   12351        4552 :                 state.dataOutRptTab->zstArea(state.dataOutRptTab->grandTotal) += mult * curSpace.floorArea;
   12352        4552 :                 state.dataOutRptTab->zstLight(state.dataOutRptTab->grandTotal) += mult * spaceTotLighting(spaceNum);
   12353        4552 :                 state.dataOutRptTab->zstPeople(state.dataOutRptTab->grandTotal) += mult * spaceTotPeople(spaceNum);
   12354        4552 :                 state.dataOutRptTab->zstPlug(state.dataOutRptTab->grandTotal) += mult * spaceTotPlugProcess(spaceNum);
   12355             : 
   12356             :                 // Subtotal between cond/unconditioned
   12357        4552 :                 if (spaceIsCond) {
   12358        4181 :                     spaceTypeCondArea(curSpace.spaceTypeNum) += curSpace.floorArea * mult;
   12359        4181 :                     state.dataOutRptTab->zstArea(state.dataOutRptTab->condTotal) += mult * curSpace.floorArea;
   12360        4181 :                     state.dataOutRptTab->zstLight(state.dataOutRptTab->condTotal) += mult * spaceTotLighting(spaceNum);
   12361        4181 :                     state.dataOutRptTab->zstPeople(state.dataOutRptTab->condTotal) += mult * spaceTotPeople(spaceNum);
   12362        4181 :                     state.dataOutRptTab->zstPlug(state.dataOutRptTab->condTotal) += mult * spaceTotPlugProcess(spaceNum);
   12363         371 :                 } else if (!spaceIsCond) {
   12364         371 :                     spaceTypeUncondArea(curSpace.spaceTypeNum) += curSpace.floorArea * mult;
   12365         371 :                     state.dataOutRptTab->zstArea(state.dataOutRptTab->uncondTotal) += mult * curSpace.floorArea;
   12366         371 :                     state.dataOutRptTab->zstLight(state.dataOutRptTab->uncondTotal) += mult * spaceTotLighting(spaceNum);
   12367         371 :                     state.dataOutRptTab->zstPeople(state.dataOutRptTab->uncondTotal) += mult * spaceTotPeople(spaceNum);
   12368         371 :                     state.dataOutRptTab->zstPlug(state.dataOutRptTab->uncondTotal) += mult * spaceTotPlugProcess(spaceNum);
   12369             :                 }
   12370             :             }
   12371             :         }
   12372             :     }
   12373             :     // total rows for Total / Not Part of Total
   12374             :     // In "Total": break between conditioned/unconditioned
   12375        3605 :     for (int iTotal = 1; iTotal <= 4; ++iTotal) {
   12376        2884 :         spaceTableBody(colSpaceArea, state.dataGlobal->numSpaces + iTotal) =
   12377        5768 :             RealToStr(state.dataOutRptTab->zstArea(iTotal) * state.dataOutRptTab->m2_unitConvWVST, 2);
   12378        2884 :         if (state.dataOutRptTab->zstArea(iTotal) != 0) {
   12379        1570 :             spaceTableBody(colSpaceLighting, state.dataGlobal->numSpaces + iTotal) =
   12380        3140 :                 RealToStr(state.dataOutRptTab->zstLight(iTotal) * state.dataOutRptTab->Wm2_unitConv / state.dataOutRptTab->zstArea(iTotal), 4);
   12381        1570 :             spaceTableBody(colSpacePlugProcess, state.dataGlobal->numSpaces + iTotal) =
   12382        3140 :                 RealToStr(state.dataOutRptTab->zstPlug(iTotal) * state.dataOutRptTab->Wm2_unitConv / state.dataOutRptTab->zstArea(iTotal), 4);
   12383             :         } else {
   12384        1314 :             spaceTableBody(colSpaceLighting, state.dataGlobal->numSpaces + iTotal) = RealToStr(0.0, 4);
   12385        1314 :             spaceTableBody(colSpacePlugProcess, state.dataGlobal->numSpaces + iTotal) = RealToStr(0.0, 4);
   12386             :         }
   12387        2884 :         if (state.dataOutRptTab->zstPeople(iTotal) != 0) {
   12388        1243 :             spaceTableBody(colSpacePeople, state.dataGlobal->numSpaces + iTotal) =
   12389        2486 :                 RealToStr(state.dataOutRptTab->zstArea(iTotal) * state.dataOutRptTab->m2_unitConvWVST / state.dataOutRptTab->zstPeople(iTotal), 2);
   12390             :         } else {
   12391        1641 :             spaceTableBody(colSpacePeople, state.dataGlobal->numSpaces + iTotal) = RealToStr(0.0, 2);
   12392             :         }
   12393             :     }
   12394             : 
   12395         721 :     Real64 totalArea = 0.0;
   12396         721 :     Real64 condArea = 0.0;
   12397         721 :     Real64 uncondArea = 0.0;
   12398         721 :     Real64 notTotalArea = 0.0;
   12399        1420 :     for (int iSpaceType = 1; iSpaceType <= state.dataGlobal->numSpaceTypes; ++iSpaceType) {
   12400         699 :         spaceTypeRowHead(iSpaceType) = state.dataHeatBal->spaceTypes(iSpaceType);
   12401         699 :         spaceTypeTableBody(colSpaceTypeTotArea, iSpaceType) = RealToStr(spaceTypeTotArea(iSpaceType) * state.dataOutRptTab->m2_unitConvWVST, 2);
   12402         699 :         spaceTypeTableBody(colSpaceTypeCondArea, iSpaceType) = RealToStr(spaceTypeCondArea(iSpaceType) * state.dataOutRptTab->m2_unitConvWVST, 2);
   12403         699 :         spaceTypeTableBody(colSpaceTypeUncondArea, iSpaceType) = RealToStr(spaceTypeUncondArea(iSpaceType) * state.dataOutRptTab->m2_unitConvWVST, 2);
   12404         699 :         spaceTypeTableBody(colSpaceTypeNotTotArea, iSpaceType) = RealToStr(spaceTypeNotTotArea(iSpaceType) * state.dataOutRptTab->m2_unitConvWVST, 2);
   12405         699 :         totalArea += spaceTypeTotArea(iSpaceType);
   12406         699 :         condArea += spaceTypeCondArea(iSpaceType);
   12407         699 :         uncondArea += spaceTypeUncondArea(iSpaceType);
   12408         699 :         notTotalArea += spaceTypeNotTotArea(iSpaceType);
   12409             :         // lighting density
   12410         699 :         if (spaceTypeTotArea(iSpaceType) > 0) {
   12411         696 :             spaceTypeTableBody(colSpaceTypeLighting, iSpaceType) =
   12412        1392 :                 RealToStr(state.dataOutRptTab->Wm2_unitConv * spaceTypeTotLighting(iSpaceType) / spaceTypeTotArea(iSpaceType), 4);
   12413             :         } else {
   12414           3 :             spaceTypeTableBody(colSpaceTypeLighting, iSpaceType) = RealToStr(0.0, 4);
   12415             :         }
   12416             :         // people density
   12417         699 :         if (spaceTypeTotPeople(iSpaceType) > 0) {
   12418         621 :             spaceTypeTableBody(colSpaceTypePeople, iSpaceType) =
   12419        1242 :                 RealToStr(spaceTypeTotArea(iSpaceType) * state.dataOutRptTab->m2_unitConvWVST / spaceTypeTotPeople(iSpaceType), 2);
   12420             :         } else {
   12421          78 :             spaceTypeTableBody(colSpaceTypePeople, iSpaceType) = RealToStr(0.0, 2);
   12422             :         }
   12423             :         // plug and process density
   12424         699 :         if (spaceTypeTotArea(iSpaceType) > 0) {
   12425         696 :             spaceTypeTableBody(colSpaceTypePlugProcess, iSpaceType) =
   12426        1392 :                 RealToStr(spaceTypeTotPlugProcess(iSpaceType) * state.dataOutRptTab->Wm2_unitConv / spaceTypeTotArea(iSpaceType), 4);
   12427             :         } else {
   12428           3 :             spaceTypeTableBody(colSpaceTypePlugProcess, iSpaceType) = RealToStr(0.0, 4);
   12429             :         }
   12430             :     }
   12431             :     // Total Area
   12432         721 :     spaceTypeTableBody(colSpaceTypeTotArea, state.dataGlobal->numSpaceTypes + 1) = RealToStr(totalArea * state.dataOutRptTab->m2_unitConvWVST, 2);
   12433         721 :     spaceTypeTableBody(colSpaceTypeCondArea, state.dataGlobal->numSpaceTypes + 1) = RealToStr(condArea * state.dataOutRptTab->m2_unitConvWVST, 2);
   12434         721 :     spaceTypeTableBody(colSpaceTypeUncondArea, state.dataGlobal->numSpaceTypes + 1) = RealToStr(uncondArea * state.dataOutRptTab->m2_unitConvWVST, 2);
   12435         721 :     spaceTypeTableBody(colSpaceTypeNotTotArea, state.dataGlobal->numSpaceTypes + 1) =
   12436        1442 :         RealToStr(notTotalArea * state.dataOutRptTab->m2_unitConvWVST, 2);
   12437             : 
   12438         721 :     if (produceTabular) {
   12439         721 :         WriteSubtitle(state, "Space Summary");
   12440         721 :         WriteTable(state, spaceTableBody, spaceRowHead, spaceColumnHead, spaceColumnWidth);
   12441             :     }
   12442         721 :     if (produceSQLite) {
   12443         721 :         if (state.dataSQLiteProcedures->sqlite) {
   12444         114 :             state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
   12445             :                 spaceTableBody, spaceRowHead, spaceColumnHead, "InputVerificationandResultsSummary", "Entire Facility", "Space Summary");
   12446             :         }
   12447             :     }
   12448         721 :     if (produceTabular) {
   12449         721 :         if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
   12450           5 :             state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(
   12451             :                 spaceTableBody, spaceRowHead, spaceColumnHead, "InputVerificationandResultsSummary", "Entire Facility", "Space Summary");
   12452             :         }
   12453             :     }
   12454         721 :     if (produceTabular) {
   12455         721 :         WriteSubtitle(state, "Space Type Summary");
   12456         721 :         WriteTable(state, spaceTypeTableBody, spaceTypeRowHead, spaceTypeColumnHead, spaceTypeColumnWidth);
   12457             :     }
   12458         721 :     if (produceSQLite) {
   12459         721 :         if (state.dataSQLiteProcedures->sqlite) {
   12460         114 :             state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(spaceTypeTableBody,
   12461             :                                                                                spaceTypeRowHead,
   12462             :                                                                                spaceTypeColumnHead,
   12463             :                                                                                "InputVerificationandResultsSummary",
   12464             :                                                                                "Entire Facility",
   12465             :                                                                                "Space Type Summary");
   12466             :         }
   12467             :     }
   12468         721 :     if (produceTabular) {
   12469         721 :         if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
   12470           5 :             state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(spaceTypeTableBody,
   12471             :                                                                                                   spaceTypeRowHead,
   12472             :                                                                                                   spaceTypeColumnHead,
   12473             :                                                                                                   "InputVerificationandResultsSummary",
   12474             :                                                                                                   "Entire Facility",
   12475             :                                                                                                   "Space Type Summary");
   12476             :         }
   12477             :     }
   12478         721 : }
   12479             : 
   12480         731 : void WriteAdaptiveComfortTable(EnergyPlusData &state)
   12481             : {
   12482             : 
   12483             :     // SUBROUTINE INFORMATION:
   12484             :     //       AUTHOR         Tyler Hoyt
   12485             :     //       DATE WRITTEN   August 2011
   12486             :     //       MODIFIED       na
   12487             :     //       RE-ENGINEERED  na
   12488             : 
   12489             :     // PURPOSE OF THIS SUBROUTINE:
   12490             :     // Writes summary table for adaptive comfort models. Tabulates
   12491             :     // occupied hours not meeting comfort bounds for ASHRAE-55 and
   12492             :     // CEN-15251 adaptive models.
   12493             : 
   12494        1462 :     Array1D_string columnHead(5);
   12495        1462 :     Array1D_int columnWidth;
   12496        1462 :     Array1D_string rowHead;
   12497        1462 :     Array2D_string tableBody;
   12498             :     int i;
   12499        1462 :     Array1D_int peopleInd; // Index the relevant people
   12500         731 :     auto &ort(state.dataOutRptTab);
   12501             : 
   12502             :     // Should deallocate after writing table. - LKL
   12503             : 
   12504         731 :     if (ort->displayAdaptiveComfort && state.dataHeatBal->TotPeople > 0) {
   12505         553 :         peopleInd.allocate(state.dataHeatBal->TotPeople);
   12506             : 
   12507        3345 :         for (i = 1; i <= state.dataHeatBal->TotPeople; ++i) {
   12508        2792 :             if (state.dataHeatBal->People(i).AdaptiveASH55 || state.dataHeatBal->People(i).AdaptiveCEN15251) {
   12509           6 :                 ++ort->numPeopleAdaptive;
   12510           6 :                 peopleInd(ort->numPeopleAdaptive) = i;
   12511             :             }
   12512             :         }
   12513             : 
   12514         553 :         rowHead.allocate(ort->numPeopleAdaptive);
   12515         553 :         tableBody.allocate(5, ort->numPeopleAdaptive);
   12516             : 
   12517         553 :         WriteReportHeaders(state, "Adaptive Comfort Summary", "Entire Facility", OutputProcessor::StoreType::Averaged);
   12518         553 :         WriteSubtitle(state, "Time Not Meeting the Adaptive Comfort Models during Occupied Hours");
   12519             : 
   12520         553 :         columnWidth.allocate(5);
   12521         553 :         columnWidth = 10;
   12522         553 :         columnHead(1) = "ASHRAE55 90% Acceptability Limits [Hours]";
   12523         553 :         columnHead(2) = "ASHRAE55 80% Acceptability Limits  [Hours]";
   12524         553 :         columnHead(3) = "CEN15251 Category I Acceptability Limits [Hours]";
   12525         553 :         columnHead(4) = "CEN15251 Category II Acceptability Limits [Hours]";
   12526         553 :         columnHead(5) = "CEN15251 Category III Acceptability Limits [Hours]";
   12527             : 
   12528         553 :         tableBody = "";
   12529         559 :         for (i = 1; i <= ort->numPeopleAdaptive; ++i) {
   12530           6 :             rowHead(i) = state.dataHeatBal->People(i).Name;
   12531           6 :             if (state.dataHeatBal->People(i).AdaptiveASH55) {
   12532           6 :                 tableBody(1, i) = RealToStr(state.dataHeatBal->People(peopleInd(i)).TimeNotMetASH5590, 2);
   12533           6 :                 tableBody(2, i) = RealToStr(state.dataHeatBal->People(peopleInd(i)).TimeNotMetASH5580, 2);
   12534             :             }
   12535           6 :             if (state.dataHeatBal->People(i).AdaptiveCEN15251) {
   12536           1 :                 tableBody(3, i) = RealToStr(state.dataHeatBal->People(peopleInd(i)).TimeNotMetCEN15251CatI, 2);
   12537           1 :                 tableBody(4, i) = RealToStr(state.dataHeatBal->People(peopleInd(i)).TimeNotMetCEN15251CatII, 2);
   12538           1 :                 tableBody(5, i) = RealToStr(state.dataHeatBal->People(peopleInd(i)).TimeNotMetCEN15251CatIII, 2);
   12539             :             }
   12540             :         }
   12541             : 
   12542         553 :         WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
   12543         553 :         if (state.dataSQLiteProcedures->sqlite) {
   12544          52 :             state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(tableBody,
   12545             :                                                                                rowHead,
   12546             :                                                                                columnHead,
   12547             :                                                                                "AdaptiveComfortSummary",
   12548             :                                                                                "Entire Facility",
   12549             :                                                                                "Time Not Meeting the Adaptive Comfort Models during Occupied Hours");
   12550             :         }
   12551         553 :         if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
   12552           4 :             state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(
   12553             :                 tableBody,
   12554             :                 rowHead,
   12555             :                 columnHead,
   12556             :                 "AdaptiveComfortSummary",
   12557             :                 "Entire Facility",
   12558             :                 "Time Not Meeting the Adaptive Comfort Models during Occupied Hours");
   12559             :         }
   12560             :     }
   12561         731 : }
   12562             : 
   12563          38 : std::string formatReportPeriodTimestamp(const int year, const int month, const int day, const int hour)
   12564             : {
   12565          38 :     if (year != 0) {
   12566           0 :         return fmt::format("{}/{}/{} {}:00", year, month, day, hour);
   12567             :     } else {
   12568          38 :         return fmt::format("{}/{} {}:00", month, day, hour);
   12569             :     }
   12570             : }
   12571             : 
   12572           8 : void WriteReportHeaderReportingPeriod(EnergyPlusData &state,
   12573             :                                       const std::string reportKeyWord,
   12574             :                                       const int periodIdx,
   12575             :                                       const Array1D<WeatherManager::ReportPeriodData> &ReportPeriodInputData)
   12576             : {
   12577          24 :     WriteReportHeaders(
   12578             :         state,
   12579          16 :         fmt::format("{} Resilience Summary for Reporting Period {}: {}", reportKeyWord, periodIdx, ReportPeriodInputData(periodIdx).title),
   12580             :         "Entire Facility",
   12581             :         OutputProcessor::StoreType::Averaged);
   12582             : 
   12583           8 :     WriteSubtitle(state,
   12584          16 :                   format("Reporting period: {} -- {}, Total Electricity Usage: {:.2R} kWh",
   12585          16 :                          formatReportPeriodTimestamp(ReportPeriodInputData(periodIdx).startYear,
   12586           8 :                                                      ReportPeriodInputData(periodIdx).startMonth,
   12587           8 :                                                      ReportPeriodInputData(periodIdx).startDay,
   12588           8 :                                                      ReportPeriodInputData(periodIdx).startHour),
   12589          16 :                          formatReportPeriodTimestamp(ReportPeriodInputData(periodIdx).endYear,
   12590           8 :                                                      ReportPeriodInputData(periodIdx).endMonth,
   12591           8 :                                                      ReportPeriodInputData(periodIdx).endDay,
   12592           8 :                                                      ReportPeriodInputData(periodIdx).endHour),
   12593          24 :                          ReportPeriodInputData(periodIdx).totalElectricityUse / 3600000.0));
   12594           8 : }
   12595             : 
   12596           4 : void WriteReportPeriodTimeConsumption(EnergyPlusData &state)
   12597             : {
   12598             :     // Reporting Period Time and Consumption Table
   12599             :     // It has the following columns: report type (thermal, co2, visual), period, start, end, total electricity
   12600           8 :     Array1D_string columnHead;
   12601           8 :     Array1D_int columnWidth;
   12602           8 :     Array1D_string rowHead;
   12603           8 :     Array2D_string tableBody;
   12604             :     int numRowsReportPeriod =
   12605           4 :         state.dataWeatherManager->TotThermalReportPers + state.dataWeatherManager->TotCO2ReportPers + state.dataWeatherManager->TotVisualReportPers;
   12606           4 :     rowHead.allocate(numRowsReportPeriod);
   12607           4 :     columnHead.allocate(6);
   12608           4 :     columnWidth.allocate(6);
   12609           4 :     columnWidth = 14; // array assignment - same for all columns
   12610           4 :     tableBody.allocate(6, numRowsReportPeriod);
   12611             : 
   12612           4 :     int constexpr reportperiodType(1);
   12613           4 :     int constexpr reportperiodId(2);
   12614           4 :     int constexpr reportperiodTitle(3);
   12615           4 :     int constexpr reportperiodStart(4);
   12616           4 :     int constexpr reportperiodEnd(5);
   12617           4 :     int constexpr reportperiodElectricity(6);
   12618             : 
   12619           4 :     WriteReportHeaders(state, "Reporting Period Summary", "Entire Facility", OutputProcessor::StoreType::Averaged);
   12620             : 
   12621           4 :     columnHead(reportperiodType) = "Report Type";
   12622           4 :     columnHead(reportperiodId) = "Report Index";
   12623           4 :     columnHead(reportperiodTitle) = "Title";
   12624           4 :     columnHead(reportperiodStart) = "Start Time";
   12625           4 :     columnHead(reportperiodEnd) = "End Time";
   12626           4 :     columnHead(reportperiodElectricity) = "Total Electricity (kWh)";
   12627          15 :     for (int i = 1; i <= numRowsReportPeriod; i++) {
   12628          11 :         rowHead(i) = std::to_string(i);
   12629             :     }
   12630             :     // loop through rows
   12631           4 :     int rowid = 1;
   12632           9 :     for (int periodIdx = 1; periodIdx <= state.dataWeatherManager->TotThermalReportPers; periodIdx++) {
   12633           5 :         writeRowReportPeriodInputVeri("Thermal", tableBody, rowid, periodIdx, state.dataWeatherManager->ThermalReportPeriodInput);
   12634           5 :         rowid += 1;
   12635             :     }
   12636           7 :     for (int periodIdx = 1; periodIdx <= state.dataWeatherManager->TotCO2ReportPers; periodIdx++) {
   12637           3 :         writeRowReportPeriodInputVeri("CO2", tableBody, rowid, periodIdx, state.dataWeatherManager->CO2ReportPeriodInput);
   12638           3 :         rowid += 1;
   12639             :     }
   12640           7 :     for (int periodIdx = 1; periodIdx <= state.dataWeatherManager->TotVisualReportPers; periodIdx++) {
   12641           3 :         writeRowReportPeriodInputVeri("Visual", tableBody, rowid, periodIdx, state.dataWeatherManager->VisualReportPeriodInput);
   12642           3 :         rowid += 1;
   12643             :     }
   12644             : 
   12645           8 :     std::string tableName = "Reporting Period Time and Consumption";
   12646           4 :     WriteSubtitle(state, tableName);
   12647           4 :     WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
   12648           4 :     if (state.dataSQLiteProcedures->sqlite) {
   12649           0 :         if (state.dataSQLiteProcedures->sqlite) {
   12650           0 :             state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
   12651             :                 tableBody, rowHead, columnHead, "ReportingPeriodSummary", "Entire Facility", tableName);
   12652             :         }
   12653             :     }
   12654           4 :     if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
   12655           0 :         state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(
   12656             :             tableBody, rowHead, columnHead, "Reporting Period Summary", "Entire Facility", tableName);
   12657             :     }
   12658           4 : }
   12659             : 
   12660           5 : void WriteThermalResilienceTablesRepPeriod(EnergyPlusData &state, int const periodIdx)
   12661             : {
   12662             : 
   12663           5 :     auto &ort(state.dataOutRptTab);
   12664           5 :     if (ort->WriteTabularFiles) {
   12665             : 
   12666             :         Real64 degreeHourConversion;
   12667           5 :         UnitsStyle unitsStyle_cur = ort->unitsStyle;
   12668             : 
   12669           5 :         if (unitsStyle_cur == UnitsStyle::InchPound) {
   12670           0 :             degreeHourConversion = getSpecificUnitMultiplier(state, "°C·hr", "°F·hr");
   12671             :         } else {
   12672           5 :             degreeHourConversion = 1.0;
   12673             :         }
   12674             : 
   12675          10 :         std::string tableType = "Thermal";
   12676           5 :         WriteReportHeaderReportingPeriod(state, tableType, periodIdx, state.dataWeatherManager->ThermalReportPeriodInput);
   12677          10 :         std::string periodTitle = state.dataWeatherManager->ThermalReportPeriodInput(periodIdx).title;
   12678             : 
   12679           5 :         int columnNum = 5;
   12680          10 :         Array1D_int columnWidth;
   12681           5 :         columnWidth.allocate(columnNum);
   12682           5 :         columnWidth = 10;
   12683          10 :         Array1D_string columnHead(5);
   12684           5 :         if (unitsStyle_cur == UnitsStyle::InchPound) {
   12685           0 :             columnHead(1) = "Safe (≤ 80.1°F) [hr]";
   12686           0 :             columnHead(2) = "Caution (> 80.1°F, ≤ 90.0°F) [hr]";
   12687           0 :             columnHead(3) = "Extreme Caution (> 90.0°F, ≤ 102.9°F) [hr]";
   12688           0 :             columnHead(4) = "Danger (> 102.9, ≤ 125.1°F) [hr]";
   12689           0 :             columnHead(5) = "Extreme Danger (> 125.1°F) [hr]";
   12690             :         } else {
   12691           5 :             columnHead(1) = "Safe (≤ 26.7°C) [hr]";
   12692           5 :             columnHead(2) = "Caution (> 26.7°C, ≤ 32.2°C) [hr]";
   12693           5 :             columnHead(3) = "Extreme Caution (> 32.2°C, ≤ 39.4°C) [hr]";
   12694           5 :             columnHead(4) = "Danger (> 39.4°C, ≤ 51.7°C) [hr]";
   12695           5 :             columnHead(5) = "Extreme Danger (> 51.7°C) [hr]";
   12696             :         }
   12697             : 
   12698          10 :         Array1D_string rowHead;
   12699          10 :         Array2D_string tableBody;
   12700           5 :         rowHead.allocate(state.dataGlobal->NumOfZones + 4);
   12701           5 :         tableBody.allocate(columnNum, state.dataGlobal->NumOfZones + 4);
   12702             : 
   12703          10 :         std::string tableName = "Heat Index Hours";
   12704           5 :         WriteResilienceBinsTableReportingPeriod(state,
   12705             :                                                 tableType,
   12706             :                                                 columnNum,
   12707             :                                                 periodIdx,
   12708             :                                                 periodTitle,
   12709             :                                                 tableName,
   12710             :                                                 columnHead,
   12711             :                                                 columnWidth,
   12712           5 :                                                 state.dataHeatBalFanSys->ZoneHeatIndexHourBinsRepPeriod,
   12713             :                                                 rowHead,
   12714             :                                                 tableBody);
   12715             : 
   12716           5 :         tableName = "Heat Index OccupantHours";
   12717           5 :         WriteResilienceBinsTableReportingPeriod(state,
   12718             :                                                 tableType,
   12719             :                                                 columnNum,
   12720             :                                                 periodIdx,
   12721             :                                                 periodTitle,
   12722             :                                                 tableName,
   12723             :                                                 columnHead,
   12724             :                                                 columnWidth,
   12725           5 :                                                 state.dataHeatBalFanSys->ZoneHeatIndexOccuHourBinsRepPeriod,
   12726             :                                                 rowHead,
   12727             :                                                 tableBody);
   12728             : 
   12729           5 :         tableName = "Heat Index OccupiedHours";
   12730           5 :         WriteResilienceBinsTableReportingPeriod(state,
   12731             :                                                 tableType,
   12732             :                                                 columnNum,
   12733             :                                                 periodIdx,
   12734             :                                                 periodTitle,
   12735             :                                                 tableName,
   12736             :                                                 columnHead,
   12737             :                                                 columnWidth,
   12738           5 :                                                 state.dataHeatBalFanSys->ZoneHeatIndexOccupiedHourBinsRepPeriod,
   12739             :                                                 rowHead,
   12740             :                                                 tableBody);
   12741             : 
   12742           5 :         columnHead(1) = "Little to no Discomfort (≤ 29) [hr]";
   12743           5 :         columnHead(2) = "Some Discomfort (> 29, ≤ 40) [hr]";
   12744           5 :         columnHead(3) = "Great Discomfort; Avoid Exertion (> 40, ≤ 45) [hr]";
   12745           5 :         columnHead(4) = "Dangerous (> 45, ≤ 50) [hr]";
   12746           5 :         columnHead(5) = "Heat Stroke Quite Possible (> 50) [hr]";
   12747           5 :         tableName = "Humidex Hours";
   12748           5 :         WriteResilienceBinsTableReportingPeriod(state,
   12749             :                                                 tableType,
   12750             :                                                 columnNum,
   12751             :                                                 periodIdx,
   12752             :                                                 periodTitle,
   12753             :                                                 tableName,
   12754             :                                                 columnHead,
   12755             :                                                 columnWidth,
   12756           5 :                                                 state.dataHeatBalFanSys->ZoneHumidexHourBinsRepPeriod,
   12757             :                                                 rowHead,
   12758             :                                                 tableBody);
   12759             : 
   12760           5 :         tableName = "Humidex OccupantHours";
   12761           5 :         WriteResilienceBinsTableReportingPeriod(state,
   12762             :                                                 tableType,
   12763             :                                                 columnNum,
   12764             :                                                 periodIdx,
   12765             :                                                 periodTitle,
   12766             :                                                 tableName,
   12767             :                                                 columnHead,
   12768             :                                                 columnWidth,
   12769           5 :                                                 state.dataHeatBalFanSys->ZoneHumidexOccuHourBinsRepPeriod,
   12770             :                                                 rowHead,
   12771             :                                                 tableBody);
   12772             : 
   12773           5 :         tableName = "Humidex OccupiedHours";
   12774           5 :         WriteResilienceBinsTableReportingPeriod(state,
   12775             :                                                 tableType,
   12776             :                                                 columnNum,
   12777             :                                                 periodIdx,
   12778             :                                                 periodTitle,
   12779             :                                                 tableName,
   12780             :                                                 columnHead,
   12781             :                                                 columnWidth,
   12782           5 :                                                 state.dataHeatBalFanSys->ZoneHumidexOccupiedHourBinsRepPeriod,
   12783             :                                                 rowHead,
   12784             :                                                 tableBody);
   12785             : 
   12786           5 :         bool hasPierceSET = true;
   12787           5 :         if (state.dataHeatBal->TotPeople == 0) {
   12788           0 :             hasPierceSET = false;
   12789           0 :             if (ort->displayThermalResilienceSummaryExplicitly) {
   12790           0 :                 ShowWarningError(state,
   12791             :                                  "Writing Reporting Period Thermal Resilience Summary - SET Degree-Hours reports: "
   12792             :                                  "Zone Thermal Comfort Pierce Model Standard Effective Temperature is required, "
   12793             :                                  "but no People object is defined.");
   12794             :             }
   12795             :         }
   12796          13 :         for (int iPeople = 1; iPeople <= state.dataHeatBal->TotPeople; ++iPeople) {
   12797           8 :             if (!state.dataHeatBal->People(iPeople).Pierce) {
   12798           0 :                 hasPierceSET = false;
   12799           0 :                 if (ort->displayThermalResilienceSummaryExplicitly) {
   12800           0 :                     ShowWarningError(state,
   12801             :                                      "Writing Reporting Period Thermal Resilience Summary - SET Degree-Hours reports: "
   12802             :                                      "Zone Thermal Comfort Pierce Model Standard Effective Temperature is required, "
   12803           0 :                                      "but no Pierce model is defined in " +
   12804           0 :                                          state.dataHeatBal->People(iPeople).Name + " object.");
   12805             :                 }
   12806             :             }
   12807             :         }
   12808             : 
   12809           5 :         if (hasPierceSET) {
   12810           5 :             columnHead(1) = "SET ≤ 12.2°C Degree-Hours [°C·hr]";
   12811           5 :             columnHead(2) = "SET ≤ 12.2°C Occupant-Weighted Degree-Hours [°C·hr]";
   12812           5 :             columnHead(3) = "SET ≤ 12.2°C Occupied Degree-Hours [°C·hr]";
   12813           5 :             columnHead(4) = "Longest SET ≤ 12.2°C Duration for Occupied Period [hr]";
   12814           5 :             columnHead(5) = "Start Time of the Longest SET ≤ 12.2°C Duration for Occupied Period ";
   12815             : 
   12816           5 :             if (unitsStyle_cur == UnitsStyle::InchPound) {
   12817           0 :                 columnHead(1) = "SET ≤ 54.0°F Degree-Hours [°F·hr]";
   12818           0 :                 columnHead(2) = "SET ≤ 54.0°F Occupant-Weighted Degree-Hours [°F·hr]";
   12819           0 :                 columnHead(3) = "SET ≤ 54.0°F Occupied Degree-Hours [°F·hr]";
   12820           0 :                 columnHead(4) = "Longest SET ≤ 54.0°F Duration for Occupied Period [hr]";
   12821           0 :                 columnHead(5) = "Start Time of the Longest SET ≤ 54.0°F Duration for Occupied Period ";
   12822             :             } else {
   12823           5 :                 columnHead(1) = "SET ≤ 12.2°C Degree-Hours [°C·hr]";
   12824           5 :                 columnHead(2) = "SET ≤ 12.2°C Occupant-Weighted Degree-Hours [°C·hr]";
   12825           5 :                 columnHead(3) = "SET ≤ 12.2°C Occupied Degree-Hours [°C·hr]";
   12826           5 :                 columnHead(4) = "Longest SET ≤ 12.2°C Duration for Occupied Period [hr]";
   12827           5 :                 columnHead(5) = "Start Time of the Longest SET ≤ 12.2°C Duration for Occupied Period ";
   12828             :             }
   12829             : 
   12830           5 :             tableName = "Heating SET Degree-Hours";
   12831          10 :             Array1D_string rowHeadSET;
   12832          10 :             Array2D_string tableBodySET;
   12833           5 :             rowHeadSET.allocate(state.dataGlobal->NumOfZones + 3);
   12834           5 :             tableBodySET.allocate(columnNum, state.dataGlobal->NumOfZones + 3);
   12835           5 :             WriteSETHoursTableReportingPeriod(state,
   12836             :                                               columnNum,
   12837             :                                               periodIdx,
   12838             :                                               periodTitle,
   12839             :                                               tableName,
   12840             :                                               columnHead,
   12841             :                                               columnWidth,
   12842           5 :                                               state.dataHeatBalFanSys->ZoneLowSETHoursRepPeriod,
   12843             :                                               rowHeadSET,
   12844             :                                               tableBodySET,
   12845             :                                               degreeHourConversion);
   12846             : 
   12847           5 :             if (unitsStyle_cur == UnitsStyle::InchPound) {
   12848           0 :                 columnHead(1) = "SET > 86°F Degree-Hours [°F·hr]";
   12849           0 :                 columnHead(2) = "SET > 86°F Occupant-Weighted Degree-Hours [°F·hr]";
   12850           0 :                 columnHead(3) = "SET > 86°F Occupied Degree-Hours [°F·hr]";
   12851           0 :                 columnHead(4) = "Longest SET > 86°F Duration for Occupied Period [hr]";
   12852           0 :                 columnHead(5) = "Start Time of the Longest SET > 86°F Duration for Occupied Period";
   12853             :             } else {
   12854           5 :                 columnHead(1) = "SET > 30°C Degree-Hours [°C·hr]";
   12855           5 :                 columnHead(2) = "SET > 30°C Occupant-Weighted Degree-Hours [°C·hr]";
   12856           5 :                 columnHead(3) = "SET > 30°C Occupied Degree-Hours [°C·hr]";
   12857           5 :                 columnHead(4) = "Longest SET > 30°C Duration for Occupied Period [hr]";
   12858           5 :                 columnHead(5) = "Start Time of the Longest SET > 30°C Duration for Occupied Period";
   12859             :             }
   12860             : 
   12861           5 :             tableName = "Cooling SET Degree-Hours";
   12862           5 :             WriteSETHoursTableReportingPeriod(state,
   12863             :                                               columnNum,
   12864             :                                               periodIdx,
   12865             :                                               periodTitle,
   12866             :                                               tableName,
   12867             :                                               columnHead,
   12868             :                                               columnWidth,
   12869           5 :                                               state.dataHeatBalFanSys->ZoneHighSETHoursRepPeriod,
   12870             :                                               rowHeadSET,
   12871             :                                               tableBodySET,
   12872             :                                               degreeHourConversion);
   12873             :         }
   12874             : 
   12875           5 :         columnHead(1) = "Hours of Safety [hr]";
   12876           5 :         columnHead(2) = "End Time of the Safety Duration";
   12877           5 :         columnHead(3) = "Safe Temperature Exceedance Hours [hr]";
   12878           5 :         columnHead(4) = "Safe Temperature Exceedance OccupantHours [hr]";
   12879           5 :         columnHead(5) = "Safe Temperature Exceedance OccupiedHours [hr]";
   12880           5 :         tableName = "Hours of Safety for Cold Events";
   12881           5 :         WriteHourOfSafetyTableReportingPeriod(state,
   12882             :                                               columnNum,
   12883             :                                               periodIdx,
   12884             :                                               periodTitle,
   12885             :                                               tableName,
   12886             :                                               columnHead,
   12887             :                                               columnWidth,
   12888           5 :                                               state.dataHeatBalFanSys->ZoneColdHourOfSafetyBinsRepPeriod,
   12889             :                                               rowHead,
   12890             :                                               tableBody,
   12891             :                                               2);
   12892             : 
   12893           5 :         tableName = "Hours of Safety for Heat Events";
   12894           5 :         WriteHourOfSafetyTableReportingPeriod(state,
   12895             :                                               columnNum,
   12896             :                                               periodIdx,
   12897             :                                               periodTitle,
   12898             :                                               tableName,
   12899             :                                               columnHead,
   12900             :                                               columnWidth,
   12901           5 :                                               state.dataHeatBalFanSys->ZoneHeatHourOfSafetyBinsRepPeriod,
   12902             :                                               rowHead,
   12903             :                                               tableBody,
   12904             :                                               2);
   12905             : 
   12906           5 :         int columnNumUnmetDegHr = 6;
   12907          10 :         Array1D_string columnHeadUnmetDegHr(6);
   12908             :         // must initialize this otherwise it will only output 5 columns
   12909          10 :         Array1D_int columnWidthUnmetDegHr;
   12910           5 :         columnWidthUnmetDegHr.allocate(columnNumUnmetDegHr);
   12911           5 :         columnWidthUnmetDegHr = 10;
   12912           5 :         columnHeadUnmetDegHr(1) = "Cooling Setpoint Unmet Degree-Hours [°C·hr]";
   12913           5 :         columnHeadUnmetDegHr(2) = "Cooling Setpoint Unmet Occupant-Weighted Degree-Hours [°C·hr]";
   12914           5 :         columnHeadUnmetDegHr(3) = "Cooling Setpoint Unmet Occupied Degree-Hours [°C·hr]";
   12915           5 :         columnHeadUnmetDegHr(4) = "Heating Setpoint Unmet Degree-Hours [°C·hr]";
   12916           5 :         columnHeadUnmetDegHr(5) = "Heating Setpoint Unmet Occupant-Weighted Degree-Hours [°C·hr]";
   12917           5 :         columnHeadUnmetDegHr(6) = "Heating Setpoint Unmet Occupied Degree-Hours [°C·hr]";
   12918           5 :         tableName = "Unmet Degree-Hours";
   12919             : 
   12920           5 :         if (unitsStyle_cur == UnitsStyle::InchPound) {
   12921             :             int indexUnitConv;
   12922           0 :             std::string curUnits;
   12923           0 :             for (int i = 1; i < columnNumUnmetDegHr; i++) {
   12924           0 :                 LookupSItoIP(state, columnHeadUnmetDegHr(i), indexUnitConv, curUnits);
   12925           0 :                 columnHeadUnmetDegHr(i) = curUnits;
   12926             :             }
   12927             :         }
   12928             : 
   12929          10 :         Array2D_string tableBodyUnmetDegHr;
   12930           5 :         tableBodyUnmetDegHr.allocate(columnNumUnmetDegHr, state.dataGlobal->NumOfZones + 4);
   12931           5 :         WriteResilienceBinsTableReportingPeriod(state,
   12932             :                                                 tableType,
   12933             :                                                 columnNumUnmetDegHr,
   12934             :                                                 periodIdx,
   12935             :                                                 periodTitle,
   12936             :                                                 tableName,
   12937             :                                                 columnHeadUnmetDegHr,
   12938             :                                                 columnWidthUnmetDegHr,
   12939           5 :                                                 state.dataHeatBalFanSys->ZoneUnmetDegreeHourBinsRepPeriod,
   12940             :                                                 rowHead,
   12941             :                                                 tableBodyUnmetDegHr,
   12942             :                                                 degreeHourConversion);
   12943             : 
   12944           5 :         int columnNumDiscomfortWt = 4;
   12945          10 :         Array1D_string columnHeadDiscomfortWt(columnNumDiscomfortWt);
   12946           5 :         columnHeadDiscomfortWt(1) = "Very-cold Exceedance OccupiedHours [hr]";
   12947           5 :         columnHeadDiscomfortWt(2) = "Cool Exceedance OccupiedHours [hr]";
   12948           5 :         columnHeadDiscomfortWt(3) = "Warm Exceedance OccupiedHours [hr]";
   12949           5 :         columnHeadDiscomfortWt(4) = "Very-hot Exceedance OccupiedHours [hr]";
   12950           5 :         tableName = "Discomfort-weighted Exceedance OccupantHours";
   12951          10 :         Array1D_int columnWidthDiscomfortWt;
   12952           5 :         columnWidthDiscomfortWt.allocate(columnNumDiscomfortWt);
   12953           5 :         columnWidth = 10;
   12954          10 :         Array2D_string tableBodyDiscomfortWt;
   12955           5 :         tableBodyDiscomfortWt.allocate(columnNumDiscomfortWt, state.dataGlobal->NumOfZones + 4);
   12956           5 :         WriteResilienceBinsTableReportingPeriod(state,
   12957             :                                                 tableType,
   12958             :                                                 columnNumDiscomfortWt,
   12959             :                                                 periodIdx,
   12960             :                                                 periodTitle,
   12961             :                                                 tableName,
   12962             :                                                 columnHeadDiscomfortWt,
   12963             :                                                 columnWidthDiscomfortWt,
   12964           5 :                                                 state.dataHeatBalFanSys->ZoneDiscomfortWtExceedOccuHourBinsRepPeriod,
   12965             :                                                 rowHead,
   12966             :                                                 tableBodyDiscomfortWt);
   12967           5 :         tableName = "Discomfort-weighted Exceedance OccupiedHours";
   12968           5 :         WriteResilienceBinsTableReportingPeriod(state,
   12969             :                                                 tableType,
   12970             :                                                 columnNumDiscomfortWt,
   12971             :                                                 periodIdx,
   12972             :                                                 periodTitle,
   12973             :                                                 tableName,
   12974             :                                                 columnHeadDiscomfortWt,
   12975             :                                                 columnWidthDiscomfortWt,
   12976           5 :                                                 state.dataHeatBalFanSys->ZoneDiscomfortWtExceedOccupiedHourBinsRepPeriod,
   12977             :                                                 rowHead,
   12978             :                                                 tableBodyDiscomfortWt);
   12979           5 :         columnHead.deallocate();
   12980           5 :         columnWidth.deallocate();
   12981           5 :         tableBody.deallocate();
   12982           5 :         columnHeadUnmetDegHr.deallocate();
   12983           5 :         columnWidthUnmetDegHr.deallocate();
   12984           5 :         tableBodyUnmetDegHr.deallocate();
   12985           5 :         columnHeadDiscomfortWt.deallocate();
   12986           5 :         columnWidthDiscomfortWt.deallocate();
   12987           5 :         tableBodyDiscomfortWt.deallocate();
   12988             :     }
   12989           5 : }
   12990             : 
   12991             : template <int columnNum>
   12992         201 : void WriteResilienceBinsTable(EnergyPlusData &state,
   12993             :                               std::array<int, columnNum> const &columnHead,
   12994             :                               const std::array<Real64, columnNum> DataHeatBalance::ZoneResilience::*memberPtr,
   12995             :                               Real64 const unitConvMultiplier)
   12996             : {
   12997         201 :     std::array<Real64, columnNum> columnMax = {0.0};
   12998         201 :     std::array<Real64, columnNum> columnMin = {0.0};
   12999         201 :     std::array<Real64, columnNum> columnSum = {0.0};
   13000         963 :     for (int j = 0; j < columnNum; j++) {
   13001         762 :         columnMin[j] = (state.dataHeatBal->Resilience(1).*memberPtr)[j] * unitConvMultiplier;
   13002             :     }
   13003        2211 :     for (int i = 1; i <= state.dataGlobal->NumOfZones; ++i) {
   13004        2010 :         const std::string &ZoneName = state.dataHeatBal->Zone(i).Name;
   13005        9888 :         for (int j = 0; j < columnNum; j++) {
   13006        7878 :             Real64 curValue = (state.dataHeatBal->Resilience(i).*memberPtr)[j] * unitConvMultiplier;
   13007        7878 :             if (curValue > columnMax[j]) columnMax[j] = curValue;
   13008        7878 :             if (curValue < columnMin[j]) columnMin[j] = curValue;
   13009        7878 :             columnSum[j] += curValue;
   13010        7878 :             PreDefTableEntry(state, columnHead[j], ZoneName, RealToStr(curValue, 2));
   13011             :         }
   13012             :     }
   13013         963 :     for (int j = 0; j < columnNum; j++) {
   13014         762 :         PreDefTableEntry(state, columnHead[j], "Min", RealToStr(columnMin[j], 2));
   13015         762 :         PreDefTableEntry(state, columnHead[j], "Max", RealToStr(columnMax[j], 2));
   13016         762 :         PreDefTableEntry(state, columnHead[j], "Average", RealToStr(columnSum[j] / state.dataGlobal->NumOfZones, 2));
   13017         762 :         PreDefTableEntry(state, columnHead[j], "Sum", RealToStr(columnSum[j], 2));
   13018             :     }
   13019         201 : }
   13020             : 
   13021             : template <int columnNum>
   13022        5670 : void WriteResilienceBinsTableNonPreDefUseZoneData(EnergyPlusData &state,
   13023             :                                                   const std::string &tableName,
   13024             :                                                   Array1D_string const &columnHead,
   13025             :                                                   Array1D_int &columnWidth,
   13026             :                                                   const std::array<Real64, columnNum> DataHeatBalance::ZoneResilience::*memberPtr,
   13027             :                                                   Array1D_string &rowHead,
   13028             :                                                   Array2D_string &tableBody,
   13029             :                                                   Real64 const unitConvMultiplier)
   13030             : {
   13031        5670 :     WriteSubtitle(state, tableName);
   13032             : 
   13033        5670 :     std::array<Real64, columnNum> columnMax = {0.0};
   13034        5670 :     std::array<Real64, columnNum> columnMin = {0.0};
   13035        5670 :     std::array<Real64, columnNum> columnSum = {0.0};
   13036             : 
   13037       33390 :     for (int j = 0; j < columnNum; j++) {
   13038       27720 :         columnMin.at(j) = (state.dataHeatBal->Resilience(1).*memberPtr).at(j) * unitConvMultiplier;
   13039             :     }
   13040       36747 :     for (int ZoneNum = 1; ZoneNum <= state.dataGlobal->NumOfZones; ZoneNum++) {
   13041       31077 :         rowHead(ZoneNum) = state.dataHeatBal->Zone(ZoneNum).Name;
   13042       62154 :         std::string ZoneName = state.dataHeatBal->Zone(ZoneNum).Name;
   13043      183009 :         for (int j = 0; j < columnNum; j++) {
   13044      151932 :             Real64 curValue = (state.dataHeatBal->Resilience(ZoneNum).*memberPtr).at(j) * unitConvMultiplier;
   13045      151932 :             if (curValue > columnMax.at(j)) columnMax.at(j) = curValue;
   13046      151932 :             if (curValue < columnMin.at(j)) columnMin.at(j) = curValue;
   13047      151932 :             columnSum.at(j) += curValue;
   13048      151932 :             tableBody(j + 1, ZoneNum) = RealToStr(curValue, 2);
   13049             :         }
   13050             :     }
   13051             : 
   13052        5670 :     rowHead(state.dataGlobal->NumOfZones + 1) = "Min";
   13053        5670 :     rowHead(state.dataGlobal->NumOfZones + 2) = "Max";
   13054        5670 :     rowHead(state.dataGlobal->NumOfZones + 3) = "Average";
   13055        5670 :     rowHead(state.dataGlobal->NumOfZones + 4) = "Sum";
   13056             : 
   13057       33390 :     for (int j = 0; j < columnNum; j++) {
   13058       27720 :         tableBody(j + 1, state.dataGlobal->NumOfZones + 1) = RealToStr(columnMin.at(j), 2);
   13059       27720 :         tableBody(j + 1, state.dataGlobal->NumOfZones + 2) = RealToStr(columnMax.at(j), 2);
   13060       27720 :         tableBody(j + 1, state.dataGlobal->NumOfZones + 3) = RealToStr(columnSum.at(j) / state.dataGlobal->NumOfZones, 2);
   13061       27720 :         tableBody(j + 1, state.dataGlobal->NumOfZones + 4) = RealToStr(columnSum.at(j), 2);
   13062             :     }
   13063             : 
   13064        5670 :     WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
   13065        5670 :     if (state.dataSQLiteProcedures->sqlite) {
   13066         549 :         state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
   13067             :             tableBody, rowHead, columnHead, "AnnualThermalResilienceSummary", "Entire Facility", tableName);
   13068             :     }
   13069        5670 :     if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
   13070          36 :         state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(
   13071             :             tableBody, rowHead, columnHead, "AnnualThermalResilienceSummary", "Entire Facility", tableName);
   13072             :     }
   13073        5670 : }
   13074             : 
   13075          54 : void WriteResilienceBinsTableReportingPeriod(EnergyPlusData &state,
   13076             :                                              const std::string &tableType,
   13077             :                                              int const columnNum,
   13078             :                                              int const periodIdx,
   13079             :                                              const std::string &periodTitle,
   13080             :                                              const std::string &tableName,
   13081             :                                              Array1D_string const &columnHead,
   13082             :                                              Array1D_int &columnWidth,
   13083             :                                              Array2D<std::vector<Real64>> const &ZoneBins,
   13084             :                                              Array1D_string &rowHead,
   13085             :                                              Array2D_string &tableBody,
   13086             :                                              Real64 const unitConvMultiplier)
   13087             : {
   13088          54 :     WriteSubtitle(state, tableName);
   13089             : 
   13090         108 :     std::vector<Real64> columnMax(columnNum, 0);
   13091         108 :     std::vector<Real64> columnMin(columnNum, 0);
   13092         108 :     std::vector<Real64> columnSum(columnNum, 0);
   13093             : 
   13094         310 :     for (int j = 0; j < columnNum; j++) {
   13095         256 :         columnMin.at(j) = ZoneBins(1, periodIdx).at(j) * unitConvMultiplier;
   13096             :     }
   13097         108 :     for (int ZoneNum = 1; ZoneNum <= state.dataGlobal->NumOfZones; ZoneNum++) {
   13098          54 :         rowHead(ZoneNum) = state.dataHeatBal->Zone(ZoneNum).Name;
   13099         108 :         std::string ZoneName = state.dataHeatBal->Zone(ZoneNum).Name;
   13100         310 :         for (int j = 0; j < columnNum; j++) {
   13101         256 :             Real64 curValue = ZoneBins(ZoneNum, periodIdx).at(j) * unitConvMultiplier;
   13102         256 :             if (curValue > columnMax.at(j)) columnMax.at(j) = curValue;
   13103         256 :             if (curValue < columnMin.at(j)) columnMin.at(j) = curValue;
   13104         256 :             columnSum.at(j) += curValue;
   13105         256 :             tableBody(j + 1, ZoneNum) = RealToStr(curValue, 2);
   13106             :         }
   13107             :     }
   13108             : 
   13109          54 :     rowHead(state.dataGlobal->NumOfZones + 1) = "Min";
   13110          54 :     rowHead(state.dataGlobal->NumOfZones + 2) = "Max";
   13111          54 :     rowHead(state.dataGlobal->NumOfZones + 3) = "Average";
   13112          54 :     rowHead(state.dataGlobal->NumOfZones + 4) = "Sum";
   13113             : 
   13114         310 :     for (int j = 0; j < columnNum; j++) {
   13115         256 :         tableBody(j + 1, state.dataGlobal->NumOfZones + 1) = RealToStr(columnMin.at(j), 2);
   13116         256 :         tableBody(j + 1, state.dataGlobal->NumOfZones + 2) = RealToStr(columnMax.at(j), 2);
   13117         256 :         tableBody(j + 1, state.dataGlobal->NumOfZones + 3) = RealToStr(columnSum.at(j) / state.dataGlobal->NumOfZones, 2);
   13118         256 :         tableBody(j + 1, state.dataGlobal->NumOfZones + 4) = RealToStr(columnSum.at(j), 2);
   13119             :     }
   13120             : 
   13121          54 :     WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
   13122          54 :     if (state.dataSQLiteProcedures->sqlite) {
   13123           0 :         state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
   13124           0 :             tableBody, rowHead, columnHead, "ReportingPeriod-" + periodTitle + "-" + tableType + "ResilienceSummary", "Entire Facility", tableName);
   13125             :     }
   13126          54 :     if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
   13127           0 :         state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(
   13128           0 :             tableBody, rowHead, columnHead, "ReportingPeriod-" + periodTitle + "-" + tableType + "ResilienceSummary", "Entire Facility", tableName);
   13129             :     }
   13130          54 : }
   13131             : 
   13132          12 : void WriteSETHoursTableNonPreDefUseZoneData(EnergyPlusData &state,
   13133             :                                             int const columnNum,
   13134             :                                             const std::string &tableName,
   13135             :                                             Array1D_string const &columnHead,
   13136             :                                             Array1D_int &columnWidth,
   13137             :                                             const std::array<Real64, 5> DataHeatBalance::ZoneResilience::*memberPtr,
   13138             :                                             Array1D_string &rowHead,
   13139             :                                             Array2D_string &tableBody,
   13140             :                                             Real64 const unitConvMultiplier)
   13141             : {
   13142             : 
   13143          12 :     WriteSubtitle(state, tableName);
   13144             : 
   13145          24 :     std::vector<Real64> columnMax(columnNum - 1, 0);
   13146          24 :     std::vector<Real64> columnMin(columnNum - 1, 0);
   13147          24 :     std::vector<Real64> columnSum(columnNum - 1, 0);
   13148          24 :     std::vector<Real64> multiplier(columnNum - 1, unitConvMultiplier);
   13149          12 :     multiplier[columnNum - 2] = 1.0;
   13150             : 
   13151          60 :     for (int j = 0; j < columnNum - 1; j++) {
   13152          48 :         columnMin.at(j) = (state.dataHeatBal->Resilience(1).*memberPtr).at(j) * multiplier.at(j);
   13153             :     }
   13154          24 :     for (int ZoneNum = 1; ZoneNum <= state.dataGlobal->NumOfZones; ZoneNum++) {
   13155          24 :         std::string ZoneName = state.dataHeatBal->Zone(ZoneNum).Name;
   13156          12 :         rowHead(ZoneNum) = state.dataHeatBal->Zone(ZoneNum).Name;
   13157          60 :         for (int j = 0; j < columnNum - 1; j++) {
   13158          48 :             Real64 curValue = (state.dataHeatBal->Resilience(ZoneNum).*memberPtr).at(j) * multiplier.at(j);
   13159          48 :             if (curValue > columnMax.at(j)) columnMax.at(j) = curValue;
   13160          48 :             if (curValue < columnMin.at(j)) columnMin.at(j) = curValue;
   13161          48 :             columnSum.at(j) += curValue;
   13162          48 :             tableBody(j + 1, ZoneNum) = RealToStr(curValue, 2);
   13163             :         }
   13164          12 :         tableBody(columnNum, ZoneNum) = DateToString((state.dataHeatBal->Resilience(ZoneNum).*memberPtr).at(columnNum - 1));
   13165             :     }
   13166             : 
   13167          12 :     rowHead(state.dataGlobal->NumOfZones + 1) = "Min";
   13168          12 :     rowHead(state.dataGlobal->NumOfZones + 2) = "Max";
   13169          12 :     rowHead(state.dataGlobal->NumOfZones + 3) = "Average";
   13170             : 
   13171          60 :     for (int j = 0; j < columnNum - 1; j++) {
   13172          48 :         tableBody(j + 1, state.dataGlobal->NumOfZones + 1) = RealToStr(columnMin.at(j), 2);
   13173          48 :         tableBody(j + 1, state.dataGlobal->NumOfZones + 2) = RealToStr(columnMax.at(j), 2);
   13174          48 :         tableBody(j + 1, state.dataGlobal->NumOfZones + 3) = RealToStr(columnSum.at(j) / state.dataGlobal->NumOfZones, 2);
   13175             :     }
   13176          12 :     tableBody(columnNum, state.dataGlobal->NumOfZones + 1) = "-";
   13177          12 :     tableBody(columnNum, state.dataGlobal->NumOfZones + 2) = "-";
   13178          12 :     tableBody(columnNum, state.dataGlobal->NumOfZones + 3) = "-";
   13179             : 
   13180          12 :     WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
   13181          12 :     if (state.dataSQLiteProcedures->sqlite) {
   13182           0 :         state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
   13183             :             tableBody, rowHead, columnHead, "AnnualThermalResilienceSummary", "Entire Facility", tableName);
   13184             :     }
   13185          12 :     if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
   13186           0 :         state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(
   13187             :             tableBody, rowHead, columnHead, "AnnualThermalResilienceSummary", "Entire Facility", tableName);
   13188             :     }
   13189          12 : }
   13190             : 
   13191          10 : void WriteSETHoursTableReportingPeriod(EnergyPlusData &state,
   13192             :                                        int const columnNum,
   13193             :                                        int const periodIdx,
   13194             :                                        const std::string &periodTitle,
   13195             :                                        const std::string &tableName,
   13196             :                                        Array1D_string const &columnHead,
   13197             :                                        Array1D_int &columnWidth,
   13198             :                                        Array2D<std::vector<Real64>> const &ZoneBins,
   13199             :                                        Array1D_string &rowHead,
   13200             :                                        Array2D_string &tableBody,
   13201             :                                        Real64 const unitConvMultiplier)
   13202             : {
   13203             : 
   13204          10 :     WriteSubtitle(state, tableName);
   13205             : 
   13206          20 :     std::vector<Real64> columnMax(columnNum - 1, 0);
   13207          20 :     std::vector<Real64> columnMin(columnNum - 1, 0);
   13208          20 :     std::vector<Real64> columnSum(columnNum - 1, 0);
   13209          20 :     std::vector<Real64> multiplier(columnNum - 1, unitConvMultiplier);
   13210          10 :     multiplier[columnNum - 2] = 1.0;
   13211             : 
   13212          50 :     for (int j = 0; j < columnNum - 1; j++) {
   13213          40 :         columnMin.at(j) = ZoneBins(1, periodIdx).at(j) * multiplier.at(j);
   13214             :     }
   13215          20 :     for (int ZoneNum = 1; ZoneNum <= state.dataGlobal->NumOfZones; ZoneNum++) {
   13216          20 :         std::string ZoneName = state.dataHeatBal->Zone(ZoneNum).Name;
   13217          10 :         rowHead(ZoneNum) = state.dataHeatBal->Zone(ZoneNum).Name;
   13218          50 :         for (int j = 0; j < columnNum - 1; j++) {
   13219          40 :             Real64 curValue = ZoneBins(ZoneNum, periodIdx).at(j) * multiplier.at(j);
   13220          40 :             if (curValue > columnMax.at(j)) columnMax.at(j) = curValue;
   13221          40 :             if (curValue < columnMin.at(j)) columnMin.at(j) = curValue;
   13222          40 :             columnSum.at(j) += curValue;
   13223          40 :             tableBody(j + 1, ZoneNum) = RealToStr(curValue, 2);
   13224             :         }
   13225          10 :         tableBody(columnNum, ZoneNum) = DateToString(ZoneBins(ZoneNum, periodIdx)[columnNum - 1]);
   13226             :     }
   13227             : 
   13228          10 :     rowHead(state.dataGlobal->NumOfZones + 1) = "Min";
   13229          10 :     rowHead(state.dataGlobal->NumOfZones + 2) = "Max";
   13230          10 :     rowHead(state.dataGlobal->NumOfZones + 3) = "Average";
   13231             : 
   13232          50 :     for (int j = 0; j < columnNum - 1; j++) {
   13233          40 :         tableBody(j + 1, state.dataGlobal->NumOfZones + 1) = RealToStr(columnMin.at(j), 2);
   13234          40 :         tableBody(j + 1, state.dataGlobal->NumOfZones + 2) = RealToStr(columnMax.at(j), 2);
   13235          40 :         tableBody(j + 1, state.dataGlobal->NumOfZones + 3) = RealToStr(columnSum.at(j) / state.dataGlobal->NumOfZones, 2);
   13236             :     }
   13237          10 :     tableBody(columnNum, state.dataGlobal->NumOfZones + 1) = "-";
   13238          10 :     tableBody(columnNum, state.dataGlobal->NumOfZones + 2) = "-";
   13239          10 :     tableBody(columnNum, state.dataGlobal->NumOfZones + 3) = "-";
   13240             : 
   13241          10 :     WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
   13242          10 :     if (state.dataSQLiteProcedures->sqlite) {
   13243           0 :         state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
   13244           0 :             tableBody, rowHead, columnHead, "ReportingPeriod-" + periodTitle + "-ThermalResilienceSummary", "Entire Facility", tableName);
   13245             :     }
   13246          10 :     if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
   13247           0 :         state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(
   13248           0 :             tableBody, rowHead, columnHead, "ReportingPeriod-" + periodTitle + "-ThermalResilienceSummary", "Entire Facility", tableName);
   13249             :     }
   13250          10 : }
   13251             : 
   13252           0 : std::string RetrieveEntryFromTableBody(Array2D_string &tableBody, int const rowIndex, int const columnIndex)
   13253             : {
   13254           0 :     return trimmed(ljustified(tableBody(columnIndex, rowIndex)));
   13255             : }
   13256             : 
   13257        1260 : void WriteHourOfSafetyTableNonPreDefUseZoneData(EnergyPlusData &state,
   13258             :                                                 int const columnNum,
   13259             :                                                 const std::string &tableName,
   13260             :                                                 Array1D_string const &columnHead,
   13261             :                                                 Array1D_int &columnWidth,
   13262             :                                                 const std::array<Real64, 5> DataHeatBalance::ZoneResilience::*memberPtr,
   13263             :                                                 Array1D_string &rowHead,
   13264             :                                                 Array2D_string &tableBody,
   13265             :                                                 int const dateColIdx)
   13266             : {
   13267             : 
   13268        1260 :     WriteSubtitle(state, tableName);
   13269        8166 :     for (int ZoneNum = 1; ZoneNum <= state.dataGlobal->NumOfZones; ++ZoneNum) {
   13270        6906 :         rowHead(ZoneNum) = state.dataHeatBal->Zone(ZoneNum).Name;
   13271       41436 :         for (int j = 1; j <= columnNum; j++) {
   13272       34530 :             tableBody(j, ZoneNum) = RealToStr((state.dataHeatBal->Resilience(ZoneNum).*memberPtr).at(j - 1), 2);
   13273             :         }
   13274        6906 :         tableBody(dateColIdx, ZoneNum) = DateToString((state.dataHeatBal->Resilience(ZoneNum).*memberPtr).at(dateColIdx - 1));
   13275             :     }
   13276             : 
   13277        2520 :     std::vector<Real64> columnMax(columnNum, 0);
   13278        2520 :     std::vector<Real64> columnMin(columnNum, 0);
   13279        2520 :     std::vector<Real64> columnSum(columnNum, 0);
   13280             : 
   13281        7560 :     for (int j = 0; j < columnNum; j++) {
   13282        6300 :         columnMin.at(j) = (state.dataHeatBal->Resilience(1).*memberPtr).at(j);
   13283             :     }
   13284        8166 :     for (int ZoneNum = 1; ZoneNum <= state.dataGlobal->NumOfZones; ++ZoneNum) {
   13285       13812 :         std::string ZoneName = state.dataHeatBal->Zone(ZoneNum).Name;
   13286       41436 :         for (int j = 0; j < columnNum; j++) {
   13287       34530 :             Real64 curValue = (state.dataHeatBal->Resilience(ZoneNum).*memberPtr).at(j);
   13288       34530 :             if (curValue > columnMax.at(j)) columnMax.at(j) = curValue;
   13289       34530 :             if (curValue < columnMin.at(j)) columnMin.at(j) = curValue;
   13290       34530 :             columnSum.at(j) += curValue;
   13291             :         }
   13292             :     }
   13293             : 
   13294        1260 :     rowHead(state.dataGlobal->NumOfZones + 1) = "Min";
   13295        1260 :     rowHead(state.dataGlobal->NumOfZones + 2) = "Max";
   13296        1260 :     rowHead(state.dataGlobal->NumOfZones + 3) = "Average";
   13297        1260 :     rowHead(state.dataGlobal->NumOfZones + 4) = "Sum";
   13298             : 
   13299        7560 :     for (int j = 0; j < columnNum; j++) {
   13300        6300 :         tableBody(j + 1, state.dataGlobal->NumOfZones + 1) = RealToStr(columnMin.at(j), 2);
   13301        6300 :         tableBody(j + 1, state.dataGlobal->NumOfZones + 2) = RealToStr(columnMax.at(j), 2);
   13302        6300 :         tableBody(j + 1, state.dataGlobal->NumOfZones + 3) = RealToStr(columnSum.at(j) / state.dataGlobal->NumOfZones, 2);
   13303        6300 :         tableBody(j + 1, state.dataGlobal->NumOfZones + 4) = RealToStr(columnSum.at(j), 2);
   13304             :     }
   13305             : 
   13306        6300 :     for (int i = 1; i < 5; i++) {
   13307        5040 :         tableBody(dateColIdx, state.dataGlobal->NumOfZones + i) = "-";
   13308             :     }
   13309             : 
   13310        1260 :     WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
   13311        1260 :     if (state.dataSQLiteProcedures->sqlite) {
   13312         122 :         state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
   13313             :             tableBody, rowHead, columnHead, "AnnualThermalResilienceSummary", "Entire Facility", tableName);
   13314             :     }
   13315        1260 :     if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
   13316           8 :         state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(
   13317             :             tableBody, rowHead, columnHead, "AnnualThermalResilienceSummary", "Entire Facility", tableName);
   13318             :     }
   13319        1260 : }
   13320             : 
   13321          10 : void WriteHourOfSafetyTableReportingPeriod(EnergyPlusData &state,
   13322             :                                            int const columnNum,
   13323             :                                            int const periodIdx,
   13324             :                                            const std::string &periodTitle,
   13325             :                                            const std::string &tableName,
   13326             :                                            Array1D_string const &columnHead,
   13327             :                                            Array1D_int &columnWidth,
   13328             :                                            Array2D<std::vector<Real64>> const &ZoneBins,
   13329             :                                            Array1D_string &rowHead,
   13330             :                                            Array2D_string &tableBody,
   13331             :                                            int const dateColIdx)
   13332             : {
   13333             : 
   13334          10 :     WriteSubtitle(state, tableName);
   13335          20 :     for (int ZoneNum = 1; ZoneNum <= state.dataGlobal->NumOfZones; ++ZoneNum) {
   13336          10 :         rowHead(ZoneNum) = state.dataHeatBal->Zone(ZoneNum).Name;
   13337          60 :         for (int j = 1; j <= columnNum; j++) {
   13338          50 :             tableBody(j, ZoneNum) = RealToStr(ZoneBins(ZoneNum, periodIdx).at(j - 1), 2);
   13339             :         }
   13340          10 :         tableBody(dateColIdx, ZoneNum) = DateToString(ZoneBins(ZoneNum, periodIdx).at(dateColIdx - 1));
   13341             :     }
   13342             : 
   13343          20 :     std::vector<Real64> columnMax(columnNum, 0);
   13344          20 :     std::vector<Real64> columnMin(columnNum, 0);
   13345          20 :     std::vector<Real64> columnSum(columnNum, 0);
   13346             : 
   13347          60 :     for (int j = 0; j < columnNum; j++) {
   13348          50 :         columnMin.at(j) = ZoneBins(1, periodIdx).at(j);
   13349             :     }
   13350          20 :     for (int i = 1; i <= state.dataGlobal->NumOfZones; ++i) {
   13351          60 :         for (int j = 0; j < columnNum; j++) {
   13352          50 :             Real64 curValue = ZoneBins(i, periodIdx).at(j);
   13353          50 :             if (curValue > columnMax.at(j)) columnMax.at(j) = curValue;
   13354          50 :             if (curValue < columnMin.at(j)) columnMin.at(j) = curValue;
   13355          50 :             columnSum.at(j) += curValue;
   13356             :         }
   13357             :     }
   13358             : 
   13359          10 :     rowHead(state.dataGlobal->NumOfZones + 1) = "Min";
   13360          10 :     rowHead(state.dataGlobal->NumOfZones + 2) = "Max";
   13361          10 :     rowHead(state.dataGlobal->NumOfZones + 3) = "Average";
   13362          10 :     rowHead(state.dataGlobal->NumOfZones + 4) = "Sum";
   13363             : 
   13364          60 :     for (int j = 0; j < columnNum; j++) {
   13365          50 :         tableBody(j + 1, state.dataGlobal->NumOfZones + 1) = RealToStr(columnMin.at(j), 2);
   13366          50 :         tableBody(j + 1, state.dataGlobal->NumOfZones + 2) = RealToStr(columnMax.at(j), 2);
   13367          50 :         tableBody(j + 1, state.dataGlobal->NumOfZones + 3) = RealToStr(columnSum.at(j) / state.dataGlobal->NumOfZones, 2);
   13368          50 :         tableBody(j + 1, state.dataGlobal->NumOfZones + 4) = RealToStr(columnSum.at(j), 2);
   13369             :     }
   13370             : 
   13371          50 :     for (int i = 1; i < 5; i++) {
   13372          40 :         tableBody(dateColIdx, state.dataGlobal->NumOfZones + i) = "-";
   13373             :     }
   13374             : 
   13375          10 :     WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
   13376          10 :     if (state.dataSQLiteProcedures->sqlite) {
   13377           0 :         state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
   13378           0 :             tableBody, rowHead, columnHead, "ReportingPeriod-" + periodTitle + "-ThermalResilienceSummary", "Entire Facility", tableName);
   13379             :     }
   13380          10 :     if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
   13381           0 :         state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(
   13382           0 :             tableBody, rowHead, columnHead, "ReportingPeriod-" + periodTitle + "-ThermalResilienceSummary", "Entire Facility", tableName);
   13383             :     }
   13384          10 : }
   13385             : 
   13386           0 : void WriteHourOfSafetyTable(EnergyPlusData &state,
   13387             :                             int const columnNum,
   13388             :                             std::vector<int> const &columnHead,
   13389             :                             Array1D<std::vector<Real64>> const &ZoneBins,
   13390             :                             int const dateColIdx)
   13391             : {
   13392           0 :     auto &Zone(state.dataHeatBal->Zone);
   13393             : 
   13394           0 :     std::vector<Real64> columnMax(columnNum, 0);
   13395           0 :     std::vector<Real64> columnMin(columnNum, 0);
   13396           0 :     std::vector<Real64> columnSum(columnNum, 0);
   13397           0 :     for (int j = 0; j < columnNum; j++) {
   13398           0 :         columnMin[j] = ZoneBins(1)[j];
   13399             :     }
   13400           0 :     for (int i = 1; i <= state.dataGlobal->NumOfZones; ++i) {
   13401           0 :         for (int j = 0; j < columnNum; j++) {
   13402           0 :             if (j == dateColIdx) {
   13403           0 :                 std::string startDateTime = DateToString(int(ZoneBins(i)[dateColIdx]));
   13404           0 :                 PreDefTableEntry(state, columnHead[dateColIdx], Zone(i).Name, startDateTime);
   13405             :             } else {
   13406           0 :                 Real64 curValue = ZoneBins(i)[j];
   13407           0 :                 if (curValue > columnMax[j]) columnMax[j] = curValue;
   13408           0 :                 if (curValue < columnMin[j]) columnMin[j] = curValue;
   13409           0 :                 columnSum[j] += curValue;
   13410           0 :                 PreDefTableEntry(state, columnHead[j], Zone(i).Name, RealToStr(curValue, 2));
   13411             :             }
   13412             :         }
   13413             :     }
   13414           0 :     for (int j = 0; j < columnNum; j++) {
   13415           0 :         if (j == dateColIdx) {
   13416           0 :             PreDefTableEntry(state, columnHead[j], "Min", "-");
   13417           0 :             PreDefTableEntry(state, columnHead[j], "Max", "-");
   13418           0 :             PreDefTableEntry(state, columnHead[j], "Average", "-");
   13419           0 :             PreDefTableEntry(state, columnHead[j], "Sum", "-");
   13420             :         } else {
   13421           0 :             PreDefTableEntry(state, columnHead[j], "Min", RealToStr(columnMin[j], 2));
   13422           0 :             PreDefTableEntry(state, columnHead[j], "Max", RealToStr(columnMax[j], 2));
   13423           0 :             PreDefTableEntry(state, columnHead[j], "Average", RealToStr(columnSum[j] / state.dataGlobal->NumOfZones, 2));
   13424           0 :             PreDefTableEntry(state, columnHead[j], "Sum", RealToStr(columnSum[j], 2));
   13425             :         }
   13426             :     }
   13427           0 : }
   13428             : 
   13429         656 : void WriteThermalResilienceTables(EnergyPlusData &state)
   13430             : {
   13431             : 
   13432             :     // Using/Aliasing
   13433         656 :     auto &ort(state.dataOutRptTab);
   13434             : 
   13435         656 :     if (state.dataGlobal->NumOfZones <= 0) return;
   13436             : 
   13437             :     Real64 degreeHourConversion;
   13438         630 :     UnitsStyle unitsStyle_cur = ort->unitsStyle;
   13439         630 :     if (unitsStyle_cur == UnitsStyle::InchPound) {
   13440          11 :         degreeHourConversion = getSpecificUnitMultiplier(state, "°C·hr", "°F·hr");
   13441             :     } else {
   13442         619 :         degreeHourConversion = 1.0;
   13443             :     }
   13444             : 
   13445         630 :     WriteReportHeaders(state, "Annual Thermal Resilience Summary", "Entire Facility", OutputProcessor::StoreType::Averaged);
   13446             : 
   13447        1260 :     Array1D_int columnWidth;
   13448         630 :     columnWidth.allocate(numColumnThermalTbl);
   13449         630 :     columnWidth = 10;
   13450        1260 :     Array1D_string rowHead;
   13451        1260 :     Array2D_string tableBody;
   13452         630 :     rowHead.allocate(state.dataGlobal->NumOfZones + 4);
   13453         630 :     tableBody.allocate(numColumnThermalTbl, state.dataGlobal->NumOfZones + 4);
   13454        1260 :     Array1D_string columnHeadStr(numColumnThermalTbl);
   13455             : 
   13456         630 :     if (unitsStyle_cur == UnitsStyle::InchPound) {
   13457          11 :         columnHeadStr(1) = "Safe (≤ 80.1°F) [hr]";
   13458          11 :         columnHeadStr(2) = "Caution (> 80.1°F, ≤ 90.0°F) [hr]";
   13459          11 :         columnHeadStr(3) = "Extreme Caution (> 90.0°F, ≤ 102.9°F) [hr]";
   13460          11 :         columnHeadStr(4) = "Danger (> 102.9, ≤ 125.1°F) [hr]";
   13461          11 :         columnHeadStr(5) = "Extreme Danger (> 125.1°F) [hr]";
   13462             :     } else {
   13463         619 :         columnHeadStr(1) = "Safe (≤ 26.7°C) [hr]";
   13464         619 :         columnHeadStr(2) = "Caution (> 26.7°C, ≤ 32.2°C) [hr]";
   13465         619 :         columnHeadStr(3) = "Extreme Caution (> 32.2°C, ≤ 39.4°C) [hr]";
   13466         619 :         columnHeadStr(4) = "Danger (> 39.4°C, ≤ 51.7°C) [hr]";
   13467         619 :         columnHeadStr(5) = "Extreme Danger (> 51.7°C) [hr]";
   13468             :     }
   13469             : 
   13470         630 :     std::array<Real64, numColumnThermalTbl> DataHeatBalance::ZoneResilience::*ptrHeatIndex = &DataHeatBalance::ZoneResilience::ZoneHeatIndexHourBins;
   13471         630 :     std::array<Real64, numColumnThermalTbl> DataHeatBalance::ZoneResilience::*ptrHeatIndexOccuHour =
   13472             :         &DataHeatBalance::ZoneResilience::ZoneHeatIndexOccuHourBins;
   13473         630 :     std::array<Real64, numColumnThermalTbl> DataHeatBalance::ZoneResilience::*ptrHeatIndexOccupiedHour =
   13474             :         &DataHeatBalance::ZoneResilience::ZoneHeatIndexOccupiedHourBins;
   13475        1260 :     std::string tableName = "Heat Index Hours";
   13476         630 :     WriteResilienceBinsTableNonPreDefUseZoneData<numColumnThermalTbl>(state, tableName, columnHeadStr, columnWidth, ptrHeatIndex, rowHead, tableBody);
   13477         630 :     tableName = "Heat Index OccupantHours";
   13478         630 :     WriteResilienceBinsTableNonPreDefUseZoneData<numColumnThermalTbl>(
   13479             :         state, tableName, columnHeadStr, columnWidth, ptrHeatIndexOccuHour, rowHead, tableBody);
   13480         630 :     tableName = "Heat Index OccupiedHours";
   13481         630 :     WriteResilienceBinsTableNonPreDefUseZoneData<numColumnThermalTbl>(
   13482             :         state, tableName, columnHeadStr, columnWidth, ptrHeatIndexOccupiedHour, rowHead, tableBody);
   13483             : 
   13484         630 :     columnHeadStr(1) = "Little to no Discomfort (≤ 29) [hr]";
   13485         630 :     columnHeadStr(2) = "Some Discomfort (> 29, ≤ 40) [hr]";
   13486         630 :     columnHeadStr(3) = "Great Discomfort; Avoid Exertion (> 40, ≤ 45) [hr]";
   13487         630 :     columnHeadStr(4) = "Dangerous (> 45, ≤ 50) [hr]";
   13488         630 :     columnHeadStr(5) = "Heat Stroke Quite Possible (> 50) [hr]";
   13489             : 
   13490         630 :     std::array<Real64, numColumnThermalTbl> DataHeatBalance::ZoneResilience::*ptrHumidex = &DataHeatBalance::ZoneResilience::ZoneHumidexHourBins;
   13491         630 :     std::array<Real64, numColumnThermalTbl> DataHeatBalance::ZoneResilience::*ptrHumidexOccuHour =
   13492             :         &DataHeatBalance::ZoneResilience::ZoneHumidexOccuHourBins;
   13493         630 :     std::array<Real64, numColumnThermalTbl> DataHeatBalance::ZoneResilience::*ptrHumidexOccupiedHour =
   13494             :         &DataHeatBalance::ZoneResilience::ZoneHumidexOccupiedHourBins;
   13495         630 :     tableName = "Humidex Hours";
   13496         630 :     WriteResilienceBinsTableNonPreDefUseZoneData<numColumnThermalTbl>(state, tableName, columnHeadStr, columnWidth, ptrHumidex, rowHead, tableBody);
   13497         630 :     tableName = "Humidex OccupantHours";
   13498         630 :     WriteResilienceBinsTableNonPreDefUseZoneData<numColumnThermalTbl>(
   13499             :         state, tableName, columnHeadStr, columnWidth, ptrHumidexOccuHour, rowHead, tableBody);
   13500         630 :     tableName = "Humidex OccupiedHours";
   13501         630 :     WriteResilienceBinsTableNonPreDefUseZoneData<numColumnThermalTbl>(
   13502             :         state, tableName, columnHeadStr, columnWidth, ptrHumidexOccupiedHour, rowHead, tableBody);
   13503             : 
   13504         630 :     bool hasPierceSET = true;
   13505         630 :     if (state.dataHeatBal->TotPeople == 0) {
   13506          74 :         hasPierceSET = false;
   13507          74 :         if (ort->displayThermalResilienceSummaryExplicitly) {
   13508           0 :             ShowWarningError(state,
   13509             :                              "Writing Annual Thermal Resilience Summary - SET Degree-Hours reports: "
   13510             :                              "Zone Thermal Comfort Pierce Model Standard Effective Temperature is required, "
   13511             :                              "but no People object is defined.");
   13512             :         }
   13513             :     }
   13514        3427 :     for (int iPeople = 1; iPeople <= state.dataHeatBal->TotPeople; ++iPeople) {
   13515        2797 :         if (!state.dataHeatBal->People(iPeople).Pierce) {
   13516        2786 :             hasPierceSET = false;
   13517        2786 :             if (ort->displayThermalResilienceSummaryExplicitly) {
   13518           0 :                 ShowWarningError(state,
   13519             :                                  "Writing Annual Thermal Resilience Summary - SET Degree-Hours reports: "
   13520             :                                  "Zone Thermal Comfort Pierce Model Standard Effective Temperature is required, "
   13521           0 :                                  "but no Pierce model is defined in " +
   13522           0 :                                      state.dataHeatBal->People(iPeople).Name + " object.");
   13523             :             }
   13524             :         }
   13525             :     }
   13526             : 
   13527         630 :     if (hasPierceSET) {
   13528           6 :         if (unitsStyle_cur == UnitsStyle::InchPound) {
   13529           0 :             columnHeadStr(1) = "SET > 86°F Degree-Hours [°F·hr]";
   13530           0 :             columnHeadStr(2) = "SET > 86°F Occupant-Weighted Degree-Hours [°F·hr]";
   13531           0 :             columnHeadStr(3) = "SET > 86°F Occupied Degree-Hours [°F·hr]";
   13532           0 :             columnHeadStr(4) = "Longest SET > 86°F Duration for Occupied Period [hr]";
   13533           0 :             columnHeadStr(5) = "Start Time of the Longest SET > 86°F Duration for Occupied Period";
   13534             :         } else {
   13535           6 :             columnHeadStr(1) = "SET > 30°C Degree-Hours [°C·hr]";
   13536           6 :             columnHeadStr(2) = "SET > 30°C Occupant-Weighted Degree-Hours [°C·hr]";
   13537           6 :             columnHeadStr(3) = "SET > 30°C Occupied Degree-Hours [°C·hr]";
   13538           6 :             columnHeadStr(4) = "Longest SET > 30°C Duration for Occupied Period [hr]";
   13539           6 :             columnHeadStr(5) = "Start Time of the Longest SET > 30°C Duration for Occupied Period";
   13540             :         }
   13541             : 
   13542           6 :         std::array<Real64, numColumnThermalTbl> DataHeatBalance::ZoneResilience::*ptrLowSETHours = &DataHeatBalance::ZoneResilience::ZoneLowSETHours;
   13543           6 :         std::array<Real64, numColumnThermalTbl> DataHeatBalance::ZoneResilience::*ptrHighSETHours =
   13544             :             &DataHeatBalance::ZoneResilience::ZoneHighSETHours;
   13545          12 :         Array1D_string rowHeadSET;
   13546          12 :         Array2D_string tableBodySET;
   13547           6 :         rowHeadSET.allocate(state.dataGlobal->NumOfZones + 3);
   13548           6 :         tableBodySET.allocate(numColumnThermalTbl, state.dataGlobal->NumOfZones + 3);
   13549           6 :         tableName = "Heating SET Degree-Hours";
   13550           6 :         WriteSETHoursTableNonPreDefUseZoneData(
   13551             :             state, numColumnThermalTbl, tableName, columnHeadStr, columnWidth, ptrLowSETHours, rowHeadSET, tableBodySET, degreeHourConversion);
   13552           6 :         tableName = "Cooling SET Degree-Hours";
   13553           6 :         WriteSETHoursTableNonPreDefUseZoneData(
   13554             :             state, numColumnThermalTbl, tableName, columnHeadStr, columnWidth, ptrHighSETHours, rowHeadSET, tableBodySET, degreeHourConversion);
   13555             :     }
   13556             : 
   13557         630 :     std::array<Real64, numColumnThermalTbl> DataHeatBalance::ZoneResilience::*ptrColdHourOfSafetyBins =
   13558             :         &DataHeatBalance::ZoneResilience::ZoneColdHourOfSafetyBins;
   13559         630 :     std::array<Real64, numColumnThermalTbl> DataHeatBalance::ZoneResilience::*ptrHeatHourOfSafetyBins =
   13560             :         &DataHeatBalance::ZoneResilience::ZoneHeatHourOfSafetyBins;
   13561         630 :     tableName = "Hours of Safety for Cold Events";
   13562         630 :     columnHeadStr(1) = "Hours of Safety [hr]";
   13563         630 :     columnHeadStr(2) = "End Time of the Safety Duration";
   13564         630 :     columnHeadStr(3) = "Safe Temperature Exceedance Hours [hr]";
   13565         630 :     columnHeadStr(4) = "Safe Temperature Exceedance OccupantHours [hr]";
   13566         630 :     columnHeadStr(5) = "Safe Temperature Exceedance OccupiedHours [hr]";
   13567         630 :     WriteHourOfSafetyTableNonPreDefUseZoneData(
   13568             :         state, numColumnThermalTbl, tableName, columnHeadStr, columnWidth, ptrColdHourOfSafetyBins, rowHead, tableBody, 2);
   13569         630 :     tableName = "Hours of Safety for Heat Events";
   13570         630 :     WriteHourOfSafetyTableNonPreDefUseZoneData(
   13571             :         state, numColumnThermalTbl, tableName, columnHeadStr, columnWidth, ptrHeatHourOfSafetyBins, rowHead, tableBody, 2);
   13572             : 
   13573        1260 :     Array1D_int columnWidthUnmetDegHr;
   13574         630 :     columnWidthUnmetDegHr.allocate(numColumnUnmetDegreeHourTbl);
   13575         630 :     columnWidthUnmetDegHr = 10;
   13576        1260 :     Array1D_string columnHeadUnmetDegHr;
   13577         630 :     columnHeadUnmetDegHr.allocate(numColumnUnmetDegreeHourTbl);
   13578        1260 :     Array2D_string tableBodyUnmetDegHr;
   13579         630 :     tableBodyUnmetDegHr.allocate(numColumnUnmetDegreeHourTbl, state.dataGlobal->NumOfZones + 4);
   13580         630 :     tableName = "Unmet Degree-Hours";
   13581         630 :     columnHeadUnmetDegHr(1) = "Cooling Setpoint Unmet Degree-Hours [°C·hr]";
   13582         630 :     columnHeadUnmetDegHr(2) = "Cooling Setpoint Unmet Occupant-Weighted Degree-Hours [°C·hr]";
   13583         630 :     columnHeadUnmetDegHr(3) = "Cooling Setpoint Unmet Occupied Degree-Hours [°C·hr]";
   13584         630 :     columnHeadUnmetDegHr(4) = "Heating Setpoint Unmet Degree-Hours [°C·hr]";
   13585         630 :     columnHeadUnmetDegHr(5) = "Heating Setpoint Unmet Occupant-Weighted Degree-Hours [°C·hr]";
   13586         630 :     columnHeadUnmetDegHr(6) = "Heating Setpoint Unmet Occupied Degree-Hours [°C·hr]";
   13587             : 
   13588         630 :     if (unitsStyle_cur == UnitsStyle::InchPound) {
   13589             :         int indexUnitConv;
   13590          22 :         std::string curUnits;
   13591          66 :         for (int i = 1; i < numColumnUnmetDegreeHourTbl; i++) {
   13592          55 :             LookupSItoIP(state, columnHeadUnmetDegHr(i), indexUnitConv, curUnits);
   13593          55 :             columnHeadUnmetDegHr(i) = curUnits;
   13594             :         }
   13595             :     }
   13596             : 
   13597         630 :     std::array<Real64, numColumnUnmetDegreeHourTbl> DataHeatBalance::ZoneResilience::*ptrUnmetDegreeHourBins =
   13598             :         &DataHeatBalance::ZoneResilience::ZoneUnmetDegreeHourBins;
   13599         630 :     WriteResilienceBinsTableNonPreDefUseZoneData<numColumnUnmetDegreeHourTbl>(
   13600             :         state, tableName, columnHeadUnmetDegHr, columnWidthUnmetDegHr, ptrUnmetDegreeHourBins, rowHead, tableBodyUnmetDegHr, degreeHourConversion);
   13601             : 
   13602         630 :     columnHeadStr.allocate(numColumnDiscomfortWtExceedHourTbl);
   13603         630 :     columnWidth.allocate(numColumnDiscomfortWtExceedHourTbl);
   13604         630 :     columnWidth = 10;
   13605         630 :     tableBody.allocate(numColumnDiscomfortWtExceedHourTbl, state.dataGlobal->NumOfZones + 4);
   13606         630 :     columnHeadStr(1) = "Very-cold Exceedance OccupantHours [hr]";
   13607         630 :     columnHeadStr(2) = "Cool Exceedance OccupantHours [hr]";
   13608         630 :     columnHeadStr(3) = "Warm Exceedance OccupantHours [hr]";
   13609         630 :     columnHeadStr(4) = "Very-hot Exceedance OccupantHours [hr]";
   13610             : 
   13611         630 :     std::array<Real64, numColumnDiscomfortWtExceedHourTbl> DataHeatBalance::ZoneResilience::*ptrDiscomfortWtExceedOccuHourBins =
   13612             :         &DataHeatBalance::ZoneResilience::ZoneDiscomfortWtExceedOccuHourBins;
   13613         630 :     std::array<Real64, numColumnDiscomfortWtExceedHourTbl> DataHeatBalance::ZoneResilience::*ptrDiscomfortWtExceedOccupiedHourBins =
   13614             :         &DataHeatBalance::ZoneResilience::ZoneDiscomfortWtExceedOccupiedHourBins;
   13615         630 :     tableName = "Discomfort-weighted Exceedance OccupantHours";
   13616         630 :     WriteResilienceBinsTableNonPreDefUseZoneData<numColumnDiscomfortWtExceedHourTbl>(
   13617             :         state, tableName, columnHeadStr, columnWidth, ptrDiscomfortWtExceedOccuHourBins, rowHead, tableBody);
   13618         630 :     tableName = "Discomfort-weighted Exceedance OccupiedHours";
   13619         630 :     WriteResilienceBinsTableNonPreDefUseZoneData<numColumnDiscomfortWtExceedHourTbl>(
   13620             :         state, tableName, columnHeadStr, columnWidth, ptrDiscomfortWtExceedOccupiedHourBins, rowHead, tableBody);
   13621         630 :     rowHead.deallocate();
   13622         630 :     columnHeadStr.deallocate();
   13623         630 :     tableBody.deallocate();
   13624         630 :     tableBodyUnmetDegHr.deallocate();
   13625         630 :     columnWidth.deallocate();
   13626         630 :     columnHeadUnmetDegHr.deallocate();
   13627         630 :     columnWidthUnmetDegHr.deallocate();
   13628             : }
   13629             : 
   13630          14 : void WriteCO2ResilienceTables(EnergyPlusData &state)
   13631             : {
   13632             : 
   13633          14 :     if (state.dataGlobal->NumOfZones <= 0) return;
   13634             :     std::array<int, numColumnCO2Tbl> columnHead = {
   13635          14 :         state.dataOutRptPredefined->pdchCO2HourSafe, state.dataOutRptPredefined->pdchCO2HourCaution, state.dataOutRptPredefined->pdchCO2HourHazard};
   13636             : 
   13637          14 :     std::array<Real64, numColumnCO2Tbl> DataHeatBalance::ZoneResilience::*ptrCO2LevelHourBins =
   13638             :         &DataHeatBalance::ZoneResilience::ZoneCO2LevelHourBins;
   13639          14 :     std::array<Real64, numColumnCO2Tbl> DataHeatBalance::ZoneResilience::*ptrCO2LevelOccuHourBins =
   13640             :         &DataHeatBalance::ZoneResilience::ZoneCO2LevelOccuHourBins;
   13641          14 :     std::array<Real64, numColumnCO2Tbl> DataHeatBalance::ZoneResilience::*ptrCO2LevelOccupiedHourBins =
   13642             :         &DataHeatBalance::ZoneResilience::ZoneCO2LevelOccupiedHourBins;
   13643          14 :     WriteResilienceBinsTable<numColumnCO2Tbl>(state, columnHead, ptrCO2LevelHourBins);
   13644             : 
   13645          28 :     columnHead = {state.dataOutRptPredefined->pdchCO2OccuHourSafe,
   13646          14 :                   state.dataOutRptPredefined->pdchCO2OccuHourCaution,
   13647          14 :                   state.dataOutRptPredefined->pdchCO2OccuHourHazard};
   13648          14 :     WriteResilienceBinsTable<numColumnCO2Tbl>(state, columnHead, ptrCO2LevelOccuHourBins);
   13649             : 
   13650          28 :     columnHead = {state.dataOutRptPredefined->pdchCO2OccupiedHourSafe,
   13651          14 :                   state.dataOutRptPredefined->pdchCO2OccupiedHourCaution,
   13652          14 :                   state.dataOutRptPredefined->pdchCO2OccupiedHourHazard};
   13653          14 :     WriteResilienceBinsTable<numColumnCO2Tbl>(state, columnHead, ptrCO2LevelOccupiedHourBins);
   13654             : }
   13655             : 
   13656           3 : void WriteCO2ResilienceTablesRepPeriod(EnergyPlusData &state, const int periodIdx)
   13657             : {
   13658           3 :     auto &ort(state.dataOutRptTab);
   13659           3 :     if (ort->WriteTabularFiles) return;
   13660           0 :     WriteReportHeaderReportingPeriod(state, "CO2", periodIdx, state.dataWeatherManager->CO2ReportPeriodInput);
   13661           0 :     std::string periodTitle = state.dataWeatherManager->CO2ReportPeriodInput(periodIdx).title;
   13662             : 
   13663           0 :     Array1D_int columnWidth;
   13664           0 :     columnWidth.allocate(numColumnCO2Tbl);
   13665           0 :     columnWidth = 10;
   13666           0 :     Array1D_string columnHead(numColumnCO2Tbl);
   13667           0 :     columnHead(1) = "Safe (<= 1000 ppm) [hr]";
   13668           0 :     columnHead(2) = "Caution (> 1000, <= 5000 ppm) [hr]";
   13669           0 :     columnHead(3) = "Hazard (> 5000 ppm) [hr]";
   13670             : 
   13671           0 :     Array1D_string rowHead;
   13672           0 :     Array2D_string tableBody;
   13673           0 :     rowHead.allocate(state.dataGlobal->NumOfZones + 4);
   13674           0 :     tableBody.allocate(numColumnCO2Tbl, state.dataGlobal->NumOfZones + 4);
   13675             : 
   13676           0 :     std::string tableName = "CO2 Level Hours";
   13677           0 :     std::string tableType = "CO2";
   13678           0 :     WriteResilienceBinsTableReportingPeriod(state,
   13679             :                                             tableType,
   13680             :                                             numColumnCO2Tbl,
   13681             :                                             periodIdx,
   13682             :                                             periodTitle,
   13683             :                                             tableName,
   13684             :                                             columnHead,
   13685             :                                             columnWidth,
   13686           0 :                                             state.dataHeatBalFanSys->ZoneCO2LevelHourBinsRepPeriod,
   13687             :                                             rowHead,
   13688             :                                             tableBody);
   13689             : 
   13690           0 :     tableName = "CO2 Level OccupantHours";
   13691           0 :     WriteResilienceBinsTableReportingPeriod(state,
   13692             :                                             tableType,
   13693             :                                             numColumnCO2Tbl,
   13694             :                                             periodIdx,
   13695             :                                             periodTitle,
   13696             :                                             tableName,
   13697             :                                             columnHead,
   13698             :                                             columnWidth,
   13699           0 :                                             state.dataHeatBalFanSys->ZoneCO2LevelOccuHourBinsRepPeriod,
   13700             :                                             rowHead,
   13701             :                                             tableBody);
   13702             : 
   13703           0 :     tableName = "CO2 Level OccupiedHours";
   13704           0 :     WriteResilienceBinsTableReportingPeriod(state,
   13705             :                                             tableType,
   13706             :                                             numColumnCO2Tbl,
   13707             :                                             periodIdx,
   13708             :                                             periodTitle,
   13709             :                                             tableName,
   13710             :                                             columnHead,
   13711             :                                             columnWidth,
   13712           0 :                                             state.dataHeatBalFanSys->ZoneCO2LevelOccupiedHourBinsRepPeriod,
   13713             :                                             rowHead,
   13714             :                                             tableBody);
   13715             : }
   13716             : 
   13717          53 : void WriteVisualResilienceTables(EnergyPlusData &state)
   13718             : {
   13719         669 :     for (int ZoneNum = 1; ZoneNum <= state.dataGlobal->NumOfZones; ++ZoneNum) {
   13720         616 :         if (state.dataDaylightingData->ZoneDaylight(ZoneNum).totRefPts == 0) {
   13721         401 :             if (state.dataOutRptTab->displayVisualResilienceSummaryExplicitly) {
   13722           0 :                 ShowWarningError(state,
   13723             :                                  "Writing Annual Visual Resilience Summary - Lighting Level Hours reports: "
   13724             :                                  "Zone Average Daylighting Reference Point Illuminance output is required, "
   13725           0 :                                  "but no Daylighting Controls are defined in Zone:" +
   13726           0 :                                      state.dataHeatBal->Zone(ZoneNum).Name);
   13727             :             }
   13728             :         }
   13729             :     }
   13730             : 
   13731          53 :     if (state.dataGlobal->NumOfZones <= 0) return;
   13732          53 :     std::array<int, numColumnVisualTbl> columnHead = {state.dataOutRptPredefined->pdchIllumHourDark,
   13733          53 :                                                       state.dataOutRptPredefined->pdchIllumHourDim,
   13734          53 :                                                       state.dataOutRptPredefined->pdchIllumHourAdequate,
   13735         159 :                                                       state.dataOutRptPredefined->pdchIllumHourBright};
   13736             : 
   13737          53 :     std::array<Real64, numColumnVisualTbl> DataHeatBalance::ZoneResilience::*ptrLightingLevelHourBins =
   13738             :         &DataHeatBalance::ZoneResilience::ZoneLightingLevelHourBins;
   13739          53 :     std::array<Real64, numColumnVisualTbl> DataHeatBalance::ZoneResilience::*ptrLightingLevelOccuHourBins =
   13740             :         &DataHeatBalance::ZoneResilience::ZoneLightingLevelOccuHourBins;
   13741          53 :     std::array<Real64, numColumnVisualTbl> DataHeatBalance::ZoneResilience::*ptrLightingLevelOccupiedHourBins =
   13742             :         &DataHeatBalance::ZoneResilience::ZoneLightingLevelOccupiedHourBins;
   13743          53 :     WriteResilienceBinsTable<numColumnVisualTbl>(state, columnHead, ptrLightingLevelHourBins);
   13744             : 
   13745         106 :     columnHead = {state.dataOutRptPredefined->pdchIllumOccuHourDark,
   13746          53 :                   state.dataOutRptPredefined->pdchIllumOccuHourDim,
   13747          53 :                   state.dataOutRptPredefined->pdchIllumOccuHourAdequate,
   13748          53 :                   state.dataOutRptPredefined->pdchIllumOccuHourBright};
   13749          53 :     WriteResilienceBinsTable<numColumnVisualTbl>(state, columnHead, ptrLightingLevelOccuHourBins);
   13750             : 
   13751         106 :     columnHead = {state.dataOutRptPredefined->pdchIllumOccupiedHourDark,
   13752          53 :                   state.dataOutRptPredefined->pdchIllumOccupiedHourDim,
   13753          53 :                   state.dataOutRptPredefined->pdchIllumOccupiedHourAdequate,
   13754          53 :                   state.dataOutRptPredefined->pdchIllumOccupiedHourBright};
   13755          53 :     WriteResilienceBinsTable<numColumnVisualTbl>(state, columnHead, ptrLightingLevelOccupiedHourBins);
   13756             : }
   13757             : 
   13758           3 : void WriteVisualResilienceTablesRepPeriod(EnergyPlusData &state, const int periodIdx)
   13759             : {
   13760           3 :     auto &ort(state.dataOutRptTab);
   13761           3 :     if (!ort->WriteTabularFiles) return;
   13762           3 :     WriteReportHeaderReportingPeriod(state, "Visual", periodIdx, state.dataWeatherManager->VisualReportPeriodInput);
   13763           6 :     std::string periodTitle = state.dataWeatherManager->VisualReportPeriodInput(periodIdx).title;
   13764             : 
   13765           6 :     Array1D_int columnWidth;
   13766           3 :     columnWidth.allocate(numColumnVisualTbl);
   13767           3 :     columnWidth = 10;
   13768           6 :     Array1D_string columnHead(numColumnVisualTbl);
   13769           3 :     columnHead(1) = "A Bit Dark (<= 100 lux) [hr]";
   13770           3 :     columnHead(2) = "Dim (> 100, <= 300 lux) [hr]";
   13771           3 :     columnHead(3) = "Adequate (> 300, <= 500 lux) [hr]";
   13772           3 :     columnHead(4) = "Bright (>500 lux) [hr]";
   13773             : 
   13774           6 :     Array1D_string rowHead;
   13775           6 :     Array2D_string tableBody;
   13776           3 :     rowHead.allocate(state.dataGlobal->NumOfZones + 4);
   13777           3 :     tableBody.allocate(numColumnVisualTbl, state.dataGlobal->NumOfZones + 4);
   13778             : 
   13779           6 :     std::string tableName = "Illuminance Level Hours";
   13780           6 :     std::string tableType = "Visual";
   13781           3 :     WriteResilienceBinsTableReportingPeriod(state,
   13782             :                                             tableType,
   13783             :                                             numColumnVisualTbl,
   13784             :                                             periodIdx,
   13785             :                                             periodTitle,
   13786             :                                             tableName,
   13787             :                                             columnHead,
   13788             :                                             columnWidth,
   13789           3 :                                             state.dataHeatBalFanSys->ZoneLightingLevelHourBinsRepPeriod,
   13790             :                                             rowHead,
   13791             :                                             tableBody);
   13792             : 
   13793           3 :     tableName = "Illuminance Level OccupantHours";
   13794           3 :     WriteResilienceBinsTableReportingPeriod(state,
   13795             :                                             tableType,
   13796             :                                             numColumnVisualTbl,
   13797             :                                             periodIdx,
   13798             :                                             periodTitle,
   13799             :                                             tableName,
   13800             :                                             columnHead,
   13801             :                                             columnWidth,
   13802           3 :                                             state.dataHeatBalFanSys->ZoneLightingLevelOccuHourBinsRepPeriod,
   13803             :                                             rowHead,
   13804             :                                             tableBody);
   13805             : 
   13806           3 :     tableName = "Illuminance Level OccupiedHours";
   13807           3 :     WriteResilienceBinsTableReportingPeriod(state,
   13808             :                                             tableType,
   13809             :                                             numColumnVisualTbl,
   13810             :                                             periodIdx,
   13811             :                                             periodTitle,
   13812             :                                             tableName,
   13813             :                                             columnHead,
   13814             :                                             columnWidth,
   13815           3 :                                             state.dataHeatBalFanSys->ZoneLightingLevelOccupiedHourBinsRepPeriod,
   13816             :                                             rowHead,
   13817             :                                             tableBody);
   13818             : }
   13819             : 
   13820         731 : void WriteHeatEmissionTable(EnergyPlusData &state)
   13821             : {
   13822             : 
   13823        1462 :     Array1D_string columnHead(6);
   13824        1462 :     Array1D_int columnWidth;
   13825        1462 :     Array1D_string rowHead;
   13826        1462 :     Array2D_string tableBody;
   13827         731 :     auto &ort(state.dataOutRptTab);
   13828             : 
   13829         731 :     if (state.dataOutRptTab->displayHeatEmissionsSummary) {
   13830             : 
   13831        1308 :         for (int iUnitSystem = 0; iUnitSystem <= 1; iUnitSystem++) {
   13832        1308 :             UnitsStyle unitsStyle_cur = ort->unitsStyle;
   13833        1308 :             bool produceTabular = true;
   13834        1308 :             bool produceSQLite = false;
   13835        1308 :             if (produceDualUnitsFlags(iUnitSystem, ort->unitsStyle, ort->unitsStyle_SQLite, unitsStyle_cur, produceTabular, produceSQLite)) break;
   13836             : 
   13837         654 :             if (produceTabular) {
   13838         654 :                 WriteReportHeaders(state, "Annual Heat Emissions Report", "Entire Facility", OutputProcessor::StoreType::Averaged);
   13839         654 :                 WriteSubtitle(state, "Annual Heat Emissions Summary");
   13840             :             }
   13841             : 
   13842         654 :             columnWidth.allocate(6);
   13843         654 :             columnWidth = 10;
   13844             : 
   13845         654 :             rowHead.allocate(1);
   13846         654 :             tableBody.allocate(6, 1);
   13847             : 
   13848         654 :             Real64 energyconversion = 1.0;
   13849         654 :             if (unitsStyle_cur == UnitsStyle::InchPound) {
   13850          11 :                 rowHead(1) = "Heat Emissions [kBtu]";
   13851          11 :                 energyconversion = 1.0 / getSpecificUnitDivider(state, "GJ", "kBtu"); // 1054351.84 J to kBtu
   13852         643 :             } else if (unitsStyle_cur == UnitsStyle::JtoGJ) {
   13853           0 :                 rowHead(1) = "Heat Emissions [GJ]";
   13854           0 :                 energyconversion = 1.0;
   13855         643 :             } else if (unitsStyle_cur == UnitsStyle::JtoKWH) {
   13856           5 :                 rowHead(1) = "Heat Emissions [kWh]";
   13857           5 :                 energyconversion = 1.0e3 / 3.6;
   13858         638 :             } else if (unitsStyle_cur == UnitsStyle::JtoMJ) {
   13859           0 :                 rowHead(1) = "Heat Emissions [MJ]";
   13860           0 :                 energyconversion = 1.0e3;
   13861         638 :             } else if (unitsStyle_cur == UnitsStyle::None) {
   13862         638 :                 rowHead(1) = "Heat Emissions [GJ]";
   13863         638 :                 energyconversion = 1.0;
   13864             :             } else {
   13865           0 :                 rowHead(1) = "Heat Emissions [GJ]";
   13866           0 :                 energyconversion = 1.0;
   13867             :             }
   13868             : 
   13869         654 :             columnHead(1) = "Envelope Convection";
   13870         654 :             columnHead(2) = "Zone Exfiltration";
   13871         654 :             columnHead(3) = "Zone Exhaust Air";
   13872         654 :             columnHead(4) = "HVAC Relief Air";
   13873         654 :             columnHead(5) = "HVAC Reject Heat";
   13874         654 :             columnHead(6) = "Total";
   13875             : 
   13876         654 :             tableBody = "";
   13877         654 :             tableBody(1, 1) = RealToStr(state.dataHeatBal->BuildingPreDefRep.emiEnvelopConv * energyconversion, 2);
   13878         654 :             tableBody(2, 1) = RealToStr(state.dataHeatBal->BuildingPreDefRep.emiZoneExfiltration * energyconversion, 2);
   13879         654 :             tableBody(3, 1) = RealToStr(state.dataHeatBal->BuildingPreDefRep.emiZoneExhaust * energyconversion, 2);
   13880         654 :             tableBody(4, 1) = RealToStr(state.dataHeatBal->BuildingPreDefRep.emiHVACRelief * energyconversion, 2);
   13881         654 :             tableBody(5, 1) = RealToStr(state.dataHeatBal->BuildingPreDefRep.emiHVACReject * energyconversion, 2);
   13882         654 :             tableBody(6, 1) = RealToStr(state.dataHeatBal->BuildingPreDefRep.emiTotHeat * energyconversion, 2);
   13883             : 
   13884         654 :             if (produceTabular) {
   13885         654 :                 WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
   13886         654 :                 if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
   13887           4 :                     state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(
   13888             :                         tableBody, rowHead, columnHead, "AnnualHeatEmissionsReport", "Entire Facility", "Annual Heat Emissions Summary");
   13889             :                 }
   13890             :             }
   13891         654 :             if (produceSQLite) {
   13892         654 :                 if (state.dataSQLiteProcedures->sqlite) {
   13893          71 :                     state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
   13894             :                         tableBody, rowHead, columnHead, "AnnualHeatEmissionsReport", "Entire Facility", "Annual Heat Emissions Summary");
   13895             :                 }
   13896             :             }
   13897             :         }
   13898             :     }
   13899         731 : }
   13900             : 
   13901         731 : void WritePredefinedTables(EnergyPlusData &state)
   13902             : {
   13903             :     // SUBROUTINE INFORMATION:
   13904             :     //       AUTHOR         Jason Glazer
   13905             :     //       DATE WRITTEN   August 2006
   13906             :     //       MODIFIED       January 2010, Kyle Benne; Added SQLite output
   13907             :     //                      March 2010, Linda Lawrie; Modify SizingPeriod:DesignDay to convert column/humidity types
   13908             :     //       RE-ENGINEERED  na
   13909             : 
   13910             :     // PURPOSE OF THIS SUBROUTINE:
   13911             :     //   Write out tables that have been predefined with data gathered
   13912             :     //   throughout the program code.
   13913             : 
   13914             :     // METHODOLOGY EMPLOYED:
   13915             :     //   Create arrays for the call to WriteTable and then call it.
   13916             :     //   This is a generic routine to write a report with multiple
   13917             :     //   subtables. The structure of the report are created in
   13918             :     //   OutputReportPredefined which also includes a routine that
   13919             :     //   builds up a tableEntry array which holds the data for the
   13920             :     //   predefined reports.
   13921             : 
   13922             :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
   13923             : 
   13924             :     // all arrays are in the format: (row, column)
   13925        1462 :     Array1D_string columnHead;
   13926        1462 :     Array1D_int columnWidth;
   13927        1462 :     Array1D_string rowHead;
   13928        1462 :     Array2D_string tableBody;
   13929        1462 :     Array1D_int rowToUnqObjName;
   13930        1462 :     Array1D_int colHeadToColTag;
   13931             :     int curNumColumns;
   13932             :     int curNumRows;
   13933             :     int curColumn;
   13934        1462 :     Array1D_string uniqueObjectName;
   13935        1462 :     Array1D_bool useUniqueObjectName;
   13936             :     int numUnqObjName;
   13937        1462 :     std::string curObjectName;
   13938             :     int countRow;
   13939             :     int countColumn;
   13940             :     int found;
   13941             :     int curColTagIndex;
   13942             :     int curRowUnqObjIndex;
   13943         731 :     int colCurrent(0);
   13944         731 :     int rowCurrent(0);
   13945             :     int iReportName;
   13946             :     int kColumnTag;
   13947             :     int lTableEntry;
   13948             :     int mUnqObjNames;
   13949             :     int nColHead;
   13950             :     int oRowHead;
   13951        1462 :     std::string colTagWithSI;
   13952        1462 :     std::string curColTag;
   13953        1462 :     Array1D_int colUnitConv;
   13954             :     int indexUnitConv;
   13955             :     int columnUnitConv;
   13956        1462 :     std::string repTableTag;
   13957             :     Real64 IPvalue;
   13958         731 :     auto &ort(state.dataOutRptTab);
   13959             : 
   13960        1462 :     for (int iUnitSystem = 0; iUnitSystem <= 1; iUnitSystem++) {
   13961        1462 :         UnitsStyle unitsStyle_cur = ort->unitsStyle;
   13962        1462 :         bool produceTabular = true;
   13963        1462 :         bool produceSQLite = false;
   13964        1462 :         if (produceDualUnitsFlags(iUnitSystem, ort->unitsStyle, ort->unitsStyle_SQLite, unitsStyle_cur, produceTabular, produceSQLite)) break;
   13965             : 
   13966             :         // loop through the entries and associate them with the subtable and create
   13967             :         // list of unique object names
   13968             :         // Much of this code is to allow for integer compares instead of string
   13969             :         // compares that are nested three levels in a loop.
   13970         731 :         uniqueObjectName.allocate(state.dataOutRptPredefined->numTableEntry);
   13971         731 :         useUniqueObjectName.allocate(state.dataOutRptPredefined->numTableEntry);
   13972         731 :         numUnqObjName = 0;
   13973     2998491 :         for (lTableEntry = 1; lTableEntry <= state.dataOutRptPredefined->numTableEntry; ++lTableEntry) {
   13974             :             // associate the subtable with each column
   13975     2997760 :             curColumn = state.dataOutRptPredefined->tableEntry(lTableEntry).indexColumn;
   13976     2997760 :             if ((curColumn >= 1) && (curColumn <= state.dataOutRptPredefined->numColumnTag)) {
   13977     2997760 :                 state.dataOutRptPredefined->tableEntry(lTableEntry).subTableIndex = state.dataOutRptPredefined->columnTag(curColumn).indexSubTable;
   13978             :             }
   13979             :             // make a list of unique object names
   13980     2997760 :             curObjectName = state.dataOutRptPredefined->tableEntry(lTableEntry).objectName;
   13981     2997760 :             found = 0;
   13982  1708929752 :             for (mUnqObjNames = 1; mUnqObjNames <= numUnqObjName; ++mUnqObjNames) {
   13983  1705931992 :                 if (curObjectName == uniqueObjectName(mUnqObjNames)) {
   13984     2746914 :                     found = mUnqObjNames;
   13985             :                 }
   13986             :             }
   13987             :             // if found then point to the unique object
   13988     2997760 :             if (found > 0) {
   13989     2746914 :                 state.dataOutRptPredefined->tableEntry(lTableEntry).uniqueObjName = found;
   13990             :                 // if not found add to the unique object list
   13991             :             } else {
   13992      250846 :                 ++numUnqObjName;
   13993      250846 :                 uniqueObjectName(numUnqObjName) = curObjectName;
   13994      250846 :                 state.dataOutRptPredefined->tableEntry(lTableEntry).uniqueObjName = numUnqObjName;
   13995             :             }
   13996             :         }
   13997             :         // loop through all reports and include those that have been flagged as 'show'
   13998       12828 :         for (iReportName = 1; iReportName <= state.dataOutRptPredefined->numReportName; ++iReportName) {
   13999       12097 :             if (state.dataOutRptPredefined->reportName(iReportName).show) {
   14000       11105 :                 if (produceTabular) {
   14001       22210 :                     WriteReportHeaders(state,
   14002       11105 :                                        state.dataOutRptPredefined->reportName(iReportName).namewithspaces,
   14003             :                                        "Entire Facility",
   14004             :                                        OutputProcessor::StoreType::Averaged);
   14005             :                 }
   14006             :                 // loop through the subtables and include those that are associated with this report
   14007      947053 :                 for (int jSubTable = 1, jSubTable_end = state.dataOutRptPredefined->numSubTable; jSubTable <= jSubTable_end; ++jSubTable) {
   14008      935948 :                     if (state.dataOutRptPredefined->subTable(jSubTable).indexReportName == iReportName) {
   14009             :                         // determine how many columns
   14010       56938 :                         curNumColumns = 0;
   14011    39152595 :                         for (kColumnTag = 1; kColumnTag <= state.dataOutRptPredefined->numColumnTag; ++kColumnTag) {
   14012    39095657 :                             if (state.dataOutRptPredefined->columnTag(kColumnTag).indexSubTable == jSubTable) {
   14013      463392 :                                 ++curNumColumns;
   14014             :                             }
   14015             :                         }
   14016             :                         // determine how many rows by going through table entries and setting
   14017             :                         // flag in useUniqueObjectName to true, then count number of true's.
   14018       56938 :                         useUniqueObjectName = false; // array assignment
   14019   217283445 :                         for (lTableEntry = 1; lTableEntry <= state.dataOutRptPredefined->numTableEntry; ++lTableEntry) {
   14020   217226507 :                             if (state.dataOutRptPredefined->tableEntry(lTableEntry).subTableIndex == jSubTable) {
   14021     2514445 :                                 useUniqueObjectName(state.dataOutRptPredefined->tableEntry(lTableEntry).uniqueObjName) = true;
   14022             :                             }
   14023             :                         }
   14024       56938 :                         curNumRows = 0;
   14025    18600180 :                         for (mUnqObjNames = 1; mUnqObjNames <= numUnqObjName; ++mUnqObjNames) {
   14026    18543242 :                             if (useUniqueObjectName(mUnqObjNames)) {
   14027      298572 :                                 ++curNumRows;
   14028             :                             }
   14029             :                         }
   14030       56938 :                         if (curNumRows == 0) curNumRows = 1;
   14031             :                         // now create the arrays that are filled with values
   14032       56938 :                         rowHead.allocate(curNumRows);
   14033       56938 :                         columnHead.allocate(curNumColumns);
   14034       56938 :                         columnWidth.dimension(curNumColumns, 14); // array assignment - same for all columns
   14035       56938 :                         tableBody.allocate(curNumColumns, curNumRows);
   14036       56938 :                         rowHead = "";
   14037       56938 :                         columnHead = "";
   14038       56938 :                         tableBody = "";
   14039             :                         // this array stores the unique object name index for each row
   14040       56938 :                         rowToUnqObjName.allocate(curNumRows);
   14041             :                         // this array stores the columnHead index for each column
   14042       56938 :                         colHeadToColTag.allocate(curNumColumns);
   14043       56938 :                         colUnitConv.allocate(curNumColumns);
   14044             :                         // set row headings
   14045       56938 :                         countRow = 0;
   14046       56938 :                         rowHead(1) = "None";
   14047    18600180 :                         for (mUnqObjNames = 1; mUnqObjNames <= numUnqObjName; ++mUnqObjNames) {
   14048    18543242 :                             if (useUniqueObjectName(mUnqObjNames)) {
   14049      298572 :                                 ++countRow;
   14050      298572 :                                 rowHead(countRow) = uniqueObjectName(mUnqObjNames);
   14051      298572 :                                 rowToUnqObjName(countRow) = mUnqObjNames;
   14052             :                             }
   14053             :                         }
   14054             :                         // set column headings
   14055       56938 :                         countColumn = 0;
   14056    39152595 :                         for (kColumnTag = 1; kColumnTag <= state.dataOutRptPredefined->numColumnTag; ++kColumnTag) {
   14057    39095657 :                             if (state.dataOutRptPredefined->columnTag(kColumnTag).indexSubTable == jSubTable) {
   14058      463392 :                                 ++countColumn;
   14059             :                                 // do the unit conversions
   14060      463392 :                                 colTagWithSI = state.dataOutRptPredefined->columnTag(kColumnTag).heading;
   14061      463392 :                                 if (unitsStyle_cur == UnitsStyle::InchPound) {
   14062        7805 :                                     LookupSItoIP(state, colTagWithSI, indexUnitConv, curColTag);
   14063        7805 :                                     colUnitConv(countColumn) = indexUnitConv;
   14064      455587 :                                 } else if (unitsStyle_cur == UnitsStyle::JtoKWH) {
   14065        3625 :                                     LookupJtokWH(state, colTagWithSI, indexUnitConv, curColTag);
   14066        3625 :                                     colUnitConv(countColumn) = indexUnitConv;
   14067             :                                 } else {
   14068      451962 :                                     curColTag = colTagWithSI;
   14069      451962 :                                     colUnitConv(countColumn) = 0;
   14070             :                                 }
   14071      463392 :                                 columnHead(countColumn) = curColTag;
   14072      463392 :                                 colHeadToColTag(countColumn) = kColumnTag;
   14073             :                             }
   14074             :                         }
   14075             :                         // fill the body of the table from the entries
   14076             :                         // find the entries associated with the current subtable
   14077   217283445 :                         for (lTableEntry = 1; lTableEntry <= state.dataOutRptPredefined->numTableEntry; ++lTableEntry) {
   14078   217226507 :                             if (state.dataOutRptPredefined->tableEntry(lTableEntry).subTableIndex == jSubTable) {
   14079             :                                 // determine what column the current entry is in
   14080     2514445 :                                 curColTagIndex = state.dataOutRptPredefined->tableEntry(lTableEntry).indexColumn;
   14081    31757442 :                                 for (nColHead = 1; nColHead <= curNumColumns; ++nColHead) {
   14082    31757442 :                                     if (curColTagIndex == colHeadToColTag(nColHead)) {
   14083     2514445 :                                         colCurrent = nColHead;
   14084     2514445 :                                         break;
   14085             :                                     }
   14086             :                                 }
   14087             :                                 // determine what row the current entry is in
   14088     2514445 :                                 curRowUnqObjIndex = state.dataOutRptPredefined->tableEntry(lTableEntry).uniqueObjName;
   14089    71050461 :                                 for (oRowHead = 1; oRowHead <= curNumRows; ++oRowHead) {
   14090    71050461 :                                     if (curRowUnqObjIndex == rowToUnqObjName(oRowHead)) {
   14091     2514445 :                                         rowCurrent = oRowHead;
   14092     2514445 :                                         break;
   14093             :                                     }
   14094             :                                 }
   14095             :                                 // finally assign the entry to the place in the table body
   14096     2514445 :                                 if (unitsStyle_cur == UnitsStyle::InchPound || unitsStyle_cur == UnitsStyle::JtoKWH) {
   14097       55244 :                                     columnUnitConv = colUnitConv(colCurrent);
   14098       55532 :                                     if (UtilityRoutines::SameString(state.dataOutRptPredefined->subTable(jSubTable).name, "SizingPeriod:DesignDay") &&
   14099         288 :                                         unitsStyle_cur == UnitsStyle::InchPound) {
   14100         228 :                                         if (UtilityRoutines::SameString(columnHead(colCurrent), "Humidity Value")) {
   14101          38 :                                             LookupSItoIP(state,
   14102          38 :                                                          state.dataOutRptPredefined->tableEntry(lTableEntry + 1).charEntry,
   14103             :                                                          columnUnitConv,
   14104             :                                                          repTableTag);
   14105          38 :                                             state.dataOutRptPredefined->tableEntry(lTableEntry + 1).charEntry = repTableTag;
   14106             :                                         }
   14107             :                                     }
   14108      110488 :                                     if (state.dataOutRptPredefined->tableEntry(lTableEntry).origEntryIsReal && (columnUnitConv != 0)) {
   14109       29259 :                                         IPvalue = ConvertIP(state, columnUnitConv, state.dataOutRptPredefined->tableEntry(lTableEntry).origRealEntry);
   14110       29259 :                                         tableBody(colCurrent, rowCurrent) =
   14111       58518 :                                             RealToStr(IPvalue, state.dataOutRptPredefined->tableEntry(lTableEntry).significantDigits);
   14112             :                                     } else {
   14113       25985 :                                         tableBody(colCurrent, rowCurrent) = state.dataOutRptPredefined->tableEntry(lTableEntry).charEntry;
   14114             :                                     }
   14115             :                                 } else {
   14116     2459201 :                                     tableBody(colCurrent, rowCurrent) = state.dataOutRptPredefined->tableEntry(lTableEntry).charEntry;
   14117             :                                 }
   14118             :                             }
   14119             :                         }
   14120             :                         // create the actual output table
   14121       56938 :                         if (produceTabular) {
   14122       56938 :                             WriteSubtitle(state, state.dataOutRptPredefined->subTable(jSubTable).name);
   14123       56938 :                             WriteTable(
   14124       56938 :                                 state, tableBody, rowHead, columnHead, columnWidth, false, state.dataOutRptPredefined->subTable(jSubTable).footnote);
   14125             :                         }
   14126       56938 :                         if (produceSQLite) {
   14127       56938 :                             if (state.dataSQLiteProcedures->sqlite) {
   14128       21786 :                                 state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
   14129             :                                     tableBody,
   14130             :                                     rowHead,
   14131             :                                     columnHead,
   14132        7262 :                                     state.dataOutRptPredefined->reportName(iReportName).name,
   14133             :                                     "Entire Facility",
   14134        7262 :                                     state.dataOutRptPredefined->subTable(jSubTable).name);
   14135             :                             }
   14136             :                         }
   14137       56938 :                         if (produceTabular) {
   14138       56938 :                             if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
   14139        1152 :                                 state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(
   14140             :                                     tableBody,
   14141             :                                     rowHead,
   14142             :                                     columnHead,
   14143         384 :                                     state.dataOutRptPredefined->reportName(iReportName).name,
   14144             :                                     "Entire Facility",
   14145         384 :                                     state.dataOutRptPredefined->subTable(jSubTable).name);
   14146             :                             }
   14147             :                         }
   14148             :                     }
   14149             :                 }
   14150             :             }
   14151             :         }
   14152             :     }
   14153         731 : }
   14154             : 
   14155         731 : void WriteComponentSizing(EnergyPlusData &state)
   14156             : {
   14157             :     // SUBROUTINE INFORMATION:
   14158             :     //       AUTHOR         Jason Glazer
   14159             :     //       DATE WRITTEN   July 2007
   14160             :     //       MODIFIED       January 2010, Kyle Benne
   14161             :     //                      Added SQLite output
   14162             :     //       RE-ENGINEERED  na
   14163             : 
   14164             :     // PURPOSE OF THIS SUBROUTINE:
   14165             :     //   Write out tables based on component sizing data originally
   14166             :     //   found in the EIO report.
   14167             : 
   14168             :     // METHODOLOGY EMPLOYED:
   14169             :     //   Create arrays for the call to WriteTable and then call it.
   14170             :     //   The tables created do not have known headers for rows or
   14171             :     //   columns so those are determined based on what calls have
   14172             :     //   been made to the Sizer routine.  A table
   14173             :     //   is created for each type of component. Columns are created
   14174             :     //   for each description within that table. Rows are created
   14175             :     //   for each named object.
   14176             : 
   14177             :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
   14178             :     // all arrays are in the format: (row, column)
   14179        1462 :     Array1D_string columnHead;
   14180        1462 :     Array1D_int columnWidth;
   14181        1462 :     Array1D_int colUnitConv;
   14182        1462 :     Array1D_string rowHead;
   14183        1462 :     Array2D_string tableBody;
   14184        1462 :     Array1D_string uniqueDesc;
   14185             :     int numUniqueDesc;
   14186        1462 :     Array1D_string uniqueObj;
   14187             :     int numUniqueObj;
   14188        1462 :     std::string curDesc;
   14189        1462 :     std::string curObj;
   14190             :     int foundEntry;
   14191             :     int foundDesc;
   14192             :     int foundObj;
   14193             :     int loopLimit;
   14194             :     int iTableEntry;
   14195             :     int jUnique;
   14196         731 :     auto &ort(state.dataOutRptTab);
   14197             : 
   14198         731 :     if (ort->displayComponentSizing) {
   14199         711 :         WriteReportHeaders(state, "Component Sizing Summary", "Entire Facility", OutputProcessor::StoreType::Averaged);
   14200             : 
   14201        1422 :         for (int iUnitSystem = 0; iUnitSystem <= 1; iUnitSystem++) {
   14202        1422 :             UnitsStyle unitsStyle_cur = ort->unitsStyle;
   14203        1422 :             bool produceTabular = true;
   14204        1422 :             bool produceSQLite = false;
   14205        1422 :             if (produceDualUnitsFlags(iUnitSystem, ort->unitsStyle, ort->unitsStyle_SQLite, unitsStyle_cur, produceTabular, produceSQLite)) break;
   14206             : 
   14207             :             // The arrays that look for unique headers are dimensioned in the
   14208             :             // running program since the size of the number of entries is
   14209             :             // not previously known. Use the size of all entries since that
   14210             :             // is the maximum possible.
   14211         711 :             uniqueDesc.allocate(state.dataOutRptPredefined->numCompSizeTableEntry);
   14212         711 :             uniqueObj.allocate(state.dataOutRptPredefined->numCompSizeTableEntry);
   14213             :             // initially clear the written flags for entire array
   14214             :             // The following line is not really necessary and it is possible that the array has
   14215             :             // not been allocated when this is first called.
   14216             :             //  CompSizeTableEntry%written = .FALSE.
   14217             :             // repeat the following loop until everything in array has been
   14218             :             // written into a table
   14219         711 :             loopLimit = 0;
   14220       11859 :             while (loopLimit <= 100) { // put a maximum count since complex loop that could run indefinitely if error
   14221        6285 :                 foundEntry = 0;
   14222        6285 :                 ++loopLimit;
   14223      597301 :                 for (iTableEntry = 1; iTableEntry <= state.dataOutRptPredefined->numCompSizeTableEntry; ++iTableEntry) {
   14224      596590 :                     if (!state.dataOutRptPredefined->CompSizeTableEntry(iTableEntry).written) {
   14225        5574 :                         foundEntry = iTableEntry;
   14226        5574 :                         break;
   14227             :                     }
   14228             :                 }
   14229        6285 :                 if (foundEntry == 0) break; // leave main loop - all items put into tables
   14230             :                 // clear active items
   14231     1358574 :                 for (auto &e : state.dataOutRptPredefined->CompSizeTableEntry)
   14232     1353000 :                     e.active = false;
   14233             :                 // make an unwritten item that is of the same type active - these will be the
   14234             :                 // entries for the particular subtable.
   14235      830600 :                 for (iTableEntry = 1; iTableEntry <= state.dataOutRptPredefined->numCompSizeTableEntry; ++iTableEntry) {
   14236      825026 :                     if (!state.dataOutRptPredefined->CompSizeTableEntry(iTableEntry).written) {
   14237      235549 :                         if (UtilityRoutines::SameString(state.dataOutRptPredefined->CompSizeTableEntry(iTableEntry).typeField,
   14238      235549 :                                                         state.dataOutRptPredefined->CompSizeTableEntry(foundEntry).typeField)) {
   14239       62641 :                             state.dataOutRptPredefined->CompSizeTableEntry(iTableEntry).active = true;
   14240             :                         }
   14241             :                     }
   14242             :                 }
   14243             :                 // identify unique descriptions and objects (columns and rows) in order
   14244             :                 // to size the table arrays properly.
   14245             :                 // reset the counters for the arrays looking for unique rows and columns
   14246        5574 :                 numUniqueDesc = 0;
   14247        5574 :                 numUniqueObj = 0;
   14248      830600 :                 for (iTableEntry = 1; iTableEntry <= state.dataOutRptPredefined->numCompSizeTableEntry; ++iTableEntry) {
   14249             :                     // search for descriptions
   14250      825026 :                     foundDesc = 0;
   14251      825026 :                     if (state.dataOutRptPredefined->CompSizeTableEntry(iTableEntry).active) {
   14252       62641 :                         curDesc = state.dataOutRptPredefined->CompSizeTableEntry(iTableEntry).description;
   14253             :                         // look through the list of unique items to see if it matches
   14254      230436 :                         for (jUnique = 1; jUnique <= numUniqueDesc; ++jUnique) {
   14255      213110 :                             if (UtilityRoutines::SameString(curDesc, uniqueDesc(jUnique))) {
   14256       45315 :                                 foundDesc = jUnique;
   14257       45315 :                                 break;
   14258             :                             }
   14259             :                         }
   14260             :                         // if not found add to the list
   14261       62641 :                         if (foundDesc == 0) {
   14262       17326 :                             ++numUniqueDesc;
   14263       17326 :                             uniqueDesc(numUniqueDesc) = curDesc;
   14264             :                         }
   14265             :                         // search for objects
   14266       62641 :                         foundObj = 0;
   14267       62641 :                         curObj = state.dataOutRptPredefined->CompSizeTableEntry(iTableEntry).nameField;
   14268      773175 :                         for (jUnique = 1; jUnique <= numUniqueObj; ++jUnique) {
   14269      755869 :                             if (UtilityRoutines::SameString(curObj, uniqueObj(jUnique))) {
   14270       45335 :                                 foundObj = jUnique;
   14271       45335 :                                 break;
   14272             :                             }
   14273             :                         }
   14274             :                         // if not found add to the list
   14275       62641 :                         if (foundObj == 0) {
   14276       17306 :                             ++numUniqueObj;
   14277       17306 :                             uniqueObj(numUniqueObj) = curObj;
   14278             :                         }
   14279             :                     }
   14280             :                 }
   14281             :                 // make sure the table has at least one row and columns
   14282        5574 :                 if (numUniqueDesc == 0) numUniqueDesc = 1;
   14283        5574 :                 if (numUniqueObj == 0) numUniqueObj = 1;
   14284             :                 // now that the unique row and column headers are known the array
   14285             :                 // sizes can be set for the table arrays
   14286        5574 :                 rowHead.allocate(numUniqueObj);
   14287        5574 :                 columnHead.allocate(numUniqueDesc);
   14288        5574 :                 columnWidth.dimension(numUniqueDesc, 14); // array assignment - same for all columns
   14289        5574 :                 colUnitConv.allocate(numUniqueDesc);
   14290        5574 :                 tableBody.allocate(numUniqueDesc, numUniqueObj);
   14291             :                 // initialize table body to blanks (in case entries are incomplete)
   14292        5574 :                 tableBody = "";
   14293             :                 // transfer the row and column headings first
   14294       22900 :                 for (jUnique = 1; jUnique <= numUniqueDesc; ++jUnique) {
   14295             :                     // do the unit conversions
   14296       17326 :                     state.dataOutRptTab->curColHeadWithSI = uniqueDesc(jUnique);
   14297       17326 :                     if (unitsStyle_cur == UnitsStyle::InchPound) {
   14298         999 :                         LookupSItoIP(
   14299         999 :                             state, state.dataOutRptTab->curColHeadWithSI, state.dataOutRptTab->indexUnitConvWCS, state.dataOutRptTab->curColHead);
   14300         333 :                         colUnitConv(jUnique) = state.dataOutRptTab->indexUnitConvWCS;
   14301             :                     } else {
   14302       16993 :                         state.dataOutRptTab->curColHead = state.dataOutRptTab->curColHeadWithSI;
   14303       16993 :                         colUnitConv(jUnique) = 0;
   14304             :                     }
   14305       17326 :                     columnHead(jUnique) = state.dataOutRptTab->curColHead;
   14306             :                 }
   14307       22880 :                 for (jUnique = 1; jUnique <= numUniqueObj; ++jUnique) {
   14308       17306 :                     rowHead(jUnique) = uniqueObj(jUnique);
   14309             :                 }
   14310             :                 // fill the table
   14311      830600 :                 for (iTableEntry = 1; iTableEntry <= state.dataOutRptPredefined->numCompSizeTableEntry; ++iTableEntry) {
   14312             :                     // find the row and column for the specific entry
   14313      825026 :                     if (state.dataOutRptPredefined->CompSizeTableEntry(iTableEntry).active) {
   14314       62641 :                         curDesc = state.dataOutRptPredefined->CompSizeTableEntry(iTableEntry).description;
   14315       62641 :                         foundDesc = 0;
   14316      230436 :                         for (jUnique = 1; jUnique <= numUniqueDesc; ++jUnique) {
   14317      230436 :                             if (UtilityRoutines::SameString(uniqueDesc(jUnique), curDesc)) {
   14318       62641 :                                 foundDesc = jUnique;
   14319       62641 :                                 break;
   14320             :                             }
   14321             :                         }
   14322       62641 :                         curObj = state.dataOutRptPredefined->CompSizeTableEntry(iTableEntry).nameField;
   14323       62641 :                         foundObj = 0;
   14324      773175 :                         for (jUnique = 1; jUnique <= numUniqueObj; ++jUnique) {
   14325      773175 :                             if (UtilityRoutines::SameString(rowHead(jUnique), curObj)) {
   14326       62641 :                                 foundObj = jUnique;
   14327       62641 :                                 break;
   14328             :                             }
   14329             :                         }
   14330       62641 :                         if ((foundDesc >= 1) && (foundObj >= 1)) {
   14331       62641 :                             state.dataOutRptTab->curValueSIWCS = state.dataOutRptPredefined->CompSizeTableEntry(iTableEntry).valField;
   14332       62641 :                             if (unitsStyle_cur == UnitsStyle::InchPound) {
   14333         601 :                                 if (colUnitConv(foundDesc) != 0) {
   14334         533 :                                     state.dataOutRptTab->curValueWCS = ConvertIP(state, colUnitConv(foundDesc), state.dataOutRptTab->curValueSIWCS);
   14335             :                                 } else {
   14336          68 :                                     state.dataOutRptTab->curValueWCS = state.dataOutRptTab->curValueSIWCS;
   14337             :                                 }
   14338             :                             } else {
   14339       62040 :                                 state.dataOutRptTab->curValueWCS = state.dataOutRptTab->curValueSIWCS;
   14340             :                             }
   14341       62641 :                             if (std::abs(state.dataOutRptTab->curValueWCS) >= 1.0) {
   14342       24932 :                                 tableBody(foundDesc, foundObj) = RealToStr(state.dataOutRptTab->curValueWCS, 2);
   14343             :                             } else {
   14344       37709 :                                 tableBody(foundDesc, foundObj) = RealToStr(state.dataOutRptTab->curValueWCS, 6);
   14345             :                             }
   14346       62641 :                             state.dataOutRptPredefined->CompSizeTableEntry(iTableEntry).written = true;
   14347             :                         }
   14348             :                     }
   14349             :                 }
   14350             :                 // write the table
   14351        5574 :                 if (produceTabular) {
   14352        5574 :                     WriteSubtitle(state, state.dataOutRptPredefined->CompSizeTableEntry(foundEntry).typeField);
   14353             :                 }
   14354             : 
   14355       10950 :                 if (state.dataOutRptPredefined->CompSizeTableEntry(foundEntry).typeField == "AirTerminal:SingleDuct:VAV:Reheat" ||
   14356        5376 :                     state.dataOutRptPredefined->CompSizeTableEntry(foundEntry).typeField == "AirTerminal:SingleDuct:VAV:NoReheat") {
   14357         225 :                     if (produceTabular) {
   14358         225 :                         WriteTable(state,
   14359             :                                    tableBody,
   14360             :                                    rowHead,
   14361             :                                    columnHead,
   14362             :                                    columnWidth,
   14363             :                                    false,
   14364             :                                    "User-Specified values were used. Design Size values were used if no User-Specified values were provided. "
   14365             :                                    "Design Size "
   14366         225 :                                    "values may be derived from alternate User-Specified values.");
   14367             :                     }
   14368             :                 } else {
   14369        5349 :                     if (produceTabular) {
   14370        5349 :                         WriteTable(state,
   14371             :                                    tableBody,
   14372             :                                    rowHead,
   14373             :                                    columnHead,
   14374             :                                    columnWidth,
   14375             :                                    false,
   14376        5349 :                                    "User-Specified values were used. Design Size values were used if no User-Specified values were provided.");
   14377             :                     }
   14378             :                 }
   14379             : 
   14380        5574 :                 if (produceSQLite) {
   14381        5574 :                     if (state.dataSQLiteProcedures->sqlite) {
   14382        1998 :                         state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
   14383             :                             tableBody,
   14384             :                             rowHead,
   14385             :                             columnHead,
   14386             :                             "ComponentSizingSummary",
   14387             :                             "Entire Facility",
   14388         999 :                             state.dataOutRptPredefined->CompSizeTableEntry(foundEntry).typeField);
   14389             :                     }
   14390             :                 }
   14391        5574 :                 if (produceTabular) {
   14392        5574 :                     if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
   14393         112 :                         state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(
   14394             :                             tableBody,
   14395             :                             rowHead,
   14396             :                             columnHead,
   14397             :                             "ComponentSizingSummary",
   14398             :                             "Entire Facility",
   14399          56 :                             state.dataOutRptPredefined->CompSizeTableEntry(foundEntry).typeField,
   14400             :                             "User-Specified values were used. Design Size values were used if no User-Specified values were provided.");
   14401             :                     }
   14402             :                 }
   14403             :             }
   14404             :         }
   14405             :     }
   14406         731 : }
   14407             : 
   14408         731 : void WriteSurfaceShadowing(EnergyPlusData &state)
   14409             : {
   14410             :     // SUBROUTINE INFORMATION:
   14411             :     //       AUTHOR         Jason Glazer
   14412             :     //       DATE WRITTEN   July 2007
   14413             :     //       MODIFIED       January 2010, Kyle Benne
   14414             :     //                      Added SQLite output
   14415             :     //       RE-ENGINEERED  June 2014, Stuart Mentzer, Performance tuning
   14416             : 
   14417             :     // PURPOSE OF THIS SUBROUTINE:
   14418             :     //   Write out tables based on which surfaces shade subsurfaces.
   14419             : 
   14420             :     // METHODOLOGY EMPLOYED:
   14421             :     //   Create arrays for the call to WriteTable and then call it.
   14422             :     //   Use <br> tag to put multiple rows into a single cell.
   14423             : 
   14424             :     // Using/Aliasing
   14425             :     using namespace DataShadowingCombinations;
   14426             : 
   14427             :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
   14428             :     // all arrays are in the format: (row, column)
   14429        1462 :     Array1D_string columnHead(1);
   14430        1462 :     Array1D_int columnWidth(1);
   14431        1462 :     Array1D_string rowHead;
   14432        1462 :     Array2D_string tableBody;
   14433        1462 :     Array1D_int unique;
   14434             :     int numUnique;
   14435             :     int curRecSurf;
   14436        1462 :     std::string listOfSurf;
   14437             :     int iShadRel;
   14438             :     int jUnique;
   14439             :     int iKindRec;
   14440             :     int numreceivingfields;
   14441             :     int HTS;
   14442             :     int NGSS;
   14443         731 :     auto &ort(state.dataOutRptTab);
   14444             : 
   14445             :     // displaySurfaceShadowing = false  for debugging
   14446         731 :     if (ort->displaySurfaceShadowing) {
   14447         653 :         numreceivingfields = 0;
   14448       31687 :         for (HTS = 1; HTS <= state.dataSurface->TotSurfaces; ++HTS) {
   14449       31034 :             numreceivingfields += state.dataShadowComb->ShadowComb(HTS).NumGenSurf;
   14450       31034 :             numreceivingfields += state.dataShadowComb->ShadowComb(HTS).NumSubSurf;
   14451             :         }
   14452             : 
   14453         653 :         state.dataOutRptPredefined->ShadowRelate.allocate(numreceivingfields);
   14454         653 :         state.dataOutRptPredefined->numShadowRelate = 0;
   14455       31687 :         for (HTS = 1; HTS <= state.dataSurface->TotSurfaces; ++HTS) {
   14456       52030 :             for (NGSS = 1; NGSS <= state.dataShadowComb->ShadowComb(HTS).NumGenSurf; ++NGSS) {
   14457       20996 :                 ++state.dataOutRptPredefined->numShadowRelate;
   14458       20996 :                 state.dataOutRptPredefined->ShadowRelate(state.dataOutRptPredefined->numShadowRelate).castSurf =
   14459       20996 :                     state.dataShadowComb->ShadowComb(HTS).GenSurf(NGSS);
   14460       20996 :                 state.dataOutRptPredefined->ShadowRelate(state.dataOutRptPredefined->numShadowRelate).recSurf = HTS;
   14461       20996 :                 state.dataOutRptPredefined->ShadowRelate(state.dataOutRptPredefined->numShadowRelate).recKind = recKindSurface;
   14462             :             }
   14463       35474 :             for (NGSS = 1; NGSS <= state.dataShadowComb->ShadowComb(HTS).NumSubSurf; ++NGSS) {
   14464        4440 :                 ++state.dataOutRptPredefined->numShadowRelate;
   14465        4440 :                 state.dataOutRptPredefined->ShadowRelate(state.dataOutRptPredefined->numShadowRelate).castSurf =
   14466        4440 :                     state.dataShadowComb->ShadowComb(HTS).SubSurf(NGSS);
   14467        4440 :                 state.dataOutRptPredefined->ShadowRelate(state.dataOutRptPredefined->numShadowRelate).recSurf = HTS;
   14468        4440 :                 state.dataOutRptPredefined->ShadowRelate(state.dataOutRptPredefined->numShadowRelate).recKind = recKindSubsurface;
   14469             :             }
   14470             :         }
   14471         653 :         assert(numreceivingfields == state.dataOutRptPredefined->numShadowRelate);
   14472             : 
   14473         653 :         WriteReportHeaders(state, "Surface Shadowing Summary", "Entire Facility", OutputProcessor::StoreType::Averaged);
   14474         653 :         unique.allocate(state.dataOutRptPredefined->numShadowRelate);
   14475             :         // do entire process twice, once with surfaces receiving, once with subsurfaces receiving
   14476        1959 :         for (iKindRec = recKindSurface; iKindRec <= recKindSubsurface; ++iKindRec) {
   14477             : 
   14478             :             // Build map from receiving surface to container of names
   14479             :             typedef std::map<int, std::pair<int, std::vector<std::string const *>>> ShadowMap;
   14480        2612 :             ShadowMap shadow_map;
   14481       52178 :             for (iShadRel = 1; iShadRel <= state.dataOutRptPredefined->numShadowRelate; ++iShadRel) {
   14482       50872 :                 if (state.dataOutRptPredefined->ShadowRelate(iShadRel).recKind == iKindRec) {
   14483       25436 :                     curRecSurf = state.dataOutRptPredefined->ShadowRelate(iShadRel).recSurf;
   14484       25436 :                     std::string const &name(state.dataSurface->Surface(state.dataOutRptPredefined->ShadowRelate(iShadRel).castSurf).Name);
   14485       25436 :                     auto &elem(shadow_map[curRecSurf]);            // Creates the entry if not present (and zero-initializes the int in the pair)
   14486       25436 :                     elem.first += static_cast<int>(name.length()); // Accumulate total of name lengths
   14487       25436 :                     elem.second.push_back(&name);                  // Add this name
   14488             :                 }
   14489             :             }
   14490        1306 :             numUnique = static_cast<int>(shadow_map.size());
   14491        1306 :             if (numUnique == 0) {
   14492         256 :                 columnHead(1) = "None";
   14493             :             } else {
   14494        1050 :                 columnHead(1) = "Possible Shadow Receivers";
   14495             :             }
   14496        1306 :             columnWidth = 14; // array assignment - same for all columns
   14497        1306 :             rowHead.allocate(numUnique);
   14498        1306 :             tableBody.allocate(1, numUnique);
   14499        1306 :             jUnique = 0;
   14500        7446 :             for (auto const &elem : shadow_map) {
   14501        6140 :                 ++jUnique;
   14502        6140 :                 curRecSurf = elem.first;
   14503        6140 :                 rowHead(jUnique) = state.dataSurface->Surface(curRecSurf).Name;
   14504        6140 :                 listOfSurf.clear();
   14505        6140 :                 listOfSurf.reserve(elem.second.first + (3 * numUnique)); // To avoid string allocations during appends
   14506       31576 :                 for (auto const *p : elem.second.second) {
   14507       25436 :                     listOfSurf += *p;
   14508       25436 :                     listOfSurf += " | "; //'<br>' // Separate append to avoid string temporary
   14509             :                 }
   14510        6140 :                 tableBody(1, jUnique) = listOfSurf;
   14511             :             }
   14512             : 
   14513             :             // write the table
   14514        1306 :             if (iKindRec == recKindSurface) {
   14515         653 :                 WriteSubtitle(state, "Surfaces (Walls, Roofs, etc) that may be Shadowed by Other Surfaces");
   14516         653 :                 if (state.dataSQLiteProcedures->sqlite) {
   14517          70 :                     state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
   14518             :                         tableBody,
   14519             :                         rowHead,
   14520             :                         columnHead,
   14521             :                         "SurfaceShadowingSummary",
   14522             :                         "Entire Facility",
   14523             :                         "Surfaces (Walls, Roofs, etc) that may be Shadowed by Other Surfaces");
   14524             :                 }
   14525         653 :                 if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
   14526           4 :                     state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(
   14527             :                         tableBody,
   14528             :                         rowHead,
   14529             :                         columnHead,
   14530             :                         "SurfaceShadowingSummary",
   14531             :                         "Entire Facility",
   14532             :                         "Surfaces (Walls, Roofs, etc) that may be Shadowed by Other Surfaces");
   14533             :                 }
   14534         653 :             } else if (iKindRec == recKindSubsurface) {
   14535         653 :                 WriteSubtitle(state, "Subsurfaces (Windows and Doors) that may be Shadowed by Surfaces");
   14536         653 :                 if (state.dataSQLiteProcedures->sqlite) {
   14537          70 :                     state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
   14538             :                         tableBody,
   14539             :                         rowHead,
   14540             :                         columnHead,
   14541             :                         "SurfaceShadowingSummary",
   14542             :                         "Entire Facility",
   14543             :                         "Subsurfaces (Windows and Doors) that may be Shadowed by Surfaces");
   14544             :                 }
   14545         653 :                 if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
   14546           4 :                     state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(
   14547             :                         tableBody,
   14548             :                         rowHead,
   14549             :                         columnHead,
   14550             :                         "SurfaceShadowingSummary",
   14551             :                         "Entire Facility",
   14552             :                         "Subsurfaces (Windows and Doors) that may be Shadowed by Surfaces");
   14553             :                 }
   14554             :             }
   14555        1306 :             WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
   14556             :         }
   14557             :     }
   14558         731 : }
   14559             : 
   14560             : // Parses the contents of the EIO (initializations) file and creates subtables for each type of record in the tabular output files
   14561             : // Glazer - November 2016
   14562         731 : void WriteEioTables(EnergyPlusData &state)
   14563             : {
   14564             : 
   14565         731 :     auto &ort(state.dataOutRptTab);
   14566             : 
   14567         731 :     if (ort->displayEioSummary) {
   14568             : 
   14569        1308 :         Array1D_string columnHead;
   14570        1308 :         Array1D_int columnWidth;
   14571        1308 :         Array1D_string rowHead;
   14572        1308 :         Array2D_string tableBody; // in the format: (row, column)
   14573        1308 :         Array1D_int colUnitConv;
   14574             : 
   14575             :         // setting up  report header
   14576         654 :         WriteReportHeaders(state, "Initialization Summary", "Entire Facility", OutputProcessor::StoreType::Averaged);
   14577             : 
   14578        1308 :         std::vector<std::string> headerLines; // holds the lines that describe each type of records - each starts with ! symbol
   14579        1308 :         std::vector<std::string> bodyLines;   // holds the data records only
   14580      205290 :         for (auto const &line : state.files.eio.getLines()) {
   14581      204636 :             if (line.at(0) == '!') {
   14582       36711 :                 headerLines.push_back(line);
   14583             :             } else {
   14584      167925 :                 if (line.at(0) == ' ') {
   14585      118384 :                     bodyLines.push_back(line.substr(1)); // remove leading space
   14586             :                 } else {
   14587       49541 :                     bodyLines.push_back(line);
   14588             :                 }
   14589             :             }
   14590             :         }
   14591             : 
   14592        1308 :         for (int iUnitSystem = 0; iUnitSystem <= 1; iUnitSystem++) {
   14593        1308 :             UnitsStyle unitsStyle_cur = ort->unitsStyle;
   14594        1308 :             bool produceTabular = true;
   14595        1308 :             bool produceSQLite = false;
   14596        1308 :             if (produceDualUnitsFlags(iUnitSystem, ort->unitsStyle, ort->unitsStyle_SQLite, unitsStyle_cur, produceTabular, produceSQLite)) break;
   14597             : 
   14598             :             // now go through each header and create a report for each one
   14599       37365 :             for (auto headerLine : headerLines) {
   14600       73422 :                 std::vector<std::string> headerFields = splitCommaString(headerLine);
   14601       73422 :                 std::string tableNameWithSigns = headerFields.at(0);
   14602             :                 std::string tableName =
   14603       73422 :                     tableNameWithSigns.substr(3, tableNameWithSigns.size() - 4); // get rid of the '! <' from the beginning and the '>' from the end
   14604             :                 // first count the number of matching lines
   14605       36711 :                 int countOfMatchingLines = 0;
   14606    10854926 :                 for (auto bodyLine : bodyLines) {
   14607    10818215 :                     if (bodyLine.size() > tableName.size()) {
   14608    21094086 :                         if (bodyLine.substr(0, tableName.size() + 1) ==
   14609    21094086 :                             tableName + ",") { // this needs to match the test used to populate the body of table below
   14610      166394 :                             ++countOfMatchingLines;
   14611             :                         }
   14612             :                     }
   14613             :                 }
   14614       36711 :                 int numRows = countOfMatchingLines;
   14615       36711 :                 int numCols = headerFields.size() - 1;
   14616             : 
   14617       36711 :                 if (numRows >= 1) {
   14618       35349 :                     rowHead.allocate(numRows);
   14619       35349 :                     columnHead.allocate(numCols);
   14620       35349 :                     columnWidth.allocate(numCols);
   14621       35349 :                     columnWidth = 14; // array assignment - same for all columns
   14622       35349 :                     tableBody.allocate(numCols, numRows);
   14623       35349 :                     tableBody = ""; // make sure everything is blank
   14624       70698 :                     std::string footnote = "";
   14625       35349 :                     colUnitConv.allocate(numCols);
   14626             :                     // transfer the header row into column headings
   14627      285646 :                     for (int iCol = 1; iCol <= numCols; ++iCol) {
   14628      250297 :                         columnHead(iCol) = headerFields.at(iCol);
   14629             :                         // set the unit conversions
   14630             :                         // colUnitConv(iCol) = unitsFromHeading(state, columnHead(iCol));
   14631             :                         // Jan 2021: use overloaded version for dual units
   14632      250297 :                         colUnitConv(iCol) = unitsFromHeading(state, columnHead(iCol), unitsStyle_cur);
   14633             :                     }
   14634             :                     // look for data lines
   14635       35349 :                     int rowNum = 0;
   14636    10242243 :                     for (auto bodyLine : bodyLines) {
   14637    10206894 :                         if (bodyLine.size() > tableName.size()) {
   14638    19883686 :                             if (bodyLine.substr(0, tableName.size() + 1) ==
   14639    19883686 :                                 tableName + ",") { // this needs to match the test used in the original counting
   14640      166394 :                                 ++rowNum;
   14641      166394 :                                 if (rowNum > countOfMatchingLines) break; // should never happen since same test as original could
   14642      332788 :                                 std::vector<std::string> dataFields = splitCommaString(bodyLine);
   14643      166394 :                                 rowHead(rowNum) = fmt::to_string(rowNum);
   14644     1775731 :                                 for (int iCol = 1; iCol <= numCols && iCol < int(dataFields.size()); ++iCol) {
   14645     1609337 :                                     if (unitsStyle_cur == UnitsStyle::InchPound || unitsStyle_cur == UnitsStyle::JtoKWH) {
   14646       24156 :                                         if (isNumber(dataFields[iCol]) && colUnitConv(iCol) > 0) { // if it is a number that has a conversion
   14647        5546 :                                             int numDecimalDigits = digitsAferDecimal(dataFields[iCol]);
   14648        5546 :                                             Real64 convertedVal = ConvertIP(state, colUnitConv(iCol), StrToReal(dataFields[iCol]));
   14649        5546 :                                             tableBody(iCol, rowNum) = RealToStr(convertedVal, numDecimalDigits);
   14650       18610 :                                         } else if (iCol == numCols && columnHead(iCol) == "Value" && iCol > 1) { // if it is the last column and the
   14651             :                                                                                                                  // header is Value then treat the
   14652             :                                                                                                                  // previous column as source of units
   14653             :                                             // int indexUnitConv =
   14654             :                                             //    unitsFromHeading(state, tableBody(iCol - 1, rowNum)); // base units on previous column
   14655             :                                             // Jan 2021: use overloaded version for dual units
   14656             :                                             int indexUnitConv =
   14657        1010 :                                                 unitsFromHeading(state, tableBody(iCol - 1, rowNum), unitsStyle_cur); // base units on previous column
   14658             : 
   14659        1010 :                                             int numDecimalDigits = digitsAferDecimal(dataFields[iCol]);
   14660        1010 :                                             Real64 convertedVal = ConvertIP(state, indexUnitConv, StrToReal(dataFields[iCol]));
   14661        1010 :                                             tableBody(iCol, rowNum) = RealToStr(convertedVal, numDecimalDigits);
   14662             :                                         } else {
   14663       17600 :                                             tableBody(iCol, rowNum) = dataFields[iCol];
   14664       24156 :                                         }
   14665             :                                     } else {
   14666     1585181 :                                         tableBody(iCol, rowNum) = dataFields[iCol];
   14667             :                                     }
   14668             :                                 }
   14669             :                             }
   14670             :                         }
   14671             :                     }
   14672             : 
   14673       35349 :                     if (produceTabular) {
   14674       35349 :                         WriteSubtitle(state, tableName);
   14675       35349 :                         WriteTable(state, tableBody, rowHead, columnHead, columnWidth, false, footnote);
   14676       35349 :                         if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
   14677          56 :                             state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(
   14678             :                                 tableBody, rowHead, columnHead, "InitializationSummary", "Entire Facility", tableName);
   14679             :                         }
   14680             :                     }
   14681       35349 :                     if (produceSQLite) {
   14682       35349 :                         if (state.dataSQLiteProcedures->sqlite) {
   14683        3724 :                             state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
   14684             :                                 tableBody, rowHead, columnHead, "InitializationSummary", "Entire Facility", tableName);
   14685             :                         }
   14686             :                     }
   14687             :                 }
   14688             :             }
   14689             :         }
   14690             : 
   14691             :         // as of Oct 2016 only the <Program Control Information:Threads/Parallel Sims> section is written after this point
   14692             :     }
   14693         731 : }
   14694             : 
   14695             : // changes the heading that contains and SI to IP as well as providing the unit conversion index
   14696             : // Glazer Nov 2016
   14697           0 : int unitsFromHeading(EnergyPlusData &state, std::string &heading)
   14698             : {
   14699           0 :     auto &ort(state.dataOutRptTab);
   14700             : 
   14701           0 :     std::string curHeading = "";
   14702           0 :     int unitConv = 0;
   14703           0 :     if (ort->unitsStyle == UnitsStyle::InchPound) {
   14704           0 :         LookupSItoIP(state, heading, unitConv, curHeading);
   14705           0 :     } else if (ort->unitsStyle == UnitsStyle::JtoKWH) {
   14706           0 :         LookupJtokWH(state, heading, unitConv, curHeading);
   14707             :     } else {
   14708           0 :         curHeading = heading;
   14709             :     }
   14710           0 :     heading = curHeading;
   14711           0 :     return (unitConv);
   14712             : }
   14713             : 
   14714             : // Jan 2021: Overloaded this function to accomondate dual units output needs
   14715             : // changes the heading that contains and SI to IP as well as providing the unit conversion index
   14716             : // Glazer Nov 2016
   14717      251307 : int unitsFromHeading(EnergyPlusData &state, std::string &heading, UnitsStyle unitsStyle_para)
   14718             : {
   14719             :     // auto &ort(state.dataOutRptTab);
   14720             : 
   14721      502614 :     std::string curHeading = "";
   14722      251307 :     int unitConv = 0;
   14723      251307 :     if (unitsStyle_para == UnitsStyle::InchPound) {
   14724        4727 :         LookupSItoIP(state, heading, unitConv, curHeading);
   14725      246580 :     } else if (unitsStyle_para == UnitsStyle::JtoKWH) {
   14726        2328 :         LookupJtokWH(state, heading, unitConv, curHeading);
   14727             :     } else {
   14728      244252 :         curHeading = heading;
   14729             :     }
   14730      251307 :     heading = curHeading;
   14731      502614 :     return (unitConv);
   14732             : }
   14733             : 
   14734             : // function that returns a vector of strings when given a string with comma delimitters
   14735             : // Glazer Nov 2016
   14736      203105 : std::vector<std::string> splitCommaString(std::string const &inputString)
   14737             : {
   14738      203105 :     std::vector<std::string> fields;
   14739      406210 :     std::string field;
   14740      406210 :     std::stringstream inputSS(inputString);
   14741     4378675 :     while (std::getline(inputSS, field, ',')) {
   14742     2087785 :         fields.push_back(stripped(field));
   14743             :     }
   14744      406210 :     return fields;
   14745             : }
   14746             : 
   14747         769 : void AddTOCLoadComponentTableSummaries(EnergyPlusData &state)
   14748             : {
   14749             :     // SUBROUTINE INFORMATION:
   14750             :     //       AUTHOR         Jason Glazer
   14751             :     //       DATE WRITTEN   March 2012
   14752             :     //       MODIFIED       na
   14753             :     //       RE-ENGINEERED  na
   14754             : 
   14755             :     // PURPOSE OF THIS SUBROUTINE:
   14756             :     //   Add the table of contents entries for the Zone heat transfer
   14757             :     //   summary report.
   14758             : 
   14759             :     // METHODOLOGY EMPLOYED:
   14760             :     //   Call the AddTOCEntry routine for each zone.
   14761             : 
   14762             :     int iZone;
   14763         769 :     auto &ort(state.dataOutRptTab);
   14764             : 
   14765         769 :     if (state.dataGlobal->CompLoadReportIsReq) {
   14766          23 :         if (ort->displayZoneComponentLoadSummary) {
   14767         161 :             for (iZone = 1; iZone <= state.dataGlobal->NumOfZones; ++iZone) {
   14768         138 :                 if (!state.dataZoneEquip->ZoneEquipConfig(iZone).IsControlled) continue;
   14769         115 :                 AddTOCEntry(state, "Zone Component Load Summary", state.dataHeatBal->Zone(iZone).Name);
   14770             :             }
   14771             :         }
   14772          23 :         if (ort->displayAirLoopComponentLoadSummary) {
   14773           2 :             for (int AirLoopNum = 1; AirLoopNum <= state.dataHVACGlobal->NumPrimaryAirSys; ++AirLoopNum) {
   14774           1 :                 AddTOCEntry(state, "AirLoop Component Load Summary", state.dataSize->FinalSysSizing(AirLoopNum).AirPriLoopName);
   14775             :             }
   14776             :         }
   14777          23 :         if (ort->displayFacilityComponentLoadSummary) {
   14778           1 :             AddTOCEntry(state, "Facility Component Load Summary", "Facility");
   14779             :         }
   14780             :     }
   14781         769 : }
   14782             : 
   14783      161772 : void AllocateLoadComponentArrays(EnergyPlusData &state)
   14784             : {
   14785             :     // SUBROUTINE INFORMATION:
   14786             :     //       AUTHOR         Jason Glazer
   14787             :     //       DATE WRITTEN   April 2012
   14788             :     //       MODIFIED       na
   14789             :     //       RE-ENGINEERED  na
   14790             : 
   14791             :     // PURPOSE OF THIS SUBROUTINE:
   14792             :     //   Allocate the arrays related to the load component report
   14793             : 
   14794             :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
   14795      161772 :     auto &ort(state.dataOutRptTab);
   14796             : 
   14797      161772 :     if (ort->AllocateLoadComponentArraysDoAllocate) {
   14798             :         // For many of the following arrays the last dimension is the number of environments and is same as sizing arrays
   14799          23 :         ort->radiantPulseTimestep.allocate({0, state.dataEnvrn->TotDesDays + state.dataEnvrn->TotRunDesPersDays}, state.dataGlobal->NumOfZones);
   14800          23 :         ort->radiantPulseTimestep = 0;
   14801          23 :         ort->radiantPulseReceived.allocate({0, state.dataEnvrn->TotDesDays + state.dataEnvrn->TotRunDesPersDays}, state.dataSurface->TotSurfaces);
   14802          23 :         ort->radiantPulseReceived = 0.0;
   14803          69 :         ort->loadConvectedNormal.allocate(state.dataEnvrn->TotDesDays + state.dataEnvrn->TotRunDesPersDays,
   14804          23 :                                           {0, state.dataGlobal->NumOfTimeStepInHour * 24},
   14805          92 :                                           state.dataSurface->TotSurfaces);
   14806          23 :         ort->loadConvectedNormal = 0.0;
   14807          69 :         ort->loadConvectedWithPulse.allocate(state.dataEnvrn->TotDesDays + state.dataEnvrn->TotRunDesPersDays,
   14808          23 :                                              {0, state.dataGlobal->NumOfTimeStepInHour * 24},
   14809          92 :                                              state.dataSurface->TotSurfaces);
   14810          23 :         ort->loadConvectedWithPulse = 0.0;
   14811          69 :         ort->netSurfRadSeq.allocate(state.dataEnvrn->TotDesDays + state.dataEnvrn->TotRunDesPersDays,
   14812          23 :                                     state.dataGlobal->NumOfTimeStepInHour * 24,
   14813          92 :                                     state.dataSurface->TotSurfaces);
   14814          23 :         ort->netSurfRadSeq = 0.0;
   14815          23 :         ort->decayCurveCool.allocate(state.dataGlobal->NumOfTimeStepInHour * 24, state.dataSurface->TotSurfaces);
   14816          23 :         ort->decayCurveCool = 0.0;
   14817          23 :         ort->decayCurveHeat.allocate(state.dataGlobal->NumOfTimeStepInHour * 24, state.dataSurface->TotSurfaces);
   14818          23 :         ort->decayCurveHeat = 0.0;
   14819          69 :         ort->ITABSFseq.allocate(state.dataEnvrn->TotDesDays + state.dataEnvrn->TotRunDesPersDays,
   14820          23 :                                 state.dataGlobal->NumOfTimeStepInHour * 24,
   14821          92 :                                 state.dataSurface->TotSurfaces);
   14822          23 :         ort->ITABSFseq = 0.0;
   14823          69 :         ort->TMULTseq.allocate(state.dataEnvrn->TotDesDays + state.dataEnvrn->TotRunDesPersDays,
   14824          23 :                                state.dataGlobal->NumOfTimeStepInHour * 24,
   14825          92 :                                state.dataViewFactor->NumOfRadiantEnclosures);
   14826          23 :         ort->TMULTseq = 0.0;
   14827          69 :         ort->peopleInstantSeq.allocate(state.dataEnvrn->TotDesDays + state.dataEnvrn->TotRunDesPersDays,
   14828          23 :                                        state.dataGlobal->NumOfTimeStepInHour * 24,
   14829          92 :                                        state.dataGlobal->NumOfZones);
   14830          23 :         ort->peopleInstantSeq = 0.0;
   14831          69 :         ort->peopleLatentSeq.allocate(state.dataEnvrn->TotDesDays + state.dataEnvrn->TotRunDesPersDays,
   14832          23 :                                       state.dataGlobal->NumOfTimeStepInHour * 24,
   14833          92 :                                       state.dataGlobal->NumOfZones);
   14834          23 :         ort->peopleLatentSeq = 0.0;
   14835          69 :         ort->peopleRadSeq.allocate(state.dataEnvrn->TotDesDays + state.dataEnvrn->TotRunDesPersDays,
   14836          23 :                                    state.dataGlobal->NumOfTimeStepInHour * 24,
   14837          92 :                                    state.dataGlobal->NumOfZones);
   14838          23 :         ort->peopleRadSeq = 0.0;
   14839          69 :         ort->lightInstantSeq.allocate(state.dataEnvrn->TotDesDays + state.dataEnvrn->TotRunDesPersDays,
   14840          23 :                                       state.dataGlobal->NumOfTimeStepInHour * 24,
   14841          92 :                                       state.dataGlobal->NumOfZones);
   14842          23 :         ort->lightInstantSeq = 0.0;
   14843          69 :         ort->lightRetAirSeq.allocate(state.dataEnvrn->TotDesDays + state.dataEnvrn->TotRunDesPersDays,
   14844          23 :                                      state.dataGlobal->NumOfTimeStepInHour * 24,
   14845          92 :                                      state.dataGlobal->NumOfZones);
   14846          23 :         ort->lightRetAirSeq = 0.0;
   14847          69 :         ort->lightLWRadSeq.allocate(state.dataEnvrn->TotDesDays + state.dataEnvrn->TotRunDesPersDays,
   14848          23 :                                     state.dataGlobal->NumOfTimeStepInHour * 24,
   14849          92 :                                     state.dataGlobal->NumOfZones);
   14850          23 :         ort->lightLWRadSeq = 0.0;
   14851          69 :         ort->lightSWRadSeq.allocate(state.dataEnvrn->TotDesDays + state.dataEnvrn->TotRunDesPersDays,
   14852          23 :                                     state.dataGlobal->NumOfTimeStepInHour * 24,
   14853          92 :                                     state.dataSurface->TotSurfaces);
   14854          23 :         ort->lightSWRadSeq = 0.0;
   14855          69 :         ort->equipInstantSeq.allocate(state.dataEnvrn->TotDesDays + state.dataEnvrn->TotRunDesPersDays,
   14856          23 :                                       state.dataGlobal->NumOfTimeStepInHour * 24,
   14857          92 :                                       state.dataGlobal->NumOfZones);
   14858          23 :         ort->equipInstantSeq = 0.0;
   14859          69 :         ort->equipLatentSeq.allocate(state.dataEnvrn->TotDesDays + state.dataEnvrn->TotRunDesPersDays,
   14860          23 :                                      state.dataGlobal->NumOfTimeStepInHour * 24,
   14861          92 :                                      state.dataGlobal->NumOfZones);
   14862          23 :         ort->equipLatentSeq = 0.0;
   14863          69 :         ort->equipRadSeq.allocate(state.dataEnvrn->TotDesDays + state.dataEnvrn->TotRunDesPersDays,
   14864          23 :                                   state.dataGlobal->NumOfTimeStepInHour * 24,
   14865          92 :                                   state.dataGlobal->NumOfZones);
   14866          23 :         ort->equipRadSeq = 0.0;
   14867          69 :         ort->refrigInstantSeq.allocate(state.dataEnvrn->TotDesDays + state.dataEnvrn->TotRunDesPersDays,
   14868          23 :                                        state.dataGlobal->NumOfTimeStepInHour * 24,
   14869          92 :                                        state.dataGlobal->NumOfZones);
   14870          23 :         ort->refrigInstantSeq = 0.0;
   14871          69 :         ort->refrigRetAirSeq.allocate(state.dataEnvrn->TotDesDays + state.dataEnvrn->TotRunDesPersDays,
   14872          23 :                                       state.dataGlobal->NumOfTimeStepInHour * 24,
   14873          92 :                                       state.dataGlobal->NumOfZones);
   14874          23 :         ort->refrigRetAirSeq = 0.0;
   14875          69 :         ort->refrigLatentSeq.allocate(state.dataEnvrn->TotDesDays + state.dataEnvrn->TotRunDesPersDays,
   14876          23 :                                       state.dataGlobal->NumOfTimeStepInHour * 24,
   14877          92 :                                       state.dataGlobal->NumOfZones);
   14878          23 :         ort->refrigLatentSeq = 0.0;
   14879          69 :         ort->waterUseInstantSeq.allocate(state.dataEnvrn->TotDesDays + state.dataEnvrn->TotRunDesPersDays,
   14880          23 :                                          state.dataGlobal->NumOfTimeStepInHour * 24,
   14881          92 :                                          state.dataGlobal->NumOfZones);
   14882          23 :         ort->waterUseInstantSeq = 0.0;
   14883          69 :         ort->waterUseLatentSeq.allocate(state.dataEnvrn->TotDesDays + state.dataEnvrn->TotRunDesPersDays,
   14884          23 :                                         state.dataGlobal->NumOfTimeStepInHour * 24,
   14885          92 :                                         state.dataGlobal->NumOfZones);
   14886          23 :         ort->waterUseLatentSeq = 0.0;
   14887          69 :         ort->hvacLossInstantSeq.allocate(state.dataEnvrn->TotDesDays + state.dataEnvrn->TotRunDesPersDays,
   14888          23 :                                          state.dataGlobal->NumOfTimeStepInHour * 24,
   14889          92 :                                          state.dataGlobal->NumOfZones);
   14890          23 :         ort->hvacLossInstantSeq = 0.0;
   14891          69 :         ort->hvacLossRadSeq.allocate(state.dataEnvrn->TotDesDays + state.dataEnvrn->TotRunDesPersDays,
   14892          23 :                                      state.dataGlobal->NumOfTimeStepInHour * 24,
   14893          92 :                                      state.dataGlobal->NumOfZones);
   14894          23 :         ort->hvacLossRadSeq = 0.0;
   14895          69 :         ort->powerGenInstantSeq.allocate(state.dataEnvrn->TotDesDays + state.dataEnvrn->TotRunDesPersDays,
   14896          23 :                                          state.dataGlobal->NumOfTimeStepInHour * 24,
   14897          92 :                                          state.dataGlobal->NumOfZones);
   14898          23 :         ort->powerGenInstantSeq = 0.0;
   14899          69 :         ort->powerGenRadSeq.allocate(state.dataEnvrn->TotDesDays + state.dataEnvrn->TotRunDesPersDays,
   14900          23 :                                      state.dataGlobal->NumOfTimeStepInHour * 24,
   14901          92 :                                      state.dataGlobal->NumOfZones);
   14902          23 :         ort->powerGenRadSeq = 0.0;
   14903          69 :         ort->infilInstantSeq.allocate(state.dataEnvrn->TotDesDays + state.dataEnvrn->TotRunDesPersDays,
   14904          23 :                                       state.dataGlobal->NumOfTimeStepInHour * 24,
   14905          92 :                                       state.dataGlobal->NumOfZones);
   14906          23 :         ort->infilInstantSeq = 0.0;
   14907          69 :         ort->infilLatentSeq.allocate(state.dataEnvrn->TotDesDays + state.dataEnvrn->TotRunDesPersDays,
   14908          23 :                                      state.dataGlobal->NumOfTimeStepInHour * 24,
   14909          92 :                                      state.dataGlobal->NumOfZones);
   14910          23 :         ort->infilLatentSeq = 0.0;
   14911          69 :         ort->zoneVentInstantSeq.allocate(state.dataEnvrn->TotDesDays + state.dataEnvrn->TotRunDesPersDays,
   14912          23 :                                          state.dataGlobal->NumOfTimeStepInHour * 24,
   14913          92 :                                          state.dataGlobal->NumOfZones);
   14914          23 :         ort->zoneVentInstantSeq = 0.0;
   14915          69 :         ort->zoneVentLatentSeq.allocate(state.dataEnvrn->TotDesDays + state.dataEnvrn->TotRunDesPersDays,
   14916          23 :                                         state.dataGlobal->NumOfTimeStepInHour * 24,
   14917          92 :                                         state.dataGlobal->NumOfZones);
   14918          23 :         ort->zoneVentLatentSeq = 0.0;
   14919          69 :         ort->interZoneMixInstantSeq.allocate(state.dataEnvrn->TotDesDays + state.dataEnvrn->TotRunDesPersDays,
   14920          23 :                                              state.dataGlobal->NumOfTimeStepInHour * 24,
   14921          92 :                                              state.dataGlobal->NumOfZones);
   14922          23 :         ort->interZoneMixInstantSeq = 0.0;
   14923          69 :         ort->interZoneMixLatentSeq.allocate(state.dataEnvrn->TotDesDays + state.dataEnvrn->TotRunDesPersDays,
   14924          23 :                                             state.dataGlobal->NumOfTimeStepInHour * 24,
   14925          92 :                                             state.dataGlobal->NumOfZones);
   14926          23 :         ort->interZoneMixLatentSeq = 0.0;
   14927          69 :         ort->feneCondInstantSeq.allocate(state.dataEnvrn->TotDesDays + state.dataEnvrn->TotRunDesPersDays,
   14928          23 :                                          state.dataGlobal->NumOfTimeStepInHour * 24,
   14929          92 :                                          state.dataGlobal->NumOfZones);
   14930          23 :         ort->feneCondInstantSeq = 0.0;
   14931          69 :         ort->feneSolarRadSeq.allocate(state.dataEnvrn->TotDesDays + state.dataEnvrn->TotRunDesPersDays,
   14932          23 :                                       state.dataGlobal->NumOfTimeStepInHour * 24,
   14933          92 :                                       state.dataSurface->TotSurfaces);
   14934          23 :         ort->feneSolarRadSeq = 0.0;
   14935          23 :         ort->AllocateLoadComponentArraysDoAllocate = false;
   14936             :     }
   14937      161772 : }
   14938             : 
   14939          23 : void DeallocateLoadComponentArrays(EnergyPlusData &state)
   14940             : {
   14941             :     // SUBROUTINE INFORMATION:
   14942             :     //       AUTHOR         Jason Glazer
   14943             :     //       DATE WRITTEN   August 2012
   14944             :     //       MODIFIED       na
   14945             :     //       RE-ENGINEERED  na
   14946             : 
   14947             :     // PURPOSE OF THIS SUBROUTINE:
   14948             :     //   Deallocate the arrays related to the load component report that will not
   14949             :     //   be needed in the reporting.
   14950             : 
   14951             :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
   14952          23 :     auto &ort(state.dataOutRptTab);
   14953          23 :     ort->radiantPulseTimestep.deallocate();
   14954          23 :     ort->radiantPulseReceived.deallocate();
   14955          23 :     ort->loadConvectedWithPulse.deallocate();
   14956          23 : }
   14957             : 
   14958          23 : void ComputeLoadComponentDecayCurve(EnergyPlusData &state)
   14959             : {
   14960             : 
   14961             :     // SUBROUTINE INFORMATION:
   14962             :     //       AUTHOR         Jason Glazer
   14963             :     //       DATE WRITTEN   August 2012
   14964             :     //       MODIFIED       na
   14965             :     //       RE-ENGINEERED  na
   14966             : 
   14967             :     // PURPOSE OF THIS SUBROUTINE:
   14968             :     // Determines the load component decay curve based on normal and pulse results from zone sizing.
   14969             : 
   14970             :     // METHODOLOGY EMPLOYED:
   14971             :     // Decay curve is the fraction of the heat convected from a surface over the initial radiant heat
   14972             :     // absorbed by the surface.
   14973             : 
   14974             :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
   14975             :     int i;
   14976             :     Real64 diff;
   14977          23 :     auto &ort(state.dataOutRptTab);
   14978          23 :     auto &Zone(state.dataHeatBal->Zone);
   14979             : 
   14980        1188 :     for (state.dataOutRptTab->SurfNumCLCDC = 1; state.dataOutRptTab->SurfNumCLCDC <= state.dataSurface->TotSurfaces;
   14981        1165 :          ++state.dataOutRptTab->SurfNumCLCDC) {
   14982        1165 :         state.dataOutRptTab->ZoneNumCLCDC = state.dataSurface->Surface(state.dataOutRptTab->SurfNumCLCDC).Zone;
   14983        1165 :         if (state.dataOutRptTab->ZoneNumCLCDC == 0) continue;
   14984        1073 :         if (!state.dataZoneEquip->ZoneEquipConfig(state.dataOutRptTab->ZoneNumCLCDC).IsControlled) continue;
   14985         841 :         state.dataOutRptTab->CoolDesSelectedCLCDC = state.dataSize->CalcFinalZoneSizing(state.dataOutRptTab->ZoneNumCLCDC).CoolDDNum;
   14986             :         // loop over timesteps after pulse occurred
   14987         841 :         if (state.dataOutRptTab->CoolDesSelectedCLCDC != 0) {
   14988         841 :             state.dataOutRptTab->TimeOfPulseCLCDC =
   14989         841 :                 ort->radiantPulseTimestep(state.dataOutRptTab->CoolDesSelectedCLCDC, state.dataOutRptTab->ZoneNumCLCDC);
   14990             :             // if the CoolDesSelected time is on a different day than
   14991             :             // when the pulse occurred, need to scan back and find when
   14992             :             // the pulse occurred.
   14993         841 :             if (state.dataOutRptTab->TimeOfPulseCLCDC == 0) {
   14994           0 :                 for (i = state.dataOutRptTab->CoolDesSelectedCLCDC; i >= 1; --i) {
   14995           0 :                     state.dataOutRptTab->TimeOfPulseCLCDC = ort->radiantPulseTimestep(i, state.dataOutRptTab->ZoneNumCLCDC);
   14996           0 :                     if (state.dataOutRptTab->TimeOfPulseCLCDC != 0) break;
   14997             :                 }
   14998             :             }
   14999         841 :             if (state.dataOutRptTab->TimeOfPulseCLCDC == 0) state.dataOutRptTab->TimeOfPulseCLCDC = 1;
   15000       51301 :             for (state.dataOutRptTab->TimeStepCLCDC = state.dataOutRptTab->TimeOfPulseCLCDC;
   15001       51301 :                  state.dataOutRptTab->TimeStepCLCDC <= state.dataGlobal->NumOfTimeStepInHour * 24;
   15002       50460 :                  ++state.dataOutRptTab->TimeStepCLCDC) {
   15003       50460 :                 if (ort->radiantPulseReceived(state.dataOutRptTab->CoolDesSelectedCLCDC, state.dataOutRptTab->SurfNumCLCDC) != 0.0) {
   15004      148860 :                     diff = ort->loadConvectedWithPulse(
   15005       49620 :                                state.dataOutRptTab->CoolDesSelectedCLCDC, state.dataOutRptTab->TimeStepCLCDC, state.dataOutRptTab->SurfNumCLCDC) -
   15006       99240 :                            ort->loadConvectedNormal(
   15007       49620 :                                state.dataOutRptTab->CoolDesSelectedCLCDC, state.dataOutRptTab->TimeStepCLCDC, state.dataOutRptTab->SurfNumCLCDC);
   15008       99240 :                     ort->decayCurveCool(state.dataOutRptTab->TimeStepCLCDC - state.dataOutRptTab->TimeOfPulseCLCDC + 1,
   15009       99240 :                                         state.dataOutRptTab->SurfNumCLCDC) =
   15010       49620 :                         -diff / ort->radiantPulseReceived(state.dataOutRptTab->CoolDesSelectedCLCDC, state.dataOutRptTab->SurfNumCLCDC);
   15011             :                 } else {
   15012        1680 :                     ort->decayCurveCool(state.dataOutRptTab->TimeStepCLCDC - state.dataOutRptTab->TimeOfPulseCLCDC + 1,
   15013        1680 :                                         state.dataOutRptTab->SurfNumCLCDC) = 0.0;
   15014             :                 }
   15015             :             }
   15016             :         }
   15017         841 :         state.dataOutRptTab->HeatDesSelectedCLCDC = state.dataSize->CalcFinalZoneSizing(state.dataOutRptTab->ZoneNumCLCDC).HeatDDNum;
   15018         841 :         if (state.dataOutRptTab->HeatDesSelectedCLCDC != 0) {
   15019         841 :             state.dataOutRptTab->TimeOfPulseCLCDC =
   15020         841 :                 ort->radiantPulseTimestep(state.dataOutRptTab->HeatDesSelectedCLCDC, state.dataOutRptTab->ZoneNumCLCDC);
   15021             :             // scan back to the day that the heating pulse occurs, if necessary
   15022         841 :             if (state.dataOutRptTab->TimeOfPulseCLCDC == 0) {
   15023           0 :                 for (i = state.dataOutRptTab->HeatDesSelectedCLCDC; i >= 1; --i) {
   15024           0 :                     state.dataOutRptTab->TimeOfPulseCLCDC = ort->radiantPulseTimestep(i, state.dataOutRptTab->ZoneNumCLCDC);
   15025           0 :                     if (state.dataOutRptTab->TimeOfPulseCLCDC != 0) break;
   15026             :                 }
   15027             :             }
   15028         841 :             if (state.dataOutRptTab->TimeOfPulseCLCDC == 0) state.dataOutRptTab->TimeOfPulseCLCDC = 1;
   15029       51301 :             for (state.dataOutRptTab->TimeStepCLCDC = state.dataOutRptTab->TimeOfPulseCLCDC;
   15030       51301 :                  state.dataOutRptTab->TimeStepCLCDC <= state.dataGlobal->NumOfTimeStepInHour * 24;
   15031       50460 :                  ++state.dataOutRptTab->TimeStepCLCDC) {
   15032       50460 :                 if (ort->radiantPulseReceived(state.dataOutRptTab->HeatDesSelectedCLCDC, state.dataOutRptTab->SurfNumCLCDC) != 0.0) {
   15033      148860 :                     diff = ort->loadConvectedWithPulse(
   15034       49620 :                                state.dataOutRptTab->HeatDesSelectedCLCDC, state.dataOutRptTab->TimeStepCLCDC, state.dataOutRptTab->SurfNumCLCDC) -
   15035       99240 :                            ort->loadConvectedNormal(
   15036       49620 :                                state.dataOutRptTab->HeatDesSelectedCLCDC, state.dataOutRptTab->TimeStepCLCDC, state.dataOutRptTab->SurfNumCLCDC);
   15037       99240 :                     ort->decayCurveHeat(state.dataOutRptTab->TimeStepCLCDC - state.dataOutRptTab->TimeOfPulseCLCDC + 1,
   15038       99240 :                                         state.dataOutRptTab->SurfNumCLCDC) =
   15039       49620 :                         -diff / ort->radiantPulseReceived(state.dataOutRptTab->HeatDesSelectedCLCDC, state.dataOutRptTab->SurfNumCLCDC);
   15040             :                 } else {
   15041        1680 :                     ort->decayCurveHeat(state.dataOutRptTab->TimeStepCLCDC - state.dataOutRptTab->TimeOfPulseCLCDC + 1,
   15042        1680 :                                         state.dataOutRptTab->SurfNumCLCDC) = 0.0;
   15043             :                 }
   15044             :             }
   15045             :         }
   15046             :     }
   15047             : 
   15048          23 :     if (state.dataGlobal->ShowDecayCurvesInEIO) {
   15049             :         // show the line definition for the decay curves
   15050           5 :         print(state.files.eio,
   15051             :               "! <Radiant to Convective Decay Curves for Cooling>,Zone Name, Surface Name, Time "
   15052           5 :               "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");
   15053           5 :         print(state.files.eio,
   15054             :               "! <Radiant to Convective Decay Curves for Heating>,Zone Name, Surface Name, Time "
   15055           5 :               "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");
   15056             :         // Put the decay curve into the EIO file
   15057          35 :         for (int iZone = 1; iZone <= state.dataGlobal->NumOfZones; ++iZone) {
   15058        1620 :             for (int kSurf : state.dataSurface->AllSurfaceListReportOrder) {
   15059        1590 :                 if (state.dataSurface->Surface(kSurf).Zone != iZone) continue;
   15060         735 :                 print(state.files.eio,
   15061             :                       "{},{},{}",
   15062             :                       "Radiant to Convective Decay Curves for Cooling",
   15063         245 :                       Zone(iZone).Name,
   15064         490 :                       state.dataSurface->Surface(kSurf).Name);
   15065        9065 :                 for (int jTime = 1; jTime <= min(state.dataGlobal->NumOfTimeStepInHour * 24, 36); ++jTime) {
   15066        8820 :                     print(state.files.eio, ",{:6.3F}", ort->decayCurveCool(jTime, kSurf));
   15067             :                 }
   15068             :                 // put a line feed at the end of the line
   15069         245 :                 print(state.files.eio, "\n");
   15070             :             }
   15071             : 
   15072        1620 :             for (int kSurf : state.dataSurface->AllSurfaceListReportOrder) {
   15073        1590 :                 if (state.dataSurface->Surface(kSurf).Zone != iZone) continue;
   15074         735 :                 print(state.files.eio,
   15075             :                       "{},{},{}",
   15076             :                       "Radiant to Convective Decay Curves for Heating",
   15077         245 :                       Zone(iZone).Name,
   15078         490 :                       state.dataSurface->Surface(kSurf).Name);
   15079        9065 :                 for (int jTime = 1; jTime <= min(state.dataGlobal->NumOfTimeStepInHour * 24, 36); ++jTime) {
   15080        8820 :                     print(state.files.eio, ",{:6.3F}", ort->decayCurveHeat(jTime, kSurf));
   15081             :                 }
   15082             :                 // put a line feed at the end of the line
   15083         245 :                 print(state.files.eio, "\n");
   15084             :             }
   15085             :         }
   15086             :     }
   15087          23 : }
   15088             : 
   15089      783283 : void GatherComponentLoadsSurface(EnergyPlusData &state)
   15090             : {
   15091             :     // SUBROUTINE INFORMATION:
   15092             :     //       AUTHOR         Jason Glazer
   15093             :     //       DATE WRITTEN   September 2012
   15094             :     //       MODIFIED       na
   15095             :     //       RE-ENGINEERED  na
   15096             : 
   15097             :     // PURPOSE OF THIS SUBROUTINE:
   15098             :     //   Gather values during sizing used for loads component report.
   15099             : 
   15100             :     // METHODOLOGY EMPLOYED:
   15101             :     //   Save sequence of values for report during sizing.
   15102             : 
   15103             :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
   15104      783283 :     auto &ort(state.dataOutRptTab);
   15105             : 
   15106      783283 :     if (state.dataGlobal->CompLoadReportIsReq && !state.dataGlobal->isPulseZoneSizing) {
   15107       31050 :         state.dataOutRptTab->TimeStepInDayGCLS =
   15108       31050 :             (state.dataGlobal->HourOfDay - 1) * state.dataGlobal->NumOfTimeStepInHour + state.dataGlobal->TimeStep;
   15109       31050 :         ort->feneCondInstantSeq(state.dataSize->CurOverallSimDay, state.dataOutRptTab->TimeStepInDayGCLS, _) = 0.0;
   15110     1603800 :         for (state.dataOutRptTab->iSurfGCLS = 1; state.dataOutRptTab->iSurfGCLS <= state.dataSurface->TotSurfaces; ++state.dataOutRptTab->iSurfGCLS) {
   15111     1572750 :             state.dataOutRptTab->ZoneNumGCLS = state.dataSurface->Surface(state.dataOutRptTab->iSurfGCLS).Zone;
   15112     1572750 :             if (state.dataOutRptTab->ZoneNumGCLS == 0) continue;
   15113     1448550 :             if (state.dataSurface->Surface(state.dataOutRptTab->iSurfGCLS).Class != DataSurfaces::SurfaceClass::Window) continue;
   15114             :             // IF (.not. ZoneEquipConfig(ZoneNum)%IsControlled) CYCLE
   15115      186300 :             ort->feneCondInstantSeq(state.dataSize->CurOverallSimDay, state.dataOutRptTab->TimeStepInDayGCLS, state.dataOutRptTab->ZoneNumGCLS) +=
   15116      372600 :                 state.dataSurface->SurfWinGainConvGlazToZoneRep(state.dataOutRptTab->iSurfGCLS) +
   15117      372600 :                 state.dataSurface->SurfWinConvHeatFlowNatural(state.dataOutRptTab->iSurfGCLS) +
   15118      372600 :                 state.dataSurface->SurfWinGainConvShadeToZoneRep(state.dataOutRptTab->iSurfGCLS) +
   15119      186300 :                 state.dataSurface->SurfWinGainFrameDividerToZoneRep(state.dataOutRptTab->iSurfGCLS);
   15120             :             // for now assume zero instant solar - may change related
   15121             :             // to how blinds and shades absorb solar radiation and
   15122             :             // convect that heat that timestep.
   15123             :             // feneSolarInstantSeq(ZoneNum,TimeStepInDay,CurOverallSimDay) = 0
   15124             :         }
   15125      217350 :         for (int izone = 1; izone <= state.dataGlobal->NumOfZones; ++izone) {
   15126      186300 :             Real64 tubularGain = 0.0;
   15127      186300 :             tubularGain = InternalHeatGains::SumInternalConvectionGainsByTypes(state, izone, OutputReportTabular::IntGainTypesTubularGCLS);
   15128      186300 :             ort->feneCondInstantSeq(state.dataSize->CurOverallSimDay, state.dataOutRptTab->TimeStepInDayGCLS, izone) += tubularGain;
   15129             :         }
   15130             :     }
   15131      783283 : }
   15132             : 
   15133       10136 : void GatherComponentLoadsHVAC(EnergyPlusData &state)
   15134             : {
   15135             :     // SUBROUTINE INFORMATION:
   15136             :     //       AUTHOR         Jason Glazer
   15137             :     //       DATE WRITTEN   September 2012
   15138             :     //       MODIFIED       na
   15139             :     //       RE-ENGINEERED  na
   15140             : 
   15141             :     // PURPOSE OF THIS SUBROUTINE:
   15142             :     //   Gather values during sizing used for loads component report.
   15143             : 
   15144             :     // METHODOLOGY EMPLOYED:
   15145             :     //   Save sequence of values for report during sizing.
   15146             : 
   15147             :     // Using/Aliasing
   15148       10136 :     auto &TimeStepSys = state.dataHVACGlobal->TimeStepSys;
   15149             : 
   15150             :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
   15151       10136 :     auto &ort(state.dataOutRptTab);
   15152             : 
   15153       10136 :     if (state.dataGlobal->CompLoadReportIsReq && !state.dataGlobal->isPulseZoneSizing) {
   15154        5068 :         state.dataOutRptTab->TimeStepInDayGCLH =
   15155        5068 :             (state.dataGlobal->HourOfDay - 1) * state.dataGlobal->NumOfTimeStepInHour + state.dataGlobal->TimeStep;
   15156       35476 :         for (state.dataOutRptTab->iZoneGCLH = 1; state.dataOutRptTab->iZoneGCLH <= state.dataGlobal->NumOfZones; ++state.dataOutRptTab->iZoneGCLH) {
   15157       30408 :             ort->infilInstantSeq(state.dataSize->CurOverallSimDay, state.dataOutRptTab->TimeStepInDayGCLH, state.dataOutRptTab->iZoneGCLH) =
   15158       60816 :                 ((state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGCLH).InfilHeatGain -
   15159       60816 :                   state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGCLH).InfilHeatLoss) /
   15160       30408 :                  (TimeStepSys * DataGlobalConstants::SecInHour)); // zone infiltration
   15161       30408 :             if (state.afn->simulation_control.type != AirflowNetwork::ControlType::NoMultizoneOrDistribution) {
   15162           0 :                 ort->infilInstantSeq(state.dataSize->CurOverallSimDay, state.dataOutRptTab->TimeStepInDayGCLH, state.dataOutRptTab->iZoneGCLH) +=
   15163           0 :                     (state.afn->AirflowNetworkReportData(state.dataOutRptTab->iZoneGCLH).MultiZoneInfiSenGainW -
   15164           0 :                      state.afn->AirflowNetworkReportData(state.dataOutRptTab->iZoneGCLH).MultiZoneInfiSenLossW); // air flow network
   15165             :             }
   15166       30408 :             ort->infilLatentSeq(state.dataSize->CurOverallSimDay, state.dataOutRptTab->TimeStepInDayGCLH, state.dataOutRptTab->iZoneGCLH) =
   15167       60816 :                 ((state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGCLH).InfilLatentGain -
   15168       60816 :                   state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGCLH).InfilLatentLoss) /
   15169       30408 :                  (TimeStepSys * DataGlobalConstants::SecInHour)); // zone infiltration
   15170       30408 :             if (state.afn->simulation_control.type != AirflowNetwork::ControlType::NoMultizoneOrDistribution) {
   15171           0 :                 ort->infilLatentSeq(state.dataSize->CurOverallSimDay, state.dataOutRptTab->TimeStepInDayGCLH, state.dataOutRptTab->iZoneGCLH) +=
   15172           0 :                     (state.afn->AirflowNetworkReportData(state.dataOutRptTab->iZoneGCLH).MultiZoneInfiLatGainW -
   15173           0 :                      state.afn->AirflowNetworkReportData(state.dataOutRptTab->iZoneGCLH).MultiZoneInfiLatLossW); // air flow network
   15174             :             }
   15175             : 
   15176       30408 :             ort->zoneVentInstantSeq(state.dataSize->CurOverallSimDay, state.dataOutRptTab->TimeStepInDayGCLH, state.dataOutRptTab->iZoneGCLH) =
   15177       60816 :                 ((state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGCLH).VentilHeatGain -
   15178       60816 :                   state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGCLH).VentilHeatLoss) /
   15179       30408 :                  (TimeStepSys * DataGlobalConstants::SecInHour)); // zone ventilation
   15180       30408 :             if (state.afn->simulation_control.type != AirflowNetwork::ControlType::NoMultizoneOrDistribution) {
   15181           0 :                 ort->zoneVentInstantSeq(state.dataSize->CurOverallSimDay, state.dataOutRptTab->TimeStepInDayGCLH, state.dataOutRptTab->iZoneGCLH) +=
   15182           0 :                     (state.afn->AirflowNetworkReportData(state.dataOutRptTab->iZoneGCLH).MultiZoneVentSenGainW -
   15183           0 :                      state.afn->AirflowNetworkReportData(state.dataOutRptTab->iZoneGCLH).MultiZoneVentSenLossW); // air flow network
   15184             :             }
   15185       30408 :             ort->zoneVentLatentSeq(state.dataSize->CurOverallSimDay, state.dataOutRptTab->TimeStepInDayGCLH, state.dataOutRptTab->iZoneGCLH) =
   15186       60816 :                 ((state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGCLH).VentilLatentGain -
   15187       60816 :                   state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGCLH).VentilLatentLoss) /
   15188       30408 :                  (TimeStepSys * DataGlobalConstants::SecInHour)); // zone ventilation
   15189       30408 :             if (state.afn->simulation_control.type != AirflowNetwork::ControlType::NoMultizoneOrDistribution) {
   15190           0 :                 ort->zoneVentInstantSeq(state.dataSize->CurOverallSimDay, state.dataOutRptTab->TimeStepInDayGCLH, state.dataOutRptTab->iZoneGCLH) +=
   15191           0 :                     (state.afn->AirflowNetworkReportData(state.dataOutRptTab->iZoneGCLH).MultiZoneVentLatGainW -
   15192           0 :                      state.afn->AirflowNetworkReportData(state.dataOutRptTab->iZoneGCLH).MultiZoneVentLatLossW); // air flow network
   15193             :             }
   15194             : 
   15195       30408 :             ort->interZoneMixInstantSeq(state.dataSize->CurOverallSimDay, state.dataOutRptTab->TimeStepInDayGCLH, state.dataOutRptTab->iZoneGCLH) =
   15196       60816 :                 ((state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGCLH).MixHeatGain -
   15197       60816 :                   state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGCLH).MixHeatLoss) /
   15198       30408 :                  (TimeStepSys * DataGlobalConstants::SecInHour)); // zone mixing
   15199       30408 :             if (state.afn->simulation_control.type != AirflowNetwork::ControlType::NoMultizoneOrDistribution) {
   15200           0 :                 ort->interZoneMixInstantSeq(
   15201           0 :                     state.dataSize->CurOverallSimDay, state.dataOutRptTab->TimeStepInDayGCLH, state.dataOutRptTab->iZoneGCLH) +=
   15202           0 :                     (state.afn->AirflowNetworkReportData(state.dataOutRptTab->iZoneGCLH).MultiZoneMixSenGainW -
   15203           0 :                      state.afn->AirflowNetworkReportData(state.dataOutRptTab->iZoneGCLH).MultiZoneMixSenLossW); // air flow network
   15204             :             }
   15205       30408 :             ort->interZoneMixLatentSeq(state.dataSize->CurOverallSimDay, state.dataOutRptTab->TimeStepInDayGCLH, state.dataOutRptTab->iZoneGCLH) =
   15206       60816 :                 ((state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGCLH).MixLatentGain -
   15207       60816 :                   state.dataHeatBal->ZnAirRpt(state.dataOutRptTab->iZoneGCLH).MixLatentLoss) /
   15208       30408 :                  (TimeStepSys * DataGlobalConstants::SecInHour)); // zone mixing
   15209       30408 :             if (state.afn->simulation_control.type != AirflowNetwork::ControlType::NoMultizoneOrDistribution) {
   15210           0 :                 ort->interZoneMixLatentSeq(
   15211           0 :                     state.dataSize->CurOverallSimDay, state.dataOutRptTab->TimeStepInDayGCLH, state.dataOutRptTab->iZoneGCLH) +=
   15212           0 :                     (state.afn->AirflowNetworkReportData(state.dataOutRptTab->iZoneGCLH).MultiZoneMixLatGainW -
   15213           0 :                      state.afn->AirflowNetworkReportData(state.dataOutRptTab->iZoneGCLH).MultiZoneMixLatLossW); // air flow network
   15214             :             }
   15215             :         }
   15216             :     }
   15217       10136 : }
   15218             : 
   15219         731 : void WriteLoadComponentSummaryTables(EnergyPlusData &state)
   15220             : {
   15221             :     // SUBROUTINE INFORMATION:
   15222             :     //       AUTHOR         Jason Glazer
   15223             :     //       DATE WRITTEN   March 2012
   15224             :     //       MODIFIED       na
   15225             :     //       RE-ENGINEERED  Amir Roth, Feb 2016 (unified with ComputeDelayedComponents to simplify code and debugging)
   15226             : 
   15227             :     // PURPOSE OF THIS SUBROUTINE:
   15228             :     //   Write the tables for the ZoneLoadComponentSummary and
   15229             :     //   ZoneLoadComponentDetail reports which summarize the major
   15230             :     //   load components for each zone in the building.
   15231             : 
   15232             :     // METHODOLOGY EMPLOYED:
   15233             :     //   Create arrays for the call to WriteTable and then call it.
   15234             :     //   This report actually consists of many sub-tables each with
   15235             :     //   its own call to WriteTable.
   15236             :     // The overall methodology is explained below:
   15237             :     //
   15238             :     // Determine decay curve - Pulse of radiant heat which is about 5% of lighting and
   15239             :     //   equipment input for a single timestep a few hours after
   15240             :     //   cooling or heat is scheduled on for each zone [radiantPulseTimestep(iZone)].
   15241             :     //   The radiant heat received on each wall is stored [radiantPulseReceived(jSurface)].
   15242             :     //   The load convected in the normal case [loadConvectedNormal(jSurface, kTime, mode)]
   15243             :     //   and in the case with the pulse [loadConvectedWithPulse(jSurface, kTime, mode)].
   15244             :     //   The difference divided by the pulse received by each surface
   15245             :     //   [radiantPulseReceived(jSurface)] is stored in [decayCurve(jSurface,kTime,mode)].
   15246             :     //
   15247             :     // Determine delayed loads - From the last timestep of the peak load on the zone
   15248             :     //   working backwards any radiant heat that was absorbed by the wall from an internal gain
   15249             :     //   or solar gain is multiplied by the appropriate timesteps in the decay curve
   15250             :     //   [decayCurve(jSurface,kTime,mode)] for timesteps that make up
   15251             :     //   the number of averaged timesteps are used to determine the peak load
   15252             :     //   [NumTimeStepsInAvg]. The sum for all surfaces in the zone are added together to
   15253             :     //   determine the delayed load.
   15254             :     //
   15255             :     // Determine instant loads - Average the convective portion of the internal gains
   15256             :     //   for the timesteps made up of the peak load period. Average those across the peak
   15257             :     //   load period.
   15258             :     //
   15259             :     // The comments from ComputeDelayedComponents which was incorporated into this routine follow:
   15260             :     //
   15261             :     // PURPOSE OF THIS SUBROUTINE:
   15262             :     //   For load component report, convert the sequence of radiant gains
   15263             :     //   for people and equipment and other internal loads into convective
   15264             :     //   gains based on the decay curves.
   15265             :     //
   15266             :     // METHODOLOGY EMPLOYED:
   15267             :     //   For each step of sequence from each design day, compute the
   15268             :     //   contributions from previous timesteps multiplied by the decay
   15269             :     //   curve. Rather than store every internal load's radiant contribution
   15270             :     //   to each surface, the EnclRadThermAbsMult and ITABSF sequences were also stored
   15271             :     //   which allocates the total radiant to each surface in the zone. The
   15272             :     //   formula used is:
   15273             :     //       SurfQRadThermInAbs(SurfNum) = QL(NZ) * EnclRadThermAbsMult(NZ) * SurfAbsThermalInt(SurfNum)
   15274             : 
   15275         731 :     auto &NumPrimaryAirSys = state.dataHVACGlobal->NumPrimaryAirSys;
   15276             : 
   15277         731 :     auto &SysSizPeakDDNum(state.dataSize->SysSizPeakDDNum);
   15278         731 :     auto &FinalSysSizing(state.dataSize->FinalSysSizing);
   15279         731 :     auto &ort(state.dataOutRptTab);
   15280         731 :     auto &Zone(state.dataHeatBal->Zone);
   15281         731 :     auto &CalcFinalFacilitySizing(state.dataSize->CalcFinalFacilitySizing);
   15282             : 
   15283         754 :     if (!((ort->displayZoneComponentLoadSummary || ort->displayAirLoopComponentLoadSummary || ort->displayFacilityComponentLoadSummary) &&
   15284          23 :           state.dataGlobal->CompLoadReportIsReq))
   15285         708 :         return;
   15286             : 
   15287             :     int coolDesSelected;
   15288             :     int timeCoolMax;
   15289             :     int heatDesSelected;
   15290             :     int timeHeatMax;
   15291             :     Real64 mult; // zone multiplier
   15292             : 
   15293             :     // Delayed components are moved into this function so that we can calculate them one zone at a time
   15294             :     // with Array1D
   15295          46 :     Array1D<Real64> peopleDelaySeqHeat;
   15296          46 :     Array1D<Real64> peopleDelaySeqCool;
   15297          46 :     Array1D<Real64> lightDelaySeqHeat;
   15298          46 :     Array1D<Real64> lightDelaySeqCool;
   15299          46 :     Array1D<Real64> equipDelaySeqHeat;
   15300          46 :     Array1D<Real64> equipDelaySeqCool;
   15301          46 :     Array1D<Real64> hvacLossDelaySeqHeat;
   15302          46 :     Array1D<Real64> hvacLossDelaySeqCool;
   15303          46 :     Array1D<Real64> powerGenDelaySeqHeat;
   15304          46 :     Array1D<Real64> powerGenDelaySeqCool;
   15305          46 :     Array1D<Real64> feneSolarDelaySeqHeat;
   15306          46 :     Array1D<Real64> feneSolarDelaySeqCool;
   15307          46 :     Array2D<Real64> surfDelaySeqHeat;
   15308          46 :     Array2D<Real64> surfDelaySeqCool;
   15309             : 
   15310          46 :     Array1D<CompLoadTablesType> ZoneHeatCompLoadTables; // for zone level component load summary output tables
   15311          46 :     Array1D<CompLoadTablesType> ZoneCoolCompLoadTables;
   15312             : 
   15313          46 :     Array1D<CompLoadTablesType> AirLoopHeatCompLoadTables; // for airloop level component load summary output tables
   15314          46 :     Array1D<CompLoadTablesType> AirLoopCoolCompLoadTables;
   15315          46 :     Array1D<CompLoadTablesType> AirLoopZonesHeatCompLoadTables; // zone results used for airloop report - never directly output
   15316          46 :     Array1D<CompLoadTablesType> AirLoopZonesCoolCompLoadTables;
   15317             : 
   15318          46 :     CompLoadTablesType FacilityHeatCompLoadTables; // for facility level component load summary output tables
   15319          46 :     CompLoadTablesType FacilityCoolCompLoadTables;
   15320          46 :     Array1D<CompLoadTablesType> FacilityZonesHeatCompLoadTables; // zone results used for facility report - never directly output
   15321          46 :     Array1D<CompLoadTablesType> FacilityZonesCoolCompLoadTables;
   15322             : 
   15323             :     // Jan 2021: The following variable is redudant in the original code, deleting the line
   15324             :     // CompLoadTablesType curCompLoadTable; // active component load table
   15325             : 
   15326          46 :     for (int iUnitSystem = 0; iUnitSystem <= 1; iUnitSystem++) {
   15327          46 :         UnitsStyle unitsStyle_cur = ort->unitsStyle;
   15328          46 :         bool produceTabular = true;
   15329          46 :         bool produceSQLite = false;
   15330          46 :         if (produceDualUnitsFlags(iUnitSystem, ort->unitsStyle, ort->unitsStyle_SQLite, unitsStyle_cur, produceTabular, produceSQLite)) break;
   15331             : 
   15332             :         // adjusted initilization location to after variable declaration for loops 2021-01-11
   15333          23 :         peopleDelaySeqHeat.dimension(state.dataGlobal->NumOfTimeStepInHour * 24, 0.0);
   15334          23 :         peopleDelaySeqHeat = 0.0;
   15335          23 :         peopleDelaySeqCool.allocate(state.dataGlobal->NumOfTimeStepInHour * 24);
   15336          23 :         peopleDelaySeqCool = 0.0;
   15337          23 :         lightDelaySeqHeat.allocate(state.dataGlobal->NumOfTimeStepInHour * 24);
   15338          23 :         lightDelaySeqHeat = 0.0;
   15339          23 :         lightDelaySeqCool.allocate(state.dataGlobal->NumOfTimeStepInHour * 24);
   15340          23 :         lightDelaySeqCool = 0.0;
   15341          23 :         equipDelaySeqHeat.allocate(state.dataGlobal->NumOfTimeStepInHour * 24);
   15342          23 :         equipDelaySeqHeat = 0.0;
   15343          23 :         equipDelaySeqCool.allocate(state.dataGlobal->NumOfTimeStepInHour * 24);
   15344          23 :         equipDelaySeqCool = 0.0;
   15345          23 :         hvacLossDelaySeqHeat.allocate(state.dataGlobal->NumOfTimeStepInHour * 24);
   15346          23 :         hvacLossDelaySeqHeat = 0.0;
   15347          23 :         hvacLossDelaySeqCool.allocate(state.dataGlobal->NumOfTimeStepInHour * 24);
   15348          23 :         hvacLossDelaySeqCool = 0.0;
   15349          23 :         powerGenDelaySeqHeat.allocate(state.dataGlobal->NumOfTimeStepInHour * 24);
   15350          23 :         powerGenDelaySeqHeat = 0.0;
   15351          23 :         powerGenDelaySeqCool.allocate(state.dataGlobal->NumOfTimeStepInHour * 24);
   15352          23 :         powerGenDelaySeqCool = 0.0;
   15353          23 :         feneSolarDelaySeqHeat.allocate(state.dataGlobal->NumOfTimeStepInHour * 24);
   15354          23 :         feneSolarDelaySeqHeat = 0.0;
   15355          23 :         feneSolarDelaySeqCool.allocate(state.dataGlobal->NumOfTimeStepInHour * 24);
   15356          23 :         feneSolarDelaySeqCool = 0.0;
   15357          23 :         surfDelaySeqHeat.allocate(state.dataGlobal->NumOfTimeStepInHour * 24, state.dataSurface->TotSurfaces);
   15358          23 :         surfDelaySeqHeat = 0.0;
   15359          23 :         surfDelaySeqCool.allocate(state.dataGlobal->NumOfTimeStepInHour * 24, state.dataSurface->TotSurfaces);
   15360          23 :         surfDelaySeqCool = 0.0;
   15361             : 
   15362             :         // initialize arrays
   15363          23 :         if (ort->displayZoneComponentLoadSummary) {
   15364          23 :             ZoneHeatCompLoadTables.allocate(state.dataGlobal->NumOfZones);
   15365         161 :             for (auto &e : ZoneHeatCompLoadTables) {
   15366         138 :                 e.cells.allocate(LoadCompCol::PerArea, LoadCompRow::GrdTot);
   15367         138 :                 e.cells = 0.;
   15368         138 :                 e.cellUsed.allocate(LoadCompCol::PerArea, LoadCompRow::GrdTot);
   15369         138 :                 e.cellUsed = false;
   15370             :             }
   15371          23 :             ZoneCoolCompLoadTables.allocate(state.dataGlobal->NumOfZones);
   15372         161 :             for (auto &e : ZoneCoolCompLoadTables) {
   15373         138 :                 e.cells.allocate(LoadCompCol::PerArea, LoadCompRow::GrdTot);
   15374         138 :                 e.cells = 0.;
   15375         138 :                 e.cellUsed.allocate(LoadCompCol::PerArea, LoadCompRow::GrdTot);
   15376         138 :                 e.cellUsed = false;
   15377             :             }
   15378             :         }
   15379          23 :         if (ort->displayAirLoopComponentLoadSummary) {
   15380           1 :             AirLoopHeatCompLoadTables.allocate(NumPrimaryAirSys);
   15381           2 :             for (auto &e : AirLoopHeatCompLoadTables) {
   15382           1 :                 e.cells.allocate(LoadCompCol::PerArea, LoadCompRow::GrdTot);
   15383           1 :                 e.cells = 0.;
   15384           1 :                 e.cellUsed.allocate(LoadCompCol::PerArea, LoadCompRow::GrdTot);
   15385           1 :                 e.cellUsed = false;
   15386           1 :                 e.zoneIndices.allocate(state.dataGlobal->NumOfZones); // only need to allocate this for the AirLoop
   15387           1 :                 e.zoneIndices = 0;
   15388             :             }
   15389           1 :             AirLoopCoolCompLoadTables.allocate(NumPrimaryAirSys);
   15390           2 :             for (auto &e : AirLoopCoolCompLoadTables) {
   15391           1 :                 e.cells.allocate(LoadCompCol::PerArea, LoadCompRow::GrdTot);
   15392           1 :                 e.cells = 0.;
   15393           1 :                 e.cellUsed.allocate(LoadCompCol::PerArea, LoadCompRow::GrdTot);
   15394           1 :                 e.cellUsed = false;
   15395           1 :                 e.zoneIndices.allocate(state.dataGlobal->NumOfZones); // only need to allocate this for the AirLoop
   15396           1 :                 e.zoneIndices = 0;
   15397             :             }
   15398           1 :             AirLoopZonesHeatCompLoadTables.allocate(state.dataGlobal->NumOfZones);
   15399           7 :             for (auto &e : AirLoopZonesHeatCompLoadTables) {
   15400           6 :                 e.cells.allocate(LoadCompCol::PerArea, LoadCompRow::GrdTot);
   15401           6 :                 e.cells = 0.;
   15402           6 :                 e.cellUsed.allocate(LoadCompCol::PerArea, LoadCompRow::GrdTot);
   15403           6 :                 e.cellUsed = false;
   15404             :             }
   15405           1 :             AirLoopZonesCoolCompLoadTables.allocate(state.dataGlobal->NumOfZones);
   15406           7 :             for (auto &e : AirLoopZonesCoolCompLoadTables) {
   15407           6 :                 e.cells.allocate(LoadCompCol::PerArea, LoadCompRow::GrdTot);
   15408           6 :                 e.cells = 0.;
   15409           6 :                 e.cellUsed.allocate(LoadCompCol::PerArea, LoadCompRow::GrdTot);
   15410           6 :                 e.cellUsed = false;
   15411             :             }
   15412             :         }
   15413          23 :         if (ort->displayFacilityComponentLoadSummary) {
   15414           1 :             FacilityHeatCompLoadTables.cells.allocate(LoadCompCol::PerArea, LoadCompRow::GrdTot);
   15415           1 :             FacilityHeatCompLoadTables.cells = 0.;
   15416           1 :             FacilityHeatCompLoadTables.cellUsed.allocate(LoadCompCol::PerArea, LoadCompRow::GrdTot);
   15417           1 :             FacilityHeatCompLoadTables.cellUsed = false;
   15418             : 
   15419           1 :             FacilityCoolCompLoadTables.cells.allocate(LoadCompCol::PerArea, LoadCompRow::GrdTot);
   15420           1 :             FacilityCoolCompLoadTables.cells = 0.;
   15421           1 :             FacilityCoolCompLoadTables.cellUsed.allocate(LoadCompCol::PerArea, LoadCompRow::GrdTot);
   15422           1 :             FacilityCoolCompLoadTables.cellUsed = false;
   15423             : 
   15424           1 :             FacilityZonesHeatCompLoadTables.allocate(state.dataGlobal->NumOfZones);
   15425           7 :             for (auto &e : FacilityZonesHeatCompLoadTables) {
   15426           6 :                 e.cells.allocate(LoadCompCol::PerArea, LoadCompRow::GrdTot);
   15427           6 :                 e.cells = 0.;
   15428           6 :                 e.cellUsed.allocate(LoadCompCol::PerArea, LoadCompRow::GrdTot);
   15429           6 :                 e.cellUsed = false;
   15430             :             }
   15431           1 :             FacilityZonesCoolCompLoadTables.allocate(state.dataGlobal->NumOfZones);
   15432           7 :             for (auto &e : FacilityZonesCoolCompLoadTables) {
   15433           6 :                 e.cells.allocate(LoadCompCol::PerArea, LoadCompRow::GrdTot);
   15434           6 :                 e.cells = 0.;
   15435           6 :                 e.cellUsed.allocate(LoadCompCol::PerArea, LoadCompRow::GrdTot);
   15436           6 :                 e.cellUsed = false;
   15437             :             }
   15438             :         }
   15439             : 
   15440             :         // get the zone areas needed later
   15441          46 :         Array1D<ZompComponentAreasType> ZoneComponentAreas;
   15442          23 :         ZoneComponentAreas.allocate(state.dataGlobal->NumOfZones);
   15443          23 :         GetZoneComponentAreas(state, ZoneComponentAreas);
   15444             : 
   15445             :         // ZoneComponentLoadSummary
   15446          23 :         if (ort->displayZoneComponentLoadSummary) {
   15447         161 :             for (int iZone = 1; iZone <= state.dataGlobal->NumOfZones; ++iZone) {
   15448         138 :                 if (!state.dataZoneEquip->ZoneEquipConfig(iZone).IsControlled) continue;
   15449         115 :                 if (allocated(state.dataSize->CalcFinalZoneSizing)) {
   15450         115 :                     coolDesSelected = state.dataSize->CalcFinalZoneSizing(iZone).CoolDDNum;
   15451         115 :                     ZoneCoolCompLoadTables(iZone).desDayNum = coolDesSelected;
   15452         115 :                     timeCoolMax = state.dataSize->CalcFinalZoneSizing(iZone).TimeStepNumAtCoolMax;
   15453         115 :                     ZoneCoolCompLoadTables(iZone).timeStepMax = timeCoolMax;
   15454             : 
   15455         115 :                     GetDelaySequences(state,
   15456             :                                       coolDesSelected,
   15457             :                                       true,
   15458             :                                       iZone,
   15459             :                                       peopleDelaySeqCool,
   15460             :                                       equipDelaySeqCool,
   15461             :                                       hvacLossDelaySeqCool,
   15462             :                                       powerGenDelaySeqCool,
   15463             :                                       lightDelaySeqCool,
   15464             :                                       feneSolarDelaySeqCool,
   15465         115 :                                       ort->feneCondInstantSeq,
   15466             :                                       surfDelaySeqCool);
   15467         345 :                     ComputeTableBodyUsingMovingAvg(state,
   15468         115 :                                                    ZoneCoolCompLoadTables(iZone).cells,
   15469         115 :                                                    ZoneCoolCompLoadTables(iZone).cellUsed,
   15470             :                                                    coolDesSelected,
   15471             :                                                    timeCoolMax,
   15472             :                                                    iZone,
   15473             :                                                    peopleDelaySeqCool,
   15474             :                                                    equipDelaySeqCool,
   15475             :                                                    hvacLossDelaySeqCool,
   15476             :                                                    powerGenDelaySeqCool,
   15477             :                                                    lightDelaySeqCool,
   15478             :                                                    feneSolarDelaySeqCool,
   15479         115 :                                                    ort->feneCondInstantSeq,
   15480             :                                                    surfDelaySeqCool);
   15481         115 :                     CollectPeakZoneConditions(state, ZoneCoolCompLoadTables(iZone), coolDesSelected, timeCoolMax, iZone, true);
   15482             :                     // send latent load info to coil summary report
   15483         230 :                     state.dataRptCoilSelection->coilSelectionReportObj->setZoneLatentLoadCoolingIdealPeak(
   15484         115 :                         iZone, ZoneCoolCompLoadTables(iZone).cells(LoadCompCol::Latent, LoadCompRow::GrdTot));
   15485             : 
   15486         115 :                     heatDesSelected = state.dataSize->CalcFinalZoneSizing(iZone).HeatDDNum;
   15487         115 :                     ZoneHeatCompLoadTables(iZone).desDayNum = heatDesSelected;
   15488         115 :                     timeHeatMax = state.dataSize->CalcFinalZoneSizing(iZone).TimeStepNumAtHeatMax;
   15489         115 :                     ZoneHeatCompLoadTables(iZone).timeStepMax = timeHeatMax;
   15490             : 
   15491         115 :                     GetDelaySequences(state,
   15492             :                                       heatDesSelected,
   15493             :                                       false,
   15494             :                                       iZone,
   15495             :                                       peopleDelaySeqHeat,
   15496             :                                       equipDelaySeqHeat,
   15497             :                                       hvacLossDelaySeqHeat,
   15498             :                                       powerGenDelaySeqHeat,
   15499             :                                       lightDelaySeqHeat,
   15500             :                                       feneSolarDelaySeqHeat,
   15501         115 :                                       ort->feneCondInstantSeq,
   15502             :                                       surfDelaySeqHeat);
   15503         345 :                     ComputeTableBodyUsingMovingAvg(state,
   15504         115 :                                                    ZoneHeatCompLoadTables(iZone).cells,
   15505         115 :                                                    ZoneHeatCompLoadTables(iZone).cellUsed,
   15506             :                                                    heatDesSelected,
   15507             :                                                    timeHeatMax,
   15508             :                                                    iZone,
   15509             :                                                    peopleDelaySeqHeat,
   15510             :                                                    equipDelaySeqHeat,
   15511             :                                                    hvacLossDelaySeqHeat,
   15512             :                                                    powerGenDelaySeqHeat,
   15513             :                                                    lightDelaySeqHeat,
   15514             :                                                    feneSolarDelaySeqHeat,
   15515         115 :                                                    ort->feneCondInstantSeq,
   15516             :                                                    surfDelaySeqHeat);
   15517         115 :                     CollectPeakZoneConditions(state, ZoneHeatCompLoadTables(iZone), heatDesSelected, timeHeatMax, iZone, false);
   15518             : 
   15519             :                     // send latent load info to coil summary report
   15520         230 :                     state.dataRptCoilSelection->coilSelectionReportObj->setZoneLatentLoadHeatingIdealPeak(
   15521         115 :                         iZone, ZoneHeatCompLoadTables(iZone).cells(LoadCompCol::Latent, LoadCompRow::GrdTot));
   15522             : 
   15523         115 :                     AddAreaColumnForZone(iZone, ZoneComponentAreas, ZoneCoolCompLoadTables(iZone));
   15524         115 :                     AddAreaColumnForZone(iZone, ZoneComponentAreas, ZoneHeatCompLoadTables(iZone));
   15525             : 
   15526         115 :                     AddTotalRowsForLoadSummary(ZoneCoolCompLoadTables(iZone));
   15527         115 :                     AddTotalRowsForLoadSummary(ZoneHeatCompLoadTables(iZone));
   15528             : 
   15529         115 :                     ComputePeakDifference(ZoneCoolCompLoadTables(iZone));
   15530         115 :                     ComputePeakDifference(ZoneHeatCompLoadTables(iZone));
   15531             : 
   15532             :                     // We delay the potential application of SI to IP conversion and actual output until after both the
   15533             :                     // AirLoopComponentLoadSummary and FacilityComponentLoadSummary have been processed because below we try to retrieve the info
   15534             :                     // directly when the timestamp would match (cf #7356), and if we converted right now, we would apply the conversion twice
   15535             :                 }
   15536             :             }
   15537             :         }
   15538             : 
   15539             :         // AirLoopComponentLoadSummary
   15540          23 :         if (ort->displayAirLoopComponentLoadSummary && NumPrimaryAirSys > 0) {
   15541           2 :             Array1D_int zoneToAirLoopCool;
   15542           1 :             zoneToAirLoopCool.dimension(state.dataGlobal->NumOfZones);
   15543           2 :             Array1D_int zoneToAirLoopHeat;
   15544           1 :             zoneToAirLoopHeat.dimension(state.dataGlobal->NumOfZones);
   15545             :             // 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
   15546             :             // (regardless of "heated" or "cooled" zone status)
   15547           2 :             for (int iAirLoop = 1; iAirLoop <= NumPrimaryAirSys; ++iAirLoop) {
   15548           1 :                 auto &finalSysSizing = FinalSysSizing(iAirLoop);
   15549           1 :                 auto &sysSizPeakDDNum = SysSizPeakDDNum(iAirLoop);
   15550           1 :                 zoneToAirLoopCool = 0;
   15551           1 :                 zoneToAirLoopHeat = 0;
   15552           1 :                 if (finalSysSizing.loadSizingType == DataSizing::LoadSizing::Sensible) {
   15553           1 :                     coolDesSelected = sysSizPeakDDNum.SensCoolPeakDD;
   15554           1 :                     if (coolDesSelected != 0) {
   15555           1 :                         timeCoolMax = sysSizPeakDDNum.TimeStepAtSensCoolPk(coolDesSelected);
   15556             :                     } else {
   15557           0 :                         timeCoolMax = 0;
   15558             :                     }
   15559           0 :                 } else if (finalSysSizing.loadSizingType == DataSizing::LoadSizing::Ventilation) {
   15560           0 :                     coolDesSelected = sysSizPeakDDNum.CoolFlowPeakDD;
   15561           0 :                     if (coolDesSelected != 0) {
   15562           0 :                         timeCoolMax = sysSizPeakDDNum.TimeStepAtCoolFlowPk(coolDesSelected);
   15563             :                     } else {
   15564           0 :                         timeCoolMax = 0;
   15565             :                     }
   15566             :                 } else {
   15567           0 :                     coolDesSelected = sysSizPeakDDNum.TotCoolPeakDD;
   15568           0 :                     if (coolDesSelected != 0) {
   15569           0 :                         timeCoolMax = sysSizPeakDDNum.TimeStepAtTotCoolPk(coolDesSelected);
   15570             :                     } else {
   15571           0 :                         timeCoolMax = 0;
   15572             :                     }
   15573             :                 }
   15574           1 :                 heatDesSelected = sysSizPeakDDNum.HeatPeakDD;
   15575           1 :                 if (heatDesSelected != 0) {
   15576           1 :                     timeHeatMax = sysSizPeakDDNum.TimeStepAtHeatPk(heatDesSelected);
   15577             :                 } else {
   15578           0 :                     timeHeatMax = 0;
   15579             :                 }
   15580             : 
   15581           1 :                 int NumZonesCooled = state.dataAirLoop->AirToZoneNodeInfo(iAirLoop).NumZonesCooled;
   15582           6 :                 for (int ZonesCooledNum = 1; ZonesCooledNum <= NumZonesCooled; ++ZonesCooledNum) { // loop over cooled zones
   15583           5 :                     int CtrlZoneNum = state.dataAirLoop->AirToZoneNodeInfo(iAirLoop).CoolCtrlZoneNums(ZonesCooledNum);
   15584           5 :                     zoneToAirLoopCool(CtrlZoneNum) = iAirLoop;
   15585           5 :                     AirLoopZonesCoolCompLoadTables(CtrlZoneNum).desDayNum = coolDesSelected;
   15586           5 :                     AirLoopZonesCoolCompLoadTables(CtrlZoneNum).timeStepMax = timeCoolMax;
   15587           5 :                     zoneToAirLoopHeat(CtrlZoneNum) = iAirLoop;
   15588           5 :                     AirLoopZonesHeatCompLoadTables(CtrlZoneNum).desDayNum = heatDesSelected;
   15589           5 :                     AirLoopZonesHeatCompLoadTables(CtrlZoneNum).timeStepMax = timeHeatMax;
   15590             :                 }
   15591           1 :                 int NumZonesHeated = state.dataAirLoop->AirToZoneNodeInfo(iAirLoop).NumZonesHeated;
   15592           1 :                 for (int ZonesHeatedNum = 1; ZonesHeatedNum <= NumZonesHeated; ++ZonesHeatedNum) { // loop over heated zones
   15593           0 :                     int CtrlZoneNum = state.dataAirLoop->AirToZoneNodeInfo(iAirLoop).HeatCtrlZoneNums(ZonesHeatedNum);
   15594           0 :                     zoneToAirLoopCool(CtrlZoneNum) = iAirLoop;
   15595           0 :                     AirLoopZonesCoolCompLoadTables(CtrlZoneNum).desDayNum = coolDesSelected;
   15596           0 :                     AirLoopZonesCoolCompLoadTables(CtrlZoneNum).timeStepMax = timeCoolMax;
   15597           0 :                     zoneToAirLoopHeat(CtrlZoneNum) = iAirLoop;
   15598           0 :                     AirLoopZonesHeatCompLoadTables(CtrlZoneNum).desDayNum = heatDesSelected;
   15599           0 :                     AirLoopZonesHeatCompLoadTables(CtrlZoneNum).timeStepMax = timeHeatMax;
   15600             :                 }
   15601             : 
   15602             :                 // now go through the zones and if design day and time of max match the previously calculated zone results use those otherwise
   15603             :                 // compute them for specific design day and time of max
   15604           7 :                 for (int iZone = 1; iZone <= state.dataGlobal->NumOfZones; ++iZone) {
   15605           6 :                     if (!state.dataZoneEquip->ZoneEquipConfig(iZone).IsControlled) continue;
   15606           5 :                     auto &airLoopZonesCoolCompLoadTables = AirLoopZonesCoolCompLoadTables(iZone);
   15607           5 :                     auto &airLoopZonesHeatCompLoadTables = AirLoopZonesHeatCompLoadTables(iZone);
   15608             :                     // The ZoneCoolCompLoadTables already hasn't gotten a potential IP conversion yet, so we won't convert it twice.
   15609          15 :                     if (ort->displayZoneComponentLoadSummary &&
   15610          10 :                         (airLoopZonesCoolCompLoadTables.desDayNum == ZoneCoolCompLoadTables(iZone).desDayNum) &&
   15611           5 :                         (airLoopZonesCoolCompLoadTables.timeStepMax == ZoneCoolCompLoadTables(iZone).timeStepMax)) {
   15612           0 :                         airLoopZonesCoolCompLoadTables = ZoneCoolCompLoadTables(iZone);
   15613             :                     } else {
   15614           5 :                         coolDesSelected = airLoopZonesCoolCompLoadTables.desDayNum;
   15615           5 :                         timeCoolMax = airLoopZonesCoolCompLoadTables.timeStepMax;
   15616             : 
   15617           5 :                         GetDelaySequences(state,
   15618             :                                           coolDesSelected,
   15619             :                                           true,
   15620             :                                           iZone,
   15621             :                                           peopleDelaySeqCool,
   15622             :                                           equipDelaySeqCool,
   15623             :                                           hvacLossDelaySeqCool,
   15624             :                                           powerGenDelaySeqCool,
   15625             :                                           lightDelaySeqCool,
   15626             :                                           feneSolarDelaySeqCool,
   15627           5 :                                           ort->feneCondInstantSeq,
   15628             :                                           surfDelaySeqCool);
   15629           5 :                         ComputeTableBodyUsingMovingAvg(state,
   15630             :                                                        airLoopZonesCoolCompLoadTables.cells,
   15631             :                                                        airLoopZonesCoolCompLoadTables.cellUsed,
   15632             :                                                        coolDesSelected,
   15633             :                                                        timeCoolMax,
   15634             :                                                        iZone,
   15635             :                                                        peopleDelaySeqCool,
   15636             :                                                        equipDelaySeqCool,
   15637             :                                                        hvacLossDelaySeqCool,
   15638             :                                                        powerGenDelaySeqCool,
   15639             :                                                        lightDelaySeqCool,
   15640             :                                                        feneSolarDelaySeqCool,
   15641           5 :                                                        ort->feneCondInstantSeq,
   15642             :                                                        surfDelaySeqCool);
   15643           5 :                         CollectPeakZoneConditions(state, airLoopZonesCoolCompLoadTables, coolDesSelected, timeCoolMax, iZone, true);
   15644           5 :                         AddAreaColumnForZone(iZone, ZoneComponentAreas, airLoopZonesCoolCompLoadTables);
   15645             :                     }
   15646          15 :                     if (ort->displayZoneComponentLoadSummary &&
   15647          10 :                         (airLoopZonesHeatCompLoadTables.desDayNum == ZoneHeatCompLoadTables(iZone).desDayNum) &&
   15648           5 :                         (airLoopZonesHeatCompLoadTables.timeStepMax == ZoneHeatCompLoadTables(iZone).timeStepMax)) {
   15649           0 :                         airLoopZonesHeatCompLoadTables = ZoneHeatCompLoadTables(iZone);
   15650             :                     } else {
   15651           5 :                         heatDesSelected = airLoopZonesHeatCompLoadTables.desDayNum;
   15652           5 :                         timeHeatMax = airLoopZonesHeatCompLoadTables.timeStepMax;
   15653             : 
   15654           5 :                         GetDelaySequences(state,
   15655             :                                           heatDesSelected,
   15656             :                                           false,
   15657             :                                           iZone,
   15658             :                                           peopleDelaySeqHeat,
   15659             :                                           equipDelaySeqHeat,
   15660             :                                           hvacLossDelaySeqHeat,
   15661             :                                           powerGenDelaySeqHeat,
   15662             :                                           lightDelaySeqHeat,
   15663             :                                           feneSolarDelaySeqHeat,
   15664           5 :                                           ort->feneCondInstantSeq,
   15665             :                                           surfDelaySeqHeat);
   15666           5 :                         ComputeTableBodyUsingMovingAvg(state,
   15667             :                                                        airLoopZonesHeatCompLoadTables.cells,
   15668             :                                                        airLoopZonesHeatCompLoadTables.cellUsed,
   15669             :                                                        heatDesSelected,
   15670             :                                                        timeHeatMax,
   15671             :                                                        iZone,
   15672             :                                                        peopleDelaySeqHeat,
   15673             :                                                        equipDelaySeqHeat,
   15674             :                                                        hvacLossDelaySeqHeat,
   15675             :                                                        powerGenDelaySeqHeat,
   15676             :                                                        lightDelaySeqHeat,
   15677             :                                                        feneSolarDelaySeqHeat,
   15678           5 :                                                        ort->feneCondInstantSeq,
   15679             :                                                        surfDelaySeqHeat);
   15680           5 :                         CollectPeakZoneConditions(state, airLoopZonesHeatCompLoadTables, heatDesSelected, timeHeatMax, iZone, false);
   15681           5 :                         AddAreaColumnForZone(iZone, ZoneComponentAreas, airLoopZonesHeatCompLoadTables);
   15682             :                     }
   15683             :                 }
   15684             :                 // combine the zones for each air loop
   15685             : 
   15686           1 :                 auto &airLoopCoolTable = AirLoopCoolCompLoadTables(iAirLoop);
   15687           1 :                 auto &airLoopHeatTable = AirLoopHeatCompLoadTables(iAirLoop);
   15688           7 :                 for (int iZone = 1; iZone <= state.dataGlobal->NumOfZones; ++iZone) {
   15689           6 :                     if (zoneToAirLoopCool(iZone) == iAirLoop) {
   15690           5 :                         mult = Zone(iZone).Multiplier * Zone(iZone).ListMultiplier;
   15691           5 :                         if (mult == 0.0) mult = 1.0;
   15692           5 :                         CombineLoadCompResults(airLoopCoolTable, AirLoopZonesCoolCompLoadTables(iZone), mult);
   15693             :                     }
   15694           6 :                     if (zoneToAirLoopHeat(iZone) == iAirLoop) {
   15695           5 :                         mult = Zone(iZone).Multiplier * Zone(iZone).ListMultiplier;
   15696           5 :                         if (mult == 0.0) mult = 1.0;
   15697           5 :                         CombineLoadCompResults(airLoopHeatTable, AirLoopZonesHeatCompLoadTables(iZone), mult);
   15698             :                     }
   15699             :                 }
   15700           2 :                 for (int SysSizIndex = 1; SysSizIndex <= state.dataSize->NumSysSizInput; ++SysSizIndex) {
   15701           1 :                     if (state.dataSize->SysSizInput(SysSizIndex).AirLoopNum != iAirLoop) continue;
   15702           1 :                     if (state.dataSize->SysSizInput(SysSizIndex).SizingOption == DataSizing::Coincident) {
   15703           0 :                         airLoopCoolTable.peakDesSensLoad = finalSysSizing.SysCoolCoinSpaceSens;
   15704           0 :                         airLoopCoolTable.designPeakLoad = finalSysSizing.SysDesCoolLoad;
   15705           0 :                         airLoopHeatTable.peakDesSensLoad = -finalSysSizing.SysHeatCoinSpaceSens;
   15706           0 :                         airLoopHeatTable.designPeakLoad = -finalSysSizing.SysDesHeatLoad;
   15707           0 :                         airLoopCoolTable.diffPeakEst = airLoopCoolTable.peakDesSensLoad - airLoopCoolTable.estInstDelSensLoad;
   15708           0 :                         airLoopCoolTable.diffDesignPeak = airLoopCoolTable.designPeakLoad - airLoopCoolTable.peakDesSensLoad;
   15709           0 :                         airLoopHeatTable.diffPeakEst = airLoopHeatTable.peakDesSensLoad - airLoopHeatTable.estInstDelSensLoad;
   15710           0 :                         airLoopCoolTable.diffDesignPeak = airLoopHeatTable.designPeakLoad - airLoopHeatTable.peakDesSensLoad;
   15711             :                     }
   15712             :                 }
   15713             : 
   15714             :                 // Coincident and NonCoincident alike
   15715           1 :                 airLoopCoolTable.mixAirTemp = finalSysSizing.MixTempAtCoolPeak;
   15716           1 :                 airLoopHeatTable.mixAirTemp = finalSysSizing.HeatMixTemp;
   15717             : 
   15718           1 :                 ComputeEngineeringChecks(airLoopCoolTable);
   15719           1 :                 ComputeEngineeringChecks(airLoopHeatTable);
   15720             : 
   15721           1 :                 AddTotalRowsForLoadSummary(airLoopCoolTable);
   15722           1 :                 AddTotalRowsForLoadSummary(airLoopHeatTable);
   15723             : 
   15724           1 :                 ComputePeakDifference(airLoopCoolTable);
   15725           1 :                 ComputePeakDifference(airLoopHeatTable);
   15726             : 
   15727           1 :                 CreateListOfZonesForAirLoop(state, airLoopCoolTable, zoneToAirLoopCool, iAirLoop);
   15728           1 :                 CreateListOfZonesForAirLoop(state, airLoopHeatTable, zoneToAirLoopHeat, iAirLoop);
   15729             : 
   15730           1 :                 LoadSummaryUnitConversion(state, airLoopCoolTable, unitsStyle_cur);
   15731           1 :                 LoadSummaryUnitConversion(state, airLoopHeatTable, unitsStyle_cur);
   15732             : 
   15733           1 :                 OutputCompLoadSummary(
   15734             :                     state, OutputType::AirLoop, airLoopCoolTable, airLoopHeatTable, iAirLoop, unitsStyle_cur, produceTabular, produceSQLite);
   15735             :             }
   15736             :         }
   15737             : 
   15738             :         // FacilityComponentLoadSummary
   15739          23 :         if (ort->displayFacilityComponentLoadSummary) {
   15740             : 
   15741           1 :             coolDesSelected = CalcFinalFacilitySizing.CoolDDNum;
   15742           1 :             timeCoolMax = CalcFinalFacilitySizing.TimeStepNumAtCoolMax;
   15743             : 
   15744           1 :             heatDesSelected = CalcFinalFacilitySizing.HeatDDNum;
   15745           1 :             timeHeatMax = CalcFinalFacilitySizing.TimeStepNumAtHeatMax;
   15746             : 
   15747           7 :             for (int iZone = 1; iZone <= state.dataGlobal->NumOfZones; ++iZone) {
   15748           6 :                 if (!state.dataZoneEquip->ZoneEquipConfig(iZone).IsControlled) continue;
   15749           5 :                 auto &facilityZonesCoolCompLoadTables = FacilityZonesCoolCompLoadTables(iZone);
   15750           5 :                 auto &facilityZonesHeatCompLoadTables = FacilityZonesHeatCompLoadTables(iZone);
   15751           5 :                 mult = Zone(iZone).Multiplier * Zone(iZone).ListMultiplier;
   15752           5 :                 if (mult == 0.0) mult = 1.0;
   15753             :                 // The ZoneCoolCompLoadTables already hasn't gotten a potential IP conversion yet, so we won't convert it twice.
   15754          10 :                 if (ort->displayZoneComponentLoadSummary && (coolDesSelected == ZoneCoolCompLoadTables(iZone).desDayNum) &&
   15755           5 :                     (timeCoolMax == ZoneCoolCompLoadTables(iZone).timeStepMax)) {
   15756           0 :                     facilityZonesCoolCompLoadTables = ZoneCoolCompLoadTables(iZone);
   15757             :                 } else {
   15758           5 :                     GetDelaySequences(state,
   15759             :                                       coolDesSelected,
   15760             :                                       true,
   15761             :                                       iZone,
   15762             :                                       peopleDelaySeqCool,
   15763             :                                       equipDelaySeqCool,
   15764             :                                       hvacLossDelaySeqCool,
   15765             :                                       powerGenDelaySeqCool,
   15766             :                                       lightDelaySeqCool,
   15767             :                                       feneSolarDelaySeqCool,
   15768           5 :                                       ort->feneCondInstantSeq,
   15769             :                                       surfDelaySeqCool);
   15770           5 :                     ComputeTableBodyUsingMovingAvg(state,
   15771             :                                                    facilityZonesCoolCompLoadTables.cells,
   15772             :                                                    facilityZonesCoolCompLoadTables.cellUsed,
   15773             :                                                    coolDesSelected,
   15774             :                                                    timeCoolMax,
   15775             :                                                    iZone,
   15776             :                                                    peopleDelaySeqCool,
   15777             :                                                    equipDelaySeqCool,
   15778             :                                                    hvacLossDelaySeqCool,
   15779             :                                                    powerGenDelaySeqCool,
   15780             :                                                    lightDelaySeqCool,
   15781             :                                                    feneSolarDelaySeqCool,
   15782           5 :                                                    ort->feneCondInstantSeq,
   15783             :                                                    surfDelaySeqCool);
   15784           5 :                     CollectPeakZoneConditions(state, facilityZonesCoolCompLoadTables, coolDesSelected, timeCoolMax, iZone, true);
   15785           5 :                     AddAreaColumnForZone(iZone, ZoneComponentAreas, facilityZonesCoolCompLoadTables);
   15786             :                 }
   15787           5 :                 facilityZonesCoolCompLoadTables.timeStepMax = timeCoolMax;
   15788           5 :                 facilityZonesCoolCompLoadTables.desDayNum = coolDesSelected;
   15789           5 :                 CombineLoadCompResults(FacilityCoolCompLoadTables, facilityZonesCoolCompLoadTables, mult);
   15790             : 
   15791          10 :                 if (ort->displayZoneComponentLoadSummary && (heatDesSelected == ZoneHeatCompLoadTables(iZone).desDayNum) &&
   15792           5 :                     (timeHeatMax == ZoneHeatCompLoadTables(iZone).timeStepMax)) {
   15793           5 :                     facilityZonesHeatCompLoadTables = ZoneHeatCompLoadTables(iZone);
   15794             :                 } else {
   15795           0 :                     GetDelaySequences(state,
   15796             :                                       heatDesSelected,
   15797             :                                       false,
   15798             :                                       iZone,
   15799             :                                       peopleDelaySeqHeat,
   15800             :                                       equipDelaySeqHeat,
   15801             :                                       hvacLossDelaySeqHeat,
   15802             :                                       powerGenDelaySeqHeat,
   15803             :                                       lightDelaySeqHeat,
   15804             :                                       feneSolarDelaySeqHeat,
   15805           0 :                                       ort->feneCondInstantSeq,
   15806             :                                       surfDelaySeqHeat);
   15807           0 :                     ComputeTableBodyUsingMovingAvg(state,
   15808             :                                                    facilityZonesHeatCompLoadTables.cells,
   15809             :                                                    facilityZonesHeatCompLoadTables.cellUsed,
   15810             :                                                    heatDesSelected,
   15811             :                                                    timeHeatMax,
   15812             :                                                    iZone,
   15813             :                                                    peopleDelaySeqHeat,
   15814             :                                                    equipDelaySeqHeat,
   15815             :                                                    hvacLossDelaySeqHeat,
   15816             :                                                    powerGenDelaySeqHeat,
   15817             :                                                    lightDelaySeqHeat,
   15818             :                                                    feneSolarDelaySeqHeat,
   15819           0 :                                                    ort->feneCondInstantSeq,
   15820             :                                                    surfDelaySeqHeat);
   15821           0 :                     CollectPeakZoneConditions(state, facilityZonesHeatCompLoadTables, heatDesSelected, timeHeatMax, iZone, false);
   15822           0 :                     AddAreaColumnForZone(iZone, ZoneComponentAreas, facilityZonesHeatCompLoadTables);
   15823             :                 }
   15824           5 :                 facilityZonesHeatCompLoadTables.timeStepMax = timeHeatMax;
   15825           5 :                 facilityZonesHeatCompLoadTables.desDayNum = heatDesSelected;
   15826           5 :                 CombineLoadCompResults(FacilityHeatCompLoadTables, facilityZonesHeatCompLoadTables, mult);
   15827             :             }
   15828             : 
   15829           1 :             auto &facilityCoolTable = FacilityCoolCompLoadTables;
   15830           1 :             auto &facilityHeatTable = FacilityHeatCompLoadTables;
   15831           1 :             facilityCoolTable.peakDesSensLoad = 0.0;
   15832           1 :             facilityCoolTable.designPeakLoad = 0.0;
   15833           1 :             facilityHeatTable.peakDesSensLoad = 0.0;
   15834           1 :             facilityHeatTable.designPeakLoad = 0.0;
   15835           1 :             facilityCoolTable.diffPeakEst = 0.0;
   15836           1 :             facilityHeatTable.diffPeakEst = 0.0;
   15837           1 :             facilityCoolTable.diffDesignPeak = 0.0;
   15838           2 :             for (int iAirLoop = 1; iAirLoop <= NumPrimaryAirSys; ++iAirLoop) {
   15839           1 :                 facilityCoolTable.peakDesSensLoad += AirLoopCoolCompLoadTables(iAirLoop).peakDesSensLoad;
   15840           1 :                 facilityCoolTable.designPeakLoad += AirLoopCoolCompLoadTables(iAirLoop).designPeakLoad;
   15841           1 :                 facilityHeatTable.peakDesSensLoad += AirLoopHeatCompLoadTables(iAirLoop).peakDesSensLoad;
   15842           1 :                 facilityHeatTable.designPeakLoad += AirLoopHeatCompLoadTables(iAirLoop).designPeakLoad;
   15843           1 :                 facilityCoolTable.diffPeakEst += AirLoopCoolCompLoadTables(iAirLoop).diffPeakEst;
   15844           1 :                 facilityCoolTable.diffDesignPeak += AirLoopCoolCompLoadTables(iAirLoop).diffDesignPeak;
   15845           1 :                 facilityHeatTable.diffPeakEst += AirLoopHeatCompLoadTables(iAirLoop).diffPeakEst;
   15846           1 :                 facilityCoolTable.diffDesignPeak += AirLoopHeatCompLoadTables(iAirLoop).diffDesignPeak;
   15847             :             }
   15848             : 
   15849           1 :             ComputeEngineeringChecks(FacilityCoolCompLoadTables);
   15850           1 :             ComputeEngineeringChecks(FacilityHeatCompLoadTables);
   15851             : 
   15852           1 :             AddTotalRowsForLoadSummary(FacilityCoolCompLoadTables);
   15853           1 :             AddTotalRowsForLoadSummary(FacilityHeatCompLoadTables);
   15854             : 
   15855           1 :             ComputePeakDifference(FacilityCoolCompLoadTables);
   15856           1 :             ComputePeakDifference(FacilityHeatCompLoadTables);
   15857             : 
   15858           1 :             LoadSummaryUnitConversion(state, FacilityCoolCompLoadTables, unitsStyle_cur);
   15859           1 :             LoadSummaryUnitConversion(state, FacilityHeatCompLoadTables, unitsStyle_cur);
   15860             : 
   15861           1 :             OutputCompLoadSummary(state,
   15862             :                                   OutputType::Facility,
   15863             :                                   FacilityCoolCompLoadTables,
   15864             :                                   FacilityHeatCompLoadTables,
   15865             :                                   0,
   15866             :                                   unitsStyle_cur,
   15867             :                                   produceTabular,
   15868             :                                   produceSQLite);
   15869             :         }
   15870             : 
   15871             :         // ZoneComponentLoadSummary: Now we convert and Display
   15872          23 :         if (ort->displayZoneComponentLoadSummary) {
   15873         161 :             for (int iZone = 1; iZone <= state.dataGlobal->NumOfZones; ++iZone) {
   15874         138 :                 if (!state.dataZoneEquip->ZoneEquipConfig(iZone).IsControlled) continue;
   15875         115 :                 if (allocated(state.dataSize->CalcFinalZoneSizing)) {
   15876         115 :                     LoadSummaryUnitConversion(state, ZoneCoolCompLoadTables(iZone), unitsStyle_cur);
   15877         115 :                     LoadSummaryUnitConversion(state, ZoneHeatCompLoadTables(iZone), unitsStyle_cur);
   15878             : 
   15879         230 :                     OutputCompLoadSummary(state,
   15880             :                                           OutputType::Zone,
   15881         115 :                                           ZoneCoolCompLoadTables(iZone),
   15882         115 :                                           ZoneHeatCompLoadTables(iZone),
   15883             :                                           iZone,
   15884             :                                           unitsStyle_cur,
   15885             :                                           produceTabular,
   15886             :                                           produceSQLite);
   15887             :                 }
   15888             :             }
   15889             :         }
   15890             : 
   15891          23 :         ZoneHeatCompLoadTables.deallocate();
   15892          23 :         ZoneCoolCompLoadTables.deallocate();
   15893          23 :         AirLoopHeatCompLoadTables.deallocate();
   15894          23 :         AirLoopCoolCompLoadTables.deallocate();
   15895          23 :         AirLoopZonesHeatCompLoadTables.deallocate();
   15896          23 :         AirLoopZonesCoolCompLoadTables.deallocate();
   15897             : 
   15898          23 :         FacilityHeatCompLoadTables.cells.deallocate();
   15899          23 :         FacilityHeatCompLoadTables.cellUsed.deallocate();
   15900          23 :         FacilityCoolCompLoadTables.cells.deallocate();
   15901          23 :         FacilityCoolCompLoadTables.cellUsed.deallocate();
   15902             : 
   15903          23 :         FacilityZonesHeatCompLoadTables.deallocate();
   15904          23 :         FacilityZonesCoolCompLoadTables.deallocate();
   15905             : 
   15906          23 :         peopleDelaySeqHeat.deallocate();
   15907          23 :         peopleDelaySeqCool.deallocate();
   15908          23 :         lightDelaySeqHeat.deallocate();
   15909          23 :         lightDelaySeqCool.deallocate();
   15910          23 :         equipDelaySeqHeat.deallocate();
   15911          23 :         equipDelaySeqCool.deallocate();
   15912          23 :         hvacLossDelaySeqHeat.deallocate();
   15913          23 :         hvacLossDelaySeqCool.deallocate();
   15914          23 :         powerGenDelaySeqHeat.deallocate();
   15915          23 :         powerGenDelaySeqCool.deallocate();
   15916          23 :         feneSolarDelaySeqHeat.deallocate();
   15917          23 :         feneSolarDelaySeqCool.deallocate();
   15918          23 :         surfDelaySeqHeat.deallocate();
   15919          23 :         surfDelaySeqCool.deallocate();
   15920             :     }
   15921             : }
   15922             : 
   15923             : // populate the delay sequence arrays for the component load summary table output
   15924         245 : void GetDelaySequences(EnergyPlusData &state,
   15925             :                        int const desDaySelected,
   15926             :                        bool const isCooling,
   15927             :                        int const zoneIndex,
   15928             :                        Array1D<Real64> &peopleDelaySeq,
   15929             :                        Array1D<Real64> &equipDelaySeq,
   15930             :                        Array1D<Real64> &hvacLossDelaySeq,
   15931             :                        Array1D<Real64> &powerGenDelaySeq,
   15932             :                        Array1D<Real64> &lightDelaySeq,
   15933             :                        Array1D<Real64> &feneSolarDelaySeq,
   15934             :                        Array3D<Real64> &feneCondInstantSeq,
   15935             :                        Array2D<Real64> &surfDelaySeq)
   15936             : {
   15937             : 
   15938             :     // static bool initAdjFenDone(false); moved to anonymous namespace for unit testing
   15939         245 :     auto &ort(state.dataOutRptTab);
   15940             : 
   15941         245 :     if (!ort->initAdjFenDone) {
   15942          69 :         state.dataOutRptTab->adjFenDone.allocate(state.dataEnvrn->TotDesDays + state.dataEnvrn->TotRunDesPersDays,
   15943          23 :                                                  state.dataGlobal->NumOfTimeStepInHour * 24,
   15944          92 :                                                  state.dataGlobal->NumOfZones);
   15945          23 :         state.dataOutRptTab->adjFenDone = false;
   15946          23 :         ort->initAdjFenDone = true;
   15947             :     }
   15948             : 
   15949         245 :     if (desDaySelected != 0) {
   15950             : 
   15951         490 :         Array2D<Real64> decayCurve;
   15952         245 :         if (isCooling) {
   15953         125 :             decayCurve = ort->decayCurveCool;
   15954             :         } else {
   15955         120 :             decayCurve = ort->decayCurveHeat;
   15956             :         }
   15957             : 
   15958       23765 :         for (int kTimeStep = 1; kTimeStep <= state.dataGlobal->NumOfTimeStepInHour * 24; ++kTimeStep) {
   15959       23520 :             Real64 peopleConvIntoZone = 0.0;
   15960       23520 :             Real64 equipConvIntoZone = 0.0;
   15961       23520 :             Real64 hvacLossConvIntoZone = 0.0;
   15962       23520 :             Real64 powerGenConvIntoZone = 0.0;
   15963       23520 :             Real64 lightLWConvIntoZone = 0.0;
   15964       23520 :             Real64 lightSWConvIntoZone = 0.0;
   15965       23520 :             Real64 feneSolarConvIntoZone = 0.0;
   15966       23520 :             Real64 adjFeneSurfNetRadSeq = 0.0;
   15967             : 
   15968             :             // code from ComputeDelayedComponents starts
   15969       47808 :             for (int spaceNum : state.dataHeatBal->Zone(zoneIndex).spaceIndexes) {
   15970       24288 :                 auto &thisSpace = state.dataHeatBal->space(spaceNum);
   15971      193440 :                 for (int jSurf = thisSpace.HTSurfaceFirst; jSurf <= thisSpace.HTSurfaceLast; ++jSurf) {
   15972      169152 :                     int radEnclosureNum = state.dataSurface->Surface(jSurf).RadEnclIndex;
   15973             : 
   15974             :                     // for each time step, step back through time and apply decay curve to radiant heat for each end use absorbed in each surface
   15975      169152 :                     Real64 peopleConvFromSurf = 0.0;
   15976      169152 :                     Real64 equipConvFromSurf = 0.0;
   15977      169152 :                     Real64 hvacLossConvFromSurf = 0.0;
   15978      169152 :                     Real64 powerGenConvFromSurf = 0.0;
   15979      169152 :                     Real64 lightLWConvFromSurf = 0.0;
   15980      169152 :                     Real64 lightSWConvFromSurf = 0.0;
   15981      169152 :                     Real64 feneSolarConvFromSurf = 0.0;
   15982             : 
   15983     8373024 :                     for (int mStepBack = 1; mStepBack <= kTimeStep; ++mStepBack) {
   15984     8203872 :                         int sourceStep = kTimeStep - mStepBack + 1;
   15985    16407744 :                         Real64 thisQRadThermInAbsMult = ort->TMULTseq(desDaySelected, sourceStep, radEnclosureNum) *
   15986    16407744 :                                                         ort->ITABSFseq(desDaySelected, sourceStep, jSurf) * state.dataSurface->Surface(jSurf).Area *
   15987     8203872 :                                                         decayCurve(mStepBack, jSurf);
   15988     8203872 :                         peopleConvFromSurf += ort->peopleRadSeq(desDaySelected, sourceStep, zoneIndex) * thisQRadThermInAbsMult;
   15989     8203872 :                         equipConvFromSurf += ort->equipRadSeq(desDaySelected, sourceStep, zoneIndex) * thisQRadThermInAbsMult;
   15990     8203872 :                         hvacLossConvFromSurf += ort->hvacLossRadSeq(desDaySelected, sourceStep, zoneIndex) * thisQRadThermInAbsMult;
   15991     8203872 :                         powerGenConvFromSurf += ort->powerGenRadSeq(desDaySelected, sourceStep, zoneIndex) * thisQRadThermInAbsMult;
   15992     8203872 :                         lightLWConvFromSurf += ort->lightLWRadSeq(desDaySelected, sourceStep, zoneIndex) * thisQRadThermInAbsMult;
   15993             :                         // short wave is already accumulated by surface
   15994     8203872 :                         lightSWConvFromSurf += ort->lightSWRadSeq(desDaySelected, sourceStep, jSurf) * decayCurve(mStepBack, jSurf);
   15995     8203872 :                         feneSolarConvFromSurf += ort->feneSolarRadSeq(desDaySelected, sourceStep, jSurf) * decayCurve(mStepBack, jSurf);
   15996             :                     } // for mStepBack
   15997             : 
   15998      169152 :                     peopleConvIntoZone += peopleConvFromSurf;
   15999      169152 :                     equipConvIntoZone += equipConvFromSurf;
   16000      169152 :                     hvacLossConvIntoZone += hvacLossConvFromSurf;
   16001      169152 :                     powerGenConvIntoZone += powerGenConvFromSurf;
   16002      169152 :                     lightLWConvIntoZone += lightLWConvFromSurf;
   16003      169152 :                     lightSWConvIntoZone += lightSWConvFromSurf;
   16004      169152 :                     feneSolarConvIntoZone += feneSolarConvFromSurf;
   16005             :                     // code from ComputeDelayedComponents ends
   16006             :                     // determine the remaining convective heat from the surfaces that are not based
   16007             :                     // on any of these other loads
   16008             :                     // negative because heat from surface should be positive
   16009      169152 :                     surfDelaySeq(kTimeStep, jSurf) =
   16010      338304 :                         -ort->loadConvectedNormal(desDaySelected, kTimeStep, jSurf) - ort->netSurfRadSeq(desDaySelected, kTimeStep, jSurf) -
   16011      169152 :                         (peopleConvFromSurf + equipConvFromSurf + hvacLossConvFromSurf + powerGenConvFromSurf + lightLWConvFromSurf +
   16012      169152 :                          lightSWConvFromSurf +
   16013             :                          feneSolarConvFromSurf); // remove net radiant for the surface
   16014             :                                                  // also remove the net radiant component on the instanteous conduction for fenestration
   16015      169152 :                     if (state.dataSurface->Surface(jSurf).Class == DataSurfaces::SurfaceClass::Window) {
   16016       28224 :                         adjFeneSurfNetRadSeq += ort->netSurfRadSeq(desDaySelected, kTimeStep, jSurf);
   16017             :                     }
   16018             :                 } // for jSurf
   16019             :             }
   16020       23520 :             peopleDelaySeq(kTimeStep) = peopleConvIntoZone;
   16021       23520 :             equipDelaySeq(kTimeStep) = equipConvIntoZone;
   16022       23520 :             hvacLossDelaySeq(kTimeStep) = hvacLossConvIntoZone;
   16023       23520 :             powerGenDelaySeq(kTimeStep) = powerGenConvIntoZone;
   16024             :             // combine short wave (visible) and long wave (thermal) impacts
   16025       23520 :             lightDelaySeq(kTimeStep) = lightLWConvIntoZone + lightSWConvIntoZone;
   16026       23520 :             feneSolarDelaySeq(kTimeStep) = feneSolarConvIntoZone;
   16027             :             // also remove the net radiant component on the instanteous conduction for fenestration
   16028       23520 :             if (!state.dataOutRptTab->adjFenDone(desDaySelected, kTimeStep, zoneIndex)) {
   16029       22080 :                 feneCondInstantSeq(desDaySelected, kTimeStep, zoneIndex) -= adjFeneSurfNetRadSeq;
   16030       22080 :                 state.dataOutRptTab->adjFenDone(desDaySelected, kTimeStep, zoneIndex) = true;
   16031             :             }
   16032             :         } // for kTimeStep
   16033             : 
   16034         245 :         decayCurve.deallocate();
   16035             : 
   16036             :     } // if desDaySelected != 0
   16037         245 : }
   16038             : 
   16039             : // set the load summary table cells based on the load sequences using moving averages to smooth out
   16040         245 : void ComputeTableBodyUsingMovingAvg(EnergyPlusData &state,
   16041             :                                     Array2D<Real64> &resultCells,
   16042             :                                     Array2D_bool &resCellsUsd,
   16043             :                                     int const desDaySelected,
   16044             :                                     int const timeOfMax,
   16045             :                                     int const zoneIndex,
   16046             :                                     Array1D<Real64> const &peopleDelaySeq,
   16047             :                                     Array1D<Real64> const &equipDelaySeq,
   16048             :                                     Array1D<Real64> const &hvacLossDelaySeq,
   16049             :                                     Array1D<Real64> const &powerGenDelaySeq,
   16050             :                                     Array1D<Real64> const &lightDelaySeq,
   16051             :                                     Array1D<Real64> const &feneSolarDelaySeq,
   16052             :                                     Array3D<Real64> const &feneCondInstantSeq,
   16053             :                                     Array2D<Real64> const &surfDelaySeq)
   16054             : {
   16055         490 :     Array1D<Real64> AvgData;     // sequence data to be averaging
   16056         490 :     Array1D<Real64> delayOpaque; // hold values for report for delayed opaque
   16057             : 
   16058         245 :     resultCells = 0.;
   16059         245 :     resCellsUsd = false;
   16060         245 :     delayOpaque.allocate(LoadCompRow::GrdTot);
   16061         245 :     AvgData.allocate(state.dataGlobal->NumOfTimeStepInHour * 24);
   16062             : 
   16063         245 :     if (desDaySelected != 0 && timeOfMax != 0) {
   16064             :         // Don't update/average original array data
   16065             :         // PEOPLE
   16066         245 :         AvgData = state.dataOutRptTab->peopleInstantSeq(desDaySelected, _, zoneIndex);
   16067         245 :         General::MovingAvg(AvgData, state.dataSize->NumTimeStepsInAvg);
   16068         245 :         resultCells(LoadCompCol::SensInst, LoadCompRow::People) = AvgData(timeOfMax);
   16069         245 :         resCellsUsd(LoadCompCol::SensInst, LoadCompRow::People) = true;
   16070         245 :         AvgData = state.dataOutRptTab->peopleLatentSeq(desDaySelected, _, zoneIndex);
   16071         245 :         General::MovingAvg(AvgData, state.dataSize->NumTimeStepsInAvg);
   16072         245 :         resultCells(LoadCompCol::Latent, LoadCompRow::People) = AvgData(timeOfMax);
   16073         245 :         resCellsUsd(LoadCompCol::Latent, LoadCompRow::People) = true;
   16074         245 :         AvgData = peopleDelaySeq(_);
   16075         245 :         General::MovingAvg(AvgData, state.dataSize->NumTimeStepsInAvg);
   16076         245 :         resultCells(LoadCompCol::SensDelay, LoadCompRow::People) = AvgData(timeOfMax);
   16077         245 :         resCellsUsd(LoadCompCol::SensDelay, LoadCompRow::People) = true;
   16078             : 
   16079             :         // LIGHTS
   16080         245 :         AvgData = state.dataOutRptTab->lightInstantSeq(desDaySelected, _, zoneIndex);
   16081         245 :         General::MovingAvg(AvgData, state.dataSize->NumTimeStepsInAvg);
   16082         245 :         resultCells(LoadCompCol::SensInst, LoadCompRow::Lights) = AvgData(timeOfMax);
   16083         245 :         resCellsUsd(LoadCompCol::SensInst, LoadCompRow::Lights) = true;
   16084         245 :         AvgData = state.dataOutRptTab->lightRetAirSeq(desDaySelected, _, zoneIndex);
   16085         245 :         General::MovingAvg(AvgData, state.dataSize->NumTimeStepsInAvg);
   16086         245 :         resultCells(LoadCompCol::SensRA, LoadCompRow::Lights) = AvgData(timeOfMax);
   16087         245 :         resCellsUsd(LoadCompCol::SensRA, LoadCompRow::Lights) = true;
   16088         245 :         AvgData = lightDelaySeq(_);
   16089         245 :         General::MovingAvg(AvgData, state.dataSize->NumTimeStepsInAvg);
   16090         245 :         resultCells(LoadCompCol::SensDelay, LoadCompRow::Lights) = AvgData(timeOfMax);
   16091         245 :         resCellsUsd(LoadCompCol::SensDelay, LoadCompRow::Lights) = true;
   16092             : 
   16093             :         // EQUIPMENT
   16094         245 :         AvgData = state.dataOutRptTab->equipInstantSeq(desDaySelected, _, zoneIndex);
   16095         245 :         General::MovingAvg(AvgData, state.dataSize->NumTimeStepsInAvg);
   16096         245 :         resultCells(LoadCompCol::SensInst, LoadCompRow::Equip) = AvgData(timeOfMax);
   16097         245 :         resCellsUsd(LoadCompCol::SensInst, LoadCompRow::Equip) = true;
   16098         245 :         AvgData = state.dataOutRptTab->equipLatentSeq(desDaySelected, _, zoneIndex);
   16099         245 :         General::MovingAvg(AvgData, state.dataSize->NumTimeStepsInAvg);
   16100         245 :         resultCells(LoadCompCol::Latent, LoadCompRow::Equip) = AvgData(timeOfMax);
   16101         245 :         resCellsUsd(LoadCompCol::Latent, LoadCompRow::Equip) = true;
   16102         245 :         AvgData = equipDelaySeq(_);
   16103         245 :         General::MovingAvg(AvgData, state.dataSize->NumTimeStepsInAvg);
   16104         245 :         resultCells(LoadCompCol::SensDelay, LoadCompRow::Equip) = AvgData(timeOfMax);
   16105         245 :         resCellsUsd(LoadCompCol::SensDelay, LoadCompRow::Equip) = true;
   16106             : 
   16107             :         // REFRIGERATION EQUIPMENT
   16108         245 :         AvgData = state.dataOutRptTab->refrigInstantSeq(desDaySelected, _, zoneIndex);
   16109         245 :         General::MovingAvg(AvgData, state.dataSize->NumTimeStepsInAvg);
   16110         245 :         resultCells(LoadCompCol::SensInst, LoadCompRow::Refrig) = AvgData(timeOfMax);
   16111         245 :         resCellsUsd(LoadCompCol::SensInst, LoadCompRow::Refrig) = true;
   16112         245 :         AvgData = state.dataOutRptTab->refrigRetAirSeq(desDaySelected, _, zoneIndex);
   16113         245 :         General::MovingAvg(AvgData, state.dataSize->NumTimeStepsInAvg);
   16114         245 :         resultCells(LoadCompCol::SensRA, LoadCompRow::Refrig) = AvgData(timeOfMax);
   16115         245 :         resCellsUsd(LoadCompCol::SensRA, LoadCompRow::Refrig) = true;
   16116         245 :         AvgData = state.dataOutRptTab->refrigLatentSeq(desDaySelected, _, zoneIndex);
   16117         245 :         General::MovingAvg(AvgData, state.dataSize->NumTimeStepsInAvg);
   16118         245 :         resultCells(LoadCompCol::Latent, LoadCompRow::Refrig) = AvgData(timeOfMax);
   16119         245 :         resCellsUsd(LoadCompCol::Latent, LoadCompRow::Refrig) = true;
   16120             : 
   16121             :         // WATER USE EQUIPMENT
   16122         245 :         AvgData = state.dataOutRptTab->waterUseInstantSeq(desDaySelected, _, zoneIndex);
   16123         245 :         General::MovingAvg(AvgData, state.dataSize->NumTimeStepsInAvg);
   16124         245 :         resultCells(LoadCompCol::SensInst, LoadCompRow::WaterUse) = AvgData(timeOfMax);
   16125         245 :         resCellsUsd(LoadCompCol::SensInst, LoadCompRow::WaterUse) = true;
   16126         245 :         AvgData = state.dataOutRptTab->waterUseLatentSeq(desDaySelected, _, zoneIndex);
   16127         245 :         General::MovingAvg(AvgData, state.dataSize->NumTimeStepsInAvg);
   16128         245 :         resultCells(LoadCompCol::Latent, LoadCompRow::WaterUse) = AvgData(timeOfMax);
   16129         245 :         resCellsUsd(LoadCompCol::Latent, LoadCompRow::WaterUse) = true;
   16130             : 
   16131             :         // HVAC EQUIPMENT LOSSES
   16132         245 :         AvgData = state.dataOutRptTab->hvacLossInstantSeq(desDaySelected, _, zoneIndex);
   16133         245 :         General::MovingAvg(AvgData, state.dataSize->NumTimeStepsInAvg);
   16134         245 :         resultCells(LoadCompCol::SensInst, LoadCompRow::HvacLoss) = AvgData(timeOfMax);
   16135         245 :         resCellsUsd(LoadCompCol::SensInst, LoadCompRow::HvacLoss) = true;
   16136         245 :         AvgData = hvacLossDelaySeq(_);
   16137         245 :         General::MovingAvg(AvgData, state.dataSize->NumTimeStepsInAvg);
   16138         245 :         resultCells(LoadCompCol::SensDelay, LoadCompRow::HvacLoss) = AvgData(timeOfMax);
   16139         245 :         resCellsUsd(LoadCompCol::SensDelay, LoadCompRow::HvacLoss) = true;
   16140             : 
   16141             :         // POWER GENERATION EQUIPMENT
   16142         245 :         AvgData = state.dataOutRptTab->powerGenInstantSeq(desDaySelected, _, zoneIndex);
   16143         245 :         General::MovingAvg(AvgData, state.dataSize->NumTimeStepsInAvg);
   16144         245 :         resultCells(LoadCompCol::SensInst, LoadCompRow::PowerGen) = AvgData(timeOfMax);
   16145         245 :         resCellsUsd(LoadCompCol::SensInst, LoadCompRow::PowerGen) = true;
   16146         245 :         AvgData = powerGenDelaySeq(_);
   16147         245 :         General::MovingAvg(AvgData, state.dataSize->NumTimeStepsInAvg);
   16148         245 :         resultCells(LoadCompCol::SensDelay, LoadCompRow::PowerGen) = AvgData(timeOfMax);
   16149         245 :         resCellsUsd(LoadCompCol::SensDelay, LoadCompRow::PowerGen) = true;
   16150             : 
   16151             :         // DOAS
   16152         245 :         resultCells(LoadCompCol::SensInst, LoadCompRow::DOAS) = state.dataSize->CalcZoneSizing(desDaySelected, zoneIndex).DOASHeatAddSeq(timeOfMax);
   16153         245 :         resCellsUsd(LoadCompCol::SensInst, LoadCompRow::DOAS) = true;
   16154         245 :         resultCells(LoadCompCol::Latent, LoadCompRow::DOAS) = state.dataSize->CalcZoneSizing(desDaySelected, zoneIndex).DOASLatAddSeq(timeOfMax);
   16155         245 :         resCellsUsd(LoadCompCol::Latent, LoadCompRow::DOAS) = true;
   16156             : 
   16157             :         // INFILTRATION
   16158         245 :         AvgData = state.dataOutRptTab->infilInstantSeq(desDaySelected, _, zoneIndex);
   16159         245 :         General::MovingAvg(AvgData, state.dataSize->NumTimeStepsInAvg);
   16160         245 :         resultCells(LoadCompCol::SensInst, LoadCompRow::Infil) = AvgData(timeOfMax);
   16161         245 :         resCellsUsd(LoadCompCol::SensInst, LoadCompRow::Infil) = true;
   16162         245 :         AvgData = state.dataOutRptTab->infilLatentSeq(desDaySelected, _, zoneIndex);
   16163         245 :         General::MovingAvg(AvgData, state.dataSize->NumTimeStepsInAvg);
   16164         245 :         resultCells(LoadCompCol::Latent, LoadCompRow::Infil) = AvgData(timeOfMax);
   16165         245 :         resCellsUsd(LoadCompCol::Latent, LoadCompRow::Infil) = true;
   16166             : 
   16167             :         // ZONE VENTILATION
   16168         245 :         AvgData = state.dataOutRptTab->zoneVentInstantSeq(desDaySelected, _, zoneIndex);
   16169         245 :         General::MovingAvg(AvgData, state.dataSize->NumTimeStepsInAvg);
   16170         245 :         resultCells(LoadCompCol::SensInst, LoadCompRow::ZoneVent) = AvgData(timeOfMax);
   16171         245 :         resCellsUsd(LoadCompCol::SensInst, LoadCompRow::ZoneVent) = true;
   16172         245 :         AvgData = state.dataOutRptTab->zoneVentLatentSeq(desDaySelected, _, zoneIndex);
   16173         245 :         General::MovingAvg(AvgData, state.dataSize->NumTimeStepsInAvg);
   16174         245 :         resultCells(LoadCompCol::Latent, LoadCompRow::ZoneVent) = AvgData(timeOfMax);
   16175         245 :         resCellsUsd(LoadCompCol::Latent, LoadCompRow::ZoneVent) = true;
   16176             : 
   16177             :         // INTERZONE MIXING
   16178         245 :         AvgData = state.dataOutRptTab->interZoneMixInstantSeq(desDaySelected, _, zoneIndex);
   16179         245 :         General::MovingAvg(AvgData, state.dataSize->NumTimeStepsInAvg);
   16180         245 :         resultCells(LoadCompCol::SensInst, LoadCompRow::IntZonMix) = AvgData(timeOfMax);
   16181         245 :         resCellsUsd(LoadCompCol::SensInst, LoadCompRow::IntZonMix) = true;
   16182         245 :         AvgData = state.dataOutRptTab->interZoneMixLatentSeq(desDaySelected, _, zoneIndex);
   16183         245 :         General::MovingAvg(AvgData, state.dataSize->NumTimeStepsInAvg);
   16184         245 :         resultCells(LoadCompCol::Latent, LoadCompRow::IntZonMix) = AvgData(timeOfMax);
   16185         245 :         resCellsUsd(LoadCompCol::Latent, LoadCompRow::IntZonMix) = true;
   16186             : 
   16187             :         // FENESTRATION CONDUCTION
   16188         245 :         AvgData = feneCondInstantSeq(desDaySelected, _, zoneIndex);
   16189         245 :         General::MovingAvg(AvgData, state.dataSize->NumTimeStepsInAvg);
   16190         245 :         resultCells(LoadCompCol::SensInst, LoadCompRow::FeneCond) = AvgData(timeOfMax);
   16191         245 :         resCellsUsd(LoadCompCol::SensInst, LoadCompRow::FeneCond) = true;
   16192             : 
   16193             :         // FENESTRATION SOLAR
   16194         245 :         AvgData = feneSolarDelaySeq(_);
   16195         245 :         General::MovingAvg(AvgData, state.dataSize->NumTimeStepsInAvg);
   16196         245 :         resultCells(LoadCompCol::SensDelay, LoadCompRow::FeneSolr) = AvgData(timeOfMax);
   16197         245 :         resCellsUsd(LoadCompCol::SensDelay, LoadCompRow::FeneSolr) = true;
   16198             : 
   16199             :         // opaque surfaces - must combine individual surfaces by class and other side conditions
   16200         245 :         delayOpaque = 0.0;
   16201         498 :         for (int spaceNum : state.dataHeatBal->Zone(zoneIndex).spaceIndexes) {
   16202         253 :             auto &thisSpace = state.dataHeatBal->space(spaceNum);
   16203        2015 :             for (int kSurf = thisSpace.HTSurfaceFirst; kSurf <= thisSpace.HTSurfaceLast; ++kSurf) {
   16204             : 
   16205        1762 :                 int curExtBoundCond = state.dataSurface->Surface(kSurf).ExtBoundCond;
   16206             :                 // if exterior is other side coefficients using ground preprocessor terms then
   16207             :                 // set it to ground instead of other side coefficients
   16208        1762 :                 if (curExtBoundCond == DataSurfaces::OtherSideCoefNoCalcExt || curExtBoundCond == DataSurfaces::OtherSideCoefCalcExt) {
   16209           0 :                     if (has_prefixi(state.dataSurface->OSC(state.dataSurface->Surface(kSurf).OSCPtr).Name, "surfPropOthSdCoef")) {
   16210           0 :                         curExtBoundCond = DataSurfaces::Ground;
   16211             :                     }
   16212             :                 }
   16213        1762 :                 AvgData = surfDelaySeq(_, kSurf);
   16214        1762 :                 General::MovingAvg(AvgData, state.dataSize->NumTimeStepsInAvg);
   16215        1762 :                 Real64 singleSurfDelay = AvgData(timeOfMax);
   16216        1762 :                 switch (state.dataSurface->Surface(kSurf).Class) {
   16217         968 :                 case DataSurfaces::SurfaceClass::Wall: {
   16218         968 :                     switch (curExtBoundCond) {
   16219         200 :                     case DataSurfaces::ExternalEnvironment: {
   16220         200 :                         delayOpaque(LoadCompRow::ExtWall) += singleSurfDelay;
   16221         200 :                     } break;
   16222           0 :                     case DataSurfaces::Ground:
   16223             :                     case DataSurfaces::GroundFCfactorMethod:
   16224             :                     case DataSurfaces::KivaFoundation: {
   16225           0 :                         delayOpaque(LoadCompRow::GrdWall) += singleSurfDelay;
   16226           0 :                     } break;
   16227           0 :                     case DataSurfaces::OtherSideCoefNoCalcExt:
   16228             :                     case DataSurfaces::OtherSideCoefCalcExt:
   16229             :                     case DataSurfaces::OtherSideCondModeledExt: {
   16230           0 :                         delayOpaque(LoadCompRow::OtherWall) += singleSurfDelay;
   16231           0 :                     } break;
   16232         768 :                     default: { // interzone
   16233         768 :                         delayOpaque(LoadCompRow::IntZonWall) += singleSurfDelay;
   16234         768 :                     } break;
   16235             :                     }
   16236         968 :                 } break;
   16237         251 :                 case DataSurfaces::SurfaceClass::Floor: {
   16238         251 :                     switch (curExtBoundCond) {
   16239           0 :                     case DataSurfaces::ExternalEnvironment: {
   16240           0 :                         delayOpaque(LoadCompRow::ExtFlr) += singleSurfDelay;
   16241           0 :                     } break;
   16242         251 :                     case DataSurfaces::Ground:
   16243             :                     case DataSurfaces::GroundFCfactorMethod:
   16244             :                     case DataSurfaces::KivaFoundation: {
   16245         251 :                         delayOpaque(LoadCompRow::GrdFlr) += singleSurfDelay;
   16246         251 :                     } break;
   16247           0 :                     case DataSurfaces::OtherSideCoefNoCalcExt:
   16248             :                     case DataSurfaces::OtherSideCoefCalcExt:
   16249             :                     case DataSurfaces::OtherSideCondModeledExt: {
   16250           0 :                         delayOpaque(LoadCompRow::OtherFlr) += singleSurfDelay;
   16251           0 :                     } break;
   16252           0 :                     default: { // interzone
   16253           0 :                         delayOpaque(LoadCompRow::IntZonFlr) += singleSurfDelay;
   16254           0 :                     } break;
   16255             :                     }
   16256         251 :                 } break;
   16257         249 :                 case DataSurfaces::SurfaceClass::Roof: {
   16258         249 :                     switch (curExtBoundCond) {
   16259           0 :                     case DataSurfaces::ExternalEnvironment: {
   16260           0 :                         delayOpaque(LoadCompRow::Roof) += singleSurfDelay;
   16261           0 :                     } break;
   16262           0 :                     case DataSurfaces::Ground:
   16263             :                     case DataSurfaces::GroundFCfactorMethod:
   16264             :                     case DataSurfaces::KivaFoundation:
   16265             :                     case DataSurfaces::OtherSideCoefNoCalcExt:
   16266             :                     case DataSurfaces::OtherSideCoefCalcExt:
   16267             :                     case DataSurfaces::OtherSideCondModeledExt: {
   16268           0 :                         delayOpaque(LoadCompRow::OtherRoof) += singleSurfDelay;
   16269           0 :                     } break;
   16270         249 :                     default: { // interzone
   16271         249 :                         delayOpaque(LoadCompRow::IntZonCeil) += singleSurfDelay;
   16272         249 :                     } break;
   16273             :                     }
   16274         249 :                 } break;
   16275           0 :                 case DataSurfaces::SurfaceClass::Door: {
   16276           0 :                     delayOpaque(LoadCompRow::OpqDoor) += singleSurfDelay;
   16277           0 :                 } break;
   16278         294 :                 default:
   16279         294 :                     break;
   16280             :                 }
   16281             :             }
   16282             :         }
   16283        2940 :         for (int k = LoadCompRow::Roof; k <= LoadCompRow::OtherFlr; ++k) {
   16284        2695 :             resultCells(LoadCompCol::SensDelay, k) = delayOpaque(k);
   16285        2695 :             resCellsUsd(LoadCompCol::SensDelay, k) = true;
   16286             :         }
   16287         245 :         resultCells(LoadCompCol::SensDelay, LoadCompRow::OpqDoor) = delayOpaque(LoadCompRow::OpqDoor);
   16288         245 :         resCellsUsd(LoadCompCol::SensDelay, LoadCompRow::OpqDoor) = true;
   16289             :     }
   16290         245 : }
   16291             : 
   16292             : // for the load summary report add values the peak conditions subtable
   16293         245 : void CollectPeakZoneConditions(
   16294             :     EnergyPlusData &state, CompLoadTablesType &compLoad, int const desDaySelected, int const timeOfMax, int const zoneIndex, bool const isCooling)
   16295             : {
   16296             : 
   16297         245 :     if (timeOfMax != 0) {
   16298             : 
   16299         245 :         auto &zone = state.dataHeatBal->Zone(zoneIndex);
   16300         245 :         auto &calcFinalZoneSizing = state.dataSize->CalcFinalZoneSizing(zoneIndex);
   16301             : 
   16302         245 :         Real64 mult = zone.Multiplier * zone.ListMultiplier;
   16303         245 :         if (mult == 0.0) mult = 1.0;
   16304             : 
   16305         245 :         if (isCooling) {
   16306             :             // Time of Peak Load
   16307         125 :             if ((size_t)desDaySelected <= state.dataWeatherManager->DesDayInput.size()) {
   16308         625 :                 compLoad.peakDateHrMin = format("{}/{} {}",
   16309         125 :                                                 state.dataWeatherManager->DesDayInput(desDaySelected).Month,
   16310         125 :                                                 state.dataWeatherManager->DesDayInput(desDaySelected).DayOfMonth,
   16311         375 :                                                 state.dataRptCoilSelection->coilSelectionReportObj->getTimeText(state, timeOfMax));
   16312             :             } else {
   16313           0 :                 compLoad.peakDateHrMin = state.dataSize->CoolPeakDateHrMin(zoneIndex);
   16314             :             }
   16315             : 
   16316             :             // Outside Dry Bulb Temperature
   16317         125 :             compLoad.outsideDryBulb = calcFinalZoneSizing.CoolOutTempSeq(timeOfMax);
   16318             : 
   16319             :             // Outside Wet Bulb Temperature
   16320             :             // use standard air pressure because air pressure is not tracked with sizing data
   16321         125 :             if (calcFinalZoneSizing.CoolOutHumRatSeq(timeOfMax) < 1.0 && calcFinalZoneSizing.CoolOutHumRatSeq(timeOfMax) > 0.0) {
   16322         375 :                 compLoad.outsideWetBulb = Psychrometrics::PsyTwbFnTdbWPb(state,
   16323         125 :                                                                          calcFinalZoneSizing.CoolOutTempSeq(timeOfMax),
   16324         125 :                                                                          calcFinalZoneSizing.CoolOutHumRatSeq(timeOfMax),
   16325         125 :                                                                          state.dataEnvrn->StdBaroPress);
   16326             :             }
   16327             : 
   16328             :             // Outside Humidity Ratio at Peak
   16329         125 :             compLoad.outsideHumRatio = calcFinalZoneSizing.CoolOutHumRatSeq(timeOfMax);
   16330             : 
   16331             :             // Zone Dry Bulb Temperature
   16332         125 :             compLoad.zoneDryBulb = calcFinalZoneSizing.CoolZoneTempSeq(timeOfMax);
   16333             : 
   16334             :             // Zone Relative Humdity
   16335             :             // use standard air pressure because air pressure is not tracked with sizing data
   16336         375 :             compLoad.zoneRelHum = Psychrometrics::PsyRhFnTdbWPb(state,
   16337         125 :                                                                 calcFinalZoneSizing.CoolZoneTempSeq(timeOfMax),
   16338         125 :                                                                 calcFinalZoneSizing.CoolZoneHumRatSeq(timeOfMax),
   16339         125 :                                                                 state.dataEnvrn->StdBaroPress);
   16340             : 
   16341             :             // Zone Humidity Ratio at Peak
   16342         125 :             compLoad.zoneHumRatio = calcFinalZoneSizing.CoolZoneHumRatSeq(timeOfMax);
   16343             : 
   16344             :             // Peak Design Sensible Load
   16345         125 :             compLoad.peakDesSensLoad = calcFinalZoneSizing.DesCoolLoad / mult; // change sign
   16346             : 
   16347             :             // Design Peak Load
   16348         125 :             compLoad.designPeakLoad = state.dataSize->FinalZoneSizing(zoneIndex).DesCoolLoad / mult;
   16349             : 
   16350             :             // Supply air temperature
   16351         125 :             if (calcFinalZoneSizing.ZnCoolDgnSAMethod == DataSizing::SupplyAirTemperature) {
   16352         125 :                 compLoad.supAirTemp = calcFinalZoneSizing.CoolDesTemp;
   16353             :             } else {
   16354           0 :                 Real64 DeltaTemp = -std::abs(calcFinalZoneSizing.CoolDesTempDiff);
   16355           0 :                 compLoad.supAirTemp = DeltaTemp + calcFinalZoneSizing.ZoneTempAtCoolPeak;
   16356             :             }
   16357             : 
   16358             :             // Main fan air flow
   16359         125 :             compLoad.mainFanAirFlow = calcFinalZoneSizing.DesCoolVolFlow;
   16360             : 
   16361             :         } else {
   16362             :             // Time of Peak Load
   16363         120 :             if ((size_t)desDaySelected <= state.dataWeatherManager->DesDayInput.size()) {
   16364         600 :                 compLoad.peakDateHrMin = format("{}/{} {}",
   16365         120 :                                                 state.dataWeatherManager->DesDayInput(desDaySelected).Month,
   16366         120 :                                                 state.dataWeatherManager->DesDayInput(desDaySelected).DayOfMonth,
   16367         360 :                                                 state.dataRptCoilSelection->coilSelectionReportObj->getTimeText(state, timeOfMax));
   16368             :             } else {
   16369           0 :                 compLoad.peakDateHrMin = state.dataSize->HeatPeakDateHrMin(zoneIndex);
   16370             :             }
   16371             : 
   16372             :             // Outside Dry Bulb Temperature
   16373         120 :             compLoad.outsideDryBulb = calcFinalZoneSizing.HeatOutTempSeq(timeOfMax);
   16374             : 
   16375             :             // Outside Wet Bulb Temperature
   16376             :             // use standard air pressure because air pressure is not tracked with sizing data
   16377         120 :             if (calcFinalZoneSizing.HeatOutHumRatSeq(timeOfMax) < 1.0 && calcFinalZoneSizing.HeatOutHumRatSeq(timeOfMax) > 0.0) {
   16378         360 :                 compLoad.outsideWetBulb = Psychrometrics::PsyTwbFnTdbWPb(state,
   16379         120 :                                                                          calcFinalZoneSizing.HeatOutTempSeq(timeOfMax),
   16380         120 :                                                                          calcFinalZoneSizing.HeatOutHumRatSeq(timeOfMax),
   16381         120 :                                                                          state.dataEnvrn->StdBaroPress);
   16382             :             }
   16383             : 
   16384             :             // Outside Humidity Ratio at Peak
   16385         120 :             compLoad.outsideHumRatio = calcFinalZoneSizing.HeatOutHumRatSeq(timeOfMax);
   16386             : 
   16387             :             // Zone Dry Bulb Temperature
   16388         120 :             compLoad.zoneDryBulb = calcFinalZoneSizing.HeatZoneTempSeq(timeOfMax);
   16389             : 
   16390             :             // Zone Relative Humdity
   16391             :             // use standard air pressure because air pressure is not tracked with sizing data
   16392         360 :             compLoad.zoneRelHum = Psychrometrics::PsyRhFnTdbWPb(state,
   16393         120 :                                                                 calcFinalZoneSizing.HeatZoneTempSeq(timeOfMax),
   16394         120 :                                                                 calcFinalZoneSizing.HeatZoneHumRatSeq(timeOfMax),
   16395         120 :                                                                 state.dataEnvrn->StdBaroPress);
   16396             : 
   16397             :             // Zone Humidity Ratio at Peak
   16398         120 :             compLoad.zoneHumRatio = calcFinalZoneSizing.HeatZoneHumRatSeq(timeOfMax);
   16399             : 
   16400             :             // Peak Design Sensible Load
   16401         120 :             compLoad.peakDesSensLoad = -calcFinalZoneSizing.DesHeatLoad / mult; // change sign
   16402             : 
   16403             :             // Design Peak Load
   16404         120 :             compLoad.designPeakLoad = -state.dataSize->FinalZoneSizing(zoneIndex).DesHeatLoad / mult;
   16405             : 
   16406             :             // Supply air temperature
   16407         120 :             if (calcFinalZoneSizing.ZnHeatDgnSAMethod == DataSizing::SupplyAirTemperature) {
   16408         120 :                 compLoad.supAirTemp = calcFinalZoneSizing.HeatDesTemp;
   16409             :             } else {
   16410           0 :                 Real64 DeltaTemp = -std::abs(calcFinalZoneSizing.HeatDesTempDiff);
   16411           0 :                 compLoad.supAirTemp = DeltaTemp + calcFinalZoneSizing.ZoneTempAtHeatPeak;
   16412             :             }
   16413             : 
   16414             :             // Main fan air flow
   16415         120 :             compLoad.mainFanAirFlow = calcFinalZoneSizing.DesHeatVolFlow;
   16416             :         }
   16417             : 
   16418             :         // Outside air flow
   16419         245 :         compLoad.outsideAirFlow = calcFinalZoneSizing.MinOA;
   16420             : 
   16421             :         // outside air %
   16422         245 :         if (compLoad.mainFanAirFlow != 0.) {
   16423         245 :             compLoad.outsideAirRatio = compLoad.outsideAirFlow / compLoad.mainFanAirFlow;
   16424             :         }
   16425             : 
   16426         245 :         compLoad.floorArea = zone.FloorArea;
   16427             : 
   16428         245 :         if (compLoad.floorArea != 0.) {
   16429             :             // airflow per floor area
   16430         245 :             compLoad.airflowPerFlrArea = compLoad.mainFanAirFlow / compLoad.floorArea;
   16431             : 
   16432             :             // capacity per floor area
   16433         245 :             compLoad.totCapPerArea = compLoad.designPeakLoad / compLoad.floorArea;
   16434             :         }
   16435         245 :         if (compLoad.designPeakLoad != 0.) {
   16436             :             // airflow per capacity
   16437         245 :             compLoad.airflowPerTotCap = compLoad.mainFanAirFlow / compLoad.designPeakLoad;
   16438             : 
   16439             :             // floor area per capacity
   16440         245 :             compLoad.areaPerTotCap = zone.FloorArea / compLoad.designPeakLoad;
   16441             :         }
   16442             : 
   16443             :         // Number of people
   16444         245 :         Real64 totNumPeople = 0.;
   16445        1600 :         for (auto &people : state.dataHeatBal->People) {
   16446        1355 :             if (zoneIndex == people.ZonePtr) {
   16447         271 :                 totNumPeople += people.NumberOfPeople;
   16448             :             }
   16449             :         }
   16450         245 :         compLoad.numPeople = totNumPeople;
   16451             :     }
   16452         245 : }
   16453             : 
   16454           4 : void ComputeEngineeringChecks(CompLoadTablesType &compLoad)
   16455             : {
   16456             :     // outside air %
   16457           4 :     if (compLoad.mainFanAirFlow != 0.) {
   16458           4 :         compLoad.outsideAirRatio = compLoad.outsideAirFlow / compLoad.mainFanAirFlow;
   16459             :     }
   16460             : 
   16461           4 :     if (compLoad.floorArea != 0.) {
   16462             :         // airflow per floor area
   16463           4 :         compLoad.airflowPerFlrArea = compLoad.mainFanAirFlow / compLoad.floorArea;
   16464             : 
   16465             :         // capacity per floor area
   16466           4 :         compLoad.totCapPerArea = compLoad.designPeakLoad / compLoad.floorArea;
   16467             :     }
   16468           4 :     if (compLoad.designPeakLoad != 0.) {
   16469             :         // airflow per capacity
   16470           4 :         compLoad.airflowPerTotCap = compLoad.mainFanAirFlow / compLoad.designPeakLoad;
   16471             : 
   16472             :         // floor area per capacity
   16473           4 :         compLoad.areaPerTotCap = compLoad.floorArea / compLoad.designPeakLoad;
   16474             :     }
   16475           4 : }
   16476             : 
   16477             : // gather the areas used in the load component tables
   16478          23 : void GetZoneComponentAreas(EnergyPlusData &state, Array1D<ZompComponentAreasType> &areas)
   16479             : {
   16480             :     using namespace DataSurfaces;
   16481             : 
   16482         161 :     for (int iZone = 1; iZone <= state.dataGlobal->NumOfZones; ++iZone) {
   16483         138 :         areas(iZone).floor = state.dataHeatBal->Zone(iZone).FloorArea;
   16484             :     }
   16485             : 
   16486        1082 :     for (auto curSurface : state.dataSurface->Surface) {
   16487        1165 :         if (!curSurface.HeatTransSurf) continue;
   16488        1059 :         bool isExterior = curSurface.ExtBoundCond == ExternalEnvironment || curSurface.ExtBoundCond == OtherSideCondModeledExt;
   16489        1059 :         bool isTouchingGround =
   16490        1059 :             curSurface.ExtBoundCond == Ground || curSurface.ExtBoundCond == GroundFCfactorMethod || curSurface.ExtBoundCond == KivaFoundation;
   16491        1059 :         int curZoneIndex = curSurface.Zone;
   16492             :         // ZoneData curZone = Zone(curSurface.Zone);
   16493        1059 :         if (curSurface.Class == SurfaceClass::Wall) {
   16494         546 :             if (isExterior) {
   16495         186 :                 areas(curZoneIndex).extWall += curSurface.GrossArea;
   16496         360 :             } else if (isTouchingGround) {
   16497           0 :                 areas(curZoneIndex).grndCntWall += curSurface.GrossArea;
   16498             :             } else {
   16499         360 :                 areas(curZoneIndex).intZoneWall += curSurface.GrossArea;
   16500             :             }
   16501         513 :         } else if (curSurface.Class == SurfaceClass::Roof) {
   16502         140 :             if (isExterior) {
   16503          23 :                 areas(curZoneIndex).roof += curSurface.GrossArea;
   16504             :             } else {
   16505         117 :                 areas(curZoneIndex).ceiling += curSurface.GrossArea;
   16506             :             }
   16507         373 :         } else if (curSurface.Class == SurfaceClass::Floor) {
   16508         235 :             if (isExterior) {
   16509           0 :                 areas(curZoneIndex).extFloor += curSurface.GrossArea;
   16510         235 :             } else if (isTouchingGround) {
   16511         118 :                 areas(curZoneIndex).grndCntFloor += curSurface.GrossArea;
   16512             :             } else {
   16513         117 :                 areas(curZoneIndex).intZoneFloor += curSurface.GrossArea;
   16514             :             }
   16515         138 :         } else if (curSurface.Class == SurfaceClass::Window || curSurface.Class == SurfaceClass::TDD_Dome) {
   16516         138 :             areas(curZoneIndex).fenestration += curSurface.GrossArea;
   16517           0 :         } else if (curSurface.Class == SurfaceClass::Door || curSurface.Class == SurfaceClass::GlassDoor) {
   16518           0 :             areas(curZoneIndex).door += curSurface.GrossArea;
   16519             :         }
   16520             :     }
   16521          23 : }
   16522             : 
   16523             : // adds the area column for the load component tables
   16524         245 : void AddAreaColumnForZone(int const zoneNum, Array1D<ZompComponentAreasType> const &compAreas, CompLoadTablesType &compLoad)
   16525             : {
   16526         245 :     compLoad.cells(LoadCompCol::Area, LoadCompRow::People) = compAreas(zoneNum).floor;
   16527         245 :     compLoad.cellUsed(LoadCompCol::Area, LoadCompRow::People) = true;
   16528             : 
   16529         245 :     compLoad.cells(LoadCompCol::Area, LoadCompRow::Lights) = compAreas(zoneNum).floor;
   16530         245 :     compLoad.cellUsed(LoadCompCol::Area, LoadCompRow::Lights) = true;
   16531             : 
   16532         245 :     compLoad.cells(LoadCompCol::Area, LoadCompRow::Equip) = compAreas(zoneNum).floor;
   16533         245 :     compLoad.cellUsed(LoadCompCol::Area, LoadCompRow::Equip) = true;
   16534             : 
   16535         245 :     compLoad.cells(LoadCompCol::Area, LoadCompRow::Refrig) = compAreas(zoneNum).floor;
   16536         245 :     compLoad.cellUsed(LoadCompCol::Area, LoadCompRow::Refrig) = true;
   16537             : 
   16538         245 :     compLoad.cells(LoadCompCol::Area, LoadCompRow::WaterUse) = compAreas(zoneNum).floor;
   16539         245 :     compLoad.cellUsed(LoadCompCol::Area, LoadCompRow::WaterUse) = true;
   16540             : 
   16541         245 :     compLoad.cells(LoadCompCol::Area, LoadCompRow::Infil) = compAreas(zoneNum).extWall;
   16542         245 :     compLoad.cellUsed(LoadCompCol::Area, LoadCompRow::Infil) = true;
   16543             : 
   16544         245 :     compLoad.cells(LoadCompCol::Area, LoadCompRow::Roof) = compAreas(zoneNum).roof;
   16545         245 :     compLoad.cellUsed(LoadCompCol::Area, LoadCompRow::Roof) = true;
   16546             : 
   16547         245 :     compLoad.cells(LoadCompCol::Area, LoadCompRow::IntZonCeil) = compAreas(zoneNum).ceiling;
   16548         245 :     compLoad.cellUsed(LoadCompCol::Area, LoadCompRow::IntZonCeil) = true;
   16549             : 
   16550         245 :     compLoad.cells(LoadCompCol::Area, LoadCompRow::OtherRoof) = compAreas(zoneNum).roof;
   16551         245 :     compLoad.cellUsed(LoadCompCol::Area, LoadCompRow::OtherRoof) = true;
   16552             : 
   16553         245 :     compLoad.cells(LoadCompCol::Area, LoadCompRow::ExtWall) = compAreas(zoneNum).extWall;
   16554         245 :     compLoad.cellUsed(LoadCompCol::Area, LoadCompRow::ExtWall) = true;
   16555             : 
   16556         245 :     compLoad.cells(LoadCompCol::Area, LoadCompRow::IntZonWall) = compAreas(zoneNum).intZoneWall;
   16557         245 :     compLoad.cellUsed(LoadCompCol::Area, LoadCompRow::IntZonWall) = true;
   16558             : 
   16559         245 :     compLoad.cells(LoadCompCol::Area, LoadCompRow::GrdWall) = compAreas(zoneNum).grndCntWall;
   16560         245 :     compLoad.cellUsed(LoadCompCol::Area, LoadCompRow::GrdWall) = true;
   16561             : 
   16562         245 :     compLoad.cells(LoadCompCol::Area, LoadCompRow::OtherWall) = compAreas(zoneNum).extWall;
   16563         245 :     compLoad.cellUsed(LoadCompCol::Area, LoadCompRow::OtherWall) = true;
   16564             : 
   16565         245 :     compLoad.cells(LoadCompCol::Area, LoadCompRow::ExtFlr) = compAreas(zoneNum).extFloor;
   16566         245 :     compLoad.cellUsed(LoadCompCol::Area, LoadCompRow::ExtFlr) = true;
   16567             : 
   16568         245 :     compLoad.cells(LoadCompCol::Area, LoadCompRow::IntZonFlr) = compAreas(zoneNum).intZoneFloor;
   16569         245 :     compLoad.cellUsed(LoadCompCol::Area, LoadCompRow::IntZonFlr) = true;
   16570             : 
   16571         245 :     compLoad.cells(LoadCompCol::Area, LoadCompRow::GrdFlr) = compAreas(zoneNum).grndCntFloor;
   16572         245 :     compLoad.cellUsed(LoadCompCol::Area, LoadCompRow::GrdFlr) = true;
   16573             : 
   16574         245 :     compLoad.cells(LoadCompCol::Area, LoadCompRow::OtherFlr) = compAreas(zoneNum).intZoneFloor;
   16575         245 :     compLoad.cellUsed(LoadCompCol::Area, LoadCompRow::OtherFlr) = true;
   16576             : 
   16577         245 :     compLoad.cells(LoadCompCol::Area, LoadCompRow::FeneCond) = compAreas(zoneNum).fenestration;
   16578         245 :     compLoad.cellUsed(LoadCompCol::Area, LoadCompRow::FeneCond) = true;
   16579             : 
   16580         245 :     compLoad.cells(LoadCompCol::Area, LoadCompRow::FeneSolr) = compAreas(zoneNum).fenestration;
   16581         245 :     compLoad.cellUsed(LoadCompCol::Area, LoadCompRow::FeneSolr) = true;
   16582             : 
   16583         245 :     compLoad.cells(LoadCompCol::Area, LoadCompRow::OpqDoor) = compAreas(zoneNum).door;
   16584         245 :     compLoad.cellUsed(LoadCompCol::Area, LoadCompRow::OpqDoor) = true;
   16585         245 : }
   16586             : 
   16587             : // Used for the AirLoop and Facility level load component tables to sum the results from invidual zones
   16588          20 : void CombineLoadCompResults(CompLoadTablesType &compLoadTotal, CompLoadTablesType const &compLoadPartial, Real64 const multiplier)
   16589             : {
   16590             :     // sum the main results
   16591         180 :     for (int col = 1; col <= LoadCompCol::PerArea; ++col) {
   16592        4320 :         for (int row = 1; row <= LoadCompRow::GrdTot; ++row) {
   16593        4160 :             compLoadTotal.cells(col, row) += compLoadPartial.cells(col, row) * multiplier;
   16594        4160 :             compLoadTotal.cellUsed(col, row) = compLoadTotal.cellUsed(col, row) || compLoadPartial.cellUsed(col, row);
   16595             :         }
   16596             :     }
   16597             : 
   16598             :     // take the partial value for these
   16599          20 :     compLoadTotal.desDayNum = compLoadPartial.desDayNum;
   16600          20 :     compLoadTotal.timeStepMax = compLoadPartial.timeStepMax;
   16601          20 :     compLoadTotal.peakDateHrMin = compLoadPartial.peakDateHrMin;
   16602          20 :     compLoadTotal.outsideDryBulb = compLoadPartial.outsideDryBulb;
   16603          20 :     compLoadTotal.outsideWetBulb = compLoadPartial.outsideWetBulb;
   16604          20 :     compLoadTotal.outsideHumRatio = compLoadPartial.outsideHumRatio;
   16605          20 :     compLoadTotal.zoneDryBulb = compLoadPartial.zoneDryBulb;
   16606          20 :     compLoadTotal.zoneRelHum = compLoadPartial.zoneRelHum;
   16607          20 :     compLoadTotal.zoneHumRatio = compLoadPartial.zoneHumRatio;
   16608          20 :     compLoadTotal.supAirTemp = compLoadPartial.supAirTemp;
   16609             : 
   16610             :     // sum the peak related values
   16611          20 :     compLoadTotal.designPeakLoad += compLoadPartial.designPeakLoad * multiplier;
   16612          20 :     compLoadTotal.diffDesignPeak += compLoadPartial.diffDesignPeak * multiplier;
   16613          20 :     compLoadTotal.peakDesSensLoad += compLoadPartial.peakDesSensLoad * multiplier;
   16614          20 :     compLoadTotal.estInstDelSensLoad += compLoadPartial.estInstDelSensLoad * multiplier;
   16615          20 :     compLoadTotal.diffPeakEst += compLoadPartial.diffPeakEst * multiplier;
   16616          20 :     compLoadTotal.mainFanAirFlow += compLoadPartial.mainFanAirFlow * multiplier;
   16617          20 :     compLoadTotal.outsideAirFlow += compLoadPartial.outsideAirFlow * multiplier;
   16618             : 
   16619             :     // sum the engineering checks
   16620          20 :     compLoadTotal.numPeople += compLoadPartial.numPeople * multiplier;
   16621          20 :     compLoadTotal.floorArea += compLoadPartial.floorArea * multiplier;
   16622          20 : }
   16623             : 
   16624             : // create the total row and total columns for the load summary tables
   16625         234 : void AddTotalRowsForLoadSummary(CompLoadTablesType &compLoadTotal)
   16626             : {
   16627             : 
   16628             :     // zero the grand total -total cell
   16629         234 :     compLoadTotal.cells(LoadCompCol::Total, LoadCompRow::GrdTot) = 0.;
   16630         234 :     compLoadTotal.cellUsed(LoadCompCol::Total, LoadCompRow::GrdTot) = true;
   16631             : 
   16632             :     // zero the grand total row
   16633        1170 :     for (int col = 1; col <= LoadCompCol::Latent; ++col) {
   16634         936 :         compLoadTotal.cells(col, LoadCompRow::GrdTot) = 0.;
   16635         936 :         compLoadTotal.cellUsed(col, LoadCompRow::GrdTot) = true;
   16636             :     }
   16637             : 
   16638        6084 :     for (int row = 1; row <= LoadCompRow::OpqDoor; ++row) {
   16639             :         // zero the total column
   16640        5850 :         compLoadTotal.cells(LoadCompCol::Total, row) = 0.;
   16641        5850 :         compLoadTotal.cellUsed(LoadCompCol::Total, row) = true;
   16642       29250 :         for (int col = 1; col <= LoadCompCol::Latent; ++col) {
   16643             :             // add the cell to the grand total row and total column
   16644       23400 :             if (compLoadTotal.cellUsed(col, row)) {
   16645        9360 :                 compLoadTotal.cells(LoadCompCol::Total, row) += compLoadTotal.cells(col, row);
   16646        9360 :                 compLoadTotal.cells(col, LoadCompRow::GrdTot) += compLoadTotal.cells(col, row);
   16647        9360 :                 compLoadTotal.cells(LoadCompCol::Total, LoadCompRow::GrdTot) += compLoadTotal.cells(col, row);
   16648             :             }
   16649             :         }
   16650             :     }
   16651             : 
   16652             :     // compute the % grand total column
   16653         234 :     Real64 grandTotalTotal = compLoadTotal.cells(LoadCompCol::Total, LoadCompRow::GrdTot);
   16654         234 :     if (grandTotalTotal != 0.0) {
   16655        6084 :         for (int row = 1; row <= LoadCompRow::OpqDoor; ++row) {
   16656        5850 :             compLoadTotal.cells(LoadCompCol::Perc, row) = 100 * compLoadTotal.cells(LoadCompCol::Total, row) / grandTotalTotal;
   16657        5850 :             compLoadTotal.cellUsed(LoadCompCol::Perc, row) = true;
   16658             :         }
   16659             :     }
   16660             :     // compute the Total per Area column
   16661        6084 :     for (int row = 1; row <= LoadCompRow::OpqDoor; ++row) {
   16662        5850 :         if (compLoadTotal.cellUsed(LoadCompCol::Total, row) && compLoadTotal.cells(LoadCompCol::Area, row) != 0.) {
   16663        2812 :             compLoadTotal.cells(LoadCompCol::PerArea, row) =
   16664        2812 :                 compLoadTotal.cells(LoadCompCol::Total, row) / compLoadTotal.cells(LoadCompCol::Area, row);
   16665        2812 :             compLoadTotal.cellUsed(LoadCompCol::PerArea, row) = true;
   16666             :         }
   16667             :     }
   16668         234 : }
   16669             : 
   16670             : // compute the peak difference between actual and estimated load in load component summary peak conditions table
   16671         234 : void ComputePeakDifference(CompLoadTablesType &compLoad)
   16672             : {
   16673             :     // Estimated Instant + Delayed Sensible Load
   16674         234 :     compLoad.estInstDelSensLoad =
   16675         234 :         compLoad.cells(LoadCompCol::SensInst, LoadCompRow::GrdTot) + compLoad.cells(LoadCompCol::SensDelay, LoadCompRow::GrdTot);
   16676             : 
   16677             :     // Difference
   16678         234 :     compLoad.diffPeakEst = compLoad.peakDesSensLoad - compLoad.estInstDelSensLoad;
   16679             : 
   16680             :     // Peak Design Diff
   16681         234 :     compLoad.diffDesignPeak = compLoad.designPeakLoad - compLoad.peakDesSensLoad;
   16682         234 : }
   16683             : 
   16684             : // apply unit conversions to the load components summary tables
   16685           0 : void LoadSummaryUnitConversion(EnergyPlusData &state, CompLoadTablesType &compLoadTotal)
   16686             : {
   16687           0 :     auto &ort(state.dataOutRptTab);
   16688             : 
   16689           0 :     if (ort->unitsStyle == UnitsStyle::InchPound) {
   16690           0 :         Real64 powerConversion = getSpecificUnitMultiplier(state, "W", "Btu/h");
   16691           0 :         Real64 areaConversion = getSpecificUnitMultiplier(state, "m2", "ft2");
   16692           0 :         Real64 powerPerAreaConversion = getSpecificUnitMultiplier(state, "W/m2", "Btu/h-ft2");
   16693           0 :         Real64 airFlowConversion = getSpecificUnitMultiplier(state, "m3/s", "ft3/min");
   16694           0 :         Real64 airFlowPerAreaConversion = getSpecificUnitMultiplier(state, "m3/s-m2", "ft3/min-ft2");
   16695           0 :         Real64 powerPerFlowLiquidConversion = getSpecificUnitMultiplier(state, "W-s/m3", "W-min/gal");
   16696           0 :         for (int row = 1; row <= LoadCompRow::GrdTot; ++row) {
   16697           0 :             for (int col = 1; col <= LoadCompCol::Total; ++col) {
   16698           0 :                 if (compLoadTotal.cellUsed(col, row)) {
   16699           0 :                     compLoadTotal.cells(col, row) *= powerConversion;
   16700             :                 }
   16701             :             }
   16702           0 :             if (compLoadTotal.cellUsed(LoadCompCol::PerArea, row)) {
   16703           0 :                 compLoadTotal.cells(LoadCompCol::PerArea, row) *= powerConversion;
   16704             :             }
   16705           0 :             if (compLoadTotal.cellUsed(LoadCompCol::Area, row)) {
   16706           0 :                 compLoadTotal.cells(LoadCompCol::Area, row) *= areaConversion;
   16707             :             }
   16708           0 :             if (compLoadTotal.cellUsed(LoadCompCol::PerArea, row)) {
   16709           0 :                 compLoadTotal.cells(LoadCompCol::PerArea, row) *= powerPerAreaConversion;
   16710             :             }
   16711             :         }
   16712           0 :         int tempConvIndx = getSpecificUnitIndex(state, "C", "F");
   16713           0 :         compLoadTotal.outsideDryBulb = ConvertIP(state, tempConvIndx, compLoadTotal.outsideDryBulb);
   16714           0 :         compLoadTotal.outsideWetBulb = ConvertIP(state, tempConvIndx, compLoadTotal.outsideWetBulb);
   16715           0 :         compLoadTotal.zoneDryBulb = ConvertIP(state, tempConvIndx, compLoadTotal.zoneDryBulb);
   16716           0 :         compLoadTotal.peakDesSensLoad *= powerConversion;
   16717             : 
   16718           0 :         compLoadTotal.supAirTemp = ConvertIP(state, tempConvIndx, compLoadTotal.supAirTemp);
   16719           0 :         compLoadTotal.mixAirTemp = ConvertIP(state, tempConvIndx, compLoadTotal.mixAirTemp);
   16720           0 :         compLoadTotal.mainFanAirFlow *= airFlowConversion;
   16721           0 :         compLoadTotal.outsideAirFlow *= airFlowConversion;
   16722           0 :         compLoadTotal.designPeakLoad *= powerConversion;
   16723           0 :         compLoadTotal.diffDesignPeak *= powerConversion;
   16724             : 
   16725           0 :         compLoadTotal.estInstDelSensLoad *= powerConversion;
   16726           0 :         compLoadTotal.diffPeakEst *= powerConversion;
   16727             : 
   16728           0 :         compLoadTotal.airflowPerFlrArea *= airFlowPerAreaConversion;
   16729           0 :         if (powerConversion != 0.) {
   16730           0 :             compLoadTotal.airflowPerTotCap = compLoadTotal.airflowPerTotCap * airFlowPerAreaConversion / powerConversion;
   16731           0 :             compLoadTotal.areaPerTotCap = compLoadTotal.areaPerTotCap * areaConversion / powerConversion;
   16732             :         }
   16733           0 :         if (areaConversion != 0.) {
   16734           0 :             compLoadTotal.totCapPerArea = compLoadTotal.totCapPerArea * powerConversion / areaConversion;
   16735             :         }
   16736           0 :         compLoadTotal.chlPumpPerFlow *= powerPerFlowLiquidConversion;
   16737           0 :         compLoadTotal.cndPumpPerFlow *= powerPerFlowLiquidConversion;
   16738             :     }
   16739           0 : }
   16740             : 
   16741             : // Jan 2021: Overloaded the function with addtional parameters for dual units;
   16742             : //           used overloading since the original function was checked in an existing test unit.
   16743             : // apply unit conversions to the load components summary tables
   16744         234 : void LoadSummaryUnitConversion(EnergyPlusData &state, CompLoadTablesType &compLoadTotal, UnitsStyle unitsStyle_para)
   16745             : {
   16746             :     // auto &ort(state.dataOutRptTab);
   16747             : 
   16748         234 :     if (unitsStyle_para == UnitsStyle::InchPound) {
   16749           0 :         Real64 powerConversion = getSpecificUnitMultiplier(state, "W", "Btu/h");
   16750           0 :         Real64 areaConversion = getSpecificUnitMultiplier(state, "m2", "ft2");
   16751           0 :         Real64 powerPerAreaConversion = getSpecificUnitMultiplier(state, "W/m2", "Btu/h-ft2");
   16752           0 :         Real64 airFlowConversion = getSpecificUnitMultiplier(state, "m3/s", "ft3/min");
   16753           0 :         Real64 airFlowPerAreaConversion = getSpecificUnitMultiplier(state, "m3/s-m2", "ft3/min-ft2");
   16754           0 :         Real64 powerPerFlowLiquidConversion = getSpecificUnitMultiplier(state, "W-s/m3", "W-min/gal");
   16755           0 :         for (int row = 1; row <= LoadCompRow::GrdTot; ++row) {
   16756           0 :             for (int col = 1; col <= LoadCompCol::Total; ++col) {
   16757           0 :                 if (compLoadTotal.cellUsed(col, row)) {
   16758           0 :                     compLoadTotal.cells(col, row) *= powerConversion;
   16759             :                 }
   16760             :             }
   16761           0 :             if (compLoadTotal.cellUsed(LoadCompCol::PerArea, row)) {
   16762           0 :                 compLoadTotal.cells(LoadCompCol::PerArea, row) *= powerConversion;
   16763             :             }
   16764           0 :             if (compLoadTotal.cellUsed(LoadCompCol::Area, row)) {
   16765           0 :                 compLoadTotal.cells(LoadCompCol::Area, row) *= areaConversion;
   16766             :             }
   16767           0 :             if (compLoadTotal.cellUsed(LoadCompCol::PerArea, row)) {
   16768           0 :                 compLoadTotal.cells(LoadCompCol::PerArea, row) *= powerPerAreaConversion;
   16769             :             }
   16770             :         }
   16771           0 :         int tempConvIndx = getSpecificUnitIndex(state, "C", "F");
   16772           0 :         compLoadTotal.outsideDryBulb = ConvertIP(state, tempConvIndx, compLoadTotal.outsideDryBulb);
   16773           0 :         compLoadTotal.outsideWetBulb = ConvertIP(state, tempConvIndx, compLoadTotal.outsideWetBulb);
   16774           0 :         compLoadTotal.zoneDryBulb = ConvertIP(state, tempConvIndx, compLoadTotal.zoneDryBulb);
   16775           0 :         compLoadTotal.peakDesSensLoad *= powerConversion;
   16776             : 
   16777           0 :         compLoadTotal.supAirTemp = ConvertIP(state, tempConvIndx, compLoadTotal.supAirTemp);
   16778           0 :         compLoadTotal.mixAirTemp = ConvertIP(state, tempConvIndx, compLoadTotal.mixAirTemp);
   16779           0 :         compLoadTotal.mainFanAirFlow *= airFlowConversion;
   16780           0 :         compLoadTotal.outsideAirFlow *= airFlowConversion;
   16781           0 :         compLoadTotal.designPeakLoad *= powerConversion;
   16782           0 :         compLoadTotal.diffDesignPeak *= powerConversion;
   16783             : 
   16784           0 :         compLoadTotal.estInstDelSensLoad *= powerConversion;
   16785           0 :         compLoadTotal.diffPeakEst *= powerConversion;
   16786             : 
   16787           0 :         compLoadTotal.airflowPerFlrArea *= airFlowPerAreaConversion;
   16788           0 :         if (powerConversion != 0.) {
   16789           0 :             compLoadTotal.airflowPerTotCap = compLoadTotal.airflowPerTotCap * airFlowPerAreaConversion / powerConversion;
   16790           0 :             compLoadTotal.areaPerTotCap = compLoadTotal.areaPerTotCap * areaConversion / powerConversion;
   16791             :         }
   16792           0 :         if (areaConversion != 0.) {
   16793           0 :             compLoadTotal.totCapPerArea = compLoadTotal.totCapPerArea * powerConversion / areaConversion;
   16794             :         }
   16795           0 :         compLoadTotal.chlPumpPerFlow *= powerPerFlowLiquidConversion;
   16796           0 :         compLoadTotal.cndPumpPerFlow *= powerPerFlowLiquidConversion;
   16797             :     }
   16798         234 : }
   16799             : 
   16800             : // make a list of the zones for the airloop component loads report
   16801           2 : void CreateListOfZonesForAirLoop(EnergyPlusData &state, CompLoadTablesType &compLoad, Array1D_int const &zoneToAirLoop, int const curAirLoop)
   16802             : {
   16803           2 :     int counter = 0;
   16804          14 :     for (int zi = 1; zi <= state.dataGlobal->NumOfZones; ++zi) {
   16805          12 :         if (zoneToAirLoop(zi) == curAirLoop) {
   16806          10 :             ++counter;
   16807          10 :             compLoad.zoneIndices(counter) = zi;
   16808             :         }
   16809             :     }
   16810           2 : }
   16811             : 
   16812             : // Jan 2021: Added additional parameters to accommodate dual-unit reporting
   16813             : // provide output from the load component summary tables
   16814         117 : void OutputCompLoadSummary(EnergyPlusData &state,
   16815             :                            EnergyPlus::OutputReportTabular::OutputType const kind,
   16816             :                            CompLoadTablesType const &compLoadCool,
   16817             :                            CompLoadTablesType const &compLoadHeat,
   16818             :                            int const zoneOrAirLoopIndex,
   16819             :                            UnitsStyle unitsStyle_para,
   16820             :                            bool produceTabular_para,
   16821             :                            bool produceSQLite_para)
   16822             : {
   16823         234 :     CompLoadTablesType curCompLoad;
   16824             :     bool writeOutput;
   16825         234 :     Array1D_string columnHead;
   16826         234 :     Array1D_int columnWidth;
   16827         234 :     Array1D_string rowHead;
   16828         234 :     Array2D_string tableBody; //(row, column)
   16829             : 
   16830         234 :     std::string reportName;
   16831         234 :     std::string zoneAirLoopFacilityName;
   16832             : 
   16833         117 :     auto &ort(state.dataOutRptTab);
   16834             : 
   16835         117 :     if (kind == OutputType::Zone && ort->displayZoneComponentLoadSummary) {
   16836         115 :         reportName = "Zone Component Load Summary";
   16837         115 :         zoneAirLoopFacilityName = state.dataHeatBal->Zone(zoneOrAirLoopIndex).Name;
   16838         115 :         writeOutput = true;
   16839           2 :     } else if (kind == OutputType::AirLoop && ort->displayAirLoopComponentLoadSummary) {
   16840           1 :         reportName = "AirLoop Component Load Summary";
   16841           1 :         zoneAirLoopFacilityName = state.dataSize->FinalSysSizing(zoneOrAirLoopIndex).AirPriLoopName;
   16842           1 :         writeOutput = true;
   16843           1 :     } else if (kind == OutputType::Facility && ort->displayFacilityComponentLoadSummary) {
   16844           1 :         reportName = "Facility Component Load Summary";
   16845           1 :         zoneAirLoopFacilityName = "Facility";
   16846           1 :         writeOutput = true;
   16847             :     } else {
   16848           0 :         writeOutput = false;
   16849             :     }
   16850         117 :     if (writeOutput) {
   16851         117 :         if (produceTabular_para) {
   16852         117 :             WriteReportHeaders(state, reportName, zoneAirLoopFacilityName, OutputProcessor::StoreType::Averaged);
   16853             :         }
   16854         234 :         std::string peakLoadCompName;
   16855         234 :         std::string peakCondName;
   16856         234 :         std::string zonesIncludedName;
   16857         234 :         std::string engineeringCheckName;
   16858         351 :         for (int coolHeat = 1; coolHeat <= 2; ++coolHeat) {
   16859         234 :             tableBody.allocate(LoadCompCol::PerArea, LoadCompRow::GrdTot);
   16860         234 :             tableBody = "";
   16861         234 :             if (coolHeat == 1) {
   16862         117 :                 curCompLoad = compLoadCool;
   16863         117 :                 peakLoadCompName = "Estimated Cooling Peak Load Components";
   16864         117 :                 peakCondName = "Cooling Peak Conditions";
   16865         117 :                 zonesIncludedName = "Zones Included for Cooling";
   16866         117 :                 engineeringCheckName = "Engineering Checks for Cooling";
   16867             :             } else {
   16868         117 :                 curCompLoad = compLoadHeat;
   16869         117 :                 peakLoadCompName = "Estimated Heating Peak Load Components";
   16870         117 :                 peakCondName = "Heating Peak Conditions";
   16871         117 :                 zonesIncludedName = "Zones Included for Heating";
   16872         117 :                 engineeringCheckName = "Engineering Checks for Heating";
   16873             :             }
   16874             :             // move number array into string array
   16875        2106 :             for (int c = 1; c <= LoadCompCol::PerArea; ++c) {
   16876       50544 :                 for (int r = 1; r <= LoadCompRow::GrdTot; ++r) { // to last row before total
   16877       48672 :                     if (curCompLoad.cellUsed(c, r)) {
   16878       29722 :                         tableBody(c, r) = RealToStr(curCompLoad.cells(c, r), 2);
   16879             :                     }
   16880             :                 }
   16881             :             }
   16882         234 :             rowHead.allocate(LoadCompRow::GrdTot);
   16883             :             // internal gains
   16884         234 :             rowHead(LoadCompRow::People) = "People";
   16885         234 :             rowHead(LoadCompRow::Lights) = "Lights";
   16886         234 :             rowHead(LoadCompRow::Equip) = "Equipment";
   16887         234 :             rowHead(LoadCompRow::Refrig) = "Refrigeration Equipment";
   16888         234 :             rowHead(LoadCompRow::WaterUse) = "Water Use Equipment";
   16889         234 :             rowHead(LoadCompRow::PowerGen) = "Power Generation Equipment";
   16890         234 :             rowHead(LoadCompRow::HvacLoss) = "HVAC Equipment Losses";
   16891         234 :             rowHead(LoadCompRow::Refrig) = "Refrigeration";
   16892             :             // misc
   16893         234 :             rowHead(LoadCompRow::DOAS) = "DOAS Direct to Zone";
   16894         234 :             rowHead(LoadCompRow::Infil) = "Infiltration";
   16895         234 :             rowHead(LoadCompRow::ZoneVent) = "Zone Ventilation";
   16896         234 :             rowHead(LoadCompRow::IntZonMix) = "Interzone Mixing";
   16897             :             // opaque surfaces
   16898         234 :             rowHead(LoadCompRow::Roof) = "Roof";
   16899         234 :             rowHead(LoadCompRow::IntZonCeil) = "Interzone Ceiling";
   16900         234 :             rowHead(LoadCompRow::OtherRoof) = "Other Roof";
   16901         234 :             rowHead(LoadCompRow::ExtWall) = "Exterior Wall";
   16902         234 :             rowHead(LoadCompRow::IntZonWall) = "Interzone Wall";
   16903         234 :             rowHead(LoadCompRow::GrdWall) = "Ground Contact Wall";
   16904         234 :             rowHead(LoadCompRow::OtherWall) = "Other Wall";
   16905         234 :             rowHead(LoadCompRow::ExtFlr) = "Exterior Floor";
   16906         234 :             rowHead(LoadCompRow::IntZonFlr) = "Interzone Floor";
   16907         234 :             rowHead(LoadCompRow::GrdFlr) = "Ground Contact Floor";
   16908         234 :             rowHead(LoadCompRow::OtherFlr) = "Other Floor";
   16909             :             // subsurfaces
   16910         234 :             rowHead(LoadCompRow::FeneCond) = "Fenestration Conduction";
   16911         234 :             rowHead(LoadCompRow::FeneSolr) = "Fenestration Solar";
   16912         234 :             rowHead(LoadCompRow::OpqDoor) = "Opaque Door";
   16913         234 :             rowHead(LoadCompRow::GrdTot) = "Grand Total";
   16914             : 
   16915         234 :             columnHead.allocate(LoadCompCol::PerArea);
   16916         234 :             if (unitsStyle_para != UnitsStyle::InchPound) {
   16917         234 :                 columnHead(LoadCompCol::SensInst) = "Sensible - Instant [W]";
   16918         234 :                 columnHead(LoadCompCol::SensDelay) = "Sensible - Delayed [W]";
   16919         234 :                 columnHead(LoadCompCol::SensRA) = "Sensible - Return Air [W]";
   16920         234 :                 columnHead(LoadCompCol::Latent) = "Latent [W]";
   16921         234 :                 columnHead(LoadCompCol::Total) = "Total [W]";
   16922         234 :                 columnHead(LoadCompCol::Perc) = "%Grand Total";
   16923         234 :                 columnHead(LoadCompCol::Area) = "Related Area [m2]";
   16924         234 :                 columnHead(LoadCompCol::PerArea) = "Total per Area [W/m2]";
   16925             :             } else {
   16926           0 :                 columnHead(LoadCompCol::SensInst) = "Sensible - Instant [Btu/h]";
   16927           0 :                 columnHead(LoadCompCol::SensDelay) = "Sensible - Delayed [Btu/h]";
   16928           0 :                 columnHead(LoadCompCol::SensRA) = "Sensible - Return Air [Btu/h]";
   16929           0 :                 columnHead(LoadCompCol::Latent) = "Latent [Btu/h]";
   16930           0 :                 columnHead(LoadCompCol::Total) = "Total [Btu/h]";
   16931           0 :                 columnHead(LoadCompCol::Perc) = "%Grand Total";
   16932           0 :                 columnHead(LoadCompCol::Area) = "Related Area [ft2]";
   16933           0 :                 columnHead(LoadCompCol::PerArea) = "Total per Area [Btu/h-ft2]";
   16934             :             }
   16935         234 :             columnWidth.dimension(LoadCompCol::PerArea, 14); // array assignment - same for all columns
   16936             : 
   16937         234 :             if (produceTabular_para) {
   16938         234 :                 WriteSubtitle(state, peakLoadCompName);
   16939         234 :                 WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
   16940             :             }
   16941         234 :             if (produceSQLite_para) {
   16942         234 :                 if (state.dataSQLiteProcedures->sqlite) {
   16943          10 :                     state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
   16944             :                         tableBody, rowHead, columnHead, reportName, zoneAirLoopFacilityName, peakLoadCompName);
   16945             :                 }
   16946             :             }
   16947         234 :             if (produceTabular_para) {
   16948         234 :                 if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
   16949           0 :                     state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(
   16950             :                         tableBody, rowHead, columnHead, reportName, zoneAirLoopFacilityName, peakLoadCompName);
   16951             :                 }
   16952             :             }
   16953             : 
   16954             :             //---- Peak Conditions
   16955             : 
   16956         234 :             rowHead.allocate(16);
   16957         234 :             columnHead.allocate(1);
   16958         234 :             columnWidth.allocate(1);
   16959         234 :             columnWidth = 14; // array assignment - same for all columns
   16960             : 
   16961         234 :             tableBody.allocate(1, 16);
   16962         234 :             tableBody = "";
   16963             : 
   16964         234 :             columnHead(1) = "Value";
   16965         234 :             if (unitsStyle_para != UnitsStyle::InchPound) {
   16966         234 :                 rowHead(1) = "Time of Peak Load";
   16967         234 :                 rowHead(2) = "Outside Dry Bulb Temperature [C]";
   16968         234 :                 rowHead(3) = "Outside Wet Bulb Temperature [C]";
   16969         234 :                 rowHead(4) = "Outside Humidity Ratio at Peak [kgWater/kgDryAir]";
   16970         234 :                 rowHead(5) = "Zone Dry Bulb Temperature [C]";
   16971         234 :                 rowHead(6) = "Zone Relative Humidity [%]";
   16972         234 :                 rowHead(7) = "Zone Humidity Ratio at Peak [kgWater/kgDryAir]";
   16973             : 
   16974         234 :                 rowHead(8) = "Supply Air Temperature [C]";
   16975         234 :                 rowHead(9) = "Mixed Air Temperature [C]";
   16976         234 :                 rowHead(10) = "Main Fan Air Flow [m3/s]";
   16977         234 :                 rowHead(11) = "Outside Air Flow [m3/s]";
   16978         234 :                 rowHead(12) = "Peak Sensible Load with Sizing Factor [W]";
   16979         234 :                 rowHead(13) = "Difference Due to Sizing Factor [W]";
   16980             : 
   16981         234 :                 rowHead(14) = "Peak Sensible Load [W]";
   16982         234 :                 rowHead(15) = "Estimated Instant + Delayed Sensible Load [W]";
   16983         234 :                 rowHead(16) = "Difference Between Peak and Estimated Sensible Load [W]";
   16984             :             } else {
   16985           0 :                 rowHead(1) = "Time of Peak Load";
   16986           0 :                 rowHead(2) = "Outside Dry Bulb Temperature [F]";
   16987           0 :                 rowHead(3) = "Outside Wet Bulb Temperature [F]";
   16988           0 :                 rowHead(4) = "Outside Humidity Ratio at Peak [lbWater/lbAir]";
   16989           0 :                 rowHead(5) = "Zone Dry Bulb Temperature [F]";
   16990           0 :                 rowHead(6) = "Zone Relative Humidity [%]";
   16991           0 :                 rowHead(7) = "Zone Humidity Ratio at Peak [lbWater/lbAir]";
   16992             : 
   16993           0 :                 rowHead(8) = "Supply Air Temperature [F]";
   16994           0 :                 rowHead(9) = "Mixed Air Temperature [F]";
   16995           0 :                 rowHead(10) = "Main Fan Air Flow [ft3/min]";
   16996           0 :                 rowHead(11) = "Outside Air Flow [ft3/min]";
   16997           0 :                 rowHead(12) = "Peak Sensible Load with Sizing Factor [Btu/h]";
   16998           0 :                 rowHead(13) = "Difference Due to Sizing Factor [Btu/h]";
   16999             : 
   17000           0 :                 rowHead(14) = "Peak Sensible Load  [Btu/h]";
   17001           0 :                 rowHead(15) = "Estimated Instant + Delayed Sensible Load [Btu/h]";
   17002           0 :                 rowHead(16) = "Difference Between Peak and Estimated Sensible Load [Btu/h]";
   17003             :             }
   17004             : 
   17005         234 :             if (curCompLoad.timeStepMax != 0) {
   17006         234 :                 tableBody(1, 1) = curCompLoad.peakDateHrMin;                  // Time of Peak Load
   17007         234 :                 tableBody(1, 2) = RealToStr(curCompLoad.outsideDryBulb, 2);   // Outside Dry Bulb Temperature
   17008         234 :                 tableBody(1, 3) = RealToStr(curCompLoad.outsideWetBulb, 2);   // Outside Wet Bulb Temperature
   17009         234 :                 tableBody(1, 4) = RealToStr(curCompLoad.outsideHumRatio, 5);  // Outside Humidity Ratio at Peak
   17010         234 :                 tableBody(1, 5) = RealToStr(curCompLoad.zoneDryBulb, 2);      // Zone Dry Bulb Temperature
   17011         234 :                 tableBody(1, 6) = RealToStr(100 * curCompLoad.zoneRelHum, 2); // Zone Relative Humdity
   17012         234 :                 tableBody(1, 7) = RealToStr(curCompLoad.zoneHumRatio, 5);     // Zone Humidity Ratio at Peak
   17013             :             }
   17014         234 :             tableBody(1, 8) = RealToStr(curCompLoad.supAirTemp, 2); // supply air temperature
   17015         234 :             if (kind == OutputType::AirLoop) {
   17016           2 :                 tableBody(1, 9) = RealToStr(curCompLoad.mixAirTemp, 2); // mixed air temperature - not for zone or facility
   17017             :             }
   17018         234 :             tableBody(1, 10) = RealToStr(curCompLoad.mainFanAirFlow, 2);     // main fan air flow
   17019         234 :             tableBody(1, 11) = RealToStr(curCompLoad.outsideAirFlow, 2);     // outside air flow
   17020         234 :             tableBody(1, 12) = RealToStr(curCompLoad.designPeakLoad, 2);     // design peak load
   17021         234 :             tableBody(1, 13) = RealToStr(curCompLoad.diffDesignPeak, 2);     // difference between Design and Peak Load
   17022         234 :             tableBody(1, 14) = RealToStr(curCompLoad.peakDesSensLoad, 2);    // Peak Design Sensible Load
   17023         234 :             tableBody(1, 15) = RealToStr(curCompLoad.estInstDelSensLoad, 2); // Estimated Instant + Delayed Sensible Load
   17024         234 :             tableBody(1, 16) = RealToStr(curCompLoad.diffPeakEst, 2);        // Difference
   17025             : 
   17026         234 :             if (produceTabular_para) {
   17027         234 :                 WriteSubtitle(state, peakCondName);
   17028         234 :                 WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
   17029             :             }
   17030         234 :             if (produceSQLite_para) {
   17031         234 :                 if (state.dataSQLiteProcedures->sqlite) {
   17032          10 :                     state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
   17033             :                         tableBody, rowHead, columnHead, reportName, zoneAirLoopFacilityName, peakCondName);
   17034             :                 }
   17035             :             }
   17036         234 :             if (produceTabular_para) {
   17037         234 :                 if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
   17038           0 :                     state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(
   17039             :                         tableBody, rowHead, columnHead, reportName, zoneAirLoopFacilityName, peakCondName);
   17040             :                 }
   17041             :             }
   17042             : 
   17043             :             //---- Engineering Checks
   17044             : 
   17045         234 :             rowHead.allocate(6);
   17046         234 :             columnHead.allocate(1);
   17047         234 :             columnWidth.allocate(1);
   17048         234 :             columnWidth = 14; // array assignment - same for all columns
   17049             : 
   17050         234 :             tableBody.allocate(1, 6);
   17051         234 :             tableBody = "";
   17052             : 
   17053         234 :             columnHead(1) = "Value";
   17054         234 :             if (unitsStyle_para != UnitsStyle::InchPound) {
   17055         234 :                 rowHead(1) = "Outside Air Fraction [fraction]";
   17056         234 :                 rowHead(2) = "Airflow per Floor Area [m3/s-m2]";
   17057         234 :                 rowHead(3) = "Airflow per Total Capacity [m3/s-W]";
   17058         234 :                 rowHead(4) = "Floor Area per Total Capacity [m2/W]";
   17059         234 :                 rowHead(5) = "Total Capacity per Floor Area [W/m2]";
   17060             :                 // rowHead( 6 ) = "Chiller Pump Power per Flow [W-s/m3]"; // facility only
   17061             :                 // rowHead( 7 ) = "Condenser Pump Power per Flor [W-s/m3]"; // facility only
   17062         234 :                 rowHead(6) = "Number of People";
   17063             :             } else {
   17064           0 :                 rowHead(1) = "Outside Air Fraction [fraction]";
   17065           0 :                 rowHead(2) = "Airflow per Floor Area [ft3/min-ft2]";
   17066           0 :                 rowHead(3) = "Airflow per Total Capacity [ft3-h/min-Btu]";
   17067           0 :                 rowHead(4) = "Floor Area per Total Capacity [ft2-h/Btu]";
   17068           0 :                 rowHead(5) = "Total Capacity per Floor Area [Btu/h-ft2]";
   17069             :                 // rowHead( 6 ) = "Chiller Pump Power per Flow [W-min/gal]";
   17070             :                 // rowHead( 7 ) = "Condenser Pump Power per Flow [W-min/gal]";
   17071           0 :                 rowHead(6) = "Number of People";
   17072             :             }
   17073             : 
   17074         468 :             tableBody(1, 1) = fmt::format("{:.{}f}", curCompLoad.outsideAirRatio, 4); // outside Air
   17075         234 :             tableBody(1, 2) = fmt::format("{:0.3E}", curCompLoad.airflowPerFlrArea);  // airflow per floor area
   17076         234 :             tableBody(1, 3) = fmt::format("{:0.3E}", curCompLoad.airflowPerTotCap);   // airflow per total capacity
   17077         234 :             tableBody(1, 4) = fmt::format("{:0.3E}", curCompLoad.areaPerTotCap);      // area per total capacity
   17078         234 :             tableBody(1, 5) = fmt::format("{:0.3E}", curCompLoad.totCapPerArea);      // total capacity per area
   17079         468 :             tableBody(1, 6) = fmt::format("{:.{}f}", curCompLoad.numPeople, 1);       // number of people
   17080             : 
   17081         234 :             if (produceTabular_para) {
   17082         234 :                 WriteSubtitle(state, engineeringCheckName);
   17083         234 :                 WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
   17084             :             }
   17085         234 :             if (produceSQLite_para) {
   17086         234 :                 if (state.dataSQLiteProcedures->sqlite) {
   17087          10 :                     state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
   17088             :                         tableBody, rowHead, columnHead, reportName, zoneAirLoopFacilityName, engineeringCheckName);
   17089             :                 }
   17090             :             }
   17091         234 :             if (produceTabular_para) {
   17092         234 :                 if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
   17093           0 :                     state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(
   17094             :                         tableBody, rowHead, columnHead, reportName, zoneAirLoopFacilityName, engineeringCheckName);
   17095             :                 }
   17096             :             }
   17097             : 
   17098             :             // write the list of zone for the AirLoop level report
   17099         234 :             if (kind == OutputType::AirLoop && curCompLoad.zoneIndices.allocated()) {
   17100           2 :                 int maxRow = 0;
   17101          14 :                 for (size_t zi = 1; zi <= curCompLoad.zoneIndices.size(); ++zi) {
   17102          12 :                     if (curCompLoad.zoneIndices(zi) > 0) {
   17103          10 :                         maxRow = zi;
   17104             :                     }
   17105             :                 }
   17106             : 
   17107           2 :                 rowHead.allocate(maxRow);
   17108           2 :                 columnHead.allocate(1);
   17109           2 :                 columnWidth.allocate(1);
   17110           2 :                 columnWidth = 14; // array assignment - same for all columns
   17111           2 :                 tableBody.allocate(1, maxRow);
   17112           2 :                 tableBody = "";
   17113             : 
   17114           2 :                 columnHead(1) = "Zone Name";
   17115          12 :                 for (int zi = 1; zi <= maxRow; ++zi) {
   17116          10 :                     rowHead(zi) = fmt::to_string(zi);
   17117          10 :                     if (curCompLoad.zoneIndices(zi) > 0) {
   17118          10 :                         tableBody(1, zi) = state.dataHeatBal->Zone(curCompLoad.zoneIndices(zi)).Name;
   17119             :                     }
   17120             :                 }
   17121             : 
   17122           2 :                 if (produceTabular_para) {
   17123           2 :                     WriteSubtitle(state, zonesIncludedName);
   17124           2 :                     WriteTable(state, tableBody, rowHead, columnHead, columnWidth);
   17125             :                 }
   17126           2 :                 if (produceSQLite_para) {
   17127           2 :                     if (state.dataSQLiteProcedures->sqlite) {
   17128           0 :                         state.dataSQLiteProcedures->sqlite->createSQLiteTabularDataRecords(
   17129             :                             tableBody, rowHead, columnHead, reportName, zoneAirLoopFacilityName, zonesIncludedName);
   17130             :                     }
   17131             :                 }
   17132           2 :                 if (produceTabular_para) {
   17133           2 :                     if (state.dataResultsFramework->resultsFramework->timeSeriesAndTabularEnabled()) {
   17134           0 :                         state.dataResultsFramework->resultsFramework->TabularReportsCollection.addReportTable(
   17135             :                             tableBody, rowHead, columnHead, reportName, zoneAirLoopFacilityName, zonesIncludedName);
   17136             :                     }
   17137             :                 }
   17138             :             }
   17139             :         }
   17140             :     }
   17141         117 : }
   17142             : 
   17143       18001 : void WriteReportHeaders(EnergyPlusData &state,
   17144             :                         std::string const &reportName,
   17145             :                         std::string const &objectName,
   17146             :                         OutputProcessor::StoreType const averageOrSum)
   17147             : {
   17148             :     // SUBROUTINE INFORMATION:
   17149             :     //       AUTHOR         Jason Glazer
   17150             :     //       DATE WRITTEN   August 2003
   17151             :     //       MODIFIED       na
   17152             :     //       RE-ENGINEERED  na
   17153             : 
   17154             :     // PURPOSE OF THIS SUBROUTINE:
   17155             :     //   Write the first few lines of each report with headers to the output
   17156             :     //   file for tabular reports.
   17157             : 
   17158       36002 :     std::string const modifiedReportName(reportName + (averageOrSum == OutputProcessor::StoreType::Summed ? " per second" : ""));
   17159       18001 :     auto &ort(state.dataOutRptTab);
   17160             : 
   17161       38502 :     for (int iStyle = 1; iStyle <= ort->numStyles; ++iStyle) {
   17162       20501 :         std::ostream &tbl_stream(*ort->TabularOutputFile(iStyle));
   17163       20501 :         std::string const &curDel(ort->del(iStyle));
   17164       20501 :         auto const style(ort->TableStyle(iStyle));
   17165       20501 :         if ((style == TableStyle::Comma) || (style == TableStyle::Tab)) {
   17166        1879 :             tbl_stream << "----------------------------------------------------------------------------------------------------\n";
   17167        1879 :             tbl_stream << "REPORT:" << curDel << modifiedReportName << '\n';
   17168        1879 :             tbl_stream << "FOR:" << curDel << objectName << '\n';
   17169       18622 :         } else if (style == TableStyle::Fixed) {
   17170         428 :             tbl_stream << "----------------------------------------------------------------------------------------------------\n";
   17171         428 :             tbl_stream << "REPORT:      " << curDel << modifiedReportName << '\n';
   17172         428 :             tbl_stream << "FOR:         " << curDel << objectName << '\n';
   17173       18194 :         } else if (style == TableStyle::HTML) {
   17174       17740 :             tbl_stream << "<hr>\n";
   17175       17740 :             tbl_stream << "<p><a href=\"#toc\" style=\"float: right\">Table of Contents</a></p>\n";
   17176       17740 :             tbl_stream << "<a name=" << MakeAnchorName(reportName, objectName) << "></a>\n";
   17177       17740 :             tbl_stream << "<p>Report:<b>" << curDel << modifiedReportName << "</b></p>\n";
   17178       17740 :             tbl_stream << "<p>For:<b>" << curDel << objectName << "</b></p>\n";
   17179       17740 :             tbl_stream << "<p>Timestamp: <b>" << std::setw(4) << ort->td(1) << '-' << std::setfill('0') << std::setw(2) << ort->td(2) << '-'
   17180       17740 :                        << std::setw(2) << ort->td(3) << '\n';
   17181       17740 :             tbl_stream << "    " << std::setw(2) << ort->td(5) << ':' << std::setw(2) << ort->td(6) << ':' << std::setw(2) << ort->td(7)
   17182       17740 :                        << std::setfill(' ') << "</b></p>\n";
   17183         454 :         } else if (style == TableStyle::XML) {
   17184         454 :             if (len(ort->prevReportName) != 0) {
   17185         436 :                 tbl_stream << "</" << ort->prevReportName << ">\n"; // close the last element if it was used.
   17186             :             }
   17187         454 :             tbl_stream << "<" << ConvertToElementTag(modifiedReportName) << ">\n";
   17188         454 :             tbl_stream << "  <for>" << objectName << "</for>\n";
   17189         454 :             ort->prevReportName = ConvertToElementTag(modifiedReportName); // save the name for next time
   17190             :         }
   17191             :     }
   17192             :     // clear the active subtable name for the XML reporting
   17193       18001 :     ort->activeSubTableName = "";
   17194             :     // save the report name if the subtable name is not available during XML processing
   17195       18001 :     ort->activeReportName = modifiedReportName;
   17196             :     // save the "for" which is the object name in the report for HTML comment that contains the report, for, and subtable
   17197       18001 :     ort->activeForName = objectName;
   17198       18001 : }
   17199             : 
   17200      126739 : void WriteSubtitle(EnergyPlusData &state, std::string const &subtitle)
   17201             : {
   17202             :     // SUBROUTINE INFORMATION:
   17203             :     //       AUTHOR         Jason Glazer
   17204             :     //       DATE WRITTEN   November 2003
   17205             :     //       MODIFIED       na
   17206             :     //       RE-ENGINEERED  na
   17207             : 
   17208             :     // PURPOSE OF THIS SUBROUTINE:
   17209             :     //   Insert a subtitle into the current report
   17210             : 
   17211             :     // Locals
   17212             :     // SUBROUTINE ARGUMENT DEFINITIONS:
   17213             : 
   17214             :     // SUBROUTINE PARAMETER DEFINITIONS:
   17215             : 
   17216             :     // INTERFACE BLOCK SPECIFICATIONS:
   17217             :     // na
   17218             : 
   17219             :     // DERIVED TYPE DEFINITIONS:
   17220             :     // na
   17221             : 
   17222             :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
   17223             :     int iStyle;
   17224      126739 :     auto &ort(state.dataOutRptTab);
   17225             : 
   17226      271051 :     for (iStyle = 1; iStyle <= ort->numStyles; ++iStyle) {
   17227      144312 :         auto const style(ort->TableStyle(iStyle));
   17228      144312 :         if ((style == TableStyle::Comma) || (style == TableStyle::Tab) || (style == TableStyle::Fixed)) {
   17229       16309 :             std::ostream &tbl_stream(*ort->TabularOutputFile(iStyle));
   17230       16309 :             tbl_stream << subtitle << "\n\n";
   17231      128003 :         } else if (style == TableStyle::HTML) {
   17232      124958 :             std::ostream &tbl_stream(*ort->TabularOutputFile(iStyle));
   17233      124958 :             tbl_stream << "<b>" << subtitle << "</b><br><br>\n";
   17234      124958 :             tbl_stream << "<!-- FullName:" << ort->activeReportName << '_' << ort->activeForName << '_' << subtitle << "-->\n";
   17235        3045 :         } else if (style == TableStyle::XML) {
   17236             :             // save the active subtable name for the XML reporting
   17237        3045 :             ort->activeSubTableName = subtitle;
   17238             :             // no other output is needed since WriteTable uses the subtable name for each record.
   17239             :         }
   17240             :     }
   17241      126739 : }
   17242             : 
   17243        8686 : void WriteTextLine(EnergyPlusData &state, std::string const &lineOfText, Optional_bool_const isBold)
   17244             : {
   17245             :     // SUBROUTINE INFORMATION:
   17246             :     //       AUTHOR         Jason Glazer
   17247             :     //       DATE WRITTEN   April 2007
   17248             :     //       MODIFIED       na
   17249             :     //       RE-ENGINEERED  na
   17250             : 
   17251             :     // PURPOSE OF THIS SUBROUTINE:
   17252             :     //   Insert a subtitle into the current report
   17253             : 
   17254             :     // Locals
   17255             :     // SUBROUTINE ARGUMENT DEFINITIONS:
   17256             : 
   17257             :     // SUBROUTINE PARAMETER DEFINITIONS:
   17258             : 
   17259             :     // INTERFACE BLOCK SPECIFICATIONS:
   17260             :     // na
   17261             : 
   17262             :     // DERIVED TYPE DEFINITIONS:
   17263             :     // na
   17264             : 
   17265             :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
   17266             :     int iStyle;
   17267             :     bool useBold;
   17268        8686 :     auto &ort(state.dataOutRptTab);
   17269             : 
   17270        8686 :     if (present(isBold)) {
   17271        7055 :         useBold = isBold;
   17272             :     } else {
   17273        1631 :         useBold = false;
   17274             :     }
   17275             : 
   17276       18685 :     for (iStyle = 1; iStyle <= ort->numStyles; ++iStyle) {
   17277        9999 :         auto const style(ort->TableStyle(iStyle));
   17278        9999 :         if ((style == TableStyle::Comma) || (style == TableStyle::Tab) || (style == TableStyle::Fixed)) {
   17279        1225 :             std::ostream &tbl_stream(*ort->TabularOutputFile(iStyle));
   17280        1225 :             tbl_stream << lineOfText << '\n';
   17281        8774 :         } else if (style == TableStyle::HTML) {
   17282        8576 :             std::ostream &tbl_stream(*ort->TabularOutputFile(iStyle));
   17283        8576 :             if (useBold) {
   17284        6955 :                 tbl_stream << "<b>" << lineOfText << "</b><br><br>\n";
   17285             :             } else {
   17286        1621 :                 tbl_stream << lineOfText << "<br>\n";
   17287             :             }
   17288         198 :         } else if (style == TableStyle::XML) {
   17289         198 :             std::ostream &tbl_stream(*ort->TabularOutputFile(iStyle));
   17290         198 :             if (!lineOfText.empty()) {
   17291         162 :                 tbl_stream << "<note>" << lineOfText << "</note>\n";
   17292             :             }
   17293             :         }
   17294             :     }
   17295        8686 : }
   17296             : 
   17297      126731 : void WriteTable(EnergyPlusData &state,
   17298             :                 Array2S_string const body, // row,column
   17299             :                 const Array1D_string &rowLabels,
   17300             :                 const Array1D_string &columnLabels,
   17301             :                 Array1D_int &widthColumn,
   17302             :                 bool transposeXML,
   17303             :                 std::string_view const footnoteText)
   17304             : {
   17305             :     // SUBROUTINE INFORMATION:
   17306             :     //       AUTHOR         Jason Glazer
   17307             :     //       DATE WRITTEN   August 2003
   17308             :     //       MODIFIED       na
   17309             :     //       RE-ENGINEERED  na
   17310             : 
   17311             :     // PURPOSE OF THIS SUBROUTINE:
   17312             :     //   Output a table to the tabular output file in the selected
   17313             :     //   style (comma, tab, space, html, xml).
   17314             :     //   The widthColumn array is only used for fixed space formatted reports
   17315             :     //   if columnLables contain a vertical bar '|', they are broken into multiple
   17316             :     //   rows.  If they exceed the column width even after that and the format is
   17317             :     //   fixed, they are further shortened.
   17318             :     //   To include the currency symbol ($ by default but other symbols if the user
   17319             :     //   has input it with Economics:CurrencyType) use the string ~~$~~ in the row
   17320             :     //   headers, column headers, and body. For HTML files, the ASCII or UNICODE
   17321             :     //   symbol for the currency will be included. For TXT files, the ASCII symbol
   17322             :     //   will be used.
   17323             : 
   17324             :     // Argument array dimensioning
   17325             : 
   17326             :     // Locals
   17327             :     // SUBROUTINE ARGUMENT DEFINITIONS:
   17328             : 
   17329             :     // SUBROUTINE PARAMETER DEFINITIONS:
   17330      126731 :     static std::string const blank;
   17331             : 
   17332             :     // INTERFACE BLOCK SPECIFICATIONS:
   17333             :     // na
   17334             : 
   17335             :     // DERIVED TYPE DEFINITIONS:
   17336             :     // na
   17337             : 
   17338             :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
   17339      253462 :     Array2D_string colLabelMulti;
   17340      253462 :     std::string workColumn;
   17341      253462 :     Array1D_string rowLabelTags;
   17342      253462 :     Array1D_string columnLabelTags;
   17343      253462 :     Array1D_string rowUnitStrings;
   17344      253462 :     Array1D_string columnUnitStrings;
   17345      253462 :     Array2D_string bodyEsc;
   17346             : 
   17347             :     int numColLabelRows;
   17348             :     int maxNumColLabelRows;
   17349             :     std::string::size_type widthRowLabel;
   17350             :     std::string::size_type maxWidthRowLabel;
   17351             : 
   17352             :     int rowsBody;
   17353             :     int colsBody;
   17354             :     int colsColumnLabels;
   17355             :     int colsWidthColumn;
   17356             :     int rowsRowLabels;
   17357             : 
   17358             :     int iCol;
   17359             :     int jRow;
   17360             :     int colWidthLimit;
   17361             :     std::string::size_type barLoc;
   17362             : 
   17363      253462 :     std::string outputLine;
   17364      253462 :     std::string spaces;
   17365             :     int iStyle;
   17366      253462 :     std::string curDel;
   17367      253462 :     std::string tagWithAttrib;
   17368             :     std::string::size_type col1start;
   17369             :     bool isTableBlank;
   17370             :     bool isRecordBlank;
   17371      126731 :     auto &ort(state.dataOutRptTab);
   17372             : 
   17373             :     // create blank string
   17374      126731 :     spaces = blank; // REPEAT(' ',1000)
   17375             :     // get sizes of arrays
   17376      126731 :     rowsBody = isize(body, 2);
   17377      126731 :     colsBody = isize(body, 1);
   17378      126731 :     rowsRowLabels = isize(rowLabels);
   17379      126731 :     colsColumnLabels = isize(columnLabels);
   17380      126731 :     colsWidthColumn = isize(widthColumn);
   17381             :     // check size of arrays for consistancy and if inconsistent use smaller value
   17382             :     // and display warning
   17383      126731 :     if (rowsBody != rowsRowLabels) {
   17384           0 :         ShowWarningError(state, "REPORT:TABLE Inconsistant number of rows.");
   17385           0 :         rowsBody = min(rowsBody, rowsRowLabels);
   17386           0 :         rowsRowLabels = rowsBody;
   17387             :     }
   17388      126731 :     if ((colsBody != colsColumnLabels) || (colsBody != colsWidthColumn)) {
   17389           0 :         ShowWarningError(state, "REPORT:TABLE Inconsistent number of columns.");
   17390           0 :         colsBody = min(colsBody, min(colsColumnLabels, colsWidthColumn));
   17391           0 :         colsWidthColumn = colsBody;
   17392           0 :         colsColumnLabels = colsBody;
   17393             :     }
   17394             :     // create arrays to hold the XML tags
   17395      126731 :     rowLabelTags.allocate(rowsBody);
   17396      126731 :     columnLabelTags.allocate(colsBody);
   17397      126731 :     rowUnitStrings.allocate(rowsBody);
   17398      126731 :     columnUnitStrings.allocate(colsBody);
   17399      126731 :     bodyEsc.allocate(colsBody, rowsBody);
   17400             :     // create new array to hold multiple line column lables
   17401      126731 :     colLabelMulti.allocate(colsColumnLabels, 50);
   17402      126731 :     colLabelMulti = blank; // set array to blank
   17403      126731 :     numColLabelRows = 0;   // default value
   17404      126731 :     maxNumColLabelRows = 0;
   17405             : 
   17406      271033 :     for (iStyle = 1; iStyle <= ort->numStyles; ++iStyle) {
   17407      144302 :         std::ostream &tbl_stream(*ort->TabularOutputFile(iStyle));
   17408      144302 :         curDel = ort->del(iStyle);
   17409             :         // go through the columns and break them into multiple lines
   17410             :         // if bar '|' is found in a row then break into two lines
   17411             :         // if longer than the column width break into two lines for fixed style only
   17412     1186563 :         for (iCol = 1; iCol <= colsColumnLabels; ++iCol) {
   17413     1042261 :             numColLabelRows = 0;
   17414     1042261 :             workColumn = columnLabels(iCol);
   17415     1042261 :             widthColumn(iCol) = max(widthColumn(iCol), static_cast<int>(len(columnLabels(iCol))));
   17416             :             while (true) {
   17417     1075129 :                 barLoc = index(workColumn, '|');
   17418     1058695 :                 if (barLoc != std::string::npos) {
   17419       16434 :                     ++numColLabelRows;
   17420       16434 :                     colLabelMulti(iCol, numColLabelRows) = workColumn.substr(0, barLoc);
   17421       16434 :                     workColumn.erase(0, barLoc + 1);
   17422             :                 } else {
   17423     1042261 :                     ++numColLabelRows;
   17424     1042261 :                     colLabelMulti(iCol, numColLabelRows) = workColumn;
   17425     1042261 :                     break; // inner do loop
   17426             :                 }
   17427             :             }
   17428     1042261 :             if (numColLabelRows > maxNumColLabelRows) {
   17429      127382 :                 maxNumColLabelRows = numColLabelRows;
   17430             :             }
   17431             :         }
   17432             :         // extra preprocessing for fixed style reports
   17433      144302 :         if (ort->TableStyle(iStyle) == TableStyle::Fixed) {
   17434             :             // break column headings into multiple rows if long (for fixed) or contain two spaces in a row.
   17435       23610 :             for (iCol = 1; iCol <= colsColumnLabels; ++iCol) {
   17436       20732 :                 colWidthLimit = widthColumn(iCol);
   17437       42212 :                 for (jRow = 1; jRow <= maxNumColLabelRows; ++jRow) {
   17438       21480 :                     pare(colLabelMulti(iCol, jRow), colWidthLimit);
   17439             :                 }
   17440             :             }
   17441        2878 :             maxWidthRowLabel = 0;
   17442       13499 :             for (jRow = 1; jRow <= rowsRowLabels; ++jRow) {
   17443       10621 :                 widthRowLabel = len(rowLabels(jRow));
   17444       10621 :                 if (widthRowLabel > maxWidthRowLabel) {
   17445        4270 :                     maxWidthRowLabel = widthRowLabel;
   17446             :                 }
   17447             :             }
   17448             :         }
   17449             : 
   17450             :         // output depending on style of format
   17451      144302 :         auto const style(ort->TableStyle(iStyle));
   17452      144302 :         if ((style == TableStyle::Comma) || (style == TableStyle::Tab)) {
   17453             :             // column headers
   17454       28207 :             for (jRow = 1; jRow <= maxNumColLabelRows; ++jRow) {
   17455       14778 :                 outputLine = curDel; // one leading delimiters on column header lines
   17456      115349 :                 for (iCol = 1; iCol <= colsColumnLabels; ++iCol) {
   17457      100571 :                     outputLine += curDel + stripped(colLabelMulti(iCol, jRow));
   17458             :                 }
   17459       14778 :                 tbl_stream << InsertCurrencySymbol(state, outputLine, false) << '\n';
   17460             :             }
   17461             :             // body with row headers
   17462      145678 :             for (jRow = 1; jRow <= rowsBody; ++jRow) {
   17463      132249 :                 outputLine = curDel + rowLabels(jRow); // one leading delimiters on table body lines
   17464     1348311 :                 for (iCol = 1; iCol <= colsBody; ++iCol) {
   17465     1216062 :                     outputLine += curDel + stripped(body(iCol, jRow));
   17466             :                 }
   17467      132249 :                 tbl_stream << InsertCurrencySymbol(state, outputLine, false) << '\n';
   17468             :             }
   17469       13429 :             if (!footnoteText.empty()) {
   17470        1061 :                 tbl_stream << fmt::format("{}\n", footnoteText);
   17471             :             }
   17472       13429 :             tbl_stream << "\n\n";
   17473             : 
   17474      130873 :         } else if (style == TableStyle::Fixed) {
   17475             :             // column headers
   17476        6079 :             for (jRow = 1; jRow <= maxNumColLabelRows; ++jRow) {
   17477        3201 :                 outputLine = blank; // spaces(:maxWidthRowLabel+2)  // two extra spaces and leave blank area for row labels
   17478        3201 :                 col1start = max(maxWidthRowLabel + 2u, static_cast<std::string::size_type>(3u));
   17479       24681 :                 for (iCol = 1; iCol <= colsColumnLabels; ++iCol) {
   17480       21480 :                     if (iCol != 1) {
   17481       18279 :                         outputLine += "  " + rjustified(sized(colLabelMulti(iCol, jRow), widthColumn(iCol)));
   17482             :                     } else {
   17483        3201 :                         outputLine = std::string(col1start - 1, ' ') + "  " + rjustified(sized(colLabelMulti(iCol, jRow), widthColumn(iCol)));
   17484             :                     }
   17485             :                 }
   17486        3201 :                 tbl_stream << InsertCurrencySymbol(state, outputLine, false) << '\n';
   17487             :             }
   17488             :             // body with row headers
   17489       13499 :             for (jRow = 1; jRow <= rowsBody; ++jRow) {
   17490       10621 :                 outputLine = "  " + rjustified(sized(rowLabels(jRow), maxWidthRowLabel)); // two blank spaces on table body lines
   17491             :                 // col1start = max( len( outputLine ) + 2u, maxWidthRowLabel + 2u );
   17492       88369 :                 for (iCol = 1; iCol <= colsBody; ++iCol) {
   17493       77748 :                     if (iCol != 1) {
   17494       67127 :                         outputLine += "  " + rjustified(sized(body(iCol, jRow), widthColumn(iCol)));
   17495             :                     } else {
   17496       10621 :                         outputLine += "   " + rjustified(sized(body(iCol, jRow), widthColumn(iCol)));
   17497             :                     }
   17498             :                 }
   17499       10621 :                 tbl_stream << InsertCurrencySymbol(state, outputLine, false) << '\n';
   17500             :             }
   17501        2878 :             if (!footnoteText.empty()) {
   17502         141 :                 tbl_stream << fmt::format("{}\n", footnoteText);
   17503             :             }
   17504        2878 :             tbl_stream << "\n\n";
   17505             : 
   17506      127995 :         } else if (style == TableStyle::HTML) {
   17507             :             // set up it being a table
   17508      124950 :             tbl_stream << "<table border=\"1\" cellpadding=\"4\" cellspacing=\"0\">\n";
   17509             :             // column headers
   17510      124950 :             tbl_stream << "  <tr><td></td>\n"; // start new row and leave empty cell
   17511     1027001 :             for (iCol = 1; iCol <= colsColumnLabels; ++iCol) {
   17512      902051 :                 outputLine = "    <td align=\"right\">";
   17513     1832306 :                 for (jRow = 1; jRow <= maxNumColLabelRows; ++jRow) {
   17514      930255 :                     outputLine += ConvertToEscaped(colLabelMulti(iCol, jRow), false);
   17515      930255 :                     if (jRow < maxNumColLabelRows) {
   17516       28204 :                         outputLine += "<br>";
   17517             :                     }
   17518             :                 }
   17519      902051 :                 tbl_stream << InsertCurrencySymbol(state, outputLine, true) << "</td>\n";
   17520             :             }
   17521      124950 :             tbl_stream << "  </tr>\n";
   17522             :             // body with row headers
   17523      881337 :             for (jRow = 1; jRow <= rowsBody; ++jRow) {
   17524      756387 :                 tbl_stream << "  <tr>\n";
   17525      756387 :                 if (rowLabels(jRow) != "") {
   17526     1500034 :                     tbl_stream << "    <td align=\"right\">" << ConvertToEscaped(InsertCurrencySymbol(state, rowLabels(jRow), true), false)
   17527     1500034 :                                << "</td>\n";
   17528             :                 } else {
   17529        6370 :                     tbl_stream << "    <td align=\"right\">&nbsp;</td>\n";
   17530             :                 }
   17531     7108492 :                 for (iCol = 1; iCol <= colsBody; ++iCol) {
   17532     6352105 :                     if (body(iCol, jRow) != "") {
   17533    11675226 :                         tbl_stream << "    <td align=\"right\">" << ConvertToEscaped(InsertCurrencySymbol(state, body(iCol, jRow), true), false)
   17534    11675226 :                                    << "</td>\n";
   17535             :                     } else {
   17536      514492 :                         tbl_stream << "    <td align=\"right\">&nbsp;</td>\n";
   17537             :                     }
   17538             :                 }
   17539      756387 :                 tbl_stream << "  </tr>\n";
   17540             :             }
   17541             :             // end the table
   17542      124950 :             tbl_stream << "</table>\n";
   17543      124950 :             if (!footnoteText.empty()) {
   17544       11661 :                 tbl_stream << fmt::format("<i>{}</i>\n", footnoteText);
   17545             :             }
   17546      124950 :             tbl_stream << "<br><br>\n";
   17547        3045 :         } else if (style == TableStyle::XML) {
   17548             :             // check if entire table is blank and it if is skip generating anything
   17549        3045 :             isTableBlank = true;
   17550        4128 :             for (jRow = 1; jRow <= rowsBody; ++jRow) {
   17551       13934 :                 for (iCol = 1; iCol <= colsBody; ++iCol) {
   17552       12851 :                     if (len(body(iCol, jRow)) > 0) {
   17553        2182 :                         isTableBlank = false;
   17554        2182 :                         break;
   17555             :                     }
   17556             :                 }
   17557        3265 :                 if (!isTableBlank) break;
   17558             :             }
   17559             :             // if non-blank cells in the table body were found create the table.
   17560        3045 :             if (!isTableBlank) {
   17561             :                 // if report name and subtable name the same add "record" to the end
   17562        2182 :                 ort->activeSubTableName = ConvertToElementTag(ort->activeSubTableName);
   17563        2182 :                 ort->activeReportNameNoSpace = ConvertToElementTag(ort->activeReportName);
   17564        2182 :                 if (UtilityRoutines::SameString(ort->activeSubTableName, ort->activeReportNameNoSpace)) {
   17565          18 :                     ort->activeSubTableName += "Record";
   17566             :                 }
   17567             :                 // if no subtable name use the report name and add "record" to the end
   17568        2182 :                 if (len(ort->activeSubTableName) == 0) {
   17569           0 :                     ort->activeSubTableName = ort->activeReportNameNoSpace + "Record";
   17570             :                 }
   17571             :                 // if a single column table, transpose it automatically
   17572        2182 :                 if ((colsBody == 1) && (rowsBody > 1)) {
   17573         272 :                     transposeXML = true;
   17574             :                 }
   17575             :                 // first convert all row and column headers into tags compatible with XML strings
   17576       12502 :                 for (jRow = 1; jRow <= rowsBody; ++jRow) {
   17577       10320 :                     rowLabelTags(jRow) = ConvertToElementTag(rowLabels(jRow));
   17578       10320 :                     if (len(rowLabelTags(jRow)) == 0) {
   17579         189 :                         rowLabelTags(jRow) = "none";
   17580             :                     }
   17581       10320 :                     rowUnitStrings(jRow) = GetUnitSubString(rowLabels(jRow));
   17582       10320 :                     if (UtilityRoutines::SameString(rowUnitStrings(jRow), "Invalid/Undefined")) {
   17583           0 :                         rowUnitStrings(jRow) = "";
   17584             :                     }
   17585             :                 }
   17586       16757 :                 for (iCol = 1; iCol <= colsBody; ++iCol) {
   17587       14575 :                     columnLabelTags(iCol) = ConvertToElementTag(columnLabels(iCol));
   17588       14575 :                     if (len(columnLabelTags(iCol)) == 0) {
   17589           0 :                         columnLabelTags(iCol) = "none";
   17590             :                     }
   17591       14575 :                     columnUnitStrings(iCol) = GetUnitSubString(columnLabels(iCol));
   17592       14575 :                     if (UtilityRoutines::SameString(columnUnitStrings(iCol), "Invalid/Undefined")) {
   17593           0 :                         columnUnitStrings(iCol) = "";
   17594             :                     }
   17595             :                 }
   17596             :                 // convert entire table body to one with escape characters (no " ' < > &)
   17597       12502 :                 for (jRow = 1; jRow <= rowsBody; ++jRow) {
   17598       82715 :                     for (iCol = 1; iCol <= colsBody; ++iCol) {
   17599       72395 :                         bodyEsc(iCol, jRow) = ConvertToEscaped(body(iCol, jRow));
   17600             :                     }
   17601             :                 }
   17602        2182 :                 if (!transposeXML) {
   17603             :                     // body with row headers
   17604       10432 :                     for (jRow = 1; jRow <= rowsBody; ++jRow) {
   17605             :                         // check if record is blank and it if is skip generating anything
   17606        8522 :                         isRecordBlank = true;
   17607        9994 :                         for (iCol = 1; iCol <= colsBody; ++iCol) {
   17608        9882 :                             if (len(bodyEsc(iCol, jRow)) > 0) {
   17609        8410 :                                 isRecordBlank = false;
   17610        8410 :                                 break;
   17611             :                             }
   17612             :                         }
   17613        8522 :                         if (!isRecordBlank) {
   17614        8410 :                             tbl_stream << "  <" << ort->activeSubTableName << ">\n";
   17615        8410 :                             if (len(rowLabelTags(jRow)) > 0) {
   17616        8410 :                                 tbl_stream << "    <name>" << rowLabelTags(jRow) << "</name>\n";
   17617             :                             }
   17618       77987 :                             for (iCol = 1; iCol <= colsBody; ++iCol) {
   17619       69577 :                                 if (len(stripped(bodyEsc(iCol, jRow))) > 0) { // skip blank cells
   17620       65816 :                                     tagWithAttrib = "<" + columnLabelTags(iCol);
   17621       65816 :                                     if (len(columnUnitStrings(iCol)) > 0) {
   17622       48434 :                                         tagWithAttrib += std::string(" units=") + char(34) + columnUnitStrings(iCol) + char(34) +
   17623             :                                                          '>'; // if units are present add them as an attribute
   17624             :                                     } else {
   17625       17382 :                                         tagWithAttrib += ">";
   17626             :                                     }
   17627       65816 :                                     tbl_stream << "    " << tagWithAttrib << stripped(bodyEsc(iCol, jRow)) << "</" << columnLabelTags(iCol) << ">\n";
   17628             :                                 }
   17629             :                             }
   17630        8410 :                             tbl_stream << "  </" << ort->activeSubTableName << ">\n";
   17631             :                         }
   17632             :                     }
   17633             :                 } else { // transpose XML table
   17634             :                     // body with row headers
   17635         544 :                     for (iCol = 1; iCol <= colsBody; ++iCol) {
   17636             :                         // check if record is blank and it if is skip generating anything
   17637         272 :                         isRecordBlank = true;
   17638         272 :                         for (jRow = 1; jRow <= rowsBody; ++jRow) {
   17639         272 :                             if (len(bodyEsc(iCol, jRow)) > 0) {
   17640         272 :                                 isRecordBlank = false;
   17641         272 :                                 break;
   17642             :                             }
   17643             :                         }
   17644         272 :                         if (!isRecordBlank) {
   17645         272 :                             tbl_stream << "  <" << ort->activeSubTableName << ">\n";
   17646             :                             // if the column has units put them into the name tag
   17647         272 :                             if (len(columnLabelTags(iCol)) > 0) {
   17648         272 :                                 if (len(columnUnitStrings(iCol)) > 0) {
   17649         109 :                                     tbl_stream << "    <name units=" << char(34) << columnUnitStrings(iCol) << char(34) << '>'
   17650         218 :                                                << columnLabelTags(iCol) << "</name>\n";
   17651             :                                 } else {
   17652         163 :                                     tbl_stream << "    <name>" << columnLabelTags(iCol) << "</name>\n";
   17653             :                                 }
   17654             :                             }
   17655        2070 :                             for (jRow = 1; jRow <= rowsBody; ++jRow) {
   17656        1798 :                                 if (len(bodyEsc(iCol, jRow)) > 0) { // skip blank cells
   17657        1782 :                                     tagWithAttrib = "<" + rowLabelTags(jRow);
   17658        1782 :                                     if (len(rowUnitStrings(jRow)) > 0) {
   17659         204 :                                         tagWithAttrib += std::string(" units=") + char(34) + rowUnitStrings(jRow) + char(34) +
   17660             :                                                          ">\n"; // if units are present add them as an attribute
   17661             :                                     } else {
   17662        1578 :                                         tagWithAttrib += ">";
   17663             :                                     }
   17664        1782 :                                     tbl_stream << "    " << tagWithAttrib << stripped(bodyEsc(iCol, jRow)) << "</" << rowLabelTags(jRow) << ">\n";
   17665             :                                 }
   17666             :                             }
   17667         272 :                             tbl_stream << "  </" << ort->activeSubTableName << ">\n";
   17668             :                         }
   17669             :                     }
   17670             :                 }
   17671        2182 :                 if (!footnoteText.empty()) {
   17672          77 :                     tbl_stream << fmt::format("  <footnote>{}</footnote>\n", footnoteText);
   17673             :                 }
   17674             :             }
   17675             :         } else {
   17676             :         }
   17677             :     }
   17678      126731 : }
   17679             : 
   17680       35608 : std::string MakeAnchorName(std::string const &reportString, std::string const &objectString)
   17681             : {
   17682             :     // SUBROUTINE INFORMATION:
   17683             :     //       AUTHOR         Jason Glazer
   17684             :     //       DATE WRITTEN   June 2005
   17685             :     //       MODIFIED
   17686             :     //       RE-ENGINEERED  na
   17687             : 
   17688             :     // PURPOSE OF THIS SUBROUTINE:
   17689             :     //   Use the name of the report and object be used to create and HTML anchor
   17690             : 
   17691             :     // METHODOLOGY EMPLOYED:
   17692             :     //   Remove spaces and put double colon between names
   17693             : 
   17694             :     // REFERENCES:
   17695             :     // na
   17696             : 
   17697             :     // USE STATEMENTS:
   17698             : 
   17699             :     // Return value
   17700       35608 :     std::string StringOut;
   17701       35608 :     StringOut.reserve(reportString.size() + objectString.size() + 2);
   17702             : 
   17703             :     // Locals
   17704             :     // SUBROUTINE ARGUMENT DEFINITIONS:
   17705             :     // na
   17706             : 
   17707             :     // SUBROUTINE PARAMETER DEFINITIONS:
   17708             : 
   17709             :     // INTERFACE BLOCK SPECIFICATIONS:
   17710             :     // na
   17711             : 
   17712             :     // DERIVED TYPE DEFINITIONS:
   17713             :     // na
   17714             : 
   17715             :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
   17716             : 
   17717      881440 :     for (auto const i : reportString) {
   17718      845832 :         if (has(validChars, i)) {
   17719      766415 :             StringOut += i;
   17720             :         }
   17721             :     }
   17722       35608 :     StringOut += "::";
   17723      569606 :     for (auto const i : objectString) {
   17724      533998 :         if (has(validChars, i)) {
   17725      498778 :             StringOut += i;
   17726             :         }
   17727             :     }
   17728       35608 :     return StringOut;
   17729             : }
   17730             : 
   17731     7650530 : std::string InsertCurrencySymbol(EnergyPlusData &state,
   17732             :                                  std::string const &inString, // Input String
   17733             :                                  bool const isHTML            // True if an HTML string
   17734             : )
   17735             : {
   17736             :     // SUBROUTINE INFORMATION:
   17737             :     //       AUTHOR         Jason Glazer
   17738             :     //       DATE WRITTEN   August 2008
   17739             :     //       MODIFIED       na
   17740             :     //       RE-ENGINEERED  na
   17741             : 
   17742             :     // PURPOSE OF THIS SUBROUTINE:
   17743             :     //   Looks for the ~~$~~
   17744             : 
   17745             :     // METHODOLOGY EMPLOYED:
   17746             :     //   na
   17747             :     // Using/Aliasing
   17748             : 
   17749             :     // Return value
   17750             : 
   17751             :     // Locals
   17752             :     // SUBROUTINE ARGUMENT DEFINITIONS:
   17753             : 
   17754             :     // SUBROUTINE PARAMETER DEFINITIONS:
   17755             :     // na
   17756             : 
   17757             :     // INTERFACE BLOCK SPECIFICATIONS:
   17758             :     // na
   17759             : 
   17760             :     // DERIVED TYPE DEFINITIONS:
   17761             :     // na
   17762             : 
   17763             :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
   17764             : 
   17765     7650530 :     std::string outSt(trimmed(inString)); // Result String
   17766     7650530 :     std::string::size_type loc = index(outSt, "~~$~~");
   17767     7654640 :     while (loc != std::string::npos) {
   17768        2055 :         if (isHTML) {
   17769        1723 :             outSt = inString.substr(0, loc) + state.dataCostEstimateManager->monetaryUnit(state.dataCostEstimateManager->selectedMonetaryUnit).html +
   17770        3446 :                     outSt.substr(loc + 5);
   17771             :         } else {
   17772         332 :             outSt = inString.substr(0, loc) + state.dataCostEstimateManager->monetaryUnit(state.dataCostEstimateManager->selectedMonetaryUnit).txt +
   17773         664 :                     outSt.substr(loc + 5);
   17774             :         }
   17775        2055 :         loc = index(outSt, "~~$~~");
   17776             :     }
   17777     7650530 :     return outSt;
   17778             : }
   17779             : 
   17780       30167 : std::string ConvertToElementTag(std::string const &inString) // Input String
   17781             : {
   17782             :     // SUBROUTINE INFORMATION:
   17783             :     //       AUTHOR         Jason Glazer
   17784             :     //       DATE WRITTEN   February 2013
   17785             :     //       MODIFIED       na
   17786             :     //       RE-ENGINEERED  na
   17787             : 
   17788             :     // PURPOSE OF THIS SUBROUTINE:
   17789             :     //   Convert report column or row header into a tag string
   17790             :     //   that just has A-Z, a-z, or 0-1 characters and is
   17791             :     //   shown in camelCase.
   17792             : 
   17793             :     // METHODOLOGY EMPLOYED:
   17794             :     //   na
   17795             : 
   17796             :     // Return value
   17797       30167 :     std::string outString; // Result String
   17798             : 
   17799             :     // Locals
   17800             :     // SUBROUTINE ARGUMENT DEFINITIONS:
   17801             : 
   17802             :     // SUBROUTINE PARAMETER DEFINITIONS:
   17803             :     // na
   17804             : 
   17805             :     // INTERFACE BLOCK SPECIFICATIONS:
   17806             :     // na
   17807             : 
   17808             :     // DERIVED TYPE DEFINITIONS:
   17809             :     // na
   17810             : 
   17811             :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
   17812             : 
   17813       30167 :     bool foundOther = true; // flag if character found besides A-Z, a-z, 0-9
   17814      624414 :     for (std::string::size_type iIn = 0, e = inString.length(); iIn < e; ++iIn) {
   17815      601593 :         char const c(inString[iIn]);
   17816      601593 :         int const curCharVal = int(c);
   17817      601593 :         if ((curCharVal >= 65) && (curCharVal <= 90)) { // A-Z upper case
   17818       92378 :             if (foundOther) {
   17819       75733 :                 outString += c; // keep as upper case after finding a space or another character
   17820             :             } else {
   17821       16645 :                 outString += char(curCharVal + 32); // convert to lower case
   17822             :             }
   17823       92378 :             foundOther = false;
   17824      509215 :         } else if ((curCharVal >= 97) && (curCharVal <= 122)) { // A-Z lower case
   17825      413792 :             if (foundOther) {
   17826        6174 :                 outString += char(curCharVal - 32); // convert to upper case
   17827             :             } else {
   17828      407618 :                 outString += c; // leave as lower case
   17829             :             }
   17830      413792 :             foundOther = false;
   17831       95423 :         } else if ((curCharVal >= 48) && (curCharVal <= 57)) { // 0-9 numbers
   17832             :             // if first character is a number then prepend with the letter "t"
   17833        9001 :             if (outString.length() == 0) outString += 't';
   17834        9001 :             outString += c;
   17835        9001 :             foundOther = false;
   17836       86422 :         } else if (curCharVal == 91) { // [ bracket
   17837        7346 :             break;                     // stop parsing because unit string was found
   17838             :         } else {
   17839       79076 :             foundOther = true;
   17840             :         }
   17841             :     }
   17842       30167 :     return outString;
   17843             : }
   17844             : 
   17845           0 : std::string ConvertUnicodeToUTF8(unsigned long const codepoint)
   17846             : {
   17847             :     // Taken from http://stackoverflow.com/a/19968992/2358662 and http://stackoverflow.com/a/148766/2358662
   17848           0 :     std::string s;
   17849           0 :     if (codepoint <= 0x7f) {
   17850           0 :         s.push_back(static_cast<char>(codepoint));
   17851           0 :     } else if (codepoint <= 0x7ff) {
   17852           0 :         s.push_back(static_cast<char>(0xc0 | ((codepoint >> 6) & 0x1f)));
   17853           0 :         s.push_back(static_cast<char>(0x80 | (codepoint & 0x3f)));
   17854           0 :     } else if (codepoint <= 0xffff) {
   17855           0 :         s.push_back(static_cast<char>(0xe0 | ((codepoint >> 12) & 0x0f)));
   17856           0 :         s.push_back(static_cast<char>(0x80 | ((codepoint >> 6) & 0x3f)));
   17857           0 :         s.push_back(static_cast<char>(0x80 | (codepoint & 0x3f)));
   17858           0 :     } else if (codepoint <= 0x10ffff) {
   17859           0 :         s.push_back(static_cast<char>(0xf0 | ((codepoint >> 18) & 0x07)));
   17860           0 :         s.push_back(static_cast<char>(0x80 | ((codepoint >> 12) & 0x3f)));
   17861           0 :         s.push_back(static_cast<char>(0x80 | ((codepoint >> 6) & 0x3f)));
   17862           0 :         s.push_back(static_cast<char>(0x80 | (codepoint & 0x3f)));
   17863             :     }
   17864           0 :     return s;
   17865             : }
   17866             : 
   17867     7591722 : std::string ConvertToEscaped(std::string const &inString, bool isXML) // Input String
   17868             : {
   17869             :     // SUBROUTINE INFORMATION:
   17870             :     //       AUTHOR         Jason Glazer
   17871             :     //       DATE WRITTEN   February 2013
   17872             :     //       MODIFIED       na
   17873             :     //       RE-ENGINEERED  na
   17874             : 
   17875             :     // PURPOSE OF THIS SUBROUTINE:
   17876             :     //   Convert to XML safe escaped character string
   17877             :     //   so it excludes:
   17878             :     //               " ' < > & degree-sign
   17879             :     //   If isXML=false, it does an HTML conversion, so only ` < > & ` and degree sign
   17880             :     //   Technically HTML4 doesn't support &quot, though most browsers would anyways.
   17881             :     //   Also, escaping single and double quotes is only needed inside attributes
   17882             : 
   17883     7591722 :     if (inString.empty()) return "";
   17884             : 
   17885    15145622 :     std::string s;
   17886     7572811 :     auto const inputSize = inString.size();
   17887     7572811 :     s.reserve(inputSize);
   17888     7572811 :     size_t index(0);
   17889             :     char c;
   17890             : 
   17891             :     while (true) {
   17892   107486432 :         if (index == inputSize) break;
   17893    99913621 :         c = inString[index++];
   17894    99913621 :         if ((c == '\"') && isXML) {
   17895           0 :             s += "&quot;";
   17896    99913621 :         } else if (c == '&') {
   17897        3970 :             s += "&amp;";
   17898    99909651 :         } else if ((c == '\'') && isXML) {
   17899          30 :             s += "&apos;";
   17900    99909621 :         } else if (c == '<') {
   17901        9722 :             s += "&lt;";
   17902    99899899 :         } else if (c == '>') {
   17903       37833 :             s += "&gt;";
   17904    99862066 :         } else if (c == char(176)) {
   17905        2148 :             s += "&deg;";
   17906    99859918 :         } else if (c == '\xC2') {
   17907       31942 :             if (index == inputSize) {
   17908           0 :                 s += '\xC2';
   17909             :             } else {
   17910       31942 :                 c = inString[index++];
   17911       31942 :                 if (c == '\xB0') {
   17912       28126 :                     s += "&deg;";
   17913             :                 } else {
   17914        3816 :                     s += '\xC2';
   17915        3816 :                     s += c;
   17916             :                 }
   17917             :             }
   17918    99827976 :         } else if (c == '\xB0') {
   17919           0 :             s += "&deg;";
   17920    99827976 :         } else if (c == '\\') {
   17921           0 :             if (index == inputSize) break;
   17922           0 :             c = inString[index++];
   17923           0 :             if ((c == '"') && isXML) {
   17924           0 :                 s += "&quot;";
   17925           0 :             } else if ((c == '\'') && isXML) {
   17926           0 :                 s += "&apos;";
   17927           0 :             } else if (c == 'u' || c == 'x') {
   17928           0 :                 int remainingLen = inputSize - index;
   17929           0 :                 unsigned long codePoint(0);
   17930           0 :                 if (c == 'u' && remainingLen > 3) {
   17931           0 :                     codePoint = std::stoul(inString.substr(index, 4), nullptr, 16);
   17932           0 :                     index += 4;
   17933           0 :                 } else if (c == 'x' && remainingLen > 1) {
   17934           0 :                     codePoint = std::stoul(inString.substr(index, 2), nullptr, 16);
   17935           0 :                     index += 2;
   17936             :                 }
   17937           0 :                 auto const unicodeString = ConvertUnicodeToUTF8(codePoint);
   17938           0 :                 if (unicodeString == "\xC2\xB0") { // only check for degree at this point
   17939           0 :                     s += "&deg;";
   17940             :                 } else {
   17941           0 :                     s += unicodeString;
   17942           0 :                 }
   17943             :             } else {
   17944           0 :                 s += c;
   17945             :             }
   17946             :         } else {
   17947    99827976 :             s += c;
   17948             :         }
   17949    99913621 :     }
   17950     7572811 :     return s;
   17951             : }
   17952             : 
   17953        1501 : void DetermineBuildingFloorArea(EnergyPlusData &state)
   17954             : {
   17955             : 
   17956             :     // SUBROUTINE INFORMATION:
   17957             :     //       AUTHOR         Jason Glazer
   17958             :     //       DATE WRITTEN   November 2003
   17959             :     //       MODIFIED       BTG added checks for plenums. Feb2004
   17960             :     //       RE-ENGINEERED  na
   17961             : 
   17962             :     // PURPOSE OF THIS SUBROUTINE:
   17963             :     //   To determine the total floor area of the building and the
   17964             :     //   conditioned floor area of the building
   17965             : 
   17966             :     // METHODOLOGY EMPLOYED:
   17967             :     //   Use the Zone array and sum the areas for all zones
   17968             : 
   17969             :     // REFERENCES:
   17970             :     // na
   17971             : 
   17972             :     // Using/Aliasing
   17973             : 
   17974             :     // Locals
   17975             :     // SUBROUTINE ARGUMENT DEFINITIONS:
   17976             :     // na
   17977             : 
   17978             :     // SUBROUTINE PARAMETER DEFINITIONS:
   17979             : 
   17980             :     // INTERFACE BLOCK SPECIFICATIONS:
   17981             :     // na
   17982             : 
   17983             :     // DERIVED TYPE DEFINITIONS:
   17984             :     // na
   17985             : 
   17986             :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
   17987             :     Real64 curZoneArea;
   17988             :     int iZone;
   17989        1501 :     auto &ort(state.dataOutRptTab);
   17990        1501 :     auto &Zone(state.dataHeatBal->Zone);
   17991             : 
   17992        1501 :     ort->buildingGrossFloorArea = 0.0;
   17993        1501 :     ort->buildingConditionedFloorArea = 0.0;
   17994        9906 :     for (iZone = 1; iZone <= state.dataGlobal->NumOfZones; ++iZone) {
   17995        8405 :         curZoneArea = Zone(iZone).FloorArea * Zone(iZone).Multiplier * Zone(iZone).ListMultiplier;
   17996             : 
   17997             :         // OLD CHECK IF PLENUM SHOULD BE EXCLUDED AUTOMATICALLY
   17998             :         // check if this zone is also a return plenum or a supply plenum
   17999             :         // found = 0
   18000             :         // if (NumZoneReturnPlenums > 0) THEN
   18001             :         //  found = UtilityRoutines::FindItemInList(Zone(iZone)%Name, ZoneRetPlenCond%ZoneName, NumZoneReturnPlenums)
   18002             :         // endif
   18003             :         // IF (found /= 0)  curZoneArea = 0.0d0
   18004             :         // found = 0
   18005             :         // if (NumZoneSupplyPlenums > 0) THEN
   18006             :         //  found = UtilityRoutines::FindItemInList(Zone(iZone)%Name, ZoneSupPlenCond%ZoneName, NumZoneSupplyPlenums)
   18007             :         // endif
   18008             :         // IF (found /= 0)  curZoneArea = 0.0d0
   18009             : 
   18010        8405 :         if (Zone(iZone).isPartOfTotalArea) {
   18011        8249 :             ort->buildingGrossFloorArea += curZoneArea;
   18012             :             // If a ZoneHVAC:EquipmentConnections is used for a zone then
   18013             :             // it is considered conditioned. Also ZONE SUPPLY PLENUM and ZONE RETURN PLENUM are
   18014             :             // also is considered conditioned.
   18015        8249 :             if (Zone(iZone).SystemZoneNodeNumber > 0) {
   18016        7371 :                 ort->buildingConditionedFloorArea += curZoneArea;
   18017             :             }
   18018             :         }
   18019             :     }
   18020        1501 : }
   18021             : 
   18022        2116 : void FillRowHead(Array1D_string &rowHead)
   18023             : {
   18024             :     // Forward fill the blanks in rowHead (eg End use column)
   18025        4232 :     std::string currentEndUseName;
   18026       33375 :     for (size_t i = 1; i <= rowHead.size(); ++i) {
   18027       62518 :         std::string thisEndUseName = rowHead(i);
   18028       31259 :         if (thisEndUseName.empty()) {
   18029        1635 :             rowHead(i) = currentEndUseName;
   18030             :         } else {
   18031       29624 :             currentEndUseName = thisEndUseName;
   18032             :         }
   18033             :     }
   18034        2116 : }
   18035             : 
   18036             : //======================================================================================================================
   18037             : //======================================================================================================================
   18038             : 
   18039             : //    ROUTINES TO RESET GATHERED VALUES TO ZERO
   18040             : 
   18041             : //======================================================================================================================
   18042             : //======================================================================================================================
   18043             : 
   18044           0 : void ResetTabularReports(EnergyPlusData &state)
   18045             : {
   18046             :     // Jason Glazer - October 2015
   18047             :     // Reset all gathering arrays to zero for multi-year simulations
   18048             :     // so that only last year is reported in tabular reports
   18049           0 :     state.dataOutRptTab->gatherElapsedTimeBEPS = 0.0;
   18050           0 :     ResetMonthlyGathering(state);
   18051           0 :     OutputReportTabularAnnual::ResetAnnualGathering(state);
   18052           0 :     ResetBinGathering(state);
   18053           0 :     ResetBEPSGathering(state);
   18054           0 :     ResetSourceEnergyEndUseGathering(state);
   18055           0 :     ResetPeakDemandGathering(state);
   18056           0 :     ResetHeatGainGathering(state);
   18057           0 :     ResetRemainingPredefinedEntries(state);
   18058           0 :     ThermalComfort::ResetThermalComfortSimpleASH55(state);
   18059           0 :     ThermalComfort::ResetSetPointMet(state);
   18060           0 :     ResetAdaptiveComfort(state);
   18061           0 :     state.dataOutputProcessor->isFinalYear = true;
   18062           0 : }
   18063             : 
   18064           0 : void ResetMonthlyGathering(EnergyPlusData &state)
   18065             : {
   18066             :     // Jason Glazer - October 2015
   18067             :     // Reset all monthly gathering arrays to zero for multi-year simulations
   18068             :     // so that only last year is reported in tabular reports
   18069             :     int iInput;
   18070             :     int jTable;
   18071             :     int kColumn;
   18072             :     int curTable;
   18073             :     int curCol;
   18074           0 :     auto &ort(state.dataOutRptTab);
   18075             : 
   18076           0 :     for (iInput = 1; iInput <= ort->MonthlyInputCount; ++iInput) {
   18077           0 :         for (jTable = 1; jTable <= ort->MonthlyInput(iInput).numTables; ++jTable) {
   18078           0 :             curTable = jTable + ort->MonthlyInput(iInput).firstTable - 1;
   18079           0 :             for (kColumn = 1; kColumn <= ort->MonthlyTables(curTable).numColumns; ++kColumn) {
   18080           0 :                 curCol = kColumn + ort->MonthlyTables(curTable).firstColumn - 1;
   18081           0 :                 ort->MonthlyColumns(curCol).timeStamp = 0;
   18082           0 :                 ort->MonthlyColumns(curCol).duration = 0.0;
   18083           0 :                 if (ort->MonthlyColumns(curCol).aggType == AggType::Maximum ||
   18084           0 :                     ort->MonthlyColumns(curCol).aggType == AggType::MaximumDuringHoursShown) {
   18085           0 :                     ort->MonthlyColumns(curCol).reslt = -HUGE_(state.dataOutRptTab->BigNumRMG);
   18086           0 :                 } else if (ort->MonthlyColumns(curCol).aggType == AggType::Minimum ||
   18087           0 :                            ort->MonthlyColumns(curCol).aggType == AggType::MinimumDuringHoursShown) {
   18088           0 :                     ort->MonthlyColumns(curCol).reslt = HUGE_(state.dataOutRptTab->BigNumRMG);
   18089             :                 } else {
   18090           0 :                     ort->MonthlyColumns(curCol).reslt = 0.0;
   18091             :                 }
   18092             :             }
   18093             :         }
   18094             :     }
   18095           0 : }
   18096             : 
   18097           0 : void ResetBinGathering(EnergyPlusData &state)
   18098             : {
   18099             :     // Jason Glazer - October 2015
   18100             :     // Reset all timebins gathering arrays to zero for multi-year simulations
   18101             :     // so that only last year is reported in tabular reports
   18102           0 :     Real64 constexpr bigVal(0.0); // used with HUGE: Value doesn't matter, only type: Initialize so compiler doesn't warn about use uninitialized
   18103           0 :     auto &ort(state.dataOutRptTab);
   18104             : 
   18105             :     // clear the binning arrays to zeros
   18106           0 :     for (auto &e : ort->BinResults) {
   18107           0 :         e.mnth = 0.0;
   18108           0 :         e.hrly = 0.0;
   18109             :     }
   18110           0 :     for (auto &e : ort->BinResultsBelow) {
   18111           0 :         e.mnth = 0.0;
   18112           0 :         e.hrly = 0.0;
   18113             :     }
   18114           0 :     for (auto &e : ort->BinResultsAbove) {
   18115           0 :         e.mnth = 0.0;
   18116           0 :         e.hrly = 0.0;
   18117             :     }
   18118             : 
   18119             :     // re-initialize statistics counters
   18120           0 :     for (auto &e : ort->BinStatistics) {
   18121           0 :         e.minimum = HUGE_(bigVal);
   18122           0 :         e.maximum = -HUGE_(bigVal);
   18123           0 :         e.n = 0;
   18124           0 :         e.sum = 0.0;
   18125           0 :         e.sum2 = 0.0;
   18126             :     }
   18127           0 : }
   18128             : 
   18129           0 : void ResetBEPSGathering(EnergyPlusData &state)
   18130             : {
   18131             :     // Jason Glazer - October 2015
   18132             :     // Reset all ABUPS gathering arrays to zero for multi-year simulations
   18133             :     // so that only last year is reported in tabular reports
   18134           0 :     auto &ort(state.dataOutRptTab);
   18135           0 :     ort->gatherTotalsBEPS = 0.0;
   18136           0 :     ort->gatherEndUseBEPS = 0.0;
   18137           0 :     ort->gatherEndUseSubBEPS = 0.0;
   18138           0 :     ort->gatherTotalsSource = 0.0;
   18139             :     // reset the specific components being gathered
   18140           0 :     ort->gatherPowerFuelFireGen = 0.0;
   18141           0 :     ort->gatherPowerPV = 0.0;
   18142           0 :     ort->gatherPowerWind = 0.0;
   18143           0 :     ort->gatherPowerHTGeothermal = 0.0;
   18144           0 :     ort->gatherElecProduced = 0.0;
   18145           0 :     ort->gatherElecPurchased = 0.0;
   18146           0 :     ort->gatherElecSurplusSold = 0.0;
   18147           0 :     ort->gatherElecStorage = 0.0;
   18148           0 :     ort->gatherPowerConversion = 0.0;
   18149           0 :     ort->gatherWaterHeatRecovery = 0.0;
   18150           0 :     ort->gatherAirHeatRecoveryCool = 0.0;
   18151           0 :     ort->gatherAirHeatRecoveryHeat = 0.0;
   18152           0 :     ort->gatherHeatHTGeothermal = 0.0;
   18153           0 :     ort->gatherHeatSolarWater = 0.0;
   18154           0 :     ort->gatherHeatSolarAir = 0.0;
   18155           0 :     ort->gatherRainWater = 0.0;
   18156           0 :     ort->gatherCondensate = 0.0;
   18157           0 :     ort->gatherWellwater = 0.0;
   18158           0 :     ort->gatherMains = 0.0;
   18159           0 :     ort->gatherWaterEndUseTotal = 0.0;
   18160           0 : }
   18161             : 
   18162           0 : void ResetSourceEnergyEndUseGathering(EnergyPlusData &state)
   18163             : {
   18164             :     // Jason Glazer - October 2015
   18165             :     // Reset all source energy end use table gathering arrays to zero for multi-year simulations
   18166             :     // so that only last year is reported in tabular reports
   18167           0 :     auto &ort(state.dataOutRptTab);
   18168           0 :     ort->gatherTotalsBySourceBEPS = 0.0;
   18169           0 :     ort->gatherEndUseBySourceBEPS = 0.0;
   18170           0 : }
   18171             : 
   18172           0 : void ResetPeakDemandGathering(EnergyPlusData &state)
   18173             : {
   18174             :     // Jason Glazer - October 2015
   18175             :     // Reset all demand end use components table gathering arrays to zero for multi-year simulations
   18176             :     // so that only last year is reported in tabular reports
   18177           0 :     auto &ort(state.dataOutRptTab);
   18178           0 :     ort->gatherDemandTotal = 0.0;
   18179           0 :     ort->gatherDemandTimeStamp = 0;
   18180           0 :     ort->gatherDemandEndUse = 0.0;
   18181           0 :     ort->gatherDemandEndUseSub = 0.0;
   18182           0 : }
   18183             : 
   18184           0 : void ResetHeatGainGathering(EnergyPlusData &state)
   18185             : {
   18186             :     // Jason Glazer - October 2015
   18187             :     // Reset all sensible heat gas summary report gathering arrays to zero for multi-year simulations
   18188             :     // so that only last year is reported in tabular reports
   18189             :     int iZone;
   18190             : 
   18191           0 :     auto &ZonePreDefRep(state.dataHeatBal->ZonePreDefRep);
   18192           0 :     for (iZone = 1; iZone <= state.dataGlobal->NumOfZones; ++iZone) {
   18193           0 :         ZonePreDefRep(iZone).SHGSAnPeoplAdd = 0.;
   18194           0 :         ZonePreDefRep(iZone).SHGSAnLiteAdd = 0.;
   18195           0 :         ZonePreDefRep(iZone).SHGSAnZoneEqHt = 0.;
   18196           0 :         ZonePreDefRep(iZone).SHGSAnZoneEqCl = 0.;
   18197           0 :         ZonePreDefRep(iZone).SHGSAnIzaAdd = 0.;
   18198           0 :         ZonePreDefRep(iZone).SHGSAnIzaRem = 0.;
   18199           0 :         ZonePreDefRep(iZone).SHGSAnWindAdd = 0.;
   18200           0 :         ZonePreDefRep(iZone).SHGSAnWindRem = 0.;
   18201           0 :         ZonePreDefRep(iZone).SHGSAnInfilAdd = 0.;
   18202           0 :         ZonePreDefRep(iZone).SHGSAnInfilRem = 0.;
   18203           0 :         ZonePreDefRep(iZone).SHGSAnEquipAdd = 0.;
   18204           0 :         ZonePreDefRep(iZone).SHGSAnEquipRem = 0.;
   18205           0 :         ZonePreDefRep(iZone).SHGSAnHvacATUHt = 0.;
   18206           0 :         ZonePreDefRep(iZone).SHGSAnHvacATUCl = 0.;
   18207           0 :         ZonePreDefRep(iZone).SHGSAnSurfHt = 0.;
   18208           0 :         ZonePreDefRep(iZone).SHGSAnSurfCl = 0.;
   18209           0 :         ZonePreDefRep(iZone).SHGSAnOtherAdd = 0.;
   18210           0 :         ZonePreDefRep(iZone).SHGSAnOtherRem = 0.;
   18211           0 :         ZonePreDefRep(iZone).htPeak = 0.;
   18212           0 :         ZonePreDefRep(iZone).htPtTimeStamp = 0;
   18213           0 :         ZonePreDefRep(iZone).SHGSHtHvacHt = 0.;
   18214           0 :         ZonePreDefRep(iZone).SHGSHtHvacCl = 0.;
   18215           0 :         ZonePreDefRep(iZone).SHGSHtSurfHt = 0.;
   18216           0 :         ZonePreDefRep(iZone).SHGSHtSurfCl = 0.;
   18217           0 :         ZonePreDefRep(iZone).SHGSHtHvacATUHt = 0.;
   18218           0 :         ZonePreDefRep(iZone).SHGSHtHvacATUCl = 0.;
   18219           0 :         ZonePreDefRep(iZone).SHGSHtPeoplAdd = 0.;
   18220           0 :         ZonePreDefRep(iZone).SHGSHtLiteAdd = 0.;
   18221           0 :         ZonePreDefRep(iZone).SHGSHtEquipAdd = 0.;
   18222           0 :         ZonePreDefRep(iZone).SHGSHtEquipRem = 0.;
   18223           0 :         ZonePreDefRep(iZone).SHGSHtWindAdd = 0.;
   18224           0 :         ZonePreDefRep(iZone).SHGSHtWindRem = 0.;
   18225           0 :         ZonePreDefRep(iZone).SHGSHtIzaAdd = 0.;
   18226           0 :         ZonePreDefRep(iZone).SHGSHtIzaRem = 0.;
   18227           0 :         ZonePreDefRep(iZone).SHGSHtInfilAdd = 0.;
   18228           0 :         ZonePreDefRep(iZone).SHGSHtInfilRem = 0.;
   18229           0 :         ZonePreDefRep(iZone).SHGSHtOtherAdd = 0.;
   18230           0 :         ZonePreDefRep(iZone).SHGSHtOtherRem = 0.;
   18231           0 :         ZonePreDefRep(iZone).clPeak = 0.;
   18232           0 :         ZonePreDefRep(iZone).clPtTimeStamp = 0;
   18233           0 :         ZonePreDefRep(iZone).SHGSClHvacHt = 0.;
   18234           0 :         ZonePreDefRep(iZone).SHGSClHvacCl = 0.;
   18235           0 :         ZonePreDefRep(iZone).SHGSClSurfHt = 0.;
   18236           0 :         ZonePreDefRep(iZone).SHGSClSurfCl = 0.;
   18237           0 :         ZonePreDefRep(iZone).SHGSClHvacATUHt = 0.;
   18238           0 :         ZonePreDefRep(iZone).SHGSClHvacATUCl = 0.;
   18239           0 :         ZonePreDefRep(iZone).SHGSClPeoplAdd = 0.;
   18240           0 :         ZonePreDefRep(iZone).SHGSClLiteAdd = 0.;
   18241           0 :         ZonePreDefRep(iZone).SHGSClEquipAdd = 0.;
   18242           0 :         ZonePreDefRep(iZone).SHGSClEquipRem = 0.;
   18243           0 :         ZonePreDefRep(iZone).SHGSClWindAdd = 0.;
   18244           0 :         ZonePreDefRep(iZone).SHGSClWindRem = 0.;
   18245           0 :         ZonePreDefRep(iZone).SHGSClIzaAdd = 0.;
   18246           0 :         ZonePreDefRep(iZone).SHGSClIzaRem = 0.;
   18247           0 :         ZonePreDefRep(iZone).SHGSClInfilAdd = 0.;
   18248           0 :         ZonePreDefRep(iZone).SHGSClInfilRem = 0.;
   18249           0 :         ZonePreDefRep(iZone).SHGSClOtherAdd = 0.;
   18250           0 :         ZonePreDefRep(iZone).SHGSClOtherRem = 0.;
   18251             :     }
   18252             : 
   18253           0 :     state.dataHeatBal->BuildingPreDefRep.htPeak = 0.;
   18254           0 :     state.dataHeatBal->BuildingPreDefRep.htPtTimeStamp = 0;
   18255           0 :     state.dataHeatBal->BuildingPreDefRep.SHGSHtHvacHt = 0.0;
   18256           0 :     state.dataHeatBal->BuildingPreDefRep.SHGSHtHvacCl = 0.0;
   18257           0 :     state.dataHeatBal->BuildingPreDefRep.SHGSHtHvacATUHt = 0.0;
   18258           0 :     state.dataHeatBal->BuildingPreDefRep.SHGSHtHvacATUCl = 0.0;
   18259           0 :     state.dataHeatBal->BuildingPreDefRep.SHGSHtSurfHt = 0.0;
   18260           0 :     state.dataHeatBal->BuildingPreDefRep.SHGSHtSurfCl = 0.0;
   18261           0 :     state.dataHeatBal->BuildingPreDefRep.SHGSHtPeoplAdd = 0.0;
   18262           0 :     state.dataHeatBal->BuildingPreDefRep.SHGSHtLiteAdd = 0.0;
   18263           0 :     state.dataHeatBal->BuildingPreDefRep.SHGSHtEquipAdd = 0.0;
   18264           0 :     state.dataHeatBal->BuildingPreDefRep.SHGSHtWindAdd = 0.0;
   18265           0 :     state.dataHeatBal->BuildingPreDefRep.SHGSHtIzaAdd = 0.0;
   18266           0 :     state.dataHeatBal->BuildingPreDefRep.SHGSHtInfilAdd = 0.0;
   18267           0 :     state.dataHeatBal->BuildingPreDefRep.SHGSHtOtherAdd = 0.0;
   18268           0 :     state.dataHeatBal->BuildingPreDefRep.SHGSHtEquipRem = 0.0;
   18269           0 :     state.dataHeatBal->BuildingPreDefRep.SHGSHtWindRem = 0.0;
   18270           0 :     state.dataHeatBal->BuildingPreDefRep.SHGSHtIzaRem = 0.0;
   18271           0 :     state.dataHeatBal->BuildingPreDefRep.SHGSHtInfilRem = 0.0;
   18272           0 :     state.dataHeatBal->BuildingPreDefRep.SHGSHtOtherRem = 0.0;
   18273             : 
   18274           0 :     state.dataHeatBal->BuildingPreDefRep.clPeak = 0.;
   18275           0 :     state.dataHeatBal->BuildingPreDefRep.clPtTimeStamp = 0;
   18276           0 :     state.dataHeatBal->BuildingPreDefRep.SHGSClHvacHt = 0.0;
   18277           0 :     state.dataHeatBal->BuildingPreDefRep.SHGSClHvacCl = 0.0;
   18278           0 :     state.dataHeatBal->BuildingPreDefRep.SHGSClSurfHt = 0.0;
   18279           0 :     state.dataHeatBal->BuildingPreDefRep.SHGSClSurfCl = 0.0;
   18280           0 :     state.dataHeatBal->BuildingPreDefRep.SHGSClHvacATUHt = 0.0;
   18281           0 :     state.dataHeatBal->BuildingPreDefRep.SHGSClHvacATUCl = 0.0;
   18282           0 :     state.dataHeatBal->BuildingPreDefRep.SHGSClPeoplAdd = 0.0;
   18283           0 :     state.dataHeatBal->BuildingPreDefRep.SHGSClLiteAdd = 0.0;
   18284           0 :     state.dataHeatBal->BuildingPreDefRep.SHGSClEquipAdd = 0.0;
   18285           0 :     state.dataHeatBal->BuildingPreDefRep.SHGSClWindAdd = 0.0;
   18286           0 :     state.dataHeatBal->BuildingPreDefRep.SHGSClIzaAdd = 0.0;
   18287           0 :     state.dataHeatBal->BuildingPreDefRep.SHGSClInfilAdd = 0.0;
   18288           0 :     state.dataHeatBal->BuildingPreDefRep.SHGSClOtherAdd = 0.0;
   18289           0 :     state.dataHeatBal->BuildingPreDefRep.SHGSClEquipRem = 0.0;
   18290           0 :     state.dataHeatBal->BuildingPreDefRep.SHGSClWindRem = 0.0;
   18291           0 :     state.dataHeatBal->BuildingPreDefRep.SHGSClIzaRem = 0.0;
   18292           0 :     state.dataHeatBal->BuildingPreDefRep.SHGSClInfilRem = 0.0;
   18293           0 :     state.dataHeatBal->BuildingPreDefRep.SHGSClOtherRem = 0.0;
   18294           0 : }
   18295             : 
   18296           0 : void ResetRemainingPredefinedEntries(EnergyPlusData &state)
   18297             : {
   18298             :     // Jason Glazer - October 2015
   18299             :     // Reset all entries that are added to the predefined reports in the FillRemainingPredefinedEntries() function to zero for multi-year
   18300             :     // simulations so that only last year is reported in tabular reports
   18301             : 
   18302           0 :     Real64 constexpr bigVal(0.0); // used with HUGE: Value doesn't matter, only type: Initialize so compiler doesn't warn about use uninitialized
   18303             :     int iLight;
   18304             :     int iZone;
   18305           0 :     auto &Zone(state.dataHeatBal->Zone);
   18306           0 :     auto &ZonePreDefRep(state.dataHeatBal->ZonePreDefRep);
   18307             : 
   18308           0 :     for (iLight = 1; iLight <= state.dataHeatBal->TotLights; ++iLight) {
   18309           0 :         state.dataHeatBal->Lights(iLight).SumTimeNotZeroCons = 0.;
   18310           0 :         state.dataHeatBal->Lights(iLight).SumConsumption = 0.;
   18311             :     }
   18312             : 
   18313           0 :     for (iZone = 1; iZone <= state.dataGlobal->NumOfZones; ++iZone) {
   18314           0 :         if (Zone(iZone).SystemZoneNodeNumber >= 0) { // conditioned zones only
   18315           0 :             if (Zone(iZone).isNominalOccupied) {
   18316           0 :                 ZonePreDefRep(iZone).MechVentVolTotalOcc = 0.;
   18317           0 :                 ZonePreDefRep(iZone).MechVentVolTotalOccStdDen = 0.;
   18318           0 :                 ZonePreDefRep(iZone).MechVentVolMin = HUGE_(bigVal);
   18319           0 :                 ZonePreDefRep(iZone).InfilVolTotalOcc = 0.;
   18320           0 :                 ZonePreDefRep(iZone).InfilVolTotalOccStdDen = 0.;
   18321           0 :                 ZonePreDefRep(iZone).InfilVolMin = HUGE_(bigVal);
   18322           0 :                 ZonePreDefRep(iZone).AFNInfilVolTotalOcc = 0.;
   18323           0 :                 ZonePreDefRep(iZone).AFNInfilVolTotalOccStdDen = 0.;
   18324           0 :                 ZonePreDefRep(iZone).AFNInfilVolMin = HUGE_(bigVal);
   18325           0 :                 ZonePreDefRep(iZone).SimpVentVolTotalOcc = 0.;
   18326           0 :                 ZonePreDefRep(iZone).SimpVentVolTotalOccStdDen = 0.;
   18327           0 :                 ZonePreDefRep(iZone).SimpVentVolMin = HUGE_(bigVal);
   18328           0 :                 ZonePreDefRep(iZone).AFNVentVolTotalOccStdDen = 0.;
   18329           0 :                 ZonePreDefRep(iZone).TotTimeOcc = 0.;
   18330             :             }
   18331             :         }
   18332             :     }
   18333           0 : }
   18334             : 
   18335           0 : void ResetAdaptiveComfort(EnergyPlusData &state)
   18336             : {
   18337             :     // Jason Glazer - October 2015
   18338             :     // Reset accumulation variable for adaptive comfort report to zero for multi-year simulations
   18339             :     // so that only last year is reported in tabular reports
   18340             :     int i;
   18341           0 :     auto &ort(state.dataOutRptTab);
   18342           0 :     if (ort->displayAdaptiveComfort && state.dataHeatBal->TotPeople > 0) {
   18343           0 :         for (i = 1; i <= state.dataHeatBal->TotPeople; ++i) {
   18344           0 :             if (state.dataHeatBal->People(i).AdaptiveASH55) {
   18345           0 :                 state.dataHeatBal->People(i).TimeNotMetASH5590 = 0.;
   18346           0 :                 state.dataHeatBal->People(i).TimeNotMetASH5580 = 0.;
   18347             :             }
   18348           0 :             if (state.dataHeatBal->People(i).AdaptiveCEN15251) {
   18349           0 :                 state.dataHeatBal->People(i).TimeNotMetCEN15251CatI = 0.;
   18350           0 :                 state.dataHeatBal->People(i).TimeNotMetCEN15251CatII = 0.;
   18351           0 :                 state.dataHeatBal->People(i).TimeNotMetCEN15251CatIII = 0.;
   18352             :             }
   18353             :         }
   18354             :     }
   18355           0 : }
   18356             : 
   18357             : //======================================================================================================================
   18358             : //======================================================================================================================
   18359             : 
   18360             : //    ROUTINES RELATED TO IF VALUE IS IN A RANGE
   18361             : 
   18362             : //======================================================================================================================
   18363             : //======================================================================================================================
   18364             : 
   18365     2542720 : bool isInTriangle(
   18366             :     Real64 const qx, Real64 const qy, Real64 const x1, Real64 const y1, Real64 const x2, Real64 const y2, Real64 const x3, Real64 const y3)
   18367             : {
   18368             :     // SUBROUTINE INFORMATION:
   18369             :     //       AUTHOR         Jason Glazer
   18370             :     //       DATE WRITTEN   June 2005
   18371             :     //       MODIFIED
   18372             :     //       RE-ENGINEERED  na
   18373             : 
   18374             :     // PURPOSE OF THIS SUBROUTINE:
   18375             :     //   Determine if point q is in triangle defined by points a,b,c
   18376             : 
   18377             :     // METHODOLOGY EMPLOYED:
   18378             :     //   The function used three times is positive the point is on the "right"
   18379             :     //   side and negative if on "left" side. By checking to make sure the signs
   18380             :     //   are always the same. it determines that the point is inside of the
   18381             :     //   triangle.
   18382             : 
   18383             :     // REFERENCES:
   18384             :     //   http://mcraefamily.com/MathHelp/GeometryPointAndTriangle2.htm
   18385             : 
   18386             :     // USE STATEMENTS:
   18387             : 
   18388             :     // Return value
   18389             :     bool isInTriangle;
   18390             : 
   18391             :     // Locals
   18392             :     // SUBROUTINE ARGUMENT DEFINITIONS:
   18393             :     // na
   18394             : 
   18395             :     // SUBROUTINE PARAMETER DEFINITIONS:
   18396             : 
   18397             :     // INTERFACE BLOCK SPECIFICATIONS:
   18398             :     // na
   18399             : 
   18400             :     // DERIVED TYPE DEFINITIONS:
   18401             :     // na
   18402             : 
   18403             :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
   18404             :     Real64 fAB;
   18405             :     Real64 fCA;
   18406             :     Real64 fBC;
   18407             : 
   18408     2542720 :     fAB = (qy - y1) * (x2 - x1) - (qx - x1) * (y2 - y1);
   18409     2542720 :     fCA = (qy - y3) * (x1 - x3) - (qx - x3) * (y1 - y3);
   18410     2542720 :     fBC = (qy - y2) * (x3 - x2) - (qx - x2) * (y3 - y2);
   18411     2542720 :     if ((fAB * fBC) >= 0.0 && (fBC * fCA) >= 0.0) {
   18412      484781 :         isInTriangle = true;
   18413             :     } else {
   18414     2057939 :         isInTriangle = false;
   18415             :     }
   18416     2542720 :     return isInTriangle;
   18417             : }
   18418             : 
   18419     1271360 : bool isInQuadrilateral(Real64 const qx,
   18420             :                        Real64 const qy,
   18421             :                        Real64 const ax,
   18422             :                        Real64 const ay,
   18423             :                        Real64 const bx,
   18424             :                        Real64 const by,
   18425             :                        Real64 const cx,
   18426             :                        Real64 const cy,
   18427             :                        Real64 const dx,
   18428             :                        Real64 const dy)
   18429             : {
   18430             :     // SUBROUTINE INFORMATION:
   18431             :     //       AUTHOR         Jason Glazer
   18432             :     //       DATE WRITTEN   June 2005
   18433             :     //       MODIFIED
   18434             :     //       RE-ENGINEERED  na
   18435             : 
   18436             :     // PURPOSE OF THIS SUBROUTINE:
   18437             :     //   Determine if point q is in a quadrilateral defined by points a,b,c,d
   18438             :     //   Those points should express a quadrilateral in order of the points going
   18439             :     //   around the outside of the polygon. They should not describe an "hourglass"
   18440             :     //   shape where the lines cross in the middle of the figure.
   18441             : 
   18442             :     // METHODOLOGY EMPLOYED:
   18443             :     //   Check if the point is in triangle a,b,c or in triangle c,d,a
   18444             : 
   18445             :     // REFERENCES:
   18446             :     //   http://mcraefamily.com/MathHelp/GeometryPointAndTriangle4.htm
   18447             : 
   18448             :     // USE STATEMENTS:
   18449             : 
   18450             :     // Return value
   18451             :     bool isInQuadrilateral;
   18452             : 
   18453             :     // Locals
   18454             :     // SUBROUTINE ARGUMENT DEFINITIONS:
   18455             :     // na
   18456             : 
   18457             :     // SUBROUTINE PARAMETER DEFINITIONS:
   18458             : 
   18459             :     // INTERFACE BLOCK SPECIFICATIONS:
   18460             :     // na
   18461             : 
   18462             :     // DERIVED TYPE DEFINITIONS:
   18463             :     // na
   18464             : 
   18465             :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
   18466             :     bool inABC;
   18467             :     bool inCDA;
   18468             : 
   18469     1271360 :     inABC = isInTriangle(qx, qy, ax, ay, bx, by, cx, cy);
   18470     1271360 :     inCDA = isInTriangle(qx, qy, cx, cy, dx, dy, ax, ay);
   18471     1271360 :     if (inABC || inCDA) {
   18472      484781 :         isInQuadrilateral = true;
   18473             :     } else {
   18474      786579 :         isInQuadrilateral = false;
   18475             :     }
   18476     1271360 :     return isInQuadrilateral;
   18477             : }
   18478             : 
   18479             : //======================================================================================================================
   18480             : //======================================================================================================================
   18481             : 
   18482             : //    SUPPORT ROUTINES
   18483             : 
   18484             : //======================================================================================================================
   18485             : //======================================================================================================================
   18486             : 
   18487     1830328 : std::string RealToStr(Real64 const RealIn, int const numDigits)
   18488             : {
   18489             :     // FUNCTION INFORMATION:
   18490             :     //       AUTHOR         Jason Glazer
   18491             :     //       DATE WRITTEN   August 2003
   18492             :     //       MODIFIED       November 2008; LKL - prevent errors
   18493             :     //       RE-ENGINEERED  na
   18494             : 
   18495             :     // PURPOSE OF THIS FUNCTION:
   18496             :     //   Abstract away the internal write concept
   18497             : 
   18498             :     // METHODOLOGY EMPLOYED:
   18499             :     // na
   18500             : 
   18501             :     // REFERENCES:
   18502             :     // na
   18503             : 
   18504             :     // USE STATEMENTS:
   18505             :     // na
   18506             : 
   18507             :     // Return value
   18508     3660656 :     std::string StringOut;
   18509             : 
   18510             :     // Locals
   18511             :     // FUNCTION ARGUMENT DEFINITIONS:
   18512             : 
   18513             :     // FUNCTION PARAMETER DEFINITIONS:
   18514             :     static constexpr std::array<const char *, 10> formDigitsA{
   18515             :         "{:#11.0F}", "{:12.1F}", "{:12.2F}", "{:12.3F}", "{:12.4F}", "{:12.5F}", "{:12.6F}", "{:12.7F}", "{:12.8F}", "{:12.9F}"};
   18516             : 
   18517             :     static constexpr std::array<Real64, 10> maxvalDigitsA(
   18518             :         {9999999999.0, 999999999.0, 99999999.0, 9999999.0, 999999.0, 99999.0, 9999.0, 999.0, 99.0, 9.0});
   18519             : 
   18520             :     // INTERFACE BLOCK SPECIFICATIONS:
   18521             :     // na
   18522             : 
   18523             :     // DERIVED TYPE DEFINITIONS:
   18524             :     // na
   18525             : 
   18526             :     // FUNCTION LOCAL VARIABLE DECLARATIONS:
   18527     1830328 :     int nDigits = numDigits;
   18528     1830328 :     if (RealIn < 0.0) --nDigits;
   18529     1830328 :     if (nDigits > 9) nDigits = 9;
   18530     1830328 :     if (nDigits < 0) nDigits = 0;
   18531             : 
   18532     1830328 :     if (std::abs(RealIn) > maxvalDigitsA.at(nDigits)) {
   18533          74 :         return format("{:12.6Z}", RealIn);
   18534             :     } else {
   18535     1830254 :         return format<FormatSyntax::FMT>(formDigitsA.at(nDigits), RealIn);
   18536             :     }
   18537             :     //  WRITE(FMT=, UNIT=stringOut) RealIn
   18538             :     // check if it did not fit
   18539             :     //  IF (stringOut(1:1) .EQ. "*") THEN
   18540             :     //    WRITE(FMT='(E12.6)', UNIT=stringOut) RealIn
   18541             :     //  END IF
   18542             : 
   18543             :     // WRITE(FMT="(F10.4)", UNIT=stringOut, IOSTAT=status ) RealIn
   18544             : }
   18545             : 
   18546       15720 : Real64 StrToReal(std::string_view stringIn)
   18547             : {
   18548             :     // SUBROUTINE INFORMATION:
   18549             :     //       AUTHOR         Linda Lawrie
   18550             :     //       DATE WRITTEN   March 2010
   18551             :     //       MODIFIED       na
   18552             :     //       RE-ENGINEERED  na
   18553             : 
   18554             :     // PURPOSE OF THIS SUBROUTINE:
   18555             :     //   Abstract away the internal read concept
   18556             : 
   18557       15720 :     auto first_char = stringIn.find_first_not_of(' ');
   18558       15720 :     if (first_char != std::string_view::npos) {
   18559       15713 :         stringIn.remove_prefix(first_char);
   18560             :     }
   18561             : 
   18562       15720 :     Real64 realValue = -99999.0;
   18563       15720 :     auto answer = fast_float::from_chars(stringIn.data(), stringIn.data() + stringIn.size(), realValue);
   18564       15720 :     if (answer.ec != std::errc()) {
   18565           7 :         return -99999.0;
   18566             :     }
   18567       15713 :     return realValue;
   18568             : }
   18569             : 
   18570       26608 : std::string DateToString(int const codedDate) // word containing encoded month, day, hour, minute
   18571             : {
   18572             :     // SUBROUTINE INFORMATION:
   18573             :     //       AUTHOR         Jason Glazer
   18574             :     //       DATE WRITTEN   August 2003
   18575             :     //       MODIFIED       na
   18576             :     //       RE-ENGINEERED  na
   18577             : 
   18578             :     // PURPOSE OF THIS SUBROUTINE:
   18579             :     //   Convert the coded date format into a usable
   18580             :     //   string
   18581             : 
   18582             :     int Month;  // month in integer format (1-12)
   18583             :     int Day;    // day in integer format (1-31)
   18584             :     int Hour;   // hour in integer format (1-24)
   18585             :     int Minute; // minute in integer format (0:59)
   18586             :     static constexpr std::array<std::string_view, 12> Months{"JAN", "FEB", "MAR", "APR", "MAY", "JUN", "JUL", "AUG", "SEP", "OCT", "NOV", "DEC"};
   18587             : 
   18588       26608 :     if (codedDate == 0) {
   18589       26571 :         return "-";
   18590             :     }
   18591             : 
   18592          37 :     General::DecodeMonDayHrMin(codedDate, Month, Day, Hour, Minute);
   18593          37 :     if (Month < 1 || Month > 12) {
   18594           0 :         return "-";
   18595             :     }
   18596             : 
   18597          37 :     --Hour;
   18598          37 :     if (Minute == 60) {
   18599           8 :         ++Hour;
   18600           8 :         Minute = 0;
   18601             :     }
   18602             : 
   18603          74 :     return fmt::format("{:02}-{:3}-{:02}:{:02}", Day, Months[Month - 1], Hour, Minute);
   18604             : }
   18605             : 
   18606       24156 : bool isNumber(std::string const &s)
   18607             : {
   18608             :     char *p;
   18609       24156 :     strtod(s.c_str(), &p);
   18610       24163 :     for (; isspace(*p); ++p)
   18611             :         ; // handle trailing whitespace
   18612       24156 :     return *p == 0;
   18613             : }
   18614             : 
   18615             : // return the number of digits after the decimal point
   18616             : // Glazer - November 2016
   18617        6556 : int digitsAferDecimal(std::string const &s)
   18618             : {
   18619        6556 :     std::size_t decimalpos = s.find('.');
   18620             :     std::size_t numDigits;
   18621        6556 :     if (decimalpos == s.npos) {
   18622          72 :         numDigits = 0;
   18623             :     } else {
   18624        6484 :         std::size_t epos = s.find('E');
   18625        6484 :         if (epos == s.npos) epos = s.find('e');
   18626        6484 :         if (epos == s.npos) {
   18627        5787 :             numDigits = s.length() - (decimalpos + 1);
   18628             :         } else {
   18629         697 :             numDigits = epos - (decimalpos + 1);
   18630             :         }
   18631             :     }
   18632        6556 :     return int(numDigits);
   18633             : }
   18634             : 
   18635         231 : void AddTOCEntry(EnergyPlusData &state, std::string const &nameSection, std::string const &nameReport)
   18636             : {
   18637             :     // SUBROUTINE INFORMATION:
   18638             :     //    AUTHOR         Jason Glazer of GARD Analytics, Inc.
   18639             :     //    DATE WRITTEN   September 2005
   18640             :     //    MODIFIED       na
   18641             :     //    RE-ENGINEERED  na
   18642             : 
   18643             :     // PURPOSE OF THIS SUBROUTINE:
   18644             :     //   Adds an entry for the TOC so that it can be created
   18645             :     //   prior to the actual reports being generated. Note that
   18646             :     //   the arguments must match what is used in
   18647             :     //   "WriteReportHeaders" for the HTML anchors to work
   18648             :     //   correctly.
   18649             : 
   18650             :     // METHODOLOGY EMPLOYED:
   18651             : 
   18652             :     // REFERENCES:
   18653             :     //    na
   18654             : 
   18655             :     // USE STATEMENTS:
   18656             : 
   18657             :     // Locals
   18658             :     // SUBROUTINE ARGUMENT DEFINITIONS:
   18659             : 
   18660             :     // SUBROUTINE PARAMETER DEFINITIONS:
   18661             :     //    na
   18662             : 
   18663             :     // INTERFACE BLOCK SPECIFICATIONS:
   18664             :     //    na
   18665             : 
   18666             :     // DERIVED TYPE DEFINITIONS:
   18667             :     //    na
   18668             : 
   18669             :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
   18670             :     //    na
   18671         231 :     auto &ort(state.dataOutRptTab);
   18672             : 
   18673         231 :     if (!allocated(ort->TOCEntries)) {
   18674          51 :         ort->TOCEntriesSize = 20;
   18675          51 :         ort->TOCEntries.allocate(ort->TOCEntriesSize);
   18676          51 :         ort->TOCEntriesCount = 1;
   18677             :     } else {
   18678         180 :         ++ort->TOCEntriesCount;
   18679             :         // if larger than current size grow the array
   18680         180 :         if (ort->TOCEntriesCount > ort->TOCEntriesSize) {
   18681           0 :             ort->TOCEntries.redimension(ort->TOCEntriesSize += 20);
   18682             :         }
   18683             :     }
   18684         231 :     ort->TOCEntries(ort->TOCEntriesCount).reportName = nameReport;
   18685         231 :     ort->TOCEntries(ort->TOCEntriesCount).sectionName = nameSection;
   18686         231 : }
   18687             : 
   18688         769 : void SetupUnitConversions(EnergyPlusData &state)
   18689             : {
   18690             :     // SUBROUTINE INFORMATION:
   18691             :     //    AUTHOR         Jason Glazer of GARD Analytics, Inc.
   18692             :     //    DATE WRITTEN   February 12, 2009
   18693             :     //    MODIFIED       March 2010; Linda Lawrie; Add deltaC and KJ/KG
   18694             :     //    RE-ENGINEERED  na
   18695             : 
   18696             :     // PURPOSE OF THIS SUBROUTINE:
   18697             :     //   Initialize the array that contains the unit conversion
   18698             :     //   information. The code is based on code generated
   18699             :     //   in a spreadsheet titled UnitConversion.xls
   18700             : 
   18701             :     // METHODOLOGY EMPLOYED:
   18702             : 
   18703             :     // REFERENCES:
   18704             :     //    na
   18705             : 
   18706             :     // USE STATEMENTS:
   18707             : 
   18708             :     // SUBROUTINE ARGUMENT DEFINITIONS:
   18709             : 
   18710             :     // SUBROUTINE PARAMETER DEFINITIONS:
   18711             :     //    na
   18712             : 
   18713             :     // INTERFACE BLOCK SPECIFICATIONS:
   18714             :     //    na
   18715             : 
   18716             :     // DERIVED TYPE DEFINITIONS:
   18717             :     //    na
   18718             : 
   18719             :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
   18720             :     //    na
   18721         769 :     auto &ort(state.dataOutRptTab);
   18722             : 
   18723         769 :     ort->UnitConvSize = 118;
   18724         769 :     ort->UnitConv.allocate(ort->UnitConvSize);
   18725         769 :     ort->UnitConv(1).siName = "%";
   18726         769 :     ort->UnitConv(2).siName = "°C";
   18727         769 :     ort->UnitConv(3).siName = "0=OFF 1=ON";
   18728         769 :     ort->UnitConv(4).siName = "0-NO  1-YES";
   18729         769 :     ort->UnitConv(5).siName = "1-YES 0-NO";
   18730         769 :     ort->UnitConv(6).siName = "A";
   18731         769 :     ort->UnitConv(7).siName = "ACH";
   18732         769 :     ort->UnitConv(8).siName = "ACH";
   18733         769 :     ort->UnitConv(9).siName = "BASE 10C";
   18734         769 :     ort->UnitConv(10).siName = "BASE 18C";
   18735         769 :     ort->UnitConv(11).siName = "C";
   18736         769 :     ort->UnitConv(12).siName = "CD/M2";
   18737         769 :     ort->UnitConv(13).siName = "DEG";
   18738         769 :     ort->UnitConv(14).siName = "FRAC";
   18739         769 :     ort->UnitConv(15).siName = "HOUR";
   18740         769 :     ort->UnitConv(16).siName = "HOURS";
   18741         769 :     ort->UnitConv(17).siName = "HR";
   18742         769 :     ort->UnitConv(18).siName = "HRS";
   18743         769 :     ort->UnitConv(19).siName = "J";
   18744         769 :     ort->UnitConv(20).siName = "J";
   18745         769 :     ort->UnitConv(21).siName = "J";
   18746         769 :     ort->UnitConv(22).siName = "J";
   18747         769 :     ort->UnitConv(23).siName = "J";
   18748         769 :     ort->UnitConv(24).siName = "J";
   18749         769 :     ort->UnitConv(25).siName = "J/KG";
   18750         769 :     ort->UnitConv(26).siName = "J/KGWATER";
   18751         769 :     ort->UnitConv(27).siName = "J/M2";
   18752         769 :     ort->UnitConv(28).siName = "K/M";
   18753         769 :     ort->UnitConv(29).siName = "KG";
   18754         769 :     ort->UnitConv(30).siName = "KG/KG";
   18755         769 :     ort->UnitConv(31).siName = "KG/M3";
   18756         769 :     ort->UnitConv(32).siName = "KG/S";
   18757         769 :     ort->UnitConv(33).siName = "KGWATER/KGDRYAIR";
   18758         769 :     ort->UnitConv(34).siName = "KGWATER/SEC";
   18759         769 :     ort->UnitConv(35).siName = "KMOL/S";
   18760         769 :     ort->UnitConv(36).siName = "KMOL/SEC";
   18761         769 :     ort->UnitConv(37).siName = "KWH";
   18762         769 :     ort->UnitConv(38).siName = "L";
   18763         769 :     ort->UnitConv(39).siName = "L";
   18764         769 :     ort->UnitConv(40).siName = "LUM/W";
   18765         769 :     ort->UnitConv(41).siName = "LUX";
   18766         769 :     ort->UnitConv(42).siName = "M";
   18767         769 :     ort->UnitConv(43).siName = "M";
   18768         769 :     ort->UnitConv(44).siName = "M/S";
   18769         769 :     ort->UnitConv(45).siName = "M/S";
   18770         769 :     ort->UnitConv(46).siName = "M2";
   18771         769 :     ort->UnitConv(47).siName = "M2/PERSON";
   18772         769 :     ort->UnitConv(48).siName = "M3";
   18773         769 :     ort->UnitConv(49).siName = "M3";
   18774         769 :     ort->UnitConv(50).siName = "M3/M2";
   18775         769 :     ort->UnitConv(51).siName = "M3/S";
   18776         769 :     ort->UnitConv(52).siName = "M3/S";
   18777         769 :     ort->UnitConv(53).siName = "M3/S-M2";
   18778         769 :     ort->UnitConv(54).siName = "M3/S-PERSON";
   18779         769 :     ort->UnitConv(55).siName = "M3/S-PERSON";
   18780         769 :     ort->UnitConv(56).siName = "PA";
   18781         769 :     ort->UnitConv(57).siName = "PA";
   18782         769 :     ort->UnitConv(58).siName = "PA";
   18783         769 :     ort->UnitConv(59).siName = "PA";
   18784         769 :     ort->UnitConv(60).siName = "PA";
   18785         769 :     ort->UnitConv(61).siName = "PA";
   18786         769 :     ort->UnitConv(62).siName = "PA";
   18787         769 :     ort->UnitConv(63).siName = "PA";
   18788         769 :     ort->UnitConv(64).siName = "S";
   18789         769 :     ort->UnitConv(65).siName = "V";
   18790         769 :     ort->UnitConv(66).siName = "W";
   18791         769 :     ort->UnitConv(67).siName = "W";
   18792         769 :     ort->UnitConv(68).siName = "W";
   18793         769 :     ort->UnitConv(69).siName = "W";
   18794         769 :     ort->UnitConv(70).siName = "W";
   18795         769 :     ort->UnitConv(71).siName = "W/KG";
   18796         769 :     ort->UnitConv(72).siName = "W/KG H2O"; // TODO: replace with W/kgWater? or rather just remove
   18797         769 :     ort->UnitConv(73).siName = "W/K";
   18798         769 :     ort->UnitConv(74).siName = "W/M2";
   18799         769 :     ort->UnitConv(75).siName = "W/M2";
   18800         769 :     ort->UnitConv(76).siName = "W/M2-C";
   18801         769 :     ort->UnitConv(77).siName = "W/M2-K";
   18802         769 :     ort->UnitConv(78).siName = "W/W";
   18803         769 :     ort->UnitConv(79).siName = "W/W";
   18804         769 :     ort->UnitConv(80).siName = "deltaC";
   18805         769 :     ort->UnitConv(81).siName = "KJ/KG";
   18806         769 :     ort->UnitConv(82).siName = "W-S/M3";
   18807         769 :     ort->UnitConv(83).siName = "W-S/M3";
   18808         769 :     ort->UnitConv(84).siName = "~~$~~/m2";
   18809         769 :     ort->UnitConv(85).siName = "GJ";
   18810         769 :     ort->UnitConv(86).siName = "GJ";
   18811         769 :     ort->UnitConv(87).siName = "GJ";
   18812         769 :     ort->UnitConv(88).siName = "GJ";
   18813         769 :     ort->UnitConv(89).siName = "GJ";
   18814         769 :     ort->UnitConv(90).siName = "GJ";
   18815         769 :     ort->UnitConv(91).siName = "GJ";
   18816         769 :     ort->UnitConv(92).siName = "MJ/m2";
   18817         769 :     ort->UnitConv(93).siName = "MJ/m2";
   18818         769 :     ort->UnitConv(94).siName = "MJ/m2";
   18819         769 :     ort->UnitConv(95).siName = "MJ/m2";
   18820         769 :     ort->UnitConv(96).siName = "Invalid/Undefined";
   18821         769 :     ort->UnitConv(97).siName = "";
   18822         769 :     ort->UnitConv(98).siName = "W/C";
   18823         769 :     ort->UnitConv(99).siName = "DAY";
   18824         769 :     ort->UnitConv(100).siName = "MIN";
   18825         769 :     ort->UnitConv(101).siName = "HR/WK";
   18826         769 :     ort->UnitConv(102).siName = "$";
   18827         769 :     ort->UnitConv(103).siName = "$/UNIT ENERGY";
   18828         769 :     ort->UnitConv(104).siName = "KW";
   18829         769 :     ort->UnitConv(105).siName = " ";
   18830         769 :     ort->UnitConv(106).siName = "AH";
   18831         769 :     ort->UnitConv(107).siName = "CLO";
   18832         769 :     ort->UnitConv(108).siName = "J/KG-K";
   18833         769 :     ort->UnitConv(109).siName = "KGWATER/S";
   18834         769 :     ort->UnitConv(110).siName = "PPM";
   18835         769 :     ort->UnitConv(111).siName = "RAD";
   18836         769 :     ort->UnitConv(112).siName = "REV/MIN";
   18837         769 :     ort->UnitConv(113).siName = "NM";
   18838         769 :     ort->UnitConv(114).siName = "BTU/W-H"; // Used for AHRI rating metrics (e.g. SEER)
   18839         769 :     ort->UnitConv(115).siName = "PERSON/M2";
   18840         769 :     ort->UnitConv(116).siName = "MM";
   18841         769 :     ort->UnitConv(117).siName = "MM";
   18842         769 :     ort->UnitConv(118).siName = "°C·hr";
   18843             : 
   18844         769 :     ort->UnitConv(1).ipName = "%";
   18845         769 :     ort->UnitConv(2).ipName = "F";
   18846         769 :     ort->UnitConv(3).ipName = "0=Off 1=On";
   18847         769 :     ort->UnitConv(4).ipName = "0-No  1-Yes";
   18848         769 :     ort->UnitConv(5).ipName = "1-Yes 0-No";
   18849         769 :     ort->UnitConv(6).ipName = "A";
   18850         769 :     ort->UnitConv(7).ipName = "ACH";
   18851         769 :     ort->UnitConv(8).ipName = "ach";
   18852         769 :     ort->UnitConv(9).ipName = "base 50F";
   18853         769 :     ort->UnitConv(10).ipName = "base 65F";
   18854         769 :     ort->UnitConv(11).ipName = "F";
   18855         769 :     ort->UnitConv(12).ipName = "cd/in2";
   18856         769 :     ort->UnitConv(13).ipName = "deg";
   18857         769 :     ort->UnitConv(14).ipName = "Frac";
   18858         769 :     ort->UnitConv(15).ipName = "Hour";
   18859         769 :     ort->UnitConv(16).ipName = "Hours";
   18860         769 :     ort->UnitConv(17).ipName = "hr";
   18861         769 :     ort->UnitConv(18).ipName = "hrs";
   18862         769 :     ort->UnitConv(19).ipName = "kBtu";
   18863         769 :     ort->UnitConv(20).ipName = "kWh";
   18864         769 :     ort->UnitConv(21).ipName = "therm";
   18865         769 :     ort->UnitConv(22).ipName = "MMBtu";
   18866         769 :     ort->UnitConv(23).ipName = "Wh";
   18867         769 :     ort->UnitConv(24).ipName = "ton-hrs";
   18868         769 :     ort->UnitConv(25).ipName = "Btu/lb";
   18869         769 :     ort->UnitConv(26).ipName = "Btu/lbWater";
   18870         769 :     ort->UnitConv(27).ipName = "kBtu/sqft";
   18871         769 :     ort->UnitConv(28).ipName = "F/ft";
   18872         769 :     ort->UnitConv(29).ipName = "lb";
   18873         769 :     ort->UnitConv(30).ipName = "lb/lb";
   18874         769 :     ort->UnitConv(31).ipName = "lb/ft3";
   18875         769 :     ort->UnitConv(32).ipName = "lb/s";
   18876         769 :     ort->UnitConv(33).ipName = "lbWater/lbDryAir";
   18877         769 :     ort->UnitConv(34).ipName = "lbWater/s";
   18878         769 :     ort->UnitConv(35).ipName = "kmol/s";
   18879         769 :     ort->UnitConv(36).ipName = "kmol/sec";
   18880         769 :     ort->UnitConv(37).ipName = "kWh";
   18881         769 :     ort->UnitConv(38).ipName = "gal";
   18882         769 :     ort->UnitConv(39).ipName = "ft3";
   18883         769 :     ort->UnitConv(40).ipName = "lum/W";
   18884         769 :     ort->UnitConv(41).ipName = "foot-candles";
   18885         769 :     ort->UnitConv(42).ipName = "ft";
   18886         769 :     ort->UnitConv(43).ipName = "in";
   18887         769 :     ort->UnitConv(44).ipName = "ft/min";
   18888         769 :     ort->UnitConv(45).ipName = "miles/hr";
   18889         769 :     ort->UnitConv(46).ipName = "ft2";
   18890         769 :     ort->UnitConv(47).ipName = "ft2/person";
   18891         769 :     ort->UnitConv(48).ipName = "ft3";
   18892         769 :     ort->UnitConv(49).ipName = "gal";
   18893         769 :     ort->UnitConv(50).ipName = "f3/f2";
   18894         769 :     ort->UnitConv(51).ipName = "ft3/min";
   18895         769 :     ort->UnitConv(52).ipName = "gal/min";
   18896         769 :     ort->UnitConv(53).ipName = "ft3/min-ft2";
   18897         769 :     ort->UnitConv(54).ipName = "ft3/min-person";
   18898         769 :     ort->UnitConv(55).ipName = "gal/min-person";
   18899         769 :     ort->UnitConv(56).ipName = "psi";
   18900         769 :     ort->UnitConv(57).ipName = "inHg";
   18901         769 :     ort->UnitConv(58).ipName = "inH2O";
   18902         769 :     ort->UnitConv(59).ipName = "ftH2O";
   18903         769 :     ort->UnitConv(60).ipName = "psi";
   18904         769 :     ort->UnitConv(61).ipName = "inHg";
   18905         769 :     ort->UnitConv(62).ipName = "inH2O";
   18906         769 :     ort->UnitConv(63).ipName = "ftH2O";
   18907         769 :     ort->UnitConv(64).ipName = "s";
   18908         769 :     ort->UnitConv(65).ipName = "V";
   18909         769 :     ort->UnitConv(66).ipName = "Btu/h";
   18910         769 :     ort->UnitConv(67).ipName = "W";
   18911         769 :     ort->UnitConv(68).ipName = "kW";
   18912         769 :     ort->UnitConv(69).ipName = "kBtuh";
   18913         769 :     ort->UnitConv(70).ipName = "ton";
   18914         769 :     ort->UnitConv(71).ipName = "kBtuh/lb";
   18915         769 :     ort->UnitConv(72).ipName = "kBtuh/lb";
   18916         769 :     ort->UnitConv(73).ipName = "Btu/h-F";
   18917         769 :     ort->UnitConv(74).ipName = "Btu/h-ft2";
   18918         769 :     ort->UnitConv(75).ipName = "kBtuh/ft2";
   18919         769 :     ort->UnitConv(76).ipName = "Btu/h-ft2-F";
   18920         769 :     ort->UnitConv(77).ipName = "Btu/h-ft2-F";
   18921         769 :     ort->UnitConv(78).ipName = "Btuh/Btuh";
   18922         769 :     ort->UnitConv(79).ipName = "W/W";
   18923         769 :     ort->UnitConv(80).ipName = "deltaF";
   18924         769 :     ort->UnitConv(81).ipName = "Btu/lb";
   18925         769 :     ort->UnitConv(82).ipName = "W-min/ft3";
   18926         769 :     ort->UnitConv(83).ipName = "W-min/gal";
   18927         769 :     ort->UnitConv(84).ipName = "~~$~~/ft2";
   18928         769 :     ort->UnitConv(85).ipName = "kBtu";
   18929         769 :     ort->UnitConv(86).ipName = "kWh";
   18930         769 :     ort->UnitConv(87).ipName = "kWh";
   18931         769 :     ort->UnitConv(88).ipName = "therm";
   18932         769 :     ort->UnitConv(89).ipName = "MMBtu";
   18933         769 :     ort->UnitConv(90).ipName = "Wh";
   18934         769 :     ort->UnitConv(91).ipName = "ton-hrs";
   18935         769 :     ort->UnitConv(92).ipName = "kWh/ft2";
   18936         769 :     ort->UnitConv(93).ipName = "kBtu/ft2";
   18937         769 :     ort->UnitConv(94).ipName = "kBtu/ft2";
   18938         769 :     ort->UnitConv(95).ipName = "kWh/m2";
   18939         769 :     ort->UnitConv(96).ipName = "Invalid/Undefined";
   18940         769 :     ort->UnitConv(97).ipName = "";
   18941         769 :     ort->UnitConv(98).ipName = "Btu/h-F";
   18942         769 :     ort->UnitConv(99).ipName = "day";
   18943         769 :     ort->UnitConv(100).ipName = "min";
   18944         769 :     ort->UnitConv(101).ipName = "hr/wk";
   18945         769 :     ort->UnitConv(102).ipName = "$";
   18946         769 :     ort->UnitConv(103).ipName = "$/unit energy";
   18947         769 :     ort->UnitConv(104).ipName = "kW";
   18948         769 :     ort->UnitConv(105).ipName = " ";
   18949         769 :     ort->UnitConv(106).ipName = "Ah";
   18950         769 :     ort->UnitConv(107).ipName = "clo";
   18951         769 :     ort->UnitConv(108).ipName = "Btu/lbm-R";
   18952         769 :     ort->UnitConv(109).ipName = "lbWater/s";
   18953         769 :     ort->UnitConv(110).ipName = "ppm";
   18954         769 :     ort->UnitConv(111).ipName = "rad";
   18955         769 :     ort->UnitConv(112).ipName = "rev/min";
   18956         769 :     ort->UnitConv(113).ipName = "lbf-ft";
   18957         769 :     ort->UnitConv(114).ipName = "Btu/W-h";
   18958         769 :     ort->UnitConv(115).ipName = "person/ft2";
   18959         769 :     ort->UnitConv(116).ipName = "in";
   18960         769 :     ort->UnitConv(117).ipName = "ft";
   18961         769 :     ort->UnitConv(118).ipName = "°F·hr";
   18962             : 
   18963         769 :     ort->UnitConv(1).mult = 1.0;
   18964         769 :     ort->UnitConv(2).mult = 1.8;
   18965         769 :     ort->UnitConv(3).mult = 1.0;
   18966         769 :     ort->UnitConv(4).mult = 1.0;
   18967         769 :     ort->UnitConv(5).mult = 1.0;
   18968         769 :     ort->UnitConv(6).mult = 1.0;
   18969         769 :     ort->UnitConv(7).mult = 1.0;
   18970         769 :     ort->UnitConv(8).mult = 1.0;
   18971         769 :     ort->UnitConv(9).mult = 1.8;
   18972         769 :     ort->UnitConv(10).mult = 1.8;
   18973         769 :     ort->UnitConv(11).mult = 1.8;
   18974         769 :     ort->UnitConv(12).mult = 0.000645160041625726;
   18975         769 :     ort->UnitConv(13).mult = 1.0;
   18976         769 :     ort->UnitConv(14).mult = 1.0;
   18977         769 :     ort->UnitConv(15).mult = 1.0;
   18978         769 :     ort->UnitConv(16).mult = 1.0;
   18979         769 :     ort->UnitConv(17).mult = 1.0;
   18980         769 :     ort->UnitConv(18).mult = 1.0;
   18981         769 :     ort->UnitConv(19).mult = 0.00000094845;
   18982         769 :     ort->UnitConv(20).mult = 0.000000277778;
   18983         769 :     ort->UnitConv(21).mult = 0.0000000094845;
   18984         769 :     ort->UnitConv(22).mult = 0.00000000094845;
   18985         769 :     ort->UnitConv(23).mult = 0.000277777777777778;
   18986         769 :     ort->UnitConv(24).mult = 0.0000000789847;
   18987         769 :     ort->UnitConv(25).mult = 0.00042956;
   18988         769 :     ort->UnitConv(26).mult = 0.0000004302105;
   18989         769 :     ort->UnitConv(27).mult = 0.00000008811404;
   18990         769 :     ort->UnitConv(28).mult = 0.54861322767449;
   18991         769 :     ort->UnitConv(29).mult = 2.2046;
   18992         769 :     ort->UnitConv(30).mult = 1.0;
   18993         769 :     ort->UnitConv(31).mult = 0.062428;
   18994         769 :     ort->UnitConv(32).mult = 2.2046;
   18995         769 :     ort->UnitConv(33).mult = 1.0;
   18996         769 :     ort->UnitConv(34).mult = 2.2046;
   18997         769 :     ort->UnitConv(35).mult = 1.0;
   18998         769 :     ort->UnitConv(36).mult = 1.0;
   18999         769 :     ort->UnitConv(37).mult = 1.0;
   19000         769 :     ort->UnitConv(38).mult = 0.264172037284185;
   19001         769 :     ort->UnitConv(39).mult = 0.0353146624712848;
   19002         769 :     ort->UnitConv(40).mult = 1.0;
   19003         769 :     ort->UnitConv(41).mult = 0.092902267;
   19004         769 :     ort->UnitConv(42).mult = 3.281;
   19005         769 :     ort->UnitConv(43).mult = 39.37;
   19006         769 :     ort->UnitConv(44).mult = 196.86;
   19007         769 :     ort->UnitConv(45).mult = 2.2369;
   19008         769 :     ort->UnitConv(46).mult = 10.764961;
   19009         769 :     ort->UnitConv(47).mult = 10.764961;
   19010         769 :     ort->UnitConv(48).mult = 35.319837041;
   19011         769 :     ort->UnitConv(49).mult = 264.172;
   19012         769 :     ort->UnitConv(50).mult = 3.281;
   19013         769 :     ort->UnitConv(51).mult = 2118.6438;
   19014         769 :     ort->UnitConv(52).mult = 15852.0;
   19015         769 :     ort->UnitConv(53).mult = 196.85;
   19016         769 :     ort->UnitConv(54).mult = 2118.6438;
   19017         769 :     ort->UnitConv(55).mult = 15852.0;
   19018         769 :     ort->UnitConv(56).mult = 0.0001450377;
   19019         769 :     ort->UnitConv(57).mult = 0.00029613;
   19020         769 :     ort->UnitConv(58).mult = 0.00401463;
   19021         769 :     ort->UnitConv(59).mult = 0.00033455;
   19022         769 :     ort->UnitConv(60).mult = 0.0001450377;
   19023         769 :     ort->UnitConv(61).mult = 0.00029613;
   19024         769 :     ort->UnitConv(62).mult = 0.00401463;
   19025         769 :     ort->UnitConv(63).mult = 0.00033455;
   19026         769 :     ort->UnitConv(64).mult = 1.0;
   19027         769 :     ort->UnitConv(65).mult = 1.0;
   19028         769 :     ort->UnitConv(66).mult = 3.412;
   19029         769 :     ort->UnitConv(67).mult = 1.0;
   19030         769 :     ort->UnitConv(68).mult = 0.001;
   19031         769 :     ort->UnitConv(69).mult = 0.00341442;
   19032         769 :     ort->UnitConv(70).mult = 0.0002843333;
   19033         769 :     ort->UnitConv(71).mult = 0.001547673;
   19034         769 :     ort->UnitConv(72).mult = 0.001547673;
   19035         769 :     ort->UnitConv(73).mult = 1.8987;
   19036         769 :     ort->UnitConv(74).mult = 0.316954237;
   19037         769 :     ort->UnitConv(75).mult = 0.000316954237;
   19038         769 :     ort->UnitConv(76).mult = 0.176085687;
   19039         769 :     ort->UnitConv(77).mult = 0.176085687;
   19040         769 :     ort->UnitConv(78).mult = 1.0;
   19041         769 :     ort->UnitConv(79).mult = 1.0;
   19042         769 :     ort->UnitConv(80).mult = 1.8;
   19043         769 :     ort->UnitConv(81).mult = 0.42956;
   19044         769 :     ort->UnitConv(82).mult = 1.0 / 2118.6438;
   19045         769 :     ort->UnitConv(83).mult = 1.0 / 15852;
   19046         769 :     ort->UnitConv(84).mult = 1.0 / 10.764961;
   19047         769 :     ort->UnitConv(85).mult = 0.00000094845 * 1000000000;
   19048         769 :     ort->UnitConv(86).mult = 0.000000277778 * 1000000000;
   19049         769 :     ort->UnitConv(87).mult = 0.000000277778 * 1000000000;
   19050         769 :     ort->UnitConv(88).mult = 0.0000000094845 * 1000000000;
   19051         769 :     ort->UnitConv(89).mult = 0.00000000094845 * 1000000000;
   19052         769 :     ort->UnitConv(90).mult = 0.000277777777777778 * 1000000000;
   19053         769 :     ort->UnitConv(91).mult = 0.0000000789847 * 1000000000;
   19054         769 :     ort->UnitConv(92).mult = 0.277777777777778 / 10.764961;
   19055         769 :     ort->UnitConv(93).mult = 0.94708628903179 / 10.764961;
   19056         769 :     ort->UnitConv(94).mult = 0.94708628903179 / 10.764961;
   19057         769 :     ort->UnitConv(95).mult = 0.27777777777778;
   19058         769 :     ort->UnitConv(96).mult = 1.0;
   19059         769 :     ort->UnitConv(97).mult = 1.0;
   19060         769 :     ort->UnitConv(98).mult = 1.8987;
   19061         769 :     ort->UnitConv(99).mult = 1.0;
   19062         769 :     ort->UnitConv(100).mult = 1.0;
   19063         769 :     ort->UnitConv(101).mult = 1.0;
   19064         769 :     ort->UnitConv(102).mult = 1.0;
   19065         769 :     ort->UnitConv(103).mult = 1.0;
   19066         769 :     ort->UnitConv(104).mult = 1.0;
   19067         769 :     ort->UnitConv(105).mult = 1.0;
   19068         769 :     ort->UnitConv(106).mult = 1.0;
   19069         769 :     ort->UnitConv(107).mult = 1.0;
   19070         769 :     ort->UnitConv(108).mult = 0.000238845896627;
   19071         769 :     ort->UnitConv(109).mult = 2.2046;
   19072         769 :     ort->UnitConv(110).mult = 1.0;
   19073         769 :     ort->UnitConv(111).mult = 1.0;
   19074         769 :     ort->UnitConv(112).mult = 1.0;
   19075         769 :     ort->UnitConv(113).mult = 0.737562149277;
   19076         769 :     ort->UnitConv(114).mult = 1.0;
   19077         769 :     ort->UnitConv(115).mult = 0.09290304;
   19078         769 :     ort->UnitConv(116).mult = 0.03937;
   19079         769 :     ort->UnitConv(117).mult = 0.003281;
   19080         769 :     ort->UnitConv(118).mult = 1.8;
   19081             : 
   19082         769 :     ort->UnitConv(2).offset = 32.0;
   19083         769 :     ort->UnitConv(11).offset = 32.0;
   19084         769 :     ort->UnitConv(25).offset = 7.6736;
   19085         769 :     ort->UnitConv(81).offset = 7.6736; // 80 is KJ/KG -- should this be multiplied by 1000?
   19086             : 
   19087         769 :     ort->UnitConv(20).hint = "ELEC";
   19088         769 :     ort->UnitConv(21).hint = "GAS";
   19089         769 :     ort->UnitConv(24).hint = "COOL";
   19090         769 :     ort->UnitConv(38).hint = "WATER";
   19091         769 :     ort->UnitConv(49).hint = "WATER";
   19092         769 :     ort->UnitConv(52).hint = "WATER";
   19093         769 :     ort->UnitConv(67).hint = "ELEC";
   19094         769 :     ort->UnitConv(70).hint = "COOL";
   19095         769 :     ort->UnitConv(79).hint = "SI";
   19096         769 :     ort->UnitConv(83).hint = "WATER";
   19097         769 :     ort->UnitConv(86).hint = "CONSUMP";
   19098         769 :     ort->UnitConv(87).hint = "ELEC";
   19099         769 :     ort->UnitConv(88).hint = "GAS";
   19100         769 :     ort->UnitConv(91).hint = "COOL";
   19101         769 :     ort->UnitConv(92).hint = "ELEC";
   19102         769 :     ort->UnitConv(93).hint = "GAS";
   19103         769 :     ort->UnitConv(93).hint = "ADDITIONAL";
   19104             : 
   19105         769 :     ort->UnitConv(19).several = true;
   19106         769 :     ort->UnitConv(20).several = true;
   19107         769 :     ort->UnitConv(21).several = true;
   19108         769 :     ort->UnitConv(22).several = true;
   19109         769 :     ort->UnitConv(23).several = true;
   19110         769 :     ort->UnitConv(24).several = true;
   19111         769 :     ort->UnitConv(38).several = true;
   19112         769 :     ort->UnitConv(39).several = true;
   19113         769 :     ort->UnitConv(42).several = true;
   19114         769 :     ort->UnitConv(43).several = true;
   19115         769 :     ort->UnitConv(44).several = true;
   19116         769 :     ort->UnitConv(45).several = true;
   19117         769 :     ort->UnitConv(48).several = true;
   19118         769 :     ort->UnitConv(49).several = true;
   19119         769 :     ort->UnitConv(51).several = true;
   19120         769 :     ort->UnitConv(52).several = true;
   19121         769 :     ort->UnitConv(54).several = true;
   19122         769 :     ort->UnitConv(55).several = true;
   19123         769 :     ort->UnitConv(56).several = true;
   19124         769 :     ort->UnitConv(57).several = true;
   19125         769 :     ort->UnitConv(58).several = true;
   19126         769 :     ort->UnitConv(59).several = true;
   19127         769 :     ort->UnitConv(60).several = true;
   19128         769 :     ort->UnitConv(61).several = true;
   19129         769 :     ort->UnitConv(62).several = true;
   19130         769 :     ort->UnitConv(63).several = true;
   19131         769 :     ort->UnitConv(66).several = true;
   19132         769 :     ort->UnitConv(67).several = true;
   19133         769 :     ort->UnitConv(68).several = true;
   19134         769 :     ort->UnitConv(69).several = true;
   19135         769 :     ort->UnitConv(70).several = true;
   19136         769 :     ort->UnitConv(74).several = true;
   19137         769 :     ort->UnitConv(75).several = true;
   19138         769 :     ort->UnitConv(78).several = true;
   19139         769 :     ort->UnitConv(79).several = true;
   19140         769 :     ort->UnitConv(82).several = true;
   19141         769 :     ort->UnitConv(83).several = true;
   19142         769 :     ort->UnitConv(85).several = true;
   19143         769 :     ort->UnitConv(86).several = true;
   19144         769 :     ort->UnitConv(87).several = true;
   19145         769 :     ort->UnitConv(88).several = true;
   19146         769 :     ort->UnitConv(89).several = true;
   19147         769 :     ort->UnitConv(90).several = true;
   19148         769 :     ort->UnitConv(91).several = true;
   19149         769 :     ort->UnitConv(92).several = true;
   19150         769 :     ort->UnitConv(93).several = true;
   19151         769 :     ort->UnitConv(94).several = true;
   19152         769 :     ort->UnitConv(95).several = true;
   19153         769 :     ort->UnitConv(116).several = true;
   19154         769 :     ort->UnitConv(117).several = true;
   19155         769 : }
   19156             : 
   19157       24895 : std::string GetUnitSubString(std::string const &inString) // Input String
   19158             : {
   19159             :     // SUBROUTINE INFORMATION:
   19160             :     //       AUTHOR         Jason Glazer
   19161             :     //       DATE WRITTEN   February 2013
   19162             :     //       MODIFIED       na
   19163             :     //       RE-ENGINEERED  na
   19164             : 
   19165             :     // PURPOSE OF THIS SUBROUTINE:
   19166             :     //   return the substring contained in brackets []
   19167             :     //   that contains the units.
   19168             : 
   19169             :     // METHODOLOGY EMPLOYED:
   19170             :     //   na
   19171             : 
   19172             :     // Return value
   19173       24895 :     std::string outUnit; // Result String
   19174             : 
   19175             :     // Locals
   19176             :     // SUBROUTINE ARGUMENT DEFINITIONS:
   19177             : 
   19178             :     // SUBROUTINE PARAMETER DEFINITIONS:
   19179             :     // na
   19180             : 
   19181             :     // INTERFACE BLOCK SPECIFICATIONS:
   19182             :     // na
   19183             : 
   19184             :     // DERIVED TYPE DEFINITIONS:
   19185             :     // na
   19186             : 
   19187             :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
   19188             : 
   19189             :     // check if string has brackets or parentheses
   19190       24895 :     std::string::size_type const posLBrac = index(inString, '['); // left bracket
   19191       24895 :     std::string::size_type const posRBrac = index(inString, ']'); // right bracket
   19192             :     // extract the substring with the units
   19193       24895 :     if ((posLBrac != std::string::npos) && (posRBrac != std::string::npos) && (posRBrac - posLBrac >= 1)) {
   19194        7346 :         outUnit = inString.substr(posLBrac + 1, posRBrac - posLBrac - 1);
   19195             :     }
   19196       24895 :     return outUnit;
   19197             : }
   19198             : 
   19199       13134 : void LookupSItoIP(EnergyPlusData &state, std::string const &stringInWithSI, int &unitConvIndex, std::string &stringOutWithIP)
   19200             : {
   19201             :     // SUBROUTINE INFORMATION:
   19202             :     //    AUTHOR         Jason Glazer of GARD Analytics, Inc.
   19203             :     //    DATE WRITTEN   February 12, 2009
   19204             : 
   19205             :     // PURPOSE OF THIS SUBROUTINE:
   19206             :     //   The input string to this subroutine can either contain
   19207             :     //   a unit that should be looked up or it can contain
   19208             :     //   but the unit and other text (such as the column heading)
   19209             :     //   that includes a hint for when the unit may have multiple
   19210             :     //   possible conversions. If the input string includes
   19211             :     //   just the unit it does not have either brackets or
   19212             :     //   parenthesis. If the string includes text with a possible
   19213             :     //   hint the units themselves will be in either brackets
   19214             :     //   or parentheses. The index to the unitConv array is returned
   19215             :     //   which can be used with the convertIP function. Also the
   19216             :     //   string with the IP units substituted is returned.
   19217             : 
   19218       26268 :     std::string unitSIOnly;
   19219             :     int modeInString;
   19220       13134 :     int constexpr misBrac(1);
   19221       13134 :     int constexpr misParen(2);
   19222       13134 :     int constexpr misBrce(3);
   19223       13134 :     int constexpr misNoHint(4);
   19224       26268 :     std::string const stringInUpper(UtilityRoutines::MakeUPPERCase(stringInWithSI));
   19225       13134 :     auto &ort(state.dataOutRptTab);
   19226             : 
   19227       13134 :     stringOutWithIP = "";
   19228             :     // check if string has brackets or parentheses
   19229       13134 :     std::string::size_type posLBrac = index(stringInUpper, '[');  // left bracket
   19230       13134 :     std::string::size_type posRBrac = index(stringInUpper, ']');  // right bracket
   19231       13134 :     std::string::size_type posLParen = index(stringInUpper, '('); // left parenthesis
   19232       13134 :     std::string::size_type posRParen = index(stringInUpper, ')'); // right parenthesis
   19233       13134 :     std::string::size_type posLBrce = index(stringInUpper, '{');  // left brace
   19234       13134 :     std::string::size_type posRBrce = index(stringInUpper, '}');  // right brace
   19235       13134 :     bool noBrackets = true;
   19236             :     // extract the substring with the units
   19237       13134 :     if ((posLBrac != std::string::npos) && (posRBrac != std::string::npos) && (posRBrac - posLBrac >= 1)) {
   19238        6411 :         unitSIOnly = stringInUpper.substr(posLBrac + 1, posRBrac - posLBrac - 1);
   19239        6411 :         modeInString = misBrac;
   19240        6411 :         noBrackets = false;
   19241        6723 :     } else if ((posLBrce != std::string::npos) && (posRBrce != std::string::npos) && (posRBrce - posLBrce >= 1)) {
   19242        2361 :         unitSIOnly = stringInUpper.substr(posLBrce + 1, posRBrce - posLBrce - 1);
   19243        2361 :         modeInString = misBrce;
   19244        4362 :     } else if ((posLParen != std::string::npos) && (posRParen != std::string::npos) && (posRParen - posLParen >= 1)) {
   19245         162 :         unitSIOnly = stringInUpper.substr(posLParen + 1, posRParen - posLParen - 1);
   19246         162 :         modeInString = misParen;
   19247             :     } else {
   19248        4200 :         unitSIOnly = stringInUpper;
   19249        4200 :         modeInString = misNoHint;
   19250             :     }
   19251       13134 :     unitSIOnly = stripped(unitSIOnly);
   19252       13134 :     int defaultConv = 0;
   19253       13134 :     int foundConv = 0;
   19254       13134 :     int firstOfSeveral = 0;
   19255     1237960 :     for (int iUnit = 1; iUnit <= ort->UnitConvSize; ++iUnit) {
   19256     1229077 :         if (UtilityRoutines::SameString(ort->UnitConv(iUnit).siName, unitSIOnly)) {
   19257       18670 :             if (ort->UnitConv(iUnit).several) {
   19258       14933 :                 if (firstOfSeveral == 0) firstOfSeveral = iUnit;
   19259       14933 :                 if (ort->UnitConv(iUnit).is_default) defaultConv = iUnit;
   19260             :                 // look for the hint string
   19261       14933 :                 if (len(ort->UnitConv(iUnit).hint) > 0) {
   19262        6349 :                     if (has(stringInUpper, ort->UnitConv(iUnit).hint)) {
   19263         514 :                         foundConv = iUnit;
   19264         514 :                         break;
   19265             :                     }
   19266             :                 }
   19267             :             } else { // not several possibilities so don't bother with rest of array
   19268        3737 :                 foundConv = iUnit;
   19269        3737 :                 break;
   19270             :             }
   19271             :         }
   19272             :     }
   19273             :     // if it is found set the selected value to what was found. if not found,
   19274             :     // directly set it to the default and if no default set it to the first item
   19275             :     // in group.  Return zero if not found.
   19276       13134 :     int selectedConv(0);
   19277       13134 :     if (foundConv > 0) {
   19278        4251 :         selectedConv = foundConv;
   19279             :     } else {
   19280             :         // not found - see if in a group it should be default or first.
   19281        8883 :         if (firstOfSeveral == 0) {
   19282        5125 :             selectedConv = 0;
   19283             :         } else {
   19284        3758 :             if (defaultConv != 0) {
   19285           0 :                 selectedConv = defaultConv;
   19286             :             } else {
   19287        3758 :                 selectedConv = firstOfSeveral;
   19288             :             }
   19289             :         }
   19290             :     }
   19291             :     // if one was selected substitute the units into the output string
   19292       13134 :     if (selectedConv > 0) {
   19293        8009 :         if (modeInString == misBrac) {
   19294        6411 :             stringOutWithIP = stringInWithSI.substr(0, posLBrac + 1) + ort->UnitConv(selectedConv).ipName + stringInWithSI.substr(posRBrac);
   19295        1598 :         } else if (modeInString == misParen) {
   19296         132 :             stringOutWithIP = stringInWithSI.substr(0, posLParen + 1) + ort->UnitConv(selectedConv).ipName + stringInWithSI.substr(posRParen);
   19297        1466 :         } else if (modeInString == misBrce) {
   19298        1466 :             stringOutWithIP = stringInWithSI.substr(0, posLBrce + 1) + ort->UnitConv(selectedConv).ipName + stringInWithSI.substr(posRBrce);
   19299           0 :         } else if (modeInString == misNoHint) {
   19300           0 :             stringOutWithIP = ort->UnitConv(selectedConv).ipName;
   19301             :         }
   19302             :     } else {
   19303             :         // if no conversion just output the input string
   19304        5125 :         stringOutWithIP = stringInWithSI;
   19305             :     }
   19306             : 
   19307       13134 :     unitConvIndex = selectedConv;
   19308             : 
   19309             :     // Add warning if units not found.
   19310       13134 :     if (unitConvIndex == 0 && !noBrackets) {
   19311           0 :         ShowWarningError(state, "Unable to find a unit conversion from " + stringInWithSI + " into IP units");
   19312           0 :         ShowContinueError(state, "Applying default conversion factor of 1.0");
   19313             :     }
   19314       13134 : }
   19315             : 
   19316        5953 : void LookupJtokWH(EnergyPlusData &state, std::string const &stringInWithJ, int &unitConvIndex, std::string &stringOutWithKWH)
   19317             : {
   19318             :     //    AUTHOR         Jason Glazer of GARD Analytics, Inc.
   19319             :     //    DATE WRITTEN   April 15, 2016
   19320             : 
   19321             :     // For the given unit expressed in J find the unit conversion
   19322             :     // using kWh instead. This is used when unitsStyle == unitsStyleJtoKWH
   19323             :     // return zero if no unit conversion should be done
   19324             : 
   19325        5953 :     stringOutWithKWH = stringInWithJ;
   19326        5953 :     std::string::size_type gjPos = stringOutWithKWH.find("[GJ]");
   19327        5953 :     std::string::size_type mjm2Pos = stringOutWithKWH.find("[MJ/m2]");
   19328        5953 :     if (gjPos != std::string::npos) {
   19329         195 :         stringOutWithKWH.replace(gjPos, 4, "[kWh]");
   19330         195 :         unitConvIndex = getSpecificUnitIndex(state, "GJ", "kWh");
   19331        5758 :     } else if (mjm2Pos != std::string::npos) {
   19332          15 :         stringOutWithKWH.replace(mjm2Pos, 7, "[kWh/m2]");
   19333          15 :         unitConvIndex = getSpecificUnitIndex(state, "MJ/m2", "kWh/m2");
   19334             :     } else {
   19335        5743 :         unitConvIndex = 0;
   19336             :     }
   19337        5953 : }
   19338             : 
   19339       36502 : Real64 ConvertIP(EnergyPlusData &state, int const unitConvIndex, Real64 const SIvalue)
   19340             : {
   19341             :     // SUBROUTINE INFORMATION:
   19342             :     //    AUTHOR         Jason Glazer of GARD Analytics, Inc.
   19343             :     //    DATE WRITTEN   February 13, 2009
   19344             :     //    MODIFIED       September 2012
   19345             :     //    RE-ENGINEERED  na
   19346             : 
   19347             :     // PURPOSE OF THIS SUBROUTINE:
   19348             :     //   Apply the selected unit conversion to the input value
   19349             :     //   expressed in SI units to result in IP units.
   19350             :     //   If zero is provided as unit index, return the original
   19351             :     //   value (no conversion)
   19352             : 
   19353             :     // METHODOLOGY EMPLOYED:
   19354             : 
   19355             :     // REFERENCES:
   19356             :     //    na
   19357             : 
   19358             :     // USE STATEMENTS:
   19359             : 
   19360             :     // Return value
   19361             :     Real64 ConvertIP;
   19362             : 
   19363             :     // Locals
   19364             :     // SUBROUTINE ARGUMENT DEFINITIONS:
   19365             : 
   19366             :     // SUBROUTINE PARAMETER DEFINITIONS:
   19367             :     //    na
   19368             : 
   19369             :     // INTERFACE BLOCK SPECIFICATIONS:
   19370             :     //    na
   19371             : 
   19372             :     // DERIVED TYPE DEFINITIONS:
   19373             :     //    na
   19374             : 
   19375             :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
   19376             :     //    na
   19377             : 
   19378       36502 :     auto &ort(state.dataOutRptTab);
   19379             : 
   19380       36502 :     if (unitConvIndex == 0 || SIvalue == -999.0 || SIvalue == -99999.0) { // don't convert unknown data to IP
   19381        3030 :         ConvertIP = SIvalue;
   19382       33472 :     } else if ((unitConvIndex > 0) && (unitConvIndex <= ort->UnitConvSize)) {
   19383       33472 :         ConvertIP = (SIvalue * ort->UnitConv(unitConvIndex).mult) + ort->UnitConv(unitConvIndex).offset;
   19384             :     } else {
   19385           0 :         ConvertIP = SIvalue;
   19386             :     }
   19387       36502 :     return ConvertIP;
   19388             : }
   19389             : 
   19390          88 : Real64 ConvertIPdelta(EnergyPlusData &state, int const unitConvIndex, Real64 const SIvalue)
   19391             : {
   19392             :     // SUBROUTINE INFORMATION:
   19393             :     //    AUTHOR         Jason Glazer of GARD Analytics, Inc.
   19394             :     //    DATE WRITTEN   February 18, 2009
   19395             :     //    MODIFIED       na
   19396             :     //    RE-ENGINEERED  na
   19397             : 
   19398             :     // PURPOSE OF THIS SUBROUTINE:
   19399             :     //   Apply the selected unit conversion to the input value
   19400             :     //   expressed in SI units to result in IP units. This routine
   19401             :     //   only uses the mulitplier and NOT the offset and is appropriate
   19402             :     //   when the number being converted is a difference or delta
   19403             :     //   between values (such as a temperature difference).
   19404             : 
   19405             :     // METHODOLOGY EMPLOYED:
   19406             : 
   19407             :     // REFERENCES:
   19408             :     //    na
   19409             : 
   19410             :     // USE STATEMENTS:
   19411             : 
   19412             :     // Return value
   19413             :     Real64 ConvertIPdelta;
   19414             : 
   19415             :     // Locals
   19416             :     // SUBROUTINE ARGUMENT DEFINITIONS:
   19417             : 
   19418             :     // SUBROUTINE PARAMETER DEFINITIONS:
   19419             :     //    na
   19420             : 
   19421             :     // INTERFACE BLOCK SPECIFICATIONS:
   19422             :     //    na
   19423             : 
   19424             :     // DERIVED TYPE DEFINITIONS:
   19425             :     //    na
   19426             : 
   19427             :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
   19428             :     //    na
   19429             : 
   19430          88 :     auto &ort(state.dataOutRptTab);
   19431             : 
   19432          88 :     if (unitConvIndex == 0) {
   19433           0 :         ConvertIPdelta = SIvalue;
   19434          88 :     } else if ((unitConvIndex > 0) && (unitConvIndex <= ort->UnitConvSize)) {
   19435          88 :         ConvertIPdelta = SIvalue * ort->UnitConv(unitConvIndex).mult;
   19436             :     } else {
   19437           0 :         ConvertIPdelta = SIvalue;
   19438             :     }
   19439          88 :     return ConvertIPdelta;
   19440             : }
   19441             : 
   19442           0 : void GetUnitConversion(EnergyPlusData &state, int const unitConvIndex, Real64 &multiplier, Real64 &offset, std::string &IPunit)
   19443             : {
   19444             :     // SUBROUTINE INFORMATION:
   19445             :     //    AUTHOR         Jason Glazer of GARD Analytics, Inc.
   19446             :     //    DATE WRITTEN   February 13, 2009
   19447             :     //    MODIFIED       na
   19448             :     //    RE-ENGINEERED  na
   19449             : 
   19450             :     // PURPOSE OF THIS SUBROUTINE:
   19451             :     //   Return of the multiplier and adder for the given
   19452             :     //   SI to IP unit conversion.
   19453             :     //     SI = (IP * multipier) + offset
   19454             :     //  This function could be replaced by referencing the
   19455             :     //  array directly but does include some checking of the
   19456             :     //  bounds of the array.
   19457             : 
   19458             :     // METHODOLOGY EMPLOYED:
   19459             : 
   19460             :     // REFERENCES:
   19461             :     //    na
   19462             : 
   19463             :     // USE STATEMENTS:
   19464             : 
   19465             :     // Locals
   19466             :     // SUBROUTINE ARGUMENT DEFINITIONS:
   19467             : 
   19468             :     // SUBROUTINE PARAMETER DEFINITIONS:
   19469             :     //    na
   19470             : 
   19471             :     // INTERFACE BLOCK SPECIFICATIONS:
   19472             :     //    na
   19473             : 
   19474             :     // DERIVED TYPE DEFINITIONS:
   19475             :     //    na
   19476             : 
   19477             :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
   19478             :     //    na
   19479             : 
   19480           0 :     auto &ort(state.dataOutRptTab);
   19481             : 
   19482           0 :     if ((unitConvIndex > 0) && (unitConvIndex <= ort->UnitConvSize)) {
   19483           0 :         multiplier = ort->UnitConv(unitConvIndex).mult;
   19484           0 :         offset = ort->UnitConv(unitConvIndex).offset;
   19485           0 :         IPunit = ort->UnitConv(unitConvIndex).ipName;
   19486             :     } else {
   19487           0 :         multiplier = 1.0;
   19488           0 :         offset = 0.0;
   19489           0 :         IPunit = "";
   19490             :     }
   19491           0 : }
   19492             : 
   19493          99 : Real64 getSpecificUnitMultiplier(EnergyPlusData &state, std::string const &SIunit, std::string const &IPunit)
   19494             : {
   19495             :     // SUBROUTINE INFORMATION:
   19496             :     //    AUTHOR         Jason Glazer of GARD Analytics, Inc.
   19497             :     //    DATE WRITTEN   February 13, 2009
   19498             :     //    MODIFIED       na
   19499             :     //    RE-ENGINEERED  na
   19500             : 
   19501             :     // PURPOSE OF THIS SUBROUTINE:
   19502             :     //   Return of the multiplier for a specific
   19503             :     //   SI to IP unit conversion. No offset is provided so
   19504             :     //   it cannot be used to convert units such as temperatures
   19505             :     //   that include an offset.
   19506             :     //     SI = (IP * multipier) + offset
   19507             :     //   Unlike LookupSItoIP, this function does not expect more
   19508             :     //   the units in the two input parameters. No hints or
   19509             :     //   defaults are used since both the SI and IP units are
   19510             :     //   input by the user.
   19511             : 
   19512             :     // METHODOLOGY EMPLOYED:
   19513             : 
   19514             :     // REFERENCES:
   19515             :     //    na
   19516             : 
   19517             :     // USE STATEMENTS:
   19518             : 
   19519             :     // Return value
   19520             :     Real64 getSpecificUnitMultiplier;
   19521             : 
   19522             :     // Locals
   19523             :     // SUBROUTINE ARGUMENT DEFINITIONS:
   19524             : 
   19525             :     // SUBROUTINE PARAMETER DEFINITIONS:
   19526             :     //    na
   19527             : 
   19528             :     // INTERFACE BLOCK SPECIFICATIONS:
   19529             :     //    na
   19530             : 
   19531             :     // DERIVED TYPE DEFINITIONS:
   19532             :     //    na
   19533             : 
   19534             :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
   19535          99 :     auto &ort(state.dataOutRptTab);
   19536             : 
   19537        5533 :     for (state.dataOutRptTab->iUnitGsum = 1; state.dataOutRptTab->iUnitGsum <= ort->UnitConvSize; ++state.dataOutRptTab->iUnitGsum) {
   19538        5533 :         if (UtilityRoutines::SameString(ort->UnitConv(state.dataOutRptTab->iUnitGsum).siName, SIunit)) {
   19539         154 :             if (UtilityRoutines::SameString(ort->UnitConv(state.dataOutRptTab->iUnitGsum).ipName, IPunit)) {
   19540          99 :                 state.dataOutRptTab->foundGsum = state.dataOutRptTab->iUnitGsum;
   19541          99 :                 break;
   19542             :             }
   19543             :         }
   19544             :     }
   19545          99 :     if (state.dataOutRptTab->foundGsum != 0) {
   19546          99 :         getSpecificUnitMultiplier = ort->UnitConv(state.dataOutRptTab->foundGsum).mult;
   19547             :     } else {
   19548           0 :         ShowWarningError(state, "Unable to find a unit conversion from " + SIunit + " to " + IPunit);
   19549           0 :         ShowContinueError(state, "Applying default conversion factor of 1.0");
   19550           0 :         getSpecificUnitMultiplier = 1.0;
   19551             :     }
   19552          99 :     return getSpecificUnitMultiplier;
   19553             : }
   19554             : 
   19555          66 : Real64 getSpecificUnitDivider(EnergyPlusData &state, std::string const &SIunit, std::string const &IPunit)
   19556             : {
   19557             :     // SUBROUTINE INFORMATION:
   19558             :     //    AUTHOR         Jason Glazer of GARD Analytics, Inc.
   19559             :     //    DATE WRITTEN   February 13, 2009
   19560             :     //    MODIFIED       na
   19561             :     //    RE-ENGINEERED  na
   19562             : 
   19563             :     // PURPOSE OF THIS SUBROUTINE:
   19564             :     //   Returns the divider (1/multiplier) for a specific
   19565             :     //   SI to IP unit conversion. No offset is provided so
   19566             :     //   it cannot be used to convert units such as temperatures
   19567             :     //   that include an offset.
   19568             :     //     SI = (IP * multipier) + offset
   19569             :     //   Unlike LookupSItoIP, this function does not expect more
   19570             :     //   the units in the two input parameters. No hints or
   19571             :     //   defaults are used since both the SI and IP units are
   19572             :     //   input by the user.
   19573             : 
   19574             :     // METHODOLOGY EMPLOYED:
   19575             : 
   19576             :     // REFERENCES:
   19577             :     //    na
   19578             : 
   19579             :     // USE STATEMENTS:
   19580             : 
   19581             :     // Return value
   19582             :     Real64 getSpecificUnitDivider;
   19583             : 
   19584             :     // Locals
   19585             :     // SUBROUTINE ARGUMENT DEFINITIONS:
   19586             : 
   19587             :     // SUBROUTINE PARAMETER DEFINITIONS:
   19588             :     //    na
   19589             : 
   19590             :     // INTERFACE BLOCK SPECIFICATIONS:
   19591             :     //    na
   19592             : 
   19593             :     // DERIVED TYPE DEFINITIONS:
   19594             :     //    na
   19595             : 
   19596             :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
   19597             :     Real64 mult;
   19598             : 
   19599          66 :     mult = getSpecificUnitMultiplier(state, SIunit, IPunit);
   19600          66 :     if (mult != 0) {
   19601          66 :         getSpecificUnitDivider = 1 / mult;
   19602             :     } else {
   19603           0 :         ShowWarningError(state, "Unable to find a unit conversion from " + SIunit + " to " + IPunit);
   19604           0 :         ShowContinueError(state, "Applying default conversion factor of 1.0");
   19605           0 :         getSpecificUnitDivider = 1.0;
   19606             :     }
   19607          66 :     return getSpecificUnitDivider;
   19608             : }
   19609             : 
   19610         210 : Real64 getSpecificUnitIndex(EnergyPlusData &state, std::string const &SIunit, std::string const &IPunit)
   19611             : {
   19612             :     // SUBROUTINE INFORMATION:
   19613             :     //    AUTHOR         Jason Glazer of GARD Analytics, Inc.
   19614             :     //    DATE WRITTEN   September 21, 2012
   19615             :     //    MODIFIED       na
   19616             :     //    RE-ENGINEERED  na
   19617             : 
   19618             :     // PURPOSE OF THIS SUBROUTINE:
   19619             :     //   Return of the unit conversion index for a specific
   19620             :     //   SI to IP unit conversion.
   19621             :     //   Unlike LookupSItoIP, this function does not expect more
   19622             :     //   the units in the two input parameters. No hints or
   19623             :     //   defaults are used since both the SI and IP units are
   19624             :     //   input by the user.
   19625             : 
   19626             :     // METHODOLOGY EMPLOYED:
   19627             : 
   19628             :     // REFERENCES:
   19629             :     //    na
   19630             : 
   19631             :     // USE STATEMENTS:
   19632             : 
   19633             :     // Return value
   19634             :     Real64 getSpecificUnitIndex;
   19635             : 
   19636             :     // Locals
   19637             :     // SUBROUTINE ARGUMENT DEFINITIONS:
   19638             : 
   19639             :     // SUBROUTINE PARAMETER DEFINITIONS:
   19640             :     //    na
   19641             : 
   19642             :     // INTERFACE BLOCK SPECIFICATIONS:
   19643             :     //    na
   19644             : 
   19645             :     // DERIVED TYPE DEFINITIONS:
   19646             :     //    na
   19647             : 
   19648             :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
   19649         210 :     auto &ort(state.dataOutRptTab);
   19650             : 
   19651       18195 :     for (state.dataOutRptTab->iUnitGsui = 1; state.dataOutRptTab->iUnitGsui <= ort->UnitConvSize; ++state.dataOutRptTab->iUnitGsui) {
   19652       18195 :         if (UtilityRoutines::SameString(ort->UnitConv(state.dataOutRptTab->iUnitGsui).siName, SIunit)) {
   19653         450 :             if (UtilityRoutines::SameString(ort->UnitConv(state.dataOutRptTab->iUnitGsui).ipName, IPunit)) {
   19654         210 :                 state.dataOutRptTab->foundGsui = state.dataOutRptTab->iUnitGsui;
   19655         210 :                 break;
   19656             :             }
   19657             :         }
   19658             :     }
   19659         210 :     if (state.dataOutRptTab->foundGsui != 0) {
   19660         210 :         getSpecificUnitIndex = state.dataOutRptTab->foundGsui;
   19661             :     } else {
   19662           0 :         getSpecificUnitIndex = 0.0;
   19663             :     }
   19664         210 :     return getSpecificUnitIndex;
   19665             : }
   19666             : 
   19667        2313 : } // namespace EnergyPlus::OutputReportTabular

Generated by: LCOV version 1.13