I have written a simple awk program to implement an "include" capability for building EPANET files. This allows you to use the following line in an EPANET file to include the contents of file "stuff.inc":
$include: stuff.inc
Files can be named in any way and can include a full path. In principle (limited by stack space) it will handle an unlimited level of nesting (include directives inside of included files).
A very useful application of this capability is two-level nesting, which allows you to easily manage scenarios. For example, if the "backbone" EPANET file contained within it the previous reference to "stuff.inc" and you created different "stuff.inc" files in different directories, each directory could define a different scenario. Each instance of "stuff.inc" could contain references to different substantial input files, which would be combined into the same backbone, depending on the directory from which you ran the buildinp program. That way you could easily maintain "canonical" information while also varying other parameters or data across scenarios.
This program will build any kind of text file. The only EPANET-specific construct is the choice of a semi-colon for a comment statement.
No warranties, implied or expressed. It's worth what you paid for it. I would be interested to know if it doesn't do what it's supposed to, though.
I've found this very useful. I hope it is useful to other EPANET users.
Regards
Ben Harding
blh@hydrosphere.com
# program buildinp.awk
# builds epanet input file using include directives
# usage: awk -f buildinp.awk inputfile > outputfile
function printline(include_file)
{
if ($1 ~/^$[iI][nN][cC][lL][uU][dD][eE]:/){
include_file = $2
print "; ==>", include_file
while (getline < include_file > 0) printline()
close (include_file)
print "; <=="
}
else{
print
}
}
{printline()}