Cliff Inbau
Bruce Rindahl

GIS as a Tool for Data Input and Visualization
for a MODFLOW Ground Water Model

Abstract

The City of Aurora's Utilities Department is using ArcView 3.0 software for preparing ground water models and analyzing simulation results. Two major ground water projects are currently under development and rely heavily upon the USGS three dimensional finite-difference ground water model, MODFLOW. Input files are difficult and time consuming to construct, and once the input files are written, future modifications pose a challenge. Typically, displaying the results of MODFLOW simulations required post processing software, which usually do not display model or information in a georeferenced format. A Geographic information system (GIS) was seen as a possible solution to the interface challenges with the MODFLOW model. Environmental Systems Research Institute's (Esri) ArcView 3.0, with Spatial Analyst, was used as an efficient tool for both pre and post processing of MODFLOW data. In a previous paper, it was demonstrated that ArcView could display drawdowns, streamflows and aquifer elevations from MODFLOW simulations. Using ArcView's ability to join GIS coverages and text tables, an easy to use interface for displaying and analyzing complex model simulation results was developed for ArcView 3.0. The next step in interfacing ArcView with MODFLOW, was to use ArcView as a method to develop MODFLOW input files. To date, routines have been developed for both the Well (WEL) and Streamflow-Routing (STR) packages. This paper will cover the steps in development and use of this GIS tool as an interface for MODFLOW including Avenue script customization.


Introduction

The City of Aurora, the third largest city in the State of Colorado, is a community of approximately 255,000 and is located in the east and southeast Denver metro area. The Utilities Department's service area covers a 135 square mile area. The raw water system supplying Aurora is large and covers a wide geographic area within Colorado, collecting water from three major river basins. Sources of water are comprised of transmountain supplies (surface collection, transferred agriculture rights) and in-basin supplies (transferred agriculture rights, surface collection, ground water, and reusable water). Ground water supplies are a small portion of the City's water supply, however this resource is playing a increasing role in several current water projects: Cherry Creek Well Field Augmentation Plan, and two stream-aquifer conjunctive use projects. This paper will focus on the GIS applications used with the Cherry Creek Well Field Augmentation Plan and not the conjunctive use projects. However, the ArcView tools developed are currently being used in the other projects.

The Cherry Creek well field consists of seven alluvium wells and has been in operation since 1956. As a result of well regulations enacted by the State of Colorado since the wells were drilled, an analysis of the potential impacts to the Cherry Creek and South Platte River systems was required for continued use of the wells (Rindahl, 1996). The Cherry Creek aquifer, above Cherry Creek Reservoir, is a groundwater source for many small communities and water districts south of the Denver Metro area. In addition to Aurora's seven wells, there are approximately 15 other municipal water supply wells that pump water out of the aquifer. As part of the study, the City hired a local consulting firm, Bishop-Brogden, Inc., to analyze well field pumping and impacts downstream. Bishop-Brogden utilized MODFLOW in their groundwater modeling and analysis.

To aid in analyzing the MODFLOW simulation results, a ArcView 3.0 application was developed by the City of Aurora Utilities. ArcView provides a clear, geo-referenced view of the model results. ArcView also provides a procedure to write out MODFLOW input files in a easy and efficient way. The purpose of this paper is to describe the ArcView 3.0 application as a method of data input into MODFLOW modules, as well as providing a way to display and analyze simulation results.

Model Description

MODFLOW was written by Michael McDonald and Arlen Harbaugh, with the U.S. Geological Survey (USGS), and is a three-dimensional finite-difference groundwater flow model. Since a detail discussion of the model is beyond the scope of this paper, the reader can refer to McDonald and Harbaugh's paper for a more detail account of MODFLOW. The model simulates recharge, evapotranspiration, areal recharge, flow to wells, flow to drains, and flow through river beds (Fetter, 1988). The MODFLOW model is comprised of a main program and several independent subroutines called "modules". The modules are grouped functionally into packages representing hydrologic functions or matrix solution algorithms(Van der Heijde and Poeter, 1996). Packages in MODFLOW include Basic (BAS), Block-Centered Flow (BCF), Output Control (OC), River (RIV), Recharge (RCH), Well (WEL), Drain (DRN), Evapotranspiration (ET), and General- Head Boundary (GHB). Several solver packages are available in MODFLOW, with the Strongly Implicit Procedure (SIP) currently being used in the Aurora Cherry Creek model.

Various researchers have written optional add-on packages for MODFLOW. In the Cherry Creek model, the Streamflow Routing Package (STR1) was utilized. STR1 was written by David Prudic (USGS) in 1989. The Streamflow Routing routine is a accounting program that tracks the flow in one or more streams that interact with groundwater(Prudic, 1989). Recharge into the aquifer in a reach ceases when the stream is dry and a stream is permitted to flow once the aquifer head is above the streambed (Prudic, 1999). Because several reaches of Cherry Creek go dry during certain times of the year, the STR1 package proved to be an integral part of the Cherry Creek model. More detail information on the Streamflow Routing package can be located in Prudic's paper.

The Cherry Creek model consisted of a 72 column by 244 row grid of 200 foot squares and was oriented in a southeast to northwest manner along the axis of Cherry Creek, upstream of Cherry Creek Reservoir. Figure 1 shows the model grid in relation to the City of Aurora. Due to limited nature of this paper, detail description of the model parameters is not covered, however, more information can be obtained from the City of Aurora.

location

Figure 1 - Location of Cherry Creek Model

GIS Coverages

