Commit the EPANET2.00.12 to trunk, the changes are summarized at \EPANET\BASE\trunk\doc\changes.txt.

git-svn-id: https://epanet.svn.sourceforge.net/svnroot/epanet/BASE/trunk@95 c320cabd-cc23-0410-96d8-e60fbf53ed7f
This commit is contained in:
Feng Shang
2008-03-06 20:06:03 +00:00
parent 48d806d9da
commit c38b8d0ac8
40 changed files with 18221 additions and 18252 deletions

View File

@@ -1,31 +0,0 @@
Water-Distribution-Network-Model
================================
ORD Water Distribution Network Model (AKA "EPANET")
Introduction
------------
This is the official EPANET source code repository maintained by US EPA ORD, NRMRL, Water Supply and Water Resources Division located in Cincinnati, Ohio.
EPANET performs extended period simulation of hydraulics and water quality within potable water distribution networks. EPANET source code is written in the C Programming Language and released in the Public Domain.
Lewis Rossman created EPANET in the early 1990s and actively developed and maintained the project until 2008. Over the intervening years he received support from too many members of the WDS modeling community to name individually.
Intended Audience
-----------------
The intended audience for this repository can be divided roughly into two groups:
- Programmers interested in water distribution system modeling
- Engineers working on water distribution system modeling interested in programming
Git Hub and software repositories are geared towards people with software development experience. If you've ever hacked EPANET or built a Matlab script for running hydraulic simulations, you may find the contents of this repository helpful. We encourage you to fork EPANET and develop a great new feature to share with the community.
Find Out More
-------------
The source code distributed here is identical to the code found at the official [EPANET Website](http://www.epa.gov/nrmrl/wswrd/dw/epanet.html).
Active Development
------------------
We are actively developing features in the following areas:
- Real Time Monitoring
- Water Quality

0
build/Cyg/CreateMSLib.bat.template Normal file → Executable file
View File

0
build/Cyg/Makefile Normal file → Executable file
View File

0
build/Cyg/runepanet.sh.template Normal file → Executable file
View File

222
build/Linux/Makefile Normal file → Executable file
View File

@@ -1,111 +1,111 @@
# Linux Makefile for EPANET # Linux Makefile for EPANET
# This will build EPANET as a shared object library # This will build EPANET as a shared object library
# (libepanet_gcc_<Rev>.so) under Linux/Unix, and a standalone # (libepanet_gcc_<Rev>.so) under Linux/Unix, and a standalone
# executable (epanet_gcc_<Rev>). # executable (epanet_gcc_<Rev>).
# The following targets are defined: # The following targets are defined:
# make # make
# -Builds libepanet_gcc_<Rev>.so, epanet_gcc_<Rev> # -Builds libepanet_gcc_<Rev>.so, epanet_gcc_<Rev>
# make install # make install
# -Creates shell wrapper runepanet_<Rev>.sh that executes epanet_gcc_<Rev>.exe. # -Creates shell wrapper runepanet_<Rev>.sh that executes epanet_gcc_<Rev>.exe.
# The runepanet_<Rev>.sh wrapper simply exports # The runepanet_<Rev>.sh wrapper simply exports
# environment variables that help locate the runtime library, # environment variables that help locate the runtime library,
# allowing you to specify your own library locations. # allowing you to specify your own library locations.
# -Installs epanet_gcc_<Rev> and runepanet_<Rev>.sh # -Installs epanet_gcc_<Rev> and runepanet_<Rev>.sh
# in <prefix>/bin, where <prefix> defaults to ~ (and can be set # in <prefix>/bin, where <prefix> defaults to ~ (and can be set
# below to something different - see "Install directories") # below to something different - see "Install directories")
# -Installs libepanet_gcc_<Rev>.so in <prefix>/lib # -Installs libepanet_gcc_<Rev>.so in <prefix>/lib
# -Installs epanet2.h in <prefix>/include. This is the required # -Installs epanet2.h in <prefix>/include. This is the required
# header file for the EPANET programmer's toolkit, and thus # header file for the EPANET programmer's toolkit, and thus
# <prefix>/include should be on your CPP include search path # <prefix>/include should be on your CPP include search path
# for subsequent use of the toolkit and linking with the # for subsequent use of the toolkit and linking with the
# library libepanet_gcc_<Rev>.so # library libepanet_gcc_<Rev>.so
# make clean # make clean
# -Removes object and library files, returning the build directory # -Removes object and library files, returning the build directory
# to its pristine state. # to its pristine state.
# You may wish to change the install path 'prefix', # You may wish to change the install path 'prefix',
# or the compiler flags, but these defaults should be fine. # or the compiler flags, but these defaults should be fine.
SHELL = /bin/sh SHELL = /bin/sh
# Target filenames # Target filenames
# svnname.sh constructs a name: <prefix><root><Rev><postfix> # svnname.sh constructs a name: <prefix><root><Rev><postfix>
# where <Rev> is the atomic revision number of the svn repo. # where <Rev> is the atomic revision number of the svn repo.
epanetsvnpath = ../../.. epanetsvnpath = ../../..
epanetrootname := $(shell ../svnname.sh $(epanetsvnpath) "" epanet_gcc_ "") epanetrootname := $(shell ../svnname.sh $(epanetsvnpath) "" epanet_gcc_ "")
libname := lib$(epanetrootname).so libname := lib$(epanetrootname).so
exename := $(epanetrootname) exename := $(epanetrootname)
# Shell wrapper # Shell wrapper
runcmdtemplate = runepanet.sh.template runcmdtemplate = runepanet.sh.template
runcmdname = $(shell ../svnname.sh $(epanetsvnpath) "" runepanet_ .sh) runcmdname = $(shell ../svnname.sh $(epanetsvnpath) "" runepanet_ .sh)
# Location of EPANET toolkit includes # Location of EPANET toolkit includes
epanetincludedir = ../../include epanetincludedir = ../../include
# Search path for sources # Search path for sources
epanetsrcdir = ../../src epanetsrcdir = ../../src
VPATH = $(epanetsrcdir):$(epanetincludedir) VPATH = $(epanetsrcdir):$(epanetincludedir)
# Install directories # Install directories
prefix = ~ prefix = ~
exec_prefix = $(prefix) exec_prefix = $(prefix)
libdir = $(exec_prefix)/lib libdir = $(exec_prefix)/lib
bindir = $(exec_prefix)/bin bindir = $(exec_prefix)/bin
includedir = $(prefix)/include includedir = $(prefix)/include
datarootdir = $(prefix)/share datarootdir = $(prefix)/share
docdir = $(datarootdir)/doc/epanet docdir = $(datarootdir)/doc/epanet
# Compiler and flags # Compiler and flags
CC = gcc CC = gcc
CFLAGS = -g -O -fPIC CFLAGS = -g -O -fPIC
CPPFLAGS = -I $(epanetincludedir) CPPFLAGS = -I $(epanetincludedir)
LDFLAGS = -L . -W1,-rpath,$(libdir) -lm LDFLAGS = -L . -W1,-rpath,$(libdir) -lm
# Installer # Installer
INSTALL = install INSTALL = install
INSTALL_PROGRAM = $(INSTALL) INSTALL_PROGRAM = $(INSTALL)
INSTALL_DATA = $(INSTALL) -m 644 INSTALL_DATA = $(INSTALL) -m 644
# Files for the shared object library # Files for the shared object library
epanet_objs=hash.o hydraul.o inpfile.o input1.o input2.o \ epanet_objs=hash.o hydraul.o inpfile.o input1.o input2.o \
input3.o mempool.o output.o quality.o report.o \ input3.o mempool.o output.o quality.o report.o \
rules.o smatrix.o rules.o smatrix.o
# Epanet header files # Epanet header files
epanet_heads=enumstxt.h funcs.h hash.h mempool.h text.h toolkit.h types.h vars.h epanet_heads=enumstxt.h funcs.h hash.h mempool.h text.h toolkit.h types.h vars.h
# Epanet main program # Epanet main program
epanet_main=epanet epanet_main=epanet
# Epanet main program header files # Epanet main program header files
epanet_main_heads=epanet2.h epanet_main_heads=epanet2.h
.PHONY: all .PHONY: all
all: $(libname) $(exename) all: $(libname) $(exename)
$(libname): $(epanet_objs) $(libname): $(epanet_objs)
$(CC) $(CFLAGS) $(CPPFLAGS) -D SOL -c $(epanetsrcdir)/$(epanet_main).c $(CC) $(CFLAGS) $(CPPFLAGS) -D SOL -c $(epanetsrcdir)/$(epanet_main).c
$(CC) $(CFLAGS) $(LDFLAGS) -shared -o $@ $(epanet_main).o $^ $(CC) $(CFLAGS) $(LDFLAGS) -shared -o $@ $(epanet_main).o $^
$(exename): $(libname) $(epanet_main_heads) $(exename): $(libname) $(epanet_main_heads)
$(CC) $(CFLAGS) $(CPPFLAGS) -D CLE -c $(epanetsrcdir)/$(epanet_main).c $(CC) $(CFLAGS) $(CPPFLAGS) -D CLE -c $(epanetsrcdir)/$(epanet_main).c
$(CC) $(CFLAGS) -o $@ $(epanet_main).o -l$(epanetrootname) $(LDFLAGS) $(CC) $(CFLAGS) -o $@ $(epanet_main).o -l$(epanetrootname) $(LDFLAGS)
$(epanet_objs): $(epanet_heads) $(epanet_objs): $(epanet_heads)
.PHONY: install .PHONY: install
install: install:
cat $(runcmdtemplate) | sed 's|libdir|$(libdir)|' \ cat $(runcmdtemplate) | sed 's|libdir|$(libdir)|' \
| sed 's|exename|$(bindir)/$(exename)|' \ | sed 's|exename|$(bindir)/$(exename)|' \
> $(runcmdname) > $(runcmdname)
$(INSTALL_PROGRAM) -D $(exename) $(bindir)/$(exename) $(INSTALL_PROGRAM) -D $(exename) $(bindir)/$(exename)
$(INSTALL_PROGRAM) -D $(libname) $(libdir)/$(libname) $(INSTALL_PROGRAM) -D $(libname) $(libdir)/$(libname)
$(INSTALL_DATA) -D $(epanetincludedir)/epanet2.h $(includedir)/epanet2.h $(INSTALL_DATA) -D $(epanetincludedir)/epanet2.h $(includedir)/epanet2.h
$(INSTALL_PROGRAM) -D $(runcmdname) $(bindir)/$(runcmdname) $(INSTALL_PROGRAM) -D $(runcmdname) $(bindir)/$(runcmdname)
.PHONY: uninstall .PHONY: uninstall
uninstall: uninstall:
.PHONY: check .PHONY: check
check: check:
.PHONY: clean .PHONY: clean
clean: clean:
-/bin/rm *.o $(libname) $(exename) $(runcmdname) -/bin/rm *.o $(libname) $(exename) $(runcmdname)

0
build/Linux/runepanet.sh.template Normal file → Executable file
View File

0
build/MSVC/Epanet/Epanet.ncb Normal file → Executable file
View File

60
build/MSVC/Epanet/Epanet.sln Normal file → Executable file
View File

@@ -1,30 +1,30 @@
Microsoft Visual Studio Solution File, Format Version 8.00 Microsoft Visual Studio Solution File, Format Version 8.00
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "EpanetLib", "..\EpanetLib\EpanetLib.vcproj", "{0B2334F0-D2D3-4F11-AA93-D8E2AED5F135}" Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "EpanetLib", "..\EpanetLib\EpanetLib.vcproj", "{0B2334F0-D2D3-4F11-AA93-D8E2AED5F135}"
ProjectSection(ProjectDependencies) = postProject ProjectSection(ProjectDependencies) = postProject
EndProjectSection EndProjectSection
EndProject EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "EpanetRun", "..\EpanetRun\EpanetRun.vcproj", "{11056F72-0330-445F-8DF9-0734DC4F785B}" Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "EpanetRun", "..\EpanetRun\EpanetRun.vcproj", "{11056F72-0330-445F-8DF9-0734DC4F785B}"
ProjectSection(ProjectDependencies) = postProject ProjectSection(ProjectDependencies) = postProject
{0B2334F0-D2D3-4F11-AA93-D8E2AED5F135} = {0B2334F0-D2D3-4F11-AA93-D8E2AED5F135} {0B2334F0-D2D3-4F11-AA93-D8E2AED5F135} = {0B2334F0-D2D3-4F11-AA93-D8E2AED5F135}
EndProjectSection EndProjectSection
EndProject EndProject
Global Global
GlobalSection(SolutionConfiguration) = preSolution GlobalSection(SolutionConfiguration) = preSolution
Debug = Debug Debug = Debug
Release = Release Release = Release
EndGlobalSection EndGlobalSection
GlobalSection(ProjectConfiguration) = postSolution GlobalSection(ProjectConfiguration) = postSolution
{0B2334F0-D2D3-4F11-AA93-D8E2AED5F135}.Debug.ActiveCfg = Debug|Win32 {0B2334F0-D2D3-4F11-AA93-D8E2AED5F135}.Debug.ActiveCfg = Debug|Win32
{0B2334F0-D2D3-4F11-AA93-D8E2AED5F135}.Debug.Build.0 = Debug|Win32 {0B2334F0-D2D3-4F11-AA93-D8E2AED5F135}.Debug.Build.0 = Debug|Win32
{0B2334F0-D2D3-4F11-AA93-D8E2AED5F135}.Release.ActiveCfg = Release|Win32 {0B2334F0-D2D3-4F11-AA93-D8E2AED5F135}.Release.ActiveCfg = Release|Win32
{0B2334F0-D2D3-4F11-AA93-D8E2AED5F135}.Release.Build.0 = Release|Win32 {0B2334F0-D2D3-4F11-AA93-D8E2AED5F135}.Release.Build.0 = Release|Win32
{11056F72-0330-445F-8DF9-0734DC4F785B}.Debug.ActiveCfg = Debug|Win32 {11056F72-0330-445F-8DF9-0734DC4F785B}.Debug.ActiveCfg = Debug|Win32
{11056F72-0330-445F-8DF9-0734DC4F785B}.Debug.Build.0 = Debug|Win32 {11056F72-0330-445F-8DF9-0734DC4F785B}.Debug.Build.0 = Debug|Win32
{11056F72-0330-445F-8DF9-0734DC4F785B}.Release.ActiveCfg = Release|Win32 {11056F72-0330-445F-8DF9-0734DC4F785B}.Release.ActiveCfg = Release|Win32
{11056F72-0330-445F-8DF9-0734DC4F785B}.Release.Build.0 = Release|Win32 {11056F72-0330-445F-8DF9-0734DC4F785B}.Release.Build.0 = Release|Win32
EndGlobalSection EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution GlobalSection(ExtensibilityGlobals) = postSolution
EndGlobalSection EndGlobalSection
GlobalSection(ExtensibilityAddIns) = postSolution GlobalSection(ExtensibilityAddIns) = postSolution
EndGlobalSection EndGlobalSection
EndGlobal EndGlobal

0
build/MSVC/Epanet/Epanet.suo Normal file → Executable file
View File

0
build/MSVC/EpanetLib/EpanetLib.ncb Normal file → Executable file
View File

42
build/MSVC/EpanetLib/EpanetLib.sln Normal file → Executable file
View File

@@ -1,21 +1,21 @@
Microsoft Visual Studio Solution File, Format Version 8.00 Microsoft Visual Studio Solution File, Format Version 8.00
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "EpanetLib", "EpanetLib.vcproj", "{0B2334F0-D2D3-4F11-AA93-D8E2AED5F135}" Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "EpanetLib", "EpanetLib.vcproj", "{0B2334F0-D2D3-4F11-AA93-D8E2AED5F135}"
ProjectSection(ProjectDependencies) = postProject ProjectSection(ProjectDependencies) = postProject
EndProjectSection EndProjectSection
EndProject EndProject
Global Global
GlobalSection(SolutionConfiguration) = preSolution GlobalSection(SolutionConfiguration) = preSolution
Debug = Debug Debug = Debug
Release = Release Release = Release
EndGlobalSection EndGlobalSection
GlobalSection(ProjectConfiguration) = postSolution GlobalSection(ProjectConfiguration) = postSolution
{0B2334F0-D2D3-4F11-AA93-D8E2AED5F135}.Debug.ActiveCfg = Debug|Win32 {0B2334F0-D2D3-4F11-AA93-D8E2AED5F135}.Debug.ActiveCfg = Debug|Win32
{0B2334F0-D2D3-4F11-AA93-D8E2AED5F135}.Debug.Build.0 = Debug|Win32 {0B2334F0-D2D3-4F11-AA93-D8E2AED5F135}.Debug.Build.0 = Debug|Win32
{0B2334F0-D2D3-4F11-AA93-D8E2AED5F135}.Release.ActiveCfg = Release|Win32 {0B2334F0-D2D3-4F11-AA93-D8E2AED5F135}.Release.ActiveCfg = Release|Win32
{0B2334F0-D2D3-4F11-AA93-D8E2AED5F135}.Release.Build.0 = Release|Win32 {0B2334F0-D2D3-4F11-AA93-D8E2AED5F135}.Release.Build.0 = Release|Win32
EndGlobalSection EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution GlobalSection(ExtensibilityGlobals) = postSolution
EndGlobalSection EndGlobalSection
GlobalSection(ExtensibilityAddIns) = postSolution GlobalSection(ExtensibilityAddIns) = postSolution
EndGlobalSection EndGlobalSection
EndGlobal EndGlobal

0
build/MSVC/EpanetLib/EpanetLib.suo Normal file → Executable file
View File

402
build/MSVC/EpanetLib/EpanetLib.vcproj Normal file → Executable file
View File

@@ -1,201 +1,201 @@
<?xml version="1.0" encoding="Windows-1252"?> <?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject <VisualStudioProject
ProjectType="Visual C++" ProjectType="Visual C++"
Version="7.10" Version="7.10"
Name="EpanetLib" Name="EpanetLib"
ProjectGUID="{0B2334F0-D2D3-4F11-AA93-D8E2AED5F135}" ProjectGUID="{0B2334F0-D2D3-4F11-AA93-D8E2AED5F135}"
Keyword="Win32Proj"> Keyword="Win32Proj">
<Platforms> <Platforms>
<Platform <Platform
Name="Win32"/> Name="Win32"/>
</Platforms> </Platforms>
<Configurations> <Configurations>
<Configuration <Configuration
Name="Debug|Win32" Name="Debug|Win32"
OutputDirectory="Debug" OutputDirectory="Debug"
IntermediateDirectory="Debug" IntermediateDirectory="Debug"
ConfigurationType="2" ConfigurationType="2"
CharacterSet="2"> CharacterSet="2">
<Tool <Tool
Name="VCCLCompilerTool" Name="VCCLCompilerTool"
Optimization="0" Optimization="0"
AdditionalIncludeDirectories="&quot;C:\Documents and Settings\james\My Documents\ENGCVS\EPANET\BASE\trunk\common&quot;" AdditionalIncludeDirectories="&quot;C:\Documents and Settings\james\My Documents\ENGCVS\EPANET\BASE\trunk\common&quot;"
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;EPANETLIB_EXPORTS;DLL" PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;EPANETLIB_EXPORTS;DLL"
MinimalRebuild="TRUE" MinimalRebuild="TRUE"
BasicRuntimeChecks="3" BasicRuntimeChecks="3"
RuntimeLibrary="1" RuntimeLibrary="1"
UsePrecompiledHeader="0" UsePrecompiledHeader="0"
WarningLevel="3" WarningLevel="3"
Detect64BitPortabilityProblems="TRUE" Detect64BitPortabilityProblems="TRUE"
DebugInformationFormat="4" DebugInformationFormat="4"
CompileAs="1"/> CompileAs="1"/>
<Tool <Tool
Name="VCCustomBuildTool"/> Name="VCCustomBuildTool"/>
<Tool <Tool
Name="VCLinkerTool" Name="VCLinkerTool"
OutputFile="$(OutDir)/epanet_msvc.dll" OutputFile="$(OutDir)/epanet_msvc.dll"
LinkIncremental="2" LinkIncremental="2"
GenerateDebugInformation="TRUE" GenerateDebugInformation="TRUE"
ProgramDatabaseFile="$(OutDir)/EpanetLib.pdb" ProgramDatabaseFile="$(OutDir)/EpanetLib.pdb"
SubSystem="2" SubSystem="2"
ImportLibrary="$(OutDir)/epanet_msvc.lib" ImportLibrary="$(OutDir)/epanet_msvc.lib"
TargetMachine="1"/> TargetMachine="1"/>
<Tool <Tool
Name="VCMIDLTool"/> Name="VCMIDLTool"/>
<Tool <Tool
Name="VCPostBuildEventTool"/> Name="VCPostBuildEventTool"/>
<Tool <Tool
Name="VCPreBuildEventTool"/> Name="VCPreBuildEventTool"/>
<Tool <Tool
Name="VCPreLinkEventTool"/> Name="VCPreLinkEventTool"/>
<Tool <Tool
Name="VCResourceCompilerTool"/> Name="VCResourceCompilerTool"/>
<Tool <Tool
Name="VCWebServiceProxyGeneratorTool"/> Name="VCWebServiceProxyGeneratorTool"/>
<Tool <Tool
Name="VCXMLDataGeneratorTool"/> Name="VCXMLDataGeneratorTool"/>
<Tool <Tool
Name="VCWebDeploymentTool"/> Name="VCWebDeploymentTool"/>
<Tool <Tool
Name="VCManagedWrapperGeneratorTool"/> Name="VCManagedWrapperGeneratorTool"/>
<Tool <Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/> Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration> </Configuration>
<Configuration <Configuration
Name="Release|Win32" Name="Release|Win32"
OutputDirectory="Release" OutputDirectory="Release"
IntermediateDirectory="Release" IntermediateDirectory="Release"
ConfigurationType="2" ConfigurationType="2"
CharacterSet="2"> CharacterSet="2">
<Tool <Tool
Name="VCCLCompilerTool" Name="VCCLCompilerTool"
AdditionalIncludeDirectories="&quot;C:\Documents and Settings\james\My Documents\ENGCVS\EPANET\BASE\trunk\common&quot;" AdditionalIncludeDirectories="&quot;C:\Documents and Settings\james\My Documents\ENGCVS\EPANET\BASE\trunk\common&quot;"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;EPANETLIB_EXPORTS;DLL" PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;EPANETLIB_EXPORTS;DLL"
RuntimeLibrary="0" RuntimeLibrary="0"
UsePrecompiledHeader="0" UsePrecompiledHeader="0"
WarningLevel="3" WarningLevel="3"
Detect64BitPortabilityProblems="TRUE" Detect64BitPortabilityProblems="TRUE"
DebugInformationFormat="3" DebugInformationFormat="3"
CompileAs="1"/> CompileAs="1"/>
<Tool <Tool
Name="VCCustomBuildTool"/> Name="VCCustomBuildTool"/>
<Tool <Tool
Name="VCLinkerTool" Name="VCLinkerTool"
OutputFile="$(OutDir)/epanet_msvc.dll" OutputFile="$(OutDir)/epanet_msvc.dll"
LinkIncremental="1" LinkIncremental="1"
GenerateDebugInformation="TRUE" GenerateDebugInformation="TRUE"
SubSystem="2" SubSystem="2"
OptimizeReferences="2" OptimizeReferences="2"
EnableCOMDATFolding="2" EnableCOMDATFolding="2"
ImportLibrary="$(OutDir)/epanet_msvc.lib" ImportLibrary="$(OutDir)/epanet_msvc.lib"
TargetMachine="1"/> TargetMachine="1"/>
<Tool <Tool
Name="VCMIDLTool"/> Name="VCMIDLTool"/>
<Tool <Tool
Name="VCPostBuildEventTool"/> Name="VCPostBuildEventTool"/>
<Tool <Tool
Name="VCPreBuildEventTool"/> Name="VCPreBuildEventTool"/>
<Tool <Tool
Name="VCPreLinkEventTool"/> Name="VCPreLinkEventTool"/>
<Tool <Tool
Name="VCResourceCompilerTool"/> Name="VCResourceCompilerTool"/>
<Tool <Tool
Name="VCWebServiceProxyGeneratorTool"/> Name="VCWebServiceProxyGeneratorTool"/>
<Tool <Tool
Name="VCXMLDataGeneratorTool"/> Name="VCXMLDataGeneratorTool"/>
<Tool <Tool
Name="VCWebDeploymentTool"/> Name="VCWebDeploymentTool"/>
<Tool <Tool
Name="VCManagedWrapperGeneratorTool"/> Name="VCManagedWrapperGeneratorTool"/>
<Tool <Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/> Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration> </Configuration>
</Configurations> </Configurations>
<References> <References>
</References> </References>
<Files> <Files>
<Filter <Filter
Name="Source Files" Name="Source Files"
Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx" Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"> UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}">
<File <File
RelativePath="..\..\..\src\epanet.c"> RelativePath="..\..\..\src\epanet.c">
</File> </File>
<File <File
RelativePath="..\..\..\common\hash.c"> RelativePath="..\..\..\common\hash.c">
</File> </File>
<File <File
RelativePath="..\..\..\src\hydraul.c"> RelativePath="..\..\..\src\hydraul.c">
</File> </File>
<File <File
RelativePath="..\..\..\src\inpfile.c"> RelativePath="..\..\..\src\inpfile.c">
</File> </File>
<File <File
RelativePath="..\..\..\src\input1.c"> RelativePath="..\..\..\src\input1.c">
</File> </File>
<File <File
RelativePath="..\..\..\src\input2.c"> RelativePath="..\..\..\src\input2.c">
</File> </File>
<File <File
RelativePath="..\..\..\src\input3.c"> RelativePath="..\..\..\src\input3.c">
</File> </File>
<File <File
RelativePath="..\..\..\common\mempool.c"> RelativePath="..\..\..\common\mempool.c">
</File> </File>
<File <File
RelativePath="..\..\..\src\output.c"> RelativePath="..\..\..\src\output.c">
</File> </File>
<File <File
RelativePath="..\..\..\src\quality.c"> RelativePath="..\..\..\src\quality.c">
</File> </File>
<File <File
RelativePath="..\..\..\src\report.c"> RelativePath="..\..\..\src\report.c">
</File> </File>
<File <File
RelativePath="..\..\..\src\rules.c"> RelativePath="..\..\..\src\rules.c">
</File> </File>
<File <File
RelativePath="..\..\..\src\smatrix.c"> RelativePath="..\..\..\src\smatrix.c">
</File> </File>
</Filter> </Filter>
<Filter <Filter
Name="Header Files" Name="Header Files"
Filter="h;hpp;hxx;hm;inl;inc;xsd" Filter="h;hpp;hxx;hm;inl;inc;xsd"
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"> UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}">
<File <File
RelativePath="..\..\..\src\enumstxt.h"> RelativePath="..\..\..\src\enumstxt.h">
</File> </File>
<File <File
RelativePath="..\..\..\include\epanet2.h"> RelativePath="..\..\..\include\epanet2.h">
</File> </File>
<File <File
RelativePath="..\..\..\src\funcs.h"> RelativePath="..\..\..\src\funcs.h">
</File> </File>
<File <File
RelativePath="..\..\..\common\hash.h"> RelativePath="..\..\..\common\hash.h">
</File> </File>
<File <File
RelativePath="..\..\..\common\mempool.h"> RelativePath="..\..\..\common\mempool.h">
</File> </File>
<File <File
RelativePath="..\..\..\src\text.h"> RelativePath="..\..\..\src\text.h">
</File> </File>
<File <File
RelativePath="..\..\..\src\toolkit.h"> RelativePath="..\..\..\src\toolkit.h">
</File> </File>
<File <File
RelativePath="..\..\..\src\types.h"> RelativePath="..\..\..\src\types.h">
</File> </File>
<File <File
RelativePath="..\..\..\src\vars.h"> RelativePath="..\..\..\src\vars.h">
</File> </File>
</Filter> </Filter>
<Filter <Filter
Name="Resource Files" Name="Resource Files"
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx" Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx"
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"> UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}">
</Filter> </Filter>
</Files> </Files>
<Globals> <Globals>
</Globals> </Globals>
</VisualStudioProject> </VisualStudioProject>

