5.13.2-dev0
mHM
The mesoscale Hydrological Model
Loading...
Searching...
No Matches
mo_mrm_river_head.f90
Go to the documentation of this file.
1!> \file mo_mrm_river_head.f90
2!> \brief \copybrief mo_mrm_river_head
3!> \details \copydetails mo_mrm_river_head
4
5!> \brief River head calculation
6!> \details Enables river - groundwater interaction in mRM.
7!> \authors Lennart Schueler
8!> \date Jul 2018
9!> \copyright Copyright 2005-\today, the mHM Developers, Luis Samaniego, Sabine Attinger: All rights reserved.
10!! mHM is released under the LGPLv3+ license \license_note
11!> \ingroup f_mrm
16 use mo_kind, only : i4, dp
18 use mo_append, only : append
19
20 implicit none
21
22 private
23
24 public :: init_masked_zeros_l0
26 public :: calc_river_head
27
28 contains
29
30 !> \brief allocates memory for L0 variable
31 subroutine init_masked_zeros_l0(iDomain, data)
32 integer(i4), intent(in) :: idomain
33 real(dp), dimension(:), allocatable, intent(inout) :: data
34 real(dp), dimension(:), allocatable :: dummy_1d
35
36 allocate(dummy_1d(level0(idomain)%nCells))
37 dummy_1d = nodata_dp
38 call append(data, dummy_1d)
39 deallocate(dummy_1d)
40 end subroutine init_masked_zeros_l0
41
42 !> \brief calculates the channel elevation from the bankfull river discharge
47 real(dp), dimension(:,:), allocatable :: channel_dpth
48 real(dp), dimension(:,:), allocatable :: channel_elev
49 real(dp), dimension(:,:), allocatable :: slope
50 real(dp), dimension(:,:), allocatable :: elev0
51 integer(i4), dimension(:,:), allocatable :: fdir0
52 integer(i4), dimension(:,:), allocatable :: facc0
53 real(dp) n ! Manning's roughness coefficient
54 integer(i4) :: nrows0, ncols0
55 integer(i4) :: s0, e0
56 integer(i4) i, j, k
57 integer(i4) idomain
58
59 n = .045_dp ! m^-1/3 s from Sutanudjaja et al. 2011
60
61 do idomain = 1, domainmeta%nDomains
62 nrows0 = level0(idomain)%nrows
63 ncols0 = level0(idomain)%ncols
64 s0 = level0(idomain)%iStart
65 e0 = level0(idomain)%iEnd
66 allocate(channel_dpth(nrows0, ncols0))
67 allocate(channel_elev(nrows0, ncols0))
68 allocate(elev0(nrows0, ncols0))
69 allocate(fdir0(nrows0, ncols0))
70 allocate(facc0(nrows0, ncols0))
71 allocate(slope(nrows0, ncols0))
72 channel_dpth(:,:) = nodata_dp
73 channel_elev(:,:) = nodata_dp
74 slope(:,:) = nodata_dp
75
76 elev0(:,:) = unpack(l0_elev(s0:e0), level0(idomain)%mask, nodata_dp)
77 fdir0(:,:) = unpack(l0_fdir(s0:e0), level0(idomain)%mask, nodata_i4)
78 facc0(:,:) = unpack(l0_facc(s0:e0), level0(idomain)%mask, nodata_i4)
79
80 do k = 1, level0(idomain)%nCells
81 i = level0(idomain)%CellCoor(k, 1)
82 j = level0(idomain)%CellCoor(k, 2)
83 if (facc0(i,j) > 1) then
84 slope(i,j) = calc_slope(idomain, elev0, fdir0, i, j)
85 channel_dpth(i,j) = ((n * &
86 l11_bankfull_runoff_in(l0_l11_remap(idomain)%lowres_id_on_highres(i,j))) / &
87 (4.8 * slope(i,j)**.5))**.6
88 channel_elev(i,j) = elev0(i,j) - channel_dpth(i,j)
89 end if
90 end do
91
92 call append(l0_channel_depth, pack(channel_dpth(:,:), &
93 level0(idomain)%mask))
94 call append(l0_channel_elevation, pack(channel_elev(:,:), &
95 level0(idomain)%mask))
96 call append(l0_slope, pack(slope(:,:), &
97 level0(idomain)%mask))
98
99 deallocate(channel_dpth)
100 deallocate(channel_elev)
101 deallocate(elev0)
102 deallocate(fdir0)
103 deallocate(facc0)
104 deallocate(slope)
105 end do
106 end subroutine calc_channel_elevation
107
108 !> \brief calculates the river head
109 subroutine calc_river_head(iDomain, L11_Qmod, river_head)
110 integer(i4), intent(in) :: idomain
111 real(dp), dimension(:), intent(in) :: l11_qmod
112 real(dp), dimension(:), allocatable, intent(inout) :: river_head
113 real(dp) :: n ! Manning's roughness coefficient
114 integer(i4) :: s0, e0
115 integer(i4) i, j, k, l11_ind
116
117 n = .045_dp ! m^-1/3 s from Sutanudjaja et al. 2011
118
119 s0 = level0(idomain)%iStart
120 e0 = level0(idomain)%iEnd
121
122 do k = s0, e0
123 i = level0(idomain)%CellCoor(k - s0 + 1, 1)
124 j = level0(idomain)%CellCoor(k - s0 + 1, 2)
125 if (i >= 0 .and. i < 99999 .and. j >= 0 .and. j < 99999) then
126 l11_ind = l0_l11_remap(idomain)%lowres_id_on_highres(i,j)
127 ! TODO L11_Qmid(L11_ind) causes IEEE_UNDERFLOW_FLAG IEEE_DENORMAL
128 river_head(k) = l0_channel_elevation(k) + &
129 (n * l11_qmod(l11_ind) / l11_bankfull_runoff_in(l11_ind) / &
130 l0_slope(k)**.5)**.6
131 end if
132 end do
133
134 end subroutine calc_river_head
135
136 !> \brief calculates domain slope
137 function calc_slope(iDomain, elev0, fDir0, i, j) result(slope)
140 integer(i4), intent(in) :: idomain
141 integer(i4), intent(in) :: i, j
142 integer(i4), intent(in), dimension(:,:), allocatable :: fdir0
143 real(dp), intent(in), dimension(:,:), allocatable :: elev0
144 real(dp) :: slope, length
145 integer(i4) :: i_down, j_down
146
147 call celllength(idomain, fdir0(i, j), i, j, &
148 iflag_cordinate_sys, length)
149 i_down = i
150 j_down = j
151 call movedownonecell(fdir0(i, j), i_down, j_down)
152
153 slope = (elev0(i,j) - elev0(i_down, j_down)) / length
154 ! TODO: as soon as current gfortran compiler is available on EVE,
155 ! use ieee_isnan from ieee_arithmetic module, instead of
156 ! slope /= slope
157 if(slope < 0.0001_dp .OR. slope > 20._dp .OR. slope /= slope) then
158 slope = 0.0001_dp
159 end if
160 end function calc_slope
161
162end module mo_mrm_river_head
Provides constants commonly used by mHM, mRM and MPR.
real(dp), parameter, public nodata_dp
integer(i4), parameter, public nodata_i4
Provides structures needed by mHM, mRM and/or mpr.
type(domain_meta), public domainmeta
real(dp), dimension(:), allocatable, public l0_elev
integer(i4), public iflag_cordinate_sys
type(grid), dimension(:), allocatable, target, public level0
Global variables for mRM only.
type(gridremapper), dimension(:), allocatable, public l0_l11_remap
integer(i4), dimension(:), allocatable, public l0_fdir
real(dp), dimension(:), allocatable, public l0_channel_depth
integer(i4), dimension(:), allocatable, public l0_facc
real(dp), dimension(:), allocatable, public l0_slope
real(dp), dimension(:), allocatable, public l11_bankfull_runoff_in
real(dp), dimension(:), allocatable, public l0_channel_elevation
Startup drainage network for mHM.
subroutine celllength(idomain, fdir, irow, jcol, icoorsystem, length)
TODO: add description.
subroutine movedownonecell(fdir, irow, jcol)
TODO: add description.
River head calculation.
subroutine, public init_masked_zeros_l0(idomain, data)
allocates memory for L0 variable
subroutine, public calc_river_head(idomain, l11_qmod, river_head)
calculates the river head
subroutine, public calc_channel_elevation()
calculates the channel elevation from the bankfull river discharge
real(dp) function calc_slope(idomain, elev0, fdir0, i, j)
calculates domain slope