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

Robert E Dickinson added a blog post
Image via Wikipedia http://sciencenow.sciencemag.org/icons/blueplus.gif); background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; margin-right: 0px; margin-bottom: 1em; margin-left: 0px;…
12 hours ago
12 hours ago
Snowlapse Monday, February 8th, 2010 Noel St. John, quasi-official photographer of TheAgitator.com, made this very cool time-lapse animation of the D.C.-area’s blizzard this past weekend.
12 hours ago
Robert E Dickinson added 2 blog posts
on Sunday
A blog post by Robert E Dickinson was featured
The solution is iterative but each iteration is dependent on the CFL or explicit time step. The time step we select is based on the CFL condition but instead of just using the explicit solution we iterate until the node depths are converged or a max…
on Friday
Marisa Oliveira is now a member of SWMM5 - Stormwater Management Model
on Thursday
Robert E Dickinson added a note
A BETTER TEXT EDITOR, ON FORUM AND BLOG POSTS For Ning Creators and members alike, adding content is an essential part of any Ning Network. When it comes to adding text, the text editor members rely on should be as easy to use as possible. Sta…
on Thursday
February 1
Chris Olson is now a member of SWMM5 - Stormwater Management Model
February 1
End of January version of QA/QC GUI and Engine Epaswmm5.exe swmm5.dll
January 31
Robert E Dickinson added 2 notes
January 30
Robert E Dickinson added a blog post
A Short History of Hydrogen Sulfide From the sewers of Paris to physiological messenger Roger P. Smith from http://www.americanscientist.org/issues/pub/2010/1/a-short-history-of-hydrogen-sulfide/2 Early last year, reports began to emerge in the Sout…
January 30
Robert E Dickinson Ich bin ein Watershed Engineer, die weniger Überschwemmungen und eine bessere Wasserqualität für die Erde will.
January 30
Robert E Dickinson added a page
January 30
Robert E Dickinson added a page
January 30
Robert E Dickinson added a page
January 30
Robert E Dickinson added a note
As rivers go, the Mississippi is one of the world’s biggies. It’s 3.734 km (2.320 mi) long and has a watershed of more than 3,2 million sq. km (1.245.000 sq. mi), the third-largest in the world (preceded only by the Amazon and Congo rivers), drai…
January 26
Robert E Dickinson added 2 photos
January 26
Robert E Dickinson added a blog post
Comment: A really nice water analogy for the field properties Divergence, Curl and Gradient from the Blog Starts With a Bang ....it's pretty mathematically intensive, but what's missing from most textbooks and E&M courses are physical explanations…
January 24
Robert E Dickinson added 2 notes
January 24

© 2010   Created by Robert E Dickinson

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

.xg_widget_main .module_blog {height: 900px;overflow : auto;position:relative;} /* Scroll Bar for Latest Activity */ .xg_widget_main .xg_module_activity .xg_module_body {height: 900px;overflow : auto;position:relative;}