286
build/MSVC/EpanetRun/EpanetRun.vcproj Normal file → Executable file
View File

@@ -1,143 +1,143 @@
<?xml version="1.0" encoding="Windows-1252"?> <?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject <VisualStudioProject
ProjectType="Visual C++" ProjectType="Visual C++"
Version="7.10" Version="7.10"
Name="EpanetRun" Name="EpanetRun"
ProjectGUID="{11056F72-0330-445F-8DF9-0734DC4F785B}" ProjectGUID="{11056F72-0330-445F-8DF9-0734DC4F785B}"
Keyword="Win32Proj"> Keyword="Win32Proj">
<Platforms> <Platforms>
<Platform <Platform
Name="Win32"/> Name="Win32"/>
</Platforms> </Platforms>
<Configurations> <Configurations>
<Configuration <Configuration
Name="Debug|Win32" Name="Debug|Win32"
OutputDirectory="Debug" OutputDirectory="Debug"
IntermediateDirectory="Debug" IntermediateDirectory="Debug"
ConfigurationType="1" ConfigurationType="1"
CharacterSet="2"> CharacterSet="2">
<Tool <Tool
Name="VCCLCompilerTool" Name="VCCLCompilerTool"
Optimization="0" Optimization="0"
AdditionalIncludeDirectories="&quot;C:\Documents and Settings\james\My Documents\ENGCVS\EPANET\BASE\trunk\include&quot;" AdditionalIncludeDirectories="&quot;C:\Documents and Settings\james\My Documents\ENGCVS\EPANET\BASE\trunk\include&quot;"
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE" PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
MinimalRebuild="TRUE" MinimalRebuild="TRUE"
BasicRuntimeChecks="3" BasicRuntimeChecks="3"
RuntimeLibrary="5" RuntimeLibrary="5"
UsePrecompiledHeader="0" UsePrecompiledHeader="0"
WarningLevel="3" WarningLevel="3"
Detect64BitPortabilityProblems="TRUE" Detect64BitPortabilityProblems="TRUE"
DebugInformationFormat="4" DebugInformationFormat="4"
CompileAs="1"/> CompileAs="1"/>
<Tool <Tool
Name="VCCustomBuildTool"/> Name="VCCustomBuildTool"/>
<Tool <Tool
Name="VCLinkerTool" Name="VCLinkerTool"
AdditionalDependencies="epanet_msvc.lib" AdditionalDependencies="epanet_msvc.lib"
OutputFile="$(OutDir)/EpanetRun.exe" OutputFile="$(OutDir)/EpanetRun.exe"
LinkIncremental="2" LinkIncremental="2"
AdditionalLibraryDirectories="&quot;C:\Documents and Settings\james\My Documents\ENGCVS\EPANET\BASE\trunk\build\MSVC\EpanetLib\Debug&quot;" AdditionalLibraryDirectories="&quot;C:\Documents and Settings\james\My Documents\ENGCVS\EPANET\BASE\trunk\build\MSVC\EpanetLib\Debug&quot;"
GenerateDebugInformation="TRUE" GenerateDebugInformation="TRUE"
ProgramDatabaseFile="$(OutDir)/EpanetRun.pdb" ProgramDatabaseFile="$(OutDir)/EpanetRun.pdb"
SubSystem="1" SubSystem="1"
TargetMachine="1"/> TargetMachine="1"/>
<Tool <Tool
Name="VCMIDLTool"/> Name="VCMIDLTool"/>
<Tool <Tool
Name="VCPostBuildEventTool"/> Name="VCPostBuildEventTool"/>
<Tool <Tool
Name="VCPreBuildEventTool"/> Name="VCPreBuildEventTool"/>
<Tool <Tool
Name="VCPreLinkEventTool"/> Name="VCPreLinkEventTool"/>
<Tool <Tool
Name="VCResourceCompilerTool"/> Name="VCResourceCompilerTool"/>
<Tool <Tool
Name="VCWebServiceProxyGeneratorTool"/> Name="VCWebServiceProxyGeneratorTool"/>
<Tool <Tool
Name="VCXMLDataGeneratorTool"/> Name="VCXMLDataGeneratorTool"/>
<Tool <Tool
Name="VCWebDeploymentTool"/> Name="VCWebDeploymentTool"/>
<Tool <Tool
Name="VCManagedWrapperGeneratorTool"/> Name="VCManagedWrapperGeneratorTool"/>
<Tool <Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/> Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration> </Configuration>
<Configuration <Configuration
Name="Release|Win32" Name="Release|Win32"
OutputDirectory="Release" OutputDirectory="Release"
IntermediateDirectory="Release" IntermediateDirectory="Release"
ConfigurationType="1" ConfigurationType="1"
CharacterSet="2"> CharacterSet="2">
<Tool <Tool
Name="VCCLCompilerTool" Name="VCCLCompilerTool"
AdditionalIncludeDirectories="&quot;C:\Documents and Settings\james\My Documents\ENGCVS\EPANET\BASE\trunk\include&quot;" AdditionalIncludeDirectories="&quot;C:\Documents and Settings\james\My Documents\ENGCVS\EPANET\BASE\trunk\include&quot;"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE" PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
RuntimeLibrary="4" RuntimeLibrary="4"
UsePrecompiledHeader="0" UsePrecompiledHeader="0"
WarningLevel="3" WarningLevel="3"
Detect64BitPortabilityProblems="TRUE" Detect64BitPortabilityProblems="TRUE"
DebugInformationFormat="3" DebugInformationFormat="3"
CompileAs="1"/> CompileAs="1"/>
<Tool <Tool
Name="VCCustomBuildTool"/> Name="VCCustomBuildTool"/>
<Tool <Tool
Name="VCLinkerTool" Name="VCLinkerTool"
AdditionalDependencies="epanet_msvc.lib" AdditionalDependencies="epanet_msvc.lib"
OutputFile="$(OutDir)/EpanetRun.exe" OutputFile="$(OutDir)/EpanetRun.exe"
LinkIncremental="1" LinkIncremental="1"
AdditionalLibraryDirectories="&quot;C:\Documents and Settings\james\My Documents\ENGCVS\EPANET\BASE\trunk\build\MSVC\EpanetLib\Release&quot;" AdditionalLibraryDirectories="&quot;C:\Documents and Settings\james\My Documents\ENGCVS\EPANET\BASE\trunk\build\MSVC\EpanetLib\Release&quot;"
GenerateDebugInformation="TRUE" GenerateDebugInformation="TRUE"
SubSystem="1" SubSystem="1"
OptimizeReferences="2" OptimizeReferences="2"
EnableCOMDATFolding="2" EnableCOMDATFolding="2"
TargetMachine="1"/> TargetMachine="1"/>
<Tool <Tool
Name="VCMIDLTool"/> Name="VCMIDLTool"/>
<Tool <Tool
Name="VCPostBuildEventTool"/> Name="VCPostBuildEventTool"/>
<Tool <Tool
Name="VCPreBuildEventTool"/> Name="VCPreBuildEventTool"/>
<Tool <Tool
Name="VCPreLinkEventTool"/> Name="VCPreLinkEventTool"/>
<Tool <Tool
Name="VCResourceCompilerTool"/> Name="VCResourceCompilerTool"/>
<Tool <Tool
Name="VCWebServiceProxyGeneratorTool"/> Name="VCWebServiceProxyGeneratorTool"/>
<Tool <Tool
Name="VCXMLDataGeneratorTool"/> Name="VCXMLDataGeneratorTool"/>
<Tool <Tool
Name="VCWebDeploymentTool"/> Name="VCWebDeploymentTool"/>
<Tool <Tool
Name="VCManagedWrapperGeneratorTool"/> Name="VCManagedWrapperGeneratorTool"/>
<Tool <Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/> Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration> </Configuration>
</Configurations> </Configurations>
<References> <References>
</References> </References>
<Files> <Files>
<Filter <Filter
Name="Source Files" Name="Source Files"
Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx" Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"> UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}">
<File <File
RelativePath="..\..\..\src\epanet.c"> RelativePath="..\..\..\src\epanet.c">
</File> </File>
</Filter> </Filter>
<Filter <Filter
Name="Header Files" Name="Header Files"
Filter="h;hpp;hxx;hm;inl;inc;xsd" Filter="h;hpp;hxx;hm;inl;inc;xsd"
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"> UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}">
<File <File
RelativePath="..\..\..\include\epanet2.h"> RelativePath="..\..\..\include\epanet2.h">
</File> </File>
</Filter> </Filter>
<Filter <Filter
Name="Resource Files" Name="Resource Files"
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx" Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx"
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"> UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}">
</Filter> </Filter>
</Files> </Files>
<Globals> <Globals>
</Globals> </Globals>
</VisualStudioProject> </VisualStudioProject>

426
build/MSVC/epanet2.mak Normal file → Executable file
View File

@@ -1,213 +1,213 @@
# Microsoft Developer Studio Generated NMAKE File, Based on epanet2.dsp # Microsoft Developer Studio Generated NMAKE File, Based on epanet2.dsp
!IF "$(CFG)" == "" !IF "$(CFG)" == ""
CFG=epanet2 - Win32 Release CFG=epanet2 - Win32 Release
!MESSAGE No configuration specified. Defaulting to epanet2 - Win32 Release. !MESSAGE No configuration specified. Defaulting to epanet2 - Win32 Release.
!ENDIF !ENDIF
!IF "$(CFG)" != "epanet2 - Win32 Release" !IF "$(CFG)" != "epanet2 - Win32 Release"
!MESSAGE Invalid configuration "$(CFG)" specified. !MESSAGE Invalid configuration "$(CFG)" specified.
!MESSAGE You can specify a configuration when running NMAKE !MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE !MESSAGE
!MESSAGE NMAKE /f "epanet2.mak" CFG="epanet2 - Win32 Release" !MESSAGE NMAKE /f "epanet2.mak" CFG="epanet2 - Win32 Release"
!MESSAGE !MESSAGE
!MESSAGE Possible choices for configuration are: !MESSAGE Possible choices for configuration are:
!MESSAGE !MESSAGE
!MESSAGE "epanet2 - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") !MESSAGE "epanet2 - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE !MESSAGE
!ERROR An invalid configuration is specified. !ERROR An invalid configuration is specified.
!ENDIF !ENDIF
!IF "$(OS)" == "Windows_NT" !IF "$(OS)" == "Windows_NT"
NULL= NULL=
!ELSE !ELSE
NULL=nul NULL=nul
!ENDIF !ENDIF
OUTDIR=.\Release OUTDIR=.\Release
INTDIR=.\Release INTDIR=.\Release
# Begin Custom Macros # Begin Custom Macros
OutDir=.\Release OutDir=.\Release
# End Custom Macros # End Custom Macros
ALL : "$(OUTDIR)\epanet2.dll" ALL : "$(OUTDIR)\epanet2.dll"
CLEAN : CLEAN :
-@erase "$(INTDIR)\epanet.obj" -@erase "$(INTDIR)\epanet.obj"
-@erase "$(INTDIR)\hash.obj" -@erase "$(INTDIR)\hash.obj"
-@erase "$(INTDIR)\hydraul.obj" -@erase "$(INTDIR)\hydraul.obj"
-@erase "$(INTDIR)\inpfile.obj" -@erase "$(INTDIR)\inpfile.obj"
-@erase "$(INTDIR)\input1.obj" -@erase "$(INTDIR)\input1.obj"
-@erase "$(INTDIR)\input2.obj" -@erase "$(INTDIR)\input2.obj"
-@erase "$(INTDIR)\input3.obj" -@erase "$(INTDIR)\input3.obj"
-@erase "$(INTDIR)\mempool.obj" -@erase "$(INTDIR)\mempool.obj"
-@erase "$(INTDIR)\output.obj" -@erase "$(INTDIR)\output.obj"
-@erase "$(INTDIR)\quality.obj" -@erase "$(INTDIR)\quality.obj"
-@erase "$(INTDIR)\report.obj" -@erase "$(INTDIR)\report.obj"
-@erase "$(INTDIR)\rules.obj" -@erase "$(INTDIR)\rules.obj"
-@erase "$(INTDIR)\smatrix.obj" -@erase "$(INTDIR)\smatrix.obj"
-@erase "$(INTDIR)\vc60.idb" -@erase "$(INTDIR)\vc60.idb"
-@erase "$(OUTDIR)\epanet2.dll" -@erase "$(OUTDIR)\epanet2.dll"
-@erase "$(OUTDIR)\epanet2.exp" -@erase "$(OUTDIR)\epanet2.exp"
-@erase "$(OUTDIR)\epanet2.lib" -@erase "$(OUTDIR)\epanet2.lib"
"$(OUTDIR)" : "$(OUTDIR)" :
if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)" if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
CPP=cl.exe 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 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:: .c{$(INTDIR)}.obj::
$(CPP) @<< $(CPP) @<<
$(CPP_PROJ) $< $(CPP_PROJ) $<
<< <<
.cpp{$(INTDIR)}.obj:: .cpp{$(INTDIR)}.obj::
$(CPP) @<< $(CPP) @<<
$(CPP_PROJ) $< $(CPP_PROJ) $<
<< <<
.cxx{$(INTDIR)}.obj:: .cxx{$(INTDIR)}.obj::
$(CPP) @<< $(CPP) @<<
$(CPP_PROJ) $< $(CPP_PROJ) $<
<< <<
.c{$(INTDIR)}.sbr:: .c{$(INTDIR)}.sbr::
$(CPP) @<< $(CPP) @<<
$(CPP_PROJ) $< $(CPP_PROJ) $<
<< <<
.cpp{$(INTDIR)}.sbr:: .cpp{$(INTDIR)}.sbr::
$(CPP) @<< $(CPP) @<<
$(CPP_PROJ) $< $(CPP_PROJ) $<
<< <<
.cxx{$(INTDIR)}.sbr:: .cxx{$(INTDIR)}.sbr::
$(CPP) @<< $(CPP) @<<
$(CPP_PROJ) $< $(CPP_PROJ) $<
<< <<
MTL=midl.exe MTL=midl.exe
MTL_PROJ=/nologo /D "NDEBUG" /mktyplib203 /win32 MTL_PROJ=/nologo /D "NDEBUG" /mktyplib203 /win32
RSC=rc.exe RSC=rc.exe
BSC32=bscmake.exe BSC32=bscmake.exe
BSC32_FLAGS=/nologo /o"$(OUTDIR)\epanet2.bsc" BSC32_FLAGS=/nologo /o"$(OUTDIR)\epanet2.bsc"
BSC32_SBRS= \ BSC32_SBRS= \
LINK32=link.exe 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" 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= \ DEF_FILE= \
"..\epanet2.def" "..\epanet2.def"
LINK32_OBJS= \ LINK32_OBJS= \
"$(INTDIR)\epanet.obj" \ "$(INTDIR)\epanet.obj" \
"$(INTDIR)\hash.obj" \ "$(INTDIR)\hash.obj" \
"$(INTDIR)\hydraul.obj" \ "$(INTDIR)\hydraul.obj" \
"$(INTDIR)\inpfile.obj" \ "$(INTDIR)\inpfile.obj" \
"$(INTDIR)\input1.obj" \ "$(INTDIR)\input1.obj" \
"$(INTDIR)\input2.obj" \ "$(INTDIR)\input2.obj" \
"$(INTDIR)\input3.obj" \ "$(INTDIR)\input3.obj" \
"$(INTDIR)\mempool.obj" \ "$(INTDIR)\mempool.obj" \
"$(INTDIR)\output.obj" \ "$(INTDIR)\output.obj" \
"$(INTDIR)\quality.obj" \ "$(INTDIR)\quality.obj" \
"$(INTDIR)\report.obj" \ "$(INTDIR)\report.obj" \
"$(INTDIR)\rules.obj" \ "$(INTDIR)\rules.obj" \
"$(INTDIR)\smatrix.obj" "$(INTDIR)\smatrix.obj"
"$(OUTDIR)\epanet2.dll" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS) "$(OUTDIR)\epanet2.dll" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
$(LINK32) @<< $(LINK32) @<<
$(LINK32_FLAGS) $(LINK32_OBJS) $(LINK32_FLAGS) $(LINK32_OBJS)
<< <<
!IF "$(NO_EXTERNAL_DEPS)" != "1" !IF "$(NO_EXTERNAL_DEPS)" != "1"
!IF EXISTS("epanet2.dep") !IF EXISTS("epanet2.dep")
!INCLUDE "epanet2.dep" !INCLUDE "epanet2.dep"
!ELSE !ELSE
!MESSAGE Warning: cannot find "epanet2.dep" !MESSAGE Warning: cannot find "epanet2.dep"
!ENDIF !ENDIF
!ENDIF !ENDIF
!IF "$(CFG)" == "epanet2 - Win32 Release" !IF "$(CFG)" == "epanet2 - Win32 Release"
SOURCE=..\epanet.c SOURCE=..\epanet.c
"$(INTDIR)\epanet.obj" : $(SOURCE) "$(INTDIR)" "$(INTDIR)\epanet.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE) $(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=..\hash.c SOURCE=..\hash.c
"$(INTDIR)\hash.obj" : $(SOURCE) "$(INTDIR)" "$(INTDIR)\hash.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE) $(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=..\hydraul.c SOURCE=..\hydraul.c
"$(INTDIR)\hydraul.obj" : $(SOURCE) "$(INTDIR)" "$(INTDIR)\hydraul.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE) $(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=..\inpfile.c SOURCE=..\inpfile.c
"$(INTDIR)\inpfile.obj" : $(SOURCE) "$(INTDIR)" "$(INTDIR)\inpfile.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE) $(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=..\input1.c SOURCE=..\input1.c
"$(INTDIR)\input1.obj" : $(SOURCE) "$(INTDIR)" "$(INTDIR)\input1.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE) $(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=..\input2.c SOURCE=..\input2.c
"$(INTDIR)\input2.obj" : $(SOURCE) "$(INTDIR)" "$(INTDIR)\input2.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE) $(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=..\input3.c SOURCE=..\input3.c
"$(INTDIR)\input3.obj" : $(SOURCE) "$(INTDIR)" "$(INTDIR)\input3.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE) $(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=..\mempool.c SOURCE=..\mempool.c
"$(INTDIR)\mempool.obj" : $(SOURCE) "$(INTDIR)" "$(INTDIR)\mempool.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE) $(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=..\output.c SOURCE=..\output.c
"$(INTDIR)\output.obj" : $(SOURCE) "$(INTDIR)" "$(INTDIR)\output.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE) $(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=..\quality.c SOURCE=..\quality.c
"$(INTDIR)\quality.obj" : $(SOURCE) "$(INTDIR)" "$(INTDIR)\quality.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE) $(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=..\report.c SOURCE=..\report.c
"$(INTDIR)\report.obj" : $(SOURCE) "$(INTDIR)" "$(INTDIR)\report.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE) $(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=..\rules.c SOURCE=..\rules.c
"$(INTDIR)\rules.obj" : $(SOURCE) "$(INTDIR)" "$(INTDIR)\rules.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE) $(CPP) $(CPP_PROJ) $(SOURCE)
SOURCE=..\smatrix.c SOURCE=..\smatrix.c
"$(INTDIR)\smatrix.obj" : $(SOURCE) "$(INTDIR)" "$(INTDIR)\smatrix.obj" : $(SOURCE) "$(INTDIR)"
$(CPP) $(CPP_PROJ) $(SOURCE) $(CPP) $(CPP_PROJ) $(SOURCE)
!ENDIF !ENDIF

