EPA 600/9-81-014
                                 February 1981
   COMPUTER  PROGRAM DOCUMENTATION

                for  the

        STREAM QUALITY MODEL

                QUAL-II
              Prepared by

           Larry A. Roesner
           Paul R. Giguere
           Donald E. Evenson
             Prepared for

Southeast Michigan Council of Governments
            Detroit, Michigan
               July 1977
          (Revised January 1981)
     Environmental Research Laboratory
    Office of Research and Development
   U.S. Environmental Protection Agency
              Athens, Georgia

-------
                              FOREWORD

      QUAL-II/SEMCOG version was developed by Water Resources Engineers
for the Southeast Michigan Council  of Governments (SEMCOG) under Section
208 of PL 92-500.  It represents a substantial improvement over previous
versions of the model and is being made available through the Center for
Water Quality Modeling as a service to interested users with the permission
of SEMCOG.  Mention of trade names or commercial  products does not consti-
tute endorsement or recommendation for use by the U.S. Environmental Pro-
tection Agency.
                                       ii

-------
                           TABLE OF CONTENTS
                                                                     Page

 I.    INTRODUCTION                                                     ]
      History and Acknowledgments                                      2
      Prototype Representation                                         3
      Model Limitations                                                4
      Model Structure and Subroutines                                  4
      Program Language and Operating Requirements                      6
      Typical Execution Times                                          6
      Job Control Considerations                                       7

 II.   GENERAL MODEL FORMULATION                                        8
      Introduction                                                     8
      Conceptual Representation                                        9
      Functional Representation                                       H
      Hydraulic Characteristics                                       I4
      Longitudinal Dispersion                                         I5

 III.  CONSTITUENT REACTIONS AND INTERRELATIONSHIPS                    19

      General Considerations                                          19
      Summary of Mathematical Relationships                           30
      Reaction Rates and Physical Constants                           32
      Temperature Dependence                                          32

 IV.   FUNCTIONAL REPRESENTATION OF TEMPERATURE                        34

      The Basic Temperature Equation                                  34
      Definition of HN                                                **
      Net Short-Wave Solar Radiation                                  ^b
      Long-Wave Atmospheric Radiation                                 J4
      Water Surface Back Radiation                                   ' 44
      Evaporation                                                     jj
      Conduction                                                      47

V.    COMPUTATIONAL REPRESENTATION                                    48
                                                                      Aft
      Prototype Representation                                        Ti
      Model Limitations                                               j™
      Numeric Solution Technique                                      *z
      List of References                                              &

VI.   COMPUTER PROGRAM DESCRIPTION                                    62

      Model Structure and Subroutines                                 62
      Main Program QUAL2                                              62
      Subroutine ALGAES                                               80
      Subroutine BODS                                                 85
      Subroutine CHANL                                                89

-------
                           TABLE OF CONTENTS
                              (Continued)
VI.   Continued
      Subroutine COLIS                                                93
      Subroutine CONSVT                                               98
      Subroutine DOS                                                 102
      Subroutine FLOAUG                                              107
      Subroutine HEATEX/HEATER                                       113
      Subroutine HYDRAU                                              123
      Subroutine INDATA                                              127
      Subroutine NH3S                                                149
      Subroutine N02S                                                154
      Subroutine N03S                                                159
      Subroutine P04S                                                164
      Subroutine RADIOS                                              169
      Subroutine REAERC                                              174
      Subroutine SOVMAT                                              179
      Subroutine TEMPS                                               183
      Subroutine TEMPSS                                              188
      Subroutine TRIMAT                                              193
      Subroutine WRPT2                                               198
      Subroutine WRPT3               '              '                  204
      Definition of Symbols                                          211

VII.  QUAL-II DESCRIPTION OF VARIABLES IN COMMON                     214
                                   iv

-------
                            LIST OF FIGURES
 No.                                                                  Page
 1-1       General Structure of QUAL-II                                  5
 II-l      Discretized Stream System                                    10
 II-2      Stream Network of Computational Elements and Reaches         12
 III-l     Major Constituent Interactions                               20
 IV-1      Heat Transfer Terms Associated with Interfacial              36
             Heat Transfer
 V-l       Classical Implicit Nodal Scheme                              51
 VI-1      General Structure of QUAL-II                                 63
 VI-2      Flow Chart for Main Program QUAL2                            67
 VI-3      Flow Chart for Subroutine ALGAES                             82
 VI-4      Flow Chart for Subroutine BODS                               87
 VI-5      Flow Chart for Subroutine CHANL                              90
 VI-6      Flow Chart for Subroutine COLIS                              95
 VI-7      Flow Chart for Subroutine CONSVT                            100
 VI-8      Flow Chart for Subroutine DOS                               104
 VI-9      Flow Chart for Subroutine FLOAUG                            109
 VI-10     Flow Chart for Subroutine HEATEX/HEATER                     114
 VI-11     Flow Chart for Subroutine HYDRAU                            124
 VI-12     Flow Chart for Subroutine INDATA                            128
 VI-13     Flow Chart for Subroutine NH3S                              151
 VI-14     Flow Chart for Subroutine N02S                              156
 VI-15     Flow Chart for Subroutine N03S                              161
 VI-16     Flow Chart for Subroutine P04S                              166
 VI-17     Flow Chart for Subroutine RADIOS                            171
 VI-18     Flow Chart for Subroutine REAERC                            175
 VI-19     Flow Chart for Subroutine SOVMAT                            180
 VI-20     Flow Chart for Subroutine TEMPS                             185
 VI-21     Flow Chart for Subroutine TEMPSS                            190
 VI-22     Flow Chart for Subroutine TRIMAT                            195
VI-23     Flow Chart for Subroutine WRPT2                             201
VI-24     Flow Chart for Subroutine WRPT3                             207

-------
                            LIST OF TABLES
No.                                                                  Page
II-l      Values of Manning's "n" Roughness Coefficient               17
II-2      Typical Values of Dispersion Coefficients                   18
III-l     Summary of Differential Equations to be
             Solved by QUA1.-II                                        31
III-2     Input Parameters for QUAL-II                                33
IV-1      Definition of Heat Transfer Terms Illustrated
             in Figure 1                                              37
IV-2      Empirical Coefficients for Determining Rs                   43
                                     vi

-------
                            I.  INTRODUCTION
          QUAL-II is a comprehensive and versatile stream water quality
model.  It can simulate up to 13 water quality constituents in any combi-
nation desired by the user.  Constituents which can be simulated are:
               1.  Dissolved Oxygen
               2.  Biochemical Oxygen Demand
               3.  Temperature
               4.  Algae as Chlorophyll a_
               5.  Ammonia as N
               6.  Nitrite as N
               7.  Nitrate as N
               8.  Dissolved Orthophosphate as P
               9.  Coliforms
              10.  Arbitrary Nonconservative Constituent
              11.  Three Conservative Constituents
The model is applicable to dendritic streams which are well mixed.  It
assumes that the major transport mechanisms, advection and dispersion,
are significant only along the main direction of flow (longitudinal axis
of the stream or canal).  It allows for multiple waste discharges,
withdrawals, tributary flows, and incremental inflow.  It also has the
capability to compute required dilution flows for flow augmentation to
meet any prespecified dissolved oxygen level.

          Hydraulically QUAL-II is limited to the simulation of time
periods during which the stream flows in the river basin are essentially
                                     #
constant.  Input waste loads must also be held constant over time.  QUAL-II
can be operated as a steady-state model or a dynamic model.  Dynamic
operation makes it possible to study water quality (primarily dissolved
oxygen and temperature) as it is affected by diurnal variations in
meteorological data.  The basic theory and mechanics behind the development
of QUAL-II are described in this Program Documentation Manual which is
intended to supplement the User's Manual.

-------
          QUAL-II can be very helpful as a water quality planning tool.
 It can be used to study the impact of waste loads (magnitude,  quality and
 location) on in-stream water quality.  It could also be used in conjunction
with a field sampling program to identify the magnitude and quality
characteristics of nonpoint source waste loads.  By operating  the model
dynamically, diurnal dissolved oxygen variations due to algae  growth and
respiration can be studied.  Dynamic operation also makes it possible to
trace the water quality impact of a slug loading, such as a spill, or of
seasonal or periodic discharges.
HISTORY AND ACKNOWLEDGMENTS

          QUAL-II/SEMCOG VERSION is a -new release of QUAL-II which was
developed by Water Resources Engineers, Inc.  It includes modifications and
refinements made in the model since its original development in 1972 and
is Intended to supersede all prior releases of the computer program.  The
significant differences between this program and earlier releases are:

          1.  Option of English or Metric units on input data.
          2.  Option for English or Metric output— choice is
              independent of input units.
          3.  Option to specify channel hydraulic properties
                                          »
              in terms of trapezoidal channels or stage-discharge
              and velocity discharge curves.
          4.  Option to use Tsivoglou's computational method for
              stream reaeration.
          5.  Improved output display routines.
          6.  Improved steady-state temperature computation routines.

          QUAL-II is an extension of the stream water quality model QUAL-I
developed in 1970 by F. 0.  Masch and Associates and the Texas Water
Development Board (1371)* and the Texas Water Development Board (1970).
*See list of r^a Bareness at rn© and of Sect i en V.
                                    2

-------
 The  computer code was written by W. A. White.  In 1972, WRE under contract
 to the U.S. Environmental Protection Agency, modified and extended QUAL-I
 to produce the first version of QUAL-II.  Over the next three years,
 several different versions of the model evolved in response to specific
 client needs.  In March of 1976, the Southeast Michigan Council  of
 Governments (SEMCOG) contracted with WRE to make further modifications
 and  to combine the best features of the existing versions of QUAL-II
 into a single model.  QUAL-II/SEMCOG VERSION is that Model.
PROTOTYPE REPRESENTATION

          QUAL-II permits any branching, one-dimensional  stream system
to be simulated.  The first step involved in approximating the prototype
is to subdivide the stream system into reaches, which are stretches of
stream that have uniform hydraulic characteristics.   Each reach is then
divided into computational elements of equal length  so that all compu-
tational elements in all reaches are the same length.  Thus, all  reaches
must consist of an integer number of computational  elements.

          In total, there are seven different types  of computational
elements; these are:
               1.  Headwater element
               2.  Standard element
               3.  Element just upstream from a junction
               4.  Junction element
               5.  Last element in system
               6.  Input element
               7.  Withdrawal element
Headwater elements begin every tributary as well as  the main river system,
and as such, they must always be the first element in a reach.  A standard
element is one that does not qualify as one of the  remaining six element
types.  Since incremental inflow is permitted in all  element types, the
only input permitted in a standard element is incremental inflow.   A type

-------
3 element is used to designate an element on the mainstem that is just
upstream from a junction element (type 4) which is an element that has
a simulated tributary entering it.   Element type 5 identifies the last
computational element in the river system; there should be only one
element type 5.  Element types 6 and 7 represent elements which have
inputs (waste loads and unsimulated tributaries) and water withdrawals,
respectively.  River reaches, which are aggregates of computational
elements, are the basis of most data input.  Hydraulic data, reaction
rate coefficients, initial conditions, and incremental runoff data are
constant for all computational elements within a reach.
MODEL LIMITATIONS

          QUAL-II has been developed to be a relatively general program;
however, certain dimensional limitations have been imposed upon it during
program development.  These limitations are as follows:
          Reaches:  a maximum of 75
          Computational elements:  no more than 20 per reach
                                   or 500 in total
          Headwater elements:  a maximum of 15
          Junction elements:  a maximum of 15
          Input and withdrawal elements:  a maximum of 90 in total
MODEL STRUCTURE AND SUBROUTINES

          QUAL-II 1s structured as one main program, QUAL2, supported by
23 different subroutines.  Figure 1-1  graphically illustrates the
functional relationships between the main program and the 23 subroutines.
The original version of QUAL was structured to permit the addition of
parameters easily through addition of subroutines.  This basic concept,
which proved to be an extremely valuable one, was maintained in the extansion

-------
PROGRAM RETURN FOR FLOW AUGMENTATION OPTION |
i*^
ro r > c o
PROGRAM RETURN FOR DYNAMIC SOLUTION OR ITERATIVE STEADY STATE SOLUTION
H>



1 N
2 t
3 t
4 t
5
6 .
7
8 ^
9
10 D-
11
12 t
13
14 fc
15
16 t
17
18 t
19
20 .
21 t
22 J
23 t
24
25 t
26
27 .
28 fr
29 t

INOATA

HYDRAU

TRIMAT

CONSVT


— — 0 CHANL
•
N.

TEMPS/TEMPSS
— - — £> HEATEX/HEATER |
^

BOOS


ALGAES


P04S


NH3S


N02S


N03S


REAERC

DOS


COLIS


RADIOS


WRPT2

FLOAUG

WRPT3

N
fv
rs
r>
u
N.
N.
N
r^-
rv
. «

program 2
^
tltment A ^ ^ ei

s
0
V
M
A
T

program
ement B
                         calling sequence
                         in element A
called  by __/
element A
          FIGURE 1-1

GENERAL STS'JCTURE OF QUAL-I!

-------
of the original version to QUAL-II.  Thus, if it becomes desirable at some
later time to add new parameters or modify existing parameter relationships,
the changes can be made with a minimum of model  restructuring.
PROGRAM LANGUAGE AND OPERATING REQUIREMENTS

          QUAL-II is written in FORTRAN IV and is compatible with the
UNIVAC 1108, CDC 6400, and IBM 360 and 370 computer systems.  The SEMCOG
version of QUAL-II requires an average of 51,000 words of core storage.
QUAL-II uses the system's 80 column card reader as the only input device
and the system's line printer as the only output device.
TYPICAL EXECUTION TIMES

          Execution time on any particular computer system is nearly
linearly related to:
          1.  The number of water quality parameters simulated,
          2.  The number of computational elements in the system, and
          3.  The number of time steps simulated when the dynamic
              simulation option is used.
Approximate execution times for a UNIVAC and IBM computer are shown below.
                                               Execution Time
                                        Steady-StateDynamic
          Computer                       Simulation*       Simulation**
          UNIVAC 1108                       0.02             0.01
          IBM 360/40                        0.15             0.05
          * Seconds/water quality parameter/computational element
          **Seconds/water quality parameter/computational element/time step

-------
JOB CONTROL CONSIDERATIONS

          If the system's normal  FORTRAN input device unit is not unit 5
or the output unit is not unit 6, then the variables "NI" and "NO" in the
subroutine INDATA should be changed to reflect the system's I/O unit
identifiers.

-------
                    II.  GENERAL MODEL FORMULATION
INTRODUCTION

          The primary objective of any stream water quality model  development
is to produce a tool which has the capability for simulating the behavior
of the hydrologic and water quality components of a stream system.   The
development of this tool to simulate prototype behavior by application of
a mathematical model on a digital  computer proceeds through three general
phases (Water Resources Engineers, Inc.  (1967)):
          1.  Conceptual representation
          2.  Functional representation
          3.  Computational representation.

          Conceptual representation involves a graphic idealization of the
prototype by description of the geometric properties that are to be modeled
and by identification of boundary conditions and interrelationships between
various parts of the prototype.  Usually, this process entails discretizing
the prototype into "elements" of a size compatible with the objectives that
the model must serve, defining these elements according to some simple
geometric rules, and designating the mode by which they are connected,
either physically or functionally, as integral parts of the whole.   A part
of this conceptual structuring is the designation of those boundary conditions
that will be considered in the simulation.

          Functional representation entails  formulation of the physical
features, processes, and boundary conditions into sets of algebraic equations.
It involves precise definition of each variable and its relationship to all
other parameters that characterize the model or its input-output relationships.
                                    3

-------
          Computational representation is the process whereby the functional
model is  translated into the mathematical forms and computational procedures
required  for solution of the problem over the desired time and space
continuum.  It is concerned with development of a specific solution technique
that can  be accommodated by the computer and with codification of the
technique in computer language.
                                                 *
          In the remainder of this section the Conceptual Representation
of QUAL-II will be described together with its general Functional
Representation for mass transport, hydraulic characteristics, and
longitudinal dispersion.  Section III will discuss specific constituent
reactions and interactions.  Section IV will develop the Functional
Representation of stream temperature as simulated in QUAL-II.
CONCEPTUAL REPRESENTATION

          Figure II-l shows a stream reach n which has been subdivided
into a number of subreaches or computational elements each of length Ax.
For each of these computational elements, the hydro!ogic balance shown
can be written in terms of flows into the upstream element (Q-{_-|), external
sources or withdrawals (Qx-j), and the outflow (Q-j) through the downstream
face of the element.  Similarly, a materials balance for any constituent
C can be written for the element.  In the materials balance, we consider
both transport (Q-C) and dispersion (A £=-|£) as the movers of mass along
the stream axis.  Mass can be added to the system via wasteloads (QXCX)
and added or removed via internal sources or sinks (S-j) such as benthic
sources and biological transformation.  Each computational element is
considered to be completely mixed.

          Thus the stream can be conceptualized as a string of completely
mixed reactors—computational elements—which are linked sequentially to
one another via the mechanisms of transport and dispersion.  Sequential

-------
      Reach 71
(QC).
                                            Qi-1
                                                   AX
                 FIGURE  II-l

          DISCRETIZED STREAM SYSTEM
After Water Resources Engineers, Inc. (1967)
                    10

-------
groups of these reactors can be defined as reaches in which the computational
elements have the same hydrogeometric properties—stream slope, channel
cross section, roughness, etc.—and biological  rate constants—BOD decay
rate, benthos source rates, algae settling rates, etc.—so that the
stream shown at the left of Figure I1-2 can be conceptually represented
by grouping of reaches and computational elements shown on the lower right
of the figure.
FUNCTIONAL REPRESENTATION
Mass Transport Equation
          The basic equation solved by QUAL-II is the advection-dispersion
mass transport equation, which is numerically integrated over time for
each water quality constituent.  This equation includes the effects of
advection, dispersion, dilution, constituent reactions and interactions,
and sources and sinks.  For any constituent, C, this equation can be
written as:
where
          at

          M
          x
          t
          C
          AX

          u
          s
                     3x
                             dx -
3(AX u C)
    3x
dx
                 mass (M)
                 distance (L)
                 time (T)
                 concentration (M/L3)
                 cross-sectional area (L2)
                 dispersion coefficient (L2/T)
                 mean velocity (L/T)
                 external source or sinks (M/T)
Since M = VC, we can write
                    3M  a
                    3?
                                       3C .  - 3V
                                       It   C It
(Ax dx)
                                                             + s
II-l
                                         II-2a
                                     11

-------
                                Most Upstnom
                                    Point
                                                     R«och
                                                     Number
                             Computational
                             Eltmtnt Numbtr~
                       FIGURE II-2

STREAM  NETWORK OF COMPUTATIONAL ELEMENTS AND  REACHES
                             12

-------
where
          V  =  Av dx  =  Incremental volume (L3)
                 x
 If we assume that the flow in the stream is steady, i.e. 3Q/3t = 0, then
 the term 3V/3t = 0 and equation II-2a becomes
                    3M  _  .1 3C
                    3t  "  V3t
Combining equations II-l and II-2b and rearranging,
          3C  .     xL                   dc
          Jt  ~     A3x        Bx      dT   ?
          The terms on the right-hand side of the equation represent,
respectively, dispersion, advection, constituent changes, external sources/
                          j/%
sinks, and dilution.  The -rr term refers only to constituent changes such
                                                              3C
as growth and decay, and should not be confused with the term   , the local
concentration gradient.  The latter term includes the effect of constituent
changes as well as dispersion, advection, sources/sinks, and dilutions.

          .Under steady-state conditions, the local derivative becomes
equal to zero; in other words:
                                                                           II-4

Changes that occur to individual constituents or particles independent of
advection, dispersion and waste inputs are defined by the term:

                             =  individual constituents changes            II-5

These changes include the physical, chemical, and biological  reactions
and interactions that occur in the stream.  Examples of these changes are
reaeration, algal  respiration and photosynthesis, and col i form die-off.

-------
HYDRAULIC CHARACTERISTICS

          QUAL-II assumes that the stream hydraulic regime  is  steady-state;
i.e. 3Q/3t = 0, therefore, the hydro!ogic balance for a  computational
element can be written simply as (see Figure II-l):

                          •  (Qx)i                       •                 JI'6
where (Qxh is the sum of the external  inflows and/or withdrawal  to  that
element.

          Once equation II-6 has been solved for Q, the  other  hydraulic
characteristics of the stream segments can be determined by equations  of
the form:
          u  »  aQb                                                       II-7
          Ax -  Q/u                                                       I1-8
and
          d  »  aQ8                                                       I1-9
where a, b, a and 3 are constants, and d is the stream depth.  These
constants usually can be determined from stage-discharge rating curves.

          Alternatively, if the cross-sectional  properties  of  the stream
segment are available as a function of the depth d, u can be obtained  as
a function of discharge by the trial  and error solution  of  Mannings equation:
                    q  .  LMAxRx2/3se1/2                            n-io
where
          A   *  cross-sectional  area of the  channel  or  canal
                 in square feet,,
          R   *  mean effective hydraulic radius  (area divided by
                 wetted perimeter)  feet,
          n   *  Manning roughness  factor (usual  range 0.010  to 0.10)
          Se  s  slope of the energy grade line,  unit!ess,
          Q   »  discharge in cubic feet per  second.
 The  value for u  1s  then  determined  from equation II-8.

                                    14

-------
 LONGITUDINAL  DISPERSION

           Dispersion is basically a convective transport mechanism.  The
 term  "dispersion" is generally used for transport associated with spatially-
 averaged velocity variation, as opposed to "diffusion" which is reserved
 for transport that is associated primarily with time-averaged velocity
 fluctuations.

           Taylor (1954) was able to derive a predictive equation for the
 longitudinal  dispersion coefficient, DL, in long straight pipes, as

                    DL  =  10 r0 u*, ftVsec.                              11-11

where rQ is the pipe radius and u* is the average shear velocity defined as

                    u*  =  / TO/P, ft/sec.                                 11-12
where
           TO  s  boundary shear stress, lb/ft2, and
           p   =  mass fluid density, Ib-sec2/ff*
Some investigators have attempted to apply Taylor's expression to streamflow.
However, such applications can be highly approximate, because of the
difference between the geometry or velocity distributions in streamflow
and those  in  a pipe.

           Elder (1959) assumed that only the vertical velocity gradient
was important in streamflow and developed an expression analogous to
Taylor's expression but with a coefficient equal to 5.93:

                    DL  =  5.93 du*                                        11-13
where d is the mean depth in feet of the stream.

          Other investigators have derived similar expressions for DL and
found it to be extremely sensitive to lateral velocity orofiles.  Elder's

-------
expression, however, seems adequate in one-dimensional  situations where
the channel is not too wide.   For very wide channels,  Fisher  (1964)  has
shown that half-width rather than depth is  the  dominant scale and therefore
is important to the definition of the longitudinal  dispersion coefficient.
Equations 11-11 and 11-13 can be written in terms  of the Manning Equation
and other variables characteristic of stream channels.
                                                                              »

          As an example, for steady-state open-channel  flow:

                    u*  -  C /~R5"                                         n-14
where
          C   =  Chezy's coefficient
          R   •  the hydraulic radius
          Se  =  the slope of the energy grade line

Chezy's coefficient is given by:
                          Rl/6
                    C  *  ~-                                             11-15

where n is the Manning roughness  coefficient tabulated for different
types of channels in Table II-'l.

          Se, the slope of the energy gradient, is given by

                    S6  »  (	^TTT)2                                   "-16
                            1.486
where u is the mean velocity.  Substituting equations 11-14, 11-15 and
11-16 Into equation 11-13 and 'letting R'» d for a wide channel  yields
the expression
                    DL  -  22.6 n u d°-833                                 11-17
                                    15

-------
                              TABLE  II-1
              VALUES  OF  MANNING'S  "n" ROUGHNESS COEFFICIENT
                        After Henderson  (1966)
Artificial Channels                                           n

Glass, plastic, machined metal                              0.010
Dressed timber, joints flush                                0.011
Sawn timber, joints uneven                                  0.014
Cement plaster                                              0.011
Concrete, steel troweled                                    0.012
Concrete, timber forms, unfinished                          0.014
Untreated gunite                                         0.015-0.017
Brickwork or dressed masonry                                0.014
Rubble set in cement                                        0.017
Earth, smooth, no weeds                                     0.020
Earth, some stones, and weeds                               0.025

Natural River Channels                                        n

Clean and straight                                       0.025-0.030
Winding with pools and shoals                            0.033-0.040
Very weedy, winding and overgrown                        0.075-0.150
Clean straight alluvial channels                            0.031  d1/6
                                                 (d = D-75 size in ft.
                                                    = diameter that
                                                      75 percent of
                                                      particles are
                                                      smaller than

-------
where
          DL  =  longitudinal  dispersion  coefficient, ftVsec.
          n   »  Manning's roughness  coefficient
          u   =  mean velocity,  ft/sec.
          d   »  mean depth,  ft.
Typical values for dispersion  coefficients  are  given in Table  II-2.

                              TABLE  II-2
               TYPICAL VALUES  OF  DISPERSION COEFFICIENTS
                          After Gloyna  (1967)
System Classification
,  ftVsec.
Flumes and small  streams
Large rivers
Estuaries
                                                             3 x 10-2
                                                             3 x
                                                             6 x 103
                                    18

-------
           III.  CONSTITUENT REACTIONS AND INTERRELATIONSHIPS
GENERAL CONSIDERATIONS

          One of the most important considerations in determining the waste-
assimilative capacity of a stream is its ability to maintain an adequate
dissolved oxygen concentration.  Dissolved oxygen concentrations in streams
are controlled by atmospheric reaeration, photosynthesis, plant and animal
respiration, benthal demand, biochemical oxygen demand, nitrification,
salinity, and temperature, among other factors.

          The most accurate oxygen balance would consider all significant
factors.  The QUAL-II includes the major interactions of the nutrient
cycles, algae production, benthic oxygen demand, carbonaceous oxygen
uptake, atmospheric aeration and their effect on the behavior of dissolved
oxygen.  Figure III-l illustrates the conceptualization of these interactions,
It should be noted that the arrows on the figure indicate the direction of
normal system progression in a moderately polluted environment; the
directions may be reversed in some circumstances for some constituents.
For example, under conditions of oxygen supersaturation, which might occur
as a result of algal photosynthesis, oxygen might be driven from solution,
opposite to the indicated direction of the flow path.

          Coliforms and the arbitrary nonconservative constituent are modeled
as nonconservative decaying constituents, and do not interact with other
constituents.  The conservative constituents, of course, neither decay nor
interact in any way with other constituents.

          The mathematical relationships that describe the individual
reactions and interactions are presented in the following paragraphs.
                                     13

-------
       ATMOSPHERIC
         AERATION
                        CARBONACEOUS
                            BOD
       CHLOROPHYLL A
           ALGAE
        FIGURE III-l
MAJOR CONSTITUENT INTERACTIONS
              20

-------
Chlorophyll a (Phytoplanktonic Algae)

          Chlorophyll a_ is considered to be directly proportional to the
concentration of phytoplanktonic algal biomass.  For the purposes of this
model algal biomass is converted to chlorophyll a_ by the simple relationship:

                          Chi a_  =  a0 A                                   III-l
where
          Chi a_ - chlorophyll ^concentration
          A     s algal biomass concentration
          a     » a conversion factor
The differential equation that governs the growth and  production  of
algae (chlorophyll a) is formulated according  to the following  relationship:
where
          A  =  algal biomass concentration
          t  =  time
          u  *  the local specific growth rate of algae  as  defined
                below, which is temperature dependent
          p  a  the local respiration rate of algae, which  is
                temperature dependent
          a, «  the local settling rate for algae
          d  a  average depth
Now, the local specific growth rate of algae is known  to be coupled  to
availability of required nutrients and light.  The standard formulation
for the local specific growth rate takes the form:
                        N3                      K,  + L
          ••  -  ••     -   -•»   -    *     '

-------
where
          ym=.v = the maximum specific growth rate
           iMOA
          Kg   - the local concentration of nitrate nitrogen
          P    = the local concentration of orthophosphate
          L    * the local intensity of light
          X    * the light extinction coefficient (Ld = Le"Xd)
    KN» Kp» KL s empirical half-saturation constants (temperature dependent)

It should be noted that equation III-3 couples algal production to the
available nutrient supply, and thus algae and chlorophyll  a_ can be expected
to vary in time and space as nutrients are added.  If either nitrogen or
phosphorus or both are not simulated, it is assumed that they will not
limit the growth of algae.  It should also be noted that equation III-3
includes light intensity, as input to the model.   Finally, the growth and
respiration constants are temperature dependent and are formulated, along
with all other temperature dependent system variables, according to the
procedure explained in a later paragraph of this  section.

Nitrogen Cycle

          The nitrogen cycle in QUAL-II contains  three components as shown
in Figure III-l.  The differential equations governing transformation of
nitrogen from one form to another are given below.

Ammonia Nitrogen

                    dN,
                    3!1   »  o1 pA - B1 NT + a3/Ax                         III-4
where
          N-1  *  the concentration of ammonia nitrogen as nitrogen
          Si  =  rate constant for the biological oxidation of ammonia
                 nitrogen, temperature dependent
          a,  *  the fraction of respired algal biomass which is
           !     resolubilized as ammonia nitrogen by bacterial action

-------
           o"3  =  the benthos source rate for ammonia nitrogen
           AX  «  average cross-sectional area

 and other terms are as previously defined.

 Nitrite Nitrogen

                     dN2
                     TIT" "  —   B l  i»i  — Do i»o                                  * * *  J
                     Qu       I   I     fc  £
 where
           No  =  the concentration of nitrite nitrogen as nitrogen
           82  =  rate constant  for the oxidation of nitrite nitrogen,
                  temperature dependent

 and other terms are as previously defined.

 Nitrate Nitrogen


                     dN3                                                    III-6
                       -  *   6,  N,  - ou  uA                                  IU  6
                              £.   L.     \
           Note  the  coupling  that exists  between  the  conversion of nitrate
.and  the  production  of algae  to  close  the loop  indicated in  Figure III-l.

 Phosphorus Cycle

           The formulation  of the phosphorus  cycle  is less  complex than
 the  nitrogen cycle  because the  model  considers only  the interaction of
 phosphorus and  algae  plus  a  sink term.   Correspondingly, the differential
 equation  describing the  distribution  can be  written  as:
                              pA  - ctg vA  + a2/Ax                           III-7
                                     23

-------
where
          P   *  the concentration of orthophosphate as phosphorus
          02  =  the fraction of algal biomass that is phosphorus
          0^2  a  the benthos source rate for phosphorus
and all other terms are as previously defined.

Carbonaceous BOO

          The rate of change of carbonaceous BOD is formulated as a first
order reaction according to the formula:

                    &  •  - K, L - K3 L                                   III-8
where
          L   *  the concentration of carbonaceous BOD
          K-j  *  the rate of decay of carbonaceous BOD
                 (temperature'dependent)
          K3  s  the rate of loss of carbonaceous BOD due
                 to settling

          Note that while the change in BOD is expressed by equation III-8,
the oxygen demand exerted as a result of the change is only KiL.  The  BOD
which settles becomes a benthic oxygen demand.

Dissolved Oxygen

          The differential equation that describes the rate of change  of
oxygen in the model is written in the form:

$  3  K2«>* - 0) + (<*3U - a4P) A - Kj L  - K4/AX - a& ^ N, - ag 32 N2    III-9

where
          0   «  the concentration of dissolved oxygen
          0*  »  the saturation concentration of dissolved oxygen
                 at the local temperature and pressure

-------
          cu  s  the rate of oxygen production per unit of
                 algae (photosynthesis)
          a^  =  the rate of oxygen uptake per unit of algae respired
          etc  =  the rate of oxygen uptake per unit of ammonia oxidation
          etc  x  the rate of oxygen uptake per unit of nitrite
                 nitrogen oxidation
          l<2  a  the aeration rate in accordance with the Fickian
                 diffusion analogy
          K4  -  constant benthic uptake rate

          The saturation concentration of dissolved oxygen is computed
at standard pressure (29.92 in. of Hg) by the equation:

          0*  =  24.89 - 0.426 T + 0.00373 T2 - 0.0000133 T3               111-10
where
          T  =  temperature of water in °F.

          According to the American Public Health Association, Inc.  (1965),
0* can be corrected for a given barometric pressure other than standard
pressure by the equation:

                    °*  •  °*Kf-es                                     '»•"
where
          P   =  barometric pressure, in.  of Hg
           at
          e.  =  saturated water vapor pressure at the temperature
                 of the water surface, in. of Hg

and for elevation less than 3,000 feet by

                    °*  •  °*  202-                                       m-12

For water temperatures above 60°F, the American Public Health Association,
Inc.  (1965)  indicates that the solubility of oxygen in water decreases by
approximately 0.008 mg/1  per 100 mg/1  of chloride present.  QUAL-II  does
not correct 0* for either pressure or chlorides.

-------
          Numerous equations have been developed to  compute  reaeration
coefficients (<«) based on stream geometry and characteristics.   Those
which have been selected as options are discussed below.

Churchill^ Elrnore, and Buckingham (1962)

          This investigation was based on probably the most extensive
and accurate measurements of stream reaeration available and produced
the following expression for K^ at 20°C (68°F):
                    K220  -  5.026 u.d-.x 2.31                    111-13
where
          IT  =  average velocity in the stream, ft/sec.
          d  =  average depth of the stream, ft
             a  reaeration coefficient, I/day
O'Connor and Dobbins (19 S3)

          These investigators proposed equations based on the turbulent
characteristics of a stream as follows:
          For streams displaying low velocities and
          Isotropic conditions

                      20  ..  C°X'5
          For streams displaying high velocities and
          nonlsotropic conditions
                      20  .            o                                   IH.15
                                    25

-------
 where
          S   a  slope of the streambed
          d   =  mean stream depth, ft.
          if   a  mean velocity, ft/ day
              *  reaeration coefficient, I/day
and where Dm is the molecular diffusion coefficient (ftVday) which can
be computed by
                    Dm  =  1.91 x 103 (1.037)1"-20                          ni-16

Isotropic conditions are satisfied when Chezy's coefficient is greater
than 17, and nonisotropic for values less than 17.   0' Conner and Dobbins
(1958) have shown that equation 111-14 is generally applicable for most
cases, and is the equation used in the program for this option.

Owens, Edwards, and Gibbs (1964)

          For streams with a velocity variation range  from 0.1 to 5.0
ft/sec, and depths from 0.4 to 11.0 ft:

                    K*°  *  9.4 u°'67/ d1'85 x 2.31                       111-17
where
          U   *  mean velocity, ft/sec.
          d   »  mean depth, ft.
              *  re aeration coefficient, I/ day
Thaakston and Krenkel (196S)

          This Investigation included several rivers in the Tennessee
Valley Authority system and resulted in the following equation for 1C,
at 20°C:
                         *  10.8 (1  + F°'5) . J   x 2.31                      111-18
                                    27

-------
 where  F is  the Froude number which can be computed  by

                    F  =  -Hi-                                            Hi-19
                          /?"?
 and  u* is the shear vel ocity,' ft/sec. , which  can  be computed by

                    u*  *  STsTg  »  .SJLjfiL                             in-20
                               e       1.49 d1*167
 where
          d   =  mean depth, ft.
          g   =  acceleration of gravity, ft/sec2
          S   =  slope of the energy gradient
          —  a  mean velocity (ft/sec)
          n   s  Manning's coefficient

 Langbien and Dwnm (1967)  •

                    K^0  =  3.3 u/d1'33 x 2.31                             IH-21
where
          TT   *   mean  velocity,  ft/sec.
          d   =   mean  depth, ft.
              *   reaeration coefficient,  I/day
Taivoglou and Wallace (1972)

          This approach  postulates that the reaeration coefficient for
a reach is proportional  to  the  change in elevation of the water surface
in the reach and inversely  proportional to the flow time through the reach.

                    4°   -  K 0
where
          K   =  constant of proportionality, ft"1
          Ah  =  change  in  water surface elevation in reach, ft.
          t   a  flow time  within reach, hours

-------
Assuming uniform flow,
                     Ah  =  Se Ax                                          II1-2.
where
          Se  =  slope of the energy gradient, ft/ft
          Ax  »  reach length, ft.
The time of passage through a reach is:

                     tf  =  ~                                             111-24
                            u
where
          u"  =  mean velocity in reach, ft/sec.

Thus, equation II1-22 can be rewritten as

                     K?,0  =  3600 K Se IT                                   111-25

where the constant 3600 converts velocity to units of ft/hr.

          The energy gradient may be input directly as noted in the User's
Manual.  If it is not specified, Se is estimated from the Manning equation:

                              H2 n2
                    e   -     u  n                                         111-26
                     6     (1.49)2 d4/3
where
          d  »  mean depth, ft.
          n  •  Manning's coefficient

          The constant K should be treated as a variable and determined
empirically.  A value of 0.0524—English units—for K was derived from
data collection in five rivers in the Southeastern United States.
                                     29

-------
Col 1 forms

          The differential equation that describes the die-off of col i forms
in the stream is:
where
          E   =  the concentration of col i forms
          Kg  =  coliform die-off rate

Arbitrary Nonconservative Constituent

          The differential equation that describes the decay of the
arbitrary nonconservative constituent is:
                     dR  .   i/  p
                     it  "  ~K6 R
where
          R   =  the concentration of the nonconservative constituent
          Kfi  =  decay rate for the constituent
SUMMARY OF MATHEMATICAL RELATIONSHIPS

          Table III-1 summarizes the complete set of equations solved by
QUAL-II with the exception of the temperature relationships.  The equations
that describe the temperature routing as well as the associated relationships
for all the heat budget terms are described in the next chapter.  The
equations presented in Table III-l include the effects of dispersion,
advection, constituent reactions and interactions, and a source term.
Section V of this documentation describes how QUAL-II is structured to
solve these equations.
                                     30

-------
                                 SUMMARY OF DIFFERENTIAL EQUATIONS TO BE SOLVED BY QUAL-II
                                                     (except temperature)
                                                    £)     3(Avuc)
u>
i,uii3ci vai i vc mineral \t/
Algae (A)
Ammonia nitrogen (N,)
Nitrite nitrogen (N2)
Nitrate nitrogen (N,)
Dissolved Orthophosphate (P)
Biochemical oxygen demand (L)
Dissolved oxygen ()
Coliform (F)
at
3A
at
3N
at
3N
at" *
3P .
at
ot
M ,
at
3F .
at
3R .
Ax3x AxSx Axdx
a(AxD, §J) 3(A uA) S. a
LA . 4- ,.,. 4- / 1 1 - n _ , , M A
A a* A aw i /iv in • P • J «
AX3X AX3X AxdX
DN
3(AvDi aT1) S(A uN ) SN
X L oX **A j./ A DMi\
Ax3x " Ax3x * Aydx * lot»pA ' BiNi 4 Ax'
3Ni
Ax3x AX3X ' Axdx f (CiN. CaN,)
3N> s
Ax3x Ax3x f Axdx f ^0* » a>p '
3(A D. |J) 3(AuP) Sp a,
X L dX 1- «.f!,. + fn In n\& -L ^}
A3x A 3x * A,dx u*lp U)A A*
X A A *
*(A.D, 1^-) 3(AvuL) -.
+ - (K + K )L
a(AxoL |f) a(Axu*) s^
3(A D. ^) 3(A uF) SF
A L UA A -IT . -- . K F
Aw3x A.3x A dx s
X A A
a(AvDi |r-) 3(A uR) »B
X L dX * « '* i/ o
                                                                                       (a,p - a,,P)A - K,L - ^ - a^.N, - a.U.Nj
                                         at
AX3X

-------
REACTION RATES AND PHYSICAL CONSTANTS

          The chemical and biological reactions that are simulated by
QUAL-II are represented by a complex set of equations that contain many
system parameters:  some are constants, some are spatially variable, and
some are temperature dependent.   Table II1-2 lists these system parameters
and gives the usual range of values, units, types of variation, and
reliability of the range for each parameter.  Kramer (1970) and Chen and
Orlob (1972) give detailed discussions of the basic sources of data, ranges
and reliabilities of each of these parameters.  Final selection of the
values for many of these system parameters should be made during model
calibration and verification.
TEMPERATURE DEPENDENCE

          All rate constants and other factors (except the saturation
concentration of oxygen) that are known to be temperature dependent are
formulated according to the relationship:
                    XT  =  X2.0  9-                                       111-28
where
          XT   =  the value of the variable at the local temperature, T(°C)
          X20  =  the value of the variable at 20°C
          9    *  an empirical constant for each temperature dependent
                  system variable
               =  1.0159 for K2
               a  1.047 for all others
                                     32

-------
                                   TABLE II1-2
                          INPUT PARAMETERS FOR  QUAL-II
run ir
•
i
i
i
•
i
i
MX

1
'
1
!
'
1








FAKAMKTKH
HANK
IH JUAL
ALPHA0
ALPHA1
ALPHA2
ALPHA3
ALPHA4
ALPHAS
ALPHA6
GR0HAX
RESPRT
CKNH3
CKN02
ALGSET
SPH0S
SNH3
CK1
CX2
CK3
CX4
CKS
CK6
CRN
CKP
CXi.
IHtSMliriUI
Ratio of chlorophyll a.
to alnae blomass ~
Fraction of alnae
biomass which Is N
Fraction of alqae
biomass which is P
0, production per unit
of algae growth
02 uptake per unit of
algae respired
(la uptake per unit of
NH] oxidation
Oz uptake per unit of
NOj oxidation
Maximum specific growth
rate of algae
Algae respiration rate
Rate constant for biological
oxidation of NH,-^02
Rate constant for bloloqical
oxidation of NOj-flO,
Local settling rate for
algae
Benthos source rate for
phosphorus
Benthos source rate for NH
Carbonaceous BOO decay rate
Reaeratlon rate
Carbonaceous BOO sink rate
Benthos source rate for BOO
Collform die-off rate
Arbitrary nonconservatlve
decay rate
Nitrogen half-saturation
constant for alqae growth
Phosphorus half-saturation
constant for algae growth
Lijht half-saturation
win:;
U9 Chi -A
«H» A
mo*
mg A
moP
mg A
mn 0
mo, A
mgO
mq A
mo 0
iglT
mo 0
mg~¥
1
3Sy
1
day
1
dly
ft
day
day-ft
TO N
day- ft
1
1
Bay
1
o"«y-ft
diy
1
3a7
I1
i
Langleys
HAHC.K Of'
VAIMK:;
50-100
0.08-0.09
0.012-0.015
1.4-1.8
1.6-2.3
3.0-4.0
1.0-1.14
1.0-3.0
O.OS-O.S
0.1-0.5
0.5-2.0
0.5-6.0
*
*
0.1-2.0
0.0-100
-0.36-0.36
*
0.5-4.0
*
0.2-0.4
0.03-0.05
.03
VAIUAULK
or HKACU
Yes
No
No
No
No
No
No
No
No
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yts
Yes
Yes
Yes
No
No
No
TKUPKKATIJHK
UKPKHUKttr
No
No
No
No
No
No
No
Yes
Yes
Yes
Yes
No
No
No
Yes
Yts
No
NO
Yes
Yes
No
No
No
HKLlAeltm
Fair
Good
Good
Good
Fair
Good
Good
Good
Fair
Fair
Fair
Fair
Poor
Poor
Poor
Good
Poor
Poor
Fair
*
Fair to Good
Fair to Good
•lood
                cor. s t ant for alia* growth
. gn i y
                                           33

-------
             IV.  FUNCTIONAL REPRESENTATION OF TEMPERATURE
THE BASIC TEMPERATURE EQUATION

          The basic mass transport equation for QUAL-II was given in
Section II as (see equation II-3):

                                   0 C)
          "at       AX 3x        AX Sx

In temperature modeling, C is taken as the concentration of heat (HL"3)
which can be equated to temperature through the relationship:

                    C  =  p c (T - T0)   '                                  IV-2
where
          p   =  the density of water (M L~3)
          c   =  the heat capacity of water (HM-"1 D'1)
          T   =  the water temperature
          T0  =  an arbitrary base temperature
          D   =  degrees

The parameters p and c can be considered constant for practical purposes.
                                jp
Also, internal heat generation, ^ , which results from viscous dissipation
of energy and boundary friction, is generally so small as to be negligible.
Thus setting ^ = 0 in equation IV-1 and substituting equation IV-2 for C
gives us (after some simplification):

          3T  ,  3(AxOl f >   3(Ax 5 T)    T  ,
          3t       Ax 3x        Ax 3x     pc V

          The source term s/V, which has units of HL"3T,   accounts for all
heat transferred across the system boundaries, i.e. heat transferred  across
the air-water interface and heat conducted across mud-water  interface.
                                      34

-------
Heat transfer across the mud-water interface  is generally  insignificant;
hence, s/V takes on the identify of the net rate of heat input, per unit
volume of stream, through the air-water interface.

          It is most convenient to represent  the interfacial heat transfer
rate as a flux Hfj having units of (HL'^T "^).  For a stream element of
length dx and mean surface width W, fyj is related to s/V as fo'llows.

          The total rate of heat input across the air-water interface is
HN dx W.  This heat is distributed uniformly  throughout the underlying
volume of A  dx, where Ax is the mean cross-sectional area of the element,
           «
thus the rate of heat gain per unit volume of water, s/V,  is computed as:
                                HN (Wdx)      HN
                •L  s    5    -  _£!	  -  Jl                             TV_A
                V     Ax dx      Ax dx        d                              1V  *

where d  =  AX/W is the hydraulic depth of the stream.  Substituting
equation IV-4 into equation IV-3 gives the generalized form of the
temperature equation as:
                              OT*         ••
                       *) i A Oi  ™L^i   /) (A  ij T 1   H
                1>t  =    AX 3x       AX 3x    + pcd"
DEFINITION OF HN

          Heat is transferred across the air-water interface of a surface
water body by three difference processes:  radiation exchange, evaporation,
and conduction.  The individual heat terms associated with these processes
are shown in Figure IV-1 and are defined in Table IV-1 along with the
typical ranges of their magnitudes in northern latitudes.

          The expression that results from the summation of these various
energy fluxes Is:
                                     35

-------
Hs      Ha      Hb
                t       5
t      "i
                                      AIR-WATER
                                      'INTERFACE
Hsn     Han
                 FIGURE IV-1

      HEAT TRANSFER TERMS ASSOCIATED WITH
           INTERFACIAL HEAT TRANSFER
                       36

-------
                              TABLE IV-1
                   DEFINITION OF HEAT TRANSFER TERMS
                        ILLUSTRATED IN  FIGURE 1
              Heat Term                    Units         Magnitude
                                                      (BTU ft'2 day'1)
H.   -  total incoming solar or           m -2T-1
 s      short-wave radiation              ML  T

                                            -2  1
Hsr  =  re^ected short-wave radiation    HL  T            40-200


Ha   =  total incoming atmospheric        m -2T-1
 a      radiation                         ML  '

                                            -2 -1
Ha».  "  reflected atmospheric radiation   HL  T            70-120
 ar


H,    »  back radiation from the water     HL'^T"1        2400-3600



He   *  heat loss by evaporation          HL'V1         150-3000


H,   s  heat loss by conduction to        M, -2T-1         -«n  .   ,,.nn
 C      atmosphere                        ML  '           "J^U  W  4UU
                                     37

-------
                    HN  =  Hsn + Han '                        IV
where
          HN   =  net energy flux passing the air-water interface,
                  Btu/ft2-day
          Hsn  =  net short-wave solar radiation flux  passing
                  through the interface after losses due to
                  absorption and scattering in the atmosphere
                  and by reflection at the interface,  Btu/ft2-day
          H    =  net long-wave atmospheric radiation  flux passing
                  through the interface after reflection, Btu/ft2-day
          Hjj   =  outgoing long-wave back radiation flux, Btu/ft2-day
          HC   =  convective energy flux passing back  and forth
                  between the interface and the atmosphere, Btu/ft2-day
          HQ   =  energy loss by evaporation, Btu/ft2-day

These mechanisms by which heat is exchanged between the water surface and
the atmosphere are fairly well understood and are adequately documented in
the literature by Edinger and Geyer (1965).  The functional representation
of these terms has been defined by Water Resources Engineers, Inc. (1967).
The formulations reported here were extracted from that more detailed work
by Frank D. Masch and Associates and the Texas Water Development Board (1971)
NET SHORT-WAVE SOLAR RADIATION

          The net incoming solar radiation is short-wave radiation which
passes directly from the sun to the earth's surface.   Its magnitude depends
on:  the altitude of the sun, which varies daily as well as seasonally for
a fixed location on the earth; the dampening effect of scattering and
absorption in the atmosphere due to cloud cover; and the reflection from
the water surface.

          The net amount of solar radiation which reaches the surface of
the earth may be represented functionally on an hourly basis as:
                                     38

-------
                                                                           IV-7
                           (1) (11) (111)      (Tv)
where
          H    s  net short-wave solar radiation flux, Btu/ft2-hour
          H    »  amount of radiation flux reaching  the earth's
                 .atmosphere, Btu/ft2-hour
                  atmospheric transmission term
                  Albedo or reflection coefficient
                  cloudiness as a fraction of sky covered
          It is appropriate for purposes of the discussion here to identify
and treat separately the four components in equation IV-7 as (i)  extra-
terrestrial solar radiation, (ii) radiation scattering and absorption,
(iii) reflectivity, and (iv) cloudiness.

Extraterrestrial Radiation

          The short-wave solar radiation flux that strikes the earth's
outer atmosphere over a given period of time is given by Water Resources
Engineers, Inc. (1967) as:
                 u
          Ho  a  ;r 

              *  r-cos T&Tcos 5 Cs1n ^ •sin (TZ^)]} r
where
          Hc-  3  solar constant = 438.0 Btu/ft2-hour
           5C
          r    »  normalized radius of the earth's orbit
              »  latitude of the site, degrees
          6    =  declination of the sun, degrees
        tjj.t   a  hour angles corresponding to the beginning and  end,
                  respectively, of any time interval  between sunrise
                  and sunset
          F    ai correction factor for diurnal  exposure to
                  radiation flux.
                                    39

-------
          Several parameters in equation IV-8 requiring further definition

are described by Water Resources Engineers,  Inc.  (1967).


Relative Earth-Sun Distance


                    r  =  1.0 + 0.17 cos [Ijjg. (186-Dy)]                    IV-9


where Dy is the number of the day of the year (beginning January 1).


Declination



                    6  =  Ttr"77 cos [    (173-Dy):i                       IV-10


Bon? Angles
and
                    tb  -  STb - Ats + ET - 12
                    t.  =  STa - At. + ET - 12                             IV-12
                     C       S     5
where STjj, STe are the standard times at the beginning and end of the

time interval selected.
          ET   »  an expression for time from a solar ephemeris
                  which represents the difference in hours between
                  "true solar time" and that computed on the basis
                  of a year average.  It is given for each day of
                  the year, Dy, by
                  ET  =  0.000121 - 0.12319 sin    - (Dy-1) - 0.0714]


                      -  0.16549 sin [    (Dy-1) + 0.3088]                 IV-13
          Ats  -  difference between standard and local civil time
                  in hours as determined from
                  Ats

-------
where
          e    s  -1 for west longitude
          e    =  +1 for east longitude
          l-sm  =  longitude of standard meridian, degrees
          Mm  =  longitude of local  meridian, degrees

Diurnal Exposure

          T  =  1 when STr < STb or STe <; STS                              IV-15

          T  =  0 when STS < STb or STe < STr                              IV-16

where STr and STs are the standard times of sunrise and sunset, respectively,
as determined from:

          STr  =  12 - ^ arc cos [tan (j|jj) tan 5] + Ats                  IV-17
and
          STS  =  24 - STr + 2Ats                                          IV-18

Radiation Scattering and Absorption

          The atmospheric transmission term, a^, is given by Water Resources
Engineers, Inc. (1967) as:

                    a   *  a" + Q.5 (1 - a' - d)                           IV ,g
                     t     1 -0.5 Rs(l - a1 + dj
in which a" is the mean atmospheric transmission coefficient after
scattering and absorption given by:

          a"  =  exp {- [0.465 + 0.0408 PWCJ

                 [0.179 + 0.421 exp (-0.721 9am}] 9an)>                     IV-20

where 6am is the optical air mass given by the expression:

-------
          e    =            exp (-Z/2532)
           am     sin a + 0.15 (±|2SL + 3.885}'1'253
in which
          Z  =  elevation of the site in feet
          a  =  sun's altitude in radians given by

                    a  =  arc sin [sin     sin 5 + cos
                          cos 6 cos   ]                                    IV-22
in which t is the hour angle, described by an equation similar to
equations IV-11 and IV-12.

          Pwc in equation IV-20 is the mean daily precipi table water content
in the atmosphere, given by the expression

                    Pwc  =  0.00614 exp (0.0489Td)                         IV-23

where T
-------
Cloudiness

          The dampening effect on the solar radiation flux is given by
Water Resources Engineers, Inc. (1967) as

                    Cs  =  1.0 - 0.65 c£                                   IV-26

where CL is the decimal fraction of the sky covered.  Water Resources
Engineers, Inc. (1967) reports that equation IV-26 gives satisfactory
results except for heavy overcast conditions, i.e. when C|_ approaches 1.0.

Reflectivity

          The reflection coefficient, RSt can be approximately computed
as a function of the solar altitude, a, by Anderson's (1954) empirical
formula:
                    Rs  *  AaB                                             IV-27

where a is in degrees, and A and B are functions of cloudiness, C[_.  Values
for A and B given by Anderson (1954) are shown in Table IV-2.

                              TABLE IV-2
               EMPIRICAL COEFFICIENTS FOR DETERMINING Rs
                         After Anderson (1954)
Cloudiness
0
Clear
0.1 - 0.5
Scattered
0.6 - 0.9
Broken
1.0
Overcast
Coefficients    ABABABAB
               1.18   -0.77   2.20   -0.97   0.95   -0.75   0.35   -0.45

-------
LONG-WAVE ATMOSPHERIC RADIATION

          The long-wave radiation emitted by the atmosphere varies directly
with the moisture content of the atmosphere.  Although it is primarily
dependent on air temperature arid humidity, it can also be affected by
ozone, carbon dioxide, and possibly other materials in the atmosphere.
Anderson (1954) indicated that the amount *of atmospheric radiation is also
significantly affected by cloud height.   The amount of long-wave atmospheric
radiation that is reflected is approximately a constant fraction of the
incoming radiation.   Anderson (1954) found this fraction to be approximately
0.03.

          The net atmospheric radiation  flux can be expressed as:

          Han  =  [2.89 x TO'6] a (Ta +  460)6 (1.0 + 0.17C^) (1 - RJ      IV-28
where
          Han  =  net -T°n9-wave atmospheric radiation flux, Btu/ft2/hour
          a    =  Stefan-Bo!tzman constant, 1.73 x 10~9 Btu/ft2/hour/
                   "Rankine4
          T.   =  air temperature at a level 6 feet above the water
                  surface, °F
          RL   s  reflectivity of the water surface for atmospheric
                  radiation =0.03
WATER SURFACE BACK RADIATION

          The third source of radiation transfer through the air-water
interface is long-wave back radiation from the water surface, H^, which
represents a loss of heat from the water.  It can be seen from Table IV-1
that back radiation accounts for a substantial portion of the heat loss
from a body of water.  This loss is expressed by the Stefan-Boltzman
Fourth Power Radiation Law for a blackbody as:

-------
                    Hb  =  0.97 a (Ts + 460)4                              IV-29
where
          Hjj  =  water surface back radiation flux, Btu/ft2/hour
          Ts  »  water surface temperature, °F

          Equation IV-29 can be linearized over a given temperature range
as:
                     Hb  =  a2 + 02 Ts                                     IV-30
where
          a2* ^2  =  constants defined over the range

In the steady-state temperature solution, this linearized version of the
back radiation equation is used to allow the temperature dependent terms
to be separated out of the equation.  Sets of cu, $? are specified for 21
5°F temperature intervals between 35°F and 135°F.  For dynamic simulations
the heat flux term calculations are based on the temperature at the
beginning of the time step.
EVAPORATION

          A water body also loses heat to the atmosphere by evaporation.
Each pound of water that leaves as water vapor carries its latent heat
of vaporization (approximately 1050 BTU at 60°F) plus its sensible heat.
Therefore, evaporation also represents a significant loss of heat.

          This heat loss can be expressed as:
                     He  =  Y HLE + Hy                                     IV-31
where
          Y   s  specific weight of the water being evaporated, lb/ft3
          HL  a  latent heat of vaporization, Btu/lb, given by
          HL  =  108* - 0.5 Ts

-------
          E   =  evaporation rate, ft/hour
          Hv  =  sensible heat loss Btu/ft2/hour
The evaporation rate, E, is most often expressed as
                     E  =  (a + bW) (es - ea)
where
and
where
                                                                 IV-32
          a,b
          W
        constants
        wind speed, in mph, measured 6 feet above the
        water surface
        saturation vapor pressure of the air, in. of Hg,
        at the temperature of the water surface, as given by
        0.1001 exp (0.03 Ts) - 0.0837
                  water vapor pressure, in. of Hg, at a height of
                  6 feet above the water surface, given as
                  e   - 0.000367 Pa (Ta - Twb)
                                                                           IV-33
ewb

ewb
Pa
Twb
\..«     1571   /

saturation vapor pressure, in. of Hg, at the
wet bulb temperature from the expression
0.1001 exp (0.03 Twb) - 0.0837
local barometric pressure, in. of Hg
wet bulb temperature, °F
                                                                           IV-34
                                                                           IV-35
The literature contains a wide range of values for the evaporation constants
a and b.  Roesner (1969) reports that a good average value of a would be
6.8 x 10~4 ft/hour-in. of Hg, while b would best be represented by 2.7 x
10"4 ft/hour-in. of Hg.-mph.

          To linearize the variation of evaporation rate with surface
water temperature Ts, equation IV-34 is approximated over 5°F intervals as:
                                                                           IV-36

-------
Sets of 0|t 8-j are specified for 21 5°F intervals between 35°F and 135°F.
The linearized evaporation expression is used in the steady-state
temperature solution.

          The sensible evaporative heat loss can be expressed simply as:

                     Hy  =  c y E (Ts - T0)                                IY-37
where
          c   -  heat capacity of water = 1 Btu/lb/°F
          T   =  reference temperature, °F
Sensible heat loss is very small compared to the other heat loss components
in the energy budget and thus is not included in the QUAL-II temperature
computation.
CONDUCTION

          Heat that is transferred between the water and the atmosphere
due to a temperature difference between the two phases is normally called
conduction.  Using the fact that transfer by conduction is a function of
the same variables as evaporation, it is possible to arrive at a propor-
tionality between heat conduction and heat loss by evaporation.  This
proportionality, known as Bowen's ratio, is expressed as:
                                         -l 202                       IV'38
                                       So
where Cg is a coefficient * 0.01.
          By using Bowen's ratio, the rate of heat loss to the atmosphere
by heat conduction, HC> can be defined as:
                                            Pa
                Hc  =  Y HL (a + bW) (0.01 gg^) {Ts - Tft)                IY-39

For practical purposes, the ratio (P./29.92) can be taken as unity.
                                    o.

-------
                    V.  COMPUTATIONAL REPRESENTATION
PROTOTYPE REPRESENTATION

          To expand upon the basic conceptual  representation presented in
Section II, QUAL-II permits any branching, one-dimensional  stream system
to be simulated.  The first step involved in approximating  the prototype
is to subdivide the stream system into reaches, which are stretches of
stream that have uniform hydraulic characteristics.   Each reach is then
divided into computational elements of equal length  so that all computational
elements in all reaches are the same length.  Thus,  all reaches must consist
of an integer number of computational  elements.

          In total, there are seven different types  of computational
elements; these are:
          1.  Headwater element
          2.  Standard element
          3.  Element just upstream from a junction
          4.  Junction element
          5.  Last element in system
          6.  Input element
          7.  Withdrawal element
Headwater elements begin every tributary as well as  the main river system,
and as such, they must always be the first element in a reach.  A standard
element is one that does not qualify as one of the remaining six element types.
Since incremental inflow is permitted in all element types, the only input
permitted in a standard element is incremental inflow.  A type 3 element is
used to designate an element on the mainstern-that is just upstream from a
junction element (type 4) which is an element that has a simulated tributary
entering it.  Element type 5 identifies the last computational element in
                                    48

-------
the river system; there should be only one element type 5.  Element types
6 and 7 represent elements which have inputs (waste loads and unsimulated
tributaries) and water withdrawals, respectively.

          River reaches, which are aggregates of computational elements,
are the basis of most data input.  Hydraulic data, reaction rate
coefficients, initial conditions, and incremental runoff data are constant
for all computational elements within a reach.
MODEL LIMITATIONS

          QUAL-II has been developed to be a relatively general program;
however, certain dimensional limitations have been imposed upon it during
program development.  These limitations are as follows:
          Reaches:  a maximum of 75
          Computational elements:  no more than 20 per reach
                                   or 500 in total
          Headwater elements:  a maximum of 15
          Junction elements:  a maximum of 15
          Input and withdrawal elements:  a maximum of 90 in total

          QUAL-II can be used to simulate any combination of the following
parameters or groups of parameters:
          1.  Conservative minerals (up to three at a time)
          2.  Temperature
          3.  BOD
          4.  Chlorophyll a_
          5.  Dissolved orthophosphate as phosphorus
          6.  Ammonia, nitrite and nitrate as nitrogen
          7.  Dissolved oxygen
          8.  Coliforms
          9.  An arbitrary nonconser/ative constituent

-------
All parameters can be simulated under either steady-state or dynamic
conditions.  If either phosphorus or the nitrogen cycle are not being
simulated, the model presumes they will  not limit algal growth.
NUMERIC SOLUTION TECHNIQUE

          At each time step and for each constituent, equation II-3 can
be written I times, once for each of the I computational  elements in the
network.  Since it is not possible to obtain analytical  solutions to
these equations under most prototype situations, a finite difference
method is used, more specifically, the classical implicit backward
difference method (see Smith, 1966).

          The general basis of a finite difference scheme is to find the
value of a variable (e.g., constituent concentration) as  a function of
space at a time step n+1 when its spatial  distribution at the n*-n time
step is known.   Time step zero corresponds to the initial condition.
Backward difference or implicit schemes are characterized by the fact
that all spatial derivatives (3/3x) are approximated in difference form
at time step n+1.

Formulation^ of the Finite Difference Scheme

          The finite difference scheme is  formulated by considering the
constituent concentration, C, at four points in the mnemonic scheme as
shown in Figure V-l.

          Three points are required at time n+1 to approximate the
spatial derivatives.  The temporal derivative is approximated at
distance step i.
                                    50

-------
M\JH ivu i i \i_/^i*i %; 	 vi o i i \u/-im
element i + l
element
i
           o
           i
N
                                          t  -
                                              At
          FIGURE V-l

CLASSICAL IMPLICIT NODAL SCHEME
                 51

-------
          Equation II-3 can be written in finite difference form in
two steps.  First, the advection and diffusion terms are differentiated
once with respect to x giving:
          3C,        l    , -    L    M   (A 50, -(AuC),.,-
                  dC.   s.
where
          vi  '  Ai
Secondly, expressing the spatial derivative of the diffusion terms in
finite difference and thence the time derivative of C in finite difference,
there results:

                                                    -n+1
V
              At         \          M. Axi
                        f..  rn
                        / Ql ci
    n+1   n    ,-n+l
                       l
In equation V-2, the term dC/dt is expressed as:
where
          r-  =  rate constant
          p.  =  internal constituent sources and sinks (e.g. nutrient
                 loss from algal growth, benthos sources, etc.)
                                     52

-------
              HP
Note that the ^-r for every constituent modeled by QUAL-II can be expressed
in this form (see Table III-l and equation IV-5).
          If equation V-2 is rearranged in terms of the coefficients of
Ci-l' Ci+1> and Ci-l' we obtain the
a, eft + b, Cf
                  + e
                                        •  Z
                                                                 V-3
where
                                        q,  T  At n
b,  *  1.0 + [(ADL), +
                                                   +Qj     - r.  At
zi   s  C1
                   n   Si
                          i
                                  At
The values of a-, b^, c^, and I* are all known at time n, while  the  C^
terms are the unknowns at time step n+1.
                                                                     n+1
          In the case of a junction element with a tributary  upstream
element, the basic equation becomes:
where
          k  rn+1  + r
          b1  C1    + c.
                                           rn+1  =  7
                                         j Cj    -  Z1
                                       At
                                                                 V-4
          j    =  the element upstream of junction element i
          C1^   s  concentration of constituent in element j at  time  n+1
                                    53

-------
          It can be seen that the dj term is analogous to the a-j term.
Both terms account for mass inputs from upstream due to dispersion and
advection.
                                         3C,
          Under steady-state conditions, g~- = 0 in equation V-l .   Working
through the finite difference approximations and rearranging terms as
before, the steady-state version of equation V-3 is derived:
                                                                           v c
                                                                           V-5
where
a.
"1
ci
zi
i 1-1 11
(ADt ) • i Q • T
r L 1-1 , l-l -I
"L y.^x. V •*
p(ADL). j (ADL)i_1 ^ Q
(ADL)1
- 5l+p
i
          Note that equation V-5 is the same as equation V-3, with the
following changes:
          ° At equals 1.0
          ° the constant 1.0 in b-j = 0.0
          « the initial concentration c" in Z^ » 0.0

Method of Solution
          Equations V-3 and V-5 each represent a set of simultaneous
linear equations whose solution provides the values of c"   for all i's.
Expressed in matrix form this set of equations appears as:
                                     54

-------
bl cl
a2 b2 c2
a3 b3 C3
a. b1 GI

...
al bl



X



-n+1
Cl
rn+l
C2
cn+l
rn+l
ci
• '
cn+l
rn+l
CI



=



zi
h
h
z<
*
zi-i
z.
                                                                            V-6
The  left  matrix  is  a  tri-diagonal  matrix.   An efficient method that readily
lends  itself to  a  computer solution  of such a set of equations is as follows:
1)  Divide through the first equation in V-6 by b] to obtain:

                    cn+1 + w  c""1
                    L]   + w1 L2

          WT   »  c-t/b-, and GT = 2
                                                                            V-7
where
2)  Combine  the expression  for  bj  (see  V-3)  and the second equation in
    V-6 to eliminate 33  and the result  is:
                     n+l
where
                 b2 ' a2 Wl
                               -n-H
                              and
                                                                            V-8
                                             - a^
                                         b-2-a2
                                     55

-------
3)  Combine equation V-8 and the  third equation in  V-6 to eliminate
    aj and the result is:

                   Cij*1 + W3 dj+1  *  G3                                 v-9
where                „                   7    ,  r
                     c3                  Z, - a-  6-
          Wo  s  r - r-rr  and  G*  -   ^ — -±-,1
           3     b  - a  W         3     b  - a  W
4)  Proceed through the equations, eliminating a^  and storing the values
    of W.j and G^ given by:
                               ci
                    Wi  =  bi " ai Wi-r 1  " 2, 3, .  .  .  ,1               V-10
and
                    Gi  =  F1	a1 I/"1* 1  = 2, 3, ...  ,1               V-ll
                     1     Di ' ai wi-l

5)  The last equation is solved for Cj    by

                                                                         V-12
6)  Solve for c   , c2» •  • •  » c    by back substitution.
                             81 - W. C^], 1-1-1, 1-2, ...  ,1         V-13
Boundary Conditions

Upstream

          In most situations  of interest,  transport  is  unidirectional
in nature, i.e., there is no  significant transport upstream.  Therefore,
the concentration at some point just upstream from the  upper end of the
stream reach of interest can  be used as the  boundary condition.  Hence,
Z-j in equation V-3 is taken as:
                                   56

-------
zl  •  cl" + T   * Pi
                     l

where c"   is the boundary condition (headwater concentration).

Downstream

          For the boundary condition at the downstream end of the system
it is possible to assume a fictitious boundary condition at a point only
slightly downstream from the lower end of the reach of interest.  This
is possible because the magnitudes of D^ and u in virtually all situations
of interest are such that the downstream boundary condition has very little
effect on the water upstream.  Then, one can let
                          n+l     rn+l                                    v_1
                                  CI                                      v  l
where Cj+j is the concentration just downstream from the end of the system.
                                    57

-------
                          LIST OF REFERENCES

American Public Health Association,  Inc., Standard Methods for the
          Examination of Water and Wastewater. American Public Health
          Association, 1965.

Anderson, E.R., Energy Budget Studies  in Water Loss  Investigations-
          Lake Hefner Studies, Technical Report,  U.S. Geological
          Survey Prof. Paper 269, 1954.

Chen, C.W. and G.T.  Orlob, Fi nal  Report, Eco 1 ogic Simulation of Aquatic
          Environments. Water Resources Engineers, Inc., prepared for
          the Office of Water Resources Research, U.S.  Department of the
          Interior,  October 1972.

Churchill, M.A., H.L. Elmore and  R.A.  Buckingham, "The  Prediction of
          Stream Reaeration Rates,"  Jour. Sanitary Eng. Div., ASCE,
          v. 7, 1962.

Duke, James H.  Jr.,  Provision of  a Steady-State Version of the Stream
          Model. QUAL, Water Resources Engineers, Inc., prepared for
          the Environmental Protection Agency, November 1973.

Eckenfelder, W.W. and D.J. O'Conner, Biological Waste Treatment, Pergamon
          Press, 1961.

Edinger, J.E. and J.C. Geyer, Heat Exchange in the Environment, Johns
          Hopkins Univ., 1965.

Elder, J.W., "The Dispersion of a Marked Fluid in Turbulent  Shear Flow,"
          Jour. Fluid Mech., v. 5, 1959.

Fisher, H.B., Diacusaian to "Time of Travel of Soluble  Contaminants  in
          Streams,"  fey T,J, Buchanan,  Proc. Sanitary Eng.  Divv, ASCE,
          y. 6, 1964.

                                    58

-------
 Frank D. Masch and Associates and the Texas Water Development Board,
          Simulation of Water Quality in Streams and Canals,  Theory and
          Description of the QUAL-I Mathematical Modeling System,  Report 128,
          the Texas Water Development Board, May 1971.

 Gloyna, E.F., Prediction of Oxygen Depletion and Recent Developments  in
          Stream Model Analyses, Stream Analysis and Thermal  Pollution,
          v. 2, prepared for Poland Proj. 26, World Health Organization,
          Univ. Texas, Austin, 1967.

 Henderson, P.M., Open Channel Flow, Macmillan Co., 1966.

 Johnson, A.E. and J.H. Duke, Jr., Incorporation of the  Tsivoglou K2 Equation
          into QUAL-II, DOSAG3 and the Receiving Water  Module of the  Storm
          Water Management Model, Water Resources Engineers,  Inc.,
          prepared for the Environmental Protection Agency, November  1973.

 Kramer, R.H., A Search of the Literature for Data Pertaining to
          Bioenergetics and Population Dynamics of Freshwater Fishes,
          Desert Biome Aquatic Program, Utah State University, August 1970.

 Langbien, W.B. and W.H. Durum, The Aeration Capacity of Streams, U.S. Geol.
          Survey Circ. 542, 1967.

O'Conner, D.J., An Analysis of the Dissolved Oxygen Variation in a Flowing
          Stream. Conf. Advances in Biological Waste Treatment, Univ.
          Texas, Austin, 1966.

O'Conner, D.J. and W.E. Dobbins,"Mechanism of Reaeration  in Natural
          Streams," Trans.  ASCE, v. 123, 1958.

Owens, M. R.W. Edwards and J.W.  Gibfas, "Some Reaeration Studies in Streams,"
          Internat. Jour.  Air and Water Pollution, v.  3,  1964.
                                   59

-------
Ralston, R. and H.S. Wilf, Mathematical  Methods  of Digital  Computers,  v.  1,
          John Wiley and Sons, Inc.,  1960.

Rawson, Jack, Reconnaissance of the Chemical  Quality  of Surface Waters
          of the San Antonio River Basin,  Texas, Texas  Water  Development
          Board Report 93, 1969.

	, Reconnaissance of the Oxygen Balance and the Variation of
          Selected Nutrients in the San  Antonio  River During  Low  Flow,
          U.S. Geol. Survey open-file report, 1970.

Roesner, L.A., Temperature Modeling in Streams,  Lecture notes, water
          quality workshop, T.V.A., 1969.

Roesner, L.A., J.R. Monser and O.E. Evenson,  Computer Program Documentation
          for the Stream Quality Model QUAL-II,  An Intermediate Technical
          Report, submitted to the Environmental Protection Agency,
          Washington, D.C., Contract No. 68-01-0742,  Iowa and Cedar
          River Basins Model Project.

Smith, J.D., Solutions to Partial Differential Equations, Macmillan  Co.,  1966.

Stone, H.L. and P.O.T. Brian, "Numerical Solution of Convective  Transport
          Problems," Jour. Am. Inst.  Chem. Eng., v. 9, no. 5, 1963.

Streeter, H.W. and E.B. Phelps, A Study of the Pollution and  Natural
          Purification of the Ohio River, U.S. Public Health  Service
          Bull. 146 (reprinted 1958), 1925.

Taylor, G.I., "The Dispersion of Matter in Turbulent Flow Through a  Pipe,"
          Proc. Royal Soc. London, 234A, 1954.
                                   60

-------
Texas Water Development Board, Simulation of Water Quality in Streams
          and Canals, Program Documentation and User's Manual, September 1970.

Thackston, E.L. and P.A. Krenkel, Longitudinal  Mixing and Reaeration  in
          Natural Streams. Technical  Report 7,  Sanitary and Water Resources
          Engineering, Vanderbilt Univ., 1966.

Thomas, H.A. Jr., Pollution Load Capacity of Streams, Water and Sewage
          Works, 1948.

Tsivoglou, E.G. and J.R. Wallace, Characterization of Stream Reaeration
          Capacity, Prepared for the Environmental Protection Agency,
          Office of Research and Monitoring, Washington, D.C., 1972.

Tsivoglou, E.G. and L.A. Neal, "Tracer Measurement of Reaeration:  III.
          Predicting the Reaeration Capacity of Inland Streams,"
          Jour. WPCF, v. 48, no. 12, December 1976.

Water Resources Engineers, Inc., Prediction of Thermal Energy Distribution
          1n Streams and Reservoirs, Prepared for the California Dept.
          of Fish and Game, 1967.

Water Resources Engineers, Inc., Technical Proposal, Upper Missisippi
          River Basin Model Project, submitted  to Environmental Protection
          Agency, May 1972.

Water Resources Engineers, Inc.  Progress Report on Contract No. 68-01-0713,
          Upper Mississippi River Basin Model Project, Sponsored by the
          Environmental  Protection Agency, submitted to Environmental
          Protection Agency, September 21, 1972.

Wunderlich, W.O.,  The Fully-Mixed Stream Temperature Regime,  ASCE
          Specialty Conf., Utah  State Univ., Logan,  Utah, 1969.
                                    51

-------
                   VI.  COMPUTER PROGRAM DESCRIPTION
MODEL STRUCTURE AND SUBROUTINES

          QUAL-II is structured as one main program,  QUAL2,  supported
by 23 different subroutines.   Figure VI-1  graphically illustrates  the
functional relationships between the main  program and its  subroutines.
The original version of QUAL, as programmed by William A.  White, was
structured to permit the addition of parameters easily through  addition
of subroutines.  This basic concept, which proved to  be an extremely
valuable one, was maintained in the extension of the  original version
to QUAL-II.  Thus, if it becomes desirable at some later time to add
new parameters or modify existing parameter relationships, the  changes
can be made with a minimum of model restructuring.

          This section describes the main  program QUAL2, and its 23
subroutines.  Each program description contains:  (1) a brief written
description of what the program does, including mathematical  relationships;
(2) a program flow chart; and (3) a program listing.   Section  VII  contains
definitions of all program variables in COMMON storage.
MAIN PROGRAM QUAL2

          QUAL2 is the main program of QUAL-II; it calls most of the
subroutines, computes some miscellaneous constants, sets up the initial
conditions, performs the convergence checks when a steady-state problem
is being solved, and controls the printing of the output reports.  The
only subroutines not called by the main program are HEATEX, HEATER, and
CHANL, which are called by Subroutines TEMPS, TEMPSS, and HYDRAU,
respectively.
                                   52

-------
PROGRAM RETURN FOR FLOW AUGMENTATION OPTION |
^
ro r > c o
PROGRAM RETURN FOR DYNAMIC SOLUTION OR ITERATIVE STEADY STATE SOLUTION
r>



1 t
2 t
3 t
4 t
5
6 .
7 *
8 t
9
10 o
11
12 t
13
14 t
— L^1
15
16 I>
17
13 .s.
19
20 t
— u-
21 t
22 J
23 t
24 ^
25 t
26
27 ,.
28 ^
29 t

INOATA

HYDRAU

TRIMAT

CONSVT

— i— £> CHANL

^

TEMPS/TEMPSS
—t- — > HEATEX/HEATER
^

BOOS


ALGAES


P04S


NH3S


N02S


N03S


REAERC

DOS


COLIS


RADIOS


WRPT2

FLOAUG

WRPT3

N
ps
K
N
PS
r^
p^
PV
PK
1 *

program 2
,^^^^ ,,ps.
titment A ^ * el

S
0
V
M
A
T

9 rag ram
emenf 3
/ ^
callinq sgqmnce 	 s called by ^/
in element A ~— " element A
         FIGURE VI-1
GENERAL STRUCTURE OF QUAL-II

-------
          After QUAL2 calls INDATA, which reads in the input data, and
computes some miscellaneous constants, it sets up the initial conditions
for each computational element.  Initial  conditions for each reach are
read in and used to define the initial conditions for all  computational
elements within a reach.  QUAL2 then calls the subroutines necessary to
simulate the water quality parameters specified on the title cards.

          The input Title Data Cards (see User's Manual) prescribe which
water quality parameters QUAL-II will simulate.  Whenever a Title Data
Card indicates a parameter  is to be simulated, the program assigns a
positive integer to an internal variable  (MODOPT) that indicates which
model options are to be used.   The correspondence between internal model
options and parameters is as follows.
          Model Option             Parameter(s) to be Simulated
           MODOPT (1)              Conservative Constituents
           MODOPT (2)              Temperature
           MODOPT (3)              Biochemical Oxygen Demand
           MODOPT (4)              Chlorophyll £
           MODOPT (5)              Dissolved Orthophosphate as P
           MODOPT (6)              Ammonia, Nitrite and Nitrate (as N)
           MODOPT (7)              Dissolved Oxygen
           MODOPT (8)              Coliforms
Any combination of the above options will work.  However, it should be
noted that if chlorophyll a_ is to be simulated when either phosphorus
or the nitrogen cycle or both are not to  be simulated, the program
assumes they will not limit algae growth.

          When temperature is to be simulated under steady-state conditions,
QUAL2 uses an iterative numerical scheme  to converge on a solution.  The
procedure is as follows:
                                    64

-------
          1.  Using the known values of temperature in each
              element (initial conditions or values from previous
              iteration step 2), select the linear constants for
              the appropriate 5°F temperature range to be substituted
              into equations IV-30 and IV-36, then compute the heat
              flux terms.
          2.  Compute a new steady-state temperature in each element.
          3.  For each element, check whether the newly computed
              temperatures:  1) lie in the same 5°F linear range
              as the old temperatures which were used to compute
              the heat flux terms, and 2) lie between 35°F and 135°F.
          4.  If the above conditions are satisfied in all elements,
              the problem is considered solved.  If one or more
              elements have not converged, repeat steps 1, 2, and 3
              using the newly calculated temperatures to compute
              the heat flux terms.  If convergence is not achieved
              after 10 iterations, terminate execution of the program.

          When chlorophyll a. is to be simulated under steady-state
conditions, QUAL2 uses an iterative numerical scheme to converge on a
solution.  Basically the procedure works as follows:
          1.  Calculate an algae growth rate based on the
              initial  conditions for the first iteration.
          2.  Compute the resulting phosphorus and nitrate
              concentrations.
          3.  Recompute the growth rate based on the newly
              computed phosphorus and nitrate levels.
          4.  Compare the previous and newly computed growth rates.
                                   ot

-------
          5.  If all growth rates have not changed by at least
              0.05 per day, the problem is considered solved.   If
              the growth rate change in any one computational
              element exceeds 0.05 per day, steps 2 through 5  are
              repeated.
Upon completion of the stream quality computations, QUAL2 selectively
reports the results and execution is terminated.

          The flow chart for QUAL2 is illustrated in Figure VI-2 and
is followed by the program listing.  All program variables contained
in COMMON are described in Section VII.
                                   66

-------
                             UHTM.IZS
                              TITUS
                               CHJL.
                               tXMTA
                              EiTMUW
                              ttQUlHB
                              C5MTWTS
MCOUM tfTUM K* HOt
   JUSWtMTJQH
                             SCT IIKTWI.
                             coNornon
                             CMXHYBMU
                             ttt± TXDMT
                                 me m
                                  NIMU
                                                            rax
                                                  OTMMIC sauna* OR
                                                  SOLUTION
                            «un saicrtD
                           qiMUTT MJWWTOS
                               V

FIGURE VI-2.   FLOW  CHART  FOR MAIN  PROGRAM  QUAL2
                                 67

-------
        STEADY-STATE SOLUTION
            REQUESTED
FIGURE  VI-2 (Continued).   FLOW  CHART FOR  MAIN PROGRAM QUAL2
                           53

-------
                                            CALL NH3S
                                           CALL SOVMAT
                                            CALL N02S
                                           CALL SOVMAT
                                            CALL N03S
                                           CALL SOVMAT
                                          CALL REAERC
                                           CALL DOS
                                          CALL SOVMAT
           STEADY-STATE SOLlfflON
               REQUESTED
FIGURE  VI-2 (Continued).   FLOW CHART  FOR  MAIN  PROGRAM QUAL2
                                   5S

-------
                                                             IS
                                                         TIME 
-------
                          IS
                     WOOPT(3) > 0
                            NO
                                        YES
          CALL HRPTZ(BOO)
                         IS
                     HOOOPT(6) > 0
                            NO
                                        YES
        CALL URPT2(C(H3)
        CAR HRPT2(CH02
        CALL HRPT2(CN03)
                          IS
                     MOOOPT(5) > 0
                                        YES
         CALL WRPT2(PHOS)
                         IS
                     WOOPT(4) > 0
                            NO
YES
         CAU URPT2(ALGAE)
                          IS
                     MOOOPT(8) > 0
                            MO
                                        YES
        CALL WRPT2(OXi)
                         IS
                     WDOPT(l) > 0
YES
CALL
CAU
CALL
URPT2
WRPT2
HRPT2
CONS
CONS
CONS
1,1
1,2
1.3
)

)
FIGURE VI-2  (Continued).   FLOW  CHART  FOR  MAIN PROGRAM QUAL2
                                      71

-------
                          own
                        Hwrosnrmcsis-
                       nsnwnat KATIOS
FIGURE VI-2 (Continued).   FLOW CHART FOR MAIN  PROGRAM QUAL2
                                72

-------
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
19.
19.
20.
21.
22.
23.
24.
25.
26.
27.
23.
29.
30.
31.
32.
33.
34.
35.
35.
37.
38.
39.
40.
41.
42.
43.
44.
45.
46.
47.
48.
49.
50.
51.
52.
53.
54.
55.
56.
57.
5 A
39 .
59.
60.
6 t
' 4 •
62.
&•>
° J .
64.
65.
66.
67.
68.
69.
70.
^ t
' " «
72.
C
C
c
c
c
c
c
c
c
c
c
c
c
c
c
c
c
c
















c
c











c.
c.



c.
c:


c


c
c
c *
c *
c.
c




PROGRAM QUAL-2

QUAL-2 IS A SET Of INTERRELATED STREAM
QUALITY ROUTING MODELS. IT HAS THE
CAPABILITY TO ROUTE TEMP. , SOD/DO,
NITROGEN SERIES, PHOSPHATE, ALAGE,
COLIFORMS, RADIO. NUCLIDE, AND
UP TO THREE CONSERVATIVE MINERALS
THROUGH A FULLY-MIXED STREAM SYSTEM.
THESE PARAMETERS CAN BE ROUTED ON AN
INDIVIDUAL BASIS OR SIMULTANEOUSLY IN
SUCH A COMBINATION AS THE USER MAY
DESIRE. QUAL-1 ALSO HAS THE CAPABILITY
TO COMPUTE THE FLOW AUGMENTATION REQEO.
TO MEET PRESELECTED MINIMUM DO LEVELS.
HYDRAULICS ARE CONSIDERED STEADY-STATE.


COMMON TITLE(20,20),RCHID(75,5),RMTHOR(75),RMTEOR(75),NHtfMAR(15),
TARGOO(75),IAUGOR(75,6),NCELRH(75),IFLAG(75,20),
ICLORD(75,20),CO£FQV(75),EXPOQV(75),COEFQH(75),EXPOQH(75),
CMANN(75),CKU75),CK3(75),K20PT(75),CK2(75),COEQK2(75),
EXPQK2(75),TINIT(75),OOINIT(75),BOINIT(75),COINIT(75,3),
QI(75),Tl(75),OO.I(75),aODI(75),CO.NSK75,3),JUNCID(15,5),
J«NC(15,3),HWrRIO(15,5),Hi»FLOWC15),HwrEMP(15),H«00(l5),
HWBOD(15),HWCONS(15,3),MASTIO(90,5),TRFACT(90),WSFLOW(90),
WSTEMP(90),*SDO(90),WSBOD(90),KSCONS(90,.n,QATOT(15),
AC500),B(500),C(500),D(15),S(500),Z(500),N(500),G(500),
FLOW(500),DEPTH(500),YEL(500),DTO.VCL(500),K2(500).K1(500),
HSNET(500),OL(500),VHW(15),D£PHW(15),DLHtt(15),T(500),
D0( 500), 800(500), CONS (500, 3 ),PTI.M£,TPRINT,DELX,
NHWTRS,NR£ACH,NWASTE,NJUNC,D£LT,01LT,02LT,DTOOX2,DT20DX,
LAT,LSM,LLM,£L£V,DAT,A£,BE,DAYOFY,DRYaLB,M£TBLB,D£MPT,
ATMPR,UI°ND, CLOUD, SONET, NI,NJ,TRLCD,TOFDAY, NT, NC, TIME, NCS


COMMON/MOOIF/ CX4(75) ,CK5 (75) ,CKNH3(75) ,CKN02(75) ,CKN03(75) ,
CKN,CKP,CXL,ALPHAO(75),ALPHA1,ALPHA2,ALPHA3,ALPHA4,
ALPHAS, ALPHA6,GROMAX,RESPRT,ALGS£T(75),SPHOS(75),
5NH3(75),KNH3(500),KN02(500),RESPRR(500),COLI(500),
ALGAE(500),PHOS(500),CNH3(500),CN02(500},CN03(500),
COLIR(75),ALGI(75),PHOSI(75),CNH3I(75),CN02I(75),
CN03I(75),COLIIT(75),ALGIT(75),PHOSIT(75),CNH3IT(7S),
CN02IT(75),CN03IT(75),MSCOLI(90),WSALG(90),WSPHOS(90), .
MSNH3(90),MSN02(90),WSN03(90),HWCOLI(1S),HMALG(1S),
HNPHOSUS),HWNH3(15),HWN02(15),HrtN03(15),GROWTH(500),
NOOOPT(10),IRCHNO(750},EXCOEF(75)


COMMOM/SSTATE/ X(500),ISS
COMMON/SSTEMP/JT(500),SOLRC}i(75),CLDRCH(75}/PATRCH(75),TOBRCH(75},
*TMBRCH(75) ,MINRCH(75)


COMMON/RADION/ CK6 (75) , RADNIK75) ,RADNI (75) , H^RAON (15) , WSRAONOO) ,
* RADIO(SOO)

COMNON/OUTPUT/IRPT1
COMMON/AUG/IAUGIT

COMMON/METER/; METRIC, METOUT
+ + t + + tt +
> *«**<«* COMMENTED OUT PER TOM 3ARNWCLL


DIMENSION TJK500)
DIMENSION TITL19(l3),nTL20(15)
REAL Kl.<2,LAr,LLM,LjM,JUNCID
DATA TIT- 49 /*H ALS,AHAS G(^HaC^T,4HH PA.4HTES ,4HIN

-------
73.
74.
75.
76.
77.
78.
79.
80.
81.
82.
83.
84.
85.
86.
87.
88.
89.
90.
91.
92.
93.
94.
95.
96.
97.
98.
99.
100.
101.
102.
103.
104.
105.
106.
107.
108.
109.
110.
111.
U2.
113.
114.
115.
116.
117.
118.
119.
1 5f>
i«U.
121
** 4 .
122.
123.
124.
125.
126.
127.
128.
129.
130.
131.
i "it
*•>« .
133.
U4.
135.
136.
137.
139.
139.
140.



C
C
C
C





C
C
C
C
C
C
c.
C
c
c
c
c
c
*P,4HER D,4,iA* A,4HRE ,4H ,4H
DATA IITL20 /4H PHO,
*T,4HI(XN ,4HRATI.,4HOS A,4HR£ ,4H




00 10 J«6,20
IsJ-5
TITL£(19,J)sTIIL19(I)
TITLEC20,J)aTITL20U)
10 CONTINUE













,4H ,4H ,4H ,4H /
4HTOS*,4HNTHE,4HSIS-,4HRESP,4HIRA
,4H ,4H ,4H ,4H /


STEP 1-0
INITIALIZE CERTAIN PARAMETERS






STEP 2-0
READ IN TITLES

STEP 3-0
READ IN ALL DATA REQUIRED FOR OP
OF THE MODELS.

STEP 4-0
IF THE CORRECT NO. OF DATA CARDS
DOT BEEN READ IN, THE PROGRAM MI
TERMINATE.

CALL. INDATACILIST,IRPI1,IAUGOP,TMAX,NCELL5)
C
C
c.














C:
C
C
c

c

c
c
c
c
c
c

c.
•










DELXsDELX*5280.0
If (ISS) 901,901,900
900 DILI = 1.0/24.0
02LT *: 1.0
CELT *•- 3600.0
IF CPTIME.LE.O.) PIIXEaTMAX
GO TO 902
901 DILI »; DELT/24.0.
D2LT*DELT
OELTaOELT*3600.0
TMAX»TMAX-O.Ol
902 CONTINUE
DTODX2*OELT/CDELX*DELX)
DT200X«2.0»OEL1/DELX






CKL3CKL*60.




* + t + t + t FEB> 1980 REVISIONS NO.

IFC»OOOPT(2).GT.O.O.AHO,ISS.LE.O)

IF (ISS.LE.O) GO TO 11.0
FUNCT=0.0
IF (SONET. LT.l.OE-4) GO. TO 51
NOLH»14
OLH'FIiOAT(NDtiH)
SOAVE=50NET/OLH
00 50 M>1,NOLH
FM*M
STEP 5-0
ESTABLISH REQUIRED CONSTANTS.
















STEP 6-0
SET INITIAL CONDITIONS.


CONVERSION OF CXL TO LANGLEYS/HR

CONVERSION TO 8TU/SQ .FT./HR
THE FOLLOWING. COMPUTES THE
AVERAGE LIGHT INTENSITY FOR
STEADY-STATE. COMPUTATION
3

CXL»CXL»3.685









74

-------
141.
142.
143.
144.
145.
146.
147.
i A Q
i^o .
149.
150.
151.
152.
151
* * j •
154.
155.
156.
157.
158.
159.
160.
Ibl.
162.
163.
164.
165.
166.
167.
168.
169.
170.
171.
172.
173.
174,
175.
176.
177.
178.
179.
180.
181.
182.
183.
184.
185.
186.
187.
188.
189.
190.
191.
192.
193.
194.
195.
196.
197.
198.
199.
200.
201.
202.
203.
204.
205.
206.
207.
208.
209.
210.






C



C





C
C
C
C















TOTsSa»V£*U.O-CDSC6.28*FM/DLH)>
50 FUNCTsFUNCT+(IOT/(CXL»TOT))
51 CONTINUE
FUNCT»FUNCT/24.
SONNENsCKL*FUNCI/ C 1 . -FUNCT}
110 CONTINUE

lAUGIIsO
998 CALL HYDRAU
CALL IRIMAT

00 915 I=1,NREACH
NCELR*NCELRH(I)
00 915 Jsl.NCELR
IOR=ICLORD(I,J)
T(IOR>=TINIT(I)
* * + FOLLOWING STATEMENT DELETED TO
PER LETTER OF 23 SEPT 1980.
















AVOID DOUBLE CONVERSIONS

IF(METRIC.GT.O)TUOR)»l.8*TUOR)+32.0
t * t
DO(IOR}=DOINII(I}
aOD(XOR)*8QINIT(I)
CONS(IOR,l)3caiNIT(I,n
COI»SCIOR,2}sCOINIT(l,2)
CONS(IOR,3)sCDINIT(l,3)
ALGAE(IOR)sALGIT(I}
PHOS(IOR)3PHOSIT(I)
CJJH3(IOR)=CNH3IT(I)
CN02(IQR)=CN02ITCI)
CN03(IOR)*CN03ITU)
COLI(IOR)=COLIIT(I)
RADlOdOR)sRAONIT(I)
IF(NOOOPT(4).EQ.O) GO TO 915
TC*0.556*(T(IOR)-63.0)
EXPTsEXP(-EXCOEF(I)*OEPTH(IOR))
















TLOGsALOG((CKu+SONNEN)/(CKL+SONNEjJ*EXPT))
GRO»iIH{IOR)sGROMAX*TLOG/(EXCOEFCI)»D£PTHUOR»






C
C
C
C
C
C
C
C
C
C
C
C
C
C




C
C
C
^
u
C
V
(*
w
GROWTH CIOR)=GROWTHCIOR)*1.047**TC
915 CONTINUE
DO 922 NWS=i,NWAST£
EFL83D*1.0«TRFACT(NMS)
»iSBOD(NWS}>EFLaOO*WSaOD(NWS)
922 CONTINUE














NITERaO
ITEKsO
999 TIMESTIME+D2LT
TPRIMTaTPRlNTr02LT














STEP 7-0
BEGIN COMPUTATIONS AND OPERATE U
STEADY-STATE CONDITIONS ARE REAC
XHICH IS THE TIME (TMAX) REQUIRE
MATER PARTICLE AT THE UPPERMOST
IN THE SYSTEM TO REACH THE END: 0
THE SYSTEM.

STEP 7-1
CALL SUBROUTINES TO PERFORM HYOR
BALANCE ON SYSTEM AND ESTABLISH
COEFFICIENT MATRIX.






STEP 7-2
ROUTE SELECTED QUALITY PARAMETER

MODOPTd) CONSERVATIVE
MDDOPTC2) TEMPERATURE
MODOPTU) BOD
75

-------
        C                                       HODOPTC4)   CHLOROPHYLL A
212.    C                                       HODOPK5)   PHOSPHOROUS
213.    C                                       MODOPTC6)   NH3,N02,N03
214.    C                                       MODOPTC7)   OXYGEN
215.    C                                       MODOPTC8)   COLIFORMS
216.    C                                       MODOPK9)   NON-CONSERVATIVE
217.    C
213.          IF (MODOPT(l).SQ.O) CO TO 702
219.      701 NT«3
220.          00 777 NC=1,NCS
221.          CALL CONSVT
222.          CALL SOYMAT
223.          NTsNm
224.          00 808 Isl.NCELLS
225.          CONS(I,NC)»Z(I)
226.      808 CONTINUE
227.      777 CONTINUE
228.    C
229.      702 If (MOBOPT(2).EQ.O) CO TO 703
230.          NT»6
231.          IF CISS.GT.O.) GO TO 7702
232.          CALL TEMPS
233.          CALL SOVMAT
234.          00 800 I=1,NCELLS
235.          TU)sZ(I)
236.      800 CONTINUE
2J7.          GO TO 703
238.    C
239.     7702 IF (NITER.GT.O) GO TO 703
240.     7703 00 7706 1 = 1, NC&.LLS
241.          TJl(I)= 9
279.          CALL P04S
280.          CALL SOYMAT
                                           75

-------
281.          DO 80S lal.NCELLS
282.          PH05U) « Z(I)
293.      aos CONTINUE:
284.    C
285.      706 IP (MO£OPT(6).CQ.O) GO TO 707
286.          NT a 10
287.          CALL NH3S
288.          CALL SOVMAT
289.          00 306 I«1,NCELLS
290.          CNH3CI) s Z(I)
291.      806 CONTINUE
292.          NT * 11
293.          CALL N02S
294.          CALL SOVMAT
295.          00 816 I=1,NCELLS
296.          CN02U) * Z(I)
297.      816 CONTINUE
298.          NT « 12
299.          CALL N03S
300.          CALL SOVMAT
301.          DO 826 Ial,NCELLS
302.          CN03U) > 2(1}
303.      826 CONTINUE
304.    C
305.      707 IF (MODOPT(7).EQ.O) GO TO 708
306.          NT = 13
307.          CALL REAERC
308.          CALL DOS
309.          CALL SOVMAT
310.          DO 803 Isl.NCELLS
311.          DO(I)=Zm
312.      303 CONTINUE
313.      708 IF (MOSOPT(8).EQ.O) GO TO 799
314.          NT » 14
315.          CALL COLIS
316.          CALL SOVMAT
317.          DO 807 I=1,NC£LLS
318.          COLIC I) * 2(1)
319.      307 CONTINUE
320.      799 CONTINUE
321.          IF(MOOOPT(9).£Q.O) GO TO 7999
322.          NT=15
323.          CALL RADIOS
324.          CALL SOVMAT
325.          DO 809 Isl.NCELLS
326.          RADIO(I)=Z(l)
327.      809 CONTINUE
328.     7999 CONTINUE
329.          IF (TPRINT.LT.PTIME) Sa'TO 997
330.          TPRINT'0.0
331.      997 CONTINUE
332.    C
333.    C                                       STEP 7-3
334.    C                                       IF STEADY-STATE CONDITION HAS NO
335.    C                                       REACHED, CONTINUE ROUTING.
336.    C
337.          IF(ISS) 9996,9996,9990
338.     9990 IF (MO£OPT(4)) 1001,1001,9992
339.     9992 HUM a 0
340.          HER > ITER t 1
341.          WRITE (NJ,7779) ITER
342.     7779 FORMAT (12H ITERATION  ,15)
343.          DO 9994 JJsl,NREACH
344.          NCELRsNCELRH(JJ)
345.          00 9994 KK*1,NCELR
3*6.          I = ICLO*OUJ,XK)
              TC»fl.S56*(T(I)-68.0)
              £XP7*£X?OEXCOEF(JJ)*OEPTH(I))
                                          77

-------
 351.           XGRO»sXGROW*1.047*«TC.
 352.           TT  a  DELX/(V£LCI>*86400.)
 353.           TGROW 3  XGROU
 354.           IF  (MODOPT(S).EQ.O)  GO  TO  9820
 355.           DGOP  * -1.0/(ALPHA2*ALGAE(I)*TT)
 356.           XA  a  OGDP
 357.           XB  a  GROWTH(I) + (CKP+PHO.S(I) )*DGDP-XGROH
 358.           XC  a  GROrtTH(I)«{CKP+PHCXSU))-XGROW*PHOS(I)
 359.           ROOT  * 5QRT(X8*XB-4.0*XA*XC-)
 360.           OPHOSa-0.5*X8/XA  * 0.5*ROOT/ABS(XA)
 361.           PHOS(I)  a PHOSUJ+OPHOS
 362.           IF  (PHOS(I).LI.O.O)  PHOS(I) = 0.0
 363.           TGROH =  XGROW*PHOSU)/(CKP+PHOSU) )
 364.     9820  IF  (MODOPT(6).EO.O)  GO  TO  9840
 365.           OGON  a -1.0/CALPHA1«ALGAE(I)*TT)
 366.           XA  a  OGON
 367.           XB  a  GROHTHCI)-KCKN+CN0.3U) )'DCDN-XGROH
 368.           XC  a  GROWTH(I)*(CXN*C!l0.3m)-XCROW*CN03
 370.           DCM03a-0.5«X8/XA  + 0.5*ROOT/AflS(XA)
 371.           CN03(I)  a CN03CI] +  OCN03
 J72.           IF  (CN03U).LI.O.O)  CN03CI) * 0.0
 373.           TGROrf a  TGRO«i*CN03(I)/CCKN+CN03U) )
 374.     9840  CONTINUE
 375.           OG  a  TGROW - GROMTH(I)
 376.           IF  (ASS(OG).LT.0.05)  GO. TO 8994
 377.           NUM a HUM + 1
 378.     8994  GROtaTH(I) a GROWTHQ) + 0.7*OG
 379.     9994  CONTINUE
 380.           WRITE (NJ,7780) NUM
 381.     7780  FORMAT (30H GROWTH RATE NON CONVERGENT IN.I4.9H  ELEMENTS)
 382.           IF  (NUM) 1001,1001,9996
 383.     9996  IF  (TIME.LT.TMAX) GO  TO. 999
 384.     1001  CONTINUE
 385.           IF(ISS.LE.O.OR.IRRTl.LE.O)  GO TO 9998
 386.           IF  (MOOOPTUn 1011,1011,1002
 387.     1002  NTa6
 388.           CALL  MRPT2CT)
 389.     1011  CONTINUE
 390.           IF  (MOOOPTO)) 1021,1021,1012
 391.     1012  NT313
 392.           CALL  URPT2CDO)
 393.     1021  CONTINUE
 394.           IF  (MODOPTC3)} 1031,^031,1022
 395.     1022  MT=7
 396.           CALL  WRPT2CBOD)
 397.     1031  CONTINUE
 398.           IF  (MQJ70PTC6)) 1041,1041,1032
 399.     1032  NT310
 400.           CALL  NRPT2CCNH3)
 401.           HT»11
 402.           CALL  WRPT2 (CN02)
 403.           NTS12
 404.           CALL  HRPT2 CCN03)
 405.     1041  CONTINUE
 406.           IF  (MODOPTC5)) 1051,1051,1042
 407.     1042  NT«9
408.          CALL  MRPT2 (PHOS)
409.     1051  CONTINUE
 410.           IF  (MODQPTC4)) 1061,1061,1052
 411.     1052  NTa8
 412.          CALL  HRPT2 (ALGAE)
 413.     1061 CONTINUE
 414.           IF  CM000PTC8)) 1071,1071,1062
 415.     1062 MTS14
 416.          CALL «RPT2 (COLD
 417.     1071 CONTINUE
 418.          IF (HOOOPT(l)) 1081,1081,1072
 419.     1072 NTs3
420.          00 1075 NC=1,NCS
                                            78

-------
 421.          CALL NRPT2  (CONSU.HC))
 422.      1075 NT-NItl
 423.      1081 CONTINUE
 424.          IF  (MODOPTC9))  1091,1091,1092
 425.      1082 NT=15
 426.          CALL MRPT2  (RADIO)
 427.      1091 CONTINUE
 428.          If  (MOOOPTC4KEQ.O) GO TO 9965
 429.    C
 430.          MT=19
 431.          1F(IRPT1.EQ.1)CALL HRPT2 (GROWTH)
 432.    C
 433.          XTEMP s ALPHA3/ALPHA4
 434.          00  9960 Ial,NCELLS
 435.          Z(I) * XTEMP'GROWTHUJ/RESPRRU)
 436.      9960 CONTINUE
 437.          NT  a 20
 438.          IFURPT1.EQ.1KALL WRPT2U)
 439.      9965 CONTINUE
440.     9998 CONTINUE
441.    C
442.    C                                       STEP 8-0
443.    C
444.    C                                       IF FLOW AUGMENTATION IS DESIRED,
445.    C                                       HOW MUCH IS REQUIRED, AUGMENT TH
446.    C                                       NECESSARY HEADWATER FLOWS AND ST
447.    C                                       ROUTING AGAIN AT TIME a ZERO.
448.    C
449.          IF  (IAUGOP.EQ.O) GO TO 9999
450.    C
451.    C + + +t + + -». FEB« 1980 REVISIONS NO. 5
452.          lAUGlTal
453.    C*t+*+*t
454.    C
455.          CALL FLOAUG
456.          If  (TIME.EQ.0.0) GO TO 998
457.     9999 CONTINUE
458.          CALL WRPT3
459.          STOP
460.          END
                                          73

-------
SUBROUTINE ALGAES*

          Subroutine ALGAES completes the setup of the equations necessary
to calculate algal biomass concentrations in each computational element.
Specifically, the subroutine completes the definition of the diagonal
term of the coefficient matrix and defines the vector of known terms on
the right hand side of the equations.  In addition, solar radiation is
read at three hour intervals if a dynamic simulation is being performed.

          The additions to the diagonal term represent the individual
constituent changes caused by constituent reactions and interactions,
and mass changes caused by stream withdrawals.  The resulting diagonal
term for each type of computation element is:
            TYPE                      DIAGONAL TERM
     All except type 7           b^  »  Xj - (uj - p - o^
     7. 'Withdrawal              b1  =  x1 - (Uf - p - Oj./DjAt - q0 —•
                                                                      'i
where x.j is defined in Subroutine TRIMAT.

          The growth rate, y^, is computed according to Equation II-6
as
                                                    In
                        N, + K«     P+TCp     A7D7 4"   Ki  + Le  Aiui
                         3    Ti  1       r  i   i i

For dynamic simulation, nitrate (N3) and phosphorus (P) values from the
previous time period are used to calculate the growth rate; for steady-
state simulation, values from the previous iteration are used.

          If, under the program options, algal concentrations are being
simulated and either nitrate or phosphorus or both are not being
simulated, the program assumes that the parameter or parameters not
simulated are not limiting.  For example, if both nitrate and phosphorus
are not being simulated the growth rate would be computed as
                                 80

-------
                                     ,
          The right hand side term contains all known inputs, which
include headwater inflows, wastewater discharges, tributary flows and
incremental runoff, and, in the case of dynamic simulation, the
concentration in the previous time step.  The known term for each type
of element for dynamic simulation is:
          TYPE                   RIGHT HAND SIDE
     1.  Headwater         S^  =  A* + q^A^ ~ - a1-Ah

     6.  Waste Input       Si  -  A* + ^'. At + qy/Aw &

     All Others            S1  •  A* + q^A! ^

For steady-state simulation, the only difference is that the value from
the previous time step, A*, is set equal to zero and At = 1.0.

          The subroutine flow chart is illustrated in Figure VI-3 and
is followed by the program listing.  All program variables contained
in COMMON are defined in Section VII.
*AII  symbols used are defined at the end of this section of the
 DocumertaTjcn Report.
                                    31

-------
                                                 ENTRY
                                            SUBROUTINE ALGAES

            (SEE DATA
             ram 19)
            INITIALIZE COUNTERS AND
              CONVERSION FACTORS
            READ SOLAR RADIATION IF
              SIMULATION IS DYNAMIC
                                                                       DO computations
                                                                       from a to b for
                                                                       ill computational
                                                                       •iMMtS
                                          CALCULATE GROWTH RATE.
                                          AND INITIALIZE KNOWN
                                            TERM AND DIAGONAL
                                          TERM FOR STEADY-STATE
                                          Oft DYNAMIC SIMULATION
                                                DETERMINE
                                          TYPE OF COMPUTATIONAL
                                                ELEMENT
   TYPE 1
 ADO HEADWATER
INPUTS TO KNOWN
  TERM, S(I)
TYPES 2. 3. 4. 5


    CONTINUE
    TYPE 6

ADO UASTEUATER
INPUTS  TO KNOWN
  TERM, S(I)
      TYPE 7

  SUBTRACT STREAM
  WITHDRAWAL FROM
DIAGONAL TERM. 8(1)
                                                 RETURN
                                                 TO QUAL
              FIGURE  VI-3.    FLOW  CHART  FOR SUBROUTINE ALGAES
                                                  32

-------
  1.          SUBROUTINE ALGAES
  2.     C
  3.          COMMON TITL£(20,20),RCHID(75,5),RMTHOR(75),RMT£OR(75),MHWWAR(15),
  4.
  5.
  6.
  7.
  8.
  9.
 10.
 11.
 12,
 13.
 14.
 15.
 16.
 17.
 19.
TARGDO(75),IAUGOJU75,&),NCELRHO5),IFLAG(75,20),
lCLORO(75,20),COErO.V<75),EXPO,C!C3(75),X20PT(75),CK2(75),COIiQ.K2(75>,
EXPQK2C75),rmT(75),DOINIT(75),B01NITC75),COINlT(75,3),
QI(75),n(75),OOJ(75),aODI(75),CONSl(75,3),JUNCIDa5,5),
JUNC(15,3),H*rRlD(l5,5),HWFLOW(15),H*T£«P(15),HWOQ(15),
HWBODU5),HHCONS(15,3),WA5TID(90,S),TRFACK90),WSFLOH(90),
WST£MP(90),MSOO(90),*SBOD(90),HSCONS(90,3),tiATOT(lS),
AC500),8(500),C(500),0(15),3(500),Z(500),rt(500),GC500),
FLOW ( 500 ), DEPTH ( 500 ),VEL (500 ),DTO.YCU 500), K2( 500 ),K1 (500),
H5NET(500),DL(500),VHWU5),DEPHW(15),OLHW(15),1(500),
DOC 500),800(500),CONS(500,3),PTIME,TPRINI,DELX,
NHWTRS,NR£ACH,NWASIS,,NJUNC,DELT,01LT,D2L;r,OTODX2,DT20DX,
LAT,LSH,LLM,£LEV,DAI,A£,8E,DAXOFY,DRXBLB',WETBLB,DEWPT,
ATMPR,HIND,CLOUD,SONET,NI,NJ,TRLCD,TOFDAX,NT,NC,TIME,NC5
 19.    C
 20.    C
 21.          COMMON/MODIFA CX4(75),CX5(75),CXNH3(75),CXN02(73),CKN03(75),
 22.         *       CXN,CKP,CKL,ALPHAO(75),ALPHA1,ALPHA2,ALPHA3,ALPHA4,
 23.         *       ALPHAS,ALPHA6,GROMAX,RESPRT,ALGSET(7S),SPHOS(75),
 24.         *       5NH3(75),KNH3(500),KN02(500),RESPRR(500),COLI(SOO),
 25.         *       ALGAE(500),PHOS(500),CNH3(500),CN02(500),CN03(500),
 25.         *       COLIR(75),ALGI(7b),PHOSI(75),CNH3I(75),CN02I(75),
 27.         *       CN03I(75),COL1II(75),ALGIT(75),PHOSIT(75),CNH3IT(75),
 28.         *       CN02IT(75),CN03IT(75),HSCOLI(90),MSALG(90),MSPHOS(90),
 29.         *       WSNH3(90),WSN02(90),rfSN03(90),HHCOLI(15),H*ALG(15),
 30.         *       HWPHOS(15},HMNH3(15),HWN02(15),HMN03(15),GROWTH(500),
 31.         »       MODOPI(10),IRCHNO(750),EXCOk;F(75)
 32.    C
 33.          COMMON/SSTAT£/X(SOO),ISS
 34.    C
 35-.    C                            INITIALIZE COUNTERS
 36.    C
 37.          NHMaO
 38.          NMS*0
 39.    C
 40.    C                                      HEAD SOLAR RADIATION DATA  IF REQO
 41.    C
 42.          IFUSS .GT. 0 .OR. MOOOPT(2)  .GT. 0) GO TO 20
 43.          IF(TRLCO) 10,10,15
 44.       10 REAO(NI,11) SONET
 45.       11 FORMAT(30X,F10.0)
 46.          TRLCO=3.0
 47.       IS TRLC03TRLCO-02LI
 48.       20 CONTINUE
 49.    C
 50.    C                            LOOP THROUGH REACHES AND COMP. ELEMENTS
51.    C
52.          DO 100 Isl,NR£ACfl
53.          NCELRsNCELRH(I)
54.          CNC£LR»NCELR
                                         83

-------
55.          ALCIJ « QI(I)/CNCELR*ALGIU)
56.          00 100 Jsl.NCELR
57.          IORsICLORDCI,J)
58.    C
59.    C                            COMPUTE ALGAE GROWTH RATES
60.    C
61.          TC * 0.556*PK03(IOR))
71.       SO IF (MODOPT(6).EQ.O> GO TO 52
72.          GROWTH(IOR) » GROWTHCIOJ?) *:.N03(IQR)/(CKN+CN03 (IOR) )
73.       52 CONTINUE
74.    C
75.    C                            INITIALIZE DIAGONAL A»0 KNOWN TERMS
76     "
7?!    V     RSACTaGROMTH(IOR)-RE:SPRR(IOR)-AL5INK
78.          BtIUR)=X(IOR)-R£ACT*01UT
79.          S(IOR)sALGAEUOR)
80.          1FCISS.GT.1) SaOR}=0.0
81.          S(IOR) = S(IOR)+ALGIJ*OTOVCL(IOR)
32.    C
83.    C                            MODIFY DIAGONAL AND/OR KNOWN TERMS
84     "
8s!    W     IFLaIFLAC(I,J)
86.          GO TD (101,100,100,100,100,103,104), IFL
87.    C
US.      101 NHWsNHWtl
89.          S(IOR) B S(IOR) - A(IOR)*HMALG(NHW)
90.          GO TO 100
91.      103 NWSsMStl
92.          S(IOR) s S(IOR) t WSFIO.N(NHS)*NSALG(NWS)*DTOVCL(XOR>
93.          GO TO 100
94.      104 NN5BNWS+1
95.          B(10R) s BCIOR) - WSFLOM(NWS)*OTOVCL(IOR)
96.      100 CONTINUE
97.          RETURN
98.          END
                                        84

-------
SUBROUTINE BODS*

          Subroutine BODS completes the setup of the equations necessary
to calculate BOD levels in each computational element.  Specifically,
the subroutine completes the definition of the diagonal term of the
coefficient matrix and defines the vector of known terms on the right
hand side of the equations.

          The additions to the diagonal term represent the individual
constituent changes caused by constituent reactions and interactions,
and mass changes caused by stream withdrawals.  The resulting diagonal
term for each type of computational element is:
           TYPE                     DIAGONAL TERM
     All except type 7        bj  -  xj + (Kx + K3)At
     7.  Withdrawal           bj  =  x1 + (Kx + K3)At - q0 77

where x-j is defined in Subroutine TRIMAT.

          The right hand side term contains all known inputs, which
include headwater inflows, wastewater discharges, tributary flows and
incremental runoff, and, in the case of dynamic simulation, the
concentration in the previous time step.  The known term for each type
of element for dynamic simulation is:
          TYPE                  RIGHT HAND SIDE
     1.  Headwater         S^  »  I* + q^LJ ~ - a^

     6.  Waste Input       Si  -  L* + q!l! ^ * qwLw &

                                   *
     All Others            S1  •  L  + ql
*AM sv^&c's US8C a"3 csfined at the end cf This section o* the
        '-at icn Resort,
                                   35

-------
For steady-state simulation,  the only difference is  that the value from
the previous time step, U, is set equal  to zero and At = 1.0.

          The subroutine flow chart is illustrated in Figure VI-4 and
is followed by the program listing.  All  program variables contained in
COMMON are defined in Section VII.
                                    36

-------
                                                 ENTRY
                                            SUBROUTINE BODS
                                               INITIALIZE
                                              COUNTERS MO
                                           CONVERSION FACTORS
                                                 A	
                                          DO computations
                                          from a to  b  for
                                          all computational
                                          dements
                                             INITIALIZE MOWN
                                            TERM AND DIAGONAL
                                          TERM FOR STEADY STATE
                                          OR DYNAMIC SIMULATION
                                                DETERMINE
                                          TYPE  OF COMPUTATIONAL
                                                ELEMENT
    TYPE 1
 AOO HEADWATER
INPUTS TO KNOW
  TERM. S(I)
TYPES 2. 3. 4. S


    CONTINUE
    TYPE 6

ADO WASTEWATER
INPUTS TO KNOWN
  TERM. S(I)
  SUBTRACT STREAM
  WITHDRAWAL FROM
DIAGONAL TERM, 3(1)
                                                 6
                                                RETURN
                                                TO QUAL
                      FISURE  VI-4.   FLOW CHART  FOR  SUBROUTINE  30CS

-------
 1.          SUBROUTINE BOOS
 2.    C
 3.    C
 4.          COMMON TITL£(20,20),RCHID(7S,5),RMTHOR(75),RMTEQR(75),NHWWAR(15),
 5.         *       TARGDO(75),IAUGO*(75,6),NC£LRH(75),IFLAG(75,20),
 6.         *       ICLORO(75,20),CO£FQV(75),EXPOQY(75),CO£FQH(7J»,EXPOQH(75),
 7.         *       CMANN(75),CK1(75),CK3(75),K20PT(75),CK2(75),COEQK2(75),
 8.         *       EXPQK2(75),IINII(75),DOINIT(75),B01NIT(75),COINIT(75,3),
 9.         *       Q1(75),TI(75),001(75),3001(75),CONSH7S,3),JUNCID(15,5),
10.         *       JUNC(15,3),HMrRIO(15,5},HWFLOW(15),HMTEMP(15),HWOO(15),
11.         *       HWBOD(15),H*CONSU5,3),WASTID(90,5),TRFACT(90),WSFLOH(90),
12.         *       WSTEMP(90),»SOO(90>,asaOD(90),WSCONS(90,3),QATOI(15),
13.         *       A(500>,8(500),C(500),0(15),S(500),Z(500),H(500),G(500),.
14.         *       FLOW(SOO),DEPTH(500),VEL(500),DTO.VCL(500),K2(500),Ki(500),
IS.         *       HSNET(SOO),DL(500),VHW(15),DEPHH(15),DLHH(15),1(500),
16.         *       00(500),800(500),CUNS(500,3),PTIME.TPRINt.OELX,
17.         * .     NHfcTRS,NREACH,MWAST£,NJUNC.D£LT,DlLT,D2LT,OTODX2,DT200X,
18.         «       LAT,LSM,LLM,ELEV,DAT,AE,BE,DA*OF*,ORYBLB,W£TBLB,0£HPT,
19.         *       ATMPR,NINO,CLOUD,SONET,NI,NJ,TRLCU,TOFOAX,NT,«C,TIME,NCS
20.    C
21.    C
22.          COMHON/SSTATE/X(500),ISS
23.          REAL K1,K3
24.    C
25.    C                            INITIALIZE COUNTERS
26.    C
27.          NHW»0
28.          NWSS0
29.    C
30.    C                            LOOP THROUGH REACHES AND COMP. ELEMENTS
31.    C
32.          00 100 I*1,NR£ACH
33.          NCELRsNCELRHU)
J4.          CNCELRsMCELR
35.          800IJsUI(I)/C»CELR*BOOI(l)
36.          oo 100 J=I,N:ELR
37.          IOR=ICLORD(I,J)
38.    C
39.    C                            INITIALIZE DIAGONAL ANO KNOWN TERMS
40.    C
41.          TC>0.556*(T(IOR)-68.0)
42.          K1(10R)=CK1U)*1.047**TC
43.          K3=CK3(I)
44.          REACT=01LT*(K1(10R)+K3)
45.          B(10R)=X(IOR)+KEACT
46.          SUOR)=aOD(10R)
47.          IF(ISS.GT.l) S(IOR)«0.0
43.          S(IOR)=S(IOR)tBODlJ*OIO.VCL(IOR)

50*    C
51.    C                            MOOIPX DIAGONAL AND/OR KNOWN TERMS
52.    C
53.          GO TO (101,100,100,100,100,103,104), IfL
54.    C
55.      101 NHHsNHN+1
56.          S(IOR)»S(IOR)-A(IOR)«HW80D(NHW)
57.          GO TO 100
58.      103 NHSsNriS+l
59.          SUOR)3S(IOR)+WSFLOW(NH3)*HSaOD(NNS)*DTaYCL(IOR)
00.          GO TO 100
61. .     104 NWSsNWS+1
62.          a(IOR)*&(IOR)-WSFLOW(HHS)»OrOVCL(IOR)
63.      100 CONTINUE
64.          RETURN
65.          END

-------
SUBROUTINE CHANL

          Subroutine CHANL is called by subroutine HYDRAU to compute the
velocity and depth in each computational element given the flow in that
element.  One of two techniques as explained in Section II, Hydraulic
Characteristics, is used depending on input specifications.  The first
involves the use of discharge coefficients and exponents to compute the
velocity and depth while the second computes these values from the
geometric properties of the stream reach.

          The subroutine flow chart is illustrated in Figure VI-5 and
is followed by the program listing.  All program variables contained in
COMMON are defined in Section VII.

-------
            INITIALIZE COUNTERS
                   SET
              DEPTH(d) - 1.0
                CALCULATE Q
                  USING
             MAIMING EQUATION
                                           SELECT NEW
                                             d USINS
                                         NEVTCN-RAPHSON
FIGURE  VI-5.   FLOW CHART  FOR  SUBROUTINE  CHANL
                             90

-------
  1.
  2.
  J.
  4.
  S.
  6.
  7.
  9.
  9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
23.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
42.
43.
44.
45.
46.
47.
48.
49.
50.
51.
52.
53.
54.
      SUBROUTINE CHANL(J,Q»VELO.OPTH)
C
C
C
C
C
C
C
C
C
C
C
C
340
C
C
350
                 THIS SUBROUTINE RETURNS VELOCITY AND DEPTH
                 USING   THE NEKTON RAPHSON TECHNIQUE WHEN
                 TRAP-CHANNEL DATA IS INPUT OR
                 ALPHA'S ANDi BETA'S OTHERWISE
    COMMON TITLE(20,20),RCHI0(75,5),RMTHOR(75),RHI£ORU5),NHWUARU5),
           TARGDO(75),IAUGOA(75,6),NCELRH(75),IFLAG(75,20),
           ICIORO<75,20),CO£FQVC75),EXPOQV(75),COEFQH(75),EXPOQH(7S),
           CMANN<75),CKl(75),CK3(75),K20PT(7S),CK2(75),COEQK2(7.5),
           EXPOK2(75),TINIT(75),DOINIT(75),BOINIT(75),COINIT(75,3),
           QI(75),TI(75),OOJU75),80DI(75),CO.NSI(75,3),JUNCIDa5,5),
           JUNC(15,3),HMTRID(15,5),HMFLOW(15),HHTEMP(15),HWDO.(15),
           HMBOD(15)rHMCONS(15,3),WASTID(90,5),TRFACT(90),MSFLOW(90),
           WSTEMP(90),HSDO(90),»SBOO(90),WSCONS(90,3},QATOT(1S),
           AC500),8(500),C(500),D(15),S(500),Z(500),»(500),0(300),
           FLOW(500),DEPTH(500),VEL(SOO),DTOVCL(500),K2(500),Kl(500),
           HSNET(500),DL(500),VHM(15),D£PHM(15),OLHM(15),T(500),
           00(500),800(500),CONS(500,3),PTIHE,TPRINr,D£LX,
           NHNTRS,NR£ACH,NriASTE,NJUNC,OELT,DlLT,Q2l.T,OTOOX2,DT20DX,
           LAT,LSM,LLM,£L£V,DAI,A£,BE,OAYOFY,DR5(aLa',i4ETBLa,OEWPT,
           ATMPR,HIND,CLOUD,SONET,NI,NJ,TRLCD,TOFOAX,NT,NC,TIME,NCS


    COMNON/MODIF/. CK4(75),CKS(75),CKNH3(75),CXN02(75),CKN03(75),
   »       CXN,CKP,CKL,ALPHAO(75),ALPHA1,ALPHA2,ALPHA3,ALPHA4,
   »       ALPHAS,ALPHA6,GROMAX,RESPRT,ALGSET(75),SPHOS(75),
   >       SNH3(75),KNH3(500),KN02(500),RESPRR(500),COLI(500),
   >       ALGAE(500),PHOS(500),CNH3(500),CN02(500),CN03(500),
   >       COLiR(75),ALGI(75),PHOSl(75),CNH31(75),CN02I(75),
   »       CN03I(75),COtIIT(75),ALGIT(75),PHOSIT(75),CNH3IT(75),
   >       CN02IT(75),CN03IT(7S),WSCOLI(90),M5ALG(90),MSPHOS(90),
   »       MSNH3(90),MSN02(90),i       HMPHOS(15),HHNH3(15),HWN02(15),HHN03(15),GROWTH(500),
   »       MOOOPT(10),IRCHNO(750),£XCOEF(75)
      COMMON/CDATA/SS1(75),SS2(75),WIDTH(75),5LOPE(75},ITRAP

      IF(O.NE.O.)GO: TO 340
      V£LO=0.
      OPTH'O
      RETURN
      CONTINUE
      IFUTRAP.EQ.DGO TO 350 •
      VELOsCOEFQV(J)*Q**£XPOQV(J)
      OPTHsCO£FQH(J)*Q**EXPOQH(J)
      RETURN
      CONTINUE
                                   91

-------
55.    C
56.    C
57.          DCb*l.
58.          DELDsl.
59.          CONSI«i.486/CMANNU>*SQRT)
60.          00 360 lsl,30
61.          AREA*0.5*im(SQRT(SS2(J)«*2 + l>)
65.          FL*sCO.NST»UAR£A»*1.6$667)/iETPESU'*l-0.33333»*DHET?»/
69.         2   (METPER**!.33333)
70.          OCL'OELO-F/or
71.          ir.(A8SCF).LT.0.001*Q) SO TO 380
72.      360 DELOsQEL
73.          MR2TE(6,1H1)
74.     1111 FORMAIUH ,32HIHERE IS- NO CONVERGENCE IN CHANL)
75.          RETURN
76.      380 COKTINUE
77.          OPTH=OEU
78.          VELO«a/AREA
79.          RETURN
80.          END
                                      92

-------
SUBROUTINE COLIS*

          Subroutine COLIS completes the setup of the equations necessary
to calculate coliform levels in each computational element.  Specifically,
the subroutine completes the definition of the diagonal term of the
coefficient matrix and defines the vector of known terms on the right
hand side of the equations.

          The additions to the diagonal term represent the individual
constituent changes caused by constituent reactions and interactions,
and mass changes caused by stream withdrawals.  The resulting diagonal
term for each type of computational element is:
          TYPE                       DIAGONAL TERM
     All except type 7           b^  •  xj + K5 At
     7.  Withdrawal              bj  =  xj + KS At - qQ —•

where x^ is defined in Subroutine TRIMAT.

          The right hand side term contains all known inputs, which
Include headwater inflows, wastewater discharges, tributary flows and
Incremental runoff, and, in the case of dynamic simulation, the
concentration in the previous .time step.  The known term for each type
of element for dynamic simulation is:
          TYPE                     RIGHT HAND SIDE
     1.  Headwater

     6.  Waste Input

     All Others
s
1

Si
si
* 1 1
* Ej + q-E-
i 1 i
* 1 1
• E* + «iEi
= E* * q^EJ
At r
vi " 1 h
At At
vTj~ * qw w 7j"
At
*AM symcGi? ussc are defined at the and of this section of the

-------
For steady-state simulation,  the only difference is  that the value from
the previous time step, E*,  is set equal  to zero and At = 1.0.

          The subroutine flow chart is illustrated in Figure VI-6 and
is followed by the program listing.   All  program variables contained in
COMMON are defined in Section VII.
                                   94

-------
                                                  ENTRY
                                            SUBROUTINE COLIS
                                               INITIALIZE
                                              COUNTERS AND
                                           CONVERSION FACTORS
                                                                        00 computations
                                                                        from a to b for
                                                                        all computational
                                                                        •leiMfits
                                             INITIALIZE KNOWN
                                            TERM AND DIAGONAL
                                          TERM FOR STEADY STATE
                                          OR DYNAMIC SIMULATION
                                                DETERMINE
                                          TYPE OF COMPUTATIONAL
                                                ELEMENT
    TYPE 1

 ADO HEADWATER
INPUTS TO K/tOWN
  TERM, S(I)
TYPES  2. 3. 4. 5


    CONTINUE
    TYPE 6

ADO UASTEWATER
INPUTS  TO KNOWN
  TERM, SU)
      TYPE 7

  SUBTRACT STREAM
  WITHDRAWAL FROM
DIAGONAL TERM, 3(1)
                                                RETURN
                                                TO QUAL
             FIGURE  VI-6.   FLOW CHART  FOR  SUBROUTINE  COLIS

-------
 1.
 2.
 3.
 4.
 S.
 6.
 7.
 8.
 9.
10.
11.
12.
13.
14.
IS.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
42.
43.
44.
45.
46.
47.
48.
49.
50.
51.
52.
53.
54.
C
C
C
C
C
C.
C
C
C
C
C
C
C
C
C
      SUBROUTINE COLIS
COMMON TITLEC20,20>,RCHID(75,5),RMTHORC75},RMTEOR(75),NHWHAR(15),
       TARCDO(75),IAUSQK(75,6),NCELRHC75),IFLAGC75,20),
       ICLORO(75,20),COEFQV(75),£XPOQV(75),COEFQHC75),EXPOQH(75>,
       CHANN(75),CK1(75),C!U(75),K20PTC75),CK2(75),COEQK2(75),
       EXPQK2(7S>,TINITn5),OOINITO5),BOINlT(75),COINm75,3),
       QI(75),TI(75),DO.IC75),BODI(75),CDHSI(75,3},JUNC1DU5,5>,
       JUNC(15,3>,HWTRID(15,5),HMFLOW(15),HNX£MPUS),HWDO.a5),
       HMBOD(lS),HWCONS(lS,3),WASTlO(90,5),TRfACT(90),W5FLOW(90),
       WStEMP(90),WSOO(90),HSBOD(90),WSCONS(90,3),QATOT(15),
       AC500), B<500), C (500), 0(15), S (500 },Z(500),KC500),G(500),
       FLQW(500),D£PTHl500),VEL(500),DTaVCL(500),K2(500),Kl(500),
       HSNEI(500),DL(500),VHW(15),DEPHW(15),DLH*U5),T(SOO),
       00(500), BOD (500 ),CONS(500, 3 ),PTIME,TPRINT,D£LX,
       NHWTRS,NREACH,NWASTE.,NJUNC, CELT, DILI, 02LT,DTODX2,DT200X,
       LAT,LSM,LLM,ELEY,DAI,AE,BE,DAYQF!(,DRYBLB,WET8L8,DEHPT,
       ATMPR, HIND, CLOUD, SONST,NI,NJ,TRLCD,TOFDAi, NT, NC.riM£>NCS


COMMON/MOOIF/7 CX4(75) , CK5(75) ,CXNH3 (75 ) ,CKN02 (75 ) ,CKN03(75) ,
       CXN,CKP,CKL,ALPHAO(75),ALPHA1,ALPHA2,ALPHA3,ALPHA4,
       ALPHAS, AUPHA6,GROMAX,RESPRT,ALGSET(75),SPHOS(75),
       SNH3(75),KNH3(500),KK02(500),RESPRR(500),COL:(500),
       ALGAE (500 ), PHOS ( 500 ),CNH3 (500 ),CN02 (500 ),CN03( 500),
       COl.IR(75),AbGI(75),PHOSI(75),CNH3I(75),CN02l(75),
       CNQ31(75),COI,IIT(75),ALGIT(75),PHOSIT(75),CNH3ir(75),
       CN02II(75),CN03IT(75),WSCOH(90),HSALG(90),WSPHOS(90),
             HWPHOS(15),HKNH3(15),HWM02(15),HHN03tl5),GROWTH(500),
             MOOOPT(10),IRCHNO(750),EXCOEF(75)
      COMMON/SSTATE/X(500),ISS
      REAL K5
      NHW«0
      NWS>0
                       INITIALIZE COUNTERS
                       LOOP THROUGH REACHES AND COMP. ELEMENTS
      00 100 Isl.HREACH
      NCELRsNCELRH(I)
      CNCELRsNCELR
      COLIJsQI(I)/CNC£LR*COLlR(I)
      DO 100 J=1,NCELR
      IOR»1CLORD(I,JJ
                       INITIALIZE DIAGONAL AND KNOWN TERMS
      TC»0.556*(T(IOR)-68.3)
                                        96

-------
55.          K5aCX5(I)*1.047**TC
56.          REACT=DiLT*K5
57.          B(IOR)sX(IOR)*REACT
58.          SUOR)aCOLI(IOR)
59.          IF (ISS.GT.O) SUOR)*0.0
60.          SUOR)«S(IOR)*COUJ*OTO.YCLCIOR>
61.          m*IFUG(I,J.)
62.    C
63.    C                            MODIFJf DIAGONAL AND/OR KNOWN TERMS
64.    C
65.          GO TO (101,100,100,100,100,103,104), IfL
66.    C
67.      101 NHWsNHU+1
63.          S(IOR)aS(IOR)-A(IOR)*HWCOLI(NHM)
69.          SO TO 100
70.    C
71.      103 NMS»NHS+1
72.          S(IOR)*S(IOR)tUSrLOW(NUS)*MSCOLI(NMS)*DTOVCL(IOR)
73.          GO TO 100
74.    C
75.      104 NWS-NMS+1
76.          B(XOR)sa(IOR)-WSri.ON(NHS)*DIOVCMIOR)
77.      100 CONTINUE
78.          RETURN
79.          END

-------
SUBROUTINE CONSVT*

          Subroutine CONSVT completes the setup of the equations necessary
to calculate concentrations of a conservative constituent level  in each
computational element.  Specifically, the subroutine completes the
definition of the diagonal  term of the coefficient matrix and defines
the vector of known terms on the right hand side of the equations.

          The additions to the diagonal term represent the individual
constituent changes caused by constituent reactions and interactions,
and mass changes caused by stream withdrawals.  The resulting diagonal
term for each type of computational element is:
          TYPE                            DIAGONAL TERM
     All except type 7                  b^  *  Xj
     7.  Withdrawal                     b1  =  x^ - q0 —•
where x-j is defined in Subroutine TRIMAT.

          The right hand side term contains all known inputs, which
include headwater inflows, wastewater discharges, tributary flows and
incremental runoff, and, in the case of dynamic simulation, the
concentration in the previous time step.  The known term for each type
of element for dynamic simulation is:
          TYPE                     RIGHT HAND SIDE
     1.  Headwater            Si  =  C* + qjcj ^- - a^

     6.  Waste Input          S^  •  C* + q.jcj ^7 + qwCw—

     All Others              ' Si  =  C* + q\C\ &
*AII symools used are defined at the end of this section of the
 Documentation Report.
                                  98

-------
                                                       «
For steady-state simulation, the only difference is that the value from
the previous time step, C?, is set equal  to zero and At = 1.0.

          The subroutine flow chart is illustrated in Figure VI-7 and
is followed by the program listing.  All  program variables contained in
COMMON are defined in Section VII.
                                   99

-------
                                                 ENTRY
                                           SUBROUTINE  CONSVT
                                              INITIALIZE
                                             COUNTERS AND
                                          CONVERSION FACTORS
                                                                       DO computations
                                                                       from 4 to b for
                                                                       all computational
                                                                       elements
                                             INITIALIZE KNOWN
                                            TERM AND DIAGONAL
                                          TERM FOR STEADY STATE
                                          OR DYNAMIC SIMULATION
                                               DETERMINE
                                          TYPE OF COMPUTATIONAL
                                                ELEMENT
    TYPE 1

 ADO HEADWATER
INPUTS TO KNOWN
  TERM, S(I)
TYPES 2. 3. 4. 5


    CONTINUE
    TYPE 6
ADO WASTEWATER
INPUTS TO KNOWN
  TERM, S(I)
     TYPE 7

  SUBTRACT STREAM
  WITHDRAWAL FROM
DIAGONAL TERM. 8(1)
                                                 0
                                                RETURN
                                                TO QUAL
             FIGURE  VI-7.   FLOW CHART  FOR SUBROUTINE CONSVT

                                              100

-------
1.
2.
3.
4}
5.
6.
7.
3.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18. •
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
42.
43.
44.
45.
46.
47.
48.
49.
bO.
51.
52.
53.
54.
55.
56.
57.
58.
59.
60.
61.
62.
63.
64.
65.

C
C
C
C
C
C
















C

C.
C
C


C
C
C






c.
C
c





c
c
c.

c
101

(
c
103 K
i
c
c
104 »
e
100 C
*
E
 SUBROUTINE CONSVT
                         CONSVT PERFORMS A CONSERVATIVE MINERAL
                         BALANCE FOR EACH COMPUTATIONAL ELEMENT
                         IN THE SYSTEM.
 COMMON TITLEC20,20),RCHIDC75,5),RMTHOR(75),RMTEORC75),NHHWARU5>,
        TARGDO(75),IAUGO*C75,6),NCELRH(75),1FOAG(75,20),
        ICLORO(75,20),CO£FQVnS),EXPOQV(75),COEFg.HC75),£XPOQH(75),
        CMANN(75),CK1(7S),CK3(75;),K20PT<75),CK2(75),COEQK2(75),
        EXPQK2(75),TINII(75),DOINIT(75),aoiNIT(75),COINIT(75,3),
        QI(75),TI<75),OO.I(75),BOOI(75),CQASI(75,3},JUNCIDU5,5),
        JUNCU5,3),HWrRID(15,5),HWFLOW(15),HWT£MP(15),HWOO.U5),
        HWBODU5),H*CONSU5,3),WASTID(90,5),TRFACT(90),HSFLOW(90),
        WSTEMP(90),WSDOC90),HS80D(90),WSCONS(90,3),QATOTUS),
        A(500),B(SOO),C(500),DU5),5(500),Z(500),K(500),G(500),
        FLOW(500),D£PTH(500},VEL(500),DTO.VCL(500),K2(500>,K1(500),
        HSN£T(500),OL (500), VHW( 15 ),DEPHW( 15 ),OLHM( 15),TC500),
        00(500),BOD(500),CONS(500,3),PTIME,TPRINT,DELX,
        NHWTRS,NREACH,NHAST£.,NJUNC,D£LT,D1LT,02LT,QTODX2,DT2CIDX,
        LAT,LSM,LLM,ELEY,DAr,AE,a£,DAXUF*,DRXaLa,rfETBLB,DEWPT,
        ATMPR,MIND,CLOUD,SONET,NI,NJ,TRLCD,TOFOAY,NT, tiC,TIME,NCS

 COMMON/SSTATE/XtSOO),ISS

                        INITIALIZE  COUNTERS
 NHWsO
 NMS'O
                        LOOP THROUGH REACHES AND COMP. ELEMENTS
 00  100  I»1,NREACH
 NCELR3NCELRHCI)
 CNCELRaNCELR
 CONSIJsQI ( I) /CNCELR*CONSI ( I , NO
 00  100  J>l,NC£Lft
 IOR»ICLORDU,J)
                        INITIALIZE DIAGONAL AND KNOWN TERMS
 B(IOR)=X(IOR)
 S(IOR)»CONS(IOR,NC)
 IF(iSS.GT.l)  S(IOR)sO.O
 S(IUR)*5(IOR)+CONSIJ*OTOVCL(IOR)
                        MODIFY DIAGONAL AND/OR KNOWN TERMS

 GO  TO  (101,100,100,100,100,103,104),  IFL

 NHWsNHW+1
 S(IOR)sS(IOR)»A(IOR)*HMCONS(NHW,NC)
GO TO  100
S(IORJ«S(IOR)+WSFLOW(NWS)*i
-------
SUBROUTINE DOS*

          Subroutine DOS completes the setup of the equations necessary
to calculate dissolved oxygen levels in each computational  element.
Specifically, the subroutine completes the definition of the diagonal
term of the coefficient matrix and defines the vector of known terms
on the right hand side of the equations.

          The additions to the diagonal term represent the individual
constituent changes caused by constituent reactions and interactions,
and mass changes caused by stream withdrawals.  The resulting diagonal
term for each type of computational element is:
          TYPE                       DIAGONAL TERM
     All except type 7           b-j  a  x^ + (K2)i At
     7.  Withdrawal              bt  =  x.j"+ (KJ1 At - qo ^

where x^ is defined in Subroutine TRIMAT and the reaeration rate
reaeration constant, (K2)^, is determined in Subroutine REAERC.

          The right hand side term contains all known inputs, which
include headwater inflows, wastewater discharges, tributary flows and
incremental runoff, and, in the case of dynamic simulation, the concentration
in the previous time step.  The known term for each type of element for
dynamic simulation is:

     Si  -  
-------
            TYPE                  RIGHT HAND SIDE


       1.  Headwater            S..  *  S^ -




       6.  Waste Input          S1  =  Si +




  For steady-state simulation, the only difference is that the value
                                *
  from the previous time step, 4»-j, is set equal to zero and At - 1.0.



          The subroutine flow chart is illustrated in Figure VI-8 and

is followed by the program listing.  All program variables contained in

COMMON are defined in Section VII.

-------
                           Coma       }
                        uwotfliK oos    I









                    .S    sat  ^s»"
                    \   108 WHITS    .>
      GONVGCT

     I MT 300

     TO ULTIMATE
                          arruua
                         countB AW
                       comtniM
                           Q	
00 camutlont
fn* t a i far

•II comiutleiul

tlMMCI
                              nmm
                       TOM AM OUGOML
                     TOW rat STOW-sun
                     on onwuc SWUUTIOH
1
Ttn i
awvre s(u AM id)
AMI AOO HtABUTCt
iwvn TO crew
TOW, «I)

1
TTTCJ 2, J, t
comiwi


I
TW 4
AOO mnnMT MOCM
TO man TGW. sm

rm »
ADO UASTDMTEX
IVUTJ 10 OOWI
TOW. S(l)

1
Tmjr
AOO IMIOOITAI. ixaau
TO an« Tom. s(n. AM
SUtTMCTSTUAN
MtTHOMUAI. flON atAfiONAt.
TOW. >(I)
                           (wniw     ^
                           TOOMM.     J
FIGURE VI-8.   FLOW  CHART  FOR SUBROUTINE  DOS
                            104

-------
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
IS.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
23.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
42.
43.
44.
45.
46.
47.
48.
49.
50.
SI.
52.
53.
54.
55.
56.
57.
58.
59.
60.
61.
62.
63.
64.
65.
66.
67.
63.
69.

C
C
















C
C











c.
C




C* • * * *
c • • « * *
c • • * • •
C • * 9 • 9



10


1
20 (
25 :
I
'
30 (
35 C
{
J
t
1
t
40 C
45 (
3
(
C
C
C
50 C
!
             SUBROUTINE DOS
            COMMON TITL£(20,20),RCHID(75,5),RMTHOR(75),RMTEOR(75),NHWHARU5),
                   TARGwO(75),IAUGOA(75,6),NC£LRH(75),IFLAS:(75,20),
                   ICLORO(75,20),CO£FQV(75),EXPOOY(75),COEFQH(75),EXPOQH(75),
                   CMANN(75),CX1(75),C:<3(75),K20PT(75),CK2(75),COEOK2(75),
                   EXPQK2(75),TINIT(75),DOIiUT(75),aOINlT(75),COlNIT(75,3),
                   OI(75),TI(75),DOJ(75),dODI(75),CONSI(75,3),JUNCID(15,5),
                   JUNC(15,3),HWTRID(15,5),HWFLOW(15),HWT£MPU5),HMDO(15),
                   HW800(15),HMCONS(15,3),MASTID(90,5),TRFACT(90),M5FLOW(90),
                   MST£MP(90},USOO(90),NSBOD(90),WSCONS(90,3),QATOTU5),
                   A(500),8(500),C(500),0(15),5(500),Z(500),W(500),G(500),
                   FLOW(500),OEPTH(500),VEL(500),DTOVCL(500),K2(500),Kl'(500),
                   HSNET(500),DL(500),VHW(15),DEPHW(15),DLHM(15),T(500),
                   00(500),800(500),CONS(500,3),PT1ME,TPRINT,OELX,
                   NHWTBS,NREACH,NWASIE.,NJUNC,OELT,D1LT,D2LT,DTODX2,DT200X,
                   LAT,L5M,LLM,ELEV,DAI,AE,BE,OAXOFY,DRY8LB,HETBLB»OEHPT,
                   ATMPR.rflNO,CLOUD,SONET,NI,NJ,TRLCD,TOFDAY,NT,NC,TIME,NCS


            COMMON/MODIF/ CK4(75),CK5(75),CXNH3(75),CXN02(75),CKN03(75),
                   CKN,CKP,CKL,ALPHAO(75),ALPHA1,ALPHA2,ALPHA3,ALPHA4,
                   ALPHAS,ALPHA6,GROMAX,RESPRT,ALGSETC 75),SPHQS(75),
                   5NH3(75),KNH3(500),KS02(500),R£SPRR(500),COLI(500),
                   ALGAE(500),PHQS(500),CNH3(500),CN02C500),CN03(500),
                   COLIH(75),ALGI(75),PHOSI(75),CNH3I(75),CN02I(75),
                   CN03I(75),COLIIT(75),ALGIT(75),PHUSIT(75),CNH3IT(75),
                   C«02IT(75),CN03ir(75),WSCOLI(90),WSALG(90),WSPHOS(90),
                   WSNH3(90),»SN02l90},iiSN03(90),HWCOLlU5),HWALG(15),
                   HMPHOS(lb),HMNH3(15),HMN02(15),HVIN03(15),GROrtTH(500),
                   MODOPT(10),IRCHNO(750),£XCOEF(75)
    COMMON/SSTAT£/X(500),ISS
    REAL K1,K2,KO
    REAL KNH3.KN02
    DATA U80U/4H 5-0/

....CONVERT BETWEEN ULTIMATE AND 5-DAY BOD BASED ON AN ASSUMED
....LAB DECAY RATE OF 0.23/DAY (BASE £ )..	MRN	

    IF(TITL£(7,6).N£.UBOD)  GO TO SO
    CFBOO » 1.0 - EXP( -5.0»0.23 )
    IVERT 3 0
            IVEKT * 1
    IF( NHMTRS .LE. 0 )  GO  TO 25
    DO 20 J s l,  NHMTRS
    HMBOD(J)  3 HMBOD(J)  /. CFBOO

 25  IF( NMASTC .L£. 0 )  GO  TO 35
    DO 30 J 3 1,  NMASTE
    HSBOD(J)  s HSaOD(J)  /! CFBOO
         MUE
          J 3 1,  NREACH
           3 Booi(j) /. craoo
    NCELR 3 NCELRH(J)
    00 40 K 3 l,  NCELR
    IOR 3 ICLORO(J,K)
    BOOUOR)  = BOO(IOR)  / CFBOD


    IF( IVERT .GE.  2 ) RETURN
            1.0 /  CFBOO
            CFBOD
                                   INITIALIZE COUNTERS
1.

-------
 72.          FACT a 1.0 / (28.3 * 86400.0)
 73.    C
 74.    C                            LOOP THROUGH REACHES AND COMP. ELEMENTS
 75.    C
 76.     •    00 100 I=1,NREACH
 77.          NCELR=NCELRH(I)
 78.          CNCELR'NCELR
 79.          DOIJ*Q1(I)/CNC£LR»DOIU)
 80.    C     RATlOsl.o/(1.0-EXP(-5.0*CKl(I)))
 81.          00 100 Jsl.NCELR
 82.          IORsICLORD(I,J)
 83.    C.
 84.    C                            INITIALIZE DIAGONAL AND XNOMN TERMS
 85.    C
 86.          S(IOR)sOOUOR)
 87.          IF (JSS.CT.l) S(IOR}>0.0
 88.          IF (MOOOPT(4).LI.l) GO TO 90
 89.          AREACT=(ALPHA3*GROWTH(IOR)-ALPHA4*RE5PRR(IOR))*01LT
 90.          S(IOft) = S(IOR) *• AREACT'ALGAEUOR)
 91.       90 IF (MOOOPT(6).LT.l) GO TO 92
 92.          SCIOR) » S(IOR) - UL?HA5*KNH3UOR)*CNH3UOR) +
 93.         1                   ALPHA6*KN02(IOR)*CN02(IOR))*D1LI
 94.       92 S(IOR) = S(IOR) - CK4(I)*DELX*DTOYCL(IOR) *FACT
 95.          TC=0.556*(TUOR)-68.0)
 96.    C     KHIOR)=KKIOR)*RATIO
 97,          OOSAI=24.89-0.4259*TCiaR)+0.003734»T(IQR)**2-0.00001328»TCIOR)**3
 98.          IF CDO.(IOR).GT.DOSAT) OO(IOR) = DOSAT
 99.          IFL=IFLAG(I,J.)
100.    C
101.    C                            MODIFX DIAGONAL AND/OR KNOWN TERMS
102.    C
103.          GO TO (101,102,102,104,102,103,105), IFU
104.    C
105.      101 NHri=MHW+l
106.          KO=K2UOK)*1.0159**TC
107.          REACT=01UT*(KO»OOSAT-K1(IOR)*80D(IOR))
108.          S(IOR)sS(IOR)tREACTfDOIJ*DTOVCL(IOR)-A(IOR)*HNOO(NHM)
109.          B(IOR)=X(IOR)*D1LT»KO
110.          GO TO: 100
111.    C
112.      102 KOa(0.5*(K2(IOR-l)+K2(IOR)))*1.0159**TC
113.          REACT=D1LT*CKO»DOSAT-KUIOR)*BODUOR))
114.          S(IOR)*S(IOR)tREACT^DOIJ.*DIO.VCL(IOR)
115.          3(IOR)=X(IOR)t01LT*KO!
116.          GO TO 100
117.    C
118.      103 NVtSsNHS+1
119.          KOa(0.5*(K2(IOR-l)+K2(IOR)))*1.0159**TC
120.          R£ACT301LT*(KO*DOSAT-K1(IOR)*BOD(IOR))
121.          S(IUR)3S(IOR)tREACTt(OOlJ-i-HSFt.OM(NMS)*NSDO(NMS)}*DTOVCL(IOR)
122.          B(IOK)3X(IOR)+01LT*KQ:
123.          GO TO 100
124.    C
125.      104 IJUNC.sIJUNCtl
126.          NS=1
127.          NNaJUNC(IJUNC,NS)
128.          KO=(0.25*(K2(IOR-1)+K2(NN)+2.0*K2(IOR)))*1.0159**TC
129.          REACT=01LT»(KO»OOSAT-Rl(10R)»BOOtlOR))
130.          S(IOR)sS(IOR)tREACTtOOIJ*DTOVCL(IOR)
131.          8(XOR)aX(IOft)t01LmOi
132.          GO TO 100
133.    C
134.      105 NWSstiHS+1
135.          KO*(O.S*(K2(IOR-1)^K2(IOR)))*1.0159**TC
136.          ReACT«DlLT*(KO*DOSAT-Kl(IOR)*aOO(IOR))
137.          SUUR)*SUOR)+ReACT+DOIJ*DrOVCL(IOR)
138.          9(IOR)3X(IOR)t01LT*KO»MSFLO»(NMS)*OTOVCL(IOR)
139.      100 CONTINUE
140.          IfCTir-e(7,6).«E.UBOD) RETURN
141.          as to to
142.          £30
                                       106

-------
SUBROUTINE FLOAUG

          Subroutine FLOAUG remains unchanged from the original version
of QUAL as documented by the Texas Water Development Board (1970).
According to that reference:
               After steady-state conditions have been reached,
          FLOAUG checks the calculated dissolved oxygen concen-
          tration against the pre-specified target levels for
          dissolved oxygen in each reach.  If the computed
          dissolved oxygen is below the target level, the routine
          then searches all of the upstream headwaters for those
          sources that the user has specified to have dilution
          water.   Dilution water is then added equally from all
          sources and calculations are repeated.  This sequence
          continues until all target levels are satisfied,
          whereupon a summary is written.
The theory of FLOAUG according to Frank D. Masch and Associates and the
Texas Water Development Board (1971) is:
               When environmental conditions are such that the
          dissolved-oxygen concentration in a stream drops below
          some required target level,  flow augmentation may be
          desirable.   The amount of augmentation water required
          to bring dissolved-oxygen concentrations up to required
          standards cannot be computed by an exact functional
          relationship; however, a good approximation can be
          given by
                         DOR  *  DOj - Cc

                                    DOR
                         n    -  n    K
                                  '07

-------
          where
               DOn  =  dissolved-oxygen concentration required
                       to meet target conditions,  mg/l
               DOj  -  some required target level of dissolved
                       oxygen, mg/l
               C-   =  minimum dissolved-oxygen concentration
                       (critical level) in the oxygen sag curve,
                       mg/l
              ,Q^   =  amount of flow augmentation required, cfs,
               Q    -  flow at the critical point in the oxygen
                       sag curve, cfs

The flow chart for FLOAUG shown in Figure VI-9 is taken from the referenced
report.  The program listing follows the figure.
                                   108

-------
           (    START   J
             INITIALIZE
            AUGMENTATION
                FLOWS
       DETERMINE LOCATION  AND
      MAGNITUDE OF MINIMUM 0.0.
           FOR EACH REACH
            MINIMUM 0.0.
            FOR EACH REACH
             SEEN CHECKED
              AGAINST
               ARGET
                 IS
               TARGET
             LEVEL 0.0.
             SATISFIED?
             COMPUTE AMTV
              OF FLOW
             AUGMENTATION
              REQUIRED
                                     DIVIDE TOTAL AUGMENTATION
                                      REQUIRED EQUALLY AMONG
                                    AVAILABLE HEADWATER SOURCES
                                    CHECK TO SEE THAT AN EXCESS
                                       OF FLOW AUGMENTATION
                                         HAS NOT BEEN USED
                                               WRITE
                                           \INTERMEDIATE~
                                              SUMMARY  /
                                                WAS
                                               FLOW
                                           AUGMENTATION
                                             REQUIRED
FIC-'JRE  VI-9.   FLOW CHART FOR  SUBROUTINE  FLOAUG
                           109

-------
 1.          SUBROUTINE FLOAUG
 2.    C
 3.    C                             FLOAUG SEARCHES THROUGH THE SYSTEM BY
 4.    C                             REACH TO DETERMINE THE MINIMUM DO. LEVEL
 5.    C                             WITHIN EACH REACH. EACH OF THESE MINIMUM
 6.    C                             DO LEVELS IS CHECKED AGAINST A SELECTED
 7.    C                             TARGET LEVEL. IF FLOW AUGMENTATION IS
 8.    C                             REQUIRED, THIS FLOW IS DISTRIBUTED
 9.    C                             EQUALLY AMONG THE HEADWATER SOURCES THAT
10.    C                             ARE. AVAILABLE TO. A GIVEN REACH.
11.    C
12.    C
13.          COMMON T1TLE(20,20),RCHID(7S,5),RMTHOR(75),RMTEOR(75),NH«WAR(15),
14.         *       TARGOO(75),IAUGOK(73,6),NC£LRH(75),IFLAG(75,20},
15.         *       ICLORO(75,20),CO£FQV(75),EXPOQV(75),COEFQH(75),EXPOQH(75),
16.         *       CMANN(75),CK1(75),CK3(75),K20PT(75),CK2(75),COEQK2(75),
17.         * .      EXPQK2(75),rlNir(75),OOINIT(75),B01NII(75),COINIT(75,3),
18.         *       QZ(75),U(75),001(75),8001(75),CON5H75,3),JUNCIDU5,5),
19.         *       JUNC(15,3),HWTRID(15,5),HWFLOH(15),HHT£MP(15),HWDO.(15),
20.         *       HMBOO(15),HMCONS(15,3),WASTID(90,5),TRFACT(90),WSFLOW(90),
21.         *       HSTEMP(90),MSDO(90),US80D(90),WSCONS(90,3),QATOTU5),
22.         *       A(500),8(500),C.C500),0(15),S(500),Z(500),W(500),G(500),
23.         *       FLOW(500),D£PIH(500),VEL(500),DiaVCL(500),K2C500),Kl(500),
24.         *       HSN£T(500},DL(500),VHW(1S),DEPHN(15),DLHH(1S),T(500),
25.         *       00(500),800(500),CONS(500,3),PTIME,TPRINT,DELX,
26.         *       NHHIRS,NREACH,NWASTE,NJUNC,D£LT,01LT,02LT,DTODX2,DT200X,
27.         *       LAT,LSM,LLM,ELEV,DAT,AE,BE,OAYOFY,DRYBLB>HET8LB,DEWPT,
28.         »       ATMPR,HIND,CLOUO,SONET,NI,NJ,TRLCD,TOFDAY,NT,NC,TIME,NCS
29.    C
30.    C
31.          DIMENSION IORMIN(75),RMILE(75),DOMIN(75),IOROER(75),QAUGU5)
32.    C
33.    C
34.    C                                       STEP 1-0
35.    C                                       INITIALIZE AUMENT&TION FLOWS
36.          DO 5 NHMal.NHMTRS
37.          QAUG(NHW)»0.0
38.        5 CONTINUE
39.    C
40.    C
41.    C                                       STEP 2-0
42.    C                                       LOOP THROUGH SYSTEM OF NREACH RE
43.    C                                       AND NCELR COMPUTATIONAL ELEMENTS
44.    C                                       REACH TO DETERMINE MINIMUM DO LE
45.    C                                       REACH AND ITS LOCATION BY RIVER
46.    C
47.          DO SO 1*1,NREACH
48.          DOMN(I)=100.0
49.          IF(NHrtNARU).EQ.O) GO TO 50
50.          NCELR=NCELRH(I)
si.          DO 100 j»t,NCELR
52.          IOR=ICLORD(I,J)
S3.          If (DO(IOR).GE.DOMIN(IO) GO TO" 100
54.          DOMIN(I)»DO(IOR)
                                        no

-------
 55.          IORMIN(I)«IOR.
 56.          XMINsj
 57.          RMILE(I)sRMTHOR(I)-XHIN*OELX/5280.0
 S3.      100 CONTINUE
 59.       SO CONTINUE
 60.          NBTARC=0
 61.    C.
 62.    C                                       STEP 3-0
 63.    C                                       LOOP THROUGH NREACH REACHES TO S
 64.    C                                       MINIMUM 00 LEVEL IS BELOW TARGET
 65.    C
 66.          DO 25 1*1,NREACH
 67.          IF COCWIN(I).GE.TARGOOm) GO TO 25
 68.    C
 69.    C                                       STEP 3-1
 70.    C                                       IF TARGET LEVEL IS NOT MET* COHP
 71.    C                                       AMOUNT OF FLOW AUGMENTATION REQU
 72.    C
 73.          NBTARGsNBTARG+1
 74.          lOROERCNBTARG)*!
 75.          IQRalORMINU)
 76.          RMILE(NBIARG)=RMILEU)
 77.          OORE3D»TARGDO(1)-OOMIN(IJ+0.1
 79.          QREQO * FLOM(IOR)*(DOR£QO/IARGDO(I) t 0.15*
 79.         »(DOREQD/TARGDO(I))**2)
 80.          QSUM»0.0
 81.          NHMARsNHMMAR(I)
 82.          00 350 J=1,NH*AR
 83.          NHWslAUGOR(I,J)
 84.          QSUMsQSUMtQAUG(NHM)
 85.  '    350 CONTINUE
 86.    C
 87.    C                                       STEP 3-2  .
 88.    C                                       DIVIDE TOTAL AUGMENTATION REQUIR
 89.    C                                       EQUALLY AMONG THE UPSTREAM HEAD*
 90.    C                                       SOURCES AVAILABLE TO A GIVEN REA
 91.    C                             GIVEN REACH.
 92.    C
 93.          O.AOD«9R£QD/NHMtfAR(I)
 94.    C
 95.    C                                       STEP 3-3
 96.    C                                       CHECK TO SEE THAT AN EXCESS OF F
 97.    C                                       AUGMENTATION HAS NOT BEEN USED.
 98     C
 99!          IF (QREOO.LT.OSUM) GO TO 25
100.          NHHARsNHWWARU)
101.          DO 375 J=1,NHWAR
102.          NHM3IAUGOR(I,J)
103.          QAUG(NHW)3QADD
104.      375 CONTINUE
105.       25 CONTINUE
106.          IF (NBTARG.EQ.O) GO TO 300
107.    C
108.    C                                       STEP 4-0
109.    C                                       WRITE 5UMMARX OF FLOW AUG'MT. RE

-------
no.    c
HI.          WRITE (NJ.200)
112.      200 FORMAT UH1,38X.39H* * * REACHES HUH OXYGEN DEFICIT * * *,//,23X,
113.         *        52HREACH NO,     REACH IDENTIFICATION       MINIMUM 00.,
114.         *        15H     RIVER MILE,/)
115.          TIMEsO.O
116.          00 250 Ksl,N8TARG
117.          I=IORDER(X)
118.          WRITE (NJ,255)  I, (RCHIDU, J) , JM ,5) ,DOMIN(I) ,RMILE(I)
119.      255 FORMAT C22X,I5,10X,5A4,7X,F5.1,11X,F6.1)
120.      250 CONTINUE
121.          WRITE (NJ,260)
122.      260 FORMAT (1HO,30X.38H* * * FLOW AUGMENTATION REQUIRED * * «,//,
123.         *        5X,100HHEAOHATER NO.     HEADWATER IDENTIFICATION     EXIS
124.         *TING HEADWATER  FLOW (CFS)     AUG. REQUIRED CCfS),/)
125.          00 270 NH*=1,NHHTRS
126.          WRITE (NJ,275)  NHW,(HHTRIDCNHH,J),Jsl.5},HWFLOW(NHH),QAUG(NHW)
127.      275 FORMAT (8X,I5,12X,5A4,16X.F10.1,20X,F10.1)
128.      270 CONTINUE
129.          DO 380 NHWsl,NHHTRS
130.          HMFLOW(NHW) • HMFLOW(NHW) *• QAUG(NHW)
1J1.      380 CONTINUE
132.          GO TO 310
133.      300 CONTINUE
134.    C
135.    C                                       STEP 5-0
136.    C                                       WRITE FINAL SUMMARY OF FLOW
137.    C                                       AUGMENTATION REQUIREMENTS.
138.    C
139.          WRITE (NJ,261)
140.      261 FORMAT (1H0.33X,32HTOTAL FOOW AUGMENTATION REQUIRED,//,
141.         *5X,101HHEADWATER NO.     HEADWATER IDENTIFICATION      INITIAL  HE
142.         *ADWATER FLOW (CFS)     AUG. REQUIRED (CFS),/)
143.          DO 305 NHWsl,MHWTRS
144.          H«IFLOI=QATOT(NH»)
145.          QATOT(NHW)3HMFLQW(NHW)-HWFLOI
146.          HNFLO*(NHW)sHWFLOI
147.          WRITE (NJ,275)  NHh,(HMTRID(NHW,J),J«l,5),HWFLOH(NHW),QATOT(NHW)
148.      305 CONTINUE
149.      310 CONTINUE
150.          RETURN
151.          END
                                          112

-------
SUBROUTINE HEATEX/HEATER

          Subroutine HEATEX is used in the dynamic simulation of temperature.
It remains unchanged from the original version of QUAL as documented by
the Texas Water Development Board (1970).   According to that reference:
              This routine computes the net amount of heat
          radiation flux being transferred across the air-Mater
          interface.  It is based on an energy budget tihioh
          considers solar radiation, atmospheric radiation,
          back radiation, conduction, and evaporation.
Detailed equations for all of the heat budget terms are presented in
Section IV.

          The flow chart for Subroutine HEATEX shown in Figure VI-10 is
taken from the Texas Water Development Board reference.  The program
listing follows the figure.

          Subroutine HEATER is used in the steady-state simulation of
temperature.   Calculations performed in HEATER are identical  to those
performed in  HEATEX except that the step (3-0)—see Figure VI-10--is not
included in HEATER.  Back radiation, evaporation, and conduction losses
are computed  in TEMPSS.   The program listing for HEATER follows the
listing for HEATEX.
                                    113

-------
                                    f   ami   \
                                    suwomxc HEATH
                                      nquneo
                                      CONSTANTS
                              COMtlft All rC«HI KCI7UIIIEOV
                              ro« C«ALUAT:N« THE VAKIOUS
                                riUUS U CHCRSr IUOSCT
                                CAicuurt POSITIOK or
                                   sun uiArm TO
                                  A stiicTca LOCArion
                                ON TNC CAHTH'S SUKfACE
                               rCAlCUUTf ITANOAIIO TIHCS

                                  AT HNtCX SUN RISES
                                      AMO StTI
                                CALCUUTt VAPOK MKSUDCSN
                                OCV >0[»T. AND OAM»CIIIIIQ
                                truer tut ro aauomcss
                                      CAlCULATt

                                      HOU« AKClES
                             L
CllCUlATt AMUKr 9F Cl.tA«x
JIT. SOU« lAOUTtail. AKO
     AiriTuot or SUM
                                uicuuri AISOMTIOH Ana
                                    SCATTHIlia Out TO
                                           conairioos
                                      CAlCUUTt
                                     mrieenvitt
                                   ULCM1.ATI HCT SOLA*
                                 SCATTtlKC, ««SO«>T10«.
                                     1*0 IfrLCCTtON
                                COMPUTE om» HCAT
                                  ANO PCRFORM (Xf»5T
                                       fo«  CACN CUNCMT
                              «ATUOH.T
                                     (  KTUXII   j
FIGURE  VI-10.   FLOW  CHART  FOR SUBROUTINE  HEATEX/HEATER

-------
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35..
36.
37.
38.
39.
40.
41.
42.
43.
44.
45.
46.
47.
48.
49.
50.
51.
52.
53.
54.
55.
56.
57.
58.
59.
60.
61.
62.
63.
64.
65.
66.
67.
68.
69.
73.

C
C
C
C
C
C
C
C
C
















C
C

C.
C
C

C
C.
C
C










C
C
C
C
C
C

C
C
C
C
C
C










 SUBROUTINE HEATEX
                         HEATEX COMPUTES THE NET AMOUNT OF HEAT
                         RADIATION FLUX BEING TRANSFERRED ACROSS
                         THE AIR-WATER INTERFACE BASED ON AN
                         ENERGY BUDGET WHICH CONSIDERS SOLAR
                         RADIATION, ATMOSPHERIC: RADIATION, BACK
                         RADIATION, CONDUCTION, AND EVAPORATION.
 COMMON TITLE(20,20),RCHID(75,5),RHTHOR(75),RMTEOR(75),NHWHARU5),
        TARGOO(75),IAUGOA(75,6),NC£LRH(75),IFLAG(75,20),
        ICLORO(75,20),COEFQVC75),EXPOQVC7S),CO£FQH(75),EXPOQH(75),
        CMANN(7S),CKU75),C!C3{75),K20PT(75),CK2(75),COEQK2<75),
        EXPQK2C75),IINin75),DOINIT(75),aOINITC75),COINIT<75,3),
        O.I(75),TI(75),OOI(75),&OOI(75),CO.NSIC75,3),JUNCID(15,5),
        JUNCC15,3),HHTRIDU5,5),HWFLOWU5),HWT£MP(15),H*00.<1S),
        HW80DU5),HaCONSUS,3),HA5TID<90,5),TRFACTC90),WSFLOW<90),
        *5TEMP(90),W500C90),ViS800(90),»iSCONS(90,3),QATOTC15),
        A(SOO),BC500),C(500),D(15),S(500),ZC500),H(500),G(500),
        FLOW(500),DEPrH(500),VELC500),DTaVCL(500),K2C500),KH500),
        HSNETC500>,DL(500),VHW(15),D£PHWC15),OLHW(1S),TC500),
        00(500),BOD(500),CONS(500,3),PTIME.TPRINI.OELX,
        NHMTRS, NREACH, NHASTE., N JUNC , DELT ,D 1LT, D2LT , DTODX2 ,DT20DX,
        LAT,LSN,LLM,ELE.Y,DAI,AE,BE,DAYQFY,DRYBL3<,WETBL8,DEWPT,
        ATMPR, WIND,CLOUD,SONET,HI ,NJ.,TRLCD,TOFDA*,NT, NC,TIME, MCS
 COMMON/METER/METRIC,METOUT
 REAL LLM,LSM,LAT
 PI*3.141628
 CON1»2.0*PI/365.0
 CON2*PI/180.0*LAT
 CON3>180.0/PI
 CON4s23.4S*PI/l80.0
 CONS3PI/12.0
 CON6S12.0/PI
 0£UTSL3(LLM-LSM)/15.0
 SOLCON=438.0
 ELtXPsEXP(-ELEV/2532.0)
                                   STEP 1-0
                                   COMPUTE REQUIRED CONSTANTS
 IF (IOFOAX.NE.0.0) GO' TO 77
                                   STEP 2-0
                                   COMPUTE ALL TERMS REQUIRED  FOR
                                   EVALUATING THE. VARIOUS FLUXES IN
                                   ENERGY BUDGET
                                   STEP 2-1
                                   COMPUTE SEASONAL AND DAILY POSIT
                                   SUN RELATIVE TO A SELECTED LOCAT
                                   THE EARTH'S SURFACE.
 REARIH*1.0t0.017*COS(C!XNlfQa6.0-DAYOFY))
 DECLINsCON4*COS(CQNl*U72.0-DAYOFY))
 RR»REARTH*»2
 EQTlMEaO.000121-0.12319»SIN(CON1*COAYOF*-1.0)-0.07014)
*       -0.16549*SIN(2.0*CON1.*(DAYQFY-1.0)+0.3038)
 DECLOfisABSCDCCLIN)
 ACS=TAN(CON2)*IAN(D£CLON)
 IF (ACS.EQ.0.0) GO I3l 9
 X*SQRTU.O-ACS*ACS)
 X=X/AC5

-------
71.
72.
73.
74.
75.
76.
77.
78.
79.
80.
81.
82.
83.
84.
85.
86.
87.
88.
89.
90.
91.
92.
93.
94.
95.
96.
97.
98.
99.
100.
101.
102.
103.
104.
105.
106.
107.
108.
109.
110.
111.
112.
113.
114.
115.
116.
117.
118.
119.
120.
121.
122.
123.
124.
125.
126.
127.
128.
129.
130.
131.
132.
133.
134.
135.
136.
137.
U3.
139.
140.





C:
C
C
C
c:








C
c
c
c
c
c










c
c
c
c
c
















c
c
c:
c










c
   ACSsATANU)
   IF (DECLIN.GT.0.0) ACS=PI-ACS
   GO TO 9
 8 ACSsPI/2.0
 9 CONTINUE
   STRsl2.0-CON6«ACS+DELrSL.
   5TSs24.0-SIRt2.0*DELTSL
   518=0.0
   STE=STB+D2LT
   GO TO 78
77 STB»STB+D2LT
   STBaST8tD2LI
78 CONTINUE
                                     STEP 2-2
                                     COMPUTE STANDARD TIMES AT  WHICH
                                     RISES AMD SETS.
                                     STEP 2-3
                                     READ IN LOCAL CLIMATALOGICAL  OAT
                                     AT DESIRED TIME INTERVAL  (MINIMU
                                     INTERVAL IS THREE HOURS).
   If (TRLCD.NE.0.0) GO TO. 82
   READ 12, CLOUD,ORmB',ilETBLB,ATHPR,MiNO
12 FORMAT (40X,5F9.0)
   IF(METRlC.Ett.O)GO tt) 13
   DR]fBLB30RYBLB*l. 8+32.0
   H£TBLB=WETBL3*1.3+32.0
   ATMPR=ATMPR*(29.9/1000.)
   HIND=*1ND/0.3048
13 CONTINUE
   HINDsrfIND*0.6818
                                     STEP 2-4
                                     COMPUTE VAPOR PRESSURES,  DEM  POI
                                     DAMPENING EFFECT OF CLOUDINESS.
   VPHB*0.1001*EXP(0.03*H£TBLB)-0.0837
   VPAIRsVPWB-0.000367* ATMPR*(DR5fBLB-WETBL8)
  *     *(1.0+(W£T8LB-32.0)/1571.0)
   DEWPT=ALUGC(VPAlRtO.0837)/0.1001)/0.03
   C5*1.0-0.65*CLOUD**2
   IF (CLOUD.GT.0.9) CS'0.50
   CNL=»CLOUD*10.0+1.0
   NL'CNL
82 CONTINUE
   TRLCOSTRLCD+02LT
   IF (TRLCD.LI.2.9) GO TO. 84
   TRLCDsO.O
84 CONTINUE
   IF (STS.LE.STB-.OR.STR.GE.STE) GO TO 35
   IF(STR.GT.STB.AND.STR.LT.ST£) GO TO 41
   IF ISTS.LT.STE.AND.SIS.GT.SI8) GO TO 42
                                     STEP 2-5
                                     COMPOTE HOUR. ANGLES
   TB=SrB-12.0-OELTSL-f£OriME
   TE=SIE-12.0-DELTSL+EQTIME
   GO TO 43
41 TB3STR-12.0-D£LTSL+EQTIME
   TE3STE-12.0-OELTSLtCQTIME
   GO TO 43
42 79=313-12. O-OELTSL+EQIIME
43 CONTIHUC
   TALTsi(T8+TS)/2.0
                               116

-------
141.
142.
144.
144.
145.
146.
147.
148.
149.
150.
151.
152.
153.
154.
155.
156.
157.
158.
159.
160.
161.
162.
163.
164.
165.
166.
167.
168.
169.
170.
171.
172.
173.
174.
175.
176.
177.
178.
179.
180.
181.
182.
183.
184.
185.
186.
187.
188.
189.
190.
191.
192.
194!
1 Q*
A 7 9 «
196.
197.
198.
199.
200.
201.
202.
203.
204.
205.
205.
207.
203.
209.
213.
C
C
C
C














C
C
C
C
C




Z'
C
C
C















C
C
C
C
C

.




C
C
C
C
C
C





STEP 2-6
COMPUTE AMT OF CLEAR SKY, SOLAR
RADIATION, AND ALTITUDE OF SUN.

SOLARsSOLCON/RR*(5IN(CON2)*SIN(DECLIN)»(TE-T8)+CON6*COS(CON2)»
» COS(DECLIN)* (SIN (CONS *TE)-smCON5*TB)))
ALPHA3SIN(CON2)*SIN(OECLIN)+COS(CON2)*CO£(DECLIN)*COS(CON5*TALT)
IF (ABS(ALPHAJ.EO.l.O) GO TO 4
YsSQKT(1.0-ALPHA*ALPHA)
Y=ALPHA/Y
ALPHA=ATAN(Y)
GO TO 5
4 IF (ALPHA. £Q. -1.0) GO TO 6
ALPHAsPI/2.0
GO TO 5
6 ALPHA=-PI/2.0
5 CONTINUE
IF (ALPHA. LI. 0.01) GO 10 35

STEP 2-7
COMPUTE ABSORPTION AND SCATTERIN
DUE TO. ATMOSPHERIC CONDITIONS.

PWCsO.OObl4*£XP(0.04S9*D£WPT)
OAM=ELEXP/ (SIN (ALPHA) tO. 15* (ALPHA*CON3+3. 885 )**(-!. 253))
AlsEXP(-(0.465+0.0408*PWC)» (0.129+0. 17 1 *EXP(-0.880*OAM) )*OAM)
A2s£XP(-(0. 465+0. 0408*PWC)*(0. 179+0. 421 *£XP(-0.721*OAM))*OAM)

STEP 2-8
COMPUTE REFLECTIVITY COEFFICIENT

GO TO (30, 31, 31, 3t, 31,31, 32, 32, 32,32, 33), NL
30 AR*1.18
BRs-0.77
GO TO 34
31 AR32.20
BR*-0.97
GO TO 34
32 ARaO.95
BRa-0.75
GO TO 34
33 AR=0.35
BRs-0.45
34 CONTINUE
RSsAR»(CON3» ALPHA) **BR
ATC»(A2+0.5*(1.0-Al-OAT))/( 1.0-0, 5»RS»(1.0-AltOAT))

STEP 2-9
COMPUTE NET SOLAR RADIATION AFTE
SCATTERING, ABSORPTION, AND. REFL

SONEr=SOLAR*ATC*CS*(1.0-RS)
IF(30H£T.L£.0)GO TO 35
GO TO 36
35 SONEIaO.O
36 CONTINUE
CLCst.O+0.17*CLOUD**2

STEP 3-0
COMPUTE OTHER HEAT FLUXES AND PE
ENERGY BUDGET FOR EACH COMPUTATI
ELEMENT.

HAs0.97*1.73S-09»2.89E-06*(DRY8L3t460.0)*»6»CLC*02LI
DO 70 I*1,NREACH
NCELRsNCELRH(I)
DO 70 Jsl.NCELR
1 3 Rs 1C LORD (I , J)
^ -\
117

-------
211.          VPW=0.1001*£XP(0.03*T(IOR}>-0.0837
212.          H8»0.97*1.73E-09«(TTOrOAXt02L7
219.          If (TOfDAX.LT.23.9) GO TO 85
220.          TOKDA1T=0.0
221.          OAXOPYsOAYOFY+l.O
222.       85 CONTINUE
223.          RETURN
224.          END
                                        113

-------
1.
2.
3.
4.
S.
6.
7.
8.
9.
10.
'11.
12.
13.
14.
IS.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
29.
29.
30.
1 1
J 1 •
32.
33.
)4
*t *
35.
36.
37.
38.
39.
40.
41.
42.
43.
44.
45.
46.
47.
48.
49.
50.
51.
52.
53.
54.
55.
56.
57.
58.
59.
60.
61.
62.
63.
64.
65.
66.
67.
63.
69.
70.

C
C
C
C
C
C
C
C
C
















C
C

C
C

C
C



C
C
C
C










C
C
C
ft
to
C
C

««
w
C
C
C
C
C




SUBROUTINE HEATERCNITER)

HCATEX COMPUTES THE NET AMOUNT OF HEAT
RADIATION FLUX BEING TRANSFERRED ACROSS
THE AIR-WATER INTERFACE BASED ON *AN
ENERGY BUDGET WHICH CONSIDERS SOLAR
RADIATION* ATMOSPHERIC RADIATION, BACK
RADIATION, CONDUCTION, AND EVAPORATION.


COMMON IITL£C20,20),RCHiD<75,5),RMTHOR(75),RMT£OR(75),NHWWAR(15),
« TARCOO(75),IAUGO*<7S,6>,NCELRH(75),IFLAG(75,20),
ICLORO(7S,20),CO£FQV(75},EXPOQV<75),CO£FQH<75),EXPOQH(75),
CMANN(75),CK1(75),CK3(75),K20PT(75),CK2(75),COEQK2{75),
£XPQK2(75),TINlT(7S),DOIIUT(75),aoitUT(75),COINIT(75.3),
QI(75),TI(75),OOI(75),BUDI(75),COJ3),QATOTC15),
AC500), 8(500), 0(500), 0(15), 5(500 ),ZC500),W( 500 ),GC500),
FLOH(500),D£PTH(SOO),V£L(500),DTO.VCU500),K2(500),K1(500),
HSN£T(500),OU500),VHW(15),D£PHM(15),DLHrf(lS),T(500),
DO(500),BOO(500),CONS(500,3),PTIME,TPRINT,DELX,
NHHTRS,NR£ACH,NWASTe,NJUNC,D£LT,DlLT,02LT,DTODX2,OT20DX,
LAT,LStt,lLM,£L£V,DAI,A£,BE,OAYOFY,DRY8La,M£TBLa,DEWPT,
ATMPR,WINU, CLOUD, SONET, NI,NJ,TRLCD,TOfOA*, NT, NC, TIME, NCS


COMMON/METER/METRIC, METOUT


COMMON/AUG/IAUGIT


COMMON/SSTEMP/JT(bOO),SQLR:>U75)rCLDF438.0
ELEXP«EXP(-EL£V/2532.0)

STEP 2-0
COMPUTE ALL TERMS REQUIRED. FOR
EVALUATING THE. VARIOUS FLUXES IN
ENERGY BUDGET

IF (TOFDAY.NE.0.0) GO TO 7?

STEP 2-i
COMPUTE SEASONAL AND DAILY POSIT
SUN RELATIVE TO A SELECTED LOCAT
THE EARTH'S SURFACE.

REARTH»1.0«.O.Ol7*COSCONl»U86.0-OAXOFn)
DECHN«CON4»COS(CON1*<172.0"OAYOFY))
RR«R£ARTH»*2
EQTIHE»0. 00012 1-0. 1231 9»SI«(CON1*(OAYOFY-1.0) -0.0701 4)
119

-------
71.
72.
73.
74.
75.
76.
77.
78.
79.
80.
81.
82.
83.
84.
85.
86.
87.
88.
89.
90.
91.
92.
93.
94.
95.
96.
97.
98.
99.
100.
101.
103
« V4 •
103.
104.
105
4 V ^ «
106.
107.
108.
109.
110.
111.
112.
113.
114.
115.
116.
117.
118.
119.
120.
121.
122.
123.
124.
125.
126.
127.
128.
129.
130.
131.
132.
133.
134.
135.
136.
137.
138.
139.
140.











C
C
C
C
C








C
C
C
C
c.
C

c

.
c















c
c
c
c.
c













c
* -0.16549*SlN(2.0*CONl*(DAYOrY-1.0)+0.3088)
DECLON=ABS(OSCLIN)
ACS«TAN(CON2)*TAN(DECLOJO
IF (ACS. EQ. 0.0) GO TO 8
* X«SORIU.O-AC5*ACS)
XSX/ACS
ACSsATAN(X)
IF (OECLIN.GT.0.0) ACS-PI-ACS
GO TO 9
8 ACSspl/2.0
9 CONTINUE

STEP 2-2
COMPUTE STANDARD TIMES AT
RISES AND SETS.

3TR»l2.0-CON6«ACS+OELTSt,
STS*24.0-STRt2.0*0£LTSL
STBaO.O
STESSTB+D2LT
GO TO 78
77 STBSST8+D2LT
STE=ST8+D2LT
78 CONTINUE

STEP 2-3













WHICH












READ IN LOCAL. CLIMATALO.GICAL DAT
AT DESIRED TIME INTERVAL
INTERVAL IS THREE HOURS).

IF (TRLCD.NE.0.0) GO TO. 82

IF(IAUGIT.LE.O) R£AD(NI,12) CLOUD, DRYBLBiWETBLB-.ATMPR, WIND

12 FORMAK40X.5F8.0)
IF(METRIC.EQ.O)GO TO 13
DRXBLB»ORXBL3*1. 8+32.0
«ETBL8=WET8L8*1. 8+32.0
ATMPRsATMPR* (29. 9/1000.)
WIND3HINO/O.J048
13 CONTINUE
WINO'UIND*0.6818
DO 922 I«1,NREACH
TNBRCH(I)*WETBL8
TDBRCH(I)3Dft¥BLB '
CLDRCH(I)sCLOUD
UINRCH(I)»MIND
PATRCH(I)*ATMPR
922 CONTINUE

STEP 2-4
COMPUTE VAPOR. PRESSURES,
(MINIMU























DEM POI
DAMPENING EFFECT OF CLOUDINESS.

Vp'ua»0.1001*EXP(0.03*METBLB')-0.0837
VPAIRsVPNB-0.000367*ATMPR*(DRXBLB-METBLa)
* *(1.0+(M£TBLB-32.0)/1571.0)
DENPT»ALOG((VPAIR+0.0837)/0.1001)/0.03
CSal.O-0.65*CLOUD**2
IF (CLOUD. GT. 0.9) CS*0.50
CNL=CLOUD*10. 0+1.0
NL^CNL
82 CONTINUE
84 CONTINUE
IF (ST3.LE.ST3.0R.STS.GS.STE) GO TO 35
IF(STR.GT.STB.AND.STR.LT.STE) GO TO 41
IF (STS.LT.STE.AND.STS.GT.sra-) GO TO 42
















120

-------
 Ml.    C                                       STEP  2-5
 142.    C                                       COMPUTE HOUR  ANGLES
 143.    C
 144.          TB*STa-l2.0-OELTSL+EQTlM£
 145.          TEaSTE-12.0-DELT5L+EQTIME
 146.          GO  TO  43
 147.       41  TBSSTR-12.0-DELISL+EQTIME
 148.          TEaSr£-12.0-OELI5LtEQTIME
 149.          50  TO  43
 ISO.       42  T8»STB-12.0-DELTSL+EQIINE
 151.          TE*STS-12.0-OELISL+£O.TIME
 152.       43  CONTINUE
 153.          TALTs(TB+TE)/2.0
 154.    C
 155.    C                                       STEP  2-6
 156.    C                                       COMPUTE AHT OF CLEAR SKY, SOLAR
 157.    C                                       RADIATION, AND ALTITUDE  OF SUN.
 158.    C
 159.      *    SOLAR»SOLCON/RR*(SIN(COJI2)*SIN(DECLIN)*(TE-T8)+CDN6*C05(CON2)*
 160.         *       COS(DECLIN)*(SmCON5*TE)-SIN(CON5*TB)))
 161.           ALPHAsSIN(CON2)»SIN(DECLIN)tCOS(CON2)*CQ.S(DECLIN}*COSCCON5*TALT)
 162.           If  (ABS(ALPHA).EO.l.O) GO  TO, 4
 163.           Y*SQRT(1.0-ALPHA*ALPHA)
 164.           JfaALPHA/Y
 165.           ALPHASATANU)
 166.           GO TO  5
 167.        4  IF  (ALPHA.EQ.-1.0) GO TO 6
 168.           ALPHAsPI/2.0
 169.           GO TO  5
 170.        6  ALPHAs-PI/2.0
 171.        5  CONTINUE
 172.           IF  (ALPHA.LT.0.01) GO TO 35
 173.     C
 174.     C                                        STEP  2-7
 175.     C                                        COMPUTE ABSORPTION AND SCATTSRIN
 176.     C                                        DUE TO. ATMOSPHERIC. CONDITIONS.
 177.     C
 178.           PWC*0.00614*£XP(0.0489*DEWPT)
 179.           OAM«ELEXP/(SIN(ALPHA)+0.15*(ALPHA*CON3t3.985)*»(•!.253))
 180.           A1»£XP<-(0.465+0.0408*PWC)»(0.129f0.171«EXP(-0.880*OAM))*OAM)
 181.           A2*SXP(-(0.465+0.0408*PHC)*(0.179+0.421*EXP(-0.721*OAM)}*OAM)
 182.     C
 183.     C                                        STEP  2-8
 184.     C                                        COMPUTE REFLECTIVITY COEFFICIENT
 185.     C
 186.           GO TO  (30,31,31,31,31,31,32,32,32,32,33), NL
 187.       30  AR-1.18
 188.           BR«-0.77
 189.           GO TO  34
 190.       31 AR*2.20
 191.           BR3-0.97
 192.          GO TO  34
 193.       32 ARsO.95
 194.          8R»-0.75
 195.          GO TO  34
 196.       33 AR»0.3S
 197.          SRs-0.45
 198.       34 CONTINUE
 199.          RS*AR«(CON3*ALPHA)**BA
 200.          AIC*(A2+O.S*(1.0-A1-OAI))/(1.0-O.S*RS*U.O-A1+OAX))
 201.    C
 202.    C                                        STEP  2-9
 203.    C                                        COMPUTE NET SOLAR RADIATION AFTE
 204.    C                                        SCATTERING, ABSORPTION,  AND REFL
205.    C
206.          SONET*SOLAR*ATC*CS*(1.0*RS)
207.          GO TO  36
209.       35 SONET=0.0
 209.       36 CONTINUE
 210.          00 923 I«1,NRSACH
                                          111
                                          ti. i

-------
211.          SOLRCH(I)=SON£T
212.      923 CONTINUE
213.          TOFDAX=TOFDAr*D2LT
214.          IF (TO/DAX.LT.23.9) GO TO 85
215.          TOFOAXsO.
216.          OAXOFXsDAXOFX+1.
217.       35 CONTINUE
218.          RETURN
219.          END
                                         122

-------
SUBROUTINE HYDRAU

          Subroutine HYDRAU remains largely unchanged from the original
version of QUAL as documented by the Texas Water Development Board (1970).
According to that reference:
               This routine performs a hydrologic balance for a
          branching stream or canal system based on continuity
          of flow.  It then computes velocities^ volumes, and
          dispersion coefficients for every computational element
          in the system.

          The only change from the original version is that Subroutine
CHANL is now called in steps 2-1, 2-2, 2-3, and 2-4 to compute velocity
and depth in each element.

          The flow chart for Subroutine HYDRAU shown in Figure VI-11 is
taken from the Texas Water Development Board reference.  The program listing
follows the figure.
                                   123

-------
                          INITIALIZE
                           COUNTERS
                             HAVE
                          HYDRAULICS
                       FOR ALL  ELEMENTS
                             BEEN
                           COMPUTED?
                              IS
                            ELEMENT
                        TYPE •  i.2,3.4,
 CALC.  HYOR.
FOR ELEMENTS
 TYPE*6  or 7
 CALC.  HY.OR.
FOR ELEMENTS
   TYPE-1
                 CALC. HYO
               FOR  ELEMENTS
                 TYPE-4
                                     CALC. HYOR.
                                    FOR  ELEMENTS
                                      TYPE»2,3
                                        or S
FIGURE VI-11.   FLOW CHART FOR SUBROUTINE HYDRAU
                                 124

-------
1.
2.
3.
4.
5.
b.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
13.
19.
20.
21.
22.
23.
24.
25.
26.
27.
29.
29.
30.
31.
32.
33.
34.
35.
36.
37.
33.
39.
40.
41.
42.
43.
44.
45.
46.
47.
48.
49.
50.
&1.
52.
S3.
54.

C
c
C
c
c
c
c
c
















c
c
c
c
c
c
c



c
c
c
f*--
w-
c
^
w








c
c
c
C:
c
SUBROUTINE HYORAU
                        HYDRAU PERFORMS A HYDROLOGIC BALANCE OH
                        THE SKSTEM BASED ON CONTINUITY. IT
                        COMPUTES THE FLOW, VELOCITY, VOLUME,
                        DEPTH, AND DISPERSION COEFFICIENT FOR
                        EVERY ELEMENT IN THE SYSTEM.

COMMON IITLE(20,20),RCHID(75,5),RMTHOR(75),RMTEOR(75),NHWWARU5),
       TARGDO<75),IAUGOR(75,6),NC£LRH(75),IFLAG(75,20),
       ICLOROC75,20),CO£FQV(75),£XPOOV(75),COEFQH(75),EXPOQH(75>,
       CMANN(7S),CKl{75>,CK3(75),K20PT(73),CK2(75),COEQK2<75),
       EXJ»,rmT(75),DOINlT<7S),SOINIT(75),COINII(75,3),
       OI(7S),TI(75),DOI(75),BODI(75),COMSI(75,3),JUNCID(15,5),
       JUNCUS,3),HWTRIO(l5.5),HWFLOWU5),HhIEMPCl5),HWOa(i5),
       HW80U(15),HWCOMSC15,3),WASTID(90,5),TRFACT(90},WSFLOW<90),
       «TEMP(90>,WSDO(90),*S8QD(90},WSCONS(90,3),QATOIC15),
       A(500),B{500),C.(500),OU5),8(500),Z(500),W(500),G(500),
       FLOW(500),DEPTH(500),VEL(SOO),OTO.VCL(500),K2(500),Ki<500),
       HSNET(500),DL(500),VHM(1S),DEPHM(1S),OLH^(1S),T(500),
       00(500),BOD(500),CONSl500,3),PTIME,TPRINT,OELX,
       NH»TRS,NREACH,NHASTS.,NJUNC,DELT,01Lli,02LI,OTODX2,OT200X,
       LAT,LSM,LLM,ELeV,DAT,AE,8e,OAYOFY,DHYSL3,METBLB,DEXPT,
       ATMPR,«INO,CLOUD,SONET,HI,NJ,TRLCD,TOFOAY,NT,NC,TIME,NCS


                                  STEP 1-0
                                  INITIALIZE COUNTERS FOR HEAOWATS
                                  UASTE INPUTS OR UITHORAWLS, AND
                                  JUNCTIONS.

NHW*0
NWS=0
IJUNC'O

                                  STEP 2-0
                                  LOOP THROUGH SYSTEM OF NREACH RE
                                  AND NCELR COMPUTATIONAL ELEMENTS
                                  REACH.

DO 100 I=1,NHEACH
NCELR3NCELRHU)
CNCELRSNCELR
fiR'OKD/CNCELR
DO 100 J»1,NCEUR
IOR*ICLORO(I,J)
IFL*IFLAG(I, J)
GO TO (101,102,102,103,102,104,104), IFL

                                  STEP 2-1
                                  COMPUTE HYDRAULICS FOR AN ELEMEN
                                  TYPE 1.
                            125

-------
55.      101 NHW3NHH+1
56.          FbOH(IOR)sHMrtiOH(NHW)+0R
57.          CALL CHANl,(I,HWrLOH(NHM),VHrf(NHW),DCPHH(NHN))
58.          DLHi*CNHlOs22.6*CMANN(I)*YHrfCNHlO*DEPHi*(NHW)»*0.833
59.          CALL CHANL(X,FLOW(IORJ,VELUOR),D£PTHCIO«))
60.          DTOVCLUOR)»DI20DX/CH*FLOW(MHtO/YH*QR
80.          CALL CHANLU,FLOH(IOR),V£LUOR),D£PTH(IOJO)
81.          DTOVCL(lOR)3DT200X/(FLai((XOR-l)/VEL.(XOR-l}tFLON(IOR}/VEL(IOR)^
82.         *            FLOM(NN)/V£L(NN})
83.          GO TO 105
84.    C
85.    C                                       STEP 2-4
86.    C                                       COMPUTE HYDRAULICS FOR ELEMENTS
87.    C                                       6 OR 7.
a a     r*
89!      104 NHSsMMS+1
90.          FLOMUQR)3FU>W(XQR-1)+USFLOH(NHS)+QR
91.          CALL CHANLU,FLOU(IOR),VELUOR),DEPTHUOfi>)
92.          DTOVCL(XO!D30T200X/(FLOM(XOR-1>/YELUOR-1)+FLOW(XOR)/VEL(XOR)>
93.      10S CONTINUE
94.          DL(10R)822.6«CMANN(X)»VEL(XOR)*DEPTH(IOR)**0.833
95.      100 CONTINUE
96.          RETURN
97.          END
                                           126

-------
SUBROUTINE INDATA

          Subroutine INDATA reads and prints all  data required by the
model except the climatological data which is read in Subroutine HEATEX/
HEATER or ALGAE*.  INDATA reads a set of title cards and 11  different
types of data that are prepared on 19 different data forms.   Seven of
the data forms are optional depending on the parameters to be simulated.
Chapter V contains additional details concerning data preparation,
descriptions of data forms and an example data set.  If INDATA detects
any data inconsistencies, it prints an error message and terminates
execution.

          Figure VI-12 illustrates the flow chart for INDATA and the
following pages contain the program listing.  All program variables
in COMMON are defined in Section VII.
*The criteria that determines which subroutine reads the climatological
 data are:
     !.   Dynamic Simulation - No Temperature Simulation:
         Read solar radiation values in ALGAE.
     2.   Dynamic Simulation - With Temperature Simulation:
         Read Climatological  Data in HEATEX.
     3.   Steady-State Simulation:
         Read Climatological  Data in HEATER.
                                    127

-------
                                         Subroutine
                                           INDATA
                                         INITIALIZE
                                           CERTAIN
                                         PARAMETERS
1 (SEE DATA
[ FORM 1)
1

                                         READ TITLES
     (SEE DATA
         FORM 2)
       OATA TYPE 1
     READ AND PRINT
   MODEL CONTROL OATA
  |  (SEE OATA
  [     FORH2)
      OATA TYPE 1A
     READ AND PRINT
  ALGAE PRODUCTION AND
   OXIDATION CONSTANTS
] (SEE OATA
[ FORM 3)
1

                                  I      OATA TYPE 2
                                       READ AND PRINT
                                  REACH IDENTIFICATION DATA/
    [(SEE OATA
       FORM 4)
[       OATA TYPE 3
     READ AND PRINT
   TARGET LEVEL 0.0. AND
 FUJU AUGMENTATION OATA
   I  (SEE OATA
   [_   FORKS)
f       DATA TYPE 4
     KM AND PRINT
 ELEMENT DESCRIPTION DATA ]
FIGURE  VI-12.   FLOW CHART  FOR  SU3PCUTINE INDATA
                                 1C8

-------
             (SEE  DATA
              FORM 6 &  6A)

             (SEE DATA
               FORK 7)
           DATA TYPE S
          READ AND PRINT
          HYDRAULIC DATA
           DATA TYPE 6
          READ AND PRINT
        OEOXYGENATION AND
     REAERATION COEFFICIENTS
            (SEE DATA
              FORMS)
             (SEE OATA
               FORM 1Z)
          OATA TYPE 6A
         READ AND PRINT
        ALGAE. NITROGEN, AND
      PHOSPHOROUS COEFFICIENTS/
1 (SEE OATA
1 FORM 9 )
I

                                           /      DATA TYPE 68
                                           I    READ AND PRINT
                                            BENTHOS. COLIFORM. AND
                                           RAOIO-NUCUDE COEFFICIEN
| (SEE OATA
1 FORM 10)
1

                                                  OATA TYPE 7
                                                READ ADO PRINT
                                              INITIAL CONDITIONS
| (SEE OATA
I FORM 11)
/

                                                 DATA TYPE  7A
                                                READ AND PRINT
                                               INITIAL CONDITIONS
                                                  (CONTINUED)
          NDATA TYPE 3
          READ AND PRINT
     JUANTITY AND QUALITY OF
       INCREMENTAL RUNOFF
FIGURE  VT--2  tConfi-
             V
FLOW  CHART  ?CR SUBROUTINE  INDATA

-------
'(SEE DATA
  FORM 13)
      DATA TYPE 8A
      READ AND PRINT
  QUALITY OF INCREMENTAL
    RUNOFF (CONTINUED)
r(SEE DATA
  FORM 14)
       DATA TYPE 9
      READ AND PRINT
      STREAM JUNCTION
   IDENTIFICATION DATA
 (SEE DATA
  FORM IS)
       DATA TYPE 10
      READ AND PRINT
   QUANTITY AND QUALITY
   OF  HEADWATER INFLOWS
^(SEE DATA
  FORM 16)
      DATA TYPE TOA
      READ WO PRINT
 ADDITIONAL QUALITY LEVELS j
   OF HEADWATER INFLOWS
r(SEE DATA
  F0i« 17)
       DATA TYPE 11
      READ AND PRINT
   QUANTITY AND QUALITY OF
     WASTE INPUTS OR
       WITHDRAWALS

 (SEE DATA
  FORM 18)
      DATA TYPE 11A
      READ AND PRINT
/ADDITIONAL QUALITY LEVELS ,
     OF WASTE INPUTS
      OR WITHDRAWALS
                                                                         PRINT ERROR
                                                                           MESSAGE
                                                                            STOP
 r!5URi VI-12  (Continued.
         PLOW  CHART  "OR SUBROUTINE  INCA7A

-------
1.
2.
3.
4.
S.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
42.
43.
44.
45.
46.
47.
48.
49.
50.
51.
52.
53.
54.
55.
56.
57.
S3.
59.
60.
61.
62.
63.
*4.
65.
66.
67.
9S.

C
C
C
C
C
C
C
C
















C
C











C
C


C
C

C
C

C
C

C
C

C

C




C
C
C
C



             SUBROUTINE INOATACILI6T, IRPT1 / UUGQP,TMAX,NCEH-S)
                                     THIS SUBROUTINE READS IN ALL DATA
                                     REQUIRED FOR THE OPERATION OF THE
                                     MODEL EXCEPT THE CL1MAIOLOGICAL
                                     DATA FOR TEMPERATURE SIMULATION.
             COMMON IITLE(20,20),RCHID(75,S),RMTHOR(75),RMIEOR(75),NHHNAR(1S),
            t       TARGOO(75),IAUGOR(75,6),NCELRH(75),IFLAG(7S,20),
            »       ICLORO(75,20),COEFQV(75),EXPOQV(75),COEFQH(75),EXPOOH(75),
            I       CMANN(75),CM(75),CK3(75),K20PT(75),CK2(75),CO£QK2(75),
            >       EXPQK2(75),T1NIT(75),OOINIT(75)>80INIT(75),COINIT(75,3),
            >       QI(75),TI(75),DOJ(75),BOD1(75),COJ*SI(75,3),JUNCID(15,5),
            >       JUNC(1S,3),HMTRIO(1S,5),HWFLOW(15),HWT£MP(15),HHDO<15),
            >       HH800(1S),HNCONS(15,3),HASTID(9U,5),TRFACT(90),WSFLOW(90),
            >       »STEMP(90),«ISDO(90),aS800(90),W$COhS(90,3),Q.ATOT<15),
            »       A(500),8(500),C(500),0(15),5(500),Z(500),W(500),GC500),
            »       FLO«(500),DEPTH(500),VEL(500),DTOVCL(500),K2(500),M(500),
            >       HSNET(500),OL(500),VHrt(15),DEPHW(15),OLH^(15),T(500),
            •       00(500),800(500),COMS(500,3),PTIHE,TPRIMT,OELX,
            I       NHWTRS,NREACH,NMASTE,NJUNC>DELT,D1LT,02LT,DTOOX2,OT20DX,
            '       LAT,LSM,LLM,ELEV,DAI,AE,BE,DAYOFi,DRY3La,^ETBL8,DEMPT,
            i       ATMPR,WIND,CLOUD,SONET,NI,NJ,TRLCD,TOFDA*,NT,HC,TIME,NCS


             COMMON/MODIF/ CK4(75),CK5(75),CKNH3(75),CKN02(75),CKN03(75),
                    CXN/CXP,CKL,ALPHAO(75)(ALPHA1,ALPHA2,ALPHA3,ALPHA4,
                    ALPHAS,ALPHAS,GROMAX,RESPRT,ALGSET(75),SPHOS(75),
                    SNH3(75)>KNH3(500),KN02(500),R£SPRR(500),COLI(500),
                    ALGAE(500),PHOSC500),CNH3(500),CN02(500),CN03(500),
                    COLiR(75),ALGI(75),PHOSI(75),CNH31(75),CN02I(75),
                    CN03I(75),COLIIT(75),ALGIT(75),PHOSIT(75),CNH3IT(75),
                    CN02II(75)>CN03IT(75)>MSCOLI(90),WSALG(90),W5PHOS(90)I
                    MSMH3(90),HSN02(90)>MSN03(90)>HMCOLI(15),HMALG(1S),
                    HKPHOS(15),HWNH3(15),HWN02(15),HHN03(15),GROWTH(500),
                    MOOOPT(10),IRCHNO(750),EXCOEF(75)


             COMMON/RAOION/. CX6(75),RADNIT(75),RADNI(75),HHRADN(15),WSRADN(90),
            »                RADIO(SOO)
             COMMON/S5TATE/1 X(500),ISS


             COMMON/COATA/SS1(75),552(75),*IDTH(75),SLOPE(75),ITRAP


             COMMOM/METER/METRIC,MEIOUT


             DIMENSION  DATA(9i,25),CODE(i4),CaDE2(6)

             REAL K1,K2,LAT,LLM,LSM,JUNCID

             DATA ENDT/4HENOT/  ,  ENOA/4HENDA/ ,  rES/4H YES/
             DATA CODE/4HHS1,4HWRIT,4HFU>*,4HSTEA,4HTRAP,4HIN(»U,4HHUMB,
            *          4HNUN ,4HTI«E,4HMAXl,4HLATI,4HSTAN,4HEVAP,4HELEy/
             DATA CODE2/4HO UP,4HO PR,4HN CO,4HALG ,4Ht* HA,4HLIGH/
                                               STEP 1-0
                                               INITIALIZE CERTAIN PARAMETERS
73.
     00 999 1*1,500
     ALGAE(I)»0.
     RESPRR(I)«0.
     GKOi0.
999 CONTINUE

-------
71.
72.
73.
74.
75.
76.
77.
78.
79.
80.
81.
82.
83.
84.
85.
86.
87.
88.
89.
90.
91.
92.
93.
94.
95.
96.
97.
98.
99.
100.
101.
102.
103.
104.
105.
106.
107.
108.
109.
110.
111.
112.
113.
114.
115.
116.
117.
118.
119.
120.
121.
122.
123.
124.
125.
126.
127.
128.
129.
130.
131.
132.
133.
134.
135.
136.
137.
138.
139.
1*3.
00 1000 I«l,250
1000 IRCHNO.(1)*0
ITRAPaO
ILISTaQ
IRPTlaO
IAUGOP »0
XSS30
LAT»0.0
LLMsO.O
LSM*0.0
DAXOFXaO.O
AEaO.O
BEao.o
ELEVsO.O
OATsO.O
NERRORaO
TIMEaO.O
TPRIHTaO.O
TOFDAX=0.0
TRLCO=0.0
CKLsO.O
MEIKICaO
HETOUTaO
NI=5
NJ=6
C.
c
C
c
00 30 1=1,16
READ (NX, 31) (IITLECI.,J)
31 FORMAT (20A4)
IF CtITI<£(l»l)-CMOI) 30,
30 CONTINUE
NERROR=1
34 1=1*1
READ (NI,31) (TITLE(I,J)


























STEP 2-0
READ IN TITLES


,J»1,20)

35,30

•

,J=1,20)
If (IlTUE(I,U-eNOT)34, 39,34
39 N>I-16
WRITE (NJ,32) M
32 FORMAT UHO,5X*16H****«
GO TO 33
35 IF CI.GE.16) GO: TO 33
MERRORal
N316-I
WRITE (NJ,36) H
J6 FORMAT (1HO,5X,15H****«
33 CONTINUE
NTITUE3I
C
C
c.
C
oo 1700 i«:,9
1700 MODOPT(I)aO
ir(TITLE(3,3) .CQ. Y£S)
DO 1710 1*6,9
IFaiTUE(I,3) .EQ. XC3)
1710 CONTINUE
IF(TITL£UO,3) .EQ. YES)
DO 1720 I»13,15
IF(TITLE(I,3)- ,EQ. YES?
1720 COHTIMUE
C
C
c:
c.
HCSaQ
ir(MOOOPTd) .LT. 1J GO.
NCS«1


TOOj MANX (,I3,18H) TITLE. CARDS READ)





TOO FEM (,I3,18H) TITLE. CARDS READ)


STEP 2-1
SET PARAMETER LIST TO BE 3IMULAT
INTO MODEL OPTION ARRAY (MODOPT)



MOD0PTU)*!

MODOPT(I-4>*1

MODOPT(6)«l

MOOOPTCI-*)-!

STEP 2-2
SET NCS (KUM9SR OF- CONSSRYATXVE
CONSTITUENTS


TO 1730

i32

-------
 141.
 142.
 143.
 144.
 145.
 146.
 147.
 149.
 149.
 ISO.
 151.
 152.
 153.
 1S4.
 155.
 156.
 157.
 158.
 159.
 160.
 161.
 162.
 163.
 164.
 165.
 166.
 167.
 168.
 U9.
 170.
 171.
 172.
 173.
 174.
 175.
 176.
 177.
 178.
 179.
 180.
 181.
 132.
 183.
 184.
 18S.
 136.
 187.
 198.
 189.
 190.
 191.
 192.
 193.
 194.
 195.
 196.
 197.
 198.
 199.
 20Q.
 201.
 202.
 203.
 204.
 205.
206.
207.
203.
209.
210.
 1730
   IF(IITLE(4,3) .CO. YES) NCS»2
   IF(TITL£(S,3) ,CQ. YES) HC3»3
   CONTINUE
C
C
C
C
C
C
C
C
                                     STEP 3-0
                                     READ IN ALL DATA REQUIRED FOR OP
                                     OF THE MODELS.

                                     STEP 3-1
                                     READ IN DATA TXPE 1 (MODEL COHTR
   21

   20

   24
   IDATAsO
   IF(MODOPT(4) .GT. 0) IDATAsl
   IF(MOOOPT(5) .GT. 0) IDATAsl
   IF(MOOOPT(6) .GT. 0) IOATA»1
   IF(MODOPT(8) .GT. 0) lOATAal
   IF(MODOPT(9) .GT. 0) IDATA'l
   NCROS«15
   DO 20 I=1,NCROS
   READ (NI,21) IDATAU,X),K=1,1&)
   FORMAT <6A4,A1,F10.0,10X.6A4,A1,F10.0)
   IF (OATA(I,1)-CNDA)20,25,20
   CONTINUE
   NERRORal
      READ (HI, 21)  (DATAU,K),K=l,i&)
      IF (DATACI,1)-£)IOA)24,29,24
      N=I-NCROS
      WRITE (NJ,22)  N
29

22 FORMAT (1HO, 5X, 16H***«* TOO MANX C,I3,18H) DATA! CARDS READ)

25
      GO TO 23
      IF (I.GE.NCROS)  GO TO 23
      IFCMODOPTC2))  1920,1920,1930
                FE3' 1980 REVISIONS NO.  9
 1920 IFCI.EQ.IDGO TO 23
 1930 NERROR'l
      N>NCROS-I
      MBITE (NJ.26)  N
   26 FORMAT (1H0.5X, 15H»**»* TOO FEW (,I3,18H)  DATA1  CARDS READ)
   23 CONTINUE
      NCROS*I
      DO 16  I>1,N
      DO 16  J»l,14
      IF (DATA(I,l)-CODE(g))  16,2,16
    2  GO TO  (3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, IS, 18), J
    3  ILIST  * 1
      CO TO  16
      GO TO 16
    5  IAUGOP a  1
      GO TO 16
    «  ISS * 2
      GO TO 16
    7  ITRAP«l
      GO TO 16
    8  M£TRICaOATA(I,8)
      METOUTsDATA(I,16)
      GO TO 16
    9  NREACH >  DATA(I,8)
      NJUNC * DATAU,16)
      GO TO 16
   10  NHHTPS >  DAIA(I,8)
      NWASIE *  DATA(I,16)
      GO TO 16
   11  D£LT  < DATA(I,8)
      DELX  a OATAU, 16)

-------
211.          GO TO 16
212.       12 TMAX a DATA(I,8)
213.          PTIME = DATAU.16)
214.          CO TO 16
21S.       13 (.AT = DATAU.8)
216.          LLM s DATA(I,16)
217.          GO TO 16
213.       14 LSM > DATA(I,8)
219.          DAYOFY * DAIA(I,16)
220.          GO TO 16
221.       IS AE * OATA(I,B)
222.          8E > OATAQ,16)
223.          GO TO 16
224.       18 ELEY*DATA(I,8)
225.          DATsOAIA(I,16)
226.       16 CONTINUE
227.          IF(NREACH-75) 610,610,620                                >
223.      620 HRITECNJ,515)  NREACH
229.      SIS FORMATUHO,5X,'*****',15,'REACHES EXCEED THE DIMENSIONS',
230.         *      ' OF 75')
231.          NERROR=1
232.      610 CONTINUE
233.          IF(NWAST£-75) 630,630,640
2J4.      640 WRIT£(NJ,516)  NWASTE
235.      516 FORMAT(1HO,SX,'*****',15,'WASTE LOADS EXCEED THE PROGRAM'
236.         *,.    ' DIMENSIONS OF 75')
237.          NERROR=1
233.      630 CONTINUE
239.          IF ULIST.EQ.O) GO TO 200
240.          WRITE (NJ,501)
241.      501 FORMAT(1H1,35X,31HWATER RESOURCES ENGINEERS, INC.,
242.         *//26X,16H* * * DATA LIST ,
243.         * 35H STREAM QUALITY ROUTING MODEL * * V32X.
244.         *34H* * * QUAL-II/SEMCOG VERSION »**,/)
245.          WRITE (NJ,502)
246.      502 FORMAT UHO,10X,24H$SS (PROBLEM TITLES) $$$,/)
247.          WRITE (NJ,201)
243.      201 FORMAT (10X,9HCARD IYPE,29X,22HQUAL-II PROGRAM TITLES)
249.          WRITE (NJ,503) ( (TITLE.CI, J) , J»l ,20) ,I»1 ,NTITLE)
250.      503 FORMAT (10X,20A4)
251.          WRITE (NJ.504)
252.      504 FORMAT (1HO,10X,34HSSS DATA TYPE 1 (CONTROL DATAJ SSI,/)
253.          WRITE (NJ,203)
254.      203 FORMAT UOX,9HCARD TYPE,36X,9HCARD TYPE)
255.          WRITE (NJ,103) C CDATAU, J),J^«1,16) ,1»1,NCRDS)
256.      103 FORMAT (2C10X,6A4,Al.F10.S))
257.      200 CONTINUE
258.          IF(MEIRIC.EQ.O) GO TO 199
259.          DELXaDELX/1.609
260.          IF(MOOOPT(2).EQ.O) 50 TO 199
261.          AE=3.2808*AE*(1000./29.9)
262.          BE«3.2308*BE*(1000./29.9)*(1609./3600.)
263.          £LEV»3.2808»ELEV
264.      199 CONTINUE
265.    C
266.    C                                       STEP 3-iA
267.    C                                       READ IN DATA TYPE U (ALGAE PROD
263.    C.                                       AND KITROGSN OXIDATION CONSTANTS
269.    C.
270.          DO 1003 131,7
271.          READ (HI, 1001) (DATAU, J) , J»l,18)
272.     1001 FORMAT (8A4,F7.0,2X,8A4,F7.0)
273.          IF (OAIA(I,1)-ENDA) 1003,1021,1003
274.     1003 CONTINUE
275.          NERROR*!
27$.     1005 1*1+1
277.          READ (NX,1001) (DATAU ,J),J=l,l8)
2"?3.          IT (OATA(I,1)-ENDA) 1005,1007,1005
27J.     1007 N»I-7
23Q.          VRITS (HJ.1020) N
                                       134

-------
 281.      1020 FORMAT  (1HO,5X,16H*»*«* TOO MANY  (,I3,20H) DATA IA CARDS READ)
 282.          GO TO 1004
 283.      1021 If (I.CE.7) GO TO 1004
 284.          IF(IDATA) 1024,1024,1025
 285.      1024 NCROS»1
 286.          GO TO 1026
 287.      1025 NERRORsl
 288.          Ns7-I
 289.          WRITE (NJ.1022) N
 29Q.      1022 FORMAT  UH0.5X,15H»*»<» TOO FEW (,I3,20H) DATA U CARDS READ)
 291.      1004 CONTINUE
 292.          Nsl-l
 293.          NCROSsI
 294.          DO 1006 1=1,N
 295.          DO 1006 J=l,6
 296.          IF(DATA(I,1)-COD£2(J))1006,1008,1006
 297.      1008 GO TO (1009,1010,1011,1012,1013,1014), J
 298.      1009 ALPHA5=DATAII,9)
 299.          ALPHA6=OATA(I,18)
 300.          GO TO 1006
 301.      1010 ALPHA3»DATA(I,9)
 302.          ALPHA4»OATA(I,18)
 303.          GO TO 1006
 304.      1011 ACPHAlsDATA(I.,9)
 305.          ALPHA2»OATA(I,18)
 306.          GO TO 1006
 307.      1012 GROMAX=DATA(I,9)
 308.          RESPRTsOATAU,18)
 309.          GO TO 1006
 310.      1013 CKN=DATA(I,9)
 311.          CKPsOATA(I,18)
 312.          GO TO 1006
 313.      1014 CKL=DATA(I,9)
 314.          SONET=DATA(I,18)
 315.      1006 CONTINUE
 316.      1026 IF (HIST .EQ. 0) GO TO. 1015
 317.          WRITE (NO,1016)
 318.      1016 FORMAT  (1HO,10X,67HSS* DATA TYPE  1A (ALGAE PRODUCTION AND NITROGEN
 319.         * OXIDATION CONSTANTS ,5H) $$«,/)
 320.          WRITE (NJ,1017)
 321.      1017 FORMAT  (10X,9HCARO TYPE,43X,9HCARD TYPE)
 322.          WRITS (NJ,1018) ((DAIA(I,J.),J»1,18),I»1,NCRDS)
 323.      1018 FORMAT(2UOX,8A4,F10.4))
 324.      1015 CONTINUE
 325.    C
 326.    C                                       STEP 3-2
 327.    C                                       READ IN DATA TYPE 2 (REACH IDENT
328.    C                                       RIVER MILE AT HEAD AND END OF RE
329.    C
 330.          II * NREACH+1
 331.          DO SO 1=1,11
 332.          READ (HI,51) (DATAd, J), J*l, 13)
 333.       51 FORMAT (3A4,3X,F5.0,5A4,3X,A4,3X,F10.0,4X,A2,4X,F10.0)
 334.          IF (DATAd, 1)-£NDA)  50,55,50
 335.       SO CONTINUE
 336.          NERROR'l
 337.       54 I»I*1
 338.          READ (NI,S1) (DATAd, J) ,J«1 ,13)
 339.          IF (OATA(I,1)-ENDA)  54,59,54
340.       59 NsI-II
341.          WRITE (NJ,52)  N
342.       52 FORMAT (1HO,5X,16H***«*  TOO MANY  (,I3,18H) DATA2 CARDS READ)
343.          GO TO 53
344.       55 IF (I.GE.II) GO' TO 53
345.          NERROR • 1
 346.          NsII-I
 347.          4RITE (NJ,56)  N
 348.       56 FORMAT UHO,5X,15H*»**«  TOO FEW (,I3,18H) DAXA2 CARDS READ)
 ^49.       53 C3NTI.1UE
350.

-------
351.          IMAXsO
352.          00 1050 I=1,HREACH
353.          IRCH»IFIX(DATACI,4)*10.t0.0001)
354.          IRCHNO.(IRCH)sl
355.          IMAX*MAXO(IMAX.IRCH)
356.     1050 CONTINUE
357.          IOROER=0
358.          00 1055 IRCH*i,IMAX
359.          If (IRCHNO(IRCH)) 1055,1055,1052
360.     1052 IORDERsIORDER+1
361.          IRCHNO.(IRCH)slORDER
302.     1055 CONTINUE
363.          00 57 l=l,NREACH
364.          IRCHsIFIX(OATA(I,4)*10,+0.0001)
365.          NRCHslRCHNO(IRCH)
366.          00 53 J=5,9
367.          K * J-4
368.          RCHIO(NRCH.K) * DATA(I,J)
369.       58 CONTINUE
370.          RMTHOR(NHCH) = DATA(I,11)
371,          RMTEORCNRCH) s OATA(I,13)
372.          IF(METRIC.NE.1)GO TO 57
373.           RMTHOJUNRCH)sRMTHOR(NRCH)/1.609
374.           RMTEOJUNRCH)sRMTEOR(HRCH)/1.609
375.       57 CONTINUE
376.          IF UtaST.EQ.O) GO TO 425
377.          WRITE (NJ.505)
373.      505 FORMAT UHO,10X,42HSS5 DATA TYPE 2 (REACH IDENTIFICATION) SSS,/)
379.          WRITE (NJ,205)
380.      205 FORMAT (10X,9HCARO TYPE,11X,21HREACH ORDER AND IOENT,
391.         *        15X,8HR, MI/KH,12X,3HR, MI/KM)
382.          WRITE (NJ,401) CIFIX(DAIA(I,6)*10.t0.0001)
415.          NRCHsIRCHNO(IRCH)
416.          NHMAR a DATA(I,7)
417.          NHriWAR(NRCH) s NHWAH
413.          TARGDD.(NRCH)=OAJA(I,3>
419.          DO 68
420.          K a J-8
                                         136

-------
421.
422.
423.
424.
425.
426.
427.
423.
429.
4JO.
431.
432.
433.
434.
435.
436.
437.
438.
439.
440.
441.
442.
443.
444.
445.
446.
447.
443.
449.
450.
451.
452.
453.
454.
455.
456.
457.
458.
459.
460.
461.
.462.
463.
464.
465.
466.
467.
468.
469.
470.
471.
472.
473.
474.
475.
476.
477.
478.
479.
480.
481.
482.
483.
484.
485.
486.
487.
408.
489.
490.

68
67
8625

506
<

206
*

402
426
C
c
C
c
c
c
c
c
c
c
c
c
V
c
c
c
c
c
c
1
I
71 1

70 1
1
74 ;
1
4
79 1
1
72 1
(
75 :
!
!
1
73 (
76 1
1
I
]
1
?
(
C
t
I
78 C
77 C
]
>
507 !
*
't
207 f
*
r
     lAUGOR(NRCH.K)  « DATA(I,J)
  68 CONTINUE
  67 CONTINUE
8625 If (IL1ST.EQ.O)  CO TO 426
     WRITE CNJ,506)
 506 FORMAT ( 1HO , 10X, 36HSSS DATA TYPE 3  (TARGET LEVEL DO AND,
                     31H FLO* AUGMENTATION SOURCES)  SSS,/)
     WRITE (NJ.206)
 206 FORMA: (iox,9HCARD TYP£,i8x,24HR£ACH   AVAIL HOWS TARGET,
              5X.22HORDER OF AVAIL SOURCES)
     WRITE (NJ.402)  CCDAIA(I,J),J=1,14),I=1,NCRDS)
 402 FORMAT ( 10X,5A4.5X,F5.0,5X,FS.O,F10.1 ,6F5.0)
STEP 3-4
READ IN DATA TYPE 4 (COMPUTATION
ELEMENT FLAG FIELD)
    1  *  ELEMENT WHICH REPRESS*
          HEADWATER SOURCE.
    2  >  AN ELEMENT WITH NO EXT
          INPUTS OTHER THAN INCR
    3  *  AN ELEMENT ON THE MAIN
          IMMEDIATELY UPSTREAM F
          JUNCTION.
    4  s  AN ELEMENT WHICH REPRE
          A STREAM JUNCTION.
    5  s  Art ELEMENT WHICH REPRE
          THE LAST COMPUTATIONAL
          IN THE SYSTEM.
          AN ELEMENT WITH A MAST
          AN ELEMENT WITH A WITH
                                          6
                                          7

    DO 70 1=1,11
    READ (NI,71)  (DATA(I,J),J*i,25)
    FORMAT  <2A4,A2,5X,FS.O,5X,F5.0,10X,20F2.0)
    IF. (DATAU,1)-ENOA) 70,75,70
    CONTINUE
    NERRORsl
    I>1+1
    READ CMI, 71)  (DATA(I,J),J=1,25)
    IF (DATA(I,1)-ENDA) 74,79,74
    N*I-II
    WRITE (NJ,72) N
    FORMAT  (1HO,5X,16H»***» TOO MANY  (,I3,13H) DATA4 CARDS READ)
    GO TO 73
    IF (I.GE.II)  GO TO 73
    NERROR  * 1
    NsII-1
    WRITE (NJ,76) N
    CONTINUE
    FORMAT  (1HO,5X,15H*«*»* TOO FEW (,13,18H) OATA4 CARDS READ)
    NCROS=I
    DO 77 I*1,NREACH
    IRCHsIFlX(DATA(I, 4) *10. +0.0001)
    NRCHalRCHNO(IRCH)
    NCELR s DATAU.5)
    NCELRH(NRCH)*NCELR
    00 78 J»6,25
    K « J-5
    IFLAG(NRCH,K)«DATA(I,J)
    CONTINUE
    CONTINUE
    IF (ILIST.EQ.O) GO TO 427
    WRITE (NJ,S07)
    FORMAT  UHO,10X,36HSS* DATA TYPE  4 (COMPUTATIONAL REACH,
                    16H FLAG FIELD) $«$,/)
    WRITS (NJ,207)
    FORMAT  UOX,9HCARD TYPE, 8X,20HREACH ELEMENTS/REACH,
            13X,19HCOMPUTATIONAL FLAGS)
    WRITE (NJ.403) ((DATA(I,J),Jal,2S),I«l,NCRDS)

-------
491.      403 FORMAT (10X,2A4,A2,5X,FS.O,5X,F5.0,10X,20F2.0)
492.      427 CONTINUE
493.          IOR=0
494.          00 28 lal,NREACH
49S.          NCELRxNCELRH(I)
496.          00 28 J»l,NCELR
497.          IOR*IOR+l
498.          ICLORO(I,J)«IOR
499.       28 CONTINUE
500.          IFUOR-500)  650,650,660
SOI.      660 HRITE(NJ,517)  IOR
502.      517 FORMAI(1HO,5X,•»**»**,IS,'COMPUTATIONAL ELEMENTS EXECEED THE.',
503.         *      ' PROGRAM DIMENSIONS OF 500')
504.          NERRORd
505.      650 CONTINUE
506.          NCELLSsIOR
507.    C
508.    C                                       STEP 3-5
509.    C                                       READ IN DATA TYPE 5 (HYDRAULIC C
510.    C-                                       FOR COMPUTING. VELOCITY AND DEPTH
511.    C
512.          00 80 1*1,11
513.          READ (NI,81) (OATACI,J),0=1,9)
514.       81 FORMAT (2A4,A2,5X,F5.0,10X,5FIO.O)
515.          IF (DATA(I,1)-ENDA) 80,85,80
516.       80 CONTINUE
517.          NERROR * 1
518.       84 1=1+1
519.          READ CNI.81) (DATACI,J),J»l,9)
520.          IF COATA(I,n-£NDA) 84,89,34
521.       89 NsI-II
522.          WRITE (NJ,82) N
523.       82 FORMAT (1HO,5X,16H***«* TOO MANY (,I3,18H) DATA5 CARDS READ)
524.          GO TO 83
525.       85 IF U.GE.II) GO TO 83
526.          NERROR * 1
527.          NsII-I
528.          WRITE (NJ,86) N
529.       86 FORMAT (1HO,5X,1SH***«* TOO FEW (,I3,18H) DATAS CARDS READ)
530.       83 CONTINUE
531.          NCRDS*!
532.          DO 87 I=I,NREA:H
533.          lRCHsiFIXCOATAU,4)*10.tO.OOOi)
534.          NRCHsIRCHNO(IRCH)
535.          IF(ITRAP.EQ.l) GO TO 183
536.          COEFQV(NRCH) * DATACI.5)
537.          EXPOQV(NRCH) a DATA(I,6)
538.          COEFQH(NRCH) s DATA U* 7)
539.          EXPOQHCNRCH) « OATA{I,8)
540.          CMAN»(NRCH) a DATA(I,9)
541.          GO TO 184
542.      183 SS1(NRCH)3DATA(I,5)
543.          SS2CNRCH)*OATA(I,6)
544.          WIOTH(NRCH)soATA(I,7)
545.          SLOPE(NRCH)sOATA(I,a)
546.          CMANN(NRCH)>OAIA(I,9)
547.      184 CONTINUE
548.    C +» + ** + + FE3' 1980 REVISIONS MO. 10
549.          IF(CMANN(NRCH).LE.O.,)CMANN(NRCH)»0.020
550.    C*t+++++
551.          IFCMETRIC.EQ.O)GO TO 87
552.          CVXX*3.2808/35.3133**EXPOQV(NRCH)
553.          COEFQV(NRCH)«CDEFQV(HRCH)«C.VXX
554.          CVXX«3.2808/35.3133»«EXPOQH(NRCH)
555.          CO£FQH(NRCH)*COEFQHCNRCH)*CVXX
556.       87 CONTINUE
557.    C * * + » + FES 1980 REVISIONS NO. 11
558.    t » * * + + (DELETION OF HUES)
559.       88 IF (ILIST.EQ.O) GO TO' 428
569.          WRITE (NJ.508)
                                         138

-------
 561.      508 FORMAT (1HO,10X,31HSSI DATA TYPE 5 (HYDRAULIC DATA,
 562.         *                40H FOR DETERMINING. VELOCITY AND DEPTH) «SS,/)
 563.          IFUTRAP.CQ.O ) WRITE(HJ,208)
 564.          IFdIRAP.NE.O )MRIIECNJ,1293)
 565.      1208 FORMAI(10X,9HCARD TYPE.8X,5HREACH,13X,16H  SSI       SS2 ,
 566.         *  .       4X,2SH«IDTH     SLOPE     CMANN)
 567.      208 FORMAT (10X,9HCARO TYPE,8X,5HREACH,13X,16HCOEFQV    EXPOQV,
 568.         *         4X,25HCOEFQH   EXPQQH     CMANN)
 569.          WRITE (NJ,404) ((DATAU,J),J=l, 9),1=1.NCRDS)
 570.      404 FORMAT (10X,2A4,A2,5X,FS.O,10X,5F10.3)
 571.      428 CONTINUE
 572.    C
 573.    C                                       STEP 3-6
 574.    C                                       READ IN DATA TYPE 6 (REACTION CO
 575.    C                                       DEOXYGENATION AND REAERATION).
 576.    C
 577.          DO 90 1=1,11
 578.          READ (HI,91) (DATAU, J) , J=l, 10)
 579.       91 FORMAT (2A4,A2,5X,F5.0,6F10 .0)
 580.          IF (DATAU,D-ENDA) 90,95,90
 581.       90 CONTINUE
 582.          NERROR = 1
 583.       94 1=1+1
 584.          READ (NI,91) (DATA(1,J),J=l,10)
 585.          IF (DATA(I,1)-£NDA) 94,99,94
 586.       99 Mal-II
 587.          WRITE (NJ,92) N
 588.       92 FORMAT (1H0.5X,16H***** TOO MANY (,I3,18H) DATAfi CARDS READ)
 589.          GO TO 93
 590.       95 IF (I.GE.II) GO TO 93
 591.          NERROR = 1
 592.          N=II-I
 593.          WRITE (NJ,96) N
 594.       96 FORMAT (1H0.5X,15H****» TOO FEW (,I3,13H) DATA6 CARDS READ)
 595.       93 CONTINUE
 596.          NCRDS=I
 597.          DO 97 I»1,NREACH
 598.          IRCHsIFIX(DATA(I,4)*10.+0.0001)
 599.          NRCHalRCHNO(lRCH)
 600.          CKl(MRCH) a OATA(I,5)
 601.          CK3(NRCH) = DATA(I,6)
 602.          K20PT(NRCH) * DATA(I,7)
 603.          CK2(NRCH) = DATA(I,8)
 604.          COEQK2(NRCH) * DATA(I49)
 605.          EXPQK2CNRCH) = DATA(I,10)
 606.          IF(METRIC.EQ.O) GO TO 97
 607.          IF(K20PT(NRCH).E0.7) COZQK2(NRCH)=COEQK2(NRCH)*(1.0/35.3133)**EXPQK2(NRCH)
 608.          IF(K20PT(NRCH).E0.8) CO£QK2(NRCH)*COEQK2(NRCH)/3.2808
 609.       97 CONTINUE
 610.          IF (ILIST.EQ.O) GO TO 429
 611.          WRITE (NJ.509)
 612.      509 FORMAT (1HO,10X,38HSS* DATA TYPE 6 (REACTION COEFFICIENTS,
 613.         *                38H FOR DEOXYGENATION AND REAERATION) JSS,/)
 614.          WRITE (NJ,209)
 615.      209 FORMAT (10X.9HCARD TYPE,8X,12HREACH     Kl,3X,2HK3,8X,5HK20PT,
 616.         *         5X,26HK2     COEQK2, OR  EXPQK2,,/,
 617.         *        74X,20HTSIV COEF   OR SLOPE,/,
618.         *        74X.21HFOR OPT 3   FOR OPT 8)
619.          IF((DATA(I,10)*1000.).GT.10.) GO TO 98
620.          WRITE (NJ,411) ( (DAIAU, J) , J«l , 10) ,I»1 ,NCROS)
621.      411 FORMAT (10X,2A4,A2,5X,F5.0,2F10.2,F10.0,Fl0.2,F10.3,5X,F10.5)
622.          GO TO 429
623.       98 WRITE (Nj,405) CCOATAU,J),J=l,10),1=1,NCRDS)
624.      405 FORMAT (10X,2A4,A2,5X,F5.0,2F10.2,FIO.O,F10.2,2F10.3)
625.      429 CONTINUE
626.    C
627.    C                                        STEP 3-6A
623.    C                                        READ IN DATA TYPE 6A (ALGAE, MIT
•>29.    C                                        AND PHOSPHORUS COEF.)
6JO.    C

-------
631.
632.
633.
634.
63S.
636.
637.
633.
639.
640.
641.
642.
643.
644.
645.
646.
647.
649.
649.
650.
651.
652.
653.
654.
655.
656.
657.
658.
659.
660.
661.
662.
663.
664.
665.
666.
667.
668.
669.
670.
671.
672.
673.
674.
675.
676.
677.
678.
679.
680.
681.
682.
683.
684.
685.
686.
687.
688.
689.
690.
691.
692.
693.
694.
695.
696.
697.
698.
69?.
703.
     DO 1100 I*i,U
     READ(NI,1101) (DATA(I,J),Jsi,12)
1101 FORMAI(5A4,5X,FS.O,2X,6F8.0)
     IF CDATACI,l)-E!tDA) 1100,1105,1100
1100 CONTINUE
     NERROR=1
1104 I=ltl
     READ(NI,110l) (DATAU,J),Jsl,12)
     IF (OATAU,1)-£NDA) 1104, 1109, 1104
1109 N=I-II
     WRITE (NJ,1102> N
1102 FORMAT ( 1HO,5X, 16H**»»* TOO MANY (,I3,19H) DATA6A CARDS READ)
     GO TO 1103
1105 IFCl.GE.Ii) GO TO U03
     IF(IDATA) 1120,1120,1130
1120 NCRDS=1
     GO TO 1140
1130 NEHRORsl
     NsII-I
     HRITE (NJ,1106) N
1106 FORMAT ( 1HO,5X, 15H<**«* TOO FEW (,I3,19H) OATA6A. CARDS READ)
1103 CONTINUE:
     NCRDS=I
     DO 1107 Jsi, BREACH
     IRCH=IFIX(DATAU,6)»10.+0.0001)
     NRCHsIRCHNOURCH)
     ALPHAO.(NRCH)=OATA(I,7)
     ALGSET(NRCH)sOATAU,3)
     CXNH3(NRCH)=DATAU,9)
     CKN02(NRCH)sDATA(I,10)
     SNH3(NRCH)sDATAU,ll)
     SPHOS(NRCH)»OATA(I,12)
     IF (METRIC. EO.O)  GO TO 1107
      A{.GSeT(NRCH)s3.2808*ALGSET(NRCH)
     SNH3(NRCH)sSNH3(NRCH)/3.2808
     SPHOSCNRCH)=SPHOS(NRCH)/3.2B08
1107 CONTIMUe
1140 IFdLIST .EQ. 0)  GO TO 1199
     HRIT£(NJ,1110)
1110 FORMAT(1HO,10X,65H S$S DATA TYPE 6A (ALGAE, NITROGEN, AND PHOSPHOR
    SUS CONSTANTS) SSS,/)
     WRITE(NJ,11H)
1111 FORMAT(10X,9HCARD TXPE.17X,6H REACH, 2X,6HALPHAO,3X,6HALGSET,2X,
    *  5HCKNH3,5X,5HCXN02,6X,4HSNH3,6X,4HSP04)
     «RITE(NJ,IU2) C(DATA(I,J), J=l,12), I=1,NCROS)
1112 FORMAT(10X,5A4,2X,F8.0,F8.1,lX,2F8.2,lX,F9.2,2F10.i)
1199 CONTINUE
C
C
C
C
                                       STEP 3-6B
                                       RCAO IN DATA TYPE 68 (OTHER COEF
     00 1200 I»1,II
     READ(NI,1201) (OATA(I,J),Jsl,12)
1201 FORMAT(SA4,5X,F5.0,2X,6F8.0)
     IF (DATA(I,1)-ENDA) 1200,, 1205,1200
1200 CONTINUE
     NERRORal
1204 laltl
     READ(MI,t201) (OATA(I,J),vJ3l,12)
     IF (DATA(I,1)-ENDA) 1204, 1209, 1204
1209 Nal-II
     WRITS (NJ,1202) N
1202 FORMAT (1HO,5X,16H<»*** TOO MANY (,I3,19H) DATA6& CARDS READ)
     GO TO 1203
1205 IFQ.GE.II) 30 TO 1203
     IFUDATA) 1220,1220,1230
1220 NCRDSsI
     GO TO 1250
1230 N£RR3ft«l
                                         140

-------
 701.          WRITE (NJ,1206)  N
 702.     1206 FORMAT UHO,5X, 15H**»»* TOO FEW  (,I3,19H)  DATA6B- CARDS  READ)
 703.     1203 CONTINUE
 704.          NCRDS=I
 705.          00 1207 I=1.NR£ACH
 706.          lRCHsmX(DATA(I,6)»10.+0.0001)
 707.          NRCH*IRCHNOURCH)
 708.          CK4(NRCH)sOATA(I,7)
 709.          CK5(NRCH)=OATA(I,8)
 710.          EXCO£F(NRCH)=OATACI,9)
 711.          CK6(NRCH)=OAIAU,10)
 712.          IF(MEIRIC.EQ.O)  GO TO 1207
 713.          CK4(NRCH)sCK4(NRCH)/3.2808
 714.          EXCOEF(NRCH)*£XCOEF(NRCH)/3.2808
 715.     1207  CONTINUE
 716.     1250  IF(ILIST.EQ.O) GO TO  1299
 717.          WRIT£(NJ,1210)
 718.     1210  FORMAT(1HO,10X,41HS«» DATA  TYPE 68  (OTHER  COEFFICIENTS)  $«$,/)
 719.          WRITE(NJ,1211)
 720.     1211  FORMAT(10X,9HCARD I3fPE,13X,SH REACH,4X,3HCX4,6X,3KCK5•3X.6HEXCQEF,
 721.         *SX,3KCK6)
 722.          WRITE(NJ,1212) ((OATAU.J),  J=l,10), I«1,NCRDS)
 723.     1212  FORMAT(10X,5A4,2X,F9.0,4F9.2)
 724.     1299  CONTINUE
 725.    C
 726.    C                                       STEP 3-7
 727,    C                                       READ IN  DATA TYPE 7 (INITIAL CON
 728.    C
 729.          DO  110  1*1,11.
 730.          READ  (Nl.lll)  (DATACI,J),J=l,12)
 731.      Ill  FORMAT  (5A4,5X,F5.0,F10.0,2F5.0,3F10.0)
 732.          IF  (DATA(I,1)-£NDA) 110,115,110
 733.      110  CONTINUE
 734.          NERRQR*!
 735.      114  IaI+1
 736.          READ  (MI,111)  CDATAU ,J) , J=l, 12)
 737.          IF  (OATA(I,1)-EMDA) 114,119,114
 738.      119  N=I-II
 739.          WRITE  (NJ.112) N
 740.      112  FORMAT  (1HO,5X,16H*»**»  TOO  MANY (,Z3,l8H) DATA7 CARDS READ)
 741.          GO TO  113
 742.       US  IF  (I.GE.II) GO TO 113
 743.           NERROR = 1
 744.           NSII-I
 745.           WRITE  (NJ.116) N
 746.       116  FORMAT  (1H0.5X,15H****«  TOO  FEW (,13,18H)  DATA? CARDS READ)
 747.       113  CONTINUE
 748.           NCRDS=I
 749.           DO 117 I=1,NR£ACH
 750.           IRCHsIFIX(OATACI,6)fl0.t0.0001)
 751.           NRCH«IRCHNO(IRCH)
 752.           TINIT(NRCH) * OATA(I,7)
 753.           IF(METRIC.EQ.l)TINIT(NRCH)>IlNlT(NRCH)*1.8t32.
 754.           DOINIT(NRCH) * DATA(I,8)
 755.           80INITCNRCH) * DATA(I,9)
 756.          COINIT(NRCH,l)aOATA(I,10)
 757.          COINII(NRCH>2)«OATA(I,11)
 758.          COINIT(NRCH,3)«OATA(I,12)
 759.      117 CONTINUE
 760.          IF (ILIST.EQ.O) GO TO 430
 761.          WRITE (NJ,510)
 762.      510 FORMAT C1HO,10X,40H»S» DATA TYPE 7 (INITIAL CONDITIONS)  $SS,/)
 763.          WRITE (NJ.210)
764.      210 FORMAT (10X.9HCARO TYPE,18X,33HREACH    TEMP      0.0.       BOD,
765.         *         6X,26HCM-1      CM-2      CM-3  )
766.          WRITS (NJ,406) ((DATAU,J),Jal,12),I»1,NCRDS)
767.      406 FORMAT (10X,5A4,5X,F6.0,/9.1,5F10.1)
763.      430 CONTINUE
        C

-------
770.    C                                       STEP 3-7A
771.    C                                       READ IN DATA TYPE7A (INITIAL CON
772.    C                                       FOR CHLOROPHYLL,NITROGEN,PHOSPHO
773.    C                                       COLIFOfiM.AND RAOIONUCLIDE)
774.    C
77S.          00 1302 1=1,11
776.          REAO(NI,1301> (DAIAU.J), J»l,12)
777.     1301 FORMAT(3A4,A2,5X,F5.0,7F8.0)
778.          IF (OATA(I,1)-ENDA) 1302,1303,1302
779.     1302 CONTINUE
780.          NERROR*!
781.     1304 1=1+1
782.          READ(NI,1301) (DATAU,J), J=l,12)
783.          IF (DATAU.i)-ENDA) 1304,1305,1304
784.     130S Nal-II
78S.          WRITE (NO,1306) N
786.     1306 FORMAT (1KO,SX,16H***** TOO MANY (,I3,20H) DATA 7A CARDS READ)
787.          CO TO 1307
788.     1303 IF U.GE.II) 50 TO 1307
789.          IFUDATA) 1321,1321,1330
790.     1321 NCROSsl
791.           GO TO. 1350
792.     1330 NERRORsl
793.          Nall-I
794.          WRITE (NJ.1308) N
795.     1308 FORMAT (1HO,5X,15H****» TOO. FEW (,I3,20H) DATA 7A CARDS READ)
796.     1307 CONTINUE
797.          NCRDSsI
798.          DO 1309 I=t,NREACH
799.          IRCHsIFIXCDATAU,5) *10. +0.0001)
800.          NRCHsIRCHNOURCH)
801.          ALGII(NRCH)=OATAU,6)/ALPHAO(NRCH)
802.          CNH3IT(NRCH)sDATA(I,7)
803.          CN02II(NRCH)=OAIA(I,8)
804.          CN03IT(NRCH)sDATA(I,9)
805.          PHOSIT(NRCH)»OATA(I,10)
806.          COLIIT(NRCH)=DArAU,ll)
807.          RAONlT(NRCH)sOATA(I,12)
809.     1309 CONTINUE
809.     1350 IF UL15T.EQ.O) GO TO 1320
810.          URITE (NJ,1310)
811.     1310 FORMAT (1HO,10X,47HS8S DATA TYPE 7A (INITIAL CONDITIONS FOR CHOROP
812.         *       29HHXLL A, NITROGEN, PHOSPHORUS,/30X,19HCOLIFORM AND SELECT
813.         *       36HEO NON-CONSERVATIVE CONSTITUENT) »SS,/)
814.          WRITE (NJ.1311)
815.     1311 FORMAT (10X.9HCARO TXPE,15X,5HREACH,5X,6HCHLORA,5X,5HNH3/N,5X,
816.         *       5HN02/N,5X,5HN03/N,7X,3HDOP,6X,4HCOLI,4X,6HNONCON)
817.          WRITE(NJ,1312} ((OATA(I,J), J=l,12), I*1,NCRDS)
818.     1312 FOKMAT (10X,3A4,A2,3X,F6.0,6X,F6.1,4X,F6.2,3F10.2,F10.2,F10.3)
819.     1320 CONTINUE
820.    C
821.    C                                       STEP 3-8
822.    C                                       READ IN DATA TYPE 8 (INCREMENTAL
823.    C                                       CONDITIONS).
824.    C
825.          00 120 1=1,11
826.          READ (NI,121) (OATAd, J), J*l,13)
827.      121 FORMAT (5A4,5X,SF5.0,3F10.0)
828.          IF CDATA(I,1)-ESDA) 120,125,120
829.      120 CONTINUE
830.          NERROR=1
831.      124 1=1+1
832.          READ (NI,121) (DATAd,J),J=l, 13)
833.          IF (DATA(I,1)-CNDA) 124,129,124
834.      129 N3I-II
835.          WRITE (NJ.122) N
836.      122 FORMAT (1HO,5X,16H***«* TOO MANY (,I3,18H) DATA8 CARDS READ)
837.          GO TO 123
338.      125 IF U.GE.II) SO TO 123
339.          NCRROR a 1
340.          N*II-I

-------
 841.          WRITE CNJ.126)  N
 842.      126 FORMAT ClHO.SX, 15H*«*»*  TOO; FEW (,I3,18H)  DATA8  CARDS READ)
 843.      123 CONTINUE
 844.          NCROSsI
 845.          DO  127 I=1,NREACH
 846.          IRCH*IFIX(DATA(I,6)*10.+0.0001)
 847.          NRCH«IRCHNO(IRCH)
 848.          QI(NRCH)  3  DAIA(I,7)
 849.          TI(NRCH)  a  DATA(I,8)
 850.          DOI(NRCH) a DATA(I,9)
 851.          80DKNRCH)  = OATA(I,10)
 852.          CONSI(NRCH,l}aOATA(I,ll)
 853.          CON5I(NRCH,2)aOATA(I,12)
 854.          CON5I(NRCH,3)*OATA(I,13)
 855.          IF(MEIRIC.EQ..O)CO  TO  127
 856.          O.I(NRCH)s35.3133*QI(!JRCH)
 857.          TI(NRCH)sl.8*TI(NRCH)+32.0
 858.      127 CONTINUE
 859.          If  ULIST.EQ.O)  CO  TO  431
 860.          WRITE (NJ.511)
 861.      511 FORMAT (1HO,10X,35HSSS DATA  TYPE  8  (INCREMENTAL  INFLOW,
 862.         *       16H  CONDITIONS) SSS)
 863.          WRITE (NJ.211)
 864.      211 FORMAT (10X.9HCARD  IXPE,17X,5HREACH.5X,IHQ,5X,4HTEMP,6X,
 865.         *      4HD.O.,7X,3HBOO,6X,4HCM-l,6X,4HCM-2,6X,4HCH-3)
 866.          WRITE (NJ,407)  ((DATACI,J),J=l,13),1=1.NCRDS)
 867.      407 FORMAT (10X,5A4,5X,F5.0,F8.3,F8.1,5F10.1)
 863.      431 CONTINUE
 369.   C
 870.   C                                       STEP  3-8A
 871.   C                                       READ  IN DATA TYPE  8A  CINCREMENTA
 872.   C                                       CONDITIONS FOR CHLOROPHYLL,  NITR
 873.   C                                       PHOSPHOROUS, COLIFORM AND  RADIO*
 874.   C
 875.           DO  1400  1=1,11
 876.           READ(Nia401) (OATA(I,J), J = 1,12)
 877.     1401  FORMAT(3A4,A2,5X,F5.0,7F8.0)
 378.           IF  (DATA(I,1)-£NOA) 1400,1402,1400
 879.     1400  CONTINUE
 880.           NERROR=1
 881.     1403  1=1+1
 882.           REAOCNI.1401) (OATA(I,J), J=l,12)
 883.           IF  COATA(I,1)-EHOA) 1403,1404,1403
 884.     1404  N=I-II
 885.           WRITE  (NJ,1405) N
 886.     1405  FORMAT (1HO,5X,16H**«*» TOO MANY  (,I3,20H) DATA. 8A CARDS READ)
 887.           CO TO  1406
 888.     1402  IF  U.GE.II) CO TO 1406
 889.           IFUDATAH420,1420,1430
 890.     1420  NCRDS'l
 891.           CO TO  1450
 892.     1430  NERRORsl
 893.           N=II-I
 894.           WRITE  (NJ,1407) N
 895.     1407  FORMAT (1HO,5X,15H*»«»* TOO FEW (,I3,20H) DATA 8A CARDS READ)
 896.     1406  CONTINUE
 897.           NCRDSsI
 898.           00 1408 I»1,NREACH
 899.           IRCH»IFIX(DATA(I,5)*10.t0.0001)
 900.           NRCHsIRCHNO(IRCH)
 901.          ALCI(NRCH)sOATA(1,6)/ALPHAO(NRCH)
 902.          CNH3I(NRCH)aOATA(I,7)
903.          C!i02I(NRCH)aOATA(l,8)
904.          CN03I(NRCH)30ATA(I,9)
 905.          PHOSI(NRCH)aOATA(I,10)
90S.          COLIR(NRCH)sDATA(I,ll)
907.          tUONI(NRCH)30AIAU,12)
 903.     1408 CONTINUE
 909.     1450  IFULIS7 .EQ.O)  CO  TO 1409
 SiO,           ^RITS  (NJ,1413)
                                         143

-------
911.     14X0 FORMA? UHO, IOX,36HS»S DATA TYPE 8A (INCREMENTAL INFLOW ,
912.         *       40H CONDITIONS TOR CHLOROPHYLL A. NITROGEN,/30X,
913.         *       51HPHOSPHORUS, COLIFORM AND SELECTED NON-CONSERVATIVE ,
914.         *       16HCONSTITUENT) $««,/)
915.          WRITE (NO,1411)
916.     1411 FORMAIUOX,9HCARD ITPE,15X,12HREACH CHLORA,3X,5HNH3/N,3X,5HN02/N,
917.         *      3X,5HN03/N,5X,3HDOP,7X,4HCOLI,2X,6HNONCON)
913.          WR1TE(NJ,1412) ((DATA(l.J), J=l,12), I«1,NCRDS)
919.     1412 FORMAI(10X,3A4,A2,8X,F6.0,5F8.2,F11.1,F8.3)
920.     1409 CONTINUE
921.    C
922.    C                                       STEP 3-9
923.    C                                       READ IN DATA TYPE 9 (STREAM JUNC
924.    C                                       IDENTIFICATION AND THE ORDER OF
925.    C                                       CONNECTING ELEMENTS TAKEN CLOCXW
926.    C                                       AROUND THE JUNCTION).
927.    C
929.          IIsNJUNC+1
929.          DO 130 1=1,11
930.          READ (NI,131) (OATAd , J) , J=l, 13)
931.      131 FORMAT (3A4,A3,5X,F5.0,5X,5A4,3(5X,F5.0))
932.          IF (DAIA(I,1)-£NDA) 130,135,130
933.      130 CONTINUE
934.          NERROR31
935.      134 1=1*1
936.          READ (NI,131) (DATAd, J) , J»l ,13)
937.          IF (OATAd,D-ENDA) 134,139,134
938.      139 Nal-II
939.          WRITE (NJ,132) N
940.      132 FORMAT (1HO,5X,UH*«*M TOO MANY (,I3,l8H) DATA9 CARDS READ)
941.          GO TO 133
942.      135 IF U.GE.II) 50 TO 133
943.          NERROR = 1
944.    '      N=II-1
945.          WRITE (NJ,136) N
946.      136 FORMAT (1HO,5X,15H**»*» TOO FEW (,I3,18H) DATA9 CARDS READ)
947.      133 CONTINUE
943.          NCRDSsI
949.          DO 137 I«1,NJUNC
950.          IJUNC • OATAd,5)
9S1.          OQ 138 J*6,10
952.          K » J-5
9S3.          JUNC1D(IJUNC,K)»DATA(I,J)
954.      138 CONTINUE
955.          JUNC(IJUNC,!) * DATA(I,1D
956.          JUNC(IJUNC,2) « DATA(Z,12)
957.          JUNC (I JUNC, 3) * DATAU,13)
953.      137 CONTINUE
959.          IF (ILIST.EQ.O) GO TO 432
960.          WRITE (NJ,S12)
961.      512 FORMAT (1HO,10X,38H$SS DATA TYPE 9 (STREAM JUNCTIONS) $$$,/)
962.          WRITE (NJ,212)
963.      212 FORMAT (10X,9HCARD TSTPE,14X.24HJUNCTION ORDER AND IOENT,
964.         *         9X,2SHUPSTRM   JUNCTION    TRIB)
965.          MRITE (NJ,408) ((DATAd,J),Jsl,13),1=1,NCRDS)
966.      408 FORMAT (10X.3A4,A3,5X,F5.0,5X,5A4,5X,F5.0,5X,F5.0,5X,F5.0)
967.      432 CONTINUE
968.    C
969.    C                                       STEP 3-10
970.    C                                       READ IN DATA TYPE 10 (HEADWATER
971.    C                                       AND THEIR CHARACTERISTICS).
972.    C
973.          II * NHWTRS+1
974.          00 140 1=1,11
975.          READ (NI,141) (OATAd, J) ,J»1,16)
976.      141 FORMAT (2A4,A2,5X,F5.0,5A4,F10.0,6F5.0)
977.          IF (OATAd, D-ENOA) 140,145,140
979.      140 CONTINUE
979.
995.      144

-------
  981.
  982.
  983.
  984.
  985.
  986.
  987.
  988.
  989.
  990.
  991.
  992.
  993.
  994.
  995.
  996.
  997.
  998.
  999.
 1000.
 1001.
 1002.
 1003.
 1004.
 1005.
 100S.
 1007.
 1009.
 1009.
 1010.
 1011.
 1012.
 1013.
 1014.
 1015.
 1016.
 1017.
 1013.
 1019.
 1020.
 1021.
 1022.
 1023.
 1024.
 1025.
 1026.
 1027.
 1028.
 1029.
 1030.
 1031.
 1032.
 1033.
 1034.
 1035.
 1036.
 1037.
 1038.
 1039.
 1040.
 1041.
 1042.
 1043.
 1044.
1045,
1046.
1047..
1043.
1049.
10SO.
      READ  (NI,141)  (OATA(I,J),J=1,16)
      IF  (DATA(I,1)-£NDA)  144,149,144
  149
      WRITE  (NJ,142)  N
  142  FORMAT  (1HO,SX, 16H**»«*  TOO  MANX  (I3,19H)  OATA10  CARDS  READ)
      GO  TO  143
  145  IF  (I.GE.II)  GO TO  143
      NERROR  *  1
      WRITE  (NJ.146)  N
  146  FORMAT ( 1HO ,5X, 15H***«*  TOO  fEW  (,I3,19H)  DATA10  CARDS  READ)
  143  CONTINUE
      NCRDSal
      DO  147 Isl,NHWIR5
      NHM  «  DATACI.4)
      00  148 J=5,9
      K »  J-4
      HWTRID(NHW,K) » DATA(I,J)
  148  CONTINUE
      HWFUOH(NHM) * DATAU.10)
      HWIEMP(NHW) = DATA(I,11)
      IF(MEIRIC.GT.O)HWFLO»(NHIO=35.3133»HWFLOW(NHW)
      IF(METRIC.GT.O)HWTEMP(NHW)si.8*HWT£MP(NHiO*32.0
      HWDO(NHlrf)  > DAIA(I,12)
      HWBOO(NHW) s OATAU,13)
      Ht{CONS(NHW,l)sDATA(I,14)
      HWCONS(NHM,2):OATA(I,15)
      HMCOMS(NHW,3)=OATA(I,16)
c
c
c
c
c
c
  141  CONTINUE
      IF  (ILIST.EQ.O) GO  TO  433
      WRITE  (NJ.513)
  513  FORMAT  (1HO, 10X, 40HSSJ DATA lift  10  (HEADWATER  SOURCES)  $$$,/}
   -   WRITE  (NJ,213)
  213  FORMAT  (10X,9HCARD  T!fPE, 10X, 23HHDWATER ORDER  AND  IDENT,
    *        5X,28HFIOW    TEMP    D.O.     BOO,
    »        24H    CM-1     CM-2    CM-3)
      WRITE  (NJ,409)  ( (DATA(I , J) , J=l , 16) , 1=1 ,NCRD5)
  409  FORMAT  (10X, 2A4 , A2 ,5X, F5 . 0 , 2X,5A4,F9.3,5F8 .2 ,F8. 3)
  433  CONTINUE

                                        STEP 3-10A
                                        READ IN DATA  TYPE  10A  (HEADWATER
                                        CHLOROPHYLL,  NITROGEN, PHOSPHORU
                                        COLIFORM AND  RADIONUCLIDE CONDIT

     DO  1500 1=1,11
     READ(NI,1501) (OATACI.J), J=l,12)
1501 FORMAT(3A4,A2,5X,F5.0,7F8.0)
     IF  (OATA(I,1)-£NDA) 1500,1502,1500
1500 CONTINUE
     NERRORsl
1503 I=I»1
     READ(NI,1S01) (OATA(I,J), J>1,12)
     IF  (OATA(I,1)-ENDA) 1503,1504,1503
1504 NzI-II
     WRITE CNJ.1505) N
1505 FORMAT  (1HO,5X,16H****« TOO MANY  (,I3,21H) DATA 10 A- CARDS READ)
     GO TO 1506
1502 If  (I.GE.II) GO TO  1506
     IFUOATA) 1520,1520,1530
1520 NCROS'l
     GO TO 1550
1530 NERRORal
     MsII-I
     WRITE (NO, 1507)  N
1507 FORMAT  ( 1H0.5X, 15H***»* TOO  FEW  (,I3,21H) DATA 10A CARDS READ)
1506 CONTINUE
     30 :
                                           145

-------
1051.          NHW=DATA(I,5)
1052.          HWALG(NHW)sOAIAd,6)/ALPHAO(l)
1053.          H*NH3(NHW)*OATA(I,7)
1054.          HWN02(NHW)sOAIAd,8)
1055.          H*N03(NHW)=OAIA(I,9)
1056.          HWPHOS(NHW)=OATA(1,10)
1057.          HWCOLI(NHW)=OATA(I,11)
1058.          HWRADN(NHW)aOATAd,12)
1059.     1508 CONTINUE
1060.     1550 IFdLlST ,EQ. 0) GO TO 1509
1061.          WRITE (NJ,1510)
1062.     1510 FORMAT(1HO,10X,29HSS$ DATA UPE 10A (HEADWATER ,
1063.         *      2SHCONOIT10NS FOR CHLOROPHYLL,
1064.         *       21HNIIROGEN, PHOSPHORUS,/30X,25HCOLIFORM AND SELECTED NON
1065.         *       30H-CONSERVATIVC CONSTITUENT)  $$$,/)
106$.          WRITE (NJ,1511)
1067,     1511 FORMAT (10X,9HCARD TYPE,UX,24HHOHATEP  CHLORA NH3/N
1068.         *       39HN02/N    N03/N     OOP      COLI  NONCON)
1°069.          HRlTe(NJ,1512) ((DAIA(I,J). J*l,12),  I»1,NCRDS)
1070.     1512 FORMAT (10X,3A4,A2,3X,F6.0,2X,F6.1,F6.2,3F8.2,F10.2,F8.3)
1071.     1509 CONTINUE
1072.    C
1073.    C                                       STEP 3-11
1074.    C                                       READ IN DATA TYPE 11 (WASTE INPU
1075.    C                                       WITHORAWLS AND THEIR CHARACTERS
1076.    C
1077.          II » NHASTEtl
1078.          00 150 1=1,11
1079.          READ (MI,151) (DATAd, J) , J»l, 17)
1080.      151 FORMAT (2A4,A2.F5.0,5A4,F5.0,F10.0,6FS.O)
1081.          IF (DATAU,D-ENDA) 150,155,150
1082.      150 CONTINUE
1083.          NERROR s 1
1084.      154 I = I + 1
1085.          READ (NI,l5l) (DATAd, J) ,0*1 ,17)
1086.          IF (DATAd,1)-ENDA) 154,159,154
1087.      159 MsI-II
1088.          WRITE (NJ.152) N
1089.      152 FORMAT (lHO,5x,16H**»»* TOO MANX (,I3,19H) DATAU CARDS READ)
1090.          GO T3 153
1091.      155 IF (I.GE.II) GO  TO 153
1092.          NERROR * 1
1093.          NsII-l
1094.          HRITE (NJ,1S6) N
1095.      156 FORMAT (1H0.5X,15H»*»»* TOO FEW (,I3,19H) DATAU CARDS READ)
1096.      153 CONTINUE
1097.          NCRD5=I
1098.          00 157 Ial,NWASTE
1099.          NNS > DATAd,4)
1100.          00 158 J=5,9
1101.          K » J-4
1102.          MASTIO(NHS.K)*OATA(I,J)
1103.      158 CONTINUE
1104.          TRFACT(NHS) > OATA(I,10)
1105.          WSFU)W(NWS) > DATAd,11)
1106.          WSTEMP(NHS) * DATA(I,12)
1107.          WSOO(NWS) > DATA(I,13)
1108.          MSBOO(NWS) c OATAd.14)
1109.          WSCONS(NHS,1)BOATA(I,15)
1110.          MSCONS(NWS,2)'OATA(I,1S)
1111.          WSCONS(NWS,3)*OATA(I,17)
1112.          IF (METRIC.EQ.O) GO TO 157
1113.          WSFLOM(NWS)>3S.3133*MSFLOW(NWS)
1114.          WSTE*i>(NWS)3l.a*tfSTEMP(MW3)+32.0
1115.      157 CONTINUE
1116.          I£ (IUI5T.EQ.O)  GO TO 434
1117.          WRITE (NJ.514)
1118.      514 FORMAT (1HO,10X.38HSS* DATA TYPE 11 (POINT SOURCE / POINT,
1119.         *       28H SOURCE CHARACTERISTICS) US,/)
1120.          WRITE (NJ.214)

-------
 1121.
 1122.
 1123.
 1124.
 1125.
 1126.
 1127.
 1128.
 1129.
 1130.
 1131.
 1132.
 1133.
 1134.
 1135.
 1136.
 1137.
 1133.
 1139.
 1140.
 1141.
 1142.
 1143.
 1144.
 1145.
 1146.
 1147.
 1143.
 1149.
 1150.
 1151.
 1152.
 1153.
 1154.
 1155.
 1155.
 1157.
 1153.
 1159.
 1160.
 1161.
 1162.
 1163.
 1164.
 1165.
 1166.
 1167.
 1163.
 1169.
 1170.
 1171.
 1172.
 1173.
 1174.
 1175.
 1176.
 1177.
 1178.
 1179.
 1180.
 1131.
 1132.
 1133.
 1134.
1195.
1186.
1137.
1133.
1139.
1190.
  214 FORMAT (10X,42HCARD TYPE  POINT SOURCE ORDER AND ID   EFF,
     *       4X.36HFLOH    TEMP    D.O.     BOD    CM-1,4X,
     *       12HCM-2    CM-3)
      WRITE (NJ,410) ((DAIAU,J),J»t,17),I«l,NCRDS)
  410 FORMAT (10X,2A4,A2.F5.0,2X,5A4,F5.2,F8.3,5F8.2,F8.3)
  434 CONTINUE

                                        STEP 3"11A
                                        READ IN DATA TYPE IIA (WASTE INP
                                        CHARACTERISTICS ALGAE, NITROGEN,
                                        PHOROPHOROUS COL1FORMS AND RADIO
      DO 1602 1=1,11
      R£AO(NI,1601) (DATA(I,J), J=l,12)
 1601 FORMAT(3A4,A2,5X,FS.O,7F8.0)
      IF (OATA(I,1)-£NDA) 1602,1621,1602
 1602 CONTINUE
      NERRORsl
 1605
C
c
C
c
c
      READ(NI,1601) (DATACI.J), J=l,12)
      IF (DATA(I,1)-ENDA) 1605,1607,1605
 1607 NsI-II
      WRITE (NJ,1620) N
 1620 FORMAT UHO,5X, 16H**«» * TOO MANX (,I3,21H) DATA 11A CARDS READ)
      GO TO 1604
 1621 IF (I.GE.II) GO TO 1604
      IF(IDATA) 1630,1630,1640
 1630 NCRDSsO
      GO TO 1650
 1640 NE8ROR-1
      WRITE (NJ,1622) N
 1622 FORMAT ( 1HO,5X, 15H***** TOO FEW (,I3,21H) DATA 11A CARDS READ)
 1604 CONTINUE
      NCRDS=I
      DO 1606 I=i,NHASTE
      NHSsOATA(I,5)
      WSALG(NWS)=OAIA(I,6)/ALPHAO(1)
      MSNH3(NNS)sOATA(I,7)
      HSN03(NMS)*DATA(I,9)
      WSPHOS(NWS)sOATA(I,10)
      WSRAON(NWS)=OATAU,12)
 1606 CONTINUE
 1650 IFULIST .EQ.  0)  GO TO  1699
      WRITS (NJ,1610)
 1610 FORMAT (1HO,10X.41HSSS  DATA TYPE IIA (POINT SOURCE CHARACTER,
     *       45HISTICS  - CHLOROPHYLL A,  NITROGEN, PHOSPHORUS,/30X,
     *       51HCOLIFORMS AND SELECTED NON-CONSERVATIVE CONSTITUENT
     *       5H)  S8S,/)
      WRITE(NJ,1611)
 1611 FORMAT UOX.9HCARD TYPE,6X,2SHPOINT SOURCE ORDER AND ID,3X,
     *       46HCHLORA    NH3/N   M02/N   N03/N      OOP    COLI,
     *       11H     NONCON)
      NCRDSsNCRDS-1
      IF  (IDATA.EQ.O) GO TO 1655
      DO  1615 l3i,NCROS
      NWS*OATA(I,5)
      FNMS3NUS
      WRITE(NJ,1612)(DATA(I,J), J«l,4),FNMS,(WA5TID(N^S,K),  K*l,5),
     * (DAIACI.J), J»6,12)
 1612 FORMAT (10X,3A4,A2,F6.0,IX,5A4,F8.3,4F3.2,FU.2,F8.3)
 1615 CONTINUE
 1655 WRITE (NJ,1612) (DATAtMCROStl,J),J»l,3)
 1699 CONTINUE
      WRITE (NJ,20S5)
 2055 FORMAT (1H1)
*

*                                       STEP 4-0
:                                       IF THE  CORRECT NO. OF  DATA CARDS
                                         K7

-------
1191.
1192.
1193.
1194.
1195.
1196.
1197.
1199.
1199.
1200.
U01.
1202.
1203.
1204.
120S.
1206.
1207.
C
c
C
                                  NOT BEEN READ IN,
                                  TERMINATE.
                   THE PROGRAM MI.
      IF (NERROR.EQ.O) GO TO 888
      WRITE (NJ,2066)
 2066 FORMAT (1H1,15X.34H* * * *
                      33H* * *
                  16X.34H* E X
                      33HR H I
                           C U
                           A T
    N
    B
W A
C A
                                                    .//'*
T
E
                  16X, 1H»,31X,3HO F,31X,1H*,//,
                  16X,34H*
                      33HI
                  16X,34H*
                      33H»
                     N P 0 T
ERR
ATA
                                       a R s   IN
  888
STOP
RETURN
END
                                         143

-------
SUBROUTINE NH3S*

          Subroutine NH3S completes the setup of the equations necessary
to calculate ammonia nitrogen concentration levels in each computational
element.  Specifically, the subroutine completes the definition of the
diagonal term of the coefficient matrix and defines the vector of known
terms on the right hand side of the equations.

          The additions to the diagonal term represent the individual
constituent changes caused by constituent reactions and interactions,
and mass changes caused by stream withdrawals.  The resulting diagonal
term for each type of computational element is:
          TYPE                       DIAGONAL TERM
     All except type 7           bi  -  *\ + (K7}1- At
     7.  Withdrawal              bj  *  x1 + (K7)1 At - q0 ^

where x^ is defined in Subroutine TRIMAT.

          The right hand side term contains all known inputs, which
include headwater inflows, wastewater discharges, tributary flows and
incremental runoff, and, in the case of dynamic simulation, the
concentration in the previous time step.  The known term for each
type of element for dynamic simulation is:
          TYPE                        RIGHT HAND SIDE
     1.  Headwater         S1  =  (Nj* + qj (N^ ~ - a1(N1)
                                                  ~ -  11h
                                        + a3 Ax
    6.   Waste  Input       S1   -  (N,)* + q!  (Nx) !  & + qw(Nl)w
                                             Ax
*-' I  syT»ccls used are defined at the ena or this section cr t-
         * on  r'.eoort.

-------
          TYPE                        RIGHT HAND  SIDE
     All Others            S1   »  (Kj)* + q!  (N,)! ^
                                  J     v1

For steady-state simulation, the only difference  is  that  the  value  from
                            *
the previous time step, (NjL. is set equal  to zero  and At  =  1.0.

          The subroutine flow chart  is illustrated in  Figure  VI-13  and
is followed by the program listing.   All  program  variables  contained  in
COMMON are defined in Section VII.
                                   150

-------
                                                 ENTRY
                                            SUBROUTINE NH3S
                                               INITIALIZE
                                              COUNTERS AND
                                           CONVERSION FACTORS
                                                                        00 computations
                                                                        from a to 6 for
                                                                        alt computational
                                                                        elements
                                             INITIALIZE KNOWN
                                            TERM AND DIAGONAL
                                          TERM FOR STEADY STATE
                                          OR DYNAMIC SIMULATION
                                                DETERMINE
                                          TYPE OF COMPUTATIONAL
                                                ELEMENT
    TYPE 1
 AOO HEADWATER
INPUTS TO aiaw
  TERM, S(t)
TYPES  2. 3. «. 5

    CONTINUE
    TYPE 6

AOO UASTEUATER
INPUTS  TO KNOWN
  TERM, S(I)
      TYPE 7

  SUBTRACT STREAM
  WITHDRAWAL FROM
DIAGONAL TERM, 8(1)
                                                 0
                                                RETURN
                                                TO CUAL
                FIGURE  VI-13,    FLOW  CHART -'OR  SUBROUTINE  NH35

-------
 1.          SUBROUTINE NH3S
 2.    C
 3.    C
 4.          COMMON TITLE(20,20),RCHID(7S,5),RMTHOR(7S),RMTEOR(75),NHWWAR(1S),
 5.         *       TARGDO(75),1AUGOR(75,6),NCELRH(75),IFLAG(75,20),
 6.         *       ICLORD(75,20),COEF1,NREACH
46.          NCELR»NCELRH(I)
47.          CNCELR'NCELR
48.          CNH3IJ*QI(I)/C?!CELR*CNH3I(X)
49.          DO 100 J=l,NC£bR
50.          IOR»ICLORO(I,J)
51.    C
52.    C                            INITIALIZE DIAGONAL AND KNOWN TERMS
53.    C
54.          IF (MODOPT(4).EQ.O) ALCAE(IOR)*0.0
                                     1:2

-------
55.          TC«0.556*(T(IOR)-68.0)
56.          KNH3(IOR)=CKNH3U)«1.047»*TC.
57.          REACT»ALPHA1*RESPRR(IOR)*ALGAE(IOR)*D1LI+SNH3(I)»0£1,X*
53.         *      OTOVCL(IOR) * FACT
59.          8CIOR)»XCIOR)+D1LT*KNH3(IOR)
60.          S(IOH)*CNH3(IOR)
61.          IF USS.GT.O) S(IOR)=0.0
62.          5
-------
SUBROUTINE N02S*

          Subroutine N02S completes the setup of the equations necessary
to calculate nitrite nitrogen levels in each computational  element.
Specifically, the subroutine completes the definition of the diagonal
term of the coefficient matrix and defines the vector of known terms on
        *
the right hand side of the equations.

          The additions to the diagonal term represent the  individual
constituent changes caused by constituent reactions and interactions,
and mass changes caused by stream withdrawals.  The resulting diagonal
term for each type of computational element is:
          TYPE                      DIAGONAL TERM
     All except type 7          bi  =  x-j + (Kg)i At
     7.  Withdrawal             b1  =  Xi + (K,)1 At - qQ ^7

where Xi is defined in Subroutine TRIMAT.

          The right hand side term contains all known inputs, which
include headwater inflows, wastewater discharges, tributary flows and
incremental runoff, and, in the case of dynamic simulation, the
concentration in the previous time step.  The known term for each type
of element for dynamic simulation is:
          TYPE                        RIfflT HAND SIDE
     1.  Headwater         Si  -  (N*)i + q^ (N^ £7 - ai (N2)h + (K7Nl)1 At

     6.  Waste Input       Si  -  (N*)1 + qj (N^). ^ + qw (Ma)w ^ + (K?Nl)1 At

     All Others            Si  •  (N*)1 + q^ (N^ —• t (K7Nl)i At
                                                    i
*Aii  symbols used ara defined at the end of this section
 of the Documentation Report.
                                154

-------
For steady-state simulation, the only difference is that the value from
the previous time step, (N*)^, is set equal  to zero and At s 1.0.
          The subroutine flow chart is illustrated in Figure VI-14 and
is followed by the program listing.  All  program variables contained in
COMMON are defined in Section VII.
                                   15:

-------
                                                 BURY
                                            SUBROUTINE N02S
                                               INITIALIZE
                                              COUNTERS WO
                                           CONVERSION FACTORS
                                                6	
                                          00 computations
                                          from * to b for
                                          all computational
                                          elements
                                             INITIALIZE KNOWN
                                            TERN AND DIAGONAL
                                          TERM FOR STEADY STATE
                                          OR DYNAMIC SIMULATION
                                               DETERMINE
                                          TYPE OF COMPUTATIONAL
                                                ELEMENT
    TYPE 1
 ADO HEADWATER
INPUTS TO KNOWN
  TERM, S(I)
TYPES 2. 3. 4. S

    CONTINUE
    TYPE 6

ADO WASTEWATER
INPUTS TO KNOWN
  TERM. S(I)
     TYPE 7

  SUBTRACT STREAM
  WITHDRAWAL FROM
DIAGONAL TERM. 8(1)
                                                RETURN
                                                TO QUAL
              FIGURE  YI-14.   FLOW CHART  FOR  SUBROUTINE  N02S
                                              156

-------
  1.           SUBROUTINE  N02S
  2.     C
  3.     C
  4.           COMMON IITLE(20,20),RCHID(75,S),RMTHOR(75),RMT£OR(75),NHWWARUS),
  5.          *      TARGDO(75),IAUGOR(7S,6),NC£LRH(75),IFLAG(75,20),
  6.          *      ICLORO(75,20),CO£FQY(75),EXPOQV(75),COEFQH(75),£XPOQH(75),
  7.          *      CMANN(75),CK1C75),CK3(75),K20PT(75),CK2(75),COEQK2C75),
  8.          »      EXPQK2(75),IINIT(75),DOINIT(75),BOINITC75),COINITC75,3),
  9.          *      01(75),TH75),001(75),aODI(75),COJISIC75,3),JUNCIDU5,5),
 10.          *      JUNC(15,3),HHTRID(15,5),HMFLONU5),HWTEMP(15),HMDO(15),
 11.          *      HWBOO(15),HHCON3(15,3),HASTID(90,5),TRFACT(90),MSFLOM(90),
 12.          *      MSTEMP<90),MSD3(90),MSBOO(90),HSCONS(90,3),QATOT(15),
 13.          *      A(500),B(500),C(500),DU5),S(500),2(500),W(500),G(500),
 14.          *      FLOW(SOO),DEPTH(500),VEL(500),DTOVCL(500),K2(500),Kl(500),
 15.          *      HSNET(500),DL(500},VHW(15),OEPHW(15),DLH*U5),1(500).
 16.          *      DO(SOO),800(500),CONS(500,3),PTIHE,TPRINT,D£LX,
 17.          * .     NHWTRS,NREACH,NMASTE,NJUNC,DELT,01LT,02Lr,OTODX2,OT20DX,
 18.          *      LAT,LSM,LLM,ELEV,DAr,AE,BE,DAXOF1t,DRY8LB,WETaLB,0£WPT,
 19.          *      AIMPR,KINO,CLOUD,SONET,NI,NJ,TRLCD,TOFDAX,NT,NC,TIME,NCS
 20.     C
 21.     C
 22.           COMMON/MODIFA CK4(75),CK5(75),CKNH3(75),CKN02(75),CXN03(75),
 23.          *      CKN,CKP,CKL,ALPHAO(75),ALPHA1,ALPHA2,ALPHA3,ALPHA4,
 24.          *       ALPHAS,ALPHA6,GROMAX,RESPRT,ALGSET(75),SPHOS(75),
 25.          *       SNH3(75),KNH3(500),!CN02(5QO),RESPRR(500),COLI(500),
 26.          *      ALGA£(500),PHOS(500),CNH3(500),CN02(500),C.H03(500),
 27.          *      COLIR(75),ALGI(75),PHOSI(75),CNH3I(75),CN02I(75),
 28.          *      CN03I(75),COLIIT(75),ALGIT(75),PHOS1T(75),CNH3IT(75),
 29.          *      CN02II(75),CM03IT(75),»SCOLI(90),hSALG(90),HSPHOS(90),
 30.          *       MSNH3(90},MSN02(90),«ISN03(9U),H>iCOLI(15),HWALG(15)>
 31.          *      HWPHOS(15),HMHH3(15),HMN02(15),HHN03(15},GROMTH(500),
 32.          *       MODOPT(10),IRCHNO(750),EXCOEF(75)
 33.     C
 34.           COMMON/SSTATE/X(500),ISS
 35.           REAL KN02,  KNH3
 36.     C
 37.     C                            INITIALIZE COUNTERS
 38.     C
 39.           NHW30
 40.           NMSaQ
 41.     C
 42.     C                            LOOP THROUGH REACHES AND COMP. ELEMENTS
 43.     C
 44.           DO 100 I>1,NREACH
 45.           NCELRsNCELRH(I)
 46.           CNCELRsNCELR

 48.'          DO 100 J=1,NCELR
 49.           IOR=ICLOKD(I,J)
 50.    C
 51.    C                            INITIALIZE DIAGONAL AND KNOWN TERMS
 52.    C
53.           IC»0.556*(T(IOR)-68.0)
54.          KN02(XORJ»CX*02(im.047**TC.
                                          157

-------
55.          REACT»01LT*KNH3UOR)*CNH3UOR)
56.          B(IOR)*XCIOR)+OUT*KN02UOR)
57.          3(IOR)aCN02(IOR)
58.          IF (ISS.GT.O) S(10R)«0.0
59.          S(IOR»S(XOR)+REACTtC)iQ2I<]*OIOVCUlOR>
60.          IFb«IFLAC(I,J)
01.    C
62.    C                            MODIFY DIAGONAL AND/OR KNOWN TERMS
63.    C
64.          GO TO (101,100,100,100,100,103,104), ITU
65.    C
66.      101 NHM=MHM+1
67.          S(IOR)sS(XOR)-A(XOR)*HWN02(NHH)
68.          GO TO 100
69.    C
70.      103 NWS*NriS+l
71.          S(IOR}3S(XOR)+WSFLOW(!4HS)*USN02 (NHS)*DTOVCLCIQR)
72.          GO TO 100
73.    C
74.      104 NriS*NHS+l
75.          B(lOR)=aaOR)-*SFlOHCM*S)*DTOYCUIOR)
76.      100 CONTINUE
77.          RETURN
78.          END

-------
SUBROUTINE N03S*

          Subroutine N03S completes the setup of the equations necessary
to calculate nitrate nitrogen levels in each computational element.
Specifically, the subroutine completes the definition of the diagonal
term of the coefficient matrix and defines the vector of known terms
on the right hand side of the equations.

          The additions to the diagonal term represent the individual
constituent changes caused by constituent reactions and interactions,
and mass changes caused by stream withdrawals.  The resulting diagonal
term for each type of computational element is:
          TYPE                         DIAGONAL TERM
     All except type 7
     7.  Withdrawal
where x  is defined in Subroutine TRIMAT.
     7.  Withdrawal                  b1  =  x1 - q0   •
          The right hand side term contains all known inputs, which
include headwater inflows, wastewater discharges, tributary flows and
incremental runoff, and, in the case of dynamic simulation, the
concentration in the previous time step.  The known term for each type
of element for dynamic simulation is:
     TYPE
1.  Headwater       Si = (N*)i + q^Nj  £• - ai(N3)h t (K8N2)i At - c^u^At

6.  Waste Input     S1 * (N*)1 + q!(N3)i ^ + qw(N3)w ^ + (K8N2). At - o^^At

All  Others          Si = (N*)1 * qj(N3). t (K3N2).  At - a^-A.At
*AII  symbols used are defined at the end of this section
 in  the Dccu.tenT.2Tion Report.

-------
For steady-state simulation, the only difference is that the value from
the previous time step, (N*)^, is set equal  to zero and At = 1.0.

          The subroutine flow chart is illustrated in Figure VI-15 and
is followed by the program listing.  All  program variables contained in
COMMON are defined in Section VII.

-------
                                                 ENTRY
                                            SUBROUTINE N03S
                                               INITIALIZE
                                              COUNTERS AND
                                           CONVERSION FACTORS
                                                                       00 computations
                                                                       fro* * to b  for  •
                                                                       all computational
                                                                       elements
                                             INITIALIZE KNOWN
                                            TERM AND DIAGONAL
                                          TERM FOR STEADY STATE
                                          OR DYNAMIC SIMULATION
                                                DETERMINE
                                          TYPE OF COMPUTATIONAL
                                                ELEMENT
    TYPE 1

 ADD HEADWATER
INPUTS TO KNOWN
  TERM, S(I)
TYPES 2. 3. 4. 5


    CONTINUE
    TYPE 6

ADO UASTEWATER
INPUTS  TO KNOWN
  TERM, S(I)
      TYPE 7

  SUBTRACT STREAM
  WITHDRAWAL FROM
DIAGONAL TERM, B(t)
                                                 G
                                                RETURN
                                                TO QUAL
                     FIGURE  VI-15.    FLOW  CHART FOR  SUBROUTINE  N03S
                                                 161

-------
 1.
 2.
 3.
 4.
 5.
 6.
 7.
 a.
 9.
10.
li.
12.
13.
14.
IS.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
25.
27.
29.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
42.
43.
44.
45.
46.
47.
48.
49.
50.
51.
52.
53.
54.
C
c
C
c
             SUBROUTINE N035
COMMON TITLE(20,20)»RCHIDC75,5),RMTHOR(75),RMTEOR(75),NHHWAR(15),
       TARGDO(75),IAUCOK(75,6),NCELRH(73),IFLAG(75,20),
       ICLORD(7S,20).COEFQV(75),£XPOQV(75),CDCFQH(75),gXPogH(75)T
       CMANN(75),CXH75),CX3<75),K20PTC75),CK2(75),COEQK2(75).
       £XPQK2(75),IXNIT(7S),OOINIT(75),BQIN1TC7S),COXNIT(75,3),
       Ql(7S),TI(75}.DCLI(75),&ODI(75},COJiSI{75,3).JUNCID(lS,5),
       JUNCU5,3),HHIRID<15,5),HWFLOWU5>,HWTEMP(1S),H*OOC15),
       HM80D(15),HHCONSU5,3),WASTlO(90,5),TRfACT(90),WSfLQM(90),
       WSTEMPC90),NSDO(90),NS80D(90),HSCONS(90,3),OATOT(15),
       A(500),8(500),C(500),0(15),S(500),2(500),W(500),G(500),
       FLOW(SQO),OEPTH(500),VEL(SOO),DTaVCL(500),K2(500),K1(500),
       HSNETCSOO),DL(500),VHWC15),DEPHW(15),DLHH(15),T(500),
       00(500),800(500),CONS(500,3),PTIME.TPRINT.DELX,
       NHWTRS,NREACH,N«IASTE,NJUNC,OELT,D1LT,02LI,OTODX2,DT200X,
       LAT,LSN,LLM,ELEV,DAI,AE,BE,DAlfOFir,DR¥Bt,a,iiilETBLB,DEWPT,
       ATMPR, ilINO, CLOUD, 50HEI, NI,NJ,XRLCD,TOFDAlf, NT, NC,TIME,NCS


COMMON/MOOIF/ CK4(75),CK5<75),CKNH3(75),CKN02(75).CKN03C75),
       CKN,CKP,CKL,ALPHAO(75),ALPHAl»A[,PHA2.AtPHA3,ALPHA4,
       ALPHAS,ALPHA6.GROMAX,RESPRT,ALGSET(75),SPHOS(75),
       SNH3(75),KNH3(500),KN02(500),RESPRH(500),COU(500),
       ALGAE(500),PHOS(500),CNH3(500),CN02(500),CN03(500),
       COLIR(75),ALCI(75),PHOSI(75),CNH3I(75),C.NQ2I(75),
       CN03I(75),COLIIT(75),ALGIT(75),PHOSIT(75),CNH3IT(75),
       CN02IT(75),CN03IT(75) ,WSCOH(90) .WSAUGC90) ,WSPHOS(90) ,
       WSNH3(90},WSN02(90),HSN03(90),HWCOLI(1S),HWALG(15),
       HWPHOS(15),H1«NH3(15),HNNU2(15),HHN03(15),GROWTH(500),
       MQDQPT(10),IRCHMQC750),EXCQEF(75)
      CQMMON/SSTATE/X(500),ISS
      REAL KN02
      NHMsO
                             INITIALIZE COUNTERS
                             LOOP THROUGH REACHES AND CONP. ELEMENTS
      00 100 Isl,NREACH
      NCELftsNCELRH(I)
      CNCELR=NCELR
      00 100 J=1,NCELR
      IOR*ICLORD(I,J)
                             INITIALIZE DIAGONAL AND KNOWN TERMS
      IF (MODOPT(4),EO.O) »LGAE(IOR)=0 . 0
      REACTB01LT*KN02(IOM)*CN02(IOR)-01LT*ALPHA1*GROMTH(IOR)*ALGAE(IOR)
                                           162

-------
ss.
56.          S(IOR)'CN03(IOR)
57.          ir (ISS.GT.O) S(IOR)«0.0
58.          S(IOR)*S(IOR)+REACT»CHa3IJ*OIOVCMIOR)
59.          IFb»irt,ACU,J)
60.    C
61.    C                            HOOirX DIAGONAL AND/OR KNOHN TERMS
62c    C
63,          50 TO UOifiOO,100,iOO,100,103,104), IFl
64.    C
65.      10} NHK«MH«*1
66.          S(10R)>S(IOR)«A(XOR)*HUH03(NHH)
67.          GO TO 100
68.    C
69.      103 NWS*NWS+1
70.          SUOR)aSUOR)+MSFLOH(NNS)*iiSh03 (NUS)*OTOVCL(IOR)
71.          GO TO 100
72.    C
73.      104 NMS*NWS*t
74.          BUOR)38UOR)-WSFLOM(NNS)*OTOVCl.(IOR)
75.      100 CONTINUE
76.          RETURN
77.          END
                                           163

-------
SUBROUTINE P04S*

          Subroutine P04S completes the setup of the equations necessary
to calculate phosphorus levels in each computational element.   Specifically,
the subroutine completes the definition of the diagonal  term of the
coefficient matrix and defines the vector of known terms on the right hand
side of the equations.

          The additions to the diagonal term represent the individual
constituent changes caused by constituent reactions and  interactions, and
mass changes caused by stream withdrawals.  The resulting diagonal  term
for each type of computational element is:
          TYPE                            DIAGONAL TERM
     All except type 7                  b.  =  x.
     7.  Withdrawal                     b.  *  xi - q0 ~

where x^ is defined in Subroutine TRIMAT.

          The right hand side term contains all known inputs, which
include headwater inflows, wastewater discharges, tributary flows and
incremental runoff, and, in the case of dynamic simulation, the
concentration in the previous time step.  The known term for eacn type
of element for dynamic simulation is:
     TYPE
1.  Headwater       Si = P* + q'P1 ^- - a-Ph + a2 (p-u^ A.At + o3Ax ~

6.  Waste Input     Si = P* + (q'P1 + q/J &- + <*2 (p-u.) A.At + a/x ^

All Others          Si • P* + q'P' 77 + a2 ^P-U^ A.At + 03Ax ~
*AII  symbols used are defined at the end of this section
 of the Documentation Report.
                                   164

-------
For steady-state simulation, the only difference is that the value from
the previous time step, P*, is set equal  to zero and At - 1.0.

          The subroutine flow chart is illustrated in Figure VI-16 and
is followed by the program listing.  All  program variables contained in
COMMON are defined in Section VII.
                                    165

-------
                                               ENTRY
                                          SUBROUTINE  P04S
                                             INITIALIZE
                                            COUNTERS AND
                                         CONVERSION FACTORS
                                               CD-	
                                         00 computations
                                         from a to  b for
                                         all computational
                                         elements
                                           INITIALIZE KNOWN
                                          TERM AND DIAGONAL
                                        TERM FOR STEADY STATE
                                        OR DYNAMIC SIMULATION
                                              DETERMINE
                                        TYPE OF COMPUTATIONAL
                                              ELEMENT
   TYPE 1
 AOO HEADWATER
INPUTS TO KfKWN
  TERM, S(I)
TYPES ?, 3.  *. S


    CONTINUE
    TYPE 6

AOO WASTEWATER
INPUTS TO KNOWN
  TERM, SO)
     TYPE 7

  SUBTRACT STREAM
  WITHDRAWAL FROM
DIAGONAL TERM, 8(1)
                                               RETURN
                                               TO QUAL
                   FIGURE  VI-16.   FLOW  CHART FOR  SUBROUTINE P04S
                                                  166

-------
 1.          SUBROUTINE P043
 2.    C
 3.    C
 4.          COMMON TITLE(20,20),RCHZD(75,5),RMTHOR(7S),RMTeOR(75),NHHHAR(15),
 5.
 b.
 T.
 8.
 9.
10.
It.
12.
13c
14.
IS.
16.
17.
18.
19.
TARGDO(75),1AUGO*(7S,6),NCELRH(73),1FLAG(75,20),
:CLORD<75,20),CO£FQVC7S),EXPOQVC75),COEFaH(75),EXPOQHC75),
CMANN(7S),CK1(75),CK3(75),X20PT(75),CK2(75),COEQK2(75),
EXPQK2(75),TIMII(75),D01NIT(75),80INIT(7S),COINIT(75,3),
QI(75),n(75),OOI(75),aODI(7S),COJISI(7S,3),JUNCID(15,S),
JUNC(15,3),HtoTRIO(15,5),HMFLOM(15),HNTEMP(lS),HMOa(15)>
HW800U5),H«ICOHS(15,3),WASTID(90,5),TRFACT(90),MSFLOi«(90),
WSTEMP(90),MSDO(90),HSBOD(90),HSCONS(90,3),QATOT(15),
A(SOO),B<500),C(500),D(15),S(SOO),Z(500),W(500),G(500),
FLOH(SOO),DEPTH(500)PVEL(500),DTO.VCL1500),K2<500),K1(500),
HSNET(500),DL(500),VHW<15),DEPHW(15),DLH«U5),T(500),
00(500),800(500),CONS(500,3),PTIME,TPRINT,DELX,
NHWTRS,NREACH,JI»A5TE,NJUNC.DELT,DlLT,D2LI,DTODX2,DT2aDX,
LAT,LSM,LLM,ELEV,DAr,AE,BE,DAXOFY,DRXBLB>WETBLB,DEWPT,
ATMPR,HIND,CLOOO,SONET,NI.NJ.TRLCD.TOFOAX,NT,NC,TIME,NCS
20.    C
21.    C
22.          COMMON/MODIF/ CK4(75),CK5(75),CKNH3(75),CXN02(75),CKN03(75),
23.         *       CKN,CKP,CKL,ALPHAO(75),ALPHA1,ALPHA2,ALPHA3,ALPHA4,
24.         *       ALPHAS,ALPHAS,GROMAX,RESPRT,ALGSET(75),SPHOS(75),
25.         *       SNH3(7S),KNH3(500),KN02(500),RESPRR(500),COLI(500),
26.         »       ALGAE(500),PHOS(500),CNH3(500),CN02(500),CN03(500),
27.         *       COLIR(75),ALGI(75),PHOSI(75).CNH3I(75),CN02IC75),
28.         *       CN03I(75),COLIIT(75),ALGIT(75),PHOSIT(75),CNH3IT(75),
29.         *       CN02IT(75),CN031T(75),HSCOLI(90),WSALG(90),WSPHOS(90),
30.         *       WSNH3(90),MSN02(90),MSN03(90),HHCOLI(15),KMALG(1S),
31.         *       HWPHOS(15),HWNH3(15),HWN02(15),HWN03(15),GROWTH(500),
32.         *       MODOPT(10),IRCHNO(750),EXCOEF(75)
33.    C
34.          COMMON/SSTATE/X(500)fISS
35.    C
36.    C
37.    C.                            INITIALIZE COUNTERS
38.          HHH«0

4o!          FACT *: 1.0 / (28.3 * 86400.0)
41.    C.
42.    C                            LOOP THROUGH REACHES AND COMP. ELEMENTS
43.    C
44.          00 100 I»1,NREACH
45.          HCELR»NCELRHU)
46.          CNCELR'NCELR
47.          PHOSIJ * QI(I.)/CNC£LR*PHOSI(I)
48.          00 100 J»1,NCELR
49.          IOR*ICLORO(I,J)
50.    C
51.    C.                            INITIALIZE DIAGONAL AND KNOWN TERMS
52.    C.
53.          S(IOR)3PHOS(IOR)
54.          fl(IOR)»X(IOR)
                                          167

-------
55.          IFUSS.GT.l) S(IOR)«0.0
56.          PSORCE=SPHOS(I)»OELX»DTOVCO(IOR) * FACT
57.          REACT * ALPHA2*
-------
SUBROUTINE RADIOS*

          Subroutine RADIOS completes the setup of the equations necessary
to calculate the concentration of an arbitrary nonconservative constituent
in each computational element.  Specifically, the subroutine completes the
definition of the diagonal term of the coefficient matrix and defines the
vector of known terms on the right hand side of the equations.

          The additions to the diagonal term represent the  individual
constituent changes caused by constituent reactions and  interactions,
and mass changes caused by stream withdrawals.  The resulting diagonal
term for each type of computational element is:
          TYPE                       DIAGONAL TERM
     All except type 7           b-j  =  x-j + K6 At
     7.  Withdrawal              b-j  =  x-j + K6 At - q0 —
                                                         i
where x-j is defined in Subroutine TRIMAT.

          The right hand side term contains all known inputs, which
include headwater inflows, wastewater discharges, tributary flows and
incremental runoff, and, in the case of dynamic simulation, the  .
concentration in the previous time step.  The known term for each type
of element for dynamic simulation is:
          TYPE                     RIGHT HAND SIDE
     1.  Headwater            Si  =  R* + qjRl ^r - a^R^

     2.  Waste Input          Si  =  R* + q'.R\ ^ + qwRw ^

     All Others               S1  =  R* + q]R! ~
                                                i
*AII symbols used are defined at the end of this section of the
 Oocumentat i en Repo rt.
                                   163

-------
For steady-state simulation, the only difference is that the value from
the previous time step, R?;, is set equal to zero and at At = 1.0.

          The subroutine flow chart is illustrated in Figure VI-17 and
is followed by the program listing.  All program variables contained in
COMMON are defined in Section VII.
                                   170

-------
                                       I         ENTRY

                                       (    SUBROUTINE RADIOS
                                          INITIALIZE COUNTERS AND
                                           CONVERSION FACTORS
                                                                        00 computations
                                                                        from a to b for
                                                                        all  computational
                                                                        elements
                                          CALCULATE GR7.-ITH RATE,
                                           AND  INITIALIZE KNOWN
                                             TERM AND DIAGONAL
                                           TERM FOR ST:ADY-STATE
                                           OR DYNAMIC SIMULATION
                                                DETERMINE
                                           TYPE OF COMPUTATIONAL
                                                ELEMENT
    TYPE  i
 ADS HEAS'.;ATER
I::?UTS TO
TYPES  2. 3. 4. 5


    CONTINUE
    TYPE  6

ADD WASTEWATER
INPUTS TO KNOWN
  TERM, S(I)
      TYPE 7

  SUBTRACT STREAM
  WITHDRAWAL FROM
DIAGONAL TERM, 8(1)
                                                  RETURN
                                                  -0 QUAL
                 FIGURE  VI-17.   FLOW CHART  FOR  SUBROUTINE  RADIOS
                                                    171

-------
 1.          SUBROUTINE RADIOS
 2.    C
 3.    C
 4.          COMMON TITLE(20,20),RCHID(75,5),RMTHOR(75),RMT£OR(75),NHUWAR(15),
 5.
 6.
 7.
 a.
 9.
10.
11.
12.
13.
U.
15.
16.
17.
18.
19.
7ARCDO(75),IAUGOm75,6)fNCELRH(75),IFLAG(75,2Q),
ICLORDC75,20),CO£FQVC75),EXPOQV<7S),COEFQH(75),EXPOQH(75),
CMANN(75),CK1(75),CK3(75),K20PT(75),CK2(75),CO£QK2(75),
EXPQK2(75),TINIT(7S),OOINIT<75),BOINIT(75),COINIT(75,3),
gi(75).TIi;75),DOJ(7S),BODI(75)»CO.NSI(75,3),JUNCID(15,5),
JUNCU5,J),HWTRID(15,5),HWFLOWU5>,HWTEMP(15).HWOa(15>,
HW80D(i5)fH«CONS(15,3),WASTIO(90,5),TRFACX(90),MSFLOW(90),
H5TEMPC90),KSDOC90),dSBOD(90),WSCONS(90,3),QAToX(15),
A(500),8(500),CC500),0(15),S(500),ZC500),«C500),G(500),
FLOH(500),DEPIH(500),VEL(500),DTaVCL(500),K2(500),Kl(500),
HSNET(500),OL(500),VHM(15),DEPHH(15),OLHW(15),T(500),
00(500),800(500),CONS(500,3),PTIME,TPRIHT,DELX,
NHWTRS.NREACH,NHASIS«NJUNC,DELT,D1LT,D2UX,DTOOX2,DT20DX,
LAT,LSM,LLM,£LEV,DAT,AE,BE,OAKOFi',DRYBLa,WETBLB,DEWPT,
ATMPR,WIND,CLOUD,SONET,NI,NJ,TRLCD,TOFOAi,IIT,HC,TIME,NC3
20.    C
21.    C
22.          COMMON/HOOIF/ CK4K75),CK5(75),CKNH3(75),CKN02(75),CKN03(75),
23.         *       CKN,CKP,CKL,ALPHAO(75),ALPHA1,ALPHA2,ALPHA3,ALPHA4,
24.         *       ALPHAS,ALPHA6,GROHAX,RESPRT,ALGSET(75),SPHOS(75),
25.         *       SNH3<7S),KNH3(500),KH02C500),RESPR«{500),COLI(500),
26.         *       ALGAE(500),PHOS(SOO),CNH3(500),CN02(500),CN03(500),
27.         *       COLIR(75>,ALGI(75),PH05I(75),CNH3I(75),CN02IC7S),
28.         *       CN03I(75),COLIIT(75),ALGIT(75).PH05IT(75),CNH3IT(75),
29.         *       CN02IT(75},CN03IT(75),HSCOLI(90),WSALG(90),HSPHOS(90>,
30.         *       MSNH3(90),HSN02(90),HSN03(90),HNCOLI(15),I1UALG(15),
31.         *       HWPHOS(15),HWNH3(15),HWN02U5),HWN03U5),GROHTH(500),
32.         *       MODOPT(10),IRCHMO(750),EXCOEF(75)
33.    C.
34.    C
35.          COMMON/RAOION/ CJC6(75),RADNIT(75),RADNI(75),H«RAON(15),HSRADN(90),
36.         *               RADIO(SOO)
37.    C
38     C
39!          COMMON/S5TATE/X(500),ISS
40.          REAL K6
41.    C
42.    C                            INITIALIZE COUNTERS
43.    C
44.          NHN*0
45.          NWS*0
46.    C
47.    C                            LOOP' THROUGH REACHES AND COMP. ELEMENTS
48.    C
49.          DO 100 lal.NREACH
50.          NCELRsNCELRH(I)
51.          CNC£LR«NCELR
52.          RADIJs<3I(l)/CNCELR*RAOMI(l)
53.          DO 100 J>1,NCELR
54.          IOR*ICLORO(I,J)
                                          172

-------
55.    C
56.    C                            INITIALIZE DIAGONAL AND KNOWN TERMS
57.    C
58.          TC*0.5S6*(T(IOR)-«8.0)
59.          K6«CKfi(I)»l.047*«TC
60.          REACT»D1LT*K6
61.          8UOR)«X(IOR)*REACT
62.          S(IOR)*RADIOUOR)
63.          IF (ISS.GT.O) SUOR)*0.0
64.          S(IOR)*S(XOR>+RADIJ*OTO.VCL(IOR)
65.          IFL*1FLAG(X,J}
66.    C
67.    C                            MODIFY DIAGONAL AND/OR KNOWN TERMS
68.    C
69.          60 TO (101.100,100,100,100,103,104), IFL
70.    C
71.      101 NHW*NHN+1
72.          S(IOR)sS(IOR)-A(IOR)*HHRADN(NHW)
73.          GO TO 100
74.    C
75.      103 NHS3NHS+1
76.          S(IOR)*S(IOR)+NSFLOH(NHS)*HSRADN(NWS)*OTOVCL(IOR)
77.          GO TO 100
78.    C
79.      104 NHS3NHS+1
80.          B(IOR)«B(IOR)-WSrLOH(NHS)*OTOVCL(IOR}
81.      100 CONTINUE
82.          RETURN
83.          END
                                          173

-------
SUBROUTINE REAERC*
          Subroutine REAERC determines the reaeration coefficient for
each computational  element through the use of any one of seven
different procedures.   However, the same procedure must be used for
all computational  elements within an individual  reach.   The choice of
which procedure to use is controlled by input options for each reach.
The seven options, procedures, and references are:
          OPTION & PROCEDURE
     1.   Read-in K2 values
                     0.969
     2.   K2 = 5.026^^x2.31
     3.  K,
              (Dmu)
                   0.5
                m
                 JT5
   x 86,400
                         REFERENCE
                         None
                         Churchill  et al  (1962)
                                        0'Conner and Dobbins (1958)
                   0.67
4.  K2 = 9.4
                        x 2.31
                         Owens  et al  (1964)
                           u*
     5.  K2 = 10.8(1  + /F)' p-x 2.31
     6.  K2 = 3.3
.333
     x 2.31
                         Thackston and Krenkel  (1966)
                                        Langbien and Durum (1967)
     7.  K, = aQc
                         None
     8.  K2 » 3600KSeu
                         Tsivoglou and Wallace (1972)
*This subroutine is unchanged from the original version of QUAl
 except for the addition of the Tsivoglou option.  All symbols
 used are defined at the end of this section of the Documentation Repor+.
                                    174

-------
where
          u   =  velocity (feet/sec)
          D   =  depth (feet)
          Dm  =  molecular diffusion coefficient (2.25 x 10"8 ft2/sec)
          F   =  Froude Number  =  u/ v'tfg
          u*  =  shear velocity (ft/sec)
              »  u n /g/1.49 D0-16?
          g   -  acceleration of gravity (32.2 ft/sec2)
          n   =  Manning's roughness coefficient
          K   -  constant (range approximately 0.05 to 0.1/ft)

          The subroutine flow chart is illustrated in Figure VI-18 and
is followed by the program listing.  All program variables contained in
COMMON are defined in Section VII.
                                   175

-------
                               ENTER
                          SUBROUTINE REAERC
                                                    DO COMPUTATIONS
                                                    FRON «, TO b
                                                    FOR STREAM REACHES
                           SET ICj OPTION
                        FOR ALL COMPUTATIONAL
                          ELEMENTS IN REACH
                                                    00 COMPUTATIONS FROM »z TO b
                                                    FOR ALL  COMPUTATIONAL ELEMENTS
                                                    WITHIN THE STREAM  REACH
               OPTION 1
             SET Kg EQUAL
           TO VALUES READ-IN
 OPTIONS 2-8
CALCULATE K

                               RETURN
                               TO QUAL
FIGURE  VI-18.    aOW CHART  FOR SUBROUTINE  REAERC
                                 175

-------
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
42.
43.
44.
45.
46.
47.
48.
49.
50.
51.
52.
53.
54.

C
C
C
C
C
C
C
C
C
















C

C
C
C
C
C
C






C
C
C
^
<•
C
C
C
C.
C
C
C
C
C
C
SUBROUTING REAERC
                        REAERC CAN EITHER READ IN REAERATION
                        COEFFICIENTS  (OPTION!), COMPUTE THKM
                        USING A SELECTED EQUATION (OPTION 2,3,
                        4,5, AND 6),  OR COMPUTE THEM BASED ON
                        K2«A*Q,**B«  ALL. K2'S  ARE TO THE BASE. E.
COMMON TITLEC20,20),RCHID(75,S),RMTHOR(75),RMTEOR(75),NHWWARUS),
       TARGDO<75).IAUGOR(75,6),NCELRH<7S),1FLAG(75,20),
       ICLORO(75,20),CO£FQV(75>,EXPOQV<7S),COEFQH(75),EXPOO.H(75>,
       CMANN(75),CKU75),CK3(75>,K20PT(75),CK2(75),COEQK2(75),
       EXPQK2<75),TINITC75),DOINIT(75),BOINIT(75),COmT(75,3),
       0.1(75),II (75),001(75),3001(75),CDNSH75,3). JUNCID( IS,3),
       JUNC(15,3),HWrRID(l5,5),HWFLOW(15),HWTEMP(15),HWDO(15),
       H*|BOD(15),HWCO*S(15,3),HASTID(90,5),TRFACT(90),WSFLOH(90),
       W5TEMP(90),WSDO(90),WSBOD(90),WSCONS{90,3),OATOT(15),
       A(500).8(500),C(500),0(15),5(500),2(500),«(500),C(500),
       FLOW(500),DEPTH(500),VEL(500),DTOVCL(500),K2(500),K1(500),
       H5NET(500),OL(500>,VHW(1S),OEPHW(15),OLHW(15),T(500),
       00(500),BOO(500),CONS(500,3),PTIME,TPRINT,DELX,
       NHHTRS,NREACH,NWASTE,NJUNC,DELT,DILI,02LI,DTOOX2,OT200X,
       LAT,L5M,LLM,EL£V,DAI,AE.BE,DAYOFlf.DRYBL8,HETBLB,OEWPT,
       ATMPR,«IINO,CLOUD,SONET,NI,NJ,TRLCD,TOFDAY,NT,NC,TIME,NCS
REAL K2,K2T
                                  STEP 1-0
                                  LOOP THROUGH SYSTEM OF NREACH RE
                                  AND NCELR COMPUTATIONAL ELEMENTS
                                  REACH.
DO 100 I»l,NREACH
NCELR«NCELRH(I)
KOPT*K20PT(I)
DO 100 J»l,NCELR
IOR»ICLORD(I,J)
IFL*IFLAG(I,J)
                                  STEP 1-1
                                  SELECT K2'S FOR ANY OPTION AS DE
                                  BY REACH.
                                  KOPT
                                  KOPT
                                  KOPT
                                  KOPT
                                  KOPT
                                  KOPT
                                  KOPT
                                  KOPT
1  K2 IS READ IN.
2  CHURCHILL (1962)
3  O'CONNER • DOBBINS (19
4  OWENS, EDWARDS, - SIBB
5  THACKSTON - KRENKEL (1
6  LANGBIEN - DURUM (1967
7  K2 = A * 0 ** B
8  TSIVOGLOU - WALLACE (1
                            177

-------
55.    C.
56.          GO TO (101,102,103,104,105,106,107,108), XOPT
57.      101 K2UOR)«CK2CI.)
58.          GO TO 100
59.      102 K2(IOR)a5.026*VEL(IOR>**0.969/DEPTH(XOR)**l.673*2.31
60.          GO TO 100
61.      103 DM«2.25E-08
62.          K2CIOR)*SO,RTCDM.*VEL(IOR>)/OEPTH(IOR)«'*1.5*8.64£*04
63.          GO TO 100
64.      104 K2(IOR)=9.4»VEL(IOR)*»0.67/DEPTH(IOR)*'»1.85*2.31
65.          GO TO 100
66.      105 Fs0.176*VELCIOR)/SQRTCDEPTH(IOR)>
67.          SHRVEL=5.675*VEL(IOR)*CMANN(I)/(1.49»DEPTHUOR)**1.167)
68.          K2(IOR)»10.8*(1.0+SQRI(r))*SHRVEL*2.31
69.          GO TO 100
70.      106 K2CIOR)a3.3*VEL{IOR)/D£PTH(IOR)*«l.333*2.31
71.          eg TO 100
72.      107 K2(IOR)sCOEQK2(I)*r[iOM(XOR)**eXPQ.K2U)
73.          GO TO 100
74.      108 CC2 ' COEQK2(I)
75.          SLOPE » EXPQK2CI)
76.          IFCSLOPE.GT.0.0) GO TO 81
77.          ir(CMANNU).GI.O.O) GO TO 82
78.          WRITE(NJ,999)
79.      999 FORHAIC1H1,10X,S4H***XMPROPER PARAMETER SPECIFICATION FOR K2 OPTIO
80.         IN 8 — /11X,42H***MUSI SPECIFY CHANNEL SLOPE OR. ROUGHNESS )
81.          CALL EXIT
32.    C  CALCULATE DELTA H FROM CHANNEL. SLOPE
83.       81 K2UOR) * SLOPE * VEL(IOR) * CC2 * 3600.
84.          GO TO 100
85.    C  CALCULATE DELTA H FROM MANNING EQ.
86.       82 K2T » CMANN(L)*CMANN(I)»VEL(IOR)*»3/DEPTH(IOR)»»<4./3.)
87.          K2CIOR) s CC2*K2T*1630.3
88.      100 CONTINUE
89.          RETURN
90.          END
                                      178

-------
SUBROUTINE SOVMAT

          Subroutine SOVMAT remains unchanged from the original version
of QUAL as documented by the Texas Water Development Board (1970).
According to that reference:
               Subroutine SOVMAT solves a system of simultaneous
          linear equations whose coefficient matrix is of tri-
          diagonal form by using a modified Gaussian Elimination
          algorithm.
The solution algorithm is presented, in detail, in Section V.  The
subroutine flow chart shown in Figure VI-19 is taken from the Texas
Water Development Board reference.  The program listing follows the
Figure.
                                    179

-------
                                              HAVE
                                          EQUATIONS F0«
                                         ALL ELEMENTS SEEN  ,
                                          SOLVED BY SACK  /
                                           SUISTITUTION
FIGURE VI-19.   FLOW CHART  FOR  SUBROUTINE SOVMAT
                           180

-------
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
2fl
* o .
29.
1ft
J v •
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
42.
43.
44.
45.
46.
47.
48.
49.
50.
51.
52.
53.
54.
55.
56.
57.
58.
59.
60.
61.
62.
63.
64.
65.
66.
67.
68.
69.
70.

C
c
C
c
c
c
• c
c
c
















c

c

c
c
c
c.

c
c
c
c
c.
c







c
c
c
c
c
101


c
c
c
c
c
102



c
c
«•.
SUBROUTINE SOVMAT


SOVMAT SOLVES A SYSTEM Or SIMULTANEOUS
LINEAR EQUATIONS WHOSE COEFFICIENT
MATRIX IS OF TRIOIACONAL FORM USING
A MODIFIED GAUSSIAN ELIMINATION TYPE OF
ALGORITHM.


COMMON TITLE(20,20),RCHID(75,5),RMTHOR(75),RMTEOR(75),NHUNAR(15),
TARGDO(75),IAUGOA(75,6),NCELRH(7S),IFLAG(75,20),
ICLORD(75,20),CO«FQV<75),EXPOQV(75),COEFQH(75),£XPOQH(7S)»
CMANN(75),CKU75),CK3(75),K20PT(75),CK2(75),COEQK2(75),
EXPQK2(75),TINII(75),DOINIT<75),B01NIT(75),COIN1I(75,3),
QI(7S),riC75),OM(75),BODI(75),CQHSl(75,3),JUNCIOU5,5),
JUNC(1S,3>,HHTRIDU5,5),HUFLOW<15),HWTEMP(15),HWDO(15),
HWBOD(15),HMCONS(15,3),WASTID(90,5),TRKACT(90),HSFLOW<90),
WSTEMP<90),MSDO(90),riSBOD(90),HSCONS(90,3),QATOT(15>,
A(500), 8(500), C(500),D( 15), SC500), 2(500), W(500),G(500),
FLOH(500),DEPrH(500),VEL(500),DiaVCL(SOO),K2(500),Kl(500),
HSNET(500),OL(500),VHW(i5),OEPHH(15),DLH*U5),T(500),
00(500), 800(500), CON5(500, 3), PTIME,TPRINI,DELX,
NHWTRS.NREACH,MWAST£,NJUNC.DELT,D1LT,02LT,DTODX2,OT20DX,
LAT.LSM,LLM»ELEV,DAI,AE,BE,DAYOFY,DRYBLB,WETBLB,DEWPT,
ATMPR, HIND, CLOUD, SONET, NI,NJ,TRLCD,IOFDAY, NT, NC,TIMS.NCS

COMMOH/OUTPUT/IRPT1

DIMENSION IFLG(SOO)

STEP 1-0
INITIALIZE COUNTER FOR STREAM JU

IJUNC'O

STEP 2-0
LOOP THROUGH SYSTEM OF NREACH RE
WITH NCELR COMPUTATIONAL ELEMENT
REACH.

00 100 HI, NREACH
NCELR«NCELRH(I)
DO 100 J«l, NCELR
IOR»ICLORD(I,J)
IFLslFLAG
-------
 71.    C                                       TYPE 4.
 72.    C
 73.      103 IJUNC»IJUNC*1
 74.          NS«1
 75.          NN3JUNC(IJUNC;,NS>
 76.          S(IOR)«SUOR)-DUJUNCO*G(HN>
 77.          DENOM*B(XOfD-AUOR)>MUOfl»n-0(XJUNC)*M(NN)
 78.          W(IOR)*CUOR)/DENOM
 79.          G(IOR)»(S
-------
SUBROUTINE TEMPS*

          Subroutine TEMPS is used for dynamic temperature simulations
and completes the setup of the equations necessary to calculate temperatures
in each computational element.  Specifically, the subroutine completes the
definition of the diagonal term of the coefficient matrix and defines the
vector of known terms on the right hand side of the equations.

          The additions to the diagonal term represent the individual
constituent changes caused by constituent reactions and interactions,
and mass changes caused by stream withdrawals.  The resulting diagonal
term for each type of computational element is:
          TYPE                           DIAGONAL TERM
     All except type 7                 b.  =  x.,-
     7.  Withdrawal                    b1  =  x1 - qfl ^-   '

where x^ is defined in Subroutine TRIMAT.

          The right hand side term contains all known inputs, which
include headwater inflows, wastewater discharges, tributary flows and
incremental runoff, and the concentration in the previous time step.
The known term for each type of element for dynamic simulation is:
          TYPE
     1.  Headwater         S.  =  T* * ^- + ql T! ^ - a-Th


                                   *    1     '  ' At        At
     6.  Waste input       s,  =  T,  * -L- * ,, T, §* + qwTw £


                                   *   "i     '  ' At
     All Others            S.  =  T.  + J-+ q  T. £!
                                       dT.    1    Vi
*AII  symbois used are defined at the end of this section
 of  the QocurrenCation Repor*.
                                   183

-------
          The subroutine flow chart is illustrated in Figure VI-20 and
is followed by the program listing.  All  program variables contained in
COMMON are defined in Section VII.
                                    184

-------
                                (am        ^
                            SUMOUTINE TEMPS    ]
                              INITIALIZE
                             COMTEK WO
                           CONVERSION FACTORS
                              CALL HEATEX
                                                 00 CMpuUtlMI
                                                 fmi • to b far
                                                 • 11 CMWUtlorw!
                                                 ill
                            INITIALIZE KNOWN
                           TERM AM DIAGONAL
                            TEW FOR DYNAMIC
                              SIMULATION


TYPE 1
ADO INCREMENTAL INFLOW
AND HEAOMATER INPUTS
TO KNOWN TERN,
S(U



TYPES 2. 3. S
ADD INCREMENTAL
INFLOW TO KNOWN
TEW. SO)



TYPE 4
ADO INCREMENTAL
INFLOW TO KNOWN
TEW, S(I)



TYPE 6
WO INCREMENTAL INFLOW
AND WASTEWATER INPUTS
TO KNOWN TERM.
S(I)



TYPE 7
ADO INCREMENTAL INFLOW
TO KNOWN TERM, S(I). AND
SUBTRACT STREAM
WITHDRAWAL FROM
DIAGONAL TERM, 8(1)


                               RETURN
                               TO QUAL
FIGURE  VI-20.    FLOW  CHART FOR  SUBROUTINE  TEMPS
                             185

-------
1.
2.
3.
4.
5.
5.
7.
3.
9.
10.
11.
12.
13.
14.
IS.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
42.
43.
44.
45.
46.
47.
48.
49.
50.
51.
52.
53.
54.

C
c
















c.
c

c
C:
C





C:
c.
C:




c;


c
c-
c:


c;
c
c.

C!
101



SUBROUTINE TCNPS
COMMON TITLE(20,20),RCHID<7S,5),RMTHOR(75),RMIEOR<75),NHWWAHU5),
       TARGDO(75).lAUGaR(75,6),NCELRH(75),IFLAG<75,20),
       ICLOROC75,20),CO£FQV(75),EXPOQV<75) ,COEFQHC75) ,EXPOO.H(75) ,
       CMANN(75),CK1(75),CK3(75),X20PT(75),CK2(75),COEQK2(75),
       EXPQK2<75>,TINir(75),DOINIT(75>,BOINIT<75),COlNITC75,3),
       gi(7S>,TI(75),DOI(75),aODI(75),CaNSI(75,3>,JUNCID(l5,5),
       JUNC(15,3),HWTRIDU5,5),HWFLOWU5),HWTEMP(15),HWDO.(15),
       HWBODUS),HWCONS(1S,3),HASTID(90,5),TRFACT(90),WSFLOW(90),
       «STEMP(90).WSDO(90),HSBOD(90),WSCONS(90,3),QATOT(15),
       A(500),B<500),C.(500),0(15),3(500),2(500),W(500),G(500),
       FLOW(500),D£PTH(500),VEU(500),DTO.VCL(500),K2(500),K1(500),
       HSNET(500),DL(SOO),VHN(1S),DEPHNU5),DLHW(1S),T(500>,
       00(500),800(500),CON5(500,3),PTIME,TPR1NT,DELX,
       NHWTR5,NREACH,NWASIE,NJUNC,DELT,D1LT,D2LT,DTODX2,DT200X,
       LAT, LSN , bLM , ELEV , OAT,AE,BE, 0AYOFX , DRY BLfr, HEtBLB, OEWPT ,
       ATMPR,WIND,CLOUD,SOHEI,NI,NJ,TRLCD,TOFDA)f,HT,NC,TIME,NCS
COMMON /S3TATE/; X(500),I55

                       INITIALIZE COUNTERS

NHM'O
NNSsO
IJUNC>0
RHOCP«62.4
CALL HEATEX
                       LOOP'THROUGH REACHES AND .COMP. ELEMENTS
00 100 Isl,NR£ACH
NCELR*NCELRH(I) '
CNCELR'NCELR
TPIJ«gi(I)/CNCCLR*TI(X<)

00 100 J«1,NCELR
IOR»ICLORO(I,J)

                       INITIALIZE KNOWN TERMS

BUOR)»X(IOR)
IFL«IFLAG(I,JO

                       MODIFY DIAGONAL AND/OR KNOWN TERMS

GO TO (101,102,102,104,102,103,105), IFL
AOEPTH»0.5*(DEPHW(NHH)*OEPTH(IOR)>
REACIsHSNET(IOR)/(RHOCP*ADEPTH)
S(IOR)»T(IOR)+REACT+rPIJ»OTOVCL(10R)-A(IOR)»HWTEHP(NHW)
                             186

-------
55.          GO TO 100
56.    C
57.      102 ADEPTH»0.5*(DEPTHaOR-mDEPTH(IOR))
58.          R£ACT»HSNET(IOR>/(RHOCP»AOEPTH)
59.          5UOR)«TUOR)*«EACT+TPIJ*OrOVCLUOR>
60.          60 TO; 100
61.    C
62.      103 NHSMNS+l
63.          ADEPIH»0.5»(DEPTH(IOR-mDEPTHUOR))
64.          REACT«HSHET(IOR)/(RHOCP*ADEPTH)
65.          5(IOR)«T(IOR)+REACT+(TPIJ*W5rLOi«(MW5)*«5TEMP(««3))*OXQVCI.(IOR)
66.          CO TO 100
67.    C
68.      104 IJUNCWIJUHC+1
69.          HS»1
70.          NN«JUNC(XJUNC:.NS)
71.          ADEPTH«0.25*8(IOR)-HSFl>ON(N«S)*OIOVCI.(XOR)
81.      100 CONTINUE
32.          RETURN
83.          END
                                         187

-------
SUBROUTINE TEMPSS*

          Subroutine TEMPSS is used for steady-state simulations and has
two main functions.  First, the heat flux terms that were not computed in
HEATER (i.e. those that are dependent on water temperature:  back radiation,
evaporation, and conduction losses) are computed.  These heat budget terms
correspond to those calculated in step (3-0) of HEATEX (dynamic simulations)
except that in TEMPSS, the loss terms are combined and the water temperature
dependent terms separated out.  In order that these terms be separable,
functional relationships for the computation of back radiation and
evaporation must be linearized, as noted in Section IV.

          The second main function of TEMPSS is the same as that of TEMPS,
namely to complete the setup of the equations necessary to calculate
temperature in each computational element.  Specifically, the subroutine
completes the definition of the diagonal term of the coefficient matrix
and defines the vector of known terms on the right hand side of the equations.

          The additions to the diagonal term represent the individual
constituent changes caused by constituent reactions and interactions, and
mass changes caused by stream withdrawals.  The resulting diagonal term
for each type of computational element is:
          TYPE                     DIAGONAL TERM
     All except type 7        b1  =  xi +
     7.  Withdrawal           b,  =  x, +    I  ^
where x^ is defined in Subroutine TRIMATE, and [hfT)]^ refers to the
temperature dependent heat flux terms.
*AII symbols used are defined at the end of this section of the
 Documentation Report.
                                   188

-------
          The right hand side term contains all known inputs, which
 include headwater inflows, wastewater discharges, tributary flows,
 incremental runoff, and in this case, the heat flux terms that are not
 dependent on water temperature.  The known term for each type of element
 for steady-state simulation is:
          TYPE                     RIGHT HAND SIDE

     1.  Headwater            S.


     6.  Waste Input          S..


     All Others               Si


where h.i" refers to water temperature independent heat flux terms.

          In comparing these terms with those computed in TEMPS for
dynamic simulations, note that the heat flux term (hj) has been separated
 into a water temperature dependent term [h(T)]^ and a water temperature
 independent term h^, the former considered an unknown and the latter a
known term in the solution.  Note also the absence of At terms and the
temperature from the previous time step (T?), since this is a steady-
state solution.

          The subroutine flow chart is illustrated in Figure VI-21 and
is followed by the program listing.  All program variables contained in
COMMON are defined in Section VII.
   n.t   q  T.   q  T
=  -- + -—- + J~1
 139

-------
                     C
                     V
                        nwoumt TOTSJ


nrruua
coutra
COWUSIM
! AM
MCTOH
                                           00 COMPUTATIONS
                                           nm • TO b ran
                                           AU COmTATIOML
                                           ELDOTS
                       nrruuzi MOM TQM
                        AM OIAOOML TOM
                        mt STtAOT-STATt
                          SIHJLATJOU
1 1
rm i
AOO INCREMENTAL INFLOW
AM) HEADWATER INPUTS
TO KNOWN TERM.
TYPES Z. 3. 5
AOO INCREMENTAL
INFLOW TO KNOWN
TERM, so

1 1
TTPt t
AOO INCREMENTAL
INFLOW TO KNOW
TERN, s(i)

TYPE 5
AOO INCREMENTAL INFLOW
AM UASTEUATER INPUTS
TO KMOM TERM.

TYPE T
AOO INCREMENTAL INFLOW
TO DOWN TERM. S(I). ANO
SUITRACT STREAM
WITHDRAWAL TOM
DIAGONAL TERM. 8(1)
                            RETURN
                            TO OUAL
FIGURE  VI-21.   FLOW CHART  FOR  SUBROUTINE TEMPSS
                            190

-------
  1.          SUBROUTINE TE.HPSS(NITER)
  2.          COMMON T1TLE(20,20),RCHID(7S,5),RMTHOR(75),HMTEOR(7S),NHHWARU5),
  3.         *       TARGDO(75),IAUGO*(75,6),NCELRH(75),IFLAG(75.20),
  4.         *       ICLORO(75,20),CO£FO.V(75),EXPOQV(75),COEFQ.H(7S),EXPOQH(7S),
  5.         *       CMANN(75),CK1(75),CK3(75),K20PT(75),CK2(75),CO£O.K2(75),
  6.         *       EXPO.K2C75),TINII(75),DOINIT(75),BOINIT(75),COINIT(75,3),
  7.         *       01(75),11(75),DOJ(75),BODI(75),COflSI(75,3),JUNCIDU5,5) ,
  8.         *       JUNC(15,3),HHTRID(15,5),HHFLOH(15),HHTEMP(1S),HWOO.(15),
  9.         *       HWBOD(15),HWCONS(1S,3),HA5TID(90,S),TRFACT(90),«SFLOW(90),
 10.         *       WSIEMP(90),hSOO(90),HSBOD(90),W5CONS<90,3),QATOT(l5),
 U0         *       A(500),8(500),:(500),0(15),S(500),2(500),W(SOO),GC500),
 12.         *       FLOW(500),DEPTH(500),VEL(500),DTa.VCL(500),K2(500),KH500),
 13.         *       HSN£T(500),DL1500),VHW(15),DEPHWU5),DLH«(15),1(500),
 14.         *       00(500),BOD(500),CONS(500,3),PTIME,TPRINI,DELX,
 IS.         *       NHWTRS,NREACH,NWASTE,NJUNC,D£LT,D1LT,02LT,DTODX2,DT200X,
 16.         *       LAT,LSH,LLM,El,EV,DAI,AE,BE,OAYOFX,DRXBLB,WeTBLB,DEW(»T,
 17.         *  .     ATMPR,MIND,CLOUD,SONET,NI,NJ,TRLCD,TOFDA]f,NT,NC»TIME,HCS
 18.          CONMOM/SSTATE/X(500),ISS
 19.          DIMENSION ALPHAK21), AOPHA2(21) ,BETAK2l) ,bETA2(2i)
 20.          DATA ALPHA1/-0.105,-0.161,-0.260,-0.360,-0.503,
 21.         S             -0.671,-0.892,-1.144,-1.474,-1.842,
 22.         A    -2.318,-2.858,-3.504,-4.264,-5.146,
 23.         B    -6.202,-7.375,-8.767,-10.342,-12.162,-14.214/
 24.          DATA BETA1/0.0088,0.0102,0.0124,0.0144,0.0170,
 25.         S             0.0198,0.0232,0.0268,0.0312,0.0358,
 26.         A    0.0414,0.0474,0.0542,0.0618,0.0702,
 27.         B    0.079,0.090,0.107,0.114,0.128,0.143/
 28.          DATA ALPHA2/71.84,70.80,69.63,68.33,66.90,65.34,
 29.         S             63.39,61.43,59.33,56.93,54.38,51.68,
 30.         A    48.83,45.43,42.28,38.59,34.76,30.70,26.39,21.83,17.027
 31.          DATA BETA2/0.826,0.852,0.878,0.904,0.930,0.956,
 32.         S             0.986,1.014,1.042,1.072,1.102,1.132,
 33.         8    1.162,1.196,1.226,1.259,1.292,1.326,1.361,1.396,1.431/
 34.          CONMON/SSTEMP/JT(500),SOLR;H(75),CLDRCH(75),PATRCH(75),
 35.         *             TDBRCH(7S),TMBRCH(7S),HlHRCHt75)
 36.          REAL MU,LAMBDA
 37.          IF (NITER.EQ.O) CALL HEATER(NITER)
 38.          NHMsQ
 39.          NMS*0
 40.          IJUNC=0
 41.          RHOCP'62.4
 42.          DO 100 lal.NREACH
 43.          VPHB*0.1001*EXP(0.03*TNBRCH(I))-0.0837
 44.          VPAIRsVPWB
 45.         *     -0.000367*PATRCHU)*(TDBRCH(I)-TWBRCH(I))«
 46.         *       (1.0>(T»IBRCH(I)-32.0)/157l.O)
 47.          CLC*1.0t0.17*CLDRCH(I)»»2
 48.          HAs4.85E-15*(TDBRCH(I)t460.0)**6*CLC
 49.          NCELR3NCELRH(I)
 50.          CNCELHsNCeLR
51.          TPIJsQI(I)/CNCELR*TI(I)
52.          DO 100 J=l,iCELR
53.          IOR=ICLORD(I,J)
54.          IFL3IFLAG(I,J)

-------
 SS.          S(IOR)=0.
 56.          TJs
 64.          HSa3.687*SOLRCHU)/24.
 65.          MU*HS+HA-ALPHA2(M)-al*83
 66.          GO TO (101,102,102,104,102,103,105), IFL
 67.      101 NHHsNHH+1
 08.          ADEPTH«0.5*(D£PHH<;NHiO+D£PIH
 69.          R£ACT2MU*D2LT/(RHOCP*AD£PTH)
 70.          ST3TPXJ*DTOVCL(IOR)-A(IOR)*HWTEMP(NHW)
 71.          SUOR)»S(IOR)+REACT+Sr
 72.          B(IOR)=X(IOR)+LAMBOA»02LT/(RHOCP*ADEPTH)
 73.          GO TO 100
 74.      102 ADEPTH>0.5*(DEPTHUOR-l)tOEPTH(IOR))
 75.          REACT=MU*D2LT/(RHOCP«*DEPTH)
 76.          S(IDR)«S(IOH3*REACH-TPIJ*DTOVCL(IQR)
 77.          B(IOR)=X(IOR)+LAM6DA*02LT/(RHOCP*ADEPTH)
 78.          GO TO 100
 79.      103 NWSsNHS+1
 80.          AOEPTH>0.3*(DEPTHQOR-l)+D£PTHUaR))
 81.          REACT=MU*D2LT/(RHOCP*AOEPTH)
 82.          STs(IPIJtwSFLOH(NMS)*WSTEMP(NMS))*DTOVCL(IOR)
 83.          S(IOR)=SUOR)tREACT+ST
 84.          8(IDR)=X(IOR)*LAMBDA»D2LT/(RHOCP*ADEPTH)
 85.          GO TO 100
 86.      104 IJUNC=UUNCtl
 87.          NS=1
 88.          NNsJUNC(IJUNC,NS)
 69.          ADEPTH»0.2S*(DEPTH(IOR-1)+OEPTH(NN)+2.*DEPTH(XOR))
 90.          REACT=MU*02LT/(RHOCP*»OEPTH)
 91.          S(IQR)=S(IORJ+REACT+TPIJ*DTOVCL(IOR)
 92.          B(IOR)sX(10R)+LAM8DA*02LT/(RHOCP*ADEPTH)
 93.          GO TO 100
 94.      105 N*S=NWS-H
 95.          ADEPTH=0.5*(DEPTHUOR-l)+OEPTH(IOR))
 96.          REACT>MU*02LT/(RHOCP*AOEPTH)
 97.          S(10R)sS(IOR)4>REACTtTPIJ*OIOVCL(10R)
 98.          BT«MSFLOH(NWS)*OTOVCLQOR)
 99.          8(IOR)=X(IOR)tUMBOA»02LT/(RHOCP*ADEPTH)-BT
100.      100 CONTINUE
1U1.          RETURN
102.          END
                                         192

-------
SUBROUTINE TRIMAT

          Subroutine TRIMAT computes all coefficients for the implicit,
finite difference advection-dispersion equation for each computational
element except for the diagonal term.  In the case of the diagonal
term, b,., TRIMAT computes that portion of term that is fixed and
independent of the constituent to be simulated.  This fixed portion of
the diagonal term is designated as x..

          In general, the basic equation that TRIMAT sets up for a
computational element, i, is:

                    aizi-l + bizi + cizi+l  =  Si
where
          b^  =  x^ + (constituent dependent terms)
       a^,c.  =  off-diagonal terms
          S,  =  known term
          z   =  variable

In die case of a computational element that contains a junction and the
upstream element in the tributary stream is n, the basic equation becomes;

                    Vl-l*b1*1*el'l+l*Vn  '  S1

Table VI-1 contains the equations for each term in each type of
computational element.

          The subroutine flow chart is illustrated in Figure VI-22
followed by the program listing.  All program variables in COMMON are
defined in Section VII.
                                    193

-------
                                                 TABLE VI-1

                                         SUBROUTINE TRIMAT EQUATIONS

                                  FOR VARIOUS TYPES OF COMPUTATIONAL ELEMENTS*
Reach Type
1.  Headwater   -D, gr - Q,  ^
2. Regular
3.  Upstream    same as 2
   from
   junction
4. Junction    same as 2
   (with n)


5. End of      -(0, ,+D,]
                         - Qi_]
6.  Input       same as 2
7. Withdrawal   same as 2
(1.0 + (Di_1 + D.)


same as 2
(1.0 +(D.



same as 2


same as 2


same as 2
                                                       + 2D.
                                                                    Q1   )
same as 1


same as 2
                                                                         Q. ±± )     same as
                                                                          1  i
                                                                                       -0-
                                                                                    same  as  2
                                                                                    same  as  2

                                                                                                       none
                                                                                                       none
              -D
                                                                                                       none
                                                                                                       none
                                                                                                       none
Equations shown are for dynamic simulations.  For steady-state simulations,
 the 1.0 in the x term is 0.0 and the At's in all terms are set to  i.O.

-------
                                                    ENTRY
                                              SUBROUTINE TRIMAT
                                                  INITIALIZE
                                                  COUNTERS
                                                                          00 COMPUTATIONS
                                                                          FROM a TO b FOR
                                                                          ALL COMPUTATIONAL
                                                                          ELEMENTS	
                                           INITIALIZE FIXED COMPONENT
                                           OF DIAGONAL TERM, x(I).
                                             FOR STEADY STATE OR
                                             DYNAMIC SIMULATION
                                                  DETERMINE
                                             TYPE OF COMPUTATIONAL
                                                   ELEMENT
     TYPE 1
 HEADWATER ELEMENT
COMPUTE COEFFICIENTS
 TYPES  2. 3, 6 OR 7
   OTHER ELEMENTS
COMPUTE COEFFICIENTS
       TYPE 4
   JUNCTION ELEMENT
 COMPUTE COEFFICIENTS
A(I),  X(I), C(I). 0(1)
       TYPE 5
    FINAL ELEMENT
COMPUTE COEFFICIENTS
                                                   RETURN
                                                   TO QUAL
                   FIGURE  VI-22.    FLOW  CHART FOR  SUBROUTINE  TRIMAT
                                                    195

-------
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
IB.
19.
20.
21.
22.
23.
24.
25.
26.
27.
29.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
42.
43.
44.
45.
46.
47.
48.
49.
50.
51.
52.
53.
54.

C
C
c.
C
c
c
c
c
















c

c
c
c
c
c
c



c
c
c
c
c
c.








c;
c
c
c,
SUBROUTINE TRIMAT
                        TRIMAT COMPUTES THE COEFFICIENT MATRIX
                        FOR THE IMPLICIT-FINITE-OIFFERENCE FORM
                        OF THE ONE-DIMENSIONAb. (AOVECTION *
                        DISPERSION) TRANSPORT EQUATION..
COMMON TITLE(20,20),RCHIO(75,5),RMTHOR(75),RMTEOR<75),NHWWAR(15),
       TARGOO(75),IAUGOJl<75,6),NCELRH(75),IFLAG.(75,20),
       ICLORO(75,20),CO£FQV<75).EXPOQVC75),COEFQH(75),EXPOQH(75),
       CMANN(75),CK1(75),CK3(75),K20PT(75),CK2(75),COEQK2(75),
       EXPQK2(75),TINIT(75),DOINIT(75),BOINIT(75),COINITC75,3),
       01(73),TI(75),DOIC75),BODl(75),COJISI(75,3),JUNCID(15,5),
       JUNC(15,3),H«TRIDU5,5),HHFLOW(15),HWTEMP(15),HWOO(15),
       H«BODU5),HWCONS(15,3),WASTIO(90,5),TRFACT(90),«SFLOH(90),
       WSTEMP(90),WSDO(90),i«ISBOD(90),«SCONS(90,3),O.ATOTU5),
       A(500),6(500),C(500),D(15),5(500),Z(500),W(500),G(500),
       FLON<500),DEPTH(500),VELC500),DTO.VCL(500),K2(500),Kl(500),
       HSNET(SOO),OL(500),VHH(15),DEPHW(15),OLHrf(15),T(500),
       00(500),800(500),CONSC500,3),PTIME,TPRINT,OELX,
       NHWTRSVNREACH,NWASTE.,NJUNC,DELTfDlLT*02LT,DTODX2,DT200X,
       LAT,LSM,LLM,ELEV,DAT,AE,BE,OAYOFY,ORYBLfl,WETBLB,DEHPT,
       ATMPR.MINO,CLOUD.SONEI,NI,NJ,TRLCD,TOFDAl,NT,NC.,riME,MC3
COMMON/SSTATE/XC500),ISS
MHW*0
IJU»C»0
                                  STEP 1-0
                                  INITIALIZE COUNTERS FOR HEADWATE
                                  WASTE LOADS OR MITHORAULS, AND S
                                  JUNCTIONS.
                                  STEP 2-0
                                  LOOP THROUGH SYSTEM OF NREACH RE
                                  WITH NCELR COMPUTATIONAL ELEMENT
                                  REACH.
DO 100 1=1,NREACH
NCELR»NCELRH(I)
DO 100 J=t,NCELR
IOR«ICLORDU,J)
X(IOR) * 1.0
IF (ISS.GT.O) X(IOR)
IFLsiFLAG(I,J)
GO TO (101,102,102,103,104,102,102), IFL
> 0.0
                                  5TKP 2-1
                                  COMPUTE COEFFICIENTS B AND C
                                  ELEMENT OF TXPE. 1.
                                          FOR
                             196

-------
55.    C
56.      101 HHNaMHM+1
57.          AUOR)s»OTODX2*DLHW(NHH)-HMrLOH(NHW)*DTaVCL(IOR)
58.          X(IOR)»XCIOR)+OTODX2»
59.          C(IOR)«-DTOOX2*DL(IOR>
60.          GO TO 100
61.    C
62.    C                                       STEP 2-2
63.    C                                       COMPUTE COEFFICIENTS A,B, AND C
64.    C                                       ELEMENTS OF TYPE 2,3,6, OR 7.
65.    C)
66.      102 ACIOR)»-DTODX2»OLClOR-l)-FLOHUOH-l)*DIO.VeLUOR)
67.          X(IOR)»X(IOR)*DTOOX2*(DL(IOR-l)+DL(IOR))fFLOH(10R)*OTOVCL(IORJ
68.          C(IOR)>-DTOOX2*Db(IOR)
69.          GO TO 100
70.    C
71 e    C                                       STEP 2-3
72.    C                                       COMPUTE COEFFICIENTS A,B,C, AND
73.    C.                                       ELEMENT OF TYPE 4.
74.    C
75.      103 IJUNC»WUNC»1
76.          N3*l
77.          NN»JUNCCIJUNC,NS)
78.          DUJUMC)B-OTOOX2*OL
80.          X(IOR)»XUOR}+OTOOX2*(OUIOR-l)tDL(NN)+2.0*DL
92.          CUORJsO.
93.      100 CONTINUE
94.          RETURN
95.          END
                                        197

-------
SUBROUTINE WRPT2

          Subroutine WRPT2 is basically the same program as documented
by the Texas Water Development Board (1970).   Minor changes to report
headings and formats are the only differences from the original  version
of the program.   For dynamic simulation QUAL-II uses WRPT2 to print
intermediate summaries of simulation results  at preselected time intervals.
For steady-state simulations, the report is an optional form of outputting
the solution.  WRPT2 writes the concentration of the quality constituents
simulated for each reach and all computational elements within the reach.
For steady-state simulations the WRPT2 also reports within the reach.
For steady-state simulations the WRPT2 also reports the number of
computational elements that do not satisfy the convergent criteria.  The
following pages illustrate an example output report from WRPT2 for a
steady-state simulation.

          WRPT2 is produced by entering "WRITE INTERMEDIATE REPORT" on
card number 2 of the TYPE 1 input data (see User's Manual Form 2).

          Figure VI-23 illustrates the subroutine flow chart and the
following pages contain the program listing.   Variables in COMMON are
defined in Section VII.
                                    190

-------
to
RCH/CL
1 73.
2 73.
3 74.
4 7b.
5 75.
RCH/CL
1
2
3
4
5
8.
8.
8.
8.
7.
1
30
87
45
62
23
1
19
19
20
18
58
2
73.55
75.11
75.42
75.65
75.35
2
8.00
8.21
8.20
8.16
7.57
74
75
75
75

8
8

8
7
TEMPERATURE
34567
.30 74.10 74.58 74.90 75.10
.49 75.61 75.64
.66 75.66 75.66 75.66 75.66
.43 75.49 75.53 75.48 75.52
DISSOLVED OXYGEN IN MG/L
3
.00
.19

.15
.55
4
7.94
8.18

8.15
7.53

7.
8.

8.
7.
5
87
18

14
51
6
7.81


8.14
7.46
7
7.75


8.14
7.45
8
75.04
75.66
75.55
0
7.71


0.15
7.43
5-DAY BIOCHEMICAL OXYGEN DEMAND
RCH/CL
1
2
3
4
5
1.
1.
1.
1.
2.
1
94
95
92
74
92
2
2.14
1.90
1.84
1.69
3.00

2
1

1
3
3
.30
.85

.65
.08
4
2.39
1.80

1.62
3.15
AMMONIA
RCH/CL
1
2
3
4
5
0.
0.
0.
0.
0.
1
03
02
02
02
07
2
0.02
0.02
0.02
0.02
0.07

0
0

0
0
3
.02
.02

.02
.07
4
0.02
0.02

0.02
0.07
NITRITE
RCH/CL
1
2
3
4
5
0.
0.
0.
0.
0.
1
00
00
00
00
00
2
0.00
0.00
0.00
0.00
0.00

0
0

0
0
3
.00
.00

.00
.00
4
0.00
0.00

0.00
0.00
NITRATE
RCH/CL
1
2
J
4
5
0.
0.
0.
0.
0.
1
49
SO
50
49
63
2
0.49
0.49
0.49
0.49
0.63

0
0

0
0
3
.49
.49

.48
.63
4
0.49
0.49

0.48
0.63

2.
1.

1.
3.
AS N

0.
0.

0.
0.
AS N

0.
0.

0.
0.
AS N

0.
0.

0.
0.
5
51
76

58
23
IN
5
02
02

02
07
IN
5
00
00

00
00
IN
5
48
49

48
63
6
2.62


1.54
3.33
MG/L
6
0.02


0.02
0.07
MG/L
6
0.00


0.00
0.00
MG/L
6
0.48


0.48
0.62
7
2.73


1.51
3.40

7
0.02


0.02
0.06

7
0.00


0.00
0.00

7
0.48


0.40
0.62
8
2.75


1.47
3.46

8
0.03


0.02
0.06

8
0.00


0.00
0.00

8
0.62


0.48
0.62
                                                                                         ITERATION  3
                                                               9    10    11    12    13    14    15    16

                                                           75.IB 75.20 75.34 75.39 75.42 75.44 75.45 75.46
                                                           73.36 74.IB
                                                           75.57 75.55 75.57 75.58
                                                                                         ITERATION  3
                                                                                      13    14    IS    16
   9    10    11     12

7.67  7.62  7.58   7.54  7.51   7.47  7.44  7.42
                                                            7.88  7.95
                                                            7.42  7.39  7.38  7.37
                                                                                         ITERATION  3
                                                                                      13    14    15    16
   9    10    11    12

2.84  2.92  2.99  3.06  3.13  3.20  3.26  3.31
                                                            1.73  1.70
                                                            3.51  3.58  3.64  3.70
                                                                                         ITERATION  3
                                                                                      13    14    15    16
   9    10    11    12

0.03  0.03  0.03  0.03  0.03  0.03  0.03  0.03
                                                            0.17  0.17
                                                            0.06  0.06  0.06  0.06
                                                                                         ITERATION  3
                                                                                       13    14    15    16
   9    10    11    12

0.00  0.00  0.00  0.00  0.00  0.00  0.00  0.00
                                                            0.00  0.00
                                                            0.00  0.00  0.00  0.01
                                                                                          ITERATION  3
                                                                                       13     14    15    16
   9    10    11    12

0.61  0.61  0.60  0.60  0.60  0.59  0.59  0.59
                                                             0.76  0.76
                                                             0.62  0.61  0.61  0.61
                                                  17
17
17
17
17
17
      18
18
18
18
18
IB
      19
19
19
19
19
19
            20
      20
20
                                                                    20
20
                                                                    20

-------
0.10
0.10
0.10
0.10
0.12
           0.10
           0.10
           0.10
           0.10
           0.12
        0.10   0.10  0.09  0.09
        0.10   0.10  0.10
                                         0.09  0.10  0.10
        0.10   0.09  0.39   0.09   0.09   0.09   0.18
        0.12   0.12  0.12   0.12   0.12   0.11   0.11
RCH/CL  1
                   ALGAE AS CHL.A IN UG/L
                    3456
                                                  8
                          10

                        0.10
                                                           0.18
                                                           0.11
                                                             10
                                                                   11    12    13    14    15    {£

                                                                 0.10  0.10  0.10  0.10  0.10  0.09
                                                                                                  17
                                                                 0.11  0.11
                                                                             ITERATION  3
                                                                          13     14     IS
  I  9.77 12.34 12.12 13.86 13.64 13.43 13.23 14.18 14.00 13.83
  2  9.64  9.29  8.96  8.65  8.35
  3  9.41  8.87
  4  8.40  8.25  8.11  7.97  7.84  7.70  7.57  7.45 16.94 16.88
  5 13.94 13.86 13.78 13.71 13.63 13.35 13.27 13.19 13.12 12.95 12.88 12.80
                                                                   11    12    13    14    IS    16

                                                                13.65 13.49 13.32 13.16 13.00 12.84
                                                                                                       17
                   FECAL COLIFORM IN NO./100 HL
HCH/CL
  1
    CL

RCH/CL
  2
RCH/CL
  3
RCH/CL
  4
    CL

RCH/CL
  5
    CL
  1
,03E  05
 11
,83E  05
  1
.80E  05
  1
,73£  05
  1
,18E  05
 11
             3.54C 05
               12
             I.69E 05
                2
                            3.25E 05
                              13
                            1.57E 05
                               3
   3.HE 05  2.87E 05
                  1.62E 05  1.46E OS
                  i.49t OS
                     2
                  1.09E 05
                    12
     14
   1.45E 05
      4
   1.31E 05
      4
                            l.OOE 05  9.20E 04
                              13
     14
         15
       1.34E 05
          5
       1.1BE 05
          5
       8.46E 04
         IS
         ,47E 05  1.37E 05  1.28E 05  1.19E 05  1.11E 05
          11        12        13        14        IS
         .13E 04  6.64E 04
              6
           2.65E
             16
           1.24E
              6
              6
           7.78E
             16

              6
           1.02E
             16
                                                                                  ITERATION  3
                                                                       7         8         9        10
                                                                05  2.44E OS  2.31C 05  2.14E OS   1.98E 05
                                                                      17        18        19        20
                                                                05
                                                                       7         8         9        10
                                                                                 8
                                                                                                    10
                                                                  7          8          9         10
                                                           04   7.15E 04   6.58e  04   2.S2E  05   2.37E  05
                                                                 17         18         19         20

                                                                  7          8          9         10
                                                           05   9.48E 04   8.84E  04   8.24E  04   7.63E  04
                                                                 17         18         19         20
RCH/CL  i

  1 82.53
  2 97.62
  3 97.54
  4 96.35
  5 97.79
RCII/CL  1
                   CONSERVATIVE MINERAL
                    3456
                                     TOS IN HG/L
                                        8     9
                                                             10
          88.96 88.51 92.86 92.45 92.04 91.64 96.15 95.75 95.37
          97.25 96.88 96.52 96.17
          97.10
          96.17 95.98 95.80 95.62 95.44 95.26 95.09109.63109.52
          97.65 97.50 97.35 97.21 96.36 96.22 96.08 95.94 95.80  95.67  95.52
                                                                             ITERATION   3
                                                              11     12     13     14     IS    16

                                                           94.99  94.62  94.25  93.90  93.54 93.20
                                                                                                       17
          ALGAE  GROWTH  RATES  IN PER OAK ARE
           345678
     0.30
     0.42
     0.44
     0.39
     0.29
  0.28
  0.43
  0.45
  0.39
  0.29
                 0.29  0.27  0.27
                 0.43  0.43  0.43
                                   0.27  0.27  0.29  0.29
                          10

                        0.28
                                                                                  ITERATION   3
                                                                               13     14     15
                                                              11     12     13     14     15     16

                                                            0.28   0.28   0.28   0.28   0.27   0.27
                                                                                                       17
            0.39  0.39  0.39  0.39  0.38   0.38   0.40   0.41
            0.29  0.29  0.29  0.29  0.29   3.29   0.29   0.29
                                                                 0.29   0.29
RCH/CL  1
                   PHOTOSYNTHESIS-RESPIRATION RATIOS  ARE
                    3456789
     2.12
     2.90
     2.99
     2.58
     1.95
           1.97  1.95
           2.88  2.86
           2.97
           2.57
           1.94
        2.56
        1.94
                       1.83  1.82
                       2.85  2.83

                       2.55  2.55
                       1.93  1.93
                          1.80   1.78  1.92  1.90
2.54
1.91
2.53
1.90
2.52
1.90
2.78
1.89
                          10

                        1.89
2.78
1.88
                                                                                  ITERATION   3
                                                                               13     14     15
                                                              11     12     13     14     15     16

                                                            1.87   1.86   1.84   1.83   1.81   1.80



                                                            1.91   1.91
                                                                                                       17
                                                                                                        10
                                                                                                        18
                                                                                                             18
                                                                                                             18
                                                                                                   18
                                                                                                              19
                                                                                                              19
                                                                                                               20
                                                                                                                   19
                                                                                                               20
                                                                                                                   19
                                                                                                                   20
                                                                                                         19
                                                                                                               20

-------
                           SUBROUTINE WRPTZ
            YES
   IS THIS
A STEADY-STATE
   soumoN
                                                     NO
PRINT TITLE FOR
 STEADY-STATE
  SIMULATION
                           PRINT TITLE FOR
                          DYNAMIC SIMULATION
                               0
                        Loop through
                        jrogran from a
                        to b for all
                        str*M reaches
                                WRITE
                             INTERMEDIATE
                             OUTPUT REPORT
                               0
                               RETURN
                               TO QUAL
FIGURE  VI-23.    FLOW CHART FOR  SUBROUTINE WRPT2
                                201

-------
 1.
 2.
 3.
 4.
 5.
 6.
 7.
 a.
 9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
42.
43.
44.
45.
46.
47.
48.
49.
50.
51.
52.
53.
54.
C
C.
C
C
C
C
C
C
C:
c:
      SUBROUTINE WRPT2(CONCJ
C
c
c

c
                           HRPT2 WRITES AN INTERMEDIATE SUMMARY
                           OF IHC SELECTED QUALITY CONSTITUENTS.
                           THESE CONSTITUENTS ARE WRITTEN BY REACH
                           AND BY ELEMENT.  THIS SUMMARY CAN BE
                           GIVEN AT A TIME INTERVAL OF DELI OR.
                           SOME MULTIPLE OF DELI.
   COMMON TITLE(20,20),RCHID(75,5),RMTHOR(75),RMTEOR(75),NHWWARU5),
          TARGDO(75),IAUGOR(75,6),NCELRH(75),IFLAG(75,20),
          ICLORD(75,20),CO£FO.V(7S),EXPOQY(75),COEFQH(75),EXPOQH(75),
          CMANN(7S),CM(75),CK3(75),K20PT(7S),CK2(75),COEQK2(7S),
          EXPQK2(75),TINIT(75),DOINIT(75),BOINIT(75),COINIT(75,3),
          QI(75),TI(75),OO.I(75),BUDI(75),CONSI(75,3),JUNCIO(15,5),
          JUNC(1S.3),HWTRIDU5.5),HWFLOW(15),HWTEMPU5),HWOO(15),
          HHBOD(15),HMCONS(15,3),MASTID(90,5).TRFACT(90J,WSFLOH(90),
          MSTEMP(90),NSOO(90),MSBOD(90),WSCONS(90,3),gATOT(15),
          A(500),8(500),C(500),D(15),5(500),2(500),H(500),G(500),
          FLOW(500),DEPTH(500),VEL(500),DTO.VCL(500),K2(500),K1(500),
          HSNET(500),DL(500),VHN(15),DEPHW(15),DLHM(15),T(500),
          00(500),800(500),CONS(500,3),PTIME.TPRINT.OELX,
          NHHTRS,NREACH,NMASTE,NJUNC,DELT,D1LT,02LT,DTQOX2,OT20DX>
          LAT,LSM,LLM,ELEV,DAT,AE,BE,DAYOFK,DRYBLB<,METBLB,DEWPT,
          ATMPR,MIND,CLOUD,SONET,NI,NJ,TRLCD,TOFDAY,NT,NC.TIME.NCS

   COMMON/MODIF/ CX4(75),CK5(75),CKNH3(75),CKN02(75),CKN03(75) ,
          CKN>CKP,CKL,ALPHAQ(75),ALPHA1,ALPHA2,ALPHA3.ALPHA4,
          ALPHAS,ALPHA6,GROMAX,RESPRT,ALGSET(75),SPHOS(75),
          SNH3(75),KNH3(500),KN02(500),RESPRR(500),COLI(500),
          ALGAE(SOO),PHOS(500),CNH3(500),CN02(500),CN03(300),
          COLIR(75),ALGI(75),PHOSI(75),CNH3I(7br,CN02I(75),
          CN03I(75),COLIIT(75),ALGIT(75),PHaSlT(75),CNH3IT(75),
          CN02IK75) ,CN03IT(7S) , WSCOLK90) , WSALGOO) ,HSPHOS(903 ,
          MSNH3(90),HSN02(90},HSN03(90),HHCOLI(15),HWALG(15),
          HHPHOS(15),HHNH3(15),HHN02(15),HHN03(15),GRQMTH(500),
          HODOPT(10),IRCHNO(750),EXCOEF(75)


   COMMON/RADION/ CK6(7S),RADNIT(75),RADNI(75),HMRAON(15),MSRADN(90),
  *               RADIO(SOO)

   COMMON/SSTATE/X(500),ISS
   DIMENSION P(20),CONC(500)

   IF (ISS) 20,20,10
10 ITIME=TIME
   WRITE (NJ,15) (TITLE(NT,J),J«6,20),IT1ME
15 FORMAT UHO,19X.15A4,4X,9HITERAT10N,I3)
   GO TO 55
20 CONTINUE
   TlNDAYsTIME/24.0
                                        202

-------
55.
56.
57.
58.
59.
60.
61.
62.
63.
64.
65.
66.
67.
68.
69.
70.
71.
72.
73.
74.
75.
76.
77.
78.
79.
80.
31.
82.
83.
84.
85.
86.
87.
88.
89.
90.
91.
92.
41
* •» •
94.
QC
"9«
96.
97.
98.
99.
100.
101.
102.
103.
104.
105.


C






C
C
C
C
C:







C
C
C
C





C
C
C





C










WRITE (NJ.50) CIITLECNr,J),J"6,20),TlNDA*
50 FORMAT UHO, 19X, 15A4,1X,FS.2,5H BAYS,/)
STEP 1-0
55 CONTINUE
IF(NT.EQ.14) GO TO 400
WRITC(NJ,60)
60 FORMAT C2X, 123HRCH/CL 123456
* 9 10 11 12 13 14 15 16 17
« 20. /)

LOOP THROUGH SYSTEM OF
BX NCELR COMPUTATIONAL
REACH.

00 100 I»1,NREACH
NCELR«NCELRHU)
DQ 200 J»t, NCELR
IOR«ICLORD(I,J)
P(J)»CONC(IOR)
IF(NI .EQ. 8) P
-------
SUBROUTINE WRPT3

          Subroutine WRPT3 is used to print the final  output from the
water quality simulations for both the steady-state solution and the
dynamic case.  WRPT3 prints a complete history of all  quality and
temperature parameters included in QUAL-II; any parameter not simulated
in the current simulation will be printed either at the value to which
it was initialized (as in the case of temperature) or as zero.   The
following pages illustrate an example output report from WRPT3 for a
steady-state simulation.

          Figure VI-24 illustrates the subroutine flow chart, and the
following pages contain the program listing.  Variables in COMMON are
defined in Section VII.
                                    204

-------
hi
f
c
«
S»CH ELT
NUfe NUM
1 1
2 2
i 3
4 4
5 5
6 6
V 7
a 8
9 9
10 10
11 11
12 12
13 13
14 14
IS 15
16 16
17 2 1
It 2 2
19 1 i
20 2 4
*1 2 5
n 3 i
23 3 2
24 4 1
25 4 2
26 4 3
27 4 4
28 4 5
29 4 6
30 4 7
31 4 8
3? 4 9
33 4 10
3i 5 1
3a 5 2
35 5 J
3? S 1
IE 5 5
39 5 6
40 5 7
us e
4i S 9
43 S 10
U 5 11
45 £ 12
TRCfcM OUAL
i • * T » r- •*•«•»
IT* SUt'J'uATl3N QUtrUt P'«ZZ UUKBER 1
CAf. OUALITV RC.'JTIt:G M3DEL LPC/CEtfCOC VERSION
**«* SIEADV STATE SIMULATION »t**t
FROM
KIL3
46.0
45.0
44.0
43.0
42.0
41.0
40.0
39.0
38.0
37.0
36.0
35.0
34.0
33.0
32.0
31.0
15.0
14.0
13.0
12.0
11.0
2.0
1.0
10.0
9.0
8.0
7.0
6.0
5.0
4.0
3.0
2.0
1.0
30.0
29.0
28.0
27.0
26.0
25.0
24.0
23.0
22.0
21.0
20.0
19.0
TO FLOW POINT INCH TEMP DC BOD NH3-M K03-N DIS-O-P CHL A COLI TDS
KILO (CHS) SOURCE FLOW DEC C (KG/L) (HC/L) (HG/L) (KG/L) (HG/L) (UG/L) /100HL ( ) (HC/L) ( ) ( )
45.0 0.98 0.0 0.02 22.94 8.19 1.94 0.03 0.49 0.10 9.77 403. 0.0 82.53 0.0 0.0
44.0 1.21 0.22 0.02 23.08 8.06 2.14 0.02 0.49 0.10 12.34 354. 0.0 88.96 0.0 0.0
43.0 .23 0.0 0.02 23.50 8.00 2.30 0.02 0.49 0.10 12.12 325. 0.0 86.51 0.0 0.0
42.0 .47 0.22 0.02 23.39 7.94 2.39 0.02 0.49 0.10 13.86 311. 0.0 92.86 0.0 0.0
41.0 .48 0.0 0.02 23.66 7.67 2.51 0.02 0.46 0.09 13.64 287. 0.0 92.45 0.0 0.0
40.0 .50 0.0 0.02 23.83 7.81 2.62 0.02 0.48 0.09 13.43 265. 0.0 92.04 0.0 0.0
39.0 .51 0.0 0.02 23.95 7.75 2.73 0.02 0.48 0.09 13.23 244. 0.0 91.64 0.0 0.0
38.0 .69 0.16 0.02 23.91 7.71 2.75 0.03 0.62 0.10 14.18 231. 0.0 96.15 0.0 0.0
37.0 .71 0.0 0.02 23.99 7.67 2.84 0.03 0.61 0.10 14.00 214. 0.0 95.75 0.0 0.0
36.0 .72 0.0 0.02 24.04 7.62 2.92 0.03 0.61 0.10 13.83 198. 0.0 95.37 0.0 0.0
35.0 .74 0.0 0.02 24.08 7.58 2.99 0.03 0.60 0.10 13.65 183. 0.0 94.99 0.0 0.0
34.0 .76 0.0 0.02 24.11 7.54 3.06 0.03 0.60 0.10 13.49 169. 0.0 94.62 0.0 0.0
33.0 .77 0.0 0.02 24.12 7.51 3.13 0.03 0.60 0.10 13.32 157. 0.0 94.25 0.0 0.0
32.0 .79 0.0 0.02 24.13 7.47 3.20 0.03 0.59 0.10 13.16 145. 0.0 93.90 0.0 0.0
31.0 .80 0.0 0.02 24.14 7.44 3.26 0.03 0.59 0.10 13.00 134. 0.0 93.54 0.0 0.0
30.0 .82 0.0 0.02 24.15 7.42 .31 0.03 0.59 0.09 12.84 124. 0.0 93.20 0.0 0.0
14.0 0.18 0.0 0.00 23.26 8.19 .95 0.02 0.50 0.10 9.64 180. 0.0 97.62 0.0 0.0
13.0 0.18 0.0 0.00 23.95 6.21 .90 0.02 0.49 0.10 9.29 162. 0.0 97.25 0.0 0.0
12.0 0.18 0.0 0.00 24.16 8.19 .85 0.02 0.49 0.10 8.96 146. 0.0 96.88 0.0 0.0
11.0 0.19 0.0 0.00 24.23 8.18 .80 0.02 0.49 0.10 8.65 131. 0.0 96.52 0.0 0.0
10.0 0.19 0.0 0.00 24.25 6.18 .76 0.02 0.49 0.10 6.35 118. 0.0 96.17 0.0 0.0
1.0 0.14 0.0 0.00 23.58 8.20 .92 0.02 0.50 0.10 9.41 173. 0.0 97.54 0.0 0.0
•0.0 0.14 0.0 0.00 24.12 6.20 .84 0.02 0.49 0.10 8.87 149. 0.0 97.10 0.0 0.0
9.0 0.33 0.0 0.00 24.24 8.18 .74 0.02 0.49 0.10 8.40 116. 0.0 96.35 0.0 0.0
6.0 0.33 0.0 0.00 24.25 6.16 .69 0.02 0.49 0.10 8.25 109. 0.0 96.17 0.0 0.0
7.0 0.34 0.0 0.00 24.25 8.15 .65 0.02 0.48 0.10 8.11 100. 0.0 95.98 0.0 0.0
6.0 0.34 0.0 0.00 24.26 8.15 .62 0.02 0.48 0.09 7.97 92. 0.0 95.80 0.0 0.0
5.0 0.34 0.0 0.00 24.26 8.14 .58 0.02 0.48 0.09 7.84 85. 0.0 95.62 0.0 0.0
4.0 0.34 0.0 0.00 24.26 6.14 .54 0.02 0.48 0.09 7.70 78. 0.0 95.44 0.0 0.0
3.0 0.34 0.0 0.00 24.26 8.14 .51 0.02 0.48 0.09 7.57 72. 0.0 95.26 0.0 0.0
2.0 0.34 0.0 0.00 24.26 6.15 .47 0.02 0.48 0.09 7.45 66. 0.0 95.09 0.0 0.0
1.0 0.75 0.41 0.00 22.96 7.68 .73 0.17 0.76 0.18 16.94 252. 0.0 109.63 0.0 O.C
0.0 0.76 0.0 0.00 23.43 7.95 .70 0.1? 0.76 0.18 16.88 237. 0.0 109.52 0.0 0.0
29.0 2.59 0.0 0.01 24.02 7.56 .92 0.07 0.63 0.12 13.94 147. 0.0 97.79 0.0 O.C
26.0 2.59 0.0 0.01 24.08 7.57 .00 0.07 0.63 0.12 13.86 137. 0.0 97.65 0.0 0.0
27.0 2.60 0.0 0.01 24.13 7..5S .08 0.07 0.63 0.12 13.78 128. 0.0 97.50 0.0 0.0
26.0 2.61 0.0 0.01 24.16 7.53 .15 0.07 0.63 0.12 13.71 119. 0.0 97.35 0.0 O.C
25.0 2.62 0.0 0.01 24.16 7.51 .23 0.07 0.63 0.12 13.63 111. 0.0 97.21 0.0 0.0
24.0 2.67 0.04 0.01 24.15 7.46 .33 0.07 0.62 0.12 13.35 102. 0.0 96.36 0.0 0.0
23.0 2.68 0.0 0.01 24.16 7.45 .40 0.06 0.62 0.12 13.27 95. 0.0 96.22 0.0 0.0
22.0 2.69 0.0 0.01 24.19 7.43 .46 0.06 0.62 0.11 13.19 88. 0.0 96.08 0.0 0.0
21.0 2.70 0.0 0.01 24.21 7.42 .51 0.06 0.62 0.11 13.12 02. 0.0 95.94 0.0 0.0
20.0 2.73 0.02 0.01 24.19 7.39 .56 0.06 0.61 0.11 12.95 76. 0.0 95.80 0.0 0.0
19.0 2.54 0.20 0.01 24.20 7.38 .64 0.06 0.61 0.11 12. OB 71. 0.0 9S.67 0.0 0.0
18.0 2.54 0.0 0.01 24.21 7.37 .70 0.06 0.61 0.11 12.80 66. 0.0 
-------
rv»
o
01
                               STREAM QUALITY SIMULATION

                               OUAL II STREAM QUALITY ROUTING MODEL



                               ***** STEADY STATE SIMULATION *****
OUTPUT PAGE NUMBER

WRE/SEMCOG VERSION

RCH ELT
ORD SUM
1 I
•2 2
3 3
4 4
5 5
6 6
7 7
8 8
9 9
10 10
11 11
12 12
13 13
14 1 14
IS J IS
16 1 16
17 2 1
IB 2 2
19 2 3
20 2 4
21 2 5
22 1
23 2
24 1
25 2
26 3
27 4
28 S
29 6
30 7
31 8
32 9
33 10
34 5 1
35 5 2
36 S 3
37 5 4
38 5 S
39 5 6
40 5 7
41 5 8
42 5 9
43 5 10
44 5 11
45 5 12

FROM
KILO
46.0
45.0
44.0
43.0
42.0
41.0
40.0
39.0
38.0
37.0
36.0
35. 0
34.0
33.0
32.0
31.0
15.0
14.0
13.0
12.0
11.0
2.0
1.0
10.0
9.0
8.0
7.0
6.0
5.0
4.0
3.0
2.0
1.0
30.0
29.0
28.0
27.0
26.0
25.0
24.0
23.0
22.0
21.0
20.0
19.0
STREAM STREAM OXKGEN 800 NH3 N02 COLI ALGAE ALGAE
TO VEL DEPTH REAIR DECAY DECAY DECAY DECAY GROWTH HESPR
KILO (MPS) (M) (1/DY) (1/DY) Cl/DY) (1/DY) (1/DY) (1/OY) Cl/DY)
45.0 0.248 0.43 7.20 0.69 0.17 .14 .72 0.30 0.11
44.0 0.265 0.49 6.73 0.69 0.17 .15 .73 0.28 0.12
43.0 0.266 0.49 6.25 0.70 0.18 .17 .76 0.29 0.12
42.0 0.280 0.54 5.86 0.70 0.18 .17 .75 0.27 0.12
41.0 0.281 0.55 5.52 0.71 0.18 .18 .77 0.27 0.12
40.0 0.282 0.55 5.49 0.72 0.18 .19 .79 0.27 0.12
39.0 0.283 0.55 5.46 0.72 0.18 .20 .80 0.27 0.12
38.0 0.293 0.59 5.25 0.72 0.18 .20 .80 0.29 0.12
37.0 0.293 0.59 5.04 0.72 0.18 .20 .80 0.29 0.12
36.0 0.294 0.59 5.01 0.72 0.18 .20 .81 0.28 0.12
35.0 0.295 0.60 4.98 0.72 0.18 .21 .81 0.28 0.12
34.0 0.296 0.60 4.95 0.72 0.18 .21 .81 0.28 0.12
33.0 0.297 0.60 4.92 0.73 0.18 .21 .81 0.28 0.12
32.0 0.298 0.61 4.89 0.73 0.18 .21 .81 0.28 0.12
31.0 0.298 0.61 4.86 0.73 0.18 .21 .81 0.27 0.12
30.0 0.299 0.61 4.84 0.73 0.18 .21 .81 0.27 0.12
14.0 0.202 0.18 24.45 0.70 0.17 .16 .74 0.42 0.12
13.0 0.203 0.18 24.64 0.72 0.18 .20 .80 0.43 0.12
12.0 0.203 0.18 24.57 0.73 0.18 .21 .82 0.43 0.12
11.0 0.204 0.18 24.44 0.73 0.18 .21 .82 0.43 0.12
10.0 0.205 0.18 24.29 0.73 0.18 .22 .82 0.43 0.12
1.0 0.141 0.15 25.89 0.71 0.18 .18 .77 0.44 0.12
-0.0 0.142 0.16 26.02 0.73 0.18 .21 .81 0.45 0.12
9.0 0.253 0.26 20.53 0.73 0.18 .21 .82 0.39 0.12
8.0 0.253 0.26 15.95 0.73 0.18 .22 .82 0.39 0.12
7.0 0.254 0.26 15.90 0.73 0.18 .22 .82 0.39 0.12
6.0 0.254 0.26 15.84 0.73 0.18 .22 .82 0.39 0.12
5.0 0.255 0.26 15.79 0.73 0.18 .22 .82 0.39 0.12
4.0 0.255 0.26 15.74 0.73 0.18 .22 .82 0.39 0.12
3.0 0.255 0.26 15.69 0.73 0.18 .22 .82 0.38 0.12
2.0 0.256 0.27 15.64 0.73 0.18 .22 .82 0.38 0.12
1.0 0.342 0.43 11.96 0.69 0.17 .15 .72 0.40 0.11
0.0 0.343 0.43 8.66 0.70 0.18 .17 .76 0.41 0.12
29.0 0.301 0.62 5.77 0.72 0.18 .20 .80 0.29 0.12
28. 0 0.301 0.62 .77 0.72 0.18 .21 .81 0.29 0.12
27.0 0.302 0.62 .76 0.73 0.18 .21 .81 0.29 0.12
26.0 0.302 0.62 .76 0.73 0.18 .21 .82 0.29 0.12
25.0 0.302 0.62 .75 0.73 0.18 .21 .82 0.29 0.12
24.0 0.304 0.62 .73 0.73 0.18 .21 .82 0.29 0.12
23.0 0.305 0.63 .71 0.73 0.18 .21 .82 0.29 0.12
22.0 0.305 0.63 .71 0.73 0.18 .21 .82 0.29 0.12
21.0 0.305 0.63 .70 0.73 0.18 .21 .82 0.29 0.12
20.0 0.306 0.63 .69 0.73 0.18 .21 .82 0.29 0.12
19.0 0.299 0.61 .75 0.73 0.18 .21 .82 0.29 0.12
18.0 0.299 0.61 .81 0.73 0.18 .21 .82 0.29 0.12

-------
                    I   suuairunwrfi  \
                        OGMPVTC
                        uMts. MAMS.
                        OUTROO AW
                        ffltowwru <
                        GMC&fTMTtQNS
                                         Low Otrou*
                                         U b for ill
                                         iti
FIGURE VI-24.   FLOW CHART  FOR  SUBROUTINE WRPT3
                          207

-------
1.
2.
3.
4.
5.
6.
7.
a.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
42.
43.
44.
45.
46.
47.
48.
49.
50.
51.
52.
53.
54.
55.
56.
57.
58.
59.
60.
61.
62.
63.
64.
65.
66.
67.
68.
69.
70.

C
C
C.
C
C
C
C
C
















C











C
C

*
C




C



















*

*
288
SUBROUTINE WRPT3
                        HRPT3 WRITES THE FINAL CONCENTRATION
                        OF THE SELECTED QUALITY CONSTITUENTS.
                        THESE CONSTITUENTS ARE MRITTEN BY REACH
                        AND. BY ELEMENT.
 COMMON TITLE<20,20),RCHID(75,5),RMTHOR<75),RMTEOR(75),NHWWARO5),
        TARGDO(75),IAUGOJU75,6),NCELRH(75),IFLAGC75,20),
        ICLORO<75,20),CO£FQV(75),EXPOQV(75),COEFQH<75),EXPOQH(75),
        CMANN(75),CK1(75),CK3(75),K20PT(75),CK2(75),COEQK2(75),
        EXPQK2C75),TlNir(75),DOINITC75J,BOINIT(75),COINITC7S,3),
        QI(75),TI(75).DO.I(75),BODK75),COJISI(75,3),JUNC1DU5,5},
        JUNCU5,3),HWTRID<15,5),HWFLOWU5),HHTENP(15),HWDOU5),
        HHBOD(15),H*CO!iSU5,3),WA5TID(90,5),TRFACT(90),W5FLOW(90),
        HSTEMP(90),HSDQ(90),NSBOD(90),WSCONS(90,3),QATOT(15),
        A(500 ), 8(500 ),C.{ 500), 0( 15), SC500) ,2(500) ,H( 500 ).GC500),
        FLOH(500),DEPTH'(500),VEL(500),DTO.VCL(500),K2(500),K1(500>,
        HSNEr(500),UL(500),l/HW(15),DEPHW(15),OLHH(lb),T(500),
        00(500), BOO (500), CONS (500, 3), PTIME,TPRIMT,DELX,
        NHWTRS,NREACH,NWASTE,NJUNC,DELT.D1LT,D2LT.DTODX2,DT20DX,
        LAT , LSM , LLM , ELEV , OAT , AE , BE , DAYOF Y , DRY BLB<, WETBLB , DEWPT ,
        ATMPR, WIND, CLOUD, SONET, NI,NJ,TRLCD,TOFOAY, NT, NC, TIME, NCS

 COMMON/MUDIF/ CK4(75) ,CK5(75) ,CKNH3(75) ,CKN02(75) ,CKN03(75) ,
        CKN,CKP,CKL,ALPHAO(75),ALPHA1,ALPHA2,ALPHA3,ALPHA4,
        ALPHAS, ALPKA6,SROMAX,RESPHT,ALG5ET( 75 ),SPHOS (75),
        SNH3(75),KNH3(500),KN02(500),RESPRR(500),COLI(500),
        ALGAeC500),PHOS(500)»CNH3(500),CN02C500),CN03(500),
        COLIR(75).ALGI(75),PHOSI(75),CNH31(75),CN02I(75),
        CN03I(75),COLIIT(75),ALGIT(75),PHOSIT(75),CNH3IT(75),
        CN02ITC75),C»03IT175),WSCOLI(90),WSALGC90),WSPH05(90),
        WSNH3(90),*SN02C90),aSN03(90),HWCOLl(15),HWALG(15),
        HWPHOS(15),HiiNH3U5),HWN02(15),HWN03U5),GROrfTH(500),
        MODOPT(10),1RCHNO(750),£XCOEF(75)


 COMMON/RAOIONX CK6 (75) , RADHIT(75) ,RADNI(75 ) , HWRADN (15) ,HSRADN(90) ,
                RAOIO(SOO)

 COMMON/SSTATC/X(500),1SS
 COMMON/METER/MEIR1C , METOUT
 REAL   K1,K2,KNH3,KN02
 DATA NPAGE/0/

 NHW * 0
 NWS = 0
 LP > 0
 OELM = DELX / 5280. 0
 IF( METOUT .SI. 0 ) DELM * OELM * 1.609
 DO 300 I a 1, NREACH
 IF( METOUT .GT. 0 ) RHTHOR(I)»RMTHOR(I)*1 .609
 NCELR * NCELRHU)
 CNCELR = NCELR
 QINC * QI(1) / CNCELR
 IF( METOUT .GT. 0 ) QINC
 00 300 J • 1, NCELR
 LP » LP * 1
 IF(MOD(LP,48).N£.nGO TO 288
 NPAGE • NPAGE t 1
 WRITE(NJ,6005) NPAGE
 IF( ISS .EQ. 0 ) HRlTE(NJ,6007)  TIME
 IF( ISS .GT. 0 ) HRITE(NJ,6Q08)
 IF( HETOUT .EQ. 0 ) MRITE(NJ,6010) TITLE( 15 , 13) , (TITLEdl , 13 ) ,
»I1»3,5),TITLE(15,15),(TITLE(II,15),II=3,5)
 IF( HETOUT .GT. 0 ) MRITE(NJ,6011 ) IITLE( 15, 13) , (TITLEdl , 13) ,
*II=3,5),TITUE(15,15),(TITLE(II,15),II*3,5)
     3 ICLORO(I,J)
                           QINC / 35.3133
                           208

-------
  71.          QHWD a 0.0
  72.          QNSI 3 0.0
  73.          IFL * IFLAGCI,J)
  74.          GO TO (290,296,296,296,296,292,294), IFL
  75.      290 NHM * NHM t 1
  76.          QHMO * HNFLOK(HHM)
  77.          GO TO 296
  79.      292 NWS s NWS * 1
  79.          QMSI • WSFLOUCNHS)
  80.          GO TO 296
   ICLOROU.J)
115.          IFL s IFLAGCI,J)
116.          TC a O.S56*CTCIOR)-68.0)
117.          XK5 » CKS(I)*l.047**TC
118.          GO TO C352,354,354,356,354,354,354), IFL
119.      352 XK2 3 K2UOR)*1.01S9**TC
120.          GO TO 370
121.      354 XK2 B (  0.5«
-------
141.         * 18HHRE/SEMCOG VERSION )
142.     6007 FORMAT( / 10X, 19HSYS1EM STATUS AFTER, F8.2. 27H HOURS OF DYNAMIC
143.         IOPERATION  )
144.     6008 FORMAT( / 10X, 3SH***** STEADY STATE SIMULATION *****  )
145.     6010 FORMATU/4X,    'RCH ELT   FROM     TO   FLOW   POINT  INCR   TEMP
146.         1     00    BOO  NH3-N  N03-N DIS-O-P CHL A  COLL*,3X,A4,
147.         23(3X,A4),/
148.         3 4X,   'NUM NUM   MILE   MILE   (CFS) SOURCE  FLOW  DEC. F (MG/L) (
149.         4MG/L) (MG/L) (MG/L) (MG/L) (UG/L) /100ML',' (',A4,')',
150.         53C C.A4,')'))
151.     6011 FORMAK//4X,    'RCH ELI   FROM     TO    FLOW  POINT  INCR   TEMP
152.         1     00    300  NH3-N  N03-N DIS-O-P CHL A  COLI',3X,A4,
153.         23(3X,A4),/
154.         3 4X,   'NUM NUM   KILO   KILO   (CMS) SOURCE  FLOW  DEG C (MG/L) (
155.         4MG/L) (MG/L) (MG/L) (MG/L) (UG/L) /100ML',' C.A4,')',
156.         53C r,A4,')'))
157.     6015 FORMAT(I4,I3,I4,2F7.1,F8.2,F7.2.F6.2.7F7.2.F7.0,4F7.2)
158.     6020 FORMAK/27X, 62HSTREAM STREAM OXYGEN    BOD    NH3    N02   COLI
159.         1ALGAE  ALGAE    /
160.         2  5X, 92HRCH ELT   FROM     TO    VEL  DEPTH  REAIR  DECAY  DECAY
161.         4 DECAY  DECAY GROWTH  RESPR CON-III   /
162.         5  5X, 91HORD NUM   MILE   MILE  (KPS)   (FT) (1/DY) (1/DY) (1/DY)
163.         6U/DY) (1/DY) (1/DY) (1/DY) (MG/L)   )
164.     6021 FORMAK/27X, 62HSTREAM STREAM OXYGEN    BOD    NH3    N02   COLI<
165.         1ALGAE  ALGAE    /
166.         2  5X, 92HRCH ELT   FROM     TO    VEL  DEPTH  REAIR  DECAY  DECAY
167.         4 DECAY  DECAY GROWTH  RESPR           /
lt>8.         5  5X, 91HORO MUM   KlLa   KILO  (MPS)    (H) (1/DY) (1/OY) U/DY)
169.         6(1/DY) (1/DY) (1/DY) (1/OY)          )
170.     6025 FORMAI(3I4,2F7.1,F7.3,9F7.2)
171.          END
                                           210

-------
                            DEFINITION OF SYMBOLS
          The following tabulation defines  the symbols  used  in  the
right hand side of the equations shown in each subroutine description,
except TRIMAT, which is self-explanatory.

       SYMBOL                                  DEFINITION
          a                    .   Coefficient in convection-diffusion
                                  equation due to upstream stream segment
          A                       Algal  biomass
          a                       Fraction of respired algal  biomass
                                  resolubilized as  ammonia nitrogen by
                                  bacterial  action
          a                       Fraction of algal  biomass  that is
                                  phosphorus
          a3                      Rate of oxygen production  per unit of
                                  algae  (photosynthesis)
          a                       Rate of oxygen uptake per unit of algae
           "                      respired
          <*5                      Rate of oxygen uptake per unit of ammonia
                                  oxidation
          a                       Rate of oxygen uptake per unit of nitrite
                                  nitrogen oxidation
          C                       Concentration of  a  conservative material
          C                       Oxygen  saturation concentration

          D                       Average stream depth
          D                       Average stream depth
          D                       Molecular diffusion coefficient
          
-------
SYMBOL                                DEFINITION

   X                      Light extinction  coefficient
   h                      Net heat flux
   KL                     Empirical  half-saturation  constant,  light
   KN                     Empirical  half-saturation  constant,  nitrogen
   Kp                     Empirical  half-saturation  constant,  phosphorus
   Kj                     Rate of decay of  carbonaceous  BOD
   <2                     Aeration rate in  accordance with the Fickian
                          diffusion  analogy
   K3                     Rate of loss of carbonaceous BOD
                          due to settling
   K^                     Constant benthic  uptake  of oxygen
   KS                     Rate of coliform  die-off
   K6                     Rate of arbitrary nonconservative  decay
   K7                     Rate constant for the biological oxidation
                          of airmonia nitrogen
   K8                     Rate constant for the oxidation of nitrite
                          nitrogen
   L                      Intensity  of light (ALGAES)
   L                      Concentration of  carbonaceous  BOD  (BODS)
   u                      Algal  specific growth rate
   0                      Maximum specific  algal growth  rate
   n                      Manning's  roughness  coefficient
   Nj                     Concentration of  ammonia nitrogen
   N                      Concentration of  nitrite nitrogen
   N3                     Concentration of  nitrate nitrogen
   P                      Concentration of  orthophosphate
   p                      Algal  respiration rate
   q                      Stream flow
   a                      Algal  settling rate
   a2                     Benthos source rate  for  amnonia
   a                      Benthos source rate  for  phosphorus
   R                      Concentration of  arbitrary nonconservative
                            212

-------
SYMBOL
            DEFINITION
   t
   T
   u
   h (subscript)
   i (subscript)
   o (subscript)
   w (subscript)
   * (superscript)
   1 (superscript)
Time
Temperature
Velocity
Shear velocity
Volume
Length
Specific heat times density
Headwater
Element
Taken out of system
Waste load
Previous time step value
Upstream element
                           213

-------
Variable Name

A(IOR)



AE

ALGAE(IOR)
ALGI(I)


ALGIT(I)


ALGSET(I)


ALPHAO(I)


ALPHA!


ALPHA2


ALPHAS


ALPHA4


ALPHAS


ALPHAS


ATMPR
            SECTION VII

              QUAL-II
DESCRIPTION OF VARIABLES IN COMMON


            Definition

  = Vector below diagonal in
    tridiagonal coefficient matrix
    for computational element IOR

  3 Evaporation coefficient

  * Concentration of algae in
    computational element IOR

  = Incremental inflow concentration
    of chlorophyll a_ into reach J

  » Initial concentration of
    chlorophyll a_ in reach I

  = Local settling rate for algae
    in reach I

  - Ratio of chlorophyll a to
    algae biomass in reach" I

  = Fraction of algae biomass
    which is N

  = Fraction of algae biomass
    which is P

  = 0« production per unit of algae
       growth

  = Og uptake per unit of algae
       respired

  = 02 uptake per unit of NH3
       oxidation
       uptake per unit of
       oxidation
    Local barometric pressure
English
 Units
 ft/hour-in. Hg

 mg/1


 ug/1


 ug/1


 ft/day
 ug Ch1-a_
   mg A
 mg N
 mg A
 mg P
 mg A

 mg 0
 mg A

. mg 0
 mg A

 mg Q
 mg A

 mg 0
 mg A

 in. Hg
                                    214

-------
 Variable Name
        Definition
English
 Units
B(IOR)



BE

BOD(IOR)


BODI(I)


BOINIT(I)

C(IOR)
CK2(I)


CK3(I)


CK4(I)


CK5(I)


CK6(I)


CKN


CKNH3(I)


CKN02(I)


CKL
Diagonal vector in tridiagonal
coefficient matrix for
computational element I OR

Evaporation coefficient

Ultimate BOD in computational
element IOR

Ultimate BOD of incremental
inflow in reach I

Initial ultimate BOD in reach I

Vector above diagonal in
tridiagonal coefficient matrix
for computational element IOR

BOD decay rate coefficient
(base e) for reach I

Reaeration coefficient (base e)
for reach I

Rate of settling or scouring
of BOD (base e) in reach I

Benthos source rate for BOD
in reach I

Col i form die-off rate in
reach I

Radionuclide decay rate
in reach I

Nitrogen half -saturation
constant for algae growth

Rate constant for biological
oxidation of NH-H    in reach I
Rate constant for biological
oxidation of N0-*N0  in reach I
 ft/hour-in. Hg-MPH

 mg/1


 mg/1


 mg/1
 I/day


 I/day


 I/day


    m
mg
^irc
Light half-saturation constant
for algae growth
 day-foot

 I/day


 I/day


 mg/1


 I/day


 I/day


 Langleys/day
                                     215

-------
Variable Name
        Definition
English
 Units
CKP


CLDRCH(I)


CLOUD



CMANN(I)


CNH3(IOR)


CNH3I(I)


CNH3.IT(I)


CNOZ(IOR)


CN02I(I)


CN02IT(I)


CN03(IOR)


CN03I(I)


CN03IT(I)


COEFQH(I)



COEFQV(I)
Phosphorus half-saturation          mg/1
constant for algae growth

Average fraction of cloud cover     tenths
in reach I (SS temp)

Fraction of sky covered             —
(cloudiness express as
decimal)

Manning's channel roughness         —
coefficient for reach I

Concentration of NH3 in             mg/1
computational element IOR

Incremental inflow concentration    mg/1
of NH3 in reach I

Initial concentration of NH3        mg/1
in reach I

Concentration of NOg in             mg/1
computational element IOR

Incremental inflow concentration    mg/1
of N0£ in reach I

Initial concentration of NOg        mg/1
in reach I

Concentration of N03 in             mg/1
computational element IOR

Incremental inflow concentration    mg/1
of N03 in reach I

Initial concentration of N03        mg/1
in reach I

Coefficient of flow for depth-
discharge relationship in
reach  I

Coefficient of flow for velocity-
discharge relationship in
reach  I
                                    216

-------
Variable Name

COEQK2(I)



COINIT(I,NC)


COLI(IOR)


COLIR(I)


COLIIT(I)


CONS(IOR.NC)



CONSI(I,NC)



D(IJUNC)




DAT

DAYOFY



DELT




DELX


DEPHW(NHW)

DEPTH(IOR)
           Definition

 = Coefficient of flow for
   reaeration-discharge
   relationship in reach I

 = Initial  conservative mineral
   concentration  in reach I

j* Concentration  of coliform  in
   computational  element IOR

 = Incremental  inflow  concentration
   of  coliform in reach I

 = Initial  concentration of
   coliform in  reach I

 = Concentration  of conservative
   minerals in  computational
   element IOR

 = Concentration  of conservative
   minerals in  incremental inflow
   in  reach I

 = Vector of coefficients  not in the
   tridiagonal  portion  of the
   coefficient  matrix  for junction
   IJUNC

 = Dust attenuation coefficient

 = Day of the year on which temper-
   ature  routing  begins  (from
   January 1)

 = Time interval  of integration
   (time  step over which  the
   solution to  the routing equation
   is  advanced)

 = Space  interval  of integration
   (length  of computational element)

 = Depth  of headwater source  NHW

 - Depth  in computational  element
   IOR
English
 Units
 mg/1


  1000
 100 ml

  1000
 100 ml

  1000
 100 ml

 mg/1



 mg/1
 days



 seconds




 miles


 feet

 feet
                                  217

-------
Va H ab e
DEWPT
OL(IOR)

DLHW(NHW)

DQ(!OR)

001(1)

DOINIT(I)

ORYBLB
DTODX2
DT20DX
DTOVCL(IOR)

DILI
D2LT
ELEV
EXCOEF(I)

EXPOQH(I)

EXPOQV(I)

EXPQK2(I)

FLOW(IOR)
          Definition
= Dew point temperature
- Dispersion coefficient in
  computational element IOR
= Dispersion coefficient at
  headwater source NHW
= Dissolved oxygen concentration
  in computational element IOR
= Dissolved oxygen concentration
  in incremental  inflow in reach I
= Initial dissolved oxygen
  concentration in reach I
= Dry bulb temperature
= DELT/DEUC2
= (2.0 x DELT)/DELX
= DT20DX/(FLOW(IOR)/VEL(IOR) +
  FLQW(IQR-1)/VEL(IOR-1}}
= Time interval of integration
= "Tiuse interval of integration
= Mean elevation of river basin
= Light extinction coefficient
  in reach I
= Exponent of flow for depth-
  discharge relationship in reach I
= Exponent of flow for velocity-
  discharge relationship in reach I
= Exponent of flow for reaeration
  discharge relationship in reach -I
= Discharge in computational
  element IOR
English
 Units
 degrees Fahr,
 ft2/sec
 ft2/sec
 mg/1
 mg/1
 mg/1
 degrees Fahr.
 sec/ft2
 sec/ft
 sec/ft3
 days
 hours
 ft
 I/ft
 CFS
                                  218

-------
Vari_ablj?J\jajne

G(IOR),.


GROMAX


GROWTH{IOR)


HSNET(IOR)



HWALG(NHW)


HWBOD(NHW)


HWCOLI(NHW)


.WCONS(NHW,NC)


HWDO(NHW)


HWFLOW(NHW)

HWNH3(NHW)


HWN02(NHW)


HWN03(NHW)


HWPHOS(NHW)


HWRADN(NHW)


KWTEMP(NHW)
          Def1nj_tj_on_   -

3 Array used in solution of
  tri-diagonal matrix

= Maximum specific growth rate
  of algae

- Algae growth rate in
  computation element IOR

= Ne'tjheat exchanged through air-
  water interface in computational
  element IOR

= Concentration of chlorophyll A
  in headwater source NHW

= Ultimate BOO of headwater source
  NHW

= Concentration of coliform in
  headwater source NHW

= Concentration of conservative
  minerals at headwater source NHW

= Dissolved oxygen concentration
  at headwater source NHW

= Discharge at'headwater source NHW

= ConcentratiqntQ.f ,W^ in
  headwater source NHW

= Concentration of NO? in
  headwater source NHW

= Concentration of N03 in
  headwater source NHW

= Concentration cf 90$ in
  headwater source NHW

= Concentration of radionuclide
  in headwater source NHW

= Temperature in headwater
  source NHW
English
 Units
 I/day


 I/day


 BTU/ft2



 ug/1


 mg/1


  1000
 100 ml

 mg/1


 mg/1


 CFS
 mg/1


 mg/1


 mg/1
 degrees Fahr.

-------
Variable Name
        Definition
English
 Units
HWTRID(NHW,15)


lAUGOR(I.NHM-) ;


ICLORD(I,J)
Alphanumeric name of headwater
sourca
1RCHNO(250)

ISS


ITRAP


JT(IOR)



JUNC(IJUNC,3)


JUNCID(IJUNC,15)


Kl(IOR)



K2{IOR)


K20PT{I)


KNH3(IOR)



KN02(IOR)
Order of iieadwater sources-
available for- flow augmentation

Order of computation.

Computational flag field

Number of Inserted, reach

Internal flag for dynamic or
steady-state simulation

Flag for trapezoidal channel
cross-sections

Temperature range number in
computational element IOR
(SS temp)

Order of computational elements
clockwise around junction IJUNG

Alphanumeric name of stream
junction IJUNC

BOD decay rate (base e)         ,
coefficient in computational
element IOR         .  .-  - ,-:: ,

Reaeration. coeff.i--s-i.ent (base-:e) •
in computational element IOR

Option for determining reaeration
coefficient in reach I

Internal variable, temperature
corrected CKNH3 in computational
element IOR

Internal variable, temperature
corrected CKNOg in computational
element IOR
 I/day
 I/day
                                  220

-------
yaHab|e__Name

IAT

LLM

LSM


METOUT

METRIC

MODOPT(IO)


NC


NCELRH(I)


NCS


NHWTRS


NHWWAR(I)


NI

NJ

NJUHC


NREACH


NT

NWASTE


PATRCH(I)
          Defirrrbion

s Mean latitude of river basin

= Local meridian of river basin •

- Stand-Bird" meridian of'time zone
  ;ifT4*hi eft-river basin is located

= Flag for metric units output

= Flag for-metric units input •

= Model option; program internal  -
  variable

- Counter for the conservative
  mineral being routed

= Number of computational elements
  in reach I (maximum = 20)

= Number of conservative minerals
  being routed (maximum * 3)

= Wumber of headwaters in stream
  "system (maximum =15)

= Number of headwater sources
  available for flow augmentation

= Input tape

= Output tape

= Number of str-ea'rff-junctionsf^-in-
  system (maxi'mum £='. 15)

= Number of reaches in system
  (maximum =75)

= Counter for printing titles

- Number of waste discharges or
  withdrawals (maximum = 90)

=£Average barometric pressure for
  reach I (SS temp)
English
 Units

 degrees"

 degrees

 degrees'
 in. Hg
                                    221

-------
Variable Name
Definition
                                     English
                                      Units
PHOS(IOR)

PHOSI(I)

PHOSIT(I)

PTIMI

QATOT(NHW)

QKI)   .
RADIO(IOR)
RADNIT(I)

RCHID(I,15)
RESPRR(IOR)

RESPRT
RMTEOR(I)
RMTHOR(I)
S(IOR)

SLOPE(I)

SNH3(I)
= Concentration"'of PQ4 in  .           mg/1
  computational element IOR
= Incremental inflow_concentratfon    mg/1
  of P04='in reach' I'
= Initial concentration of PO^        mg/1
  in reach I
= Time interval for witthg           hours
  intermediate summary •
= Total flow augmentation from        CFS
  each headwater source used
= Incremental inflow in reach I       CFS
= Concentration of arbitrary          rag/1
  nonconservative in
  computationa1 e1emeni IOR
= Incremental inflow concentration    —-
  of radionuclides in reach I
= Initial concentration of            —
  radionuclides in reach I
= Alphanumeric name of reach I        —
* Algae::respiratioh!Tate in
  computation element IOR
- Alqae respiration rate
= River "mile Vt 'ertd of reach I
- Ri ver mi 16 at head • of reach I
= Vector of the known- heat or
  material balance obtained in
  computational 'element IOR
= Longitudinal slope of
  trapezoidal channel of reach I
= Benthos source rate for NH3	
  in reach I                          day-foot
                            I/day

                            I/day
                            miles
                            mi 1 es
                            degrees Fahr,
                            or rng/1

                            ft/ft

                              mg N
                                   222

-------
Variable Name

SOLRCH(I)


SSI (I)


ss2(i)


T(IOR)


TARSDO(I)



TDBRCH(I)
 'I ME




TINIT(I)


TITLE(I.J)

TOFDAY

TPRINT


TRFACT(NWS)




TRLCD


TWBRCH(I)
          Definjjtlon,

= Average light -intensity, for
  reach I (S3 _temp)

- .Side slope,!  (run/rise) of.,
  trapezoidal channel of  reach  I

- Side slope 2  (run/rise) of
  trapezoidal channel of  reach  I

= Temperature, in computational
  element IQR

= Minpura allowable  target  level
  for dissolved oxygen  ......
  concentration in reach  I

= Average dry bulb temperature
  in reach  I ..(SS temp)  .

= Temperature of incremental
  inflow in reach  I

= Length of -time over which a.
  quality constituent has been
  routed

= Temperature of incremental
  inflow w -reach.. -I.

= Alphanumeric^ifpgram  titles

= Hour of day

= Time counter to "determine wheYi
  to write, in tamed.!' ate
English
 Units.^

 Langleys/day
= Treatment plant. jsff.icie,nc.y...,3v
  (decimal fraction) for waste"
  discharge NWS,
             * ~r
= Time counter to determine iwjien -
  to reach Local Clinia'tological data

= Average .wet butb "temperature in
  reach I (SS temp)
 degrees


 mg/1



 degrees Fahr.


 degrees Fahr.


 hours



 degrees Fahr,




 hours

 hours
 hours


 degrees Fahr.
                                   223

-------
Variable Name
          Definition
                                     English
                                      Units
VEL(IOR)


VHW(NHW)

H(IOR)


WASTID(NWS,90)



WETBLB

WIOTH(I)


WIND

WINRCH(I)


WSALG(NWS)



WSBQD(NWS)


WSCQLI(NWS)



WSCONS(NWS.NC)



WSDQ(NWS)


WSFLOW(NWS)


WSNH3(NWS)
= Velocity in computational
  element IOR
                                      FPS
= Velocity at headwater source NHW    FPS

= Array used 1n-solution-of           —
  tr1-diagonal  matrix
» Alphanumeric
  plant, withdrawal, *ortpoint
  source NWS

* Wet bulb temperature

* Bottom width of trapezoidal,
  channel of reach I

- Wind velocity

= Average wind speed for reach I
  (SS temp)

= Input concentration of
  chlorophyll  a_ for waste load
  or point source NWS

= Ultimate BOO of waste loading
  or point source NWS

= Input concentration of fecal
  coliform for waste load or
  point source NWS

= Concentration of conservative
  mineral in waste load or
  point source NWS
                            i
= Concentration of dissolved oxygen
  in waste load or point source NWD

= Discharge of waste load, with-
  drawal or point source

= Input concentration of t
  for waste load or point
  source NWS
                                      degrees Fahr.

                                      feet


                                      KNOTS

                                      ft/sec


                                      vg/i



                                      rag/1


                                       1000-
                                      rag/1



                                      mg/1


                                      CFS


                                      mg/1
                                   224

-------
VariableName

WSN02(NWS)



WSNOS(NWS)


WSPHOS(NWS)

      o

WSRADN(NWS)




WSTEMPtNWSl


X(IOR)


Z(IOR)
          Definition

= Input concentration-,Q#i.|W2 for
  waste load or poTfit'iutirce NWS

= Input concentration o"|fN03 ,,,fer \
  waste load or ooint source"mS

= Input concentration of P04 for'
  waste load or poirit, soucce NWS

= Input concentration of
  radlonuclitle for waste Joad
  or point source NWS

= Temperature of waste 1oad or
  point source>NWS

= Program -'internal -variable, -for ,
  computational:element IOR

= Temporary storage vector.for
  computational element IOR
English
 UnHs

 mg/1


 mg/1


 mg/1
 degrees  Fahr.
                                   225
                                                   i y.3. sovfrntHN? POW
                                                                   ?«< - ?5 7 -019/3009

-------