GCC Code Coverage Report


Directory: src/solver/
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 99.4% 485 / 0 / 488
Functions: 100.0% 15 / 0 / 15
Branches: 82.2% 222 / 0 / 270

statsrpt.c
Line Branch Exec Source
1 //-----------------------------------------------------------------------------
2 // statsrpt.c
3 //
4 // Project: EPA SWMM5
5 // Version: 5.2
6 // Date: 11/19/22 (Build 5.2.2)
7 // Author: L. Rossman
8 //
9 // Report writing functions for summary statistics.
10 //
11 // Update History
12 // ==============
13 // Build 5.1.008:
14 // - New Groundwater Summary table added.
15 // - Reported Max. Depth added to Node Depth Summary table.
16 // Build 5.1.009:
17 // - Units on column heading in Node Inflow Summary table fixed.
18 // Build 5.1.011:
19 // - Redundant units conversion on max. reported node depth removed.
20 // - Node Surcharge table only produced for dynamic wave routing.
21 // Build 5.1.013:
22 // - Pervious and impervious runoff added to Subcatchment Runoff Summary.
23 // Build 5.1.015:
24 // - Fixes bug in summary statistics when Report Start date > Start Date.
25 // Build 5.2.0:
26 // - Adds a new Street & Inlet Summary table.
27 // - Fixes value used for total reporting time.
28 // Build 5.2.1:
29 // - Replaces the "3" in "ft3" and "m3" with ANSI superscript (\xB3).
30 // Build 5.2.2
31 // - Calculation of % Evaporation and % Exfiltration losses for storage
32 // units was corrected.
33 // Build 5.2.5
34 // - Changed flow format to scientific to prevent the merging of extremely
35 // large flows that make it difficult to interpret results.
36 //-----------------------------------------------------------------------------
37 #define _CRT_SECURE_NO_DEPRECATE
38
39 #include <stdlib.h>
40 #include <string.h>
41 #include <math.h>
42 #include <time.h>
43 #include "headers.h"
44 #include "lid.h"
45
46 //-----------------------------------------------------------------------------
47 // Imported variables
48 //-----------------------------------------------------------------------------
49 extern TSubcatchStats* SubcatchStats; // defined in STATS.C
50 extern TNodeStats* NodeStats;
51 extern TLinkStats* LinkStats;
52 extern TStorageStats* StorageStats;
53 extern TOutfallStats* OutfallStats;
54 extern TPumpStats* PumpStats;
55 extern double MaxOutfallFlow;
56 extern double MaxRunoffFlow;
57 extern double RoutingTimeSpan;
58
59 extern double* NodeInflow; // defined in MASSBAL.C
60 extern double* NodeOutflow;
61
62 //-----------------------------------------------------------------------------
63 // Local functions
64 //-----------------------------------------------------------------------------
65 void writeSubcatchRunoff(void);
66 void writeGroundwater(void);
67 void writeSubcatchLoads(void);
68 void writeNodeDepths(void);
69 void writeNodeFlows(void);
70 void writeNodeSurcharge(void);
71 void writeNodeFlooding(void);
72 void writeStorageVolumes(void);
73 void writeOutfallLoads(void);
74 void writeLinkFlows(void);
75 void writeFlowClass(void);
76 void writeLinkSurcharge(void);
77 void writePumpFlows(void);
78 void writeLinkLoads(void);
79
80 #define WRITE(x) (report_writeLine((x)))
81
82 static char FlowFmt[6];
83 static double Vcf;
84
85 //=============================================================================
86
87 61 void statsrpt_writeReport()
88 //
89 // Input: none
90 // Output: none
91 // Purpose: reports simulation summary statistics.
92 //
93 {
94 // --- set number of decimal places for reporting flow values
95
2/4
✓ Branch 0 taken 61 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 61 times.
61 if ( FlowUnits == MGD || FlowUnits == CMS ) sstrncpy(FlowFmt, "%9.3f", 5);
96 61 else sstrncpy(FlowFmt, "%9.2f", 5);
97
98 // --- conversion factor from cu. ft. to mil. gallons or megaliters
99
2/2
✓ Branch 0 taken 58 times.
✓ Branch 1 taken 3 times.
61 if (UnitSystem == US) Vcf = 7.48 / 1.0e6;
100 3 else Vcf = 28.317 / 1.0e6;
101
102 // --- report summary results for subcatchment runoff
103
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 26 times.
61 if ( Nobjects[SUBCATCH] > 0 )
104 {
105
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
35 if ( !IgnoreRainfall ||
106 (Nobjects[SNOWMELT] > 0 && !IgnoreSnowmelt) ||
107 (Nobjects[AQUIFER] > 0 && !IgnoreGwater) )
108 {
109 35 writeSubcatchRunoff();
110 35 lid_writeWaterBalance();
111
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 32 times.
35 if ( !IgnoreGwater ) writeGroundwater();
112
4/4
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 27 times.
✓ Branch 2 taken 7 times.
✓ Branch 3 taken 1 time.
35 if ( Nobjects[POLLUT] > 0 && !IgnoreQuality) writeSubcatchLoads();
113 }
114 }
115
116 // --- report summary results for flow routing
117
3/4
✓ Branch 0 taken 51 times.
✓ Branch 1 taken 10 times.
✓ Branch 2 taken 51 times.
✗ Branch 3 not taken.
61 if ( Nobjects[LINK] > 0 && !IgnoreRouting )
118 {
119 51 writeNodeDepths();
120 51 writeNodeFlows();
121
2/2
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 13 times.
51 if ( RouteModel == DW ) writeNodeSurcharge();
122 51 writeNodeFlooding();
123 51 writeStorageVolumes();
124 51 writeOutfallLoads();
125 51 inlet_writeStatsReport();
126 51 writeLinkFlows();
127 51 writeFlowClass();
128 51 writeLinkSurcharge();
129 51 writePumpFlows();
130
4/4
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 43 times.
✓ Branch 2 taken 7 times.
✓ Branch 3 taken 1 time.
51 if ( Nobjects[POLLUT] > 0 && !IgnoreQuality) writeLinkLoads();
131 }
132 61 }
133
134 //=============================================================================
135
136 35 void writeSubcatchRunoff()
137 {
138 int j;
139 double a, x, r;
140
141
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
35 if ( Nobjects[SUBCATCH] == 0 ) return;
142 35 WRITE("");
143 35 WRITE("***************************");
144 35 WRITE("Subcatchment Runoff Summary");
145 35 WRITE("***************************");
146 35 WRITE("");
147 35 fprintf(Frpt.file,
148
149 "\n ------------------------------------------------------------------------------------------------------------------------------"
150 "\n Total Total Total Total Imperv Perv Total Total Peak Runoff"
151 "\n Precip Runon Evap Infil Runoff Runoff Runoff Runoff Runoff Coeff");
152
2/2
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 2 times.
35 if ( UnitSystem == US ) fprintf(Frpt.file,
153 "\n Subcatchment in in in in in in in %8s %3s",
154 VolUnitsWords[UnitSystem], FlowUnitWords[FlowUnits]);
155 2 else fprintf(Frpt.file,
156 "\n Subcatchment mm mm mm mm mm mm mm %8s %3s",
157 VolUnitsWords[UnitSystem], FlowUnitWords[FlowUnits]);
158 35 fprintf(Frpt.file,
159 "\n ------------------------------------------------------------------------------------------------------------------------------");
160
161
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 35 times.
131 for ( j = 0; j < Nobjects[SUBCATCH]; j++ )
162 {
163 96 a = Subcatch[j].area;
164
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if ( a == 0.0 ) continue;
165 96 fprintf(Frpt.file, "\n %-20s", Subcatch[j].ID);
166 96 x = SubcatchStats[j].precip * UCF(RAINDEPTH);
167 96 fprintf(Frpt.file, " %10.2f", x/a);
168 96 x = SubcatchStats[j].runon * UCF(RAINDEPTH);
169 96 fprintf(Frpt.file, " %10.2f", x/a);
170 96 x = SubcatchStats[j].evap * UCF(RAINDEPTH);
171 96 fprintf(Frpt.file, " %10.2f", x/a);
172 96 x = SubcatchStats[j].infil * UCF(RAINDEPTH);
173 96 fprintf(Frpt.file, " %10.2f", x/a);
174 96 x = SubcatchStats[j].impervRunoff * UCF(RAINDEPTH);
175 96 fprintf(Frpt.file, " %10.2f", x/a);
176 96 x = SubcatchStats[j].pervRunoff * UCF(RAINDEPTH);
177 96 fprintf(Frpt.file, " %10.2f", x/a);
178 96 x = SubcatchStats[j].runoff * UCF(RAINDEPTH);
179 96 fprintf(Frpt.file, " %10.2f", x/a);
180 96 x = SubcatchStats[j].runoff * Vcf;
181 96 fprintf(Frpt.file, "%12.2f", x);
182 96 x = SubcatchStats[j].maxFlow * UCF(FLOW);
183 96 fprintf(Frpt.file, " %8.2f", x);
184 96 r = SubcatchStats[j].precip + SubcatchStats[j].runon;
185
2/2
✓ Branch 0 taken 95 times.
✓ Branch 1 taken 1 time.
96 if ( r > 0.0 ) r = SubcatchStats[j].runoff / r;
186 96 fprintf(Frpt.file, "%8.3f", r);
187 }
188 35 WRITE("");
189 }
190
191 //=============================================================================
192
193 3 void writeGroundwater(void)
194 {
195 int i, j;
196 3 int count = 0;
197 3 double totalSeconds = NewRunoffTime / 1000.;
198 double x[9];
199
200
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if ( Nobjects[SUBCATCH] == 0 ) return;
201
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 3 times.
13 for ( j = 0; j < Nobjects[SUBCATCH]; j++ )
202 {
203
1/2
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
10 if ( Subcatch[j].groundwater != NULL ) count++;
204 }
205
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if ( count == 0 ) return;
206
207 3 WRITE("");
208 3 WRITE("*******************");
209 3 WRITE("Groundwater Summary");
210 3 WRITE("*******************");
211 3 WRITE("");
212 3 fprintf(Frpt.file,
213
214 "\n -----------------------------------------------------------------------------------------------------"
215 "\n Total Total Maximum Average Average Final Final"
216 "\n Total Total Lower Lateral Lateral Upper Water Upper Water"
217 "\n Infil Evap Seepage Outflow Outflow Moist. Table Moist. Table");
218
2/2
✓ Branch 0 taken 1 time.
✓ Branch 1 taken 2 times.
3 if ( UnitSystem == US ) fprintf(Frpt.file,
219 "\n Subcatchment in in in in %3s ft ft",
220 FlowUnitWords[FlowUnits]);
221 2 else fprintf(Frpt.file,
222 "\n Subcatchment mm mm mm mm %3s m m",
223 FlowUnitWords[FlowUnits]);
224 3 fprintf(Frpt.file,
225 "\n -----------------------------------------------------------------------------------------------------");
226
227
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 3 times.
13 for ( j = 0; j < Nobjects[SUBCATCH]; j++ )
228 {
229
2/4
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 10 times.
10 if ( Subcatch[j].area == 0.0 || Subcatch[j].groundwater == NULL ) continue;
230 10 fprintf(Frpt.file, "\n %-20s", Subcatch[j].ID);
231 10 x[0] = Subcatch[j].groundwater->stats.infil * UCF(RAINDEPTH);
232 10 x[1] = Subcatch[j].groundwater->stats.evap * UCF(RAINDEPTH);
233 10 x[2] = Subcatch[j].groundwater->stats.deepFlow * UCF(RAINDEPTH);
234 10 x[3] = Subcatch[j].groundwater->stats.latFlow * UCF(RAINDEPTH);
235 10 x[4] = Subcatch[j].groundwater->stats.maxFlow * UCF(FLOW) * Subcatch[j].area;
236 10 x[5] = Subcatch[j].groundwater->stats.avgUpperMoist / totalSeconds;
237 10 x[6] = Subcatch[j].groundwater->stats.avgWaterTable * UCF(LENGTH) /
238 totalSeconds;
239 10 x[7] = Subcatch[j].groundwater->stats.finalUpperMoist;
240 10 x[8] = Subcatch[j].groundwater->stats.finalWaterTable * UCF(LENGTH);
241
2/2
✓ Branch 1 taken 90 times.
✓ Branch 2 taken 10 times.
100 for (i = 0; i < 9; i++) fprintf(Frpt.file, " %8.2f", x[i]);
242 }
243 3 WRITE("");
244 }
245
246 //=============================================================================
247
248 7 void writeSubcatchLoads()
249 {
250 int i, j, p;
251 double x;
252 double* totals;
253 char units[15];
254 7 char subcatchLine[] = "--------------------";
255 7 char pollutLine[] = "--------------";
256
257 // --- create an array to hold total loads for each pollutant
258 7 totals = (double *) calloc(Nobjects[POLLUT], sizeof(double));
259
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if ( totals )
260 {
261 // --- print the table headings
262 7 WRITE("");
263 7 WRITE("****************************");
264 7 WRITE("Subcatchment Washoff Summary");
265 7 WRITE("****************************");
266 7 WRITE("");
267 7 fprintf(Frpt.file, "\n %s", subcatchLine);
268
2/2
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 7 times.
25 for (p = 0; p < Nobjects[POLLUT]; p++) fprintf(Frpt.file, "%s", pollutLine);
269 7 fprintf(Frpt.file, "\n ");
270
2/2
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 7 times.
25 for (p = 0; p < Nobjects[POLLUT]; p++) fprintf(Frpt.file, "%14s", Pollut[p].ID);
271 7 fprintf(Frpt.file, "\n Subcatchment ");
272
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 7 times.
25 for (p = 0; p < Nobjects[POLLUT]; p++)
273 {
274 18 i = UnitSystem;
275
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
18 if ( Pollut[p].units == COUNT ) i = 2;
276 18 sstrncpy(units, LoadUnitsWords[i], 14);
277 18 fprintf(Frpt.file, "%14s", units);
278 18 totals[p] = 0.0;
279 }
280 7 fprintf(Frpt.file, "\n %s", subcatchLine);
281
2/2
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 7 times.
25 for (p = 0; p < Nobjects[POLLUT]; p++) fprintf(Frpt.file, "%s", pollutLine);
282
283 // --- print the pollutant loadings from each subcatchment
284
2/2
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 7 times.
38 for ( j = 0; j < Nobjects[SUBCATCH]; j++ )
285 {
286 31 fprintf(Frpt.file, "\n %-20s", Subcatch[j].ID);
287
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 31 times.
113 for (p = 0; p < Nobjects[POLLUT]; p++)
288 {
289 82 x = Subcatch[j].totalLoad[p];
290 82 totals[p] += x;
291
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 82 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
82 if ( Pollut[p].units == COUNT ) x = LOG10(x);
292 82 fprintf(Frpt.file, "%14.3f", x);
293 }
294 }
295
296 // --- print the total loading of each pollutant
297 7 fprintf(Frpt.file, "\n %s", subcatchLine);
298
2/2
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 7 times.
25 for (p = 0; p < Nobjects[POLLUT]; p++) fprintf(Frpt.file, "%s", pollutLine);
299 7 fprintf(Frpt.file, "\n System ");
300
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 7 times.
25 for (p = 0; p < Nobjects[POLLUT]; p++)
301 {
302 18 x = totals[p];
303
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
18 if ( Pollut[p].units == COUNT ) x = LOG10(x);
304 18 fprintf(Frpt.file, "%14.3f", x);
305 }
306 7 free(totals);
307 7 WRITE("");
308 }
309 7 }
310
311 //=============================================================================
312
313 51 void writeNodeDepths()
314 //
315 // Input: none
316 // Output: none
317 // Purpose: writes simulation statistics for nodes to report file.
318 //
319 {
320 int j, days, hrs, mins;
321
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 51 times.
51 if ( Nobjects[LINK] == 0 ) return;
322
323 51 WRITE("");
324 51 WRITE("******************");
325 51 WRITE("Node Depth Summary");
326 51 WRITE("******************");
327 51 WRITE("");
328
329 51 fprintf(Frpt.file,
330 "\n ---------------------------------------------------------------------------------"
331 "\n Average Maximum Maximum Time of Max Reported"
332 "\n Depth Depth HGL Occurrence Max Depth");
333
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 3 times.
51 if ( UnitSystem == US ) fprintf(Frpt.file,
334 "\n Node Type Feet Feet Feet days hr:min Feet");
335 3 else fprintf(Frpt.file,
336 "\n Node Type Meters Meters Meters days hr:min Meters");
337 51 fprintf(Frpt.file,
338 "\n ---------------------------------------------------------------------------------");
339
340
2/2
✓ Branch 0 taken 413 times.
✓ Branch 1 taken 51 times.
464 for ( j = 0; j < Nobjects[NODE]; j++ )
341 {
342 413 fprintf(Frpt.file, "\n %-20s", Node[j].ID);
343 413 fprintf(Frpt.file, " %-9s ", NodeTypeWords[Node[j].type]);
344 413 getElapsedTime(NodeStats[j].maxDepthDate, &days, &hrs, &mins);
345 413 fprintf(Frpt.file, "%7.2f %7.2f %7.2f %4d %02d:%02d %10.2f",
346 413 NodeStats[j].avgDepth / ReportStepCount * UCF(LENGTH),
347 413 NodeStats[j].maxDepth * UCF(LENGTH),
348 413 (NodeStats[j].maxDepth + Node[j].invertElev) * UCF(LENGTH),
349 413 days, hrs, mins, NodeStats[j].maxRptDepth);
350 }
351 51 WRITE("");
352 }
353
354 //=============================================================================
355
356 51 void writeNodeFlows()
357 //
358 // Input: none
359 // Output: none
360 // Purpose: writes flow statistics for nodes to report file.
361 //
362 {
363 int j;
364 int days1, hrs1, mins1;
365
366 51 WRITE("");
367 51 WRITE("*******************");
368 51 WRITE("Node Inflow Summary");
369 51 WRITE("*******************");
370 51 WRITE("");
371
372 51 fprintf(Frpt.file,
373 "\n -------------------------------------------------------------------------------------------------"
374 "\n Maximum Maximum Lateral Total Flow"
375 "\n Lateral Total Time of Max Inflow Inflow Balance"
376 "\n Inflow Inflow Occurrence Volume Volume Error"
377 "\n Node Type %3s %3s days hr:min %8s %8s Percent",
378 FlowUnitWords[FlowUnits], FlowUnitWords[FlowUnits], VolUnitsWords[UnitSystem],
379 VolUnitsWords[UnitSystem]);
380 51 fprintf(Frpt.file,
381 "\n -------------------------------------------------------------------------------------------------");
382
383
2/2
✓ Branch 0 taken 413 times.
✓ Branch 1 taken 51 times.
464 for ( j = 0; j < Nobjects[NODE]; j++ )
384 {
385 413 fprintf(Frpt.file, "\n %-20s", Node[j].ID);
386 413 fprintf(Frpt.file, " %-9s", NodeTypeWords[Node[j].type]);
387 413 getElapsedTime(NodeStats[j].maxInflowDate, &days1, &hrs1, &mins1);
388 413 fprintf(Frpt.file, FlowFmt, NodeStats[j].maxLatFlow * UCF(FLOW));
389 413 fprintf(Frpt.file, FlowFmt, NodeStats[j].maxInflow * UCF(FLOW));
390 413 fprintf(Frpt.file, " %4d %02d:%02d", days1, hrs1, mins1);
391 413 fprintf(Frpt.file, "%12.3g", NodeStats[j].totLatFlow * Vcf);
392 413 fprintf(Frpt.file, "%12.3g", NodeInflow[j] * Vcf);
393
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 409 times.
413 if ( fabs(NodeOutflow[j]) < 1.0 )
394 4 fprintf(Frpt.file, "%12.3f %s",
395 4 (NodeInflow[j]-NodeOutflow[j])*Vcf*1.0e6,
396 VolUnitsWords2[UnitSystem]);
397 else
398 409 fprintf(Frpt.file, "%12.3f", (NodeInflow[j]-NodeOutflow[j]) /
399 409 NodeOutflow[j]*100.);
400 }
401 51 WRITE("");
402 51 }
403
404 //=============================================================================
405
406 38 void writeNodeSurcharge()
407 {
408 38 int j, n = 0;
409 double t, d1, d2;
410
411 38 WRITE("");
412 38 WRITE("**********************");
413 38 WRITE("Node Surcharge Summary");
414 38 WRITE("**********************");
415 38 WRITE("");
416
417
2/2
✓ Branch 0 taken 328 times.
✓ Branch 1 taken 38 times.
366 for ( j = 0; j < Nobjects[NODE]; j++ )
418 {
419
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 256 times.
328 if ( Node[j].type == OUTFALL ) continue;
420
2/2
✓ Branch 0 taken 196 times.
✓ Branch 1 taken 60 times.
256 if ( NodeStats[j].timeSurcharged == 0.0 ) continue;
421
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 60 times.
60 t = MAX(0.01, (NodeStats[j].timeSurcharged / 3600.0));
422
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 44 times.
60 if ( n == 0 )
423 {
424 16 WRITE("Surcharging occurs when water rises above the top of the highest conduit.");
425 16 fprintf(Frpt.file,
426 "\n ---------------------------------------------------------------------"
427 "\n Max. Height Min. Depth"
428 "\n Hours Above Crown Below Rim");
429
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 3 times.
16 if ( UnitSystem == US ) fprintf(Frpt.file,
430 "\n Node Type Surcharged Feet Feet");
431 3 else fprintf(Frpt.file,
432 "\n Node Type Surcharged Meters Meters");
433 16 fprintf(Frpt.file,
434 "\n ---------------------------------------------------------------------");
435 16 n = 1;
436 }
437 60 fprintf(Frpt.file, "\n %-20s", Node[j].ID);
438 60 fprintf(Frpt.file, " %-9s", NodeTypeWords[Node[j].type]);
439 60 d1 = NodeStats[j].maxDepth + Node[j].invertElev - Node[j].crownElev;
440
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 60 times.
60 if ( d1 < 0.0 ) d1 = 0.0;
441 60 d2 = Node[j].fullDepth - NodeStats[j].maxDepth;
442
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 56 times.
60 if ( d2 < 0.0 ) d2 = 0.0;
443 60 fprintf(Frpt.file, " %9.2f %9.3f %9.3f",
444 60 t, d1*UCF(LENGTH), d2*UCF(LENGTH));
445 }
446
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 16 times.
38 if ( n == 0 ) WRITE("No nodes were surcharged.");
447 38 WRITE("");
448 38 }
449
450 //=============================================================================
451
452 51 void writeNodeFlooding()
453 {
454 51 int j, n = 0;
455 int days, hrs, mins;
456 double t;
457
458 51 WRITE("");
459 51 WRITE("*********************");
460 51 WRITE("Node Flooding Summary");
461 51 WRITE("*********************");
462 51 WRITE("");
463
464
2/2
✓ Branch 0 taken 413 times.
✓ Branch 1 taken 51 times.
464 for ( j = 0; j < Nobjects[NODE]; j++ )
465 {
466
2/2
✓ Branch 0 taken 102 times.
✓ Branch 1 taken 311 times.
413 if ( Node[j].type == OUTFALL ) continue;
467
2/2
✓ Branch 0 taken 277 times.
✓ Branch 1 taken 34 times.
311 if ( NodeStats[j].timeFlooded == 0.0 ) continue;
468
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 34 times.
34 t = MAX(0.01, (NodeStats[j].timeFlooded / 3600.0));
469
470
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 21 times.
34 if ( n == 0 )
471 {
472 13 WRITE("Flooding refers to all water that overflows a node, whether it ponds or not.");
473 13 fprintf(Frpt.file,
474 "\n --------------------------------------------------------------------------"
475 "\n Total Maximum"
476 "\n Maximum Time of Max Flood Ponded"
477 "\n Hours Rate Occurrence Volume");
478
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 1 time.
13 if ( RouteModel == DW ) fprintf(Frpt.file, " Depth");
479 1 else fprintf(Frpt.file, " Volume");
480 13 fprintf(Frpt.file,
481 "\n Node Flooded %3s days hr:min %8s",
482 FlowUnitWords[FlowUnits], VolUnitsWords[UnitSystem]);
483
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 1 time.
13 if ( RouteModel == DW ) fprintf(Frpt.file, " %6s",
484 PondingUnitsWords[UnitSystem]);
485
1/2
✓ Branch 0 taken 1 time.
✗ Branch 1 not taken.
1 else if ( UnitSystem == US ) fprintf(Frpt.file, " 1000 ft\xB3");
486 else fprintf(Frpt.file, " 1000 m\xB3");
487 13 fprintf(Frpt.file,
488 "\n --------------------------------------------------------------------------");
489 13 n = 1;
490 }
491 34 fprintf(Frpt.file, "\n %-20s", Node[j].ID);
492 34 fprintf(Frpt.file, " %7.2f ", t);
493 34 fprintf(Frpt.file, FlowFmt, NodeStats[j].maxOverflow * UCF(FLOW));
494 34 getElapsedTime(NodeStats[j].maxOverflowDate, &days, &hrs, &mins);
495 34 fprintf(Frpt.file, " %4d %02d:%02d", days, hrs, mins);
496 34 fprintf(Frpt.file, "%12.3f", NodeStats[j].volFlooded * Vcf);
497
2/2
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 1 time.
34 if ( RouteModel == DW )
498 33 fprintf(Frpt.file, " %9.3f",
499 33 (NodeStats[j].maxDepth - Node[j].fullDepth) * UCF(LENGTH));
500 else
501 1 fprintf(Frpt.file, " %9.3f", NodeStats[j].maxPondedVol /
502 1 1000.0 * UCF(VOLUME));
503 }
504
505
2/2
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 13 times.
51 if ( n == 0 ) WRITE("No nodes were flooded.");
506 51 WRITE("");
507 51 }
508
509 //=============================================================================
510
511 51 void writeStorageVolumes()
512 //
513 // Input: none
514 // Output: none
515 // Purpose: writes simulation statistics for storage units to report file.
516 //
517 {
518 int j, k, days, hrs, mins;
519 double avgVol, maxVol, pctAvgVol, pctMaxVol;
520 double pctEvapLoss, pctSeepLoss;
521
522
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 34 times.
51 if ( Nnodes[STORAGE] > 0 )
523 {
524 17 WRITE("");
525 17 WRITE("**********************");
526 17 WRITE("Storage Volume Summary");
527 17 WRITE("**********************");
528 17 WRITE("");
529
530 17 fprintf(Frpt.file,
531 "\n ------------------------------------------------------------------------------------------------"
532 "\n Average Avg Evap Exfil Maximum Max Time of Max Maximum"
533 "\n Volume Pcnt Pcnt Pcnt Volume Pcnt Occurrence Outflow");
534
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 3 times.
17 if ( UnitSystem == US ) fprintf(Frpt.file,
535 "\n Storage Unit 1000 ft\xB3 Full Loss Loss 1000 ft\xB3 Full days hr:min ");
536 3 else fprintf(Frpt.file,
537 "\n Storage Unit 1000 m\xB3 Full Loss Loss 1000 m\xB3 Full days hr:min ");
538 17 fprintf(Frpt.file, "%3s", FlowUnitWords[FlowUnits]);
539 17 fprintf(Frpt.file,
540 "\n ------------------------------------------------------------------------------------------------");
541
542
2/2
✓ Branch 0 taken 225 times.
✓ Branch 1 taken 17 times.
242 for ( j = 0; j < Nobjects[NODE]; j++ )
543 {
544
2/2
✓ Branch 0 taken 185 times.
✓ Branch 1 taken 40 times.
225 if ( Node[j].type != STORAGE ) continue;
545 40 k = Node[j].subIndex;
546 40 fprintf(Frpt.file, "\n %-20s", Node[j].ID);
547 40 avgVol = StorageStats[k].avgVol / (double)ReportStepCount;
548 40 maxVol = StorageStats[k].maxVol;
549 40 pctMaxVol = 0.0;
550 40 pctAvgVol = 0.0;
551
2/2
✓ Branch 0 taken 39 times.
✓ Branch 1 taken 1 time.
40 if ( Node[j].fullVolume > 0.0 )
552 {
553 39 pctAvgVol = avgVol / Node[j].fullVolume * 100.0;
554 39 pctMaxVol = maxVol / Node[j].fullVolume * 100.0;
555 }
556 40 pctEvapLoss = 0.0;
557 40 pctSeepLoss = 0.0;
558
1/2
✓ Branch 0 taken 40 times.
✗ Branch 1 not taken.
40 if ( NodeInflow[j] > 0.0 )
559 {
560 40 pctEvapLoss = StorageStats[k].evapLosses / NodeInflow[j] * 100.0;
561 40 pctSeepLoss = StorageStats[k].exfilLosses / NodeInflow[j] * 100.0;
562 }
563
564 80 fprintf(Frpt.file, "%10.3f %5.1f %5.1f %5.1f %10.3f %5.1f",
565 40 avgVol*UCF(VOLUME)/1000.0, pctAvgVol, pctEvapLoss, pctSeepLoss,
566 40 maxVol*UCF(VOLUME)/1000.0, pctMaxVol);
567
568 40 getElapsedTime(StorageStats[k].maxVolDate, &days, &hrs, &mins);
569 40 fprintf(Frpt.file, " %4d %02d:%02d ", days, hrs, mins);
570 40 fprintf(Frpt.file, FlowFmt, StorageStats[k].maxFlow*UCF(FLOW));
571 }
572 17 WRITE("");
573 }
574 51 }
575
576 //=============================================================================
577
578 51 void writeOutfallLoads()
579 //
580 // Input: node
581 // Output: none
582 // Purpose: writes simulation statistics for outfall nodess to report file.
583 //
584 {
585 char units[15];
586 int i, j, k, p;
587 double x;
588 double outfallCount, flowCount;
589 double flowSum, freqSum, volSum;
590 double* totals;
591
592
1/2
✓ Branch 0 taken 51 times.
✗ Branch 1 not taken.
51 if ( Nnodes[OUTFALL] > 0 )
593 {
594 // --- initial totals
595 51 totals = (double *) calloc(Nobjects[POLLUT], sizeof(double));
596
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 51 times.
75 for (p=0; p<Nobjects[POLLUT]; p++) totals[p] = 0.0;
597 51 flowSum = 0.0;
598 51 freqSum = 0.0;
599 51 volSum = 0.0;
600
601 // --- print table title
602 51 WRITE("");
603 51 WRITE("***********************");
604 51 WRITE("Outfall Loading Summary");
605 51 WRITE("***********************");
606 51 WRITE("");
607
608 // --- print table column headers
609 51 fprintf(Frpt.file,
610 "\n -----------------------------------------------------------");
611
2/2
✓ Branch 1 taken 24 times.
✓ Branch 2 taken 51 times.
75 for (p = 0; p < Nobjects[POLLUT]; p++) fprintf(Frpt.file, "--------------");
612 51 fprintf(Frpt.file,
613 "\n Flow Avg Max Total");
614
2/2
✓ Branch 1 taken 24 times.
✓ Branch 2 taken 51 times.
75 for (p=0; p<Nobjects[POLLUT]; p++) fprintf(Frpt.file," Total");
615 51 fprintf(Frpt.file,
616 "\n Freq Flow Flow Volume");
617
2/2
✓ Branch 1 taken 24 times.
✓ Branch 2 taken 51 times.
75 for (p = 0; p < Nobjects[POLLUT]; p++) fprintf(Frpt.file, "%14s", Pollut[p].ID);
618 51 fprintf(Frpt.file,
619 "\n Outfall Node Pcnt %3s %3s %8s",
620 FlowUnitWords[FlowUnits], FlowUnitWords[FlowUnits],
621 VolUnitsWords[UnitSystem]);
622
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 51 times.
75 for (p = 0; p < Nobjects[POLLUT]; p++)
623 {
624 24 i = UnitSystem;
625
2/2
✓ Branch 0 taken 1 time.
✓ Branch 1 taken 23 times.
24 if ( Pollut[p].units == COUNT ) i = 2;
626 24 sstrncpy(units, LoadUnitsWords[i], 14);
627 24 fprintf(Frpt.file, "%14s", units);
628 }
629 51 fprintf(Frpt.file,
630 "\n -----------------------------------------------------------");
631
2/2
✓ Branch 1 taken 24 times.
✓ Branch 2 taken 51 times.
75 for (p = 0; p < Nobjects[POLLUT]; p++) fprintf(Frpt.file, "--------------");
632
633 // --- identify each outfall node
634
2/2
✓ Branch 0 taken 413 times.
✓ Branch 1 taken 51 times.
464 for (j=0; j<Nobjects[NODE]; j++)
635 {
636
2/2
✓ Branch 0 taken 311 times.
✓ Branch 1 taken 102 times.
413 if ( Node[j].type != OUTFALL ) continue;
637 102 k = Node[j].subIndex;
638 102 flowCount = OutfallStats[k].totalPeriods;
639
640 // --- print node ID, flow freq., avg. flow, max. flow & flow vol.
641 102 fprintf(Frpt.file, "\n %-20s", Node[j].ID);
642 102 x = 100.*flowCount/(double)ReportStepCount;
643 102 fprintf(Frpt.file, "%7.2f", x);
644 102 freqSum += x;
645
2/2
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 3 times.
102 if ( flowCount > 0 )
646 99 x = OutfallStats[k].avgFlow*UCF(FLOW)/flowCount;
647 else
648 3 x = 0.0;
649 102 flowSum += x;
650
651 102 fprintf(Frpt.file, " ");
652 102 fprintf(Frpt.file, FlowFmt, x);
653 102 fprintf(Frpt.file, " ");
654 102 fprintf(Frpt.file, FlowFmt, OutfallStats[k].maxFlow*UCF(FLOW));
655 102 fprintf(Frpt.file, "%12.3f", NodeInflow[j] * Vcf);
656 102 volSum += NodeInflow[j];
657
658 // --- print load of each pollutant for outfall
659
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 102 times.
126 for (p=0; p<Nobjects[POLLUT]; p++)
660 {
661 24 x = OutfallStats[k].totalLoad[p] * LperFT3 * Pollut[p].mcf;
662 24 totals[p] += x;
663
3/4
✓ Branch 0 taken 1 time.
✓ Branch 1 taken 23 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 time.
24 if ( Pollut[p].units == COUNT ) x = LOG10(x);
664 24 fprintf(Frpt.file, "%14.3f", x);
665 }
666 }
667
668 // --- print total outfall loads
669 51 outfallCount = Nnodes[OUTFALL];
670 51 fprintf(Frpt.file,
671 "\n -----------------------------------------------------------");
672
2/2
✓ Branch 1 taken 24 times.
✓ Branch 2 taken 51 times.
75 for (p = 0; p < Nobjects[POLLUT]; p++) fprintf(Frpt.file, "--------------");
673
674 51 fprintf(Frpt.file, "\n System %7.2f ",
675 freqSum/outfallCount);
676 51 fprintf(Frpt.file, FlowFmt, flowSum);
677 51 fprintf(Frpt.file, " ");
678 51 fprintf(Frpt.file, FlowFmt, MaxOutfallFlow*UCF(FLOW));
679 51 fprintf(Frpt.file, "%12.3f", volSum * Vcf);
680
681
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 51 times.
75 for (p = 0; p < Nobjects[POLLUT]; p++)
682 {
683 24 x = totals[p];
684
3/4
✓ Branch 0 taken 1 time.
✓ Branch 1 taken 23 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 time.
24 if ( Pollut[p].units == COUNT ) x = LOG10(x);
685 24 fprintf(Frpt.file, "%14.3f", x);
686 }
687 51 WRITE("");
688 51 free(totals);
689 }
690 51 }
691
692 //=============================================================================
693
694 51 void writeLinkFlows()
695 //
696 // Input: none
697 // Output: none
698 // Purpose: writes simulation statistics for links to report file.
699 //
700 {
701 int j, k, days, hrs, mins;
702 double v, fullDepth;
703
704
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 51 times.
51 if (Nobjects[LINK] == 0) return;
705 51 WRITE("");
706 51 WRITE("********************");
707 51 WRITE("Link Flow Summary");
708 51 WRITE("********************");
709 51 WRITE("");
710
711 51 fprintf(Frpt.file,
712 "\n -----------------------------------------------------------------------------"
713 "\n Maximum Time of Max Maximum Max/ Max/"
714 "\n |Flow| Occurrence |Veloc| Full Full");
715
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 3 times.
51 if (UnitSystem == US) fprintf(Frpt.file,
716 "\n Link Type %3s days hr:min ft/sec Flow Depth",
717 FlowUnitWords[FlowUnits]);
718 3 else fprintf(Frpt.file,
719 "\n Link Type %3s days hr:min m/sec Flow Depth",
720 FlowUnitWords[FlowUnits]);
721 51 fprintf(Frpt.file,
722 "\n -----------------------------------------------------------------------------");
723
724
2/2
✓ Branch 0 taken 332 times.
✓ Branch 1 taken 51 times.
383 for (j = 0; j < Nobjects[LINK]; j++)
725 {
726 // --- print link ID
727 332 k = Link[j].subIndex;
728 332 fprintf(Frpt.file, "\n %-20s", Link[j].ID);
729
730 // --- print link type
731
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 326 times.
332 if (Link[j].xsect.type == DUMMY) fprintf(Frpt.file, " DUMMY ");
732
2/2
✓ Branch 0 taken 1 time.
✓ Branch 1 taken 325 times.
326 else if (Link[j].xsect.type == IRREGULAR) fprintf(Frpt.file, " CHANNEL ");
733 325 else fprintf(Frpt.file, " %-7s ", LinkTypeWords[Link[j].type]);
734
735 // --- print max. flow & time of occurrence
736 332 getElapsedTime(LinkStats[j].maxFlowDate, &days, &hrs, &mins);
737 332 fprintf(Frpt.file, FlowFmt, LinkStats[j].maxFlow*UCF(FLOW));
738 332 fprintf(Frpt.file, " %4d %02d:%02d", days, hrs, mins);
739
740 // --- print max flow / flow capacity for pumps
741
3/4
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 323 times.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
332 if (Link[j].type == PUMP && Link[j].qFull > 0.0)
742 {
743 9 fprintf(Frpt.file, " ");
744 9 fprintf(Frpt.file, " %6.2f",
745 9 LinkStats[j].maxFlow / Link[j].qFull);
746 9 continue;
747 }
748
749 // --- stop printing for dummy conduits
750
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 317 times.
323 if (Link[j].xsect.type == DUMMY) continue;
751
752 // --- stop printing for outlet links (since they don't have xsections)
753
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 317 times.
317 if (Link[j].type == OUTLET) continue;
754
755 // --- print max velocity & max/full flow for conduits
756
2/2
✓ Branch 0 taken 299 times.
✓ Branch 1 taken 18 times.
317 if (Link[j].type == CONDUIT)
757 {
758 299 v = LinkStats[j].maxVeloc*UCF(LENGTH);
759
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 299 times.
299 if (v > 50.0) fprintf(Frpt.file, " >50.00");
760 299 else fprintf(Frpt.file, " %7.2f", v);
761 299 fprintf(Frpt.file, " %6.2f", LinkStats[j].maxFlow / Link[j].qFull /
762 299 (double)Conduit[k].barrels);
763 }
764 18 else fprintf(Frpt.file, " ");
765
766 // --- print max/full depth
767 317 fullDepth = Link[j].xsect.yFull;
768
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 307 times.
317 if (Link[j].type == ORIFICE &&
769
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 8 times.
10 Orifice[k].type == BOTTOM_ORIFICE) fullDepth = 0.0;
770
2/2
✓ Branch 0 taken 315 times.
✓ Branch 1 taken 2 times.
317 if (fullDepth > 0.0)
771 {
772 315 fprintf(Frpt.file, " %6.2f", LinkStats[j].maxDepth / fullDepth);
773 }
774 2 else fprintf(Frpt.file, " ");
775 }
776 51 WRITE("");
777 }
778
779 //=============================================================================
780
781 51 void writeFlowClass()
782 //
783 // Input: none
784 // Output: none
785 // Purpose: writes flow classification for each conduit to report file.
786 //
787 {
788 int i, j, k;
789 51 double totalSeconds = RoutingTimeSpan;
790
791
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 38 times.
51 if ( RouteModel != DW ) return;
792 38 WRITE("");
793 38 WRITE("***************************");
794 38 WRITE("Flow Classification Summary");
795 38 WRITE("***************************");
796 38 WRITE("");
797 38 fprintf(Frpt.file,
798 "\n -------------------------------------------------------------------------------------"
799 "\n Adjusted ---------- Fraction of Time in Flow Class ---------- "
800 "\n /Actual Up Down Sub Sup Up Down Norm Inlet "
801 "\n Conduit Length Dry Dry Dry Crit Crit Crit Crit Ltd Ctrl "
802 "\n -------------------------------------------------------------------------------------");
803
2/2
✓ Branch 0 taken 273 times.
✓ Branch 1 taken 38 times.
311 for ( j = 0; j < Nobjects[LINK]; j++ )
804 {
805
2/2
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 245 times.
273 if ( Link[j].type != CONDUIT ) continue;
806
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 245 times.
245 if ( Link[j].xsect.type == DUMMY ) continue;
807 245 k = Link[j].subIndex;
808 245 fprintf(Frpt.file, "\n %-20s", Link[j].ID);
809 245 fprintf(Frpt.file, " %6.2f ", Conduit[k].modLength / Conduit[k].length);
810
2/2
✓ Branch 0 taken 1715 times.
✓ Branch 1 taken 245 times.
1960 for ( i=0; i<MAX_FLOW_CLASSES; i++ )
811 {
812 1715 fprintf(Frpt.file, " %4.2f",
813 1715 LinkStats[j].timeInFlowClass[i] /= totalSeconds); //5.2
814 //(double)ReportStepCount);
815 }
816 245 fprintf(Frpt.file, " %4.2f", LinkStats[j].timeNormalFlow / totalSeconds);
817 245 fprintf(Frpt.file, " %4.2f", LinkStats[j].timeInletControl / totalSeconds);
818 }
819 38 WRITE("");
820 }
821
822 //=============================================================================
823
824 51 void writeLinkSurcharge()
825 {
826 51 int i, j, n = 0;
827 double t[5];
828
829 51 WRITE("");
830 51 WRITE("*************************");
831 51 WRITE("Conduit Surcharge Summary");
832 51 WRITE("*************************");
833 51 WRITE("");
834
2/2
✓ Branch 0 taken 332 times.
✓ Branch 1 taken 51 times.
383 for ( j = 0; j < Nobjects[LINK]; j++ )
835 {
836
2/2
✓ Branch 0 taken 299 times.
✓ Branch 1 taken 33 times.
332 if ( Link[j].type != CONDUIT ||
837
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 299 times.
332 Link[j].xsect.type == DUMMY ) continue;
838 299 t[0] = LinkStats[j].timeSurcharged / 3600.0;
839 299 t[1] = LinkStats[j].timeFullUpstream / 3600.0;
840 299 t[2] = LinkStats[j].timeFullDnstream / 3600.0;
841 299 t[3] = LinkStats[j].timeFullFlow / 3600.0;
842
2/2
✓ Branch 0 taken 215 times.
✓ Branch 1 taken 84 times.
299 if ( t[0] + t[1] + t[2] + t[3] == 0.0 ) continue;
843 84 t[4] = LinkStats[j].timeCapacityLimited / 3600.0;
844
4/4
✓ Branch 0 taken 187 times.
✓ Branch 1 taken 233 times.
✓ Branch 2 taken 420 times.
✓ Branch 3 taken 84 times.
504 for (i=0; i<5; i++) t[i] = MAX(0.01, t[i]);
845
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 66 times.
84 if (n == 0)
846 {
847 18 fprintf(Frpt.file,
848 "\n ----------------------------------------------------------------------------"
849 "\n Hours Hours "
850 "\n --------- Hours Full -------- Above Full Capacity"
851 "\n Conduit Both Ends Upstream Dnstream Normal Flow Limited"
852 "\n ----------------------------------------------------------------------------");
853 18 n = 1;
854 }
855 84 fprintf(Frpt.file, "\n %-20s", Link[j].ID);
856 84 fprintf(Frpt.file, " %8.2f %8.2f %8.2f %8.2f %8.2f",
857 t[0], t[1], t[2], t[3], t[4]);
858 }
859
2/2
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 18 times.
51 if ( n == 0 ) WRITE("No conduits were surcharged.");
860 51 WRITE("");
861 51 }
862
863 //=============================================================================
864
865 51 void writePumpFlows()
866 //
867 // Input: none
868 // Output: none
869 // Purpose: writes simulation statistics for pumps to report file.
870 //
871 {
872 int j, k;
873 double avgFlow, pctUtilized, pctOffCurve1, pctOffCurve2,
874 51 totalSeconds = RoutingTimeSpan;
875
876
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 3 times.
51 if ( Nlinks[PUMP] == 0 ) return;
877
878 3 WRITE("");
879 3 WRITE("***************");
880 3 WRITE("Pumping Summary");
881 3 WRITE("***************");
882 3 WRITE("");
883
884 3 fprintf(Frpt.file,
885 "\n ---------------------------------------------------------------------------------------------------------"
886 "\n Min Avg Max Total Power %% Time Off"
887 "\n Percent Number of Flow Flow Flow Volume Usage Pump Curve"
888 "\n Pump Utilized Start-Ups %3s %3s %3s %8s Kw-hr Low High"
889 "\n ---------------------------------------------------------------------------------------------------------",
890 FlowUnitWords[FlowUnits], FlowUnitWords[FlowUnits],
891 FlowUnitWords[FlowUnits], VolUnitsWords[UnitSystem]);
892
2/2
✓ Branch 0 taken 123 times.
✓ Branch 1 taken 3 times.
126 for ( j = 0; j < Nobjects[LINK]; j++ )
893 {
894
2/2
✓ Branch 0 taken 114 times.
✓ Branch 1 taken 9 times.
123 if ( Link[j].type != PUMP ) continue;
895 9 k = Link[j].subIndex;
896 9 fprintf(Frpt.file, "\n %-20s", Link[j].ID);
897 9 pctUtilized = PumpStats[k].utilized / totalSeconds * 100.0;
898 9 avgFlow = PumpStats[k].avgFlow;
899
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if ( PumpStats[k].totalPeriods > 0 )
900 9 avgFlow /= PumpStats[k].totalPeriods;
901 36 fprintf(Frpt.file, " %8.2f %10d %9.2f %9.2f %9.2f %9.3f %9.2f",
902 9 pctUtilized, PumpStats[k].startUps, PumpStats[k].minFlow*UCF(FLOW),
903 9 avgFlow*UCF(FLOW), PumpStats[k].maxFlow*UCF(FLOW),
904 9 PumpStats[k].volume*Vcf, PumpStats[k].energy);
905 9 pctOffCurve1 = PumpStats[k].offCurveLow;
906 9 pctOffCurve2 = PumpStats[k].offCurveHigh;
907
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if ( PumpStats[k].utilized > 0.0 )
908 {
909 9 pctOffCurve1 = pctOffCurve1 / PumpStats[k].utilized * 100.0;
910 9 pctOffCurve2 = pctOffCurve2 / PumpStats[k].utilized * 100.0;
911 }
912 9 fprintf(Frpt.file, " %6.1f %6.1f", pctOffCurve1, pctOffCurve2);
913 }
914 3 WRITE("");
915 }
916
917 //=============================================================================
918
919 7 void writeLinkLoads()
920 {
921 int i, j, p;
922 double x;
923 char units[15];
924 7 char linkLine[] = "--------------------";
925 7 char pollutLine[] = "--------------";
926
927 // --- print the table headings
928 7 WRITE("");
929 7 WRITE("***************************");
930 7 WRITE("Link Pollutant Load Summary");
931 7 WRITE("***************************");
932 7 WRITE("");
933 7 fprintf(Frpt.file, "\n %s", linkLine);
934
2/2
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 7 times.
25 for (p = 0; p < Nobjects[POLLUT]; p++) fprintf(Frpt.file, "%s", pollutLine);
935 7 fprintf(Frpt.file, "\n ");
936
2/2
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 7 times.
25 for (p = 0; p < Nobjects[POLLUT]; p++) fprintf(Frpt.file, "%14s", Pollut[p].ID);
937 7 fprintf(Frpt.file, "\n Link ");
938
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 7 times.
25 for (p = 0; p < Nobjects[POLLUT]; p++)
939 {
940 18 i = UnitSystem;
941
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
18 if ( Pollut[p].units == COUNT ) i = 2;
942 18 sstrncpy(units, LoadUnitsWords[i], 14);
943 18 fprintf(Frpt.file, "%14s", units);
944 }
945 7 fprintf(Frpt.file, "\n %s", linkLine);
946
2/2
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 7 times.
25 for (p = 0; p < Nobjects[POLLUT]; p++) fprintf(Frpt.file, "%s", pollutLine);
947
948 // --- print the pollutant loadings carried by each link
949
2/2
✓ Branch 0 taken 47 times.
✓ Branch 1 taken 7 times.
54 for ( j = 0; j < Nobjects[LINK]; j++ )
950 {
951 47 fprintf(Frpt.file, "\n %-20s", Link[j].ID);
952
2/2
✓ Branch 0 taken 106 times.
✓ Branch 1 taken 47 times.
153 for (p = 0; p < Nobjects[POLLUT]; p++)
953 {
954 106 x = Link[j].totalLoad[p] * LperFT3 * Pollut[p].mcf;
955
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 106 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
106 if ( Pollut[p].units == COUNT ) x = LOG10(x);
956
2/2
✓ Branch 0 taken 102 times.
✓ Branch 1 taken 4 times.
106 if ( x < 10000. ) fprintf(Frpt.file, "%14.3f", x);
957 4 else fprintf(Frpt.file, "%14.3e", x);
958 }
959 }
960 7 WRITE("");
961 7 }
962