0
build/svnname.sh Normal file → Executable file
View File

108
doc/Readme.txt Normal file → Executable file
View File

@@ -1,54 +1,54 @@
Contents of EPANET2.ZIP Contents of EPANET2.ZIP
======================= =======================
This archive contains the source code for the EPANET 2 This archive contains the source code for the EPANET 2
network hydraulic and water quality solver. The solver network hydraulic and water quality solver. The solver
provides functions for simulating the extended period provides functions for simulating the extended period
hydraulic and water quality behavior of water distribution hydraulic and water quality behavior of water distribution
system pipe networks. It is written in ANSI-compatible C system pipe networks. It is written in ANSI-compatible C
and can be compiled into either a Windows Dynamic Link and can be compiled into either a Windows Dynamic Link
Library of functions or into a command-line executable. Library of functions or into a command-line executable.
The archived code is set up for compilation as a DLL. The archived code is set up for compilation as a DLL.
To compile it as a command line (or console) application To compile it as a command line (or console) application
simply comment out the "#define DLL" macro statement at simply comment out the "#define DLL" macro statement at
the top of EPANET.C and un-comment the "#define CLE" macro. the top of EPANET.C and un-comment the "#define CLE" macro.
The DLL version of the solver (epanet2.dll) is used with The DLL version of the solver (epanet2.dll) is used with
the EPANET 2 user interface executable (epanet2w.exe) to the EPANET 2 user interface executable (epanet2w.exe) to
form a complete Windows modeling package. It also serves form a complete Windows modeling package. It also serves
as the function library for the EPANET Programmer's Toolkit, as the function library for the EPANET Programmer's Toolkit,
allowing developers to construct their own customized pipe allowing developers to construct their own customized pipe
network analysis applications. network analysis applications.
The following C-code files are included in this archive: The following C-code files are included in this archive:
EPANET.C -- main module providing supervisory control EPANET.C -- main module providing supervisory control
INPUT1.C -- controls processing of input data INPUT1.C -- controls processing of input data
INPUT2.C -- reads data from input file INPUT2.C -- reads data from input file
INPUT3.C -- parses individual lines of input data INPUT3.C -- parses individual lines of input data
INPFILE.C -- saves modified input data to a text file INPFILE.C -- saves modified input data to a text file
RULES.C -- implements rule-based control of piping system RULES.C -- implements rule-based control of piping system
HYDRAUL.C -- computes extended period hydraulic behavior HYDRAUL.C -- computes extended period hydraulic behavior
QUALITY.C -- tracks transport & fate of water quality QUALITY.C -- tracks transport & fate of water quality
OUTPUT.C -- handles transfer of data to and from binary files OUTPUT.C -- handles transfer of data to and from binary files
REPORT.C -- handles reporting of results to text file REPORT.C -- handles reporting of results to text file
SMATRIX.C -- sparse matrix linear equation solver routines SMATRIX.C -- sparse matrix linear equation solver routines
MEMPOOL.C -- memory pool management routines MEMPOOL.C -- memory pool management routines
HASH.C -- hash table routines HASH.C -- hash table routines
Also included are the following header files: Also included are the following header files:
TOOLKIT.H -- function prototypes of exported DLL functions TOOLKIT.H -- function prototypes of exported DLL functions
FUNCS.H -- prototypes of all other functions FUNCS.H -- prototypes of all other functions
TYPES.H -- declaration of global constants and data structures TYPES.H -- declaration of global constants and data structures
VARS.H -- declaration of global variables VARS.H -- declaration of global variables
HASH.H -- header file for hash table routines HASH.H -- header file for hash table routines
MEMPOOL.H -- header file for memory pool routines MEMPOOL.H -- header file for memory pool routines
ENUMSTXT.H -- string constants for enumerated types ENUMSTXT.H -- string constants for enumerated types
TEXT.H -- declaration of all other string constants TEXT.H -- declaration of all other string constants
The comments at the top of each file lists the date when the latest 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 update was made, and these updates can be located in the code by
searching for comments with the phrase "/*** Updated" or with the searching for comments with the phrase "/*** Updated" or with the
release number (e.g., 2.00.12) in them. release number (e.g., 2.00.12) in them.
Other useful documentation that can be consulted includes the EPANET Other useful documentation that can be consulted includes the EPANET
Programmers Toolkit Help file and the EPANET Version 2 Users Manual. Programmers Toolkit Help file and the EPANET Version 2 Users Manual.

114
doc/changes.txt Normal file → Executable file
View File

@@ -1,57 +1,57 @@
----------------------- -----------------------
Build 2.00.12 (2/25/08) Build 2.00.12 (2/25/08)
----------------------- -----------------------
Computational Engine Changes (epanet2.dll and epanet2d.exe): Computational Engine Changes (epanet2.dll and epanet2d.exe):
=============================================================================== ===============================================================================
CODE MODULES CHANGES CODE MODULES CHANGES
=============================================================================== ===============================================================================
EPANET.C Temporary files are now written to the users's current working EPANET.C Temporary files are now written to the users's current working
INPUT1.C directory or to the designated Temporary Directory when running INPUT1.C directory or to the designated Temporary Directory when running
VARS.H the Windows GUI, thus avoiding file access problems for users VARS.H the Windows GUI, thus avoiding file access problems for users
FUNCS.H who do not have administrative privileges on their machine. FUNCS.H who do not have administrative privileges on their machine.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
EPANET.C The following tank parameters were made available for retrieval EPANET.C The following tank parameters were made available for retrieval
TOOLKIT.H using the Toolkit's ENgetnodevalue function: tank diameter, TOOLKIT.H using the Toolkit's ENgetnodevalue function: tank diameter,
EPANET2.H minimum volume, index of the tank's volume curve, the initial, EPANET2.H minimum volume, index of the tank's volume curve, the initial,
minimum, and maximum water levels, the fraction of a 2-compart- minimum, and maximum water levels, the fraction of a 2-compart-
ment tank devoted to the mixing zone, and the tank's bulk ment tank devoted to the mixing zone, and the tank's bulk
reaction rate coefficient. These same parameters (with the reaction rate coefficient. These same parameters (with the
exception of the volume curve) were made modifiable using the exception of the volume curve) were made modifiable using the
ENsetnodevalue function, as was the choice of mixing model. ENsetnodevalue function, as was the choice of mixing model.
See the Toolkit Help file for details. See the Toolkit Help file for details.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
EPANET.C A new Toolkit function, ENaddpattern, was added that allows 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 TOOLKIT.C programmers to add a new time pattern to the network in any
EPANET2.H custom code that they write. EPANET2.H custom code that they write.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
HYDRAUL.C A DAMPLIMIT parameter was added to control at what point during 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 INPUT1.C the hydraulic solution iterations status checks on PRVs and PSVs
INPUT3.C begin and subsequent flow changes are dampened. INPUT3.C begin and subsequent flow changes are dampened.
REPORT.C REPORT.C
VARS.H VARS.H
TEXT.H TEXT.H
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
HYDRAUL.C Demands for tanks (net inflows/outflows) were not always being 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 set to zero when the tank was full or empty which was causing
problems in the water quality routing solutions. problems in the water quality routing solutions.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
QUALITY.C The water quality functions for all of the tank mixing models QUALITY.C The water quality functions for all of the tank mixing models
were modified so as to produce more robust results for cases were modified so as to produce more robust results for cases
where there is a significant amount of volume exchange over a where there is a significant amount of volume exchange over a
water quality time step. water quality time step.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
EPANET.C A problem with the system not recognizing that water quality EPANET.C A problem with the system not recognizing that water quality
QUALITY.C reactions could begin after some initial period of time when QUALITY.C reactions could begin after some initial period of time when
VARS.H the Toolkit was used to modify reaction rate coefficients was VARS.H the Toolkit was used to modify reaction rate coefficients was
fixed. fixed.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
INPFILE.C A problem with extraneous lines being written to the [REPORT] INPFILE.C A problem with extraneous lines being written to the [REPORT]
section of an EPANET input file created with the ENsaveinpfile section of an EPANET input file created with the ENsaveinpfile
function was fixed. Also the number of decimal places for some function was fixed. Also the number of decimal places for some
items written to the saved file, such as nodal demands, was items written to the saved file, such as nodal demands, was
increased. increased.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
TYPES.H The code version was changed to 20012 and INT4 was explicitly TYPES.H The code version was changed to 20012 and INT4 was explicitly
defined as an "int" data type. defined as an "int" data type.
=============================================================================== ===============================================================================

458
include/epanet2.h Normal file → Executable file
View File

@@ -1,229 +1,229 @@
/* /*
** EPANET2.H ** EPANET2.H
** **
** C/C++ header file for EPANET Programmers Toolkit ** C/C++ header file for EPANET Programmers Toolkit
** **
** Last updated on 2/14/08 (2.00.12) ** Last updated on 2/14/08 (2.00.12)
*/ */
#ifndef EPANET2_H #ifndef EPANET2_H
#define EPANET2_H #define EPANET2_H
// --- Define the EPANET toolkit constants // --- Define the EPANET toolkit constants
#define EN_ELEVATION 0 /* Node parameters */ #define EN_ELEVATION 0 /* Node parameters */
#define EN_BASEDEMAND 1 #define EN_BASEDEMAND 1
#define EN_PATTERN 2 #define EN_PATTERN 2
#define EN_EMITTER 3 #define EN_EMITTER 3
#define EN_INITQUAL 4 #define EN_INITQUAL 4
#define EN_SOURCEQUAL 5 #define EN_SOURCEQUAL 5
#define EN_SOURCEPAT 6 #define EN_SOURCEPAT 6
#define EN_SOURCETYPE 7 #define EN_SOURCETYPE 7
#define EN_TANKLEVEL 8 #define EN_TANKLEVEL 8
#define EN_DEMAND 9 #define EN_DEMAND 9
#define EN_HEAD 10 #define EN_HEAD 10
#define EN_PRESSURE 11 #define EN_PRESSURE 11
#define EN_QUALITY 12 #define EN_QUALITY 12
#define EN_SOURCEMASS 13 #define EN_SOURCEMASS 13
#define EN_INITVOLUME 14 #define EN_INITVOLUME 14
#define EN_MIXMODEL 15 #define EN_MIXMODEL 15
#define EN_MIXZONEVOL 16 #define EN_MIXZONEVOL 16
#define EN_TANKDIAM 17 #define EN_TANKDIAM 17
#define EN_MINVOLUME 18 #define EN_MINVOLUME 18
#define EN_VOLCURVE 19 #define EN_VOLCURVE 19
#define EN_MINLEVEL 20 #define EN_MINLEVEL 20
#define EN_MAXLEVEL 21 #define EN_MAXLEVEL 21
#define EN_MIXFRACTION 22 #define EN_MIXFRACTION 22
#define EN_TANK_KBULK 23 #define EN_TANK_KBULK 23
#define EN_DIAMETER 0 /* Link parameters */ #define EN_DIAMETER 0 /* Link parameters */
#define EN_LENGTH 1 #define EN_LENGTH 1
#define EN_ROUGHNESS 2 #define EN_ROUGHNESS 2
#define EN_MINORLOSS 3 #define EN_MINORLOSS 3
#define EN_INITSTATUS 4 #define EN_INITSTATUS 4
#define EN_INITSETTING 5 #define EN_INITSETTING 5
#define EN_KBULK 6 #define EN_KBULK 6
#define EN_KWALL 7 #define EN_KWALL 7
#define EN_FLOW 8 #define EN_FLOW 8
#define EN_VELOCITY 9 #define EN_VELOCITY 9
#define EN_HEADLOSS 10 #define EN_HEADLOSS 10
#define EN_STATUS 11 #define EN_STATUS 11
#define EN_SETTING 12 #define EN_SETTING 12
#define EN_ENERGY 13 #define EN_ENERGY 13
#define EN_DURATION 0 /* Time parameters */ #define EN_DURATION 0 /* Time parameters */
#define EN_HYDSTEP 1 #define EN_HYDSTEP 1
#define EN_QUALSTEP 2 #define EN_QUALSTEP 2
#define EN_PATTERNSTEP 3 #define EN_PATTERNSTEP 3
#define EN_PATTERNSTART 4 #define EN_PATTERNSTART 4
#define EN_REPORTSTEP 5 #define EN_REPORTSTEP 5
#define EN_REPORTSTART 6 #define EN_REPORTSTART 6
#define EN_RULESTEP 7 #define EN_RULESTEP 7
#define EN_STATISTIC 8 #define EN_STATISTIC 8
#define EN_PERIODS 9 #define EN_PERIODS 9
#define EN_NODECOUNT 0 /* Component counts */ #define EN_NODECOUNT 0 /* Component counts */
#define EN_TANKCOUNT 1 #define EN_TANKCOUNT 1
#define EN_LINKCOUNT 2 #define EN_LINKCOUNT 2
#define EN_PATCOUNT 3 #define EN_PATCOUNT 3
#define EN_CURVECOUNT 4 #define EN_CURVECOUNT 4
#define EN_CONTROLCOUNT 5 #define EN_CONTROLCOUNT 5
#define EN_JUNCTION 0 /* Node types */ #define EN_JUNCTION 0 /* Node types */
#define EN_RESERVOIR 1 #define EN_RESERVOIR 1
#define EN_TANK 2 #define EN_TANK 2
#define EN_CVPIPE 0 /* Link types */ #define EN_CVPIPE 0 /* Link types */
#define EN_PIPE 1 #define EN_PIPE 1
#define EN_PUMP 2 #define EN_PUMP 2
#define EN_PRV 3 #define EN_PRV 3
#define EN_PSV 4 #define EN_PSV 4
#define EN_PBV 5 #define EN_PBV 5
#define EN_FCV 6 #define EN_FCV 6
#define EN_TCV 7 #define EN_TCV 7
#define EN_GPV 8 #define EN_GPV 8
#define EN_NONE 0 /* Quality analysis types */ #define EN_NONE 0 /* Quality analysis types */
#define EN_CHEM 1 #define EN_CHEM 1
#define EN_AGE 2 #define EN_AGE 2
#define EN_TRACE 3 #define EN_TRACE 3
#define EN_CONCEN 0 /* Source quality types */ #define EN_CONCEN 0 /* Source quality types */
#define EN_MASS 1 #define EN_MASS 1
#define EN_SETPOINT 2 #define EN_SETPOINT 2
#define EN_FLOWPACED 3 #define EN_FLOWPACED 3
#define EN_CFS 0 /* Flow units types */ #define EN_CFS 0 /* Flow units types */
#define EN_GPM 1 #define EN_GPM 1
#define EN_MGD 2 #define EN_MGD 2
#define EN_IMGD 3 #define EN_IMGD 3
#define EN_AFD 4 #define EN_AFD 4
#define EN_LPS 5 #define EN_LPS 5
#define EN_LPM 6 #define EN_LPM 6
#define EN_MLD 7 #define EN_MLD 7
#define EN_CMH 8 #define EN_CMH 8
#define EN_CMD 9 #define EN_CMD 9
#define EN_TRIALS 0 /* Misc. options */ #define EN_TRIALS 0 /* Misc. options */
#define EN_ACCURACY 1 #define EN_ACCURACY 1
#define EN_TOLERANCE 2 #define EN_TOLERANCE 2
#define EN_EMITEXPON 3 #define EN_EMITEXPON 3
#define EN_DEMANDMULT 4 #define EN_DEMANDMULT 4
#define EN_LOWLEVEL 0 /* Control types */ #define EN_LOWLEVEL 0 /* Control types */
#define EN_HILEVEL 1 #define EN_HILEVEL 1
#define EN_TIMER 2 #define EN_TIMER 2
#define EN_TIMEOFDAY 3 #define EN_TIMEOFDAY 3
#define EN_AVERAGE 1 /* Time statistic types. */ #define EN_AVERAGE 1 /* Time statistic types. */
#define EN_MINIMUM 2 #define EN_MINIMUM 2
#define EN_MAXIMUM 3 #define EN_MAXIMUM 3
#define EN_RANGE 4 #define EN_RANGE 4
#define EN_MIX1 0 /* Tank mixing models */ #define EN_MIX1 0 /* Tank mixing models */
#define EN_MIX2 1 #define EN_MIX2 1
#define EN_FIFO 2 #define EN_FIFO 2
#define EN_LIFO 3 #define EN_LIFO 3
#define EN_NOSAVE 0 /* Save-results-to-file flag */ #define EN_NOSAVE 0 /* Save-results-to-file flag */
#define EN_SAVE 1 #define EN_SAVE 1
#define EN_INITFLOW 10 /* Re-initialize flow flag */ #define EN_INITFLOW 10 /* Re-initialize flow flag */
// --- define WINDOWS // --- define WINDOWS
#undef WINDOWS #undef WINDOWS
#ifdef _WIN32 #ifdef _WIN32
#define WINDOWS #define WINDOWS
#endif #endif
#ifdef __WIN32__ #ifdef __WIN32__
#define WINDOWS #define WINDOWS
#endif #endif
// --- define DLLEXPORT // --- define DLLEXPORT
#ifdef WINDOWS #ifdef WINDOWS
#ifdef __cplusplus #ifdef __cplusplus
#define DLLEXPORT extern "C" __declspec(dllexport) __stdcall #define DLLEXPORT extern "C" __declspec(dllexport) __stdcall
#else #else
#define DLLEXPORT __declspec(dllexport) __stdcall #define DLLEXPORT __declspec(dllexport) __stdcall
#endif #endif
#else #else
#ifdef __cplusplus #ifdef __cplusplus
#define DLLEXPORT extern "C" #define DLLEXPORT extern "C"
#else #else
#define DLLEXPORT #define DLLEXPORT
#endif #endif
#endif #endif
// --- declare the EPANET toolkit functions // --- declare the EPANET toolkit functions
int DLLEXPORT ENepanet(char *, char *, char *, void (*) (char *)); int DLLEXPORT ENepanet(char *, char *, char *, void (*) (char *));
int DLLEXPORT ENopen(char *, char *, char *); int DLLEXPORT ENopen(char *, char *, char *);
int DLLEXPORT ENsaveinpfile(char *); int DLLEXPORT ENsaveinpfile(char *);
int DLLEXPORT ENclose(void); int DLLEXPORT ENclose(void);
int DLLEXPORT ENsolveH(void); int DLLEXPORT ENsolveH(void);
int DLLEXPORT ENsaveH(void); int DLLEXPORT ENsaveH(void);
int DLLEXPORT ENopenH(void); int DLLEXPORT ENopenH(void);
int DLLEXPORT ENinitH(int); int DLLEXPORT ENinitH(int);
int DLLEXPORT ENrunH(long *); int DLLEXPORT ENrunH(long *);
int DLLEXPORT ENnextH(long *); int DLLEXPORT ENnextH(long *);
int DLLEXPORT ENcloseH(void); int DLLEXPORT ENcloseH(void);
int DLLEXPORT ENsavehydfile(char *); int DLLEXPORT ENsavehydfile(char *);
int DLLEXPORT ENusehydfile(char *); int DLLEXPORT ENusehydfile(char *);
int DLLEXPORT ENsolveQ(void); int DLLEXPORT ENsolveQ(void);
int DLLEXPORT ENopenQ(void); int DLLEXPORT ENopenQ(void);
int DLLEXPORT ENinitQ(int); int DLLEXPORT ENinitQ(int);
int DLLEXPORT ENrunQ(long *); int DLLEXPORT ENrunQ(long *);
int DLLEXPORT ENnextQ(long *); int DLLEXPORT ENnextQ(long *);
int DLLEXPORT ENstepQ(long *); int DLLEXPORT ENstepQ(long *);
int DLLEXPORT ENcloseQ(void); int DLLEXPORT ENcloseQ(void);
int DLLEXPORT ENwriteline(char *); int DLLEXPORT ENwriteline(char *);
int DLLEXPORT ENreport(void); int DLLEXPORT ENreport(void);
int DLLEXPORT ENresetreport(void); int DLLEXPORT ENresetreport(void);
int DLLEXPORT ENsetreport(char *); int DLLEXPORT ENsetreport(char *);
int DLLEXPORT ENgetcontrol(int, int *, int *, float *, int DLLEXPORT ENgetcontrol(int, int *, int *, float *,
int *, float *); int *, float *);
int DLLEXPORT ENgetcount(int, int *); int DLLEXPORT ENgetcount(int, int *);
int DLLEXPORT ENgetoption(int, float *); int DLLEXPORT ENgetoption(int, float *);
int DLLEXPORT ENgettimeparam(int, long *); int DLLEXPORT ENgettimeparam(int, long *);
int DLLEXPORT ENgetflowunits(int *); int DLLEXPORT ENgetflowunits(int *);
int DLLEXPORT ENgetpatternindex(char *, int *); int DLLEXPORT ENgetpatternindex(char *, int *);
int DLLEXPORT ENgetpatternid(int, char *); int DLLEXPORT ENgetpatternid(int, char *);
int DLLEXPORT ENgetpatternlen(int, int *); int DLLEXPORT ENgetpatternlen(int, int *);
int DLLEXPORT ENgetpatternvalue(int, int, float *); int DLLEXPORT ENgetpatternvalue(int, int, float *);
int DLLEXPORT ENgetqualtype(int *, int *); int DLLEXPORT ENgetqualtype(int *, int *);
int DLLEXPORT ENgeterror(int, char *, int); int DLLEXPORT ENgeterror(int, char *, int);
int DLLEXPORT ENgetnodeindex(char *, int *); int DLLEXPORT ENgetnodeindex(char *, int *);
int DLLEXPORT ENgetnodeid(int, char *); int DLLEXPORT ENgetnodeid(int, char *);
int DLLEXPORT ENgetnodetype(int, int *); int DLLEXPORT ENgetnodetype(int, int *);
int DLLEXPORT ENgetnodevalue(int, int, float *); int DLLEXPORT ENgetnodevalue(int, int, float *);
int DLLEXPORT ENgetlinkindex(char *, int *); int DLLEXPORT ENgetlinkindex(char *, int *);
int DLLEXPORT ENgetlinkid(int, char *); int DLLEXPORT ENgetlinkid(int, char *);
int DLLEXPORT ENgetlinktype(int, int *); int DLLEXPORT ENgetlinktype(int, int *);
int DLLEXPORT ENgetlinknodes(int, int *, int *); int DLLEXPORT ENgetlinknodes(int, int *, int *);
int DLLEXPORT ENgetlinkvalue(int, int, float *); int DLLEXPORT ENgetlinkvalue(int, int, float *);
int DLLEXPORT ENgetversion(int *); int DLLEXPORT ENgetversion(int *);
int DLLEXPORT ENsetcontrol(int, int, int, float, int, float); int DLLEXPORT ENsetcontrol(int, int, int, float, int, float);
int DLLEXPORT ENsetnodevalue(int, int, float); int DLLEXPORT ENsetnodevalue(int, int, float);
int DLLEXPORT ENsetlinkvalue(int, int, float); int DLLEXPORT ENsetlinkvalue(int, int, float);
int DLLEXPORT ENaddpattern(char *); int DLLEXPORT ENaddpattern(char *);
int DLLEXPORT ENsetpattern(int, float *, int); int DLLEXPORT ENsetpattern(int, float *, int);
int DLLEXPORT ENsetpatternvalue(int, int, float); int DLLEXPORT ENsetpatternvalue(int, int, float);
int DLLEXPORT ENsettimeparam(int, long); int DLLEXPORT ENsettimeparam(int, long);
int DLLEXPORT ENsetoption(int, float); int DLLEXPORT ENsetoption(int, float);
int DLLEXPORT ENsetstatusreport(int); int DLLEXPORT ENsetstatusreport(int);
int DLLEXPORT ENsetqualtype(int, char *, char *, char *); int DLLEXPORT ENsetqualtype(int, char *, char *, char *);
#endif #endif

270
src/enumstxt.h Normal file → Executable file
View File

@@ -1,135 +1,135 @@
/* /*
*********************************************************************** ***********************************************************************
ENUMSTXT.H -- Text strings for enumerated data types in EPANET ENUMSTXT.H -- Text strings for enumerated data types in EPANET
VERSION: 2.00 VERSION: 2.00
DATE: 5/8/00 DATE: 5/8/00
AUTHOR: L. Rossman AUTHOR: L. Rossman
US EPA - NRMRL US EPA - NRMRL
********************************************************************** **********************************************************************
*/ */
char *NodeTxt[] = {t_JUNCTION, char *NodeTxt[] = {t_JUNCTION,
t_RESERVOIR, t_RESERVOIR,
t_TANK}; t_TANK};
char *LinkTxt[] = {w_CV, char *LinkTxt[] = {w_CV,
w_PIPE, w_PIPE,
w_PUMP, w_PUMP,
w_PRV, w_PRV,
w_PSV, w_PSV,
w_PBV, w_PBV,
w_FCV, w_FCV,
w_TCV, w_TCV,
w_GPV}; w_GPV};
char *StatTxt[] = {t_XHEAD, char *StatTxt[] = {t_XHEAD,
t_TEMPCLOSED, t_TEMPCLOSED,
t_CLOSED, t_CLOSED,
t_OPEN, t_OPEN,
t_ACTIVE, t_ACTIVE,
t_XFLOW, t_XFLOW,
t_XFCV, t_XFCV,
t_XPRESSURE, t_XPRESSURE,
t_FILLING, t_FILLING,
t_EMPTYING}; t_EMPTYING};
char *FormTxt[] = {w_HW, char *FormTxt[] = {w_HW,
w_DW, w_DW,
w_CM}; w_CM};
char *RptFormTxt[] = {t_HW, char *RptFormTxt[] = {t_HW,
t_DW, t_DW,
t_CM}; t_CM};
char *RptFlowUnitsTxt[] = {u_CFS, char *RptFlowUnitsTxt[] = {u_CFS,
u_GPM, u_GPM,
u_MGD, u_MGD,
u_IMGD, u_IMGD,
u_AFD, u_AFD,
u_LPS, u_LPS,
u_LPM, u_LPM,
u_MLD, u_MLD,
u_CMH, u_CMH,
u_CMD}; u_CMD};
char *FlowUnitsTxt[] = {w_CFS, char *FlowUnitsTxt[] = {w_CFS,
w_GPM, w_GPM,
w_MGD, w_MGD,
w_IMGD, w_IMGD,
w_AFD, w_AFD,
w_LPS, w_LPS,
w_LPM, w_LPM,
w_MLD, w_MLD,
w_CMH, w_CMH,
w_CMD}; w_CMD};
char *PressUnitsTxt[] = {w_PSI, char *PressUnitsTxt[] = {w_PSI,
w_KPA, w_KPA,
w_METERS}; w_METERS};
char *QualTxt[] = {w_NONE, char *QualTxt[] = {w_NONE,
w_CHEM, w_CHEM,
w_AGE, w_AGE,
w_TRACE}; w_TRACE};
char *SourceTxt[] = {w_CONCEN, char *SourceTxt[] = {w_CONCEN,
w_MASS, w_MASS,
w_SETPOINT, w_SETPOINT,
w_FLOWPACED}; w_FLOWPACED};
char *ControlTxt[] = {w_BELOW, char *ControlTxt[] = {w_BELOW,
w_ABOVE, w_ABOVE,
w_TIME, w_TIME,
w_CLOCKTIME}; w_CLOCKTIME};
char *TstatTxt[] = {w_NONE, char *TstatTxt[] = {w_NONE,
w_AVG, w_AVG,
w_MIN, w_MIN,
w_MAX, w_MAX,
w_RANGE}; w_RANGE};
char *MixTxt[] = {w_MIXED, char *MixTxt[] = {w_MIXED,
w_2COMP, w_2COMP,
w_FIFO, w_FIFO,
w_LIFO, w_LIFO,
NULL}; NULL};
char *RptFlagTxt[] = {w_NO, char *RptFlagTxt[] = {w_NO,
w_YES, w_YES,
w_FULL}; w_FULL};
char *SectTxt[] = {s_TITLE, s_JUNCTIONS, s_RESERVOIRS, char *SectTxt[] = {s_TITLE, s_JUNCTIONS, s_RESERVOIRS,
s_TANKS, s_PIPES, s_PUMPS, s_TANKS, s_PIPES, s_PUMPS,
s_VALVES, s_CONTROLS, s_RULES, s_VALVES, s_CONTROLS, s_RULES,
s_DEMANDS, s_SOURCES, s_EMITTERS, s_DEMANDS, s_SOURCES, s_EMITTERS,
s_PATTERNS, s_CURVES, s_QUALITY, s_PATTERNS, s_CURVES, s_QUALITY,
s_STATUS, s_ROUGHNESS, s_ENERGY, s_STATUS, s_ROUGHNESS, s_ENERGY,
s_REACTIONS, s_MIXING, s_REPORT, s_REACTIONS, s_MIXING, s_REPORT,
s_TIMES, s_OPTIONS, s_COORDS, s_TIMES, s_OPTIONS, s_COORDS,
s_VERTICES, s_LABELS, s_BACKDROP, s_VERTICES, s_LABELS, s_BACKDROP,
s_TAGS, s_END, s_TAGS, s_END,
NULL}; NULL};
char *RptSectTxt[] = {NULL, t_JUNCTION, t_RESERVOIR, char *RptSectTxt[] = {NULL, t_JUNCTION, t_RESERVOIR,
t_TANK, t_PIPE, t_PUMP, t_TANK, t_PIPE, t_PUMP,
t_VALVE, t_CONTROL, t_RULE, t_VALVE, t_CONTROL, t_RULE,
t_DEMANDFOR,t_SOURCE, t_EMITTER, t_DEMANDFOR,t_SOURCE, t_EMITTER,
t_PATTERN, t_CURVE, t_QUALITY, t_PATTERN, t_CURVE, t_QUALITY,
t_STATUS, t_ROUGHNESS,t_ENERGY, t_STATUS, t_ROUGHNESS,t_ENERGY,
t_REACTION, t_MIXING, t_REPORT, t_REACTION, t_MIXING, t_REPORT,
t_TIME, t_OPTION}; t_TIME, t_OPTION};
char *Fldname[] = {t_ELEV, t_DEMAND, t_HEAD, char *Fldname[] = {t_ELEV, t_DEMAND, t_HEAD,
t_PRESSURE, t_QUALITY, t_LENGTH, t_PRESSURE, t_QUALITY, t_LENGTH,
t_DIAM, t_FLOW, t_VELOCITY, t_DIAM, t_FLOW, t_VELOCITY,
t_HEADLOSS, t_LINKQUAL, t_LINKSTATUS, t_HEADLOSS, t_LINKQUAL, t_LINKSTATUS,
t_SETTING, t_REACTRATE, t_FRICTION, t_SETTING, t_REACTRATE, t_FRICTION,
"", "", "", "", "", "", NULL}; "", "", "", "", "", "", NULL};
char *LogoTxt[] = {LOGO1,LOGO2,LOGO3,LOGO4,LOGO5,LOGO6,NULL}; char *LogoTxt[] = {LOGO1,LOGO2,LOGO3,LOGO4,LOGO5,LOGO6,NULL};

6246
src/epanet.c Normal file → Executable file

File diff suppressed because it is too large Load Diff

562
src/funcs.h Normal file → Executable file
View File

@@ -1,281 +1,281 @@
/* /*
************************************************************************** **************************************************************************
FUNCS.H -- Function Prototypes for EPANET Program FUNCS.H -- Function Prototypes for EPANET Program
VERSION: 2.00 VERSION: 2.00
DATE: 5/8/00 DATE: 5/8/00
9/25/00 9/25/00
10/25/00 10/25/00
12/29/00 12/29/00
3/1/01 3/1/01
2/14/08 (2.00.12) 2/14/08 (2.00.12)
AUTHOR: L. Rossman AUTHOR: L. Rossman
US EPA - NRMRL US EPA - NRMRL
************************************************************************** **************************************************************************
*/ */
/*****************************************************************/ /*****************************************************************/
/* Most float arguments have been changed to double - 7/3/07 */ /* Most float arguments have been changed to double - 7/3/07 */
/*****************************************************************/ /*****************************************************************/
/* ------- EPANET.C --------------------*/ /* ------- EPANET.C --------------------*/
/* /*
** NOTE: The exportable functions that can be called ** NOTE: The exportable functions that can be called
** via the DLL are prototyped in TOOLKIT.H. ** via the DLL are prototyped in TOOLKIT.H.
*/ */
void initpointers(void); /* Initializes pointers */ void initpointers(void); /* Initializes pointers */
int allocdata(void); /* Allocates memory */ int allocdata(void); /* Allocates memory */
void freeTmplist(STmplist *); /* Frees items in linked list */ void freeTmplist(STmplist *); /* Frees items in linked list */
void freeFloatlist(SFloatlist *); /* Frees list of floats */ void freeFloatlist(SFloatlist *); /* Frees list of floats */
void freedata(void); /* Frees allocated memory */ void freedata(void); /* Frees allocated memory */
int openfiles(char *,char *,char *); /* Opens input & report files */ int openfiles(char *,char *,char *); /* Opens input & report files */
int openhydfile(void); /* Opens hydraulics file */ int openhydfile(void); /* Opens hydraulics file */
int openoutfile(void); /* Opens binary output file */ int openoutfile(void); /* Opens binary output file */
int strcomp(char *, char *); /* Compares two strings */ int strcomp(char *, char *); /* Compares two strings */
char* getTmpName(char* fname); /* Gets temporary file name */ //(2.00.12 - LR) char* getTmpName(char* fname); /* Gets temporary file name */ //(2.00.12 - LR)
double interp(int, double *, /* Interpolates a data curve */ double interp(int, double *, /* Interpolates a data curve */
double *, double); double *, double);
int findnode(char *); /* Finds node's index from ID */ int findnode(char *); /* Finds node's index from ID */
int findlink(char *); /* Finds link's index from ID */ int findlink(char *); /* Finds link's index from ID */
char* geterrmsg(int); /* Gets text of error message */ char* geterrmsg(int); /* Gets text of error message */
void errmsg(int); /* Reports program error */ void errmsg(int); /* Reports program error */
void writecon(char *); /* Writes text to console */ void writecon(char *); /* Writes text to console */
void writewin(char *); /* Passes text to calling app */ void writewin(char *); /* Passes text to calling app */
/* ------- INPUT1.C --------------------*/ /* ------- INPUT1.C --------------------*/
int getdata(void); /* Gets network data */ int getdata(void); /* Gets network data */
void setdefaults(void); /* Sets default values */ void setdefaults(void); /* Sets default values */
void initreport(void); /* Initializes report options */ void initreport(void); /* Initializes report options */
void adjustdata(void); /* Adjusts input data */ void adjustdata(void); /* Adjusts input data */
int inittanks(void); /* Initializes tank levels */ int inittanks(void); /* Initializes tank levels */
void initunits(void); /* Determines reporting units */ void initunits(void); /* Determines reporting units */
void convertunits(void); /* Converts data to std. units*/ void convertunits(void); /* Converts data to std. units*/
/* -------- INPUT2.C -------------------*/ /* -------- INPUT2.C -------------------*/
int netsize(void); /* Determines network size */ int netsize(void); /* Determines network size */
int readdata(void); /* Reads in network data */ int readdata(void); /* Reads in network data */
int newline(int, char *); /* Processes new line of data */ int newline(int, char *); /* Processes new line of data */
int addnodeID(int, char *); /* Adds node ID to data base */ int addnodeID(int, char *); /* Adds node ID to data base */
int addlinkID(int, char *); /* Adds link ID to data base */ int addlinkID(int, char *); /* Adds link ID to data base */
int addpattern(char *); /* Adds pattern to data base */ int addpattern(char *); /* Adds pattern to data base */
int addcurve(char *); /* Adds curve to data base */ int addcurve(char *); /* Adds curve to data base */
STmplist *findID(char *, STmplist *); /* Locates ID on linked list */ STmplist *findID(char *, STmplist *); /* Locates ID on linked list */
int unlinked(void); /* Checks for unlinked nodes */ int unlinked(void); /* Checks for unlinked nodes */
int getpumpparams(void); /* Computes pump curve coeffs.*/ int getpumpparams(void); /* Computes pump curve coeffs.*/
int getpatterns(void); /* Gets pattern data from list*/ int getpatterns(void); /* Gets pattern data from list*/
int getcurves(void); /* Gets curve data from list */ int getcurves(void); /* Gets curve data from list */
int findmatch(char *,char *[]); /* Finds keyword in line */ int findmatch(char *,char *[]); /* Finds keyword in line */
int match(char *, char *); /* Checks for word match */ int match(char *, char *); /* Checks for word match */
int gettokens(char *); /* Tokenizes input line */ int gettokens(char *); /* Tokenizes input line */
int getfloat(char *, double *); /* Converts string to double */ int getfloat(char *, double *); /* Converts string to double */
double hour(char *, char *); /* Converts time to hours */ double hour(char *, char *); /* Converts time to hours */
int setreport(char *); /* Processes reporting command*/ int setreport(char *); /* Processes reporting command*/
void inperrmsg(int,int,char *); /* Input error message */ void inperrmsg(int,int,char *); /* Input error message */
/* ---------- INPUT3.C -----------------*/ /* ---------- INPUT3.C -----------------*/
int juncdata(void); /* Processes junction data */ int juncdata(void); /* Processes junction data */
int tankdata(void); /* Processes tank data */ int tankdata(void); /* Processes tank data */
int pipedata(void); /* Processes pipe data */ int pipedata(void); /* Processes pipe data */
int pumpdata(void); /* Processes pump data */ int pumpdata(void); /* Processes pump data */
int valvedata(void); /* Processes valve data */ int valvedata(void); /* Processes valve data */
int patterndata(void); /* Processes pattern data */ int patterndata(void); /* Processes pattern data */
int curvedata(void); /* Processes curve data */ int curvedata(void); /* Processes curve data */
int demanddata(void); /* Processes demand data */ int demanddata(void); /* Processes demand data */
int controldata(void); /* Processes simple controls */ int controldata(void); /* Processes simple controls */
int energydata(void); /* Processes energy data */ int energydata(void); /* Processes energy data */
int sourcedata(void); /* Processes source data */ int sourcedata(void); /* Processes source data */
int emitterdata(void); /* Processes emitter data */ int emitterdata(void); /* Processes emitter data */
int qualdata(void); /* Processes quality data */ int qualdata(void); /* Processes quality data */
int reactdata(void); /* Processes reaction data */ int reactdata(void); /* Processes reaction data */
int mixingdata(void); /* Processes tank mixing data */ int mixingdata(void); /* Processes tank mixing data */
int statusdata(void); /* Processes link status data */ int statusdata(void); /* Processes link status data */
int reportdata(void); /* Processes report options */ int reportdata(void); /* Processes report options */
int timedata(void); /* Processes time options */ int timedata(void); /* Processes time options */
int optiondata(void); /* Processes analysis options */ int optiondata(void); /* Processes analysis options */
int optionchoice(int); /* Processes option choices */ int optionchoice(int); /* Processes option choices */
int optionvalue(int); /* Processes option values */ int optionvalue(int); /* Processes option values */
int getpumpcurve(int); /* Constructs a pump curve */ int getpumpcurve(int); /* Constructs a pump curve */
int powercurve(double, double, double,/* Coeffs. of power pump curve*/ int powercurve(double, double, double,/* Coeffs. of power pump curve*/
double, double, double *, double, double, double *,
double *, double *); double *, double *);
int valvecheck(int, int, int); /* Checks valve placement */ int valvecheck(int, int, int); /* Checks valve placement */
void changestatus(int, char, double); /* Changes status of a link */ void changestatus(int, char, double); /* Changes status of a link */
/* -------------- RULES.C --------------*/ /* -------------- RULES.C --------------*/
void initrules(void); /* Initializes rule base */ void initrules(void); /* Initializes rule base */
void addrule(char *); /* Adds rule to rule base */ void addrule(char *); /* Adds rule to rule base */
int allocrules(void); /* Allocates memory for rule */ int allocrules(void); /* Allocates memory for rule */
int ruledata(void); /* Processes rule input data */ int ruledata(void); /* Processes rule input data */
int checkrules(long); /* Checks all rules */ int checkrules(long); /* Checks all rules */
void freerules(void); /* Frees rule base memory */ void freerules(void); /* Frees rule base memory */
/* ------------- REPORT.C --------------*/ /* ------------- REPORT.C --------------*/
int writereport(void); /* Writes formatted report */ int writereport(void); /* Writes formatted report */
void writelogo(void); /* Writes program logo */ void writelogo(void); /* Writes program logo */
void writesummary(void); /* Writes network summary */ void writesummary(void); /* Writes network summary */
void writehydstat(int,double); /* Writes hydraulic status */ void writehydstat(int,double); /* Writes hydraulic status */
void writeenergy(void); /* Writes energy usage */ void writeenergy(void); /* Writes energy usage */
int writeresults(void); /* Writes node/link results */ int writeresults(void); /* Writes node/link results */
void writeheader(int,int); /* Writes heading on report */ void writeheader(int,int); /* Writes heading on report */
void writeline(char *); /* Writes line to report file */ void writeline(char *); /* Writes line to report file */
void writerelerr(int, double); /* Writes convergence error */ void writerelerr(int, double); /* Writes convergence error */
void writestatchange(int,char,char); /* Writes link status change */ void writestatchange(int,char,char); /* Writes link status change */
void writecontrolaction(int, int); /* Writes control action taken*/ void writecontrolaction(int, int); /* Writes control action taken*/
void writeruleaction(int, char *); /* Writes rule action taken */ void writeruleaction(int, char *); /* Writes rule action taken */
int writehydwarn(int,double); /* Writes hydraulic warnings */ int writehydwarn(int,double); /* Writes hydraulic warnings */
void writehyderr(int); /* Writes hydraulic error msg.*/ void writehyderr(int); /* Writes hydraulic error msg.*/
int disconnected(void); /* Checks for disconnections */ int disconnected(void); /* Checks for disconnections */
void marknodes(int, int *, char *); /* Identifies connected nodes */ void marknodes(int, int *, char *); /* Identifies connected nodes */
void getclosedlink(int, char *); /* Finds a disconnecting link */ void getclosedlink(int, char *); /* Finds a disconnecting link */
void writelimits(int,int); /* Writes reporting limits */ void writelimits(int,int); /* Writes reporting limits */
int checklimits(double *,int,int); /* Checks variable limits */ int checklimits(double *,int,int); /* Checks variable limits */
void writetime(char *); /* Writes current clock time */ void writetime(char *); /* Writes current clock time */
char *clocktime(char *, long); /* Converts time to hrs:min */ char *clocktime(char *, long); /* Converts time to hrs:min */
char *fillstr(char *, char, int); /* Fills string with character*/ char *fillstr(char *, char, int); /* Fills string with character*/
int getnodetype(int); /* Determines node type */ int getnodetype(int); /* Determines node type */
/* --------- HYDRAUL.C -----------------*/ /* --------- HYDRAUL.C -----------------*/
int openhyd(void); /* Opens hydraulics solver */ int openhyd(void); /* Opens hydraulics solver */
/*** Updated 3/1/01 ***/ /*** Updated 3/1/01 ***/
void inithyd(int); /* Re-sets initial conditions */ void inithyd(int); /* Re-sets initial conditions */
int runhyd(long *); /* Solves 1-period hydraulics */ int runhyd(long *); /* Solves 1-period hydraulics */
int nexthyd(long *); /* Moves to next time period */ int nexthyd(long *); /* Moves to next time period */
void closehyd(void); /* Closes hydraulics solver */ void closehyd(void); /* Closes hydraulics solver */
int allocmatrix(void); /* Allocates matrix coeffs. */ int allocmatrix(void); /* Allocates matrix coeffs. */
void freematrix(void); /* Frees matrix coeffs. */ void freematrix(void); /* Frees matrix coeffs. */
void initlinkflow(int, char, double); /* Initializes link flow */ void initlinkflow(int, char, double); /* Initializes link flow */
void setlinkflow(int, double); /* Sets link flow via headloss*/ void setlinkflow(int, double); /* Sets link flow via headloss*/
void setlinkstatus(int, char, char *, /* Sets link status */ void setlinkstatus(int, char, char *, /* Sets link status */
double *); double *);
void setlinksetting(int, double, /* Sets pump/valve setting */ void setlinksetting(int, double, /* Sets pump/valve setting */
char *, double *); char *, double *);
void resistance(int); /* Computes resistance coeff. */ void resistance(int); /* Computes resistance coeff. */
void demands(void); /* Computes current demands */ void demands(void); /* Computes current demands */
int controls(void); /* Controls link settings */ int controls(void); /* Controls link settings */
long timestep(void); /* Computes new time step */ long timestep(void); /* Computes new time step */
void tanktimestep(long *); /* Time till tanks fill/drain */ void tanktimestep(long *); /* Time till tanks fill/drain */
void controltimestep(long *); /* Time till control action */ void controltimestep(long *); /* Time till control action */
void ruletimestep(long *); /* Time till rule action */ void ruletimestep(long *); /* Time till rule action */
void addenergy(long); /* Accumulates energy usage */ void addenergy(long); /* Accumulates energy usage */
void getenergy(int, double *, double *); /* Computes link energy use */ void getenergy(int, double *, double *); /* Computes link energy use */
void tanklevels(long); /* Computes new tank levels */ void tanklevels(long); /* Computes new tank levels */
double tankvolume(int,double); /* Finds tank vol. from grade */ double tankvolume(int,double); /* Finds tank vol. from grade */
double tankgrade(int,double); /* Finds tank grade from vol. */ double tankgrade(int,double); /* Finds tank grade from vol. */
int netsolve(int *,double *); /* Solves network equations */ int netsolve(int *,double *); /* Solves network equations */
int badvalve(int); /* Checks for bad valve */ int badvalve(int); /* Checks for bad valve */
int valvestatus(void); /* Updates valve status */ int valvestatus(void); /* Updates valve status */
int linkstatus(void); /* Updates link status */ int linkstatus(void); /* Updates link status */
char cvstatus(char,double,double); /* Updates CV status */ char cvstatus(char,double,double); /* Updates CV status */
char pumpstatus(int,double); /* Updates pump status */ char pumpstatus(int,double); /* Updates pump status */
char prvstatus(int,char,double, /* Updates PRV status */ char prvstatus(int,char,double, /* Updates PRV status */
double,double); double,double);
char psvstatus(int,char,double, /* Updates PSV status */ char psvstatus(int,char,double, /* Updates PSV status */
double,double); double,double);
char fcvstatus(int,char,double, /* Updates FCV status */ char fcvstatus(int,char,double, /* Updates FCV status */
double); double);
void tankstatus(int,int,int); /* Checks if tank full/empty */ void tankstatus(int,int,int); /* Checks if tank full/empty */
int pswitch(void); /* Pressure switch controls */ int pswitch(void); /* Pressure switch controls */
double newflows(void); /* Updates link flows */ double newflows(void); /* Updates link flows */
void newcoeffs(void); /* Computes matrix coeffs. */ void newcoeffs(void); /* Computes matrix coeffs. */
void linkcoeffs(void); /* Computes link coeffs. */ void linkcoeffs(void); /* Computes link coeffs. */
void nodecoeffs(void); /* Computes node coeffs. */ void nodecoeffs(void); /* Computes node coeffs. */
void valvecoeffs(void); /* Computes valve coeffs. */ void valvecoeffs(void); /* Computes valve coeffs. */
void pipecoeff(int); /* Computes pipe coeff. */ void pipecoeff(int); /* Computes pipe coeff. */
double DWcoeff(int, double *); /* Computes D-W coeff. */ double DWcoeff(int, double *); /* Computes D-W coeff. */
void pumpcoeff(int); /* Computes pump coeff. */ void pumpcoeff(int); /* Computes pump coeff. */
/*** Updated 10/25/00 ***/ /*** Updated 10/25/00 ***/
/*** Updated 12/29/00 ***/ /*** Updated 12/29/00 ***/
void curvecoeff(int,double,double *, /* Computes curve coeffs. */ void curvecoeff(int,double,double *, /* Computes curve coeffs. */
double *); double *);
void gpvcoeff(int); /* Computes GPV coeff. */ void gpvcoeff(int); /* Computes GPV coeff. */
void pbvcoeff(int); /* Computes PBV coeff. */ void pbvcoeff(int); /* Computes PBV coeff. */
void tcvcoeff(int); /* Computes TCV coeff. */ void tcvcoeff(int); /* Computes TCV coeff. */
void prvcoeff(int,int,int); /* Computes PRV coeff. */ void prvcoeff(int,int,int); /* Computes PRV coeff. */
void psvcoeff(int,int,int); /* Computes PSV coeff. */ void psvcoeff(int,int,int); /* Computes PSV coeff. */
void fcvcoeff(int,int,int); /* Computes FCV coeff. */ void fcvcoeff(int,int,int); /* Computes FCV coeff. */
void emittercoeffs(void); /* Computes emitter coeffs. */ void emittercoeffs(void); /* Computes emitter coeffs. */
double emitflowchange(int); /* Computes new emitter flow */ double emitflowchange(int); /* Computes new emitter flow */
/* ----------- SMATRIX.C ---------------*/ /* ----------- SMATRIX.C ---------------*/
int createsparse(void); /* Creates sparse matrix */ int createsparse(void); /* Creates sparse matrix */
int allocsparse(void); /* Allocates matrix memory */ int allocsparse(void); /* Allocates matrix memory */
void freesparse(void); /* Frees matrix memory */ void freesparse(void); /* Frees matrix memory */
int buildlists(int); /* Builds adjacency lists */ int buildlists(int); /* Builds adjacency lists */
int paralink(int, int, int); /* Checks for parallel links */ int paralink(int, int, int); /* Checks for parallel links */
void xparalinks(void); /* Removes parallel links */ void xparalinks(void); /* Removes parallel links */
void freelists(void); /* Frees adjacency lists */ void freelists(void); /* Frees adjacency lists */
void countdegree(void); /* Counts links at each node */ void countdegree(void); /* Counts links at each node */
int reordernodes(void); /* Finds a node re-ordering */ int reordernodes(void); /* Finds a node re-ordering */
int mindegree(int, int); /* Finds min. degree node */ int mindegree(int, int); /* Finds min. degree node */
int growlist(int); /* Augments adjacency list */ int growlist(int); /* Augments adjacency list */
int newlink(Padjlist); /* Adds fill-ins for a node */ int newlink(Padjlist); /* Adds fill-ins for a node */
int linked(int, int); /* Checks if 2 nodes linked */ int linked(int, int); /* Checks if 2 nodes linked */
int addlink(int, int, int); /* Creates new fill-in */ int addlink(int, int, int); /* Creates new fill-in */
int storesparse(int); /* Stores sparse matrix */ int storesparse(int); /* Stores sparse matrix */
int ordersparse(int); /* Orders matrix storage */ int ordersparse(int); /* Orders matrix storage */
void transpose(int,int *,int *, /* Transposes sparse matrix */ void transpose(int,int *,int *, /* Transposes sparse matrix */
int *,int *,int *,int *,int *); int *,int *,int *,int *,int *);
int linsolve(int, double *, double *, /* Solution of linear eqns. */ int linsolve(int, double *, double *, /* Solution of linear eqns. */
double *); /* via Cholesky factorization */ double *); /* via Cholesky factorization */
/* ----------- QUALITY.C ---------------*/ /* ----------- QUALITY.C ---------------*/
int openqual(void); /* Opens WQ solver system */ int openqual(void); /* Opens WQ solver system */
void initqual(void); /* Initializes WQ solver */ void initqual(void); /* Initializes WQ solver */
int runqual(long *); /* Gets current WQ results */ int runqual(long *); /* Gets current WQ results */
int nextqual(long *); /* Updates WQ by hyd.timestep */ int nextqual(long *); /* Updates WQ by hyd.timestep */
int stepqual(long *); /* Updates WQ by WQ time step */ int stepqual(long *); /* Updates WQ by WQ time step */
int closequal(void); /* Closes WQ solver system */ int closequal(void); /* Closes WQ solver system */
int gethyd(long *, long *); /* Gets next hyd. results */ int gethyd(long *, long *); /* Gets next hyd. results */
char setReactflag(void); /* Checks for reactive chem. */ char setReactflag(void); /* Checks for reactive chem. */
void transport(long); /* Transports mass in network */ void transport(long); /* Transports mass in network */
void initsegs(void); /* Initializes WQ segments */ void initsegs(void); /* Initializes WQ segments */
void reorientsegs(void); /* Re-orients WQ segments */ void reorientsegs(void); /* Re-orients WQ segments */
void updatesegs(long); /* Updates quality in segments*/ void updatesegs(long); /* Updates quality in segments*/
void removesegs(int); /* Removes a WQ segment */ void removesegs(int); /* Removes a WQ segment */
void addseg(int,double,double); /* Adds a WQ segment to pipe */ void addseg(int,double,double); /* Adds a WQ segment to pipe */
void accumulate(long); /* Sums mass flow into node */ void accumulate(long); /* Sums mass flow into node */
void updatenodes(long); /* Updates WQ at nodes */ void updatenodes(long); /* Updates WQ at nodes */
void sourceinput(long); /* Computes source inputs */ void sourceinput(long); /* Computes source inputs */
void release(long); /* Releases mass from nodes */ void release(long); /* Releases mass from nodes */
void updatetanks(long); /* Updates WQ in tanks */ void updatetanks(long); /* Updates WQ in tanks */
void updatesourcenodes(long); /* Updates WQ at source nodes */ void updatesourcenodes(long); /* Updates WQ at source nodes */
void tankmix1(int, long); /* Complete mix tank model */ void tankmix1(int, long); /* Complete mix tank model */
void tankmix2(int, long); /* 2-compartment tank model */ void tankmix2(int, long); /* 2-compartment tank model */
void tankmix3(int, long); /* FIFO tank model */ void tankmix3(int, long); /* FIFO tank model */
void tankmix4(int, long); /* LIFO tank model */ void tankmix4(int, long); /* LIFO tank model */
double sourcequal(Psource); /* Finds WQ input from source */ double sourcequal(Psource); /* Finds WQ input from source */
double avgqual(int); /* Finds avg. quality in pipe */ double avgqual(int); /* Finds avg. quality in pipe */
void ratecoeffs(void); /* Finds wall react. coeffs. */ void ratecoeffs(void); /* Finds wall react. coeffs. */
double piperate(int); /* Finds wall react. coeff. */ double piperate(int); /* Finds wall react. coeff. */
double pipereact(int,double,double,long);/* Reacts water in a pipe */ double pipereact(int,double,double,long);/* Reacts water in a pipe */
double tankreact(double,double,double, double tankreact(double,double,double,
long); /* Reacts water in a tank */ long); /* Reacts water in a tank */
double bulkrate(double,double,double); /* Finds bulk reaction rate */ double bulkrate(double,double,double); /* Finds bulk reaction rate */
double wallrate(double,double,double,double);/* Finds wall reaction rate */ double wallrate(double,double,double,double);/* Finds wall reaction rate */
/* ------------ OUTPUT.C ---------------*/ /* ------------ OUTPUT.C ---------------*/
int savenetdata(void); /* Saves basic data to file */ int savenetdata(void); /* Saves basic data to file */
int savehyd(long *); /* Saves hydraulic solution */ int savehyd(long *); /* Saves hydraulic solution */
int savehydstep(long *); /* Saves hydraulic timestep */ int savehydstep(long *); /* Saves hydraulic timestep */
int saveenergy(void); /* Saves energy usage */ int saveenergy(void); /* Saves energy usage */
int readhyd(long *); /* Reads hydraulics from file */ int readhyd(long *); /* Reads hydraulics from file */
int readhydstep(long *); /* Reads time step from file */ int readhydstep(long *); /* Reads time step from file */
int saveoutput(void); /* Saves results to file */ int saveoutput(void); /* Saves results to file */
int nodeoutput(int, REAL4 *, double); /* Saves node results to file */ int nodeoutput(int, REAL4 *, double); /* Saves node results to file */
int linkoutput(int, REAL4 *, double); /* Saves link results to file */ int linkoutput(int, REAL4 *, double); /* Saves link results to file */
int savefinaloutput(void); /* Finishes saving output */ int savefinaloutput(void); /* Finishes saving output */
int savetimestat(REAL4 *, char); /* Saves time stats to file */ int savetimestat(REAL4 *, char); /* Saves time stats to file */
int savenetreacts(double, double, int savenetreacts(double, double,
double, double); /* Saves react. rates to file */ double, double); /* Saves react. rates to file */
int saveepilog(void); /* Saves output file epilog */ int saveepilog(void); /* Saves output file epilog */
/* ------------ INPFILE.C --------------*/ /* ------------ INPFILE.C --------------*/
int saveinpfile(char *); /* Saves network to text file */ int saveinpfile(char *); /* Saves network to text file */

