38 cxs_xf, cxs_h, cxs_rf, unitconv, &
39 icalcmeth)
result(depth)
41 real(dp),
intent(in) :: qrch
42 real(dp),
intent(in) :: width
43 real(dp),
intent(in) :: rough
44 real(dp),
intent(in) :: slope
45 real(dp),
dimension(:),
intent(in) :: cxs_xf
46 real(dp),
dimension(:),
intent(in) :: cxs_h
47 real(dp),
dimension(:),
intent(in) :: cxs_rf
48 real(dp),
intent(in) :: unitconv
49 integer(I4B),
intent(in) :: icalcmeth
54 if (icalcmeth == 1)
then
57 cxs_xf, cxs_h, cxs_rf, unitconv, &
62 cxs_xf, cxs_h, cxs_rf, unitconv, &
74 cxs_xf, cxs_h, cxs_rf, unitconv, &
75 icalcmeth)
result(depth)
79 real(dp),
intent(in) :: qrch
80 real(dp),
intent(in) :: width
81 real(dp),
intent(in) :: rough
82 real(dp),
intent(in) :: slope
83 real(dp),
dimension(:),
intent(in) :: cxs_xf
84 real(dp),
dimension(:),
intent(in) :: cxs_h
85 real(dp),
dimension(:),
intent(in) :: cxs_rf
86 real(dp),
intent(in) :: unitconv
87 integer(I4B),
intent(in) :: icalcmeth
93 integer(I4B) :: maxiter = 100
95 real(dp) :: dmaxchg =
dem5
104 b = maxval(cxs_h) *
dtwo
107 bisectiter:
do iter = 1, maxiter
110 f_c =
calc_qman(c, width, rough, slope, &
111 cxs_xf, cxs_h, cxs_rf, unitconv, icalcmeth) - qrch
112 if (f_c ==
dzero .or. (b - a) /
dtwo < dmaxchg)
then
117 f_a =
calc_qman(a, width, rough, slope, &
118 cxs_xf, cxs_h, cxs_rf, unitconv, icalcmeth) - qrch
119 if (sign(
done, f_c) == sign(
done, f_a))
then
128 print *,
"bisection routine failed"
138 cxs_xf, cxs_h, cxs_rf, unitconv, &
139 icalcmeth)
result(depth)
143 real(dp),
intent(in) :: qrch
144 real(dp),
intent(in) :: width
145 real(dp),
intent(in) :: rough
146 real(dp),
intent(in) :: slope
147 real(dp),
dimension(:),
intent(in) :: cxs_xf
148 real(dp),
dimension(:),
intent(in) :: cxs_h
149 real(dp),
dimension(:),
intent(in) :: cxs_rf
150 real(dp),
intent(in) :: unitconv
151 integer(I4B),
intent(in) :: icalcmeth
157 integer(I4B) :: maxiter = 100
159 real(dp) :: dmaxchg =
dem5
161 real(dp) :: perturbation
171 perturbation = deps *
dtwo
177 nriter:
do iter = 1, maxiter
179 q1 =
calc_qman(d + perturbation, width, rough, slope, &
180 cxs_xf, cxs_h, cxs_rf, unitconv, icalcmeth)
182 if (dq /=
dzero)
then
183 derv = perturbation / (q1 - q0)
191 cxs_xf, cxs_h, cxs_rf, unitconv, icalcmeth)
195 if (abs(dd) < dmaxchg)
then
210 cxs_xf, cxs_h, cxs_rf, unitconv, icalcmeth)
result(qman)
213 real(dp),
intent(in) :: depth
214 real(dp),
intent(in) :: width
215 real(dp),
intent(in) :: rough
216 real(dp),
intent(in) :: slope
217 real(dp),
dimension(:),
intent(in) :: cxs_xf
218 real(dp),
dimension(:),
intent(in) :: cxs_h
219 real(dp),
dimension(:),
intent(in) :: cxs_rf
220 real(dp),
intent(in) :: unitconv
221 integer(I4B),
intent(in) :: icalcmeth
227 integer(I4B) :: linmeth
229 select case (icalcmeth)
233 cxs_xf, cxs_h, cxs_rf, unitconv, &
237 cxs_xf, cxs_h, cxs_rf, unitconv)
241 cxs_xf, cxs_h, cxs_rf, unitconv, &
247 cxs_xf, cxs_h, cxs_rf, unitconv, &
248 linmeth)
result(qman)
251 real(dp),
intent(in) :: depth
252 real(dp),
intent(in) :: width
253 real(dp),
intent(in) :: rough
254 real(dp),
intent(in) :: slope
255 real(dp),
dimension(:),
intent(in) :: cxs_xf
256 real(dp),
dimension(:),
intent(in) :: cxs_h
257 real(dp),
dimension(:),
intent(in) :: cxs_rf
258 real(dp),
intent(in) :: unitconv
259 integer(I4B),
intent(in) :: linmeth
271 real(dp) :: rough_composite
277 if (depth >
dzero)
then
282 cxs_xf, cxs_h, cxs_rf, &
291 qman = unitconv * aw * (rh**
dtwothirds) * sqrt(slope) / rough
298 cxs_xf, cxs_h, cxs_rf, &
301 integer(I4B),
intent(in) :: npts
302 real(dp),
intent(in) :: depth
303 real(dp),
intent(in) :: width
304 real(dp),
intent(in) :: rough
305 real(dp),
intent(in) :: slope
306 real(dp),
dimension(:),
intent(in) :: cxs_xf
307 real(dp),
dimension(:),
intent(in) :: cxs_h
308 real(dp),
dimension(:),
intent(in) :: cxs_rf
309 integer(I4B),
intent(in) :: linmeth
319 real(dp),
dimension(npts) :: stations
320 real(dp),
dimension(npts - 1) :: perimeters
324 stations(n) = cxs_xf(n) * width
328 select case (linmeth)
341 if (depth >
dzero)
then
348 rc = rc + (rough * cxs_rf(n))**exp1 * perimeters(n)
349 wp = wp + perimeters(n)
362 cxs_xf, cxs_h, cxs_rf, unitconv)
result(qman)
365 real(dp),
intent(in) :: depth
366 real(dp),
intent(in) :: width
367 real(dp),
intent(in) :: rough
368 real(dp),
intent(in) :: slope
369 real(dp),
dimension(:),
intent(in) :: cxs_xf
370 real(dp),
dimension(:),
intent(in) :: cxs_h
371 real(dp),
dimension(:),
intent(in) :: cxs_rf
372 real(dp),
intent(in) :: unitconv
389 if (depth >
dzero)
then
420 qman = unitconv * aw * (rh**
dtwothirds) * sqrt(slope) / rough
437 integer(I4B),
intent(in) :: npts
438 real(dp),
dimension(npts),
intent(in) :: stations
444 w = stations(npts) - stations(1)
459 integer(I4B),
intent(in) :: npts
460 real(dp),
dimension(npts),
intent(in) :: xfraction
461 real(dp),
dimension(npts),
intent(in) :: heights
462 real(dp),
intent(in) :: width
463 real(dp),
intent(in) :: d
467 real(dp),
dimension(npts) :: stations
468 real(dp),
dimension(npts - 1) :: widths
472 stations(n) = xfraction(n) * width
496 integer(I4B),
intent(in) :: npts
497 real(dp),
dimension(npts),
intent(in) :: xfraction
498 real(dp),
dimension(npts),
intent(in) :: heights
499 real(dp),
intent(in) :: width
500 real(dp),
intent(in) :: d
504 real(dp),
dimension(npts) :: stations
505 real(dp),
dimension(npts - 1) :: perimeters
509 stations(n) = xfraction(n) * width
520 p = p + perimeters(n)
533 integer(I4B),
intent(in) :: npts
534 real(dp),
dimension(npts),
intent(in) :: xfraction
535 real(dp),
dimension(npts),
intent(in) :: heights
536 real(dp),
intent(in) :: width
537 real(dp),
intent(in) :: d
541 real(dp),
dimension(npts) :: stations
542 real(dp),
dimension(npts - 1) :: areas
546 stations(n) = xfraction(n) * width
567 width, rough, d)
result(c)
569 integer(I4B),
intent(in) :: npts
570 real(dp),
dimension(npts),
intent(in) :: xfraction
571 real(dp),
dimension(npts),
intent(in) :: heights
572 real(dp),
dimension(:),
intent(in) :: cxs_rf
573 real(dp),
intent(in) :: width
574 real(dp),
intent(in) :: rough
575 real(dp),
intent(in) :: d
590 width, rough, d)
result(c)
592 integer(I4B),
intent(in) :: npts
593 real(dp),
dimension(npts),
intent(in) :: xfraction
594 real(dp),
dimension(npts),
intent(in) :: heights
595 real(dp),
dimension(:),
intent(in) :: cxs_rf
596 real(dp),
intent(in) :: width
597 real(dp),
intent(in) :: rough
598 real(dp),
intent(in) :: d
611 ravg = rough * cxs_rf(1)
614 xfraction, heights, cxs_rf, 0)
628 real(dp),
dimension(:),
intent(in) :: xfraction
632 if (
size(xfraction) == 4)
then
633 if (xfraction(1) == xfraction(2) .and. &
634 xfraction(3) == xfraction(4))
then
644 real(dp),
dimension(:),
intent(in) :: cxs_rf
650 rmin = minval(cxs_rf(1:3))
651 rmax = maxval(cxs_rf(1:3))
665 width, rough, d)
result(c)
667 integer(I4B),
intent(in) :: npts
668 real(dp),
dimension(npts),
intent(in) :: xfraction
669 real(dp),
dimension(npts),
intent(in) :: heights
670 real(dp),
dimension(:),
intent(in) :: cxs_rf
671 real(dp),
intent(in) :: width
672 real(dp),
intent(in) :: rough
673 real(dp),
intent(in) :: d
681 real(dp),
dimension(npts) :: stations
682 real(dp),
dimension(npts - 1) :: areas
683 real(dp),
dimension(npts - 1) :: perimeters
687 stations(n) = xfraction(n) * width
699 rc = cxs_rf(n) * rough
719 integer(I4B),
intent(in) :: npts
720 real(dp),
dimension(npts),
intent(in) :: stations
721 real(dp),
dimension(npts),
intent(in) :: heights
722 real(dp),
intent(in) :: d
728 real(dp),
dimension(npts - 1) :: areas
729 real(dp),
dimension(npts - 1) :: perimeters
741 p = p + perimeters(n)
771 integer(I4B),
intent(in) :: npts
772 real(dp),
dimension(npts),
intent(in) :: xfraction
773 real(dp),
dimension(npts),
intent(in) :: heights
774 real(dp),
intent(in) :: width
775 real(dp),
intent(in) :: d
779 real(dp),
dimension(npts) :: stations
783 stations(n) = xfraction(n) * width
799 roughness, conv_fact, width, slope, d)
result(q)
801 integer(I4B),
intent(in) :: npts
802 real(dp),
dimension(npts),
intent(in) :: xfraction
803 real(dp),
dimension(npts),
intent(in) :: heights
804 real(dp),
dimension(npts),
intent(in) :: roughfracs
805 real(dp),
intent(in) :: roughness
806 real(dp),
intent(in) :: conv_fact
807 real(dp),
intent(in) :: width
808 real(dp),
intent(in) :: slope
809 real(dp),
intent(in) :: d
817 real(dp),
dimension(npts) :: stations
818 real(dp),
dimension(npts - 1) :: areas
819 real(dp),
dimension(npts - 1) :: perimeters
830 stations(n) = xfraction(n) * width
838 p = p + perimeters(n)
850 r = roughness * roughfracs(n)
851 if (p * r >
dzero)
then
854 q = q + conv_fact * a * rh**
dtwothirds * sqrt(slope) / r
871 integer(I4B),
intent(in) :: npts
872 real(DP),
dimension(npts),
intent(in) :: stations
873 real(DP),
dimension(npts),
intent(in) :: heights
874 real(DP),
intent(in) :: d
875 real(DP),
dimension(npts - 1),
intent(inout) :: p
905 if (xlen >
dzero)
then
913 dlen = min(d, dmax) - dmin
918 p(n) = sqrt(xlen**
dtwo + dlen**
dtwo)
931 integer(I4B),
intent(in) :: npts
932 real(DP),
dimension(npts),
intent(in) :: stations
933 real(DP),
dimension(npts),
intent(in) :: heights
934 real(DP),
intent(in) :: d
935 real(DP),
dimension(npts - 1),
intent(inout) :: a
963 if (xlen >
dzero)
then
967 a(n) = xlen * (d - dmax)
971 if (dmax /= dmin .and. d > dmin)
then
973 a(n) = a(n) +
dhalf * (d - dmin) * xlen
975 a(n) = a(n) +
dhalf * (dmax - dmin) * xlen
991 integer(I4B),
intent(in) :: npts
992 real(DP),
dimension(npts),
intent(in) :: stations
993 real(DP),
dimension(npts),
intent(in) :: heights
994 real(DP),
intent(in) :: d
995 real(DP),
dimension(npts - 1),
intent(inout) :: w
1010 x1 = stations(n + 1)
1035 real(dp),
intent(inout) :: x0
1036 real(dp),
intent(inout) :: x1
1037 real(dp),
intent(in) :: d0
1038 real(dp),
intent(in) :: d1
1039 real(dp),
intent(inout) :: dmax
1040 real(dp),
intent(inout) :: dmin
1041 real(dp),
intent(in) :: d
1061 else if (d < dmax)
then
1064 if (abs(dlen) >
dzero)
then
1070 dx = (d - d1) * slope
1075 dx = (d - d0) * slope
This module contains simulation constants.
real(dp), parameter dtwothirds
real constant 2/3
real(dp), parameter dp999
real constant 999/1000
real(dp), parameter dhalf
real constant 1/2
real(dp), parameter dzero
real constant zero
real(dp), parameter dem5
real constant 1e-5
real(dp), parameter dtwo
real constant 2
real(dp), parameter dthree
real constant 3
real(dp), parameter done
real constant 1
This module defines variable data types.
subroutine schsmooth(d, smooth, dwdh)
@ brief sChSmooth
This module contains stateless sfr subroutines and functions.
real(dp) function, public calc_qman(depth, width, rough, slope, cxs_xf, cxs_h, cxs_rf, unitconv, icalcmeth)
Calculate streamflow using Manning's equation.
real(dp) function, public get_composite_conveyance(npts, xfraction, heights, cxs_rf, width, rough, d)
Calculate composite conveyance.
real(dp) function, public get_mannings_section(npts, xfraction, heights, roughfracs, roughness, conv_fact, width, slope, d)
Calculate the manning's discharge for a reach.
real(dp) function, public get_hydraulic_radius_xf(npts, xfraction, heights, width, d)
Calculate the hydraulic radius for a reach.
subroutine get_cross_section_areas(npts, stations, heights, d, a)
Calculate the cross-sectional areas for each line segment.
logical(lgp) function has_uniform_resistance(cxs_rf)
Determine if roughness is uniform for the section.
logical(lgp) function is_rectangular(xfraction)
Determine if cross section is rectangular.
real(dp) function, public calc_composite_roughness(npts, depth, width, rough, slope, cxs_xf, cxs_h, cxs_rf, linmeth)
real(dp) function, public calc_depth_from_q(qrch, width, rough, slope, cxs_xf, cxs_h, cxs_rf, unitconv, icalcmeth)
Calculate the depth at the midpoint of a irregular cross-section.
pure subroutine get_wetted_station(x0, x1, d0, d1, dmax, dmin, d)
Calculate the station values for the wetted portion of the cross-section.
real(dp) function, public get_hydraulic_radius(npts, stations, heights, d)
Calculate the hydraulic radius for a reach.
real(dp) function calc_qman_by_section(depth, width, rough, slope, cxs_xf, cxs_h, cxs_rf, unitconv)
subroutine get_wetted_topwidths(npts, stations, heights, d, w)
Calculate the wetted top widths for each line segment.
real(dp) function, public get_cross_section_area(npts, xfraction, heights, width, d)
Calculate the cross-sectional area for a reach.
real(dp) function, public get_wetted_topwidth(npts, xfraction, heights, width, d)
Calculate the wetted top width for a reach.
real(dp) function calc_qman_composite(depth, width, rough, slope, cxs_xf, cxs_h, cxs_rf, unitconv, linmeth)
real(dp) function calc_depth_from_q_nr(qrch, width, rough, slope, cxs_xf, cxs_h, cxs_rf, unitconv, icalcmeth)
Calculate the depth at the midpoint of a irregular cross-section.
real(dp) function, public get_conveyance(npts, xfraction, heights, cxs_rf, width, rough, d)
Calculate conveyance.
subroutine get_wetted_perimeters(npts, stations, heights, d, p)
Calculate the wetted perimeters for each line segment.
real(dp) function, public get_wetted_perimeter(npts, xfraction, heights, width, d)
Calculate the wetted perimeter for a reach.
real(dp) function get_rectangular_conveyance(npts, xfraction, heights, cxs_rf, width, rough, d)
Calculate conveyance for rectangular channel.
real(dp) function, public get_saturated_topwidth(npts, stations)
Calculate the saturated top width for a reach.
real(dp) function calc_depth_from_q_bisect(qrch, width, rough, slope, cxs_xf, cxs_h, cxs_rf, unitconv, icalcmeth)
Calculate the depth at the midpoint of a irregular cross-section.