Skip to content

Instantly share code, notes, and snippets.

@dleutnant
Created October 9, 2018 09:27
Show Gist options
  • Save dleutnant/872ee59a2140bd068bc84a756a5ce223 to your computer and use it in GitHub Desktop.
Save dleutnant/872ee59a2140bd068bc84a756a5ce223 to your computer and use it in GitHub Desktop.
How to compile SWMM5 library on Debian with GCC
# change dir
cd ~
# download swmm source code from epa website
wget https://www.epa.gov/sites/production/files/2018-08/swmm51013_engine_0.zip
# unzip engine files
unzip swmm51013_engine_0.zip
# extract makefiles to directory "MakeFiles"
unzip makefiles.zip -d MakeFiles
# extract source code to directory "source51013"
unzip source5_1_013.zip -d source51013
# extract makefile to compile the shared object library (note: we overwrite the existing Readme.txt with the "-o" argument)
unzip -o MakeFiles/GNU-LIB.zip
# copy the Makefile to the directory containing the swmm5 source files
cp Makefile source51013/
# change directory
cd source51013/
# modify Makefile to avoid "/usr/bin/ld: swmm5.o: relocation R_X86_64_PC32 against symbol `ErrorCode'
# can not be used when making a shared object; recompile with -fPIC" error
sed -i "2i CFLAGS= -fPIC" Makefile
# compile the shared object library
make
@Kevin-M-Smith
Copy link

Thanks for sharing - this is very helpful!

I've put together the final Makefile for the standalone executable in its own repository:
https://github.com/Kevin-M-Smith/swmm5-ubuntu-cli

@jak3kaj
Copy link

jak3kaj commented May 9, 2020

Thank you both!

@HamedGhodsi90
Copy link

Hi dleutnant,
I appreciate the proposed guideline to build a swmm executive file for Linux.
I have a question in this regard. I could prepare the swmm5 file (executive) and I am able to run a simulation model using swmmr package (run_swmm() function). But when I use the read_out() function to analyze the output file (.out), I get an error that says "SWMM executable not found".
Any idea about why it does not work or how can I fix this issue?

@dleutnant
Copy link
Author

read_out() does not call SWMM5. Could you please try to file an reproducible example? Are you able to execute the examples shipped with the package? (hint: as it seems this is rather a {swmmr} issue, please file the issue at its official github so that others could find it as well. Thanks)

@qasimAde
Copy link

Thanks for the great contribution to running swmm5 in Linux. I was able to compile the SWMM in CentOS Linux, but pls how to i run it with my .inp file? I am sorry for this question, I am new to the system.

@dleutnant
Copy link
Author

According to APPENDIX D – COMMAND LINE SWMM of the manual (link) the command line for running SWMM in this fashion is:

swmm5 inpfile rptfile outfile

@qasimAde
Copy link

According to APPENDIX D – COMMAND LINE SWMM of the manual (link) the command line for running SWMM in this fashion is:

swmm5 inpfile rptfile outfile

I tried this and i got an error message - "Command not found", after following the procedure in this github page. The only part l i did not do is copied below

"If a standalone executable is required, do the following:
add main.o to objs
remove -shared
change libswmm5.so to swmm5 in cc call
make "

Or do i need to do this for run as well?

@dleutnant
Copy link
Author

Or do i need to do this for run as well?

Yes, you need to modify the make file.

@qasimAde
Copy link

Thanks. I got this message
" No rule to make target 'main.o(objs)', needed by swmm5. Stop

@dleutnant
Copy link
Author

I recommend to use the Makefile of @Kevin-M-Smith (comment above) which is here.

@qasimAde
Copy link

Thanks @dleutnant. I tried the above link and it worked . I was able to run the examples, but when i tried using my own data, i got "cannot not open external file used for the time series" . My rainfall data are in .dat format and was attached via the GUI where the model was initially created. Please options do i have to update these files in Linux?

@dleutnant
Copy link
Author

dleutnant commented Jul 25, 2021

Your issue is not related to the gist. The swmm mailing list is more appropriate in this respect. Also, please make sure to read the chapter about error codes in the swmm manual. Anyway, I think you should check your file paths and make sure external files are accessible.

@qasimAde
Copy link

Thanks very much @dleutnant, I was able to successfully compiled the swmm5 and ran it with my model copying the external files into Linux and updating the file path. I am very grateful.

@qasimAde
Copy link

qasimAde commented Aug 2, 2021

Hello, please is there a way to run a continuous model from command line. For example, run a simulation today and want tomorrow's simulation to start from yesterday's simulation. Somehow , the way .hsf file works in the GUI.

@dleutnant
Copy link
Author

Your issue is not related to the gist. The swmm mailing list is more appropriate in this respect.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment