/
OutputReportTabular.cc
14742 lines (13417 loc) · 641 KB
/
OutputReportTabular.cc
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// C++ Headers
#include <cassert>
#include <cmath>
#include <iomanip>
#include <map>
#include <utility>
#include <vector>
// ObjexxFCL Headers
#include <ObjexxFCL/Array.functions.hh>
#include <ObjexxFCL/Fmath.hh>
#include <ObjexxFCL/gio.hh>
#include <ObjexxFCL/numeric.hh>
#include <ObjexxFCL/string.functions.hh>
#include <ObjexxFCL/Time_Date.hh>
// EnergyPlus Headers
#include <CommandLineInterface.hh>
#include <OutputReportTabular.hh>
#include <DataAirflowNetwork.hh>
#include <DataCostEstimate.hh>
#include <DataDefineEquip.hh>
#include <DataEnvironment.hh>
#include <DataErrorTracking.hh>
#include <DataGlobalConstants.hh>
#include <DataHeatBalance.hh>
#include <DataHVACGlobals.hh>
#include <DataIPShortCuts.hh>
#include <DataOutputs.hh>
#include <DataPrecisionGlobals.hh>
#include <DataShadowingCombinations.hh>
#include <DataSizing.hh>
#include <DataStringGlobals.hh>
#include <DataSurfaces.hh>
#include <DataWater.hh>
#include <DataZoneEquipment.hh>
#include <DirectAirManager.hh>
#include <DisplayRoutines.hh>
#include <ExteriorEnergyUse.hh>
#include <General.hh>
#include <InputProcessor.hh>
#include <LowTempRadiantSystem.hh>
#include <ManageElectricPower.hh>
#include <OutputProcessor.hh>
#include <OutputReportPredefined.hh>
#include <OutputReportTabularAnnual.hh>
#include <PollutionModule.hh>
#include <Psychrometrics.hh>
#include <ScheduleManager.hh>
#include <SQLiteProcedures.hh>
#include <ThermalComfort.hh>
#include <UtilityRoutines.hh>
#include <VentilatedSlab.hh>
#include <ZonePlenum.hh>
namespace EnergyPlus {
namespace OutputReportTabular {
// MODULE INFORMATION:
// AUTHOR Jason Glazer of GARD Analytics, Inc.
// DATE WRITTEN July 2003
// MODIFIED na
// RE-ENGINEERED na
// PURPOSE OF THIS MODULE:
// This module allows the user to define several different tabular
// report that have a specific format.
// METHODOLOGY EMPLOYED:
// Generally aggregation. Specifically, the IDF objects are read into data
// structures on the first call to update the data. The data structures
// include not only ones to hold the IDF data but also that initialize
// the structure used to gather data each iteration. The report:table:binned
// object is stored in OutputTableBinned.
// During initialization the TableResults data structure is created which contains
// all the information needed to perform the aggregation on a timestep basis.
// After the end of the simulation the original Output data structures
// are scanned and actual tables are created doing any scaling as necessary
// and placing all the results into an output table. The output table
// is written in the selected format for each of the tables defined.
// REFERENCES:
// None.
// OTHER NOTES:.
// |--> BinResults
// |
// |--> BinResultsAbove
// OutputTableBinned ---------------->|
// |--> BinResultsBelow
// |
// |--> BinObjVarID
//
// |--> MonthlyFieldSetInput
// MonthlyInput --------------------->|
// |--> MonthlyTable --> MonthlyColumns
// Using/Aliasing
using namespace DataPrecisionGlobals;
using namespace InputProcessor;
using DataGlobals::BigNumber;
using DataGlobals::ZoneTSReporting;
using DataGlobals::HVACTSReporting;
using DataGlobals::KindOfSim;
using DataGlobals::ksDesignDay;
using DataGlobals::ksRunPeriodDesign;
using DataGlobals::ksRunPeriodWeather;
using DataGlobals::DoWeathSim;
using DataGlobals::DoOutputReporting;
using DataGlobals::DisplayExtraWarnings;
using DataGlobals::OutputFileInits;
using DataGlobals::HourOfDay;
using DataGlobals::TimeStep;
using DataGlobals::SecInHour;
using DataGlobals::TimeStepZone;
using DataGlobals::TimeStepZoneSec;
using DataGlobals::CurrentTime;
using DataGlobals::NumOfZones;
using DataGlobals::OutputFileDebug;
using namespace DataGlobalConstants;
using namespace OutputReportPredefined;
// Data
//MODULE PARAMETER DEFINITIONS:
int const MaxHeaderLength( 50 );
int const MaxNoteLength( 200 );
int const aggTypeSumOrAvg( 1 );
int const aggTypeMaximum( 2 );
int const aggTypeMinimum( 3 );
int const aggTypeValueWhenMaxMin( 4 );
int const aggTypeHoursZero( 5 );
int const aggTypeHoursNonZero( 6 );
int const aggTypeHoursPositive( 7 );
int const aggTypeHoursNonPositive( 8 );
int const aggTypeHoursNegative( 9 );
int const aggTypeHoursNonNegative( 10 );
int const aggTypeSumOrAverageHoursShown( 11 );
int const aggTypeMaximumDuringHoursShown( 12 );
int const aggTypeMinimumDuringHoursShown( 13 );
int const tableStyleComma( 1 );
int const tableStyleTab( 2 );
int const tableStyleFixed( 3 );
int const tableStyleHTML( 4 );
int const tableStyleXML( 5 );
int const unitsStyleNone( 0 ); // no change to any units
int const unitsStyleJtoKWH( 1 );
int const unitsStyleJtoMJ( 2 );
int const unitsStyleJtoGJ( 3 );
int const unitsStyleInchPound( 4 );
int const unitsStyleNotFound( 5 );
int const isAverage( 1 );
int const isSum( 2 );
int const stepTypeZone( ZoneTSReporting );
int const stepTypeHVAC( HVACTSReporting );
// BEPS Report Related Variables
// From Report:Table:Predefined - BEPS
int const numResourceTypes( 14 );
int const numSourceTypes( 12 );
static std::string const validChars( "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_:." );
static std::string const BlankString;
//MODULE VARIABLE DECLARATIONS:
// The Binned table type is different and only references one variable and its structure is very
// different from the others so it is has its own type.
// arrays for time binned results
int OutputTableBinnedCount;
int BinResultsTableCount;
int BinResultsIntervalCount;
int const numNamedMonthly( 62 );
// These reports are detailed/named in routine InitializePredefinedMonthlyTitles
int MonthlyInputCount( 0 );
int sizeMonthlyInput( 0 );
int MonthlyFieldSetInputCount( 0 );
int sizeMonthlyFieldSetInput( 0 );
int MonthlyTablesCount( 0 );
int MonthlyColumnsCount( 0 );
Array1D_bool IsMonthGathered( 12, false ); // shown as true for any month used
int TOCEntriesCount( 0 );
int TOCEntriesSize( 0 );
int UnitConvSize;
bool WriteTabularFiles( false );
// Allow up to five output files to be created
int const maxNumStyles( 5 );
// From Report:Table:Style
int unitsStyle( 0 ); // see list of parameters
int numStyles( 0 );
std::ofstream csv_stream; // CSV table stream
std::ofstream tab_stream; // Tab table stream
std::ofstream fix_stream; // Fixed table stream
std::ofstream htm_stream; // HTML table stream
std::ofstream xml_stream; // XML table stream
Array1D< std::ofstream * > TabularOutputFile( maxNumStyles, { &csv_stream, &tab_stream, &fix_stream, &htm_stream, &xml_stream } ); // Table stream array
Array1D_string del( maxNumStyles ); // the delimiter to use
Array1D_int TableStyle( maxNumStyles, 0 ); // see list of parameters
Real64 timeInYear( 0.0 );
// Flags for predefined tabular reports
bool displayTabularBEPS( false );
bool displayLEEDSummary( false );
bool displayTabularCompCosts( false ); // added BTG 5/6/04 for component cost summary
bool displayTabularVeriSum( false ); // added JG 2006-06-28 for input verification and summary report
bool displayComponentSizing( false );
bool displaySurfaceShadowing( false );
bool displayDemandEndUse( false );
bool displayAdaptiveComfort( false );
bool displaySourceEnergyEndUseSummary( false );
bool displayZoneComponentLoadSummary( false );
// BEPS Report Related Variables
// From Report:Table:Predefined - BEPS
// arrays that hold the meter numbers that are initialized at get input
Array1D_int meterNumTotalsBEPS( numResourceTypes, 0 );
Array1D_int meterNumTotalsSource( numSourceTypes, 0 );
Array1D_bool fuelfactorsused( numSourceTypes, false );
Array1D_bool ffUsed( numResourceTypes, false );
Array1D< Real64 > SourceFactors( numResourceTypes, 0.0 );
Array1D_bool ffSchedUsed( numResourceTypes, false );
Array1D_int ffSchedIndex( numResourceTypes, 0 );
Array2D_int meterNumEndUseBEPS( numResourceTypes, NumEndUses, 0 );
Array3D_int meterNumEndUseSubBEPS;
// arrays that hold the names of the resource and end uses
Array1D_string resourceTypeNames( numResourceTypes );
Array1D_string sourceTypeNames( numSourceTypes );
Array1D_string endUseNames( NumEndUses );
// arrays that hold the actual values for the year
Array1D< Real64 > gatherTotalsBEPS( numResourceTypes, 0.0 );
Array1D< Real64 > gatherTotalsBySourceBEPS( numResourceTypes, 0.0 );
Array1D< Real64 > gatherTotalsSource( numSourceTypes, 0.0 );
Array1D< Real64 > gatherTotalsBySource( numSourceTypes, 0.0 );
Array2D< Real64 > gatherEndUseBEPS( numResourceTypes, NumEndUses, 0.0 );
Array2D< Real64 > gatherEndUseBySourceBEPS( numResourceTypes, NumEndUses, 0.0 );
Array3D< Real64 > gatherEndUseSubBEPS;
// arrays the hold the demand values
Array1D< Real64 > gatherDemandTotal( numResourceTypes, 0.0 );
Array2D< Real64 > gatherDemandEndUse( numResourceTypes, NumEndUses, 0.0 );
Array3D< Real64 > gatherDemandEndUseSub;
Array1D_int gatherDemandTimeStamp( numResourceTypes, 0 );
// to keep track of hours for the BEPS report gathering
Real64 gatherElapsedTimeBEPS( 0.0 );
// for normalization of results
Real64 buildingGrossFloorArea( 0.0 );
Real64 buildingConditionedFloorArea( 0.0 );
// keep track if schedules are used in fuel factors
bool fuelFactorSchedulesUsed( false );
// for electic load components on BEPS report
int meterNumPowerFuelFireGen( 0 );
Real64 gatherPowerFuelFireGen( 0.0 );
int meterNumPowerPV( 0 );
Real64 gatherPowerPV( 0.0 );
int meterNumPowerWind( 0 );
Real64 gatherPowerWind( 0.0 );
Real64 OverallNetEnergyFromStorage( 0.0 );
int meterNumPowerHTGeothermal( 0 );
Real64 gatherPowerHTGeothermal( 0.0 );
int meterNumElecProduced( 0 );
Real64 gatherElecProduced( 0.0 );
int meterNumElecPurchased( 0 );
Real64 gatherElecPurchased( 0.0 );
int meterNumElecSurplusSold( 0 );
Real64 gatherElecSurplusSold( 0.0 );
// for on site thermal source components on BEPS report
int meterNumWaterHeatRecovery( 0 );
Real64 gatherWaterHeatRecovery( 0.0 );
int meterNumAirHeatRecoveryCool( 0 );
Real64 gatherAirHeatRecoveryCool( 0.0 );
int meterNumAirHeatRecoveryHeat( 0 );
Real64 gatherAirHeatRecoveryHeat( 0.0 );
int meterNumHeatHTGeothermal( 0 );
Real64 gatherHeatHTGeothermal( 0.0 );
int meterNumHeatSolarWater( 0 );
Real64 gatherHeatSolarWater( 0.0 );
int meterNumHeatSolarAir( 0 );
Real64 gatherHeatSolarAir( 0.0 );
// for on site water components on BEPS report
int meterNumRainWater( 0 );
Real64 gatherRainWater( 0.0 );
int meterNumCondensate( 0 );
Real64 gatherCondensate( 0.0 );
int meterNumGroundwater( 0 );
Real64 gatherWellwater( 0.0 );
int meterNumMains( 0 );
Real64 gatherMains( 0.0 );
int meterNumWaterEndUseTotal( 0 );
Real64 gatherWaterEndUseTotal( 0.0 );
// for source energy conversion factors on BEPS report
Real64 sourceFactorElectric( 0.0 );
Real64 sourceFactorNaturalGas( 0.0 );
Real64 efficiencyDistrictCooling( 0.0 );
Real64 efficiencyDistrictHeating( 0.0 );
Real64 sourceFactorSteam( 0.0 );
Real64 sourceFactorGasoline( 0.0 );
Real64 sourceFactorDiesel( 0.0 );
Real64 sourceFactorCoal( 0.0 );
Real64 sourceFactorFuelOil1( 0.0 );
Real64 sourceFactorFuelOil2( 0.0 );
Real64 sourceFactorPropane( 0.0 );
Real64 sourceFactorOtherFuel1( 0.0 );
Real64 sourceFactorOtherFuel2( 0.0 );
Array1D_int td( 8 );
//(1) Current year
//(2) Current month
//(3) Current day
//(4) Time difference with respect to UTC in minutes (0-59)
//(5) Hour of the day (0-23)
//(6) Minutes (0-59)
//(7) Seconds (0-59)
//(8) Milliseconds (0-999)
// Design day name storage
Array1D_string DesignDayName;
int DesignDayCount( 0 );
//arrays related to pulse and load component reporting
Array2D< Real64 > radiantPulseUsed;
Array2D_int radiantPulseTimestep;
Array2D< Real64 > radiantPulseReceived;
Array3D< Real64 > loadConvectedNormal;
Array3D< Real64 > loadConvectedWithPulse;
Array3D< Real64 > netSurfRadSeq;
Array2D< Real64 > decayCurveCool;
Array2D< Real64 > decayCurveHeat;
Array3D< Real64 > ITABSFseq; // used for determining the radiant fraction on each surface
Array3D< Real64 > TMULTseq; // used for determining the radiant fraction on each surface
Array3D< Real64 > peopleInstantSeq;
Array3D< Real64 > peopleLatentSeq;
Array3D< Real64 > peopleRadSeq;
Array3D< Real64 > peopleDelaySeq;
Array3D< Real64 > lightInstantSeq;
Array3D< Real64 > lightRetAirSeq;
Array3D< Real64 > lightLWRadSeq; // long wave thermal radiation
Array3D< Real64 > lightSWRadSeq; // short wave visible radiation
Array3D< Real64 > lightDelaySeq;
Array3D< Real64 > equipInstantSeq;
Array3D< Real64 > equipLatentSeq;
Array3D< Real64 > equipRadSeq;
Array3D< Real64 > equipDelaySeq;
Array3D< Real64 > refrigInstantSeq;
Array3D< Real64 > refrigRetAirSeq;
Array3D< Real64 > refrigLatentSeq;
Array3D< Real64 > waterUseInstantSeq;
Array3D< Real64 > waterUseLatentSeq;
Array3D< Real64 > hvacLossInstantSeq;
Array3D< Real64 > hvacLossRadSeq;
Array3D< Real64 > hvacLossDelaySeq;
Array3D< Real64 > powerGenInstantSeq;
Array3D< Real64 > powerGenRadSeq;
Array3D< Real64 > powerGenDelaySeq;
Array3D< Real64 > infilInstantSeq;
Array3D< Real64 > infilLatentSeq;
Array3D< Real64 > zoneVentInstantSeq;
Array3D< Real64 > zoneVentLatentSeq;
Array3D< Real64 > interZoneMixInstantSeq;
Array3D< Real64 > interZoneMixLatentSeq;
Array3D< Real64 > feneCondInstantSeq;
//REAL(r64), DIMENSION(:,:,:),ALLOCATABLE,PUBLIC :: feneSolarInstantSeq
Array3D< Real64 > feneSolarRadSeq;
Array3D< Real64 > feneSolarDelaySeq;
Array3D< Real64 > surfDelaySeq;
int maxUniqueKeyCount( 0 );
// for the XML report must keep track fo the active sub-table name and report set by other routines
std::string activeSubTableName;
std::string activeReportNameNoSpace;
std::string activeReportName;
std::string activeForName;
std::string prevReportName;
// SUBROUTINE SPECIFICATIONS FOR MODULE PrimaryPlantLoops
//PRIVATE DateToStr
// Object Data
Array1D< OutputTableBinnedType > OutputTableBinned;
Array2D< BinResultsType > BinResults; // table number, number of intervals
Array1D< BinResultsType > BinResultsBelow; // time below the lowest defined bin
Array1D< BinResultsType > BinResultsAbove; // time above the highest defined bin
Array1D< BinObjVarIDType > BinObjVarID;
Array1D< BinStatisticsType > BinStatistics;
Array1D< NamedMonthlyType > namedMonthly; // for predefined monthly report titles
Array1D< MonthlyFieldSetInputType > MonthlyFieldSetInput;
Array1D< MonthlyInputType > MonthlyInput;
Array1D< MonthlyTablesType > MonthlyTables;
Array1D< MonthlyColumnsType > MonthlyColumns;
Array1D< TOCEntriesType > TOCEntries;
Array1D< UnitConvType > UnitConv;
static gio::Fmt fmtLD( "*" );
static gio::Fmt fmtA( "(A)" );
// Functions
void
UpdateTabularReports( int const IndexTypeKey ) // What kind of data to update (Zone, HVAC)
{
// SUBROUTINE INFORMATION:
// AUTHOR Jason Glazer
// DATE WRITTEN July 2003
// MODIFIED na
// RE-ENGINEERED na
// PURPOSE OF THIS SUBROUTINE:
// This is the routine that is called at the end of the time step
// loop and updates the arrays of data that will later being put
// into the tabular reports.
// METHODOLOGY EMPLOYED:
// REFERENCES:
// na
// USE STATEMENTS:
// na
// Locals
// SUBROUTINE ARGUMENT DEFINITIONS:
// SUBROUTINE PARAMETER DEFINITIONS:
// na
// INTERFACE BLOCK SPECIFICATIONS:
// na
// DERIVED TYPE DEFINITIONS:
// na
// SUBROUTINE LOCAL VARIABLE DECLARATIONS:
static bool GetInput( true );
if ( IndexTypeKey != ZoneTSReporting && IndexTypeKey != HVACTSReporting ) {
ShowFatalError( "Invalid reporting requested -- UpdateTabularReports" );
}
if ( GetInput ) {
GetInputTabularMonthly();
OutputReportTabularAnnual::GetInputTabularAnnual();
GetInputTabularTimeBins();
GetInputTabularStyle();
GetInputTabularPredefined();
// noel -- noticed this was called once and very slow -- sped up a little by caching keys
InitializeTabularMonthly();
GetInputFuelAndPollutionFactors();
SetupUnitConversions();
AddTOCZoneLoadComponentTable();
GetInput = false;
date_and_time( _, _, _, td );
}
if ( DoOutputReporting && WriteTabularFiles && ( KindOfSim == ksRunPeriodWeather ) ) {
if ( IndexTypeKey == stepTypeZone ) {
gatherElapsedTimeBEPS += TimeStepZone;
}
if ( DoWeathSim ) {
GatherMonthlyResultsForTimestep( IndexTypeKey );
OutputReportTabularAnnual::GatherAnnualResultsForTimeStep( IndexTypeKey );
GatherBinResultsForTimestep( IndexTypeKey );
GatherBEPSResultsForTimestep( IndexTypeKey );
GatherSourceEnergyEndUseResultsForTimestep( IndexTypeKey );
GatherPeakDemandForTimestep( IndexTypeKey );
GatherHeatGainReport( IndexTypeKey );
}
}
}
//======================================================================================================================
//======================================================================================================================
// GET INPUT ROUTINES
//======================================================================================================================
//======================================================================================================================
void
GetInputTabularMonthly()
{
// SUBROUTINE INFORMATION:
// AUTHOR Jason Glazer
// DATE WRITTEN July 2003
// MODIFIED na
// RE-ENGINEERED na
// PURPOSE OF THIS SUBROUTINE:
// The routine assigns the input information for
// REPORT:TABLE:MONTHLY also known as tabular monthly
// reports that are defined by the user. The input
// information is assigned to a data structure that
// is used for both user defined monthly reports and
// predefined monthly reports.
// METHODOLOGY EMPLOYED:
// Uses get input structure and call to build up
// data on monthly reports.
// REFERENCES:
// na
// USE STATEMENTS:
// na
// Locals
// SUBROUTINE ARGUMENT DEFINITIONS:
// na
// SUBROUTINE PARAMETER DEFINITIONS:
static std::string const CurrentModuleObject( "Output:Table:Monthly" );
// INTERFACE BLOCK SPECIFICATIONS:
// na
// DERIVED TYPE DEFINITIONS:
// na
// SUBROUTINE LOCAL VARIABLE DECLARATIONS:
int curTable; // index of the current table being processed in MonthlyInput
int curAggType; // kind of aggregation identified (see AggType parameters)
std::string curAggString; // Current aggregation sting
int jField;
int NumParams; // Number of elements combined
int NumAlphas; // Number of elements in the alpha array
int NumNums; // Number of elements in the numeric array
Array1D_string AlphArray; // character string data
Array1D< Real64 > NumArray; // numeric data
int IOStat; // IO Status when calling get input subroutine
static bool ErrorsFound( false );
bool IsNotOK; // Flag to verify name
bool IsBlank; // Flag for blank name
MonthlyInputCount = GetNumObjectsFound( CurrentModuleObject );
if ( MonthlyInputCount > 0 ) {
WriteTabularFiles = true;
// if not a run period using weather do not create reports
if ( ! DoWeathSim ) {
ShowWarningError( CurrentModuleObject + " requested with SimulationControl Run Simulation for Weather File Run Periods set to No so " + CurrentModuleObject + " will not be generated" );
return;
}
}
GetObjectDefMaxArgs( CurrentModuleObject, NumParams, NumAlphas, NumNums );
AlphArray.allocate( NumAlphas );
NumArray.dimension( NumNums, 0.0 );
for ( int TabNum = 1, TabNum_end = MonthlyInputCount; TabNum <= TabNum_end; ++TabNum ) { // MonthlyInputCount is modified in the loop
GetObjectItem( CurrentModuleObject, TabNum, AlphArray, NumAlphas, NumArray, NumNums, IOStat );
IsNotOK = false;
IsBlank = false;
if ( TabNum - 1 > 0 ) {
VerifyName( AlphArray( 1 ), MonthlyInput, &MonthlyInputType::name, TabNum - 1, IsNotOK, IsBlank, CurrentModuleObject + " Name" );
if ( IsNotOK ) {
ErrorsFound = true;
if ( IsBlank ) AlphArray( 1 ) = "RTMBLANK";
}
}
if ( NumAlphas < 2 ) {
ShowSevereError( CurrentModuleObject + ": No fields specified." );
}
// add to the data structure
curTable = AddMonthlyReport( AlphArray( 1 ), int( NumArray( 1 ) ) );
for ( jField = 2; jField <= NumAlphas; jField += 2 ) {
curAggString = AlphArray( jField + 1 );
// set accumulator values to default as appropriate for aggregation type
if ( SameString( curAggString, "SumOrAverage" ) ) {
curAggType = aggTypeSumOrAvg;
} else if ( SameString( curAggString, "Maximum" ) ) {
curAggType = aggTypeMaximum;
} else if ( SameString( curAggString, "Minimum" ) ) {
curAggType = aggTypeMinimum;
} else if ( SameString( curAggString, "ValueWhenMaximumOrMinimum" ) ) {
curAggType = aggTypeValueWhenMaxMin;
} else if ( SameString( curAggString, "HoursZero" ) ) {
curAggType = aggTypeHoursZero;
} else if ( SameString( curAggString, "HoursNonzero" ) ) {
curAggType = aggTypeHoursNonZero;
} else if ( SameString( curAggString, "HoursPositive" ) ) {
curAggType = aggTypeHoursPositive;
} else if ( SameString( curAggString, "HoursNonpositive" ) ) {
curAggType = aggTypeHoursNonPositive;
} else if ( SameString( curAggString, "HoursNegative" ) ) {
curAggType = aggTypeHoursNegative;
} else if ( SameString( curAggString, "HoursNonnegative" ) ) {
curAggType = aggTypeHoursNonNegative;
} else if ( SameString( curAggString, "SumOrAverageDuringHoursShown" ) ) {
curAggType = aggTypeSumOrAverageHoursShown;
} else if ( SameString( curAggString, "MaximumDuringHoursShown" ) ) {
curAggType = aggTypeMaximumDuringHoursShown;
} else if ( SameString( curAggString, "MinimumDuringHoursShown" ) ) {
curAggType = aggTypeMinimumDuringHoursShown;
} else {
curAggType = aggTypeSumOrAvg;
ShowWarningError( CurrentModuleObject + '=' + MonthlyInput( TabNum ).name + ", Variable name=" + AlphArray( jField ) );
ShowContinueError( "Invalid aggregation type=\"" + curAggString + "\" Defaulting to SumOrAverage." );
}
AddMonthlyFieldSetInput( curTable, AlphArray( jField ), "", curAggType );
}
}
}
int
AddMonthlyReport(
std::string const & inReportName,
int const inNumDigitsShown
)
{
// SUBROUTINE INFORMATION:
// AUTHOR Jason Glazer
// DATE WRITTEN August 2008
// MODIFIED
// RE-ENGINEERED na
// PURPOSE OF THIS SUBROUTINE:
// Creates a monthly report
// METHODOLOGY EMPLOYED:
// na
// REFERENCES:
// na
// USE STATEMENTS:
// Return value
// Locals
// SUBROUTINE ARGUMENT DEFINITIONS:
// na
// SUBROUTINE PARAMETER DEFINITIONS:
// INTERFACE BLOCK SPECIFICATIONS:
// na
// DERIVED TYPE DEFINITIONS:
// na
// SUBROUTINE LOCAL VARIABLE DECLARATIONS:
int const SizeAdder( 25 );
if ( ! allocated( MonthlyInput ) ) {
MonthlyInput.allocate( SizeAdder );
sizeMonthlyInput = SizeAdder;
MonthlyInputCount = 1;
} else {
++MonthlyInputCount;
// if larger than current size grow the array
if ( MonthlyInputCount > sizeMonthlyInput ) {
MonthlyInput.redimension( sizeMonthlyInput += SizeAdder );
}
}
// initialize new record
MonthlyInput( MonthlyInputCount ).name = inReportName;
MonthlyInput( MonthlyInputCount ).showDigits = inNumDigitsShown;
return MonthlyInputCount;
}
void
AddMonthlyFieldSetInput(
int const inMonthReport,
std::string const & inVariMeter,
std::string const & inColHead,
int const inAggregate
)
{
// SUBROUTINE INFORMATION:
// AUTHOR Jason Glazer
// DATE WRITTEN August 2008
// MODIFIED
// RE-ENGINEERED na
// PURPOSE OF THIS SUBROUTINE:
// Assigns the column information for predefined
// monthly reports
// METHODOLOGY EMPLOYED:
// Simple assignments to public variables.
// REFERENCES:
// na
// USE STATEMENTS:
// Locals
// SUBROUTINE ARGUMENT DEFINITIONS:
// SUBROUTINE PARAMETER DEFINITIONS:
int const sizeIncrement( 50 );
// INTERFACE BLOCK SPECIFICATIONS:
// na
// DERIVED TYPE DEFINITIONS:
// na
// SUBROUTINE LOCAL VARIABLE DECLARATIONS:
// na
if ( ! allocated( MonthlyFieldSetInput ) ) {
MonthlyFieldSetInput.allocate( sizeIncrement );
sizeMonthlyFieldSetInput = sizeIncrement;
MonthlyFieldSetInputCount = 1;
} else {
++MonthlyFieldSetInputCount;
// if larger than current size grow the array
if ( MonthlyFieldSetInputCount > sizeMonthlyFieldSetInput ) {
MonthlyFieldSetInput.redimension( sizeMonthlyFieldSetInput *= 2 ); //Tuned Changed += sizeIncrement to *= 2 for reduced heap allocations (at some space cost)
}
}
// initialize new record)
MonthlyFieldSetInput( MonthlyFieldSetInputCount ).variMeter = inVariMeter;
MonthlyFieldSetInput( MonthlyFieldSetInputCount ).colHead = inColHead;
MonthlyFieldSetInput( MonthlyFieldSetInputCount ).aggregate = inAggregate;
//update the references from the MonthlyInput array
if ( ( inMonthReport > 0 ) && ( inMonthReport <= MonthlyInputCount ) ) {
if ( MonthlyInput( inMonthReport ).firstFieldSet == 0 ) {
MonthlyInput( inMonthReport ).firstFieldSet = MonthlyFieldSetInputCount;
MonthlyInput( inMonthReport ).numFieldSet = 1;
} else {
++MonthlyInput( inMonthReport ).numFieldSet;
}
}
}
void
InitializeTabularMonthly()
{
// SUBROUTINE INFORMATION:
// AUTHOR Jason Glazer
// DATE WRITTEN July 2008
// MODIFIED na
// RE-ENGINEERED na
// PURPOSE OF THIS SUBROUTINE:
// This routine initializes the data structures based
// on input from either the IDF file or from the predefined
// monthly reports. The data structures follow the IDD
// closely. The routine initializes many of the arrays
// for monthly tables.
// METHODOLOGY EMPLOYED:
// Process the data structures that define monthly tabular
// reports
// NOTE:
// The bulk of this routine used to be part of the the
// GetInputTabularMonthly routine but when predefined
// monthly reports were added this routine was seperated
// from input.
// REFERENCES:
// na
// USE STATEMENTS:
// na
// Locals
// SUBROUTINE ARGUMENT DEFINITIONS:
// na
// SUBROUTINE PARAMETER DEFINITIONS:
// na
// INTERFACE BLOCK SPECIFICATIONS:
// na
// DERIVED TYPE DEFINITIONS:
// na
// SUBROUTINE LOCAL VARIABLE DECLARATIONS:
int TabNum; // index when cycling through each table
int NumColumns; // number of columns specified in the input for an object
int FirstColumn; // the first column of the monthly input
std::string curVariMeter; // current variable or meter
int colNum; // loop index for columns
int KeyCount;
int TypeVar;
int AvgSumVar;
int StepTypeVar;
std::string UnitsVar; // Units sting, may be blank
//CHARACTER(len=MaxNameLength), DIMENSION(:), ALLOCATABLE :: NamesOfKeys ! Specific key name
//INTEGER, DIMENSION(:) , ALLOCATABLE :: IndexesForKeyVar ! Array index
Array1D_string UniqueKeyNames;
int UniqueKeyCount;
int iKey;
int jUnique;
int found;
int kUniqueKey;
int lTable;
int mColumn;
int ColumnsRecount;
int TablesRecount;
static Real64 BigNum( 0.0 );
bool environmentKeyFound;
static bool VarWarning( true );
static int ErrCount1( 0 );
static int ErrCount2( 0 );
//INTEGER :: maxKeyCount
// if not a running a weather simulation do not create reports
if ( ! DoWeathSim ) return;
maxUniqueKeyCount = 1500;
UniqueKeyNames.allocate( maxUniqueKeyCount );
// First pass through the input objects is to put the name of the report
// into the array and count the number of unique keys found to allocate
// the monthlyTables and monthlyColumns
// This approach seems inefficient but I know of no other way to size
// the arrays prior to filling them and to size the arrays basically
// the same steps must be gone through as with filling the arrays.
//#ifdef ITM_KEYCACHE
// Noel comment: How about allocating these variables once for the whole routine?
// Again, if a max value for key count can be agreed upon, we could use it here --
// otherwise, will have to have re-allocate logic.
//maxKeyCount=1500 ! ?
//ALLOCATE(NamesOfKeys(maxKeyCount))
//ALLOCATE(IndexesForKeyVar(maxKeyCount))
//#endif
MonthlyColumnsCount = 0;
MonthlyTablesCount = 0;
for ( TabNum = 1; TabNum <= MonthlyInputCount; ++TabNum ) {
// the number of columns based on number of alpha fields
NumColumns = MonthlyInput( TabNum ).numFieldSet;
FirstColumn = MonthlyInput( TabNum ).firstFieldSet;
environmentKeyFound = false;
UniqueKeyCount = 0;
for ( colNum = 1; colNum <= NumColumns; ++colNum ) {
//#ifdef ITM_KEYCACHE
// Noel comment: First time in this TabNum/ColNum loop, let's save the results
// of GetVariableKeyCountandType & GetVariableKeys.
curVariMeter = MakeUPPERCase( MonthlyFieldSetInput( FirstColumn + colNum - 1 ).variMeter );
// call the key count function but only need count during this pass
GetVariableKeyCountandType( curVariMeter, KeyCount, TypeVar, AvgSumVar, StepTypeVar, UnitsVar );
// IF (KeyCount > maxKeyCount) THEN
// DEALLOCATE(NamesOfKeys)
// DEALLOCATE(IndexesForKeyVar)
// maxKeyCount=KeyCount
// ALLOCATE(NamesOfKeys(maxKeyCount))
// ALLOCATE(IndexesForKeyVar(maxKeyCount))
// ENDIF
MonthlyFieldSetInput( FirstColumn + colNum - 1 ).NamesOfKeys.allocate( KeyCount );
MonthlyFieldSetInput( FirstColumn + colNum - 1 ).IndexesForKeyVar.allocate( KeyCount );
// fill keys?
GetVariableKeys( curVariMeter, TypeVar, MonthlyFieldSetInput( FirstColumn + colNum - 1 ).NamesOfKeys, MonthlyFieldSetInput( FirstColumn + colNum - 1 ).IndexesForKeyVar );
// save these values to use later -- noel
MonthlyFieldSetInput( FirstColumn + colNum - 1 ).variMeterUpper = curVariMeter;
MonthlyFieldSetInput( FirstColumn + colNum - 1 ).typeOfVar = TypeVar;
MonthlyFieldSetInput( FirstColumn + colNum - 1 ).keyCount = KeyCount;
MonthlyFieldSetInput( FirstColumn + colNum - 1 ).varAvgSum = AvgSumVar;
MonthlyFieldSetInput( FirstColumn + colNum - 1 ).varStepType = StepTypeVar;
MonthlyFieldSetInput( FirstColumn + colNum - 1 ).varUnits = UnitsVar;
// DO iKey = 1, KeyCount
// MonthlyFieldSetInput(FirstColumn + ColNum - 1)%NamesOfKeys(iKey) = NamesOfKeys(iKey) !noel
// MonthlyFieldSetInput(FirstColumn + ColNum - 1)%IndexesForKeyVar(iKey) = IndexesForKeyVar(iKey) !noel
// ENDDO
//#else
// curVariMeter = MakeUPPERCase(MonthlyFieldSetInput(FirstColumn + ColNum - 1)%variMeter)
// ! call the key count function but only need count during this pass
// CALL GetVariableKeyCountandType(curVariMeter,KeyCount,TypeVar,AvgSumVar,StepTypeVar,UnitsVar)
// ALLOCATE(NamesOfKeys(KeyCount))
// ALLOCATE(IndexesForKeyVar(KeyCount))
// CALL GetVariableKeys(curVariMeter,TypeVar,NamesOfKeys,IndexesForKeyVar)
//#endif
for ( iKey = 1; iKey <= KeyCount; ++iKey ) {
found = 0;
// set a flag if environment variables are found
if ( SameString( MonthlyFieldSetInput( FirstColumn + colNum - 1 ).NamesOfKeys( iKey ), "ENVIRONMENT" ) ) {
environmentKeyFound = true;
found = -1; //so not counted in list of unique keys
}
for ( jUnique = 1; jUnique <= UniqueKeyCount; ++jUnique ) {
if ( SameString( UniqueKeyNames( jUnique ), MonthlyFieldSetInput( FirstColumn + colNum - 1 ).NamesOfKeys( iKey ) ) ) {
found = jUnique;
break;
}
}
if ( found == 0 ) {
++UniqueKeyCount;
if ( UniqueKeyCount > maxUniqueKeyCount ) {
UniqueKeyNames.redimension( maxUniqueKeyCount += 500 );
}
UniqueKeyNames( UniqueKeyCount ) = MonthlyFieldSetInput( FirstColumn + colNum - 1 ).NamesOfKeys( iKey );
}
}
//#ifdef ITM_KEYCACHE
// ! Don't deallocate here, only allocating/deallocating once for the whole routine
//#else
// DEALLOCATE(NamesOfKeys)
// DEALLOCATE(IndexesForKeyVar)
//#endif
} //colNum
// fix for CR8285 - when monthly report is only environmental variables
if ( environmentKeyFound && UniqueKeyCount == 0 ) {
UniqueKeyCount = 1;
}
// increment the number of tables based on the number of unique keys
MonthlyTablesCount += UniqueKeyCount;
MonthlyColumnsCount += UniqueKeyCount * NumColumns;
} //TabNum the end of the loop through the inputs objects
// Now that we have the maximum size of the number of tables (each table is
// repeated for the number of keys found) and the number of total columns
// of all of the tables, allocate the arrays to store this information.
MonthlyTables.allocate( MonthlyTablesCount );
MonthlyColumns.allocate( MonthlyColumnsCount );
// Initialize tables and results
MonthlyTables.keyValue() = "";
MonthlyTables.firstColumn() = 0;
MonthlyTables.numColumns() = 0;
MonthlyColumns.varName() = "";
MonthlyColumns.varNum() = 0;
MonthlyColumns.typeOfVar() = 0;
MonthlyColumns.avgSum() = 0;
MonthlyColumns.stepType() = 0;
MonthlyColumns.units() = "";
MonthlyColumns.aggType() = 0;
for ( colNum = 1; colNum <= MonthlyColumnsCount; ++colNum ) {
MonthlyColumns( colNum ).reslt = 0.0;
MonthlyColumns( colNum ).timeStamp = 0;
MonthlyColumns( colNum ).duration = 0.0;
}
ColumnsRecount = 0;
TablesRecount = 0;
for ( TabNum = 1; TabNum <= MonthlyInputCount; ++TabNum ) {
// the number of columns based on number of alpha fields
NumColumns = MonthlyInput( TabNum ).numFieldSet;
FirstColumn = MonthlyInput( TabNum ).firstFieldSet;
UniqueKeyCount = 0;
environmentKeyFound = false;
for ( colNum = 1; colNum <= NumColumns; ++colNum ) {
//#ifdef ITM_KEYCACHE
// Noel comment: Here is where we could use the saved values
curVariMeter = MonthlyFieldSetInput( FirstColumn + colNum - 1 ).variMeterUpper;
KeyCount = MonthlyFieldSetInput( FirstColumn + colNum - 1 ).keyCount;
TypeVar = MonthlyFieldSetInput( FirstColumn + colNum - 1 ).typeOfVar;
AvgSumVar = MonthlyFieldSetInput( FirstColumn + colNum - 1 ).varAvgSum;
StepTypeVar = MonthlyFieldSetInput( FirstColumn + colNum - 1 ).varStepType;
UnitsVar = MonthlyFieldSetInput( FirstColumn + colNum - 1 ).varUnits;
// DO iKey = 1, KeyCount !noel
// NamesOfKeys(iKey) = MonthlyFieldSetInput(FirstColumn + ColNum - 1)%NamesOfKeys(iKey) !noel
// IndexesForKeyVar(iKey) = MonthlyFieldSetInput(FirstColumn + ColNum - 1)%IndexesForKeyVar(iKey) !noel
// ENDDO
//#else
// curVariMeter = MakeUPPERCase(MonthlyFieldSetInput(FirstColumn + ColNum - 1)%variMeter)
// ! call the key count function but only need count during this pass
// CALL GetVariableKeyCountandType(curVariMeter,KeyCount,TypeVar,AvgSumVar,StepTypeVar,UnitsVar)
// ALLOCATE(NamesOfKeys(KeyCount))
// ALLOCATE(IndexesForKeyVar(KeyCount))
// CALL GetVariableKeys(curVariMeter,TypeVar,NamesOfKeys,IndexesForKeyVar)
//#endif
if ( KeyCount == 0 ) {
++ErrCount1;
if ( ErrCount1 == 1 && ! DisplayExtraWarnings && ! VarWarning && KindOfSim == ksRunPeriodWeather ) {
ShowWarningError( "Processing Monthly Tabular Reports: Variable names not valid for this simulation" );
ShowContinueError( "...use Output:Diagnostics,DisplayExtraWarnings; to show more details on individual variables." );
}
//fixing CR5878 removed the showing of the warning once about a specific variable.
if ( DisplayExtraWarnings && KindOfSim == ksRunPeriodWeather ) {
ShowWarningError( "Processing Monthly Tabular Reports: " + MonthlyInput( TabNum ).name );
ShowContinueError( "..Variable name=" + curVariMeter + " not valid for this simulation." );
if ( VarWarning ) {
ShowContinueError( "..Variables not valid for this simulation will have \"[Invalid/Undefined]\" in the Units Column of the Table Report." );
VarWarning = false;
}
}
}
for ( iKey = 1; iKey <= KeyCount; ++iKey ) {
found = 0;
// set a flag if environment variables are found
if ( SameString( MonthlyFieldSetInput( FirstColumn + colNum - 1 ).NamesOfKeys( iKey ), "ENVIRONMENT" ) ) {
environmentKeyFound = true;