220
src/hash.c Normal file → Executable file
View File

@@ -1,110 +1,110 @@
/*----------------------------------------------------------------------------- /*-----------------------------------------------------------------------------
** hash.c ** hash.c
** **
** Implementation of a simple Hash Table for string storage & retrieval ** Implementation of a simple Hash Table for string storage & retrieval
** **
** Written by L. Rossman ** Written by L. Rossman
** Last Updated on 6/19/03 ** Last Updated on 6/19/03
** **
** The hash table data structure (HTable) is defined in "hash.h". ** The hash table data structure (HTable) is defined in "hash.h".
** Interface Functions: ** Interface Functions:
** HTcreate() - creates a hash table ** HTcreate() - creates a hash table
** HTinsert() - inserts a string & its index value into a hash table ** HTinsert() - inserts a string & its index value into a hash table
** HTfind() - retrieves the index value of a string from a table ** HTfind() - retrieves the index value of a string from a table
** HTfree() - frees a hash table ** HTfree() - frees a hash table
** **
********************************************************************* *********************************************************************
** NOTE: This is a modified version of the original HASH.C module. ** NOTE: This is a modified version of the original HASH.C module.
********************************************************************* *********************************************************************
*/ */
#include <malloc.h> #include <malloc.h>
#include <string.h> #include <string.h>
#include "hash.h" #include "hash.h"
/* Use Fletcher's checksum to compute 2-byte hash of string */ /* Use Fletcher's checksum to compute 2-byte hash of string */
unsigned int hash(char *str) unsigned int hash(char *str)
{ {
unsigned int sum1= 0, check1; unsigned int sum1= 0, check1;
unsigned long sum2= 0L; unsigned long sum2= 0L;
while( '\0' != *str ) while( '\0' != *str )
{ {
sum1 += (*str); sum1 += (*str);
str++; str++;
if ( 255 <= sum1 ) sum1 -= 255; if ( 255 <= sum1 ) sum1 -= 255;
sum2 += sum1; sum2 += sum1;
} }
check1= sum2; check1= sum2;
check1 %= 255; check1 %= 255;
check1= 255 - (sum1+check1) % 255; check1= 255 - (sum1+check1) % 255;
sum1= 255 - (sum1+check1) % 255; sum1= 255 - (sum1+check1) % 255;
return( ( ( check1 << 8 ) | sum1 ) % HTMAXSIZE); return( ( ( check1 << 8 ) | sum1 ) % HTMAXSIZE);
} }
HTtable *HTcreate() HTtable *HTcreate()
{ {
int i; int i;
HTtable *ht = (HTtable *) calloc(HTMAXSIZE, sizeof(HTtable)); HTtable *ht = (HTtable *) calloc(HTMAXSIZE, sizeof(HTtable));
if (ht != NULL) for (i=0; i<HTMAXSIZE; i++) ht[i] = NULL; if (ht != NULL) for (i=0; i<HTMAXSIZE; i++) ht[i] = NULL;
return(ht); return(ht);
} }
int HTinsert(HTtable *ht, char *key, int data) int HTinsert(HTtable *ht, char *key, int data)
{ {
unsigned int i = hash(key); unsigned int i = hash(key);
struct HTentry *entry; struct HTentry *entry;
if ( i >= HTMAXSIZE ) return(0); if ( i >= HTMAXSIZE ) return(0);
entry = (struct HTentry *) malloc(sizeof(struct HTentry)); entry = (struct HTentry *) malloc(sizeof(struct HTentry));
if (entry == NULL) return(0); if (entry == NULL) return(0);
entry->key = key; entry->key = key;
entry->data = data; entry->data = data;
entry->next = ht[i]; entry->next = ht[i];
ht[i] = entry; ht[i] = entry;
return(1); return(1);
} }
int HTfind(HTtable *ht, char *key) int HTfind(HTtable *ht, char *key)
{ {
unsigned int i = hash(key); unsigned int i = hash(key);
struct HTentry *entry; struct HTentry *entry;
if ( i >= HTMAXSIZE ) return(NOTFOUND); if ( i >= HTMAXSIZE ) return(NOTFOUND);
entry = ht[i]; entry = ht[i];
while (entry != NULL) while (entry != NULL)
{ {
if ( strcmp(entry->key,key) == 0 ) return(entry->data); if ( strcmp(entry->key,key) == 0 ) return(entry->data);
entry = entry->next; entry = entry->next;
} }
return(NOTFOUND); return(NOTFOUND);
} }
char *HTfindKey(HTtable *ht, char *key) char *HTfindKey(HTtable *ht, char *key)
{ {
unsigned int i = hash(key); unsigned int i = hash(key);
struct HTentry *entry; struct HTentry *entry;
if ( i >= HTMAXSIZE ) return(NULL); if ( i >= HTMAXSIZE ) return(NULL);
entry = ht[i]; entry = ht[i];
while (entry != NULL) while (entry != NULL)
{ {
if ( strcmp(entry->key,key) == 0 ) return(entry->key); if ( strcmp(entry->key,key) == 0 ) return(entry->key);
entry = entry->next; entry = entry->next;
} }
return(NULL); return(NULL);
} }
void HTfree(HTtable *ht) void HTfree(HTtable *ht)
{ {
struct HTentry *entry, struct HTentry *entry,
*nextentry; *nextentry;
int i; int i;
for (i=0; i<HTMAXSIZE; i++) for (i=0; i<HTMAXSIZE; i++)
{ {
entry = ht[i]; entry = ht[i];
while (entry != NULL) while (entry != NULL)
{ {
nextentry = entry->next; nextentry = entry->next;
free(entry); free(entry);
entry = nextentry; entry = nextentry;
} }
} }
free(ht); free(ht);
} }

48
src/hash.h Normal file → Executable file
View File

@@ -1,24 +1,24 @@
/* HASH.H /* HASH.H
** **
** Header file for Hash Table module HASH.C ** Header file for Hash Table module HASH.C
** **
*/ */
#define HTMAXSIZE 1999 #define HTMAXSIZE 1999
#define NOTFOUND 0 #define NOTFOUND 0
struct HTentry struct HTentry
{ {
char *key; char *key;
int data; int data;
struct HTentry *next; struct HTentry *next;
}; };
typedef struct HTentry *HTtable; typedef struct HTentry *HTtable;
HTtable *HTcreate(void); HTtable *HTcreate(void);
int HTinsert(HTtable *, char *, int); int HTinsert(HTtable *, char *, int);
int HTfind(HTtable *, char *); int HTfind(HTtable *, char *);
char *HTfindKey(HTtable *, char *); char *HTfindKey(HTtable *, char *);
void HTfree(HTtable *); void HTfree(HTtable *);

4972
src/hydraul.c Normal file → Executable file

File diff suppressed because it is too large Load Diff

1242
src/inpfile.c Normal file → Executable file

File diff suppressed because it is too large Load Diff

1278
src/input1.c Normal file → Executable file

File diff suppressed because it is too large Load Diff

1932
src/input2.c Normal file → Executable file

File diff suppressed because it is too large Load Diff

3726
src/input3.c Normal file → Executable file

File diff suppressed because it is too large Load Diff

408
src/mempool.c Normal file → Executable file
View File

