SWMM5 - Stormwater Management Model

SWMM 5, Watersheds, Water Quality,Hydrology, Hydraulics - Watersheds

MST File Generation

MST File Creation C Code

//   mstFileGenerator.c
//
//   Project:  EPA SWMM5
//   Version:  5.00.00D
//   Date:     10/01/03
//   Author:   R. Dickinson & Carl Chan
//
//   Report writing functions for MST file
//   This code was adapted from Chuck Moore's fortran routines
//   ASCRESA.FOR and ASCHEAD.FOR in SWMM 4.
//-----------------------------------------------------------------------------

#include <string.h>
#include <math.h>
#include <time.h>
#include "headers.h"

//-----------------------------------------------------------------------------
// Imported Variables
//-----------------------------------------------------------------------------
extern double     Qcf[];               // flow units conversion factors
                                       // (see swmm5.c)

//===========================================================================================
//      Mike SWMM Header information for the MST File for Mike SWMM 2002 - cdm september 2003
//===========================================================================================

void report_write_mst_file()
{
    int IOUTPUT=1;
    int j;
    int i;
    int n1;
    int n2;
    int k ;
    int internal;
    int newklass;
    int iamCountC;
    int iamCountO;
    int iamCountP;
    int iamCountW;
    float temp ;
    char str[80];
    char str2[80];
    static time_t SysTime;
    static struct tm * SysTime1;

    // header information for the Mike SWMM file; similar to ASCHEADA in SWMM 4 Fortran Code
    fprintf(Fmst.file,   "%s","* ================================================");
    fprintf(Fmst.file, "\n%s","* ==  SWMM EXTRAN DETAILED ASCII INTERFACE FILE ==");
    fprintf(Fmst.file, "\n%s","* ==  CREATED BY SWMM 5.0F                      ==");
    fprintf(Fmst.file, "\n%s","* ==  CDM Inc.              March 2004          ==");
    fprintf(Fmst.file, "\n%s","* ================================================");
    fprintf(Fmst.file, "\n%s","* ================================================");
    fprintf(Fmst.file, "\n%s","    2  * RecSel                               <<< Always 2");
    fprintf(Fmst.file, "\n%s","    2  * Rectype                              <<< Always 2");
    fprintf(Fmst.file, "\n%s","* =    TIME DESC.                           ==");

    time(&SysTime);
    SysTime1 = localtime(&SysTime);
    strftime(str,sizeof(str),"%d",SysTime1);
    fprintf(Fmst.file, "\n%d-%2d-%2d %2d:%2d:%2d%s",1900+SysTime1->tm_year,SysTime1->tm_mon+1,SysTime1->tm_mday,SysTime1->tm_hour,SysTime1->tm_min,SysTime1->tm_sec,"   * File Creation Date    : YYYY-MM-DD HH:MM:SS");
    datetime_dateToMSTstr(StartDate, str);
    datetime_timeToMSTStr(StartDate,str2);
    fprintf(Fmst.file, "\n%s %s %s",str,str2,"  * Simulation Start Date : YYYY-MM-DD HH:MM:SS");

    fprintf(Fmst.file, "\n%10d  %s",Nobjects[NODE],"* Div_Intg[1]          <<<                Number of nodes including outfalls");
    
    // cdm january 2006 - get ride of Nlinks and substitute the
    //                    actual number of Pumps, weirs and conduits
    iamCountP = 0;
    for (i=0; i <  Nobjects[LINK]; i++)
    {  if(Link[i].type == PUMP) iamCountP++; }    
    fprintf(Fmst.file, "\n%10d  %s",iamCountP,"* Div_Intg[2]          <<<                                   Number of pumps");   
    iamCountW = 0;
    for (i=0; i <  Nobjects[LINK]; i++)
    {  if(Link[i].type == WEIR) iamCountW++; }    
    fprintf(Fmst.file, "\n%10d  %s",iamCountW,"* Div_Intg[3]          <<<                                   Number of weirs");
    iamCountC = 0;
    for (i=0; i <  Nobjects[LINK]; i++)
    {  if(Link[i].type == CONDUIT) iamCountC++; }    
    fprintf(Fmst.file, "\n%10d  %s",iamCountC,"* Div_Intg[4]          <<<                     Number of conduits (branches)");
    iamCountO = 0;
    for (i=0; i <  Nobjects[LINK]; i++)
    {  if(Link[i].type == ORIFICE) iamCountO++; }    

    fprintf(Fmst.file, "\n%s","      3457  * Div_Intg[5]          <<<                Model number indicates SWMM EXTRAN");
    temp = (EndDateTime-StartDateTime)*MSECperDAY/(float)ReportStep/1000.0;
    fprintf(Fmst.file, "\n%5.0f%s",temp,".0000  * Div_Real[1]          <<<               Number of output time steps in file");
    fprintf(Fmst.file, "\n%10.4f  %s",(EndDateTime-StartDateTime)*MSECperDAY/3600000.0,"* Div_Real[2]          <<<                    Total simulation time in hours");
    fprintf(Fmst.file, "\n%10.4f  %s",(float)RouteStep,"* Div_Real[3]          <<<                              Time step in seconds");
    fprintf(Fmst.file, "\n%10.4f  %s",(float)ReportStep,"* Div_Real[4]          <<<                          Output time step seconds");
    fprintf(Fmst.file, "\n%s","    0.0000  * Div_Real[6]          <<<                                          not used");
    fprintf(Fmst.file, "\n%s","         0 * Number of extra records");
    fprintf(Fmst.file, "\n%s","* ============================================");
    fprintf(Fmst.file, "\n%s","* =    ITEM DESC.                           ==");
    fprintf(Fmst.file, "\n%s","         0 * RecSel     <<<                        0 indicates item descriptor");
    fprintf(Fmst.file, "\n%s","         2 * Rectype    <<<                                          2 is time");
    fprintf(Fmst.file, "\n%s","         1 * Number of  <<<");
    fprintf(Fmst.file, "\n%s"," ");
    fprintf(Fmst.file, "\n%s","* ============================================");
    fprintf(Fmst.file, "\n%s","* =    ITEM DESC.                           ==");
    fprintf(Fmst.file, "\n%s","         0 * RecSel     <<<                        0 indicates item descriptor");
    fprintf(Fmst.file, "\n%s","       103 * Rectype    <<<                        103 is junction water level");
    fprintf(Fmst.file, "\n%10d %s",Nobjects[NODE],"* Number of  <<<                                number of junctions");
    fprintf(Fmst.file, "\n%s"," SWMM EXTRAN, WATER LEVEL JUNCTIONS                                    FEET");
    fprintf(Fmst.file, "\n%s","* ============================================");
    fprintf(Fmst.file, "\n%s","* =    ITEM DESC.                           ==");
    fprintf(Fmst.file, "\n%s","         0 * RecSel     <<<                        0 indicates item descriptor");
    fprintf(Fmst.file, "\n%s","       203 * Rectype    <<<                              203 is pump discharge");
    fprintf(Fmst.file, "\n%10d %s",iamCountP,"* Number of  <<<                                    Number of Pumps");
    fprintf(Fmst.file, "\n%s"," SWMM EXTRAN, DISCHARGE PUMP                                           CFS");
    fprintf(Fmst.file, "\n%s","* ============================================");
    fprintf(Fmst.file, "\n%s","* =    ITEM DESC.                           ==");
    fprintf(Fmst.file, "\n%s","         0 * RecSel     <<<                        0 indicates item descriptor");
    fprintf(Fmst.file, "\n%s","       204 * Rectype    <<<                              204 is weir discharge");
    fprintf(Fmst.file, "\n%10d %s",iamCountW,"* Number of  <<<                                    Number of Weirs");
    fprintf(Fmst.file, "\n%s"," SWMM EXTRAN, DISCHARGE WEIR                                           CFS");
    fprintf(Fmst.file, "\n%s","* ============================================");
    fprintf(Fmst.file, "\n%s","* =    ITEM DESC.                           ==");
    fprintf(Fmst.file, "\n%s","         0 * RecSel     <<<                        0 indicates item descriptor");
    fprintf(Fmst.file, "\n%s","       220 * Rectype    <<<                           220 is orifice discharge");
    fprintf(Fmst.file, "\n%10d %s",iamCountO,"* Number of  <<<                                 Number of Orifices");
    fprintf(Fmst.file, "\n%s","SWMM EXTRAN, DISCHARGE ORIFICE                                        CFS");
    fprintf(Fmst.file, "\n%s","* ============================================");
    fprintf(Fmst.file, "\n%s","* =    ITEM DESC.                           ==");
    fprintf(Fmst.file, "\n%s","         0 * RecSel     <<<                        0 indicates item descriptor");
    fprintf(Fmst.file, "\n%s","       100 * Rectype    <<<                            100 is link water level");
    fprintf(Fmst.file, "\n%10d %s",iamCountC*2,"* Number of  <<<    Number of grid level points, 2 for each conduit");
    fprintf(Fmst.file, "\n%s"," SWMM EXTRAN, WATER LEVEL LINKS                                        FEET");
    fprintf(Fmst.file, "\n%s","* ============================================");
    fprintf(Fmst.file, "\n%s","* =    ITEM DESC.                           ==");
    fprintf(Fmst.file, "\n%s","         0 * RecSel     <<<                        0 indicates item descriptor");
    fprintf(Fmst.file, "\n%s","       200 * Rectype    <<<                            200 is flow in conduits");
    fprintf(Fmst.file, "\n%10d %s",iamCountC,"* Number of  <<<     Number of discharge points, 1 for each conduit");
    fprintf(Fmst.file, "\n%s"," SWMM EXTRAN, DISCHARGE BRANCHES                                       CFS");
    fprintf(Fmst.file, "\n%s","* ============================================");
    // the end of the header information for the Mike SWMM File

    // the following section is similar to ASCRESA in the SWMM 4 Fortran Code
    // output individual chan descriptions
    fprintf(Fmst.file, "\n%s%10d%s","* =    CHAN DESC.   ",IOUTPUT,"              ==");
    fprintf(Fmst.file, "\n%s","         1 * RecSel     <<<                          1 indicates Channel Desc.");
    fprintf(Fmst.file, "\n%s","         2 * Rectype    <<<                                          2 is time");
    fprintf(Fmst.file, "\n%s","         0 * Unittype   <<< Always zero, not used");
    fprintf(Fmst.file, "\n%s"," ");
    fprintf(Fmst.file, "\n    %s","0.0000000000E+00    0.0000000000E+00 * Minimum value and corresponding time                                             Hours");
    fprintf(Fmst.file, "\n    %16e%20e %s",(EndDateTime-StartDateTime)*SECperDAY/3600.0,(EndDateTime-StartDateTime)*SECperDAY/3600.0,"    * Maximum value and corresponding time                                             HOURS");
    for (i = 1; i <=5; i++)
    fprintf(Fmst.file, "\n%s%1d%s","         0  * Div_Intg[",i,"]          <<<");
    fprintf(Fmst.file, "\n%s"," 3600.0000  * Div_Real[1]          <<<                              Time unit in seconds");
    fprintf(Fmst.file, "\n%s","    0.0000  * Div_Real[2]          <<<");
    fprintf(Fmst.file, "\n%s","    0.0000  * Div_Real[3]          <<<");
    fprintf(Fmst.file, "\n%s","    0.0000  * Div_Real[4]          <<<");
    fprintf(Fmst.file, "\n%s","    0.0000  * Div_Real[5]          <<<");
    fprintf(Fmst.file, "\n%s","          0 * Bool1 (1=True, 0=False)");
    fprintf(Fmst.file, "\n%s","          0 * Bool2 (1=True, 0=False)");
    fprintf(Fmst.file, "\n%s","          0 * Number of extra records");
    fprintf(Fmst.file, "\n%s","* ============================================");

    for ( j = 0; j < Nobjects[NODE]; j++ ) {
    IOUTPUT++;
    fprintf(Fmst.file, "\n%s%10d%s","* =    CHAN DESC.   ",IOUTPUT,"              ==");
    fprintf(Fmst.file, "\n%s","         1 * RecSel     <<<                          1 indicates Channel Desc.");
    fprintf(Fmst.file, "\n%s","       103 * Rectype    <<<                               Junction Water Level");
    fprintf(Fmst.file, "\n%s","         0 * Unittype   <<< Always zero, not used");
    fprintf(Fmst.file, "\n    %16s",Node[j].ID);
    fprintf(Fmst.file, "\n    %s","0.0000000000E+00    0.0000000000E+00 * Minimum value and corresponding time             do not know these set to zero for now");
    fprintf(Fmst.file, "\n    %s","0.0000000000E+00    0.0000000000E+00 * Maximum value and corresponding time             do not know these set to zero for now");
    fprintf(Fmst.file, "\n%10d%s",IOUTPUT-1,"  * Div_Intg[1]          <<<");
    switch (Node[j].type)
    {
      case JUNCTION:
           fprintf(Fmst.file, "\n%s","         1  * Div_Intg[2]          <<<       junction type 1 manhole, 2 basin, 3 outfall");
           break ;
      case STORAGE:
           fprintf(Fmst.file, "\n%s","         2  * Div_Intg[2]          <<<       junction type 1 manhole, 2 basin, 3 outfall");
           break ;
      case OUTFALL:
           fprintf(Fmst.file, "\n%s","         3  * Div_Intg[2]          <<<       junction type 1 manhole, 2 basin, 3 outfall");
    }
    for (i = 3; i <=5; i++)
    fprintf(Fmst.file, "\n%s%1d%s","         0  * Div_Intg[",i,"]          <<<");
    for (i = 1; i <=1; i++)
    fprintf(Fmst.file, "\n%s%1d%s","    0.0000  * Div_Real[",i,"]          <<<                                    Weir elevation");
    for (i = 2; i <=2; i++)
    fprintf(Fmst.file, "\n%s%1d%s","    0.0000  * Div_Real[",i,"]          <<<                          Critical elevation input");
    for (i = 3; i <=5; i++)
    fprintf(Fmst.file, "\n%s%1d%s","    0.0000  * Div_Real[",i,"]          <<<");
    fprintf(Fmst.file, "\n%s","          0 * Bool1 (1=True, 0=False)                    Indicates that there is a weir");
    fprintf(Fmst.file, "\n%s","          0 * Bool2 (1=True, 0=False)       indicates that critical elevation was input");
    fprintf(Fmst.file, "\n%s","          1 * Number of extra records");
    fprintf(Fmst.file, "\n%s","* =    REAL DESC.                           ==");
    fprintf(Fmst.file, "\n%s","     6 * RecSel     <<<                             6 identifies real desc");
    fprintf(Fmst.file, "\n%20.10e%s",Node[j].invertElev,"   <<<  1                                   junction invert");
    fprintf(Fmst.file, "\n%20.10e%s",Node[j].invertElev+Node[j].fullDepth,"   <<<  2                                  ground elevation");
    fprintf(Fmst.file, "\n%20.10e%s",Node[j].xCoord,"   <<<  3                                        x location");
    fprintf(Fmst.file, "\n%20.10e%s",Node[j].yCoord,"   <<<  4                                        y location");
    for (i = 5; i <= 20; i++)
    fprintf(Fmst.file, "\n%s%2d"," 0.0000000000E+00      <<< ",i);
    fprintf(Fmst.file, "\n%s","* ============================================");
    }

    // pumps
    internal = 0;
    for ( j = 0; j < Nobjects[LINK]; j++ ) {
    if(Link[j].type == PUMP) {
    IOUTPUT++;
    internal++;
    fprintf(Fmst.file, "\n%s%10d%s","* =    CHAN DESC.   ",IOUTPUT,"              ==");
    fprintf(Fmst.file, "\n%s","         1 * RecSel     <<<                          1 indicates Channel Desc.");
    fprintf(Fmst.file, "\n%s","       203 * Rectype    <<<                              203 is pump discharge");
    fprintf(Fmst.file, "\n%s","         0 * Unittype   <<< Always zero, not used");
    n1 = Link[j].node1;
    n2 = Link[j].node2;
    fprintf(Fmst.file, "\n%-16s TO %-16s",Node[n1].ID,Node[n2].ID);
    fprintf(Fmst.file, "\n    %s","0.0000000000E+00    0.0000000000E+00 * Minimum value and corresponding time             do not know these set to zero for now");
    fprintf(Fmst.file, "\n    %s","0.0000000000E+00    0.0000000000E+00 * Maximum value and corresponding time             do not know these set to zero for now");
    fprintf(Fmst.file, "\n%10d%s",internal,"  * Div_Intg[1]          <<<");
    fprintf(Fmst.file, "\n         1  * Div_Intg[2]     Number of pumps Extran only has one pump");
    fprintf(Fmst.file, "\n         2  * Div_Intg[3]     Pump Type");
    for (i = 4; i <=5; i++)
    fprintf(Fmst.file, "\n%s%1d%s","         0  * Div_Intg[",i,"]    <<<");
    for (i = 1; i <=1; i++)
    // extran pump doesn't have a length get from x,y or put in 50 feet
    fprintf(Fmst.file, "\n%s%1d%s","   50.0000  * Div_Real[",i,"]          <<<");
    for (i = 2; i <=5; i++)
    fprintf(Fmst.file, "\n%s%1d%s","    0.0000  * Div_Real[",i,"]          <<<");
    fprintf(Fmst.file, "\n%s","          0  * Bool1 (1=True, 0=False) <<<         ");
    fprintf(Fmst.file, "\n%s","          0  * Bool1 (1=True, 0=False) ");
    fprintf(Fmst.file, "\n%s","          1  * Number of extra records <<<         ");
    fprintf(Fmst.file, "\n%s","* =    REAL DESC.                           ==");
    fprintf(Fmst.file, "\n%s","     6 * RecSel     <<<                             6 identifies real desc");
    fprintf(Fmst.file, "\n%20.10e%s",Node[n1].invertElev,"   <<<  1                                   junction invert");
    fprintf(Fmst.file, "\n%20.10e%s",Node[n2].invertElev+Node[n2].fullDepth,"   <<<  2                                  ground elevation");
    fprintf(Fmst.file, "\n%20.10e%s",Node[n1].xCoord,"   <<<  3                                        x location");
    fprintf(Fmst.file, "\n%20.10e%s",Node[n2].yCoord,"   <<<  4                                        y location");
    for (i = 5; i <= 20; i++)
    fprintf(Fmst.file, "\n%s%2d"," 0.0000000000E+00      <<< ",i);
    fprintf(Fmst.file, "\n%s","* ============================================");
    }
    }

    // orifices
    internal = 0 ;
    for ( j = 0; j < Nobjects[LINK]; j++ ) {
    if(Link[j].type == ORIFICE) {
    IOUTPUT++;
    internal++;
    fprintf(Fmst.file, "\n%s%10d%s","* =    CHAN DESC.   ",IOUTPUT,"              ==");
    fprintf(Fmst.file, "\n%s","         1 * RecSel     <<<                          1 indicates Channel Desc.");
    fprintf(Fmst.file, "\n%s","       220 * Rectype    <<<                                  Orifice Discharge");
    fprintf(Fmst.file, "\n%s","         0 * Unittype   <<< Always zero, not used");
    n1 = Link[j].node1;
    n2 = Link[j].node2;
    fprintf(Fmst.file, "\n%-16s TO %-16s",Node[n1].ID,Node[n2].ID);
    fprintf(Fmst.file, "\n    %s","0.0000000000E+00    0.0000000000E+00 * Minimum value and corresponding time             do not know these set to zero for now");
    fprintf(Fmst.file, "\n    %s","0.0000000000E+00    0.0000000000E+00 * Maximum value and corresponding time             do not know these set to zero for now");
    fprintf(Fmst.file, "\n%10d%s",internal,"  * Div_Intg[1]          <<<");
    for (i = 2; i <=5; i++)
    fprintf(Fmst.file, "\n%s%1d%s","         0  * Div_Intg[",i,"]          <<<");
    for (i = 1; i <=5; i++)
    fprintf(Fmst.file, "\n%s%1d%s","    0.0000  * Div_Real[",i,"]          <<<");
    fprintf(Fmst.file, "\n%s","           0 * Bool1 (1=True, 0=False)");
    fprintf(Fmst.file, "\n%s","           0 * Bool2 (1=True, 0=False)");
    fprintf(Fmst.file, "\n%s","           0 * Number of extra records");
    fprintf(Fmst.file, "\n%s","* ============================================");
    }
    }

    // weirs
    internal = 0 ;
    for ( j = 0; j < Nobjects[LINK]; j++ ) {
    if(Link[j].type == WEIR) {
    IOUTPUT++;
    internal++;
    fprintf(Fmst.file, "\n%s%10d%s","* =    CHAN DESC.   ",IOUTPUT,"              ==");
    fprintf(Fmst.file, "\n%s","         1 * RecSel     <<<                          1 indicates Channel Desc.");
    fprintf(Fmst.file, "\n%s","       204 * Rectype    <<<                              204 is weir discharge");
    fprintf(Fmst.file, "\n%s","         0 * Unittype   <<< Always zero, not used");
    n1 = Link[j].node1;
    n2 = Link[j].node2;
    fprintf(Fmst.file, "\n%-16s TO %-16s",Node[n1].ID,Node[n2].ID);
    fprintf(Fmst.file, "\n    %s","0.0000000000E+00    0.0000000000E+00 * Minimum value and corresponding time             do not know these set to zero for now");
    fprintf(Fmst.file, "\n    %s","0.0000000000E+00    0.0000000000E+00 * Maximum value and corresponding time             do not know these set to zero for now");
    fprintf(Fmst.file, "\n%10d%s",internal,"  * Div_Intg[1]          <<<");
    fprintf(Fmst.file, "\n         1  * Div_Intg[2]              ");
    fprintf(Fmst.file, "\n         2  * Div_Intg[3]              ");
    fprintf(Fmst.file, "\n         1  * Div_Intg[4]              ");
    fprintf(Fmst.file, "\n         0  * Div_Intg[5]              ");
    for (i = 1; i <=5; i++)
    fprintf(Fmst.file, "\n%s%1d%s","    0.0000  * Div_Real[",i,"]          <<<");
    fprintf(Fmst.file, "\n%s","           0 * Bool1 (1=True, 0=False)");
    fprintf(Fmst.file, "\n%s","           0 * Bool2 (1=True, 0=False)");
    fprintf(Fmst.file, "\n%s","           0 * Number of extra records");
    fprintf(Fmst.file, "\n%s","* =    REAL DESC.                           ==");
    fprintf(Fmst.file, "\n%s","     6 * RecSel     <<<                             6 identifies real desc");
    fprintf(Fmst.file, "\n%20.10e%s",Node[n1].invertElev,"   <<<  1                                   junction invert");
    fprintf(Fmst.file, "\n%20.10e%s",Node[n2].invertElev+Node[n2].fullDepth,"   <<<  2                                  ground elevation");
    fprintf(Fmst.file, "\n%20.10e%s",Node[n1].xCoord,"   <<<  3                                        x location");
    fprintf(Fmst.file, "\n%20.10e%s",Node[n2].yCoord,"   <<<  4                                        y location");
    for (i = 5; i <= 20; i++)
    fprintf(Fmst.file, "\n%s%2d"," 0.0000000000E+00      <<< ",i);
    fprintf(Fmst.file, "\n%s","* ============================================");
    }
    }

    // conduits
    for ( j = 0; j < Nobjects[LINK]; j++ ) {
    if(Link[j].type == CONDUIT) {
    IOUTPUT++;
    // translate the SWMM 5 conduit types to the Mike SWMM or SWMM 4 Newklass type
    newklass = 1;  // default for the transport conduits
    if(Link[j].xsect.type==1) newklass = 1;
    if(Link[j].xsect.type==2) newklass = 21;
    if(Link[j].xsect.type==3) newklass = 21;
    if(Link[j].xsect.type==4) newklass = 22;
    if(Link[j].xsect.type==5) newklass = 22;
    if(Link[j].xsect.type==6) newklass = 22;
    if(Link[j].xsect.type==7) newklass = 23;
    if(Link[j].xsect.type==8) newklass = 24;
    if(Link[j].xsect.type==21)newklass = 21 ;
    if(Link[j].xsect.type==11)newklass = 5;
    if(Link[j].xsect.type==12)newklass = 6;
    if(Link[j].xsect.type==13)newklass = 7;

    // first grid point for the conduit
    fprintf(Fmst.file, "\n%s%10d%s","* =    CHAN DESC.   ",IOUTPUT,"              ==");
    fprintf(Fmst.file, "\n%s","         1 * RecSel     <<<                          1 indicates Channel Desc.");
    fprintf(Fmst.file, "\n%s","       100 * Rectype    <<<                                 Water Level Branch");
    fprintf(Fmst.file, "\n%s","         0 * Unittype   <<< Always zero, not used");
    n1 = Link[j].node1;
    n2 = Link[j].node2;
    k  = Link[j].subIndex;
    fprintf(Fmst.file, "\n%-16s TO %-16s",Node[n1].ID,Node[n2].ID);
    fprintf(Fmst.file, "\n    %s","0.0000000000E+00    0.0000000000E+00 * Minimum value and corresponding time             do not know these set to zero for now");
    fprintf(Fmst.file, "\n    %s","0.0000000000E+00    0.0000000000E+00 * Maximum value and corresponding time             do not know these set to zero for now");
    for (i = 1; i <=1; i++)
    fprintf(Fmst.file, "\n%s%3d%s%1d%s","       ",j+1,"  * Div_Intg[",i,"]          <<<");
    for (i = 2; i <=2; i++)
    fprintf(Fmst.file, "\n%s%2d%s%1d%s","        ",newklass,"  * Div_Intg[",i,"]          <<<                         Internal Extran pipe type");
    for (i = 3; i <=3; i++)
    fprintf(Fmst.file, "\n%s%1d%s","         3  * Div_Intg[",i,"]          <<<                Number of grid points 3 for extran");
    for (i = 4; i <=4; i++)
    fprintf(Fmst.file, "\n%s%1d%s","         1  * Div_Intg[",i,"]          <<<                                 grid point number");
    for (i = 5; i <=5; i++)
    fprintf(Fmst.file, "\n%s%1d%s","         0  * Div_Intg[",i,"]          <<<");
    for (i = 1; i <=1; i++)
    fprintf(Fmst.file, "\n%s%1d%s","    0.0000  * Div_Real[",i,"]          <<<                        Distance from upstream end");
    for (i = 2; i <=2; i++)
    fprintf(Fmst.file, "\n%10.4f%s%1d%s",Link[j].xsect.yFull,"  * Div_Real[",i,"]          <<<                                    conduit height");
    for (i = 3; i <=3; i++)
    fprintf(Fmst.file, "\n%10.4f%s%1d%s",Link[j].z1+Node[n1].invertElev,"  * Div_Real[",i,"]          <<<                                  invert elevation");
    for (i = 4; i <=4; i++)
    fprintf(Fmst.file, "\n%10.4f%s%1d%s",Node[n1].invertElev+Node[n1].fullDepth,"  * Div_Real[",i,"]          <<<                                  ground elevation");
    for (i = 5; i <=5; i++)
    fprintf(Fmst.file, "\n%s%1d%s","    0.0000  * Div_Real[",i,"]          <<<");
    fprintf(Fmst.file, "\n%s","           0 * Bool1 (1=True, 0=False)");
    fprintf(Fmst.file, "\n%s","           0 * Bool2 (1=True, 0=False)");
    fprintf(Fmst.file, "\n%s","           1 * Number of extra records");
    fprintf(Fmst.file, "\n%s","* =    REAL DESC.                           ==");
    fprintf(Fmst.file, "\n%s",                           "     6 * RecSel     <<<                             6 identifies real desc");
    fprintf(Fmst.file, "\n%20.10e%s",Link[j].z1+Node[n1].invertElev,         "   <<<  1             Pipe invert elevation at upstream end");
    fprintf(Fmst.file, "\n%20.10e%s",Link[j].z2+Node[n2].invertElev,         "   <<<  2           Pipe invert elevation at downstream end");
    fprintf(Fmst.file, "\n%20.10e%s",Link[j].xsect.yFull,"   <<<  3                                       Pipe height");
    fprintf(Fmst.file, "\n%20.10e%s",Conduit[k].length,  "   <<<  4                                       Pipe length");
    fprintf(Fmst.file, "\n%20.10e%s",Node[n1].invertElev,"   <<<  5                           Invert of upstream node");
    fprintf(Fmst.file, "\n%20.10e%s",Link[j].qFull,"   <<<  6                            full flow q (mannings");
    for (i = 7; i <= 20; i++)
    fprintf(Fmst.file, "\n%s%2d"," 0.0000000000E+00      <<< ",i);
    fprintf(Fmst.file, "\n%s","* ============================================");
    // end of the first grid point for the conduit

    // second grid point for the conduit
    IOUTPUT++;
    fprintf(Fmst.file, "\n%s%10d%s","* =    CHAN DESC.   ",IOUTPUT,"              ==");
    fprintf(Fmst.file, "\n%s","         1 * RecSel     <<<                          1 indicates Channel Desc.");
    fprintf(Fmst.file, "\n%s","       200 * Rectype    <<<                                   Discharge Branch");
    fprintf(Fmst.file, "\n%s","         0 * Unittype   <<< Always zero, not used");
    fprintf(Fmst.file, "\n%-16s TO %-16s",Node[n1].ID,Node[n2].ID);
    fprintf(Fmst.file, "\n    %s","0.0000000000E+00    0.0000000000E+00 * Minimum value and corresponding time             do not know these set to zero for now");
    fprintf(Fmst.file, "\n    %s","0.0000000000E+00    0.0000000000E+00 * Maximum value and corresponding time             do not know these set to zero for now");
    for (i = 1; i <=1; i++)
    fprintf(Fmst.file, "\n%s%3d%s%1d%s","       ",j+1,"  * Div_Intg[",i,"]          <<<");
    for (i = 2; i <=2; i++)
    fprintf(Fmst.file, "\n%s%2d%s%1d%s","        ",newklass,"  * Div_Intg[",i,"]          <<<                         Internal Extran pipe type");
    for (i = 3; i <=3; i++)
    fprintf(Fmst.file, "\n%s%1d%s","         3  * Div_Intg[",i,"]          <<<                Number of grid points 3 for extran");
    for (i = 4; i <=4; i++)
    fprintf(Fmst.file, "\n%s%1d%s","         2  * Div_Intg[",i,"]          <<<                                 grid point number");
    for (i = 5; i <=5; i++)
    fprintf(Fmst.file, "\n%s%1d%s","         0  * Div_Intg[",i,"]          <<<");
    for (i = 1; i <=1; i++)
    fprintf(Fmst.file, "\n%10.4f%s%1d%s",0.5*Conduit[k].length,"  * Div_Real[",i,"]          <<<                        Distance from upstream end");
    for (i = 2; i <=2; i++)
    fprintf(Fmst.file, "\n%10.4f%s%1d%s",Link[j].qFull,"  * Div_Real[",i,"]          <<<                                    qfull, manning");
    for (i = 3; i <=3; i++)
    fprintf(Fmst.file, "\n%10.4f%s%1d%s",0.5*(Link[j].z1+Link[j].z2+Node[n1].invertElev+Node[n2].invertElev),"  * Div_Real[",i,"]          <<<                                  invert elevation");
    for (i = 4; i <=4; i++)
    fprintf(Fmst.file, "\n%10.4f%s%1d%s",0.5*(Node[n1].invertElev+Node[n1].fullDepth+Node[n2].invertElev+Node[n2].fullDepth),"  * Div_Real[",i,"]          <<<                                  ground elevation");
    for (i = 5; i <=5; i++)
    fprintf(Fmst.file, "\n%s%1d%s","    0.0000  * Div_Real[",i,"]          <<<");
    fprintf(Fmst.file, "\n%s","           0 * Bool1 (1=True, 0=False)");
    fprintf(Fmst.file, "\n%s","           0 * Bool2 (1=True, 0=False)");
    fprintf(Fmst.file, "\n%s","           0 * Number of extra records");
    fprintf(Fmst.file, "\n%s","* ============================================");

    // third grid point of the conduit
    IOUTPUT++;
    fprintf(Fmst.file, "\n%s%10d%s","* =    CHAN DESC.   ",IOUTPUT,"              ==");
    fprintf(Fmst.file, "\n%s","         1 * RecSel     <<<                          1 indicates Channel Desc.");
    fprintf(Fmst.file, "\n%s","       100 * Rectype    <<<                                 Water Level Branch");
    fprintf(Fmst.file, "\n%s","         0 * Unittype   <<< Always zero, not used");
    fprintf(Fmst.file, "\n%-16s TO %-16s",Node[n1].ID,Node[n2].ID);
    fprintf(Fmst.file, "\n    %s","0.0000000000E+00    0.0000000000E+00 * Minimum value and corresponding time             do not know these set to zero for now");
    fprintf(Fmst.file, "\n    %s","0.0000000000E+00    0.0000000000E+00 * Maximum value and corresponding time             do not know these set to zero for now");
    for (i = 1; i <=1; i++)
    fprintf(Fmst.file, "\n%s%3d%s%1d%s","       ",j+1,"  * Div_Intg[",i,"]          <<<");
    for (i = 2; i <=2; i++)
    fprintf(Fmst.file, "\n%s%2d%s%1d%s","        ",newklass,"  * Div_Intg[",i,"]          <<<                         Internal Extran pipe type");
    for (i = 3; i <=3; i++)
    fprintf(Fmst.file, "\n%s%1d%s","         3  * Div_Intg[",i,"]          <<<                Number of grid points 3 for extran");
    for (i = 4; i <=4; i++)
    fprintf(Fmst.file, "\n%s%1d%s","         3  * Div_Intg[",i,"]          <<<                                 grid point number");
    for (i = 5; i <=5; i++)
    fprintf(Fmst.file, "\n%s%1d%s","         0  * Div_Intg[",i,"]          <<<");
    for (i = 1; i <=1; i++)
    fprintf(Fmst.file, "\n%10.4f%s%1d%s",Conduit[k].length,"  * Div_Real[",i,"]          <<<                        Distance from upstream end");
    for (i = 2; i <=2; i++)
    fprintf(Fmst.file, "\n%10.4f%s%1d%s",Link[j].xsect.yFull,"  * Div_Real[",i,"]          <<<                                        Pipe height");
    for (i = 3; i <=3; i++)
    fprintf(Fmst.file, "\n%10.4f%s%1d%s",Link[j].z2+Node[n2].invertElev,"  * Div_Real[",i,"]          <<<                                  invert elevation");
    for (i = 4; i <=4; i++)
    fprintf(Fmst.file, "\n%10.4f%s%1d%s",Node[n2].invertElev+Node[n2].fullDepth,"  * Div_Real[",i,"]          <<<                                  ground elevation");
    for (i = 5; i <=5; i++)
    fprintf(Fmst.file, "\n%s%1d%s","    0.0000  * Div_Real[",i,"]          <<<");
    fprintf(Fmst.file, "\n%s","           0 * Bool1 (1=True, 0=False)");
    fprintf(Fmst.file, "\n%s","           0 * Bool2 (1=True, 0=False)");
    fprintf(Fmst.file, "\n%s","           0 * Number of extra records");
    if(j < Nlinks[CONDUIT]-1) fprintf(Fmst.file, "\n%s","* ============================================");
    }
    }
}