For this particular groundwater project, the modeling effort proceeded the GIS coverage and development work. Currently, however, the MODFLOW and GIS are proceeding on a concurrent basis. Originally the MODFLOW grid and other features were designed and laid out using AutoCad. Once GIS was seen as a tool to assist the modeling effort, the City of Aurora converted the grid CAD file into a ArcInfo polygon coverage and used TRANSFORM to geo-rectify the coverage. Refer to Rindahl (1996) for a detailed procedure of creating the MODFLOW GIS grid coverage. A copy of the model grid was created using only the cells that are used in the tributary aquifer modeling. Both pumping wells and monitoring well coverages were generated from CAD and survey data. The streamflow cell coverage was created from the model grid coverage using only the cells where streamflow is modeled.

Additional GIS layers were used for reference purposes only. The line stream layer in the study area was developed from 1:24,000 scale USGS DLG data. Other GIS layers such as streets were developed by the City of Aurora's Public Works Department as part of the City's base map.

In order to display and evaluate MODFLOW simulations using ArcView additional attributes had to be added to the well, stream and MODFLOW attribute tables. A relate field called "Loc-Tag" was added to all coverages, as well as most database tables. The Loc-Tag field is simply a character string consisting of MODFLOW row and column number separated by a "-". Figure 2 shows the attribute table for the model layer, note the Loc_Tag field. With Loc-Tag, model input databases and output results can be joined to the respective coverage or shape file. This relate is helpful in displaying model results, such as drawdown or head, however, fixed attributes such as bottom elevation and transmissivity can also be displayed. One of the main benefits in using the GIS with MODFLOW is that simulation results can be displayed geo-referenced, allowing topological relationships between the model and other spatial features.

Loc-tag

Figure 2 - Model Attribute Table

The Well coverage attribute table (or PAT table) includes such information as well name, permit number, owner, aquifer layer, and Loc-Tag. The model grid coverage attribute tables contain row, column, storage, transmissivity, bottom elevation, and Loc_tag. In addition to the model grid attributes, the streamflow attribute table includes the following: reach, layer, segment, conductivity, bottom elevation, top elevation, width, slope, and channel roughness.

Creating MODFLOW Input Files

The main focus of this GIS project was to create a improved method of inputting data into MODFLOW that takes advantage of ArcView 3.0 and Spatial Analyst. With over 10 modules in MODFLOW, the project approach was to focus on one module at a time. To date two modules, the Well and the Streamflow Routing packages, have been completed. Completing ArcView 3.0 scripts which build the input files for the two MODFLOW packages proves that the concept of using ArcView to build MODFLOW data files can be done. Other package routines will be developed in the future as needed. One main advantage of using ArcView to input data into the model was to simplify repetitive and difficult tasks while creating or modifying MODFLOW input text files. As any MODFLOW user knows the input files for the different packages can be quite large, with repetition of parameters for each stress period modeled. Once a input file is built, to change a parameter value can be difficult and time consuming.

Well (WEL) Package

MODFLOW's Well package was chosen as the first module to attack. Because the GIS was not available at the start of the groundwater modeling effort in 1991, most of the data files for the model were already completed manually. In 1996 and 1997, the modeling effort shifted to "what-if" scenarios based upon various well pumping patterns and stream flow discharges. The Avenue script for WEL input was created to allow flexibility in modifying well pumping scenarios for Aurora and other water user's wells.

The first step in generating the WEL file was to design a database table for the well pumping data. The simple database design has one record for each well. Fields include Well_name, Loc-Tag, and Stress Period (one stress period for field). Figure 3 shows what the table looks like. Linking the well pumping table with the well attribute table using Loc-Tag as the relate field is done by the table join script ("Intable_join"). Once the tables are linked, the total number of wells to include in any simulation are selected either from the View or the attribute table. Currently, any variation in the number of wells pumping during the different stress periods has be handle via the well pumping table by using 0's for no pumping. MODFLOW will accept 0's in the WEL Package for pumping. Figure 4 displays selected wells and the joined attribute and pumping table that will be written to a text file. The WEL file generator Avenue script ("Pump_output") is activated by an icon, which will step the user through developing the WEL input file using various menus, including stress periods to be modeled and output file name. The user interface offers flexibility in allowing the pumping data to be in positive or negative values (MODFLOW treats negative discharges as pumping). The input data is justified to the MODFLOW format by calling a script called "Right_justify". The WEL input Avenue script can be found in Appendix A; in addition, a sample of the WEL input file is in Appendix B.

Well Table

Figure 3 - Well Pumping Table

Selecting Wells

Figure 4 - Selecting Wells for MODFLOW Input

Streamflow-Routing (STR) Package

The Streamflow-Routing (STR) Package in MODFLOW was the next module linked to ArcView. This module input file was much more difficult to write from ArcView, since the file is very complex. A sample of the STR input file can be found in the Appendix B. At the time of this report only single segment streams can be used with this Avenue script. The multiple segment stream option is close to being finalized. Currently, diversions are not handled by this script. This particular application proves to be useful by allowing changes to be made to the input file easily and quickly. For example, changes to the streamflow discharge for different hydrology scenarios can easily be handled by making changes to the flow table or even creating a new table and rerunning the Avenue script. Changes to fixed attributes such as channel slope, roughness, conductivity, elevations and width can easily be modified using ArcView or Spatial Analyst, and then the program can be rerun, producing a new stream input file. Figure 5 displays Reach 1 cell in Segment 1 and the corresponding attribute table. Likewise, any stream cell can be selected for modifications to channel characteristics, such as channel width and slope.