@@ -1,204 +1,204 @@
/* mempool.c /* mempool.c
** **
** A simple fast memory allocation package. ** A simple fast memory allocation package.
** **
** By Steve Hill in Graphics Gems III, David Kirk (ed.), ** By Steve Hill in Graphics Gems III, David Kirk (ed.),
** Academic Press, Boston, MA, 1992 ** Academic Press, Boston, MA, 1992
** **
** Modified by Lew Rossman, 8/13/94. ** Modified by Lew Rossman, 8/13/94.
** **
** AllocInit() - create an alloc pool, returns the old pool handle ** AllocInit() - create an alloc pool, returns the old pool handle
** Alloc() - allocate memory ** Alloc() - allocate memory
** AllocReset() - reset the current pool ** AllocReset() - reset the current pool
** AllocSetPool() - set the current pool ** AllocSetPool() - set the current pool
** AllocFree() - free the memory used by the current pool. ** AllocFree() - free the memory used by the current pool.
** **
*/ */
#include <stdlib.h> #include <stdlib.h>
#include <malloc.h> #include <malloc.h>
#include "mempool.h" #include "mempool.h"
/* /*
** ALLOC_BLOCK_SIZE - adjust this size to suit your installation - it ** ALLOC_BLOCK_SIZE - adjust this size to suit your installation - it
** should be reasonably large otherwise you will be mallocing a lot. ** should be reasonably large otherwise you will be mallocing a lot.
*/ */
#define ALLOC_BLOCK_SIZE 64000 /*(62*1024)*/ #define ALLOC_BLOCK_SIZE 64000 /*(62*1024)*/
/* /*
** alloc_hdr_t - Header for each block of memory. ** alloc_hdr_t - Header for each block of memory.
*/ */
typedef struct alloc_hdr_s typedef struct alloc_hdr_s
{ {
struct alloc_hdr_s *next; /* Next Block */ struct alloc_hdr_s *next; /* Next Block */
char *block, /* Start of block */ char *block, /* Start of block */
*free, /* Next free in block */ *free, /* Next free in block */
*end; /* block + block size */ *end; /* block + block size */
} alloc_hdr_t; } alloc_hdr_t;
/* /*
** alloc_root_t - Header for the whole pool. ** alloc_root_t - Header for the whole pool.
*/ */
typedef struct alloc_root_s typedef struct alloc_root_s
{ {
alloc_hdr_t *first, /* First header in pool */ alloc_hdr_t *first, /* First header in pool */
*current; /* Current header */ *current; /* Current header */
} alloc_root_t; } alloc_root_t;
/* /*
** root - Pointer to the current pool. ** root - Pointer to the current pool.
*/ */
static alloc_root_t *root; static alloc_root_t *root;
/* /*
** AllocHdr() ** AllocHdr()
** **
** Private routine to allocate a header and memory block. ** Private routine to allocate a header and memory block.
*/ */
static alloc_hdr_t *AllocHdr(void); static alloc_hdr_t *AllocHdr(void);
static alloc_hdr_t * AllocHdr() static alloc_hdr_t * AllocHdr()
{ {
alloc_hdr_t *hdr; alloc_hdr_t *hdr;
char *block; char *block;
block = (char *) malloc(ALLOC_BLOCK_SIZE); block = (char *) malloc(ALLOC_BLOCK_SIZE);
hdr = (alloc_hdr_t *) malloc(sizeof(alloc_hdr_t)); hdr = (alloc_hdr_t *) malloc(sizeof(alloc_hdr_t));
if (hdr == NULL || block == NULL) return(NULL); if (hdr == NULL || block == NULL) return(NULL);
hdr->block = block; hdr->block = block;
hdr->free = block; hdr->free = block;
hdr->next = NULL; hdr->next = NULL;
hdr->end = block + ALLOC_BLOCK_SIZE; hdr->end = block + ALLOC_BLOCK_SIZE;
return(hdr); return(hdr);
} }
/* /*
** AllocInit() ** AllocInit()
** **
** Create a new memory pool with one block. ** Create a new memory pool with one block.
** Returns pointer to the new pool. ** Returns pointer to the new pool.
*/ */
alloc_handle_t * AllocInit() alloc_handle_t * AllocInit()
{ {
alloc_handle_t *newpool; alloc_handle_t *newpool;
root = (alloc_root_t *) malloc(sizeof(alloc_root_t)); root = (alloc_root_t *) malloc(sizeof(alloc_root_t));
if (root == NULL) return(NULL); if (root == NULL) return(NULL);
if ( (root->first = AllocHdr()) == NULL) return(NULL); if ( (root->first = AllocHdr()) == NULL) return(NULL);
root->current = root->first; root->current = root->first;
newpool = (alloc_handle_t *) root; newpool = (alloc_handle_t *) root;
return(newpool); return(newpool);
} }
/* /*
** Alloc() ** Alloc()
** **
** Use as a direct replacement for malloc(). Allocates ** Use as a direct replacement for malloc(). Allocates
** memory from the current pool. ** memory from the current pool.
*/ */
char * Alloc(long size) char * Alloc(long size)
{ {
alloc_hdr_t *hdr = root->current; alloc_hdr_t *hdr = root->current;
char *ptr; char *ptr;
/* /*
** Align to 4 byte boundary - should be ok for most machines. ** Align to 4 byte boundary - should be ok for most machines.
** Change this if your machine has weird alignment requirements. ** Change this if your machine has weird alignment requirements.
*/ */
size = (size + 3) & 0xfffffffc; size = (size + 3) & 0xfffffffc;
ptr = hdr->free; ptr = hdr->free;
hdr->free += size; hdr->free += size;
/* Check if the current block is exhausted. */ /* Check if the current block is exhausted. */
if (hdr->free >= hdr->end) if (hdr->free >= hdr->end)
{ {
/* Is the next block already allocated? */ /* Is the next block already allocated? */
if (hdr->next != NULL) if (hdr->next != NULL)
{ {
/* re-use block */ /* re-use block */
hdr->next->free = hdr->next->block; hdr->next->free = hdr->next->block;
root->current = hdr->next; root->current = hdr->next;
} }
else else
{ {
/* extend the pool with a new block */ /* extend the pool with a new block */
if ( (hdr->next = AllocHdr()) == NULL) return(NULL); if ( (hdr->next = AllocHdr()) == NULL) return(NULL);
root->current = hdr->next; root->current = hdr->next;
} }
/* set ptr to the first location in the next block */ /* set ptr to the first location in the next block */
ptr = root->current->free; ptr = root->current->free;
root->current->free += size; root->current->free += size;
} }
/* Return pointer to allocated memory. */ /* Return pointer to allocated memory. */
return(ptr); return(ptr);
} }
/* /*
** AllocSetPool() ** AllocSetPool()
** **
** Change the current pool. Return the old pool. ** Change the current pool. Return the old pool.
*/ */
alloc_handle_t * AllocSetPool(alloc_handle_t *newpool) alloc_handle_t * AllocSetPool(alloc_handle_t *newpool)
{ {
alloc_handle_t *old = (alloc_handle_t *) root; alloc_handle_t *old = (alloc_handle_t *) root;
root = (alloc_root_t *) newpool; root = (alloc_root_t *) newpool;
return(old); return(old);
} }
/* /*
** AllocReset() ** AllocReset()
** **
** Reset the current pool for re-use. No memory is freed, ** Reset the current pool for re-use. No memory is freed,
** so this is very fast. ** so this is very fast.
*/ */
void AllocReset() void AllocReset()
{ {
root->current = root->first; root->current = root->first;
root->current->free = root->current->block; root->current->free = root->current->block;
} }
/* /*
** AllocFreePool() ** AllocFreePool()
** **
** Free the memory used by the current pool. ** Free the memory used by the current pool.
** Don't use where AllocReset() could be used. ** Don't use where AllocReset() could be used.
*/ */
void AllocFreePool() void AllocFreePool()
{ {
alloc_hdr_t *tmp, alloc_hdr_t *tmp,
*hdr = root->first; *hdr = root->first;
while (hdr != NULL) while (hdr != NULL)
{ {
tmp = hdr->next; tmp = hdr->next;
free((char *) hdr->block); free((char *) hdr->block);
free((char *) hdr); free((char *) hdr);
hdr = tmp; hdr = tmp;
} }
free((char *) root); free((char *) root);
root = NULL; root = NULL;
} }

38
src/mempool.h Normal file → Executable file
View File

@@ -1,19 +1,19 @@
/* /*
** mempool.h ** mempool.h
** **
** Header for mempool.c ** Header for mempool.c
** **
** The type alloc_handle_t provides an opaque reference to the ** The type alloc_handle_t provides an opaque reference to the
** alloc pool - only the alloc routines know its structure. ** alloc pool - only the alloc routines know its structure.
*/ */
typedef struct typedef struct
{ {
long dummy; long dummy;
} alloc_handle_t; } alloc_handle_t;
alloc_handle_t *AllocInit(void); alloc_handle_t *AllocInit(void);
char *Alloc(long); char *Alloc(long);
alloc_handle_t *AllocSetPool(alloc_handle_t *); alloc_handle_t *AllocSetPool(alloc_handle_t *);
void AllocReset(void); void AllocReset(void);
void AllocFreePool(void); void AllocFreePool(void);

1394
src/output.c Normal file → Executable file

File diff suppressed because it is too large Load Diff

3304
src/quality.c Normal file → Executable file

File diff suppressed because it is too large Load Diff

2444
src/report.c Normal file → Executable file

File diff suppressed because it is too large Load Diff

1934
src/rules.c Normal file → Executable file

File diff suppressed because it is too large Load Diff

1500
src/smatrix.c Normal file → Executable file

File diff suppressed because it is too large Load Diff

1060
src/text.h Normal file → Executable file

File diff suppressed because it is too large Load Diff

448
src/toolkit.h Normal file → Executable file
View File

@@ -1,224 +1,224 @@
/* /*
******************************************************************* *******************************************************************
TOOLKIT.H - Prototypes for EPANET Functions Exported to DLL Toolkit TOOLKIT.H - Prototypes for EPANET Functions Exported to DLL Toolkit
VERSION: 2.00 VERSION: 2.00
DATE: 5/8/00 DATE: 5/8/00
10/25/00 10/25/00
3/1/01 3/1/01
8/15/07 (2.00.11) 8/15/07 (2.00.11)
2/14/08 (2.00.12) 2/14/08 (2.00.12)
AUTHOR: L. Rossman AUTHOR: L. Rossman
US EPA - NRMRL US EPA - NRMRL
******************************************************************* *******************************************************************
*/ */
// --- Define DLLEXPORT // --- Define DLLEXPORT
#ifdef DLL #ifdef DLL
#ifdef __cplusplus #ifdef __cplusplus
#define DLLEXPORT extern "C" __declspec(dllexport) __stdcall #define DLLEXPORT extern "C" __declspec(dllexport) __stdcall
#else #else
#define DLLEXPORT __declspec(dllexport) __stdcall #define DLLEXPORT __declspec(dllexport) __stdcall
#endif #endif
#else #else
#ifdef __cplusplus #ifdef __cplusplus
#define DLLEXPORT extern "C" #define DLLEXPORT extern "C"
#else #else
#define DLLEXPORT #define DLLEXPORT
#endif #endif
#endif #endif
// --- Define the EPANET toolkit constants // --- Define the EPANET toolkit constants
#define EN_ELEVATION 0 /* Node parameters */ #define EN_ELEVATION 0 /* Node parameters */
#define EN_BASEDEMAND 1 #define EN_BASEDEMAND 1
#define EN_PATTERN 2 #define EN_PATTERN 2
#define EN_EMITTER 3 #define EN_EMITTER 3
#define EN_INITQUAL 4 #define EN_INITQUAL 4
#define EN_SOURCEQUAL 5 #define EN_SOURCEQUAL 5
#define EN_SOURCEPAT 6 #define EN_SOURCEPAT 6
#define EN_SOURCETYPE 7 #define EN_SOURCETYPE 7
#define EN_TANKLEVEL 8 #define EN_TANKLEVEL 8
#define EN_DEMAND 9 #define EN_DEMAND 9
#define EN_HEAD 10 #define EN_HEAD 10
#define EN_PRESSURE 11 #define EN_PRESSURE 11
#define EN_QUALITY 12 #define EN_QUALITY 12
#define EN_SOURCEMASS 13 #define EN_SOURCEMASS 13
#define EN_INITVOLUME 14 #define EN_INITVOLUME 14
#define EN_MIXMODEL 15 #define EN_MIXMODEL 15
#define EN_MIXZONEVOL 16 #define EN_MIXZONEVOL 16
#define EN_TANKDIAM 17 #define EN_TANKDIAM 17
#define EN_MINVOLUME 18 #define EN_MINVOLUME 18
#define EN_VOLCURVE 19 #define EN_VOLCURVE 19
#define EN_MINLEVEL 20 #define EN_MINLEVEL 20
#define EN_MAXLEVEL 21 #define EN_MAXLEVEL 21
#define EN_MIXFRACTION 22 #define EN_MIXFRACTION 22
#define EN_TANK_KBULK 23 #define EN_TANK_KBULK 23
#define EN_DIAMETER 0 /* Link parameters */ #define EN_DIAMETER 0 /* Link parameters */
#define EN_LENGTH 1 #define EN_LENGTH 1
#define EN_ROUGHNESS 2 #define EN_ROUGHNESS 2
#define EN_MINORLOSS 3 #define EN_MINORLOSS 3
#define EN_INITSTATUS 4 #define EN_INITSTATUS 4
#define EN_INITSETTING 5 #define EN_INITSETTING 5
#define EN_KBULK 6 #define EN_KBULK 6
#define EN_KWALL 7 #define EN_KWALL 7
#define EN_FLOW 8 #define EN_FLOW 8
#define EN_VELOCITY 9 #define EN_VELOCITY 9
#define EN_HEADLOSS 10 #define EN_HEADLOSS 10
#define EN_STATUS 11 #define EN_STATUS 11
#define EN_SETTING 12 #define EN_SETTING 12
#define EN_ENERGY 13 #define EN_ENERGY 13
#define EN_DURATION 0 /* Time parameters */ #define EN_DURATION 0 /* Time parameters */
#define EN_HYDSTEP 1 #define EN_HYDSTEP 1
#define EN_QUALSTEP 2 #define EN_QUALSTEP 2
#define EN_PATTERNSTEP 3 #define EN_PATTERNSTEP 3
#define EN_PATTERNSTART 4 #define EN_PATTERNSTART 4
#define EN_REPORTSTEP 5 #define EN_REPORTSTEP 5
#define EN_REPORTSTART 6 #define EN_REPORTSTART 6
#define EN_RULESTEP 7 #define EN_RULESTEP 7
#define EN_STATISTIC 8 #define EN_STATISTIC 8
#define EN_PERIODS 9 #define EN_PERIODS 9
#define EN_NODECOUNT 0 /* Component counts */ #define EN_NODECOUNT 0 /* Component counts */
#define EN_TANKCOUNT 1 #define EN_TANKCOUNT 1
#define EN_LINKCOUNT 2 #define EN_LINKCOUNT 2
#define EN_PATCOUNT 3 #define EN_PATCOUNT 3
#define EN_CURVECOUNT 4 #define EN_CURVECOUNT 4
#define EN_CONTROLCOUNT 5 #define EN_CONTROLCOUNT 5
#define EN_JUNCTION 0 /* Node types */ #define EN_JUNCTION 0 /* Node types */
#define EN_RESERVOIR 1 #define EN_RESERVOIR 1
#define EN_TANK 2 #define EN_TANK 2
#define EN_CVPIPE 0 /* Link types. */ #define EN_CVPIPE 0 /* Link types. */
#define EN_PIPE 1 /* See LinkType in TYPES.H */ #define EN_PIPE 1 /* See LinkType in TYPES.H */
#define EN_PUMP 2 #define EN_PUMP 2
#define EN_PRV 3 #define EN_PRV 3
#define EN_PSV 4 #define EN_PSV 4
#define EN_PBV 5 #define EN_PBV 5
#define EN_FCV 6 #define EN_FCV 6
#define EN_TCV 7 #define EN_TCV 7
#define EN_GPV 8 #define EN_GPV 8
#define EN_NONE 0 /* Quality analysis types. */ #define EN_NONE 0 /* Quality analysis types. */
#define EN_CHEM 1 /* See QualType in TYPES.H */ #define EN_CHEM 1 /* See QualType in TYPES.H */
#define EN_AGE 2 #define EN_AGE 2
#define EN_TRACE 3 #define EN_TRACE 3
#define EN_CONCEN 0 /* Source quality types. */ #define EN_CONCEN 0 /* Source quality types. */
#define EN_MASS 1 /* See SourceType in TYPES.H. */ #define EN_MASS 1 /* See SourceType in TYPES.H. */
#define EN_SETPOINT 2 #define EN_SETPOINT 2
#define EN_FLOWPACED 3 #define EN_FLOWPACED 3
#define EN_CFS 0 /* Flow units types. */ #define EN_CFS 0 /* Flow units types. */
#define EN_GPM 1 /* See FlowUnitsType */ #define EN_GPM 1 /* See FlowUnitsType */
#define EN_MGD 2 /* in TYPES.H. */ #define EN_MGD 2 /* in TYPES.H. */
#define EN_IMGD 3 #define EN_IMGD 3
#define EN_AFD 4 #define EN_AFD 4
#define EN_LPS 5 #define EN_LPS 5
#define EN_LPM 6 #define EN_LPM 6
#define EN_MLD 7 #define EN_MLD 7
#define EN_CMH 8 #define EN_CMH 8
#define EN_CMD 9 #define EN_CMD 9
#define EN_TRIALS 0 /* Misc. options */ #define EN_TRIALS 0 /* Misc. options */
#define EN_ACCURACY 1 #define EN_ACCURACY 1
#define EN_TOLERANCE 2 #define EN_TOLERANCE 2
#define EN_EMITEXPON 3 #define EN_EMITEXPON 3
#define EN_DEMANDMULT 4 #define EN_DEMANDMULT 4
#define EN_LOWLEVEL 0 /* Control types. */ #define EN_LOWLEVEL 0 /* Control types. */
#define EN_HILEVEL 1 /* See ControlType */ #define EN_HILEVEL 1 /* See ControlType */
#define EN_TIMER 2 /* in TYPES.H. */ #define EN_TIMER 2 /* in TYPES.H. */
#define EN_TIMEOFDAY 3 #define EN_TIMEOFDAY 3
#define EN_AVERAGE 1 /* Time statistic types. */ #define EN_AVERAGE 1 /* Time statistic types. */
#define EN_MINIMUM 2 /* See TstatType in TYPES.H */ #define EN_MINIMUM 2 /* See TstatType in TYPES.H */
#define EN_MAXIMUM 3 #define EN_MAXIMUM 3
#define EN_RANGE 4 #define EN_RANGE 4
#define EN_MIX1 0 /* Tank mixing models */ #define EN_MIX1 0 /* Tank mixing models */
#define EN_MIX2 1 #define EN_MIX2 1
#define EN_FIFO 2 #define EN_FIFO 2
#define EN_LIFO 3 #define EN_LIFO 3
#define EN_NOSAVE 0 /* Save-results-to-file flag */ #define EN_NOSAVE 0 /* Save-results-to-file flag */
#define EN_SAVE 1 #define EN_SAVE 1
#define EN_INITFLOW 10 /* Re-initialize flows flag */ #define EN_INITFLOW 10 /* Re-initialize flows flag */
// --- Declare the EPANET toolkit functions // --- Declare the EPANET toolkit functions
int DLLEXPORT ENepanet(char *, char *, char *, void (*) (char *)); int DLLEXPORT ENepanet(char *, char *, char *, void (*) (char *));
int DLLEXPORT ENopen(char *, char *, char *); int DLLEXPORT ENopen(char *, char *, char *);
int DLLEXPORT ENsaveinpfile(char *); int DLLEXPORT ENsaveinpfile(char *);
int DLLEXPORT ENclose(void); int DLLEXPORT ENclose(void);
int DLLEXPORT ENsolveH(void); int DLLEXPORT ENsolveH(void);
int DLLEXPORT ENsaveH(void); int DLLEXPORT ENsaveH(void);
int DLLEXPORT ENopenH(void); int DLLEXPORT ENopenH(void);
int DLLEXPORT ENinitH(int); int DLLEXPORT ENinitH(int);
int DLLEXPORT ENrunH(long *); int DLLEXPORT ENrunH(long *);
int DLLEXPORT ENnextH(long *); int DLLEXPORT ENnextH(long *);
int DLLEXPORT ENcloseH(void); int DLLEXPORT ENcloseH(void);
int DLLEXPORT ENsavehydfile(char *); int DLLEXPORT ENsavehydfile(char *);
int DLLEXPORT ENusehydfile(char *); int DLLEXPORT ENusehydfile(char *);
int DLLEXPORT ENsolveQ(void); int DLLEXPORT ENsolveQ(void);
int DLLEXPORT ENopenQ(void); int DLLEXPORT ENopenQ(void);
int DLLEXPORT ENinitQ(int); int DLLEXPORT ENinitQ(int);
int DLLEXPORT ENrunQ(long *); int DLLEXPORT ENrunQ(long *);
int DLLEXPORT ENnextQ(long *); int DLLEXPORT ENnextQ(long *);
int DLLEXPORT ENstepQ(long *); int DLLEXPORT ENstepQ(long *);
int DLLEXPORT ENcloseQ(void); int DLLEXPORT ENcloseQ(void);
int DLLEXPORT ENwriteline(char *); int DLLEXPORT ENwriteline(char *);
int DLLEXPORT ENreport(void); int DLLEXPORT ENreport(void);
int DLLEXPORT ENresetreport(void); int DLLEXPORT ENresetreport(void);
int DLLEXPORT ENsetreport(char *); int DLLEXPORT ENsetreport(char *);
int DLLEXPORT ENgetcontrol(int, int *, int *, float *, int DLLEXPORT ENgetcontrol(int, int *, int *, float *,
int *, float *); int *, float *);
int DLLEXPORT ENgetcount(int, int *); int DLLEXPORT ENgetcount(int, int *);
int DLLEXPORT ENgetoption(int, float *); int DLLEXPORT ENgetoption(int, float *);
int DLLEXPORT ENgettimeparam(int, long *); int DLLEXPORT ENgettimeparam(int, long *);
int DLLEXPORT ENgetflowunits(int *); int DLLEXPORT ENgetflowunits(int *);
int DLLEXPORT ENgetpatternindex(char *, int *); int DLLEXPORT ENgetpatternindex(char *, int *);
int DLLEXPORT ENgetpatternid(int, char *); int DLLEXPORT ENgetpatternid(int, char *);
int DLLEXPORT ENgetpatternlen(int, int *); int DLLEXPORT ENgetpatternlen(int, int *);
int DLLEXPORT ENgetpatternvalue(int, int, float *); int DLLEXPORT ENgetpatternvalue(int, int, float *);
int DLLEXPORT ENgetqualtype(int *, int *); int DLLEXPORT ENgetqualtype(int *, int *);
int DLLEXPORT ENgeterror(int, char *, int); int DLLEXPORT ENgeterror(int, char *, int);
int DLLEXPORT ENgetnodeindex(char *, int *); int DLLEXPORT ENgetnodeindex(char *, int *);
int DLLEXPORT ENgetnodeid(int, char *); int DLLEXPORT ENgetnodeid(int, char *);
int DLLEXPORT ENgetnodetype(int, int *); int DLLEXPORT ENgetnodetype(int, int *);
int DLLEXPORT ENgetnodevalue(int, int, float *); int DLLEXPORT ENgetnodevalue(int, int, float *);
int DLLEXPORT ENgetlinkindex(char *, int *); int DLLEXPORT ENgetlinkindex(char *, int *);
int DLLEXPORT ENgetlinkid(int, char *); int DLLEXPORT ENgetlinkid(int, char *);
int DLLEXPORT ENgetlinktype(int, int *); int DLLEXPORT ENgetlinktype(int, int *);
int DLLEXPORT ENgetlinknodes(int, int *, int *); int DLLEXPORT ENgetlinknodes(int, int *, int *);
int DLLEXPORT ENgetlinkvalue(int, int, float *); int DLLEXPORT ENgetlinkvalue(int, int, float *);
int DLLEXPORT ENgetversion(int *); int DLLEXPORT ENgetversion(int *);
int DLLEXPORT ENsetcontrol(int, int, int, float, int, float); int DLLEXPORT ENsetcontrol(int, int, int, float, int, float);
int DLLEXPORT ENsetnodevalue(int, int, float); int DLLEXPORT ENsetnodevalue(int, int, float);
int DLLEXPORT ENsetlinkvalue(int, int, float); int DLLEXPORT ENsetlinkvalue(int, int, float);
int DLLEXPORT ENaddpattern(char *); int DLLEXPORT ENaddpattern(char *);
int DLLEXPORT ENsetpattern(int, float *, int); int DLLEXPORT ENsetpattern(int, float *, int);
int DLLEXPORT ENsetpatternvalue(int, int, float); int DLLEXPORT ENsetpatternvalue(int, int, float);
int DLLEXPORT ENsettimeparam(int, long); int DLLEXPORT ENsettimeparam(int, long);
int DLLEXPORT ENsetoption(int, float); int DLLEXPORT ENsetoption(int, float);
int DLLEXPORT ENsetstatusreport(int); int DLLEXPORT ENsetstatusreport(int);
int DLLEXPORT ENsetqualtype(int, char *, char *, char *); int DLLEXPORT ENsetqualtype(int, char *, char *, char *);

906
src/types.h Normal file → Executable file
View File