//===========================================================================================
//      Mike SWMM Results information for the MST File for Mike SWMM 2002 - cdm september 2003
//===========================================================================================

void report_write_mst_file_results()
{
    int j ;
    int n1, n2 ;
    MSirec = 1 ;

    if(MSicount  > 20) { report_write_mst_file_record_selection(); MSicount = 1 ; }

    fprintf(Fmst.file, "\n%20.10e %s%2d%3d",TotalRoutingTime/3600.0,"     <<<         ",MSirec,MSicount);
    MSirec++;
    MSicount++;
    if(MSicount  > 20) { report_write_mst_file_record_selection(); MSicount = 1 ; }

    // save the node information
    for ( j = 0; j < Nobjects[NODE]; j++ ) {
    fprintf(Fmst.file, "\n%20.10e %s%2d%3d",Node[j].invertElev+Node[j].newDepth,"     <<<         ",MSirec,MSicount);
    MSirec++;
    MSicount++;
    if(MSicount  > 20) { report_write_mst_file_record_selection(); MSicount = 1 ; }
    }

    // write pump flows
    for ( j = 0; j < Nobjects[LINK]; j++ ) {
    if(Link[j].type == PUMP) {
    fprintf(Fmst.file, "\n%20.10e %s%2d%3d",Link[j].newFlow*Qcf[FlowUnits],"     <<<         ",MSirec,MSicount);
    MSirec++;
    MSicount++;
    if(MSicount  > 20) { report_write_mst_file_record_selection(); MSicount = 1 ; }
    }}

    // write orifice flows
    for ( j = 0; j < Nobjects[LINK]; j++ ) {
    if(Link[j].type == ORIFICE) {
    fprintf(Fmst.file, "\n%20.10e %s%2d%3d",Link[j].newFlow*Qcf[FlowUnits],"     <<<         ",MSirec,MSicount);
    MSirec++;
    MSicount++;
    if(MSicount  > 20) { report_write_mst_file_record_selection(); MSicount = 1 ; }
    }}

    // write weir flows
    for ( j = 0; j < Nobjects[LINK]; j++ ) {
    if(Link[j].type == WEIR) {
    fprintf(Fmst.file, "\n%20.10e %s%2d%3d",Link[j].newFlow*Qcf[FlowUnits],"     <<<         ",MSirec,MSicount);
    MSirec++;
    MSicount++;
    if(MSicount  > 20) { report_write_mst_file_record_selection(); MSicount = 1 ; }
    }}

    // write link flows
    for ( j = 0; j < Nobjects[LINK]; j++ ) {
    if(Link[j].type == CONDUIT) {
    n1 = Link[j].node1;
    // cdm march 2006 fprintf(Fmst.file, "\n%16e%s%2d%3d",Node[n1].invertElev+Node[n1].newDepth,"       <<<         ",MSirec,MSicount);
    fprintf(Fmst.file, "\n%20.10e %s%2d%3d",Link[j].w1+Node[n1].invertElev,"     <<<         ",MSirec,MSicount);
    MSirec++;
    MSicount++;
    if(MSicount > 20) { report_write_mst_file_record_selection(); MSicount = 1 ; }

    fprintf(Fmst.file, "\n%20.10e %s%2d%3d",Link[j].newFlow*Qcf[FlowUnits],"     <<<         ",MSirec,MSicount);
    MSirec++;
    MSicount++;
    if(MSicount > 20 ) { report_write_mst_file_record_selection(); MSicount = 1 ; }

    n2 = Link[j].node2;
    // cdm march 2006 fprintf(Fmst.file, "\n%16e%s%2d%3d",Node[n2].invertElev+Node[n2].newDepth,"       <<<         ",MSirec,MSicount);
    fprintf(Fmst.file, "\n%20.10e %s%2d%3d",Link[j].w2+Node[n2].invertElev,"     <<<         ",MSirec,MSicount);
    MSirec++;
    MSicount++;
    if(MSicount  > 20) { report_write_mst_file_record_selection(); MSicount = 1 ; }
    }}
}

