Approach for Delineation of Contributing Areas and

Zones of Transport to Selected Public-Supply Wells

Using a Regional Ground-Water Flow Model,

Palm Beach County, Florida

U.S. Geological Survey

Palm Beach County Department of Environmental Resources

South Florida Water Management District

WaterResources

Investigations

Report 01-4158

Prepared in cooperation with the

and the
Approach for Delineation of Contributing

Areas and Zones of Transport to Selected

Public-Supply Wells Using a Regional 

Ground-Water Flow Model, Palm Beach

County, Florida

By Robert A. Renken, Raul D. Patterson, Leonard L. Orzol, 

and Joann Dixon

U.S. Geological Survey

Water-Resources Investigations Report 01-4158

Prepared in cooperation with the

PALM BEACH COUNTY DEPARTMENT OF ENVIRONMENTAL RESOURCES and the

SOUTH FLORIDA WATER MANAGEMENT DISTRICT

Tallahassee, Florida

2001
U.S. DEPARTMENT OF THE INTERIOR

GALE A. NORTON, Secretary

U.S. GEOLOGICAL SURVEY

Charles G. Groat, Director

Use of trade, product, or firm names in this publication is for descriptive purposes only 

and does not imply endorsement by the U.S. Geological Survey

For additional information 

write to: 

District Chief 

U.S. Geological Survey

Suite 3015

227 N. Bronough Street

Tallahassee, FL 32301

Additional information about water resources in Florida is available on the World 

Wide Web at http://fl.water.usgs.gov

Copies of this report can be 

purchased from:

U.S. Geological Survey

Branch of Information Services

Box 25286

Denver, CO 80225-0286

888-ASK-USGS
Contents III

CONTENTS

Abstract...................................................................................................................................................................................... 1

Introduction................................................................................................................................................................................ 2

Purpose and Scope ........................................................................................................................................................... 4

Previous Studies............................................................................................................................................................... 4

Description of Study Area ......................................................................................................................................................... 4

Hydrogeology and Ground-Water Flow........................................................................................................................... 5

Surface-Water Conveyance System ................................................................................................................................. 7

Background................................................................................................................................................................................ 7

Review of Existing Ground-Water Flow Models........................................................................................................... 11

Large-Area Flow Model for Palm Beach County .......................................................................................................... 11

Simulation of Ground-Water Flow (MODFLOW) and Particle Tracking (MODPATH) .............................................. 13

Telescopic Mesh Refinement Programs for MODFLOW ............................................................................................. 13

Postprocessing (MODTOOLS)...................................................................................................................................... 14

Development of Graphical User Interfaces for Creating Embedded Models .......................................................................... 14

Graphical User Interface for MODTMR ....................................................................................................................... 14

AvHDRD and AvWELL Refiner Graphical User Interfaces for MODFLOW.............................................................. 18

Application of the Embedded Model....................................................................................................................................... 23

Boca Raton Well Field Embedded Model...................................................................................................................... 23

Calibration and Sensitivity Analysis.................................................................................................................... 30

Water Budget ....................................................................................................................................................... 31

Pathlines, Contributing Areas, and Delineation of Zones of Transport......................................................................... 32

Analysis................................................................................................................................................................ 46

Limitations ........................................................................................................................................................... 52

Summary .................................................................................................................................................................................. 53

References Cited ...................................................................................................................................................................... 53

Appendix I: Installation and Instructions for AvMODTMR, AvHDRD, and AvWELL Refiner.................. CD in back pocket

Appendix II: Documentation of AvMODTMR Avenue Scripts .................................................................... CD in back pocket

Appendix III: Documentation of AvHDRD Avenue Scripts ......................................................................... CD in back pocket

Appendix IV: Documentation of AvWELL Avenue Scripts.......................................................................... CD in back pocket

FIGURES

1. Map showing location of study area in Palm Beach County, Florida ........................................................................... 3

2. Map showing location of well fields in Boca Raton ..................................................................................................... 5

3. Columns showing stratigraphic units included in the surficial aquifer system and the Biscayne aquifer .................... 6

4. Palm Beach County regional model grid showing model domain, boundary conditions in layer 1, and 

simulated head for average steady-state conditions during January 1989 to June 1990............................................... 8

5. Schematic diagram showing zones of contribution, influence, and transport under sloping water-table 

conditions ...................................................................................................................................................................... 9

6. Diagrams showing area contributing recharge to a single discharging well in a simplified hypothetical 

ground-water system ................................................................................................................................................... 10

7. Chart showing relation between geologic and hydrogeologic units and the Palm Beach County regional and 

Boca Raton well field model layers ............................................................................................................................ 12

8. AvMODTMR graphical user interface dialog box for telescopic mesh refinement ................................................... 15

9. AvMODTMR dialog boxes for defining local grid, using local grid wizard, selecting layers, setting layer 

boundary conditions, and choosing units .............................................................................................................. 16, 17

10. Diagrams showing step-wise and continuously defined properties and computation of reach bed conductance....... 19

11. AvHDRD and AvWell graphical user interface dialog boxes for telescopic mesh refinement ................................... 20

12. Flow diagram showing process for delineating zone-of-transport areas to public-supply wells in a 

local-scale model......................................................................................................................................................... 24
IV Contents

13-17. Well field model grids showing relation between regional and local domains and internal and external 

boundary conditions for:

13. Model layer 1 ........................................................................................................................................................25

14. Model layer 2 ........................................................................................................................................................26

15. Model layer 3 ........................................................................................................................................................27

16. Model layer 4 ........................................................................................................................................................28

17. Model layer 5 ........................................................................................................................................................29

18-28. Model grids showing:

18. Calibrated recharge for the Boca Raton well field model.....................................................................................33

19. Hydraulic conductivity for layer 1, Boca Raton well field model........................................................................34

20. Leakance for layer 1, Boca Raton well field model..............................................................................................35

21. Transmissivity for layer 2, Boca Raton well field model .....................................................................................36

22. Leakance for layer 2, Boca Raton well field model..............................................................................................37

23. Transmissivity for layer 3, Boca Raton well field model .....................................................................................38

24. Leakance for layer 3, Boca Raton well field model..............................................................................................39

25. Transmissivity for layer 4, Boca Raton well field model .....................................................................................40

26. Leakance for layer 4, Boca Raton well field model..............................................................................................41

27. Transmissivity for layer 5, Boca Raton well field model .....................................................................................42

28. Simulated steady-state potentiometric surface and residual differences between simulated and observed 

water levels in the Boca Raton well field, average January 1989 to June 1990 conditions .................................43

29. Graphs showing sensitivity of the Boca Raton well field model to changes in selected model parameters .........44, 45

30. Grid of Boca Raton model domain showing backward-tracked particle pathlines from selected municipal 

supply wells in which particles were allowed to travel until encountering internal sinks, sources, or 

boundaries....................................................................................................................................................................47

31. Grid of Boca Raton model domain with backward-tracked endpoint analysis showing contributing areas 

for selected municipal supply wells in which particles were allowed to travel until encountering internal 

sinks, sources, or boundaries .......................................................................................................................................48

32-34. Model grids showing zones of transport for selected municipal supply wells in the Boca Raton well field, 

assuming uniform:

32. Porosity of 20 percent ...........................................................................................................................................49

33. Porosity of 30 percent ...........................................................................................................................................50

34. Porosity of 40 percent ...........................................................................................................................................51

TABLES

1. Sample of part of MODFLOW River output file from AvHDRD ......................................................................................21

2. ArcView attribute table of well geospatial data set.............................................................................................................22

3. Water budget for the Boca Raton embedded flow model....................................................................................................46
Contents V

CONVERSION FACTORS, ACRONYMS, ABBREVIATIONS, AND VERTICAL DATUM

ACRONYMS AND ABBREVIATIONS

Temperature in degrees Fahrenheit (°F) may be converted to degrees Celsius (°C) as follows:

°C = (°F - 32)/1.8

Sea level: In this report, “sea level” refers to the National Geodetic Vertical Datum of 1929 (NGVD of 1929)−−

a geodetic datum derived from a general adjustment of the first-order levels nets of the United States and Canada, 

formerly called Sea Level Datum of 1929.

Multiply By To obtain

inch (in.) 25.4 millimeter

in/yr (inch per year) 25.4 millimeter per year

foot (ft) 0.3048 meter

foot per day (ft/d) 0.3048 meter per day

foot per year (ft/yr) 0.3048 meter per year

mile (mi) 1.609 kilometer

gallon per day (gal/d) 0.003785 cubic meter per day

Mgal/d (million gallons per day) 0.04381 cubic meter per second

GHB General-Head Boundary package

GIS geographic information system

GUI graphical user interface

LRS linear referencing system

LWDD Lake Worth Drainage District

MODFLOW ground-water flow model

MODTMR MODFLOW Telescopic Mesh Refinement program

RMSE root mean square error

SFWMD South Florida Water Management District

TMR telescopic mesh refinement

TMRDIFF telescopic mesh refinement difference

UTM universal transverse mercator

USEPA U.S. Environmental Protection Agency

USGS U.S. Geological Survey

WHPA wellhead protection area
VI Contents
Abstract 1

Approach for Delineation of Contributing Areas and 

Zones of Transport to Selected Public-Supply Wells 

Using a Regional Ground-Water Flow Model, Palm 

Beach County, Florida

By Robert A. Renken, Raul D. Patterson, Leonard L. Orzol, and Joann Dixon 

Abstract

Rapid urban development and population 

growth in Palm Beach County, Florida, have been 

accompanied with the need for additional freshwater withdrawals from the surficial aquifer 

system. To maintain water quality, County officials 

protect capture areas and determine zones of transport of municipal supply wells. A multistep process 

was used to help automate the delineation of wellhead protection areas.

 A modular ground-water flow model 

(MODFLOW) Telescopic Mesh Refinement 

program (MODTMR) was used to construct 

an embedded flow model and combined with 

particle tracking to delineate zones of transport to 

supply wells; model output was coupled with a 

geographic information system. An embedded 

flow MODFLOW model was constructed using 

input and output file data from a preexisting threedimensional, calibrated model of the surficial aquifer system. Three graphical user interfaces for use 

with the geographic information software, ArcView, 

were developed to enhance the telescopic mesh 

refinement process. These interfaces include 

AvMODTMR for use with MODTMR; AvHDRD 

to build MODFLOW river and drain input files 

from dynamically segmented linear (canals) data 

sets; and AvWELL Refiner, an interface designed 

to examine and convert well coverage spatial 

data layers to a MODFLOW Well package input 

file. MODPATH (the U.S. Geological Survey 

particle-tracking postprocessing program) and 

MODTOOLS (the set of U.S. Geological Survey 

computer programs to translate MODFLOW and 

MODPATH output to a geographic information 

system) were used to map zones of transport. 

A steady-state, five-layer model of the Boca 

Raton area was created using the telescopic mesh 

refinement process and calibrated to average 

conditions during January 1989 to June 1990. 

A sensitivity analysis of various model parameters 

indicates that the model is most sensitive to 

changes in recharge rates, hydraulic conductivity 

for layer 1, and leakance for layers 3 and 4 

(Biscayne aquifer).
2 Approach for Delineation of Contributing Areas and Zones of Transport to Selected Public-Supply Wells Using a Regional 

Ground-Water Flow Model, Palm Beach County, Florida

Recharge (58 percent); river (canal) leakance 

(29 percent); and inflow through the northern, western, and southern prescribed flux model boundaries 

(10 percent) represent the major inflow components. 

Principal outflow components in the Boca Raton 

well field area include well discharge (56 percent), 

river (canal) leakance (27 percent), and water that 

discharges along the coast (10 percent).

A particle-tracking analysis using 

MODPATH was conducted to better understand 

well-field ground-water flow patterns and time of 

travel. MODTOOLS was used to construct zonesof-transport spatial data for municipal supply 

wells. Porosity estimates were uniformly increased 

to study the effect of porosity on zones of transport. 

Where porosity was increased, the size of the zones 

of transport were shown to decrease.

INTRODUCTION

The principal source of public-water supply in 

Palm Beach County, Fla. (fig. 1), is the surficial aquifer system. Rapid urban development and population 

growth in the county have increased demand for freshwater withdrawals and resulted in the installation of 

additional supply wells. Potable water demand for 

urban users is projected to increase 115 percent in 

Palm Beach County between 1990 and 2010 (South 

Florida Water Management District, 1998).

The surficial aquifer system, which consists of 

highly permeable limestone and sand, is highly susceptible to contamination in the urbanized areas of Palm 

Beach County. To address this concern, water managers delineate wellhead protection areas (WHPA’s) to 

help protect ground-water supplies from contamination. 

The U.S. Environmental Protection Agency (USEPA) 

established the Wellhead Protection Program, under 

1986 amendments to the Safe Drinking Water Act of 

1974. A WHPA is defined as the surface and subsurface area surrounding a well, wellfield, or spring 

through which contaminants may pass and reach 

the ground water contributing to the supply source. 

Criteria and methods for WHPA delineation have been 

described in USEPA guidance documents (U.S. Environmental Protection Agency, 1987). A numerical 

ground-water flow model in combination with a 

particle-tracking postprocessing package is one 

quantitative methodology used to determine the areas 

contributing recharge to individual wells or well fields. 

The tracking of water particles backward from areas of 

withdrawal to areas of recharge within the model 

domain is a method often used to define a WHPA. 

The countywide model used by the Palm Beach 

County Department of Environmental Resources to 

determine a WHPA in Palm Beach County is a twodimensional MODFLOW model (Dames and Moore, 

1986). The model was calibrated to 1984 baseline 

conditions, but model verification was not conducted. 

A proprietary telescoping computer code has been 

used to construct small-area local models. Water particle transport is simulated using a random walk Monte 

Carlo technique (Prickett and others, 1981) for masstransport computations and to generate time-of-travel 

contours.

The two-dimensional MODFLOW model 

described above has a number of limitations. The 

countywide model consists of only one layer and 

does not account for vertical variability in the surficial 

aquifer system. Simplification of internal boundaries 

within a single-layer model can greatly affect model 

results. Flux into or from a river boundary cell may be 

improperly quantified in a single-layer model. Well 

withdrawals in a single layer model are assumed to 

have occurred over the entire thickness of the aquifer, 

rather than be properly assigned to a specific flow 

horizon. A telescoping computer code developed for 

this model to construct small-area models can use only 

prescribed-head boundary conditions. As the current 

water-supply utilities expand, small area well-field 

protection models will need to account for possible 

changes in boundary conditions and multiple well 

fields with overlapping areas of influence. A digital 

tool, such as a geographic information system (GIS) to 

transfer georeferenced particle pathlines, zones of 

transport, or areas contributing recharge is lacking, 

and WHPA’s that have been delineated are subject to 

public scrutiny. 

To address these needs, the U.S. Geological 

Survey (USGS), in cooperation with the Palm Beach 

County Department of Environmental Resources and 

the South Florida Water Management District 

(SFWMD), initiated a study to develop a process using 

a GIS in which telescopic mesh refinement (TMR) can 

be used to construct local, embedded flow models. 
Introduction 3

ATLANTIC OCEAN

Lake

Okeechobee

PALM BEACH COUNTY

LAKE WORTH

DRAINAGE

DISTRICT

PALM BEACH COUNTY BOCA RATON

PALM BEACH COUNTY

HENDRY COUNTY

MARTIN COUNTY

OKEECHOBEE

COUNTY

GLADES COUNTY

WATER

CONSERVATION

AREA NO. 1

WATER

CONSERVATION

AREA NO. 2A

BROWARD COUNTY

Hillsboro Canal

North New River Canal

Miami Canal

L8

West Palm Beach

Canal

Canal

INTRACOASTAL

WATERWAY

Canal Cross

L-40 Canal

L-7 Canal

Florida’s Turnpike

LWE-2W Canal

LWE-2E Canal

(C-51)

EXPLANATION

80°45 ́ 80°30 ́ 80°15 ́ 80°00 ́

27°15 ́

27°00 ́

26°30 ́

26°15 ́

26°45 ́

LWL-40

Canal

441

1

95

Palm

Beach

County

0

0

15 MILES

15 KILOMETERS

5 10

5 10

Road

Canal

Large-area model and study area

Boca Raton small-area model

Figure 1. Location of study area in Palm Beach County, Florida.
4 Approach for Delineation of Contributing Areas and Zones of Transport to Selected Public-Supply Wells Using a Regional 

Ground-Water Flow Model, Palm Beach County, Florida

The local models would be subsequently used to 

delineate a WHPA associated with supply wells. 

An existing multilayer SFWMD model (Yan and 

others, 1995) is used to illustrate the TMR process. 

Purpose and Scope

The purposes of this report are to: (1) demonstrate an approach in which TMR can be used to construct an embedded flow model, (2) delineate zones of 

transport to public-supply wells, and (3) display 

examples of this approach. This study required the 

integrated use of MODTMR (an ArcView graphical 

user interface (GUI) extension for MODTMR) and 

ArcView GUI extensions to rediscretize canal and well 

spatial data sets. This report illustrates the coupled use 

of MODFLOW ground-water flow and MODPATH 

particle-tracking models. The MODTOOLS program 

(Orzol, 1997) is used to create digital spatial data layers of flow paths and to delineate zones of transport.

Previous Studies

Several reports provide useful background 

information on the hydrogeology of Palm Beach 

County, including those by Parker and others (1955), 

Land and others (1973), Land (1975; 1977), Rodis and 

Land (1976), Scott (1977), Scott and others (1977), 

Klein and Hull (1978), Fischer (1980), Swayze and 

Miller (1984), Miller (1985a,b; 1987; 1988), Fish 

(1988), and Russell and Wexler (1993). Dames and 

Moore (1986) documented the one-layer, countywide 

model developed for use in wellhead protection in 

Palm Beach County. The SFWMD published two 

reports (Shine and others, 1989; Yan and others, 1995) 

that document multilayer MODFLOW ground-water 

flow models for Palm Beach County. 

Reports that discuss TMR include those by 

Townley and Wilson (1980), Buxton and Reilly 

(1986), Miller and Voss (1987), Ward and others 

(1987), Garza and West (1995), and Merritt (1996). 

Leake and Claar (1999) recently helped to automate 

the TMR process with development of MODTMR, 

RIVGRID, and TMRDIFF. 

An increasing number of reports document the 

process of using flow models and particle tracking to 

determine the source of water entering an aquifer, 

identify recharge areas, and delineate capture zones or 

define zones of transport for municipal supply wells. 

Published reports include those by Morrissey (1989), 

Barlow (1989; 1995), Hutchinson (1990), Bair and 

Roadcap (1992), Bailey (1993), Zarriello (1993), 

Reilly and Pollock (1993), Sonenshein (1995), Merritt 

(1996), and Snyder and others (1998). Sonenshein 

(1995) combined particle tracking and spatial tools to 

identify land uses overlying flow paths that extend to 

wells in a ground-water quality monitoring network. 

Snyder and others (1998) and Orzol and Truini (1999) 

successfully integrated a GIS with flow modeling and 

particle-tracking efforts to delineate zones of transport. 

DESCRIPTION OF STUDY AREA

The study area includes the eastern two-thirds of 

Palm Beach County, Fla., and small parts of the Atlantic Ocean to the east, Martin County to the north, and 

Broward County to the south (fig. 1). Water Conservation Area 2A forms the southwestern corner of the 

study area. Much of eastern Palm Beach County consists of residential housing, commercial, light industry, 

and recreational areas such as parks and golf courses. 

Agricultural water use is generally restricted to the 

western and northwestern parts of the county. 

Boca Raton is located in southeastern Palm 

Beach County, and ground water is the sole potable 

water-supply source for the city. In 1990, the City 

of Boca Raton provided water to more than 61,450 

permanent residents, and at least 23,000 additional 

seasonal residents (Camp, Dresser, and McKee, Inc., 

2000). In 1990, the average daily per capita demand 

for treated water was estimated to be 327 gal/d. 

Withdrawals from the Boca Raton well field 

area are designed to meet municipal, commercial, and 

recreational needs. Boca Raton obtains its water from 

6 well fields including 56 operational supply wells 

(fig. 2) that have a total design capacity of 93.7 Mgal/d. 

The number of wells within the Boca Raton well 

fields (fig. 2) has increased considerably over time. 

Currently, 13 wells are not used, owing to concern 

about coastal saltwater intrusion or other types of 

contamination. Coastal wells are not pumped at 

maximum rates largely to minimize saltwater intrusion.
Description of Study Area 5

0 1 2 KILOMETERS

0 1 2 MILES

North well field

Northwest

well field

Southwest well field

Central

well field

Northeast

well field

Southeast

well field

Municipal well

Canal

EXPLANATION

LWL-40 Canal

LWE-2W Canal

LWE-2E Canal

Intracoastal

Waterway

PALM BEACH COUNTY

BROWARD COUNTY

ATLANTIC OCEAN

Hydrogeology and Ground-Water Flow

Palm Beach County is underlain by two major 

aquifer systems: the shallow, unconfined sequence 

known as the surficial aquifer system and the lower, 

confined Floridan aquifer system. The systems are 

separated by the intermediate confining unit composed 

of silt, green clay, limestone, and fine sand. The surficial aquifer system comprises a coastward-thickening 

wedge of unconsolidated to poorly consolidated clastic 

and carbonate sediments that extend from land surface 

to the top of the underlying intermediate confining 

unit. West of Florida’s Turnpike, the surficial aquifer 

system ranges from 150 to 200 ft thick; it is as much 

as 400 ft thick in southeastern Palm Beach County. 

Sediments comprising the surficial aquifer system are 

Pliocene to Pleistocene in age and consist of fossiliferous limestone of the Tamiami Formation; sand, 

marl and interbedded sand of the Caloosahatchee 

Formation; interbedded sand, shell, and limestone of 

the Fort Thompson Formation; sandy limestone and 

marl of the Anastasia Formation; and fine to medium 

quartz sand of the Pamlico Sand (fig. 3). 

Figure 2. Location of well fields in Boca Raton.
6 Approach for Delineation of Contributing Areas and Zones of Transport to Selected Public-Supply Wells Using a Regional 

Ground-Water Flow Model, Palm Beach County, Florida

Series Geologic

unit

Hydrogeologic

units Lithology

Pleistocene

Surficial aquifer system

Pliocene

Miocene

Late Oligocene

Pamlico Sand

Biscayne

Aquifer

Fort Thompson

Formation

Anastasia

Formation

Caloosahatchee

Formation

Tamiami Formation

Intermediate

confining

unit Hawthorn Group

Fine to medium

quartz sand

Interbedded sand, shell,

and limestone

Sandy limestone and

marl, coquina, and sand

Marl, fossiliferous limestone

Sandy silt to sand,

dense, green clay,

quartz sand, with beds

of limestone, sandy

shell or dolomite.

Phosphate common

Sand, marl and

interbedded sand

In Palm Beach County, the surficial aquifer 

system is divided into two hydrogeologic units: a 

moderate to highly transmissive “production zone” and 

a less transmissive “nonproduction zone” (Shine and 

others, 1989). In the southern part of the county, the 

production zone consists largely of the Biscayne aquifer, but includes moderately transmissive limestone 

that directly overlie and underlie it. The Biscayne 

aquifer is absent in the central and northern parts of 

the county and the non-Biscayne production zone 

comprises moderately transmissive limestone. The 

nonproduction zone includes low to moderately permeable sand and marl of the Pamlico Sand, Anastasia 

Formation, and the Caloosahatchee Formation.

The Biscayne aquifer (Parker, 1951; Parker and 

others, 1955) is the most productive source of ground 

water in Palm Beach County (fig. 3) and has been 

designated as a sole source aquifer (Federal Register 

Notice, 1979). In southern Palm Beach County, the 

Biscayne aquifer has been described alternatively as 

the cavity-riddled zone (Land, 1977), cavity zone 

(Fischer, 1980), and zone of secondary permeability 

(Swayze and Miller, 1984); this zone is characterized 

as a cavernous unit of greater permeability due to the 

dissolution of calcareous cement that bonds quartz 

sand, coquina, and sandy limestone. Hydraulic conductivity of the Biscayne aquifer in Palm Beach 

County is reported to be as much as 4,000 ft/d 

(Shine and others, 1989). Some of the highest hydraulic 

conductivities of the Biscayne aquifer in Palm Beach 

County are found in the Boca Raton area. Limestone 

and sand directly overlie or underlie the Biscayne 

aquifer in much of the area forming a zone of moderate transmissivity. Hydraulic conductivity of the nonBiscayne production zone averages 150 ft/d in the 

northern and central parts of the county. The hydraulic 

conductivity of the nonproduction zone is estimated to 

average 50 ft/d.

The surficial aquifer system is underlain by the 

intermediate confining unit that includes the phosphatic 

Hawthorn Group of Miocene and late Oligocene age 

(fig. 3) and is reported to range from 500 to 700 ft 

thick (Shine and others, 1989). The intermediate 

confining unit comprises sandy silt and includes dense, 

green clay with beds of limestone, shells and sand, 

and dolomite. A basal zone of permeable limestone 

contained within the Arcadia Formation (not shown) 

may be present.

The underlying Floridan aquifer system (not 

shown) forms a thick sequence of limestone and 

dolomite; however, this system does not contain 

potable water in the study area in Palm Beach County. 

The Floridan aquifer system in Palm Beach County 

is confined by the overlying Hawthorn Group, suggesting there is limited hydraulic interaction with the overlying surficial aquifer system. 

Figure 3. Stratigraphic units included in the surficial aquifer system and the Biscayne 

aquifer (modified from Shine and others, 1989).
Background 7

The occurrence of ground water in the surficial 

aquifer system is under semiconfined or unconfined 

conditions. Regional flow patterns in Palm Beach 

County are mostly toward the Atlantic Ocean, major 

canals (Hillsboro and West Palm Beach Canals), and 

Water Conservation Area No. 1 (fig. 1). Ground water 

flows outward from a large circular high in the northern half of the county (fig. 4). In the southern half of 

the county, ground water flows outward from a northtrending linear high that parallels the LWE-2W/2E 

canals and Florida’s Turnpike (figs. 1 and 4. Seasonal 

change in canal stage and recharge cause the water to 

fluctuate between 1 and 4 ft/yr. However, regulation of 

canal levels for agricultural and flood-control purposes 

masks changes in seasonal ground-water levels 

(Miller, 1988). 

Surface-Water Conveyance System

Hydraulic interconnection between the aquifer 

and the canal system greatly influences ground-water 

flow in Palm Beach County. The Hillsboro Canal and 

West Palm Beach (C-51) Canals form part of a larger, 

more regional conveyance system that drains water 

from Lake Okeechobee, wetland areas, and the surficial aquifer system to the Atlantic Ocean (fig. 1). 

A perimeter levee and seepage canal, L-40 Canal, 

borders Water Conservation Area No. 1 in southern 

Palm Beach County. Water levels in this water-conservation area are regulated between 14 and 17 ft above 

sea level to provide storage for rainfall and to accommodate a wet- and dry-season regime. An extensive 

series of secondary and lateral canals form a widespread surface-water conveyance system that substantially affects ground-water levels in the surficial 

aquifer system through recharge and drainage.

Shine and others (1989) separate surface-water 

systems into three types; namely maintained systems, 

weir and control structure systems, and water catchment and retention systems. Maintained systems are 

characterized by canal networks that have specified 

water levels and can recharge or drain an aquifer 

depending on the head gradient. Weir and control 

structure systems induce drainage of the aquifer where 

ground-water levels are above weir elevations and are 

more widespread in the northern half of the county. 

Drainage of the aquifer occurs in those areas where 

ground-water levels are above weir elevations. 

Water catchment and retention systems mostly 

function as recharge systems that hold excess water 

and recharge the aquifer when stage levels exceed 

ground-water levels. 

The Lake Worth Drainage District (LWDD) 

encompasses much of southern Palm Beach County 

and the entire area that was included as part of the 

Boca Raton small-area model (fig. 1). The LWDD is a 

maintained canal system in which stage is maintained 

at specified levels; the canal stage varies from sea 

level near the coast to 15.5 ft in north-trending lateral 

canals that parallel Florida’s Turnpike.

BACKGROUND

Five criteria have been described by the U.S. 

Environmental Protection Agency (1987) that are used 

separately or collectively to define a WHPA. These 

criteria include distance, drawdown, time of travel, 

flow boundaries, and assimilative capacity. Distance 

criterion is used to place a protection zone that is 

an arbitrary fixed radius from the withdrawal well. 

A zone of influence (fig. 5) is the distance from a well 

in which a cone of depression and drawdown can be 

measured. Ground-water divides or other physical 

boundaries of an aquifer are used to define a zone of 

contribution; a zone of contribution is a three-dimensional volume within an aquifer that contributes 

ground water to a pumping well. Time of travel is the 

time needed for a water particle to travel along a flow 

path to the well. A zone of transport, is defined by the 

volume within an aquifer that contributes water to a 

discharge feature for a specific time of travel. A zone 

of transport can be projected to land surface in a map 

view and defined by the two-dimensional area 

bounded by lines connecting points of equal time of 

travel. Zones of transport for several intervals of time 

may comprise a zone of contribution. Assimilate 

capacity criterion can be used to reduce the size of a 

WHPA if contaminants are attenuated during movement through the vadose zone of an aquifer due to 

absorption, dilution, dispersion, precipitation, or 

degradation. 

As a result of physical framework and flow 

system complexities, wellhead protection strategies 

described above may not adequately define the area 

contributing recharge to a supply well. Barlow (1989; 

1995) employed the concept of “contributing area” to 
8 Approach for Delineation of Contributing Areas and Zones of Transport to Selected Public-Supply Wells Using a Regional 

Ground-Water Flow Model, Palm Beach County, Florida

0 4

4

8 MILES

0 8 KILOMETERS

EXPLANATION

Regional river cell

Canal

Line of simulated head.

Interval is 2 feet

10

Boca Raton small-area

model

MARTIN COUNTY

PALM BEACH COUNTY

PALM BEACH COUNTY

BROWARD COUNTY

10

20

16

14

14

6

6

Regional drain cell

Regional general head

boundary cell

Regional well cell

Figure 4. Palm Beach County regional model grid showing model domain, boundary 

conditions in layer 1, and simulated head for average steady-state conditions during January 

1989 to June 1990 (modified from Yan and others, 1995).
Background 9

A

A

A ́

A ́

VERTICAL PROFILE

Ground-water

Ground-water

divide

divide

Zone of influence

Zone of contribution

Well Land surface

Prepumping water level

Water table

Bedrock

Water table

PLAN VIEW

Ground-water divide

ZOT (0-30)

ZOT (30-210)

ZOT (210-500)

Line of equal elevation

of water table

Pumping well

NOT TO SCALE

EXPLANATION

ZONE OF TRANSPORT

0-30 Days

30-210 Days

210-500 Days

Cone of depression

Zone of contribution

ZOT (0-30) Zone of transport boundary--Number in parenthesis

is time of travel, in days

Direction of ground-water flow

Figure 5. Zones of contribution, influence, and transport under sloping water-table conditions 

(modified from U.S. Environmental Protection Agency, 1987).
10 Approach for Delineation of Contributing Areas and Zones of Transport to Selected Public-Supply Wells Using a Regional 

Ground-Water Flow Model, Palm Beach County, Florida

Area

contributing

recharge

Area

contributing

recharge

Discharging

well

Discharging

well

Land surface

Water table

Screened zone

Bounding

flow lines

Bounding

flow lines

Not to scale

avoid use of the regulatory wellhead protection terminology and problems that can be associated with analytical, empirical, and numerical methods used to 

determine recharge areas. A contributing area can be 

defined as the land-surface area that delineates the 

location of water entering the ground-water system at 

the water table that eventually flows to the well and 

discharges (Reilly and Pollock, 1993) (fig. 6). 

Different methods can be applied to define local 

hydrologic conditions in a small-area model. With 

TMR (Ward and others, 1987), a large-area model is 

used to define perimeter boundary conditions and to 

provide model parameters for the small-area model. 

This approach is used in studies that require a detailed 

model for a geographically small area (when compared 

to the extent of the entire aquifer system), such as in 

the vicinity of a well field or contaminant plume. An 

important advantage to such an approach is that the 

boundaries for the small-area model do not have to 

coincide with physical boundaries of the aquifer 

because the effects of the regional aquifer are represented in the boundary conditions of the small-area 

model. Another advantage to TMR is scale-dependent 

problems can be resolved with an appropriate scale 

model. For example, the curvature of the potentiometric surface can be more accurately simulated if the 

Figure 6. Area contributing recharge to a single discharging 

well in a simplified hypothetical ground-water system. Upper 

diagram is cross-sectional view, and lower diagram is map view 

(modified from Reilly and Pollock, 1993).
Background 11

grid spacing is more finely discretized. Reports that 

document the TMR approach include Miller and Voss 

(1987), Ward and others (1987), Buxton and Reilly 

(1986), and Merritt (1996). 

A second approach to simulate local hydrologic 

conditions is to modify the regional model to a smaller 

grid size in the vicinity of the well field or in the vicinity of river or drain nodes. One important advantage of 

this “modified-grid” approach, in which the large-area 

model domain is used, is that it allows simulation of 

an area bounded by the physical limits of the aquifer. 

Additionally, this approach requires that only the original model be modified and recalibrated without construction of a new model. A major drawback to a 

modified finite-difference grid is the creation of model 

cells of finer discretization outside the area of interest. 

A grid with fewer nodes is preferred to minimize data 

manipulation and the amount of computer computation 

time. 

A third approach, rarely used, is to construct a 

large-area model domain with comparatively small 

grid spacing. Although only one model has to be calibrated, powerful computers may be required to reduce 

computation time. Additionally, calibration difficulties 

and convergence problems may arise because some 

solvers are not designed to handle very large matrices. 

The Palm Beach County study area is traversed by an 

extensive surface-water conveyance and drainage system; therefore, refinement of a countywide model grid 

that accurately depicts all details of the canal system in 

a single model was not considered practical. 

The advantages and disadvantages of the three 

methods were weighed. As such, the TMR process of 

creating a small-area model was chosen for purposes 

of this study.

Review of Existing Ground-Water Flow Models

Several large-area MODFLOW models have 

been developed to simulate ground-water flow in Palm 

Beach County. A two-dimensional MODFLOW model 

that is currently being used by the Palm Beach County 

Department of Environmental Resources was developed by Dames and Moore (1986). Three-dimensional, 

large-area flow models have been prepared by the 

SFWMD (Shine and others, 1989; Yan and others, 

1995).

The MODFLOW model developed by Dames 

and Moore (1986) is designed for wellhead protection 

purposes. The thickness of the surficial aquifer system 

is treated as single unconfined model layer. Encompassing the entire county, the model was calibrated to 

average 1984 steady-state conditions. Model verification was not performed. The Palm Beach County 

Department of Environmental Resources used this 

model in combination with a random-walk technique 

to compute mass transport and particle time of travel.

Separate three-dimensional MODFLOW models 

were constructed to simulate flow in northern and 

southern parts of Palm Beach County for purposes of 

resource assessment and water management (Shine 

and others, 1989). Multilayering (six layers) allowed 

for variations in permeability within the aquifer and 

partial penetration of wells and canals. A steady-state 

calibration was conducted using average water levels 

between October 1983 and May 1985, and a transient 

verification was performed using monthly time steps 

during the same period. 

The large-area MODFLOW model constructed 

by Yan and others (1995) encompasses much of Palm 

Beach County, northernmost Broward County, and 

southernmost Martin County and was designed to aid 

water-supply planning. This MODFLOW model was 

selected to illustrate the TMR process and is referred 

herein, as the SFWMD model.

Large-Area Flow Model for Palm Beach County 

The SFWMD model grid consists of 41,250 

uniform grid cells, of which 55 percent are active cells. 

Each of the five-grid layers consists of 110 rows and 

75 columns (fig. 4). The SFWMD model uses five 

model layers to represent different parts of the surficial 

aquifer system (fig. 7). Layer 1 generally extends to a 

depth of 20 ft below sea level and is considered to represent soil and low-permeability sediments that form 

the uppermost part of the surficial aquifer system. 

Layer 2 consists of rock that lies between the base of 

layer 1 and the upper surface of a highly transmissive 

water-bearing zone that includes the Biscayne aquifer 

in southern Palm Beach County. Layers 3 and 4 represent the Biscayne aquifer and northern lateral equivalents. The boundaries of these two layers were selected 

on the basis of highly permeable limestone found in 

cores or where hydraulic conductivity was reported to 
12 Approach for Delineation of Contributing Areas and Zones of Transport to Selected Public-Supply Wells Using a Regional 

Ground-Water Flow Model, Palm Beach County, Florida

Geologic unit

Undifferentiated sand of

Pleistocene age

(Pamilco Sand)

Fort Thompson Formation

Anastasia Formation

Tamiami Formation

Caloosahatchee Formation

Surficial aquifer system

Unnamed

Biscayne aquifer

Hydrogeologic unit

Unnamed

Hawthorn Group Confining unit

Regional model

layer

Layer 1 Layer 1

Layer 2 Layer 2

Layer 3 Layer 3

Layer 4 Layer 4

Layer 5 Layer 5

Boca Raton

well field model

Not modeled Not modeled

be 1,600 ft/d or greater. Model layer 5 extends from 

the base of the highly transmissive zone to the base 

of the surficial aquifer system and represents lesspermeable sand, silt, and shell material. 

Recharge is treated in the SFMWD model as a 

prescribed-flux boundary, computing it as the amount 

of precipitation minus water lost to runoff, and evapotranspiration losses at the land surface. The bottom of 

the model was treated as a prescribed-flux (no-flow) 

boundary. Head-dependent flux and prescribed-head 

boundaries were selected along the perimeter boundaries using the MODFLOW General-Head Boundary 

(GHB) package. Along the eastern model Intracoastal/ 

Atlantic Ocean boundary (layers 1 and 2), a generalhead boundary with a high conductance was used with 

a mean monthly sea level equivalent to the head of the 

nearshore tidal body. This effectively allowed the general-head boundary to function as a prescribed-head 

boundary. Lower conductance values were used in successively lower layers (3 to 5) along the Intracoastal 

Waterway/Atlantic Ocean boundary. A similar 

structure for the general-head boundary condition was 

used to represent Water Conservation Area No. 1 and 

L-8 Canal on the western model perimeter (fig. 1). 

High conductance values were used in layer 1 so that 

the boundary functioned as a prescribed head, and 

lower conductance values were used in lower model 

layers. Layers 2 to 5 function more as general head 

cells, and flux movement across the boundary is based 

more on conductance and head gradient. General-head 

boundaries also were applied along the northern and 

southern boundaries in Martin and Broward Counties. 

These boundaries were constructed, in part, using 

hydrologic and hydraulic conditions from calibrated 

models of Martin (Adams, 1992) and Broward Counties (Restrepo and others, 1992). The northern and 

southern edges of the model was placed away from 

the county line to reduce the boundary effects on 

hydrologic stress. 

Figure 7. Relation between geologic and hydrogeologic units and the Palm Beach County regional and Boca Raton 

well field model layers.
Background 13

 Hydraulic head was the only type of observation used for model calibration. Although the SFMWD 

model documentation reveals simulated head failed to 

meet calibration standards in about one third of the 

observation wells, no effort was made as part of this 

study to improve the existing regional calibration (an 

activity considered beyond the scope of this study).

Numerical modeling requires simplification of 

the hydrogeologic system, some of which may limit its 

applicability. Unfortunately, simplifying assumptions 

of the large-area Palm Beach County model are not 

explicitly described in the SFMWD model documentation. A 1:10 ratio of leakance to horizontal conductivity was assumed. Although a thorough evaluation was 

not conducted, Yan and others (1995) assumed insensitivity to changes in specific yield and storage coefficient. This assumption parallels sensitivity results of 

Broward County (Restrepo and others, 1992) and 

Martin County (Adams, 1992) ground-water flow 

models. 

Simulation of Ground-Water Flow (MODFLOW) 

and Particle Tracking (MODPATH)

Simulation of ground-water flow in the Palm 

Beach County and Boca Raton well field area was 

performed using the MODFLOW model. MODFLOW 

is the USGS computer program for simulating hydrologic processes and features in ground-water systems 

(McDonald and Harbaugh, 1988; Harbaugh and 

McDonald, 1996). MODFLOW solves the partial 

differential equation for ground-water flow by using a 

finite-difference algorithm. The SFWMD Palm Beach 

County model was converted to the MODFLOW96 

format to allow construction of a small-area model 

using USGS TMR software. 

Particle tracking is a method used in conjunction 

with numerical simulation of ground-water flow to 

delineate flow paths and evaluate advective contaminant transport. Particle tracking can be used also to 

determine recharge and discharge areas, identify errors 

in the conceptual model, evaluate the effect of internal 

and external boundary conditions, and calculate time 

of travel (Anderson and Woessner, 1992). The transport process of dissolved contaminants, in many 

cases, is dominated by ground-water advection. 

Particle tracking does provide an estimate of the 

contaminant migration--a fundamental concern in 

wellhead protection. However, particle tracking does 

not consider the chemical effects of contaminant 

absorption, degradation, or decay. Particle tracking 

does not account for dispersion which could increase 

the areal extent of a contaminant plume. 

MODPATH (Pollock, 1989; 1994), a USGS 

particle-tracking postprocessing program designed for 

use with MODFLOW, uses a semianalytical particletracking scheme to describe flow paths of water particles within a grid cell. MODPATH calculates threedimensional pathlines, and particles of water as timeof-travel information are tracked individually through 

the flow system. Particle paths are computed in 

MODPATH by tracking particles from one cell to the 

next until the particle reaches a boundary, an internal 

sink/source, or satisfies some other termination criterion. MODPATH requires two areal input parameters 

not used in MODFLOW96 (Harbaugh and McDonald, 

1996): bottom elevation of a model layer and porosity. 

Telescopic Mesh Refinement Programs for 

MODFLOW

Three software programs have been developed 

for use in TMR using the USGS MODFLOW model: 

MODTMR, TMRDIFF, and RIVGRID (Leake and 

Claar, 1999). MODTMR (MODFLOW Telescopic 

Mesh Refinement) is a software program designed 

to construct small-area model input files using 

MODFLOW96 input and output data sets from a 

large-area model. A separate program, RIVGRID 

(Leake and Claar, 1999), was developed to construct 

MODFLOW96 input data sets for linear hydrologic 

features contained in both regional and local models. 

RIVGRID uses grid-independent line segment data 

to define the location of continuous, narrow surfacewater features such as rivers, streams, drains, or general-head boundaries, which may be represented by 

the River, Stream, Drain, and GHB packages for 

MODFLOW. TMRDIFF (Telescopic Mesh Refinement DIFFerence) can be used to compare computed 

head or drawdown in the small-area model with simulated head or drawdown in the large-area model. 

MODTMR uses regridding, rediscretization, and 

interpolation processes to assign parameters to the 

small-area model. The program is designed also to 

extract perimeter boundary conditions using simulated 
14 Approach for Delineation of Contributing Areas and Zones of Transport to Selected Public-Supply Wells Using a Regional 

Ground-Water Flow Model, Palm Beach County, Florida

head and cell-by-cell flux data. MODTMR constructs 

perimeter boundary conditions using the FHB1 package 

(Leake and Lilly, 1997), a MODFLOW package that 

allows a user to specify flux or head boundaries using 

flow and/or head information obtained from the-large 

area model. MODTMR will construct small-area 

model data sets for River, Drain, GHB, and Well package input files which represent linear or point features. 

The data sets, however, may not be properly placed 

within specific small-area model layer cells; instead, 

they are placed in small-area model cells that intersect 

the regional cell and contain the boundary condition 

(Leake and Claar, 1999). It is important to recognize 

that external and internal boundaries represented by 

these MODFLOW packages can be inappropriately 

distributed if MODTMR is used strictly, and consideration is not given to the validity of the assigned 

boundary location (Leake and Claar, 1999, p. 26-27). 

The computer program ZONEBUDGET 

(Harbaugh, 1990) was used as part of the TMR 

process to compare SFMWD and Boca Raton well 

field water-budget components. ZONEBUDGET 

calculates subarea water budgets using MODFLOW 

cell-by-cell flow data. Leake and Claar (1999, p. 5) 

indicate that consistency should be maintained 

between corresponding large- and small-area waterbudget components. Modification of small-area model 

parameters and internal boundaries should be incorporated into the large-area model, with the regional 

model resimulated and recalibrated. The upscaling 

transfer of modified local model parameters and 

sources and sinks into the large-area model was 

considered to be beyond the scope of this study.

Postprocessing (MODTOOLS)

MODTOOLS (Orzol, 1997) is a series of 

computer programs that translate MODFLOW and 

MODPATH data into GIS output files suited to illustrate complex hydrologic conditions. MODTOOLS 

uses input or output data from a MODFLOW or 

MODPATH simulation to construct several types of 

GIS output files. MODFLOW GIS output generated 

by MODTOOLS includes velocity vectors, contours of 

input and output data arrays, and cell value data. 

MODPATH GIS files created by MODTOOLS 

include particle pathlines, particle endpoints, particle 

time series, zones of transport, and model grids. For 

purposes of this study, MODTOOLS was used to 

create GIS spatial data that included contours of 

simulated head, pathlines, and zones of transport.

ENDPOINT and TIMESERS MODPATH 

analyses are required to use the MODTOOLS zone of 

transport option. MODTOOLS constructs zones of 

transport for discharge features (wells) by projecting 

these volumetric zones on a two-dimensional surface 

(plan or cross-sectional view). Particle positions used 

in the zone of transport output may lie well below the 

water table. Accordingly, a plan view of a zone-oftransport polygon does not necessarily represent a 

recharge or source area (Orzol, 1997, p.10). A MODTOOLS limitation in the zone-of-transport option is 

that the method used to construct spatial data layers 

may produce triangular inflections in zone boundaries. 

DEVELOPMENT OF GRAPHICAL USER 

INTERFACES FOR CREATING 

EMBEDDED MODELS

Three GUI’s for ArcView were developed to 

enhance the TMR process. They include AvMODTMR 

for use with MODTMR; AvHDRD to build MODFLOW River and Drain input files from dynamically 

segmented linear (canals) data sets; and AvWELL 

Refiner, an interface designed to examine and convert 

well coverage spatial data layers to a MODFLOW 

Well package input file (app. I). ArcView, rather than 

ARCINFO (Version 7.X), was used to link MODTMR 

with GIS due its more graphical nature and programming ease. AVENUE is the programming language 

used to customize the ArcView GUI and is an objectoriented programming language. 

Graphical User Interface for MODTMR

The user-friendly ArcView extension, 

AvMODTMR. was developed as a graphical user interface to MODTMR. The AvMODTMR (app. II) application enhances use of MODTMR by offering dialog 

boxes and graphical tools which are designed to create 

the input file for MODTMR. The most cumbersome 

part of creating the MODTMR input file is spatially 
Development of Graphical User Interfaces for Creating Embedded Models 15

relating the local grid to the regional grid and specifying the boundary conditions for the MODFLOW96 

FHB1 package. The AvMODTMR interface facilitates 

this process by capitalizing on GIS georeferencing 

capabilities. The regional grid is placed in its spatial 

domain in a convenient map projection such as a 

Universal Transverse Mercator (UTM) or State Plane 

Coordinate System. The local grid is defined by use of 

a dialog box to specify coordinates and model dimensions or by drawing it on the map canvas (or view) and 

using the graphical tools. AvMODTMR contains capabilities for layer discretization and selection of boundary conditions. The user can select a single layer, a 

subset, or all regional model layers for inclusion in the 

small-area model. 

The AvMODTMR GUI is an ArcView “plug-in” 

and is accessed by loading it through the “File” menu, 

“Extensions” item. Once the AvMODTMR launch 

button is invoked, the main dialog box opens (fig. 8), 

requiring the user to browse to the large-area model 

MODFLOW96 NAME file. Large-area model input 

and output data sets must be located on disk space 

identified by the NAME file which are subsequently 

read and posted to the “Regional Model” area of the 

dialog box. The user directs their attention to the 

“Local Model” area of the dialog box where information pertaining to the small-area model must be 

prescribed. A root filename for local simulation is 

entered, options are selected, and the plan view, local 

model domain is defined. 

Figure 8. AvMODTMR graphical user interface dialog box for telescopic mesh refinement. 

The dialog box is visible upon launching the graphical user interface.
16 Approach for Delineation of Contributing Areas and Zones of Transport to Selected Public-Supply Wells Using a Regional 

Ground-Water Flow Model, Palm Beach County, Florida

A B

There are two ways to define the plan view 

domain, with each method having a dialog box that is 

launched from the Main dialog box. If small-area 

model dimensions and orientation are predetermined, 

the values are entered into the dialog box (fig. 9A) 

launched by the button; otherwise, 

the button can be used. The first of 

these buttons toggles to a button 

once the AvMODTMR grid construction process is 

initiated. The “Local Grid Wizard” is a dialog box 

(fig. 9B) that contains graphical tools for creating the 

local grid interactively on the map canvas. A “Draw 

Study Area” tool allows the user to draw an irregular polygon bounding the study. In addition, a “Draw 

Rotation” tool enables the user to draw a vector 

line on the canvas to indicate the rotation of the grid. 

The user then enters the dimensions of the column 

width and row height in text boxes. At this point, 

either method has provided enough information to 

uniquely define the local grid. Pressing the “Preview” 

button permits the user to examine the small-area grid 

dimensions before actually creating the file by drawing 

a box oriented in the direction of line, circumscribed 

on the polygon. Construction of the model grid as an 

ArcView Shapefile is initiated by clicking the “OK” 

button; once completed, it is added to the “View” as a 

theme or layer. Another layer added is the FHB theme, 

which consists of the same source data as the grid, but 

only shows the cells forming the perimeter of the 

small-area model grid. With either method used, the 

embedded model grid must be placed wholly inside the 

regional model grid and should avoid points of concentrated flow, such as rivers, drains, and wells (Leake 

and Claar, 1999, p. 4).

Model layers to be used in the small-area model 

are selected by clicking the button 

and choosing a continuous range of layers shown in a 

dialog box (fig. 9C) from the large-area model to be 

simulated in the small-area model. No additional discretization of model layers can be performed with 

AvMODTMR, so another preprocessor would be 

required if finer vertical discretization is required. 

Figure 9. AvMODTMR dialog boxes for defining local grid, using local grid wizard, selecting layers, setting layer 

boundary conditions, and choosing units.
Development of Graphical User Interfaces for Creating Embedded Models 17

Figure 9. (Continued) AvMODTMR dialog boxes for defining local grid, using local grid wizard, selecting layers, 

setting layer boundary conditions, and choosing units.

Further layer discretization requires a greater programming effort and was considered beyond the scope of 

this study. However, a text editor may be used to modify the MODTMR input file constructed by 

AvMODTMR. 

Prescribed-head or prescribed-flux boundary 

conditions are selected for each small-area model layer 

using the AvMODTMR graphical tool set. By default, 

prescribed flux is automatically assigned for all perimeter cells (designated by a blue cell color). From the 

main dialog box, the button 

launches a separate dialog box (fig. 9D) permitting 

modification of boundary conditions, one layer at a 

time; any combination of prescribed-flux or prescribed-head boundary conditions can be applied to 

perimeter cells. 

C D

E
18 Approach for Delineation of Contributing Areas and Zones of Transport to Selected Public-Supply Wells Using a Regional 

Ground-Water Flow Model, Palm Beach County, Florida

The current version of the AvMODTMR 

imposes several restrictions on the use of MODTMR. 

Although time units may differ between regional and 

local models, the length unit prescribed by the user in 

the regional model is automatically used in the local 

model (fig. 9E). MODTMR permits local grid rotation 

to be specified at any model corner. With the current 

version of AvMODTMR, the user can only specify 

a local grid rotation angle centered around the upper 

left grid corner (outer corner of row 1, column 1); 

MODTMR allows any corner to be used as the reference point for rotation (a flexibility that is not available to the AvMODTMR user). However, this 

limitation is offset by the intuitive graphical nature 

of AvMODTMR. 

AvHDRD and AvWELL Refiner Graphical User 

Interfaces for MODFLOW

RIVGRID (Leake and Claar, 1999) is a program 

released with MODTMR to generate River, Drain, 

Stream, and GHB package files, which improve on the 

limited geometric accuracy provided in the discretized 

large-area model. All of the head-dependent flow 

boundaries created by MODTMR use an interpolation 

scheme that utilized location information based solely 

on row, column, and layer large-area model spatial 

indices. The discretization process used in MODFLOW generalizes the information to discrete cells, 

and the exact path of linear features cannot be reconstructed from input files alone. Geometric information 

regarding feature alignment must be provided, either 

from coordinates of points where a feature changes 

course (vertices) or from GIS coverages that contain 

their alignment and topology within their data structure. RIVGRID utilizes the former method as coordinate data must be input for each vertex, along with 

locations where the various required parameters 

change (bottom elevation, riverbed conductance, and 

stage). RIVGRID is not a GIS-based program and is 

not a program designed to interface with GIS data sets. 

A more efficient technique to work with linear 

hydrologic spatial data sets is dynamic segmentation 

(Wilsnack, 1998). Dynamic segmentation is a GIS data 

model that is implemented in ARCINFO and ArcView 

as a route system with attribute information (hydrologic properties) stored in attribute tables. In a route 

system, each canal is a distinct and unique feature 

represented by a linear element, the geometry of which 

matches that of the real-world hydrologic features 

(river, stream, and canal). Each route has a definite 

origin, where a measuring system begins at zero and 

increases with the length of the feature in a downstream sense to its terminus. In other words, a linear 

referencing system (LRS) is established on the feature. 

A LRS is analogous to a Cartesian referencing 

system in that any point can be specified with two 

pieces of information; the latter requires an X,Y value 

and the former requires a Route-ID and a Measure. 

The Route-ID (name or a sequential value) indicates 

the name of the linear feature in which data are 

assigned, and the measure places it in the proper location along the feature length. This enables geocoding 

of information related to the feature (including hydrologic modeling parameters, such as sediment thickness) to their exact location along the feature. For 

instance, if a sediment thickness measurement was 

taken on a canal, it can be associated and mapped to 

its exact location along the canal by simply using the 

“feature identifier” (canal name), and the “position 

along” (meters from its origin). A common function in 

dynamic segmentation is to associate an approximate 

X,Y location to a route to obtain the position along 

the feature (distance from the origin) of the datapoint. 

In a dynamic segmentation model, attribute tables are 

called “event” tables, and there is one table for each 

hydrologic parameter of interest. In an event table, 

each observation is a separate record that includes its 

route identifier (river name), a “position along” (linear 

distance), and the value of the observation at the specified location. Events (river properties) can be defined, 

depending on how the hydrologic property varies 

along the river, as either continuous or step-wise 

(fig. 10A,B). Continuous properties vary linearly from 

one point to the next along the length of the hydrologic 

feature and include sediment thickness, bottom elevation, and stage (fig. 10A). Step-wise properties remain 

constant over a certain length (fig. 10B). Man-made 

canals are engineered channels with fixed bottom 

widths over long stretches. For purposes of this study, 

bottom width was the only property designated as stepwise. The records of a step-wise event only require one 

position location to be specified; the position indicates 

where the value is defined.
Development of Graphical User Interfaces for Creating Embedded Models 19

B. Step-wise property (bottom width)

A. Continuous property (sediment thickness)

C. Bed conductance for segments 1 to 4

D. Reach bed conductance for reach (used in MODFLOW package)

C1 C2 C3

C4

C =SC eq i

Local model

grid cell i,j,k

NAME TO BOTWID

LWL40E 6247.39 8.0

LWL41 19864.00 9.0

LWL41 20826.00 10.0

LWL41 20953.80 12.0

LWL41

NAME TO THICK

LWL40E 6247.392 1.2

LWL41 14804.10 2.0

LWL41 18951.70 1.2

LWL41 20953.80 1.5

LWL41 26167.60 0.5

LWL41

LWL41

LWL41

Figure 10. Step-wise and continuously 

defined properties and computation of 

reach bed conductance.
20 Approach for Delineation of Contributing Areas and Zones of Transport to Selected Public-Supply Wells Using a Regional 

Ground-Water Flow Model, Palm Beach County, Florida

A separate GUI extension, AvHDRD (app. III 

and fig. 11), was designed as part of this study to read 

dynamically segmented canal data and construct River 

and Drain MODFLOW input files. The AvHDRD GUI 

is an ArcView “plug-in” and is accessed by loading it 

through the “File” menu, “Extensions” item. The 

AvHDRD GUI is launched by pressing the button. 

AvHDRD can be used to extract information from 

each canal property event table and compute conductance terms by canal reach within each River (or 

Drain) cell. One event table is created for each of the 

relevant hydrologic properties: sediment thickness and 

hydraulic conductivity, bottom width and elevation, 

and, in the case of rivers, stage. Using standard GIS 

Figure 11. AvHDRD and AvWell graphical user interface dialog boxes for telescopic mesh 

refinement.
Development of Graphical User Interfaces for Creating Embedded Models 21

procedures, the event tables are mapped to the route 

system. AvHDRD can handle any combination of continuous or step-wise events (any or all properties could 

be step-wise or continuous). The user must decide 

which of the properties should be continuous and 

which should be step-wise in their application. A segment is defined as a stretch of a linear hydrologic feature within a cell in which step-wise properties remain 

constant and continuous properties may vary linearly 

(fig. 10C). In contrast, a reach is the length of the river 

that traverses the entire cell. There may be more than 

one segment in a reach because a property change may 

occur within the reach, marking the break point 

between segments.

The AvHDRD GUI extension computes values 

for each river or drain reach by use of a model grid 

overlay, extracting hydrologic feature properties, calculating conductance values, and writing an input file. 

The model grid is placed over the route system, and 

each cell that overlies a river feature is marked along 

with the measures that mark its cell intersection points. 

This method accounts for rivers that may meander, 

begin, or end at the cell. River meanders may result in 

more than two cell intersection points, and rivers that 

begin/end with a cell result in one cell intersection 

point. By using the route system and the information in 

the property event tables, a mean value for each property is extracted for each segment. The conductances 

are computed for each segment from the mean values, 

and then reach conductance is computed as the sum of 

the segment conductances (fig. 10D). Each item of 

information is sorted by cell sequence number and 

then by canal name, and records of the following type 

are printed to an ASCII file (table 1). A pound sign “#” 

is inserted after the required River/Drain file parameters to separate the River/Drain MODFLOW input 

data from spatial data record information. This latter 

information facilitates identification of a river or drain 

reach. This information, particularly useful if a cell 

contains more than one reach, can be used to map 

route system conductance values as a spatial data set 

property event. 

Table 1. Sample of part of MODFLOW River output file from AvHDRD 

[Dots represent continuation of output file]

832 83

832 

 1 1 7 15.6300 3667.47 5.73 # LWE2W 106381.15 106821.25

 1 1 8 15.6600 3668.05 6.74 # LWE2E 91759.19 92199.35

 1 1 38 14.9500 3315.57 4.13 # LWE3 104852.22 105170.52

 1 1 39 14.8700 1279.68 4.31 # LWE3 105170.52 105293.37

 1 1 61 8.1400 1467.23 3.15 # LWE4 90946.33 91386.50

 1 2 7 15.6400 3667.47 5.71 # LWE2W 106821.25 107261.34

 1 2 8 15.6600 3667.21 6.68 # LWE2E 92199.35 92639.42

 1 2 20 15.6000 1107.18 7.58 # LWL39 10389.71 10611.15

 1 2 21 15.4800 4766.83 7.51 # LWL39 10611.15 11051.16

 1 2 22 15.3200 4766.83 7.43 # LWL39 11051.16 11491.18

 . . . . . . . . . .

 . . . . . . . . . .

 . . . . . . . . . .
22 Approach for Delineation of Contributing Areas and Zones of Transport to Selected Public-Supply Wells Using a Regional 

Ground-Water Flow Model, Palm Beach County, Florida

Point coverage data layers were constructed 

using public and nonpublic supply well construction 

and location data documented in Yan and others (1995) 

or available in the SFWMD model well package data 

set. Pumpage rates for specific wells were provided in 

the SFWMD model documentation (Yan and others, 

1995). Accordingly, estimated pumpage rates for discrete wells are based on regional cell withdrawal rates. 

A separate GUI extension (AvWELL Refiner) 

for ArcView (app. IV and fig. 11) was prepared to 

allow the user to inspect or modify point spatial data 

sets, modify withdrawal rates and cell and layer location, or add/remove supply wells for purposes of local 

model simulation. The AvWELL Refiner GUI creates 

a new MODFLOW96 Well input file for an embedded 

model data set. The MODFLOW96 Well file created 

by MODTMR divides flux rates obtained from 

regional well cells and redistributes flux rates into all 

of corresponding local model cells. The redistribution 

of well flux from the regional to local model is completed on a percentage area basis. Withdrawal or injection wells are point features and can be more properly 

assigned to a single local model cell based on its physical location. AvWELL Refiner takes advantage of 

GIS functionality to assign the entire flow rate to the 

correct local model cell. A geographically referenced 

local model grid is superimposed on a point geospatial 

data set so that only local cells that overlie a well are 

treated as a MODFLOW Well (prescribed-flux) 

boundary condition. 

A point geospatial data set and a local model 

grid are required to use AvWELL Refiner and must be 

loaded as “themes” on the ArcView map canvas or 

“View.” A point geospatial data set must be constructed and contain the well identifier, map coordinates with the same projection and units provided in 

the local model grid, local model layer in which the 

well pumps from/to, and a flux rate for each stress 

period (table 2). The local model grid must also be in 

an ArcView Shapefile format, with the following integer fields as attributes: “Row,” “Col,” and “Seqnum” 

where “Seqnum” is the sequence number of the cells 

in model layer 1.

Well control points and the local model grid 

geospatial data sets are added as themes to an ArcView 

“view.” The AvWELL Refiner extension is loaded by 

accessing the File > Extensions...menu option. The 

AvWELL Refiner dialog window is launched by clicking on the launch button , or by the menu item 

“Well Refiner” on the “MODTMR” menu bar. The 

MODFLOW96 local model Name file is loaded using 

the “Browse” dialog box option. Once loaded, the 

number of stress periods are automatically read and 

printed on the dialog box next to the “Stress Periods” 

label. The file path to the model data set is printed on 

the line labeled “Path to files.” The user must select 

the well point geospatial data set from a list box 

marked “Well Theme” and is immediately prompted to 

indicate the data field that contains the “Well ID,” 

“Layer,” and “Pumpage” information. The user is 

Table 2. ArcView attribute table of well geospatial data set

Well 

No. x-coordinate y-coordinate Layer

Pumpage 

(cubic feet per day)

1 2 3

23-E 797548.63 747954.06 4 -96,348 0.0 -96,348

15-W 784291.00 744933.88 5 -427,410 .0 -427,410

25-E 796869.50 741082.50 3 80,513 .0 -80,513

11-E 798050.56 741293.31 3 111,260 .0 -111,260

25-W 785987.75 749589.75 4 584,438 .0 584,438

13-W 782753.00 743712.13 5 206,513 .0 -206,153
Application of the Embedded Model 23

prompted consecutively to indicate the “Pumpage” 

data fields for each stress period. One must also identify the local model grid geospatial data set, selecting 

it from a list box labeled “Grid Theme.” AvWELL 

Refiner overlays the local model grid on the well data 

set and associates each well control point with a corresponding local grid cell. More than one well control 

point in a specific grid cell is permitted. The data can 

be reviewed in the central area of the dialog by navigating through the records with the left and right 

arrows. A MODFLOW96 Well input file is prepared 

by clicking on the “Write File” button. AvWELL 

Refiner will overwrite the MODFLOW96 Well input 

file generated by MODTMR so the user may prefer to 

first rename the MODTMR-generated Well filename. 

The records are written in blocks, with one 

block for each stress period. This is accomplished programmatically by use of a nested loop; an outer loop 

iterates through a stress period (pumpage fields), and 

an inner loop examines each well that lies within the 

local model grid. Pumpage rates for each record (a 

well) are read as part of the inner loop, discarding a 

well control point if its withdrawal rate is equal to 

zero. A check is made at the start of the outer loop to 

determine if the user wishes to utilize the same pumpage field in the next stress period (i.e., pumpage rates 

are the same). If a “yes” response is given, a value of 

“-1” is written to the Well file and the loop terminates, 

moving to the next stress period. The “-1” is used in 

MODFLOW to indicate that the pumpage from the 

previous stress period will be used for the current one. 

APPLICATION OF THE EMBEDDED 

MODEL

Development of an embedded wellhead protection model and delineation of well-specific zones of 

transport required a multitask process (fig. 12). The 

four principal tasks are: (1) development of an embedded ground-water flow model in which input files are 

extracted from a calibrated, multilayer, SFWMD 

regional ground-water flow model; (2) perform calibration and evaluate embedded model sensitivity to 

hydrologic parameters; (3) perform backward tracking 

of water particles from selected municipal supply 

wells; and (4) postprocessing and storage of flow and 

particle-tracking information into a GIS database.

Boca Raton Well Field Embedded Model

A small-area MODFLOW model of the Boca 

Raton well field was constructed and calibrated (tasks 1 

and 2 in fig. 12) using information provided in the 

SFWMD regional model. Steady-state calibration was 

based on average conditions from January 1989 to June 

1990. As a result of the large cell size (2,650 x 2,650 ft) 

in the countywide, large-area model, simulation results 

did not meet acceptable scale requirements for flow and 

particle analysis in the Boca Raton well field area. 

A five-layer, embedded, small-area MODFLOW model 

was constructed to simulate ground-water flow in the 

Boca Raton area (figs. 13-17). The embedded model 

area was subdivided using a uniform grid containing 

72 rows and 84 columns; each of the 6,048 cells is 

440 ft long on each side. Five layers were used in the 

regional model and embedded model (fig. 7).

Prior to selection of the Boca well field model 

domain, backward tracking was performed using the 

SFWMD regional model to delineate the direction and 

extent of particle movement from selected municipal 

wells. The northern, southern, and western model 

perimeter prescribed-flux boundaries, extracted as part 

of the TMR process, were placed away from the Boca 

Raton well field area to reduce boundary effects. The 

Intracoastal Waterway (figs. 1 and 2) lies near the eastern edge of the well field; initially, the entire model 

domain was located inland, but subsequently was modified to extend beyond the coastline. Although the general direction of ground-water flow is eastward, water 

levels maintained in the LWDD canal system (fig. 1) 

create variations in the water table and locally affect the 

direction of ground-water flow. The southern boundary 

was selected south of Hillsboro Canal, a ground-water 

sink. The northern boundary was selected near the 

LWL-40 Canal (fig.1). The western boundary was 

placed along a primary lateral canal (LWE-2W Canal) 

located along a regional ground-water divide as indicated on water-table maps (Kane, 1992 a,b). 

A prescribed-head boundary along the coastline 

was set equal to mean monthly sea level (0.5 ft) in 

layer 1 (fig. 13) for all cells east of the west shore of 

the Intracoastal Waterway. Prescribed-head cell boundary values also were used in column 84 in layers 2 to 

5 (figs. 14-17) and assumed to represent mean monthly 

sea level. No effort was made to adjust heads in offshore prescribed-head cells for salinity differences−−

an important model limitation discussed later.
24 Approach for Delineation of Contributing Areas and Zones of Transport to Selected Public-Supply Wells Using a Regional 

Ground-Water Flow Model, Palm Beach County, Florida

MODFLOW regional model

MODTMR, River, Drain, and

Well graphical user interfaces

MODTMR

Parse GIS canal

and well coverage

datasets

Run and calibrate MODFLOW

embedded flow model

Conduct sensitivity

analysis

MODPATH particle tracking

MODTOOLS

Spatial data

Particle pathlines

Particle endpoints

Particle time series

Zones of transport

Input and output

contour arrays

Velocity vectors

Cell values

Model grid

Visualization using GIS

TASK 1

TASK 2

TASK 3

TASK 4

Figure 12. Process for delineating zone-of-transport areas to public-supply 

wells in a local-scale model. GIS is geographic information system.
Application of the Embedded Model 25

REGIONAL MODEL

CONTROL POINT

Intracoastal Waterway coastline

BOUNDARY CONDITIONS

LOCAL MODEL

EXPLANATION 0 1 2 MILES

0 1 2 KILOMETERS

Atlantic Ocean coastline

Local prescribed well cell

Local prescribed flux cell

Local river cell

Local prescribed head cell

Municipal well

Nonpublic supply well

Observation well

Regional river cell

Regional well cell

Regional general

head boundary

Figure 13. Well field model grids showing relation between regional and local domains and internal and external 

boundary conditions for model layer 1.
26 Approach for Delineation of Contributing Areas and Zones of Transport to Selected Public-Supply Wells Using a Regional 

Ground-Water Flow Model, Palm Beach County, Florida

0 1 2 MILES

0 1 2 KILOMETERS

CONTROL POINT

Municipal well

Nonpublic supply well

Observation well

Local prescribed well cell

Local prescribed flux cell

Local prescribed head cell

Regional general

head boundary

EXPLANATION

Regional well cell

REGIONAL MODEL

BOUNDARY CONDITIONS

LOCAL MODEL Intracoastal Waterway coastline

Atlantic Ocean coastline

Figure 14. Well field model grids showing relation between regional and local domains and internal and external 

boundary conditions for model layer 2.
Application of the Embedded Model 27

0 1 2 MILES

0 1 2 KILOMETERS

CONTROL POINT

Municipal well

Nonpublic supply well

Observation well

Local prescribed well cell

Local prescribed flux cell

Local prescribed head cell

Regional general

head boundary

EXPLANATION

Regional well cell

REGIONAL MODEL

BOUNDARY CONDITIONS

LOCAL MODEL Intracoastal Waterway coastline

Atlantic Ocean coastline

Figure 15. Well field model grids showing relation between regional and local domains and internal and external 

boundary conditions for model layer 3.
28 Approach for Delineation of Contributing Areas and Zones of Transport to Selected Public-Supply Wells Using a Regional 

Ground-Water Flow Model, Palm Beach County, Florida

0 1 2 MILES

0 1 2 KILOMETERS

CONTROL POINT

Municipal well

Nonpublic supply well

Observation well

Local prescribed well cell

Local prescribed flux cell

Local prescribed head cell

Regional general

head boundary

EXPLANATION

Regional well cell

REGIONAL MODEL

BOUNDARY CONDITIONS

LOCAL MODEL Intracoastal Waterway coastline

Atlantic Ocean coastline

Figure 16. Well field model grids showing relation between regional and local domains and internal and external 

boundary conditions for model layer 4.
Application of the Embedded Model 29

0 1 2 MILES

0 1 2 KILOMETERS

REGIONAL MODEL

CONTROL POINT

BOUNDARY CONDITIONS

LOCAL MODEL

EXPLANATION

Local prescribed well cell

Local prescribed flux cell

Local prescribed head cell

Municipal well

Nonpublic supply well

Observation well

Regional well cell

Regional general

head boundary

Intracoastal Waterway coastline

Atlantic Ocean coastline

Figure 17. Well field model grids showing relation between regional and local domains and internal and external 

boundary conditions for model layer 5.
30 Approach for Delineation of Contributing Areas and Zones of Transport to Selected Public-Supply Wells Using a Regional 

Ground-Water Flow Model, Palm Beach County, Florida

Automated selection of prescribed-head or 

prescribed-flux boundaries along an irregular coastline 

is not possible in the current version of MODTMR or 

AvMODTMR. Manual regridding to modify IBOUND 

and other areal model parameters in layer 1 was 

required to accurately represent the coastline. 

The MODFLOW River package (McDonald and 

Harbaugh, 1988; Harbaugh and McDonald, 1996) was 

used to allow leakage to or from the aquifer along 

drainage and lateral canals. Some canals in the largearea model (Yan and others, 1995) were represented 

by the MODFLOW Drain package to simulate the 

discharge from uncontrolled drainage canals with 

uncontrolled water levels. All canals in the Boca Raton 

small-area embedded model area were represented as 

rivers in the large-area model. Accordingly, internal 

boundary conditions of the same type were used to 

maintain consistency between the large-area and 

embedded small-area models. The AvHDRD GUI and 

GIS canal data were used to construct a new River 

package input file. Canal GIS data sets included canalbottom elevation, bottom width, hydraulic conductivity of the bed sediment, canal-bottom sediment thickness, and canal stage. Stage levels within the canal 

reaches were set to the LWDD maintenance control 

levels. Before model calibration, bed conductance 

values for the small-area model cells were compared 

with the cell in the corresponding area of the regional 

model to ensure consistency between both models. 

The user must compare conductance data in the largearea and small-area models to ensure consistency 

between the two models. The principal reason to maintain consistency is that river water-budget components 

in the small-area model should be similar to the inflow 

and outflow components in the corresponding area of 

the large-area model (Leake and Claar, 1999, p. 5). 

The MODFLOW Well package (McDonald and 

Harbaugh, 1988; Harbaugh and McDonald, 1996) was 

used to simulate well withdrawals. Detailed information 

regarding well-field operation rates at specific wells 

during 1989-90 were not available during the course of 

this study. Well discharge was obtained directly from 

the regional model cell-value data set. Discharge rates 

for regional cells were reallocated, divided equally 

among the various supply wells contained within a 

discrete cell.

Recharge rates in the embedded local model were 

extracted as part of the TMR process from the MODFLOW Recharge package input file. Recharge estimates 

were modified further as part of model calibration. On 

the basis of the calibrated model, the mean estimate of 

calibrated recharge is 0.006 ft/d or about 27 in/yr.

Hydraulic conductivity and transmissivity arrays 

extracted during the TMR process are based originally 

on aquifer test data collected for the large-area SFWMD 

model. Transmissivity and leakance arrays also were 

extracted directly during the TMR process. Regional 

precalibrated leakance values were calculated by assuming leakance was equal to 0.1 multiplied by the horizontal conductivity, divided by the approximate thickness 

between midpoints of vertically adjacent cells.

A modified Blaney-Criddle algorithm was used 

to estimate maximum evapotranspiration rates for the 

large-area SFWMD model. An evapotranspiration surface elevation of 1.5 ft below land surface was used 

during the large-area model calibration process, and 

extinction depths that ranged from 1 to 5 ft (in the 

small-area domain area) were based on land use and 

estimated root depths for various types of vegetation. 

Evapotranspiration rates, evapotranspiration surface 

elevation, and extinction depths in the embedded local 

model were extracted as part of the TMR process from 

the MODFLOW Evapotranspiration package input file. 

Calibration and Sensitivity Analysis

Mean water levels between January 1989 and 

June 1990 were used to simulate steady-state groundwater flow in the telescoped Boca Raton well field and 

calibrated to the observed mean water-level data for 

that period of time. The embedded model simulated 

potentiometric surface compares favorably to the simulated surface in the regional model and is similar to 

countywide potentiometric surface maps by Kane 

(1992a,b). 

The purpose of model calibration was to develop 

a set of parameters and stresses that result in a reasonable simulation of ground-water flow within the surficial aquifer system in the embedded Boca Raton model 

area. Calibration was achieved by a trial-and-error 

approach in which model parameters including transmissivity, hydraulic conductivity, leakance, riverbed 

conductance, and recharge were adjusted to minimize differences between simulated and observed hydraulic head. 
Application of the Embedded Model 31

Model parameters were modified during the 

calibration process, but limited to the range of values 

identified elsewhere in the regional model. Estimates 

of recharge, hydraulic conductivity, leakance, and 

transmissivity are shown in figures 18 to 27. Evapotranspiration and withdrawal rates from wells were 

not adjusted during calibration.

Calibration criteria were based on matching 

observed and simulated heads within 1.5 ft of the 

mean water levels. Of the 41 observation wells 

screened in the model layers, 37 wells are included 

in layer 1. Layer 4 includes one well, and layer 5 

includes three wells. Although the model is numerically sensitive to leakance associated with layers 3 

and 4, the small number of observation wells make 

it difficult to evaluate if the model satisfies actual 

hydrologic conditions.

A comparison of the measured water level at 

observation wells and the simulated potentiometric 

surface of model layer 1 is shown in figure 28. A positive number indicates that the observed water level is 

higher than the simulated water level; whereas, a negative number indicates that the observed water level is 

less than the simulated water level. Calibration criteria 

were met at 34 observation wells; however, simulated 

head could be matched only within 3 ft of observed 

water levels at 5 wells. Differences at two wells, all 

located near pumping centers, exceeded 3 ft. A review 

of the calibrated regional model indicated that eight 

observation wells in the Boca Raton well field area 

were poorly calibrated (Yan and others, 1995). 

Differences between observed and simulated 

water levels after an adjustment of a parameter were 

used as indicators of the model sensitivity. If a small 

change in a parameter results in relatively large 

changes in model results, the outcome is considered 

sensitive to that parameter. This may mean that the 

model parameter has to be determined very accurately 

or alternatively; the model cannot be used to determine 

whether a calibrated parameter is reasonable. 

The root mean square error (RMSE) is used as 

a measure of the fit between observed and simulated 

water levels. If the errors between the observed and 

simulated water levels are normally distributed, the 

RMSE is an approximation of standard deviation of 

the errors. In this case, two-thirds of the errors are 

less than the RMSE (1.95 for the calibration period). 

The RMSE was calculated in feet and plotted to 

display the range of sensitivity when model parameters 

were decreased one-half or increased two fold (fig. 29). 

The model appears most sensitive to a reduction in the 

leakance of layer 3, a reduction in leakance of layer 4, 

increases in the rate of recharge, and increases in 

hydraulic conductivity of layer 1. The model is moderately sensitive to changes in riverbed conductance and 

transmissivity of layer 4. Adjustments to riverbed conductance seem to best help the calibration results in 

places where an observation well is located near a 

canal. The model is effectively insensitive to all other 

parameters. 

Water Budget

The steady-state budget of the simulated system 

of the Boca Raton well field model (table 3) indicates 

that recharge is the major inflow component (58 percent), with river leakage contributing 29 percent of the 

inflow. Prescribed flux along the northern, western, 

and southern boundaries contributed about 10 percent 

of the total amount of water entering the Boca Raton 

well field model area. Well recharge and inflow at the 

coastal (prescribed-head) boundary (Intracoastal 

Canal) contributed only 2.8 and 0.2 percent of the 

inflow, respectively. 

Well discharge (56 percent) and river leakage 

(27 percent) represent the principal outflow water-budget components. Discharge at the coastal prescribedhead boundary represents about 10 percent of the total 

budget, whereas northern, western, and eastern prescribed flux boundaries represent only 6.5 percent of 

the outflow component. Evapotranspiration is less than 

0.001 percent of the total outflow components. In the 

Boca Raton model domain area, the extinction depth 

lies above the simulated head in nearly all model cells. 

Water-budget data suggest that evapotranspiration 

occurs either at land surface or in the unsaturated 

zone--zones not simulated in MODFLOW96. 

The Boca Raton well field water budget and 

water-budget components obtained from the SFWMD 

model using ZONEBUDGET were compared to evaluate consistency between large-area and small-area 

models. Inflow budget components including prescribed head (treated as a head-dependent boundary in 

the SFWMD model), prescribed flux, and injection 

well components are comparatively consistent, both in 

terms of volume and percent of the total water budget. 
32 Approach for Delineation of Contributing Areas and Zones of Transport to Selected Public-Supply Wells Using a Regional 

Ground-Water Flow Model, Palm Beach County, Florida

Outflow budget components including prescribed head 

(head-dependent boundary in the SFWMD model), 

well discharge, and evapotranspiration are similar. 

Several water-budget differences are evident. 

The total Boca Raton water budget (47.2 in.) is less 

than the SFWMD model subarea total budget (50.9 in.) 

determined using ZONEBUDGET. Budget differences 

are largely attributed to the changes made to the Boca 

Raton well field model, including modification of 

boundary conditions in layer 1 to accurately represent 

the coastline configuration. 

River leakage and recharge are the major inflow 

water-budget components in the small area model that 

do not favorably compare with the zone budget determination, also attributed to modification of model 

parameters during the calibration process. Recharge 

represents a larger percentage of inflow in the Boca 

Raton water-budget analysis. River (canal) leakage 

similarly represented a smaller inflow component in 

the Boca Raton model of the overall water budget 

(29 percent) when compared to zone budget amount 

(34.6 percent). River (canal) leakage was a smaller 

outflow component in the local model (27.2 percent) 

when compared to the regional model (31.7 percent). 

Pathlines, Contributing Areas, and Delineation 

of Zones of Transport

Flow pathlines, contributing areas, and time-oftravel estimates for selected municipal Boca Raton 

supply wells were constructed using the MODPATH 

particle-tracking program (Task 3 in fig. 12). Particle 

paths can be tracked forward in time from recharge 

areas or backward from a supply well to contributing 

areas. Contributing areas for recharge were defined by 

backtracking particles from the supply well to the 

water table. Although not performed in this study, 

forward tracking can be used to clarify poorly defined 

areas located between backward-tracked particles and 

help to ensure areas contributing recharge to wells are 

correct in size (Barlow, 1995). A pathline analysis was 

conducted initially to provide insight to the general 

configuration of contributing areas and for definition 

of a 500-day time-of-travel zone of transport. Subsequently, particles were permitted to travel until they 

encountered internal sinks or sources or boundaries.

Ground-water pathlines under simulated steadystate head conditions between January 1989 and June 

1990 were created by placing 1,000 particles in each 

selected cell containing municipal supply wells that 

discharge water at prescribed rates. Zones of transport 

and time of travel in the Boca Raton well field were 

estimated assuming steady-state conditions and the 

pumping conditions defined in the large-area model 

analysis. For modeling purposes, steady-state hydrologic conditions were considered to represent average 

hydrologic conditions; such conditions could vary considerably if new supply wells were added to the well 

field. An independent effort to verify ground-water 

flow velocities, such as through the use of chemical 

tracers, was considered beyond the scope of this study 

and was not conducted.

Canals located within the Boca Raton embedded 

model were collectively treated as weak sinks; cells 

that contain weak sinks do not discharge at rates sufficient to consume all water entering them. Although not 

considered in this study, one of two approaches can be 

used to resolve the issue of weak sinks: (1) reduce 

model cell size so that flow entering cells with internal 

sinks is completely discharged, or (2) conduct two 

analyses. In one analysis, weak sinks are ignored; in an 

alternative analysis, particles are programmed as stopping at weak sinks. 

The Boca Raton embedded flow model is based 

on input parameters developed as part of a regional 

flow model. Unfortunately, porosity estimates are 

sparse; the spatial distribution of porosity within the 

surficial aquifer system is poorly known in Palm 

Beach County and the Boca Raton well field area. 

Porosity estimates of limestone from the Tamiami 

Formation in southwestern Palm Beach County range 

from 20 to 30 percent (Reese and Cunningham, 2000). 

The porosity of Tamiami Formation core samples collected from the North Dixie well field in eastern Broward County (not shown) is reported to range from 38 

to 40 percent (Fish, 1988). 

For purposes of this study, uniform porosity 

distributions of 20, 30, and 40 percent were separately 

assumed for the surficial aquifer system. Porosity 

within the surficial aquifer system can vary considerably, and therefore, could affect time of travel. However, such variations are not likely to affect pathline 

configurations.
Application of the Embedded Model 33

EXPLANATION

RECHARGE, IN FEET PER DAY

01 2 3 MILES

0 1 2 3 KILOMETERS

4.38 - 13.14

13.14 - 21.9

21.9 - 26.28

26.28 - 35.04

35.04 - 43.8

Intracoastal Waterway coastline

Atlantic Ocean coastline

Figure 18. Calibrated recharge for the Boca Raton well field model.
34 Approach for Delineation of Contributing Areas and Zones of Transport to Selected Public-Supply Wells Using a Regional 

Ground-Water Flow Model, Palm Beach County, Florida

EXPLANATION

HYDRAULIC CONDUCTIVITY,

IN FEET PER DAY

0 1 2 3 MILES

0 1 2 3 KILOMETERS

30 - 50

50 - 120

120 - 200

200 - 400

Intracoastal Waterway coastline

Atlantic Ocean coastline

Figure 19. Hydraulic conductivity for layer 1, Boca Raton well field model.
Application of the Embedded Model 35

EXPLANATION

LEAKANCE, IN FEET

PER DAY PER FOOT

0 1 2 3 MILES

0 1 2 3 KILOMETERS

0.106 - 0.113

0.113 - 0.124

0.124 - 0.137

0.137 - 0.154

0.154 - 0.183

Intracoastal Waterway coastline

Atlantic Ocean coastline

Figure 20. Leakance for layer 1, Boca Raton well field model.
36 Approach for Delineation of Contributing Areas and Zones of Transport to Selected Public-Supply Wells Using a Regional 

Ground-Water Flow Model, Palm Beach County, Florida

0 1 2 3 MILES

0 1 2 3 KILOMETERS

EXPLANATION

TRANSMISSIVITY, IN FEET

SQUARED PER DAY

1,000 - 1,500

1,500 - 1,850

1,850 - 2,000

2,000 - 2,500

2,500 - 2,750

Intracoastal Waterway coastline

Atlantic Ocean coastline

Figure 21. Transmissivity for layer 2, Boca Raton well field model.
Application of the Embedded Model 37

EXPLANATION

LEAKANCE, IN FEET

PER DAY PER FOOT

0.151 - 0.188

0.188 - 0.223

0.223 - 0.266

0.266 - 0.336

0.336 - 0.44

Intracoastal Waterway coastline

Atlantic Ocean coastline

0 1 2 3 MILES

0 1 2 3 KILOMETERS

Figure 22. Leakance for layer 2, Boca Raton well field model.
38 Approach for Delineation of Contributing Areas and Zones of Transport to Selected Public-Supply Wells Using a Regional 

Ground-Water Flow Model, Palm Beach County, Florida

EXPLANATION

TRANSMISSIVITY, IN FEET

SQUARED PER DAY

750 - 10,000

10,000 - 30,000

30,000 - 40,000

40,000 - 65,000

65,000 - 112,500

Intracoastal Waterway coastline

Atlantic Ocean coastline

0 1 2 3 MILES

0 1 2 3 KILOMETERS

Figure 23. Transmissivity for layer 3, Boca Raton well field model.
Application of the Embedded Model 39

EXPLANATION

0.158 - 0.258

0.258 - 0.409

0.409 - 0.621

0.621 - 5.000

5.000 - 6.897

LEAKANCE, IN FEET

PER DAY PER FOOT

Intracoastal Waterway coastline

Atlantic Ocean coastline

0 1 2 3 MILES

0 1 2 3 KILOMETERS

Figure 24. Leakance for layer 3, Boca Raton well field model.
40 Approach for Delineation of Contributing Areas and Zones of Transport to Selected Public-Supply Wells Using a Regional 

Ground-Water Flow Model, Palm Beach County, Florida

EXPLANATION

TRANSMISSIVITY, IN FEET

SQUARED PER DAY

800 - 10,000

10,000 - 25,000

25,000 - 65,000

65,000 - 100,000

100,000 - 140,000

Intracoastal Waterway coastline

Atlantic Ocean coastline

0 1 2 3 MILES

0 1 2 3 KILOMETERS

Figure 25. Transmissivity for layer 4, Boca Raton well field model.
Application of the Embedded Model 41

EXPLANATION

LEAKANCE, IN FEET

PER DAY PER FOOT

0.038 - 0.048

0.048 - 0.059

0.059 - 0.075

0.075 - 0.099

0.099 - 0.166

Intracoastal Waterway coastline

Atlantic Ocean coastline

0 1 2 3 MILES

0 1 2 3 KILOMETERS

Figure 26. Leakance for layer 4, Boca Raton well field model.
42 Approach for Delineation of Contributing Areas and Zones of Transport to Selected Public-Supply Wells Using a Regional 

Ground-Water Flow Model, Palm Beach County, Florida

EXPLANATION

TRANSMISSIVITY, IN FEET

SQUARED PER DAY

2,000 - 4,430

4,430 - 6,390

6,390 - 7,720

7,720 - 8,855

8,855 - 9,890

Intracoastal Waterway coastline

Atlantic Ocean coastline

0 1 2 3 MILES

0 1 2 3 KILOMETERS

Figure 27. Transmissivity for layer 5, Boca Raton well field model.
Application of the Embedded Model 43

EXPLANATION

0 1 2 KILOMETERS

0 1 2 MILES

0.570 2.310

-1.321 1.710

-6.274

1.385

-6.263

-0.128

-0.349

0.705

0.414

1.497

1.437

-0.556

0.800

1.704

-0.161

-0.186

-0.368

-0.414 4.538

-0.207

0.554

-0.297

1.852

0.692

-0.579 0.980

1.358

1.398

0.320 0.006

-0.825

-0.900

-1.082

-0.127

-1.224

-0.185

1.551

0.032

4.855

2.536

15

5

10

5

Line of equal potentiometric

surface in layer 1. Interval is 1

foot. Datum is sea level

10

CONTROL POINT

BOUNDARY CONDITIONS

LOCAL MODEL

Local prescribed well cell

Local prescribed flux cell

Local river cell

Local prescribed head cell

Municipal well

Nonpublic supply well

Observation well. Number indicates

observed minus simulated head,

in feet

0.032

Intracoastal Waterway coastline

Atlantic Ocean coastline

Figure 28. Simulated steady-state potentiometric surface and residual differences between simulated and observed 

water levels in the Boca Raton well field, average January 1989 to June 1990 conditions.
44 Approach for Delineation of Contributing Areas and Zones of Transport to Selected Public-Supply Wells Using a Regional 

Ground-Water Flow Model, Palm Beach County, Florida

Riverbed conductance

1.5

1.5 1.5

2.0

2.0 2.0

2.5

2.5 2.5

3.0

3.0 3.0

0 1 2 3

1.5

2.0

2.5

3.0

0

0

0

0

0

0.5

0.5

0.5

0.5

0.5

1.0

1.0

1.0

1.0

1.0

1.5

1.5

1.5

1.5

1.5

2.0

2.0

2.0

2.0

2.0

2.5

2.5

2.5

2.5

2.5

MULTIPLIER

MULTIPLIER

MULTIPLIER

MULTIPLIER

MULTIPLIER MULTIPLIER

Leakance (Layer 1) Leakance (Layer 2)

Leakance (Layer 3)

1.5 1.5

2.0 2.0

2.5 2.5

3.0 3.0

3.5 3.5

Leakance (Layer 4)

ROOT MEAN

SQUARE ERROR,

IN FEET

ROOT MEAN

SQUARE ERROR,

IN FEET

ROOT MEAN

SQUARE ERROR,

IN FEET

ROOT MEAN

SQUARE ERROR,

IN FEET

ROOT MEAN

SQUARE ERROR,

IN FEET

ROOT MEAN

SQUARE ERROR,

IN FEET

Recharge

Figure 29. Sensitivity of the Boca Raton well field model to changes in selected model parameters.
Application of the Embedded Model 45

Hydraulic conductivity (Layer 1)

MULTIPLIER

Transmissivity (Layer 2)

Transmissivity (Layer 3)

0 1 2 3 4

Transmissivity (Layer 5)

ROOT MEAN

SQUARE ERROR,

IN FEET

ROOT MEAN

SQUARE ERROR,

IN FEET

ROOT MEAN

SQUARE ERROR,

IN FEET

ROOT MEAN

SQUARE ERROR,

IN FEET

ROOT MEAN

SQUARE ERROR,

IN FEET

0 0

0

0

0.5 0.5

0.5

0.5

1.0 1.0

1.0

1.0

1.5 1.5

1.5

1.5

2.0 2.0

2.0

2.0

2.5 2.5

2.5

2.5

MULTIPLIER MULTIPLIER

MULTIPLIER

MULTIPLIER

1.5 1.5

1.5 1.5

1.5

2.0 2.0

2.0 2.0

2.0

2.5 2.5

2.5 2.5

2.5

3.0 3.0

3.0 3.0

3.0

Transmissivity (Layer 4)

Figure 29. (Continued) Sensitivity of the Boca Raton well field model to changes in selected model parameters.
46 Approach for Delineation of Contributing Areas and Zones of Transport to Selected Public-Supply Wells Using a Regional 

Ground-Water Flow Model, Palm Beach County, Florida

Previous investigators, including Barlow (1989), 

Morrisey (1989), Reilly and Pollock (1993), and Orzol 

and Truini (1999), have evaluated physical factors that 

may influence the location, extent, and shape of the 

areas of contribution and zones of transport. These 

factors include the specific character of the physical 

hydrogeologic framework (permeability, porosity, 

saturated thickness, recharge from induced infiltration, 

well interference, and extent of the aquifer) and the 

anthropogenic stress on the hydrologic environment 

that causes changes in head, flow, and boundary 

conditions.

Analysis

A pathline analysis in which particles were 

permitted to travel until they encountered internal 

sinks, sources, or boundaries illustrates ground-water 

movement within the system (fig. 30). In this analysis, 

the average time of travel for such conditions was 

more than 22 years. Long-term pathlines to supply 

wells mostly extend to the west and northwest from 

supply wells. Contributing areas of recharge to the 

supply wells were defined where particles were backtracked to the water table (fig. 31). Contributing areas 

generally conform to the same configuration illustrated 

by the pathline analysis and also extend to the northwest and west. Some particle endpoints are located 

along the edge of the model domain and intersect 

external boundaries; in these areas, contributing 

recharge areas for supply wells extend beyond the 

simulated area of the Boca Raton well field. 

Zones of transport were delineated for several 

different Boca Raton municipal supply wells (figs. 32-

34) assuming separate uniform distributions of 20, 30, 

and 40 percent porosity. Transport zones surrounding 

each major well field correspond to contoured areas 

that lie between 30-, 210-, and 500-day time-of-travel 

contours to a producing water-supply well. 

Table 3. Water budget for the Boca Raton embedded flow model

[Prescribed flux along the northern, western, and eastern boundaries. --, no data; <, less than the value]

Component

Boca Raton model Zone budget

Percent Inches Percent Inches

Inflow components

Recharge 58 27.4 54 27.5

Prescribed-flux boundaries 10 .5 8.8 4.5

Coastal prescribed-head boundary .2 .012 -- --

Head-dependent boundary -- -- 0 0

River (canal) leakage 29 14 34.6 17.6

Well recharge 2.8 1.3 2.6 1.3

Total 100.0 47.2 100.0 50.9

Outflow components

Prescribed-flux boundaries 6.5 3.1 6 3.1

Coastal prescribed-head boundary 10.4 4.9 -- --

Coastal head-dependent boundary -- -- 10.8 5.5

Well discharge 55.9 26.4 51.3 26.2

Evapotranspiration <.001 .001 .2 .1

River (canal) leakage 27.2 12.8 31.7 16

Total 100.0 47.2 100.0 50.9
Application of the Embedded Model 47

0 1 2 KILOMETERS

0 1 2 MILES EXPLANATION

Particle pathline

Municipal well

Nonpublic supply well

CONTROL POINT

BOUNDARY CONDITIONS

LOCAL MODEL

Local prescribed well cell

Local prescribed flux cell

Local river cell

Local prescribed head cell

Intracoastal Waterway coastline

Atlantic Ocean coastline

Figure 30. Boca Raton model domain showing backward-tracked particle pathlines from selected 

municipal supply wells in which particles were allowed to travel until encountering internal sinks, 

sources, or boundaries.
48 Approach for Delineation of Contributing Areas and Zones of Transport to Selected Public-Supply Wells Using a Regional 

Ground-Water Flow Model, Palm Beach County, Florida

EXPLANATION

CONTROL POINT

BOUNDARY CONDITIONS

LOCAL MODEL

Local prescribed well cell

Local prescribed flux cell

Local river cell

Local prescribed head cell

Municipal well

Nonpublic supply well

Particle endpoints

0 1 2 KILOMETERS

0 1 2 MILES

Intracoastal Waterway coastline

Atlantic Ocean coastline

Figure 31. Boca Raton model domain with backward-tracked endpoint analysis showing 

contributing areas for selected municipal supply wells in which particles were allowed to 

travel until encountering internal sinks, sources, or boundaries.
Application of the Embedded Model 49

EXPLANATION 0 1 2 MILES

0 1 2 KILOMETERS

BOUNDARY CONDITIONS

LOCAL MODEL

ZONES OF TRANSPORT

TIME OF TRAVEL, IN DAYS

0 to 30

30 to 210

210 to 500

Local prescribed well cell

Local prescribed flux cell

Local river cell

Local prescribed head cell

CONTROL POINT

Municipal well

Nonpublic supply well

Intracoastal Waterway coastline

Atlantic Ocean coastline

Figure 32. Zones of transport for selected municipal supply wells in the Boca Raton well field, assuming uniform 

porosity of 20 percent.
50 Approach for Delineation of Contributing Areas and Zones of Transport to Selected Public-Supply Wells Using a Regional 

Ground-Water Flow Model, Palm Beach County, Florida

0 to 30

30 to 210

210 to 500

CONTROL POINT

BOUNDARY CONDITIONS

LOCAL MODEL

ZONES OF TRANSPORT

TIME OF TRAVEL, IN DAYS

EXPLANATION 0 1 2 MILES

0 1 2 KILOMETERS

Municipal well

Nonpublic supply well

Local prescribed well cell

Local prescribed flux cell

Local river cell

Local prescribed head cell

Intracoastal Waterway coastline

Atlantic Ocean coastline

Figure 33. Zones of transport for selected municipal supply wells in the Boca Raton well field, assuming uniform 

porosity of 30 percent.
Application of the Embedded Model 51

0 to 30

30 to 210

210 to 500

CONTROL POINT

BOUNDARY CONDITIONS

LOCAL MODEL

ZONES OF TRANSPORT

TIME OF TRAVEL, IN DAYS

EXPLANATION 0 1 2 MILES

0 1 2 KILOMETERS

Local prescribed well cell

Local prescribed flux cell

Local river cell

Local prescribed head cell

Municipal well

Nonpublic supply well

Intracoastal Waterway coastline

Atlantic Ocean coastline

Figure 34. Zones of transport for selected municipal supply wells in the Boca Raton well field, assuming uniform 

porosity of 40 percent.
52 Approach for Delineation of Contributing Areas and Zones of Transport to Selected Public-Supply Wells Using a Regional 

Ground-Water Flow Model, Palm Beach County, Florida

For purposes of this study, the effect of porosity on the location, extent, or shape of zone of transport was the only physical factor evaluated. Porosity 

estimates, a physical parameter used in particle tracking but not in flow simulation, partly determine particle velocity and the time of travel. Particle velocity 

will change, but flow paths remain unchanged. In 

general, particle velocity increases as porosity 

decreases. Where porosity is increased uniformly, the 

size and shape of individual zones-of-transport areas 

were shown to increase. The total area encompassed 

by individual zones of transport occurred where a 20 

percent porosity was assumed. Conversely, zone-oftransport areas are smallest areally where a uniform 

40 percent porosity was assumed. 

Limitations

The embedded Boca Raton model uses steadystate, time-averaged, climatic conditions from January 

1989 to June 1990 which were the conditions of the 

regional model calibration. The small-area model was 

not calibrated to transient conditions; thus, it cannot 

be used to evaluate a transient response to changes in 

hydrologic stress (such as an increase or a decrease in 

well-pumpage rates).The SFWMD model would 

require recalibration if it were deemed necessary to 

evaluate other stress scenarios within the embedded 

area. 

Boundary conditions involve considerable simplification of the system and could greatly affect 

model results. For purposes of the embedded model, 

prescribed-head and prescribed-flux boundaries are 

considered valid for the January 1989 to June 1990 

steady-state calibration period. The scope of this 

study did not include an adjustment of heads in offshore prescribed-head cells for salinity differences. 

Equivalent freshwater heads would be greater than 

mean monthly tidal stage. Therefore, the embedded 

model may not be properly calibrated near the coast. 

A limitation of a small-area, embedded model is 

that it is ultimately constrained by the conceptual 

framework of a large-area model and how well the 

SFWMD model accurately reflects actual conditions. 

As the focus of this study was to develop a GUI to 

facilitate and expedite TMR, little effort was made to 

improve the conceptual framework. A calibrated, 

small-scale model will be more finely discretized, but 

may not depict realistic physical and hydrologic 

conditions. 

Discharge rates for individual withdrawal wells 

were estimated because data could not be obtained. 

An additional limitation to the small-area embedded 

model could result from the observation wells available for calibration purposes. All but 4 of 41 observation wells were assigned to model layer 1 of the Boca 

Raton embedded model. Model layers 3 and 4 represent the Biscayne aquifer. In the Boca Raton well field 

area, however, no observation wells were completed in 

the section of the Biscayne aquifer assigned to model 

layer 3 and only one observation well was completed 

in the lower part of the aquifer (layer 4). Therefore, a 

calibrated model may not properly represent conditions within that horizon. The lack of observation well 

data could adversely affect the parameter values not 

directly connected to these layers.

Some parameters estimated during model calibration may be highly correlated; consequently, the 

set of calibrated parameter values may not be unique. 

For example, the model may respond nearly identically 

to either a decrease in recharge and an increase in 

hydraulic conductivity or an increase in recharge and 

a decrease in hydraulic conductivity. If a condition 

such as this were to exist, either recharge or hydraulic 

conductivity could be estimated by model calibration 

but not both--one parameter would have to be independently estimated and not adjusted during model 

calibration. Nonunique parameters pose a problem 

because model response may not be correct for stresses 

that differ from those used during model calibration 

(for example, an increase in well pumpage). However, 

it was beyond the scope of this study to investigate 

this possibility in more detail.

Limitations to the particle-tracking phase of the 

study and the analysis of zones of transport are those 

directly attributed to the Boca Raton embedded numerical flow model. Additionally, a transient model may 

better illustrate flow path variability that occurs in 

response to transient change in hydrologic conditions. 

The steady-state model described herein cannot be 

used to assess the transient development of pathlines 

or zones of transport. 

An additional limitation is that particle tracking 

in an heterogeneous carbonate aquifer (Biscayne aquifer) containing cavernous and vuggy porosity or preferential flow zones may be of limited value. Groundwater flow in carbonate aquifers is broadly controlled 

by hydraulic gradient, but the actual flow paths are 
Summary 53

constrained by a rock fabric that has been subject to 

diagenetic alteration, dissolution, and tectonic stress 

(fractures). Numerical flow models in combination 

with particle tracking in karstic aquifers may be used 

to delineate a zone of transport or zone of contribution, 

but realistic field conditions are probably poorly 

represented. 

SUMMARY

On the basis of a rapid rise in population and 

urban development in Palm Beach County, Fla., 

during the last decade, the demand for potable water is 

expected to increase 115 percent between 1990 and 

2010. Increased demand on public-water supply has 

resulted in the installation of additional supply wells 

with an accompanying need to update the Palm Beach 

County wellhead protection model. 

A TMR process was used to construct an 

embedded flow model and combined with particle 

tracking to delineate contributing areas to supply 

wells. Model input and output files were then coupled 

with a GIS. An embedded flow model of the Boca 

Raton well field was constructed using input and 

output file data from a preexisting large area, threedimensional, calibrated MODFLOW ground-water 

flow model that simulated flow within the surficial 

aquifer system in Palm Beach County. An ArcView 

GUI for MODTMR was developed to accelerate the 

process to construct MODFLOW model input files. 

The ArcView GUI, AvHDRD, was prepared to 

process dynamically segmented canal coverage data 

and was used in the MODFLOW River package. 

A third ArcView GUI extension, AvWELL Refiner, 

was constructed to process well point coverage data 

for purposes of constructing MODFLOW Well 

package data sets. 

Mean water levels between January 1988 and 

June 1990 were used to simulate steady-state flow in 

the Boca Raton well field. Simulation of steady-state 

ground-water flow within the embedded flow model 

of the Boca Raton well field shows that recharge 

(58 percent) is the major source of water to the system. 

Other large budget inflow components include river 

leakage (29 percent) and prescribed-flux boundaries 

(10 percent). Major outflow components are well 

discharge (55.9 percent), river leakage (27.2 percent), 

prescribed head (10.4 percent) and prescribed flux 

(6.5 percent) boundaries. Evapotranspiration represented less than 1 percent of the total outflow from the 

local system; this is attributed to regionally calibrated 

evapotranspiration parameters in which simulated head 

lies below the extinction depth.

The model appears most sensitive to reductions 

in the vertical conductivity of layers 3 and 4 (Biscayne 

aquifer) and increases in recharge rates and in the 

hydraulic conductivity of layer 1. The model is insensitive to changes in evapotranspiration; transmissivity 

in layers 2, 3, and 5; and variations in vertical conductivity in layers 1 and 2. Canal (river) leakance adjustments were made to locally improve calibration results 

in some areas.

 Backward particle tracking was conducted 

using MODPATH to identify flow paths from selected 

municipal supply wells and for purposes of estimating 

time of travel. MODTOOLS was used to translate flow 

and particle-tracking model output to GIS and to map 

contributing recharge areas and zones of transport. 

A pathline analysis was conducted in which water 

particles were allowed to pass through weak sinks. 

Particle paths suggest that supply wells located in the 

central and western parts of the Boca Raton well field 

area are recharged, in part, by ground water that moves 

west and northwest. Coastal wells appear to be 

recharged by water that enters the system closer to the 

supply wells. Zones of transport for 30, 210, and 500 

days were constructed using model output data and 

placed into a GIS. Sparse porosity data are available in 

the Boca Raton well field area. Porosity distributions 

were varied to evaluate the effect of this parameter on 

zones of transport. In general, a zone of transport for a 

supply well is greater in areal extent if a lower porosity 

estimate is assumed.

REFERENCES CITED

Adams, Karin, 1992, A three-dimensional finite difference 

ground water flow model of the surficial aquifer system 

in Martin County, Florida: West Palm Beach, South 

Florida Water Management District Technical Publication 92-02, 220 p.

Anderson, M.P., and Woessner, W.W, 1992, Applied groundwater modeling--simulation of flow and advective transport: San Diego, Calif., Academic Press, 381 p.
54 Approach for Delineation of Contributing Areas and Zones of Transport to Selected Public-Supply Wells Using a Regional 

Ground-Water Flow Model, Palm Beach County, Florida

Bailey, Z.C., 1993, Hydrology of the Jackson, Tennessee 

area and delineation of areas contributing ground water 

to the Jackson well fields: U.S. Geological Survey 

Water-Resources Investigations Report 92-4146, 54 p.

Bair, E.S., and Roadcap, G.S., 1992, Comparison of flow 

models used to delineate capture zones of wells: 

1. Leaky-confined fracture-carbonate aquifer: Groundwater, v. 30, no. 2, p. 199-211.

Barlow, P.M., 1989, Delineation of contributing areas to 

public supply wells in stratified glacial-drift aquifers, 

in Protection of ground water from the bottom up--

Local responses to wellhead protection: U.S. Environmental Protection Agency Conference Proceedings, 

October 2-3, 1989, Danvers, Mass., p. 145-164.

------- 1995, Particle-tracking analysis of contributing area of 

public-supply wells in simple and complex flow systems, Cape Cod, Massachusetts: U.S. Geological Survey Water-Supply Paper 2434, 66 p.

Buxton, H.T., and Reilly, T.E., 1986, A technique for analysis of ground-water systems of regional and subregional 

scales applied to Long Island, New York: U.S. Geological Survey Water Supply Paper 2310, p. 129-142.

Camp, Dresser, and McKee, Inc., 2000, City of Boca Raton 

Water Systems Master Plan Update for the City of Boca 

Raton Utilities Services Department.

Dames and Moore, Inc., 1986, Wellfield protection modeling 

study, Palm Beach County, Florida: Report for Board of 

County Commissioners, 29 p.

Federal Register Notice, October 11, 1979, v. 44, no. 198.

Fischer, J.N., Jr., 1980, Evaluation of a cavity-riddled zone 

of the shallow aquifer near Riviera Beach, Palm Beach 

County, Florida: U.S. Geological Survey Water 

Resources Investigations Report 80-60, 39 p.

Fish, J.E., 1988, Hydrogeology, aquifer characteristics, and 

ground-water flow of the surficial aquifer system, Broward County, Florida: U.S. Geological Survey WaterResources Investigation 87-4034, 92 p.

Garza, R., and West, C.T., 1995, Documentation and guidelines for the application of telescoped models to simulate ground-water flow in coastal Georgia and adjacent 

parts of Florida and South Carolina: U.S. Geological 

Survey Water Resources Investigations Report 94-4091, 

49 p.

Harbaugh, A.W., 1990, A computer program for calculating 

subregional water budgets using results from the U.S. 

Geological Survey modular three-dimensional groundwater flow model: U.S. Geological Survey Open-File 

Report 90-392, 46 p. 

Harbaugh, A.W., and McDonald, M.G., 1996, User’s documentation for MODFLOW-96, an update to the U.S. 

Geological Survey modular finite-difference groundwater flow model: U.S. Geological Survey Open-File 

Report 96-485, 56 p.

Hutchinson, C.B., 1990, Analysis of ground-water flow in 

the AS-sand aquifer at Paramaribo, Surname, South 

America: U.S. Geological Survey Water-Resources 

Investigations Report 90-4036, 65 p.

Kane, R.L., 1992a, Altitude of the water table in the surficial 

aquifer system, shallow zone, in eastern Palm Beach 

County, Florida, May 1-5, 1989: U.S. Geological Survey Open-File Report 92-86, 1 sheet. 

------- 1992b, Potentiometric surface of the surficial aquifer 

system, deep zone, in eastern Palm Beach County, Florida, May 1-5, 1989: U.S. Geological Survey Open-File 

Report 92-102, 1 sheet. 

Klein, Howard, and Hull, J.E., 1978, Biscayne aquifer, 

southeast Florida: U.S. Geological Survey Water 

Resources Investigations Report 78-107, 52 p.

Land, L.F., 1975, Effects of lowering interior canal stages on 

salt-water intrusion into the shallow aquifer in southeast 

Palm Beach County, Florida: U.S. Geological Survey 

Open-File Report 75-74, 59 p.

------- 1977, Ground-water resources of the Riviera Beach 

area, Palm Beach County, Florida: U.S. Geological Survey Water-Resources Investigations Report 77-47, 38 p.

Land, L.F., Rodis, H.G., and Schneider, J.J., 1973, Appraisal 

of the water resources of eastern Palm Beach County, 

Florida: Tallahassee, Florida Bureau of Geology Report 

of Investigations No. 67, 64 p. 

Leake, S.A., and Claar, D.V., 1999, Procedures and computer programs for telescopic mesh refinement using 

MODFLOW: U.S. Geological Survey Open-File Report 

99-238, 53 p.

Leake, S.A., and Lilly, M.R., 1997, Documentation of a 

computer program (FHB1) for assignment of transient 

specified-flow and specified-head boundaries, in Applications of the Modular Finite-Difference Ground-Water 

Flow Model (MODFLOW): U.S. Geological Survey 

Water-Resources Investigations Report 97-571, 50 p.

McDonald, M.G., and Harbaugh, A.W., 1988, A modular 

three dimensional finite difference ground-water flow 

model: Techniques of Water-Resources Investigations of 

the U.S. Geological Survey, book 6, chap. A1, 586 p.

Merritt, M.L., 1996, Numerical simulation of a plume of 

brackish water in the Biscayne aquifer originating from 

a flowing artesian well, Dade County, Florida: U.S. 

Geological Survey Water-Supply Paper 2464, 74 p.

Miller, R.T., and Voss, C.I., 1987, Finite-difference grid for a 

doublet well in an anisotropic aquifer: Ground Water, 

v. 24, no. 4, p. 490-496.

Miller, W.L., 1985a, Altitude of water table, surficial aquifer, 

Palm Beach County, Florida, April 24-26, 1984: U.S. 

Geological Survey Open File Report 85-336, 1 sheet.

------- 1985b, Altitude of water table, surficial aquifer, Palm 

Beach County, Florida, November 9-14, 1984: U.S. 

Geological Survey Open File Report 85-637, 1 sheet.
References Cited 55

------- 1987, Lithology and base of the surficial aquifer system, Palm Beach County, Florida: U.S. Geological Survey Open File Report 86-4067, 1 sheet.

------- 1988, Description and evaluation of the effects of 

urban and agricultural development of the surficial aquifer system, Palm Beach County, Florida: U.S. Geological Survey Water-Resources Investigations Report 

88-4056, 58 p.

Morrissey, D.J., 1989, Estimation of the recharge area contributing water to a pumped well in a glacial-drift, rivervalley aquifer: U.S. Geological Survey Water-Supply 

Paper 2338, 41 p.

Orzol, L.L., 1997, User’s guide for MODTOOLS – computer programs for translating data of MODFLOW and 

MODPATH into geographic information system files: 

U.S. Geological Survey Open-File Report 97-240, 86 p.

Orzol, L.L, and Truini, Margot, 1999, Evaluation of factors 

that influence estimated zones of transport for six 

municipal wells in Clark County, Washington: U.S. 

Geological Survey Water-Resources Investigations 

Report 97-4224, 65 p.

Parker, G.G., 1951, Geologic and hydrologic factors in the 

perennial yield of the Biscayne aquifer: Journal of the 

American Water Works Association, v. 43, no. 2, 

p. 817-834.

Parker, G.G., Ferguson, G.E., Love, S.K., and others, 1955, 

Water resources of southeastern Florida, with special 

reference to geology and ground water of the Miami 

area: U.S. Geological Survey Water-Supply Paper 1255, 

965 p.

Pollock, D.W., 1989, Documentation of computer programs 

to compute and display pathlines using results from the 

U.S. Geological Survey modular three dimensional 

finite-difference ground-water flow model: U.S. Geological Survey Open-File Report 89-381, 188 p.

------- 1994, User’s guide for MODPATH/MODPATHPLOT, Version 3: A particle tracking post-processing 

package for MODFLOW, the U.S. Geological Survey 

finite-difference ground-water flow model: U.S. Geological Survey Open File Report 94-464, 234 p.

Prickett, H.L., Naymik, T.G., and Lonnquist, C.G., 1981, 

A “random walk” solute transport model for selected 

groundwater quality evaluations: Illinois State Water 

Survey Bulletin 65, 103 p.

Reese, R.S., and Cunningham, K.J., 2000, Hydrogeology of 

the gray limestone aquifer in southern Florida: U.S. 

Geological Survey Water-Resources Investigations 

Report 99-4213, 244 p. 

Reilly, T.R., and Pollock, D.W., 1993, Factors affecting areas 

contributing recharge to wells in shallow aquifers: U.S. 

Geological Survey Water Supply Paper 2412, 21 p.

Restrepo, J.I., Bevier, Cindy, and Butler, David, 1992, 

A three-dimensional finite-difference ground water flow 

model of the surficial aquifer system, Broward County, 

Florida: West Palm Beach, South Florida Water Management District Technical Publication 92-05, 262 p.

Rodis, H.G., and Land, L.F., 1976, The shallow aquifer--

A prime freshwater resource in eastern Palm Beach 

County, Florida: U.S. Geological Survey Water 

Resources Investigations Report 76-21, 12 p.

Russell, G.M., and Wexler, E.J., 1993, Hydrogeology and 

simulation of ground-water flow near the Lantana Landfill, Palm Beach County, Florida: U.S. Geological Survey Water-Resources Investigations Report 92-4107, 

55 p.

Scott, W.B., 1977, Hydraulic conductivity and water quality 

of the shallow aquifer, Palm Beach County, Florida: 

U.S. Geological Survey Water-Resources Investigations Report 76-119, 22 p.

Scott, W.B., Land, L.F., and Rodis, H.G., 1977, Saltwater 

intrusion in the shallow aquifer in Palm Beach and 

Martin Counties, Florida: U.S. Geological Survey 

Water-Resources Investigations Report 76-135, 1 sheet.

Shine, M.J., Padgett, D.G.J., and Barfknecht, W.M., 1989, 

Ground water resource assessment of eastern Palm 

Beach County, Florida: West Palm Beach, South Florida 

Water Management District Technical Publication 89-4, 

pt. I, 372 p.

Snyder, D.T., Wilkinson, J.M., and Orzol, L.L., 1998, Use of 

a ground-water flow model with particle tracking to 

evaluate ground-water vulnerability, Clark County, 

Washington: U.S. Geological Survey Water-Supply 

Paper 2488, 63 p.

Sonenshein, R.S., 1995, A hydrogeologic approach to identify land uses that overlie ground-water flow paths, Broward County, Florida: U.S. Geological Survey WaterResources Investigations Report 94-4167, 59 p.

South Florida Water Management District, 1998, Upper East 

Coast water supply plan: West Palm Beach, South Florida Water Management District Planning Document, 

v. 1, 132 p.

Swayze, L.J., and Miller, W.L., 1984, Hydrogeology of a 

zone of secondary permeability in the surficial aquifer 

of eastern Palm Beach County, Florida: U.S. Geological 

Survey Water-Resources Investigations Report 83-4249, 

38 p.

Townley, L.R., and Wilson, J.L., 1980, Description of 

user’s manual for a finite-element aquifer flow model 

AQUIFEM-1: Technical Report No. E252, Ralph 

Parsons Laboratory for Water Resources and Hydrodynamics, M.I.T., Cambridge, Mass., 294 p.

U.S. Environmental Protection Agency, 1987, Guidelines for 

delineation of wellhead protection areas: Washington, 

D.C., [variously paged].
56 Approach for Delineation of Contributing Areas and Zones of Transport to Selected Public-Supply Wells Using a Regional 

Ground-Water Flow Model, Palm Beach County, Florida

Ward, D.S., Buss, D.R., Mercer, J.W., and Hughes, S.S., 

1987, Evaluation of a groundwater corrective action at 

the Chem-Dyne hazardous waste site using a telescope 

mesh refinement modeling approach: Water Resources 

Research, v. 23, no. 4, p. 603-617.

Wilsnack, Mark, 1998, GIS techniques for incorporating 

surface water features into MODFLOW models: West 

Palm Beach, South Florida Water Management District 

Hydrologic Systems Modeling Division Planning 

Department, 20 p.

Yan, J.J., Bevier, Cindy, and Smith, K.A., 1995, Revision 

and recalibration of the three dimensional ground water 

flow model of Palm Beach County, Florida: West Palm 

Beach, South Florida Water Management District Technical Memorandum DRE-322, 214 p.

Zarriello, P.J., 1993, Determination of the contributing area 

to six municipal ground water supplies in the Tug Hill 

glacial aquifer of northern New York, with emphasis on 

the Lacona-Sandy Creek well field: U.S. Geological 

Survey Water-Resources Investigations Report 90-4145, 

51 p. 
APPENDIX I

Installation and Instructions for 

AvMODTMR, AvHDRD, and AvWELL Refiner
2

INSTALLATION AND INSTRUCTIONS FOR AvMODTMR

To install:

1. Create a folder for the AvMODTMR files and set an environment variable named 

“AVMODTMR” to its path, for example:

D:\modtmr\tmr-gui

2. Create a folder named “images” and another named “legends” in the folder created in step 1:

D:\modtmr\tmr-gui\images

D:\modtmr\tmr-gui\legends

3. Expand AvMODTMR zip file, and place the following files in the corresponding folders:

avmodtmr.avx~ESRI\AV_GIS30\ARCVIEW\EXT32\

water_banner1.gifin “images” folder 

fhb.avl, locgrid.avl, reggrid.avlin “legends” folder

4. Create a file named avmodtmr.ini (or change the one provided in the AvMODTMR zip file) so it 

contains one line for each of the paths to: the legends, the images and the MODTMR executable 

(modtmr.exe) file in the following format:

theLegendPath=D:\modtmr\tmr-gui\avmodtmracc\legends

theImagePath=D:\modtmr\tmr-gui\avmodtmracc\images

theExePath=D:\modtmr\tmrprogs

Place the avmodtmr.ini file in the folder indicated by the AVMODTMR environment variable.

General information:

1. ArcView version 3.2 is required to run AvMODTMR.

2. AvMODTMR can be used to create input files for use with the USGS MODTMR program.

3. The regional grid must be in an ArcView shapefile format. A MODFLOW grid named 

“reg_grid_pol” in ArcView shapefile format is provided in the sample dataset in this CD1 in the 

“covers” folder under “data.” A MODFLOW grid coverage (in ArcInfo format) can be converted 

to an ArcView shapefile by adding the coverage as a theme in ArcView and saving it as a shapefile, using the “Theme” > “Convert to Shapefile...” menu choice. The Column, Row, and 

Seqnum fields must be integers and they must be named, respectively, “Col,” “Row,” and 

“Seqnum.” Seqnum is the sequential number of cells (of layer 1), starting with number 1 at row 1, 

column 1, incrementing by one while moving along the columns in the first row, and continuing 

the same sequence for each successive row until reaching the last column of the last row.

1

The CD containing the dataset and executable files is available upon request from the Miami Subdistrict office (U.S. Geological

Survey, 9100 N.W. 36th Street, Suite 107, Miami, FL 33178). For further information, call (305) 717-5800.
3

4. The regional ground-water flow simulation must have been completed using MODFLOW-96 as 

specified in Leake, S.A., and Claar, D.V., 1999, Procedures and Computer Programs for Telescopic Mesh Refinement, USGS/OFR 99-238. Additionally, the cell-by-cell flow and the heads 

files must use the file extensions “.cbc” and “.hed”, respectively. A MODFLOW regional groundwater flow simulation is provided in the sample dataset of this CD in the “data” folder under 

“models”.

5. MODTMR allows for vertical rediscretization of layers in the input file, but AvMODTMR does 

not provide for manipulation of bottom elevations for the local model. However, if needed, you 

may be able to import the local model input datasets created by MODTMR into a

MODFLOW preprocessing software package to modify the layer elevations.

6. MODTMR allows for different distance units to be used for the local model. However, 

AvMODTMR requires that the distance units for the local model be the same as for the regional 

model. Because GIS requires the use of a single map projection for both the regional and local 

model grids, it follows that the distance units should be the same for both grids. This is not a 

restriction, but rather a safeguard.

To run:

1. Start ArcView. Open an existing project or create a new one.

2. Click on “File” > “Extensions...” to open the “Extensions” window. Load the extension named 

“ArcView MODTMR Extension” by selecting it so that a check mark appears next to the name.

3. Go to the project window and select an existing view or create a new one. (Make sure “Views” is 

the selected object in the vertical scroll bar of the project window). To open an existing view, 

select it in the project window and click “Open.” To create a new View, click on the “New” button.

4. With a View window active, go to the button bar and press the AvMODTMR launch button:

If the ArcView project has not been saved, a prompt will appear requiring to do so.

5. A prompt will immediately appear to locate the Regional Grid, which is a polygon theme of the 

regional model grid (see item 1 under “General Information” above). Browse to the location of 

the regional grid theme and select it. The regional model grid theme will appear on the View, and 

the AvMODTMR dialog will open. The remaining steps refer to the AvMODTMR dialog unless 

they specify otherwise.

6. Load the regional simulation name file by clicking on the "BROWSE..." button next to the 

“Regional Model Name” text box at the top of the dialog box. Browse to the location of the name 

file (*.nam). Basic information about the regional model will be posted in the area labeled 

“REGIONAL MODEL” in the top part of the dialog.
4

7. In the “LOCAL MODEL” area of the dialog, enter a name for the local simulation, enter a unit 

number on which to process the FHB package, and select the “All Packages” option (if creating 

all of the different MODFLOW input files for the local model). Then select the Time Units for the 

local model (years, days, hours, minutes, or seconds).

8. Create the local grid theme. The user may choose from either of two methods to create the local 

grid theme. If using the “Create Local Grid” method, the user must have all of the following 

parameters cited below to define the local grid. Click the “Create Local Grid...” button to bring 

up the “Defining Local Grid” dialog, and enter values in the respective boxes:

a. X and Y coordinates of the grid origin (extreme corner of row 1, column 1 cell),

b. Rotation angle about the grid origin,

c. Number of rows,

d. Row height,

e. Number of columns,

f. Column width.

g. Clicking on the “Preview” button will draw an outline of the local grid under the current settings. Adjust the values if desired and click on “Apply” or “OK” to create the local grid.

The second method to create the local grid is to use the “Local Grid Wizard” to define the local

grid graphically:

a. Click on the “Local Grid Wizard” button to bring up the “Local Grid Wizard” dialog.

b. Click on the "Draw Study Area" tool. Go to the view, and digitize a study area polygon, which 

bounds the area of interest for the local model. The “Delete” button can be used to delete the 

study area polygon and start over. Use the “Move”/“Reshape” buttons to adjust the location/

shape of the study area polygon, if desired.

c. The slope of the orientation line will be used to align the local model grid. Click on the "Draw 

Rotation" tool. Return to the view and draw a rotation line for indicating the direction for orienting the local grid. This is done by clicking once in the "upstream" side of the study area 

polygon, and then a second time on the "downstream" side. The “Delete” button can be used 

to delete the rotation line and start over. The alignment of the rotation line can be changed 

with the “Adjust Rotation” tool by moving its endpoints to new locations.

d. Enter values in the "Row Size" and "Column Size" boxes. The extent of the local grid may be 

previewed by clicking on the “Preview” button. Click “OK” to create the local grid, and enter 

a name for the local grid at the prompt. The local grid will then be created and added to the 

View.

Creating the local grid may take several minutes, depending on the number of cells and on the 

computer being used.

Regardless of the method used to create the local grid, the FHB theme (which contains the userdefined boundary conditions for the vertical faces of the local grid) will also be created and added 

to the View. By default, all of the boundary conditions will be initially set to specified flow and 

will appear blue. The user will be allowed to specify the boundary conditions in step 10.

Once you have created the local grid theme, you can modify it (its orientation, origin location, as 
5

well as the number and size of the rows and columns), by clicking on the “Modify Local Grid...” 

button that now appears in place of the “Create Local Grid...” button. The local grid may also be 

deleted by clicking on the “Delete Local Grid” button and then recreated by either of the two 

methods described above. Modifying the width and/or height of the local grid will result in the 

boundary conditions being reset to the default value of specified flow (see step 10 below); the 

only modifications to the local grid that allow the set boundary conditions to remain are rotation 

and translation.

9. Select the layers to be used. Only use this if the local model vertical domain is to differ from that 

of the regional model (that is, a subset of the regional model layers will be used in the local 

model). Click on the “Which Layers To Use...” button to open the “Select Layers to Use” window. To change the layers being used, click and drag to select them. Register your selection by 

clicking “Apply” or “OK” to close the window as well.

10. Designate the boundary conditions (BCs) for the local model. Click on the "Set Layer BCs..." 

button. The “Set Layer Boundary Conditions” window will appear. By default, all boundary conditions are initially set to specified flow. They are shown in blue in the view, whereas specified 

head cells are displayed in red. Use the "Specified Head" or "Specified Flow" tools to change the 

boundary conditions for the desired layers. Follow these steps to change the BCs for each layer:

a. Select the layer on the list box.

b. Choose the tool of the desired BC: either specified flow or specified head.

c. Apply the tool onto the view over the cells to be changed. Clicking on a single cell will change 

its BC. To change the BC of multiple adjacent cells, click-and-drag a rectangle with the 

pointer: all the underlying cells will take on the value of the selected tool.

d. Repeat for all desired layers.

e. Click on “OK” button to dismiss the window. Respond “Yes” to confirmation pop-up window 

to save your changes.

11. Create the MODTMR input file by clicking on the "Build MODTMR Input File." Save it in the 

same directory as the regional MODFLOW model data set. A window will appear showing the 

contents of the MODTMR input file. Click on “OK” to dismiss it. A second pop-up window will 

prompt you to save the file to disk. Hit “Yes” if you wish to save it and indicate the location. 

Inspect the contents of the file for adherence to the MODTMR input file requirements.

12. Open a DOS window and run MODTMR with the MODTMR input file created in step 11. The 

MODFLOW dataset for the local simulation will be created.
6

INSTALLATION AND INSTRUCTIONS FOR AvHDRD

To install:

Copy the file AvHDRD.avx into the Ext32 folder of the ArcView installation directory (usually 

C:\ESRI\AV_GIS30\ARCVIEW\EXT32\).

General information:

1. ArcView version 3.2 is required to run AvHDRD.

2. AvHDRD can be used to create River and Drain input files for use with the USGS

MODFLOW program.

3. AvHDRD can be used only for steady-state conditions.

4. All rivers and drains are assumed to be in the top model layer (that is, no penetration into the second layer).

5. A MODFLOW-96 data set output from MODTMR containing a River and/or Drain input file.

6. A dynamically segmented GIS dataset of the area being modeled is required consisting of a route 

coverage (representing the river and/or drain hydrographic features) along with related tables 

(“event” tables for each of the conductance properties). A sample dataset is provided in this CD 

(available upon request from the USGS Miami Subdistrict office) in the folder “data.” A route 

coverage named “Canals” is located in the “covers” folder, and an event table for each conductance property is located in the “tables” folder.

7. A MODFLOW grid in ArcView shapefile format is required. A MODFLOW grid in ArcView 

shapefile format is provided in the sample dataset in the “covers” folder under “data.” A MODFLOW grid coverage (in ArcInfo format) can be converted to an ArcView shapefile by adding the 

coverage as a theme in ArcView and saving it as a shapefile, using the “Theme” > “Convert to 

Shapefile...” menu choice. The Column and Row fields must be integers and they must be named 

“Col” and “Row,” respectively.

8. The files created contain conductance values computed from the event tables overlaid with the 

local grid indicated by the user. Thus, the conductance values in the input files created by this 

program may not be consistent with those from the calibrated regional model from which 

MODTMR created the original River and/or Drain input files.

9. The names of the value fields contained in the conductance property event tables are hard coded, 

and they must be named as follows: Bottom Elevation: "Botel;" Bottom Width: "Botwid;" Sediment Thickness: "Thick;" Sediment Hydraulic Conductivity: "K;" Classification of Rivers/

Drains: "classify;" Stage: "Stage" (only for River input files). All fields are numeric, with the 

exception of “classify,” which is alphanumeric. Use a value of “RIVER” for rivers, and “DRAIN” 

for drains in the “classify” field.

10. Any existing River or Drain input files with the same root name located in the root directory will 

be overwritten. In order to preserve an existing file, create a duplicate with a different name, or 

copy it to another location. The original files should not be deleted or renamed so that the header 

information can be duplicated in the files output by AvHDRD.
7

11. Any reaches for which data were missing will be assigned conductance values of - 9999. Also, in 

the "comments" field in the table, a comment will be written in the input file (following a “#” 

character) indicating which parameter had missing data and over what interval. If the "Write package file" option is used, these values of -9999 will be written to the river or drain input file.

To run:

1. Start ArcView and add the AvHDRD extension to the project. Choose “Extensions...” from the 

File menu and check on the AvHDRD extension.

2. Add the route coverage as a theme to a View.

3. Add the local grid theme into the View.

4. Add the event tables for the various conductance properties to the ArcView Project. The event 

tables in the sample dataset consist of: botel.dbf (bottom elevation); botwid.dbf (bottom width); 

classify.dbf (classifies features into rivers or drains); sed_k.dbf (sediment hydraulic conductivity); 

thick.dbf (sediment thickness); and stage.dbf (stage for rivers).

5. Add each event table to the View as an event theme. For each event table:

a. Open the "Add Event Theme" window. Click on “View” > “Add Event Theme...”

b. Click on the second button at the top of the window (the one that looks like a ruler).

c. Select the Route theme and the Route field. In the sample dataset the Route field is "Name,"

d. Choose either “points” or “lines” (choose points for those events where the property varies 

linearly from one point to the next, and lines for those events where the property is constant 

throughout entire intervals).

e. Select the event table, the “Event field” in the table. In the sample dataset, the Event field is 

“Name.”

f. Select location field(s). For “points,” set the "Location field" to be “Measure”; for the linear 

events, set the "From field" to be “Measure” and leave the “To field” as “<None>”.

6. Open the "Head Dependent River & Drain Package Writer" dialog by clicking on “River or 

Drain...” from the “MODTMR” menu, or by clicking on the AvRDHD launch button:

The remaining steps refer to the "Head Dependent River & Drain Package Writer" dialog.

7. Load the name file by clicking on the "BROWSE..." button and browse to the location of the 

name file (*.nam). The path to files and the root name for the simulation will be automatically 

entered in the “Path to files” and “Root Name” text boxes, respectively.

8. Select the “Grid Theme” and “Route Theme” in their respective list boxes near the upper right 

corner of the dialog.
8

9. Enter a minimum segment length. A segment is defined as a portion of a reach over which all 

parameters are either constant or vary linearly. However, when conductance property locations 

are too close to one another, it is practical to consider them to be at the same position. The minimum segment length is used as a criterion to identify these cases so that a new segment is not created. Care must be taken when two sample points very close to one another are purposely used to 

represent abrupt changes in a parameter. For example, the bottom width of a man-made channel 

can change in a very short distance. If this exists in the dataset, an amount smaller than this 

should be used as the minimum segment length.

10. In the area of the dialog entitled “Event Tables,” indicate each property by choosing the appropriate event table.

11. In the “Select package” area of the dialog, select either "River" or "Drain." The unit number for 

writing cell-by-cell flow terms (as indicated in the original River or Drain file) will be automatically copied to the adjacent text box, under “CBC Unit No.”

12. Check the "Write package file" checkbox to create the package file on disk.

13. Click on "Process" to finish. A package event table will be created for the selected package and 

added as a theme to your view. The package event table will be named like the root name of the 

simulation, with "_riv" or "_drn" appended, and it contains the data required by the package. If 

the user has checked the option "Write package file," a fixed-format ASCII input file will be created in the folder indicated by the “Path to files” and named like the root name of the simulation. 

Comments are inserted at the end of each line, indicating the canal name and the “from” and “to” 

locations along the canal for each reach.
9

INSTALLATION AND INSTRUCTIONS FOR AvWELL Refiner

To install:

Copy the file AvWell.avx into the Ext32 folder of the ArcView installation directory (usually 

C:\ESRI\AV_GIS30\ARCVIEW\EXT32\).

General information:

1. ArcView version 3.2 is required to run AvWELL Refiner.

2. AvWELL Refiner can be used to create well input files for use with the USGS MODFLOW program.

3. Requirements are a point theme of the wells in the model area with a Well_name or Well_id field, 

a Layer field containing the layer where each well pumps (the user must split up the pumpage 

among the layers for any wells that pump from multiple layers), and one Pumpage field for each 

stress period in the simulation containing the pumpage rate for each well.

4. A MODFLOW grid in ArcView shapefile format is required. A MODFLOW grid in ArcView 

shapefile format is provided in the sample dataset in the “covers” folder under “data.” A MODFLOW grid coverage (in ArcInfo format) can be converted to an ArcView shapefile by adding the 

coverage as a theme in ArcView and saving it as a shapefile, using the “Theme” > “Convert to 

Shapefile...” menu choice. The Column and Row fields must be integers, and they must be 

named “Col” and “Row,” respectively.

5. A MODFLOW-96 local simulation output by MODTMR is needed to improve the spatial accuracy of the wells in the WEL file.

6. If an existing well input file with the same root name is located in the root directory it will be 

overwritten. In order to preserve an existing file, create a duplicate with a different name, or copy 

it to another location. The original files should not be deleted or renamed so that AvWell can 

duplicate the header information in the well input file.

To run:

1. Start ArcView and add the AvWELL extension to the project. Choose “Extensions...” from the 

File menu and check on the AvWELL extension.

2. Add the well point theme and the model grid theme.

3. Open the "MODTMR Well Refiner" dialog by clicking on “Well Refiner...” from the 

“MODTMR” menu, or by clicking on the AvWELL launch button:

The remaining steps refer to the "MODTMR Well Refiner" dialog.
10

4. On the dialog, click on the “Browse...” button next to the “Root Name:” text box and browse to 

and select thePFam). The path to files and the number of stress periods (NPER) will be read from 

the BAS file and posted on the dialog.

5. Select the Well Theme. A set of windows will open prompting for a well name (or well ID) field, 

a layer field and one pumpage field for each stress period.

6. In the “Grid theme” list box, select the model grid theme.

7. (Optional) Use the navigate buttons on the form to inspect the well data (Note: to add/change/

delete wells, use ArcView’s feature editing capabilities to modify the well theme).

8. Click on the “Write File” button to create the well file.
APPENDIX II

Documentation of 

AvMODTMR Avenue Scripts
2

'************* U.S. Geological Survey preliminary computer program ************

'******************************************************************************

'************* AvMODTMR.BuildBCTArrays **************

'******************************************************************************

'** Language: ArcView Avenue **

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*=============================================================================

'* Author/Site, Date, Event

'* --------------------------------------------------------------------------

'* Raul D. Patterson Phone: (305) 717-5865

'* U. S. Geological Survey - WRD FAX: (305) 717-5801

'* 9100 NW 36th St., Suite 109

'* Miami, Florida 33178 USA Internet: rdpatter@usgs.gov

'*

'*=============================================================================

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*

'* Disclaimer: 

' Although this program has been used by the U.S. Geological Survey,

' no warranty, expressed or implied, is made by the USGS as to the

' accuracy and functioning of the program and related program

' material nor shall the fact of distribution constitute any such

' warranty, and no responsibility is assumed by the USGS in

' connection therewith.

'*

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*=============================================================================

'

'---VERSION 1.0 AVMODTMR 11MAY2001 9:19 AM

'

'::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'

' .. Purpose: Locates the Local Grid in the View and gets the LML dictionary

' from its object tag. Reads the LML dictionary and creates the FHB Field List

' from the positions of the 0's and 1's (i.e. if at position 3 there's a 1, 

' then the field "FHB_L3" is added to the list). Then, it creates query 

' strings for each of the four faces of the local model ('Col = 1' for the 

' First Col or FCBCT Array, 'Row = NROW2' for the Last Row or LRBCT Array, 

' etc...). An outer loop constructs each BCT Array by selecting the cells that

' satisfy the query,with an inner loop looking up the values for each of the 

' fields in the FHB Field List. While constructing the current BCT Array, when

' the current line hits 80 characters (or when it reaches the length of the 

' Array Size) a New Line chr is inserted to begin a new line. At end of inner 

' loop a check is made to see if the current Array, is a constant array; if it

' is, the array is replaced by "CONSTANT i", where i is 0 or 1. After the inner

' loop, the current BCT Array is appended to theBCTArray.

'

'123456789012345678901234567890123456789012345678901234567890123456789012345678

'get arguments sent:

theView = SELF.Get(0)

theBCTArray = ""

'Locate the Local grid theme and it's BCT theme:

theLocGridTheme = av.Run("AvMODTMR.GetGridTheme", {theView, "L"})

theLocParamList = theLocGridTheme.GetObjectTag

theBCTFTheme = theLocParamList.Get(1)

theBCTFTab = theBCTFTheme.GetFTab

'grab the LML dictionary from the loc theme's obj tag:

theLMLDict = theLocGridTheme.GetObjectTag.Get(5)
3

'Create the BCT Field List

theBCTFieldList = List.Make

for each n in theLMLDict.ReturnKeys

 theFlag = theLMLDict.Get(n)

 if (theFlag = 1) then

 theFieldName = "FHB_L"+n.AsString

 theBCTFieldList.Add(theFieldName)

 end

end

'Create the BCT Array Query String Dictionary:

theBCTArrayQStringDict = Dictionary.Make(10)

theBCTArrayQStringDict.Add(1, "([Col] = 1)")

NCOL2 = theLocParamList.Get(7).AsNumber

theBCTArrayQStringDict.Add(2, "([Col] = "+NCOL2.AsString+" )")

theBCTArrayQStringDict.Add(3, "([Row] = 1)")

NROW2 = theLocParamList.Get(6).AsNumber

theBCTArrayQStringDict.Add(4, "([Row] = "+NROW2.AsString+" )")

'Create BCT Array Dictionary (empty, to be filled below):

for each n in theBCTArrayQStringDict.ReturnKeys

 aBCTArrayString = ""

 

 'set array size for BCTArray:

 theArraySize = Nil

 if ((n = 1) or (n = 2)) then

 theArraySize = NROW2

 elseif ((n = 3) or (n = 4)) then

 theArraySize = NCOL2

 end

 

 'Query the table to select only the current face for processing:

 theBCTFTheme.ClearSelection

 theQString = theBCTArrayQStringDict.Get(n)

 theBCTFTab.Query(theQString, theBCTFTab.GetSelection, #VTAB_SELTYPE_NEW)

 theBCTFTab.UpdateSelection

 

 'Process the entire face, one field at a time, to create the BCT array

 'for this face:

 theValueList = List.Make

 Fcount = 0

 for each aFieldName in theBCTFieldList

 aField = theBCTFTab.FindField(aFieldName)

 Fcount = Fcount + 1

 charCounter = 0

 for each rec in theBCTFTab.GetSelection

 theValue = theBCTFTab.ReturnValue(aField, rec)

 aBCTArrayString = aBCTArrayString + theValue.AsString

 charCounter = charCounter + 1

 if (((charCounter.Mod(theArraySize) = 0) and 

 (Fcount <= (theBCTFieldList.Count - 1))) or

 (charCounter.Mod(80) = 0)) then

 aBCTArrayString = aBCTArrayString + NL

 end

 theValueList.Add(theValue)

 end

 end

 

 'test if min = max; if yes, array is constant, else, create header and append 

 'to beginnig of BCTArrayString:

 theValueList.Sort(TRUE)

 MinValue = theValueList.Get(0)

 MaxValue = theValueList.Get(theValueList.Count - 1)
4

 if (MinValue = MaxValue) then

 aBCTArrayString = "CONSTANT "+MaxValue.AsString

 else 'create a header for the array:

 theArrayHeader = "INTERNAL 1 ("+theArraySize.AsString+"I1) 8"

 aBCTArrayString = theArrayHeader + NL + aBCTArrayString

 end

 

 'append to theBCTArray:

 if (theBCTArray = "") then

 theBCTArray = aBCTArrayString

 else

 theBCTArray = theBCTArray+NL+aBCTArrayString

 end

 

 'go on to process next face,

 

end

theBCTFTheme.ClearSelection

Return theBCTArray
5

'************* U.S. Geological Survey preliminary computer program ************

'******************************************************************************

'************* AvMODTMR.ChangeFHBFlag **************

'******************************************************************************

'** Language: ArcView Avenue **

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*=============================================================================

'* Author/Site, Date, Event

'* --------------------------------------------------------------------------

'* Raul D. Patterson Phone: (305) 717-5865

'* U. S. Geological Survey - WRD FAX: (305) 717-5801

'* 9100 NW 36th St., Suite 109

'* Miami, Florida 33178 USA Internet: rdpatter@usgs.gov

'*

'*=============================================================================

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*

'* Disclaimer: 

' Although this program has been used by the U.S. Geological Survey,

' no warranty, expressed or implied, is made by the USGS as to the

' accuracy and functioning of the program and related program

' material nor shall the fact of distribution constitute any such

' warranty, and no responsibility is assumed by the USGS in

' connection therewith.

'*

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*=============================================================================

'

'---VERSION 1.0 AVMODTMR 11MAY2001 9:19 AM

'

'::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'

' .. Purpose: Sets FHB Boundary Condition Type (BCT) for the FHB Theme. This

' script is called by 'apply' scripts used with tools to either click on a 

' perimeter cell or drag a rectangle to enclose several perimeter cells to 

' change their BCT value. 'theValue' is 0 or 1, depending on the BCT tool 

' being used to call this script: if it is the specified flow tool, then the 

' value is 0, and if it is the specified head tool, it is 1. 'r' is either a

' point or a rectangle sent by the calling script. 'theLayer' is the current

' layer for which the BCT's are being set. 

'

'0123456789012345678901234567890123456789012345678901234567890123456789012345678

theValue = SELF.Get(0)

theView = SELF.Get(1)

r = SELF.Get(2)

theLayer = SELF.Get(3)

theThemes = theView.GetThemes

'Determine which is FHB theme, error out if none exists:

theFHBTheme = NIL

for each T in theThemes

 if ((T.GetObjectTag.Is(List)) and (T.GetObjectTag.Get(0) = "L")) then

 theFHBTheme = T.GetObjectTag.Get(1)

 break

 end

end

if (theFHBTheme = NIL) then

 MsgBox.Error("Error: no FHB theme.", "")

 Return Nil

end
6

if (r.IsNull) then 

 p = theView.GetDisplay.ReturnUserPoint

 if (System.IsShiftKeyDown) then

 op = #VTAB_SELTYPE_XOR

 else

 op = #VTAB_SELTYPE_NEW

 end

 theFHBTheme.SelectByPoint(p, op)

else

 if (System.IsShiftKeyDown) then

 op = #VTAB_SELTYPE_OR

 else

 op = #VTAB_SELTYPE_NEW

 end

 theFHBTheme.SelectByRect(r, op)

end

av.GetProject.SetModified(true)

theVTab = theFHBTheme.GetFTab

theVTab.StartEditingWithRecovery

theFieldName = "FHB_L"+theLayer

theFHBField = theVTab.FindField(theFieldName)

theShapeF = theVTab.FindField("Shape")

for each Rec in theVTab.GetSelection

 theVTab.SetValue(theFHBField, Rec, theValue)

 thePoly = theVTab.ReturnValue(theShapeF, Rec) 

end

theRedrawRect = theFHBTheme.GetSelectedExtent

theFHBTheme.ClearSelection

theView.GetDisplay.InvalidateRect (theRedrawRect)
7

'************* U.S. Geological Survey preliminary computer program ************

'******************************************************************************

'************* AvMODTMR.CreateGrid **************

'******************************************************************************

'** Language: ArcView Avenue **

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*=============================================================================

'* Author/Site, Date, Event

'* --------------------------------------------------------------------------

'* Raul D. Patterson Phone: (305) 717-5865

'* U. S. Geological Survey - WRD FAX: (305) 717-5801

'* 9100 NW 36th St., Suite 109

'* Miami, Florida 33178 USA Internet: rdpatter@usgs.gov

'*

'*=============================================================================

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*

'* Disclaimer: 

' Although this program has been used by the U.S. Geological Survey,

' no warranty, expressed or implied, is made by the USGS as to the

' accuracy and functioning of the program and related program

' material nor shall the fact of distribution constitute any such

' warranty, and no responsibility is assumed by the USGS in

' connection therewith.

'*

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*=============================================================================

'

'---VERSION 1.0 AVMODTMR 11MAY2001 9:19 AM

'

'::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'

' .. Purpose: Creates a polygon grid theme for use in creating MODFLOW

' simulations. Used in this application to create the local grid theme. 

' Requires the X and Y coordinates of the upper left hand corner of the model 

' grid (XCRNR2 and YCRNR2, respectively.), the number of rows and columns 

' (NROW2, NCOL2), and their dimensions (DELR2, DELC2). Note that DELR2 and 

' DELC2 must be constant, but do not need to be the same. Called whenever the 

' local model grid is to be created or re-created (occurs when the dimensions 

' are altered upon modifying it).

'

'0123456789012345678901234567890123456789012345678901234567890123456789012345678

XCRNR2 = SELF.Get(0)

YCRNR2 = SELF.Get(1)

NROW2 = SELF.Get(2)

NCOL2 = SELF.Get(3)

DELR2 = SELF.Get(4)

DELC2 = SELF.Get(5)

theFileName = SELF.Get(6)

theGridFTab = FTab.MakeNew (theFileName, Polygon)

theGridFTab.StartEditingWithRecovery

theRowF = Field.Make ("Row", #FIELD_LONG, 5, 0)

theColF = Field.Make ("Col", #FIELD_LONG, 5, 0)

theSeqnumF = Field.Make ("Seqnum", #FIELD_LONG, 5, 0)

theAreaF = Field.Make ("Area", #FIELD_DOUBLE, 10, 2)

theFieldList = {theAreaF, theRowF, theColF, theSeqnumF}

theGridFTab.AddFields(theFieldList)
8

theShapeF = theGridFTab.FindField("Shape")

'Initialize remaining parameters (those not being sent as arguments):

MaxColLength = NROW2 * DELR2

MaxRowLength = NCOL2 * DELC2

theMaxSeqnum = NROW2 * NCOL2

'Initialize loop counters and accumulators:

theColLength = 0

theRowLength = 0

theRowNum = 0

theColNum = 0

theSeqnum = 0

av.ShowMsg ("Creating Output Grid...")

av.SetStatus(0)

for each i in 1..NROW2

 

 for each j in 1..NCOL2

 

 'update counters:

 theSeqnum = theSeqnum + 1

 PercentDone = (theSeqnum/theMaxSeqnum)*100

 av.SetStatus(PercentDone)

 

 'create corner points for new cell:

 PtA = (XCRNR2 + theRowLength)@(YCRNR2 - theColLength)

 PtB = PtA.Clone

 PtB.Move(DELC2, 0)

 PtC = PtA.Clone

 PtC.Move(DELC2, -DELR2)

 PtD = PtA.Clone

 PtD.Move(0, -DELR2)

 

 'Create new cell with above points:

 aNewCell = Polygon.Make({{PtA, PtB, PtC, PtD}})

 

 'Get parameters

 anArea = aNewCell.ReturnArea

 aNewRec = theGridFTab.AddRecord

 theGridFTab.SetValue(theShapeF, aNewRec, aNewCell)

 theGridFTab.SetValue(theRowF, aNewRec, i)

 theGridFTab.SetValue(theColF, aNewRec, j)

 theGridFTab.SetValue(theSeqNumF, aNewRec, theSeqnum)

 theGridFTab.SetValue(theAreaF, aNewRec, anArea)

 

 theRowLength = theRowLength + DELC2

 

 end

 theRowLength = 0

 theColLength = theColLength + DELR2

end

av.ShowMsg("")

av.ClearStatus

theGridFTab.StopEditingWithRecovery(TRUE)
9

'************* U.S. Geological Survey preliminary computer program ************

'******************************************************************************

'************* AvMODTMR.DlgEditLayerBCs.lbxSelLocalLayer.Select ************

'******************************************************************************

'** Language: ArcView Avenue **

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*=============================================================================

'* Author/Site, Date, Event

'* --------------------------------------------------------------------------

'* Raul D. Patterson Phone: (305) 717-5865

'* U. S. Geological Survey - WRD FAX: (305) 717-5801

'* 9100 NW 36th St., Suite 109

'* Miami, Florida 33178 USA Internet: rdpatter@usgs.gov

'*

'*=============================================================================

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*

'* Disclaimer: 

' Although this program has been used by the U.S. Geological Survey,

' no warranty, expressed or implied, is made by the USGS as to the

' accuracy and functioning of the program and related program

' material nor shall the fact of distribution constitute any such

' warranty, and no responsibility is assumed by the USGS in

' connection therewith.

'*

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*=============================================================================

'

'---VERSION 1.0 AVMODTMR 11MAY2001 9:19 AM

'

'::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'

' .. Purpose: Sets the active layer for modifying BCT's in the FHB Theme.

' Whenever a layer is selected in the dialog, the legend of the FHB Theme is 

' redrawn using that layers' BCT array, which is encoded in the field 

' "FHB_LayN", where N is the layer number.

'

'123456789012345678901234567890123456789012345678901234567890123456789012345678

theView = av.GetActiveDoc

'Find the FHB theme:

theFHBTheme = NIL

theLocTheme = av.Run("AvMODTMR.GetGridTheme", {theView, "L"})

theFHBTheme = theLocTheme.GetObjectTag.Get(1)

'Find the FHBFieldName of current Layer:

theLayer = SELF.GetSelection.Get(0).AsList.Get(3)

theFHBFieldName = "FHB_L"+theLayer

theOrigFHBLegend = theFHBTheme.GetLegend

aFHBLegend = Legend.Make(#SYMBOL_FILL)

aFHBLegend.Unique (theFHBTheme, theFHBFieldName)

aFHBLegend.SetClassInfo(0, theOrigFHBLegend.ReturnClassInfo(0))

aFHBLegend.SetClassInfo(1, theOrigFHBLegend.ReturnClassInfo(1))

'Reset the TOC and redraw themes:

theFHBTheme.SetLegend(aFHBLegend)

theFHBTheme.SetName(theLocTheme.GetName+" FHB BCs, Layer "+theLayer.AsString)

theFHBTheme.Invalidate(FALSE)
10

'************* U.S. Geological Survey preliminary computer program ************

'******************************************************************************

'************* AvMODTMR.DlgEditLayerBCs.Open **************

'******************************************************************************

'** Language: ArcView Avenue **

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*=============================================================================

'* Author/Site, Date, Event

'* --------------------------------------------------------------------------

'* Raul D. Patterson Phone: (305) 717-5865

'* U. S. Geological Survey - WRD FAX: (305) 717-5801

'* 9100 NW 36th St., Suite 109

'* Miami, Florida 33178 USA Internet: rdpatter@usgs.gov

'*

'*=============================================================================

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*

'* Disclaimer: 

' Although this program has been used by the U.S. Geological Survey,

' no warranty, expressed or implied, is made by the USGS as to the

' accuracy and functioning of the program and related program

' material nor shall the fact of distribution constitute any such

' warranty, and no responsibility is assumed by the USGS in

' connection therewith.

'*

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*=============================================================================

'

'---VERSION 1.0 AVMODTMR 11MAY2001 9:19 AM

'

'::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'

' .. Purpose: loads the 'Select local layer' list box with lines of the form

' "Layer n (Reg.Lay m )". The LML array is used to indicate which regional

' model layers are to be included in the local model. The LMLDict is a 

' dictionary that contains values 1..n, corresponding to the n layers in the

' regional model, the keys are either 0's or 1's, the former being the flag

' indicating that the regional model layer will be used in the local model. m 

' is a sequential number for the local model layers. Created from LMLDict 

' values that are not 0.

'

'0123456789012345678901234567890123456789012345678901234567890123456789012345678

theView = av.GetActiveDoc

'Locate the Local grid theme:

theLocGridTheme = av.Run("AvMODTMR.GetGridTheme", {theView, "L"})

theLMLDict = theLocGridTheme.GetObjectTag.Get(5)

theRegLays = theLMLDict.ReturnKeys

theRegLays.Sort(TRUE)

'_LocalLayDict = Dictionary.Make(100)

aLocalLayList = List.Make

counter = 1

for each aLay in theRegLays

 if (theLMLDict.Get(aLay) <> 0) then

 aLocalLayer = "Layer "+counter.AsString+" (Reg.Lay "+aLay.AsString++")"

 theValue = aLay

 '_LocalLayDict.Add(aLocalLayer, aLay)

 counter = counter + 1
11

 aLocalLayList.Add(aLocalLayer)

 end

end

SELF.FindByName("lbxSelLocalLayer").DefineFromList (aLocalLayList)
12

'************* U.S. Geological Survey preliminary computer program ************

'******************************************************************************

'************* AvMODTMR.DlgLayers.Open **************

'******************************************************************************

'** Language: ArcView Avenue **

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*=============================================================================

'* Author/Site, Date, Event

'* --------------------------------------------------------------------------

'* Raul D. Patterson Phone: (305) 717-5865

'* U. S. Geological Survey - WRD FAX: (305) 717-5801

'* 9100 NW 36th St., Suite 109

'* Miami, Florida 33178 USA Internet: rdpatter@usgs.gov

'*

'*=============================================================================

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*

'* Disclaimer: 

' Although this program has been used by the U.S. Geological Survey,

' no warranty, expressed or implied, is made by the USGS as to the

' accuracy and functioning of the program and related program

' material nor shall the fact of distribution constitute any such

' warranty, and no responsibility is assumed by the USGS in

' connection therewith.

'*

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*=============================================================================

'

'---VERSION 1.0 AVMODTMR 11MAY2001 9:19 AM

'

'::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'

' .. Purpose: Populates the list of choices in the dialog with the currently

' selected layers from the LML Array, stored in the variable LMLDict.

'

'0123456789012345678901234567890123456789012345678901234567890123456789012345678

theView = av.GetActiveDoc

'Locate the Local grid theme:

theLocGridTheme = NIL

for each T in theView.GetThemes

 if ((T.GetObjectTag.Is(List)) and (T.GetObjectTag.Get(0) = "L")) then

 theLocGridTheme = T

 break

 end

end

theLMLDict = theLocGridTheme.GetObjectTag.Get(5)

theListOfLayers = theLMLDict.ReturnKeys

theListOfLayers.Sort(TRUE)

theTextListOfLayers = {}

aSelectedLayerList = {}

theSelRangeFirstRow = nil

CountNoOfLaysUsed = 0

for each aLay in theListOfLayers

 thisLayerLMLCode = theLMLDict.Get(aLay)

 

 if (thisLayerLMLCode = 1) then
13

 

 'Sets the first layer being used - 1 into theSelRangeOrigin:

 

 if (theSelRangeFirstRow = Nil) then

 theSelRangeFirstRow = aLay - 1

 end

 

 CountNoOfLaysUsed = CountNoOfLaysUsed + 1

 end

 

 aStringLay = "Layer"++aLay.AsString

 theTextListOfLayers.Add(aStringLay)

end

theListBox = SELF.FindByName("lbxLayers")

theListBox.DefineFromList(theTextListOfLayers)

theStartSel = 0@theSelRangeFirstRow

theExtent = 1@CountNoOfLaysUsed

theSelRange = Rect.Make(theStartSel, theExtent)

theListBox.SetSelection (theSelRange, FALSE)

theListBox.ShowCurrent

'Set Listeners of this control to be the "Apply" button in this control:

theListBox.AddListener(SELF.FindByName("lbtApply"))
14

'************* U.S. Geological Survey preliminary computer program ************

'******************************************************************************

'************* AvMODTMR.DlgLocGridWiz.lbtOK.Click **************

'******************************************************************************

'** Language: ArcView Avenue **

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*=============================================================================

'* Author/Site, Date, Event

'* --------------------------------------------------------------------------

'* Raul D. Patterson Phone: (305) 717-5865

'* U. S. Geological Survey - WRD FAX: (305) 717-5801

'* 9100 NW 36th St., Suite 109

'* Miami, Florida 33178 USA Internet: rdpatter@usgs.gov

'*

'*=============================================================================

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*

'* Disclaimer: 

' Although this program has been used by the U.S. Geological Survey,

' no warranty, expressed or implied, is made by the USGS as to the

' accuracy and functioning of the program and related program

' material nor shall the fact of distribution constitute any such

' warranty, and no responsibility is assumed by the USGS in

' connection therewith.

'*

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*=============================================================================

'

'---VERSION 1.0 AVMODTMR 11MAY2001 9:19 AM

'

'::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'

' .. Purpose: Obtains some of the parameters to create the local grid from the 

' text lines in the dialog, and the remaining ones from calling the script

' 'AvMODTMR.MakeOrientedBox'. Then runs the script 'AvMODTMR.MakeLocGridTheme'

' passing it the parameters.

'

'123456789012345678901234567890123456789012345678901234567890123456789012345678

theView = av.GetActiveDoc

'get the Column Width and Row Height from the dialog:

DlgLocGridWiz = SELF.GetDialog

theDELC2 = DlgLocGridWiz.FindByName("txlColWidth").GetText.AsNumber

theDELR2 = DlgLocGridWiz.FindByName("txlRowHeight").GetText.AsNumber

'get the rest of the local grid dimensions from the oriented bounding box:

theLocGridParam = av.Run("AvMODTMR.MakeOrientedBox", {theView, theDELC2, 

 theDELR2})

theNCOL2 = theLocGridParam.Get(0)

theNROW2 = theLocGridParam.Get(1)

theX_coor = theLocGridParam.Get(2)

theY_coor = theLocGridParam.Get(3)

theRotation = theLocGridParam.Get(4)

theRegGridTheme = av.Run("AvMODTMR.GetGridTheme", {theView, "R"})

theFileName = NIL

av.Run("AvMODTMR.MakeLocGridTheme", {theX_coor, theY_coor, theRotation, 

 theNROW2, theDELR2, theNCOL2, theDELC2, theView, theRegGridTheme, 

 theFileName})
15

SELF.GetDialog.Close
16

'************* U.S. Geological Survey preliminary computer program ************

'******************************************************************************

'************* AvMODTMR.DlgLocGridWiz.lbtPreview.Click **************

'******************************************************************************

'** Language: ArcView Avenue **

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*=============================================================================

'* Author/Site, Date, Event

'* --------------------------------------------------------------------------

'* Raul D. Patterson Phone: (305) 717-5865

'* U. S. Geological Survey - WRD FAX: (305) 717-5801

'* 9100 NW 36th St., Suite 109

'* Miami, Florida 33178 USA Internet: rdpatter@usgs.gov

'*

'*=============================================================================

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*

'* Disclaimer: 

' Although this program has been used by the U.S. Geological Survey,

' no warranty, expressed or implied, is made by the USGS as to the

' accuracy and functioning of the program and related program

' material nor shall the fact of distribution constitute any such

' warranty, and no responsibility is assumed by the USGS in

' connection therewith.

'*

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*=============================================================================

'

'---VERSION 1.0 AVMODTMR 11MAY2001 9:19 AM

'

'::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'

' .. Purpose: Draws the preview box for the local grid theme. Calls the script 

' 'AvMODTMR.MakeLocalGridOutline', sending it the parameters obtained by calling 

' 'AvMODTMR.MakeOrientedBox' and by reading the values from the "Row Height" and 

' "Column Width" textlines.

'

'0123456789012345678901234567890123456789012345678901234567890123456789012345678

theView = av.GetActiveDoc

DELC2 = SELF.GetDialog.FindByName("txlColWidth").GetText.AsNumber

DELR2 = SELF.GetDialog.FindByName("txlRowHeight").GetText.AsNumber

theLocGridParameters = av.Run("AvMODTMR.MakeOrientedBox", {theView, DELC2, 

 DELR2})

NCOL2 = theLocGridParameters.Get(0)

NROW2 = theLocGridParameters.Get(1)

XCRNR1 = theLocGridParameters.Get(2)

YCRNR1 = theLocGridParameters.Get(3)

theRotation = theLocGridParameters.Get(4)

H = NROW2 * DELR2

W = NCOL2 * DELC2

av.Run("AvMODTMR.MakeLocalGridOutline", {XCRNR1, YCRNR1, theRotation, H, W})
17

'************* U.S. Geological Survey preliminary computer program ************

'******************************************************************************

'************* AvMODTMR.DlgLocGridWiz.tolDrawStudyArea.Update **********

'******************************************************************************

'** Language: ArcView Avenue **

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*=============================================================================

'* Author/Site, Date, Event

'* --------------------------------------------------------------------------

'* Raul D. Patterson Phone: (305) 717-5865

'* U. S. Geological Survey - WRD FAX: (305) 717-5801

'* 9100 NW 36th St., Suite 109

'* Miami, Florida 33178 USA Internet: rdpatter@usgs.gov

'*

'*=============================================================================

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*

'* Disclaimer: 

' Although this program has been used by the U.S. Geological Survey,

' no warranty, expressed or implied, is made by the USGS as to the

' accuracy and functioning of the program and related program

' material nor shall the fact of distribution constitute any such

' warranty, and no responsibility is assumed by the USGS in

' connection therewith.

'*

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*=============================================================================

'

'---VERSION 1.0 AVMODTMR 11MAY2001 9:19 AM

'

'::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'

' .. Purpose: checks if the 'Study Area' graphic is present, and if it is, 

' it sets the control disabled; if it is not, it sets the control enabled.

'

'0123456789012345678901234567890123456789012345678901234567890123456789012345678

theView = av.GetActiveDoc

 

LocPolyPresent = av.Run("AvMODTMR.IsGraphicPresent", {theView, 

 "theLocalPolygon"})

SELF.SetEnabled(LocPolyPresent.Not)

SELF.GetDialog.FindByName("txtDrawStudyArea").SetEnabled(LocPolyPresent.Not)
18

'************* U.S. Geological Survey preliminary computer program ************

'******************************************************************************

'************* AvMODTMR.DlgLocGridWiz.tolMove.Click ***********

'******************************************************************************

'** Language: ArcView Avenue **

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*=============================================================================

'* Author/Site, Date, Event

'* --------------------------------------------------------------------------

'* Raul D. Patterson Phone: (305) 717-5865

'* U. S. Geological Survey - WRD FAX: (305) 717-5801

'* 9100 NW 36th St., Suite 109

'* Miami, Florida 33178 USA Internet: rdpatter@usgs.gov

'*

'*=============================================================================

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*

'* Disclaimer: 

' Although this program has been used by the U.S. Geological Survey,

' no warranty, expressed or implied, is made by the USGS as to the

' accuracy and functioning of the program and related program

' material nor shall the fact of distribution constitute any such

' warranty, and no responsibility is assumed by the USGS in

' connection therewith.

'*

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*=============================================================================

'

'---VERSION 1.0 AVMODTMR 11MAY2001 9:19 AM

'

'::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'

' .. Purpose: calls up the arcview script 'View.SelectTool', which works for

' moving any selected graphic, however, this tool can only be used for the

' 'Study Area' polygon. This restriction is set in the "if.." statement. 

'

'0123456789012345678901234567890123456789012345678901234567890123456789012345678

theView = av.GetActiveDoc

theMapDisplay =theView.GetDisplay

theGraphics = theView.GetGraphics

LocalPolygonPresent = av.Run("AvMODTMR.IsGraphicPresent", {theView, 

 "theLocalPolygon"})

if (LocalPolygonPresent) then

 theLocalPolygon = theGraphics.FindByName("theLocalPolygon")

 if (theGraphics.GetSelected.Count > 0) then

 theMapDisplay.InvalidateRect(theGraphics.ReturnSelectedExtent.Scale(1.25))

 end

 theGraphics.UnselectAll

 theLocalPolygon.SetSelected(TRUE)

 theMapDisplay.InvalidateRect(theGraphics.ReturnSelectedExtent.Scale(1.25))

end

av.Run("View.SelectTool", {})
19

'************* U.S. Geological Survey preliminary computer program ************

'******************************************************************************

'************* AvMODTMR.DlgMODTMR.cbxLocITMUNI.Select ***********

'******************************************************************************

'** Language: ArcView Avenue **

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*=============================================================================

'* Author/Site, Date, Event

'* --------------------------------------------------------------------------

'* Raul D. Patterson Phone: (305) 717-5865

'* U. S. Geological Survey - WRD FAX: (305) 717-5801

'* 9100 NW 36th St., Suite 109

'* Miami, Florida 33178 USA Internet: rdpatter@usgs.gov

'*

'*=============================================================================

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*

'* Disclaimer: 

' Although this program has been used by the U.S. Geological Survey,

' no warranty, expressed or implied, is made by the USGS as to the

' accuracy and functioning of the program and related program

' material nor shall the fact of distribution constitute any such

' warranty, and no responsibility is assumed by the USGS in

' connection therewith.

'*

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*=============================================================================

'

'---VERSION 1.0 AVMODTMR 11MAY2001 9:19 AM

'

'::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'

' .. Purpose: When a time unit is selected in the LOCAL MODEL's time unit drop

' down list box, the corresponding ITMUNI2 variable is set to the 8th position

' in the local theme's object tag.

'set the ITMUNI2 space in the local grid themes'

'object tag to be the chosen time unit:

theChosenTimeUnit = SELF.GetSelection

theITMUNIList = _theTimeUnitDict.ReturnKeys

thePropLocITMUNI = NIL

for each anITMUNI in theITMUNIList

 aTimeUnit = _theTimeUnitDict.Get(anITMUNI)

 if (theChosenTimeUnit = aTimeUnit) then

 thePropLocITMUNI = anITMUNI.AsNumber

 break

 end

end

theView = av.GetActiveDoc

theLocTheme = av.Run("AvMODTMR.GetGridTheme", {theView, "L"})

if (theLocTheme = NIL) then

 Return NIL

else

 theLocParamList = theLocTheme.GetObjectTag

 theLocParamList.Set(8, thePropLocITMUNI)

 theLocTheme.SetObjectTag(theLocParamList)

end
20

SELF.BroadcastUpdate
21

'************* U.S. Geological Survey preliminary computer program ************

'******************************************************************************

'************* AvMODTMR.DlgMODTMR.cpaToggleLMPRF.Click ***********

'******************************************************************************

'** Language: ArcView Avenue **

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*=============================================================================

'* Author/Site, Date, Event

'* --------------------------------------------------------------------------

'* Raul D. Patterson Phone: (305) 717-5865

'* U. S. Geological Survey - WRD FAX: (305) 717-5801

'* 9100 NW 36th St., Suite 109

'* Miami, Florida 33178 USA Internet: rdpatter@usgs.gov

'*

'*=============================================================================

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*

'* Disclaimer: 

' Although this program has been used by the U.S. Geological Survey,

' no warranty, expressed or implied, is made by the USGS as to the

' accuracy and functioning of the program and related program

' material nor shall the fact of distribution constitute any such

' warranty, and no responsibility is assumed by the USGS in

' connection therewith.

'*

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*=============================================================================

'

'---VERSION 1.0 AVMODTMR 11MAY2001 9:19 AM

'

'::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'

' .. Purpose: Locates local grid theme, and, if present, resets object tag with

' changed LMPRF:

'

'0123456789012345678901234567890123456789012345678901234567890123456789012345678

'Retrieve local grid theme:

theView = av.GetActiveDoc

theLocThemeTypeFlag = "L"

theLocTheme = av.Run ("AvMODTMR.GetGridTheme", {theView,theLocThemeTypeFlag})

if (theLocTheme = NIL) then

 Return Nil

else

 theLMPRRFlagKW = SELF.GetLabel.AsList.Get(0) 

 av.Run("AvMODTMR.SetLocalModelPRocessingFlag", {theLMPRRFlagKW, theView, 

 theLocTheme})

end

SELF.BroadcastUpdate
22

'************* U.S. Geological Survey preliminary computer program ************

'******************************************************************************

'************* AvMODTMR.DlgMODTMR.lbtCreateLocGrid.Click *************

'******************************************************************************

'** Language: ArcView Avenue **

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*=============================================================================

'* Author/Site, Date, Event

'* --------------------------------------------------------------------------

'* Raul D. Patterson Phone: (305) 717-5865

'* U. S. Geological Survey - WRD FAX: (305) 717-5801

'* 9100 NW 36th St., Suite 109

'* Miami, Florida 33178 USA Internet: rdpatter@usgs.gov

'*

'*=============================================================================

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*

'* Disclaimer: 

' Although this program has been used by the U.S. Geological Survey,

' no warranty, expressed or implied, is made by the USGS as to the

' accuracy and functioning of the program and related program

' material nor shall the fact of distribution constitute any such

' warranty, and no responsibility is assumed by the USGS in

' connection therewith.

'*

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*=============================================================================

'

'---VERSION 1.0 AVMODTMR 11MAY2001 9:19 AM

'

'::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'

' .. Purpose: Opens the dialog that defines the local grid and immediately 

' creates a graphic that consists of a box that wraps around the local grid and

' places a bullseye-type of symbol at XCRNR1, XCRNR2 for reference in rotation.

'

'0123456789012345678901234567890123456789012345678901234567890123456789012345678

theView = av.GetActiveDoc

theGraphics = theView.GetGraphics

theThemeTypeFlag = "L"

theLocGridTheme = av.run("AvMODTMR.GetGridTheme", {theView, theThemeTypeFlag})

'If there's no local theme, then simply open the dialog:

'script, else, draw the box and origin before opening it:

if (theLocGridTheme = NIL) then

 theDlgDefineLocGrid = av.FindDialog("AvMODTMR.DlgDefineLocGrid")

 theDlgDefineLocGrid.Open

 Return NIL

else

 theLocParamList = theLocGridTheme.GetObjectTag

 'the following lines create a graphic box that wraps around the local grid

 'and places a bulls-eye like symbol on the UL corner

 '(row1, col1). The graphic box comes from the box stored

 'in the 17th element of the local grid's obj tag

 'parameter list.

 theXCRNR2 = theLocParamList.Get(11).AsNumber

 theYCRNR2 = theLocParamList.Get(12).AsNumber

 theANGL2 = theLocParamList.Get(13).AsNumber

 theNROW2 = theLocParamList.Get(6).AsNumber
23

 theDELR2 = theLocParamList.Get(14).AsNumber

 H = theNROW2 * theDELR2

 theNCOL2 = theLocParamList.Get(7).AsNumber

 theDELC2 = theLocParamList.Get(15).AsNumber

 W = theNCOL2 * theDELC2

 

 theOrigin = theXCRNR2@theYCRNR2

 

 av.Run("AvMODTMR.MakeLocalGridOutline", {theXCRNR2, theYCRNR2, theANGL2,

 H, W})

 

 theDlgDefineLocGrid = av.FindDialog("AvMODTMR.DlgDefineLocGrid")

 theDlgDefineLocGrid.Open

 

 theView.Invalidate

end
24

'************* U.S. Geological Survey preliminary computer program ************

'******************************************************************************

'*************** AvMODTMR.DlgMODTMR.lbtRegSimBrowse.Click *****************

'******************************************************************************

'** Language: ArcView Avenue **

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*=============================================================================

'* Author/Site, Date, Event

'* --------------------------------------------------------------------------

'* Raul D. Patterson Phone: (305) 717-5865

'* U. S. Geological Survey - WRD FAX: (305) 717-5801

'* 9100 NW 36th St., Suite 109

'* Miami, Florida 33178 USA Internet: rdpatter@usgs.gov

'*

'*=============================================================================

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*

'* Disclaimer: 

' Although this program has been used by the U.S. Geological Survey,

' no warranty, expressed or implied, is made by the USGS as to the

' accuracy and functioning of the program and related program

' material nor shall the fact of distribution constitute any such

' warranty, and no responsibility is assumed by the USGS in

' connection therewith.

'*

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*=============================================================================

'

'---VERSION 1.0 AVMODTMR 11MAY2001 9:19 AM

'

'::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'

' .. Purpose: Browse for .NAM file of regional simulation data set. Verifies 

' that words were used to specify options in .OC file by and that the option 

' 'COMPACT BUDGET FILES' was used in the regional model by searching for the 

' phrase among the first 8 lines, something required by MODTMR. An error

' message is created with the problems found if any of these items don't 

' check. It then reads the NLAY, NCOL, NROW, NPER and ITMUNI values from 

' record 3 of the BAS file and writes them to their respective text boxes in

' the 'REGIONAL MODEL' portion of the dialog. Reads ISS (is steady state) flag

' from the BCF package. Checks that all the files listed in the name file are

' in the paths as indicated in it. Error string is reported at the end in a 

' text box that can be copied and pasted to a text editor to be used as a 

' checklist for making the required modifications. NOTE: THE REGIONAL

' SIMULATION MUST BE RUN IN MODFLOW 96 WITH ALL OF THESE OPTIONS. MERELY

' CHANGING THE OPTIONS IN THE DATASET WITHOUT RUNNING THE SIMULATION WILL

' ALLOW YOU TO CONTINUE WITH AVMODTMR, BUT MODTMR WILL LIKELY ERROR OUT.

'Point to regional simulation name file, return nil if nothing set:

theRegNameFileFullPath = FileDialog.Show ("*.nam", "MODFLOW Name File (*.nam)",

 "Select Name File for Regional MODFLOW Simulation")

if (theRegNameFileFullPath = NIL) then

 MsgBox.Info("No NAME file selected, returning to MODTMR dialog", "")

 return Nil

else

 'Set the Path to files and the Name file file name, but not as globals yet,

 'since checks need to be made. If it passes all checks, the globals will be

 'set at the end.

 thePathToFiles = theRegNameFileFullPath.ReturnDir.AsString

 theRegNameFile = theRegNameFileFullPath.GetBaseName.AsString
25

end

'Initialize an error string to contain all error messages:

theErrorString = ""

'Look for Output Control file and make sure "COMPACT BUDGET FILES" is among

'first 8 lines (this also assures words were used to specify options):

theOC_File = av.Run("AvMODTMR.GetFileNameFromNameFile",

 {theRegNameFileFullPath,"OC"})

theOC_FileName = (thePathToFiles + "\" + theOC_File).AsFileName

 ' Check if the OC file exists, exit if it doesn't:

 if (theOC_FileName.IsFile.Not) then

 theErrorString = theErrorString + "No *.oc file found in path: "+NL+

 thePathToFiles+NL+

 NL+

 NL

 else

 'Proceed to check if the string "COMPACT BUDGET FILES" exists among first 

 '8 lines:

 aLineList = List.Make

 theOC_File = LineFile.Make(theOC_FileName, #FILE_PERM_READ)

 theOC_File.Read(aLineList, 8)

 OCFileInCorrectFormat = FALSE

 for each aLine in aLineList

 if (aLine = "COMPACT BUDGET FILES") then

 OCFileInCorrectFormat = TRUE

 Break

 end

 end

 if (OCFileInCorrectFormat.Not) then

 theErrorString = theErrorString + "Output Control file is in wrong " +

 "format."+NL+ "Make sure options are specified using " +

 "words and that the option 'COMPACT BUDGET FILES' is" +

 "used"+ NL + NL

 end

 theOC_File.Close

 aLineList = Nil 

 end

'Look for cbc file, if not found, append error message to theErrorString, 

'if found, then set the Cell-by-cell file text box to hold theCellByCellFile:

theCellByCellFile = thePathToFiles + "\" + theRegNameFile + ".cbc"

theCellByCellFileName = theCellByCellFile.AsFileName

if (theCellByCellFileName = NIL) then

 theErrorString = theErrorString + "No Cell-by-cell (*.cbc) file found in " +

 "path: " + NL +

 thePathToFiles + NL + NL

end

'Look for hed file, if not found, append error message to theErrorString, if 

'found, then set the Head file text box to hold theHeadFile:

theHeadFile = thePathToFiles + "\" + theRegNameFile + ".hed"

theHeadFileName = theHeadFile.AsFileName

if (theHeadFileName = NIL) then

 theErrorString = theErrorString + "No Head (*.hed) file found in path: "+NL+

 thePathToFiles+ NL + NL + NL
26

end

 

'Check for option 'FREE' in 4th line of .BAS file and grab NLAY, NCOL, etc...

'from line 3:

theBAS_File = av.Run("AvMODTMR.GetFileNameFromNameFile",

 {theRegNameFileFullPath, "BAS"})

theBAS_FileName = (thePathToFiles + "\" + theBAS_File).AsFileName

 ' Check if the BAS file exists, exit if it doesn't:

 if (theBAS_FileName.IsFile.Not) then

 theErrorString = theErrorString + "No *.bas file found in path: "+NL+

 thePathToFiles+NL+

 NL+

 NL

 else 

 ' Open the BAS file:

 aLineList = List.Make

 theBASFile = LineFile.Make (theBAS_FileName, #FILE_PERM_READ)

 theBASFile.Read( aLineList, 4 )

 the3rdLine = aLineList.Get(2)

 delimit = "SPACE"

 if (the3rdLine.Left(11).Contains(",")) then

 delimit = "COMMA"

 end

 if (delimit = "COMMA") then

 theVariableList = the3rdLine.AsTokens(",")

 elseif (delimit = "SPACE") then

 theVariableList = the3rdLine.AsList

 end

 theRegNLAY = theVariableList.Get(0)

 theRegNROW = theVariableList.Get(1)

 theRegNCOL = theVariableList.Get(2)

 theRegNPER = theVariableList.Get(3)

 theRegTimeUnit = theVariableList.Get(4)

 

 theTimeUnitDict = _theTimeUnitDict

 theRegITMUNI = theTimeUnitDict.Get(theRegTimeUnit)

 

 theBASFile.Close

 aLineList = Nil

 

 end

 

 

'Get the ISS (SS or Trans.) value in position 1, 1st line of .BCF file:

theBCF_File = av.Run("AvMODTMR.GetFileNameFromNameFile",

 {theRegNameFileFullPath, "BCF"})

theBCF_FileName = (thePathToFiles + "\" + theBCF_File).AsFileName

 ' Check if the BCF file exists, exit if it doesn't:

 if (theBCF_FileName.IsFile.Not) then

 theErrorString = theErrorString + "No *.bcf file found in path: "+NL+

 thePathToFiles+NL+

 NL+

 NL

 else
27

 ' Open the BCF file:

 aLineList = List.Make

 theBCFFile = LineFile.Make (theBCF_FileName, #FILE_PERM_READ)

 theBCFFile.Read( aLineList, 1 )

 

 the1stLine = aLineList.Get(0)

 

 delimit = "SPACE"

 if (the1stLine.Left(11).Contains(",")) then

 delimit = "COMMA"

 end

 if (delimit = "COMMA") then

 theVariableList = the1stLine.AsTokens(",")

 elseif (delimit = "SPACE") then

 theVariableList = the1stLine.AsList

 end

 

 theISSFlag = the1stLine.AsList.Get(0)

 

 theBCFFile.Close

 aLineList = Nil

 end

 

 

'Check the rest of the files listed in the name file are in the directory:

theMissingFileString = ""

aLineList = List.Make

theNameFile = LineFile.Make (theRegNameFileFullPath, #FILE_PERM_READ)

theNameFile.Read(aLineList, theNameFile.GetSize)

n = 0

theListOfUnitsUsed = List.Make

for each aLine in aLineList

 n = n + 1

 theNameFileLineParaList = aLine.AsList

 

 if (theNameFileLineParaList.Count <> 3) then

 MsgBox.ListAsString(theNameFileLineParaList, "not 3 args in NAM file Line",

 "")

 continue

 end

 

 aFileType = theNameFileLineParaList.Get(0).Left(4)

 aUnitNo = theNameFileLineParaList.Get(1)

 theListOfUnitsUsed.Add(aUnitNo)

 aFileName = theNameFileLineParaList.Get(2)

 

 theFileName = (thePathToFiles + "\" + aFileName).AsFileName

 if ((aFileType = "LIST") or (aFileType = "DATA")) then

 continue

 elseif (theFileName.IsFile.Not) then

 MsgBox.Report("the following is a file name of a pkg from the name file, "+ 

 "but it's not where the name file indicates" + NL + 

 theFileName.AsString, "")

 aFileExtension = aFileName.Right(3).UCase

 theMissingFileString = theMissingFileString + aFileExtension + NL

 end

end

if((theMissingFileString = "").Not) then

 theErrorString = theErrorString + NL + NL + "The following input files " +
28

 "are listed in the regional model name file, but are " +

 "not in: "+thePathToFiles

end

'Make sure the view contains a Regional grid theme:

theView = av.GetActiveDoc

theRegTheme = av.run("AvMODTMR.GetGridTheme", {theView, "R"})

theRegParamList = theRegTheme.GetObjectTag

'Finally, if there are no problems (i.e., theErrorString = "") then set 

'variables and set read-only reg sim controls in the MODTMR dialog with their

'values.

if (theErrorString = "") then

 

 'Set View units with user-defined query:

 theUnitDict = Dictionary.Make(1)

 theUnitDict.Add("feet", #UNITS_LINEAR_FEET)

 theUnitDict.Add("meters", #UNITS_LINEAR_METERS)

 

 theUnits = MsgBox.ListAsString(theUnitDict.ReturnKeys, "Select the units " +

 "of the Regional Model" + NL +

 "NOTE: This will be the LENGTH units of the local model as well",

 "Choose Units")

 if (theUnits = NIL) then

 MsgBox.Warning("You must specify the units of the regional model, " + 

 "terminating program", 

 "Can Not Continue Without Length Units") 

 Return NIL

 else

 theView.SetUnits(theUnitDict.Get(theUnits))

 theRegGridTheme = NIL

 txlUnits = SELF.GetDialog.FindByName("txlUnits")

 txlUnits.SetText(theUnits)

 theLocUnitsLabel = SELF.GetDialog.FindByName("txtLocUnits").SetLabel(

 "Length Units: "+theUnits)

 end

 'Set the regional simulation variables and place them in the reg theme's 

 'object tag:

 

 MFNAME = theRegNameFile

 PathToFiles = thePathToFiles

 RegNLAY = theRegNLAY

 RegNROW = theRegNROW

 RegNCOL = theRegNCOL

 RegITMUNI = theRegITMUNI

 RegNPER = theRegNPER

 UsedIUNITS = theListOfUnitsUsed

 aTempMFNAMEString = theRegNameFile

 XXCBC = MFNAME.Substitute(".nam", ".cbc")

 XXHED = MFNAME.Substitute(".nam", ".hed")

 theRegParamList.Set(1, MFNAME)

 theRegParamList.Set(7, XXCBC)

 theRegParamList.Set(8, XXHED)

 '***** these parameters (9 - 15) need to be added to the obj tag of the

 '***** reg grid theme with all the rest and then Set here:

 theRegParamList.Set(9, UsedIUNITS)

 theRegParamList.Set(10, RegNLAY)

 theRegParamList.Set(11, RegITMUNI)

 theRegParamList.Set(12, RegNROW)
29

 theRegParamList.Set(13, RegNCOL)

 theRegParamList.Set(14, theISSFlag)

 theRegParamList.Set(15, RegNPER)

 theRegParamList.Set(16, theUnits)

 theRegParamList.Set(17, thePathToFiles)

 

 SELF.GetDialog.FindByName("txlRegNameFile").SetText(MFNAME)

 SELF.GetDialog.FindByName("txlPathToFiles").SetText(PathToFiles)

 SELF.GetDialog.FindByName("txlRegNLAY").SetText(RegNLAY)

 SELF.GetDialog.FindByName("txlRegNROW").SetText(RegNROW)

 SELF.GetDialog.FindByName("txlRegNCOL").SetText(RegNCOL)

 SELF.GetDialog.FindByName("txlRegITMUNI").SetText(RegITMUNI)

 SELF.GetDialog.FindByName("txlRegNPER").SetText(RegNPER)

 

 theRegTheme.SetObjectTag(theRegParamList)

 

 

 

 if (theISSFlag = "1") then

 radRegSteadyState = SELF.GetDialog.FindByName("radRegSteadyState")

 radRegSteadyState.Select

 elseif (theISSFlag = "0") then

 radRegTransient = SELF.GetDialog.FindByName("radRegTransient")

 radRegTransient.Select

 end

 

 'select the radio button for using all regional layers (the default):

 SELF.GetDialog.FindByName("radUseAllLayers").Select

 

 'select the radio button for processing all files (not just FHB pkg):

 SELF.GetDialog.FindByName("radAllPackages").Select

 

 av.GetProject.SetModified(TRUE) 

 

else

 Clipboard.The.Empty

 Clipboard.The.Add(theErrorString)

 Clipboard.The.Update

 MsgBox.Report (theErrorString, "These are the errors in your Regional " +

 "data set")

 Return Nil

end
30

'************* U.S. Geological Survey preliminary computer program ************

'******************************************************************************

'************* AvMODTMR.DlgMODTMR.lbtWriteFile.Click ************

'******************************************************************************

'** Language: ArcView Avenue **

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*=============================================================================

'* Author/Site, Date, Event

'* --------------------------------------------------------------------------

'* Raul D. Patterson Phone: (305) 717-5865

'* U. S. Geological Survey - WRD FAX: (305) 717-5801

'* 9100 NW 36th St., Suite 109

'* Miami, Florida 33178 USA Internet: rdpatter@usgs.gov

'*

'*=============================================================================

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*

'* Disclaimer: 

' Although this program has been used by the U.S. Geological Survey,

' no warranty, expressed or implied, is made by the USGS as to the

' accuracy and functioning of the program and related program

' material nor shall the fact of distribution constitute any such

' warranty, and no responsibility is assumed by the USGS in

' connection therewith.

'*

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*=============================================================================

'

'---VERSION 1.0 AVMODTMR 11MAY2001 9:19 AM

'

'::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'

' .. Purpose: reads the data items from the obj tags of the regional and local 

' themes copying them into a string that is formatted as a MODTMR input file 

' and written to disk at the user's option.

'

'123456789012345678901234567890123456789012345678901234567890123456789012345678

theView = av.GetActiveDoc

theRegTheme = av.Run("AvMODTMR.GetGridTheme", {theView, "R"})

theRegParamList = theRegTheme.GetObjectTag

theLocTheme = av.Run("AvMODTMR.GetGridTheme", {theView, "L"})

theLocParamList = theLocTheme.GetObjectTag

'Get regional parameters:

MFNAME = theRegParamList.Get(1)

XYFAC1 = theRegParamList.Get(2).AsString

ICRNR1 = theRegParamList.Get(3).AsString

XCRNR1 = theRegParamList.Get(4).AsString

YCRNR1 = theRegParamList.Get(5).AsString

ANGL1 = theRegParamList.Get(6).AsString

XXCBC = theRegParamList.Get(7).AsString
31

XXHED = theRegParamList.Get(8).AsString

'Get local parameters:

LMDSN = theLocParamList.Get(3)

LMPRF = theLocParamList.Get(4).AsString

'get LML:

LML = ""

LMLDict = theLocParamList.Get(5)

theLayers = LMLDict.ReturnKeys

theLayers.Sort(TRUE)

for each aLay in theLayers

 LML = LML + LMLDict.Get(aLay).AsString+ " "

end

'trim last space:

LML = LML.Left(LML.Count - 1)

NROW2 = theLocParamList.Get(6).AsString

NCOL2 = theLocParamList.Get(7).AsString

ITMUN2 = theLocParamList.Get(8).AsString

XYFAC2 = theLocParamList.Get(9).AsString

ICRNR2 = theLocParamList.Get(10).AsString

XCRNR2 = theLocParamList.Get(11).AsString

YCRNR2 = theLocParamList.Get(12).AsString

ANGL2 = theLocParamList.Get(13).AsString

DELR2 = "CONSTANT "+theLocParamList.Get(14).AsString

DELC2 = "CONSTANT "+theLocParamList.Get(15).AsString

theBCTArray = av.Run("AvMODTMR.BuildBCTArrays", {theView})

'get the FHB unit number from the dialog:

IFHBUN = SELF.GetDialog.FindByName("txlIFHBUN").GetText

'string together the parameters:

 

 'initiate the string for the input file:

 aMODTMRFileString = ""

 'build 1st line:

 aMODTMRFileString = MFNAME++LMDSN++IFHBUN++LMPRF+nl

 'build 2nd line:

 aMODTMRFileString = aMODTMRFileString+XYFAC1++ICRNR1++XCRNR1++YCRNR1++ANGL1+

 nl

 

 'build 3rd line:

 aMODTMRFileString = aMODTMRFileString+LML+nl

 

 'build 4th line:

 aMODTMRFileString = aMODTMRFileString+NROW2++NCOL2++ITMUN2+nl

 
32

 'build 5th line:

 aMODTMRFileString = aMODTMRFileString+XYFAC2++ICRNR2++XCRNR2++YCRNR2++ANGL2+

 nl

 

 'build 6th line:

 aMODTMRFileString = aMODTMRFileString+DELR2+nl

 

 'build 7th line:

 aMODTMRFileString = aMODTMRFileString+DELC2+nl

 

 'build 8th line:

 aMODTMRFileString = aMODTMRFileString+XXCBC+nl

 

 'build 9th line:

 aMODTMRFileString = aMODTMRFileString+XXHED+nl

 

 'build 10th line:

 aMODTMRFileString = aMODTMRFileString+theBCTArray+nl

 

MsgBox.Report(aMODTMRFileString, "This is the MODTMR input file")

SaveFile = MsgBox.YesNo("Would you like to write this to a file?", 

 "Saving MODTMR Input File", TRUE)

if (SaveFile.Not) then

 Return NIL 'else, continue...

end

'See if a MODTMR input file has already been associated with this local grid:

theFileName = NIL

if (theLocParamList.Count = 18) then

 'there's something there, check if it's an existing file:

 if (theLocParamList.Get(17).AsFileName.IsFile) then

 theFileName = theLocParamList.Get(17).AsFileName

 end

end

'If theFileName is NIL, none has been associated before (or maybe file was 

'deleted), so ask for one:

if (theFileName = NIL) then

 'Create a default one with the same path to files as the regional sim.:

 theDlgMODTMR_Dialog = SELF.GetDialog

 thePathToFiles = theDlgMODTMR_Dialog.FindByName("txlPathToFiles").GetText

 theFileNameString = theDlgMODTMR_Dialog.FindByName(

 "txlLocalNameFile").GetText

 theDefFileNameString = thePathToFiles+"\"+theFileNameString

 theDefFileName = FileName.Make(theDefFileNameString)

else

 'Grab the one that's already there and use it as the default:

 theDefFileName = theFileName

end

'Prompt user for a file name:

theFileName = FileDialog.Put(theDefFileName,"", "Save MODTMR Input File")

if (theFileName = NIL) then

 MsgBox.Warning("No File Name Given", "File Not Created")

 Return NIL

end

theTextFile = TextFile.Make (theFileName, #FILE_PERM_WRITE)

theTextFile.Write (aMODTMRFileString, aMODTMRFileString.Count)

theTextFile.Close
33

if (theLocParamList.Count = 17) then

 theLocParamList.Add(theFileName.AsString) '*** 18th item in theLocParamList

else

 theLocParamList.Set(17, theFileName.AsString)

end

theLocTheme.SetObjectTag(theLocParamList)

av.GetProject.SetModified(TRUE)
34

'************* U.S. Geological Survey preliminary computer program ************

'******************************************************************************

'************* AvMODTMR.DlgMODTMR.txlFHBUN.FocusLost ************

'******************************************************************************

'** Language: ArcView Avenue **

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*=============================================================================

'* Author/Site, Date, Event

'* --------------------------------------------------------------------------

'* Raul D. Patterson Phone: (305) 717-5865

'* U. S. Geological Survey - WRD FAX: (305) 717-5801

'* 9100 NW 36th St., Suite 109

'* Miami, Florida 33178 USA Internet: rdpatter@usgs.gov

'*

'*=============================================================================

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*

'* Disclaimer: 

' Although this program has been used by the U.S. Geological Survey,

' no warranty, expressed or implied, is made by the USGS as to the

' accuracy and functioning of the program and related program

' material nor shall the fact of distribution constitute any such

' warranty, and no responsibility is assumed by the USGS in

' connection therewith.

'*

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*=============================================================================

'

'---VERSION 1.0 AVMODTMR 11MAY2001 9:19 AM

'

'::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'

' .. Purpose: Checks if the file unit entered by the user for the FHB package 

' has been used, sending the user an error message that it's been used and

' reporting the unit numbers that have already been used by other packages.

thePropFHBUnitNo = SELF.GetText

theView = av.GetActiveDoc

theThemeTypeFlag = "R"

theRegTheme = av.run("AvMODTMR.GetGridTheme", {theView, theThemeTypeFlag})

theRegParamList = theRegTheme.GetObjectTag

theUsedIUNITS = theRegParamList.Get(9)

for each aUnitNo in theUsedIUNITS

 if (aUnitNo = thePropFHBUnitNo) then

 'make a string will all the used IUNITS:

 aStringOfIUNITS = ""

 for each anItem in theUsedIUNITS

 aStringOfIUNITS = aStringOfIUNITS + anItem +", "

 end

 MsgBox.Info("The following unit numbers have been used: "+aStringOfIUNITS, 

 "Try a Different Unit Number")

 SELF.SetText("")

 SELF.Focus

 break

 end

end

'Find the local grid theme in the view and set its 17th item in the obj. tag

'to be this IFHBUN value:
35

theLocThemeTypeFlag = "L"

theLocTheme = av.run("AvMODTMR.GetGridTheme", {theView, theLocThemeTypeFlag})

if ((theLocTheme = NIL).Not) then

 theLocParamList = theLocTheme.GetObjectTag

 theLocParamList.Set(16, thePropFHBUnitNo)

 theLocTheme.SetObjectTag(theLocParamList)

end

SELF.BroadcastUpdate
36

'************* U.S. Geological Survey preliminary computer program ************

'******************************************************************************

'************* AvMODTMR.DrawTempBox *************

'******************************************************************************

'** Language: ArcView Avenue **

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*=============================================================================

'* Author/Site, Date, Event

'* --------------------------------------------------------------------------

'* Raul D. Patterson Phone: (305) 717-5865

'* U. S. Geological Survey - WRD FAX: (305) 717-5801

'* 9100 NW 36th St., Suite 109

'* Miami, Florida 33178 USA Internet: rdpatter@usgs.gov

'*

'*=============================================================================

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*

'* Disclaimer: 

' Although this program has been used by the U.S. Geological Survey,

' no warranty, expressed or implied, is made by the USGS as to the

' accuracy and functioning of the program and related program

' material nor shall the fact of distribution constitute any such

' warranty, and no responsibility is assumed by the USGS in

' connection therewith.

'*

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*=============================================================================

'

'---VERSION 1.0 AVMODTMR 11MAY2001 9:19 AM

'

'::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'

' .. Purpose: a routine that takes in an origin point and a polygon designating

' the UL origin and boundaries of the local grid and draws a graphics of them

' on the view.

'

'1234567890123456789012345678901234567890123456789012345678901234567890123456789

theView = av.GetActiveDoc

theGraphics = theView.GetGraphics

'Check if any of the graphics exist on the view and delete them

'if they do:

av.Run("AvMODTMR.DeletePreviewBox", {theView})

theOrigin = SELF.Get(0)

theBox = SELF.Get(1)

aBoxGShp = GraphicShape.Make(theBox)

aBoxGShp.SetName("LocBounds")

theBoxSymbol = Symbol.Make(#SYMBOL_FILL)

theBoxSymbol.SetOlColor(Color.GetBlack)

theBoxSymbol.SetOlWidth (2)

aClearColor = Color.Make

aClearColor.SetTransparent(TRUE)

theBoxSymbol.SetColor(aClearColor)

aBoxGShp.SetSymbol(theBoxSymbol)

'get the Upper Left vertex of the box & place point:

aBullseyeGShp = GraphicShape.Make(theOrigin)

aBullseyeGshp.SetName("LocOrigin")

'set point's symbol to a bulls-eye (default palette #42):
37

thePalette = Palette.Make

thePaletteFile = "$AVHOME/symbols/default.avp".AsFileName

thePalette.LoadFromFile(#PALETTE_LIST_MARKER, thePaletteFile)

theMarkerList = thePalette.GetList(#PALETTE_LIST_MARKER)

theSymbol = theMarkerList.Get(42).Clone

aBullseyeGShp.SetSymbol (theSymbol)

aGraphicGroup = GraphicGroup.Make

aGraphicGroup.Add(aBoxGShp)

aGraphicGroup.Add(aBullseyeGShp)

aGraphicGroup.SetName("theRefBox")

theGraphics.Add(aGraphicGroup)

theView.GetDisplay.InvalidateRect(aGraphicGroup.GetBounds)
38

'************* U.S. Geological Survey preliminary computer program ************

'******************************************************************************

'************* AvMODTMR.EnsurePosRealEntry **************

'******************************************************************************

'** Language: ArcView Avenue **

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*=============================================================================

'* Author/Site, Date, Event

'* --------------------------------------------------------------------------

'* Raul D. Patterson Phone: (305) 717-5865

'* U. S. Geological Survey - WRD FAX: (305) 717-5801

'* 9100 NW 36th St., Suite 109

'* Miami, Florida 33178 USA Internet: rdpatter@usgs.gov

'*

'*=============================================================================

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*

'* Disclaimer: 

' Although this program has been used by the U.S. Geological Survey,

' no warranty, expressed or implied, is made by the USGS as to the

' accuracy and functioning of the program and related program

' material nor shall the fact of distribution constitute any such

' warranty, and no responsibility is assumed by the USGS in

' connection therewith.

'*

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*=============================================================================

'

'---VERSION 1.0 AVMODTMR 11MAY2001 9:19 AM

'

'::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'

' .. Purpose: used as the lost focus script for the DELC2 and DELR2 text lines

' in the 'Local Grid Wizard' dialog. It runs 'AvMODTMR.CheckForPositiveReal', 

' returns an error message if the entry is not a positive number. Then, it

' clears the text and returns focus to the textline.

'

'0123456789012345678901234567890123456789012345678901234567890123456789012345678

theNumber = SELF.GetText

theArgs = {theNumber}

theAnswer = av.Run("AvMODTMR.CheckForPositiveReal", theArgs)

if (theAnswer = NIL) then

 MsgBox.Error("Enter a positive number", "Grid Spacings Must be Positive Numbers")

 SELF.SetText("")

 SELF.Focus

end
39

'************* U.S. Geological Survey preliminary computer program ************

'******************************************************************************

'************* AvMODTMR.GetFieldMinMaxValues **************

'******************************************************************************

'** Language: ArcView Avenue **

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*=============================================================================

'* Author/Site, Date, Event

'* --------------------------------------------------------------------------

'* Raul D. Patterson Phone: (305) 717-5865

'* U. S. Geological Survey - WRD FAX: (305) 717-5801

'* 9100 NW 36th St., Suite 109

'* Miami, Florida 33178 USA Internet: rdpatter@usgs.gov

'*

'*=============================================================================

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*

'* Disclaimer: 

' Although this program has been used by the U.S. Geological Survey,

' no warranty, expressed or implied, is made by the USGS as to the

' accuracy and functioning of the program and related program

' material nor shall the fact of distribution constitute any such

' warranty, and no responsibility is assumed by the USGS in

' connection therewith.

'*

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*=============================================================================

'

'---VERSION 1.0 AVMODTMR 11MAY2001 9:19 AM

'

'::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'

' .. Purpose: returns a list containing the minimum and maximum elements in a

' field of a table.

'

'0123456789012345678901234567890123456789012345678901234567890123456789012345678

theVTab = SELF.Get(0)

theFieldName = SELF.Get(1)

theField = theVTab.FindField(theFieldName)

aValueList = List.Make

for each aRec in theVTab

 aValue = theVTab.ReturnValue(theField, aRec)

 aValueList.Add(aValue)

end

aValueList.RemoveDuplicates

aValueList.Sort(TRUE)

theMinVal = aValueList.Get(0)

theMaxVal = aValueList.Get(aValueList.Count - 1)

Return {theMinVal, theMaxVal}
40

'************* U.S. Geological Survey preliminary computer program ************

'******************************************************************************

'************* AvMODTMR.GetFileNameFromNameFile ************

'******************************************************************************

'** Language: ArcView Avenue **

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*=============================================================================

'* Author/Site, Date, Event

'* --------------------------------------------------------------------------

'* Raul D. Patterson Phone: (305) 717-5865

'* U. S. Geological Survey - WRD FAX: (305) 717-5801

'* 9100 NW 36th St., Suite 109

'* Miami, Florida 33178 USA Internet: rdpatter@usgs.gov

'*

'*=============================================================================

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*

'* Disclaimer: 

' Although this program has been used by the U.S. Geological Survey,

' no warranty, expressed or implied, is made by the USGS as to the

' accuracy and functioning of the program and related program

' material nor shall the fact of distribution constitute any such

' warranty, and no responsibility is assumed by the USGS in

' connection therewith.

'*

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*=============================================================================

'

'---VERSION 1.0 AVMODTMR 11MAY2001 9:19 AM

'

'::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'

' .. Purpose: receives the FileName of the Name File of a MODFLOW96 simulation

' and a keyword used to specify the type of file (i.e. "WEL" for the Well file)

' and it returns a string of the path indicated in the name file for the file.

' If it does not find the file it returns an empty string. NOTE: the path will

' returned will be exactly as it appears in the name file, if it is a relative

' path, then that is what will returned.

'

'0123456789012345678901234567890123456789012345678901234567890123456789012345678

'AvMODTMR.GetFileNameFromNameFile

theNameFileName = SELF.Get(0)

theFileKeyword = SELF.Get(1)

theNAMFile = LineFile.Make(theNameFileName, #FILE_PERM_READ)

theLineList = {}

theNAMFile.Read(theLineList, theNAMFile.GetSize)

theWantedFileName = NIL

for each aLine in theLineList

 aLine = aLine.Trim

 if ((aLine = "") or (aLine.Left(1) = "#")) then

 continue

 end

 theWords = aLine.AsList

 if (theWords.Get(0) = theFileKeyword) then

 theWantedFileName = theWords.Get(2)

 break

 end

end
41

theNAMFile.Close

'strip any relative path characters (ie. "..\")

theWantedFileName.Substitute("..\", "")

Return theWantedFileName
42

'************* U.S. Geological Survey preliminary computer program ************

'******************************************************************************

'************* AvMODTMR.GetGridGeometry *************

'******************************************************************************

'** Language: ArcView Avenue **

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*=============================================================================

'* Author/Site, Date, Event

'* --------------------------------------------------------------------------

'* Raul D. Patterson Phone: (305) 717-5865

'* U. S. Geological Survey - WRD FAX: (305) 717-5801

'* 9100 NW 36th St., Suite 109

'* Miami, Florida 33178 USA Internet: rdpatter@usgs.gov

'*

'*=============================================================================

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*

'* Disclaimer: 

' Although this program has been used by the U.S. Geological Survey,

' no warranty, expressed or implied, is made by the USGS as to the

' accuracy and functioning of the program and related program

' material nor shall the fact of distribution constitute any such

' warranty, and no responsibility is assumed by the USGS in

' connection therewith.

'*

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*=============================================================================

'

'---VERSION 1.0 AVMODTMR 11MAY2001 9:19 AM

'

'::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'

' .. Purpose: receives a grid theme of a MODFLOW simulation and returns a list

' containing three items: 1 and 2: the X and Y coordinates of the Upper Left

' (UL) corner vertex of the grid and, 3: the rotation angle of the grid. The 

' UL corner is the lone vertex of the cell located at Row 1 Col 1. Also returns

' the rotation angle of the grid relative to the positive x-axis in degrees 

' counter clock-wise.

'

'0123456789012345678901234567890123456789012345678901234567890123456789012345678

theGridTheme = SELF.Get(0)

theVTab = theGridTheme.GetFTab

'Locate the first cell:

theFirstCellNo = 1

theFirstCell = av.Run("AvMODTMR.ReturnACertainCell", {theVTab, theFirstCellNo})

'Locate the lone vertex of the first cell:

 'Select arbitrarily small number to use as search radius for identifying lone 

 'vertex

 theMinDist = 1

 

 the1stCellVertex = av.Run("AvMODTMR.ReturnLoneVertex", {theFirstCell, theVTab,

 theMinDist})

 

theXCRNR = the1stCellVertex.GetX

theXCRNR.SetFormat("d.")

theYCRNR = the1stCellVertex.GetY

theYCRNR.SetFormat("d.")

'Locate the lone vertex of the last cell in the first row:
43

theColFldName = "Col"

theNCOL = av.Run("AvMODTMR.GetFieldMinMaxValues", {theVTab, 

 theColFldName}).Get(1)

the1stRowLastCellNo = theNCOL

the1stRowLastCell = av.Run("AvMODTMR.ReturnACertainCell", {theVTab, 

 the1stRowLastCellNo})

the1stRowLastCellVertex = av.Run("AvMODTMR.ReturnLoneVertex", 

 {the1stRowLastCell, theVTab, theMinDist})

'Calculate the angle of inclination:

X1 = theXCRNR

Y1 = theYCRNR

X2 = the1stRowLastCellVertex.GetX

Y2 = the1stRowLastCellVertex.GetY

Slope = (Y2 - Y1)/(X2 - X1)

'the rotation angle (in the range -180 to 180, in radians)

theANGLpm180Rad = Slope.ATan

theANGLpm180Deg = theANGLpm180Rad.AsDegrees

'convert to degrees CCW:

if (theANGLpm180Deg >= 0) then

 theANGL = theANGLpm180Deg

elseif (theANGLpm180Deg < 0) then

 theANGL = 360 + theANGLpm180Deg

end

theANGL.SetFormat( "d." )

theXCRNRtext = theXCRNR.AsString+"."

theYCRNRtext = theYCRNR.AsString+"."

theANGLtext = theANGL.AsString+"."

theGridGeomParamList = {theXCRNRtext, theYCRNRtext, theANGLtext}

Return theGridGeomParamList
44

'************* U.S. Geological Survey preliminary computer program ************

'******************************************************************************

'************* AvMODTMR.GetGridTheme **************

'******************************************************************************

'** Language: ArcView Avenue **

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*=============================================================================

'* Author/Site, Date, Event

'* --------------------------------------------------------------------------

'* Raul D. Patterson Phone: (305) 717-5865

'* U. S. Geological Survey - WRD FAX: (305) 717-5801

'* 9100 NW 36th St., Suite 109

'* Miami, Florida 33178 USA Internet: rdpatter@usgs.gov

'*

'*=============================================================================

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*

'* Disclaimer: 

' Although this program has been used by the U.S. Geological Survey,

' no warranty, expressed or implied, is made by the USGS as to the

' accuracy and functioning of the program and related program

' material nor shall the fact of distribution constitute any such

' warranty, and no responsibility is assumed by the USGS in

' connection therewith.

'*

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*=============================================================================

'

'---VERSION 1.0 AVMODTMR 11MAY2001 9:19 AM

'

'::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'

' .. Purpose: requires the view and the Theme Type Flag, a string with values

' "R" (for Regional) or "L" (for Local). Returns either the Local Grid theme or

' the Regional Grid theme, depending on the value of the Theme Type Flag. If no

' theme with that value in its object tag, then NIL is returned.

'

'0123456789012345678901234567890123456789012345678901234567890123456789012345678

'Usage: av.run("AvMODTMR.GetGridTheme", {theView, theThemeTypeFlag})

theView = SELF.Get(0)

theThemeTypeFlag = SELF.Get(1)

theWantedTheme = NIL

for each T in theView.GetThemes

 if ((T.GetObjectTag.Is(List)) and 

 (T.GetObjectTag.Get(0) = theThemeTypeFlag)) then

 theWantedTheme = T

 break

 end

end

Return theWantedTheme
45

'************* U.S. Geological Survey preliminary computer program ************

'******************************************************************************

'************* AvMODTMR.Install **************

'******************************************************************************

'** Language: ArcView Avenue **

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*=============================================================================

'* Author/Site, Date, Event

'* --------------------------------------------------------------------------

'* Raul D. Patterson Phone: (305) 717-5865

'* U. S. Geological Survey - WRD FAX: (305) 717-5801

'* 9100 NW 36th St., Suite 109

'* Miami, Florida 33178 USA Internet: rdpatter@usgs.gov

'*

'*=============================================================================

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*

'* Disclaimer: 

' Although this program has been used by the U.S. Geological Survey,

' no warranty, expressed or implied, is made by the USGS as to the

' accuracy and functioning of the program and related program

' material nor shall the fact of distribution constitute any such

' warranty, and no responsibility is assumed by the USGS in

' connection therewith.

'*

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*=============================================================================

'

'---VERSION 1.0 AVMODTMR 11MAY2001 9:19 AM

'

'::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'

' .. Purpose: Installs extension, adding all the GUI elements and their scripts

' to the ArcView. The dialogs and scripts are automatically added. However,

' any buttons and menus that are in the extension must be explicitly added to

' the current project's GUIs.

'

'0123456789012345678901234567890123456789012345678901234567890123456789012345678

'Install ONLY if there is an active project

if (av.GetProject = nil) then

 return NIL

end

''Retrieve objects from extension:

theProject = av.GetProject

theDlgMODTMROpenButton = SELF.Get(0)

'Install the open button for the MODTMR dialog:

viewGUI = av.GetProject.FindGUI("View")

if (viewGUI <> NIL) then

 theViewGUIButtonBar = viewGUI.GetButtonBar

 theViewGUIButtons = theViewGUIButtonBar.GetControls

 'Make it the last item

 thePlace = theViewGUIButtons.Count

 theViewGUIButtonBar.Add(theDlgMODTMROpenButton, thePlace)

end
46

'************* U.S. Geological Survey preliminary computer program ************

'******************************************************************************

'************* AvMODTMR.Load **************

'******************************************************************************

'** Language: ArcView Avenue **

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*=============================================================================

'* Author/Site, Date, Event

'* --------------------------------------------------------------------------

'* Raul D. Patterson Phone: (305) 717-5865

'* U. S. Geological Survey - WRD FAX: (305) 717-5801

'* 9100 NW 36th St., Suite 109

'* Miami, Florida 33178 USA Internet: rdpatter@usgs.gov

'*

'*=============================================================================

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*

'* Disclaimer: 

' Although this program has been used by the U.S. Geological Survey,

' no warranty, expressed or implied, is made by the USGS as to the

' accuracy and functioning of the program and related program

' material nor shall the fact of distribution constitute any such

' warranty, and no responsibility is assumed by the USGS in

' connection therewith.

'*

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*=============================================================================

'

'---VERSION 1.0 AVMODTMR 11MAY2001 9:19 AM

'

'::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'

' .. Purpose: gets executed before the extension objects are actually added to

' the project. This checks that the environment variable $AVMODTMR has been set

' in the operating system. This variable contains the path to the AVMODTMR ini

' file and should be set by the systems administrator. The ini file is looked

' for (using the path inidicated by $AVMODTMR) and if it is not found, then it

' is created by this script. The user the user is first prompted for a location 

' where to write the ini file (should be in the folder where the $AVMODTMR is 

' set to or will be set to subsequently) then for these three paths: 1. the 

' legends folder, 2. the images folder, and 3. the MODTMR executable folder. 

' From this the ini file is written, and the next time the extension is loaded, ' 

this script will again try to locate it. Only when the 3 paths can be 

' verified in this script will the loading of the extension proceed. Also, the

' global variable for the Time Unit Dictionary is created, as well as the splash 

' screen is displayed.

'

'0123456789012345678901234567890123456789012345678901234567890123456789012345678

theAvMODTMR_iniFileName = NIL

'look for AvMODTMR.ini file in $AVMODTMR:

'try locating $AVMODTMR:

theAVMODTMRPath = System.GetEnvVar("AVMODTMR")

if (theAVMODTMRPath = NIL) then 'the env var wasn't set, but AvMODTMR.ini may 

still exist

 MsgBox.Warning("the AVMODTMR environment variable has not been set. Set it 

pointing to "+

 "the location of the folders "+"legends".Quote+" and "+"images".Quote ++

 "(ie. c:\..\tmr-gui\) to avoid being prompted again next time you load "+

 "the AvMODTMR extension", "")

 theAvMODTMR_iniFileName = FileDialog.Show("*.ini", "AvMODTMR.ini File",

 "Click 'Cancel' if none found")

 if (theAvMODTMR_iniFileName = NIL) then
47

 theAvMODTMR_iniFileName = FileDialog.Put ("$HOME\AvMODTMR.ini".AsFileName, 

"*.ini", "")

 end

 if (theAvMODTMR_iniFileName = NIL) then

 MsgBox.Error("A Path for the AvMODTMR ini file must be given", "Can Not Load 

Extension")

 Return NIL

 end

 theAVMODTMRPath = System.SetEnvVar("AVMODTMR", 

theAvMODTMR_iniFileName.ReturnDir.AsString)

else

 'try to get ini file in $AVMODTMR:

 theAvMODTMR_iniFileName = "$AVMODTMR\AvMODTMR.ini".AsFileName

end

LegendPathOK = FALSE

ImagePathOK = FALSE

ExePathOK = FALSE

if (theAvMODTMR_iniFileName.IsFile) then

 

 'get the paths and parse its values into variables:

 theAvMODTMRIniFile = LineFile.Make(theAvMODTMR_iniFileName, #FILE_PERM_READ)

 thePathLineList = List.Make

 theAvMODTMRIniFile.Read(thePathLineList, 3)

 theAvMODTMRIniFile.Close

 theLegendPath = thePathLineList.Get(0).AsTokens("=").Get(1)

 if ( theLegendPath.AsFileName.IsDir ) then

 LegendPathOK = TRUE

 _theLegendPath = theLegendPath

 end

 theImagePath = thePathLineList.Get(1).AsTokens("=").Get(1)

 if ( theImagePath.AsFileName.IsDir ) then

 ImagePathOK = TRUE

 _theImagePath = theImagePath

 end

 theExePath = thePathLineList.Get(2).AsTokens("=").Get(1)

 if ( theExePath.AsFileName.IsDir ) then

 ExePathOK = TRUE

 _theExePath = theExePath

 end

end

 

if (LegendPathOK.Not) then

 theLegendFile = FileDialog.Show("*.avl", "AvMODTMR Legend File",

 "Select a legend file")

 if (theLegendFile = NIL) then

 MsgBox.Error("the AvMODTMR legends folder does not exist",

 "Can not load AvMODTMR Extension")

 Return NIL

 else

 theLegendPath = theLegendFile.ReturnDir.AsString

 _theLegendPath = theLegendPath

 end

end

 

if (ImagePathOK.Not) then

 theImageFile = FileDialog.Show("*.*", "AvMODTMR Image File",

 "Select an image file")

 if (theImageFile = NIL) then

 MsgBox.Error("the AvMODTMR images folder does not exist",
48

 "Can not load AvMODTMR Extension")

 Return NIL

 else

 theImagePath = theImageFile.ReturnDir.AsString

 _theImagePath = theImagePath

 end

end

if (ExePathOK.Not) then

 theExeFile = FileDialog.Show("*.exe", "MODTMR Executable",

 "Select the MODTMR exe file")

 if (theExeFile = NIL) then

 MsgBox.Error("the MODTMR executable does not exist",

 "Can not load AvMODTMR Extension")

 Return NIL

 else

 theExePath = theExeFile.ReturnDir.AsString

 _theExePath = theExePath

 end

end

if ( LegendPathOK.Not or ImagePathOK.Not or ExePathOK.Not ) then

 're-write AvMODTMR ini file

 theAvMODTMRIniFile = LineFile.Make(theAvMODTMR_iniFileName, #FILE_PERM_WRITE)

 aLineList = {"theLegendPath="+theLegendPath, "theImagePath="+theImagePath,

 "theMODTMRexePath="+theExePath}

 theAvMODTMRIniFile.Write(aLineList, 3)

 theAvMODTMRIniFile.Close

end

'Build the ITMUNI dictionary and set as a global variable:

theTimeUnitDict = Dictionary.Make(1)

theTimeUnitDict.Add("0","Undefined")

theTimeUnitDict.Add("1","Seconds")

theTimeUnitDict.Add("2","Minutes")

theTimeUnitDict.Add("3","Hours")

theTimeUnitDict.Add("4","Days")

theTimeUnitDict.Add("5","Years")

_theTimeUnitDict = theTimeUnitDict

'Show the splash screen:

theImageFileName = FileName.Make(theImagePath.AsString + "\" + 

"water_banner1.gif")

MsgBox.Banner (theImageFileName, 3, "ArcView MODTMR Extension")
49

'************* U.S. Geological Survey preliminary computer program ************

'******************************************************************************

'************* AvMODTMR.LoadParamToDialog **************

'******************************************************************************

'** Language: ArcView Avenue **

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*=============================================================================

'* Author/Site, Date, Event

'* --------------------------------------------------------------------------

'* Raul D. Patterson Phone: (305) 717-5865

'* U. S. Geological Survey - WRD FAX: (305) 717-5801

'* 9100 NW 36th St., Suite 109

'* Miami, Florida 33178 USA Internet: rdpatter@usgs.gov

'*

'*=============================================================================

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*

'* Disclaimer: 

' Although this program has been used by the U.S. Geological Survey,

' no warranty, expressed or implied, is made by the USGS as to the

' accuracy and functioning of the program and related program

' material nor shall the fact of distribution constitute any such

' warranty, and no responsibility is assumed by the USGS in

' connection therewith.

'*

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*=============================================================================

'

'---VERSION 1.0 AVMODTMR 11MAY2001 9:19 AM

'

'::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'

' .. Purpose: Called by the MODTMR Doc Activate script. Writes the parameters 

' stored in the object tags of the regional and grid themes to their respective

' controls in the dialog.

'01234567890123456789012345678901234567890123456789012345678901234567890123456789

theView = SELF.Get(0)

theMODTMR_Dlg = SELF.Get(1)

theLocThemeTypeFlag = "L"

theLocTheme = av.run("AvMODTMR.GetGridTheme", {theView, theLocThemeTypeFlag})

theRegThemeTypeFlag = "R"

theRegTheme = av.run("AvMODTMR.GetGridTheme", {theView, theRegThemeTypeFlag})

if ((theRegTheme = NIL).Not) then

 

 

 theRegParamList= theRegTheme.GetObjectTag

 

 

 MFNAME = theRegParamList.Get(1)

 if ((MFNAME = "").Not) then

 theMODTMR_Dlg.FindByName("txlRegNameFile").SetText(MFNAME)

 end

 theMODTMR_Dlg.FindByName("txlRegGridTheme").Update

 
50

 RegNLAY = theRegParamList.Get(10)

 if ((RegNLAY = "").Not) then

 theMODTMR_Dlg.FindByName("txlRegNLAY").SetText(RegNLAY)

 end

 RegITMUNI = theRegParamList.Get(11)

 if ((RegITMUNI = "").Not) then

 theMODTMR_Dlg.FindByName("txlRegITMUNI").SetText(RegITMUNI)

 end

 

 RegNROW = theRegParamList.Get(12)

 if ((RegNROW = "").Not) then

 theMODTMR_Dlg.FindByName("txlRegNROW").SetText(RegNROW)

 end

 

 RegNCOL = theRegParamList.Get(13)

 if ((RegNCOL = "").Not) then

 theMODTMR_Dlg.FindByName("txlRegNCOL").SetText(RegNCOL)

 end

 

 RegISSFlag = theRegParamList.Get(14)

 if (RegISSFlag = 0) then 

 theMODTMR_Dlg.FindByName("radRegTransient").Select

 elseif (RegISSFlag = 1) then

 theMODTMR_Dlg.FindByName("radRegSteadyState").Select

 end

 

 RegNPER = theRegParamList.Get(15)

 if ((RegNPER = "").Not) then

 theMODTMR_Dlg.FindByName("txlRegNPER").SetText(RegNPER)

 end

 

 theUnits = theRegParamList.Get(16)

 if ((theUnits = "").Not) then

 theMODTMR_Dlg.FindByName("txlUnits").SetText(theUnits)

 end

 thePathToFiles = theRegParamList.Get(17)

 if ((thePathToFiles = "").Not) then

 theMODTMR_Dlg.FindByName("txlPathToFiles").SetText(thePathToFiles)

 end

end

'Now, let's look at the local grid theme, if present, and fill its att's:

if ((theLocTheme = NIL).Not) then

 

 

 theLocParamList= theLocTheme.GetObjectTag

 

 theMODTMR_Dlg.FindByName("txlLocalGridTheme").Update

 

 theRegGridTheme = theLocParamList.Get(2)

 if ((theRegGridTheme = NIL).Not) then

 'continuetheMODTMR_Dlg.FindByName("txlRegNameFile").SetText(MFNAME)

 elseif ((theRegGridTheme.GetView = theLocTheme.GetView).Not) then

 'issue warning because the view does not contain a regional grid theme

 'IN FUTURE, PUT A MECHANISM TO DEAL WITH THIS, PREVENTING THE EXISTANCE

 'OF LOCAL GRID THEMES W/O A REG. GRID THEME.
51

 else

 'do something else

 end

 theLMDSN = theLocParamList.Get(3)

 if ((theLMDSN = "").Not) then

 theMODTMR_Dlg.FindByName("txlLocalNameFile").SetText(theLMDSN)

 end

 

 theLMPRF = theLocParamList.Get(4)

 if (theLMPRF = 0) then 

 theMODTMR_Dlg.FindByName("radAllPackages").Select

 elseif (RegISSFlag = 1) then

 theMODTMR_Dlg.FindByName("radFHBPkgOnly").Select

 end

 

 theNROW2 = theLocParamList.Get(6)

 if ((theNROW2 = "").Not) then

 theMODTMR_Dlg.FindByName("txtNROW2rpt").SetLabel("No. of Rows: "+theNROW2)

 end

 

 theNCOL2 = theLocParamList.Get(7)

 if ((theNCOL2 = "").Not) then

 theMODTMR_Dlg.FindByName("txtNCOL2rpt").SetLabel("No. of Columns: "+

 theNCOL2)

 end

 theITMUN2 = theLocParamList.Get(8)

 if ((theITMUN2 = "").Not) then

 cbxLocITMUNI = theMODTMR_Dlg.FindByName("cbxLocITMUNI")

 'SET THE VALUE OF THIS AND MAKE IT THE VISIBLE CHOICE:

 end

 

 theXCRNR2num = theLocParamList.Get(11).AsNumber

 theXCRNR2num.SetFormat("d.dd")

 theXCRNR2 = theXCRNR2num.AsString

 if ((theXCRNR2 = "").Not) then

 theMODTMR_Dlg.FindByName("txtXCRNR2rpt").SetLabel("Origin X-coor: "+

 theXCRNR2)

 end

 

 theYCRNR2num = theLocParamList.Get(12).AsNumber

 theYCRNR2num.SetFormat("d.dd")

 theYCRNR2 = theYCRNR2num.AsString

 if ((theYCRNR2 = "").Not) then

 theMODTMR_Dlg.FindByName("txtYCRNR2rpt").SetLabel("Origin Y-coor: "+

 theYCRNR2)

 end

 theANGL2num = theLocParamList.Get(13).AsNumber

 theANGL2num.SetFormat("d.dd")

 theANGL2 = theANGL2num.AsString

 if ((theANGL2 = "").Not) then

 theMODTMR_Dlg.FindByName("txtANGL2rpt").SetLabel("Rotation: "+theANGL2)

 end

 

 theDELR2 = theLocParamList.Get(14)

 if ((theDELR2 = "").Not) then

 theMODTMR_Dlg.FindByName("txtDELR2rpt").SetLabel("Row Height: "+theDELR2)

 end

 theDELC2 = theLocParamList.Get(15)

 if ((theDELC2 = "").Not) then
52

 theMODTMR_Dlg.FindByName("txtDELC2rpt").SetLabel("Column Width: "+theDELC2)

 end

 

 theIFHBUN = theLocParamList.Get(16)

 if ((theIFHBUN = NIL).Not) then

 theMODTMR_Dlg.FindByName("txlIFHBUN").SetText(theIFHBUN)

 end

end
53

'************* U.S. Geological Survey preliminary computer program ************

'******************************************************************************

'************* AvMODTMR.MakeCenteredLine ************

'******************************************************************************

'** Language: ArcView Avenue **

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*=============================================================================

'* Author/Site, Date, Event

'* --------------------------------------------------------------------------

'* Raul D. Patterson Phone: (305) 717-5865

'* U. S. Geological Survey - WRD FAX: (305) 717-5801

'* 9100 NW 36th St., Suite 109

'* Miami, Florida 33178 USA Internet: rdpatter@usgs.gov

'*

'*=============================================================================

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*

'* Disclaimer: 

' Although this program has been used by the U.S. Geological Survey,

' no warranty, expressed or implied, is made by the USGS as to the

' accuracy and functioning of the program and related program

' material nor shall the fact of distribution constitute any such

' warranty, and no responsibility is assumed by the USGS in

' connection therewith.

'*

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*=============================================================================

'

'---VERSION 1.0 AVMODTMR 11MAY2001 9:19 AM

'

'::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'

' .. Purpose: Receives an angle Theta, a point theCenPt, and a number 

' theLength. Creates and returns a line oriented at an angle Theta, centered 

' at point theCenPt and of length theLength.

'

'123456789012345678901234567890123456789012345678901234567890123456789012345678

Theta = SELF.Get(0)

theCenPt = SELF.Get(1)

theLength = SELF.Get(2)

theHalfLength = theLength / 2

theDeltaX = theHalfLength * Theta.Cos

theDeltaY = theHalfLength * Theta.Sin

theAxialBegPt = (theCenPt.GetX - theDeltaX)@(theCenPt.GetY - theDeltaY)

theAxialEndPt = (theCenPt.GetX + theDeltaX)@(theCenPt.GetY + theDeltaY)

theAxialLine = PolyLine.Make({{theAxialBegPt, theAxialEndPt}})

Return theAxialLine
54

'************* U.S. Geological Survey preliminary computer program ************

'******************************************************************************

'************* AvMODTMR.MakeLocalGridOutline ************

'******************************************************************************

'** Language: ArcView Avenue **

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*=============================================================================

'* Author/Site, Date, Event

'* --------------------------------------------------------------------------

'* Raul D. Patterson Phone: (305) 717-5865

'* U. S. Geological Survey - WRD FAX: (305) 717-5801

'* 9100 NW 36th St., Suite 109

'* Miami, Florida 33178 USA Internet: rdpatter@usgs.gov

'*

'*=============================================================================

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*

'* Disclaimer: 

' Although this program has been used by the U.S. Geological Survey,

' no warranty, expressed or implied, is made by the USGS as to the

' accuracy and functioning of the program and related program

' material nor shall the fact of distribution constitute any such

' warranty, and no responsibility is assumed by the USGS in

' connection therewith.

'*

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*=============================================================================

'

'---VERSION 1.0 AVMODTMR 11MAY2001 9:19 AM

'

'::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'

' .. Purpose: Receives the numbers X1, X2, Theta, H, and W. X1, Y1 are the x 

' and y coordinates of the Upper Left (UL) corner of a model grid; Theta is the

' angle of orientation of the grid relative to the pos x-axis, and H, W are the

' Height (length of a column) and Width (length of a row) of the grid. Computes

' the size and location of the rectangle forming the edge of the grid and calls

' the script 'AvMODTMR.DrawTempBox' to draw outline and origin of the grid.

'

'0123456789012345678901234567890123456789012345678901234567890123456789012345678

theView = av.GetActiveDoc

theGraphics = theView.GetGraphics

'Get all sent arguments:

X1 = Self.Get(0)

Y1 = Self.Get(1)

Theta = SELF.Get(2)

 Theta = Theta.AsRadians

H = Self.Get(3)

W = SELF.Get(4)

'Create graphic origin point and add to view:

 theOrigin = Point.Make(X1, Y1)

 

 

'Create graphic box and add to view:

 

 'create vertices:

 Theta2 = Theta

 X2 = X1 + (W*Theta2.Cos)
55

 Y2 = Y1 + (W*Theta2.Sin)

 

 Theta3 = Theta2 - (Number.GetPi/2)

 X3 = X2 + (H*Theta3.Cos)

 Y3 = Y2 + (H*Theta3.Sin)

 

 Theta4 = Theta3 - (Number.GetPi/2)

 X4 = X3 + (W*Theta4.Cos)

 Y4 = Y3 + (W*Theta4.Sin)

 

 'make box and add to view as a graphic:

 theBox = Polygon.Make( {{X1@Y1, X2@Y2, X3@Y3, X4@Y4}} )

 'Call the script to draw it:

 av.Run("AvMODTMR.DrawTempBox", {theOrigin, theBox})
56

'************* U.S. Geological Survey preliminary computer program ************

'******************************************************************************

'************* AvMODTMR.MakeLocGridTheme *************

'******************************************************************************

'** Language: ArcView Avenue **

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*=============================================================================

'* Author/Site, Date, Event

'* --------------------------------------------------------------------------

'* Raul D. Patterson Phone: (305) 717-5865

'* U. S. Geological Survey - WRD FAX: (305) 717-5801

'* 9100 NW 36th St., Suite 109

'* Miami, Florida 33178 USA Internet: rdpatter@usgs.gov

'*

'*=============================================================================

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*

'* Disclaimer: 

' Although this program has been used by the U.S. Geological Survey,

' no warranty, expressed or implied, is made by the USGS as to the

' accuracy and functioning of the program and related program

' material nor shall the fact of distribution constitute any such

' warranty, and no responsibility is assumed by the USGS in

' connection therewith.

'*

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*=============================================================================

'

'---VERSION 1.0 AVMODTMR 11MAY2001 9:19 AM

'

'::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'

' .. Purpose: Receives the variables to discretize, orient, and position the 

' local grid theme and then calls the script to Make grid w/o rotation 

' (AvMODTMR.CreateGrid), script to rotate grid if rotation <> 0 

' (AvMODTMR.RotateGrid), populates the local grid parameter list (the local grid 

' theme's obj. tag), and then creates the FHB theme.

'

'0123456789012345678901234567890123456789012345678901234567890123456789012345678

'Get parameters sent:

theX_coor = SELF.Get(0)

theY_coor = SELF.Get(1)

theRotation = SELF.Get(2)

theNROW2 = SELF.Get(3)

theDELR2 = SELF.Get(4)

theNCOL2 = SELF.Get(5)

theDELC2 = SELF.Get(6)

theView = SELF.Get(7)

theRegGridTheme = SELF.Get(8)

theFileName = SELF.Get(9)

'get file name for the local grid if not NIL:

if (theFileName = NIL) then

 

 theDlgMODTMR = av.FindDialog("AvMODTMR.DlgMODTMR")

 theOutName = theDlgMODTMR.FindByName("txlLocalNameFile").GetText

 theDefaultFileName = (FileName.GetCWD.AsString +"\"+theOutName).AsFileName

 theFileName = FileDialog.Put (theDefaultFileName, "*.shp", 

 "Save Output Local Grid")

 if (theFileName = NIL) then

 MsgBox.Warning("No Output Local Grid Shapefile specified", 

 "Can Not Proceed")
57

 Return Nil

 elseif ((theFileName.AsString.Right(4) = ".shp").Not) then

 theFileName = (theFileName.AsString + ".shp").AsFileName

 end

end

'create local grid:

av.Run("AvMODTMR.CreateGrid", {theX_coor, theY_coor, theNROW2,

 theNCOL2, theDELR2, theDELC2,theFileName})

theLocGridTheme = Theme.Make(theFileName.AsString.AsSrcName)

theView.AddTheme(theLocGridTheme)

'set legend:

theLocGridLegend = Legend.Make(#SYMBOL_FILL)

theLocGridLegendFileName = (_theLegendPath+"\locgrid.avl").AsFileName

theLocGridLegend.Load(theLocGridLegendFileName, #LEGEND_LOADTYPE_ALL)

theLocGridTheme.SetLegend(theLocGridLegend)

theLocGridTheme.SetVisible(TRUE)

'rotate grid as well, if rotation is not 0:

if (theRotation <> 0) then

 av.Run("AvMODTMR.RotateGrid", {theLocGridTheme, theRotation})

end

'add the "FHB_L#" fields to the local grid theme, one for each of the n layers

'in the regional model:

 

 aFieldList = {}

 theRegParamList = theRegGridTheme.GetObjectTag

 RegNLAY = theRegParamList.Get(10)

 for each n in 1..RegNLAY.AsNumber

 aFieldName = "FHB_L"+n.AsString

 aNewField = Field.Make (aFieldName, #FIELD_LONG, 1, 0)

 aFieldList.Add(aNewField)

 end

 

 'Add FHB fields:

 theLocGridFTab = theLocGridTheme.GetFTab

 theLocGridFTab.StartEditingWithRecovery

 theLocGridFTab.AddFields(aFieldList)

 theLocGridFTab.Flush

 theLocGridFTab.StopEditingWithRecovery(TRUE)

 'create the FHB theme by cloning the local grid theme: 

 theFHBTheme = theLocGridTheme.Clone

 theFHBTheme.SetName(theLocGridTheme.GetName++"FHB BCs")

 

 'set legend:

 aFHBLegend = Legend.Make(#SYMBOL_FILL)

 theFHBLegendFileName = (_theLegendPath+"\FHB.avl").AsFileName

 aFHBLegend.Load(theFHBLegendFileName, #LEGEND_LOADTYPE_ALL)

 theFHBTheme.SetLegend(aFHBLegend)

 

 qString = "( [Row] = 1) or ([Row] = "+theNROW2.AsString+") or "+

 "([Col] = 1) or ([Col] = "+theNCOL2.AsString+" )"

 theFHBVTab = theFHBTheme.GetFTab

 theFHBVTab.SetDefinition (qString)
58

 theView.AddTheme(theFHBTheme)

 theFHBTheme.SetVisible(TRUE)

'create and populate the param. list for the local grid:

theLocGridObjList = List.Make

theGridThemeType = "L"

DlgMODTMR = av.FindDialog("AvMODTMR.DlgMODTMR")

theRegGridTheme = theRegGridTheme

LMDSN = DlgMODTMR.FindByName("txlLocalNameFile").GetText

theLMPRFoption = DlgMODTMR.FindByName("cpaLMPRF").GetSelected.GetLabel

if (theLMPRFoption = "FHB Package Only") then

 LMPRF = "1"

elseif (theLMPRFoption = "All Packages") then

 LMPRF = "0"

end

 

'Populate the LML dictionary so all regional layers are used (as default):

RegLayCount = DlgMODTMR.FindByName("txlRegNLAY").GetText.AsNumber

LML = Dictionary.Make(RegLayCount)

for each i in 1..RegLayCount by 1

 LML.Add(i, 1) 'All 1's since we start out with all the Reg layers.

end

NROW2 = theNROW2.AsString

NCOL2 = theNCOL2.AsString

ITMUN2text = DlgMODTMR.FindByName("txlRegITMUNI").GetText

ITMUN2 = NIL

for each i in 0..5

 aTimeTextValue = _theTimeUnitDict.Get(i.AsString)

 if (aTimeTextValue = ITMUN2text) then

 ITMUN2 = i

 break

 end

end

XYFAC2 = 1.AsString

ICRNR2 = 1.AsString

 

XCRNR2 = theX_coor.SetFormat("d.dd").AsString

YCRNR2 = theY_coor.SetFormat("d.dd").AsString

theAngle = av.Run("AvMODTMR.Return0to360Angle", {theRotation})

ANGL2 = theAngle.SetFormat("d.dd").AsString

DELR2 = theDELR2.AsString

DELC2 = theDELC2.AsString

IFHBUN = NIL

txlIFHBUN = DlgMODTMR.FindByName("txlIFHBUN")

if ((txlIFHBUN.GetText = NIL).Not) then

 IFHBUN = txlIFHBUN.GetText

end

theLocGridObjList = {theGridThemeType, theFHBTheme, theRegGridTheme,

 LMDSN, LMPRF, LML, NROW2, NCOL2, ITMUN2, XYFAC2, ICRNR2, XCRNR2,
59

 YCRNR2, ANGL2, DELR2, DELC2, IFHBUN}

theLocGridTheme.SetObjectTag(theLocGridObjList)

av.GetProject.SetModified(TRUE)
60

'************* U.S. Geological Survey preliminary computer program ************

'******************************************************************************

'************* AvMODTMR.MakeOrientedBox *************

'******************************************************************************

'** Language: ArcView Avenue **

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*=============================================================================

'* Author/Site, Date, Event

'* --------------------------------------------------------------------------

'* Raul D. Patterson Phone: (305) 717-5865

'* U. S. Geological Survey - WRD FAX: (305) 717-5801

'* 9100 NW 36th St., Suite 109

'* Miami, Florida 33178 USA Internet: rdpatter@usgs.gov

'*

'*=============================================================================

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*

'* Disclaimer: 

' Although this program has been used by the U.S. Geological Survey,

' no warranty, expressed or implied, is made by the USGS as to the

' accuracy and functioning of the program and related program

' material nor shall the fact of distribution constitute any such

' warranty, and no responsibility is assumed by the USGS in

' connection therewith.

'*

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*=============================================================================

'

'---VERSION 1.0 AVMODTMR 11MAY2001 9:19 AM

'

'::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'

' .. Purpose: Receives the View, and the numbers DELC and DELR. Finds the 

' graphics named "theLocalPolygon", and "theDirectionLine" in the view 

' and then constructs a bounding rectangle that is circumscribed around the 

' Local Polygon and oriented in the direction of the Direction Line. From the

' rectangle it obtains the Upper Left corner of the model domain (ie. theX_coor

' and theY_coor), the number of columns, and rows (NCOL and NROW), and the 

' Rotation angle (theRotation). The circumscribed rectangle almost always

' extends slightly beyond the bounds of the Local Polygon since the DELC and 

' DELR are constant and NROW and NCOL are integers.

'

'123456789012345678901234567890123456789012345678901234567890123456789012345678

theView = SELF.Get(0)

DELC = SELF.Get(1)

DELR = SELF.Get(2)

theView = av.GetActiveDoc

theGraphics = theView.GetGraphics

theLocPoly = theGraphics.FindByName("theLocalPolygon").GetShape

theDirLine = theGraphics.FindByName("theDirectionLine").GetShape

'Get properties of poly to be used to construct lines:

theLength = theLocPoly.ReturnLength

theHalfLength = theLength / 2

theCenPt = theLocPoly.ReturnCenter

'Get theDirLine's slope as a pos angle relative to the pos x-axis:

ThetaDeg = av.Run("AvMODTMR.ReturnAngleNormalized", {theDirLine})

Theta = ThetaDeg.AsRadians
61

'Create Axial Line. Passes through centroid of theLocPoly and is of length 

'equal to the Lengtheter of same.

theAxialLine = av.Run("AvMODTMR.MakeCenteredLine", {Theta, theCenPt, theLength})

'Create Transverse Line. Perpendicular to Axial Line, through poly center and

'same length (eq. to poly Length).

'create begining point:

theTransAngle = Theta + (Number.GetPi/2)

theTransLine = av.Run("AvMODTMR.MakeCenteredLine", {theTransAngle, theCenPt, 

 theLength})

theTransLine = theTransLine.Flip

'Create the Axial pair lines and the Transverse pair lines:

theAxialPair = av.Run("AvMODTMR.ReturnLinesOffsetToPolyBnd", {theLocPoly, 

 theAxialLine})

theRightLine = theAxialPair.Get(0)

theLeftLine = theAxialPair.Get(1)

theTransPair = av.Run("AvMODTMR.ReturnLinesOffsetToPolyBnd", {theLocPoly, 

 theTransLine})

theBackLine = theTransPair.Get(0)

theFrontLine = theTransPair.Get(1)

'Intersect lines to create points 1, 2, & 4 (defining the oriented bounding 

'box around the poly, numbered clockwise):

Pt1 = theLeftLine.PointIntersection(theBackLine).AsList.Get(0)

Pt2 = theFrontLine.PointIntersection(theLeftLine).AsList.Get(0)

Pt4 = theRightLine.PointIntersection(theBackLine).AsList.Get(0)

theNCOL = (Pt1.Distance(Pt2)/DELC).Ceiling

theNROW = (Pt1.Distance(Pt4)/DELR).Ceiling

theX_coor = Pt1.GetX

theY_coor = Pt1.GetY

theRotation = ThetaDeg

Return {theNCOL, theNROW, theX_coor, theY_coor, theRotation}
62

'************* U.S. Geological Survey preliminary computer program ************

'******************************************************************************

'************* AvMODTMR.Modify_CreateLocGrid ************

'******************************************************************************

'** Language: ArcView Avenue **

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*=============================================================================

'* Author/Site, Date, Event

'* --------------------------------------------------------------------------

'* Raul D. Patterson Phone: (305) 717-5865

'* U. S. Geological Survey - WRD FAX: (305) 717-5801

'* 9100 NW 36th St., Suite 109

'* Miami, Florida 33178 USA Internet: rdpatter@usgs.gov

'*

'*=============================================================================

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*

'* Disclaimer: 

' Although this program has been used by the U.S. Geological Survey,

' no warranty, expressed or implied, is made by the USGS as to the

' accuracy and functioning of the program and related program

' material nor shall the fact of distribution constitute any such

' warranty, and no responsibility is assumed by the USGS in

' connection therewith.

'*

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*=============================================================================

'

'---VERSION 1.0 AVMODTMR 11MAY2001 9:19 AM

'

'::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'

' .. Purpose: receives the dialog and the active view; from the dialog it gets 

' all the values stored in the text lines; from the active view it gets the 

' Regional grid theme and the Local Grid theme (if one exists). If a Local 

' grid theme exists, it modifies it if its geometry has been altered (ie. 

' rotation change or re-discretizing); if one does not exist or if it does but

' its geometry has been altered, then it is created, by calling the script 

' "AvMODTMR.MakeLocGridTheme".

'

'0123456789012345678901234567890123456789012345678901234567890123456789012345678

theView = SELF.Get(0)

dlgDefineLocGrid = SELF.Get(1)

'find local grid and regional grid:

theLocGridTypeFlag = "L"

theLocGridTheme = av.Run("AvMODTMR.GetGridTheme", {theView, theLocGridTypeFlag})

theRegGridTypeFlag = "R"

theRegGridTheme = av.Run("AvMODTMR.GetGridTheme", {theView, theRegGridTypeFlag})

theX_coorString = dlgDefineLocGrid.FindByName("txlXcoor").GetText

theX_coor = theX_coorString.AsNumber.SetFormat("d.dd")

theY_coorString = dlgDefineLocGrid.FindByName("txlYcoor").GetText

theY_coor = theY_coorString.AsNumber.SetFormat("d.dd")

theRotationString = dlgDefineLocGrid.FindByName("txlRotation").GetText

theRotation = theRotationString.AsNumber.SetFormat("d.dd")

theNROW2 = dlgDefineLocGrid.FindByName("txlNROW2").GetText.AsNumber

theDELR2 = dlgDefineLocGrid.FindByName("txlDELR2").GetText.AsNumber.SetFormat("d.dd")
63

theNCOL2 = dlgDefineLocGrid.FindByName("txlNCOL2").GetText.AsNumber

theDELC2 = dlgDefineLocGrid.FindByName("txlDELC2").GetText.AsNumber.SetFormat("d.dd")

if (theLocGridTheme = NIL) then

 'then create it:

 av.Run("AvMODTMR.MakeLocGridTheme", {theX_coor, theY_coor, theRotation, 

 theNROW2, theDELR2, theNCOL2, theDELC2, theView, theRegGridTheme, 

 NIL})

 theView.Invalidate

 Return NIL

end

'run tests to find out what needs to be done (rotate/translate, regrid):

theLocParamList = theLocGridTheme.GetObjectTag

 

'Check to see if regridding is necessary, if it is, then delete local grid & 

'its FHB theme:

Regridding = FALSE

theOldNROW2 = theLocParamList.Get(6).AsNumber

theOldNCOL2 = theLocParamList.Get(7).AsNumber

theOldDELR2 = theLocParamList.Get(14).AsNumber.SetFormat("d.dd")

theOldDELC2 = theLocParamList.Get(15).AsNumber.SetFormat("d.dd")

ChangeInNROW2 = theNROW2 - theOldNROW2

ChangeInNCOL2 = theNCOL2 - theOldNCOL2

ChangeInDELR2 = theDELR2 - theOldDELR2

ChangeInDELC2 = theDELC2 - theOldDELC2

'Check if re-gridding is required, if yes, call AvMODTMR.MakeLocGridTheme, 

'sending it the new local grid dimension parameters:

if ((ChangeInNROW2 <> 0) or (ChangeInNCOL2 <> 0) or (ChangeInDELR2 <> 0) or

 (ChangeInDELC2 <> 0)) then

 Regridding = TRUE

end

'then it must be deleted and re-created:

if (Regridding) then

 'get its file name before deleting the theme to re-use it:

 theLocGridFileName = theLocGridTheme.GetSrcName.GetFileName

 

 'delete the local theme, its FHB theme and their tables:

 av.run("AvMODTMR.DeleteLocGridThemes", {theView, theLocGridTheme})

 

 'recreate the local grid:

 av.Run("AvMODTMR.MakeLocGridTheme", {theX_coor, theY_coor, theRotation, 

 theNROW2, theDELR2, theNCOL2, theDELC2, theView, theRegGridTheme, 

 theLocGridFileName})

 Return NIL

end

'regrid or rotate/translate, if necessary:

'Check to see if there's been any change in origin location or rotation:

theCurrentX_coor = theLocParamList.Get(11).AsNumber

theCurrentY_coor = theLocParamList.Get(12).AsNumber
64

 

if ((theCurrentX_coor <> theX_coor) or (theCurrentY_coor <> theY_coor)) then

 'ie., translation required:

 av.Run("AvMODTMR.TranslateGrid", {theLocGridTheme, theX_coor, theY_coor})

 theLocParamList.Set(11, theX_coor.AsString)

 theLocParamList.Set(12, theY_coor.AsString)

 theLocGridTheme.SetObjectTag(theLocParamList)

 av.GetProject.SetModified(TRUE)

end

'Check to see if there's been any change in rotation:

theCurrentRotation = theLocParamList.Get(13).AsNumber 

if (theCurrentRotation <> theRotation) then

 'ie., rotation required:

 av.Run("AvMODTMR.RotateGrid", {theLocGridTheme, theRotation})

 theAngle = av.Run("AvMODTMR.Return0to360Angle", {theRotation})

 theLocParamList.Set(13, theAngle.AsString)

 theLocGridTheme.SetObjectTag(theLocParamList)

 av.GetProject.SetModified(TRUE)

end
65

'************* U.S. Geological Survey preliminary computer program ************

'******************************************************************************

'************* AvMODTMR.OpenDlgMODTMR *************

'******************************************************************************

'** Language: ArcView Avenue **

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*=============================================================================

'* Author/Site, Date, Event

'* --------------------------------------------------------------------------

'* Raul D. Patterson Phone: (305) 717-5865

'* U. S. Geological Survey - WRD FAX: (305) 717-5801

'* 9100 NW 36th St., Suite 109

'* Miami, Florida 33178 USA Internet: rdpatter@usgs.gov

'*

'*=============================================================================

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*

'* Disclaimer: 

' Although this program has been used by the U.S. Geological Survey,

' no warranty, expressed or implied, is made by the USGS as to the

' accuracy and functioning of the program and related program

' material nor shall the fact of distribution constitute any such

' warranty, and no responsibility is assumed by the USGS in

' connection therewith.

'*

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*=============================================================================

'

'---VERSION 1.0 AVMODTMR 11MAY2001 9:19 AM

'

'::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'

' .. Purpose: launched by button in view GUI, this script opens the MODTMR

' dialog. It first checks that the project has been saved and prompts user to

' do so if it has not. Then, it searches for the regional grid theme in the

' view, and prompts the user to add it with a browse window if there isn't one.

' Regional Grid theme is added to the view with a pre-defined legend, its

' object tag is initialized with the parameter list, and the parameter list is

' filled with empty values that are place-holders, except for a few basic 

' geometry information that is determined from the theme itself by calling

' 'AvMODTMR.GetGridGeometry'. Finally, the 'AvMODTMR.LoadParamToDialog' is 

' called to load the parameters to the dialog.

'

'0123456789012345678901234567890123456789012345678901234567890123456789012345678

theView = av.GetActiveDoc

'Make sure the project has been saved:

theProjectHasBeenSaved = TRUE

if (av.GetProject.GetFileName = NIL) then

 theProjectHasBeenSaved = FALSE

 av.Run("Project.Save", {})

 theProjectFileName = av.GetProject.GetFileName

 if (theProjectFileName = NIL) then

 MsgBox.Error("You can not continue unless you save the project first", "")

 Return NIL

 end

end

ThereIsAGridThemeAlready = FALSE

for each T in theView.GetThemes

 if ((T.GetObjectTag.Is(List)) and (T.GetObjectTag.Get(0) = "R")) then
66

 ThereIsAGridThemeAlready = TRUE

 break

 end

end

DlgMODTMR = av.FindDialog("AvMODTMR.DlgMODTMR")

if (ThereIsAGridThemeAlready.Not) then

 LoadExistingRegGridTheme = MsgBox.YesNo("Would you like to add a Regional "+

 "Grid theme?", "No Regional Grid Theme in View", TRUE)

 if (LoadExistingRegGridTheme) then

 theRegGridThemeFileName = FileDialog.Show ("*.shp", "ArcView Shapefile",

 "Select the Regional Grid Theme")

 theRegGridThemeSrcName = SrcName.Make(theRegGridThemeFileName.AsString)

 theRegGridTheme = Theme.Make(theRegGridThemeSrcName)

 

 'Initialize the object tag of the local grid theme:

 

 theLocGridObjList = List.Make

 

 theGridThemeType = "R"

 MFNAME = ""

 XYFAC1 = 1

 ICRNR1 = 1

 

 regGridGeomParamList = av.Run("AvMODTMR.GetGridGeometry", {theRegGridTheme})

 XCRNR1 = regGridGeomParamList.Get(0)

 YCRNR1 = regGridGeomParamList.Get(1)

 ANGL1 = regGridGeomParamList.Get(2)

 XXCBC = ""

 XXHED = ""

 UsedIUNITS = ""

 RegNLAY = ""

 RegITMUNI = ""

 RegNROW = ""

 RegNCOL = ""

 theISSFlag = ""

 RegNPER = ""

 theUnits = ""

 thePathToFiles = ""

 theRegParamList = {theGridThemeType, MFNAME, XYFAC1, ICRNR1, XCRNR1, 

 YCRNR1, ANGL1, XXCBC, XXHED, UsedIUNITS, RegNLAY, RegITMUNI, RegNROW,

 RegNCOL, theISSFlag, RegNPER, theUnits, thePathToFiles}

 

 

 theRegGridTheme.SetObjectTag(theRegParamList)

 

 theView.AddTheme(theRegGridTheme)

 theRegGridTheme.SetVisible(TRUE)

 theRegGridThemeLegend = Legend.Make(#SYMBOL_FILL)

 

 theRegGridAVL = (_theLegendPath+"\reggrid.avl").AsFileName

 

 theRegGridThemeLegend.Load( theRegGridAVL , #LEGEND_LOADTYPE_ALL)

 theRegGridTheme.SetLegend(theRegGridThemeLegend)

 theRegGridTheme.UpdateLegend

 theView.Invalidate

 av.GetProject.SetModified(TRUE)

 

 'CLEAR UP ALL CONTROLS BECAUSE IT'S A NEW TMR VIEW:

 theTextLineControls = DlgMODTMR.FindByClass(TextLine)

 for each aControl in theTextLineControls
67

 aControl.SetText("")

 end

 

 

 else

 MsgBox.Info("No regional grid theme, no AvMODTMR", 

 "Can Not Continue Without a Regional Grid Theme")

 return NIL

 end

else

 theControls = DlgMODTMR.FindByClass(Control)

 for each aControl in theControls

 aControl.SetEnabled(TRUE)

 end

 av.run("AvMODTMR.LoadParamToDialog", {theView, DlgMODTMR})

end

'UPDATE SCRIPTS TO LAUNCH:

DlgMODTMR.FindByName("cbxLocITMUNI").Update

'Update the Reg Grid theme text line:

DlgMODTMR.FindByName("txlRegGridTheme").Update

'Update the Local Grid theme text line:

DlgMODTMR.FindByName("txlLocalGridTheme").Update

DlgMODTMR.Update

DlgMODTMR.Open
68

'************* U.S. Geological Survey preliminary computer program ************

'******************************************************************************

'************* AvMODTMR.Return0to360Angle *************

'******************************************************************************

'** Language: ArcView Avenue **

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*=============================================================================

'* Author/Site, Date, Event

'* --------------------------------------------------------------------------

'* Raul D. Patterson Phone: (305) 717-5865

'* U. S. Geological Survey - WRD FAX: (305) 717-5801

'* 9100 NW 36th St., Suite 109

'* Miami, Florida 33178 USA Internet: rdpatter@usgs.gov

'*

'*=============================================================================

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*

'* Disclaimer: 

' Although this program has been used by the U.S. Geological Survey,

' no warranty, expressed or implied, is made by the USGS as to the

' accuracy and functioning of the program and related program

' material nor shall the fact of distribution constitute any such

' warranty, and no responsibility is assumed by the USGS in

' connection therewith.

'*

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*=============================================================================

'

'---VERSION 1.0 AVMODTMR 11MAY2001 9:19 AM

'

'::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'

' .. Purpose: receives an angle in degrees and returns the angle expressed as 

' degrees CCW from pos-X axis.

'

'123456789012345678901234567890123456789012345678901234567890123456789012345678

theAngle = SELF.Get(0)

if (theAngle.Abs > 360) then

 theAngle = theAngle.Mod(360)

end

if (theAngle < 0) then

 theAngle = 360 + theAngle

end

Return theAngle
69

'************* U.S. Geological Survey preliminary computer program ************

'******************************************************************************

'************* AvMODTMR.ReturnACertainCell **************

'******************************************************************************

'** Language: ArcView Avenue **

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*=============================================================================

'* Author/Site, Date, Event

'* --------------------------------------------------------------------------

'* Raul D. Patterson Phone: (305) 717-5865

'* U. S. Geological Survey - WRD FAX: (305) 717-5801

'* 9100 NW 36th St., Suite 109

'* Miami, Florida 33178 USA Internet: rdpatter@usgs.gov

'*

'*=============================================================================

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*

'* Disclaimer: 

' Although this program has been used by the U.S. Geological Survey,

' no warranty, expressed or implied, is made by the USGS as to the

' accuracy and functioning of the program and related program

' material nor shall the fact of distribution constitute any such

' warranty, and no responsibility is assumed by the USGS in

' connection therewith.

'*

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*=============================================================================

'

'---VERSION 1.0 AVMODTMR 11MAY2001 9:19 AM

'

'::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'

' .. Purpose: receives the attribute table of a grid (polygonal) theme, and 

' returns the cell with the sequence number given by the argument "theCellNo"

' NOTE: the field "Seqnum" is hardcode in this script and so it must be in the

' attribute table. This should contain the sequential numbering of the cell

' ids, which customarily start with 1 at Row 1, Col 1, increment through the

' cells of the row and then begin at Col 1 of the next row, and so on.

'

'0123456789012345678901234567890123456789012345678901234567890123456789012345678

theVTab = SELF.Get(0)

theCellNo = SELF.Get(1)

theSeqnumFld = theVTab.FindField("Seqnum")

theShapeFld = theVTab.FindField("Shape")

theCell = NIL

for each aRow in theVTab

 theSeqnum = theVTab.ReturnValue(theSeqnumFld, aRow)

 if (theSeqnum = theCellNo) then

 theCell = theVTab.ReturnValue(theShapeFld, aRow)

 break

 end

end

if (theCell = NIL) then

 MsgBox.Error("No such cell found in the grid theme", "Terminating")

 Return Nil

else

 Return theCell

end
70

'************* U.S. Geological Survey preliminary computer program ************

'******************************************************************************

'************* AvMODTMR.ReturnAngleNormalized *************

'******************************************************************************

'** Language: ArcView Avenue **

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*=============================================================================

'* Author/Site, Date, Event

'* --------------------------------------------------------------------------

'* Raul D. Patterson Phone: (305) 717-5865

'* U. S. Geological Survey - WRD FAX: (305) 717-5801

'* 9100 NW 36th St., Suite 109

'* Miami, Florida 33178 USA Internet: rdpatter@usgs.gov

'*

'*=============================================================================

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*

'* Disclaimer: 

' Although this program has been used by the U.S. Geological Survey,

' no warranty, expressed or implied, is made by the USGS as to the

' accuracy and functioning of the program and related program

' material nor shall the fact of distribution constitute any such

' warranty, and no responsibility is assumed by the USGS in

' connection therewith.

'*

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*=============================================================================

'

'---VERSION 1.0 AVMODTMR 11MAY2001 9:19 AM

'

'::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'

' .. Purpose: takes in a line and returns the angle it makes with the positive

' X-axis.

'

'123456789012345678901234567890123456789012345678901234567890123456789012345678

theDirLine = SELF.Get(0)

theBegPt = theDirLine.Along(0)

theEndPt = theDirLine.Along(100)

X1 = theBegPt.GetX

Y1 = theBegPt.GetY

X2 = theEndPt.GetX

Y2 = theEndPt.GetY

Hyp = theDirLine.ReturnLength

'Account for angles of 0, 90, 180, and 270:

if (Y1 = Y2) then

 if (X1 < X2) then

 ThetaDeg = 0

 elseif (X1 > X2) then

 ThetaDeg = 180

 end

 Return ThetaDeg

end

if (X1 = X2) then

 if (Y1 < Y2) then

 ThetaDeg = 90

 elseif (Y1 > Y2) then

 ThetaDeg = 270

 end
71

 Return ThetaDeg

end

Adj = X2 - X1

Opp = Y2 - Y1

CosPhi = Adj/Hyp

SinPhi = Opp/Hyp

TanPhi = Opp/Adj

Theta = NIL

if ((SinPhi > 0) and (CosPhi > 0)) then

 Phi = SinPhi.ASin

 Theta = Phi

elseif ((SinPhi > 0) and (CosPhi < 0)) then

 Phi = SinPhi.ASin

 Theta = (Number.GetPi) - Phi

elseif ((SinPhi < 0) and (CosPhi < 0)) then

 Phi = TanPhi.ATan

 Theta = (Number.GetPi) + Phi

elseif ((SinPhi < 0) and (CosPhi > 0)) then

 Phi = CosPhi.ACos

 Theta = (2 * Number.GetPi) - Phi

end

ThetaDeg = Theta * (180/Number.GetPi)

Return ThetaDeg
72

'************* U.S. Geological Survey preliminary computer program ************

'******************************************************************************

'************* AvMODTMR.ReturnLinesOffsetToPolyBnd ***********

'******************************************************************************

'** Language: ArcView Avenue **

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*=============================================================================

'* Author/Site, Date, Event

'* --------------------------------------------------------------------------

'* Raul D. Patterson Phone: (305) 717-5865

'* U. S. Geological Survey - WRD FAX: (305) 717-5801

'* 9100 NW 36th St., Suite 109

'* Miami, Florida 33178 USA Internet: rdpatter@usgs.gov

'*

'*=============================================================================

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*

'* Disclaimer: 

' Although this program has been used by the U.S. Geological Survey,

' no warranty, expressed or implied, is made by the USGS as to the

' accuracy and functioning of the program and related program

' material nor shall the fact of distribution constitute any such

' warranty, and no responsibility is assumed by the USGS in

' connection therewith.

'*

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*=============================================================================

'

'---VERSION 1.0 AVMODTMR 11MAY2001 9:19 AM

'

'::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'

' .. Purpose: receives the 'Local Polygon' and the 'Direction Line', and returns

' lines parallel to the Direction Line, and tangent to the Local Polygon.

'

'0123456789012345678901234567890123456789012345678901234567890123456789012345678

theLocPoly = SELF.Get(0)

theDirLine = SELF.Get(1)

'Find the farthest pt on the right and left sides:

 theLeftMaxDist = 0

 theRightMaxDist = 0

 for each n in 0..100 by 0.1

 thePointAlongPoly = theLocPoly.Along(n)

 theDist = -1 * theDirLine.QueryPointDistance(thePointAlongPoly,1)

 if (theDist > 0) then

 if (theDist > theRightMaxDist) then

 theRightMaxDist = theDist

 end

 else

 if (theDist < theLeftMaxDist) then

 theLeftMaxDist = theDist

 end

 end

 end 

 

 theRightLine = theDirLine.ReturnOffset(theRightMaxDist)

 theLeftLine = theDirLine.ReturnOffset(theLeftMaxDist)

 

 theLinePair = {theRightLine, theLeftLine}

 

 Return theLinePair
73

'************* U.S. Geological Survey preliminary computer program ************

'******************************************************************************

'************* AvMODTMR.ReturnLoneVertex **************

'******************************************************************************

'** Language: ArcView Avenue **

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*=============================================================================

'* Author/Site, Date, Event

'* --------------------------------------------------------------------------

'* Raul D. Patterson Phone: (305) 717-5865

'* U. S. Geological Survey - WRD FAX: (305) 717-5801

'* 9100 NW 36th St., Suite 109

'* Miami, Florida 33178 USA Internet: rdpatter@usgs.gov

'*

'*=============================================================================

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*

'* Disclaimer: 

' Although this program has been used by the U.S. Geological Survey,

' no warranty, expressed or implied, is made by the USGS as to the

' accuracy and functioning of the program and related program

' material nor shall the fact of distribution constitute any such

' warranty, and no responsibility is assumed by the USGS in

' connection therewith.

'*

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*=============================================================================

'

'---VERSION 1.0 AVMODTMR 11MAY2001 9:19 AM

'

'::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'

' .. Purpose: receives a Cell, the Attribute Table of the Grid Theme, and a 

' distance (theMinDist) and returns the lone vertex in the Cell, which is the 

' vertex that is not touching any other cells.

'

'0123456789012345678901234567890123456789012345678901234567890123456789012345678

theCell = SELF.Get(0)

theVTab = SELF.Get(1)

theMinDist = SELF.Get(2)

theMinDist = 1

theShapeFld = theVTab.FindField("Shape")

theListOfVertices = theCell.AsMultiPoint.AsList

theLoneVertex = NIL

theThreshDist = theMinDist/2

aCountOfTouches = 0

for each aVert in theListOfVertices

 for each aRec in theVTab

 aCell = theVTab.ReturnValue(theShapeFld, aRec)

 if (aVert.Distance(aCell) < theThreshDist) then

 aCountOfTouches = aCountOfTouches + 1

 end

 if (aCountOfTouches > 1) then

 aCountOfTouches = 0

 break

 end

 end
74

 if (aCountOfTouches = 1) then

 theLoneVertex = aVert

 break

 end

end

if (theLoneVertex = NIL) then

 MsgBox.Error("No lone vertex found", "Terminating")

 Return Nil

else

 Return theLoneVertex

end
75

'************* U.S. Geological Survey preliminary computer program ************

'******************************************************************************

'************* AvMODTMR.RotateGrid **************

'******************************************************************************

'** Language: ArcView Avenue **

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*=============================================================================

'* Author/Site, Date, Event

'* --------------------------------------------------------------------------

'* Raul D. Patterson Phone: (305) 717-5865

'* U. S. Geological Survey - WRD FAX: (305) 717-5801

'* 9100 NW 36th St., Suite 109

'* Miami, Florida 33178 USA Internet: rdpatter@usgs.gov

'*

'*=============================================================================

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*

'* Disclaimer: 

' Although this program has been used by the U.S. Geological Survey,

' no warranty, expressed or implied, is made by the USGS as to the

' accuracy and functioning of the program and related program

' material nor shall the fact of distribution constitute any such

' warranty, and no responsibility is assumed by the USGS in

' connection therewith.

'*

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*=============================================================================

'

'---VERSION 1.0 AVMODTMR 11MAY2001 9:19 AM

'

'::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'

' .. Purpose: Receives the grid theme to be rotated and a rotation angle. 

' Obtains the current rotation angle of the grid, as well as the x and y coor's

' of the origin, by calling 'AvMODTMR.GetGridGeometry'. Then, it computes the 

' difference between the angles and rotates each vertex of each cell by that

' angle difference using the distance from each vertex to the origin as the 

' radius of rotation, pivoted about the origin. 

'

'123456789012345678901234567890123456789012345678901234567890123456789012345678

theGridTheme = SELF.Get(0)

theNewANGL = SELF.Get(1)

'Get theNewANGL to be from 0 to 360:

if (theNewANGL.Abs > 360) then

 theNewANGL = theNewANGL.Mod(360)

end

if (theNewANGL < 0) then

 theNewANGL = 360 + theNewANGL

end

theCurrentParam = av.Run ("AvMODTMR.GetGridGeometry", {theGridTheme})

 Xorigin = theCurrentParam.Get(0).AsNumber

 Yorigin = theCurrentParam.Get(1).AsNumber

theCurrentANGL = theCurrentParam.Get(2).AsNumber

'Get theCurrentANGL to be from 0 to 360:

if (theCurrentANGL.Abs > 360) then

 theCurrentANGL = theCurrentANGL.Mod(360)
76

end

if (theCurrentANGL < 0) then

 theCurrentANGL = 360 + theCurrentANGL

end

'Get the difference of the new and curr angl's to be bet. -180 & 180:

theDeltaANGL = theNewANGL - theCurrentANGL

if (theDeltaANGL > 180) then

 theDeltaANGL = theDeltaANGL - 360

elseif (theDeltaANGL < -180) then

 theDeltaANGL = theDeltaANGL + 360

end

theFTab = theGridTheme.GetFTab

theShapeF = theFTab.FindField("Shape")

theSeqnumF = theFTab.FindField("Seqnum")

theFTab.StartEditingWithRecovery

aTempList = List.Make

total = theFTab.GetNumRecords

i = 0

av.ShowMsg ("Rotating Grid...")

for each aRec in theFTab

 i = i + 1

 aTempList.Empty

 

 PercentDone = (i / total)*100

 av.SetStatus(PercentDone)

 

 aCell = theFTab.ReturnValue(theShapeF, aRec)

 

 theListOfSegments = aCell.AsList

 theListOfVertices = theListOfSegments.Get(0)

 

 for each aVertex in theListOfVertices

 

 X1world = aVertex.GetX

 Y1world = aVertex.GetY

 X1 = X1world - Xorigin

 Y1 = Y1world - Yorigin

 r = ((X1^2) + (Y1^2)).Sqrt

 

 if (r > 0) then

 

 Theta1 = (Y1/X1).Atan

 Theta1_deg = Theta1.AsDegrees

 

 'Make sure Theta1_deg in deg CCW:

 if (X1 < 0) then

 Theta1_deg = Theta1_deg + 180

 end

 

 Theta2_deg = Theta1_deg + theDeltaANGL

 

 Theta2 = Theta2_deg.AsRadians 

 X2 = r * (Theta2.Cos)

 Y2 = r * (Theta2.Sin)

 X2world = Xorigin + X2
77

 Y2world = Yorigin + Y2

 

 aVertex.SetX(X2world)

 aVertex.SetY(Y2world)

 end

 

 aTempList.Add(aVertex)

 

 end

 

 aMovedCell = Polygon.Make({aTempList})

 

 theFTab.SetValue(theShapeF, aRec, aMovedCell)

 

end

av.ShowMsg("")

av.ClearStatus

theFTab.StopEditingWithRecovery(TRUE)
78

'************* U.S. Geological Survey preliminary computer program ************

'******************************************************************************

'************* AvMODTMR.SetLayersUsed **************

'******************************************************************************

'** Language: ArcView Avenue **

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*=============================================================================

'* Author/Site, Date, Event

'* --------------------------------------------------------------------------

'* Raul D. Patterson Phone: (305) 717-5865

'* U. S. Geological Survey - WRD FAX: (305) 717-5801

'* 9100 NW 36th St., Suite 109

'* Miami, Florida 33178 USA Internet: rdpatter@usgs.gov

'*

'*=============================================================================

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*

'* Disclaimer: 

' Although this program has been used by the U.S. Geological Survey,

' no warranty, expressed or implied, is made by the USGS as to the

' accuracy and functioning of the program and related program

' material nor shall the fact of distribution constitute any such

' warranty, and no responsibility is assumed by the USGS in

' connection therewith.

'*

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*=============================================================================

'

'---VERSION 1.0 AVMODTMR 11MAY2001 9:19 AM

'

'::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'

' .. Purpose: Sets the LML array. The LMLDict is a dictionary that holds the 

' LML array information the LMLDict has as many entries as there are layers in

' the regional model. the regional model layer number is the key, and the value

' is either 0 (notused in the local model) or 1 (used in local model). There 

' must be a continuous range of regional model layers selected, (i.e. the local

' model can consist of layers 2,3, and 4 of a 5 layer model, but it can not

' consist of layers 1,2 and 4). This script sets the range of layers from the 

' regional model that will be used in the local model by modifying the LMLDict.

'

'0123456789012345678901234567890123456789012345678901234567890123456789012345678

theListBox = av.FindDialog("AvMODTMR.DlgLayers").FindByName("lbxLayers")

theNewLayersUsed = theListBox.GetSelection

'creates a temp dictionary where to store values for the theLMLDict, should the 

user 

'choose to override it:

aTempLayUsedDict = Dictionary.Make(100)

for each aLay in theListBox.GetList

 aKey = aLay.AsList.Get(1).AsNumber 

 aTempLayUsedDict.Set(aKey, 1)

end

'make a list of the layers not being used, to assign them an LML value of 0:

theLayersNotUsed = theListBox.GetList - theNewLayersUsed

for each aLay in theLayersNotUsed

 theKey = aLay.AsList.Get(1).AsNumber
79

 theValue = 0

 aTempLayUsedDict.Set(theKey, theValue)

end

'Compare if any changes have taken place in the layers being used:

'Locate the Local grid theme:

theView = av.GetActiveDoc

theLocGridTheme = NIL

for each T in theView.GetThemes

 if ((T.GetObjectTag.Is(List)) and (T.GetObjectTag.Get(0) = "L")) then

 theLocGridTheme = T

 break

 end

end

theLMLDict = theLocGridTheme.GetObjectTag.Get(5)

theLays = theLMLDict.ReturnKeys

theLays.Sort(TRUE)

for each aLay in theLays

 theCurrentValue = theLMLDict.Get(aLay)

 theNewValue = aTempLayUsedDict.Get(aLay)

 if (theCurrentValue <> theNewValue) then

 SaveChanges = MsgBox.YesNo("Keep changes to the layer selection?", 

 "The Layer Selection Has Changed", FALSE)

 if (SaveChanges) then

 theLMLDict = aTempLayUsedDict

 av.GetProject.SetModified (true)

 end

 aTempLayUsedDict = Nil

 break

 end

end

theParamList = theLocGridTheme.GetObjectTag

theParamList.Set(5,theLMLDict)

theLocGridTheme.SetObjectTag(theParamList)

aTempLayUsedDict = Nil
80

'************* U.S. Geological Survey preliminary computer program ************

'******************************************************************************

'************* AvMODTMR.SetLocalModelPRocessingFlag **************

'******************************************************************************

'** Language: ArcView Avenue **

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*=============================================================================

'* Author/Site, Date, Event

'* --------------------------------------------------------------------------

'* Raul D. Patterson Phone: (305) 717-5865

'* U. S. Geological Survey - WRD FAX: (305) 717-5801

'* 9100 NW 36th St., Suite 109

'* Miami, Florida 33178 USA Internet: rdpatter@usgs.gov

'*

'*=============================================================================

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*

'* Disclaimer: 

' Although this program has been used by the U.S. Geological Survey,

' no warranty, expressed or implied, is made by the USGS as to the

' accuracy and functioning of the program and related program

' material nor shall the fact of distribution constitute any such

' warranty, and no responsibility is assumed by the USGS in

' connection therewith.

'*

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*=============================================================================

'

'---VERSION 1.0 AVMODTMR 11MAY2001 9:19 AM

'

'::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'

' .. Purpose: sets the local model processing flag (LMPRF), which is a flag used

' in the MODTMR input file that indicates wether MODTMR should create all 

' MODFLOW packages (LMPRF = 0), or just the FHB package (LMPRF = 1). The value

' is stored in the object tag of the Local Grid theme as the 5th item.

'

'0123456789012345678901234567890123456789012345678901234567890123456789012345678

LMPRFFlagKW = SELF.Get(0)

theView = SELF.Get(1)

theLocTheme = SELF.Get(2)

LMPRF = NIL

theLocParamList = theLocTheme.GetObjectTag

if (LMPRFFlagKW = "All") then

 LMPRF = "0"

elseif (LMPRFFlagKW = "FHB") then

 LMPRF = "1"

end

theLocParamList.Set(4, LMPRF)

theLocTheme.SetObjectTag(theLocParamList)
81

'************* U.S. Geological Survey preliminary computer program ************

'******************************************************************************

'************* AvMODTMR.TranslateGrid **************

'******************************************************************************

'** Language: ArcView Avenue **

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*=============================================================================

'* Author/Site, Date, Event

'* --------------------------------------------------------------------------

'* Raul D. Patterson Phone: (305) 717-5865

'* U. S. Geological Survey - WRD FAX: (305) 717-5801

'* 9100 NW 36th St., Suite 109

'* Miami, Florida 33178 USA Internet: rdpatter@usgs.gov

'*

'*=============================================================================

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*

'* Disclaimer: 

' Although this program has been used by the U.S. Geological Survey,

' no warranty, expressed or implied, is made by the USGS as to the

' accuracy and functioning of the program and related program

' material nor shall the fact of distribution constitute any such

' warranty, and no responsibility is assumed by the USGS in

' connection therewith.

'*

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*=============================================================================

'

'---VERSION 1.0 AVMODTMR 11MAY2001 9:19 AM

'

'::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'

' .. Purpose: translates the grid from its current position to one given by 

' it's new X_coor and Y_coor. Receives the new X_coor, the new Y_coor, and the

' Local Grid theme. The current origin X_coor and Y_coor are obtained by

' reading them off the 12th and 13th position in the Local Grid Theme's object

' tag. Then the difference between the X_coor and the Y_coor of the new origin

' and those of the current origin are subtracted to obtain offsets in the X and

' Y directions. Each vertex of every cell is moved by these offsets, thereby 

' moving the grid.

'

'0123456789012345678901234567890123456789012345678901234567890123456789012345678

theLocalGridTheme = SELF.Get(0)

theNewX_coor = SELF.Get(1)

theNewY_coor = SELF.Get(2)

'retrieve current values:

theLocParamList = theLocalGridTheme.GetObjectTag

theCurrentX_coor = theLocParamList.Get(11).AsNumber

theCurrentY_coor = theLocParamList.Get(12).AsNumber

'Find offset values:

theDeltaX = theNewX_coor - theCurrentX_coor

theDeltaY = theNewY_coor - theCurrentY_coor

theFTab = theLocalGridTheme.GetFTab

theShapeF = theFTab.FindField("Shape")

theFTab.StartEditingWithRecovery

aTempList = List.Make
82

total = theFTab.GetNumRecords

i = 0

av.ShowMsg ("Moving Grid...")

for each aRec in theFTab

 i = i + 1

 aTempList.Empty

 

 PercentDone = (i / total)*100

 av.SetStatus(PercentDone)

 

 aCell = theFTab.ReturnValue(theShapeF, aRec)

 

 theListOfSegments = aCell.AsList

 theListOfVertices = theListOfSegments.Get(0)

 

 for each aVertex in theListOfVertices

 aVertex.Move(theDeltaX, theDeltaY)

 aTempList.Add(aVertex)

 end

 aMovedCell = Polygon.Make({aTempList})

 

 theFTab.SetValue(theShapeF, aRec, aMovedCell)

 

end

av.ShowMsg("")

av.ClearStatus

theFTab.StopEditingWithRecovery(TRUE)
83

'************* U.S. Geological Survey preliminary computer program ************

'******************************************************************************

'************* Make Extension **************

'******************************************************************************

'** Language: ArcView Avenue **

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*=============================================================================

'* Author/Site, Date, Event

'* --------------------------------------------------------------------------

'* Raul D. Patterson Phone: (305) 717-5865

'* U. S. Geological Survey - WRD FAX: (305) 717-5801

'* 9100 NW 36th St., Suite 109

'* Miami, Florida 33178 USA Internet: rdpatter@usgs.gov

'*

'*=============================================================================

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*

'* Disclaimer: 

' Although this program has been used by the U.S. Geological Survey,

' no warranty, expressed or implied, is made by the USGS as to the

' accuracy and functioning of the program and related program

' material nor shall the fact of distribution constitute any such

' warranty, and no responsibility is assumed by the USGS in

' connection therewith.

'*

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*=============================================================================

'

'---VERSION 1.0 AVMODTMR 11NOVEMBER2000 8:57 PM

'

'::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'

' .. Purpose: This script creates the extension, adding all scripts and dialogs

' to the extension and then saving the extension to disk to create the file

' AvMODTMR.avx

'

'0123456789012345678901234567890123456789012345678901234567890123456789012345678

AvMODTMRExt = Extension.Make("$TEMP\AvMODTMR.avx".AsFileName, "ArcView MODTMR "+

 "Extension", av.FindScript("AvMODTMR.Install"), 

 av.FindScript("AvMODTMR.Uninstall"), {"$AVBIN/avdlog.dll".AsFileName})

AvMODTMRExt.SetAbout("ArcView GUI for the"+

 " USGS's MODTMR MODFLOW Telescopic Mesh Refinement program")

AvMODTMRExt.SetExtVersion( 1 )

AvMODTMRExt.SetLoadScript(av.FindScript("AvMODTMR.Load"))

AvMODTMRExt.SetUnLoadScript(av.FindScript("AvMODTMR.UnLoad"))

'Add Controls and Dialogs:

 'Add GUI buttons:

 theViewGUIButtons = av.FindGUI("View").GetButtonBar.GetControls

'0123456789012345678901234567890123456789012345678901234567890123456789012345678

 '*****

 AvMODTMRExt.Add(theViewGUIButtons.Get(theViewGUIButtons.Count - 3))'1ST OBJECT

 '*****

 'Add dialogs:

 theDlgMODTMR = av.FindDoc("AvMODTMR.DlgMODTMR").GetDialog

 

 '*****
84

 AvMODTMRExt.Add(theDlgMODTMR) '2ND OBJECT

 '*****

 

 theDlgLayers = av.FindDoc("AvMODTMR.DlgLayers").GetDialog

 

 '*****

 AvMODTMRExt.Add(theDlgLayers) '3RD OBJECT

 '*****

 

 theDlgEditLayerBCs = av.FindDoc("AvMODTMR.DlgEditLayerBCs").GetDialog

 '*****

 AvMODTMRExt.Add(theDlgEditLayerBCs) '4TH OBJECT

 '*****

 

 theDlgDefineLocGrid = av.FindDoc("AvMODTMR.DlgDefineLocGrid").GetDialog

 '*****

 AvMODTMRExt.Add(theDlgDefineLocGrid) '5TH OBJECT

 '*****

 

 theDlgLocGridWiz = av.FindDoc("AvMODTMR.DlgLocGridWiz").GetDialog

 '*****

 AvMODTMRExt.Add(theDlgLocGridWiz) '6TH OBJECT

 '*****

 

 

'Add scripts:

for each aDoc in av.GetProject.GetDocs

 if ((aDoc.Is(SEd)) and (aDoc.GetName.Left("AvMODTMR".Count + 1) = " 

 AvMODTMR.")) then

 if (aDoc.IsCompiled) then

 AvMODTMRExt.Add(aDoc.GetScript)

 else

 MsgBox.Info("the script" ++aDoc.GetName++"is not compiled, extension not"+

 " created", "")

 aDoc.GetWin.Open

 Return Nil

 end

 end

end

AvMODTMRExt.Commit
APPENDIX III

Documentation of 

AvHDRD Avenue Scripts
2

'************* U.S. Geological Survey preliminary computer program ************

'******************************************************************************

'************* AvHDRD Make Extension *************

'******************************************************************************

'** Language: ArcView Avenue **

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*=============================================================================

'* Author/Site, Date, Event

'* --------------------------------------------------------------------------

'* Raul D. Patterson Phone: (305) 717-5865

'* U. S. Geological Survey - WRD FAX: (305) 717-5801

'* 9100 NW 36th St., Suite 109

'* Miami, Florida 33178 USA Internet: rdpatter@usgs.gov

'*

'*=============================================================================

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*

'* Disclaimer: 

' Although this program has been used by the U.S. Geological Survey,

' no warranty, expressed or implied, is made by the USGS as to the

' accuracy and functioning of the program and related program

' material nor shall the fact of distribution constitute any such

' warranty, and no responsibility is assumed by the USGS in

' connection therewith.

'*

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*=============================================================================

'

'---VERSION 1.0 AVHDRD 20APRIL2001 12:37 PM

'

'::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'

' .. Purpose: This script creates the extension, adding all scripts and dialogs

' to the extension and then saving the extension to disk to create the file

' avhdrd.avx

'

'0123456789012345678901234567890123456789012345678901234567890123456789012345678

AvHDFExt = Extension.Make("$TEMP\AvHDRD.avx".AsFileName, 

 "AvHDRD Extension",

 av.FindScript("AvHDRD.Install"), av.FindScript("AvHDRD.Uninstall"),

 {"$AVBIN/avdlog.dll".AsFileName})

AvHDFExt.SetUnloadScript(av.FindScript("AvHDRD.UnLoad"))

AvHDFExt.SetAbout("AvHDRD: ArcView GUI for creating River and Drain MODFLOW "+

 "input files from dynamically-segmented data")

AvHDFExt.SetExtVersion( 1 )

'Add Controls and Dialogs:

 'Add GUI controls:

 theViewGUI = av.FindGUI("View")

 theViewGUIButtons = theViewGUI.GetButtonBar.GetControls

 theOpenButton = theViewGUIButtons.Get(theViewGUIButtons.Count - 3)

 theViewGUIMenuBar = theViewGUI.GetMenuBar

 theMenu = theViewGUIMenuBar.GetControls.Get(5)

 theChoice = theMenu.GetControls.Get(1)

 theSpace = theMenu.GetControls.Get(0)

 
3

 '*****

 AvHDFExt.Add(theOpenButton) '1ST OBJECT

 AvHDFExt.Add(theSpace) '2RD OBJECT

 AvHDFExt.Add(theChoice) '3TH OBJECT

 '***** 

 'Add dialogs:

 theDlgAvHDF = av.FindDoc("DlgAvHDF").GetDialog

 

 '*****

 AvHDFExt.Add(theDlgAvHDF) '4TH OBJECT

 '*****

 

 'Add scripts:

 for each aDoc in av.GetProject.GetDocs

 if ((aDoc.Is(SEd)) and 

 (aDoc.GetName.Left("AvHDRD".Count + 1) = "AvHDRD.")) then

 if (aDoc.IsCompiled) then

 AvHDFExt.Add(aDoc.GetScript)

 else

 MsgBox.Info("the script" ++aDoc.GetName++

 "is not compiled, extension not created", "")

 aDoc.GetWin.Open

 Return Nil

 end

 end

 end

 AvHDFExt.Add(av.FindDoc("VTab.FieldUniqueList").GetScript)

 AvHDFExt.Add(av.FindDoc("VTab.GetFieldMinMaxValues").GetScript)

 

AvHDFExt.Commit
4

'************* U.S. Geological Survey preliminary computer program ************

'******************************************************************************

'************* AvHDRD.BuildLocValPairDict *************

'******************************************************************************

'** Language: ArcView Avenue **

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*=============================================================================

'* Author/Site, Date, Event

'* --------------------------------------------------------------------------

'* Raul D. Patterson Phone: (305) 717-5865

'* U. S. Geological Survey - WRD FAX: (305) 717-5801

'* 9100 NW 36th St., Suite 109

'* Miami, Florida 33178 USA Internet: rdpatter@usgs.gov

'*

'*=============================================================================

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*

'* Disclaimer: 

' Although this program has been used by the U.S. Geological Survey,

' no warranty, expressed or implied, is made by the USGS as to the

' accuracy and functioning of the program and related program

' material nor shall the fact of distribution constitute any such

' warranty, and no responsibility is assumed by the USGS in

' connection therewith.

'*

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*=============================================================================

'

'---VERSION 1.0 AVHDRD 20APRIL2001 12:37 PM

'

'::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'

' .. Purpose: Builds a dictionary with keys that are canal names and values that

' are lists of pairs (themselves lists) of locations with their respective 

' values. Such a dictionary is property specific, for example, bottom width. It

' is called by other scripts to obtain locations of property changes and also to

' obtain values between property changes to interpolate them. Receives the 

' Feature table of the event theme for the property, the event field, which is

' the field containing the canal or river identifier (name or id used in dynamic

' segmentation), the location field, which is the field containing the 

' "position along" the canal or drain, the value field, which contains the value

' of the property (actual bottom elevations) and a value called Canal Count. The

' feature table has selected all the records that touch the grid. It is from

' this selected set of records that the dictionary is built. Returns the

' Location Value Pair Dictionary.

' 

'

'0123456789012345678901234567890123456789012345678901234567890123456789012345678

theFTab = SELF.Get(0)

theEventFld = SELF.Get(1)

theLocFld = SELF.Get(2)

theValueFld = SELF.Get(3)

theCanalCount = SELF.Get(4)

theProp = SELF.Get(5)

theLocValPairDict = Dictionary.Make(theCanalCount/15)

av.ClearMsg

av.ShowMsg("Assembling "+theProp+" arrays")

theRecTotal = theFTab.GetNumSelRecords
5

theRecCounter = 0

for each aRec in theFTab.GetSelection

 theCanalName = theFTab.ReturnValue(theEventFld, aRec)

 thePosition = theFTab.ReturnValue(theLocFld, aRec)

 theValue = theFTab.ReturnValue(theValueFld, aRec)

 theCanalPropDataList = theLocValPairDict.Get(theCanalName)

 if (theCanalPropDataList = NIL) then

 theCanalPropDataList = List.Make

 end

 theCanalPropDataList.Add({thePosition, theValue})

 theLocValPairDict.Add(theCanalName, theCanalPropDataList)

 

 theRecCounter = theRecCounter + 1

 

 av.SetStatus((theRecCounter/theRecTotal)*100)

end

av.ClearStatus

av.ClearMsg

Return theLocValPairDict
6

'************* U.S. Geological Survey preliminary computer program ************

'******************************************************************************

'************* AvHDRD.CreateRivDrnEvent **************

'******************************************************************************

'** Language: ArcView Avenue **

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*=============================================================================

'* Author/Site, Date, Event

'* --------------------------------------------------------------------------

'* Raul D. Patterson Phone: (305) 717-5865

'* U. S. Geological Survey - WRD FAX: (305) 717-5801

'* 9100 NW 36th St., Suite 109

'* Miami, Florida 33178 USA Internet: rdpatter@usgs.gov

'*

'*=============================================================================

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*

'* Disclaimer: 

' Although this program has been used by the U.S. Geological Survey,

' no warranty, expressed or implied, is made by the USGS as to the

' accuracy and functioning of the program and related program

' material nor shall the fact of distribution constitute any such

' warranty, and no responsibility is assumed by the USGS in

' connection therewith.

'*

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*=============================================================================

'

'---VERSION 1.0 AVHDRD 20APRIL2001 12:37 PM

'

'::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'

' .. Purpose: Called by the script 'AvHDRD.MainProcessor', it creates an event 

' table which is subsequently added to the the view as an event theme. The 

' event table looks like a River or Drain package, with the addition of the

' fields needed to make it an event table. It creates the fields 'Name', 'From',

' 'To', 'Seqnum', 'Row', 'Col', 'Cond'(conductance), a bottom elevation field, a

' 'Comment' field and a stage field in the case of rivers (RIV). The Cell Canal

' Dictionary (theCellCanalDict) is looped through to access each cell. Then,

' each cell is looped through to access the canal(s) contained in it (individual

' Reaches), for each of which one record will be written in the event table. 

' Finally, a third loop accesses the segment parameter list and computes a 

' conductance for each segment (a Reach is broken up into Segments at the 

' locations where any property changes). The segment conductances are added for

' the reach (Ceq = C1 + C2 +...+ Cn) to obtain the conductance for the reach.

' The parameters (bottom width, sediment K, stage, etc...) have values of -9999

' for missing data. If any such segments are found the value entered for the

' reach will be -9999, and an entry will be made into the 'Comments' field

' indicating the parameter(s) and over what interval(s) there was missing data.

' 

'0123456789012345678901234567890123456789012345678901234567890123456789012345678

RivOrDrn = SELF.Get(0)

theCellCanalDict = SELF.Get(1)

theOutFileName = SELF.Get(2)

NROW = SELF.Get(3)

NCOL = SELF.Get(4)

theRouteThemeFld = SELF.Get(5)

theLocPrecision = SELF.Get(6)

theLocWidth = SELF.Get(7)

theValPrecision = SELF.Get(8)

theValWidth = SELF.Get(9) 

theBEValFld = SELF.Get(10)
7

theRowFld = SELF.Get(11)

theColFld = SELF.Get(12)

theSeqnumFld = SELF.Get(13)

if (RivOrDrn = "RIVER") then

 theStageValFld = SELF.Get(14)

end

theVTab = VTab.MakeNew(theOutFileName, dBASE)

theVTab.StartEditingWithRecovery

theNameFld = theRouteThemeFld.Clone

theFromFld = Field.Make("From", #FIELD_DOUBLE, theLocWidth, theLocPrecision)

theToFld = Field.Make("To", #FIELD_DOUBLE, theLocWidth, theLocPrecision)

theOutVTabSeqnumFld = theSeqnumFld.Clone

theOutVTabRowFld = theRowFld.Clone

theOutVTabColFld = theColFld.Clone

theOutVTabSeqnumFld = theSeqnumFld.Clone

theOutVTabBEValFld = theBEValFld.Clone

theConductanceFld = Field.Make("Cond", #FIELD_DOUBLE, 15, 3)

theCommentFld = Field.Make("Comment", #FIELD_CHAR, 255, 0)

theFldList = {theNameFld, theFromFld, theToFld, theOutVTabSeqnumFld, 

 theOutVTabRowFld, theOutVTabColFld, theConductanceFld,

 theOutVTabBEValFld, theCommentFld}

if (RivOrDrn = "RIVER") then

 theOutVTabStageValFld = theStageValFld.Clone

 theFldList.Add(theOutVTabStageValFld)

 theFldList.Shuffle(theOutVTabStageValFld, 7)

end

theVTab.AddFields(theFldList)

'get the cell seqnum to sort by them:

theCells = theCellCanalDict.ReturnKeys

theCells.Sort(TRUE)

'get a count of reaches (for MXRIVR and ITMP):

NoOfReaches = 0

for each aCell in theCells

 theRow = (aCell/NCOL).Ceiling

 theCol = aCell - ((theRow - 1)*NCOL)

 for each aCanal in theCellCanalDict.Get(aCell)

 theReachError = ""

 theCondError = ""

 theStageError = ""

 theBEError = ""

 NoOfReaches = NoOfReaches + 1

 'this gets all the info for a river or drain file record:

 aCanalName = aCanal.GetName

 theReachLength = 0

 aSegStgWeightedAccum = 0

 aSegBEWeightedAccum = 0

 theReachCond = 0

 theReachFrom = 99999999

 theReachTo = 0

 for each aSegParamList in aCanal

 aSegFrom = aSegParamList.Get(0)

 if (aSegFrom < theReachFrom) then

 theReachFrom = aSegFrom
8

 end

 aSegTo = aSegParamList.Get(1)

 if (aSegTo > theReachTo) then 

 theReachTo = aSegTo

 end

 aSegLength = aSegTo - aSegFrom

 theReachLength = theReachLength + aSegLength

 aSegK = aSegParamList.Get(2)

 if (aSegK = -9999) then

 theCondError = theCondError + "SK [" + aSegFrom.AsString +

 ", " + aSegTo.AsString + "]; "

 end

 aSegBW = aSegParamList.Get(3)

 if (aSegBW = -9999) then

 theCondError = theCondError + "BW [" + aSegFrom.AsString +

 ", " + aSegTo.AsString + "]; "

 end

 aSegST = aSegParamList.Get(4)

 if (aSegST = -9999) then

 theCondError = theCondError + "ST [" + aSegFrom.AsString +

 ", " + aSegTo.AsString + "]; "

 end

 aSegBE = aSegParamList.Get(5)

 if (aSegBE = -9999) then

 theBEError = theBEError + "BE [" + aSegFrom.AsString +

 ", " + aSegTo.AsString + "]; "

 end

 aSegBEWeighted = aSegBE * aSegLength

 aSegBEWeightedAccum = aSegBEWeightedAccum + aSegBEWeighted

 if ((RivOrDrn) = "RIVER") then

 aSegStg = aSegParamList.Get(6)

 if (aSegStg = -9999) then

 theStageError = theStageError + "Stg [" + aSegFrom.AsString +

 ", " + aSegTo.AsString + "]; "

 end

 aSegStgWeighted = aSegStg * aSegLength

 aSegStgWeightedAccum = aSegStgWeightedAccum + aSegStgWeighted

 end

 aSegCond = ( aSegK * aSegBW * aSegLength ) / aSegST

 theReachCond = theReachCond + aSegCond '(Ceq = C1 + C2 + ... + Cn)

 end

 

 if (RivOrDrn = "RIVER") then

 if (theStageError = "") then

 theReachStage = aSegStgWeightedAccum/theReachLength

 else

 theReachStage = -9999

 end

 end

 

 if ((theCondError = "").Not) then

 theReachCond = -9999

 end

 

 if (theBEError = "") then

 theReachBE = aSegBEWeightedAccum/theReachLength

 else

 theReachBE = -9999

 end

 theReachError = theStageError + theCondError + theBEError

 'populate table:
9

 aNewRec = theVTab.AddRecord

 theVTab.SetValue(theNameFld, aNewRec, aCanalName)

 theVTab.SetValue(theFromFld, aNewRec, theReachFrom)

 theVTab.SetValue(theToFld, aNewRec, theReachTo)

 theVTab.SetValue(theOutVTabSeqnumFld, aNewRec, aCell)

 theVTab.SetValue(theOutVTabRowFld, aNewRec, theRow)

 theVTab.SetValue(theOutVTabColFld, aNewRec, theCol)

 if (RivOrDrn = "RIVER") then

 theVTab.SetValue(theOutVTabStageValFld, aNewRec, theReachStage)

 end

 theVTab.SetValue(theOutVTabBEValFld, aNewRec, theReachBE)

 theVTab.SetValue(theConductanceFld, aNewRec, theReachCond)

 theVTab.SetValue(theCommentFld, aNewRec, theReachError)

 end

end

theVTab.StopEditingWithRecovery(TRUE)

Return {theVTab, theNameFld, theToFld, theFromFld}
10

'************* U.S. Geological Survey preliminary computer program ************

'******************************************************************************

'************* AvHDRD.DlgMain.cbxGridTheme.Update **************

'******************************************************************************

'** Language: ArcView Avenue **

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*=============================================================================

'* Author/Site, Date, Event

'* --------------------------------------------------------------------------

'* Raul D. Patterson Phone: (305) 717-5865

'* U. S. Geological Survey - WRD FAX: (305) 717-5801

'* 9100 NW 36th St., Suite 109

'* Miami, Florida 33178 USA Internet: rdpatter@usgs.gov

'*

'*=============================================================================

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*

'* Disclaimer: 

' Although this program has been used by the U.S. Geological Survey,

' no warranty, expressed or implied, is made by the USGS as to the

' accuracy and functioning of the program and related program

' material nor shall the fact of distribution constitute any such

' warranty, and no responsibility is assumed by the USGS in

' connection therewith.

'*

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*=============================================================================

'

'---VERSION 1.0 AVHDRD 20APRIL2001 12:37 PM

'

'::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'

' .. Purpose: Update script for the 'Grid Theme' drop-down list box. It

' populates the control with the polygon themes in the view.

'

'0123456789012345678901234567890123456789012345678901234567890123456789012345678

theView = av.GetActiveDoc

theType = #FIELD_SHAPEPOLY

thePolyThemes = av.Run("AvHDRD.FindFThemesOfAType", {theView, theType})

SELF.DefineFromList(thePolyThemes)
11

'************* U.S. Geological Survey preliminary computer program ************

'******************************************************************************

'************* AvHDRD.DlgMain.cbxRouteTheme.Update *************

'******************************************************************************

'** Language: ArcView Avenue **

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*=============================================================================

'* Author/Site, Date, Event

'* --------------------------------------------------------------------------

'* Raul D. Patterson Phone: (305) 717-5865

'* U. S. Geological Survey - WRD FAX: (305) 717-5801

'* 9100 NW 36th St., Suite 109

'* Miami, Florida 33178 USA Internet: rdpatter@usgs.gov

'*

'*=============================================================================

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*

'* Disclaimer: 

' Although this program has been used by the U.S. Geological Survey,

' no warranty, expressed or implied, is made by the USGS as to the

' accuracy and functioning of the program and related program

' material nor shall the fact of distribution constitute any such

' warranty, and no responsibility is assumed by the USGS in

' connection therewith.

'*

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*=============================================================================

'

'---VERSION 1.0 AVHDRD 20APRIL2001 12:37 PM

'

'::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'

' .. Purpose: Update script for the 'Route Theme' drop-down list box. It

' populates the control with the Route themes in the view.

'

'0123456789012345678901234567890123456789012345678901234567890123456789012345678

theView = av.GetActiveDoc

theRouteThemes = {}

for each T in theView.GetThemes

 if (T.Is(FTheme)) then

 theSrc = T.GetSrcName.GetSubName.AsString

 if (theSrc = "*route*".AsPattern) then

 theRouteThemes.Add(T)

 end

 end

end

SELF.DefineFromList(theRouteThemes)
12

'************* U.S. Geological Survey preliminary computer program ************

'******************************************************************************

'************* AvHDRD.DlgMain.lbtProcess.Click *************

'******************************************************************************

'** Language: ArcView Avenue **

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*=============================================================================

'* Author/Site, Date, Event

'* --------------------------------------------------------------------------

'* Raul D. Patterson Phone: (305) 717-5865

'* U. S. Geological Survey - WRD FAX: (305) 717-5801

'* 9100 NW 36th St., Suite 109

'* Miami, Florida 33178 USA Internet: rdpatter@usgs.gov

'*

'*=============================================================================

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*

'* Disclaimer: 

' Although this program has been used by the U.S. Geological Survey,

' no warranty, expressed or implied, is made by the USGS as to the

' accuracy and functioning of the program and related program

' material nor shall the fact of distribution constitute any such

' warranty, and no responsibility is assumed by the USGS in

' connection therewith.

'*

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*=============================================================================

'

'---VERSION 1.0 AVHDRD 20APRIL2001 12:37 PM

'

'::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'

' .. Purpose: Checks which package was selected by the user for processing and

' obtains the necessary parameters input by the user in the main dialog and runs

' the main processing script (AvHDRD.MainProcessor). If 'Write package file'

' option is checked, then call AvHDRD.WriteRivDrnFile.

'

'0123456789012345678901234567890123456789012345678901234567890123456789012345678

DlgMain = SELF.GetDialog

cpaPkgSelections = DlgMain.FindByName("cpaPkgSelections")

RivOrDrn = cpaPkgSelections.GetSelected.GetLabel.UCase

if (RivOrDrn = "RIVER") then

 IXXXCB = DlgMain.FindByName("txlIRIVCB").GetText

elseif (RivOrDrn = "DRAIN") then

 IXXXCB = DlgMain.FindByName("txlIDRNCB").GetText

end

PathToFiles = DlgMain.FindByName("txlPathToFiles").GetText

RootName = DlgMain.FindByName("txlRootName").GetText

MinSegLength = DlgMain.FindByName("txlMinSegLength").GetText.AsNumber

theGridTheme = DlgMain.FindByName("cbxGridTheme").GetSelection

theCanalRteTheme = DlgMain.FindByName("cbxRouteTheme").GetSelection

theRivDrnTheme = DlgMain.FindByName("cbxClassify").GetSelection

theBETheme = DlgMain.FindByName("cbxBottElev").GetSelection

theBWTheme = DlgMain.FindByName("cbxBottWid").GetSelection

theSedThickTheme = DlgMain.FindByName("cbxSedThick").GetSelection

theSedKTheme = DlgMain.FindByName("cbxSedK").GetSelection

if (RivOrDrn = "RIVER") then

 theStageTheme = DlgMain.FindByName("cbxStage").GetSelection

else
13

 theStageTheme = NIL

end

theFileName = PathToFiles + "\" + RootName

theArgList = {RivOrDrn, theFileName, MinSegLength, theGridTheme,

 theCanalRteTheme, theRivDrnTheme, theBETheme, theBWTheme, theSedThickTheme,

 theSedKTheme, theStageTheme}

'run the Main processor, but return the pkg event VTab:

thePkgEventVTab = av.Run("AvHDRD.MainProcessor", theArgList)

'if write file checkbox is checked, write out the package file:

if (DlgMain.FindByName("chkWriteFile").IsSelected) then

 av.Run("AvHDRD.WriteRivDrnFile",

 {thePkgEventVTab, theFileName, RivOrDrn, IXXXCB})

end
14

'************* U.S. Geological Survey preliminary computer program ************

'******************************************************************************

'************* AvHDRD.DlgMain.radDrain.Click **************

'******************************************************************************

'** Language: ArcView Avenue **

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*=============================================================================

'* Author/Site, Date, Event

'* --------------------------------------------------------------------------

'* Raul D. Patterson Phone: (305) 717-5865

'* U. S. Geological Survey - WRD FAX: (305) 717-5801

'* 9100 NW 36th St., Suite 109

'* Miami, Florida 33178 USA Internet: rdpatter@usgs.gov

'*

'*=============================================================================

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*

'* Disclaimer: 

' Although this program has been used by the U.S. Geological Survey,

' no warranty, expressed or implied, is made by the USGS as to the

' accuracy and functioning of the program and related program

' material nor shall the fact of distribution constitute any such

' warranty, and no responsibility is assumed by the USGS in

' connection therewith.

'*

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*=============================================================================

'

'---VERSION 1.0 AVHDRD 20APRIL2001 12:37 PM

'

'::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'

' .. Purpose: Calls the script 'AvHDRD.GetIXXXCB' to locate the Cell-by-Cell

' file unit number indicated in the existing drain file, since, presumably, the

' user may wish to use the same one for the new drain file. It is placed into

' the IXXXCB textline adjacent to it. If the file is not found, then nothing 

' happens and the user can enter any value into the text box.

'

'0123456789012345678901234567890123456789012345678901234567890123456789012345678

txlIDRNCB = SELF.GetDialog.FindByName("txlIDRNCB")

theCurrentNo = txlIDRNCB.GetText

if (theCurrentNo = Nil) then

 theCurrentNo = ""

end

theFType = "DRN"

IDRNCB = av.Run("AvHDRD.GetIXXXCB", {theFType, theCurrentNo})

txlIDRNCB.SetText(IDRNCB)
15

'************* U.S. Geological Survey preliminary computer program ************

'******************************************************************************

'************* AvHDRD.DlgMain.radRiver.Click **************

'******************************************************************************

'** Language: ArcView Avenue **

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*=============================================================================

'* Author/Site, Date, Event

'* --------------------------------------------------------------------------

'* Raul D. Patterson Phone: (305) 717-5865

'* U. S. Geological Survey - WRD FAX: (305) 717-5801

'* 9100 NW 36th St., Suite 109

'* Miami, Florida 33178 USA Internet: rdpatter@usgs.gov

'*

'*=============================================================================

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*

'* Disclaimer: 

' Although this program has been used by the U.S. Geological Survey,

' no warranty, expressed or implied, is made by the USGS as to the

' accuracy and functioning of the program and related program

' material nor shall the fact of distribution constitute any such

' warranty, and no responsibility is assumed by the USGS in

' connection therewith.

'*

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*=============================================================================

'

'---VERSION 1.0 AVHDRD 20APRIL2001 12:37 PM

'

'::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'

' .. Purpose: Calls the script 'AvHDRD.GetIXXXCB' to locate the Cell-by-Cell

' file unit number indicated in the existing river file, since, presumably, the

' user may wish to use the same one for the new river file. It is placed into

' the IXXXCB textline adjacent to it. If the file is not found, then nothing 

' happens and the user can enter any value into the text box.

'

'0123456789012345678901234567890123456789012345678901234567890123456789012345678

txlIRIVCB = SELF.GetDialog.FindByName("txlIRIVCB")

theCurrentNo = txlIRIVCB.GetText

if (theCurrentNo = Nil) then

 theCurrentNo = ""

end

theFType = "RIV"

IRIVCB = av.Run("AvHDRD.GetIXXXCB", {theFType, theCurrentNo})

txlIRIVCB.SetText(IRIVCB)
16

'************* U.S. Geological Survey preliminary computer program ************

'******************************************************************************

'************* AvHDRD.FindFThemesOfAType *************

'******************************************************************************

'** Language: ArcView Avenue **

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*=============================================================================

'* Author/Site, Date, Event

'* --------------------------------------------------------------------------

'* Raul D. Patterson Phone: (305) 717-5865

'* U. S. Geological Survey - WRD FAX: (305) 717-5801

'* 9100 NW 36th St., Suite 109

'* Miami, Florida 33178 USA Internet: rdpatter@usgs.gov

'*

'*=============================================================================

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*

'* Disclaimer: 

' Although this program has been used by the U.S. Geological Survey,

' no warranty, expressed or implied, is made by the USGS as to the

' accuracy and functioning of the program and related program

' material nor shall the fact of distribution constitute any such

' warranty, and no responsibility is assumed by the USGS in

' connection therewith.

'*

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*=============================================================================

'

'---VERSION 1.0 AVHDRD 20APRIL2001 12:37 PM

'

'::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'

' .. Purpose: called by the update scripts of the theme drop-down list boxes

' 'Route Theme' and 'Grid Theme' to retrieve all the themes in the view 

' (theView) of type "theType".

'

'0123456789012345678901234567890123456789012345678901234567890123456789012345678

theView = SELF.Get(0)

theType = SELF.Get(1)

theFThemes = List.Make

for each T in theView.GetThemes

 if (T.Is(FTheme)) then

 if (T.GetFTab.FindField("Shape").GetType = theType) then

 theFThemes.Add(T)

 end

 end

end

Return theFThemes
17

'************* U.S. Geological Survey preliminary computer program ************

'******************************************************************************

'************* AvHDRD.FixedOrFree **************

'******************************************************************************

'** Language: ArcView Avenue **

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*=============================================================================

'* Author/Site, Date, Event

'* --------------------------------------------------------------------------

'* Raul D. Patterson Phone: (305) 717-5865

'* U. S. Geological Survey - WRD FAX: (305) 717-5801

'* 9100 NW 36th St., Suite 109

'* Miami, Florida 33178 USA Internet: rdpatter@usgs.gov

'*

'*=============================================================================

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*

'* Disclaimer: 

' Although this program has been used by the U.S. Geological Survey,

' no warranty, expressed or implied, is made by the USGS as to the

' accuracy and functioning of the program and related program

' material nor shall the fact of distribution constitute any such

' warranty, and no responsibility is assumed by the USGS in

' connection therewith.

'*

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*=============================================================================

'

'---VERSION 1.0 AVHDRD 20APRIL2001 12:37 PM

'

'::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'

' .. Purpose: determines whether free or fixed format is being used in the

' input files for the simulation.

'

'0123456789012345678901234567890123456789012345678901234567890123456789012345678

theNameFileName = SELF.Get(0)

theLineList = List.Make

theNameFile = LineFile.Make(theNameFileName, #FILE_PERM_READ)

theNameFile.Read(theLineList, 4)

theNameFile.Close

theOptions = theLineList.Get(3).AsList

theAnswer = "FIXED"

for each anOpt in theOptions

 if (anOpt.UCase = "FREE") then

 theAnswer = "FREE"

 Return theAnswer

 end

end

Return theAnswer
18

'************* U.S. Geological Survey preliminary computer program ************

'******************************************************************************

'************* AvHDRD.GetDynSegThemes **************

'******************************************************************************

'** Language: ArcView Avenue **

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*=============================================================================

'* Author/Site, Date, Event

'* --------------------------------------------------------------------------

'* Raul D. Patterson Phone: (305) 717-5865

'* U. S. Geological Survey - WRD FAX: (305) 717-5801

'* 9100 NW 36th St., Suite 109

'* Miami, Florida 33178 USA Internet: rdpatter@usgs.gov

'*

'*=============================================================================

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*

'* Disclaimer: 

' Although this program has been used by the U.S. Geological Survey,

' no warranty, expressed or implied, is made by the USGS as to the

' accuracy and functioning of the program and related program

' material nor shall the fact of distribution constitute any such

' warranty, and no responsibility is assumed by the USGS in

' connection therewith.

'*

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*=============================================================================

'

'---VERSION 1.0 AVHDRD 20APRIL2001 12:37 PM

'

'::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'

' .. Purpose: called by the update scripts of the theme drop-down list boxes

' of all the event themes ('Classify', 'Bottom Width', etc...) to retrieve all 

' the dynamically segmented event themes in the view (theView).

'

'0123456789012345678901234567890123456789012345678901234567890123456789012345678

theView = SELF.Get(0)

theDynSegThemes = {}

for each T in theView.GetThemes

 if (T.GetSrcName.Is(DynName)) then

 theDynSegThemes.Add(T)

 end

end

Return theDynSegThemes
19

'************* U.S. Geological Survey preliminary computer program ************

'******************************************************************************

'************* AvHDRD.GetEventThemeInfo ************

'******************************************************************************

'** Language: ArcView Avenue **

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*=============================================================================

'* Author/Site, Date, Event

'* --------------------------------------------------------------------------

'* Raul D. Patterson Phone: (305) 717-5865

'* U. S. Geological Survey - WRD FAX: (305) 717-5801

'* 9100 NW 36th St., Suite 109

'* Miami, Florida 33178 USA Internet: rdpatter@usgs.gov

'*

'*=============================================================================

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*

'* Disclaimer: 

' Although this program has been used by the U.S. Geological Survey,

' no warranty, expressed or implied, is made by the USGS as to the

' accuracy and functioning of the program and related program

' material nor shall the fact of distribution constitute any such

' warranty, and no responsibility is assumed by the USGS in

' connection therewith.

'*

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*=============================================================================

'

'---VERSION 1.0 AVHDRD 20APRIL2001 12:37 PM

'

'::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'

' .. Purpose: Determines whether the event theme is a point event theme or a 

' linear, continuous event theme, and returns the Position field, the Event

' field, and the type (point or linear).

'

'0123456789012345678901234567890123456789012345678901234567890123456789012345678

theEventTheme = SELF.Get(0)

theDynName = theEventTheme.GetSrcName

if (theDynName.IsPoint) then

 theType = "Point"

 thePosFld = theDynName.GetMeasureField

elseif (theDynName.IsContinuous) then

 thePosFld = theDynName.GetFromField

 theType = "Continuous"

end

theEventFld = theDynName.GetEventRouteId

Return {thePosFld, theEventFld, theType}
20

'************* U.S. Geological Survey preliminary computer program ************

'******************************************************************************

'************* AvHDRD.GetIXXXCB **************

'******************************************************************************

'** Language: ArcView Avenue **

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*=============================================================================

'* Author/Site, Date, Event

'* --------------------------------------------------------------------------

'* Raul D. Patterson Phone: (305) 717-5865

'* U. S. Geological Survey - WRD FAX: (305) 717-5801

'* 9100 NW 36th St., Suite 109

'* Miami, Florida 33178 USA Internet: rdpatter@usgs.gov

'*

'*=============================================================================

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*

'* Disclaimer: 

' Although this program has been used by the U.S. Geological Survey,

' no warranty, expressed or implied, is made by the USGS as to the

' accuracy and functioning of the program and related program

' material nor shall the fact of distribution constitute any such

' warranty, and no responsibility is assumed by the USGS in

' connection therewith.

'*

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*=============================================================================

'

'---VERSION 1.0 AVHDRD 20APRIL2001 12:37 PM

'

'::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'

' .. Purpose: receives the FType, which is either 'RIV' or 'DRN' and the current

' number that is in the text line next to the package option button (it could

' be blank) and it uses the name file in the path to files and root name to find

' the name of the FType file. Then it tries to open the FType file and retrieve

' the unit number in the variable IDRNCB or IRIVCB.

'

'0123456789012345678901234567890123456789012345678901234567890123456789012345678

theFType = SELF.Get(0)

theCurrentNo = SELF.Get(1)

'get existing RIV, DRN files:

DlgAvHDF = av.FindDialog("DlgAvHDF")

thePathToFiles = DlgAvHDF.FindByName("txlPathToFiles").GetText

theRootName = DlgAvHDF.FindByName("txlRootName").GetText

theNameFileOnDisk = (thePathToFiles + "\" + theRootName + ".nam").AsFileName

if (theNameFileOnDisk = NIL) then

 Return NIL

end

'initialize thePkgFileName:

thePkgFileName = NIL

'locate it in the name file, if it exists...

theLineList = List.Make

theNameFile = LineFile.Make(theNameFileOnDisk, #FILE_PERM_READ)

theNameFile.Read(theLineList, theNameFile.GetSize)

for each aLine in theLineList

 theItemList = aLine.AsList

 if (theItemList.Get(0) = theFType) then
21

 thePkgFileName = theItemList.Get(2)

 break

 end

end

theNameFile.Close

'at this point, if no Pkg File Name, then return nil with message:

if (thePkgFileName = NIL) then

 MsgBox.Warning("No file of type "+theFType+" indicated in name file "+

 theNameFileOnDisk.AsString, "")

 Return theCurrentNo

end

'open the package file and get the CBC Unit No.

thePkgFileName = (thePathToFiles + "\" + thePkgFileName).AsFileName

if (thePkgFileName.IsFile.Not) then

 thePkgFileName = FileDialog.Show("*."+theFType.LCase,

 "*."+theFType.LCase, "Locate the "+theFType+" file")

 if (thePkgFileName = Nil) then

 Return theCurrentNo 'return a blank string if pkg file not given

 end

end

thePkgFile = LineFile.Make(thePkgFileName, #FILE_PERM_READ)

thePkgFile.SetPos(0)

the1stLine = thePkgFile.ReadElt

IXXXCB = the1stLine.AsList.Get(1)

thePkgFile.Close

Return IXXXCB
22

'************* U.S. Geological Survey preliminary computer program ************

'******************************************************************************

'************* AvHDRD.InsertBreaksAtChanges *************

'******************************************************************************

'** Language: ArcView Avenue **

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*=============================================================================

'* Author/Site, Date, Event

'* --------------------------------------------------------------------------

'* Raul D. Patterson Phone: (305) 717-5865

'* U. S. Geological Survey - WRD FAX: (305) 717-5801

'* 9100 NW 36th St., Suite 109

'* Miami, Florida 33178 USA Internet: rdpatter@usgs.gov

'*

'*=============================================================================

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*

'* Disclaimer: 

' Although this program has been used by the U.S. Geological Survey,

' no warranty, expressed or implied, is made by the USGS as to the

' accuracy and functioning of the program and related program

' material nor shall the fact of distribution constitute any such

' warranty, and no responsibility is assumed by the USGS in

' connection therewith.

'*

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*=============================================================================

'

'---VERSION 1.0 AVHDRD 20APRIL2001 12:37 PM

'

'::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'

' .. Purpose: Called by the Main Processing script (AvHDRD.MainProcessor) to 

' insert breaks at changes in canal properties in the cell-canal dictionary. 

' The location where a property changes along the length of a reach (the 

' stretch of a canal within a given cell) is called a breakpoint. The cell-

' canal dictionary has cell sequence numbers as keys and lists of canals as 

' values. Each of these canals has a list of breakpoint pairs, which define a

' continuous stretch of canals where all properties are the same (in the case

' of continuously defined properties) or varying linearly between known values

' (in the case of point-defined properties). The initial set of breakpoint

' pairs for a reach are just the cell boundaries, where the canal crosses in

' and out of the cell. When a canal is being processed, its existing breakpoint

' pairs are checked against the locations of the property's event location-value

' pair dictionary (theEventLocValPairDict) for inclusion. If a location is

' within a breakpoint pair, the breakpoint pair is split into two (2) breakpoint

' pairs using the location to separate them. Because changes in properties can

' occur in different places for the various parameters and no knowledge of their 

' location is known until they are visited, this process is repeated for each

' property. Accordingly, this script is executed once for each property.

'

'0123456789012345678901234567890123456789012345678901234567890123456789012345678

theCellCanalDict = SELF.Get(0)

theEventLocValPairDict = SELF.Get(1)

MinSegLength = SELF.Get(2)

aNewCellCanalDict = Dictionary.Make(theCellCanalDict.GetSize)

for each aCell in theCellCanalDict.ReturnKeys '(ie. Seqnum 156)

 aListOfCanals = theCellCanalDict.Get(aCell) '(ie. lists {"C2", "C111"},

 'where "C2" = {{1000,1250},

 '{1500, 1649}})
23

 aNewListOfCanals = List.Make

 for each aCanal in aListOfCanals

 aCanalName = aCanal.GetName

 'skip this canal altogether if no data for it in theEventLocValPairDict

 

 if (theEventLocValPairDict.Get(aCanalName) = NIL) then

 aNewListOfBrkPntPairLists = aCanal 

 else

 aNewListOfBrkPntPairLists = List.Make

 aNewListOfBrkPntPairLists.SetName(aCanalName)

 

 for each aBrkPntPair in aCanal

 

 theBegPos = aBrkPntPair.Get(0)

 theEndPos = aBrkPntPair.Get(1)

 

 'search for any prop changes in this range:

 aTempBrkPntList = List.Make

 for each aListOfLocValPairs in theEventLocValPairDict.Get(aCanalName)

 theChangePos = aListOfLocValPairs.Get(0)

 if (((theChangePos - theBegPos) > MinSegLength) and

 ((theEndPos - theChangePos) > MinSegLength)) then

 aTempBrkPntList.Add(theChangePos)

 end

 end

 if (aTempBrkPntList.Count = 0) then

 aNewListOfBrkPntPairLists.Add(aBrkPntPair)

 aTempBrkPntList = Nil

 else

 aCanalSegBrkPntList = aTempBrkPntList + aBrkPntPair

 aCanalSegBrkPntList.Sort(TRUE)

 for each i in 0..(aCanalSegBrkPntList.Count - 2)

 aNewBegPos = aCanalSegBrkPntList.Get(i)

 aNewEndPos = aCanalSegBrkPntList.Get(i + 1)

 aNewBrkPntPair = {aNewBegPos, aNewEndPos}

 aNewListOfBrkPntPairLists.Add(aNewBrkPntPair)

 end

 end 

 end 'aCanalSegBrkPntList now has all new pairs resulting from the 

 'splitting of the original pairs at the brk pnts.

 end

 aNewListOfCanals.Add(aNewListOfBrkPntPairLists) 

 end

 aNewCellCanalDict.Add(aCell, aNewListOfCanals)

end

aCellCanalDict = NIL

Return aNewCellCanalDict
24

'************* U.S. Geological Survey preliminary computer program ************

'******************************************************************************

'************* AvHDRD.Install **************

'******************************************************************************

'** Language: ArcView Avenue **

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*=============================================================================

'* Author/Site, Date, Event

'* --------------------------------------------------------------------------

'* Raul D. Patterson Phone: (305) 717-5865

'* U. S. Geological Survey - WRD FAX: (305) 717-5801

'* 9100 NW 36th St., Suite 109

'* Miami, Florida 33178 USA Internet: rdpatter@usgs.gov

'*

'*=============================================================================

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*

'* Disclaimer: 

' Although this program has been used by the U.S. Geological Survey,

' no warranty, expressed or implied, is made by the USGS as to the

' accuracy and functioning of the program and related program

' material nor shall the fact of distribution constitute any such

' warranty, and no responsibility is assumed by the USGS in

' connection therewith.

'*

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*=============================================================================

'

'---VERSION 1.0 AVHDRD 20APRIL2001 12:37 PM

'

'::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'

' .. Purpose: Install script is executed only when the extension is loaded for

' the first time in an ArcView session. Installs the dialog, dlgAvHDF, the 

' extension scripts, as well as the button and MODTMR menu (if not already

' present), and the 'River and Drain...' choice for launching the dialog.

'

'0123456789012345678901234567890123456789012345678901234567890123456789012345678

'Install ONLY if there is an active project

if (av.GetProject = nil) then

 return NIL

end

'Retrieve objects from extension:

theProject = av.GetProject

theOpenButton = SELF.Get(0)

theSpace = SELF.Get(1)

theChoice = SELF.Get(2)

'the project must have a View GUI:

theViewGUI = av.GetProject.FindGUI("View")

if (theViewGUI = NIL) then

 Return NIL

end

'Install the open button:

theViewGUIButtonBar = theViewGUI.GetButtonBar

theViewGUIButtons = theViewGUIButtonBar.GetControls

'Make it the last item

thePlace = theViewGUIButtons.Count
25

theViewGUIButtonBar.Add(theOpenButton, thePlace)

'now install menu choice and MODTMR menu if not present:

theViewMenuBar = theViewGUI.GetMenuBar

theMODTMRMenu = theViewMenuBar.FindByLabel("MODTMR")

if (theMODTMRMenu = NIL) then

 'add it:

 theWindowMenu = theViewMenuBar.FindByName("Window")

 thePlace = theViewMenuBar.GetControls.Find(theWindowMenu) - 1

 theMenu = theViewMenuBar.New(thePlace)

 theMenu.SetLabel("&MODTMR")

 theMenu.Add(theChoice, 0)

else

 'add a space and then it:

 theMODTMRMenu.Add(theSpace, 99)

 theMODTMRMenu.Add(theChoice, 99)

end

theViewGUI.SetModified(TRUE)
26

'************* U.S. Geological Survey preliminary computer program ************

'******************************************************************************

'************* AvHDRD.MainProcessor *************

'******************************************************************************

'** Language: ArcView Avenue **

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*=============================================================================

'* Author/Site, Date, Event

'* --------------------------------------------------------------------------

'* Raul D. Patterson Phone: (305) 717-5865

'* U. S. Geological Survey - WRD FAX: (305) 717-5801

'* 9100 NW 36th St., Suite 109

'* Miami, Florida 33178 USA Internet: rdpatter@usgs.gov

'*

'*=============================================================================

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*

'* Disclaimer: 

' Although this program has been used by the U.S. Geological Survey,

' no warranty, expressed or implied, is made by the USGS as to the

' accuracy and functioning of the program and related program

' material nor shall the fact of distribution constitute any such

' warranty, and no responsibility is assumed by the USGS in

' connection therewith.

'*

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*=============================================================================

'

'---VERSION 1.0 AVHDRD 20APRIL2001 12:37 PM

'

'::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'

' .. Purpose: Receives the following information as an argument list: 1. 

' RivOrDrn ('RIVER' or 'DRAIN', a string indicating which package to create) ;

' 2. theFileName (the file name to use for the package input file, named by

' using the root name of the simulation and appending a .riv, or .drn); 3. 

' MinSegLength (a length threshold below which segments will not be processed

' nor written); 4. theGridTheme ; 5. theCanalRteTheme (the Route coverage theme

' of canal feaures); 6. theRivDrnTheme (an event theme classifying the canal

' features as either River or Drain); 7. theBETheme (an event theme of bottom

' elevations for the rivers and drain features); 8. theBWTheme (an event theme 

' of bottom width); 9. theSedThickTheme (an event theme of sediment thickness);

' 10. theSedKTheme (event theme of sediment K); 11. theStageTheme (an event

' theme of stages). Builds a dictionary (a type of look-up array) that has

' cell seqnum as keys and as values named lists of canal names (one for each

' canal that crosses the cell) with breakpoints and parameter values. The event

' themes for the various conductance properties and stage may be defined as

' either linear or point. If linear, they must be defined as continuous events.

' The algorithm will detect from the event theme what type it is and interpolate

' accordingly. An event theme with the package information is created by 

' calling 'AvHDRD.MakeEventFromFile'and added to the view. The event theme is

' named <root_name>_xxx.dbf, where xxx is "riv" or "drn".

'

'0123456789012345678901234567890123456789012345678901234567890123456789012345678

theView = av.GetActiveDoc

theMapDisplay = theView.GetDisplay

RivOrDrn = SELF.Get(0)

theFileName = SELF.Get(1)

MinSegLength = SELF.Get(2)
27

theGridTheme = SELF.Get(3)

theCanalRteTheme = SELF.Get(4)

theRivDrnTheme = SELF.Get(5)

theBETheme = SELF.Get(6)

theBWTheme = SELF.Get(7)

theSedThickTheme = SELF.Get(8)

theSedKTheme = SELF.Get(9)

if (RivOrDrn = "RIVER") then

 theStageTheme = SELF.Get(10)

end

theGridThemeFTab = theGridTheme.GetFTab

theGridShapeFld = theGridThemeFTab.FindField("Shape")

theGridIDFld = theGridThemeFTab.FindField("Seqnum")

theGridRowFld = theGridThemeFTab.FindField("Row")

NROW = av.Run("VTab.GetFieldMinMaxValues", {theGridThemeFTab, "Row"}).Get(1)

theGridColFld = theGridThemeFTab.FindField("Col")

NCOL = av.Run("VTab.GetFieldMinMaxValues", {theGridThemeFTab, "Col"}).Get(1)

theCanalRteThemeFTab = theCanalRteTheme.GetFTab

theCanalNameFld = theCanalRteThemeFTab.FindField("Name")

theCanalShapeFld = theCanalRteThemeFTab.FindField("Shape")

theRivDrnThemeFTab = theRivDrnTheme.GetFTab

theRivDrnShapeFld = theRivDrnThemeFTab.FindField("Shape")

theRivDrnValueFld = theRivDrnThemeFTab.FindField("Classify")

theRivDrnThemeInfo = av.Run("AvHDRD.GetEventThemeInfo", {theRivDrnTheme})

theRivDrnLocFld = theRivDrnThemeInfo.Get(0)

theRivDrnEventFld = theRivDrnThemeInfo.Get(1)

theRivDrnThemeType = theRivDrnThemeInfo.Get(2)

theBEThemeFTab = theBETheme.GetFTab

theBEValueFld = theBEThemeFTab.FindField("Botel")

theBEThemeInfo = av.Run("AvHDRD.GetEventThemeInfo", {theBETheme})

theBELocFld = theBEThemeInfo.Get(0)

theBEEventFld = theBEThemeInfo.Get(1)

theBEThemeType = theBEThemeInfo.Get(2)

theBWThemeFTab = theBWTheme.GetFTab

theBWValueFld = theBWThemeFTab.FindField("Botwid")

theBWThemeInfo = av.Run("AvHDRD.GetEventThemeInfo", {theBWTheme})

theBWLocFld = theBWThemeInfo.Get(0)

theBWEventFld = theBWThemeInfo.Get(1)

theBWThemeType = theBWThemeInfo.Get(2)

theSTThemeFTab = theSedThickTheme.GetFTab

theSTValueFld = theSTThemeFTab.FindField("Thick")

theSedThickThemeInfo = av.Run("AvHDRD.GetEventThemeInfo", {theSedThickTheme})

theSTLocFld = theSedThickThemeInfo.Get(0)

theSTEventFld = theSedThickThemeInfo.Get(1)

theSTThemeType = theSedThickThemeInfo.Get(2)

theSKThemeFTab = theSedKTheme.GetFTab

theSKValueFld = theSKThemeFTab.FindField("K")

theSedKThemeInfo = av.Run("AvHDRD.GetEventThemeInfo", {theSedKTheme})

theSKLocFld = theSedKThemeInfo.Get(0)

theSKEventFld = theSedKThemeInfo.Get(1)

theSKThemeType = theSedKThemeInfo.Get(2)

if (RivOrDrn = "RIVER") then

 theStageThemeFTab = theStageTheme.GetFTab
28

 theStageValueFld = theStageThemeFTab.FindField("Stage_avg")

 theStageThemeInfo = av.Run("AvHDRD.GetEventThemeInfo", {theStageTheme})

 theStageLocFld = theStageThemeInfo.Get(0)

 theStageEventFld = theStageThemeInfo.Get(1)

 theStageThemeType = theStageThemeInfo.Get(2)

else

 theStageValueFld = NIL

end

'Select all the chosen features (rivers or drains), based on RivOrDrn, that

'touch grid as well:

 theGridTheme.ClearSelection

 theRivDrnTheme.SelectByTheme(theGridTheme, #FTAB_RELTYPE_INTERSECTS, 0, 

 #VTAB_SELTYPE_NEW)

 theRivOrDrnCriteria = "(["+theRivDrnValueFld.GetName+"] = "+RivOrDrn.Quote+")"

 theRivDrnThemeFTab.Query(theRivOrDrnCriteria, theRivDrnThemeFTab.GetSelection,

 #VTAB_SELTYPE_AND)

 theRivDrnThemeFTab.UpdateSelection

'Conversely, select grid cells that touch chosen features:

 theGridTheme.SelectByTheme(theRivDrnTheme, #FTAB_RELTYPE_INTERSECTS, 0, 

 #VTAB_SELTYPE_NEW)

 theGridThemeFTab.UpdateSelection

'select linear events based on touching selected grid cells:

 theCanalRteTheme.SelectByTheme(theGridTheme, #FTAB_RELTYPE_INTERSECTS, 0, 

 #VTAB_SELTYPE_NEW)

 aCanalNameShapeDict = Dictionary.Make(theCanalRteThemeFTab.GetNumSelRecords /

 15)

 for each aCan in theCanalRteThemeFTab.GetSelection

 theCanalName = theCanalRteThemeFTab.ReturnValue(theCanalNameFld, aCan)

 theCanal = theCanalRteThemeFTab.ReturnValue(theCanalShapeFld, aCan)

 aCanalNameShapeDict.Add(theCanalName, theCanal)

 end

 

 theBWTheme.SelectByTheme(theGridTheme, #FTAB_RELTYPE_INTERSECTS, 0, 

 #VTAB_SELTYPE_NEW)

 

 

'select point events based on being on a canal touching grid:

 

 theBETheme.SelectByTheme(theCanalRteTheme, #FTAB_RELTYPE_INTERSECTS, 0, 

 #VTAB_SELTYPE_NEW)

 theSedThickTheme.SelectByTheme(theCanalRteTheme, #FTAB_RELTYPE_INTERSECTS, 0, 

 #VTAB_SELTYPE_NEW)

 theSedKTheme.SelectByTheme(theCanalRteTheme, #FTAB_RELTYPE_INTERSECTS, 0, 

 #VTAB_SELTYPE_NEW)

 

 if (RivOrDrn = "RIVER") then

 theStageTheme.SelectByTheme(theCanalRteTheme, #FTAB_RELTYPE_INTERSECTS, 0, 

 #VTAB_SELTYPE_NEW)

 end
29

'Intersect each cell with each canal and create a dictionary of cells made up 

'of the seqnum as key and a list of canal lists as values. These canal lists 

'will be one per each canal that intersects the cell with canal name as list 

'name and the list of breakpoints as list items:

 theCellCanalDict = Dictionary.Make(theGridThemeFTab.GetNumSelRecords/15)

 for each aRec in theGridThemeFTab.GetSelection

 

 theCell = theGridThemeFTab.ReturnValue(theGridShapeFld, aRec)

 theSeqnum = theGridThemeFTab.ReturnValue(theGridIDFld, aRec)

 

 for each aRow in theRivDrnThemeFTab.GetSelection

 

 theCanalName = theRivDrnThemeFTab.ReturnValue(theRivDrnEventFld, aRow)

 theCanalStretch = theRivDrnThemeFTab.ReturnValue(theRivDrnShapeFld, aRow)

 

 theCanal = aCanalNameShapeDict.Get(theCanalName)

 

 theCanalLength = theCanal.ReturnLength

 

 if (theCell.Intersects(theCanalStretch)) then

 

 aCanalBrkPntList = List.Make

 aCanalBrkPntList.SetName(theCanalName)

 theCanalParts = theCell.LineIntersection(theCanalStretch).Explode

 

 theSegPairList = List.Make

 

 for each aPart in theCanalParts

 

 

 

 if (theCell.Contains(aPart)) then

 the1stPoint = aPart.Along(0)

 theLastPoint = aPart.Along(100)

 elseif (theCell.Intersects(aPart)) then

 theIntPolyline = theCell.LineIntersection(aPart)

 theListOfSegs = theIntPolyline.AsList

 the1stSegPointList = theListOfSegs.Get(0)

 the1stPoint = the1stSegPointList.Get(0)

 

 theLastSegPointList = theListOfSegs.Get(theListOfSegs.Count - 1)

 theLastPoint = theLastSegPointList.Get(theLastSegPointList.Count - 

 1)

 end

 

 the1stLocation = (theCanal.PointPosition(the1stPoint)/100) *

 theCanalLength

 theLastLocation = (theCanal.PointPosition(theLastPoint)/100)*

 theCanalLength

 

 aSegPair = {the1stLocation, theLastLocation}

 aCanalBrkPntList.Add(aSegPair)

 

 

 end

 

 'Done processing this reach for current cell, add its Canal Brk Pnt

 'List to the ListOfCanalBrkPntLists:

 

 if (theCellCanalDict.Get(theSeqnum) = NIL) then

 ListOfCanalBrkPntList = List.Make
30

 ListOfCanalBrkPntList.Add(aCanalBrkPntList)

 theCellCanalDict.Add(theSeqnum, ListOfCanalBrkPntList)

 else

 ListOfCanalBrkPntList = theCellCanalDict.Get(theSeqnum)

 ListOfCanalBrkPntList.Add(aCanalBrkPntList)

 theCellCanalDict.Add(theSeqnum, ListOfCanalBrkPntList)

 end

 end

 

 end 

 

 end

'with every canal touching the grid, make a dictionary that has

'the canal name as key, and a list of location, value pairs as values.

 

 'get a count of canals that intersect grid:

 theCanalCount = theCanalRteThemeFTab.GetNumSelRecords

 

 theBELocValPairDict = av.Run("AvHDRD.BuildLocValPairDict", {theBEThemeFTab, 

 theBEEventFld, theBELocFld, theBEValueFld, 

 theCanalCount, "Bottom Elevation"})

 theSTLocValPairDict = av.Run("AvHDRD.BuildLocValPairDict", {theSTThemeFTab, 

 theSTEventFld, theSTLocFld, theSTValueFld, 

 theCanalCount, "Sediment Thickness"})

 theSKLocValPairDict = av.Run("AvHDRD.BuildLocValPairDict", {theSKThemeFTab, 

 theSKEventFld, theSKLocFld, theSKValueFld, 

 theCanalCount, "Sediment Conductivity"})

 

 if (RivOrDrn = "RIVER") then

 theStageLocValPairDict = av.Run("AvHDRD.BuildLocValPairDict", 

 {theStageThemeFTab, theStageEventFld, theStageLocFld,

 theStageValueFld, theCanalCount, "Stage"})

 end

 

 theBWLocValPairDict = av.Run("AvHDRD.BuildLocValPairDict", {theBWThemeFTab,

 theBWEventFld, theBWLocFld, theBWValueFld, 

 theCanalCount, "Bottom Width"})

'insert breaks at any location where property changes within a pair of points.

theCellCanalDict = av.Run("AvHDRD.InsertBreaksAtChanges", {theCellCanalDict,

 theBELocValPairDict, MinSegLength})

theCellCanalDict = av.Run("AvHDRD.InsertBreaksAtChanges", {theCellCanalDict,

 theBWLocValPairDict, MinSegLength})

theCellCanalDict = av.Run("AvHDRD.InsertBreaksAtChanges", {theCellCanalDict,

 theSTLocValPairDict, MinSegLength})

 

theCellCanalDict = av.Run("AvHDRD.InsertBreaksAtChanges", {theCellCanalDict,

 theSKLocValPairDict, MinSegLength})
31

if (RivOrDrn = "RIVER") then

 theCellCanalDict = av.Run("AvHDRD.InsertBreaksAtChanges", {theCellCanalDict,

 theStageLocValPairDict, MinSegLength})

end

'add values to the LocValPairs for each canal in each cell of the Cell Canal

'Dictionary:

theCellCanalDict = av.Run("AvHDRD.PropValExtract", {theCellCanalDict,

 theSKLocValPairDict, theSKThemeType})

 

theCellCanalDict = av.Run("AvHDRD.PropValExtract", {theCellCanalDict,

 theBWLocValPairDict, theBWThemeType})

 

theCellCanalDict = av.Run("AvHDRD.PropValExtract", {theCellCanalDict,

 theSTLocValPairDict, theSTThemeType})

 

theCellCanalDict = av.Run("AvHDRD.PropValExtract", {theCellCanalDict,

 theBELocValPairDict, theBEThemeType})

 

if (RivOrDrn = "RIVER") then

 theCellCanalDict = av.Run("AvHDRD.PropValExtract", {theCellCanalDict,

 theStageLocValPairDict, theStageThemeType})

end

'Find the highest precision of all the location fields in the event tables to

'use for the location fields in the conductance event table:

theLocationFields = {theBELocFld, theSTLocFld, theSKLocFld, theBWLocFld}

if (RivOrDrn = "RIVER") then

 theLocationFields.Add(theStageLocFld)

end

theLocPrecisionList = List.Make

theLocWidthList = List.Make

for each aField in theLocationFields

 thePrecision = aField.GetPrecision

 theLocWidth = aField.GetWidth

 theLocWidthList.Add(theLocWidth)

 theLocPrecisionList.Add(thePrecision)

end

theLocPrecisionList.Sort(TRUE)

theLocPrecision = theLocPrecisionList.Get(theLocPrecisionList.Count - 1)

theLocWidthList.Sort(TRUE)

theLocWidth = theLocWidthList.Get(theLocWidthList.Count - 1)

'Find the lowest precision of all the cond param fields in the event tables to

'use for the conductance field in the conductance event table:

theCondFields = {theSTValueFld, theSKValueFld, theBWValueFld}

'initialize with the lowest presicion of the location fields, since length for 

'cond is computed from it:

theCondPrecision = theLocPrecisionList.Get(0)

for each aField in theCondFields

 thePrecision = aField.GetPrecision

 if (thePrecision < theCondPrecision) then

 theCondPrecision = thePrecision

 end

end

'****the cond field is arbitrarily sized 16, but should be sized according
32

'to the highest cond value obtained from the largest width, and K, some

'appropriate length (such as 3x the larger of DELR, DELC) and the smallest 

'thickness appearing in the respective event tables:

theCondWidth = 16 ' Should be the highest cond computed - 

 ' theCondPrecision - 1

theFileExt = ""

if (RivOrDrn = "RIVER") then

 theFileSuffix = "_riv"

elseif (RivOrDrn = "DRAIN") then

 theFileSuffix = "_drn"

end

theOutFileName = (theFileName + theFileSuffix+ "." + "dbf").AsFileName

thePkgEventInfo = av.Run("AvHDRD.CreateRivDrnEvent", {RivOrDrn, 

 theCellCanalDict, theOutFileName, NROW, NCOL,

 theCanalNameFld, theLocPrecision, theLocWidth,

 theCondPrecision, theCondWidth, theBEValueFld,

 theGridRowFld, theGridColFld, theGridIDFld,

 theStageValueFld})

thePkgEventVTab = thePkgEventInfo.Get(0)

theNameFld = thePkgEventInfo.Get(1)

theFromFld = thePkgEventInfo.Get(2)

theToFld = thePkgEventInfo.Get(3)

thePkgDynName = DynName.Make(theCanalRteThemeFTab, theCanalNameFld)

thePkgDynName.SetLineEvent (thePkgEventVTab, theNameFld, theFromFld, theToFld)

thePkgEventTheme = Theme.Make(thePkgDynName)

theView.AddTheme(thePkgEventTheme)

Return thePkgEventVTab
33

'** *********** U.S. Geological Survey preliminary computer program ************

'******************************************************************************

'************* AvHDRD.PropValExtract *************

'******************************************************************************

'** Language: ArcView Avenue **

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*=============================================================================

'* Author/Site, Date, Event

'* --------------------------------------------------------------------------

'* Raul D. Patterson Phone: (305) 717-5865

'* U. S. Geological Survey - WRD FAX: (305) 717-5801

'* 9100 NW 36th St., Suite 109

'* Miami, Florida 33178 USA Internet: rdpatter@usgs.gov

'*

'*=============================================================================

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*

'* Disclaimer: 

' Although this program has been used by the U.S. Geological Survey,

' no warranty, expressed or implied, is made by the USGS as to the

' accuracy and functioning of the program and related program

' material nor shall the fact of distribution constitute any such

' warranty, and no responsibility is assumed by the USGS in

' connection therewith.

'*

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*=============================================================================

'

'---VERSION 1.0 AVHDRD 20APRIL2001 12:37 PM

'

'::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'

' .. Purpose: Called by the AvHDRD.MainProcessor script once for each property

' (bottom elevation, stage, etc...). The CellCanalDict is a dictionary that

' contains cell seqnum as keys and lists of canals breakpoint lists as values.

' For instance one entry will be named '156', for the 156th cell; its value

' will be a list of named lists, one for each canal that crosses it and the

' name of the each list will be the canal name, for example 'C2'; list 'C2'

' will contain breakpoint pair lists. For instance if the canal goes thru the

' cell, crossing it first at measure 1000, then at 1649, and there's a single

' property change within it at 1250, then there will be two breakpoint lists:

' {1000, 1250} and {1250, 1649} in it. In summary, one of the canals (there

' could be more than one) that crosses cell 156 is canal C2, which has two

' segments (due to a change in properties at a location within the cell) and 

' thus, two breakpoint lists. The breakpoint lists are visited one at a time

' and a value of the property is interpolated at the midpoint of the segment

' from the surrounding values of the property for that canal in the canal

' propertydictionary. The method of interpolation for the property depends on

' the event type. For point events, a linear interpolation is done between the 

' nearest upstream and downstream points. For continuous linear events (as

' bottom width may be for drainage canals), the value is simply taken as the

' nearest upstream value. If the interpolation can not be done due to lack of

' data, a value of -9999 is entered for the property. The value is entered at 

' at the end of the canal breakpoint list as the last item.

'

'0123456789012345678901234567890123456789012345678901234567890123456789012345678

theCellCanalDict = SELF.Get(0)

thePropLocValPairDict = SELF.Get(1)

theEventType = SELF.Get(2)

for each aCell in theCellCanalDict.ReturnKeys '(ie. Seqnum 156)
34

 aListOfCanals = theCellCanalDict.Get(aCell) '(ie. lists {"C2", "C111"},

 'C2 = {{1000, 1250},{1250,1649}})

 for each aCanal in aListOfCanals

 

 aCanalName = aCanal.GetName

 

 for each aBrkPntPair in aCanal

 

 theBegPos = aBrkPntPair.Get(0)

 theEndPos = aBrkPntPair.Get(1)

 

 theMidPos = (theBegPos + theEndPos)/2

 if (thePropLocValPairDict.Get(aCanalName) = NIL) then

 theVal = -9999

 elseif (theEventType = "Point") then 'ie, it's a point property

 theBeforePos = 0

 theBeforeVal = -9999

 theAfterPos = 99999999

 theAfterVal = -9999

 for each aLocValPair in thePropLocValPairDict.Get(aCanalName)

 aPos = aLocValPair.Get(0)

 if ((aPos < theMidPos) and (aPos > theBeforePos)) then

 theBeforePos = aPos

 theBeforeVal = aLocValPair.Get(1)

 elseif ((aPos > theMidPos) and (aPos < theAfterPos)) then

 theAfterPos = aPos

 theAfterVal = aLocValPair.Get(1)

 end

 end

 if ((theAfterVal = -9999) and (theBeforeVal = -9999)) then

 theVal = -9999

 end

 if ((theAfterVal = -9999) xor (theBeforeVal = -9999)) then

 if(theAfterVal > theBeforeVal) then

 theVal = theAfterVal

 else

 theVal = theBeforeVal

 end

 end

 if ((theAfterVal <> -9999) and (theBeforeVal <> -9999)) then

 'then we linearly interpolate:

 theVal = theBeforeVal + 

 (((theAfterVal - theBeforeVal)/

 (theAfterPos - theBeforePos))*(theMidPos - theBeforePos))

 

 end

 elseif (theEventType = "Continuous") then

 theAfterPos = 99999999

 theAfterVal = -9999

 for each aLocValPair in thePropLocValPairDict.Get(aCanalName)

 aPos = aLocValPair.Get(0)

 if ((aPos > theMidPos) and (aPos < theAfterPos)) then

 theAfterPos = aPos

 theAfterVal = aLocValPair.Get(1)

 end

 end

 theVal = theAfterVal

 end

 

 aBrkPntPair.Add(theVal)

 

 end 
35

 

 end 

 

end 

Return theCellCanalDict
36

'************* U.S. Geological Survey preliminary computer program ************

'******************************************************************************

'************* AvHDRD.UnInstall **************

'******************************************************************************

'** Language: ArcView Avenue **

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*=============================================================================

'* Author/Site, Date, Event

'* --------------------------------------------------------------------------

'* Raul D. Patterson Phone: (305) 717-5865

'* U. S. Geological Survey - WRD FAX: (305) 717-5801

'* 9100 NW 36th St., Suite 109

'* Miami, Florida 33178 USA Internet: rdpatter@usgs.gov

'*

'*=============================================================================

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*

'* Disclaimer: 

' Although this program has been used by the U.S. Geological Survey,

' no warranty, expressed or implied, is made by the USGS as to the

' accuracy and functioning of the program and related program

' material nor shall the fact of distribution constitute any such

' warranty, and no responsibility is assumed by the USGS in

' connection therewith.

'*

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*=============================================================================

'

'---VERSION 1.0 AVHDRD 20APRIL2001 12:37 PM

'

'::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'

' .. Purpose: Uninstalls the extension and all of its objects. If after

' removing the 'River and Drain...' choice from the MODTMR menu there are no 

' more choices left in it, then the menu itself is removed.

' AvHDRD.UnInstall

theProject = av.GetProject

if (theProject = nil) then

 return nil

end

if (theProject.IsClosing) then

 return nil

end

' Remove the button from the button bar

theViewGUI = av.GetProject.FindGUI("View")

theButtonBar = theViewGUI.GetButtonBar

theButtonBar.Remove(SELF.Get(0))

'start removing menu/menu item:

theMenuBar = theViewGUI.GetMenuBar

'quit if no MODTMR menu:

if (theMenuBar.FindByLabel("MODTMR") = NIL) then

 Return NIL

end

'remove "River and Drain..." item, if it exists:
37

theMODTMRmenu = theMenuBar.FindByLabel("MODTMR") 

theChoice = theMODTMRmenu.FindByLabel("River and Drain...")

if ((theChoice = NIL).Not) then

 theMODTMRmenu.Remove(theChoice)

end

'Remove the MODTMR menu if it contains no items at this point:

theMenuChoices = 0

for each aControl in theMODTMRmenu.GetControls

 if (aControl.Is(Choice)) then

 theMenuChoices = theMenuChoices + 1

 end

end

if (theMenuChoices = 0) then

 theMenuBar.Remove(theMODTMRmenu)

end
38

'************* U.S. Geological Survey preliminary computer program ************

'******************************************************************************

'************* AvHDRD.WriteRivDrnFile **************

'******************************************************************************

'** Language: ArcView Avenue **

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*=============================================================================

'* Author/Site, Date, Event

'* --------------------------------------------------------------------------

'* Raul D. Patterson Phone: (305) 717-5865

'* U. S. Geological Survey - WRD FAX: (305) 717-5801

'* 9100 NW 36th St., Suite 109

'* Miami, Florida 33178 USA Internet: rdpatter@usgs.gov

'*

'*=============================================================================

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*

'* Disclaimer:

' Although this program has been used by the U.S. Geological Survey,

' no warranty, expressed or implied, is made by the USGS as to the

' accuracy and functioning of the program and related program

' material nor shall the fact of distribution constitute any such

' warranty, and no responsibility is assumed by the USGS in

' connection therewith.

'*

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*=============================================================================

'

'---VERSION 1.0 AVHDRD 20APRIL2001 12:37 PM

'

'::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'

' .. Purpose: Receives the table (theVTab) containing the package information,

' the file name (theFileName), the river/drain keyword (RivOrDrn), and the unit

' number for writing cell-by-cell flow values (IXXXCB). Writes the package file

' for river or drains, depending on the value of RivOrDrn. River files will

' have extension "*.riv", while drain files will have extension "*.drn". The

' files are written in fixed format (using 10 column fields), and beyond the

' last column writes three additional fields: feature name (the name of the

' canal or river - "C2", for instance), From, and To, which are the measures 

' along the river for each reach. This permits spatial association of the

' records with the route coverage being used.

'

'0123456789012345678901234567890123456789012345678901234567890123456789012345678

theVTab = SELF.Get(0)

theFileName = SELF.Get(1)

RivOrDrn = SELF.Get(2)

IXXXCB = SELF.Get(3)

thePosNumFmtString = "d.ddd"

theValueNumFmtString = "d.dddd"

theNameFld = theVTab.FindField("Name")

theFromFld = theVTab.FindField("From")

theToFld = theVTab.FindField("To")

theRowFld = theVTab.FindField("Row")

theColFld = theVTab.FindField("Col")

theCondFld = theVTab.FindField("Cond")

if (RivOrDrn = "RIVER") then

 theStageFld = theVTab.FindField("Stage_avg")

end

theBEFld = theVTab.FindField("Botel")
39

if (RivOrDrn = "River") then

 theFileExt = ".riv"

elseif (RivOrDrn = "Drain") then

 theFileExt = ".drn"

end

theFileName = (theFileName + theFileExt).AsFileName

theFileString = ""

the10SpaceBlank = " "

the15SpaceBlank = " "

NoOfReaches = theVTab.GetNumRecords

'Create the File String:

for each aRecord in theVTab

 theRow = theVTab.ReturnValue(theRowFld, aRecord)

 theRow.SetFormat( "d" )

 theRowString = the10SpaceBlank.Left(10 - theRow.AsString.Count) +

 theRow.AsString

 theCol = theVTab.ReturnValue(theColFld, aRecord)

 theCol.SetFormat( "d" )

 theColString = the10SpaceBlank.Left(10 - theCol.AsString.Count) +

 theCol.AsString

 theReachCond = theVTab.ReturnValue(theCondFld, aRecord)

 theReachCond.SetFormat( "d.dd" )

 theReachCondString = the10SpaceBlank.Left(10 - 

 theReachCond.AsString.Count) +

 theReachCond.AsString

 theReachBE = theVTab.ReturnValue(theBEFld, aRecord)

 theReachBE.SetFormat( "d.dd" )

 theReachBEString = the10SpaceBlank.Left(10 - theReachBE.AsString.Count) +

 theReachBE.AsString

 theReachFrom = theVTab.ReturnValue(theFromFld, aRecord)

 theReachFrom.SetFormat ( "d.dd" )

 theReachFromString = the10SpaceBlank.Left(10 - 

 theReachFrom.AsString.Count) +

 theReachFrom.AsString

 theReachTo = theVTab.ReturnValue(theToFld, aRecord)

 theReachTo.SetFormat ( "d.dd" )

 theReachToString = the10SpaceBlank.Left(10 - theReachTo.AsString.Count) +

 theReachTo.AsString

 aCanalName = theVTab.ReturnValue(theNameFld, aRecord)

 aCanalName = the15SpaceBlank.Left(15 - aCanalName.Count) + aCanalName 

 

 if (RivOrDrn = "RIVER") then

 

 theReachStage = theVTab.ReturnValue(theStageFld, aRecord)

 theReachStage.SetFormat( "d.dddd" )

 theReachStageString = the10SpaceBlank.Left(10 - 

 theReachStage.AsString.Count) +

 theReachStage.AsString

 aRecordString = " 1" + theRowString + theColString +

 theReachStageString + 

 theReachCondString + theReachBEString + 

 aCanalName + theReachFromString + theReachToString

 

 elseif (RivOrDrn = "DRAIN") then

 

 aRecordString = " 1" + theRowString + theColString + 

 theReachBEString + theReachCondString +

 aCanalName + theReachFromString + theReachToString

 end

 theFileString = theFileString + aRecordString + nl
40

 end

theFileString = the10SpaceBlank.Left(10 - NoOfReaches.AsString.Count) +

 NoOfReaches.AsString + the10SpaceBlank.Left(10 - 

 IXXXCB.AsString.Count) + IXXXCB.AsString + NL +

 the10SpaceBlank.Left(10 - NoOfReaches.AsString.Count) +

 NoOfReaches.AsString + NL + theFileString

theTextFile = TextFile.Make(theFileName, #FILE_PERM_WRITE)

theTextFile.Write(theFileString, theFileString.Count)

theTextFile.Close
APPENDIX IV

Documentation of 

AvWELL Avenue Scripts
2

'************* U.S. Geological Survey preliminary computer program ************

'******************************************************************************

'************* AvWell Make Extension **************

'******************************************************************************

'** Language: ArcView Avenue **

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*=============================================================================

'* Author/Site, Date, Event

'* --------------------------------------------------------------------------

'* Raul D. Patterson Phone: (305) 717-5865

'* U. S. Geological Survey - WRD FAX: (305) 717-5801

'* 9100 NW 36th St., Suite 109

'* Miami, Florida 33178 USA Internet: rdpatter@usgs.gov

'*

'*=============================================================================

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*

'* Disclaimer: 

' Although this program has been used by the U.S. Geological Survey,

' no warranty, expressed or implied, is made by the USGS as to the

' accuracy and functioning of the program and related program

' material nor shall the fact of distribution constitute any such

' warranty, and no responsibility is assumed by the USGS in

' connection therewith.

'*

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*=============================================================================

'

'---VERSION 1.0 AVWELL 08MAY2001 8:36 AM

'

'::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'

' .. Purpose: This script creates the extension, adding all scripts and dialogs

' to the extension and then saving the extension to disk to create the file

' AvWell.avx

'

'0123456789012345678901234567890123456789012345678901234567890123456789012345678

AvWellExt = Extension.Make("$AVEXT\AvWell.avx".AsFileName, 

 "ArcView MODTMR Well Extension", av.FindScript("AvWell.Install"), 

 av.FindScript("AvWell.UnInstall"), {"$AVBIN\avdlog.dll".AsFileName})

AvWellExt.SetAbout("ArcView GUI for refining MODFLOW Well (WEL) packages")

AvWellExt.SetExtVersion( 1 )

AvWellExt.SetUnloadScript(av.FindScript("AvWell.Unload"))

'Add GUI Controls and Dialogs:

 'Add GUI controls:

 theViewGUI = av.FindGUI("View")

 theViewGUIButtons = theViewGUI.GetButtonBar.GetControls

 theOpenButton = theViewGUIButtons.Get(theViewGUIButtons.Count - 1)

 theViewGUIMenuBar = theViewGUI.GetMenuBar

 theMenu = theViewGUIMenuBar.GetControls.Get(5)

 theChoice = theMenu.GetControls.Get(1)

 theSpace = theMenu.GetControls.Get(0)

 

 '*****

 AvWellExt.Add(theOpenButton) '1ST OBJECT

 AvWellExt.Add(theSpace) '2RD OBJECT
3

 AvWellExt.Add(theChoice) '3TH OBJECT

 '***** 

 'Add dialogs:

 dlgAvWell = av.FindDoc("dlgAvWell").GetDialog

 

 '*****

 AvWellExt.Add(dlgAvWell) '4TH OBJECT

 '*****

 'Add scripts:

 for each aDoc in av.GetProject.GetDocs

 if ((aDoc.Is(SEd)) and (aDoc.GetName.Left("AvWell".Count + 1) = 

 "AvWell.")) then

 if (aDoc.IsCompiled) then

 AvWellExt.Add(aDoc.GetScript)

 else

 MsgBox.Info("the script" ++aDoc.GetName++"is not compiled, extension" +

 "not created", "")

 aDoc.GetWin.Open

 Return Nil

 end

 end

 end

 'add any other misc scripts:

 AvWellExt.Add(av.FindDoc("View.FindFThemesOfAType").GetScript)

 AvWellExt.Add(av.FindDoc("Avtmr.GetGridTheme").GetScript)

 AvWellExt.Add(av.FindDoc("Avtmr.GetFileNameFromNameFile").GetScript)

 

AvWellExt.Commit
4

'************* U.S. Geological Survey preliminary computer program ************

'******************************************************************************

'************* AvWell.dlgAvWell.btnNext.Click **************

'******************************************************************************

'** Language: ArcView Avenue **

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*=============================================================================

'* Author/Site, Date, Event

'* --------------------------------------------------------------------------

'* Raul D. Patterson Phone: (305) 717-5865

'* U. S. Geological Survey - WRD FAX: (305) 717-5801

'* 9100 NW 36th St., Suite 109

'* Miami, Florida 33178 USA Internet: rdpatter@usgs.gov

'*

'*=============================================================================

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*

'* Disclaimer: 

' Although this program has been used by the U.S. Geological Survey,

' no warranty, expressed or implied, is made by the USGS as to the

' accuracy and functioning of the program and related program

' material nor shall the fact of distribution constitute any such

' warranty, and no responsibility is assumed by the USGS in

' connection therewith.

'*

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*=============================================================================

'

'---VERSION 1.0 AVWELL 08MAY2001 8:36 AM

'

'::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'

' .. Purpose: Clicking advances current record by one. It grabs the existing 

' current records' record number and increments it by one by calling the script

' "AvWell.MoveRecord" with the keyword "NEXT" as an argument. Sends updates

' to all the well reporting controls.

'

'0123456789012345678901234567890123456789012345678901234567890123456789012345678

'

theView = av.GetActiveDoc

theWellTheme = av.Run("Avtmr.GetGridTheme", {theView, "W"})

if (theWellTheme = NIL) then

 Return NIL

end

theCurrRecNo = av.Run("AvWell.MoveRecord", {theWellTheme, "NEXT"})

SELF.Update

SELF.BroadcastUpdate

av.GetProject.SetModified(TRUE)
5

'************* U.S. Geological Survey preliminary computer program ************

'******************************************************************************

'************* AvWell.dlgAvWell.btnPrevious.Click ************

'******************************************************************************

'** Language: ArcView Avenue **

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*=============================================================================

'* Author/Site, Date, Event

'* --------------------------------------------------------------------------

'* Raul D. Patterson Phone: (305) 717-5865

'* U. S. Geological Survey - WRD FAX: (305) 717-5801

'* 9100 NW 36th St., Suite 109

'* Miami, Florida 33178 USA Internet: rdpatter@usgs.gov

'*

'*=============================================================================

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*

'* Disclaimer: 

' Although this program has been used by the U.S. Geological Survey,

' no warranty, expressed or implied, is made by the USGS as to the

' accuracy and functioning of the program and related program

' material nor shall the fact of distribution constitute any such

' warranty, and no responsibility is assumed by the USGS in

' connection therewith.

'*

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*=============================================================================

'

'---VERSION 1.0 AVWELL 08MAY2001 8:36 AM

'

'::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'

' .. Purpose: Clicking rewinds current record by one. It grabs the existing 

' current records' record number and decreases it by one by calling the script

' "AvWell.MoveRecord" with the keyword "PREVIOUS" as an argument. Sends updates

' to all the well reporting controls.

'

'0123456789012345678901234567890123456789012345678901234567890123456789012345678

theView = av.GetActiveDoc

theWellTheme = av.Run("Avtmr.GetGridTheme", {theView, "W"})

if (theWellTheme = NIL) then

 Return NIL

end

av.Run("AvWell.MoveRecord", {theWellTheme, "PREVIOUS"})

SELF.Update

SELF.BroadCastUpdate

av.GetProject.SetModified(TRUE)
6

'************* U.S. Geological Survey preliminary computer program ************

'******************************************************************************

'************* AvWell.dlgAvWell.cbxGridTheme.Select *************

'******************************************************************************

'** Language: ArcView Avenue **

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*=============================================================================

'* Author/Site, Date, Event

'* --------------------------------------------------------------------------

'* Raul D. Patterson Phone: (305) 717-5865

'* U. S. Geological Survey - WRD FAX: (305) 717-5801

'* 9100 NW 36th St., Suite 109

'* Miami, Florida 33178 USA Internet: rdpatter@usgs.gov

'*

'*=============================================================================

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*

'* Disclaimer: 

' Although this program has been used by the U.S. Geological Survey,

' no warranty, expressed or implied, is made by the USGS as to the

' accuracy and functioning of the program and related program

' material nor shall the fact of distribution constitute any such

' warranty, and no responsibility is assumed by the USGS in

' connection therewith.

'*

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*=============================================================================

'

'---VERSION 1.0 AVWELL 08MAY2001 8:36 AM

'

'::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'

' .. Purpose: executed upon selecting a polygon theme as the grid theme, it sets

' the selected grid theme into the object tag of the well theme, then calls the

' script "AvWell.OverlayWellsWithGrid". Also, resets the record tracker item in

' the well theme and issues an update to the well reporting controls.

'

'0123456789012345678901234567890123456789012345678901234567890123456789012345678

theDialog = SELF.GetDialog

'identify controls:

cbxWellTheme = theDialog.FindByName("cbxWellTheme")

theWellTheme = cbxWellTheme.GetSelection

theGridTheme = SELF.GetSelection

theWellTheme.GetObjectTag.Set(4, theGridTheme) '*** 5th pos well theme obj tag

av.Run("AvWell.OverlayWellsWithGrid",

 {theWellTheme, theGridTheme})

theVTab = theWellTheme.GetFTab

theDialog.SetServer(theVTab)

theTotalRecs = theVTab.GetNumSelRecords

theCurrentRec = theVTab.GetSelection.GetNextSet(-1)

theWellNo = 1

theWellTheme.GetObjectTag.Set(6,{theCurrentRec, theTotalRecs, theWellNo})

'Reset the Record tracker item in the well theme's object tag:

av.Run("AvWell.MoveRecord", {theWellTheme, "RESET"})

'in a previous call, the well theme was overlain with the grid theme,

'selecting all the wells within it; now we load their pumpage data to

'the pumpage listbox:

 lbxPumpage = theDialog.FindByName("lbxPumpage")
7

 av.Run("AvWell.LoadPumpage", {theWellTheme, lbxPumpage})

 lbxPumpage.Update

'send updates to the record navigating controls

SELF.BroadcastUpdate

av.GetProject.SetModified(TRUE)
8

'************* U.S. Geological Survey preliminary computer program ************

'******************************************************************************

'************* AvWell.dlgAvWell.cbxWellTheme.Select ************

'******************************************************************************

'** Language: ArcView Avenue **

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*=============================================================================

'* Author/Site, Date, Event

'* --------------------------------------------------------------------------

'* Raul D. Patterson Phone: (305) 717-5865

'* U. S. Geological Survey - WRD FAX: (305) 717-5801

'* 9100 NW 36th St., Suite 109

'* Miami, Florida 33178 USA Internet: rdpatter@usgs.gov

'*

'*=============================================================================

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*

'* Disclaimer: 

' Although this program has been used by the U.S. Geological Survey,

' no warranty, expressed or implied, is made by the USGS as to the

' accuracy and functioning of the program and related program

' material nor shall the fact of distribution constitute any such

' warranty, and no responsibility is assumed by the USGS in

' connection therewith.

'*

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*=============================================================================

'

'---VERSION 1.0 AVWELL 08MAY2001 8:36 AM

'

'::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'

' .. Purpose: sets up the selected point theme as the well theme. Upon 

' selecting the theme, the user is prompted for a well name or id field (should

' be a text field with identifiers for the wells), then prompts for the layer

' field (contains the layer number in the simulation that the well withdraws

' from), and then it asks the user to select the pumpage fields. One pumpage

' field must be designated by the user for each period in the variable NPER,

' which is obtained from the basic package of the local simulation. The pumpage

' field should be numeric with pumpage in the units used by the local simulation

' and the values should be negative for withdrawal, positive for injection. The

' above information (along with place holders for other information yet to be 

' entered) is assembled into a list which is set as the well theme's object tag.

' The information in the list is needed by the rest of the programs to create

' the well package file. The attribute table of the well theme is then set as

' the server for the dialog. At the beginning, a search is made in the view for

' a well theme that may have previously been designated, by calling the script

' "Avtmr.GetGridTheme"; if one is found, the user is asked whether to keep it or

' replace it with the selected theme. Updates are broadcast to listening 

' controls at the end.

'

'0123456789012345678901234567890123456789012345678901234567890123456789012345678

theView = av.GetActiveDoc

theDialog = SELF.GetDialog

txlWellName = theDialog.FindByName("txlWellName")

txtNPER = theDialog.FindByName("txtNPER")

lbxPumpage = theDialog.FindByName("lbxPumpage")

cbxGridTheme = theDialog.FindByName("cbxGridTheme")

'if a well theme's been designated, then ask user whether
9

'to change to the new one and delete old one's object tag.

theSelTheme = SELF.GetSelection

theWellTheme = av.Run("Avtmr.GetGridTheme", {theView, "W"})

if (theSelTheme = theWellTheme) then

 theFTab = theWellTheme.GetFTab

 theDialog.SetServer(theFTab)

 lbxPumpage.Update

 return NIL

elseif (theWellTheme = NIL) then

 'none's been designated, we'll go with this one

 theWellTheme = theSelTheme

else 'they're choosing a new well theme

 'verify:

 change = MsgBox.YesNo ("The well theme is currently "+theWellTheme.GetName +

 ", Would you like to change it to be " + 

 theSelTheme.GetName + "?", "Selecting Well Theme", TRUE)

 if (change) then

 theWellTheme.SetObjectTag("")

 theWellTheme = theSelTheme

 else

 SELF.Update

 theFTab = theWellTheme.GetFTab

 theDialog.SetServer(theFTab)

 lbxPumpage.Update

 Return NIL

 end

end

theFTab = theWellTheme.GetFTab

theWellList = List.Make

theWellList.Add("W") '**0th item added to theWellList

'make lists of all string flds and all num flds:

theStringFlds = {}

theNumFlds = {}

for each F in theFTab.GetFields

 if (F.IsTypeNumber) then

 theNumFlds.Add(F)

 elseif (F.IsTypeString) then

 theStringFlds.Add(F)

 end

end

'get the well name field:

theWellFld = MsgBox.ListAsString(theStringFlds, "Select Well Name field",

 "Selecting Fields")

theWellFldName = theWellFld.GetName

theWellList.Add(theWellFldName) '**1st item added to theWellList

theStringFlds.RemoveObj(theWellFld)

'get the layer field:

theLayerFld = MsgBox.ListAsString(theNumFlds, "Select Layer field",

 "Selecting Fields")

theLayerFldName = theLayerFld.GetName

theWellList.Add(theLayerFldName) '**2nd item added to theWellList
10

theNumFlds.RemoveObj(theLayerFld)

'get the flds for each stress period:

NPER = txtNPER.GetLabel.AsList.Get(2).AsNumber

thePumpFlds = List.Make

for each i in 1..NPER

 'get the fld for the i-th stress period pumpage:

 anPumpFld = MsgBox.ListAsString(theNumFlds, "Select Stress Period"++

 i.AsString++"field", "Selecting Fields")

 thePumpFlds.Add(anPumpFld.GetName)

end

'get the file name for the name file in the path to files:

theRootName = theDialog.FindByName("txlRootName").GetText

thePath = theDialog.FindByName("txtPathToFiles").GetLabel.AsList.Get(3)

theFileNameString = thePath + "\" + theRootName + ".nam"

theFileName = FileName.Make(theFileNameString)

theWellList.Add(thePumpFlds) '**3rd item added to theWellList

theWellList.Add(NIL) '**4th item added to the WellList (placeholder

 ' for theGridTheme)

theWellList.Add(theFileName) '**5th item added to the WellList

theWellList.Add("") '**6th item added to the WellList (placeholder

 ' for theRecTrackList)

theWellTheme.SetObjectTag(theWellList)

theDialog.SetServer(theFTab)

SELF.BroadcastUpdate

av.GetProject.SetModified(TRUE)
11

'************* U.S. Geological Survey preliminary computer program ************

'******************************************************************************

'************* AvWell.dlgAvWell.lbtBrowse.Click **************

'******************************************************************************

'** Language: ArcView Avenue **

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*=============================================================================

'* Author/Site, Date, Event

'* --------------------------------------------------------------------------

'* Raul D. Patterson Phone: (305) 717-5865

'* U. S. Geological Survey - WRD FAX: (305) 717-5801

'* 9100 NW 36th St., Suite 109

'* Miami, Florida 33178 USA Internet: rdpatter@usgs.gov

'*

'*=============================================================================

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*

'* Disclaimer: 

' Although this program has been used by the U.S. Geological Survey,

' no warranty, expressed or implied, is made by the USGS as to the

' accuracy and functioning of the program and related program

' material nor shall the fact of distribution constitute any such

' warranty, and no responsibility is assumed by the USGS in

' connection therewith.

'*

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*=============================================================================

'

'---VERSION 1.0 AVWELL 08MAY2001 8:36 AM

'

'::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'

' Purpose: Prompts the user to browse to the MODFLOW Name File of the local

' simulation. Locates the basic file and reads the value NPER from it. Posts

' the Path to Files, NPER and the Root name of the simulation into their 

' respective controls and send an update to enable the drop-down list box for

' the well theme.

'

'0123456789012345678901234567890123456789012345678901234567890123456789012345678

'

theView = av.GetActiveDoc

theDialog = SELF.GetDialog

'identify controls:

txlRootName = theDialog.FindByName("txlRootName")

txtPathToFiles = theDialog.FindByName("txtPathToFiles")

txtNPER = theDialog.FindByName("txtNPER")

cbxWellTheme = theDialog.FindByName("cbxWellTheme")

cpaThemes = theDialog.FindByName("cpaThemes")

'browse to the simulation's name file:

theWellTheme = av.Run("Avtmr.GetGridTheme", {theView, "W"})

if ((theWellTheme = NIL).Not) then

 theNameFileName = theWellTheme.GetObjectTag.Get(5)

 theNameFileName.ReturnDir.SetCWD

end

theNameFileName = FileDialog.Show ("*.nam", "MODFLOW Name File (*.nam)",

 "Select Name File for Local MODFLOW Simulation")
12

if (theNameFileName = NIL) then

 Return NIL

end

if ((theWellTheme = NIL).Not) then

 theWellTheme.GetObjectTag.Set(5, theNameFileName)

 av.GetProject.SetModified(TRUE)

end

PathToFiles = theNameFileName.ReturnDir.AsString

txtPathToFiles.SetLabel("Path to Files:" ++ PathToFiles)

txtPathToFiles.SetEnabled(TRUE)

txlRootName.SetText(theNameFileName.GetBaseName)

txlRootName.SetEnabled(TRUE)

'set NPER:

theBASFileName = (PathToFiles + "\" +

 av.Run("Avtmr.GetFileNameFromNameFile", 

 {theNameFileName, "BAS"})).AsFileName

theBASFile = LineFile.Make(theBASFileName, #FILE_PERM_READ)

theBASFile.SetPos(2)

the3rdLine = theBASFile.ReadElt

NPER = the3rdLine.AsList.Get(3)

theBASFile.Close

txtNPER.SetLabel("Stress Periods: "+NPER)

txtNPER.SetEnabled(TRUE)

cpaThemes.SetEnabled(TRUE)

cbxWellTheme.SetEnabled(TRUE)
13

'************* U.S. Geological Survey preliminary computer program ************

'******************************************************************************

'************* AvWell.dlgAvWell.lbtWriteFile.Click ***********

'******************************************************************************

'** Language: ArcView Avenue **

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*=============================================================================

'* Author/Site, Date, Event

'* --------------------------------------------------------------------------

'* Raul D. Patterson Phone: (305) 717-5865

'* U. S. Geological Survey - WRD FAX: (305) 717-5801

'* 9100 NW 36th St., Suite 109

'* Miami, Florida 33178 USA Internet: rdpatter@usgs.gov

'*

'*=============================================================================

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*

'* Disclaimer: 

' Although this program has been used by the U.S. Geological Survey,

' no warranty, expressed or implied, is made by the USGS as to the

' accuracy and functioning of the program and related program

' material nor shall the fact of distribution constitute any such

' warranty, and no responsibility is assumed by the USGS in

' connection therewith.

'*

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*=============================================================================

'

'---VERSION 1.0 AVWELL 08MAY2001 8:36 AM

'

'::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'

' .. Purpose: Writes the WEL file by using the parameters stored in the Well

' Theme's object tag. Locates the current WEL package file, giving the user

' the opportunity to re-name the old file before creating the new one to avoid

' over-writing it. Loops through the Pump fields, writing a block of data to 

' the WEL file for each new stress pump field by looping through the records, 

' and writes a -1 in a new line for those stress periods using the same field as

' the previous stress period. The determination of whether the previous stress

' period's information will be used is done by comparing the pump field in the 

' current iteration with that of the previous one. If it is the same field, 

' then there is no need to write a new block of data and a -1 is written on the

' next line indicating that the previous stress period’s pumping values will be

' reused in the current stress period. If a well is inactive for a given stress

' period, then its pumping value is 0. Accordingly, at the beginning of the loop

' a reselect query is executed for "[PumpFldName] <> 0", and this selection is 

' then processed, leaving out the wells with pumping values of 0.

'

'0123456789012345678901234567890123456789012345678901234567890123456789012345678

theView = av.GetActiveDoc

theWellTheme = av.Run("Avtmr.GetGridTheme", {theView, "W"})

theWellFTab = theWellTheme.GetFTab

'Get current list of parameters:

theParamList = theWellTheme.GetObjectTag

theWellFldName = theParamList.Get(1)

theLayFldName = theParamList.Get(2)

thePumpFldNames = theParamList.Get(3)

theGridTheme = theParamList.Get(4)

theNamFileName = theParamList.Get(5)
14

the10SpaceString = " "

the12SpaceString = " "

'momentarily, for the duration of this script:

'locate current WEL pkg file where NAME file points, copying existing file to a

'new name and reusing the name in the NAME file for the new one:

theOldFile = av.Run("Avtmr.GetFileNameFromNameFile", {theNamFileName, "WEL"})

theOldFileName = (theNamFileName.ReturnDir.AsString + "\" + 

theOldFile).AsFileName

if (theOldFileName.IsFile.Not) then

 MsgBox.Info("The location indicated in the Name file for the WEL file will "+

 "be used", "the Current WEL file," + theOldFile +

 " was not found", "")

else

 OverWrite = MsgBox.YesNo("the Current WEL file exists:"+NL+theOldFile, 

 "Over-write Current WEL File?", FALSE)

 if (OverWrite.Not) then

 MsgBox.Info("To run again, re-name the old WEL file and then try again",

 "Terminating Execution")

 Return NIL

 end

end

theNewFileName = theOldFileName

'Open up the old file to read the first non-comment line:

theOldWellFile = LineFile.Make(theOldFileName, #FILE_PERM_READ)

the1stLine = NIL

While (the1stLine = NIL)

 aLine = theOldWellFile.ReadElt

 if (aLine.Trim.Left(1) <> "#") then

 the1stLine = aLine

 break

 end

end

theOldWellFile.Close

if (the1stLine = NIL) then

 MsgBox.Error("Invalid WEL file: no valid records found", "Terminating "+

 "Execution")

 Return NIL

end

'get IWELCB, the only thing to be retained from the old well file:

IWELCB = the1stLine.AsList.Get(1)

'Start up the new file (this will overwrite the old file)

theNewFile = LineFile.Make(theNewFileName, #FILE_PERM_WRITE)

'get NCOL and NROW from BAS file:

theBASFileName = (theNamFileName.ReturnDir.AsString + 
15

 "\" + av.Run("Avtmr.GetFileNameFromNameFile", 

 {theNamFileName, "BAS"})).AsFileName

theBASFile = LineFile.Make(theBASFileName, #FILE_PERM_READ)

theBASFile.SetPos (2)

the3rdBASLine = theBASFile.ReadElt

theItems = the3rdBASLine.AsList

 

NROW = theItems.Get(1).AsNumber

NCOL = theItems.Get(2).AsNumber

NROWxNCOL = NROW * NCOL

NPER = theItems.Get(3).AsNumber

theBASFile.Close

'the PumpFldName is used as a Key to a dictionary that contains either bitmaps

'or a number, -1. A -1 is used whenever a pump field is used for consecutive

'stress periods.

theNumOfRecs = theWellFTab.GetNumRecords

PER = 0

thePrevFldName = ""

theNullVal = 0

MXWELL = 0

'save selection to issue it in the upcoming loop:

theOrigBitmap = theWellFTab.GetSelection.Clone

theWellFTab.GetSelection.ClearAll

theWellFTab.UpdateSelection

aStressPerDict = Dictionary.Make((thePumpFldNames.Count/10).Ceiling)

av.ClearMsg

av.ShowMsg("Sizing arrays...")

for each aPumpFldName in thePumpFldNames

 PER = PER + 1

 aStressPerList = List.Make

 if (aPumpFldName = thePrevFldName) then

 ITMP = -1

 aStressPerList = {ITMP}

 else 'Determine MXWELL, ITMP for this stress period by doing selects:

 aBitmap = theOrigBitmap.Clone

 theWellFTab.SetSelection( theOrigBitmap )

 theWellFTab.UpdateSelection

 

 theQString = "(["+aPumpFldName+"] <> "+theNullVal.AsString+" )"

 theWellFTab.Query(theQString, aBitmap, #VTAB_SELTYPE_AND)

 theWellFTab.SetSelection(aBitmap)

 theWellFTab.UpdateSelection

 ITMP = theWellFTab.GetNumSelRecords

 if (ITMP > MXWELL) then

 MXWELL = ITMP

 end

 aStressPerList = {ITMP, aBitmap}

 end

 aStressPerDict.Add(PER, aStressPerList)

 thePrevFldName = aPumpFldName

end

av.ClearMsg

MXWELL = MXWELL.AsString

the1stLine = the10SpaceString.Left(10 - MXWELL.Count)+MXWELL + 

 the10SpaceString.Left(10 - IWELCB.Count)+IWELCB
16

theNewFile.WriteElt(the1stLine)

theLayFld = theWellFTab.FindField(theLayFldName)

theRowFld = theWellFTab.FindField("Row")

theColFld = theWellFTab.FindField("Col")

theShpFld = theWellFTab.FindField("Shape")

theWellFld = theWellFTab.FindField(theWellFldName)

thisPumpFldName = NIL

'thePumpFldNames contain one field for each stress period and they may

'be repeated (ie. the same Pump field may be used by more than one stress

'period, whether the stress periods are consecutive or not). A determi-

'nation is made at the beginning of the loop to check if the same pump field

'is being used as in the previous stress period, if yes, a -1 is written

'otherwise, a whole new block of data is written.

 

 'initialize variables:

 ITMP = 0

 aTenSpaceString = " "

 

for each i in 1..NPER

 

 theList = aStressPerDict.Get(i)

 ITMP = theList.Get(0)

 

 if (ITMP < 0) then

 theNewFile.WriteElt(" -1")

 continue 'a new set of type3 recs isn't needed, so next PERiod...

 else

 theITMPSpaces = aTenSpaceString.Left(10 - ITMP.AsString.Count)

 theNewFile.WriteElt(theITMPSpaces + ITMP.AsString)

 end

 

 'access the values of this selection and put them into a dictionary that

 'uses SeqNum as its key, and the values are lists of Item Lists. Each

 'anItemList containing, in sequence, the elements of a record:

 

 aBitmap = theList.Get(1)

 

 theDict = Dictionary.Make(theWellFTab.GetNumSelRecords/10)

 theWellFTab.SetSelection(aBitmap)

 theWellFTab.UpdateSelection

 

 aPumpFldName = thePumpFldNames.Get(i - 1)

 thePumpFld = theWellFTab.FindField(aPumpFldName)

 

 for each aRec in theWellFTab.GetSelection

 

 theLay = theWellFTab.ReturnValue(theLayFld, aRec)

 theRow = theWellFTab.ReturnValue(theRowFld, aRec)

 theCol = theWellFTab.ReturnValue(theColFld, aRec)

 theSeqnum = ((theLay - 1) * NROWxNCOL) + ((theRow - 1) * NCOL) + theCol

 theLay = theLay.AsString

 theRow = theRow.AsString

 theCol = theCol.AsString

 thePumpage = theWellFTab.ReturnValue(thePumpFld, aRec).SetFormat(

 "d.d").AsString

 theWell = theWellFTab.ReturnValue(theWellFld, aRec)

 theWell = theWell.Left(12) + the12SpaceString.Left(12 - theWell.Count)

 theShape = theWellFTab.ReturnValue(theShpFld, aRec)

 theXcoor = theShape.GetX.SetFormat("d.dd").AsString

 theYcoor = theShape.GetY.SetFormat("d.dd").AsString
17

 

 aRecord = {theLay, theRow, theCol, thePumpage, theWell, theXcoor, theYcoor}

 

 if (theDict.Get(theSeqnum) = NIL) then

 aListOfRecords = List.Make

 aListOfRecords.Add(aRecord)

 theDict.Add(theSeqnum, aListOfRecords)

 else

 aListOfRecords = theDict.Get(theSeqnum)

 aListOfRecords.Add(aRecord)

 theDict.Set(theSeqnum, aListOfRecords)

 end

 end

 

 'write out the records:

 

 theSeqnums = theDict.ReturnKeys

 theSeqnums.Sort(TRUE)

 'create a string for this PER's data:

 PERString = ""

 for each aSeqnum in theSeqnums

 theListOfRecords = theDict.Get(aSeqnum)

 for each aRecord in theListOfRecords

 aRecString = ""

 for each i in 0..3

 anItem = aRecord.Get(i)

 theSpaces = aTenSpaceString.Left(10 - anItem.Count)

 aRecString = aRecString + theSpaces + anItem

 end

 aRecString = aRecString + " #"

 for each i in 4..6

 anItem = aRecord.Get(i)

 aRecString = aRecString ++ anItem

 end

 theNewFile.WriteElt(aRecString)

 end

 end

end

theNewFile.Close
18

'************* U.S. Geological Survey preliminary computer program ************

'******************************************************************************

'************* AvWell.dlgAvWell.Open **************

'******************************************************************************

'** Language: ArcView Avenue **

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*=============================================================================

'* Author/Site, Date, Event

'* --------------------------------------------------------------------------

'* Raul D. Patterson Phone: (305) 717-5865

'* U. S. Geological Survey - WRD FAX: (305) 717-5801

'* 9100 NW 36th St., Suite 109

'* Miami, Florida 33178 USA Internet: rdpatter@usgs.gov

'*

'*=============================================================================

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*

'* Disclaimer: 

' Although this program has been used by the U.S. Geological Survey,

' no warranty, expressed or implied, is made by the USGS as to the

' accuracy and functioning of the program and related program

' material nor shall the fact of distribution constitute any such

' warranty, and no responsibility is assumed by the USGS in

' connection therewith.

'*

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*=============================================================================

'

'---VERSION 1.0 AVWELL 08MAY2001 8:36 AM

'

'::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'

' .. Purpose: Sets up environment for dialog. First, all controls are

' referenced. Then, the broadcast-listener relationships are set up among the

' controls. At the end, updates are sent to all the controls to initialize the

' dialog. Prior to initialization, a well theme is searched for in the current

' view; if a well theme has been designated in the view, then it is determined

' whether a grid theme has been associated with it. If there is no

' well theme, the form will open up with all controls disabled except for the

' Browse and Close buttons. If a well theme exists but no grid theme, then

' additionally, the well theme drop-down list box and the grid theme drop-down

' list box will be enabled as well.

'

'0123456789012345678901234567890123456789012345678901234567890123456789012345678

'

theView = av.GetActiveDoc

'identify controls:

txlRootName = SELF.FindByName("txlRootName")

cbxWellTheme = SELF.FindByName("cbxWellTheme")

cbxGridTheme = SELF.FindByName("cbxGridTheme")

txtNPER = SELF.FindByName("txtNPER")

txtPathToFiles = SELF.FindByName("txtPathToFiles")

txlWellName = SELF.FindByName("txlWellName")

txlXcoor = SELF.FindByName("txlXcoor")

txlYcoor = SELF.FindByName("txlYcoor")

txlLayer = SELF.FindByName("txlLayer")

lbxPumpage = SELF.FindByName("lbxPumpage")

txtRecTracker = SELF.FindByName("txtRecTracker")

btnPrevious = SELF.FindByName("btnPrevious")
19

btnNext = SELF.FindByName("btnNext")

lbtWriteFile = SELF.FindByName("lbtWriteFile")

'set up broadcast/listener relationships:

theRecTrackingControls = {txlWellName, btnNext, btnPrevious, txtRecTracker, 

 txlXcoor, txlYcoor, txlLayer, lbxPumpage}

btnPrevious.SetListeners(theRecTrackingControls)

btnNext.SetListeners(theRecTrackingControls)

cbxGridTheme.SetListeners(theRecTrackingControls)

cbxWellTheme.SetListeners(theRecTrackingControls)

cbxGridTheme.AddListener(cbxWellTheme)

cbxGridTheme.AddListener(lbtWriteFile)

cbxWellTheme.AddListener(cbxGridTheme)

cbxWellTheme.AddListener(lbtWriteFile)

'check if a well theme exists in the view, if it does, check if a grid theme 

'is in the View, if not in the view. If a well theme exists nd its grid

'a theme also exists, then overlay grid with wells, and initialize dialog:

theWellTheme = av.Run("Avtmr.GetGridTheme", {theView, "W"})

if ((theWellTheme = NIL).Not) then

 theWellParamList = theWellTheme.GetObjectTag

 theGridTheme = theWellParamList.Get(4)

 

 if (theGridTheme = NIL) then

 'do nothing

 elseif (theView.GetThemes.Find(theGridTheme) = -1) then

 MsgBox.Warning("The previosly selected grid theme, "+theGridTheme.GetName+

 ", is not in the view, select a new grid theme", 

 "Grid Theme Not Found")

 theWellParamList.Set(4, NIL)

 theWellTheme.SetObjectTag(theWellParamList)

 else 'overlay themes, reset controls:

 av.Run("AvWell.OverlayWellsWithGrid", {theWellTheme, theGridTheme})

 SELF.SetServer(theWellTheme.GetFTab)

 'reset record tracker:

 av.Run("AvWell.MoveRecord", {theWellTheme, "RESET"})

 'reload pumpage data to Pumpage listbox:

 av.Run("AvWell.LoadPumpage", {theWellTheme, lbxPumpage})

 end

end

'send updates for initialization:

txlRootName.Update

txtPathToFiles.Update

txtNPER.Update

cbxWellTheme.Update

cbxGridTheme.Update

btnPrevious.Update

btnNext.Update

txtRecTracker.Update

txlWellName.Update

txlXcoor.Update

txlYcoor.Update

txlLayer.Update
20

lbxPumpage.Update

lbtWriteFile.Update
21

'************* U.S. Geological Survey preliminary computer program ************

'******************************************************************************

'************* AvWell.Install **************

'******************************************************************************

'** Language: ArcView Avenue **

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*=============================================================================

'* Author/Site, Date, Event

'* --------------------------------------------------------------------------

'* Raul D. Patterson Phone: (305) 717-5865

'* U. S. Geological Survey - WRD FAX: (305) 717-5801

'* 9100 NW 36th St., Suite 109

'* Miami, Florida 33178 USA Internet: rdpatter@usgs.gov

'*

'*=============================================================================

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*

'* Disclaimer: 

' Although this program has been used by the U.S. Geological Survey,

' no warranty, expressed or implied, is made by the USGS as to the

' accuracy and functioning of the program and related program

' material nor shall the fact of distribution constitute any such

' warranty, and no responsibility is assumed by the USGS in

' connection therewith.

'*

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*=============================================================================

'

'---VERSION 1.0 AVWELL 08MAY2001 8:36 AM

'

'::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'

' .. Purpose: Install script is executed only when the extension is loaded for

' the first time in an ArcView session. Installs the dialog, dlgAvWell, the 

' extension scripts, as well as the button and MODTMR menu (if not already

' present), and the 'Well Refiner...' choice for launching the dialog.

'

'0123456789012345678901234567890123456789012345678901234567890123456789012345678

'Install ONLY if there is an active project

if (av.GetProject = nil) then

 return NIL

end

'Retrieve objects from extension:

theProject = av.GetProject

theOpenButton = SELF.Get(0)

theSpace = SELF.Get(1)

theChoice = SELF.Get(2)

'the project must have a View GUI:

theViewGUI = av.GetProject.FindGUI("View")

if (theViewGUI = NIL) then

 Return NIL

end

'Install the open button:

theViewGUIButtonBar = theViewGUI.GetButtonBar

theViewGUIButtons = theViewGUIButtonBar.GetControls

'Make it the last item

thePlace = theViewGUIButtons.Count
22

theViewGUIButtonBar.Add(theOpenButton, thePlace)

'now install menu choice and MODTMR menu if not present:

theViewMenuBar = theViewGUI.GetMenuBar

theMODTMRMenu = theViewMenuBar.FindByLabel("MODTMR")

if (theMODTMRMenu = NIL) then

 'add it:

 theWindowMenu = theViewMenuBar.FindByName("Window")

 thePlace = theViewMenuBar.GetControls.Find(theWindowMenu) - 1

 theMenu = theViewMenuBar.New(thePlace)

 theMenu.SetLabel("&MODTMR")

 theMenu.Add(theChoice, 0)

else

 'add a space and then it:

 theMODTMRMenu.Add(theSpace, 99)

 theMODTMRMenu.Add(theChoice, 99)

end

theViewGUI.SetModified(TRUE)
23

'************* U.S. Geological Survey preliminary computer program ************

'******************************************************************************

'************* AvWell.LoadPumpage **************

'******************************************************************************

'** Language: ArcView Avenue **

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*=============================================================================

'* Author/Site, Date, Event

'* --------------------------------------------------------------------------

'* Raul D. Patterson Phone: (305) 717-5865

'* U. S. Geological Survey - WRD FAX: (305) 717-5801

'* 9100 NW 36th St., Suite 109

'* Miami, Florida 33178 USA Internet: rdpatter@usgs.gov

'*

'*=============================================================================

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*

'* Disclaimer: 

' Although this program has been used by the U.S. Geological Survey,

' no warranty, expressed or implied, is made by the USGS as to the

' accuracy and functioning of the program and related program

' material nor shall the fact of distribution constitute any such

' warranty, and no responsibility is assumed by the USGS in

' connection therewith.

'*

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*=============================================================================

'

'---VERSION 1.0 AVWELL 08MAY2001 8:36 AM

'

'::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'

' .. Purpose: loads the pumpage data for the wells in the pumpage fields to the 

' Pumpage list box, and sets the first row visible.

'

'0123456789012345678901234567890123456789012345678901234567890123456789012345678

theWellTheme = SELF.Get(0)

lbxPumpage = SELF.Get(1)

theDialog = lbxPumpage.GetDialog

theWellParams = theWellTheme.GetObjectTag

theWellFTab = theWellTheme.GetFTab

thePumpFlds = {}

thePumpFldsNames = theWellParams.Get(3)

for each P in thePumpFldsNames

 aPumpFld = theWellFTab.FindField(P)

 thePumpFlds.Add(aPumpFld)

end

lbxPumpage.DefineFromVTab (theDialog.GetServer, thePumpFlds, TRUE)

lbxPumpage.SetRowHeight(100)
24

'************* U.S. Geological Survey preliminary computer program ************

'******************************************************************************

'************* AvWell.MoveRecord **************

'******************************************************************************

'** Language: ArcView Avenue **

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*=============================================================================

'* Author/Site, Date, Event

'* --------------------------------------------------------------------------

'* Raul D. Patterson Phone: (305) 717-5865

'* U. S. Geological Survey - WRD FAX: (305) 717-5801

'* 9100 NW 36th St., Suite 109

'* Miami, Florida 33178 USA Internet: rdpatter@usgs.gov

'*

'*=============================================================================

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*

'* Disclaimer: 

' Although this program has been used by the U.S. Geological Survey,

' no warranty, expressed or implied, is made by the USGS as to the

' accuracy and functioning of the program and related program

' material nor shall the fact of distribution constitute any such

' warranty, and no responsibility is assumed by the USGS in

' connection therewith.

'*

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*=============================================================================

'

'---VERSION 1.0 AVWELL 08MAY2001 8:36 AM

'

'::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'

'

' .. Purpose: Moves the current record in the selected set of the well attribute

' table one up or down, or rewinds back to the first selected record, depending

' on the keyword that is received as an argument ("NEXT", "PREVIOUS" or 

' "RESET"). Updates the obj tag of the well theme to store the new record 

' number.

'

'0123456789012345678901234567890123456789012345678901234567890123456789012345678

theWellTheme = SELF.Get(0)

theAction = SELF.Get(1)

theWellParams = theWellTheme.GetObjectTag

theRecTrackList = theWellParams.Get(6)

CurrRec = theRecTrackList.Get(0)

theWellNo = theRecTrackList.Get(2)

theWellThemeSelection = theWellTheme.GetFTab.GetSelection

if (theAction = "NEXT") then

 CurrRec = theWellThemeSelection.GetNextSet(CurrRec)

 theWellNo = theWellNo + 1

elseif (theAction = "PREVIOUS") then

 CurrRec = theWellThemeSelection.GetPrevSet(CurrRec)

 theWellNo = theWellNo - 1

elseif (theAction = "RESET") then

 CurrRec = theWellThemeSelection.GetNextSet(-1)

 theWellNo = 1

end
25

theRecTrackList.Set(0, CurrRec)

theRecTrackList.Set(2, theWellNo)

theWellParams.Set(6, theRecTrackList)

theWellTheme.SetObjectTag(theWellParams)

Return CurrRec
26

'************* U.S. Geological Survey preliminary computer program ************

'******************************************************************************

'************* AvWell.OverlayWellsWithGrid ************

'******************************************************************************

'** Language: ArcView Avenue **

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*=============================================================================

'* Author/Site, Date, Event

'* --------------------------------------------------------------------------

'* Raul D. Patterson Phone: (305) 717-5865

'* U. S. Geological Survey - WRD FAX: (305) 717-5801

'* 9100 NW 36th St., Suite 109

'* Miami, Florida 33178 USA Internet: rdpatter@usgs.gov

'*

'*=============================================================================

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*

'* Disclaimer: 

' Although this program has been used by the U.S. Geological Survey,

' no warranty, expressed or implied, is made by the USGS as to the

' accuracy and functioning of the program and related program

' material nor shall the fact of distribution constitute any such

' warranty, and no responsibility is assumed by the USGS in

' connection therewith.

'*

'*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'*=============================================================================

'

'---VERSION 1.0 AVWELL 08MAY2001 8:36 AM

'

'::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

'

' .. Purpose: overlays the grid theme on the well theme, thereby appending to 

' the attribute table of the latter the grid fields 'seqnum', 'row', and 'col'.

' the overlay is performed by a spatial join in which the "from" field is the

' shape field of the grid theme, and the "to" field is the shape field of the

' well theme. Then, a selection by theme is done on the well theme with the

' grid theme to select only those wells that fall inside the grid theme.

'

'0123456789012345678901234567890123456789012345678901234567890123456789012345678

theWellTheme = SELF.Get(0)

theGridTheme = SELF.Get(1)

'do the spatial join:

theWellFTab = theWellTheme.GetFTab

theWellShpFld = theWellFTab.FindField("Shape")

theGridFTab = theGridTheme.GetFTab

theGridShpFld = theGridFTab.FindField("Shape")

'check if well ftab has any joins, unjoining all if yes:

if (theWellFTab.IsBase.Not) then

 av.GetProject.SetModified(true)

 theWellFTab.UnjoinAll

end

theWellFTab.Join(theWellShpFld, theGridFTab, theGridShpFld)

theWellTheme.SelectByTheme (theGridTheme, #FTAB_RELTYPE_ISCOMPLETELYWITHIN,

 0, #VTAB_SELTYPE_NEW)

theWellFTab.UpdateSelection