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) :: xfraction
439 real(dp),
intent(in) :: width
443 real(dp),
dimension(npts) :: stations
447 stations(n) = xfraction(n) * width
452 w = stations(npts) - stations(1)
467 integer(I4B),
intent(in) :: npts
468 real(dp),
dimension(npts),
intent(in) :: xfraction
469 real(dp),
dimension(npts),
intent(in) :: heights
470 real(dp),
intent(in) :: width
471 real(dp),
intent(in) :: d
475 real(dp),
dimension(npts) :: stations
476 real(dp),
dimension(npts - 1) :: widths
480 stations(n) = xfraction(n) * width
504 integer(I4B),
intent(in) :: npts
505 real(dp),
dimension(npts),
intent(in) :: xfraction
506 real(dp),
dimension(npts),
intent(in) :: heights
507 real(dp),
intent(in) :: width
508 real(dp),
intent(in) :: d
512 real(dp),
dimension(npts) :: stations
513 real(dp),
dimension(npts - 1) :: perimeters
517 stations(n) = xfraction(n) * width
528 p = p + perimeters(n)
541 integer(I4B),
intent(in) :: npts
542 real(dp),
dimension(npts),
intent(in) :: xfraction
543 real(dp),
dimension(npts),
intent(in) :: heights
544 real(dp),
intent(in) :: width
545 real(dp),
intent(in) :: d
549 real(dp),
dimension(npts) :: stations
550 real(dp),
dimension(npts - 1) :: areas
554 stations(n) = xfraction(n) * width
575 width, rough, d)
result(c)
577 integer(I4B),
intent(in) :: npts
578 real(dp),
dimension(npts),
intent(in) :: xfraction
579 real(dp),
dimension(npts),
intent(in) :: heights
580 real(dp),
dimension(:),
intent(in) :: cxs_rf
581 real(dp),
intent(in) :: width
582 real(dp),
intent(in) :: rough
583 real(dp),
intent(in) :: d
598 width, rough, d)
result(c)
600 integer(I4B),
intent(in) :: npts
601 real(dp),
dimension(npts),
intent(in) :: xfraction
602 real(dp),
dimension(npts),
intent(in) :: heights
603 real(dp),
dimension(:),
intent(in) :: cxs_rf
604 real(dp),
intent(in) :: width
605 real(dp),
intent(in) :: rough
606 real(dp),
intent(in) :: d
619 ravg = rough * cxs_rf(1)
622 xfraction, heights, cxs_rf, 0)
636 real(dp),
dimension(:),
intent(in) :: xfraction
640 if (
size(xfraction) == 4)
then
641 if (xfraction(1) == xfraction(2) .and. &
642 xfraction(3) == xfraction(4))
then
652 real(dp),
dimension(:),
intent(in) :: cxs_rf
658 rmin = minval(cxs_rf(1:3))
659 rmax = maxval(cxs_rf(1:3))
673 width, rough, d)
result(c)
675 integer(I4B),
intent(in) :: npts
676 real(dp),
dimension(npts),
intent(in) :: xfraction
677 real(dp),
dimension(npts),
intent(in) :: heights
678 real(dp),
dimension(:),
intent(in) :: cxs_rf
679 real(dp),
intent(in) :: width
680 real(dp),
intent(in) :: rough
681 real(dp),
intent(in) :: d
689 real(dp),
dimension(npts) :: stations
690 real(dp),
dimension(npts - 1) :: areas
691 real(dp),
dimension(npts - 1) :: perimeters
695 stations(n) = xfraction(n) * width
707 rc = cxs_rf(n) * rough
727 integer(I4B),
intent(in) :: npts
728 real(dp),
dimension(npts),
intent(in) :: stations
729 real(dp),
dimension(npts),
intent(in) :: heights
730 real(dp),
intent(in) :: d
736 real(dp),
dimension(npts - 1) :: areas
737 real(dp),
dimension(npts - 1) :: perimeters
749 p = p + perimeters(n)
779 integer(I4B),
intent(in) :: npts
780 real(dp),
dimension(npts),
intent(in) :: xfraction
781 real(dp),
dimension(npts),
intent(in) :: heights
782 real(dp),
intent(in) :: width
783 real(dp),
intent(in) :: d
787 real(dp),
dimension(npts) :: stations
791 stations(n) = xfraction(n) * width
807 roughness, conv_fact, width, slope, d)
result(q)
809 integer(I4B),
intent(in) :: npts
810 real(dp),
dimension(npts),
intent(in) :: xfraction
811 real(dp),
dimension(npts),
intent(in) :: heights
812 real(dp),
dimension(npts),
intent(in) :: roughfracs
813 real(dp),
intent(in) :: roughness
814 real(dp),
intent(in) :: conv_fact
815 real(dp),
intent(in) :: width
816 real(dp),
intent(in) :: slope
817 real(dp),
intent(in) :: d
825 real(dp),
dimension(npts) :: stations
826 real(dp),
dimension(npts - 1) :: areas
827 real(dp),
dimension(npts - 1) :: perimeters
838 stations(n) = xfraction(n) * width
846 p = p + perimeters(n)
858 r = roughness * roughfracs(n)
859 if (p * r >
dzero)
then
862 q = q + conv_fact * a * rh**
dtwothirds * sqrt(slope) / r
879 integer(I4B),
intent(in) :: npts
880 real(DP),
dimension(npts),
intent(in) :: stations
881 real(DP),
dimension(npts),
intent(in) :: heights
882 real(DP),
intent(in) :: d
883 real(DP),
dimension(npts - 1),
intent(inout) :: p
913 if (xlen >
dzero)
then
921 dlen = min(d, dmax) - dmin
926 p(n) = sqrt(xlen**
dtwo + dlen**
dtwo)
939 integer(I4B),
intent(in) :: npts
940 real(DP),
dimension(npts),
intent(in) :: stations
941 real(DP),
dimension(npts),
intent(in) :: heights
942 real(DP),
intent(in) :: d
943 real(DP),
dimension(npts - 1),
intent(inout) :: a
971 if (xlen >
dzero)
then
975 a(n) = xlen * (d - dmax)
979 if (dmax /= dmin .and. d > dmin)
then
981 a(n) = a(n) +
dhalf * (d - dmin) * xlen
983 a(n) = a(n) +
dhalf * (dmax - dmin) * xlen
999 integer(I4B),
intent(in) :: npts
1000 real(DP),
dimension(npts),
intent(in) :: stations
1001 real(DP),
dimension(npts),
intent(in) :: heights
1002 real(DP),
intent(in) :: d
1003 real(DP),
dimension(npts - 1),
intent(inout) :: w
1018 x1 = stations(n + 1)
1043 real(dp),
intent(inout) :: x0
1044 real(dp),
intent(inout) :: x1
1045 real(dp),
intent(in) :: d0
1046 real(dp),
intent(in) :: d1
1047 real(dp),
intent(inout) :: dmax
1048 real(dp),
intent(inout) :: dmin
1049 real(dp),
intent(in) :: d
1065 else if (d >= dmax)
then
1077 xt = x0 + slope * (d - d0)
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_saturated_topwidth(npts, xfraction, width)
Calculate the saturated top width for a reach.
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 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.