Stream cells

Figure 5 - Stream Cell Modifications

Like the well program, the streamflow-routing requires a flow table for each starting reach. In this project, the flow table has the flow values for the Parker Gage for dry, average, and wet hydrology simulations. An example of this table is shown in Figure 6. Unlike WEL input file development, the flow table and stream coverage are not linked in this application, but rather are queried through an Avenue script. The "Stream_out" script is activated to produce the STR input file. A menu driven interface steps the user through the process of developing the STR file. Files and coverages read by the script are selected, the hydrology scenarios (wet, average, or dry) are selected, then starting and ending stress periods are selected. The program reads the number of reaches and stream segments from the stream attribute table. If multiple segments are to be modeled, then user must input the order of segments joining into a list (this is described in more detail in Prudic, 1989). The users will then proceed through a series of menus requiring input for stream and diversion simulations, printing options, and flow units. All of the input data and flags are passed to the "Right_justify" script for formatting, then are written to the STR input file. The "Stream_out" script is located in Appendix A.

FLow Table

Figure 6 - Flow Table For Starting Reach

Using ArcView Spatial Analyst

In addition to creating MODFLOW input files directly, ArcView's Spatial Analyst provided tools to capture spatial data for input into the model. Current progress is being made in using Spatial Analyst create rainfall and evapotranspiration surfaces from point data sets. Next, the MODFLOW grid polygon coverage is used as a zonal layer over the surface layer, and using Summarize Zones a table is created. If the Loc-Tag field is used in the zonal command, then the summary table can be joined or linked to the MODFLOW grid polygon attribute table. Joining the tables allows data input into the various packages. Elevation data from USGS Digital Elevation Models (DEM) were loaded into MODFLOW in a similar way for another Aurora groundwater modeling project.

Displaying Model Results

The displaying of MODFLOW simulation results was discussed in detail by Rindahl (1996). At that time the ArcView 2.1 application resided on a UNIX platform. With the release of ArcView 3.0 and Spatial Analyst, the Water Resources Division at Aurora has focused more on developing applications for PC's. Recently, the ArcView 2.1 scripts for displaying model results, including animation, were converted to ArcView 3.0 Avenue format.

Output for MODFLOW simulations can either be in printed form or in binary files. Several C programs were written to read the MODFLOW binary output files and translate into ASCII test tables readable by ArcView. The C program first skips the binary file header then reads and stores the value for every cell in the time step, this is repeated for every time step in the file (Rindahl, 1996). Finally, the output file is created by first writing the header, then one line for each cell consisting of the Loc-Tag and the variable (e.g. drawdown, head elevation) values for each time step of the model run (Rindahl, 1996). Refer to Rindahl's paper (1996) for the program code.

The final process in displaying model results is handled through existing ArcView tools or through Avenue scripts. Using the Loc-Tag field in both the attribute tables and the MODFLOW ASCII output, the tables can be joined. As discussed in Rindahl's paper (1996), any model stress period result can be displayed using the legend editor of ArcView.

Several enhancements for viewing MODFLOW results were created in Avenue. One Avenue program allows the user to control the legend editor and another allows animation of time step results. Originally, these scripts were developed for ArcView 2.1, but were modified substantially for ArcView 3.0. The script controlling the legend editor allows the user to specify the increment displayed for selected time steps, then the ability to select from the color ramps available through ArcView 3.0. For example, the script creates a drawdown legend in even 0.5 foot increments. The created legend can then be saved for future use.

The final Avenue script converted to ArcView 3.0 is the animation of time steps program. Using the saved legend defined above, the user selects time steps to be sequentially displayed, showing a animation of drawdown fluxes, head elevation changes, or stream discharge. Several tricks in Avenue allows the animation to redraw only the aquifer portion of the display and not the entire view. Figure 7 illustrates the aquifer drawdown for Stress Period number 23 for a wet year scenario. Both scripts are included in the Appendix.

Display

Figure 7 - Displaying MODFLOW Results with ArcView 3.0

Conclusion

ArcView 3.0 has been successfully used for creating MODFLOW input file for both the Well and Streamflow-Routing packages. This tool will allow MODFLOW users to create and manipulate complex MODFLOW input files in a easy and efficient way. Avenue scripts allowed flexibility in modifying well pumping and streamflow scenarios for various "what-if" scenarios. One main advantage of using ArcView to input data into the model was to simplify repetitive and difficult tasks while creating or modifying large MODFLOW input text files.

To aid in analyzing the MODFLOW model results, a ArcView 3.0 application was developed. ArcView provides a clear, geo-referenced view of the model results. By using MODFLOW coverages in a GIS, topologic anlysis can be used such as measurements, nearness and overlays. Animation and simulation of stress periods variables are possible. ArcView 3.0 provides users and decision makers with a tool assisting in groundwater management decisions.


Acknowledgments

ArcView 2.1 and 3.0, Spatial Analyst, and ArcInfo were developed by Environmental Systems Research Institute, Inc. (Esri)

MODFLOW was developed by Michael G. McDonald and Alren W. Harbaugh for the USGS.

Streamflow-Routing package for MODFLOW was developed by David E. Purdic for the USGS.

The particular MODFLOW model describe in this paper was developed by Bishop- Brogden and Associates, Lakewood, Colorado under contract by the City of Aurora.


References

Fetter, C.W., 1988. Applied Hydrogeology. Merrill Publishing Co..

