diff --git a/.gitignore b/.gitignore index 4d37fe3..8782d5f 100644 --- a/.gitignore +++ b/.gitignore @@ -14,16 +14,110 @@ # Doxygen output doxygen_out/ -# Mac Stuff +# mac .DS_Store -*.swp -*~.nib -*.build/ -DerivedData/ -Debug/ -*.xcodeproj/ -!*.xcodeproj/project.pbxproj +##### +# Xcode private settings (window sizes, bookmarks, breakpoints, custom executables, smart groups) +# +# This is complicated: +# +# SOMETIMES you need to put this file in version control. +# Apple designed it poorly - if you use "custom executables", they are +# saved in this file. +# 99% of projects do NOT use those, so they do NOT want to version control this file. +# ..but if you're in the 1%, comment out the line "*.pbxuser" +*.pbxuser *.mode1v3 *.mode2v3 +*.perspectivev3 +# NB: also, whitelist the default ones, some projects need to use these +!default.pbxuser +!default.mode1v3 +!default.mode2v3 +!default.perspectivev3 + + +#### +# Xcode 4 - semi-personal settings, often included in workspaces +# +# You can safely ignore the xcuserdata files - but do NOT ignore the files next to them +# + +xcuserdata + +#### +# XCode 4 workspaces - more detailed +# +# Workspaces are important! They are a core feature of Xcode - don't exclude them :) +# +# Workspace layout is quite spammy. For reference: +# +# (root)/ +# (project-name).xcodeproj/ +# project.pbxproj +# project.xcworkspace/ +# contents.xcworkspacedata +# xcuserdata/ +# (your name).xcuserdatad/ +# WorkspaceSettings.xcsettings +# xcuserdata/ +# (your name).xcuserdatad/ +# xcschemes/ +# (project-name).xcscheme +# +# +# +# Xcode 4 workspaces - SHARED +# +# This is UNDOCUMENTED (google: "developer.apple.com xcshareddata" - 0 results +# But if you're going to kill personal workspaces, at least keep the shared ones... +# +# +!xcshareddata + +#### +# XCode 4 build-schemes +# +# PRIVATE ones are stored inside xcuserdata +!xcschemes + +# Visual Studio 2012 +*.suo +*.sdf +*.filters +*.user +*.cdf +*.cache +*.obj +*.ilk +*.resources +*.tlb +*.tli +*.tlh +*.tmp +*.rsp +*.pgc +*.pgd +*.meta +*.tlog +*.manifest +*.res +*.pch +*.exp +*.idb +*.rep +*.xdc +*.pdb +*_manifest.rc +*.bsc +*.sbr +*.xml +*.metagen +*.bi +*.opensdf + +Debug/ + + diff --git a/build/Cyg/Makefile b/build/Cyg/Makefile deleted file mode 100755 index b900e36..0000000 --- a/build/Cyg/Makefile +++ /dev/null @@ -1,125 +0,0 @@ -# Cygwin Makefile for EPANET - -# This will build EPANET as a cygwin DLL and import -# library (cygepanet.dll/libcygepanet.dll.a) under Cygwin/gcc, -# and a standalone executable (cygepanet.exe). -# The current release of the Cygwin environment can be -# obtained from http://www.cygwin.com - -# The following targets are defined (for execution in -# the build directory under the Cygwin environment): -# make -# -Builds cygepanet2.dll, cygepanet2.def, libcygepanet2.dll.a, -# cygepanet2.exe -# make install -# -Creates shell wrapper runcygepanet2.sh that -# executes cygepanet2.exe. -# The runcygepanet2.sh wrapper simply exports -# environment variables so that the DLL is found at runtime, -# allowing you to specify your own locations for installing -# the DLL. -# -Installs cygepanet2.dll, cygepanet2.exe, and runcygepanet2.sh -# in /bin, where defaults to ~ (and can be set -# below to something different - see "Install directories") -# -Installs libcygepanet2.dll.a (import library), and cygepanet2.def, -# in /lib -# -Installs epanet2.h in /include. This is the required -# header file for the EPANET programmer's toolkit, and thus -# /include should be on your CPP include search path -# for subsequent use of the toolkit and linking with the import -# library libcygepanet2.dll.a. -# make clean -# -Removes object and library files, returning the build directory -# to its pristine state. - -SHELL = /bin/sh - -# C H A N G E H E R E A S N E E D E D -# You may wish to change the install path 'prefix', -# or the compiler flags, but these defaults should be fine. - -# Target filenames -epanetrootname := cygepanet2 -dllname := $(epanetrootname).dll -defname := $(epanetrootname).def -implibname = lib$(dllname).a -exename := $(epanetrootname) -# Shell wrapper -runcmdtemplate = runepanet.sh.template -runcmdname = runcygepanet2.sh -# Location of EPANET toolkit includes -epanetincludedir = ../../include -# Search path for sources -epanetsrcdir = ../../src -VPATH = $(epanetsrcdir):$(epanetincludedir) - -# Install directories -prefix = ~ -exec_prefix = $(prefix) -srcdir = . -libdir = $(exec_prefix)/lib -bindir = $(exec_prefix)/bin -includedir = $(prefix)/include -datarootdir = $(prefix)/share -docdir = $(datarootdir)/doc/epanet - -# Compiler and flags -CC = /bin/gcc -dlltool = /bin/dlltool -CFLAGS = -g -O3 -CPPFLAGS = -I $(srcdir) -I $(epanetincludedir) -LDFLAGS = -L . -W1,-rpath,$(libdir) -lm - -# Installer -INSTALL = install -INSTALL_PROGRAM = $(INSTALL) -INSTALL_DATA = $(INSTALL) -m 644 - -# EPANET object files -epanet_objs=hash.o hydraul.o inpfile.o input1.o input2.o \ - input3.o mempool.o output.o quality.o report.o \ - rules.o smatrix.o -# Epanet header files -epanet_heads=enumstxt.h funcs.h hash.h mempool.h text.h toolkit.h types.h vars.h -epanet_main_heads=epanet2.h -# Epanet main program -epanet_main=epanet - -.PHONY: all -all: $(dllname) $(exename) - -$(dllname): $(epanet_objs) -# $(dlltool) -z $(defname) --dllname $(dllname) --output-lib $(implibname) $^ -# $(CC) $(CFLAGS) $(LDFLAGS) -shared -o $@ $(defname) $^ - $(CC) $(CFLAGS) $(CPPFLAGS) -D SOL -c $(epanetsrcdir)/$(epanet_main).c - $(CC) $(CFLAGS) $(LDFLAGS) -shared -o $@ $(epanet_main).o $^ -Wl,--output-def,$(defname) - $(CC) $(CFLAGS) $(LDFLAGS) -shared -o $@ $(epanet_main).o $^ -Wl,--kill-at - $(dlltool) -d $(defname) --dllname $@ --output-lib $(implibname) --kill-at - -$(exename): $(epanet_objs) - $(CC) $(CFLAGS) $(CPPFLAGS) -D CLE -c $(epanetsrcdir)/$(epanet_main).c - $(CC) $(CFLAGS) -o $@ $(epanet_main).o $^ $(LDFLAGS) - -$(epanet_objs): $(epanet_heads) - -.PHONY: install -install: - cat $(runcmdtemplate) | sed 's|libdir|$(bindir)|' \ - | sed 's|exename|$(bindir)/$(exename)|' \ - > $(runcmdname) - $(INSTALL_PROGRAM) -D $(exename) $(bindir)/$(exename) - $(INSTALL_PROGRAM) -D $(dllname) $(bindir)/$(dllname) - $(INSTALL_PROGRAM) -D $(defname) $(libdir)/$(defname) - $(INSTALL_PROGRAM) -D $(implibname) $(libdir)/$(implibname) - $(INSTALL_DATA) -D $(epanetincludedir)/epanet2.h $(includedir)/epanet2.h - $(INSTALL_PROGRAM) -D $(runcmdname) $(bindir)/$(runcmdname) - -.PHONY: uninstall -uninstall: - -.PHONY: check -check: - -.PHONY: clean -clean: - -/bin/rm *.o $(dllname) $(defname) $(implibname) $(exename).exe $(runcmdname) diff --git a/build/Cyg/Makefile_Rev b/build/Cyg/Makefile_Rev deleted file mode 100755 index c09750c..0000000 --- a/build/Cyg/Makefile_Rev +++ /dev/null @@ -1,130 +0,0 @@ -# Cygwin Makefile for EPANET - -# This will build EPANET as a cygwin DLL and import -# library (cygepanet_gcc_.dll/libcygepanet_gcc_.dll.a) under Cygwin/gcc, -# and a standalone executable (cygepanet_gcc_.exe). -# is the atomic revision number of the EPANET SVN repo, -# so the results of each build can be unambiguously tracked to a repo Rev. -# The current release of the Cygwin environment can be -# obtained from http://www.cygwin.com - -# The following targets are defined (for execution in -# the build directory under the Cygwin environment): -# make -# -Builds cygepanet_gcc_.dll, cygepanet_gcc_.def, libcygepanet_gcc_.dll.a, -# cygepanet_gcc_.exe -# make install -# -Creates shell wrapper runcygepanet_.sh that -# executes cygepanet_gcc_.exe. -# The runcygepanet_.sh wrapper simply exports -# environment variables so that the DLL is found at runtime, -# allowing you to specify your own locations for installing -# the DLL. -# -Installs cygepanet_gcc_.dll, cygepanet_gcc_.exe, and runcygepanet_.sh -# in /bin, where defaults to ~ (and can be set -# below to something different - see "Install directories") -# -Installs libcygepanet_gcc_.dll.a (import library), and cygepanet_gcc_.def, -# in /lib -# -Installs epanet2.h in /include. This is the required -# header file for the EPANET programmer's toolkit, and thus -# /include should be on your CPP include search path -# for subsequent use of the toolkit and linking with the import -# library libcygepanet_gcc_.dll.a. -# make clean -# -Removes object and library files, returning the build directory -# to its pristine state. - -SHELL = /bin/sh - -# C H A N G E H E R E A S N E E D E D -# You may wish to change the install path 'prefix', -# or the compiler flags, but these defaults should be fine. - -# Target filenames -# svnname.sh constructs a name: -# where is the atomic revision number of the svn repo. -epanetsvnpath = ../../.. -epanetrootname := $(shell ../svnname.sh $(epanetsvnpath) "" cygepanet_gcc_ "") -dllname := $(epanetrootname).dll -defname := $(epanetrootname).def -implibname = lib$(dllname).a -exename := $(epanetrootname) -# Shell wrapper -runcmdtemplate = runepanet.sh.template -runcmdname = $(shell ../svnname.sh $(epanetsvnpath) "" runcygepanet_ .sh) -# Location of EPANET toolkit includes -epanetincludedir = ../../include -# Search path for sources -epanetsrcdir = ../../src -VPATH = $(epanetsrcdir):$(epanetincludedir) - -# Install directories -prefix = ~ -exec_prefix = $(prefix) -srcdir = . -libdir = $(exec_prefix)/lib -bindir = $(exec_prefix)/bin -includedir = $(prefix)/include -datarootdir = $(prefix)/share -docdir = $(datarootdir)/doc/epanet - -# Compiler and flags -CC = /bin/gcc -dlltool = /bin/dlltool -CFLAGS = -g -O3 -CPPFLAGS = -I $(srcdir) -I $(epanetincludedir) -LDFLAGS = -L . -W1,-rpath,$(libdir) -lm - -# Installer -INSTALL = install -INSTALL_PROGRAM = $(INSTALL) -INSTALL_DATA = $(INSTALL) -m 644 - -# EPANET object files -epanet_objs=hash.o hydraul.o inpfile.o input1.o input2.o \ - input3.o mempool.o output.o quality.o report.o \ - rules.o smatrix.o -# Epanet header files -epanet_heads=enumstxt.h funcs.h hash.h mempool.h text.h toolkit.h types.h vars.h -epanet_main_heads=epanet2.h -# Epanet main program -epanet_main=epanet - -.PHONY: all -all: $(dllname) $(exename) - -$(dllname): $(epanet_objs) -# $(dlltool) -z $(defname) --dllname $(dllname) --output-lib $(implibname) $^ -# $(CC) $(CFLAGS) $(LDFLAGS) -shared -o $@ $(defname) $^ - $(CC) $(CFLAGS) $(CPPFLAGS) -D SOL -c $(epanetsrcdir)/$(epanet_main).c - $(CC) $(CFLAGS) $(LDFLAGS) -shared -o $@ $(epanet_main).o $^ -Wl,--output-def,$(defname) - $(CC) $(CFLAGS) $(LDFLAGS) -shared -o $@ $(epanet_main).o $^ -Wl,--kill-at - $(dlltool) -d $(defname) --dllname $@ --output-lib $(implibname) --kill-at - -$(exename): $(epanet_objs) - $(CC) $(CFLAGS) $(CPPFLAGS) -D CLE -c $(epanetsrcdir)/$(epanet_main).c - $(CC) $(CFLAGS) -o $@ $(epanet_main).o $^ $(LDFLAGS) - -$(epanet_objs): $(epanet_heads) - -.PHONY: install -install: - cat $(runcmdtemplate) | sed 's|libdir|$(bindir)|' \ - | sed 's|exename|$(bindir)/$(exename)|' \ - > $(runcmdname) - $(INSTALL_PROGRAM) -D $(exename) $(bindir)/$(exename) - $(INSTALL_PROGRAM) -D $(dllname) $(bindir)/$(dllname) - $(INSTALL_PROGRAM) -D $(defname) $(libdir)/$(defname) - $(INSTALL_PROGRAM) -D $(implibname) $(libdir)/$(implibname) - $(INSTALL_DATA) -D $(epanetincludedir)/epanet2.h $(includedir)/epanet2.h - $(INSTALL_PROGRAM) -D $(runcmdname) $(bindir)/$(runcmdname) - -.PHONY: uninstall -uninstall: - -.PHONY: check -check: - -.PHONY: clean -clean: - -/bin/rm *.o $(dllname) $(defname) $(implibname) $(exename).exe $(runcmdname) diff --git a/build/Cyg/runepanet.sh.template b/build/Cyg/runepanet.sh.template deleted file mode 100755 index 55ae0d3..0000000 --- a/build/Cyg/runepanet.sh.template +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh -export PATH=libdir:$PATH -export LD_LIBRARY_PATH=libdir:$LD_LIBRARY_PATH -exec exename "$@" diff --git a/build/Linux/Makefile b/build/Linux/Makefile deleted file mode 100755 index 2a0a396..0000000 --- a/build/Linux/Makefile +++ /dev/null @@ -1,108 +0,0 @@ -# Linux Makefile for EPANET - -# This will build EPANET as a shared object library -# (libepanet2.so) under Linux/Unix, and a standalone -# executable (epanet2). - -# The following targets are defined: -# make -# -Builds libepanet2.so, epanet2 -# make install -# -Creates shell wrapper runepanet2.sh that executes epanet2. -# The runepanet2.sh wrapper simply exports -# environment variables that help locate the runtime library, -# allowing you to specify your own library locations. -# -Installs epanet2 and runepanet2.sh -# in /bin, where defaults to ~ (and can be set -# below to something different - see "Install directories") -# -Installs libepanet2.so in /lib -# -Installs epanet2.h in /include. This is the required -# header file for the EPANET programmer's toolkit, and thus -# /include should be on your CPP include search path -# for subsequent use of the toolkit and linking with the -# library libepanet2.so -# make clean -# -Removes object and library files, returning the build directory -# to its pristine state. - -# You may wish to change the install path 'prefix', -# or the compiler flags, but these defaults should be fine. - -SHELL = /bin/sh - -# Target filenames -epanetrootname := epanet2 -libname := lib$(epanetrootname).so -exename := $(epanetrootname) -# Shell wrapper -runcmdtemplate = runepanet.sh.template -runcmdname = runepanet2.sh -# Location of EPANET toolkit includes -epanetincludedir = ../../include -# Search path for sources -epanetsrcdir = ../../src -VPATH = $(epanetsrcdir):$(epanetincludedir) - -# Install directories -prefix = ~ -exec_prefix = $(prefix) -libdir = $(exec_prefix)/lib -bindir = $(exec_prefix)/bin -includedir = $(prefix)/include -datarootdir = $(prefix)/share -docdir = $(datarootdir)/doc/epanet - -# Compiler and flags -CC = gcc -CFLAGS = -g -O3 -fPIC -CPPFLAGS = -I $(epanetincludedir) -LDFLAGS = -L . -W1,-rpath,$(libdir) -lm - -# Installer -INSTALL = install -INSTALL_PROGRAM = $(INSTALL) -INSTALL_DATA = $(INSTALL) -m 644 - -# Files for the shared object library -epanet_objs=hash.o hydraul.o inpfile.o input1.o input2.o \ - input3.o mempool.o output.o quality.o report.o \ - rules.o smatrix.o -# Epanet header files -epanet_heads=enumstxt.h funcs.h hash.h mempool.h text.h toolkit.h types.h vars.h -# Epanet main program -epanet_main=epanet -# Epanet main program header files -epanet_main_heads=epanet2.h - -.PHONY: all -all: $(libname) $(exename) - -$(libname): $(epanet_objs) - $(CC) $(CFLAGS) $(CPPFLAGS) -D SOL -c $(epanetsrcdir)/$(epanet_main).c - $(CC) $(CFLAGS) $(LDFLAGS) -shared -o $@ $(epanet_main).o $^ - -$(exename): $(libname) $(epanet_main_heads) - $(CC) $(CFLAGS) $(CPPFLAGS) -D CLE -c $(epanetsrcdir)/$(epanet_main).c - $(CC) $(CFLAGS) -o $@ $(epanet_main).o -l$(epanetrootname) $(LDFLAGS) - -$(epanet_objs): $(epanet_heads) - -.PHONY: install -install: - cat $(runcmdtemplate) | sed 's|libdir|$(libdir)|' \ - | sed 's|exename|$(bindir)/$(exename)|' \ - > $(runcmdname) - $(INSTALL_PROGRAM) -D $(exename) $(bindir)/$(exename) - $(INSTALL_PROGRAM) -D $(libname) $(libdir)/$(libname) - $(INSTALL_DATA) -D $(epanetincludedir)/epanet2.h $(includedir)/epanet2.h - $(INSTALL_PROGRAM) -D $(runcmdname) $(bindir)/$(runcmdname) - -.PHONY: uninstall -uninstall: - -.PHONY: check -check: - -.PHONY: clean -clean: - -/bin/rm *.o $(libname) $(exename) $(runcmdname) diff --git a/build/Linux/Makefile_Rev b/build/Linux/Makefile_Rev deleted file mode 100755 index f6e33bc..0000000 --- a/build/Linux/Makefile_Rev +++ /dev/null @@ -1,111 +0,0 @@ -# Linux Makefile for EPANET - -# This will build EPANET as a shared object library -# (libepanet_gcc_.so) under Linux/Unix, and a standalone -# executable (epanet_gcc_). - -# The following targets are defined: -# make -# -Builds libepanet_gcc_.so, epanet_gcc_ -# make install -# -Creates shell wrapper runepanet_.sh that executes epanet_gcc_.exe. -# The runepanet_.sh wrapper simply exports -# environment variables that help locate the runtime library, -# allowing you to specify your own library locations. -# -Installs epanet_gcc_ and runepanet_.sh -# in /bin, where defaults to ~ (and can be set -# below to something different - see "Install directories") -# -Installs libepanet_gcc_.so in /lib -# -Installs epanet2.h in /include. This is the required -# header file for the EPANET programmer's toolkit, and thus -# /include should be on your CPP include search path -# for subsequent use of the toolkit and linking with the -# library libepanet_gcc_.so -# make clean -# -Removes object and library files, returning the build directory -# to its pristine state. - -# You may wish to change the install path 'prefix', -# or the compiler flags, but these defaults should be fine. - -SHELL = /bin/sh - -# Target filenames -# svnname.sh constructs a name: -# where is the atomic revision number of the svn repo. -epanetsvnpath = ../../.. -epanetrootname := $(shell ../svnname.sh $(epanetsvnpath) "" epanet_gcc_ "") -libname := lib$(epanetrootname).so -exename := $(epanetrootname) -# Shell wrapper -runcmdtemplate = runepanet.sh.template -runcmdname = $(shell ../svnname.sh $(epanetsvnpath) "" runepanet_ .sh) -# Location of EPANET toolkit includes -epanetincludedir = ../../include -# Search path for sources -epanetsrcdir = ../../src -VPATH = $(epanetsrcdir):$(epanetincludedir) - -# Install directories -prefix = ~ -exec_prefix = $(prefix) -libdir = $(exec_prefix)/lib -bindir = $(exec_prefix)/bin -includedir = $(prefix)/include -datarootdir = $(prefix)/share -docdir = $(datarootdir)/doc/epanet - -# Compiler and flags -CC = gcc -CFLAGS = -g -O3 -fPIC -CPPFLAGS = -I $(epanetincludedir) -LDFLAGS = -L . -W1,-rpath,$(libdir) -lm - -# Installer -INSTALL = install -INSTALL_PROGRAM = $(INSTALL) -INSTALL_DATA = $(INSTALL) -m 644 - -# Files for the shared object library -epanet_objs=hash.o hydraul.o inpfile.o input1.o input2.o \ - input3.o mempool.o output.o quality.o report.o \ - rules.o smatrix.o -# Epanet header files -epanet_heads=enumstxt.h funcs.h hash.h mempool.h text.h toolkit.h types.h vars.h -# Epanet main program -epanet_main=epanet -# Epanet main program header files -epanet_main_heads=epanet2.h - -.PHONY: all -all: $(libname) $(exename) - -$(libname): $(epanet_objs) - $(CC) $(CFLAGS) $(CPPFLAGS) -D SOL -c $(epanetsrcdir)/$(epanet_main).c - $(CC) $(CFLAGS) $(LDFLAGS) -shared -o $@ $(epanet_main).o $^ - -$(exename): $(libname) $(epanet_main_heads) - $(CC) $(CFLAGS) $(CPPFLAGS) -D CLE -c $(epanetsrcdir)/$(epanet_main).c - $(CC) $(CFLAGS) -o $@ $(epanet_main).o -l$(epanetrootname) $(LDFLAGS) - -$(epanet_objs): $(epanet_heads) - -.PHONY: install -install: - cat $(runcmdtemplate) | sed 's|libdir|$(libdir)|' \ - | sed 's|exename|$(bindir)/$(exename)|' \ - > $(runcmdname) - $(INSTALL_PROGRAM) -D $(exename) $(bindir)/$(exename) - $(INSTALL_PROGRAM) -D $(libname) $(libdir)/$(libname) - $(INSTALL_DATA) -D $(epanetincludedir)/epanet2.h $(includedir)/epanet2.h - $(INSTALL_PROGRAM) -D $(runcmdname) $(bindir)/$(runcmdname) - -.PHONY: uninstall -uninstall: - -.PHONY: check -check: - -.PHONY: clean -clean: - -/bin/rm *.o $(libname) $(exename) $(runcmdname) diff --git a/build/Linux/runepanet.sh.template b/build/Linux/runepanet.sh.template deleted file mode 100755 index 55ae0d3..0000000 --- a/build/Linux/runepanet.sh.template +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh -export PATH=libdir:$PATH -export LD_LIBRARY_PATH=libdir:$LD_LIBRARY_PATH -exec exename "$@" diff --git a/build/MSVC/epanet-dll/epanet-dll.sln b/build/MSVC/epanet-dll/epanet-dll.sln deleted file mode 100755 index ef8b365..0000000 --- a/build/MSVC/epanet-dll/epanet-dll.sln +++ /dev/null @@ -1,20 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 10.00 -# Visual Studio 2008 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "epanet-dll", "epanet-dll.vcproj", "{3646F046-B542-4712-929F-E6A4F0C1F835}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Release|Win32 = Release|Win32 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {3646F046-B542-4712-929F-E6A4F0C1F835}.Debug|Win32.ActiveCfg = Debug|Win32 - {3646F046-B542-4712-929F-E6A4F0C1F835}.Debug|Win32.Build.0 = Debug|Win32 - {3646F046-B542-4712-929F-E6A4F0C1F835}.Release|Win32.ActiveCfg = Release|Win32 - {3646F046-B542-4712-929F-E6A4F0C1F835}.Release|Win32.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/build/MSVC/epanet-dll/epanet-dll.vcproj b/build/MSVC/epanet-dll/epanet-dll.vcproj deleted file mode 100755 index 12dbb3f..0000000 --- a/build/MSVC/epanet-dll/epanet-dll.vcproj +++ /dev/null @@ -1,282 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/build/MSVC/epanet-exe/epanet-exe.sln b/build/MSVC/epanet-exe/epanet-exe.sln deleted file mode 100755 index 76b8fbc..0000000 --- a/build/MSVC/epanet-exe/epanet-exe.sln +++ /dev/null @@ -1,20 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 10.00 -# Visual Studio 2008 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "epanet-exe", "epanet-exe.vcproj", "{67C47E99-8BA3-4597-AFA8-566C26FF9C78}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Release|Win32 = Release|Win32 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {67C47E99-8BA3-4597-AFA8-566C26FF9C78}.Debug|Win32.ActiveCfg = Debug|Win32 - {67C47E99-8BA3-4597-AFA8-566C26FF9C78}.Debug|Win32.Build.0 = Debug|Win32 - {67C47E99-8BA3-4597-AFA8-566C26FF9C78}.Release|Win32.ActiveCfg = Release|Win32 - {67C47E99-8BA3-4597-AFA8-566C26FF9C78}.Release|Win32.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/build/MSVC/epanet-exe/epanet-exe.vcproj b/build/MSVC/epanet-exe/epanet-exe.vcproj deleted file mode 100755 index 7a6d512..0000000 --- a/build/MSVC/epanet-exe/epanet-exe.vcproj +++ /dev/null @@ -1,284 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/build/MSVC/epanet2.mak b/build/MSVC/epanet2.mak deleted file mode 100755 index a5c37ac..0000000 --- a/build/MSVC/epanet2.mak +++ /dev/null @@ -1,213 +0,0 @@ -# Microsoft Developer Studio Generated NMAKE File, Based on epanet2.dsp -!IF "$(CFG)" == "" -CFG=epanet2 - Win32 Release -!MESSAGE No configuration specified. Defaulting to epanet2 - Win32 Release. -!ENDIF - -!IF "$(CFG)" != "epanet2 - Win32 Release" -!MESSAGE Invalid configuration "$(CFG)" specified. -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "epanet2.mak" CFG="epanet2 - Win32 Release" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "epanet2 - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE -!ERROR An invalid configuration is specified. -!ENDIF - -!IF "$(OS)" == "Windows_NT" -NULL= -!ELSE -NULL=nul -!ENDIF - -OUTDIR=.\Release -INTDIR=.\Release -# Begin Custom Macros -OutDir=.\Release -# End Custom Macros - -ALL : "$(OUTDIR)\epanet2.dll" - - -CLEAN : - -@erase "$(INTDIR)\epanet.obj" - -@erase "$(INTDIR)\hash.obj" - -@erase "$(INTDIR)\hydraul.obj" - -@erase "$(INTDIR)\inpfile.obj" - -@erase "$(INTDIR)\input1.obj" - -@erase "$(INTDIR)\input2.obj" - -@erase "$(INTDIR)\input3.obj" - -@erase "$(INTDIR)\mempool.obj" - -@erase "$(INTDIR)\output.obj" - -@erase "$(INTDIR)\quality.obj" - -@erase "$(INTDIR)\report.obj" - -@erase "$(INTDIR)\rules.obj" - -@erase "$(INTDIR)\smatrix.obj" - -@erase "$(INTDIR)\vc60.idb" - -@erase "$(OUTDIR)\epanet2.dll" - -@erase "$(OUTDIR)\epanet2.exp" - -@erase "$(OUTDIR)\epanet2.lib" - -"$(OUTDIR)" : - if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)" - -CPP=cl.exe -CPP_PROJ=/nologo /MT /W4 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "EPANET2_EXPORTS" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c - -.c{$(INTDIR)}.obj:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.cpp{$(INTDIR)}.obj:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.cxx{$(INTDIR)}.obj:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.c{$(INTDIR)}.sbr:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.cpp{$(INTDIR)}.sbr:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -.cxx{$(INTDIR)}.sbr:: - $(CPP) @<< - $(CPP_PROJ) $< -<< - -MTL=midl.exe -MTL_PROJ=/nologo /D "NDEBUG" /mktyplib203 /win32 -RSC=rc.exe -BSC32=bscmake.exe -BSC32_FLAGS=/nologo /o"$(OUTDIR)\epanet2.bsc" -BSC32_SBRS= \ - -LINK32=link.exe -LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /incremental:no /pdb:"$(OUTDIR)\epanet2.pdb" /machine:I386 /def:"..\epanet2.def" /out:"$(OUTDIR)\epanet2.dll" /implib:"$(OUTDIR)\epanet2.lib" -DEF_FILE= \ - "..\epanet2.def" -LINK32_OBJS= \ - "$(INTDIR)\epanet.obj" \ - "$(INTDIR)\hash.obj" \ - "$(INTDIR)\hydraul.obj" \ - "$(INTDIR)\inpfile.obj" \ - "$(INTDIR)\input1.obj" \ - "$(INTDIR)\input2.obj" \ - "$(INTDIR)\input3.obj" \ - "$(INTDIR)\mempool.obj" \ - "$(INTDIR)\output.obj" \ - "$(INTDIR)\quality.obj" \ - "$(INTDIR)\report.obj" \ - "$(INTDIR)\rules.obj" \ - "$(INTDIR)\smatrix.obj" - -"$(OUTDIR)\epanet2.dll" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS) - $(LINK32) @<< - $(LINK32_FLAGS) $(LINK32_OBJS) -<< - - -!IF "$(NO_EXTERNAL_DEPS)" != "1" -!IF EXISTS("epanet2.dep") -!INCLUDE "epanet2.dep" -!ELSE -!MESSAGE Warning: cannot find "epanet2.dep" -!ENDIF -!ENDIF - - -!IF "$(CFG)" == "epanet2 - Win32 Release" -SOURCE=..\epanet.c - -"$(INTDIR)\epanet.obj" : $(SOURCE) "$(INTDIR)" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -SOURCE=..\hash.c - -"$(INTDIR)\hash.obj" : $(SOURCE) "$(INTDIR)" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -SOURCE=..\hydraul.c - -"$(INTDIR)\hydraul.obj" : $(SOURCE) "$(INTDIR)" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -SOURCE=..\inpfile.c - -"$(INTDIR)\inpfile.obj" : $(SOURCE) "$(INTDIR)" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -SOURCE=..\input1.c - -"$(INTDIR)\input1.obj" : $(SOURCE) "$(INTDIR)" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -SOURCE=..\input2.c - -"$(INTDIR)\input2.obj" : $(SOURCE) "$(INTDIR)" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -SOURCE=..\input3.c - -"$(INTDIR)\input3.obj" : $(SOURCE) "$(INTDIR)" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -SOURCE=..\mempool.c - -"$(INTDIR)\mempool.obj" : $(SOURCE) "$(INTDIR)" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -SOURCE=..\output.c - -"$(INTDIR)\output.obj" : $(SOURCE) "$(INTDIR)" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -SOURCE=..\quality.c - -"$(INTDIR)\quality.obj" : $(SOURCE) "$(INTDIR)" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -SOURCE=..\report.c - -"$(INTDIR)\report.obj" : $(SOURCE) "$(INTDIR)" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -SOURCE=..\rules.c - -"$(INTDIR)\rules.obj" : $(SOURCE) "$(INTDIR)" - $(CPP) $(CPP_PROJ) $(SOURCE) - - -SOURCE=..\smatrix.c - -"$(INTDIR)\smatrix.obj" : $(SOURCE) "$(INTDIR)" - $(CPP) $(CPP_PROJ) $(SOURCE) - - - -!ENDIF - diff --git a/build/MSVS/LemonTigerJ.sln b/build/MSVS/LemonTigerJ.sln new file mode 100644 index 0000000..f61001a --- /dev/null +++ b/build/MSVS/LemonTigerJ.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2012 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "LemonTigerJ", "LemonTigerJ.vcxproj", "{4B66D9F0-407B-4995-B625-1CA1B72662C6}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {4B66D9F0-407B-4995-B625-1CA1B72662C6}.Debug|Win32.ActiveCfg = Debug|Win32 + {4B66D9F0-407B-4995-B625-1CA1B72662C6}.Debug|Win32.Build.0 = Debug|Win32 + {4B66D9F0-407B-4995-B625-1CA1B72662C6}.Release|Win32.ActiveCfg = Release|Win32 + {4B66D9F0-407B-4995-B625-1CA1B72662C6}.Release|Win32.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/build/MSVS/LemonTigerJ.vcxproj b/build/MSVS/LemonTigerJ.vcxproj new file mode 100644 index 0000000..7ffa87b --- /dev/null +++ b/build/MSVS/LemonTigerJ.vcxproj @@ -0,0 +1,105 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {4B66D9F0-407B-4995-B625-1CA1B72662C6} + Win32Proj + + + + DynamicLibrary + true + v110 + + + Application + false + v110 + + + + + + + + + + + + + true + + + true + + + + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions);_CRT_SECURE_NO_WARNINGS + MultiThreadedDebugDLL + Level3 + ProgramDatabase + Disabled + .\include + + + MachineX86 + true + Console + + + + + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + MultiThreadedDLL + Level3 + ProgramDatabase + + + MachineX86 + true + Console + true + true + + + + + + \ No newline at end of file diff --git a/build/MingW/CreateMSLib.bat.template b/build/MingW/CreateMSLib.bat.template deleted file mode 100755 index 3f8c06b..0000000 --- a/build/MingW/CreateMSLib.bat.template +++ /dev/null @@ -1 +0,0 @@ -"MSVClibexe" /machine:i386 /def:defname diff --git a/build/MingW/Makefile b/build/MingW/Makefile deleted file mode 100755 index 55d1ae1..0000000 --- a/build/MingW/Makefile +++ /dev/null @@ -1,161 +0,0 @@ -# MinGW Makefile for EPANET - -# Note: This makefile usese MinGW to produce native windows -# libraries and executables. The dll/import library, and -# executable files will have the same names as those produced -# using other Windows compilers, e.g. MSVC++. So be aware that -# there is no way to reliably distinguish between these two compiler -# sources based on output filenames. - -# This will build EPANET as a native windows DLL and import -# library (epanet2.dll/libepanet2.dll.a) using MinGW/gcc, -# and a standalone executable (epanet2.exe). -# This makefile also creates a windows batch file -# (see MScmdname below) that can be run to produce an import -# library for linking the DLL using MSVC. -# This makefile assumes a minimum -# MinGW installation, and uses the MinGW gcc compiler from -# the MinGW install directory. -# The current release of MinGW can be obtained from -# http://www.mingw.org/wiki/Getting_Started -- the easiest -# approach is to download the latest MingW installer and -# accept all of the defaults. - -# The following targets are defined (for execution in -# the build directory): -# make -# -Builds epanet2.dll, epanet2.def, libepanet2.dll.a, -# epanet2.exe -# make install -# -Creates scripts runepanet2.sh and CreateEpanet2Lib.bat that -# execute epanet2.exe, and MSVC 'lib' (to create an MSVC -# import library). The runepanet2.sh wrapper simply exports -# environment variables so that the DLL is found at runtime, -# allowing you to specify your own locations for installing -# the DLL. -# -Installs epanet2.dll, epanet2.exe, and runepanet2.sh -# in /bin, where defaults to ~ (and can be set -# below to something different - see "Install directories") -# -Installs libepanet2.dll.a (import library), epanet2.def, -# and CreateEpanet2Lib.bat in /lib -# -Installs epanet2.h in /include. This is the required -# header file for the EPANET programmer's toolkit, and thus -# /include should be on your CPP include search path -# for subsequent use of the toolkit and linking with the import -# library libepanet2.dll.a or epanet2.lib. -# make clean -# -Removes object and library files, returning the build directory -# to its pristine state. - -SHELL = /bin/sh - -# C H A N G E H E R E A S N E E D E D -# Change (as needed) the MinGW install directory below. -# Change (as needed) the location off the MS LIB tool. -# You may also wish to change the install path 'prefix', -# or the compiler flags, but these defaults should be fine. - -# MinGW top level install directory, accessible from build environment -MinGWdir = /cygdrive/c/MinGW -# Microsoft lib tool directory (for creating an MS import library) -MSVClibexe = c:\\Program Files\\Microsoft Visual Studio 9.0\\VC\\bin\\lib - -# Target filenames -# svnname.sh constructs a name: -# where is the atomic revision number of the svn repo. -epanetrootname := epanet2 -dllname := $(epanetrootname).dll -defname := $(epanetrootname).def -implibname = lib$(dllname).a -exename := $(epanetrootname) -# Shell wrapper -runcmdtemplate = runepanet.sh.template -runcmdname = runepanet2.sh -# MSVC import lib batch file -MScmdtemplate = CreateMSLib.bat.template -MScmdname = CreateEpanet2Lib.bat -# Location of EPANET toolkit includes -epanetincludedir = ../../include -# Search path for sources -epanetsrcdir = ../../src -VPATH = $(epanetsrcdir):$(epanetincludedir) - -# Install directories -winprefix = $(shell cygpath -w $$HOME) -prefix = ~ -exec_prefix = $(prefix) -srcdir = . -libdir = $(exec_prefix)/lib -winlibdir = "$(winprefix)\lib" -bindir = $(exec_prefix)/bin -includedir = $(prefix)/include -winincludedir = "$(winprefix)\include" -datarootdir = $(prefix)/share -docdir = $(datarootdir)/doc/epanet - -# Compiler and flags -# MinGW gcc -CC = $(MinGWdir)/bin/gcc -dlltool = $(MinGWdir)/bin/dlltool -CFLAGS = -g -O3 -CPPFLAGS = -I $(srcdir) -I $(epanetincludedir) -LDFLAGS = -L . -W1,-rpath,$(libdir) -lm - -# Installer -INSTALL = install -INSTALL_PROGRAM = $(INSTALL) -INSTALL_DATA = $(INSTALL) -m 644 - -# EPANET object files -epanet_objs=hash.o hydraul.o inpfile.o input1.o input2.o \ - input3.o mempool.o output.o quality.o report.o \ - rules.o smatrix.o -# Epanet header files -epanet_heads=enumstxt.h funcs.h hash.h mempool.h text.h toolkit.h types.h vars.h -epanet_main_heads=epanet2.h -# Epanet main program -epanet_main=epanet - -.PHONY: all -all: $(dllname) $(exename) - -$(dllname): $(epanet_objs) -# $(dlltool) -z $(defname) --dllname $(dllname) --output-lib $(implibname) $^ -# $(CC) $(CFLAGS) $(LDFLAGS) -shared -o $@ $(defname) $^ - $(CC) $(CFLAGS) $(CPPFLAGS) -D DLL -c $(epanetsrcdir)/epanet.c - $(CC) $(CFLAGS) $(LDFLAGS) -shared -o $@ epanet.o $^ -Wl,--output-def,$(defname) - $(CC) $(CFLAGS) $(LDFLAGS) -shared -o $@ epanet.o $^ -Wl,--kill-at - $(dlltool) -d $(defname) --dllname $@ --output-lib $(implibname) --kill-at - -$(exename): $(epanet_objs) - $(CC) $(CFLAGS) $(CPPFLAGS) -D CLE -c $(epanetsrcdir)/$(epanet_main).c - $(CC) $(CFLAGS) -o $@ $(epanet_main).o $^ $(LDFLAGS) - -$(epanet_objs): $(epanet_heads) - -.PHONY: install -install: - cat $(runcmdtemplate) | sed 's|libdir|$(bindir)|' \ - | sed 's|exename|$(bindir)/$(exename)|' \ - > $(runcmdname) - cat $(MScmdtemplate) | sed 's|MSVClibexe|$(MSVClibexe)|' \ - | sed 's|defname|$(defname)|' \ - | sed 's|libdir|$(libdir)|' \ - > $(MScmdname) - $(INSTALL_PROGRAM) -D $(exename) $(bindir)/$(exename) - $(INSTALL_PROGRAM) -D $(dllname) $(bindir)/$(dllname) - $(INSTALL_PROGRAM) -D $(defname) $(libdir)/$(defname) - $(INSTALL_PROGRAM) -D $(implibname) $(libdir)/$(implibname) - $(INSTALL_DATA) -D $(epanetincludedir)/epanet2.h $(includedir)/epanet2.h - $(INSTALL_PROGRAM) -D $(runcmdname) $(bindir)/$(runcmdname) - $(INSTALL_PROGRAM) -D $(MScmdname) $(libdir)/$(MScmdname) - -.PHONY: uninstall -uninstall: - -.PHONY: check -check: - -.PHONY: clean -clean: - -/bin/rm *.o $(dllname) $(defname) $(implibname) $(exename).exe $(runcmdname) $(MScmdname) diff --git a/build/MingW/Makefile_Rev b/build/MingW/Makefile_Rev deleted file mode 100755 index c88de77..0000000 --- a/build/MingW/Makefile_Rev +++ /dev/null @@ -1,159 +0,0 @@ -# Cygwin/MinGW Makefile for EPANET - -# This will build EPANET as a native windows DLL and import -# library (epanet_gcc_.dll/libepanet_gcc_.dll.a) under Cygwin/MinGW, -# and a standalone executable (epanet_gcc_.exe). -# is the atomic revision number of the EPANET SVN repo, -# so the results of each build can be unambiguously tracked to a repo Rev. -# This makefile also creates a windows batch file -# (see MScmdname below) that will produce an import -# library for linking the DLL using MSVC. -# This makefile assumes a Cygwin environment with minimal -# MinGW installation, and uses the MinGW gcc compiler from -# the MinGW install directory. -# The current release of MinGW can be obtained from -# http://www.mingw.org/wiki/Getting_Started -- the easiest -# approach is to download the latest MingW installer and -# accept all of the defaults. -# The current release of the Cygwin environment can be -# obtained from http://www.cygwin.com - -# The following targets are defined (for execution in -# the build directory under the Cygwin environment): -# make -# -Builds epanet_gcc_.dll, epanet_gcc_.def, libepanet_gcc_.dll.a, -# epanet_gcc_.exe -# make install -# -Creates shell wrappers runepanet_.sh and CreateMSLib_.bat that -# execute epanet_gcc_.exe, and MSVC 'lib' (to create an MSVC -# import library). The runepanet_.sh wrapper simply exports -# environment variables so that the DLL is found at runtime, -# allowing you to specify your own locations for installing -# the DLL. -# -Installs epanet_gcc_.dll, epanet_gcc_.exe, and runepanet_.sh -# in /bin, where defaults to ~ (and can be set -# below to something different - see "Install directories") -# -Installs libepanet_gcc_.dll.a (import library), epanet_gcc_.def, -# and CreateMSLib-.bat in /lib -# -Installs epanet2.h in /include. This is the required -# header file for the EPANET programmer's toolkit, and thus -# /include should be on your CPP include search path -# for subsequent use of the toolkit and linking with the import -# library libepanet_gcc_.dll.a. -# make clean -# -Removes object and library files, returning the build directory -# to its pristine state. - -SHELL = /bin/sh - -# C H A N G E H E R E A S N E E D E D -# Change (as needed) the MinGW install directory below. -# Change (as needed) the location off the MS LIB tool. -# You may also wish to change the install path 'prefix', -# or the compiler flags, but these defaults should be fine. - -# MinGW top level install directory, accessible from build environment -MinGWdir = /cygdrive/c/MinGW -# Microsoft lib tool directory (for creating an MS import library) -MSVClibexe = c:\\Program Files\\Microsoft Visual Studio 9.0\\VC\\bin\\lib - -# Target filenames -# svnname.sh constructs a name: -# where is the atomic revision number of the svn repo. -epanetsvnpath = ../../.. -epanetrootname := $(shell ../svnname.sh $(epanetsvnpath) "" epanet_gcc_ "") -dllname := $(epanetrootname).dll -defname := $(epanetrootname).def -implibname = lib$(dllname).a -exename := $(epanetrootname) -# Shell wrapper -runcmdtemplate = runepanet.sh.template -runcmdname = $(shell ../svnname.sh $(epanetsvnpath) "" runepanet_ .sh) -# MSVC import lib batch file -MScmdtemplate = CreateMSLib.bat.template -MScmdname = $(shell ../svnname.sh $(epanetsvnpath) "" CreateEpanetLib_ .bat) -# Location of EPANET toolkit includes -epanetincludedir = ../../include -# Search path for sources -epanetsrcdir = ../../src -VPATH = $(epanetsrcdir):$(epanetincludedir) - -# Install directories -winprefix = $(shell cygpath -w $$HOME) -prefix = ~ -exec_prefix = $(prefix) -srcdir = . -libdir = $(exec_prefix)/lib -winlibdir = "$(winprefix)\lib" -bindir = $(exec_prefix)/bin -includedir = $(prefix)/include -winincludedir = "$(winprefix)\include" -datarootdir = $(prefix)/share -docdir = $(datarootdir)/doc/epanet - -# Compiler and flags -# MinGW gcc -CC = $(MinGWdir)/bin/gcc -dlltool = $(MinGWdir)/bin/dlltool -CFLAGS = -g -O3 -CPPFLAGS = -I $(srcdir) -I $(epanetincludedir) -LDFLAGS = -L . -W1,-rpath,$(libdir) -lm - -# Installer -INSTALL = install -INSTALL_PROGRAM = $(INSTALL) -INSTALL_DATA = $(INSTALL) -m 644 - -# EPANET object files -epanet_objs=hash.o hydraul.o inpfile.o input1.o input2.o \ - input3.o mempool.o output.o quality.o report.o \ - rules.o smatrix.o -# Epanet header files -epanet_heads=enumstxt.h funcs.h hash.h mempool.h text.h toolkit.h types.h vars.h -epanet_main_heads=epanet2.h -# Epanet main program -epanet_main=epanet - -.PHONY: all -all: $(dllname) $(exename) - -$(dllname): $(epanet_objs) -# $(dlltool) -z $(defname) --dllname $(dllname) --output-lib $(implibname) $^ -# $(CC) $(CFLAGS) $(LDFLAGS) -shared -o $@ $(defname) $^ - $(CC) $(CFLAGS) $(CPPFLAGS) -D DLL -c $(epanetsrcdir)/epanet.c - $(CC) $(CFLAGS) $(LDFLAGS) -shared -o $@ epanet.o $^ -Wl,--output-def,$(defname) - $(CC) $(CFLAGS) $(LDFLAGS) -shared -o $@ epanet.o $^ -Wl,--kill-at - $(dlltool) -d $(defname) --dllname $@ --output-lib $(implibname) --kill-at - -$(exename): $(epanet_objs) - $(CC) $(CFLAGS) $(CPPFLAGS) -D CLE -c $(epanetsrcdir)/$(epanet_main).c - $(CC) $(CFLAGS) -o $@ $(epanet_main).o $^ $(LDFLAGS) - -$(epanet_objs): $(epanet_heads) - -.PHONY: install -install: - cat $(runcmdtemplate) | sed 's|libdir|$(bindir)|' \ - | sed 's|exename|$(bindir)/$(exename)|' \ - > $(runcmdname) - cat $(MScmdtemplate) | sed 's|MSVClibexe|$(MSVClibexe)|' \ - | sed 's|defname|$(defname)|' \ - | sed 's|libdir|$(libdir)|' \ - > $(MScmdname) - $(INSTALL_PROGRAM) -D $(exename) $(bindir)/$(exename) - $(INSTALL_PROGRAM) -D $(dllname) $(bindir)/$(dllname) - $(INSTALL_PROGRAM) -D $(defname) $(libdir)/$(defname) - $(INSTALL_PROGRAM) -D $(implibname) $(libdir)/$(implibname) - $(INSTALL_DATA) -D $(epanetincludedir)/epanet2.h $(includedir)/epanet2.h - $(INSTALL_PROGRAM) -D $(runcmdname) $(bindir)/$(runcmdname) - $(INSTALL_PROGRAM) -D $(MScmdname) $(libdir)/$(MScmdname) - -.PHONY: uninstall -uninstall: - -.PHONY: check -check: - -.PHONY: clean -clean: - -/bin/rm *.o $(dllname) $(defname) $(implibname) $(exename).exe $(runcmdname) $(MScmdname) diff --git a/build/MingW/runepanet.sh.template b/build/MingW/runepanet.sh.template deleted file mode 100755 index 55ae0d3..0000000 --- a/build/MingW/runepanet.sh.template +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh -export PATH=libdir:$PATH -export LD_LIBRARY_PATH=libdir:$LD_LIBRARY_PATH -exec exename "$@" diff --git a/build/Xcode/epanet/epanet.xcodeproj/project.pbxproj b/build/Xcode/epanet/epanet.xcodeproj/project.pbxproj index 3ef27ef..30d1018 100644 --- a/build/Xcode/epanet/epanet.xcodeproj/project.pbxproj +++ b/build/Xcode/epanet/epanet.xcodeproj/project.pbxproj @@ -25,7 +25,6 @@ 22322F941068369500641384 /* rules.c in Sources */ = {isa = PBXBuildFile; fileRef = 22322F7F1068369500641384 /* rules.c */; }; 22322F951068369500641384 /* smatrix.c in Sources */ = {isa = PBXBuildFile; fileRef = 22322F801068369500641384 /* smatrix.c */; }; 22322F961068369500641384 /* text.h in Headers */ = {isa = PBXBuildFile; fileRef = 22322F811068369500641384 /* text.h */; }; - 22322F971068369500641384 /* toolkit.h in Headers */ = {isa = PBXBuildFile; fileRef = 22322F821068369500641384 /* toolkit.h */; }; 22322F981068369500641384 /* types.h in Headers */ = {isa = PBXBuildFile; fileRef = 22322F831068369500641384 /* types.h */; }; 22322F991068369500641384 /* vars.h in Headers */ = {isa = PBXBuildFile; fileRef = 22322F841068369500641384 /* vars.h */; }; 22322F9A1068369500641384 /* epanet.c in Sources */ = {isa = PBXBuildFile; fileRef = 22322F711068369500641384 /* epanet.c */; }; @@ -70,7 +69,7 @@ /* Begin PBXFileReference section */ 22322F66106833BB00641384 /* runepanet */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = runepanet; sourceTree = BUILT_PRODUCTS_DIR; }; 22322F701068369500641384 /* enumstxt.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = enumstxt.h; path = ../../../src/enumstxt.h; sourceTree = SOURCE_ROOT; }; - 22322F711068369500641384 /* epanet.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = epanet.c; path = ../../../src/epanet.c; sourceTree = SOURCE_ROOT; }; + 22322F711068369500641384 /* epanet.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; lineEnding = 2; name = epanet.c; path = ../../../src/epanet.c; sourceTree = SOURCE_ROOT; xcLanguageSpecificationIdentifier = xcode.lang.c; }; 22322F721068369500641384 /* funcs.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = funcs.h; path = ../../../src/funcs.h; sourceTree = SOURCE_ROOT; }; 22322F731068369500641384 /* hash.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = hash.c; path = ../../../src/hash.c; sourceTree = SOURCE_ROOT; }; 22322F741068369500641384 /* hash.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = hash.h; path = ../../../src/hash.h; sourceTree = SOURCE_ROOT; }; @@ -82,15 +81,14 @@ 22322F7A1068369500641384 /* mempool.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = mempool.c; path = ../../../src/mempool.c; sourceTree = SOURCE_ROOT; }; 22322F7B1068369500641384 /* mempool.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = mempool.h; path = ../../../src/mempool.h; sourceTree = SOURCE_ROOT; }; 22322F7C1068369500641384 /* output.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = output.c; path = ../../../src/output.c; sourceTree = SOURCE_ROOT; }; - 22322F7D1068369500641384 /* quality.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = quality.c; path = ../../../src/quality.c; sourceTree = SOURCE_ROOT; }; + 22322F7D1068369500641384 /* quality.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; lineEnding = 2; name = quality.c; path = ../../../src/quality.c; sourceTree = SOURCE_ROOT; xcLanguageSpecificationIdentifier = xcode.lang.c; }; 22322F7E1068369500641384 /* report.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = report.c; path = ../../../src/report.c; sourceTree = SOURCE_ROOT; }; 22322F7F1068369500641384 /* rules.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = rules.c; path = ../../../src/rules.c; sourceTree = SOURCE_ROOT; }; 22322F801068369500641384 /* smatrix.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = smatrix.c; path = ../../../src/smatrix.c; sourceTree = SOURCE_ROOT; }; 22322F811068369500641384 /* text.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = text.h; path = ../../../src/text.h; sourceTree = SOURCE_ROOT; }; - 22322F821068369500641384 /* toolkit.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = toolkit.h; path = ../../../src/toolkit.h; sourceTree = SOURCE_ROOT; }; 22322F831068369500641384 /* types.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = types.h; path = ../../../src/types.h; sourceTree = SOURCE_ROOT; }; 22322F841068369500641384 /* vars.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = vars.h; path = ../../../src/vars.h; sourceTree = SOURCE_ROOT; }; - 22322FA9106836B000641384 /* epanet2.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = epanet2.h; path = ../../../include/epanet2.h; sourceTree = SOURCE_ROOT; }; + 22322FA9106836B000641384 /* epanet2.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 2; name = epanet2.h; path = ../../../include/epanet2.h; sourceTree = SOURCE_ROOT; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; }; 2255753B17551217009946B1 /* libepanet-static.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libepanet-static.a"; sourceTree = BUILT_PRODUCTS_DIR; }; D2AAC0630554660B00DB518D /* libepanet.dylib */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.dylib"; includeInIndex = 0; path = libepanet.dylib; sourceTree = BUILT_PRODUCTS_DIR; }; /* End PBXFileReference section */ @@ -133,12 +131,12 @@ 08FB7795FE84155DC02AAC07 /* Source */ = { isa = PBXGroup; children = ( - 22322F701068369500641384 /* enumstxt.h */, 22322F711068369500641384 /* epanet.c */, + 22322F751068369500641384 /* hydraul.c */, + 22322F701068369500641384 /* enumstxt.h */, 22322F721068369500641384 /* funcs.h */, 22322F731068369500641384 /* hash.c */, 22322F741068369500641384 /* hash.h */, - 22322F751068369500641384 /* hydraul.c */, 22322F761068369500641384 /* inpfile.c */, 22322F771068369500641384 /* input1.c */, 22322F781068369500641384 /* input2.c */, @@ -151,7 +149,6 @@ 22322F7F1068369500641384 /* rules.c */, 22322F801068369500641384 /* smatrix.c */, 22322F811068369500641384 /* text.h */, - 22322F821068369500641384 /* toolkit.h */, 22322F831068369500641384 /* types.h */, 22322F841068369500641384 /* vars.h */, ); @@ -196,7 +193,6 @@ 22322F891068369500641384 /* hash.h in Headers */, 22322F901068369500641384 /* mempool.h in Headers */, 22322F961068369500641384 /* text.h in Headers */, - 22322F971068369500641384 /* toolkit.h in Headers */, 22322F981068369500641384 /* types.h in Headers */, 22322F991068369500641384 /* vars.h in Headers */, ); @@ -473,10 +469,7 @@ EXECUTABLE_PREFIX = lib; GCC_DYNAMIC_NO_PIC = NO; GCC_ENABLE_OBJC_EXCEPTIONS = YES; - GCC_PREPROCESSOR_DEFINITIONS = ( - "DEBUG=1", - "$(inherited)", - ); + GCC_PREPROCESSOR_DEFINITIONS = "EN_API_FLOAT_TYPE=double"; GCC_SYMBOLS_PRIVATE_EXTERN = NO; GCC_WARN_64_TO_32_BIT_CONVERSION = YES; MACOSX_DEPLOYMENT_TARGET = 10.8; @@ -497,6 +490,7 @@ DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; EXECUTABLE_PREFIX = lib; GCC_ENABLE_OBJC_EXCEPTIONS = YES; + GCC_PREPROCESSOR_DEFINITIONS = "EN_API_FLOAT_TYPE=double"; GCC_WARN_64_TO_32_BIT_CONVERSION = YES; MACOSX_DEPLOYMENT_TARGET = 10.8; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -541,6 +535,7 @@ 2255753D17551217009946B1 /* Release */, ); defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; }; /* End XCConfigurationList section */ }; diff --git a/build/Xcode/epanet/epanet.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/build/Xcode/epanet/epanet.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..052c6dc --- /dev/null +++ b/build/Xcode/epanet/epanet.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/build/svnname.sh b/build/svnname.sh deleted file mode 100755 index adc579f..0000000 --- a/build/svnname.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash -SVNREV=`svn info "$1" | grep Revision | awk -F": " '{print $2}'` -echo $2$3${SVNREV}$4 diff --git a/doc/LICENSE.txt b/doc/LICENSE.txt deleted file mode 100644 index e89e95d..0000000 --- a/doc/LICENSE.txt +++ /dev/null @@ -1,9 +0,0 @@ -The EPANET software was developed by Lewis Rossman (US-EPA). - -This public-domain software developed by the U.S. EPA, -National Risk Management Research Laboratory in Cincinnati, Ohio. -Although these programs have been used by the U.S. EPA, no warranty, -expressed or implied, is made by the U.S. EPA as to the accuracy and -functioning of the programs and related program material, nor shall the -fact of distribution constitute any such warranty, and no responsibility -is assumed by the U.S. EPA in connection therewith. diff --git a/doc/Readme.txt b/doc/Readme.txt deleted file mode 100755 index 6a43140..0000000 --- a/doc/Readme.txt +++ /dev/null @@ -1,54 +0,0 @@ -Contents of EPANET2.ZIP -======================= -This archive contains the source code for the EPANET 2 -network hydraulic and water quality solver. The solver -provides functions for simulating the extended period -hydraulic and water quality behavior of water distribution -system pipe networks. It is written in ANSI-compatible C -and can be compiled into either a Windows Dynamic Link -Library of functions or into a command-line executable. - -The archived code is set up for compilation as a DLL. -To compile it as a command line (or console) application -simply comment out the "#define DLL" macro statement at -the top of EPANET.C and un-comment the "#define CLE" macro. - -The DLL version of the solver (epanet2.dll) is used with -the EPANET 2 user interface executable (epanet2w.exe) to -form a complete Windows modeling package. It also serves -as the function library for the EPANET Programmer's Toolkit, -allowing developers to construct their own customized pipe -network analysis applications. - -The following C-code files are included in this archive: - EPANET.C -- main module providing supervisory control - INPUT1.C -- controls processing of input data - INPUT2.C -- reads data from input file - INPUT3.C -- parses individual lines of input data - INPFILE.C -- saves modified input data to a text file - RULES.C -- implements rule-based control of piping system - HYDRAUL.C -- computes extended period hydraulic behavior - QUALITY.C -- tracks transport & fate of water quality - OUTPUT.C -- handles transfer of data to and from binary files - REPORT.C -- handles reporting of results to text file - SMATRIX.C -- sparse matrix linear equation solver routines - MEMPOOL.C -- memory pool management routines - HASH.C -- hash table routines - -Also included are the following header files: - TOOLKIT.H -- function prototypes of exported DLL functions - FUNCS.H -- prototypes of all other functions - TYPES.H -- declaration of global constants and data structures - VARS.H -- declaration of global variables - HASH.H -- header file for hash table routines - MEMPOOL.H -- header file for memory pool routines - ENUMSTXT.H -- string constants for enumerated types - TEXT.H -- declaration of all other string constants - -The comments at the top of each file lists the date when the latest -update was made, and these updates can be located in the code by -searching for comments with the phrase "/*** Updated" or with the -release number (e.g., 2.00.12) in them. - -Other useful documentation that can be consulted includes the EPANET -Programmers Toolkit Help file and the EPANET Version 2 Users Manual. diff --git a/doc/changes.txt b/doc/changes.txt deleted file mode 100755 index 867837d..0000000 --- a/doc/changes.txt +++ /dev/null @@ -1,57 +0,0 @@ ------------------------ -Build 2.00.12 (2/25/08) ------------------------ - -Computational Engine Changes (epanet2.dll and epanet2d.exe): -=============================================================================== -CODE MODULES CHANGES -=============================================================================== -EPANET.C Temporary files are now written to the users's current working -INPUT1.C directory or to the designated Temporary Directory when running -VARS.H the Windows GUI, thus avoiding file access problems for users -FUNCS.H who do not have administrative privileges on their machine. -------------------------------------------------------------------------------- -EPANET.C The following tank parameters were made available for retrieval -TOOLKIT.H using the Toolkit's ENgetnodevalue function: tank diameter, -EPANET2.H minimum volume, index of the tank's volume curve, the initial, - minimum, and maximum water levels, the fraction of a 2-compart- - ment tank devoted to the mixing zone, and the tank's bulk - reaction rate coefficient. These same parameters (with the - exception of the volume curve) were made modifiable using the - ENsetnodevalue function, as was the choice of mixing model. - See the Toolkit Help file for details. -------------------------------------------------------------------------------- -EPANET.C A new Toolkit function, ENaddpattern, was added that allows -TOOLKIT.C programmers to add a new time pattern to the network in any -EPANET2.H custom code that they write. -------------------------------------------------------------------------------- -HYDRAUL.C A DAMPLIMIT parameter was added to control at what point during -INPUT1.C the hydraulic solution iterations status checks on PRVs and PSVs -INPUT3.C begin and subsequent flow changes are dampened. -REPORT.C -VARS.H -TEXT.H -------------------------------------------------------------------------------- -HYDRAUL.C Demands for tanks (net inflows/outflows) were not always being - set to zero when the tank was full or empty which was causing - problems in the water quality routing solutions. -------------------------------------------------------------------------------- -QUALITY.C The water quality functions for all of the tank mixing models - were modified so as to produce more robust results for cases - where there is a significant amount of volume exchange over a - water quality time step. -------------------------------------------------------------------------------- -EPANET.C A problem with the system not recognizing that water quality -QUALITY.C reactions could begin after some initial period of time when -VARS.H the Toolkit was used to modify reaction rate coefficients was - fixed. -------------------------------------------------------------------------------- -INPFILE.C A problem with extraneous lines being written to the [REPORT] - section of an EPANET input file created with the ENsaveinpfile - function was fixed. Also the number of decimal places for some - items written to the saved file, such as nodal demands, was - increased. -------------------------------------------------------------------------------- -TYPES.H The code version was changed to 20012 and INT4 was explicitly - defined as an "int" data type. -=============================================================================== diff --git a/include/epanet2.h b/include/epanet2.h old mode 100755 new mode 100644 index ff05d27..d851a43 --- a/include/epanet2.h +++ b/include/epanet2.h @@ -1,14 +1,44 @@ /* -** EPANET2.H -** -** C/C++ header file for EPANET Programmers Toolkit -** -** Last updated on 2/14/08 (2.00.12) -*/ + ******************************************************************* + + TOOLKIT.H - Prototypes for EPANET Functions Exported to DLL Toolkit + + VERSION: 2.00 + DATE: 5/8/00 + 10/25/00 + 3/1/01 + 8/15/07 (2.00.11) + 2/14/08 (2.00.12) + AUTHOR: L. Rossman + US EPA - NRMRL + + ******************************************************************* + */ #ifndef EPANET2_H #define EPANET2_H +#ifndef EN_API_FLOAT_TYPE +#define EN_API_FLOAT_TYPE float +#endif + +#ifndef DLLEXPORT +#ifdef DLL +#ifdef __cplusplus +#define DLLEXPORT extern "C" __declspec(dllexport) +#else +#define DLLEXPORT __declspec(dllexport) +#endif +#elif defined(CYGWIN) +#define DLLEXPORT __stdcall +#else +#ifdef __cplusplus +#define DLLEXPORT +#else +#define DLLEXPORT +#endif +#endif +#endif // --- Define the EPANET toolkit constants #define EN_ELEVATION 0 /* Node parameters */ @@ -36,8 +66,8 @@ #define EN_MAXLEVEL 21 #define EN_MIXFRACTION 22 #define EN_TANK_KBULK 23 - -#define EN_TANKVOLUME 24 /* TNT */ +#define EN_TANKVOLUME 24 +#define EN_MAXVOLUME 25 #define EN_DIAMETER 0 /* Link parameters */ #define EN_LENGTH 1 @@ -65,9 +95,16 @@ #define EN_RULESTEP 7 #define EN_STATISTIC 8 #define EN_PERIODS 9 -#define EN_STARTTIME 10 /* Added TNT 10/2/2009 */ +#define EN_STARTTIME 10 /* Added TNT 10/2/2009 */ +#define EN_HTIME 11 +#define EN_QTIME 12 +#define EN_HALTFLAG 13 +#define EN_NEXTEVENT 14 -#define EN_NODECOUNT 0 /* Component counts */ +#define EN_ITERATIONS 0 +#define EN_RELATIVEERROR 1 + +#define EN_NODECOUNT 0 /* Component counts */ #define EN_TANKCOUNT 1 #define EN_LINKCOUNT 2 #define EN_PATCOUNT 3 @@ -78,8 +115,8 @@ #define EN_RESERVOIR 1 #define EN_TANK 2 -#define EN_CVPIPE 0 /* Link types */ -#define EN_PIPE 1 +#define EN_CVPIPE 0 /* Link types. */ +#define EN_PIPE 1 /* See LinkType in TYPES.H */ #define EN_PUMP 2 #define EN_PRV 3 #define EN_PSV 4 @@ -88,19 +125,19 @@ #define EN_TCV 7 #define EN_GPV 8 -#define EN_NONE 0 /* Quality analysis types */ -#define EN_CHEM 1 +#define EN_NONE 0 /* Quality analysis types. */ +#define EN_CHEM 1 /* See QualType in TYPES.H */ #define EN_AGE 2 #define EN_TRACE 3 -#define EN_CONCEN 0 /* Source quality types */ -#define EN_MASS 1 +#define EN_CONCEN 0 /* Source quality types. */ +#define EN_MASS 1 /* See SourceType in TYPES.H. */ #define EN_SETPOINT 2 #define EN_FLOWPACED 3 -#define EN_CFS 0 /* Flow units types */ -#define EN_GPM 1 -#define EN_MGD 2 +#define EN_CFS 0 /* Flow units types. */ +#define EN_GPM 1 /* See FlowUnitsType */ +#define EN_MGD 2 /* in TYPES.H. */ #define EN_IMGD 3 #define EN_AFD 4 #define EN_LPS 5 @@ -115,13 +152,13 @@ #define EN_EMITEXPON 3 #define EN_DEMANDMULT 4 -#define EN_LOWLEVEL 0 /* Control types */ -#define EN_HILEVEL 1 -#define EN_TIMER 2 +#define EN_LOWLEVEL 0 /* Control types. */ +#define EN_HILEVEL 1 /* See ControlType */ +#define EN_TIMER 2 /* in TYPES.H. */ #define EN_TIMEOFDAY 3 #define EN_AVERAGE 1 /* Time statistic types. */ -#define EN_MINIMUM 2 +#define EN_MINIMUM 2 /* See TstatType in TYPES.H */ #define EN_MAXIMUM 3 #define EN_RANGE 4 @@ -132,121 +169,107 @@ #define EN_NOSAVE 0 /* Save-results-to-file flag */ #define EN_SAVE 1 -#define EN_INITFLOW 10 /* Re-initialize flow flag */ + +#define EN_INITFLOW 10 /* Re-initialize flows flag */ - -// --- define WINDOWS - -#undef WINDOWS -#ifdef _WIN32 - #define WINDOWS -#endif -#ifdef __WIN32__ - #define WINDOWS -#endif - -// --- define DLLEXPORT - -#ifndef DLLEXPORT - #ifdef DLL - #if defined(CYGWIN) - #define DLLEXPORT __stdcall - #elif defined(WINDOWS) - #ifdef __cplusplus - #define DLLEXPORT extern "C" __declspec(dllexport) - #else - #define DLLEXPORT __declspec(dllexport) - #endif - #else - #ifdef __cplusplus - #define DLLEXPORT extern "C" - #else - #define DLLEXPORT - #endif - #endif - #else - #define DLLEXPORT - #endif -#endif - -// --- declare the EPANET toolkit functions -#ifdef __cplusplus +// --- Declare the EPANET toolkit functions +#if defined(__cplusplus) extern "C" { #endif - int DLLEXPORT ENepanet(char *, char *, char *, void (*) (char *)); - int DLLEXPORT ENopen(char *, char *, char *); - int DLLEXPORT ENsaveinpfile(char *); - int DLLEXPORT ENclose(void); - - int DLLEXPORT ENsolveH(void); - int DLLEXPORT ENsaveH(void); - int DLLEXPORT ENopenH(void); - int DLLEXPORT ENinitH(int); - int DLLEXPORT ENrunH(long *); - int DLLEXPORT ENnextH(long *); - int DLLEXPORT ENcloseH(void); - int DLLEXPORT ENsavehydfile(char *); - int DLLEXPORT ENusehydfile(char *); - - int DLLEXPORT ENsolveQ(void); - int DLLEXPORT ENopenQ(void); - int DLLEXPORT ENinitQ(int); - int DLLEXPORT ENrunQ(long *); - int DLLEXPORT ENnextQ(long *); - int DLLEXPORT ENstepQ(long *); - int DLLEXPORT ENcloseQ(void); - - int DLLEXPORT ENwriteline(char *); - int DLLEXPORT ENreport(void); - int DLLEXPORT ENresetreport(void); - int DLLEXPORT ENsetreport(char *); - - int DLLEXPORT ENgetcontrol(int, int *, int *, float *, - int *, float *); - int DLLEXPORT ENgetcount(int, int *); - int DLLEXPORT ENgetoption(int, float *); - int DLLEXPORT ENgettimeparam(int, long *); - int DLLEXPORT ENgetflowunits(int *); - int DLLEXPORT ENgetpatternindex(char *, int *); - int DLLEXPORT ENgetpatternid(int, char *); - int DLLEXPORT ENgetpatternlen(int, int *); - int DLLEXPORT ENgetpatternvalue(int, int, float *); - int DLLEXPORT ENgetaveragepatternvalue(int index, EN_API_FLOAT_TYPE *value); - int DLLEXPORT ENgetqualtype(int *, int *); - int DLLEXPORT ENgeterror(int, char *, int); - - int DLLEXPORT ENgetnodeindex(char *, int *); - int DLLEXPORT ENgetnodeid(int, char *); - int DLLEXPORT ENgetnodetype(int, int *); - int DLLEXPORT ENgetnodevalue(int, int, float *); - - int DLLEXPORT ENgetnumdemands(int, int *); - int DLLEXPORT ENgetbasedemand(int, int, float *); - int DLLEXPORT ENgetdemandpattern(int, int, int *); - - int DLLEXPORT ENgetlinkindex(char *, int *); - int DLLEXPORT ENgetlinkid(int, char *); - int DLLEXPORT ENgetlinktype(int, int *); - int DLLEXPORT ENgetlinknodes(int, int *, int *); - int DLLEXPORT ENgetlinkvalue(int, int, float *); + int DLLEXPORT ENepanet(char *, char *, char *, void (*) (char *)); - int DLLEXPORT ENgetcurve(int curveIndex, int *nValues, float **xValues, float **yValues); + int DLLEXPORT ENopen(char *, char *, char *); + int DLLEXPORT ENsaveinpfile(char *); + int DLLEXPORT ENclose(void); - int DLLEXPORT ENgetversion(int *); + int DLLEXPORT ENsolveH(void); + int DLLEXPORT ENsaveH(void); + int DLLEXPORT ENopenH(void); + int DLLEXPORT ENinitH(int); + int DLLEXPORT ENrunH(long *); + int DLLEXPORT ENnextH(long *tstep); + int DLLEXPORT ENcloseH(void); + int DLLEXPORT ENsavehydfile(char *); + int DLLEXPORT ENusehydfile(char *); + + int DLLEXPORT ENsolveQ(void); + int DLLEXPORT ENopenQ(void); + int DLLEXPORT ENinitQ(int); + int DLLEXPORT ENrunQ(long *); + int DLLEXPORT ENnextQ(long *); + int DLLEXPORT ENstepQ(long *); + int DLLEXPORT ENcloseQ(void); + + int DLLEXPORT ENwriteline(char *); + int DLLEXPORT ENreport(void); + int DLLEXPORT ENresetreport(void); + int DLLEXPORT ENsetreport(char *); + + int DLLEXPORT ENgetcontrol(int, int *, int *, EN_API_FLOAT_TYPE *, + int *, EN_API_FLOAT_TYPE *); + int DLLEXPORT ENgetcount(int, int *); + int DLLEXPORT ENgetoption(int, EN_API_FLOAT_TYPE *); + int DLLEXPORT ENgettimeparam(int, long *); + int DLLEXPORT ENgetflowunits(int *); + int DLLEXPORT ENgetpatternindex(char *, int *); + int DLLEXPORT ENgetpatternid(int, char *); + int DLLEXPORT ENgetpatternlen(int, int *); + int DLLEXPORT ENgetpatternvalue(int, int, EN_API_FLOAT_TYPE *); + int DLLEXPORT ENgetaveragepatternvalue(int index, EN_API_FLOAT_TYPE *value); + int DLLEXPORT ENgetqualtype(int *, int *); + int DLLEXPORT ENgeterror(int, char *, int); + int DLLEXPORT ENgetstatistic(int code, int* value); + + int DLLEXPORT ENgetnodeindex(char *, int *); + int DLLEXPORT ENgetnodeid(int, char *); + int DLLEXPORT ENgetnodetype(int, int *); + int DLLEXPORT ENgetnodevalue(int, int, EN_API_FLOAT_TYPE *); + int DLLEXPORT ENgetcoord(int , EN_API_FLOAT_TYPE *, EN_API_FLOAT_TYPE *); + + int DLLEXPORT ENgetnumdemands(int, int *); + int DLLEXPORT ENgetbasedemand(int, int, EN_API_FLOAT_TYPE *); + int DLLEXPORT ENgetdemandpattern(int, int, int *); + + int DLLEXPORT ENgetlinkindex(char *, int *); + int DLLEXPORT ENgetlinkid(int, char *); + int DLLEXPORT ENgetlinktype(int, int *); + int DLLEXPORT ENgetlinknodes(int, int *, int *); + int DLLEXPORT ENgetlinkvalue(int, int, EN_API_FLOAT_TYPE *); + + int DLLEXPORT ENgetcurve(int curveIndex, int *nValues, EN_API_FLOAT_TYPE **xValues, EN_API_FLOAT_TYPE **yValues); - int DLLEXPORT ENsetcontrol(int, int, int, float, int, float); - int DLLEXPORT ENsetnodevalue(int, int, float); - int DLLEXPORT ENsetlinkvalue(int, int, float); - int DLLEXPORT ENaddpattern(char *); - int DLLEXPORT ENsetpattern(int, float *, int); - int DLLEXPORT ENsetpatternvalue(int, int, float); - int DLLEXPORT ENsettimeparam(int, long); - int DLLEXPORT ENsetoption(int, float); - int DLLEXPORT ENsetstatusreport(int); - int DLLEXPORT ENsetqualtype(int, char *, char *, char *); -#ifdef __cplusplus -}; + + int DLLEXPORT ENgetversion(int *); + + int DLLEXPORT ENsetcontrol(int, int, int, EN_API_FLOAT_TYPE, int, EN_API_FLOAT_TYPE); + int DLLEXPORT ENsetnodevalue(int, int, EN_API_FLOAT_TYPE); + int DLLEXPORT ENsetlinkvalue(int, int, EN_API_FLOAT_TYPE); + int DLLEXPORT ENaddpattern(char *); + int DLLEXPORT ENsetpattern(int, EN_API_FLOAT_TYPE *, int); + int DLLEXPORT ENsetpatternvalue(int, int, EN_API_FLOAT_TYPE); + int DLLEXPORT ENsettimeparam(int, long); + int DLLEXPORT ENsetoption(int, EN_API_FLOAT_TYPE); + int DLLEXPORT ENsetstatusreport(int); + int DLLEXPORT ENsetqualtype(int qualcode, char *chemname, char *chemunits, char *tracenode); + + //LemonTiger functions + /* See testLT.c for a LemonTiger test */ + + //LT equivalent to ENopenH() + ENopenQ() + ENinitH() + ENinitQ() + int DLLEXPORT ENopeninitHQ(); + + //LT equivalent to ENrunQ() + ENnextQ(); + int DLLEXPORT ENrunnextHQ(long*, long*); + + //LT equivalent to ENrunQ() + ENstepQ(); + int DLLEXPORT ENrunstepHQ(long*, long*); + + //LT equivalent to ENcloseH() + ENcloseQ(); + int DLLEXPORT ENcloseHQ(); + +#if defined(__cplusplus) +} #endif -#endif +#endif //TOOLKIT_H \ No newline at end of file diff --git a/src/enumstxt.h b/src/enumstxt.h index 6a8404e..a546b7e 100755 --- a/src/enumstxt.h +++ b/src/enumstxt.h @@ -11,6 +11,9 @@ AUTHOR: L. Rossman ********************************************************************** */ +#ifndef ENUMSTXT_H +#define ENUMSTXT_H + char *NodeTxt[] = {t_JUNCTION, t_RESERVOIR, t_TANK}; @@ -133,3 +136,4 @@ char *Fldname[] = {t_ELEV, t_DEMAND, t_HEAD, char *LogoTxt[] = {LOGO1,LOGO2,LOGO3,LOGO4,LOGO5,LOGO6,NULL}; +#endif \ No newline at end of file diff --git a/src/epanet.c b/src/epanet.c index 72e352e..1a10546 100755 --- a/src/epanet.c +++ b/src/epanet.c @@ -107,17 +107,6 @@ execute function x and set the error code equal to its return value. ******************************************************************************* */ -/*** New compile directives ***/ //(2.00.11 - LR) -//#define CLE /* Compile as a command line executable */ -//#define SOL /* Compile as a shared object library */ -//#define DLL /* Compile as a Windows DLL */ - -/*** Following lines are deprecated ***/ //(2.00.11 - LR) -//#ifdef DLL -//#include -//#include -//#endif - /*** Need to define WINDOWS to use the getTmpName function ***/ //(2.00.12 - LR) // --- define WINDOWS #undef WINDOWS @@ -137,14 +126,14 @@ execute function x and set the error code equal to its return value. #endif #include #include //(2.00.12 - LR) -#include "hash.h" + #include "text.h" #include "types.h" #include "enumstxt.h" #include "funcs.h" #define EXTERN #include "vars.h" -#include "toolkit.h" +#include "epanet2.h" void (* viewprog) (char *); /* Pointer to progress viewing function */ @@ -1761,7 +1750,7 @@ int DLLEXPORT ENgetlinkvalue(int index, int code, EN_API_FLOAT_TYPE *value) } -int DLLEXPORT ENgetcurve(int curveIndex, int *nValues, EN_API_FLOAT_TYPE **xValues, EN_API_FLOAT_TYPE **yValues) // !sph +int DLLEXPORT ENgetcurve(int curveIndex, int *nValues, EN_API_FLOAT_TYPE **xValues, EN_API_FLOAT_TYPE **yValues) /*---------------------------------------------------------------- ** Input: curveIndex = curve index ** Output: *nValues = number of points on curve @@ -1794,6 +1783,7 @@ int DLLEXPORT ENgetcurve(int curveIndex, int *nValues, EN_API_FLOAT_TYPE **xVal return err; } + /* ---------------------------------------------------------------- Functions for changing network data @@ -1984,7 +1974,7 @@ int DLLEXPORT ENsetnodevalue(int index, int code, EN_API_FLOAT_TYPE v) if (j < 0 || j > Npats) return(205); source->Pat = j; } - else + else // code == EN_SOURCETYPE { j = ROUND(value); if ( j < CONCEN || j > FLOWPACED) return(251); @@ -2358,44 +2348,69 @@ int DLLEXPORT ENsettimeparam(int code, long value) */ } if (value < 0) return(202); - switch(code) - { - case EN_DURATION: Dur = value; - if (Rstart > Dur) Rstart = 0; - break; - case EN_HYDSTEP: if (value == 0) return(202); - Hstep = value; - Hstep = MIN(Pstep, Hstep); - Hstep = MIN(Rstep, Hstep); - Qstep = MIN(Qstep, Hstep); - break; - case EN_QUALSTEP: if (value == 0) return(202); - Qstep = value; - Qstep = MIN(Qstep, Hstep); - break; - case EN_PATTERNSTEP: if (value == 0) return(202); - Pstep = value; - if (Hstep > Pstep) Hstep = Pstep; - break; - case EN_PATTERNSTART: Pstart = value; - break; - case EN_REPORTSTEP: if (value == 0) return(202); - Rstep = value; - if (Hstep > Rstep) Hstep = Rstep; - break; - case EN_REPORTSTART: if (Rstart > Dur) return(202); - Rstart = value; - break; - case EN_RULESTEP: if (value == 0) return(202); - Rulestep = value; - Rulestep = MIN(Rulestep, Hstep); - break; - case EN_STATISTIC: if (value > RANGE) return(202); - Tstatflag = (char)value; - break; - case EN_HTIME: Htime = value; - break; - default: return(251); + switch(code) + { + case EN_DURATION: + Dur = value; + if (Rstart > Dur) Rstart = 0; + break; + + case EN_HYDSTEP: + if (value == 0) return(202); + Hstep = value; + Hstep = MIN(Pstep, Hstep); + Hstep = MIN(Rstep, Hstep); + Qstep = MIN(Qstep, Hstep); + break; + + case EN_QUALSTEP: + if (value == 0) return(202); + Qstep = value; + Qstep = MIN(Qstep, Hstep); + break; + + case EN_PATTERNSTEP: + if (value == 0) return(202); + Pstep = value; + if (Hstep > Pstep) Hstep = Pstep; + break; + + case EN_PATTERNSTART: + Pstart = value; + break; + + case EN_REPORTSTEP: + if (value == 0) return(202); + Rstep = value; + if (Hstep > Rstep) Hstep = Rstep; + break; + + case EN_REPORTSTART: + if (Rstart > Dur) return(202); + Rstart = value; + break; + + case EN_RULESTEP: + if (value == 0) return(202); + Rulestep = value; + Rulestep = MIN(Rulestep, Hstep); + break; + + case EN_STATISTIC: + if (value > RANGE) return(202); + Tstatflag = (char)value; + break; + + case EN_HTIME: + Htime = value; + break; + + case EN_QTIME: + Qtime = value; + break; + + default: + return(251); } return(0); } @@ -2406,8 +2421,8 @@ int DLLEXPORT ENsetoption(int code, EN_API_FLOAT_TYPE v) ** Input: code = option code (see TOOLKIT.H) ** v = option value ** Output: none -** Returns: error code -** Purpose: sets value for an analysis option +** Returns: error code +** Purpose: sets value for an analysis option **---------------------------------------------------------------- */ { diff --git a/src/funcs.h b/src/funcs.h index c7907f8..9847275 100755 --- a/src/funcs.h +++ b/src/funcs.h @@ -25,6 +25,10 @@ AUTHOR: L. Rossman ** NOTE: The exportable functions that can be called ** via the DLL are prototyped in TOOLKIT.H. */ + +#ifndef FUNCS_H +#define FUNCS_H + void initpointers(void); /* Initializes pointers */ int allocdata(void); /* Allocates memory */ void freeTmplist(STmplist *); /* Frees items in linked list */ @@ -282,3 +286,5 @@ int saveepilog(void); /* Saves output file epilog */ /* ------------ INPFILE.C --------------*/ int saveinpfile(char *); /* Saves network to text file */ + +#endif diff --git a/src/hydraul.c b/src/hydraul.c index eb97ba7..bdf0213 100755 --- a/src/hydraul.c +++ b/src/hydraul.c @@ -205,7 +205,7 @@ int runhyd(long *t) if (Statflag) writehydstat(iter,relerr); /* solution info */ - _relativeError = relerr; + _relativeError = (int)relerr; _iterations = iter; /*** Updated 3/1/01 ***/ @@ -1064,7 +1064,6 @@ void tanklevels(long tstep) else if (Tank[i].V - D[n] <= Tank[i].Vmin) { Tank[i].V = Tank[i].Vmin; } - H[n] = tankgrade(i,Tank[i].V); } } /* End of tanklevels */ diff --git a/src/mempool.h b/src/mempool.h index 2e43dde..ede9d44 100755 --- a/src/mempool.h +++ b/src/mempool.h @@ -6,6 +6,10 @@ ** The type alloc_handle_t provides an opaque reference to the ** alloc pool - only the alloc routines know its structure. */ + +#ifndef MEMPOOL_H +#define MEMPOOL_H + #ifndef DLLEXPORT #ifdef DLL #ifdef __cplusplus @@ -24,6 +28,7 @@ #endif #endif + typedef struct { long dummy; @@ -34,3 +39,5 @@ DLLEXPORT char *Alloc(long); DLLEXPORT alloc_handle_t *AllocSetPool(alloc_handle_t *); DLLEXPORT void AllocReset(void); DLLEXPORT void AllocFreePool(void); + +#endif \ No newline at end of file diff --git a/src/output.c b/src/output.c index 83b9de3..4237736 100755 --- a/src/output.c +++ b/src/output.c @@ -162,8 +162,9 @@ int savehyd(long *htime) /* Force flow in closed links to be zero then save flows */ for (i=1; i<=Nlinks; i++) { - if (S[i] <= CLOSED) x[i] = 0.0f; - else x[i] = (REAL4)Q[i]; + if (S[i] <= CLOSED) x[i] = 0.0f; + else x[i] = (REAL4)Q[i]; + } fwrite(x+1,sizeof(REAL4),Nlinks,HydFile); @@ -379,7 +380,7 @@ int nodeoutput(int j, REAL4 *x, double ucf) } /* End of nodeoutput */ -int linkoutput(int j, float *x, double ucf) +int linkoutput(int j, REAL4 *x, double ucf) /* **---------------------------------------------------------------- ** Input: j = type of link variable diff --git a/src/quality.c b/src/quality.c index abf89fc..d17af7c 100755 --- a/src/quality.c +++ b/src/quality.c @@ -108,7 +108,7 @@ int openqual() /* Allocate scratch array & reaction rate array*/ XC = (double *) calloc(MAX((Nnodes+1),(Nlinks+1)),sizeof(double)); R = (double *) calloc((Nlinks+1), sizeof(double)); - ERRCODE(MEMCHECK(X)); + ERRCODE(MEMCHECK(XC)); ERRCODE(MEMCHECK(R)); /* Allocate memory for WQ solver */ @@ -151,9 +151,10 @@ void initqual() for (i=1; i<=Nnodes; i++) C[i] = Node[i].C0; for (i=1; i<=Ntanks; i++) Tank[i].C = Node[Tank[i].Node].C0; for (i=1; i<=Ntanks; i++) Tank[i].V = Tank[i].V0; - for (i=1; i<=Nnodes; i++) - if (Node[i].S != NULL) Node[i].S->Smass = 0.0; - + for (i=1; i<=Nnodes; i++) { + if (Node[i].S != NULL) Node[i].S->Smass = 0.0; + } + QTankVolumes = calloc(Ntanks, sizeof(double)); // keep track of previous step's tank volumes. QLinkFlow = calloc(Nlinks, sizeof(double)); // keep track of previous step's link flows. @@ -229,10 +230,10 @@ int runqual(long *t) errcode = gethyd(&hydtime, &hydstep); if (!OpenHflag) { // test for sequential vs stepwise // sequential - Htime = hydtime + hydstep; - } + Htime = hydtime + hydstep; + } else { - // stepwise calculation + // stepwise calculation - hydraulic results are already in memory for (int i=1; i<= Ntanks; ++i) { QTankVolumes[i-1] = Tank[i].V; } @@ -246,6 +247,21 @@ int runqual(long *t) } } + else { + // stepwise calculation + for (int i=1; i<= Ntanks; ++i) { + QTankVolumes[i-1] = Tank[i].V; + } + + for (int i=1; i<= Nlinks; ++i) + { + if (S[i] <= CLOSED) { + QLinkFlow[i-1] = Q[i]; + } + } + + } + return(errcode); } @@ -300,7 +316,7 @@ int nextqual(long *tstep) } } - + /* Perform water quality routing over this time step */ if (Qualflag != NONE && hydstep > 0) transport(hydstep); @@ -425,10 +441,10 @@ int gethyd(long *hydtime, long *hydstep) // if hydraulics are not open, then we're operating in sequential mode. // else hydraulics are open, so use the hydraulic results in memory rather than reading from the temp file. if (!OpenHflag) { - /* Read hydraulic results from file */ - if (!readhyd(hydtime)) return(307); - if (!readhydstep(hydstep)) return(307); - Htime = *hydtime; + /* Read hydraulic results from file */ + if (!readhyd(hydtime)) return(307); + if (!readhydstep(hydstep)) return(307); + Htime = *hydtime; } /* Save current results to output file */ @@ -497,7 +513,7 @@ void transport(long tstep) */ { long qtime, dt; - + /* Repeat until elapsed time equals hydraulic time step */ AllocSetPool(SegPool); //(2.00.11 - LR) @@ -513,6 +529,7 @@ void transport(long tstep) release(dt); /* Release new nodal flows */ } updatesourcenodes(tstep); /* Update quality at source nodes */ + } @@ -1080,21 +1097,19 @@ void updatetanks(long dt) for (i=1; i<=Ntanks; i++) { n = Tank[i].Node; - /* Use initial quality for reservoirs */ if (Tank[i].A == 0.0) { C[n] = Node[n].C0; } - /* Update tank WQ based on mixing model */ else { switch(Tank[i].MixModel) { - case MIX2: tankmix2(i,dt); break; - case FIFO: tankmix3(i,dt); break; - case LIFO: tankmix4(i,dt); break; - default: tankmix1(i,dt); break; + case MIX2: tankmix2(i,dt); break; + case FIFO: tankmix3(i,dt); break; + case LIFO: tankmix4(i,dt); break; + default: tankmix1(i,dt); break; } } diff --git a/src/testLemonTiger.cpp b/src/testLemonTiger.cpp new file mode 100755 index 0000000..0863e9a --- /dev/null +++ b/src/testLemonTiger.cpp @@ -0,0 +1,332 @@ +#include +#include +#include +#include +#include +#include "testLemonTiger.h" +#include "toolkit.h" + +#define COLW 15 +#define OUTPRECISION 6 + +using namespace std; + +typedef struct { + double head; + double demand; + double quality; +} nodeState_t; + +typedef struct { + double flow; +} linkState_t; + +typedef map networkNodeState_t; // nodeIndex, state +typedef map networkLinkState_t; // linkIndex, state + +typedef struct { + networkNodeState_t nodeState; + networkLinkState_t linkState; +} networkState_t; +typedef map result_t; // time, networkState +// access results by, for instance, resultsContainer[time][nodeIndex].head + + + +void checkErr(int err, std::string function); +void saveHydResults(networkState_t* networkState); +void saveQualResults(networkState_t* networkState); +void printResults(result_t* state1, result_t* state2, std::ostream& out); +void compare(result_t* results1, result_t* results2, std::ostream &out); + +int main(int argc, char * argv[]) { + + // create storage structures for results. + result_t epanetResults, lemonTigerResults; + + cout << "Lemon Tiger TEST" << endl + << "________________" << endl; + + + long simulationTime = 0; + long nextEventH = 0, nextEventQ = 0; + long simTimeRemaining = 0; + + try { + + /* Batch solver (old epanet) */ + cout << "*****Original EPANET results******" << endl; + checkErr( ENopen(argv[1], argv[2], (char*)""), "ENopen" ); + + checkErr( ENopenH(), "ENopenH" ); + checkErr( ENinitH(EN_SAVE), "ENinitH" ); + + cout << "Running hydraulics..." << endl; + do { + + /* Solve for hydraulics & advance to next time period */ + checkErr( ENrunH(&simulationTime), "ENrunH" ); + checkErr( ENnextH(&nextEventH), "ENnextH" ); + + // gather hydraulic results + saveHydResults(&epanetResults[simulationTime]); + + + + } while (nextEventH > 0); + // hydraulics are done + checkErr( ENcloseH(), "ENcloseH" ); + cout << "\t\t\tdone." << endl; + cout << "Running WQ..." << endl; + + checkErr( ENopenQ(), "ENopenQ" ); + checkErr( ENinitQ(EN_NOSAVE), "ENinitQ" ); + + do { + + checkErr( ENrunQ(&simulationTime), "ENrunQ" ); + checkErr( ENnextQ(&nextEventH), "ENstepQ" ); + + // gather quality results + saveQualResults(&epanetResults[simulationTime]); + + } while (nextEventH > 0); + // water quality is done + checkErr( ENcloseQ(), "ENcloseQ" ); + cout << "\t\t\tdone." << endl; + + // everything is done + checkErr( ENclose(), "ENclose" ); + + + nextEventH = 0; + simTimeRemaining = 0; + simulationTime = 0; + + /* stepwise solver (LemonTiger) */ + cout << "*****LemonTiger results******" << endl; + + checkErr( ENopen(argv[1], argv[2], (char*)""), "ENopen" ); + + checkErr( ENopenH(), "ENopenH" ); + checkErr( ENinitH(EN_NOSAVE), "ENinitH" ); + checkErr( ENopenQ(), "ENopenQ" ); + checkErr( ENinitQ(EN_NOSAVE), "ENinitQ" ); + + cout << "Running stepwise hydraulics and water quality..." << endl; + do { + /* Solve for hydraulics & advance to next time period */ + checkErr( ENrunH(&simulationTime), "ENrunH" ); + checkErr( ENrunQ(&simulationTime), "ENrunQ" ); + + checkErr( ENnextH(&nextEventH), "ENnextH" ); + checkErr( ENnextQ(&nextEventQ), "ENstepQ" ); + + + saveHydResults(&lemonTigerResults[simulationTime]); + saveQualResults(&lemonTigerResults[simulationTime]); + + + } while (nextEventH > 0); + cout << "\t\t\tdone." << endl; + + // all done + checkErr( ENcloseH(), "ENcloseH" ); + checkErr( ENcloseQ(), "ENcloseQ" ); + checkErr( ENclose(), "ENclose" ); + + + // summarize the results + printResults(&epanetResults, &lemonTigerResults, cout); + compare(&epanetResults, &lemonTigerResults, cout); + + } catch (int err) { + cerr << "exiting with error " << err << endl; + } +} + + +void saveHydResults(networkState_t* networkState) { + int nNodes, nLinks; + float head, demand, flow; + ENgetcount(EN_NODECOUNT, &nNodes); + ENgetcount(EN_LINKCOUNT, &nLinks); + for (int iNode = 1; iNode <= nNodes; ++iNode) { + ENgetnodevalue(iNode, EN_HEAD, &head); + ENgetnodevalue(iNode, EN_DEMAND, &demand); + (*networkState).nodeState[iNode].head = head; + (*networkState).nodeState[iNode].demand = demand; + } + for (int iLink = 1; iLink <= nLinks; ++iLink) { + ENgetlinkvalue(iLink, EN_FLOW, &flow); + (*networkState).linkState[iLink].flow = flow; + } +} + + +void saveQualResults(networkState_t* networkState) { + int nNodes; + float quality; + ENgetcount(EN_NODECOUNT, &nNodes); + + for (int iNode = 1; iNode <= nNodes; iNode++) { + ENgetnodevalue(iNode, EN_QUALITY, &quality); + (*networkState).nodeState[iNode].quality = quality; + } +} + + +void printResults(result_t* results1, result_t* results2, std::ostream &out) { + + result_t::const_iterator resultIterator; + + for (resultIterator = (*results1).begin(); resultIterator != (*results1).end(); ++resultIterator) { + // get the current frame + const long time = resultIterator->first; + const networkNodeState_t networkNodeState1= resultIterator->second.nodeState; + //nodeState1 = resultIterator->second.nodeState; + const networkLinkState_t networkLinkState1 = resultIterator->second.linkState; + //linkState1 = resultIterator->second.linkState; + + // see if this time is indexed in the second state container + if ((*results2).find(time) == (*results2).end()) { + // nope. + out << "time " << time << " not found in second result set" << endl; + } + else { + // get the second result set's state + const networkNodeState_t networkNodeState2 = (*results2)[time].nodeState; + const networkLinkState_t networkLinkState2 = (*results2)[time].linkState; + // print the current simulation time + out << left; + out << setfill('*') << setw(100) << "*" << endl; + out << setfill(' '); + out << setw(4) << "T = " << setw(6) << time; + out << "|" << setw(3*COLW) << "EPANET"; + out << "|" << setw(3*COLW) << "LemonTiger" << endl; + out << setw(10) << "Index" << "|"; + out << setw(COLW) << "Demand" << setw(COLW) << "Head" << setw(COLW) << "Quality" << "|"; + out << setw(COLW) << "Demand" << setw(COLW) << "Head" << setw(COLW) << "Quality" << endl; + out << setprecision(OUTPRECISION); + + // loop through the nodes in the networkState objs, and print out the results for this time period + networkNodeState_t::const_iterator networkNodeIterator; + for (networkNodeIterator = networkNodeState1.begin(); networkNodeIterator != networkNodeState1.end(); ++networkNodeIterator) { + int nodeIndex = networkNodeIterator->first; + // trusting that all nodes are present... + const nodeState_t nodeState1 = networkNodeIterator->second; + const nodeState_t nodeState2 = networkNodeState2.at(nodeIndex); + + if (nodeState1.quality != nodeState2.quality ) { + // epanet + out << setw(10) << nodeIndex << "|"; + out << setw(COLW) << nodeState1.demand; + out << setw(COLW) << nodeState1.head; + out << setw(COLW) << nodeState1.quality; + + // lemontiger + out << "|"; + out << setw(COLW) << nodeState2.demand; + out << setw(COLW) << nodeState2.head; + out << setw(COLW) << nodeState2.quality; + out << endl; + } + } + + networkLinkState_t::const_iterator networkLinkIterator; + for (networkLinkIterator = networkLinkState1.begin(); networkLinkIterator != networkLinkState1.end(); ++networkLinkIterator) { + int linkIndex = networkLinkIterator->first; + // trusting that all nodes are present... + const linkState_t linkState1 = networkLinkIterator->second; + const linkState_t linkState2 = networkLinkState2.at(linkIndex); + + if ( linkState1.flow != linkState2.flow ) { + // epanet + out << setw(10) << linkIndex << "|"; + out << setw(COLW) << linkState1.flow; + + // lemontiger + out << "|"; + out << setw(COLW) << linkState2.flow; + out << endl; + } + } + + + } + } + +} + + + +void compare(result_t* results1, result_t* results2, std::ostream &out) { + + double sumHeadDiff=0, sumDemandDiff=0, sumQualDiff=0, sumFlowDiff=0; + + result_t::const_iterator resultIterator; + + for (resultIterator = (*results1).begin(); resultIterator != (*results1).end(); ++resultIterator) { + // get the current frame + const long time = resultIterator->first; + const networkNodeState_t nodeState1 = resultIterator->second.nodeState; + const networkLinkState_t linkState1 = resultIterator->second.linkState; + + // see if this time is indexed in the second state container + if ((*results2).find(time) == (*results2).end()) { + // nope. + out << "time " << time << " not found in second result set" << endl; + } + else { + // get the second result set's state + const networkNodeState_t networkNodeState2 = (*results2)[time].nodeState; + const networkLinkState_t networkLinkState2 = (*results2)[time].linkState; + double qualD=0; + + networkNodeState_t::const_iterator networkNodeIterator; + for (networkNodeIterator = nodeState1.begin(); networkNodeIterator != nodeState1.end(); ++networkNodeIterator) { + int nodeIndex = networkNodeIterator->first; + // trusting that all nodes are present... + const nodeState_t nodeState1 = networkNodeIterator->second; + const nodeState_t nodeState2 = networkNodeState2.at(nodeIndex); + + sumHeadDiff += fabs(nodeState1.head - nodeState2.head); + sumDemandDiff += fabs(nodeState1.demand - nodeState2.demand); + + qualD += fabs(nodeState1.quality - nodeState2.quality); + } + //out << "T: " << time << " dq: " << setprecision(20) << qualD << endl; + sumQualDiff += qualD; + + networkLinkState_t::const_iterator networkLinkIterator; + for (networkLinkIterator = linkState1.begin(); networkLinkIterator != linkState1.end(); ++networkLinkIterator) { + int linkIndex = networkLinkIterator->first; + // trusting that all nodes are present... + const linkState_t linkState1 = networkLinkIterator->second; + const linkState_t linkState2 = networkLinkState2.at(linkIndex); + + sumFlowDiff += fabs(linkState1.flow - linkState2.flow); + } + } + } + + int c1 = 18; + int p = 20; + out << setw(c1) << "Head Diff:" << setprecision(p) << sumHeadDiff << endl; + out << setw(c1) << "Demand Diff:" << setprecision(p) << sumDemandDiff << endl; + out << setw(c1) << "Quality Diff:" << setprecision(p) << sumQualDiff << endl; + out << setw(c1) << "Flow Diff:" << setprecision(p) << sumFlowDiff << endl; + + +} + + +void checkErr(int err, std::string function) { + if (err > 0) { + cerr << "Error in " << function << ": " << err << endl; + char errmsg[1024]; + ENgeterror(err, errmsg, 1024); + cerr << errmsg << endl; + throw err; + } +} diff --git a/src/testLemonTiger.h b/src/testLemonTiger.h new file mode 100755 index 0000000..5c1cc2f --- /dev/null +++ b/src/testLemonTiger.h @@ -0,0 +1,15 @@ +// +// testLemonTiger.h +// epanet +// +// Created by Sam Hatchett on 2/1/13. +// +// + +#ifndef __epanet__testLemonTiger__ +#define __epanet__testLemonTiger__ + +#include +#include + +#endif /* defined(__epanet__testLemonTiger__) */ diff --git a/src/toolkit.h b/src/toolkit.h deleted file mode 100755 index 3420969..0000000 --- a/src/toolkit.h +++ /dev/null @@ -1,259 +0,0 @@ -/* -******************************************************************* - -TOOLKIT.H - Prototypes for EPANET Functions Exported to DLL Toolkit - -VERSION: 2.00 -DATE: 5/8/00 - 10/25/00 - 3/1/01 - 8/15/07 (2.00.11) - 2/14/08 (2.00.12) -AUTHOR: L. Rossman - US EPA - NRMRL - -******************************************************************* -*/ - -#ifndef TOOLKIT_H -#define TOOLKIT_H - -#ifndef EN_API_FLOAT_TYPE - #define EN_API_FLOAT_TYPE float -#endif - -#ifndef DLLEXPORT - #ifdef DLL - #ifdef __cplusplus - #define DLLEXPORT extern "C" __declspec(dllexport) - #else - #define DLLEXPORT __declspec(dllexport) - #endif - #elif defined(CYGWIN) - #define DLLEXPORT __stdcall - #else - #ifdef __cplusplus - #define DLLEXPORT - #else - #define DLLEXPORT - #endif - #endif -#endif - -// --- Define the EPANET toolkit constants - -#define EN_ELEVATION 0 /* Node parameters */ -#define EN_BASEDEMAND 1 -#define EN_PATTERN 2 -#define EN_EMITTER 3 -#define EN_INITQUAL 4 -#define EN_SOURCEQUAL 5 -#define EN_SOURCEPAT 6 -#define EN_SOURCETYPE 7 -#define EN_TANKLEVEL 8 -#define EN_DEMAND 9 -#define EN_HEAD 10 -#define EN_PRESSURE 11 -#define EN_QUALITY 12 -#define EN_SOURCEMASS 13 -#define EN_INITVOLUME 14 -#define EN_MIXMODEL 15 -#define EN_MIXZONEVOL 16 - -#define EN_TANKDIAM 17 -#define EN_MINVOLUME 18 -#define EN_VOLCURVE 19 -#define EN_MINLEVEL 20 -#define EN_MAXLEVEL 21 -#define EN_MIXFRACTION 22 -#define EN_TANK_KBULK 23 -#define EN_TANKVOLUME 24 -#define EN_MAXVOLUME 25 - -#define EN_DIAMETER 0 /* Link parameters */ -#define EN_LENGTH 1 -#define EN_ROUGHNESS 2 -#define EN_MINORLOSS 3 -#define EN_INITSTATUS 4 -#define EN_INITSETTING 5 -#define EN_KBULK 6 -#define EN_KWALL 7 -#define EN_FLOW 8 -#define EN_VELOCITY 9 -#define EN_HEADLOSS 10 -#define EN_STATUS 11 -#define EN_SETTING 12 -#define EN_ENERGY 13 -#define EN_LINKQUAL 14 /* TNT */ - -#define EN_DURATION 0 /* Time parameters */ -#define EN_HYDSTEP 1 -#define EN_QUALSTEP 2 -#define EN_PATTERNSTEP 3 -#define EN_PATTERNSTART 4 -#define EN_REPORTSTEP 5 -#define EN_REPORTSTART 6 -#define EN_RULESTEP 7 -#define EN_STATISTIC 8 -#define EN_PERIODS 9 -#define EN_STARTTIME 10 /* Added TNT 10/2/2009 */ -#define EN_HTIME 11 -#define EN_HALTFLAG 12 -#define EN_NEXTEVENT 13 - -#define EN_ITERATIONS 0 -#define EN_RELATIVEERROR 1 - -#define EN_NODECOUNT 0 /* Component counts */ -#define EN_TANKCOUNT 1 -#define EN_LINKCOUNT 2 -#define EN_PATCOUNT 3 -#define EN_CURVECOUNT 4 -#define EN_CONTROLCOUNT 5 - -#define EN_JUNCTION 0 /* Node types */ -#define EN_RESERVOIR 1 -#define EN_TANK 2 - -#define EN_CVPIPE 0 /* Link types. */ -#define EN_PIPE 1 /* See LinkType in TYPES.H */ -#define EN_PUMP 2 -#define EN_PRV 3 -#define EN_PSV 4 -#define EN_PBV 5 -#define EN_FCV 6 -#define EN_TCV 7 -#define EN_GPV 8 - -#define EN_NONE 0 /* Quality analysis types. */ -#define EN_CHEM 1 /* See QualType in TYPES.H */ -#define EN_AGE 2 -#define EN_TRACE 3 - -#define EN_CONCEN 0 /* Source quality types. */ -#define EN_MASS 1 /* See SourceType in TYPES.H. */ -#define EN_SETPOINT 2 -#define EN_FLOWPACED 3 - -#define EN_CFS 0 /* Flow units types. */ -#define EN_GPM 1 /* See FlowUnitsType */ -#define EN_MGD 2 /* in TYPES.H. */ -#define EN_IMGD 3 -#define EN_AFD 4 -#define EN_LPS 5 -#define EN_LPM 6 -#define EN_MLD 7 -#define EN_CMH 8 -#define EN_CMD 9 - -#define EN_TRIALS 0 /* Misc. options */ -#define EN_ACCURACY 1 -#define EN_TOLERANCE 2 -#define EN_EMITEXPON 3 -#define EN_DEMANDMULT 4 - -#define EN_LOWLEVEL 0 /* Control types. */ -#define EN_HILEVEL 1 /* See ControlType */ -#define EN_TIMER 2 /* in TYPES.H. */ -#define EN_TIMEOFDAY 3 - -#define EN_AVERAGE 1 /* Time statistic types. */ -#define EN_MINIMUM 2 /* See TstatType in TYPES.H */ -#define EN_MAXIMUM 3 -#define EN_RANGE 4 - -#define EN_MIX1 0 /* Tank mixing models */ -#define EN_MIX2 1 -#define EN_FIFO 2 -#define EN_LIFO 3 - -#define EN_NOSAVE 0 /* Save-results-to-file flag */ -#define EN_SAVE 1 - -#define EN_INITFLOW 10 /* Re-initialize flows flag */ - - -// --- Declare the EPANET toolkit functions -#if defined(__cplusplus) -extern "C" { -#endif - int DLLEXPORT ENepanet(char *, char *, char *, void (*) (char *)); - - int DLLEXPORT ENopen(char *, char *, char *); - int DLLEXPORT ENsaveinpfile(char *); - int DLLEXPORT ENclose(void); - - int DLLEXPORT ENsolveH(void); - int DLLEXPORT ENsaveH(void); - int DLLEXPORT ENopenH(void); - int DLLEXPORT ENinitH(int); - int DLLEXPORT ENrunH(long *); - int DLLEXPORT ENnextH(long *); - int DLLEXPORT ENcloseH(void); - int DLLEXPORT ENsavehydfile(char *); - int DLLEXPORT ENusehydfile(char *); - - int DLLEXPORT ENsolveQ(void); - int DLLEXPORT ENopenQ(void); - int DLLEXPORT ENinitQ(int); - int DLLEXPORT ENrunQ(long *); - int DLLEXPORT ENnextQ(long *); - int DLLEXPORT ENstepQ(long *); - int DLLEXPORT ENcloseQ(void); - - int DLLEXPORT ENwriteline(char *); - int DLLEXPORT ENreport(void); - int DLLEXPORT ENresetreport(void); - int DLLEXPORT ENsetreport(char *); - - int DLLEXPORT ENgetcontrol(int, int *, int *, EN_API_FLOAT_TYPE *, - int *, EN_API_FLOAT_TYPE *); - int DLLEXPORT ENgetcount(int, int *); - int DLLEXPORT ENgetoption(int, EN_API_FLOAT_TYPE *); - int DLLEXPORT ENgettimeparam(int, long *); - int DLLEXPORT ENgetflowunits(int *); - int DLLEXPORT ENgetpatternindex(char *, int *); - int DLLEXPORT ENgetpatternid(int, char *); - int DLLEXPORT ENgetpatternlen(int, int *); - int DLLEXPORT ENgetpatternvalue(int, int, EN_API_FLOAT_TYPE *); - int DLLEXPORT ENgetaveragepatternvalue(int index, EN_API_FLOAT_TYPE *value); - int DLLEXPORT ENgetqualtype(int *, int *); - int DLLEXPORT ENgeterror(int, char *, int); - int DLLEXPORT ENgetstatistic(int code, int* value); - - int DLLEXPORT ENgetnodeindex(char *, int *); - int DLLEXPORT ENgetnodeid(int, char *); - int DLLEXPORT ENgetnodetype(int, int *); - int DLLEXPORT ENgetnodevalue(int, int, EN_API_FLOAT_TYPE *); - int DLLEXPORT ENgetcoord(int , EN_API_FLOAT_TYPE *, EN_API_FLOAT_TYPE *); - - int DLLEXPORT ENgetnumdemands(int, int *); - int DLLEXPORT ENgetbasedemand(int, int, EN_API_FLOAT_TYPE *); - int DLLEXPORT ENgetdemandpattern(int, int, int *); - - int DLLEXPORT ENgetlinkindex(char *, int *); - int DLLEXPORT ENgetlinkid(int, char *); - int DLLEXPORT ENgetlinktype(int, int *); - int DLLEXPORT ENgetlinknodes(int, int *, int *); - int DLLEXPORT ENgetlinkvalue(int, int, EN_API_FLOAT_TYPE *); - - int DLLEXPORT ENgetcurve(int curveIndex, int *nValues, EN_API_FLOAT_TYPE **xValues, EN_API_FLOAT_TYPE **yValues); - - int DLLEXPORT ENgetversion(int *); - - int DLLEXPORT ENsetcontrol(int, int, int, EN_API_FLOAT_TYPE, int, EN_API_FLOAT_TYPE); - int DLLEXPORT ENsetnodevalue(int, int, EN_API_FLOAT_TYPE); - int DLLEXPORT ENsetlinkvalue(int, int, EN_API_FLOAT_TYPE); - int DLLEXPORT ENaddpattern(char *); - int DLLEXPORT ENsetpattern(int, EN_API_FLOAT_TYPE *, int); - int DLLEXPORT ENsetpatternvalue(int, int, EN_API_FLOAT_TYPE); - int DLLEXPORT ENsettimeparam(int, long); - int DLLEXPORT ENsetoption(int, EN_API_FLOAT_TYPE); - int DLLEXPORT ENsetstatusreport(int); - int DLLEXPORT ENsetqualtype(int, char *, char *, char *); - -#if defined(__cplusplus) -} -#endif - -#endif //TOOLKIT_H \ No newline at end of file diff --git a/src/types.h b/src/types.h index becf1b2..f9bcfab 100755 --- a/src/types.h +++ b/src/types.h @@ -28,7 +28,7 @@ AUTHOR: L. Rossman Definition of 4-byte integers & reals ------------------------------------------- */ -typedef float REAL4; //(2.00.11 - LR) +typedef double REAL4; //(2.00.11 - LR) typedef int INT4; //(2.00.12 - LR) /* diff --git a/src/vars.h b/src/vars.h index 99273e3..4378123 100755 --- a/src/vars.h +++ b/src/vars.h @@ -22,10 +22,10 @@ AUTHOR: L. Rossman *RptFile, /* Report file pointer */ *HydFile, /* Hydraulics file pointer */ *TmpOutFile; /* Temporary file handle */ -EXTERN long HydOffset, /* Hydraulics file byte offset */ + long HydOffset, /* Hydraulics file byte offset */ OutOffset1, /* 1st output file byte offset */ OutOffset2; /* 2nd output file byte offset */ -EXTERN char Msg[MAXMSG+1], /* Text of output message */ + char Msg[MAXMSG+1], /* Text of output message */ InpFname[MAXFNAME+1], /* Input file name */ Rpt1Fname[MAXFNAME+1], /* Primary report file name */ Rpt2Fname[MAXFNAME+1], /* Secondary report file name */ @@ -65,7 +65,7 @@ EXTERN char Msg[MAXMSG+1], /* Text of output message */ OpenQflag, /* Quality system opened flag */ SaveQflag, /* Quality results saved flag */ Saveflag; /* General purpose save flag */ -EXTERN int MaxNodes, /* Node count from input file */ + int MaxNodes, /* Node count from input file */ MaxLinks, /* Link count from input file */ MaxJuncs, /* Junction count */ MaxPipes, /* Pipe count */ @@ -99,7 +99,7 @@ EXTERN int MaxNodes, /* Node count from input file */ PageSize, /* Lines/page in output report */ CheckFreq, /* Hydraulics solver parameter */ MaxCheck; /* Hydraulics solver parameter */ -EXTERN double Ucf[MAXVAR], /* Unit conversion factors */ + double Ucf[MAXVAR], /* Unit conversion factors */ Ctol, /* Water quality tolerance */ Htol, /* Hydraulic head tolerance */ Qtol, /* Flow rate tolerance */ @@ -128,7 +128,7 @@ EXTERN double Ucf[MAXVAR], /* Unit conversion factors */ Wwall, /* Avg. wall reaction rate */ Wtank, /* Avg. tank reaction rate */ Wsource; /* Avg. mass inflow */ -EXTERN long Tstart, /* Starting time of day (sec) */ + long Tstart, /* Starting time of day (sec) */ Hstep, /* Nominal hyd. time step (sec) */ Qstep, /* Quality time step (sec) */ Pstep, /* Time pattern time step (sec) */ @@ -141,12 +141,12 @@ EXTERN long Tstart, /* Starting time of day (sec) */ Hydstep, /* Actual hydraulic time step */ Rulestep, /* Rule evaluation time step */ Dur; /* Duration of simulation (sec) */ -EXTERN SField Field[MAXVAR]; /* Output reporting fields */ + SField Field[MAXVAR]; /* Output reporting fields */ /* Array pointers not allocated and freed in same routine */ -EXTERN char *S, /* Link status */ + char *S, /* Link status */ *OldStat; /* Previous link/tank status */ -EXTERN double *D, /* Node actual demand */ + double *D, /* Node actual demand */ *C, /* Node actual quality */ *E, /* Emitter flows */ *K, /* Link settings */ @@ -193,19 +193,19 @@ EXTERN int _relativeError, _iterations; /* Info about hydraulic solution */ ** The following arrays are used to efficiently manage this sparsity: */ -EXTERN double *Aii, /* Diagonal coeffs. of A */ + double *Aii, /* Diagonal coeffs. of A */ *Aij, /* Non-zero, off-diagonal coeffs. of A */ *F; /* Right hand side coeffs. */ -EXTERN double *P, /* Inverse headloss derivatives */ + double *P, /* Inverse headloss derivatives */ *Y; /* Flow correction factors */ -EXTERN int *Order, /* Node-to-row of A */ + int *Order, /* Node-to-row of A */ *Row, /* Row-to-node of A */ *Ndx; /* Index of link's coeff. in Aij */ /* ** The following arrays store the positions of the non-zero coeffs. ** of the lower triangular portion of A whose values are stored in Aij: */ -EXTERN int *XLNZ, /* Start position of each column in NZSUB */ + int *XLNZ, /* Start position of each column in NZSUB */ *NZSUB, /* Row index of each coeff. in each column */ *LNZ; /* Position of each coeff. in Aij array */ diff --git a/test/Net3.inp b/test/Net3.inp new file mode 100644 index 0000000..8e39dd1 --- /dev/null +++ b/test/Net3.inp @@ -0,0 +1,481 @@ +[TITLE] +EPANET Example Network 3 +Example showing how the percent of Lake water in a dual-source +system changes over time. + +[JUNCTIONS] +;ID Elev Demand Pattern + 10 147 0 ; + 15 32 1 3 ; + 20 129 0 ; + 35 12.5 1 4 ; + 40 131.9 0 ; + 50 116.5 0 ; + 60 0 0 ; + 601 0 0 ; + 61 0 0 ; + 101 42 189.95 ; + 103 43 133.2 ; + 105 28.5 135.37 ; + 107 22 54.64 ; + 109 20.3 231.4 ; + 111 10 141.94 ; + 113 2 20.01 ; + 115 14 52.1 ; + 117 13.6 117.71 ; + 119 2 176.13 ; + 120 0 0 ; + 121 -2 41.63 ; + 123 11 1 2 ; + 125 11 45.6 ; + 127 56 17.66 ; + 129 51 0 ; + 131 6 42.75 ; + 139 31 5.89 ; + 141 4 9.85 ; + 143 -4.5 6.2 ; + 145 1 27.63 ; + 147 18.5 8.55 ; + 149 16 27.07 ; + 151 33.5 144.48 ; + 153 66.2 44.17 ; + 157 13.1 51.79 ; + 159 6 41.32 ; + 161 4 15.8 ; + 163 5 9.42 ; + 164 5 0 ; + 166 -2 2.6 ; + 167 -5 14.56 ; + 169 -5 0 ; + 171 -4 39.34 ; + 173 -4 0 ; + 177 8 58.17 ; + 179 8 0 ; + 181 8 0 ; + 183 11 0 ; + 184 16 0 ; + 185 16 25.65 ; + 187 12.5 0 ; + 189 4 107.92 ; + 191 25 81.9 ; + 193 18 71.31 ; + 195 15.5 0 ; + 197 23 17.04 ; + 199 -2 119.32 ; + 201 0.1 44.61 ; + 203 2 1 5 ; + 204 21 0 ; + 205 21 65.36 ; + 206 1 0 ; + 207 9 69.39 ; + 208 16 0 ; + 209 -2 0.87 ; + 211 7 8.67 ; + 213 7 13.94 ; + 215 7 92.19 ; + 217 6 24.22 ; + 219 4 41.32 ; + 225 8 22.8 ; + 229 10.5 64.18 ; + 231 5 16.48 ; + 237 14 15.61 ; + 239 13 44.61 ; + 241 13 0 ; + 243 14 4.34 ; + 247 18 70.38 ; + 249 18 0 ; + 251 30 24.16 ; + 253 36 54.52 ; + 255 27 40.39 ; + 257 17 0 ; + 259 25 0 ; + 261 0 0 ; + 263 0 0 ; + 265 0 0 ; + 267 21 0 ; + 269 0 0 ; + 271 6 0 ; + 273 8 0 ; + 275 10 0 ; + +[RESERVOIRS] +;ID Head Pattern + River 220.0 ; + Lake 167.0 ; + +[TANKS] +;ID Elevation InitLevel MinLevel MaxLevel Diameter MinVol VolCurve + 1 131.9 13.1 .1 32.1 85 0 ; + 2 116.5 23.5 6.5 40.3 50 0 ; + 3 129.0 29.0 4.0 35.5 164 0 ; + +[PIPES] +;ID Node1 Node2 Length Diameter Roughness MinorLoss Status + 20 3 20 99 99 199 0 Open ; + 40 1 40 99 99 199 0 Open ; + 50 2 50 99 99 199 0 Open ; + 60 River 60 1231 24 140 0 Open ; + 101 10 101 14200 18 110 0 Open ; + 103 101 103 1350 16 130 0 Open ; + 105 101 105 2540 12 130 0 Open ; + 107 105 107 1470 12 130 0 Open ; + 109 103 109 3940 16 130 0 Open ; + 111 109 111 2000 12 130 0 Open ; + 112 115 111 1160 12 130 0 Open ; + 113 111 113 1680 12 130 0 Open ; + 114 115 113 2000 8 130 0 Open ; + 115 107 115 1950 8 130 0 Open ; + 116 113 193 1660 12 130 0 Open ; + 117 263 105 2725 12 130 0 Open ; + 119 115 117 2180 12 130 0 Open ; + 120 119 120 730 12 130 0 Open ; + 121 120 117 1870 12 130 0 Open ; + 122 121 120 2050 8 130 0 Open ; + 123 121 119 2000 30 141 0 Open ; + 125 123 121 1500 30 141 0 Open ; + 129 121 125 930 24 130 0 Open ; + 131 125 127 3240 24 130 0 Open ; + 133 20 127 785 20 130 0 Open ; + 135 127 129 900 24 130 0 Open ; + 137 129 131 6480 16 130 0 Open ; + 145 129 139 2750 8 130 0 Open ; + 147 139 141 2050 8 130 0 Open ; + 149 143 141 1400 8 130 0 Open ; + 151 15 143 1650 8 130 0 Open ; + 153 145 141 3510 12 130 0 Open ; + 155 147 145 2200 12 130 0 Open ; + 159 147 149 880 12 130 0 Open ; + 161 149 151 1020 8 130 0 Open ; + 163 151 153 1170 12 130 0 Open ; + 169 125 153 4560 8 130 0 Open ; + 171 119 151 3460 12 130 0 Open ; + 173 119 157 2080 30 141 0 Open ; + 175 157 159 2910 30 141 0 Open ; + 177 159 161 2000 30 141 0 Open ; + 179 161 163 430 30 141 0 Open ; + 180 163 164 150 14 130 0 Open ; + 181 164 166 490 14 130 0 Open ; + 183 265 169 590 30 141 0 Open ; + 185 167 169 60 8 130 0 Open ; + 186 187 204 99.9 8 130 0 Open ; + 187 169 171 1270 30 141 0 Open ; + 189 171 173 50 30 141 0 Open ; + 191 271 171 760 24 130 0 Open ; + 193 35 181 30 24 130 0 Open ; + 195 181 177 30 12 130 0 Open ; + 197 177 179 30 12 130 0 Open ; + 199 179 183 210 12 130 0 Open ; + 201 40 179 1190 12 130 0 Open ; + 202 185 184 99.9 8 130 0 Open ; + 203 183 185 510 8 130 0 Open ; + 204 184 205 4530. 12 130 0 Open ; + 205 204 185 1325. 12 130 0 Open ; + 207 189 183 1350 12 130 0 Open ; + 209 189 187 500 8 130 0 Open ; + 211 169 269 646 12 130 0 Open ; + 213 191 187 2560 12 130 0 Open ; + 215 267 189 1230 12 130 0 Open ; + 217 191 193 520 12 130 0 Open ; + 219 193 195 360 12 130 0 Open ; + 221 161 195 2300 8 130 0 Open ; + 223 197 191 1150 12 130 0 Open ; + 225 111 197 2790 12 130 0 Open ; + 229 173 199 4000 24 141 0 Open ; + 231 199 201 630 24 141 0 Open ; + 233 201 203 120 24 130 0 Open ; + 235 199 273 725 12 130 0 Open ; + 237 205 207 1200 12 130 0 Open ; + 238 207 206 450 12 130 0 Open ; + 239 275 207 1430 12 130 0 Open ; + 240 206 208 510 12 130 0 Open ; + 241 208 209 885 12 130 0 Open ; + 243 209 211 1210 16 130 0 Open ; + 245 211 213 990 16 130 0 Open ; + 247 213 215 4285 16 130 0 Open ; + 249 215 217 1660 16 130 0 Open ; + 251 217 219 2050 14 130 0 Open ; + 257 217 225 1560 12 130 0 Open ; + 261 213 229 2200 8 130 0 Open ; + 263 229 231 1960 12 130 0 Open ; + 269 211 237 2080 12 130 0 Open ; + 271 237 229 790 8 130 0 Open ; + 273 237 239 510 12 130 0 Open ; + 275 239 241 35 12 130 0 Open ; + 277 241 243 2200 12 130 0 Open ; + 281 241 247 445 10 130 0 Open ; + 283 239 249 430 12 130 0 Open ; + 285 247 249 10 12 130 0 Open ; + 287 247 255 1390 10 130 0 Open ; + 289 50 255 925 10 130 0 Open ; + 291 255 253 1100 10 130 0 Open ; + 293 255 251 1100 8 130 0 Open ; + 295 249 251 1450 12 130 0 Open ; + 297 120 257 645 8 130 0 Open ; + 299 257 259 350 8 130 0 Open ; + 301 259 263 1400 8 130 0 Open ; + 303 257 261 1400 8 130 0 Open ; + 305 117 261 645 12 130 0 Open ; + 307 261 263 350 12 130 0 Open ; + 309 265 267 1580 8 130 0 Open ; + 311 193 267 1170 12 130 0 Open ; + 313 269 189 646 12 130 0 Open ; + 315 181 271 260 24 130 0 Open ; + 317 273 275 2230 8 130 0 Open ; + 319 273 205 645 12 130 0 Open ; + 321 163 265 1200 30 141 0 Open ; + 323 201 275 300 12 130 0 Open ; + 325 269 271 1290 8 130 0 Open ; + 329 61 123 45500 30 140 0 Open ; + 330 60 601 1 30 140 0 Closed ; + 333 601 61 1 30 140 0 Open ; + +[PUMPS] +;ID Node1 Node2 Parameters + 10 Lake 10 HEAD 1 ; + 335 60 61 HEAD 2 ; + +[VALVES] +;ID Node1 Node2 Diameter Type Setting MinorLoss + +[TAGS] + +[DEMANDS] +;Junction Demand Pattern Category + +[STATUS] +;ID Status/Setting + 10 Closed + +[PATTERNS] +;ID Multipliers +;General Default Demand Pattern + 1 1.34 1.94 1.46 1.44 .76 .92 + 1 .85 1.07 .96 1.1 1.08 1.19 + 1 1.16 1.08 .96 .83 .79 .74 + 1 .64 .64 .85 .96 1.24 1.67 +;Demand Pattern for Node 123 + 2 0 0 0 0 0 1219 + 2 0 0 0 1866 1836 1818 + 2 1818 1822 1822 1817 1824 1816 + 2 1833 1817 1830 1814 1840 1859 +;Demand Pattern for Node 15 + 3 620 620 620 620 620 360 + 3 360 0 0 0 0 360 + 3 360 360 360 360 0 0 + 3 0 0 0 0 360 360 +;Demand Pattern for Node 35 + 4 1637 1706 1719 1719 1791 1819 + 4 1777 1842 1815 1825 1856 1801 + 4 1819 1733 1664 1620 1613 1620 + 4 1616 1647 1627 1627 1671 1668 +;Demand Pattern for Node 203 + 5 4439 4531 4511 4582 4531 4582 + 5 4572 4613 4643 4643 4592 4613 + 5 4531 4521 4449 4439 4449 4460 + 5 4439 4419 4368 4399 4470 4480 + +[CURVES] +;ID X-Value Y-Value +;PUMP: Pump Curve for Pump 10 (Lake Source) + 1 0 104. + 1 2000. 92. + 1 4000. 63. +;PUMP: Pump Curve for Pump 335 (River Source) + 2 0 200. + 2 8000. 138. + 2 14000. 86. + +[CONTROLS] +;Lake source operates only part of the day +Link 10 OPEN AT TIME 1 +Link 10 CLOSED AT TIME 15 + +;Pump 335 controlled by level in Tank 1 +;When pump is closed, bypass pipe is opened +Link 335 OPEN IF Node 1 BELOW 17.1 +Link 335 CLOSED IF Node 1 ABOVE 19.1 +Link 330 CLOSED IF Node 1 BELOW 17.1 +Link 330 OPEN IF Node 1 ABOVE 19.1 + + +[RULES] + +[ENERGY] + Global Efficiency 75 + Global Price 0.0 + Demand Charge 0.0 + +[EMITTERS] +;Junction Coefficient + +[QUALITY] +;Node InitQual + + +[SOURCES] +;Node Type Quality Pattern + +[REACTIONS] +;Type Pipe/Tank Coefficient + + +[REACTIONS] + Order Bulk 1 + Order Tank 1 + Order Wall 1 + Global Bulk 0.0 + Global Wall 0.0 + Limiting Potential 0.0 + Roughness Correlation 0.0 + +[MIXING] +;Tank Model + +[TIMES] + Duration 24:00 + Hydraulic Timestep 1:00 + Quality Timestep 0:05 + Pattern Timestep 1:00 + Pattern Start 0:00 + Report Timestep 1:00 + Report Start 0:00 + Start ClockTime 12 am + Statistic None + +[REPORT] + Status Yes + Summary No + Page 0 + +[OPTIONS] + Units GPM + Headloss H-W + Specific Gravity 1.0 + Viscosity 1.0 + Trials 40 + Accuracy 0.001 + CHECKFREQ 2 + MAXCHECK 10 + DAMPLIMIT 0 + Unbalanced Continue 10 + Pattern 1 + Demand Multiplier 1.0 + Emitter Exponent 0.5 + Quality Trace Lake + Diffusivity 1.0 + Tolerance 0.01 + +[COORDINATES] +;Node X-Coord Y-Coord + 10 9.00 27.85 + 15 38.68 23.76 + 20 29.44 26.91 + 35 25.46 10.52 + 40 27.02 9.81 + 50 33.01 3.01 + 60 23.90 29.94 + 601 23.00 29.49 + 61 23.71 29.03 + 101 13.81 22.94 + 103 12.96 21.31 + 105 16.97 21.28 + 107 18.45 20.46 + 109 17.64 18.92 + 111 20.21 17.53 + 113 22.04 16.61 + 115 20.98 19.18 + 117 21.69 21.28 + 119 23.70 22.76 + 120 22.08 23.10 + 121 23.54 25.50 + 123 23.37 27.31 + 125 24.59 25.64 + 127 29.29 26.40 + 129 30.32 26.39 + 131 37.89 29.55 + 139 33.28 24.54 + 141 35.68 23.08 + 143 37.47 21.97 + 145 33.02 19.29 + 147 30.24 20.38 + 149 29.62 20.74 + 151 28.29 21.39 + 153 28.13 22.63 + 157 24.85 20.16 + 159 23.12 17.50 + 161 25.10 15.28 + 163 25.39 14.98 + 164 25.98 15.14 + 166 26.48 15.13 + 167 25.88 12.98 + 169 25.68 12.74 + 171 26.65 11.80 + 173 26.87 11.59 + 179 25.71 10.40 + 181 25.72 10.74 + 183 25.45 10.18 + 184 25.15 9.52 + 185 25.01 9.67 + 187 23.64 11.04 + 189 24.15 11.37 + 191 22.10 14.07 + 193 22.88 14.35 + 195 23.18 14.72 + 197 20.97 15.18 + 199 29.42 8.44 + 201 30.89 8.57 + 203 31.14 8.89 + 204 23.80 10.90 + 205 29.20 6.46 + 206 31.66 6.64 + 207 31.00 6.61 + 208 32.54 6.81 + 209 33.76 6.59 + 211 34.20 5.54 + 213 35.26 6.16 + 215 39.95 8.73 + 217 42.11 8.67 + 219 44.86 9.32 + 225 43.53 7.38 + 229 36.16 3.49 + 231 38.38 2.54 + 237 35.37 3.08 + 239 35.76 2.31 + 241 35.87 2.11 + 243 37.04 0.00 + 247 35.02 2.05 + 249 35.02 1.81 + 251 34.15 1.10 + 253 32.17 1.88 + 255 33.51 2.45 + 257 21.17 23.32 + 259 20.80 23.40 + 261 20.79 21.45 + 263 20.32 21.57 + 265 25.39 13.60 + 267 23.38 12.95 + 269 25.03 12.14 + 271 25.97 11.00 + 273 29.16 7.38 + 275 31.07 8.29 + River 24.15 31.06 + Lake 8.00 27.53 + 1 27.46 9.84 + 2 32.99 3.45 + 3 29.41 27.27 + +[VERTICES] +;Link X-Coord Y-Coord + +[LABELS] +;X-Coord Y-Coord Label & Anchor Node + 8.00 29.42 "LAKE" + 25.00 31.10 "RIVER" + +[BACKDROP] + DIMENSIONS 6.16 -1.55 46.70 32.61 + UNITS None + FILE + OFFSET 0.00 0.00 + +[END] diff --git a/test/sampletown.inp b/test/sampletown.inp new file mode 100755 index 0000000..787f689 --- /dev/null +++ b/test/sampletown.inp @@ -0,0 +1,150 @@ +[TITLE] + + +[JUNCTIONS] +;ID Elev Demand Pattern + TreatmentPlant 0 0 ; + Montgomery 0 80 ; + Tennessee 0 250 ; + Reading 0 100 ; + Mills 0 1000 stepdemand ; + Vine 0 50 ; + +[RESERVOIRS] +;ID Head Pattern + Resr 100 ; + +[TANKS] +;ID Elevation InitLevel MinLevel MaxLevel Diameter MinVol VolCurve + NewportTank 50 40 0 80 20 0 ; + +[PIPES] +;ID Node1 Node2 Length Diameter Roughness MinorLoss Status + ReservoirCheckValve Resr TreatmentPlant 10 4 100 0 CV ; + 2 TreatmentPlant Montgomery 3 6 100 0 Open ; + 3 Montgomery Tennessee 6 6 100 0 Open ; + 4 Tennessee Reading 12 6 100 0 Open ; + 5 Reading Mills 24 6 100 0 Open ; + NewportTankPipe Tennessee NewportTank 50 3 100 0 Open ; + 1 Reading Vine 50 6 100 0 Open ; + +[PUMPS] +;ID Node1 Node2 Parameters + +[VALVES] +;ID Node1 Node2 Diameter Type Setting MinorLoss + +[TAGS] + +[DEMANDS] +;Junction Demand Pattern Category + +[STATUS] +;ID Status/Setting + +[PATTERNS] +;ID Multipliers +; + stepdemand 1 1 1 1 1 1 + stepdemand 0 0 0 0 0 0 + +[CURVES] +;ID X-Value Y-Value + +[CONTROLS] + + + + +[RULES] + + + +[ENERGY] + Global Efficiency 75 + Global Price 0 + Demand Charge 0 + +[EMITTERS] +;Junction Coefficient + +[QUALITY] +;Node InitQual + +[SOURCES] +;Node Type Quality Pattern + +[REACTIONS] +;Type Pipe/Tank Coefficient + + +[REACTIONS] + Order Bulk 1 + Order Tank 1 + Order Wall 1 + Global Bulk 0 + Global Wall 0 + Limiting Potential 0 + Roughness Correlation 0 + +[MIXING] +;Tank Model + +[TIMES] + Duration 24:00 + Hydraulic Timestep 0:10 + Quality Timestep 0:01 + Pattern Timestep 1:00 + Pattern Start 0:00 + Report Timestep 1:00 + Report Start 0:00 + Start ClockTime 12 am + Statistic NONE + +[REPORT] + Status No + Summary No + Page 0 + +[OPTIONS] + Units GPM + Headloss H-W + Specific Gravity 1 + Viscosity 1 + Trials 40 + Accuracy 0.001 + CHECKFREQ 2 + MAXCHECK 10 + DAMPLIMIT 0 + Unbalanced Continue 10 + Pattern 1 + Demand Multiplier 1.0 + Emitter Exponent 0.5 + Quality Trace Resr + Diffusivity 1 + Tolerance 0.01 + +[COORDINATES] +;Node X-Coord Y-Coord + TreatmentPlant -1075.95 6943.94 + Montgomery 1273.73 6946.20 + Tennessee 3204.11 6946.20 + Reading 6352.85 6946.20 + Mills 10226.04 6943.94 + Vine 6356.24 5063.29 + Resr -2414.20 6923.08 + NewportTank 3209.76 8318.26 + +[VERTICES] +;Link X-Coord Y-Coord + +[LABELS] +;X-Coord Y-Coord Label & Anchor Node + +[BACKDROP] + DIMENSIONS 0.00 0.00 10000.00 10000.00 + UNITS Meters + FILE + OFFSET 0.00 0.00 + +[END] diff --git a/test/simplenet.inp b/test/simplenet.inp new file mode 100644 index 0000000..a0ccdc0 --- /dev/null +++ b/test/simplenet.inp @@ -0,0 +1,123 @@ +[TITLE] +EPANET Example Network 3 +Example showing how the percent of Lake water in a dual-source +system changes over time. + +[JUNCTIONS] +;ID Elev Demand Pattern + node1 147 1 1 ; + node2 147 1 1 + +[RESERVOIRS] +;ID Head Pattern + reservoir 220.0 ; + +[TANKS] +;ID Elevation InitLevel MinLevel MaxLevel Diameter MinVol VolCurve + +[PIPES] +;ID Node1 Node2 Length Diameter Roughness MinorLoss Status + pipe1 reservoir node1 100 12 100 0 Open ; + pipe2 node1 node2 100 12 100 0 Open ; + +[PUMPS] +;ID Node1 Node2 Parameters + +[VALVES] +;ID Node1 Node2 Diameter Type Setting MinorLoss + +[TAGS] + +[DEMANDS] +;Junction Demand Pattern Category + +[STATUS] +;ID Status/Setting + 10 Closed + +[PATTERNS] +;ID Multipliers +;General Default Demand Pattern + 1 1 + +[CURVES] +;ID X-Value Y-Value + + +[CONTROLS] + +[RULES] + +[ENERGY] + Global Efficiency 75 + Global Price 0.0 + Demand Charge 0.0 + +[EMITTERS] +;Junction Coefficient + +[QUALITY] +;Node InitQual + + +[SOURCES] +;Node Type Quality Pattern + +[REACTIONS] +;Type Pipe/Tank Coefficient + + +[REACTIONS] + Order Bulk 1 + Order Tank 1 + Order Wall 1 + Global Bulk 0.0 + Global Wall 0.0 + Limiting Potential 0.0 + Roughness Correlation 0.0 + +[MIXING] +;Tank Model + +[TIMES] + Duration 24:00 + Hydraulic Timestep 0:05 + Quality Timestep 0:05 + Pattern Timestep 1:00 + Pattern Start 0:00 + Report Timestep 1:00 + Report Start 0:00 + Start ClockTime 12 am + Statistic None + +[REPORT] + Status Yes + Summary No + Page 0 + +[OPTIONS] + Units GPM + Headloss H-W + Specific Gravity 1.0 + Viscosity 1.0 + Trials 40 + Accuracy 0.001 + CHECKFREQ 2 + MAXCHECK 10 + DAMPLIMIT 0 + Unbalanced Continue 10 + Pattern 1 + Demand Multiplier 1.0 + Emitter Exponent 0.5 + Quality Trace reservoir + Diffusivity 1.0 + Tolerance 0.01 + +[COORDINATES] +;Node X-Coord Y-Coord + + +[VERTICES] +;Link X-Coord Y-Coord + +[END]