Thanks! I had had great luck using the binary results file using the description in the SWMM5 Interfacing guide and was hoping there was a document like that with a description of the runoff interface file. I was thinking I would try reading one first to confirm I knew the format then I could write one. Following the code in runoff.c and subcatch.c it looks straightforward. The following (in C#) works fine to get the initial information:
FileStream fs1 = new FileStream(infile, FileMode.Open);
The next thing I am expecting to see are the results according to the following from runoff_saveToFile
fwrite(&tStep, sizeof(float), 1, Frunoff.file);
for (j=0; j<Nobjects[SUBCATCH]; j++)
{
subcatch_getResults(j, 1.0, SubcatchResults);
fwrite(SubcatchResults, sizeof(float), n, Frunoff.file);
}
Together with tracing down in subcatch_getResults the following:
x[SUBCATCH_RAINFALL]
x[SUBCATCH_SNOWDEPTH]
x[SUBCATCH_LOSSES]
x[SUBCATCH_RUNOFF]
x[SUBCATCH_GW_FLOW]
x[SUBCATCH_GW_ELEV]
x[SUBCATCH_WASHOFF+p]
I was expecting to see time step (a float) then 6 floats plus one for each pollutant.
I try reading that with:
float[,] fltValue = new float[6 + lngNumPollutants, lngMaxSteps];
float[] dbltimestep = new float[lngMaxSteps];
//number of variables = 6 + numpollutnat
for (int i = 0; i < lngMaxSteps; i += 1)
{
dbltimestep[i] = br.ReadSingle();
for (int j = 0; i < 6 + lngNumPollutants; i += 1)
fltValue[i, j] = br.ReadSingle();
{
But it doesn’t work? In my test file I only have one subcatchemnt, will need to modify the above once I figure this out. My first time step ( dbltimestep[1]) doesn't make any sence. If I don't solve this it's not that big of a deal we have a work around.
Comments
What is saved to the runoff file is n values
int n = MAX_SUBCATCH_RESULTS + Nobjects[POLLUT] - 1;
where MAX_SUBCATCH_RESULTS is 7 or if you have no pollutants really 6.
Thanks! I had had great luck using the binary results file using the description in the SWMM5 Interfacing guide and was hoping there was a document like that with a description of the runoff interface file. I was thinking I would try reading one first to confirm I knew the format then I could write one. Following the code in runoff.c and subcatch.c it looks straightforward. The following (in C#) works fine to get the initial information:
FileStream fs1 = new FileStream(infile, FileMode.Open);
BinaryReader br = new BinaryReader(fs1);
char[] SomeCharsChars = null;
SomeCharsChars = br.ReadChars(12);// "SWMM5-RUNOFF"
long lngNumCatchments = br.ReadInt32();
long lngNumPollutants = br.ReadInt32();
long lngFlowUnits = br.ReadInt32();
long lngMaxSteps = br.ReadInt32();
The next thing I am expecting to see are the results according to the following from runoff_saveToFile
fwrite(&tStep, sizeof(float), 1, Frunoff.file);
for (j=0; j<Nobjects[SUBCATCH]; j++)
{
subcatch_getResults(j, 1.0, SubcatchResults);
fwrite(SubcatchResults, sizeof(float), n, Frunoff.file);
}
Together with tracing down in subcatch_getResults the following:
x[SUBCATCH_RAINFALL]
x[SUBCATCH_SNOWDEPTH]
x[SUBCATCH_LOSSES]
x[SUBCATCH_RUNOFF]
x[SUBCATCH_GW_FLOW]
x[SUBCATCH_GW_ELEV]
x[SUBCATCH_WASHOFF+p]
I was expecting to see time step (a float) then 6 floats plus one for each pollutant.
I try reading that with:
float[,] fltValue = new float[6 + lngNumPollutants, lngMaxSteps];
float[] dbltimestep = new float[lngMaxSteps];
//number of variables = 6 + numpollutnat
for (int i = 0; i < lngMaxSteps; i += 1)
{
dbltimestep[i] = br.ReadSingle();
for (int j = 0; i < 6 + lngNumPollutants; i += 1)
fltValue[i, j] = br.ReadSingle();
{
But it doesn’t work? In my test file I only have one subcatchemnt, will need to modify the above once I figure this out. My first time step ( dbltimestep[1]) doesn't make any sence. If I don't solve this it's not that big of a deal we have a work around.
Thanks,
David