file - All Forums - SWMM 5 or SWMM or EPASWMM and SWMM5 in ICM_SWMM
2024-03-29T05:48:30Z
https://swmm2000.com/forum/topics/feed/tag/file
How to Make an Excel Fixed Width File from SWMM 5
https://swmm2000.com/forum/topics/how-to-make-an-excel-fixed-width-file-from-swmm-5
2012-12-12T15:56:11.000Z
2012-12-12T15:56:11.000Z
Robert Dickinson
https://swmm2000.com/members/doonePlace
<div><div dir="ltr" style="text-align: left;">
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt;"><b style="background-color: white;"><span style="font-family: georgia, serif;">How to <span class="il">Make</span> an <span class="il">Excel</span> <span class="il">Fixed</span> <span class="il">Width</span> <span class="il">File</span> from <span class="il">SWMM</span> <span class="il">5</span></span></b></div>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt;"></div>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt;"><br />
<span style="background-color: white;"><span style="font-family: georgia, serif;">You can use this macro for MATLAB or some other DOS based program by using the Tools command of <span class="il">SWMM</span> <span class="il">5</span> and configuring the <span class="il">EXCEL</span> <span class="il">file</span> option.  If you use the <span class="il">EXCEL</span> tool then your <span class="il">SWMM</span> <span class="il">5</span> input <span class="il">file</span> will be opened up in <span class="il">EXCEL</span> and you can use this macro to <span class="il">make</span> a <span class="il">fixed</span> format <span class="il">file</span> for <span class="il">SWMM</span> <span class="il">5</span>.  Note, <span class="il">SWMM</span> <span class="il">5</span> does not use <span class="il">fixed</span> format but other programs may need it for reading,  You adjust the column widths in the macro for your program.</span></span></div>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt;"></div>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt;"><br />
<span style="background-color: white;"><span style="font-family: georgia, serif;"><a href="http://1.bp.blogspot.com/-6se2BQ_kmjk/UgPuR4tQwRI/AAAAAAAAEBg/UB9CeIl8taE/s1600/image001-718325.png"><img alt="" border="0" id="BLOGGER_PHOTO_ID_5909829127087636754" src="http://1.bp.blogspot.com/-6se2BQ_kmjk/UgPuR4tQwRI/AAAAAAAAEBg/UB9CeIl8taE/s400/image001-718325.png" name="BLOGGER_PHOTO_ID_5909829127087636754" /></a></span></span></div>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt;"></div>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt;"><br />
<span style="background-color: white;"><span style="font-family: georgia, serif;">Here is the macro, which is placed  in <span class="il">Excel</span> using these command:</span></span></div>
<ol start="1" style="margin-bottom: 0in;" type="1">
<li class="MsoNormal" style="margin: 0in 0in 0.0001pt;"><span style="background-color: white;"><span style="font-family: georgia, serif;">Copy the code above.</span></span></li>
<li class="MsoNormal" style="margin: 0in 0in 0.0001pt;"><span style="background-color: white;"><span style="font-family: georgia, serif;">Open <span class="il">Excel</span>.</span></span></li>
<li class="MsoNormal" style="margin: 0in 0in 0.0001pt;"><span style="background-color: white;"><span style="font-family: georgia, serif;">Alt + F11 to open the Visual Basic Editor.</span></span></li>
<li class="MsoNormal" style="margin: 0in 0in 0.0001pt;"><span style="background-color: white;"><span style="font-family: georgia, serif;">Click Insert-Module from the menu.</span></span></li>
<li class="MsoNormal" style="margin: 0in 0in 0.0001pt;"><span style="background-color: white;"><span style="font-family: georgia, serif;">Paste the code into the window that appears at right.</span></span></li>
</ol>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt;"><br />
<span style="background-color: white;"><span style="font-family: georgia, serif;">Option Explicit</span></span></div>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt;"></div>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt;"><br />
<span style="background-color: white;"><span style="font-family: georgia, serif;">Sub CreateFixedWidthFile(strFile As String, ws As Worksheet, s() As Integer)</span></span></div>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt;"><br />
<span style="background-color: white;"><span style="font-family: georgia, serif;">    Dim i As Long, j As Long</span></span></div>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt;"><br />
<span style="background-color: white;"><span style="font-family: georgia, serif;">    Dim strLine As String, strCell As String</span></span></div>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt;"><br />
<span style="background-color: white;"><span style="font-family: georgia, serif;">    </span></span></div>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt;"><br />
<span style="background-color: white;"><span style="font-family: georgia, serif;">     'get a freefile</span></span></div>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt;"><br />
<span style="background-color: white;"><span style="font-family: georgia, serif;">     ' <b>source is <a href="http://www.vbaexpress.com/kb/getarticle.php?kb_id=759" target="_blank">http://www.vbaexpress.com/kb/getarticle.php?kb_id=759</a></b></span></span></div>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt;"><br />
<span style="background-color: white;"><span style="font-family: georgia, serif;">    Dim fNum As Long</span></span></div>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt;"><br />
<span style="background-color: white;"><span style="font-family: georgia, serif;">    fNum = FreeFile</span></span></div>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt;"><br />
<span style="background-color: white;"><span style="font-family: georgia, serif;">    </span></span></div>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt;"><br />
<span style="background-color: white;"><span style="font-family: georgia, serif;">     'open the textfile</span></span></div>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt;"><br />
<span style="background-color: white;"><span style="font-family: georgia, serif;">    Open strFile For Output As fNum</span></span></div>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt;"><br />
<span style="background-color: white;"><span style="font-family: georgia, serif;">     'loop from first to last row</span></span></div>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt;"><br />
<span style="background-color: white;"><span style="font-family: georgia, serif;">     'use 2 rather than 1 to ignore header row</span></span></div>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt;"><br />
<span style="background-color: white;"><span style="font-family: georgia, serif;">    For i = 1 To ws.Range("a65536").End(xlUp).Row</span></span></div>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt;"><br />
<span style="background-color: white;"><span style="font-family: georgia, serif;">         'new line</span></span></div>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt;"><br />
<span style="background-color: white;"><span style="font-family: georgia, serif;">        strLine = ""</span></span></div>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt;"><br />
<span style="background-color: white;"><span style="font-family: georgia, serif;">         'loop through each field</span></span></div>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt;"><br />
<span style="background-color: white;"><span style="font-family: georgia, serif;">        For j = 0 To UBound(s)</span></span></div>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt;"><br />
<span style="background-color: white;"><span style="font-family: georgia, serif;">             '<span class="il">make</span> sure we only take chars up to length of field (may want to output some sort of error if it is longer than field)</span></span></div>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt;"><br />
<span style="background-color: white;"><span style="font-family: georgia, serif;">            strCell = Left$(ws.Cells(i, j + 1).Value, s(j))</span></span></div>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt;"><br />
<span style="background-color: white;"><span style="font-family: georgia, serif;">             'add on string of spaces with length equal to the difference in length between field length and value length</span></span></div>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt;"><br />
<span style="background-color: white;"><span style="font-family: georgia, serif;">            strLine = strLine & strCell & String$(s(j) - Len(strCell), Chr$(32))</span></span></div>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt;"><br />
<span style="background-color: white;"><span style="font-family: georgia, serif;">        Next j</span></span></div>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt;"><br />
<span style="background-color: white;"><span style="font-family: georgia, serif;">         'write the line to the <span class="il">file</span></span></span></div>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt;"><br />
<span style="background-color: white;"><span style="font-family: georgia, serif;">        Print #fNum, strLine</span></span></div>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt;"><br />
<span style="background-color: white;"><span style="font-family: georgia, serif;">    Next i</span></span></div>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt;"><br />
<span style="background-color: white;"><span style="font-family: georgia, serif;">     'close the <span class="il">file</span></span></span></div>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt;"><br />
<span style="background-color: white;"><span style="font-family: georgia, serif;">    Close #fNum</span></span></div>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt;"><br />
<span style="background-color: white;"><span style="font-family: georgia, serif;">    </span></span></div>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt;"><br />
<span style="background-color: white;"><span style="font-family: georgia, serif;">End Sub</span></span></div>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt;"></div>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt;"><br /></div>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt;"><br />
<span style="background-color: white;"><span style="font-family: georgia, serif;"> 'for example the code could be called using:</span></span></div>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt;"></div>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt;"><br />
<span style="background-color: white;"><span style="font-family: georgia, serif;">Sub CreateFile()</span></span></div>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt;"><br />
<span style="background-color: white;"><span style="font-family: georgia, serif;">    Dim sPath As String</span></span></div>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt;"><br />
<span style="background-color: white;"><span style="font-family: georgia, serif;">    sPath = Application.GetSaveAsFilename("SWMM5_Fixed_EXPORT", "Text Files,*.inp")</span></span></div>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt;"><br />
<span style="background-color: white;"><span style="font-family: georgia, serif;">    If LCase$(sPath) = "false" Then Exit Sub</span></span></div>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt;"><br />
<span style="background-color: white;"><span style="font-family: georgia, serif;">     'specify the widths of our fields</span></span></div>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt;"><br />
<span style="background-color: white;"><span style="font-family: georgia, serif;">     'the number of columns is the number specified in the line below +1</span></span></div>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt;"><br />
<span style="background-color: white;"><span style="font-family: georgia, serif;">    Dim s(15) As Integer</span></span></div>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt;"><br />
<span style="background-color: white;"><span style="font-family: georgia, serif;">     'starting at 0 specify the <span class="il">width</span> of each column for the SWMM5 <span class="il">File</span>, alter the columns if you need more columns in your data input <span class="il">file</span></span></span></div>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt;"><br />
<span style="background-color: white;"><span style="font-family: georgia, serif;">    s(0) = 40</span></span></div>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt;"><br />
<span style="background-color: white;"><span style="font-family: georgia, serif;">    s(1) = 20</span></span></div>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt;"><br />
<span style="background-color: white;"><span style="font-family: georgia, serif;">    s(2) = 20</span></span></div>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt;"><br />
<span style="background-color: white;"><span style="font-family: georgia, serif;">    s(3) = 20</span></span></div>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt;"><br />
<span style="background-color: white;"><span style="font-family: georgia, serif;">    s(4) = 20</span></span></div>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt;"><br />
<span style="background-color: white;"><span style="font-family: georgia, serif;">    s(<span class="il">5</span>) = 20</span></span></div>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt;"><br />
<span style="background-color: white;"><span style="font-family: georgia, serif;">    s(6) = 20</span></span></div>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt;"><br />
<span style="background-color: white;"><span style="font-family: georgia, serif;">    s(7) = 20</span></span></div>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt;"><br />
<span style="background-color: white;"><span style="font-family: georgia, serif;">    s(8) = 20</span></span></div>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt;"><br />
<span style="background-color: white;"><span style="font-family: georgia, serif;">    s(9) = 20</span></span></div>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt;"><br />
<span style="background-color: white;"><span style="font-family: georgia, serif;">    s(10) = 20</span></span></div>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt;"><br />
<span style="background-color: white;"><span style="font-family: georgia, serif;">    s(11) = 20</span></span></div>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt;"><br />
<span style="background-color: white;"><span style="font-family: georgia, serif;">    s(12) = 20</span></span></div>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt;"><br />
<span style="background-color: white;"><span style="font-family: georgia, serif;">    s(13) = 20</span></span></div>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt;"><br />
<span style="background-color: white;"><span style="font-family: georgia, serif;">    s(14) = 20</span></span></div>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt;"><br />
<span style="background-color: white;"><span style="font-family: georgia, serif;">    s(15) = 20</span></span></div>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt;"><br />
<span style="background-color: white;"><span style="font-family: georgia, serif;">     'for example to use 3 columns with field of length <span class="il">5</span>, 10 and 15 you would use:</span></span></div>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt;"><br />
<span style="background-color: white;"><span style="font-family: georgia, serif;">    'dim s(2) as Integer</span></span></div>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt;"><br />
<span style="background-color: white;"><span style="font-family: georgia, serif;">     's(0)=<span class="il">5</span></span></span></div>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt;"><br />
<span style="background-color: white;"><span style="font-family: georgia, serif;">     's(1)=10</span></span></div>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt;"><br />
<span style="background-color: white;"><span style="font-family: georgia, serif;">     's(2)=15</span></span></div>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt;"><br />
<span style="background-color: white;"><span style="font-family: georgia, serif;">     'write to <span class="il">file</span> the data from the activesheet</span></span></div>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt;"><br />
<span style="background-color: white;"><span style="font-family: georgia, serif;">    CreateFixedWidthFile sPath, ActiveSheet, s</span></span></div>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt;"><br />
<span style="background-color: white;"><span style="font-family: georgia, serif;">End Sub</span></span></div>
<br />
<span style="background-color: white;"><span style="font-family: georgia, serif;"> .</span></span></div>
</div>
urban runoff simulation using hotfile.
https://swmm2000.com/forum/topics/urban-runoff-simulation-using-hotfile
2012-10-31T11:24:07.000Z
2012-10-31T11:24:07.000Z
krishnendu pritam deb
https://swmm2000.com/members/krishnendupritamdeb
<div><div>i am doing a simulation on urban runoff. my work requires that i save simulation every 15 minutes and then use that simulated results as my input file for the next simulation. </div><div>How can I use hotstart file for saving simulation and using for the next step ?</div><div>I also need the result file for every 15 minute simulation as it will be used in another program. </div><div>Thanks in advance .</div></div>
command line problem
https://swmm2000.com/forum/topics/command-line-problem
2011-02-22T17:38:05.000Z
2011-02-22T17:38:05.000Z
Chris Olson
https://swmm2000.com/members/ChrisOlson
<div><p>Hello - I am trying to run SWMM5 (V21) from the command line but the model is not running as expected. Upon command line execution, the SWMM GUI opens up and the command prompt opens displaying...</p><p>C:\swmmbat>epaswmm5.exe iter1.inp report.rpt output.out</p><p>(there is a space between the file names)</p><p>...but the model does not run. If I run the .inp file directly from the GUI, the model runs just fine (suggesting no problems with the input file). I've tried executing using several different methods (directly through command prompt, batch file and Matlab) but nothing works.</p><p> </p>I have the epaswmm5.exe and swmm5.dll files located in the following folder along with the attached rainfall, input and batch files. (apologies for the large rainfall file).<br/><p>C:\swmmbat</p><p> </p><p>My batch file syntax is:</p><p>epaswmm5.exe iter1.inp report.rpt output.out</p><p>(yes, the batch file is located in the same folder as the .exe and .inp files and there are spaces inbetween file names)</p><p> </p><p>My Matlab code is:</p><p>cd('C:\swmmbat');<br/>dos('epaswmm5.exe iter1.inp report.rpt output.out');</p><p>(NOTE: I've also tried the 'system' command..same results)</p><p> </p><p>Thanks in advance for any suggestions you might offer.</p><p> </p><p>Thanks,</p><p>Chris</p></div>
Issues viewing results in SWMM GUI
https://swmm2000.com/forum/topics/issues-viewing-results-in-swmm
2010-10-29T19:21:35.000Z
2010-10-29T19:21:35.000Z
Katie
https://swmm2000.com/members/Katie
<div>I used MATLAB to run my SWMM files: (using batch and python files)disp ('Event 1: Present Scenario')disp('processing Python')cd ('C:\Program Files\HEC\HEC-DSSVue')% Changed the inp file and run name for each scenariosystem('G:\EPA_SWMM5\Update_SWMM_Inflows_Thesis_Event_1 G:\EPA_SWMM5 G:\EPA_SWMM5\WestCampusSWMM_OnlyD_RP_Event_1_Present.inp Event_1_Present');disp('computing SWMM')cd ('C:\Program Files\EPA SWMM 5.0')% change the inp file and corresponding rpt and out file namessystem('swmm5 G:\EPA_SWMM5\WestCampusSWMM_OnlyD_RP_Event_1_Present.inp G:\EPA_SWMM5\WestCampusSWMM_OnlyD_RP_Event_1_Present.rpt G:\EPA_SWMM5\WestCampusSWMM_OnlyD_RP_Event_1_Present.out');BUT, now that I did not use the SWMM GUI, I am unable to view the results in SWMM. Does anyone have any suggestions on how to fix this or another program that will allow me to view the hydrographs of my results.(This is modeling a storm sewer network to show the differences in peak flow/runoff volume when different Low Impact Development techniques are implemented. The hydrological data came from the results of Hec-HMS.)</div>