@@ -1,453 +1,453 @@
/* /*
*********************************************************************** ***********************************************************************
TYPES.H -- Global constants and data types for EPANET program TYPES.H -- Global constants and data types for EPANET program
VERSION: 2.00 VERSION: 2.00
DATE: 5/8/00 DATE: 5/8/00
9/7/00 9/7/00
10/25/00 10/25/00
3/1/01 3/1/01
12/6/01 12/6/01
6/24/02 6/24/02
8/15/07 (2.00.11) 8/15/07 (2.00.11)
2/14/08 (2.00.12) 2/14/08 (2.00.12)
AUTHOR: L. Rossman AUTHOR: L. Rossman
US EPA - NRMRL US EPA - NRMRL
********************************************************************** **********************************************************************
*/ */
/*********************************************************/ /*********************************************************/
/* All floats have been re-declared as doubles (7/3/07). */ /* All floats have been re-declared as doubles (7/3/07). */
/*********************************************************/ /*********************************************************/
/* /*
------------------------------------------- -------------------------------------------
Definition of 4-byte integers & reals Definition of 4-byte integers & reals
------------------------------------------- -------------------------------------------
*/ */
typedef float REAL4; //(2.00.11 - LR) typedef float REAL4; //(2.00.11 - LR)
typedef int INT4; //(2.00.12 - LR) typedef int INT4; //(2.00.12 - LR)
/* /*
----------------------------- -----------------------------
Global Constants Global Constants
----------------------------- -----------------------------
*/ */
/*** Updated ***/ /*** Updated ***/
#define CODEVERSION 20012 //(2.00.12 - LR) #define CODEVERSION 20012 //(2.00.12 - LR)
#define MAGICNUMBER 516114521 #define MAGICNUMBER 516114521
#define VERSION 200 #define VERSION 200
#define EOFMARK 0x1A /* Use 0x04 for UNIX systems */ #define EOFMARK 0x1A /* Use 0x04 for UNIX systems */
#define MAXTITLE 3 /* Max. # title lines */ #define MAXTITLE 3 /* Max. # title lines */
#define MAXID 31 /* Max. # characters in ID name */ //(2.00.11 - LR) #define MAXID 31 /* Max. # characters in ID name */ //(2.00.11 - LR)
#define MAXMSG 79 /* Max. # characters in message text */ #define MAXMSG 79 /* Max. # characters in message text */
#define MAXLINE 255 /* Max. # characters read from input line */ #define MAXLINE 255 /* Max. # characters read from input line */
#define MAXFNAME 259 /* Max. # characters in file name */ #define MAXFNAME 259 /* Max. # characters in file name */
#define MAXTOKS 40 /* Max. items per line of input */ #define MAXTOKS 40 /* Max. items per line of input */
#define TZERO 1.E-4 /* Zero time tolerance */ #define TZERO 1.E-4 /* Zero time tolerance */
#define TRUE 1 #define TRUE 1
#define FALSE 0 #define FALSE 0
#define FULL 2 #define FULL 2
#define BIG 1.E10 #define BIG 1.E10
#define TINY 1.E-6 #define TINY 1.E-6
#define MISSING -1.E10 #define MISSING -1.E10
#define PI 3.141592654 #define PI 3.141592654
/*** Updated 9/7/00 ***/ /*** Updated 9/7/00 ***/
/* Various conversion factors */ /* Various conversion factors */
#define GPMperCFS 448.831 #define GPMperCFS 448.831
#define AFDperCFS 1.9837 #define AFDperCFS 1.9837
#define MGDperCFS 0.64632 #define MGDperCFS 0.64632
#define IMGDperCFS 0.5382 #define IMGDperCFS 0.5382
#define LPSperCFS 28.317 #define LPSperCFS 28.317
#define LPMperCFS 1699.0 #define LPMperCFS 1699.0
#define CMHperCFS 101.94 #define CMHperCFS 101.94
#define CMDperCFS 2446.6 #define CMDperCFS 2446.6
#define MLDperCFS 2.4466 #define MLDperCFS 2.4466
#define M3perFT3 0.028317 #define M3perFT3 0.028317
#define LperFT3 28.317 #define LperFT3 28.317
#define MperFT 0.3048 #define MperFT 0.3048
#define PSIperFT 0.4333 #define PSIperFT 0.4333
#define KPAperPSI 6.895 #define KPAperPSI 6.895
#define KWperHP 0.7457 #define KWperHP 0.7457
#define SECperDAY 86400 #define SECperDAY 86400
#define DIFFUS 1.3E-8 /* Diffusivity of chlorine */ #define DIFFUS 1.3E-8 /* Diffusivity of chlorine */
/* @ 20 deg C (sq ft/sec) */ /* @ 20 deg C (sq ft/sec) */
#define VISCOS 1.1E-5 /* Kinematic viscosity of water */ #define VISCOS 1.1E-5 /* Kinematic viscosity of water */
/* @ 20 deg C (sq ft/sec) */ /* @ 20 deg C (sq ft/sec) */
#define SEPSTR " \t\n\r" /* Token separator characters */ #define SEPSTR " \t\n\r" /* Token separator characters */
/* /*
--------------------------------------------------------------------- ---------------------------------------------------------------------
Macro to test for successful allocation of memory Macro to test for successful allocation of memory
--------------------------------------------------------------------- ---------------------------------------------------------------------
*/ */
#define MEMCHECK(x) (((x) == NULL) ? 101 : 0 ) #define MEMCHECK(x) (((x) == NULL) ? 101 : 0 )
#define FREE(x) (free((x))) #define FREE(x) (free((x)))
/* /*
--------------------------------------------------------------------- ---------------------------------------------------------------------
Conversion macros to be used in place of functions Conversion macros to be used in place of functions
--------------------------------------------------------------------- ---------------------------------------------------------------------
*/ */
#define INT(x) ((int)(x)) /* integer portion of x */ #define INT(x) ((int)(x)) /* integer portion of x */
#define FRAC(x) ((x)-(int)(x)) /* fractional part of x */ #define FRAC(x) ((x)-(int)(x)) /* fractional part of x */
#define ABS(x) (((x)<0) ? -(x) : (x)) /* absolute value of x */ #define ABS(x) (((x)<0) ? -(x) : (x)) /* absolute value of x */
#define MIN(x,y) (((x)<=(y)) ? (x) : (y)) /* minimum of x and y */ #define MIN(x,y) (((x)<=(y)) ? (x) : (y)) /* minimum of x and y */
#define MAX(x,y) (((x)>=(y)) ? (x) : (y)) /* maximum of x and y */ #define MAX(x,y) (((x)>=(y)) ? (x) : (y)) /* maximum of x and y */
#define ROUND(x) (((x)>=0) ? (int)((x)+.5) : (int)((x)-.5)) #define ROUND(x) (((x)>=0) ? (int)((x)+.5) : (int)((x)-.5))
/* round-off of x */ /* round-off of x */
#define MOD(x,y) ((x)%(y)) /* x modulus y */ #define MOD(x,y) ((x)%(y)) /* x modulus y */
#define SQR(x) ((x)*(x)) /* x-squared */ #define SQR(x) ((x)*(x)) /* x-squared */
#define SGN(x) (((x)<0) ? (-1) : (1)) /* sign of x */ #define SGN(x) (((x)<0) ? (-1) : (1)) /* sign of x */
#define UCHAR(x) (((x) >= 'a' && (x) <= 'z') ? ((x)&~32) : (x)) #define UCHAR(x) (((x) >= 'a' && (x) <= 'z') ? ((x)&~32) : (x))
/* uppercase char of x */ /* uppercase char of x */
/* /*
------------------------------------------------------ ------------------------------------------------------
Macro to evaluate function x with error checking Macro to evaluate function x with error checking
(Fatal errors are numbered higher than 100) (Fatal errors are numbered higher than 100)
------------------------------------------------------ ------------------------------------------------------
*/ */
#define ERRCODE(x) (errcode = ((errcode>100) ? (errcode) : (x))) #define ERRCODE(x) (errcode = ((errcode>100) ? (errcode) : (x)))
/* /*
------------------------------------------------------ ------------------------------------------------------
Macro to find Pump index of Link[x] Macro to find Pump index of Link[x]
(Diameter = pump index for pump links) (Diameter = pump index for pump links)
------------------------------------------------------ ------------------------------------------------------
*/ */
#define PUMPINDEX(x) (ROUND(Link[(x)].Diam)) #define PUMPINDEX(x) (ROUND(Link[(x)].Diam))
/* /*
------------------------------------------------------ ------------------------------------------------------
Global Data Structures Global Data Structures
------------------------------------------------------ ------------------------------------------------------
*/ */
struct IDstring /* Holds component ID labels */ struct IDstring /* Holds component ID labels */
{ {
char ID[MAXID+1]; char ID[MAXID+1];
}; };
struct Floatlist /* Element of list of floats */ struct Floatlist /* Element of list of floats */
{ {
double value; double value;
struct Floatlist *next; struct Floatlist *next;
}; };
typedef struct Floatlist SFloatlist; typedef struct Floatlist SFloatlist;
struct Tmplist /* Element of temp list for Pattern & Curve data */ struct Tmplist /* Element of temp list for Pattern & Curve data */
{ {
int i; int i;
char ID[MAXID+1]; char ID[MAXID+1];
SFloatlist *x; SFloatlist *x;
SFloatlist *y; SFloatlist *y;
struct Tmplist *next; struct Tmplist *next;
}; };
typedef struct Tmplist STmplist; typedef struct Tmplist STmplist;
typedef struct /* TIME PATTERN OBJECT */ typedef struct /* TIME PATTERN OBJECT */
{ {
char ID[MAXID+1]; /* Pattern ID */ char ID[MAXID+1]; /* Pattern ID */
int Length; /* Pattern length */ int Length; /* Pattern length */
double *F; /* Pattern factors */ double *F; /* Pattern factors */
} Spattern; } Spattern;
typedef struct /* CURVE OBJECT */ typedef struct /* CURVE OBJECT */
{ {
char ID[MAXID+1]; /* Curve ID */ char ID[MAXID+1]; /* Curve ID */
int Type; /* Curve type */ int Type; /* Curve type */
int Npts; /* Number of points */ int Npts; /* Number of points */
double *X; /* X-values */ double *X; /* X-values */
double *Y; /* Y-values */ double *Y; /* Y-values */
} Scurve; } Scurve;
struct Sdemand /* DEMAND CATEGORY OBJECT */ struct Sdemand /* DEMAND CATEGORY OBJECT */
{ {
double Base; /* Baseline demand */ double Base; /* Baseline demand */
int Pat; /* Pattern index */ int Pat; /* Pattern index */
struct Sdemand *next; /* Next record */ struct Sdemand *next; /* Next record */
}; };
typedef struct Sdemand *Pdemand; /* Pointer to demand object */ typedef struct Sdemand *Pdemand; /* Pointer to demand object */
struct Ssource /* WQ SOURCE OBJECT */ struct Ssource /* WQ SOURCE OBJECT */
{ {
/*int Node;*/ /* Node index of source */ /*int Node;*/ /* Node index of source */
double C0; /* Base concentration/mass */ double C0; /* Base concentration/mass */
int Pat; /* Pattern index */ int Pat; /* Pattern index */
double Smass; /* Actual mass flow rate */ double Smass; /* Actual mass flow rate */
char Type; /* SourceType (see below) */ char Type; /* SourceType (see below) */
}; };
typedef struct Ssource *Psource; /* Pointer to WQ source object */ typedef struct Ssource *Psource; /* Pointer to WQ source object */
typedef struct /* NODE OBJECT */ typedef struct /* NODE OBJECT */
{ {
char ID[MAXID+1]; /* Node ID */ char ID[MAXID+1]; /* Node ID */
double El; /* Elevation */ double El; /* Elevation */
Pdemand D; /* Demand pointer */ Pdemand D; /* Demand pointer */
Psource S; /* Source pointer */ Psource S; /* Source pointer */
double C0; /* Initial quality */ double C0; /* Initial quality */
double Ke; /* Emitter coeff. */ double Ke; /* Emitter coeff. */
char Rpt; /* Reporting flag */ char Rpt; /* Reporting flag */
} Snode; } Snode;
typedef struct /* LINK OBJECT */ typedef struct /* LINK OBJECT */
{ {
char ID[MAXID+1]; /* Link ID */ char ID[MAXID+1]; /* Link ID */
int N1; /* Start node index */ int N1; /* Start node index */
int N2; /* End node index */ int N2; /* End node index */
double Diam; /* Diameter */ double Diam; /* Diameter */
double Len; /* Length */ double Len; /* Length */
double Kc; /* Roughness */ double Kc; /* Roughness */
double Km; /* Minor loss coeff. */ double Km; /* Minor loss coeff. */
double Kb; /* Bulk react. coeff */ double Kb; /* Bulk react. coeff */
double Kw; /* Wall react. coeff */ double Kw; /* Wall react. coeff */
double R; /* Flow resistance */ double R; /* Flow resistance */
char Type; /* Link type */ char Type; /* Link type */
char Stat; /* Initial status */ char Stat; /* Initial status */
char Rpt; /* Reporting flag */ char Rpt; /* Reporting flag */
} Slink; } Slink;
typedef struct /* TANK OBJECT */ typedef struct /* TANK OBJECT */
{ {
int Node; /* Node index of tank */ int Node; /* Node index of tank */
double A; /* Tank area */ double A; /* Tank area */
double Hmin; /* Minimum water elev */ double Hmin; /* Minimum water elev */
double Hmax; /* Maximum water elev */ double Hmax; /* Maximum water elev */
double H0; /* Initial water elev */ double H0; /* Initial water elev */
double Vmin; /* Minimum volume */ double Vmin; /* Minimum volume */
double Vmax; /* Maximum volume */ double Vmax; /* Maximum volume */
double V0; /* Initial volume */ double V0; /* Initial volume */
double Kb; /* Reaction coeff. (1/days) */ double Kb; /* Reaction coeff. (1/days) */
double V; /* Tank volume */ double V; /* Tank volume */
double C; /* Concentration */ double C; /* Concentration */
int Pat; /* Fixed grade time pattern */ int Pat; /* Fixed grade time pattern */
int Vcurve; /* Vol.- elev. curve index */ int Vcurve; /* Vol.- elev. curve index */
char MixModel; /* Type of mixing model */ char MixModel; /* Type of mixing model */
/* (see MixType below) */ /* (see MixType below) */
double V1max; /* Mixing compartment size */ double V1max; /* Mixing compartment size */
} Stank; } Stank;
typedef struct /* PUMP OBJECT */ typedef struct /* PUMP OBJECT */
{ {
int Link; /* Link index of pump */ int Link; /* Link index of pump */
int Ptype; /* Pump curve type */ int Ptype; /* Pump curve type */
/* (see PumpType below) */ /* (see PumpType below) */
double Q0; /* Initial flow */ double Q0; /* Initial flow */
double Qmax; /* Maximum flow */ double Qmax; /* Maximum flow */
double Hmax; /* Maximum head */ double Hmax; /* Maximum head */
double H0; /* Shutoff head */ double H0; /* Shutoff head */
double R; /* Flow coeffic. */ double R; /* Flow coeffic. */
double N; /* Flow exponent */ double N; /* Flow exponent */
int Hcurve; /* Head v. flow curve index */ int Hcurve; /* Head v. flow curve index */
int Ecurve; /* Effic. v. flow curve index */ int Ecurve; /* Effic. v. flow curve index */
int Upat; /* Utilization pattern index */ int Upat; /* Utilization pattern index */
int Epat; /* Energy cost pattern index */ int Epat; /* Energy cost pattern index */
double Ecost; /* Unit energy cost */ double Ecost; /* Unit energy cost */
double Energy[6]; /* Energy usage statistics: */ double Energy[6]; /* Energy usage statistics: */
/* 0 = pump utilization */ /* 0 = pump utilization */
/* 1 = avg. efficiency */ /* 1 = avg. efficiency */
/* 2 = avg. kW/flow */ /* 2 = avg. kW/flow */
/* 3 = avg. kwatts */ /* 3 = avg. kwatts */
/* 4 = peak kwatts */ /* 4 = peak kwatts */
/* 5 = cost/day */ /* 5 = cost/day */
} Spump; } Spump;
typedef struct /* VALVE OBJECT */ typedef struct /* VALVE OBJECT */
{ {
int Link; /* Link index of valve */ int Link; /* Link index of valve */
} Svalve; } Svalve;
typedef struct /* CONTROL STATEMENT */ typedef struct /* CONTROL STATEMENT */
{ {
int Link; /* Link index */ int Link; /* Link index */
int Node; /* Control node index */ int Node; /* Control node index */
long Time; /* Control time */ long Time; /* Control time */
double Grade; /* Control grade */ double Grade; /* Control grade */
double Setting; /* New link setting */ double Setting; /* New link setting */
char Status; /* New link status */ char Status; /* New link status */
char Type; /* Control type */ char Type; /* Control type */
/* (see ControlType below) */ /* (see ControlType below) */
} Scontrol; } Scontrol;
struct Sadjlist /* NODE ADJACENCY LIST ITEM */ struct Sadjlist /* NODE ADJACENCY LIST ITEM */
{ {
int node; /* Index of connecting node */ int node; /* Index of connecting node */
int link; /* Index of connecting link */ int link; /* Index of connecting link */
struct Sadjlist *next; /* Next item in list */ struct Sadjlist *next; /* Next item in list */
}; };
/* Pointer to adjacency list item */ /* Pointer to adjacency list item */
typedef struct Sadjlist *Padjlist; typedef struct Sadjlist *Padjlist;
struct Sseg /* PIPE SEGMENT record used */ struct Sseg /* PIPE SEGMENT record used */
{ /* for WQ routing */ { /* for WQ routing */
double v; /* Segment volume */ double v; /* Segment volume */
double c; /* Water quality value */ double c; /* Water quality value */
struct Sseg *prev; /* Record for previous segment */ struct Sseg *prev; /* Record for previous segment */
}; };
typedef struct Sseg *Pseg; /* Pointer to pipe segment */ typedef struct Sseg *Pseg; /* Pointer to pipe segment */
typedef struct /* FIELD OBJECT of report table */ typedef struct /* FIELD OBJECT of report table */
{ {
char Name[MAXID+1]; /* Name of reported variable */ char Name[MAXID+1]; /* Name of reported variable */
char Units[MAXID+1]; /* Units of reported variable */ char Units[MAXID+1]; /* Units of reported variable */
char Enabled; /* Enabled if in table */ char Enabled; /* Enabled if in table */
int Precision; /* Number of decimal places */ int Precision; /* Number of decimal places */
double RptLim[2]; /* Lower/upper report limits */ double RptLim[2]; /* Lower/upper report limits */
} SField; } SField;
/* /*
---------------------------------------------- ----------------------------------------------
Global Enumeration Variables Global Enumeration Variables
---------------------------------------------- ----------------------------------------------
*/ */
enum Hydtype /* Hydraulics solution option: */ enum Hydtype /* Hydraulics solution option: */
{USE, /* use from previous run */ {USE, /* use from previous run */
SAVE, /* save after current run */ SAVE, /* save after current run */
SCRATCH}; /* use temporary file */ SCRATCH}; /* use temporary file */
enum QualType /* Water quality analysis option: */ enum QualType /* Water quality analysis option: */
{NONE, /* no quality analysis */ {NONE, /* no quality analysis */
CHEM, /* analyze a chemical */ CHEM, /* analyze a chemical */
AGE, /* analyze water age */ AGE, /* analyze water age */
TRACE}; /* trace % of flow from a source */ TRACE}; /* trace % of flow from a source */
enum NodeType /* Type of node: */ enum NodeType /* Type of node: */
{JUNC, /* junction */ {JUNC, /* junction */
RESERV, /* reservoir */ RESERV, /* reservoir */
TANK}; /* tank */ TANK}; /* tank */
enum LinkType /* Type of link: */ enum LinkType /* Type of link: */
{CV, /* pipe with check valve */ {CV, /* pipe with check valve */
PIPE, /* regular pipe */ PIPE, /* regular pipe */
PUMP, /* pump */ PUMP, /* pump */
PRV, /* pressure reducing valve */ PRV, /* pressure reducing valve */
PSV, /* pressure sustaining valve */ PSV, /* pressure sustaining valve */
PBV, /* pressure breaker valve */ PBV, /* pressure breaker valve */
FCV, /* flow control valve */ FCV, /* flow control valve */
TCV, /* throttle control valve */ TCV, /* throttle control valve */
GPV}; /* general purpose valve */ GPV}; /* general purpose valve */
enum CurveType /* Type of curve: */ enum CurveType /* Type of curve: */
{V_CURVE, /* volume curve */ {V_CURVE, /* volume curve */
P_CURVE, /* pump curve */ P_CURVE, /* pump curve */
E_CURVE, /* efficiency curve */ E_CURVE, /* efficiency curve */
H_CURVE}; /* head loss curve */ H_CURVE}; /* head loss curve */
enum PumpType /* Type of pump curve: */ enum PumpType /* Type of pump curve: */
{CONST_HP, /* constant horsepower */ {CONST_HP, /* constant horsepower */
POWER_FUNC, /* power function */ POWER_FUNC, /* power function */
CUSTOM, /* user-defined custom curve */ CUSTOM, /* user-defined custom curve */
NOCURVE}; NOCURVE};
enum SourceType /* Type of source quality input */ enum SourceType /* Type of source quality input */
{CONCEN, /* inflow concentration */ {CONCEN, /* inflow concentration */
MASS, /* mass inflow booster */ MASS, /* mass inflow booster */
SETPOINT, /* setpoint booster */ SETPOINT, /* setpoint booster */
FLOWPACED}; /* flow paced booster */ FLOWPACED}; /* flow paced booster */
enum ControlType /* Control condition type: */ enum ControlType /* Control condition type: */
{LOWLEVEL, /* act when grade below set level */ {LOWLEVEL, /* act when grade below set level */
HILEVEL, /* act when grade above set level */ HILEVEL, /* act when grade above set level */
TIMER, /* act when set time reached */ TIMER, /* act when set time reached */
TIMEOFDAY}; /* act when time of day occurs */ TIMEOFDAY}; /* act when time of day occurs */
enum StatType /* Link/Tank status: */ enum StatType /* Link/Tank status: */
{XHEAD, /* pump cannot deliver head (closed) */ {XHEAD, /* pump cannot deliver head (closed) */
TEMPCLOSED, /* temporarily closed */ TEMPCLOSED, /* temporarily closed */
CLOSED, /* closed */ CLOSED, /* closed */
OPEN, /* open */ OPEN, /* open */
ACTIVE, /* valve active (partially open) */ ACTIVE, /* valve active (partially open) */
XFLOW, /* pump exceeds maximum flow */ XFLOW, /* pump exceeds maximum flow */
XFCV, /* FCV cannot supply flow */ XFCV, /* FCV cannot supply flow */
XPRESSURE, /* valve cannot supply pressure */ XPRESSURE, /* valve cannot supply pressure */
FILLING, /* tank filling */ FILLING, /* tank filling */
EMPTYING}; /* tank emptying */ EMPTYING}; /* tank emptying */
enum FormType /* Head loss formula: */ enum FormType /* Head loss formula: */
{HW, /* Hazen-Williams */ {HW, /* Hazen-Williams */
DW, /* Darcy-Weisbach */ DW, /* Darcy-Weisbach */
CM}; /* Chezy-Manning */ CM}; /* Chezy-Manning */
enum UnitsType /* Unit system: */ enum UnitsType /* Unit system: */
{US, /* US */ {US, /* US */
SI}; /* SI (metric) */ SI}; /* SI (metric) */
enum FlowUnitsType /* Flow units: */ enum FlowUnitsType /* Flow units: */
{CFS, /* cubic feet per second */ {CFS, /* cubic feet per second */
GPM, /* gallons per minute */ GPM, /* gallons per minute */
MGD, /* million gallons per day */ MGD, /* million gallons per day */
IMGD, /* imperial million gal. per day */ IMGD, /* imperial million gal. per day */
AFD, /* acre-feet per day */ AFD, /* acre-feet per day */
LPS, /* liters per second */ LPS, /* liters per second */
LPM, /* liters per minute */ LPM, /* liters per minute */
MLD, /* megaliters per day */ MLD, /* megaliters per day */
CMH, /* cubic meters per hour */ CMH, /* cubic meters per hour */
CMD}; /* cubic meters per day */ CMD}; /* cubic meters per day */
enum PressUnitsType /* Pressure units: */ enum PressUnitsType /* Pressure units: */
{PSI, /* pounds per square inch */ {PSI, /* pounds per square inch */
KPA, /* kiloPascals */ KPA, /* kiloPascals */
METERS}; /* meters */ METERS}; /* meters */
enum RangeType /* Range limits: */ enum RangeType /* Range limits: */
{LOW, /* lower limit */ {LOW, /* lower limit */
HI, /* upper limit */ HI, /* upper limit */
PREC}; /* precision */ PREC}; /* precision */
enum MixType /* Tank mixing regimes */ enum MixType /* Tank mixing regimes */
{MIX1, /* 1-compartment model */ {MIX1, /* 1-compartment model */
MIX2, /* 2-compartment model */ MIX2, /* 2-compartment model */
FIFO, /* First in, first out model */ FIFO, /* First in, first out model */
LIFO}; /* Last in, first out model */ LIFO}; /* Last in, first out model */
enum TstatType /* Time series statistics */ enum TstatType /* Time series statistics */
{SERIES, /* none */ {SERIES, /* none */
AVG, /* time-averages */ AVG, /* time-averages */
MIN, /* minimum values */ MIN, /* minimum values */
MAX, /* maximum values */ MAX, /* maximum values */
RANGE}; /* max - min values */ RANGE}; /* max - min values */
#define MAXVAR 21 /* Max. # types of network variables */ #define MAXVAR 21 /* Max. # types of network variables */
/* (equals # items enumed below) */ /* (equals # items enumed below) */
enum FieldType /* Network variables: */ enum FieldType /* Network variables: */
{ELEV, /* nodal elevation */ {ELEV, /* nodal elevation */
DEMAND, /* nodal demand flow */ DEMAND, /* nodal demand flow */
HEAD, /* nodal hydraulic head */ HEAD, /* nodal hydraulic head */
PRESSURE, /* nodal pressure */ PRESSURE, /* nodal pressure */
QUALITY, /* nodal water quality */ QUALITY, /* nodal water quality */
LENGTH, /* link length */ LENGTH, /* link length */
DIAM, /* link diameter */ DIAM, /* link diameter */
FLOW, /* link flow rate */ FLOW, /* link flow rate */
VELOCITY, /* link flow velocity */ VELOCITY, /* link flow velocity */
HEADLOSS, /* link head loss */ HEADLOSS, /* link head loss */
LINKQUAL, /* avg. water quality in link */ LINKQUAL, /* avg. water quality in link */
STATUS, /* link status */ STATUS, /* link status */
SETTING, /* pump/valve setting */ SETTING, /* pump/valve setting */
REACTRATE, /* avg. reaction rate in link */ REACTRATE, /* avg. reaction rate in link */
FRICTION, /* link friction factor */ FRICTION, /* link friction factor */
POWER, /* pump power output */ POWER, /* pump power output */
TIME, /* simulation time */ TIME, /* simulation time */
VOLUME, /* tank volume */ VOLUME, /* tank volume */
CLOCKTIME, /* simulation time of day */ CLOCKTIME, /* simulation time of day */
FILLTIME, /* time to fill a tank */ FILLTIME, /* time to fill a tank */
DRAINTIME}; /* time to drain a tank */ DRAINTIME}; /* time to drain a tank */
enum SectType {_TITLE,_JUNCTIONS,_RESERVOIRS,_TANKS,_PIPES,_PUMPS, enum SectType {_TITLE,_JUNCTIONS,_RESERVOIRS,_TANKS,_PIPES,_PUMPS,
_VALVES,_CONTROLS,_RULES,_DEMANDS,_SOURCES,_EMITTERS, _VALVES,_CONTROLS,_RULES,_DEMANDS,_SOURCES,_EMITTERS,
_PATTERNS,_CURVES,_QUALITY,_STATUS,_ROUGHNESS,_ENERGY, _PATTERNS,_CURVES,_QUALITY,_STATUS,_ROUGHNESS,_ENERGY,
_REACTIONS,_MIXING,_REPORT,_TIMES,_OPTIONS, _REACTIONS,_MIXING,_REPORT,_TIMES,_OPTIONS,
_COORDS,_VERTICES,_LABELS,_BACKDROP,_TAGS,_END}; _COORDS,_VERTICES,_LABELS,_BACKDROP,_TAGS,_END};
enum HdrType /* Type of table heading */ enum HdrType /* Type of table heading */
{STATHDR, /* Hydraulic Status */ {STATHDR, /* Hydraulic Status */
ENERHDR, /* Energy Usage */ ENERHDR, /* Energy Usage */
NODEHDR, /* Node Results */ NODEHDR, /* Node Results */
LINKHDR}; /* Link Results */ LINKHDR}; /* Link Results */