//===========================================================================================
//      Mike SWMM Results header information for the MST File for Mike SWMM 2002 - cdm september 2003
//===========================================================================================

void report_write_mst_file_record_selection()
{
       fprintf(Fmst.file, "\n%s","* =    RESULT DESC.                         ==");
       fprintf(Fmst.file, "\n%s","        10 * RecSel     <<<                                      Result record");
}


//===========================================================================================
//      Mike SWMM Last record is a padded record - cdm september 2003
//===========================================================================================

void report_write_mst_file_record_padded()
{
    int j ;
    MSirec=1;

    fprintf(Fmst.file, "\n%s","* = PAD REMAINING FIELDS OF 20 LINE RECORD WITH ZEROS");

    // save the padded data
    for ( j = MSicount; j <= 20; j++ ) {
    fprintf(Fmst.file, "\n%s%2d%3d","    0.0000000000E+00   <<<         ",MSirec,MSicount);
    MSirec++;
    MSicount++;
    }

Last updated by Robert E Dickinson Apr. 21, 2008.

Latest Activity

tian tian and Hussam joined SWMM5 - Stormwater Management Model
1 hour ago
5 hours ago
Robert E Dickinson added a blog post
MWH Soft Releases InfoWorks and FloodWorks Version 11 New Version Available for Industry-Leading Workgroup Management Modeling Software for Wastewater, Stormwater, Drinking Water, and River Systems Broomfield, Colorado USA, September 8, 2010 MWH Sof…
16 hours ago
mohammed A Alim is now a member of SWMM5 - Stormwater Management Model
yesterday
Robert E Dickinson added a blog post
Creating Clearer Climate Computer Codes by Eli Kintisch on 3 September 2010, 12:01 PM | Permanent Link | 2 Comments EmailPrint|More PREVIOUS ARTICLE NEXT ARTICLE British software engineers Nick Barnes and David Jones have spent the past 3 years t…
on Sunday
Robert E Dickinson just checked out the RSS pages...
(via RSS Pages)
on Friday
August 31
Antony Manoharan is now a member of SWMM5 - Stormwater Management Model
August 31
Robert E Dickinson added a blog post
MWH Soft Releases InfoSewer Version 6.0 for ArcGIS 10 New Version of the Leading Wastewater Modeling and Management Package Leverages Newest Esri Software Broomfield, Colorado USA, August 31, 2010 — MWH Soft, a leading global innovator of wet in…
August 31
------------------------ Build 5.0.020 (08/23/10) ------------------------ Engine Updates 1. A refactoring bug that prevented SWMM from reading rainfall data from external rainfall files was fixed. See gage.c.
August 23
lia almila and Dr. MVRL Murthy joined SWMM5 - Stormwater Management Model
August 22
There are 152 members on SWMM5 - Stormwater Management Model
August 19
SWMM5 - Stormwater Management Model now has leaderboards
August 19
August 17
David Jones is now a member of SWMM5 - Stormwater Management Model
August 17
Robert E Dickinson added a blog post
From the NYT In Weather Chaos, a Case for Global Warming The collective answer of the scientific community can be boiled down to a single word: probably. “The climate is changing,” said Jay Lawrimore, chief of climate analysis at the National Clima…
August 17
You should still adjust the width individually for each subcatchment but compare the peak flows for the combined flows to your monitored data. Unless you want to model S1, S2 and S3 together then you are best off estimating the width for each subcat…
August 15
Thank you for your help. However, the flow measurement was only taken at the outlet of the whole catchment (Out 1). if i want to calibrate the runoff quantity, how can i obtain the width of the whole catchment? Am i combine the total width of subcat…
August 15
Originally, when SWMM was developed the width parameter was the collection length of the subcatchment. For example, it would be the gutter length on a street going to an inlet. In your case one easy way to estimate the Width for the subcatchment goi…
August 14
Chow Ming Fai added a blog post
Hello,I am not familiar on using SWMM for quantity and quality modeling. i need some helps here.I have a problem on calibrating the total width of catchment in SWMM quantity modeling. Figure shown below is my studied catchment. the surface runoff is…
August 14

© 2010   Created by Robert E Dickinson.   Powered by .

Badges  |  Report An Issue | SWMM 5 Blog  |  Terms of Service