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: 81.9% 221 / 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 58 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
3/4
✓ Branch 0 taken 55 times.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 55 times.
58 if ( FlowUnits == MGD || FlowUnits == CMS ) sstrncpy(FlowFmt, "%9.3f", 5);
96 55 else sstrncpy(FlowFmt, "%9.2f", 5);
97
98 // --- conversion factor from cu. ft. to mil. gallons or megaliters
99
2/2
✓ Branch 0 taken 55 times.
✓ Branch 1 taken 3 times.
58 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 37 times.
✓ Branch 1 taken 21 times.
58 if ( Nobjects[SUBCATCH] > 0 )
104 {
105
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 37 times.
37 if ( !IgnoreRainfall ||
106 (Nobjects[SNOWMELT] > 0 && !IgnoreSnowmelt) ||
107 (Nobjects[AQUIFER] > 0 && !IgnoreGwater) )
108 {
109 37 writeSubcatchRunoff();
110 37 lid_writeWaterBalance();
111
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 28 times.
37 if ( !IgnoreGwater ) writeGroundwater();
112
3/4
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 23 times.
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
37 if ( Nobjects[POLLUT] > 0 && !IgnoreQuality) writeSubcatchLoads();
113 }
114 }
115
116 // --- report summary results for flow routing
117
3/4
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 10 times.
✓ Branch 2 taken 48 times.
✗ Branch 3 not taken.
58 if ( Nobjects[LINK] > 0 && !IgnoreRouting )
118 {
119 48 writeNodeDepths();
120 48 writeNodeFlows();
121
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 13 times.
48 if ( RouteModel == DW ) writeNodeSurcharge();
122 48 writeNodeFlooding();
123 48 writeStorageVolumes();
124 48 writeOutfallLoads();
125 48 inlet_writeStatsReport();
126 48 writeLinkFlows();
127 48 writeFlowClass();
128 48 writeLinkSurcharge();
129 48 writePumpFlows();
130
3/4
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 34 times.
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
48 if ( Nobjects[POLLUT] > 0 && !IgnoreQuality) writeLinkLoads();
131 }
132 58 }
133
134 //=============================================================================
135
136 37 void writeSubcatchRunoff()
137 {
138 int j;
139 double a, x, r;
140
141
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 37 times.
37 if ( Nobjects[SUBCATCH] == 0 ) return;
142 37 WRITE("");
143 37 WRITE("***************************");
144 37 WRITE("Subcatchment Runoff Summary");
145 37 WRITE("***************************");
146 37 WRITE("");
147 37 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 35 times.
✓ Branch 1 taken 2 times.
37 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 37 fprintf(Frpt.file,
159 "\n ------------------------------------------------------------------------------------------------------------------------------");
160
161
2/2
✓ Branch 0 taken 2393 times.
✓ Branch 1 taken 37 times.
2430 for ( j = 0; j < Nobjects[SUBCATCH]; j++ )
162 {
163 2393 a = Subcatch[j].area;
164
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2393 times.
2393 if ( a == 0.0 ) continue;
165 2393 fprintf(Frpt.file, "\n %-20s", Subcatch[j].ID);
166 2393 x = SubcatchStats[j].precip * UCF(RAINDEPTH);
167 2393 fprintf(Frpt.file, " %10.2f", x/a);
168 2393 x = SubcatchStats[j].runon * UCF(RAINDEPTH);
169 2393 fprintf(Frpt.file, " %10.2f", x/a);
170 2393 x = SubcatchStats[j].evap * UCF(RAINDEPTH);
171 2393 fprintf(Frpt.file, " %10.2f", x/a);
172 2393 x = SubcatchStats[j].infil * UCF(RAINDEPTH);
173 2393 fprintf(Frpt.file, " %10.2f", x/a);
174 2393 x = SubcatchStats[j].impervRunoff * UCF(RAINDEPTH);
175 2393 fprintf(Frpt.file, " %10.2f", x/a);
176 2393 x = SubcatchStats[j].pervRunoff * UCF(RAINDEPTH);
177 2393 fprintf(Frpt.file, " %10.2f", x/a);
178 2393 x = SubcatchStats[j].runoff * UCF(RAINDEPTH);
179 2393 fprintf(Frpt.file, " %10.2f", x/a);
180 2393 x = SubcatchStats[j].runoff * Vcf;
181 2393 fprintf(Frpt.file, "%12.2f", x);
182 2393 x = SubcatchStats[j].maxFlow * UCF(FLOW);
183 2393 fprintf(Frpt.file, " %8.2f", x);
184 2393 r = SubcatchStats[j].precip + SubcatchStats[j].runon;
185
2/2
✓ Branch 0 taken 1735 times.
✓ Branch 1 taken 658 times.
2393 if ( r > 0.0 ) r = SubcatchStats[j].runoff / r;
186 2393 fprintf(Frpt.file, "%8.3f", r);
187 }
188 37 WRITE("");
189 }
190
191 //=============================================================================
192
193 9 void writeGroundwater(void)
194 {
195 int i, j;
196 9 int count = 0;
197 9 double totalSeconds = NewRunoffTime / 1000.;
198 double x[9];
199
200
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 if ( Nobjects[SUBCATCH] == 0 ) return;
201
2/2
✓ Branch 0 taken 2311 times.
✓ Branch 1 taken 9 times.
2320 for ( j = 0; j < Nobjects[SUBCATCH]; j++ )
202 {
203
2/2
✓ Branch 0 taken 2241 times.
✓ Branch 1 taken 70 times.
2311 if ( Subcatch[j].groundwater != NULL ) count++;
204 }
205
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 if ( count == 0 ) return;
206
207 9 WRITE("");
208 9 WRITE("*******************");
209 9 WRITE("Groundwater Summary");
210 9 WRITE("*******************");
211 9 WRITE("");
212 9 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 7 times.
✓ Branch 1 taken 2 times.
9 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 9 fprintf(Frpt.file,
225 "\n -----------------------------------------------------------------------------------------------------");
226
227
2/2
✓ Branch 0 taken 2311 times.
✓ Branch 1 taken 9 times.
2320 for ( j = 0; j < Nobjects[SUBCATCH]; j++ )
228 {
229
3/4
✓ Branch 0 taken 2311 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 70 times.
✓ Branch 3 taken 2241 times.
2311 if ( Subcatch[j].area == 0.0 || Subcatch[j].groundwater == NULL ) continue;
230 2241 fprintf(Frpt.file, "\n %-20s", Subcatch[j].ID);
231 2241 x[0] = Subcatch[j].groundwater->stats.infil * UCF(RAINDEPTH);
232 2241 x[1] = Subcatch[j].groundwater->stats.evap * UCF(RAINDEPTH);
233 2241 x[2] = Subcatch[j].groundwater->stats.deepFlow * UCF(RAINDEPTH);
234 2241 x[3] = Subcatch[j].groundwater->stats.latFlow * UCF(RAINDEPTH);
235 2241 x[4] = Subcatch[j].groundwater->stats.maxFlow * UCF(FLOW) * Subcatch[j].area;
236 2241 x[5] = Subcatch[j].groundwater->stats.avgUpperMoist / totalSeconds;
237 2241 x[6] = Subcatch[j].groundwater->stats.avgWaterTable * UCF(LENGTH) /
238 totalSeconds;
239 2241 x[7] = Subcatch[j].groundwater->stats.finalUpperMoist;
240 2241 x[8] = Subcatch[j].groundwater->stats.finalWaterTable * UCF(LENGTH);
241
2/2
✓ Branch 1 taken 20169 times.
✓ Branch 2 taken 2241 times.
22410 for (i = 0; i < 9; i++) fprintf(Frpt.file, " %8.2f", x[i]);
242 }
243 9 WRITE("");
244 }
245
246 //=============================================================================
247
248 14 void writeSubcatchLoads()
249 {
250 int i, j, p;
251 double x;
252 double* totals;
253 char units[15];
254 14 char subcatchLine[] = "--------------------";
255 14 char pollutLine[] = "--------------";
256
257 // --- create an array to hold total loads for each pollutant
258 14 totals = (double *) calloc(Nobjects[POLLUT], sizeof(double));
259
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if ( totals )
260 {
261 // --- print the table headings
262 14 WRITE("");
263 14 WRITE("****************************");
264 14 WRITE("Subcatchment Washoff Summary");
265 14 WRITE("****************************");
266 14 WRITE("");
267 14 fprintf(Frpt.file, "\n %s", subcatchLine);
268
2/2
✓ Branch 1 taken 46 times.
✓ Branch 2 taken 14 times.
60 for (p = 0; p < Nobjects[POLLUT]; p++) fprintf(Frpt.file, "%s", pollutLine);
269 14 fprintf(Frpt.file, "\n ");
270
2/2
✓ Branch 1 taken 46 times.
✓ Branch 2 taken 14 times.
60 for (p = 0; p < Nobjects[POLLUT]; p++) fprintf(Frpt.file, "%14s", Pollut[p].ID);
271 14 fprintf(Frpt.file, "\n Subcatchment ");
272
2/2
✓ Branch 0 taken 46 times.
✓ Branch 1 taken 14 times.
60 for (p = 0; p < Nobjects[POLLUT]; p++)
273 {
274 46 i = UnitSystem;
275
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 46 times.
46 if ( Pollut[p].units == COUNT ) i = 2;
276 46 sstrncpy(units, LoadUnitsWords[i], 14);
277 46 fprintf(Frpt.file, "%14s", units);
278 46 totals[p] = 0.0;
279 }
280 14 fprintf(Frpt.file, "\n %s", subcatchLine);
281
2/2
✓ Branch 1 taken 46 times.
✓ Branch 2 taken 14 times.
60 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 2334 times.
✓ Branch 1 taken 14 times.
2348 for ( j = 0; j < Nobjects[SUBCATCH]; j++ )
285 {
286 2334 fprintf(Frpt.file, "\n %-20s", Subcatch[j].ID);
287
2/2
✓ Branch 0 taken 9294 times.
✓ Branch 1 taken 2334 times.
11628 for (p = 0; p < Nobjects[POLLUT]; p++)
288 {
289 9294 x = Subcatch[j].totalLoad[p];
290 9294 totals[p] += x;
291
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 9294 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
9294 if ( Pollut[p].units == COUNT ) x = LOG10(x);
292 9294 fprintf(Frpt.file, "%14.3f", x);
293 }
294 }
295
296 // --- print the total loading of each pollutant
297 14 fprintf(Frpt.file, "\n %s", subcatchLine);
298
2/2
✓ Branch 1 taken 46 times.
✓ Branch 2 taken 14 times.
60 for (p = 0; p < Nobjects[POLLUT]; p++) fprintf(Frpt.file, "%s", pollutLine);
299 14 fprintf(Frpt.file, "\n System ");
300
2/2
✓ Branch 0 taken 46 times.
✓ Branch 1 taken 14 times.
60 for (p = 0; p < Nobjects[POLLUT]; p++)
301 {
302 46 x = totals[p];
303
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 46 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
46 if ( Pollut[p].units == COUNT ) x = LOG10(x);
304 46 fprintf(Frpt.file, "%14.3f", x);
305 }
306 14 free(totals);
307 14 WRITE("");
308 }
309 14 }
310
311 //=============================================================================
312
313 48 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 48 times.
48 if ( Nobjects[LINK] == 0 ) return;
322
323 48 WRITE("");
324 48 WRITE("******************");
325 48 WRITE("Node Depth Summary");
326 48 WRITE("******************");
327 48 WRITE("");
328
329 48 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 45 times.
✓ Branch 1 taken 3 times.
48 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 48 fprintf(Frpt.file,
338 "\n ---------------------------------------------------------------------------------");
339
340
2/2
✓ Branch 0 taken 10173 times.
✓ Branch 1 taken 48 times.
10221 for ( j = 0; j < Nobjects[NODE]; j++ )
341 {
342 10173 fprintf(Frpt.file, "\n %-20s", Node[j].ID);
343 10173 fprintf(Frpt.file, " %-9s ", NodeTypeWords[Node[j].type]);
344 10173 getElapsedTime(NodeStats[j].maxDepthDate, &days, &hrs, &mins);
345 10173 fprintf(Frpt.file, "%7.2f %7.2f %7.2f %4d %02d:%02d %10.2f",
346 10173 NodeStats[j].avgDepth / ReportStepCount * UCF(LENGTH),
347 10173 NodeStats[j].maxDepth * UCF(LENGTH),
348 10173 (NodeStats[j].maxDepth + Node[j].invertElev) * UCF(LENGTH),
349 10173 days, hrs, mins, NodeStats[j].maxRptDepth);
350 }
351 48 WRITE("");
352 }
353
354 //=============================================================================
355
356 48 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 48 WRITE("");
367 48 WRITE("*******************");
368 48 WRITE("Node Inflow Summary");
369 48 WRITE("*******************");
370 48 WRITE("");
371
372 48 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 48 fprintf(Frpt.file,
381 "\n -------------------------------------------------------------------------------------------------");
382
383
2/2
✓ Branch 0 taken 10173 times.
✓ Branch 1 taken 48 times.
10221 for ( j = 0; j < Nobjects[NODE]; j++ )
384 {
385 10173 fprintf(Frpt.file, "\n %-20s", Node[j].ID);
386 10173 fprintf(Frpt.file, " %-9s", NodeTypeWords[Node[j].type]);
387 10173 getElapsedTime(NodeStats[j].maxInflowDate, &days1, &hrs1, &mins1);
388 10173 fprintf(Frpt.file, FlowFmt, NodeStats[j].maxLatFlow * UCF(FLOW));
389 10173 fprintf(Frpt.file, FlowFmt, NodeStats[j].maxInflow * UCF(FLOW));
390 10173 fprintf(Frpt.file, " %4d %02d:%02d", days1, hrs1, mins1);
391 10173 fprintf(Frpt.file, "%12.3g", NodeStats[j].totLatFlow * Vcf);
392 10173 fprintf(Frpt.file, "%12.3g", NodeInflow[j] * Vcf);
393
2/2
✓ Branch 0 taken 5758 times.
✓ Branch 1 taken 4415 times.
10173 if ( fabs(NodeOutflow[j]) < 1.0 )
394 5758 fprintf(Frpt.file, "%12.3f %s",
395 5758 (NodeInflow[j]-NodeOutflow[j])*Vcf*1.0e6,
396 VolUnitsWords2[UnitSystem]);
397 else
398 4415 fprintf(Frpt.file, "%12.3f", (NodeInflow[j]-NodeOutflow[j]) /
399 4415 NodeOutflow[j]*100.);
400 }
401 48 WRITE("");
402 48 }
403
404 //=============================================================================
405
406 35 void writeNodeSurcharge()
407 {
408 35 int j, n = 0;
409 double t, d1, d2;
410
411 35 WRITE("");
412 35 WRITE("**********************");
413 35 WRITE("Node Surcharge Summary");
414 35 WRITE("**********************");
415 35 WRITE("");
416
417
2/2
✓ Branch 0 taken 10088 times.
✓ Branch 1 taken 35 times.
10123 for ( j = 0; j < Nobjects[NODE]; j++ )
418 {
419
2/2
✓ Branch 0 taken 308 times.
✓ Branch 1 taken 9780 times.
10088 if ( Node[j].type == OUTFALL ) continue;
420
2/2
✓ Branch 0 taken 9638 times.
✓ Branch 1 taken 142 times.
9780 if ( NodeStats[j].timeSurcharged == 0.0 ) continue;
421
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 142 times.
142 t = MAX(0.01, (NodeStats[j].timeSurcharged / 3600.0));
422
2/2
✓ Branch 0 taken 15 times.
✓ Branch 1 taken 127 times.
142 if ( n == 0 )
423 {
424 15 WRITE("Surcharging occurs when water rises above the top of the highest conduit.");
425 15 fprintf(Frpt.file,
426 "\n ---------------------------------------------------------------------"
427 "\n Max. Height Min. Depth"
428 "\n Hours Above Crown Below Rim");
429
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 3 times.
15 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 15 fprintf(Frpt.file,
434 "\n ---------------------------------------------------------------------");
435 15 n = 1;
436 }
437 142 fprintf(Frpt.file, "\n %-20s", Node[j].ID);
438 142 fprintf(Frpt.file, " %-9s", NodeTypeWords[Node[j].type]);
439 142 d1 = NodeStats[j].maxDepth + Node[j].invertElev - Node[j].crownElev;
440
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 142 times.
142 if ( d1 < 0.0 ) d1 = 0.0;
441 142 d2 = Node[j].fullDepth - NodeStats[j].maxDepth;
442
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 129 times.
142 if ( d2 < 0.0 ) d2 = 0.0;
443 142 fprintf(Frpt.file, " %9.2f %9.3f %9.3f",
444 142 t, d1*UCF(LENGTH), d2*UCF(LENGTH));
445 }
446
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 15 times.
35 if ( n == 0 ) WRITE("No nodes were surcharged.");
447 35 WRITE("");
448 35 }
449
450 //=============================================================================
451
452 48 void writeNodeFlooding()
453 {
454 48 int j, n = 0;
455 int days, hrs, mins;
456 double t;
457
458 48 WRITE("");
459 48 WRITE("*********************");
460 48 WRITE("Node Flooding Summary");
461 48 WRITE("*********************");
462 48 WRITE("");
463
464
2/2
✓ Branch 0 taken 10173 times.
✓ Branch 1 taken 48 times.
10221 for ( j = 0; j < Nobjects[NODE]; j++ )
465 {
466
2/2
✓ Branch 0 taken 338 times.
✓ Branch 1 taken 9835 times.
10173 if ( Node[j].type == OUTFALL ) continue;
467
2/2
✓ Branch 0 taken 9809 times.
✓ Branch 1 taken 26 times.
9835 if ( NodeStats[j].timeFlooded == 0.0 ) continue;
468
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 26 times.
26 t = MAX(0.01, (NodeStats[j].timeFlooded / 3600.0));
469
470
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 16 times.
26 if ( n == 0 )
471 {
472 10 WRITE("Flooding refers to all water that overflows a node, whether it ponds or not.");
473 10 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 9 times.
✓ Branch 1 taken 1 time.
10 if ( RouteModel == DW ) fprintf(Frpt.file, " Depth");
479 1 else fprintf(Frpt.file, " Volume");
480 10 fprintf(Frpt.file,
481 "\n Node Flooded %3s days hr:min %8s",
482 FlowUnitWords[FlowUnits], VolUnitsWords[UnitSystem]);
483
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 1 time.
10 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 10 fprintf(Frpt.file,
488 "\n --------------------------------------------------------------------------");
489 10 n = 1;
490 }
491 26 fprintf(Frpt.file, "\n %-20s", Node[j].ID);
492 26 fprintf(Frpt.file, " %7.2f ", t);
493 26 fprintf(Frpt.file, FlowFmt, NodeStats[j].maxOverflow * UCF(FLOW));
494 26 getElapsedTime(NodeStats[j].maxOverflowDate, &days, &hrs, &mins);
495 26 fprintf(Frpt.file, " %4d %02d:%02d", days, hrs, mins);
496 26 fprintf(Frpt.file, "%12.3f", NodeStats[j].volFlooded * Vcf);
497
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 1 time.
26 if ( RouteModel == DW )
498 25 fprintf(Frpt.file, " %9.3f",
499 25 (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 10 times.
48 if ( n == 0 ) WRITE("No nodes were flooded.");
506 48 WRITE("");
507 48 }
508
509 //=============================================================================
510
511 48 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 19 times.
✓ Branch 1 taken 29 times.
48 if ( Nnodes[STORAGE] > 0 )
523 {
524 19 WRITE("");
525 19 WRITE("**********************");
526 19 WRITE("Storage Volume Summary");
527 19 WRITE("**********************");
528 19 WRITE("");
529
530 19 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 16 times.
✓ Branch 1 taken 3 times.
19 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 19 fprintf(Frpt.file, "%3s", FlowUnitWords[FlowUnits]);
539 19 fprintf(Frpt.file,
540 "\n ------------------------------------------------------------------------------------------------");
541
542
2/2
✓ Branch 0 taken 6555 times.
✓ Branch 1 taken 19 times.
6574 for ( j = 0; j < Nobjects[NODE]; j++ )
543 {
544
2/2
✓ Branch 0 taken 6438 times.
✓ Branch 1 taken 117 times.
6555 if ( Node[j].type != STORAGE ) continue;
545 117 k = Node[j].subIndex;
546 117 fprintf(Frpt.file, "\n %-20s", Node[j].ID);
547 117 avgVol = StorageStats[k].avgVol / (double)ReportStepCount;
548 117 maxVol = StorageStats[k].maxVol;
549 117 pctMaxVol = 0.0;
550 117 pctAvgVol = 0.0;
551
1/2
✓ Branch 0 taken 117 times.
✗ Branch 1 not taken.
117 if ( Node[j].fullVolume > 0.0 )
552 {
553 117 pctAvgVol = avgVol / Node[j].fullVolume * 100.0;
554 117 pctMaxVol = maxVol / Node[j].fullVolume * 100.0;
555 }
556 117 pctEvapLoss = 0.0;
557 117 pctSeepLoss = 0.0;
558
2/2
✓ Branch 0 taken 43 times.
✓ Branch 1 taken 74 times.
117 if ( NodeInflow[j] > 0.0 )
559 {
560 43 pctEvapLoss = StorageStats[k].evapLosses / NodeInflow[j] * 100.0;
561 43 pctSeepLoss = StorageStats[k].exfilLosses / NodeInflow[j] * 100.0;
562 }
563
564 234 fprintf(Frpt.file, "%10.3f %5.1f %5.1f %5.1f %10.3f %5.1f",
565 117 avgVol*UCF(VOLUME)/1000.0, pctAvgVol, pctEvapLoss, pctSeepLoss,
566 117 maxVol*UCF(VOLUME)/1000.0, pctMaxVol);
567
568 117 getElapsedTime(StorageStats[k].maxVolDate, &days, &hrs, &mins);
569 117 fprintf(Frpt.file, " %4d %02d:%02d ", days, hrs, mins);
570 117 fprintf(Frpt.file, FlowFmt, StorageStats[k].maxFlow*UCF(FLOW));
571 }
572 19 WRITE("");
573 }
574 48 }
575
576 //=============================================================================
577
578 48 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 48 times.
✗ Branch 1 not taken.
48 if ( Nnodes[OUTFALL] > 0 )
593 {
594 // --- initial totals
595 48 totals = (double *) calloc(Nobjects[POLLUT], sizeof(double));
596
2/2
✓ Branch 0 taken 46 times.
✓ Branch 1 taken 48 times.
94 for (p=0; p<Nobjects[POLLUT]; p++) totals[p] = 0.0;
597 48 flowSum = 0.0;
598 48 freqSum = 0.0;
599 48 volSum = 0.0;
600
601 // --- print table title
602 48 WRITE("");
603 48 WRITE("***********************");
604 48 WRITE("Outfall Loading Summary");
605 48 WRITE("***********************");
606 48 WRITE("");
607
608 // --- print table column headers
609 48 fprintf(Frpt.file,
610 "\n -----------------------------------------------------------");
611
2/2
✓ Branch 1 taken 46 times.
✓ Branch 2 taken 48 times.
94 for (p = 0; p < Nobjects[POLLUT]; p++) fprintf(Frpt.file, "--------------");
612 48 fprintf(Frpt.file,
613 "\n Flow Avg Max Total");
614
2/2
✓ Branch 1 taken 46 times.
✓ Branch 2 taken 48 times.
94 for (p=0; p<Nobjects[POLLUT]; p++) fprintf(Frpt.file," Total");
615 48 fprintf(Frpt.file,
616 "\n Freq Flow Flow Volume");
617
2/2
✓ Branch 1 taken 46 times.
✓ Branch 2 taken 48 times.
94 for (p = 0; p < Nobjects[POLLUT]; p++) fprintf(Frpt.file, "%14s", Pollut[p].ID);
618 48 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 46 times.
✓ Branch 1 taken 48 times.
94 for (p = 0; p < Nobjects[POLLUT]; p++)
623 {
624 46 i = UnitSystem;
625
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 46 times.
46 if ( Pollut[p].units == COUNT ) i = 2;
626 46 sstrncpy(units, LoadUnitsWords[i], 14);
627 46 fprintf(Frpt.file, "%14s", units);
628 }
629 48 fprintf(Frpt.file,
630 "\n -----------------------------------------------------------");
631
2/2
✓ Branch 1 taken 46 times.
✓ Branch 2 taken 48 times.
94 for (p = 0; p < Nobjects[POLLUT]; p++) fprintf(Frpt.file, "--------------");
632
633 // --- identify each outfall node
634
2/2
✓ Branch 0 taken 10173 times.
✓ Branch 1 taken 48 times.
10221 for (j=0; j<Nobjects[NODE]; j++)
635 {
636
2/2
✓ Branch 0 taken 9835 times.
✓ Branch 1 taken 338 times.
10173 if ( Node[j].type != OUTFALL ) continue;
637 338 k = Node[j].subIndex;
638 338 flowCount = OutfallStats[k].totalPeriods;
639
640 // --- print node ID, flow freq., avg. flow, max. flow & flow vol.
641 338 fprintf(Frpt.file, "\n %-20s", Node[j].ID);
642 338 x = 100.*flowCount/(double)ReportStepCount;
643 338 fprintf(Frpt.file, "%7.2f", x);
644 338 freqSum += x;
645
2/2
✓ Branch 0 taken 95 times.
✓ Branch 1 taken 243 times.
338 if ( flowCount > 0 )
646 95 x = OutfallStats[k].avgFlow*UCF(FLOW)/flowCount;
647 else
648 243 x = 0.0;
649 338 flowSum += x;
650
651 338 fprintf(Frpt.file, " ");
652 338 fprintf(Frpt.file, FlowFmt, x);
653 338 fprintf(Frpt.file, " ");
654 338 fprintf(Frpt.file, FlowFmt, OutfallStats[k].maxFlow*UCF(FLOW));
655 338 fprintf(Frpt.file, "%12.3f", NodeInflow[j] * Vcf);
656 338 volSum += NodeInflow[j];
657
658 // --- print load of each pollutant for outfall
659
2/2
✓ Branch 0 taken 1026 times.
✓ Branch 1 taken 338 times.
1364 for (p=0; p<Nobjects[POLLUT]; p++)
660 {
661 1026 x = OutfallStats[k].totalLoad[p] * LperFT3 * Pollut[p].mcf;
662 1026 totals[p] += x;
663
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1026 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1026 if ( Pollut[p].units == COUNT ) x = LOG10(x);
664 1026 fprintf(Frpt.file, "%14.3f", x);
665 }
666 }
667
668 // --- print total outfall loads
669 48 outfallCount = Nnodes[OUTFALL];
670 48 fprintf(Frpt.file,
671 "\n -----------------------------------------------------------");
672
2/2
✓ Branch 1 taken 46 times.
✓ Branch 2 taken 48 times.
94 for (p = 0; p < Nobjects[POLLUT]; p++) fprintf(Frpt.file, "--------------");
673
674 48 fprintf(Frpt.file, "\n System %7.2f ",
675 freqSum/outfallCount);
676 48 fprintf(Frpt.file, FlowFmt, flowSum);
677 48 fprintf(Frpt.file, " ");
678 48 fprintf(Frpt.file, FlowFmt, MaxOutfallFlow*UCF(FLOW));
679 48 fprintf(Frpt.file, "%12.3f", volSum * Vcf);
680
681
2/2
✓ Branch 0 taken 46 times.
✓ Branch 1 taken 48 times.
94 for (p = 0; p < Nobjects[POLLUT]; p++)
682 {
683 46 x = totals[p];
684
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 46 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
46 if ( Pollut[p].units == COUNT ) x = LOG10(x);
685 46 fprintf(Frpt.file, "%14.3f", x);
686 }
687 48 WRITE("");
688 48 free(totals);
689 }
690 48 }
691
692 //=============================================================================
693
694 48 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 48 times.
48 if (Nobjects[LINK] == 0) return;
705 48 WRITE("");
706 48 WRITE("********************");
707 48 WRITE("Link Flow Summary");
708 48 WRITE("********************");
709 48 WRITE("");
710
711 48 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 45 times.
✓ Branch 1 taken 3 times.
48 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 48 fprintf(Frpt.file,
722 "\n -----------------------------------------------------------------------------");
723
724
2/2
✓ Branch 0 taken 10508 times.
✓ Branch 1 taken 48 times.
10556 for (j = 0; j < Nobjects[LINK]; j++)
725 {
726 // --- print link ID
727 10508 k = Link[j].subIndex;
728 10508 fprintf(Frpt.file, "\n %-20s", Link[j].ID);
729
730 // --- print link type
731
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 10506 times.
10508 if (Link[j].xsect.type == DUMMY) fprintf(Frpt.file, " DUMMY ");
732
2/2
✓ Branch 0 taken 1 time.
✓ Branch 1 taken 10505 times.
10506 else if (Link[j].xsect.type == IRREGULAR) fprintf(Frpt.file, " CHANNEL ");
733 10505 else fprintf(Frpt.file, " %-7s ", LinkTypeWords[Link[j].type]);
734
735 // --- print max. flow & time of occurrence
736 10508 getElapsedTime(LinkStats[j].maxFlowDate, &days, &hrs, &mins);
737 10508 fprintf(Frpt.file, FlowFmt, LinkStats[j].maxFlow*UCF(FLOW));
738 10508 fprintf(Frpt.file, " %4d %02d:%02d", days, hrs, mins);
739
740 // --- print max flow / flow capacity for pumps
741
4/4
✓ Branch 0 taken 106 times.
✓ Branch 1 taken 10402 times.
✓ Branch 2 taken 83 times.
✓ Branch 3 taken 23 times.
10508 if (Link[j].type == PUMP && Link[j].qFull > 0.0)
742 {
743 83 fprintf(Frpt.file, " ");
744 83 fprintf(Frpt.file, " %6.2f",
745 83 LinkStats[j].maxFlow / Link[j].qFull);
746 83 continue;
747 }
748
749 // --- stop printing for dummy conduits
750
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 10423 times.
10425 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 10423 times.
10423 if (Link[j].type == OUTLET) continue;
754
755 // --- print max velocity & max/full flow for conduits
756
2/2
✓ Branch 0 taken 9772 times.
✓ Branch 1 taken 651 times.
10423 if (Link[j].type == CONDUIT)
757 {
758 9772 v = LinkStats[j].maxVeloc*UCF(LENGTH);
759
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9772 times.
9772 if (v > 50.0) fprintf(Frpt.file, " >50.00");
760 9772 else fprintf(Frpt.file, " %7.2f", v);
761 9772 fprintf(Frpt.file, " %6.2f", LinkStats[j].maxFlow / Link[j].qFull /
762 9772 (double)Conduit[k].barrels);
763 }
764 651 else fprintf(Frpt.file, " ");
765
766 // --- print max/full depth
767 10423 fullDepth = Link[j].xsect.yFull;
768
2/2
✓ Branch 0 taken 159 times.
✓ Branch 1 taken 10264 times.
10423 if (Link[j].type == ORIFICE &&
769
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 145 times.
159 Orifice[k].type == BOTTOM_ORIFICE) fullDepth = 0.0;
770
2/2
✓ Branch 0 taken 10386 times.
✓ Branch 1 taken 37 times.
10423 if (fullDepth > 0.0)
771 {
772 10386 fprintf(Frpt.file, " %6.2f", LinkStats[j].maxDepth / fullDepth);
773 }
774 37 else fprintf(Frpt.file, " ");
775 }
776 48 WRITE("");
777 }
778
779 //=============================================================================
780
781 48 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 48 double totalSeconds = RoutingTimeSpan;
790
791
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 35 times.
48 if ( RouteModel != DW ) return;
792 35 WRITE("");
793 35 WRITE("***************************");
794 35 WRITE("Flow Classification Summary");
795 35 WRITE("***************************");
796 35 WRITE("");
797 35 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 10449 times.
✓ Branch 1 taken 35 times.
10484 for ( j = 0; j < Nobjects[LINK]; j++ )
804 {
805
2/2
✓ Branch 0 taken 731 times.
✓ Branch 1 taken 9718 times.
10449 if ( Link[j].type != CONDUIT ) continue;
806
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9718 times.
9718 if ( Link[j].xsect.type == DUMMY ) continue;
807 9718 k = Link[j].subIndex;
808 9718 fprintf(Frpt.file, "\n %-20s", Link[j].ID);
809 9718 fprintf(Frpt.file, " %6.2f ", Conduit[k].modLength / Conduit[k].length);
810
2/2
✓ Branch 0 taken 68026 times.
✓ Branch 1 taken 9718 times.
77744 for ( i=0; i<MAX_FLOW_CLASSES; i++ )
811 {
812 68026 fprintf(Frpt.file, " %4.2f",
813 68026 LinkStats[j].timeInFlowClass[i] /= totalSeconds); //5.2
814 //(double)ReportStepCount);
815 }
816 9718 fprintf(Frpt.file, " %4.2f", LinkStats[j].timeNormalFlow / totalSeconds);
817 9718 fprintf(Frpt.file, " %4.2f", LinkStats[j].timeInletControl / totalSeconds);
818 }
819 35 WRITE("");
820 }
821
822 //=============================================================================
823
824 48 void writeLinkSurcharge()
825 {
826 48 int i, j, n = 0;
827 double t[5];
828
829 48 WRITE("");
830 48 WRITE("*************************");
831 48 WRITE("Conduit Surcharge Summary");
832 48 WRITE("*************************");
833 48 WRITE("");
834
2/2
✓ Branch 0 taken 10508 times.
✓ Branch 1 taken 48 times.
10556 for ( j = 0; j < Nobjects[LINK]; j++ )
835 {
836
2/2
✓ Branch 0 taken 9772 times.
✓ Branch 1 taken 736 times.
10508 if ( Link[j].type != CONDUIT ||
837
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9772 times.
10508 Link[j].xsect.type == DUMMY ) continue;
838 9772 t[0] = LinkStats[j].timeSurcharged / 3600.0;
839 9772 t[1] = LinkStats[j].timeFullUpstream / 3600.0;
840 9772 t[2] = LinkStats[j].timeFullDnstream / 3600.0;
841 9772 t[3] = LinkStats[j].timeFullFlow / 3600.0;
842
2/2
✓ Branch 0 taken 9500 times.
✓ Branch 1 taken 272 times.
9772 if ( t[0] + t[1] + t[2] + t[3] == 0.0 ) continue;
843 272 t[4] = LinkStats[j].timeCapacityLimited / 3600.0;
844
4/4
✓ Branch 0 taken 861 times.
✓ Branch 1 taken 499 times.
✓ Branch 2 taken 1360 times.
✓ Branch 3 taken 272 times.
1632 for (i=0; i<5; i++) t[i] = MAX(0.01, t[i]);
845
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 255 times.
272 if (n == 0)
846 {
847 17 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 17 n = 1;
854 }
855 272 fprintf(Frpt.file, "\n %-20s", Link[j].ID);
856 272 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 31 times.
✓ Branch 1 taken 17 times.
48 if ( n == 0 ) WRITE("No conduits were surcharged.");
860 48 WRITE("");
861 48 }
862
863 //=============================================================================
864
865 48 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 48 totalSeconds = RoutingTimeSpan;
875
876
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 12 times.
48 if ( Nlinks[PUMP] == 0 ) return;
877
878 12 WRITE("");
879 12 WRITE("***************");
880 12 WRITE("Pumping Summary");
881 12 WRITE("***************");
882 12 WRITE("");
883
884 12 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 10333 times.
✓ Branch 1 taken 12 times.
10345 for ( j = 0; j < Nobjects[LINK]; j++ )
893 {
894
2/2
✓ Branch 0 taken 10227 times.
✓ Branch 1 taken 106 times.
10333 if ( Link[j].type != PUMP ) continue;
895 106 k = Link[j].subIndex;
896 106 fprintf(Frpt.file, "\n %-20s", Link[j].ID);
897 106 pctUtilized = PumpStats[k].utilized / totalSeconds * 100.0;
898 106 avgFlow = PumpStats[k].avgFlow;
899
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 85 times.
106 if ( PumpStats[k].totalPeriods > 0 )
900 21 avgFlow /= PumpStats[k].totalPeriods;
901 424 fprintf(Frpt.file, " %8.2f %10d %9.2f %9.2f %9.2f %9.3f %9.2f",
902 106 pctUtilized, PumpStats[k].startUps, PumpStats[k].minFlow*UCF(FLOW),
903 106 avgFlow*UCF(FLOW), PumpStats[k].maxFlow*UCF(FLOW),
904 106 PumpStats[k].volume*Vcf, PumpStats[k].energy);
905 106 pctOffCurve1 = PumpStats[k].offCurveLow;
906 106 pctOffCurve2 = PumpStats[k].offCurveHigh;
907
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 85 times.
106 if ( PumpStats[k].utilized > 0.0 )
908 {
909 21 pctOffCurve1 = pctOffCurve1 / PumpStats[k].utilized * 100.0;
910 21 pctOffCurve2 = pctOffCurve2 / PumpStats[k].utilized * 100.0;
911 }
912 106 fprintf(Frpt.file, " %6.1f %6.1f", pctOffCurve1, pctOffCurve2);
913 }
914 12 WRITE("");
915 }
916
917 //=============================================================================
918
919 14 void writeLinkLoads()
920 {
921 int i, j, p;
922 double x;
923 char units[15];
924 14 char linkLine[] = "--------------------";
925 14 char pollutLine[] = "--------------";
926
927 // --- print the table headings
928 14 WRITE("");
929 14 WRITE("***************************");
930 14 WRITE("Link Pollutant Load Summary");
931 14 WRITE("***************************");
932 14 WRITE("");
933 14 fprintf(Frpt.file, "\n %s", linkLine);
934
2/2
✓ Branch 1 taken 46 times.
✓ Branch 2 taken 14 times.
60 for (p = 0; p < Nobjects[POLLUT]; p++) fprintf(Frpt.file, "%s", pollutLine);
935 14 fprintf(Frpt.file, "\n ");
936
2/2
✓ Branch 1 taken 46 times.
✓ Branch 2 taken 14 times.
60 for (p = 0; p < Nobjects[POLLUT]; p++) fprintf(Frpt.file, "%14s", Pollut[p].ID);
937 14 fprintf(Frpt.file, "\n Link ");
938
2/2
✓ Branch 0 taken 46 times.
✓ Branch 1 taken 14 times.
60 for (p = 0; p < Nobjects[POLLUT]; p++)
939 {
940 46 i = UnitSystem;
941
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 46 times.
46 if ( Pollut[p].units == COUNT ) i = 2;
942 46 sstrncpy(units, LoadUnitsWords[i], 14);
943 46 fprintf(Frpt.file, "%14s", units);
944 }
945 14 fprintf(Frpt.file, "\n %s", linkLine);
946
2/2
✓ Branch 1 taken 46 times.
✓ Branch 2 taken 14 times.
60 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 6816 times.
✓ Branch 1 taken 14 times.
6830 for ( j = 0; j < Nobjects[LINK]; j++ )
950 {
951 6816 fprintf(Frpt.file, "\n %-20s", Link[j].ID);
952
2/2
✓ Branch 0 taken 27182 times.
✓ Branch 1 taken 6816 times.
33998 for (p = 0; p < Nobjects[POLLUT]; p++)
953 {
954 27182 x = Link[j].totalLoad[p] * LperFT3 * Pollut[p].mcf;
955
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 27182 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
27182 if ( Pollut[p].units == COUNT ) x = LOG10(x);
956
2/2
✓ Branch 0 taken 27178 times.
✓ Branch 1 taken 4 times.
27182 if ( x < 10000. ) fprintf(Frpt.file, "%14.3f", x);
957 4 else fprintf(Frpt.file, "%14.3e", x);
958 }
959 }
960 14 WRITE("");
961 14 }
962