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.

About

Robert E Dickinson Robert E Dickinson created this social network on Ning.

Create your own social network!

Latest Activity

Robert E Dickinson added a note
Public Praises Science; Scientists Fault Public, Media Scientific Achievements Less Prominent Than a Decade Ago Overview Americans like science. Overwhelming majorities say that science has had a positive effect on society and that science has m...
3 hours ago
Robert E Dickinson added a blog post
This is a interesting Science Daily post on how many of our problematic brain problems are related to "survival" brain functions in insects. Human-like Brain Disturbances In Insects: Locusts Shed Light On Migraines, Stroke And Epilepsy ScienceDai...
on Sunday
Robert E Dickinson added a note
 The current InfoSWMM Report manager report is ALMOST good enough to be used as a calibration file except for: 1. the word Days 2. the semi colon and 3. the name of the object is not on the top line It is easy to convert the files by text editor b...
July 2
July 1
Joan Oppenheimer is now a member of SWMM5 - Stormwater Management Model
July 1
Robert E Dickinson added a note
Why are There 60 Minutes in an Hour? Published by Gary Wallace February 10, 2009, Category: Applied Mathematics We are all familiar with dividing our days into 24 hours and our hours into 60 minutes. But why do we use these particular units for...
June 26
Robert E Dickinson added 2 notes
June 25
Robert E Dickinson added 3 notes
June 23
Mark Drury is now a member of SWMM5 - Stormwater Management Model
June 18
suba is now a member of SWMM5 - Stormwater Management Model
June 15
Robert E Dickinson added a note
Life May Extend Planet's 'Life': Billion-year Life Extension For Earth Also Doubles Odds Of Finding Life On Other Planets ScienceDaily (June 13, 2009) — Roughly a billion years from now, the ever-increasing radiation from the sun will have heated ...
June 13
Robert E Dickinson added a note
Maybe It's Raining Less Than We Thought: Physicists Make A Splash With Raindrops Discovery ScienceDaily (June 11, 2009) — It's conventional wisdom in atmospheric science circles: large raindrops fall faster than smaller drops, because they're bigg...
June 12
Edward added a discussion
I am the supporter and user of SWMM5. Recently I built a small model using SWMM5 and found some weird outputs. The model build is attached herewith for your reference. The model is built for run with time series of inflows and downstream water le...
June 8
Edward is now a member of SWMM5 - Stormwater Management Model
June 8
Hi Doone! It has been a long while since we've chatted. I wanted to drop by to say hello...hoping that life is treating you and your family well. We are enjoying our time in Naples/Marco Island. Living on the Big Cypress basin has brought plenty o...
June 5
Robert E Dickinson added a note
Computer Graphics Researchers Simulate The Sounds Of Water And Other Liquids ScienceDaily (June 4, 2009) — Splash, splatter, babble, sploosh, drip, drop, bloop and ploop! Those are some of the sounds that have been missing from computer graphic ...
June 4
Robert E Dickinson added 2 notes
May 29
Tysne Pedler added 2 discussions
May 26
Tysne Pedler is now a member of SWMM5 - Stormwater Management Model
May 25
Welcome, Mike.
May 22

Word Cloud

SiteStats

77 Members
5 Groups
2 Events
33 Discussions
104 Blog posts
159 Photos
44 Videos
2 Music Tracks

Translate Tools

© 2009   Created by Robert E Dickinson on Ning.   Create Your Own Social Network

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