-
Notifications
You must be signed in to change notification settings - Fork 1
/
test.c
65 lines (59 loc) · 1.69 KB
/
test.c
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
// Test of the SWMM5 C Interfacing functions
// This is a command line executable that takes the name
// of a SWMM input file as its only command line argument
// and produces a time series listing to the console of the
// following system output results: total rainfall, total
// runoff and total outfall flow.
// This file must be compiled along with swmm5_iface.c
// and swmm5.h, and linked with swmm5.dll and swmm5.lib.
#include <stdio.h>
#include "swmm5_iface.h"
int main(int argc, char *argv[])
{
int i, r;
float x, y, z;
char rptfile[] = "tmp.rpt";
char outfile[] = "tmp.out";
// Check if a SWMM input file name is provided
if (argc < 2)
{
printf("\nNo file name was provided.\n");
return 0;
}
// Run the SWMM analysis
r = RunSwmmDll(argv[1], rptfile, outfile);
if (r > 0)
{
printf("\nSWMM run was unsuccessful; error code = %d\n", r);
}
else
{
// Open outfile as a SWMM output file
r = OpenSwmmOutFile(outfile);
if (r == 1)
{
printf("\nInvalid results in SWMM output file.\n");
}
else if (r == 2)
{
printf("\nFile is not a SWMM output file.\n");
}
else
{
printf("\nTime Total Total Total");
printf("\nPeriod Rainfall Runoff Outflow");
printf("\n====================================");
for (i=1; i<=SWMM_Nperiods; i++)
{
GetSwmmResult(3, 0, 1, i, &x);
GetSwmmResult(3, 0, 4, i, &y);
GetSwmmResult(3, 0, 11, i, &z);
printf("\n%6d %8.2f %8.2f %8.2f", i, x, y, z);
}
CloseSwmmOutFile();
}
}
remove(rptfile);
remove(outfile);
return 0;
}