392
src/vars.h Normal file → Executable file
View File

@@ -1,196 +1,196 @@
/* /*
************************************************************************ ************************************************************************
Global Variables for EPANET Program Global Variables for EPANET Program
VERSION: 2.00 VERSION: 2.00
DATE: 5/8/00 DATE: 5/8/00
6/24/02 6/24/02
2/14/08 (2.00.12) 2/14/08 (2.00.12)
AUTHOR: L. Rossman AUTHOR: L. Rossman
US EPA - NRMRL US EPA - NRMRL
************************************************************************ ************************************************************************
*/ */
EXTERN FILE *InFile, /* Input file pointer */ EXTERN FILE *InFile, /* Input file pointer */
*OutFile, /* Output file pointer */ *OutFile, /* Output file pointer */
*RptFile, /* Report file pointer */ *RptFile, /* Report file pointer */
*HydFile, /* Hydraulics file pointer */ *HydFile, /* Hydraulics file pointer */
*TmpOutFile; /* Temporary file handle */ *TmpOutFile; /* Temporary file handle */
EXTERN long HydOffset, /* Hydraulics file byte offset */ EXTERN long HydOffset, /* Hydraulics file byte offset */
OutOffset1, /* 1st output file byte offset */ OutOffset1, /* 1st output file byte offset */
OutOffset2; /* 2nd output file byte offset */ OutOffset2; /* 2nd output file byte offset */
EXTERN char Msg[MAXMSG+1], /* Text of output message */ EXTERN char Msg[MAXMSG+1], /* Text of output message */
InpFname[MAXFNAME+1], /* Input file name */ InpFname[MAXFNAME+1], /* Input file name */
Rpt1Fname[MAXFNAME+1], /* Primary report file name */ Rpt1Fname[MAXFNAME+1], /* Primary report file name */
Rpt2Fname[MAXFNAME+1], /* Secondary report file name */ Rpt2Fname[MAXFNAME+1], /* Secondary report file name */
HydFname[MAXFNAME+1], /* Hydraulics file name */ HydFname[MAXFNAME+1], /* Hydraulics file name */
OutFname[MAXFNAME+1], /* Binary output file name */ OutFname[MAXFNAME+1], /* Binary output file name */
MapFname[MAXFNAME+1], /* Map file name */ MapFname[MAXFNAME+1], /* Map file name */
TmpFname[MAXFNAME+1], /* Temporary file name */ //(2.00.12 - LR) TmpFname[MAXFNAME+1], /* Temporary file name */ //(2.00.12 - LR)
TmpDir[MAXFNAME+1], /* Temporary directory name */ //(2.00.12 - LR) TmpDir[MAXFNAME+1], /* Temporary directory name */ //(2.00.12 - LR)
Title[MAXTITLE][MAXMSG+1], /* Problem title */ Title[MAXTITLE][MAXMSG+1], /* Problem title */
ChemName[MAXID+1], /* Name of chemical */ ChemName[MAXID+1], /* Name of chemical */
ChemUnits[MAXID+1], /* Units of chemical */ ChemUnits[MAXID+1], /* Units of chemical */
DefPatID[MAXID+1], /* Default demand pattern ID */ DefPatID[MAXID+1], /* Default demand pattern ID */
/*** Updated 6/24/02 ***/ /*** Updated 6/24/02 ***/
Atime[13], /* Clock time (hrs:min:sec) */ Atime[13], /* Clock time (hrs:min:sec) */
Outflag, /* Output file flag */ //(2.00.12 - LR) Outflag, /* Output file flag */ //(2.00.12 - LR)
Hydflag, /* Hydraulics flag */ Hydflag, /* Hydraulics flag */
Qualflag, /* Water quality flag */ Qualflag, /* Water quality flag */
Reactflag, /* Reaction indicator */ //(2.00.12 - LR) Reactflag, /* Reaction indicator */ //(2.00.12 - LR)
Unitsflag, /* Unit system flag */ Unitsflag, /* Unit system flag */
Flowflag, /* Flow units flag */ Flowflag, /* Flow units flag */
Pressflag, /* Pressure units flag */ Pressflag, /* Pressure units flag */
Formflag, /* Hydraulic formula flag */ Formflag, /* Hydraulic formula flag */
Rptflag, /* Report flag */ Rptflag, /* Report flag */
Summaryflag, /* Report summary flag */ Summaryflag, /* Report summary flag */
Messageflag, /* Error/warning message flag */ Messageflag, /* Error/warning message flag */
Statflag, /* Status report flag */ Statflag, /* Status report flag */
Energyflag, /* Energy report flag */ Energyflag, /* Energy report flag */
Nodeflag, /* Node report flag */ Nodeflag, /* Node report flag */
Linkflag, /* Link report flag */ Linkflag, /* Link report flag */
Tstatflag, /* Time statistics flag */ Tstatflag, /* Time statistics flag */
Warnflag, /* Warning flag */ Warnflag, /* Warning flag */
Openflag, /* Input processed flag */ Openflag, /* Input processed flag */
OpenHflag, /* Hydraul. system opened flag */ OpenHflag, /* Hydraul. system opened flag */
SaveHflag, /* Hydraul. results saved flag */ SaveHflag, /* Hydraul. results saved flag */
OpenQflag, /* Quality system opened flag */ OpenQflag, /* Quality system opened flag */
SaveQflag, /* Quality results saved flag */ SaveQflag, /* Quality results saved flag */
Saveflag; /* General purpose save flag */ Saveflag; /* General purpose save flag */
EXTERN int MaxNodes, /* Node count from input file */ EXTERN int MaxNodes, /* Node count from input file */
MaxLinks, /* Link count from input file */ MaxLinks, /* Link count from input file */
MaxJuncs, /* Junction count */ MaxJuncs, /* Junction count */
MaxPipes, /* Pipe count */ MaxPipes, /* Pipe count */
MaxTanks, /* Tank count */ MaxTanks, /* Tank count */
MaxPumps, /* Pump count */ MaxPumps, /* Pump count */
MaxValves, /* Valve count */ MaxValves, /* Valve count */
MaxControls, /* Control count */ MaxControls, /* Control count */
MaxRules, /* Rule count */ MaxRules, /* Rule count */
MaxPats, /* Pattern count */ MaxPats, /* Pattern count */
MaxCurves, /* Curve count */ MaxCurves, /* Curve count */
Nnodes, /* Number of network nodes */ Nnodes, /* Number of network nodes */
Ntanks, /* Number of tanks */ Ntanks, /* Number of tanks */
Njuncs, /* Number of junction nodes */ Njuncs, /* Number of junction nodes */
Nlinks, /* Number of network links */ Nlinks, /* Number of network links */
Npipes, /* Number of pipes */ Npipes, /* Number of pipes */
Npumps, /* Number of pumps */ Npumps, /* Number of pumps */
Nvalves, /* Number of valves */ Nvalves, /* Number of valves */
Ncontrols, /* Number of simple controls */ Ncontrols, /* Number of simple controls */
Nrules, /* Number of control rules */ Nrules, /* Number of control rules */
Npats, /* Number of time patterns */ Npats, /* Number of time patterns */
Ncurves, /* Number of data curves */ Ncurves, /* Number of data curves */
Nperiods, /* Number of reporting periods */ Nperiods, /* Number of reporting periods */
Ncoeffs, /* Number of non-0 matrix coeffs*/ Ncoeffs, /* Number of non-0 matrix coeffs*/
DefPat, /* Default demand pattern */ DefPat, /* Default demand pattern */
Epat, /* Energy cost time pattern */ Epat, /* Energy cost time pattern */
MaxIter, /* Max. hydraulic trials */ MaxIter, /* Max. hydraulic trials */
ExtraIter, /* Extra hydraulic trials */ ExtraIter, /* Extra hydraulic trials */
TraceNode, /* Source node for flow tracing */ TraceNode, /* Source node for flow tracing */
PageSize, /* Lines/page in output report */ PageSize, /* Lines/page in output report */
CheckFreq, /* Hydraulics solver parameter */ CheckFreq, /* Hydraulics solver parameter */
MaxCheck; /* Hydraulics solver parameter */ MaxCheck; /* Hydraulics solver parameter */
EXTERN double Ucf[MAXVAR], /* Unit conversion factors */ EXTERN double Ucf[MAXVAR], /* Unit conversion factors */
Ctol, /* Water quality tolerance */ Ctol, /* Water quality tolerance */
Htol, /* Hydraulic head tolerance */ Htol, /* Hydraulic head tolerance */
Qtol, /* Flow rate tolerance */ Qtol, /* Flow rate tolerance */
RQtol, /* Flow resistance tolerance */ RQtol, /* Flow resistance tolerance */
Hexp, /* Exponent in headloss formula */ Hexp, /* Exponent in headloss formula */
Qexp, /* Exponent in orifice formula */ Qexp, /* Exponent in orifice formula */
Dmult, /* Demand multiplier */ Dmult, /* Demand multiplier */
Hacc, /* Hydraulics solution accuracy */ Hacc, /* Hydraulics solution accuracy */
DampLimit, /* Solution damping threshold */ //(2.00.12 - LR) DampLimit, /* Solution damping threshold */ //(2.00.12 - LR)
BulkOrder, /* Bulk flow reaction order */ BulkOrder, /* Bulk flow reaction order */
WallOrder, /* Pipe wall reaction order */ WallOrder, /* Pipe wall reaction order */
TankOrder, /* Tank reaction order */ TankOrder, /* Tank reaction order */
Kbulk, /* Global bulk reaction coeff. */ Kbulk, /* Global bulk reaction coeff. */
Kwall, /* Global wall reaction coeff. */ Kwall, /* Global wall reaction coeff. */
Climit, /* Limiting potential quality */ Climit, /* Limiting potential quality */
Rfactor, /* Roughness-reaction factor */ Rfactor, /* Roughness-reaction factor */
Diffus, /* Diffusivity (sq ft/sec) */ Diffus, /* Diffusivity (sq ft/sec) */
Viscos, /* Kin. viscosity (sq ft/sec) */ Viscos, /* Kin. viscosity (sq ft/sec) */
SpGrav, /* Specific gravity */ SpGrav, /* Specific gravity */
Ecost, /* Base energy cost per kwh */ Ecost, /* Base energy cost per kwh */
Dcost, /* Energy demand charge/kw/day */ Dcost, /* Energy demand charge/kw/day */
Epump, /* Global pump efficiency */ Epump, /* Global pump efficiency */
Emax, /* Peak energy usage */ Emax, /* Peak energy usage */
Dsystem, /* Total system demand */ Dsystem, /* Total system demand */
Wbulk, /* Avg. bulk reaction rate */ Wbulk, /* Avg. bulk reaction rate */
Wwall, /* Avg. wall reaction rate */ Wwall, /* Avg. wall reaction rate */
Wtank, /* Avg. tank reaction rate */ Wtank, /* Avg. tank reaction rate */
Wsource; /* Avg. mass inflow */ Wsource; /* Avg. mass inflow */
EXTERN long Tstart, /* Starting time of day (sec) */ EXTERN long Tstart, /* Starting time of day (sec) */
Hstep, /* Nominal hyd. time step (sec) */ Hstep, /* Nominal hyd. time step (sec) */
Qstep, /* Quality time step (sec) */ Qstep, /* Quality time step (sec) */
Pstep, /* Time pattern time step (sec) */ Pstep, /* Time pattern time step (sec) */
Pstart, /* Starting pattern time (sec) */ Pstart, /* Starting pattern time (sec) */
Rstep, /* Reporting time step (sec) */ Rstep, /* Reporting time step (sec) */
Rstart, /* Time when reporting starts */ Rstart, /* Time when reporting starts */
Rtime, /* Next reporting time */ Rtime, /* Next reporting time */
Htime, /* Current hyd. time (sec) */ Htime, /* Current hyd. time (sec) */
Qtime, /* Current quality time (sec) */ Qtime, /* Current quality time (sec) */
Hydstep, /* Actual hydraulic time step */ Hydstep, /* Actual hydraulic time step */
Rulestep, /* Rule evaluation time step */ Rulestep, /* Rule evaluation time step */
Dur; /* Duration of simulation (sec) */ Dur; /* Duration of simulation (sec) */
EXTERN SField Field[MAXVAR]; /* Output reporting fields */ EXTERN SField Field[MAXVAR]; /* Output reporting fields */
/* Array pointers not allocated and freed in same routine */ /* Array pointers not allocated and freed in same routine */
EXTERN char *S, /* Link status */ EXTERN char *S, /* Link status */
*OldStat; /* Previous link/tank status */ *OldStat; /* Previous link/tank status */
EXTERN double *D, /* Node actual demand */ EXTERN double *D, /* Node actual demand */
*C, /* Node actual quality */ *C, /* Node actual quality */
*E, /* Emitter flows */ *E, /* Emitter flows */
*K, /* Link settings */ *K, /* Link settings */
*Q, /* Link flows */ *Q, /* Link flows */
*R, /* Pipe reaction rate */ *R, /* Pipe reaction rate */
*X; /* General purpose array */ *X; /* General purpose array */
EXTERN double *H; /* Node heads */ EXTERN double *H; /* Node heads */
EXTERN STmplist *Patlist; /* Temporary time pattern list */ EXTERN STmplist *Patlist; /* Temporary time pattern list */
EXTERN STmplist *Curvelist; /* Temporary list of curves */ EXTERN STmplist *Curvelist; /* Temporary list of curves */
EXTERN Spattern *Pattern; /* Time patterns */ EXTERN Spattern *Pattern; /* Time patterns */
EXTERN Scurve *Curve; /* Curve data */ EXTERN Scurve *Curve; /* Curve data */
EXTERN Snode *Node; /* Node data */ EXTERN Snode *Node; /* Node data */
EXTERN Slink *Link; /* Link data */ EXTERN Slink *Link; /* Link data */
EXTERN Stank *Tank; /* Tank data */ EXTERN Stank *Tank; /* Tank data */
EXTERN Spump *Pump; /* Pump data */ EXTERN Spump *Pump; /* Pump data */
EXTERN Svalve *Valve; /* Valve data */ EXTERN Svalve *Valve; /* Valve data */
EXTERN Scontrol *Control; /* Control data */ EXTERN Scontrol *Control; /* Control data */
EXTERN HTtable *Nht, *Lht; /* Hash tables for ID labels */ EXTERN HTtable *Nht, *Lht; /* Hash tables for ID labels */
EXTERN Padjlist *Adjlist; /* Node adjacency lists */ EXTERN Padjlist *Adjlist; /* Node adjacency lists */
/* /*
** NOTE: Hydraulic analysis of the pipe network at a given point in time ** NOTE: Hydraulic analysis of the pipe network at a given point in time
** is done by repeatedly solving a linearized version of the ** is done by repeatedly solving a linearized version of the
** equations for conservation of flow & energy: ** equations for conservation of flow & energy:
** **
** A*H = F ** A*H = F
** **
** where H = vector of heads (unknowns) at each node, ** where H = vector of heads (unknowns) at each node,
** F = vector of right-hand side coeffs. ** F = vector of right-hand side coeffs.
** A = square matrix of coeffs. ** A = square matrix of coeffs.
** and both A and F are updated at each iteration until there is ** and both A and F are updated at each iteration until there is
** negligible change in pipe flows. ** negligible change in pipe flows.
** **
** Each row (or column) of A corresponds to a junction in the pipe ** Each row (or column) of A corresponds to a junction in the pipe
** network. Each link (pipe, pump or valve) in the network has a ** network. Each link (pipe, pump or valve) in the network has a
** non-zero entry in the row-column of A that corresponds to its ** non-zero entry in the row-column of A that corresponds to its
** end points. This results in A being symmetric and very sparse. ** end points. This results in A being symmetric and very sparse.
** The following arrays are used to efficiently manage this sparsity: ** The following arrays are used to efficiently manage this sparsity:
*/ */
EXTERN double *Aii, /* Diagonal coeffs. of A */ EXTERN double *Aii, /* Diagonal coeffs. of A */
*Aij, /* Non-zero, off-diagonal coeffs. of A */ *Aij, /* Non-zero, off-diagonal coeffs. of A */
*F; /* Right hand side coeffs. */ *F; /* Right hand side coeffs. */
EXTERN double *P, /* Inverse headloss derivatives */ EXTERN double *P, /* Inverse headloss derivatives */
*Y; /* Flow correction factors */ *Y; /* Flow correction factors */
EXTERN int *Order, /* Node-to-row of A */ EXTERN int *Order, /* Node-to-row of A */
*Row, /* Row-to-node of A */ *Row, /* Row-to-node of A */
*Ndx; /* Index of link's coeff. in Aij */ *Ndx; /* Index of link's coeff. in Aij */
/* /*
** The following arrays store the positions of the non-zero coeffs. ** The following arrays store the positions of the non-zero coeffs.
** of the lower triangular portion of A whose values are stored in Aij: ** of the lower triangular portion of A whose values are stored in Aij:
*/ */
EXTERN int *XLNZ, /* Start position of each column in NZSUB */ EXTERN int *XLNZ, /* Start position of each column in NZSUB */
*NZSUB, /* Row index of each coeff. in each column */ *NZSUB, /* Row index of each coeff. in each column */
*LNZ; /* Position of each coeff. in Aij array */ *LNZ; /* Position of each coeff. in Aij array */