McDonald, M.G. and A.W. Harbaugh, 1988. A Modular Three-Dimensional Finite- Difference Ground-Water Flow Model. Techniques of Water Resources Investigations of the U.S. Geological Survey (USGS), Book 6, Chapter A1, Denver, Colorado.

Prudic, D.E., 1989. Documentation of a Computer Program to Simulate Stream-Aquifer Relations Using a Modular, Finite-Difference, Ground-Water Flow Model. Open-File Report 88-729, U.S. Geological Survey, Carson City, Nevada.

Rindahl, B., 1996. Groundwater Modeling and Analysis Using the USGS MODFLOW Program and ArcView. Proceedings of the 16th Annual User Esri Conference, Environmental Systems Research Institute, Inc. (Esri), Redlands, California.

Van der Heijde, P. and E. Poeter, 1996. Application of the USGS MODFLOW Ground- Water Flow Simulation System. International Ground Water Modeling Center, Colorado School of Mines, Golden, Colorado.


Appendix A - Avenue Scripts


'Right Justify Script for Input into MODFLOW
str = SELF.get(0)
len = SELF.get(1)

   for each i in 1..len
	str = " " + str
   end

return str.right(len)


'PUMP_OUTPUT.AVE
'USAGE: Creates Well input file for MODFLOW
'Written by: Cliff Inbau and Bruce Rindahl
'City of Aurora Utilities
'Lastest Update: 3/25/97

theView = av.GetActiveDoc
theTheme = theView.FindTheme("wells.shp")

'Need to Select wells for Output

theFTab = theTheme.GetFTab
thefieldlist = theFTab.GetFields
f1 = msgbox.list(thefieldlist,"Pick first Stress Period","STRESS PERIOD 1")
f2 = msgbox.list(thefieldlist,"Pick last Stress Period","LAST STRESS PERIOD")
loc_field = theFTab.FindField("loc_tag")
theFF = theFieldList.Find(f1)
theLF = theFieldList.Find(f2)
theLayer1 = theFTab.FindField("layer")
theBitMap = theFTab.GetSelection

'Specify output file name

theWFN = MsgBox.Input("Please Enter Well Input File Name For MODFLOW (with .wel 
extension)","WELL FILE","c:\aview\database\well1.wel")

if (File.Exists(theWFN.asFileName)) then
   q1 = (MsgBox.LongYesNo("Do you wish to OVERWRITE file?","File Exists",false))
    if (q1 = false) then  
      exit
    end
end

'Specify if Well Pumping records are positive or negitive in the input sheet
qpositive = (MsgBox.LongYesNo("Is Input Well Pumping Data Positive?","INPUT DATA",true)) 

'Writing to WELL FILE

