5.13.2-dev0
mHM
The mesoscale Hydrological Model
Loading...
Searching...
No Matches
mo_mhm_interface_run.f90
Go to the documentation of this file.
1!> \file mo_mhm_interface_run.f90
2!> \brief \copybrief mo_mhm_interface_run
3!> \details \copydetails mo_mhm_interface_run
4
5!> \brief Module providing interfaces for running preconfigured mHM.
6!> \details Interfaces to control the mHM run from outside (prepare domain, do timestep, ...).
7!> \authors Sebastian Mueller, Matthias Kelbling
8!> \version 0.1
9!> \date Jan 2022
10!> \copyright Copyright 2005-\today, the mHM Developers, Luis Samaniego, Sabine Attinger: All rights reserved.
11!! mHM is released under the LGPLv3+ license \license_note
12!> \ingroup f_mhm
14
15 ! forces
16 use mo_kind, only: i4, dp
17 use mo_message, only: message, error_message
18 use mo_string_utils, only : num2str
19 ! mhm
21 use mo_optimization_types, only : optidata_sim
23 use mo_common_mhm_mrm_variables, only : &
25 lcyearid, &
28 ntstepday, &
29 optimize, &
31 simper, &
32 timestep, &
34 c2tstu, &
36 use mo_common_variables, only : &
38 level0, &
39 level1, &
40 domainmeta, &
42 use mo_global_variables, only : &
47 l1_aetsoil, &
51 l1_inter, &
52 l1_melt, &
54 l1_percol, &
59 l1_rain, &
61 l1_satstw, &
62 l1_sealstw, &
64 l1_snow, &
69 l1_twsaobs, &
70 l1_etobs, &
71 l1_smobs, &
73 evap_coeff, &
81 use mo_julian, only : caldat, julday
82 use mo_string_utils, only : num2str
83 use mo_mhm, only : mhm
87 use mo_constants, only : hoursecs
89 use mo_mrm_global_variables, only : &
91 l11_c1, &
92 l11_c2, &
93 l11_l1_id, &
94 l11_tsrout, &
95 l11_fromn, &
96 l11_length, &
100 l11_qmod, &
101 l11_qout, &
102 l11_qtin, &
103 l11_qtr, &
104 l11_slope, &
105 l11_ton, &
106 l1_l11_id, &
107 domain_mrm, &
108 level11, &
109 mrm_runoff, &
112 gw_coupling, &
115 use mo_mpr_global_variables, only : &
119 l1_alpha, &
120 l1_degday, &
121 l1_degdayinc, &
122 l1_degdaymax, &
124 l1_fasp, &
125 l1_froots, &
126 l1_fsealed, &
128 l1_kbaseflow, &
129 l1_kperco, &
130 l1_kslowflow, &
131 l1_karstloss, &
132 l1_kfastflow, &
133 l1_maxinter, &
143 l1_no_count, &
144 l1_bulkdens, &
146 l1_cosmicl3, &
150 use mo_mrm_mpr, only : mrm_update_param
152 use mo_mrm_routing, only : mrm_routing
153 use mo_utils, only : ge
155 use mo_mpr_eval, only : mpr_eval
156
157contains
158
159 !> \brief prepare single run of mHM
160 subroutine mhm_interface_run_prepare(parameterset, opti_domain_indices, runoff_present, BFI_present)
161 implicit none
162 !> a set of global parameter (gamma) to run mHM, DIMENSION [no. of global_Parameters]
163 real(dp), dimension(:), optional, intent(in) :: parameterset
164 !> selected domains for optimization
165 integer(i4), dimension(:), optional, intent(in) :: opti_domain_indices
166 !> whether runoff is present
167 logical, optional, intent(in) :: runoff_present
168 !> whether BFI is present
169 logical, optional, intent(in) :: BFI_present
170
171 integer(i4) :: i, iDomain, domainID
172
173 ! run_cfg%output_runoff = .false. by default
174 if (present(runoff_present)) run_cfg%output_runoff = runoff_present
175 ! run_cfg%output_BFI = .false. by default
176 if (present(bfi_present)) run_cfg%output_BFI = bfi_present
177
178 ! store current parameter set
179 allocate(run_cfg%parameterset(size(global_parameters, dim=1)))
180 if (.not. present(parameterset) .and. optimize) then
181 call error_message("mhm_interface_run_prepare: Can't optimize without parameter!")
182 else if (.not. present(parameterset)) then
183 run_cfg%parameterset = global_parameters(:, 3)
184 else
185 run_cfg%parameterset = parameterset
186 end if
187
188 ! store domain indices for domain loop
189 if (optimize .and. present(opti_domain_indices)) then
190 run_cfg%nDomains = size(opti_domain_indices)
191 allocate(run_cfg%domain_indices(run_cfg%nDomains))
192 run_cfg%domain_indices = opti_domain_indices
193 else
194 run_cfg%nDomains = domainmeta%nDomains
195 allocate(run_cfg%domain_indices(run_cfg%nDomains))
196 run_cfg%domain_indices = [(i, i=1, run_cfg%nDomains)]
197 end if
198
199 !----------------------------------------------------------
200 ! Check optionals and initialize
201 !----------------------------------------------------------
202 if (run_cfg%output_runoff) then
203 do i = 1, run_cfg%nDomains
204 idomain = run_cfg%get_domain_index(i)
205 domainid = domainmeta%indices(idomain)
206 if (.not. domainmeta%doRouting(idomain)) then
207 call error_message("***ERROR: runoff for domain", trim(num2str(domainid)),&
208 "can not be produced, since routing process is off in Process Matrix")
209 end if
210 end do
211 end if
212
213 ! prepare BFI calculation
214 if (run_cfg%output_BFI) then
215 allocate(bfi_qbf_sum(run_cfg%nDomains))
216 allocate(bfi_qt_sum(run_cfg%nDomains))
217 bfi_qbf_sum = 0.0_dp
218 bfi_qt_sum = 0.0_dp
219 end if
220
221 if (read_restart) then
222 do i = 1, run_cfg%nDomains
223 idomain = run_cfg%get_domain_index(i)
224 domainid = domainmeta%indices(idomain)
225 ! this reads the eff. parameters and optionally the states and fluxes
226 call read_restart_states(idomain, domainid, mhmfilerestartin(idomain))
227 end do
229 call message(' Resetting mHM states and fluxes from restart files ...')
231 end if
232 else
234 call mpr_eval(run_cfg%parameterset)
236 end if
237
238 allocate(run_cfg%L1_fNotSealed(size(l1_fsealed, 1), size(l1_fsealed, 2), size(l1_fsealed, 3)))
239 run_cfg%L1_fNotSealed = 1.0_dp - l1_fsealed
240
241 end subroutine mhm_interface_run_prepare
242
243 !> \brief get number of domains for looping
245 implicit none
246 integer(i4), intent(inout) :: ndomains !< number of domains
247 ndomains = run_cfg%nDomains
248 end subroutine mhm_interface_run_get_ndomains
249
250 !> \brief prepare single domain to run mHM on
251 subroutine mhm_interface_run_prepare_domain(domain, etOptiSim, twsOptiSim, neutronsOptiSim, smOptiSim)
252 implicit none
253 !> domain loop counter
254 integer(i4), intent(in), optional :: domain
255 !> returns soil moisture time series for all grid cells (of multiple Domains concatenated),DIMENSION [nCells, nTimeSteps]
256 type(optidata_sim), dimension(:), optional, intent(inout) :: smOptiSim
257 !> dim1=ncells, dim2=time
258 type(optidata_sim), dimension(:), optional, intent(inout) :: neutronsOptiSim
259 !> returns evapotranspiration time series for all grid cells (of multiple Domains concatenated),DIMENSION [nCells, nTimeSteps]
260 type(optidata_sim), dimension(:), optional, intent(inout) :: etOptiSim
261 !> returns tws time series for all grid cells (of multiple Domains concatenated),DIMENSION [nCells, nTimeSteps]
262 type(optidata_sim), dimension(:), optional, intent(inout) :: twsOptiSim
263
264 integer(i4) :: iDomain, domainID
265
266 ! get domain index
267 run_cfg%selected_domain = 1_i4
268 if (present(domain)) run_cfg%selected_domain = domain
269 idomain = run_cfg%get_domain_index(run_cfg%selected_domain)
270 domainid = domainmeta%indices(idomain)
271
272 ! evapotranspiration optimization
273 if (present(etoptisim)) call etoptisim(idomain)%init(l1_etobs(idomain))
274 ! total water storage optimization
275 if (present(twsoptisim)) call twsoptisim(idomain)%init(l1_twsaobs(idomain))
276 ! neutrons optimization
277 if (present(neutronsoptisim)) call neutronsoptisim(idomain)%init(l1_neutronsobs(idomain))
278 ! sm optimization
279 if (present(smoptisim)) call smoptisim(idomain)%init(l1_smobs(idomain))
280
281 ! get Domain information
282 run_cfg%nCells = level1(idomain)%nCells
283 run_cfg%mask1 => level1(idomain)%mask
284 run_cfg%s1 = level1(idomain)%iStart
285 run_cfg%e1 = level1(idomain)%iEnd
286
287 if (domainmeta%doRouting(idomain)) then
288 ! ----------------------------------------
289 ! initialize factor between routing resolution and hydrologic model resolution
290 ! ----------------------------------------
291 run_cfg%tsRoutFactor = 1_i4
292 allocate(run_cfg%InflowDischarge(size(inflowgauge%Q, dim = 2)))
293 run_cfg%InflowDischarge = 0._dp
294
295 ! read states from restart
296 if (read_restart) then
297 call mrm_read_restart_states(idomain, domainid, mrmfilerestartin(idomain))
299 call message(' Resetting mRM states and fluxes from restart files for domain ', num2str(idomain), ' ...')
301 end if
302 end if
303 ! get Domain information at L11 if routing is activated
304 run_cfg%s11 = level11(idomain)%iStart
305 run_cfg%e11 = level11(idomain)%iEnd
306 run_cfg%mask11 => level11(idomain)%mask
307
308 ! initialize routing parameters (has to be called for routing option 2)
309 if ((processmatrix(8, 1) .eq. 2) .or. (processmatrix(8, 1) .eq. 3)) &
310 call mrm_update_param( &
311 idomain, run_cfg%parameterset(processmatrix(8, 3) - processmatrix(8, 2) + 1 : processmatrix(8, 3)))
312 ! initialize variable for runoff for routing
313 allocate(run_cfg%RunToRout(run_cfg%e1 - run_cfg%s1 + 1))
314 run_cfg%RunToRout = 0._dp
315
316 if ( riv_temp_pcs%active ) then
317 ! set indices for current L11 domain
318 riv_temp_pcs%s11 = run_cfg%s11
319 riv_temp_pcs%e11 = run_cfg%e11
320 ! allocate current L1 lateral components
321 call riv_temp_pcs%alloc_lateral(run_cfg%nCells)
322 end if
323 end if
324
325 ! init datetime variable
326 call run_cfg%domainDateTime%init(idomain)
327
328 ! init time-loop
329 run_cfg%time_step = 0_i4
330
332
333 !> \brief check if current time loop is finished
334 subroutine mhm_interface_run_finished(time_loop_finished)
335 implicit none
336 logical, intent(inout) :: time_loop_finished !< flag to indicate end of timeloop
337 time_loop_finished = run_cfg%time_step == run_cfg%domainDateTime%nTimeSteps
338 end subroutine mhm_interface_run_finished
339
340 !> \brief do one time-step on current domain
342 implicit none
343
344 integer(i4) :: iDomain, domainID, tt, jj, s1, e1
345
346 ! increment time step count (first input is 0)
347 run_cfg%time_step = run_cfg%time_step + 1_i4
348 ! current time counter and domain indices
349 tt = run_cfg%time_step
350 s1 = run_cfg%s1
351 e1 = run_cfg%e1
352 idomain = run_cfg%get_domain_index(run_cfg%selected_domain)
353 domainid = domainmeta%indices(idomain)
354
355 call run_cfg%domainDateTime%update_LAI_timestep()
356
357 ! update the meteo-handler
358 call meteo_handler%update_timestep( &
359 tt=tt, &
360 time=run_cfg%domainDateTime%newTime - 0.5_dp, &
361 idomain=idomain, &
362 level1=level1, &
364
365 ! get corrected pet
366 call meteo_handler%get_corrected_pet(pet_calc=l1_pet_calc(s1 : e1), &
367 ! pet calculation dependencies
368 petlaicorfactorl1 = l1_petlaicorfactor(s1 : e1, run_cfg%domainDateTime%iLAI, run_cfg%domainDateTime%yId), &
369 fasp = l1_fasp(s1 : e1, 1, 1), &
370 harsamcoeff = l1_harsamcoeff(s1 : e1, 1, 1), &
371 latitude = pack(level1(idomain)%y, level1(idomain)%mask), &
372 prietayalpha = l1_prietayalpha(s1 : e1, run_cfg%domainDateTime%iLAI, 1), &
373 aeroresist = l1_aeroresist(s1 : e1, run_cfg%domainDateTime%iLAI, run_cfg%domainDateTime%yId), &
374 surfresist = l1_surfresist(s1 : e1, run_cfg%domainDateTime%iLAI, 1))
375
376 ! get temperature and precipitation
377 call meteo_handler%get_temp(temp_calc=l1_temp_calc(s1 : e1))
378 call meteo_handler%get_prec(prec_calc=l1_prec_calc(s1 : e1))
379
380 ! -------------------------------------------------------------------------
381 ! ARGUMENT LIST KEY FOR mHM
382 ! -------------------------------------------------------------------------
383 ! C CONFIGURATION
384 ! F FORCING DATA L2
385 ! Q INFLOW FROM UPSTREAM AREAS
386 ! L0 MORPHOLOGIC DATA L0
387 ! L1 MORPHOLOGIC DATA L1
388 ! L11 MORPHOLOGIC DATA L11
389 ! P GLOBAL PARAMETERS
390 ! E EFFECTIVE PARAMETER FIELDS (L1, L11 levels)
391 ! S STATE VARIABLES L1
392 ! X FLUXES (L1, L11 levels)
393 ! --------------------------------------------------------------------------
394 call mhm( &
395 read_states = read_restart, & ! IN C
396 tt = tt, &
397 time = run_cfg%domainDateTime%newTime - 0.5_dp, &
399 horizon_depth = horizondepth_mhm, & ! IN C
400 ncells1 = run_cfg%nCells, &
401 nhorizons_mhm = nsoilhorizons_mhm, &
402 c2tstu = c2tstu, & ! IN C
405 fsealed1 = l1_fsealed(s1 : e1, 1, run_cfg%domainDateTime%yId), & ! INOUT L1
406 interc = l1_inter(s1 : e1), &
407 snowpack = l1_snowpack(s1 : e1), &
408 sealedstorage = l1_sealstw(s1 : e1), & ! INOUT S
409 soilmoisture = l1_soilmoist(s1 : e1, :), &
410 unsatstorage = l1_unsatstw(s1 : e1), &
411 satstorage = l1_satstw(s1 : e1), & ! INOUT S
412 neutrons = l1_neutrons(s1 : e1), & ! INOUT S
413 pet_calc = l1_pet_calc(s1 : e1), & ! INOUT X
414 temp_calc = l1_temp_calc(s1 : e1), & ! INOUT X
415 prec_calc = l1_prec_calc(s1 : e1), & ! INOUT X
416 aet_soil = l1_aetsoil(s1 : e1, :), &
417 aet_canopy = l1_aetcanopy(s1 : e1), &
418 aet_sealed = l1_aetsealed(s1 : e1), & ! INOUT X
419 baseflow = l1_baseflow(s1 : e1), &
420 infiltration = l1_infilsoil(s1 : e1, :), &
421 fast_interflow = l1_fastrunoff(s1 : e1), & ! INOUT X
422 melt = l1_melt(s1 : e1), &
423 perc = l1_percol(s1 : e1), &
424 prec_effect = l1_preeffect(s1 : e1), &
425 rain = l1_rain(s1 : e1), & ! INOUT X
426 runoff_sealed = l1_runoffseal(s1 : e1), &
427 slow_interflow = l1_slowrunoff(s1 : e1), &
428 snow = l1_snow(s1 : e1), & ! INOUT X
429 throughfall = l1_throughfall(s1 : e1), &
430 total_runoff = l1_total_runoff(s1 : e1), & ! INOUT X
431 ! MPR
432 alpha = l1_alpha(s1 : e1, 1, run_cfg%domainDateTime%yId), &
433 deg_day_incr = l1_degdayinc(s1 : e1, 1, run_cfg%domainDateTime%yId), &
434 deg_day_max = l1_degdaymax(s1 : e1, 1, run_cfg%domainDateTime%yId), & ! INOUT E1
435 deg_day_noprec = l1_degdaynopre(s1 : e1, 1, run_cfg%domainDateTime%yId), &
436 deg_day = l1_degday(s1 : e1, 1, 1), & ! INOUT E1
437 frac_roots = l1_froots(s1 : e1, :, run_cfg%domainDateTime%yId), & ! INOUT E1
438 interc_max = l1_maxinter(s1 : e1, run_cfg%domainDateTime%iLAI, 1), &
439 karst_loss = l1_karstloss(s1 : e1, 1, 1), & ! INOUT E1
440 k0 = l1_kfastflow(s1 : e1, 1, run_cfg%domainDateTime%yId), &
441 k1 = l1_kslowflow(s1 : e1, 1, run_cfg%domainDateTime%yId), & ! INOUT E1
442 k2 = l1_kbaseflow(s1 : e1, 1, run_cfg%domainDateTime%yId), &
443 kp = l1_kperco(s1 : e1, 1, run_cfg%domainDateTime%yId), & ! INOUT E1
444 soil_moist_fc = l1_soilmoistfc(s1 : e1, :, run_cfg%domainDateTime%yId), & ! INOUT E1
445 soil_moist_sat = l1_soilmoistsat(s1 : e1, :, run_cfg%domainDateTime%yId), & ! INOUT E1
446 soil_moist_exponen = l1_soilmoistexp(s1 : e1, :, run_cfg%domainDateTime%yId), &
447 jarvis_thresh_c1 = l1_jarvis_thresh_c1(s1 : e1, 1, 1), & ! INOUT E1
448 temp_thresh = l1_tempthresh(s1 : e1, 1, run_cfg%domainDateTime%yId), &
449 unsat_thresh = l1_unsatthresh(s1 : e1, 1, 1), & ! INOUT E1
450 water_thresh_sealed = l1_sealedthresh(s1 : e1, 1, 1), & ! INOUT E1
451 wilting_point = l1_wiltingpoint(s1 : e1, :, run_cfg%domainDateTime%yId), & ! INOUT E1
452 ! >> neutron count
453 no_count = l1_no_count(s1:e1, 1, 1), & ! INOUT E1
454 bulkdens = l1_bulkdens(s1:e1, :, run_cfg%domainDateTime%yId), & ! INOUT E1
455 latticewater = l1_latticewater(s1:e1, :, run_cfg%domainDateTime%yId), & ! INOUT E1
456 cosmicl3 = l1_cosmicl3(s1:e1, :, run_cfg%domainDateTime%yId) & ! INOUT E1
457 )
458
459 ! call mRM routing
460 run_cfg%doRoute = .false.
461 if (domainmeta%doRouting(idomain)) then
462 ! set discharge timestep
463 run_cfg%iDischargeTS = ceiling(real(tt, dp) / real(ntstepday, dp))
464 ! set input variables for routing
465 if (processmatrix(8, 1) .eq. 1) then
466 ! >>>
467 ! >>> original Muskingum routing, executed every time
468 ! >>>
469 run_cfg%doRoute = .true.
470 run_cfg%tsRoutFactorIn = 1._dp
471 run_cfg%timestep_rout = timestep
472 run_cfg%RunToRout = l1_total_runoff(s1 : e1) ! runoff [mm TS-1] mm per timestep
473 run_cfg%InflowDischarge = inflowgauge%Q(run_cfg%iDischargeTS, :) ! inflow discharge in [m3 s-1]
474 !
475 else if ((processmatrix(8, 1) .eq. 2) .or. &
476 (processmatrix(8, 1) .eq. 3)) then
477 ! >>>
478 ! >>> adaptive timestep
479 ! >>>
480 run_cfg%doRoute = .false.
481 ! calculate factor
482 run_cfg%tsRoutFactor = l11_tsrout(idomain) / (timestep * hoursecs)
483 ! print *, 'routing factor: ', tsRoutFactor
484 ! prepare routing call
485 if (run_cfg%tsRoutFactor .lt. 1._dp) then
486 ! ----------------------------------------------------------------
487 ! routing timesteps are shorter than hydrologic time steps
488 ! ----------------------------------------------------------------
489 ! set all input variables
490 run_cfg%tsRoutFactorIn = run_cfg%tsRoutFactor
491 run_cfg%RunToRout = l1_total_runoff(s1 : e1) ! runoff [mm TS-1] mm per timestep
492 run_cfg%InflowDischarge = inflowgauge%Q(run_cfg%iDischargeTS, :) ! inflow discharge in [m3 s-1]
493 run_cfg%timestep_rout = timestep
494 run_cfg%doRoute = .true.
495 else
496 ! ----------------------------------------------------------------
497 ! routing timesteps are longer than hydrologic time steps
498 ! ----------------------------------------------------------------
499 ! set all input variables
500 run_cfg%tsRoutFactorIn = run_cfg%tsRoutFactor
501 ! Runoff is accumulated in [mm]
502 run_cfg%RunToRout = run_cfg%RunToRout + l1_total_runoff(s1 : e1)
503 run_cfg%InflowDischarge = run_cfg%InflowDischarge + inflowgauge%Q(run_cfg%iDischargeTS, :)
504 ! reset tsRoutFactorIn if last period did not cover full period
505 if ((tt == run_cfg%domainDateTime%nTimeSteps) .and. (mod(tt, nint(run_cfg%tsRoutFactorIn)) /= 0_i4)) &
506 run_cfg%tsRoutFactorIn = mod(tt, nint(run_cfg%tsRoutFactorIn))
507 if ((mod(tt, nint(run_cfg%tsRoutFactorIn)) .eq. 0_i4) .or. (tt .eq. run_cfg%domainDateTime%nTimeSteps)) then
508 ! Inflow discharge is given as flow-rate and has to be converted to [m3]
509 run_cfg%InflowDischarge = run_cfg%InflowDischarge / run_cfg%tsRoutFactorIn
510 run_cfg%timestep_rout = timestep * nint(run_cfg%tsRoutFactorIn, i4)
511 run_cfg%doRoute = .true.
512 end if
513 end if
514 end if
515 ! prepare temperature routing
516 if ( riv_temp_pcs%active ) then
517 ! init riv-temp from current air temp
518 if ( tt .eq. 1_i4 ) call riv_temp_pcs%init_riv_temp( &
519 temp_air = l1_temp_calc(s1 : e1), &
520 efecarea = level1(idomain)%CellArea * 1.e-6_dp, &
521 l1_l11_id = l1_l11_id(s1 : e1), &
522 l11_areacell = level11(idomain)%CellArea * 1.e-6_dp, &
523 l11_l1_id = l11_l1_id(run_cfg%s11 : run_cfg%e11), &
524 map_flag = ge(resolutionrouting(idomain), resolutionhydrology(idomain)) &
525 )
526 ! get riv-temp specific meteo arrays
527 call meteo_handler%get_ssrd(riv_temp_pcs%L1_ssrd_calc)
528 call meteo_handler%get_strd(riv_temp_pcs%L1_strd_calc)
529 call meteo_handler%get_tann(riv_temp_pcs%L1_tann_calc)
530 ! accumulate source Energy at L1 level
531 call riv_temp_pcs%acc_source_E( &
532 fsealed_area_fraction = l1_fsealed(s1 : e1, 1, run_cfg%domainDateTime%yId), &
533 fast_interflow = l1_fastrunoff(s1 : e1), &
534 slow_interflow = l1_slowrunoff(s1 : e1), &
535 baseflow = l1_baseflow(s1 : e1), &
536 direct_runoff = l1_runoffseal(s1 : e1), &
537 temp_air = l1_temp_calc(s1 : e1) &
538 )
539 ! if routing should be performed, scale source energy to L11 level
540 if ( run_cfg%doRoute ) call riv_temp_pcs%finalize_source_E( &
541 efecarea = level1(idomain)%CellArea * 1.e-6_dp, &
542 l1_l11_id = l1_l11_id(s1 : e1), &
543 l11_areacell = level11(idomain)%CellArea * 1.e-6_dp, &
544 l11_l1_id = l11_l1_id(run_cfg%s11 : run_cfg%e11), &
545 timestep = run_cfg%timestep_rout, &
546 map_flag = ge(resolutionrouting(idomain), resolutionhydrology(idomain)) &
547 )
548 end if
549 ! -------------------------------------------------------------------
550 ! execute routing
551 ! -------------------------------------------------------------------
552 if (run_cfg%doRoute) call mrm_routing(&
553 ! general INPUT variables
554 read_restart, &
555 processmatrix(8, 1), & ! parse process Case to be used
556 run_cfg%parameterset(processmatrix(8, 3) - processmatrix(8, 2) + 1 : processmatrix(8, 3)), & ! routing par.
557 run_cfg%RunToRout, & ! runoff [mm TS-1] mm per timestep old: L1_total_runoff_in(run_cfg%s1:run_cfg%e1, tt), &
558 level1(idomain)%CellArea * 1.e-6_dp, &
559 l1_l11_id(s1 : e1), &
560 level11(idomain)%CellArea * 1.e-6_dp, &
561 l11_l1_id(run_cfg%s11 : run_cfg%e11), &
562 l11_netperm(run_cfg%s11 : run_cfg%e11), & ! routing order at L11
563 l11_fromn(run_cfg%s11 : run_cfg%e11), & ! link source at L11
564 l11_ton(run_cfg%s11 : run_cfg%e11), & ! link target at L11
565 l11_noutlets(idomain), & ! number of outlets
566 run_cfg%timestep_rout, & ! timestep of runoff to rout [h]
567 run_cfg%tsRoutFactorIn, & ! simulate timestep in [h]
568 level11(idomain)%nCells, & ! number of Nodes
569 domain_mrm(idomain)%nInflowGauges, &
570 domain_mrm(idomain)%InflowGaugeIndexList(:), &
571 domain_mrm(idomain)%InflowGaugeHeadwater(:), &
572 domain_mrm(idomain)%InflowGaugeNodeList(:), &
573 run_cfg%InflowDischarge, &
574 domain_mrm(idomain)%nGauges, &
575 domain_mrm(idomain)%gaugeIndexList(:), &
576 domain_mrm(idomain)%gaugeNodeList(:), &
577 ge(resolutionrouting(idomain), resolutionhydrology(idomain)), &
578 ! original routing specific input variables
579 l11_length(run_cfg%s11 : run_cfg%e11 - 1), & ! link length
580 l11_slope(run_cfg%s11 : run_cfg%e11 - 1), &
581 l11_nlinkfracfpimp(run_cfg%s11 : run_cfg%e11, run_cfg%domainDateTime%yId), & ! fraction of impervious layer at L11 scale
582 ! general INPUT/OUTPUT variables
583 l11_c1(run_cfg%s11 : run_cfg%e11), & ! first muskingum parameter
584 l11_c2(run_cfg%s11 : run_cfg%e11), & ! second muskigum parameter
585 l11_qout(run_cfg%s11 : run_cfg%e11), & ! routed runoff flowing out of L11 cell
586 l11_qtin(run_cfg%s11 : run_cfg%e11, :), & ! inflow water into the reach at L11
587 l11_qtr(run_cfg%s11 : run_cfg%e11, :), & !
588 l11_qmod(run_cfg%s11 : run_cfg%e11), &
589 mrm_runoff(tt, :) &
590 )
591 ! -------------------------------------------------------------------
592 ! groundwater coupling
593 ! -------------------------------------------------------------------
594 if (gw_coupling) then
596 end if
597 ! -------------------------------------------------------------------
598 ! reset variables
599 ! -------------------------------------------------------------------
600 if (processmatrix(8, 1) .eq. 1) then
601 ! reset Input variables
602 run_cfg%InflowDischarge = 0._dp
603 run_cfg%RunToRout = 0._dp
604 else if ((processmatrix(8, 1) .eq. 2) .or. (processmatrix(8, 1) .eq. 3)) then
605 if ((.not. (run_cfg%tsRoutFactorIn .lt. 1._dp)) .and. run_cfg%doRoute) then
606 do jj = 1, nint(run_cfg%tsRoutFactorIn) ! BUG: this should start at 2
607 mrm_runoff(tt - jj + 1, :) = mrm_runoff(tt, :)
608 end do
609 ! reset Input variables
610 run_cfg%InflowDischarge = 0._dp
611 run_cfg%RunToRout = 0._dp
612 ! reset lateral fluxes and time-step counter if routing was done
613 if ( riv_temp_pcs%active ) call riv_temp_pcs%reset_timestep()
614 end if
615 ! if routing is done every time-step, reset river-temp time step
616 if (run_cfg%tsRoutFactor .lt. 1._dp .and. riv_temp_pcs%active ) call riv_temp_pcs%reset_timestep()
617 end if
618 end if
619
620 ! output only for evaluation period
621 run_cfg%domainDateTime%tIndex_out = (tt - warmingdays(idomain) * ntstepday) ! tt if write out of warming period
622
623 call run_cfg%domainDateTime%increment()
624
625 ! update the year-dependent domainDateTime%yId (land cover id)
626 if (run_cfg%domainDateTime%is_new_year .and. tt < run_cfg%domainDateTime%nTimeSteps) then
627 run_cfg%domainDateTime%yId = lcyearid(run_cfg%domainDateTime%year, idomain)
628 end if
629
630 ! calculate BFI releated after warming days if wanted
631 if ( run_cfg%output_BFI .and. (run_cfg%domainDateTime%tIndex_out > 0_i4) ) then
632 bfi_qbf_sum(idomain) = bfi_qbf_sum(idomain) &
633 + sum(l1_baseflow(s1 : e1) * level1(idomain)%CellArea) / level1(idomain)%nCells
634 bfi_qt_sum(idomain) = bfi_qt_sum(idomain) &
635 + sum(l1_total_runoff(s1 : e1) * level1(idomain)%CellArea) / level1(idomain)%nCells
636 end if
637
638 end subroutine mhm_interface_run_do_time_step
639
640 !> \brief write output after current time-step
642 implicit none
643 integer(i4) :: iDomain, tt, s0, e0
644
645 ! get time step
646 tt = run_cfg%time_step
647
648 ! get domain index
649 idomain = run_cfg%get_domain_index(run_cfg%selected_domain)
650
651 if ( (.not. optimize) .and. (run_cfg%domainDateTime%tIndex_out > 0_i4)) then
652 if (any(outputflxstate_mrm) .AND. (domainmeta%doRouting(idomain))) then
653
654 if (run_cfg%domainDateTime%tIndex_out == 1) then
655 run_cfg%nc_mrm = mrm_outputdataset(idomain, run_cfg%mask11)
656 end if
657
658 ! update Dataset (riv-temp as optional input)
659 if ( riv_temp_pcs%active ) then
660 call mrm_updatedataset(run_cfg%nc_mrm, &
661 l11_qmod(run_cfg%s11 : run_cfg%e11), riv_temp_pcs%river_temp(riv_temp_pcs%s11 : riv_temp_pcs%e11))
662 else
663 call mrm_updatedataset(run_cfg%nc_mrm, l11_qmod(run_cfg%s11 : run_cfg%e11))
664 end if
665
666 ! write data
667 if (run_cfg%domainDateTime%writeout(timestep_model_outputs_mrm, tt)) then
668 call run_cfg%nc_mrm%writeTimestep(run_cfg%domainDateTime%tIndex_out * timestep)
669 end if
670
671 if(tt == run_cfg%domainDateTime%nTimeSteps) then
672 call run_cfg%nc_mrm%close()
673 end if
674
675 if ( gw_coupling ) then
676 ! create
677 if (run_cfg%domainDateTime%tIndex_out == 1) then
678 run_cfg%nc_gw = gw_outputdataset(idomain, level0(idomain)%mask)
679 end if
680 ! add data
681 s0 = level0(idomain)%iStart
682 e0 = level0(idomain)%iEnd
684 ! write
685 if (run_cfg%domainDateTime%writeout(-2, tt)) then ! -2 for monthly
686 call run_cfg%nc_gw%writeTimestep(run_cfg%domainDateTime%tIndex_out * timestep)
687 end if
688 ! close
689 if(tt == run_cfg%domainDateTime%nTimeSteps) then
690 call run_cfg%nc_gw%close()
691 end if
692 end if
693
694 end if
695
696 if (any(outputflxstate)) then
697
698 if (run_cfg%domainDateTime%tIndex_out == 1) then
699 run_cfg%nc_mhm = mhm_outputdataset(idomain, run_cfg%mask1)
700 end if
701
702 call mhm_updatedataset(&
703 run_cfg%nc_mhm, &
704 run_cfg%s1, run_cfg%e1, &
705 l1_fsealed(:, 1, run_cfg%domainDateTime%yId), &
706 run_cfg%L1_fNotSealed(:, 1, run_cfg%domainDateTime%yId), &
707 l1_inter, &
708 l1_snowpack, &
709 l1_soilmoist, &
710 l1_soilmoistsat(:, :, run_cfg%domainDateTime%yId), &
711 l1_sealstw, &
712 l1_unsatstw, &
713 l1_satstw, &
714 l1_neutrons, &
715 l1_pet_calc, &
716 l1_aetsoil, &
717 l1_aetcanopy, &
718 l1_aetsealed, &
723 l1_baseflow, &
724 l1_percol, &
725 l1_infilsoil, &
726 l1_preeffect, &
727 l1_melt &
728 )
729
730 ! write data
731 if (run_cfg%domainDateTime%writeout(timestep_model_outputs, tt)) then
732 call run_cfg%nc_mhm%writeTimestep(run_cfg%domainDateTime%tIndex_out * timestep)
733 end if
734
735 if(tt == run_cfg%domainDateTime%nTimeSteps) then
736 call run_cfg%nc_mhm%close()
737 end if
738
739 end if
740 end if ! <-- if (.not. optimize)
741
742 end subroutine mhm_interface_run_write_output
743
744 !> \brief add simulation data to optimization data types
745 subroutine mhm_interface_run_update_optisim(etOptiSim, twsOptiSim, neutronsOptiSim, smOptiSim)
746 implicit none
747 !> returns soil moisture time series for all grid cells (of multiple Domains concatenated),DIMENSION [nCells, nTimeSteps]
748 type(optidata_sim), dimension(:), optional, intent(inout) :: smOptiSim
749 !> dim1=ncells, dim2=time
750 type(optidata_sim), dimension(:), optional, intent(inout) :: neutronsOptiSim
751 !> returns evapotranspiration time series for all grid cells (of multiple Domains concatenated),DIMENSION [nCells, nTimeSteps]
752 type(optidata_sim), dimension(:), optional, intent(inout) :: etOptiSim
753 !> returns tws time series for all grid cells (of multiple Domains concatenated),DIMENSION [nCells, nTimeSteps]
754 type(optidata_sim), dimension(:), optional, intent(inout) :: twsOptiSim
755
756 integer(i4) :: gg, s1, e1, lcId
757
758 integer(i4) :: iDomain, tt
759
760 ! get time step
761 tt = run_cfg%time_step
762
763 ! get domain index
764 idomain = run_cfg%get_domain_index(run_cfg%selected_domain)
765
766 ! slice settings
767 s1 = run_cfg%s1
768 e1 = run_cfg%e1
769 lcid = run_cfg%domainDateTime%yId
770
771 !----------------------------------------------------------------------
772 ! FOR SOIL MOISTURE
773 ! NOTE:: modeled soil moisture is averaged according to input time step
774 ! soil moisture (timeStep_sm_input)
775 !----------------------------------------------------------------------
776 if (present(smoptisim)) then
777 ! only for evaluation period - ignore warming days
778 if ((tt - warmingdays(idomain) * ntstepday) .GT. 0) then
779 ! decide for daily, monthly or yearly aggregation
780 call smoptisim(idomain)%average_per_timestep(l1_smobs(idomain)%timeStepInput, &
781 run_cfg%domainDateTime%is_new_day, run_cfg%domainDateTime%is_new_month, run_cfg%domainDateTime%is_new_year)
782 ! last timestep is already done - write_counter exceeds size(smOptiSim(iDomain)%dataSim, dim=2)
783 if (tt /= run_cfg%domainDateTime%nTimeSteps) then
784 ! aggregate soil moisture to needed time step for optimization
785 call smoptisim(idomain)%average_add(sum(l1_soilmoist(:, 1 : nsoilhorizons_sm_input), dim = 2) / &
786 sum(l1_soilmoistsat(:, 1 : nsoilhorizons_sm_input, lcid), dim = 2))
787 end if
788 end if
789 end if
790
791 !----------------------------------------------------------------------
792 ! FOR NEUTRONS
793 ! NOTE:: modeled neutrons are averaged daily
794 !----------------------------------------------------------------------
795 if (present(neutronsoptisim)) then
796 ! only for evaluation period - ignore warming days
797 if ((tt - warmingdays(idomain) * ntstepday) .GT. 0) then
798 ! decide for daily, monthly or yearly aggregation
799 ! daily
800 if (run_cfg%domainDateTime%is_new_day) then
801 call neutronsoptisim(idomain)%average()
802 end if
803
804 ! last timestep is already done - write_counter exceeds size(sm_opti, dim=2)
805 if (tt /= run_cfg%domainDateTime%nTimeSteps) then
806 ! aggregate neutrons to needed time step for optimization
807 call neutronsoptisim(idomain)%average_add(l1_neutrons(s1 : e1))
808 end if
809 end if
810 end if
811
812 !----------------------------------------------------------------------
813 ! FOR EVAPOTRANSPIRATION
814 ! NOTE:: modeled evapotranspiration is averaged according to input time step
815 ! evapotranspiration (timeStep_et_input)
816 !----------------------------------------------------------------------
817 if (present(etoptisim)) then
818 ! only for evaluation period - ignore warming days
819 if ((tt - warmingdays(idomain) * ntstepday) .GT. 0) then
820 ! decide for daily, monthly or yearly aggregation
821 call etoptisim(idomain)%increment_counter(l1_etobs(idomain)%timeStepInput, &
822 run_cfg%domainDateTime%is_new_day, run_cfg%domainDateTime%is_new_month, run_cfg%domainDateTime%is_new_year)
823
824 ! last timestep is already done - write_counter exceeds size(etOptiSim(iDomain)%dataSim, dim=2)
825 if (tt /= run_cfg%domainDateTime%nTimeSteps) then
826 ! aggregate evapotranspiration to needed time step for optimization
827 call etoptisim(idomain)%add(sum(l1_aetsoil(s1 : e1, :), dim = 2) * &
828 run_cfg%L1_fNotSealed(s1 : e1, 1, lcid) + &
829 l1_aetcanopy(s1 : e1) + &
830 l1_aetsealed(s1 : e1) * l1_fsealed(s1 : e1, 1, lcid))
831 end if
832 end if
833 end if
834
835 !----------------------------------------------------------------------
836 ! FOR TWS
837 ! NOTE:: modeled tws is averaged according to input time step
838 ! (timeStepInput)
839 !----------------------------------------------------------------------
840 if (present(twsoptisim)) then
841 ! only for evaluation period - ignore warming days
842 if ((tt - warmingdays(idomain) * ntstepday) > 0) then
843 ! decide for daily, monthly or yearly aggregation
844 call twsoptisim(idomain)%average_per_timestep(l1_twsaobs(idomain)%timeStepInput, &
845 run_cfg%domainDateTime%is_new_day, run_cfg%domainDateTime%is_new_month, run_cfg%domainDateTime%is_new_year)
846
847 ! last timestep is already done - write_counter exceeds size(twsOptiSim(iDomain)%dataSim, dim=2)
848 if (tt /= run_cfg%domainDateTime%nTimeSteps) then
849 ! aggregate evapotranspiration to needed time step for optimization
850 call twsoptisim(idomain)%average_add(l1_inter(s1 : e1) + l1_snowpack(s1 : e1) + l1_sealstw(s1 : e1) + &
851 l1_unsatstw(s1 : e1) + l1_satstw(s1 : e1))
852 do gg = 1, nsoilhorizons_mhm
853 call twsoptisim(idomain)%add(l1_soilmoist(s1 : e1, gg))
854 end do
855 end if
856 end if
857 end if
858
859 ! TODO-RIV-TEMP: add OptiSim for river temperature
860
862
863 !> \brief finalize current domain after running
865 implicit none
866
867 integer(i4) :: iDomain
868
869 ! get domain index
870 idomain = run_cfg%get_domain_index(run_cfg%selected_domain)
871
872 if (allocated(run_cfg%InflowDischarge)) deallocate(run_cfg%InflowDischarge)
873 if (domainmeta%doRouting(idomain)) then
874 ! clean runoff variable
875 deallocate(run_cfg%RunToRout)
876 if ( riv_temp_pcs%active ) call riv_temp_pcs%dealloc_lateral()
877 end if
878
880
881 !> \brief finalize run
882 subroutine mhm_interface_run_finalize(runoff, BFI)
883 implicit none
884 !> returns runoff time series, DIMENSION [nTimeSteps, nGaugesTotal]
885 real(dp), dimension(:, :), allocatable, optional, intent(out) :: runoff
886 !> baseflow index, dim1=domainID
887 real(dp), dimension(:), allocatable, optional, intent(out) :: BFI
888
889 if (present(runoff) .and. (processmatrix(8, 1) > 0)) runoff = mrm_runoff
890 if (present(bfi)) then
891 bfi = bfi_qbf_sum / bfi_qt_sum
892 deallocate(bfi_qbf_sum)
893 deallocate(bfi_qt_sum)
894 end if
895
896 if (allocated(run_cfg%parameterset)) deallocate(run_cfg%parameterset)
897 if (allocated(run_cfg%L1_fNotSealed)) deallocate(run_cfg%L1_fNotSealed)
898 if (allocated(run_cfg%domain_indices)) deallocate(run_cfg%domain_indices)
899
900 end subroutine mhm_interface_run_finalize
901
902end module mo_mhm_interface_run
Python bindings of mHM.
Definition __init__.py:1
type for date time information with an increment subroutine
Provides structures needed by mHM, mRM and/or mpr.
character(256), dimension(:), allocatable, public mrmfilerestartin
logical, public restart_reset_fluxes_states
flag to reset fluxes and states read from restart to default values
character(256), dimension(:), allocatable, public mhmfilerestartin
real(dp), dimension(:), allocatable, public resolutionrouting
integer(i4), dimension(:), allocatable, public warmingdays
integer(i4), dimension(:, :), allocatable, public lcyearid
type(period), dimension(:), allocatable, public simper
Provides structures needed by mhm_eval to store current run config.
type(run_cfg_t), public run_cfg
This is a container to hold all information while running mHM.
Provides structures needed by mHM, mRM and/or mpr.
real(dp), dimension(:), allocatable, public resolutionhydrology
real(dp), dimension(:, :), allocatable, target, public global_parameters
type(domain_meta), public domainmeta
integer(i4), dimension(nprocesses, 3), public processmatrix
type(grid), dimension(:), allocatable, target, public level1
type(grid), dimension(:), allocatable, target, public level0
Main global variables for mHM.
type(meteo_handler_type), public meteo_handler
the meteo handler class
real(dp), dimension(:), allocatable, public l1_slowrunoff
[mm TS-1] Slow runoff component
real(dp), dimension(:, :), allocatable, public l1_aetsoil
[mm TS-1] Actual ET from soil layers
real(dp), dimension(:), allocatable, public l1_rain
[mm TS-1] Rain precipitation depth
real(dp), dimension(:), allocatable, public l1_aetsealed
[mm TS-1] Real evap.
real(dp), dimension(:), allocatable, public l1_satstw
[mm] groundwater storage
logical, dimension(noutflxstate) outputflxstate
Define model outputs see "mhm_outputs.nml" dim1 = number of output variables to be written.
real(dp), dimension(:), allocatable, public l1_aetcanopy
[mm TS-1] Real evaporation intensity from canopy
type(optidata), dimension(:), allocatable, public l1_twsaobs
this stores L1_tws, the mask, the directory of the observerd data, and the timestepInput of the simul...
real(dp), dimension(:), allocatable, public l1_snow
[mm TS-1] Snow precipitation depth
real(dp), dimension(:), allocatable, public l1_preeffect
[mm TS-1] Effective precip.
type(optidata), dimension(:), allocatable, public l1_neutronsobs
real(dp), dimension(:), allocatable, public l1_inter
[mm] Interception
real(dp), dimension(:), allocatable, public neutron_integral_afast
pre-calculated integrand for
real(dp), dimension(:), allocatable, public l1_sealstw
[mm] Retention storage of impervious areas
real(dp), dimension(:), allocatable, public l1_percol
[mm TS-1] Percolation.
type(optidata), dimension(:), allocatable, public l1_smobs
real(dp), dimension(:, :), allocatable, public l1_soilmoist
[mm] Soil moisture of each horizon
integer(i4) timestep_model_outputs
timestep for writing model outputs
real(dp), dimension(int(yearmonths, i4)), public evap_coeff
[-] Evap.
real(dp), dimension(:), allocatable, public bfi_qbf_sum
q2 weighted sum for each domain
real(dp), dimension(:), allocatable, public bfi_qt_sum
q2 weighted sum for each domain
real(dp), dimension(:), allocatable, public l1_pet_calc
[mm TS-1] estimated/corrected potential evapotranspiration
real(dp), dimension(:), allocatable, public l1_unsatstw
[mm] upper soil storage
type(optidata), dimension(:), allocatable, public l1_etobs
real(dp), dimension(:), allocatable, public l1_melt
[mm TS-1] Melting snow depth.
real(dp), dimension(:), allocatable, public l1_fastrunoff
[mm TS-1] Fast runoff component
real(dp), dimension(:), allocatable, public l1_snowpack
[mm] Snowpack
real(dp), dimension(:), allocatable, public l1_neutrons
[mm] Ground Albedo Neutrons
real(dp), dimension(:), allocatable, public l1_prec_calc
[mm TS-1] precipitation for current time step
real(dp), dimension(:), allocatable, public l1_runoffseal
[mm TS-1] Direct runoff from impervious areas
real(dp), dimension(:, :), allocatable, public l1_infilsoil
[mm TS-1] Infiltration intensity each soil horizon
real(dp), dimension(:), allocatable, public l1_baseflow
[mm TS-1] Baseflow
real(dp), dimension(:), allocatable, public l1_throughfall
[mm TS-1] Throughfall.
real(dp), dimension(:), allocatable, public l1_temp_calc
[degC] temperature for current time step
real(dp), dimension(:), allocatable, public l1_total_runoff
[m3 TS-1] Generated runoff
Initialization of all state variables of mHM.
subroutine, public variables_default_init
Default initalization mHM related L1 variables.
subroutine, public fluxes_states_default_init
initialize fluxes and states with default values
Module providing interfaces for running preconfigured mHM.
subroutine mhm_interface_run_get_ndomains(ndomains)
get number of domains for looping
subroutine mhm_interface_run_prepare(parameterset, opti_domain_indices, runoff_present, bfi_present)
prepare single run of mHM
subroutine mhm_interface_run_write_output()
write output after current time-step
subroutine mhm_interface_run_prepare_domain(domain, etoptisim, twsoptisim, neutronsoptisim, smoptisim)
prepare single domain to run mHM on
subroutine mhm_interface_run_update_optisim(etoptisim, twsoptisim, neutronsoptisim, smoptisim)
add simulation data to optimization data types
subroutine mhm_interface_run_finished(time_loop_finished)
check if current time loop is finished
subroutine mhm_interface_run_do_time_step()
do one time-step on current domain
subroutine mhm_interface_run_finalize_domain()
finalize current domain after running
subroutine mhm_interface_run_finalize(runoff, bfi)
finalize run
Call all main processes of mHM.
Definition mo_mhm.f90:93
Runs MPR.
subroutine, public mpr_eval(parameterset, opti_domain_indices)
Runs MPR and writes to global effective parameters.
Global variables for mpr only.
real(dp), dimension(:, :, :), allocatable, public l1_degday
real(dp), dimension(:, :, :), allocatable, public l1_degdaymax
real(dp), dimension(:, :, :), allocatable, public l1_soilmoistexp
real(dp), dimension(:, :, :), allocatable, public l1_harsamcoeff
real(dp), dimension(:, :, :), allocatable, public l1_karstloss
real(dp), dimension(:, :, :), allocatable, public l1_unsatthresh
real(dp), dimension(:, :, :), allocatable, public l1_kperco
real(dp), dimension(:, :, :), allocatable, public l1_alpha
real(dp), dimension(:, :, :), allocatable, public l1_surfresist
real(dp), dimension(:,:,:), allocatable, public l1_cosmicl3
real(dp), dimension(:, :, :), allocatable, public l1_degdayinc
real(dp), dimension(:, :, :), allocatable, public l1_petlaicorfactor
real(dp), dimension(:, :, :), allocatable, public l1_fasp
real(dp), dimension(:, :, :), allocatable, public l1_kbaseflow
real(dp), dimension(:, :, :), allocatable, public l1_soilmoistfc
integer(i4), public nsoilhorizons_mhm
real(dp), dimension(:, :, :), allocatable, public l1_maxinter
real(dp), dimension(:,:,:), allocatable, public l1_bulkdens
real(dp), dimension(:, :, :), allocatable, public l1_degdaynopre
real(dp), dimension(:, :, :), allocatable, public l1_wiltingpoint
real(dp), dimension(:, :, :), allocatable, public l1_prietayalpha
real(dp), dimension(:, :, :), allocatable, public l1_fsealed
real(dp), dimension(:, :, :), allocatable, public l1_froots
real(dp), dimension(:, :, :), allocatable, public l1_jarvis_thresh_c1
real(dp), dimension(:, :, :), allocatable, public l1_tempthresh
real(dp), dimension(:), allocatable, public horizondepth_mhm
real(dp), dimension(:,:,:), allocatable, public l1_no_count
real(dp), dimension(:, :, :), allocatable, public l1_kfastflow
real(dp), dimension(:, :, :), allocatable, public l1_kslowflow
real(dp), dimension(:, :, :), allocatable, public l1_aeroresist
real(dp), dimension(:, :, :), allocatable, public l1_sealedthresh
real(dp), dimension(:, :, :), allocatable, public l1_soilmoistsat
real(dp), dimension(:,:,:), allocatable, public l1_latticewater
Global variables for mRM only.
type(gaugingstation), public inflowgauge
real(dp), dimension(:, :), allocatable, public l11_qtin
integer(i4), dimension(:), allocatable, public l11_netperm
real(dp), dimension(:), allocatable, public l11_qout
real(dp), dimension(:, :), allocatable, public l11_nlinkfracfpimp
integer(i4), dimension(:), allocatable, public l11_l1_id
integer(i4), dimension(:), allocatable, public l1_l11_id
type(riv_temp_type), public riv_temp_pcs
This is a container for the river temperature routing process (pcs)
real(dp), dimension(:, :), allocatable, public mrm_runoff
integer(i4), dimension(:), allocatable, public l11_fromn
logical, dimension(noutflxstate) outputflxstate_mrm
Define model outputs see "mhm_outputs.nml".
real(dp), dimension(:), allocatable, public l11_length
real(dp), dimension(:), allocatable, public l11_qmod
integer(i4), dimension(:), allocatable, public l11_ton
type(domaininfo_mrm), dimension(:), allocatable, target, public domain_mrm
type(grid), dimension(:), allocatable, target, public level11
integer(i4) timestep_model_outputs_mrm
timestep for writing model outputs
real(dp), dimension(:), allocatable, public l11_c1
real(dp), dimension(:), allocatable, public l11_slope
integer(i4), dimension(:), allocatable, public l11_noutlets
real(dp), dimension(:), allocatable, public l11_tsrout
real(dp), dimension(:), allocatable, public l0_river_head_mon_sum
real(dp), dimension(:, :), allocatable, public l11_qtr
real(dp), dimension(:), allocatable, public l11_areacell
real(dp), dimension(:), allocatable, public l11_c2
Wrapper for initializing Routing.
subroutine, public fluxes_states_default_init_routing(idomain)
initialize fluxes and states with default values for mRM
subroutine, public variables_default_init_routing
Default initalization mRM related L11 variables.
Perform Multiscale Parameter Regionalization on Routing Parameters.
subroutine, public mrm_update_param(idomain, param)
TODO: add description.
Restart routines.
subroutine, public mrm_read_restart_states(idomain, domainid, infile)
read routing states
River head calculation.
subroutine, public calc_river_head(idomain, l11_qmod, river_head)
calculates the river head
Performs runoff routing for mHM at level L11.
subroutine, public mrm_routing(read_states, processcase, global_routing_param, l1_total_runoff, l1_areacell, l1_l11_id, l11_areacell, l11_l1_id, l11_netperm, l11_fromn, l11_ton, l11_noutlets, timestep, tsroutfactor, nnodes, ninflowgauges, inflowgaugeindexlist, inflowgaugeheadwater, inflowgaugenodelist, inflowdischarge, ngauges, gaugeindexlist, gaugenodelist, map_flag, l11_length, l11_slope, l11_fracfpimp, l11_c1, l11_c2, l11_qout, l11_qtin, l11_qtr, l11_qmod, gaugedischarge)
route water given runoff
Creates NetCDF output for different fluxes and state variables of mHM.
subroutine mrm_updatedataset(nc_mrm, l11_qmod, l11_riv_temp)
Update all variables.
type(outputdataset) function gw_outputdataset(idomain, mask)
Initialize groundwater coupling OutputDataset.
subroutine gw_updatedataset(nc_gw, l0_river_head)
Update riverhead.
type(outputdataset) function mrm_outputdataset(idomain, mask)
Initialize mRM OutputDataset.
reading and writing states, fluxes and configuration for restart of mHM.
subroutine, public read_restart_states(idomain, domainid, infile)
reads fluxes and state variables from file
Creates NetCDF output for different fluxes and state variables of mHM.
type(outputdataset) function mhm_outputdataset(idomain, mask1)
Initialize mHM OutputDataset.
subroutine mhm_updatedataset(nc_mhm, sidx, eidx, l1_fsealed, l1_fnotsealed, l1_inter, l1_snowpack, l1_soilmoist, l1_soilmoistsat, l1_sealstw, l1_unsatstw, l1_satstw, l1_neutrons, l1_pet, l1_aetsoil, l1_aetcanopy, l1_aetsealed, l1_total_runoff, l1_runoffseal, l1_fastrunoff, l1_slowrunoff, l1_baseflow, l1_percol, l1_infilsoil, l1_preeffect, l1_melt)
Update all variables.