Line data Source code
1 : !> \dir mRM
2 : !> \brief \copybrief f_mrm
3 : !> \details \copydetails f_mrm
4 :
5 : !> \defgroup f_mrm mRM - Fortran modules
6 : !> \brief Core modules of mRM.
7 : !> \details These modules provide the core components of mRM.
8 :
9 : !> \file mo_mrm_global_variables.f90
10 : !> \brief \copybrief mo_mrm_global_variables
11 : !> \details \copydetails mo_mrm_global_variables
12 :
13 : !> \brief Global variables for mRM only
14 : !> \details Global variables used to run mRM for mHM.
15 : !> \changelog
16 : !! - Robert Schweppe Dec 2017
17 : !! - merged duplicated variables with mhm into common variables
18 : !! - Robert Schweppe Jun 2018
19 : !! - refactoring and reformatting
20 : !> \authors Luis Samaniego, Stephan Thober
21 : !> \date Aug 2015
22 : !> \copyright Copyright 2005-\today, the mHM Developers, Luis Samaniego, Sabine Attinger: All rights reserved.
23 : !! mHM is released under the LGPLv3+ license \license_note
24 : !> \ingroup f_mrm
25 : module mo_mrm_global_variables
26 :
27 : use mo_kind, only : i4, i8, dp
28 : use mo_mrm_constants, only : nOutFlxState
29 : use mo_common_types, only : Grid, GridRemapper
30 : use mo_mrm_riv_temp_class, only : riv_temp_type
31 :
32 : implicit none
33 :
34 : PUBLIC :: gaugingStation
35 :
36 : ! -------------------------------------------------------------------
37 : ! General variables
38 : ! -------------------------------------------------------------------
39 : logical :: is_start ! flag for first timestep for mpr
40 :
41 : ! -------------------------------------------------------------------
42 : ! DEFINE OUTPUTS
43 : ! -------------------------------------------------------------------
44 : !
45 : integer(i4) :: output_deflate_level_mrm !< compression of output nc files
46 : integer(i4) :: output_time_reference_mrm !< time reference point location in output nc files
47 : logical :: output_double_precision_mrm !< float precision in output nc files
48 : integer(i4) :: timeStep_model_outputs_mrm !< timestep for writing model outputs
49 : logical, dimension(nOutFlxState) :: outputFlxState_mrm !< Define model outputs see "mhm_outputs.nml"
50 : ! dim1 = number of output variables to be written
51 : logical :: readLatLon
52 :
53 : ! ------------------------------------------------------------------
54 : ! DIRECTORIES
55 : ! ------------------------------------------------------------------
56 : ! has the dimension of nDomains
57 : character(256), dimension(:), allocatable, public :: dirGauges ! Directory where discharge files are located
58 : character(256), dimension(:), allocatable, public :: dirTotalRunoff ! Directory where simulated total runoff files are located
59 : character(256), public :: filenameTotalRunoff ! Filename of simulated total runoff file
60 : character(256), public :: varnameTotalRunoff ! variable name of total runoff
61 : character(256), dimension(:), allocatable, public :: dirBankfullRunoff ! Dir. where simulated bankfull runoff files are located
62 :
63 : ! ------------------------------------------------------------------
64 : ! CONSTANT
65 : ! ------------------------------------------------------------------
66 : integer(i4), public :: nTstepDay ! Number of time intervals per day
67 : ! ! (was previously NAGG)
68 :
69 : ! -------------------------------------------------------------------
70 : ! GRID description
71 : ! -------------------------------------------------------------------
72 : type(Grid), dimension(:), allocatable, target, public :: level11 ! Reference of the routing variables
73 : type(GridRemapper), dimension(:), allocatable, public :: l0_l11_remap ! grid information at runoff level
74 :
75 :
76 : ! -----------------------------------------------------------------
77 : ! RUNOFF variable
78 : ! -----------------------------------------------------------------
79 : real(dp), dimension(:, :), allocatable, public :: mRM_runoff ! variable containing runoff for each domain and gauge
80 :
81 : ! -----------------------------------------------------------------
82 : ! GAUGED station data
83 : ! -----------------------------------------------------------------
84 : integer(i4), public :: nGaugesTotal ! Number of evaluation gauges for all domains
85 : integer(i4), public :: nGaugesLocal ! Number of evaluation gauges for all domains on a subprocess
86 : integer(i4), public :: nInflowGaugesTotal ! Number of evaluation gauges for all domains
87 : integer(i4), public :: nMeasPerDay ! Number of observations per day,
88 : ! ! e.g. 24 -> hourly discharge, 1 -> daily discharge
89 : type gaugingStation
90 : integer(i4), dimension(:), allocatable :: domainId ! domain Id
91 : integer(i4), dimension(:), allocatable :: gaugeId ! Gauge Id (e.g. 0000444)
92 : character(256), dimension(:), allocatable :: fname ! Name runoff file
93 : real(dp), dimension(:, :), allocatable :: Q ! [m3 s-1] observed daily mean discharge (simPer)
94 : ! ! dim1=number observations, dim2=number of gauges
95 : real(dp), dimension(:, :), allocatable :: T ! [K] observed daily mean temperature (simPer)
96 : end type gaugingStation
97 : type(gaugingStation), public :: gauge ! Gauging station information
98 : type(gaugingStation), public :: InflowGauge ! inflow gauge information
99 :
100 : ! -------------------------------------------------------------------
101 : ! DOMAIN general description
102 : ! -------------------------------------------------------------------
103 : type domainInfo_mRM
104 : ! dim1 = maximum number of gauges in a given domain
105 : ! discharge measurement gauges
106 : integer(i4) :: nGauges ! Number of gauges within a domain
107 : integer(i4), dimension(:), allocatable :: gaugeIdList ! Gauge Id list (e.g. 0000444 0000445)
108 : integer(i4), dimension(:), allocatable :: gaugeIndexList ! Gauge index list (e.g. 1 for 00444, 2 for 00445)
109 : integer(i4), dimension(:), allocatable :: gaugeNodeList ! Gauge node list at L11
110 :
111 : ! discharge inflow gauges (e.g if headwar bsins are missing)
112 : integer(i4) :: nInflowGauges ! Number of gauges within a domain
113 : integer(i4), dimension(:), allocatable :: InflowGaugeIdList ! Gauge Id list (e.g. 0000444 0000445)
114 : integer(i4), dimension(:), allocatable :: InflowGaugeIndexList ! Gauge index list (e.g. 1 for 00444, 2 for 00445)
115 : integer(i4), dimension(:), allocatable :: InflowGaugeNodeList ! Gauge node list at L11
116 : logical, dimension(:), allocatable :: InflowGaugeHeadwater ! if headwater cells of inflow gauge will be considered
117 :
118 : ! domain outlet
119 : ! TODO: move this out of here since it is mrm_net_startup relevant only for domain0
120 : integer(i4) :: L0_Noutlet
121 : integer(i4), dimension(:), allocatable :: L0_rowOutlet ! Outlet locations in L0
122 : integer(i4), dimension(:), allocatable :: L0_colOutlet ! Outlet locations in L0
123 : end type domainInfo_mRM
124 :
125 : ! dim1 = domainId
126 : type(domainInfo_mRM), dimension(:), allocatable, public, target :: domain_mrm ! domain structure
127 :
128 : !> \class sink_cells_t
129 : !> \brief container to hold all sink cell ids for a domain
130 : type, public :: sink_cells_t
131 : integer(i4), dimension(:), allocatable :: ids ! cell ids of sinks
132 : end type sink_cells_t
133 : type(sink_cells_t), dimension(:), allocatable :: sink_cells !< sink cell ids for each domain
134 :
135 : ! -------------------------------------------------------------------
136 : ! L0 DOMAIN description -> those are needed within the mrm_net_startup routines only
137 : ! TODO: deallocate when net_startup is done
138 : ! -------------------------------------------------------------------
139 : ! dim1 = number grid cells
140 : ! input data - morphological variables
141 : integer(i4), public, dimension(:), allocatable :: L0_gaugeLoc ! Location of gauges within the catchment
142 : integer(i4), public, dimension(:), allocatable :: L0_InflowGaugeLoc ! Location of inflow gauges within catchment
143 : integer(i4), public, dimension(:), allocatable :: L0_fAcc ! Flow accumulation
144 : integer(i4), public, dimension(:), allocatable :: L0_fDir ! Flow direction (standard ArcGIS)
145 : !
146 : ! mRM derived variables
147 : ! dim1 = number grid cells L0
148 : integer(i4), public, dimension(:), allocatable :: L0_draSC ! Index of draining cell of each sub catchment
149 : ! ! i.e. a routing cell L11
150 : integer(i4), public, dimension(:), allocatable :: L0_draCell ! Draining cell id at L11 of ith cell of L0
151 : integer(i4), public, dimension(:), allocatable :: L0_streamNet ! Stream network
152 : integer(i4), public, dimension(:), allocatable :: L0_floodPlain ! Floodplains of stream i
153 : integer(i4), public, dimension(:), allocatable :: L0_noutlet ! number of river outlets at level 0
154 : real(dp), public, dimension(:), allocatable :: L0_celerity ! celerity at level 0
155 :
156 : ! -------------------------------------------------------------------
157 : ! L1 DOMAIN description
158 : ! -------------------------------------------------------------------
159 : ! dim1 = number grid cells L1
160 : integer(i4), public, dimension(:), allocatable :: L11_L1_ID ! Mapping of L11 Id on L1
161 : ! -------------------------------------------------------------------
162 : ! L1 variables
163 : ! -------------------------------------------------------------------
164 : ! dim1 = number grid cells L1
165 : ! dim2 = number of timesteps
166 : real(dp), public, dimension(:, :), allocatable :: L1_total_runoff_in
167 :
168 : ! -------------------------------------------------------------------
169 : ! L11 DOMAIN description
170 : ! -------------------------------------------------------------------
171 : ! dim1 = number grid cells L11
172 : ! dim2 = 2
173 : integer(i4), public, dimension(:,:), allocatable :: L11_cellCoor ! Cell coordinates (row,col)
174 : ! ! -> <only domain> Routing
175 : integer(i4), public, dimension(:), allocatable :: L1_L11_ID ! Mapping of L1 Id on L11
176 : real(dp), public, dimension(:), allocatable :: L11_areaCell ! [km2] Effective area of cell at this level
177 : real(dp), public, dimension(:), allocatable :: L11_fAcc ! [km2] flow Accumulation of cell at this level
178 : integer(i4), public, dimension(:), allocatable :: L11_fDir ! Flow direction (standard notation)
179 : integer(i4), public, dimension(:), allocatable :: L11_nOutlets
180 : real(dp), public, dimension(:), allocatable :: L11_celerity ! [m/s] celerity per grid-cell, only for
181 : ! routing-case = 3
182 : real(dp), public, dimension(:), allocatable :: L11_meandering ! Proxy: L11_length/Lopt
183 : ! Lopt := shortest possible way of stream
184 : real(dp), public, dimension(:), allocatable :: L11_LinkIn_fAcc ! fAcc inflow per Link
185 :
186 : ! Constants
187 : ! dim1 = number grid cells L11
188 : integer(i4), public, dimension(:), allocatable :: L11_rowOut ! Grid vertical location of the Outlet
189 : integer(i4), public, dimension(:), allocatable :: L11_colOut ! Grid horizontal location of the Outlet
190 :
191 : ! -------------------------------------------------------------------
192 : ! L11 NETWORK description
193 : ! -------------------------------------------------------------------
194 : ! Fluxes
195 : ! dim1 = number grid cells L11
196 : ! dim2 = 2
197 : real(dp), public, dimension(:), allocatable :: L11_Qmod ! [m3 s-1] Simulated discharge
198 : real(dp), public, dimension(:), allocatable :: L11_qOUT ! [m3 s-1] Total outflow from cells L11 at time tt
199 : real(dp), public, dimension(:, :), allocatable :: L11_qTIN ! Total discharge inputs at t-1 and t
200 : real(dp), public, dimension(:, :), allocatable :: L11_qTR ! Routed outflow leaving a node
201 :
202 : integer(i4), public, dimension(:), allocatable :: L11_fromN ! From node (sinks are at the end)
203 : integer(i4), public, dimension(:), allocatable :: L11_toN ! To node (sinks are at the end)
204 : integer(i4), public, dimension(:), allocatable :: L11_netPerm ! Routing sequence (permutation of L11_rOrder)
205 : integer(i4), public, dimension(:), allocatable :: L11_fRow ! From row in L0 grid
206 : integer(i4), public, dimension(:), allocatable :: L11_fCol ! From col in L0 grid
207 : integer(i4), public, dimension(:), allocatable :: L11_tRow ! To row in L0 grid
208 : integer(i4), public, dimension(:), allocatable :: L11_tCol ! To col in L0 grid
209 : integer(i4), public, dimension(:), allocatable :: L11_rOrder ! Network routing order
210 : integer(i4), public, dimension(:), allocatable :: L11_label ! Label Id [0='', 1=HeadWater, 2=Sink]
211 : logical, public, dimension(:), allocatable :: L11_sink ! .true. if sink node reached
212 : real(dp), public, dimension(:), allocatable :: L11_length ! [m] Total length of river link
213 : real(dp), public, dimension(:), allocatable, target :: L11_aFloodPlain ! [m2] Area of the flood plain
214 : ! ! impervious cover
215 : real(dp), public, dimension(:), allocatable :: L11_slope ! [1] Average slope of river link
216 :
217 : ! Parameters
218 : ! dim1 = number grid cells L11
219 : real(dp), public, dimension(:, :), allocatable :: L11_nLinkFracFPimp ! fraction of impervious lcover at the floodplain
220 : ! dims: nLink, LCYearID
221 :
222 : real(dp), public, dimension(:), allocatable :: L11_K ! [d] kappa: Muskingum travel time parameter.
223 : real(dp), public, dimension(:), allocatable :: L11_xi ! [1] xi: Muskingum diffusion parameter
224 : ! ! (attenuation).
225 : real(dp), public, dimension(:), allocatable :: L11_tsRout ! [s] Routing timestep
226 : real(dp), public, dimension(:), allocatable :: L11_C1 ! [-] Routing parameter C1=f(K,xi, DT) (Chow, 25-41)
227 : real(dp), public, dimension(:), allocatable :: L11_C2 ! [-] Routing parameter C2 (")
228 :
229 : ! -------------------------------------------------------------------
230 : ! GROUNDWATER COUPLING VARIABLES
231 : ! -------------------------------------------------------------------
232 : ! TODO this must be read from nml
233 : logical :: gw_coupling
234 : ! dim1 = number grid cells L1
235 : real(dp), public, dimension(:), allocatable :: L11_bankfull_runoff_in
236 : ! dim2 = number grid cells L0
237 : real(dp), public, dimension(:), allocatable :: L0_channel_depth
238 : real(dp), public, dimension(:), allocatable :: L0_channel_elevation
239 : ! the cumulated river heads, for monthly average
240 : real(dp), public, dimension(:), allocatable :: L0_river_head_mon_sum
241 : real(dp), public, dimension(:), allocatable :: L0_slope
242 :
243 : ! -------------------------------------------------------------------
244 : ! RIVER TEMPERATURE VARIABLES
245 : ! -------------------------------------------------------------------
246 : !> This is a container for the river temperature routing process (pcs)
247 : type(riv_temp_type), public :: riv_temp_pcs
248 0 : end module mo_mrm_global_variables
|