lf = linefile.Make(theWFN.asFileName,#FILE_PERM_WRITE)

theTotalWell = theBitMap.Count
theTotalWell2 = av.run("Right_Justify",{theTotalWell.AsString,10})
'Query for WELCB
theWELCB = msgBox.input("Enter WELCB Unit Number, Default is 0","WELCB 
INPUT","0").AsNumber
theWELCB2 = av.run("Right_Justify",{theWELCB.AsString,10})

lf.WriteElt(theTotalWell2 + theWELCB2)

for each i in theFF..theLF
  aField = thefieldlist.Get(i)
  theNumWells = theBitMap.Count
  WellNum = av.run("Right_Justify",{theNumWells.AsString,10})
  x = aField.GetAlias
  x2 = av.run("Right_Justify",{x.AsString,10})
  lf.WriteElt(WellNum + x2)

    for each r in theBitMap
       theLayer2 = theFTab.ReturnValue(theLayer1,r)
          if (theLayer2.isNULL) then
            theLayer2 = 1
          end 
       l = theFTab.ReturnValue(loc_field,r)
       l2 = l.Substitute("-"," ")
       row = l2.Extract(0)
       col = l2.Extract(1)
       q = theFTab.ReturnValueNumber(aField,r)
          if ((q = 0) or (q.isNULL)) then
            q = 0
          end    
          if (qpositive) then
            if ((q > 0) or (q < 0)) then
              q = -q
            end
          end  
       L = av.run("Right_Justify",{theLayer2.AsString,10})
       row = av.run("Right_Justify",{row,10})
       col = av.run("Right_Justify",{col,10}) 
       q = av.run("Right_Justify",{q.SetFormat("d.dddddd").AsString,10}) 
       lf.WriteElt(L + row + col + q)
    end   
end
lf.close


'STREAM_OUT
'USAGE: Creates Stream input file for MODFLOW
'Written by: Cliff Inbau and Bruce Rindahl
'City of Aurora Utilities
'Lastest Update: 4/8/97

theView = av.GetActiveDoc

'Setting Theme Variables

theThemes = theView.GetActiveThemes
theFTab = theThemes.Get(0).GetFTab

theFTabList = theFTab.GetFields
reach = theFTab.FindField("reach")
theLayer = theFTab.FindField("layer")
seq = theFTab.FindField("seq")
cond = theFTab.FindField("cond")
bot_elev = theFTab.FindField("bot_elev")
top_elev = theFTab.FindField("top_elev")
width = theFTab.FindField("width")
slope = theFTab.FindField("slope")
rough = theFTab.FindField("rough")
row = theFTab.FindField("row")
col = theFTab.FindField("column")

'Setting Tables Variables

theTBLS = FileDialog.show("*.dbf","DBF Tables (*.dbf)","Select Streamflow File")
theVTab = VTab.Make(theTBLS,false,false)
hydroField = theVTab.FindField("h_type")
hydroList = {"WET","AVG","DRY"}
h_choice = msgBox.ChoiceAsString(hydroList,"Please select hydrologic runoff type","RUNOFF
SELECTION")
q_string = hydroField.AsString ++ "=" ++ h_choice.AsString 
  
theVTab.SetDefinition(q_string)
theVTab.UpdateSelection
av.GetProject.SetModified(true)

theFieldList = theVTab.GetFields
f1 = msgbox.list(theFieldList,"Pick first Stress Period (SP)","STRESS PERIOD 1")
f2 = msgbox.list(theFieldList,"Pick last Stress Period (SP)","LAST STRESS PERIOD")
theFF = theFieldList.Find(f1)
theLF = theFieldList.Find(f2)

for each r in theVTab
  if(theVTab.ReturnValue(hydroField,r) = h_choice) then
    theRec = r.clone
  end
end

'Specify output file name

theSFN = MsgBox.Input("Please Enter Stream Input File Name For MODFLOW (with .str 
extension)","STREAM FILE","c:\aview\database\stream1.str")

if (File.Exists(theSFN.asFileName)) then
   q1 = (MsgBox.LongYesNo("Do you wish to OVERWRITE file?","File Exists",false))
    if (q1 = false) then 
      exit
    end
end

'Writing to MODFLOW input file

lf = linefile.Make(theSFN.asFileName,#FILE_PERM_WRITE)

theBitMap = theFTab.GetSelection
bitCount = theBitMap.count
if (bitCount = 0) then 
   theFTab.GetSelection.SetAll
   theFTab.UpdateSelection
   av.GetProject.SetModified(true)
end
theBitMap = theFTab.GetSelection
bitCount = theBitMap.count

'input for each simulation

MXSTRM = bitCount
MXSTRM = av.run("Right_Justify",{MXSTRM.AsString,10})
'the number of stream segments is read from attribute table of stream coverage
theMax1 = nil
for each rec in theBitMap
  theValue = theFTab.ReturnValueNumber(seq,rec)
  if (not (theValue.IsNull)) then
    if (theMax1 = nil) then
      theMax1 = theValue
    else
      theMax1 = theMax1 max theValue
    end
  end  
end

NSS = av.run("Right_Justify",{theMax1.AsString,10})
NTRIB = msgBox.input("Enter Number of Tributary Segments that Can Be Join During Simulation: 
between 0 and 10","NTRIB","0").AsNumber
  while ((NTRIB > 10) or (NTRIB < 0))
    msgBox.Warning("Must Input a number between 0 and 10!!!","")
    NTRIB = msgBox.input("Enter the Max number of Tributary seqments that can join during simulation 
MAX <= 10","NTRIB","0").AsNumber
  end
NTRIB = av.run("Right_Justify",{NTRIB.AsString,10})

'creating input for tributary segments
if (NTRIB.AsNumber > 0) then
   Trib = Dictionary.Make(NSS.AsNumber)
      for each k in 1..NSS.AsNumber
        templist = list.make
          for each l in 1..NTRIB.AsNumber
             ITrib = msgBox.input("Input Tributary #"+l.AsString + " for Segment" + k.AsString,
	       "INPUT TRIBUTARIES","0") 
             templist.Add(ITrib)
          end 
        Trib.Add(k,templist) 
      end
end

'contiune with input for each simulation
NDIV = msgBox.LongYesNo("Are diversions to be simulated?","NDIV",false)
  if (NDIV = TRUE) then
    NDIV = 1
  else  
    NDIV = 0
  end 
NDIV = av.run("Right_Justify",{NDIV.AsString,10}) 
ICALC = msgBox.LongYesNo("Are stream stages to be simulated?","ICALC",true)
  if (ICALC = TRUE) then
    ICALC = 1
  else  
    ICALC = 0
  end
ICALC2 = av.run("Right_Justify",{ICALC.AsString,10})
flowUnits = msgBox.ChoiceAsString({"cfs","cms"},"Select Flow Units","UNITS")
CONST = 1.0
  if (flowUnits = "cfs") then
    CONST = 1.486
  end
CONST = av.run("Right_Justify",{CONST.AsString,10}) 
leakage = msgBox.Input("Enter Unit Number to output leakage: >0 save to disk; =0 not saved or printed; 
<0 printed","Leakage Output","0").AsNumber
ISTCB1 = av.run("Right_Justify",{leakage.AsString,10})
store_stream = msgBox.Input("Enter unit number to save streamflow out of reach: > 0 to save;<= 0 not to 
save","SAVE STREAMFLOW OR PRINT???","0").AsNumber
ISTCB2 = av.run("Right_Justify",{store_stream.AsString,10})

lf.WriteElt(MXSTRM + NSS + NTRIB + NDIV + ICALC2 + CONST + ISTCB1 + ISTCB2)

'input for each stress period
ITMP = MXSTRM
input_print = msgBox.LongYesNo("Supress Printing of Input Data Set for each Stress Period?","INPUT 
PRINTING",true)
  IRDFLG = 1
    if (input_print) then
       IRDFLG = 0
    end
result_print = msgBox.LongYesNo("Supress Printing of Stress Period Results?","RESULT 
PRINTING",false)
  IPTFLG = 0
    if (result_print) then
       IPTFLG = 1
    end   
'ISTCB2 = av.run("Right_Justify",{store_stream.AsString,10})
IRDFLG = av.run("Right_Justify",{IRDFLG.AsString,10})
IPTFLG = av.run("Right_Justify",{IPTFLG.AsString,10})

'indexing stream attribute table
order = Dictionary.Make(bitCount + 2)

MaxReach = {}
for each i in 1..NSS.AsNumber
  MaxReach.Add(0)
end

for each r in theBitMap
  segment = theFTab.ReturnValueNumber(seq,r)
  rech = theFTab.ReturnValueNumber(reach,r)
  if ( MaxReach.Get(segment-1) < rech) then
    MaxReach.Set(segment-1,rech)
  end
  order.Add(segment.AsString+"-"+rech.AsString,r.clone)
end

for each i in theFF..theLF
  
  lf.WriteElt(ITMP + IRDFLG + IPTFLG)
  
  for each j in 1..NSS.AsNumber
    for each k in 1..MaxReach.Get(j-1)
      r = order.Get(j.AsString + "-" + k.AsString)
      theLayer2 = theFTab.ReturnValue(theLayer,r)
      theRow2 = theFTab.ReturnValue(row,r)
      theCol2 = theFTab.ReturnValue(col,r)
      theSeq2 = theFTab.ReturnValue(seq,r)
      theReach2 = theFTab.ReturnValue(reach,r)
        if (theReach2 = 1) then
           q = theVTab.ReturnValueNumber(theFieldList.Get(i),theRec).SetFormat("d.dddddd")
        else 
           q = 0
        end   
      theStage = 0
      theCond2 = theFTab.ReturnValue(cond,r).SetFormat("d.ddddddd")
      bot_elev2 = theFTab.ReturnValue(bot_elev,r).SetFormat("d.dd")
      top_elev2 = theFTab.ReturnValue(top_elev,r).SetFormat("d.dd")
      theLayer2 = av.run("Right_Justify",{theLayer2.AsString,5})
      theRow2 = av.run("Right_Justify",{theRow2.AsString,5})
      theCol2 = av.run("Right_Justify",{theCol2.AsString,5})
      theSeq2 = av.run("Right_Justify",{theSeq2.AsString,5})
      theReach2 = av.run("Right_Justify",{theReach2.AsString,5})
      q = av.run("Right_Justify",{q.AsString,15})
      theStage = av.run("Right_Justify",{theStage.AsString,10})
      theCond2 = av.run("Right_Justify",{theCond2.AsString,10})
      bot_elev2 = av.run("Right_Justify",{bot_elev2.AsString,10})
      top_elev2 = av.run("Right_Justify",{top_elev2.AsString,10})

      lf.WriteElt(theLayer2 + theRow2 + theCol2 + theSeq2 + theReach2 + q + theStage + theCond2 + bot_elev2 + top_elv2) 
    end
  end
  
  if (ICALC = 1) then  
    for each j in 1..NSS.AsNumber
      for each k in 1..MaxReach.Get(j-1)
         r = order.Get(j.AsString + "-" + k.AsString)
         width2 = theFTab.ReturnValue(width,r)
         slope2 = theFTab.ReturnValue(slope,r).SetFormat("d.ddddddd")
         rough2 = theFTab.ReturnValue(rough,r).SetFormat("d.ddd")
         width2 = av.run("Right_Justify",{width2.AsString,10})
         slope2 = av.run("Right_Justify",{slope2.AsString,10})
         rough2 = av.run("Right_Justify",{rough2.AsString,10})
         lf.WriteElt(width2 + slope2 + rough2)
      end  
    end
  end
  if (NTRIB.AsNumber > 0) then 
    for each m in 1..NSS.AsNumber
       TEMP = ""
          for each n in 1..NTRIB.AsNumber
           TEMP = TEMP + av.run("Right_Justify",{TRIB.Get(m).Get(n-1),5}) 
          end  
          lf.WriteElt(TEMP)
    end  
  end 
end

lf.Close


'INTERVAL.AVE
'USAGE: Creates legend and ramps colors
'Written by: Cliff Inbau and Bruce Rindahl
'City of Aurora Utilities
'Lastest Update: 4/8/97

if(av.GetActiveDoc.GetActiveThemes.Count > 1) then
  MsgBox.Info("Select only one Theme!","ERROR")
  return -1
end
theTheme = av.GetActiveDoc.GetActiveThemes.Get(0)
aLegend = theTheme.GetLegend
theFTab = theTheme.GetFtab
theField = MsgBox.List(theFTab.GetFields,"Select the Field","Legend")

aLegend.Interval(theTheme,theField.AsString,4)

cList = aLegend.GetClassifications
MaxValue = cList.Get(3).ReturnMaximum
MinValue = cList.Get(0).ReturnMinimum
Int = MsgBox.Input("Input the Interval Value" + nl + "Range : " + MinValue.AsString ++"-"++ 
         MaxValue.AsString,"Interval","").AsNumber
num = ((MaxValue - MinValue)/Int).Floor + 2
if(num > 64) then
  MsgBox.Info("Too Many Classifications","ERROR")
  return -1
end
aLegend.Interval(theTheme,theField.AsString,num)
cList = aLegend.GetClassifications
x = (MinValue / Int).Floor * Int
if(x <= MinValue) then
  x = x + Int
end  
for each i in 0..(cList.Count-1)
  aLegend.GetClassifications.Get(i).SetMinimum(x - Int)
  aLegend.GetClassifications.Get(i).SetMaximum(x)
  aLegend.GetClassifications.Get(i).SetLabel((x - Int).SetFormat("d.dd").AsString ++ "-" ++ 
        (x).SetFormat("d.dd").AsString)
  x = x + Int
end
sList = aLegend.GetSymbols
for each i in 0..(sList.Count-1)
  aLegend.GetSymbols.Get(i).SetOutlined(FALSE)
end
rampList = SymbolList.GetPredefined(#SYMLIST_TYPE_COLORRAMP)
theRamp = MsgBox.Choice(rampList,"Please Select a Color Ramp","COLOR RAM")
aLegend.GetSymbols.RampSavedColors(theRamp)
theTheme.UpdateLegend


'Cycle_leg.AVE
'USAGE: Cycles legend
'Written by: Bruce Rindahl and Cliff Inbau
'City of Aurora Utilities
'Lastest Update: 4/14/97

theView = av.GetActiveDoc

choice1 = msgBox.YesNo("Do you wish to animate the stream?","CHOICE",False)
if (choice1 = false) then

 'MODFLOW Model Grid Objects
 theTheme = theView.FindTheme("cc_model.shp")
 theTName = theTheme.GetName
 aLegend = theTheme.GetLegend
 theFTab = theTheme.GetFtab
 aList = theFTab.GetFields

 'Selecting Fields (Stress Periods) to Animate
 aField = MsgBox.List(aList,"Select the First Field","Legend")
 theFF = aList.Find(aField)
 aField = MsgBox.List(aList,"Select the Last Field","Legend")
 theLF = aList.Find(aField)

 for each i in theFF..theLF
   newField = alist.Get(i)
   aLegend.SetFieldNames({newField})
   aLegend.Load("C:\aview\legends\drawd.avl".asFileName,#LEGEND_LOADTYPE_SYMBOLS)
   aSymbol = Symbol.Make(#SYMBOL_FILL)
   aSymbol.SetColor(Color.GetWhite)
   aSymbol.SetOutlined(FALSE)
   aLegend.SetNullSymbol(aSymbol)
 
   theTheme.SetName(aList.Get(i).GetAlias)
   theTheme.SetVisible(False)
   theTheme.UpdateLegend
   theTheme.SetVisible(True)
   theView.Draw(theView.GetDisplay)
 end
 theTheme.SetName(theTName)

else

'MODFLOW Model Grid Objects
 theTheme = theView.FindTheme("cc_model.shp")
 theTName = theTheme.GetName
 aLegend = theTheme.GetLegend
 theFTab = theTheme.GetFtab
 aList = theFTab.GetFields

 'MODFLOW Stream Objects
 theTheme2 = theView.FindTheme("ccstream.shp")
 theTName2 = theTheme2.GetName
 aLegend2 = theTheme2.GetLegend
 theFTab2 = theTheme2.GetFtab
 aList2 = theFTab2.GetFields

 'Selecting Fields (Stress Periods) to Animate
 aField = MsgBox.List(aList,"Select the First Field","Legend")
 theFF = aList.Find(aField)
 aField = MsgBox.List(aList,"Select the Last Field","Legend")
 theLF = aList.Find(aField)

 for each i in theFF..theLF
   newField = alist.Get(i)
   aLegend.SetFieldNames({newField})
   temp = theFTab2.FindField(newField.GetAlias)
   aLegend2.SetFieldNames({temp})
   aLegend.Load("C:\aview\legends\drawd.avl".asFileName,#LEGEND_LOADTYPE_SYMBOLS)
   aLegend2.Load("C:\aview\legends\stream.avl".asFileName,#LEGEND_LOADTYPE_SYMBOLS)
   aSymbol = Symbol.Make(#SYMBOL_FILL)
   aSymbol.SetColor(Color.GetWhite)
   aSymbol.SetOutlined(FALSE)
   aLegend.SetNullSymbol(aSymbol)
   theTheme.SetName(aList.Get(i).GetAlias)
   theTheme2.SetName(aList.Get(i).GetAlias)
   theTheme.SetVisible(False)
   theTheme2.SetVisible(False)
   theTheme.UpdateLegend
   theTheme2.UpdateLegend
   theTheme.SetVisible(True)
   theTheme2.SetVisible(True)
   theView.Draw(theView.GetDisplay)
 end
 theTheme.SetName(theTName)
 theTheme2.SetName(theTName2)
end

Appendix B - Sample MODFLOW Files

Sample MODFLOW WEL input file

12         0
        12       Sp1
         1       104        38  0.000000
         1       102        38 -0.263804
         1       101        39 -0.219837
         1        99        37 -0.307772
         1        99        42 -0.219837
         1        92        45  0.000000
         1        98        45  0.000000
         1       105        41 -0.110500
         1       150        39  0.000000
         1        96        43  0.000000
         1       104        46  0.000000
         1        96        46  0.000000
        12       Sp2
         1       104        38  0.000000
         1       102        38 -0.757914
         1       101        39 -0.631595
         1        99        37 -0.884233
         1        99        42 -0.631595
         1        92        45  0.000000
         1        98        45  0.000000
         1       105        41  0.000000
         1       150        39  0.000000
         1        96        43  0.000000
         1       104        46  0.000000
         1        96        46  0.000000
                  .
            (repeated for a stress periods)	

Sample MODFLOW STR input file

 50         1         0         0         1     1.486         0         0
        50         0         0
    1  244   17    1    1       1.000000         0 0.5297366    792.20    797.20
    1  243   18    1    2              0         0 0.5297366    791.52    796.52
    1  242   19    1    3              0         0 0.5297366    790.84    795.84
    1  241   20    1    4              0         0 0.5297366    790.16    795.16
    1  240   21    1    5              0         0 0.5297366    789.48    794.48
    1  239   21    1    6              0         0 0.5297366    788.80    793.80
    1  238   22    1    7              0         0 0.5297366    786.77    791.77
    1  237   22    1    8              0         0 0.5297366    784.73    789.73
    1  236   22    1    9              0         0 0.5297366    782.70    787.70
    1  235   22    1   10              0         0 0.5297366    780.67    785.67
    1  234   22    1   11              0         0 0.5297366    778.63    783.63
    1  233   21    1   12              0         0 0.1324342    776.60    781.60
    1  232   20    1   13              0         0 0.1324342    776.11    781.11
    1  231   20    1   14              0         0 0.1324342    775.63    780.63
    1  230   20    1   15              0         0 0.1324342    775.14    780.14
    1  229   20    1   16              0         0 0.1324342    774.66    779.66
    1  228   21    1   17              0         0 0.1324342    774.17    779.17
    1  228   22    1   18              0         0 0.1324342    773.69    778.69
    1  227   23    1   19              0         0 0.1324342    773.20    778.20
    1  227   24    1   20              0         0 0.1324342    772.45    777.45
    1  226   25    1   21              0         0 0.1324342    771.70    776.70
    1  225   25    1   22              0         0 0.1324342    770.95    775.95
    1  224   26    1   23              0         0 0.1324342    770.48    775.48
    1  223   26    1   24              0         0 0.1324342    770.00    775.00
    1  222   26    1   25              0         0 0.1324342    769.20    774.20
    1  221   26    1   26              0         0 0.1324342    768.30    773.40
    1  220   27    1   27              0         0 0.1324342    767.70    772.70
    1  219   27    1   28              0         0 0.1324342    767.00    772.00
    1  218   27    1   29              0         0 0.1324342    765.63    770.63
    1  217   27    1   30              0         0 0.1324342    764.26    769.26
    1  216   27    1   31              0         0 0.1324342    762.90    767.90
    1  215   28    1   32              0         0 0.1324342    761.53    766.53
    1  214   29    1   33              0         0 0.1324342    760.16    765.16
    1  214   30    1   34              0         0 0.1324342    758.80    763.80
    1  214   31    1   35              0         0 0.1324342    757.85    762.85
    1  214   32    1   36              0         0 0.1324342    756.90    761.90
    1  214   33    1   37              0         0 0.1324342    755.96    760.96
    1  213   34    1   38              0         0 0.1324342    755.00    760.00
    1  212   34    1   39              0         0 0.1324342    754.06    759.06
    1  211   35    1   40              0         0 0.1324342    753.11    758.11
    1  210   35    1   41              0         0 0.1324342    752.17    757.17
    1  209   36    1   42              0         0 0.1324342    751.26    756.26
    1  208   36    1   43              0         0 0.1324342    750.35    755.35
    1  207   37    1   44              0         0 0.1324342    749.45    754.45
    1  206   37    1   45              0         0 0.1324342    748.54    753.54
    1  205   38    1   46              0         0 0.1324342    746.96    751.96
    1  204   38    1   47              0         0 0.5297366    745.38    750.38
    1  203   39    1   48              0         0 0.5297366    743.80    748.80
    1  203   40    1   49              0         0 0.5297366    743.18    748.18
    1  202   40    1   50              0         0 0.5297366    742.56    747.56
        10 0.0029714     0.030
        10 0.0029714     0.030
        10 0.0029714     0.030
        10 0.0029714     0.030
        10 0.0029714     0.030
        10 0.0029714     0.030
        10 0.0088852     0.030
        10 0.0088852     0.030
        10 0.0088852     0.030
        10 0.0088852     0.030
        10 0.0088852     0.030
        10 0.0088852     0.030
        10 0.0021224     0.030
        10 0.0021224     0.030
        10 0.0021224     0.030
        10 0.0021224     0.030
        10 0.0021224     0.030
        10 0.0021224     0.030
        10 0.0021224     0.030
        10 0.0032773     0.030
        10 0.0032773     0.030
        10 0.0032773     0.030
        10 0.0032773     0.030
        10 0.0038454     0.030
        10 0.0038454     0.030
        10 0.0038454     0.030
        10 0.0038454     0.030
        10 0.0038454     0.030
        10 0.0030588     0.030
        10 0.0030588     0.030
        10 0.0030588     0.030
        10 0.0030588     0.030
        10 0.0056807     0.030
        10 0.0056807     0.030
        10 0.0056807     0.030
        10 0.0056807     0.030
        10 0.0056807     0.030
        10 0.0037871     0.030
        10 0.0037871     0.030
        10 0.0037871     0.030
        10 0.0032045     0.030
        10 0.0032045     0.030
        10 0.0032045     0.030
        10 0.0069042     0.030
        10 0.0069042     0.030
        10 0.0069042     0.030
        10 0.0069042     0.030
        10 0.0069042     0.030
        10 0.0027092     0.030
        10 0.0027092     0.030
        10 0.0027092     0.030
        10 0.0027092     0.030
        10 0.0027726     0.030
        10 0.0041365     0.030
        10 0.0041365     0.030
    (repeated for all stress periods)


Authors

Cliff Inbau, Water Resource Engineer (Primary and Presenting Author)
Bruce Rindahl, Senior Water Resource Engineer (co-author)
City of Aurora, Utilities Department
1450 South Havana Street, Suite 232
Aurora, CO  80012

Phone:  (303) 739-7384
Fax:  (303) 739-7604
E-mail:  cinbau@dilbert.ci.aurora.co.us