5.13.3
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
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, &
72 l1_spfobs, &
74 evap_coeff, &
82 use mo_julian, only : caldat, julday
83 use mo_string_utils, only : num2str
84 use mo_mhm, only : mhm
88 use mo_constants, only : hoursecs
90 use mo_mrm_global_variables, only : &
92 l11_c1, &
93 l11_c2, &
94 l11_l1_id, &
95 l11_tsrout, &
96 l11_fromn, &
97 l11_length, &
98 sink_cells, &
100 l11_noutlets, &
101 l11_netperm, &
102 l11_qmod, &
103 l11_qout, &
104 l11_qtin, &
105 l11_qtr, &
106 l11_slope, &
107 l11_ton, &
108 l1_l11_id, &
109 domain_mrm, &
110 level11, &
111 mrm_runoff, &
114 gw_coupling, &
117 use mo_mpr_global_variables, only : &
121 l1_alpha, &
122 l1_degday, &
123 l1_degdayinc, &
124 l1_degdaymax, &
126 l1_fasp, &
127 l1_froots, &
128 l1_fsealed, &
130 l1_kbaseflow, &
131 l1_kperco, &
132 l1_kslowflow, &
133 l1_karstloss, &
134 l1_kfastflow, &
135 l1_maxinter, &
145 l1_no_count, &
146 l1_bulkdens, &
148 l1_cosmicl3, &
152 use mo_mrm_mpr, only : mrm_update_param
154 use mo_mrm_routing, only : mrm_routing
155 use mo_utils, only : ge
157 use mo_mpr_eval, only : mpr_eval
158
159contains
160
161 !> \brief prepare single run of mHM
162 subroutine mhm_interface_run_prepare(parameterset, opti_domain_indices, runoff_present, BFI_present)
163 implicit none
164 !> a set of global parameter (gamma) to run mHM, DIMENSION [no. of global_Parameters]
165 real(dp), dimension(:), optional, intent(in) :: parameterset
166 !> selected domains for optimization
167 integer(i4), dimension(:), optional, intent(in) :: opti_domain_indices
168 !> whether runoff is present
169 logical, optional, intent(in) :: runoff_present
170 !> whether BFI is present
171 logical, optional, intent(in) :: BFI_present
172
173 integer(i4) :: i, iDomain, domainID
174
175 ! run_cfg%output_runoff = .false. by default
176 if (present(runoff_present)) run_cfg%output_runoff = runoff_present
177 ! run_cfg%output_BFI = .false. by default
178 if (present(bfi_present)) run_cfg%output_BFI = bfi_present
179
180 ! store current parameter set
181 allocate(run_cfg%parameterset(size(global_parameters, dim=1)))
182 if (.not. present(parameterset) .and. optimize) then
183 call error_message("mhm_interface_run_prepare: Can't optimize without parameter!")
184 else if (.not. present(parameterset)) then
185 run_cfg%parameterset = global_parameters(:, 3)
186 else
187 run_cfg%parameterset = parameterset
188 end if
189
190 ! store domain indices for domain loop
191 if (optimize .and. present(opti_domain_indices)) then
192 run_cfg%nDomains = size(opti_domain_indices)
193 allocate(run_cfg%domain_indices(run_cfg%nDomains))
194 run_cfg%domain_indices = opti_domain_indices
195 else
196 run_cfg%nDomains = domainmeta%nDomains
197 allocate(run_cfg%domain_indices(run_cfg%nDomains))
198 run_cfg%domain_indices = [(i, i=1, run_cfg%nDomains)]
199 end if
200
201 !----------------------------------------------------------
202 ! Check optionals and initialize
203 !----------------------------------------------------------
204 if (run_cfg%output_runoff) then
205 do i = 1, run_cfg%nDomains
206 idomain = run_cfg%get_domain_index(i)
207 domainid = domainmeta%indices(idomain)
208 if (.not. domainmeta%doRouting(idomain)) then
209 call error_message("***ERROR: runoff for domain", trim(num2str(domainid)),&
210 "can not be produced, since routing process is off in Process Matrix")
211 end if
212 end do
213 end if
214
215 ! prepare BFI calculation
216 if (run_cfg%output_BFI) then
217 allocate(bfi_qbf_sum(run_cfg%nDomains))
218 allocate(bfi_qt_sum(run_cfg%nDomains))
219 bfi_qbf_sum = 0.0_dp
220 bfi_qt_sum = 0.0_dp
221 end if
222
223 if (read_restart) then
224 do i = 1, run_cfg%nDomains
225 idomain = run_cfg%get_domain_index(i)
226 domainid = domainmeta%indices(idomain)
227 ! this reads the eff. parameters and optionally the states and fluxes
228 call read_restart_states(idomain, domainid, mhmfilerestartin(idomain))
229 end do
231 call message(' Resetting mHM states and fluxes from restart files ...')
233 end if
234 else
236 call mpr_eval(run_cfg%parameterset)
238 end if
239
240 allocate(run_cfg%L1_fNotSealed(size(l1_fsealed, 1), size(l1_fsealed, 2), size(l1_fsealed, 3)))
241 run_cfg%L1_fNotSealed = 1.0_dp - l1_fsealed
242
243 end subroutine mhm_interface_run_prepare
244
245 !> \brief get number of domains for looping
247 implicit none
248 integer(i4), intent(inout) :: ndomains !< number of domains
249 ndomains = run_cfg%nDomains
250 end subroutine mhm_interface_run_get_ndomains
251
252 !> \brief prepare single domain to run mHM on
253 subroutine mhm_interface_run_prepare_domain(domain, etOptiSim, twsOptiSim, neutronsOptiSim, smOptiSim, sweOptiSim)
254 implicit none
255 !> domain loop counter
256 integer(i4), intent(in), optional :: domain
257 !> returns soil moisture time series for all grid cells (of multiple Domains concatenated),DIMENSION [nCells, nTimeSteps]
258 type(optidata_sim), dimension(:), optional, intent(inout) :: smOptiSim
259 !> dim1=ncells, dim2=time
260 type(optidata_sim), dimension(:), optional, intent(inout) :: neutronsOptiSim
261 !> returns evapotranspiration time series for all grid cells (of multiple Domains concatenated),DIMENSION [nCells, nTimeSteps]
262 type(optidata_sim), dimension(:), optional, intent(inout) :: etOptiSim
263 !> returns tws time series for all grid cells (of multiple Domains concatenated),DIMENSION [nCells, nTimeSteps]
264 type(optidata_sim), dimension(:), optional, intent(inout) :: twsOptiSim
265 !> returns swe time series for all grid cells (of multiple Domains concatenated),DIMENSION [nCells, nTimeSteps]
266 type(optidata_sim), dimension(:), optional, intent(inout) :: sweOptiSim
267
268 integer(i4) :: iDomain, domainID
269
270 ! get domain index
271 run_cfg%selected_domain = 1_i4
272 if (present(domain)) run_cfg%selected_domain = domain
273 idomain = run_cfg%get_domain_index(run_cfg%selected_domain)
274 domainid = domainmeta%indices(idomain)
275
276 ! evapotranspiration optimization
277 if (present(etoptisim)) call etoptisim(idomain)%init(l1_etobs(idomain))
278 ! total water storage optimization
279 if (present(twsoptisim)) call twsoptisim(idomain)%init(l1_twsaobs(idomain))
280 ! neutrons optimization
281 if (present(neutronsoptisim)) call neutronsoptisim(idomain)%init(l1_neutronsobs(idomain))
282 ! sm optimization
283 if (present(smoptisim)) call smoptisim(idomain)%init(l1_smobs(idomain))
284 ! swe optimization
285 if (present(sweoptisim)) call sweoptisim(idomain)%init(l1_spfobs(idomain))
286
287 ! get Domain information
288 run_cfg%nCells = level1(idomain)%nCells
289 run_cfg%mask1 => level1(idomain)%mask
290 run_cfg%s1 = level1(idomain)%iStart
291 run_cfg%e1 = level1(idomain)%iEnd
292
293 if (domainmeta%doRouting(idomain)) then
294 ! ----------------------------------------
295 ! initialize factor between routing resolution and hydrologic model resolution
296 ! ----------------------------------------
297 run_cfg%tsRoutFactor = 1_i4
298 allocate(run_cfg%InflowDischarge(size(inflowgauge%Q, dim = 2)))
299 run_cfg%InflowDischarge = 0._dp
300
301 ! read states from restart
302 if (read_restart) then
303 call mrm_read_restart_states(idomain, domainid, mrmfilerestartin(idomain))
305 call message(' Resetting mRM states and fluxes from restart files for domain ', num2str(idomain), ' ...')
307 end if
308 end if
309 ! get Domain information at L11 if routing is activated
310 run_cfg%s11 = level11(idomain)%iStart
311 run_cfg%e11 = level11(idomain)%iEnd
312 run_cfg%mask11 => level11(idomain)%mask
313
314 ! initialize routing parameters (has to be called for routing option 2)
315 if ((processmatrix(8, 1) .eq. 2) .or. (processmatrix(8, 1) .eq. 3)) &
316 call mrm_update_param( &
317 idomain, run_cfg%parameterset(processmatrix(8, 3) - processmatrix(8, 2) + 1 : processmatrix(8, 3)))
318 ! initialize variable for runoff for routing
319 allocate(run_cfg%RunToRout(run_cfg%e1 - run_cfg%s1 + 1))
320 run_cfg%RunToRout = 0._dp
321
322 if ( riv_temp_pcs%active ) then
323 ! set indices for current L11 domain
324 riv_temp_pcs%s11 = run_cfg%s11
325 riv_temp_pcs%e11 = run_cfg%e11
326 ! allocate current L1 lateral components
327 call riv_temp_pcs%alloc_lateral(run_cfg%nCells)
328 end if
329 end if
330
331 ! init datetime variable
332 call run_cfg%domainDateTime%init(idomain)
333
334 ! init time-loop
335 run_cfg%time_step = 0_i4
336
338
339 !> \brief check if current time loop is finished
340 subroutine mhm_interface_run_finished(time_loop_finished)
341 implicit none
342 logical, intent(inout) :: time_loop_finished !< flag to indicate end of timeloop
343 time_loop_finished = run_cfg%time_step == run_cfg%domainDateTime%nTimeSteps
344 end subroutine mhm_interface_run_finished
345
346 !> \brief do one time-step on current domain
348 implicit none
349
350 integer(i4) :: iDomain, domainID, tt, jj, s1, e1
351
352 ! increment time step count (first input is 0)
353 run_cfg%time_step = run_cfg%time_step + 1_i4
354 ! current time counter and domain indices
355 tt = run_cfg%time_step
356 s1 = run_cfg%s1
357 e1 = run_cfg%e1
358 idomain = run_cfg%get_domain_index(run_cfg%selected_domain)
359 domainid = domainmeta%indices(idomain)
360
361 call run_cfg%domainDateTime%update_LAI_timestep()
362
363 ! update the meteo-handler
364 call meteo_handler%update_timestep( &
365 tt=tt, &
366 time=run_cfg%domainDateTime%newTime - 0.5_dp, &
367 idomain=idomain, &
368 level1=level1, &
370
371 ! get corrected pet
372 call meteo_handler%get_corrected_pet(pet_calc=l1_pet_calc(s1 : e1), &
373 ! pet calculation dependencies
374 petlaicorfactorl1 = l1_petlaicorfactor(s1 : e1, run_cfg%domainDateTime%iLAI, run_cfg%domainDateTime%yId), &
375 fasp = l1_fasp(s1 : e1, 1, 1), &
376 harsamcoeff = l1_harsamcoeff(s1 : e1, 1, 1), &
377 latitude = pack(level1(idomain)%y, level1(idomain)%mask), &
378 prietayalpha = l1_prietayalpha(s1 : e1, run_cfg%domainDateTime%iLAI, 1), &
379 aeroresist = l1_aeroresist(s1 : e1, run_cfg%domainDateTime%iLAI, run_cfg%domainDateTime%yId), &
380 surfresist = l1_surfresist(s1 : e1, run_cfg%domainDateTime%iLAI, 1))
381
382 ! get temperature and precipitation
383 call meteo_handler%get_temp(temp_calc=l1_temp_calc(s1 : e1))
384 call meteo_handler%get_prec(prec_calc=l1_prec_calc(s1 : e1))
385
386 ! -------------------------------------------------------------------------
387 ! ARGUMENT LIST KEY FOR mHM
388 ! -------------------------------------------------------------------------
389 ! C CONFIGURATION
390 ! F FORCING DATA L2
391 ! Q INFLOW FROM UPSTREAM AREAS
392 ! L0 MORPHOLOGIC DATA L0
393 ! L1 MORPHOLOGIC DATA L1
394 ! L11 MORPHOLOGIC DATA L11
395 ! P GLOBAL PARAMETERS
396 ! E EFFECTIVE PARAMETER FIELDS (L1, L11 levels)
397 ! S STATE VARIABLES L1
398 ! X FLUXES (L1, L11 levels)
399 ! --------------------------------------------------------------------------
400 call mhm( &
401 read_states = read_restart, & ! IN C
402 tt = tt, &
403 time = run_cfg%domainDateTime%newTime - 0.5_dp, &
405 horizon_depth = horizondepth_mhm, & ! IN C
406 ncells1 = run_cfg%nCells, &
407 nhorizons_mhm = nsoilhorizons_mhm, &
408 c2tstu = c2tstu, & ! IN C
411 fsealed1 = l1_fsealed(s1 : e1, 1, run_cfg%domainDateTime%yId), & ! INOUT L1
412 interc = l1_inter(s1 : e1), &
413 snowpack = l1_snowpack(s1 : e1), &
414 sealedstorage = l1_sealstw(s1 : e1), & ! INOUT S
415 soilmoisture = l1_soilmoist(s1 : e1, :), &
416 unsatstorage = l1_unsatstw(s1 : e1), &
417 satstorage = l1_satstw(s1 : e1), & ! INOUT S
418 neutrons = l1_neutrons(s1 : e1), & ! INOUT S
419 pet_calc = l1_pet_calc(s1 : e1), & ! INOUT X
420 temp_calc = l1_temp_calc(s1 : e1), & ! INOUT X
421 prec_calc = l1_prec_calc(s1 : e1), & ! INOUT X
422 aet_soil = l1_aetsoil(s1 : e1, :), &
423 aet_canopy = l1_aetcanopy(s1 : e1), &
424 aet_sealed = l1_aetsealed(s1 : e1), & ! INOUT X
425 baseflow = l1_baseflow(s1 : e1), &
426 infiltration = l1_infilsoil(s1 : e1, :), &
427 fast_interflow = l1_fastrunoff(s1 : e1), & ! INOUT X
428 melt = l1_melt(s1 : e1), &
429 perc = l1_percol(s1 : e1), &
430 prec_effect = l1_preeffect(s1 : e1), &
431 rain = l1_rain(s1 : e1), & ! INOUT X
432 runoff_sealed = l1_runoffseal(s1 : e1), &
433 slow_interflow = l1_slowrunoff(s1 : e1), &
434 snow = l1_snow(s1 : e1), & ! INOUT X
435 throughfall = l1_throughfall(s1 : e1), &
436 total_runoff = l1_total_runoff(s1 : e1), & ! INOUT X
437 ! MPR
438 alpha = l1_alpha(s1 : e1, 1, run_cfg%domainDateTime%yId), &
439 deg_day_incr = l1_degdayinc(s1 : e1, 1, run_cfg%domainDateTime%yId), &
440 deg_day_max = l1_degdaymax(s1 : e1, 1, run_cfg%domainDateTime%yId), & ! INOUT E1
441 deg_day_noprec = l1_degdaynopre(s1 : e1, 1, run_cfg%domainDateTime%yId), &
442 deg_day = l1_degday(s1 : e1, 1, 1), & ! INOUT E1
443 frac_roots = l1_froots(s1 : e1, :, run_cfg%domainDateTime%yId), & ! INOUT E1
444 interc_max = l1_maxinter(s1 : e1, run_cfg%domainDateTime%iLAI, 1), &
445 karst_loss = l1_karstloss(s1 : e1, 1, 1), & ! INOUT E1
446 k0 = l1_kfastflow(s1 : e1, 1, run_cfg%domainDateTime%yId), &
447 k1 = l1_kslowflow(s1 : e1, 1, run_cfg%domainDateTime%yId), & ! INOUT E1
448 k2 = l1_kbaseflow(s1 : e1, 1, run_cfg%domainDateTime%yId), &
449 kp = l1_kperco(s1 : e1, 1, run_cfg%domainDateTime%yId), & ! INOUT E1
450 soil_moist_fc = l1_soilmoistfc(s1 : e1, :, run_cfg%domainDateTime%yId), & ! INOUT E1
451 soil_moist_sat = l1_soilmoistsat(s1 : e1, :, run_cfg%domainDateTime%yId), & ! INOUT E1
452 soil_moist_exponen = l1_soilmoistexp(s1 : e1, :, run_cfg%domainDateTime%yId), &
453 jarvis_thresh_c1 = l1_jarvis_thresh_c1(s1 : e1, 1, 1), & ! INOUT E1
454 temp_thresh = l1_tempthresh(s1 : e1, 1, run_cfg%domainDateTime%yId), &
455 unsat_thresh = l1_unsatthresh(s1 : e1, 1, 1), & ! INOUT E1
456 water_thresh_sealed = l1_sealedthresh(s1 : e1, 1, 1), & ! INOUT E1
457 wilting_point = l1_wiltingpoint(s1 : e1, :, run_cfg%domainDateTime%yId), & ! INOUT E1
458 ! >> neutron count
459 no_count = l1_no_count(s1:e1, 1, 1), & ! INOUT E1
460 bulkdens = l1_bulkdens(s1:e1, :, run_cfg%domainDateTime%yId), & ! INOUT E1
461 latticewater = l1_latticewater(s1:e1, :, run_cfg%domainDateTime%yId), & ! INOUT E1
462 cosmicl3 = l1_cosmicl3(s1:e1, :, run_cfg%domainDateTime%yId) & ! INOUT E1
463 )
464
465 ! call mRM routing
466 run_cfg%doRoute = .false.
467 if (domainmeta%doRouting(idomain)) then
468 ! set discharge timestep
469 run_cfg%iDischargeTS = ceiling(real(tt, dp) / real(ntstepday, dp))
470 ! set input variables for routing
471 if (processmatrix(8, 1) .eq. 1) then
472 ! >>>
473 ! >>> original Muskingum routing, executed every time
474 ! >>>
475 run_cfg%doRoute = .true.
476 run_cfg%tsRoutFactorIn = 1._dp
477 run_cfg%timestep_rout = timestep
478 run_cfg%RunToRout = l1_total_runoff(s1 : e1) ! runoff [mm TS-1] mm per timestep
479 run_cfg%InflowDischarge = inflowgauge%Q(run_cfg%iDischargeTS, :) ! inflow discharge in [m3 s-1]
480 !
481 else if ((processmatrix(8, 1) .eq. 2) .or. &
482 (processmatrix(8, 1) .eq. 3)) then
483 ! >>>
484 ! >>> adaptive timestep
485 ! >>>
486 run_cfg%doRoute = .false.
487 ! calculate factor
488 run_cfg%tsRoutFactor = l11_tsrout(idomain) / (timestep * hoursecs)
489 ! print *, 'routing factor: ', tsRoutFactor
490 ! prepare routing call
491 if (run_cfg%tsRoutFactor .lt. 1._dp) then
492 ! ----------------------------------------------------------------
493 ! routing timesteps are shorter than hydrologic time steps
494 ! ----------------------------------------------------------------
495 ! set all input variables
496 run_cfg%tsRoutFactorIn = run_cfg%tsRoutFactor
497 run_cfg%RunToRout = l1_total_runoff(s1 : e1) ! runoff [mm TS-1] mm per timestep
498 run_cfg%InflowDischarge = inflowgauge%Q(run_cfg%iDischargeTS, :) ! inflow discharge in [m3 s-1]
499 run_cfg%timestep_rout = timestep
500 run_cfg%doRoute = .true.
501 else
502 ! ----------------------------------------------------------------
503 ! routing timesteps are longer than hydrologic time steps
504 ! ----------------------------------------------------------------
505 ! set all input variables
506 run_cfg%tsRoutFactorIn = run_cfg%tsRoutFactor
507 ! Runoff is accumulated in [mm]
508 run_cfg%RunToRout = run_cfg%RunToRout + l1_total_runoff(s1 : e1)
509 run_cfg%InflowDischarge = run_cfg%InflowDischarge + inflowgauge%Q(run_cfg%iDischargeTS, :)
510 ! reset tsRoutFactorIn if last period did not cover full period
511 if ((tt == run_cfg%domainDateTime%nTimeSteps) .and. (mod(tt, nint(run_cfg%tsRoutFactorIn)) /= 0_i4)) &
512 run_cfg%tsRoutFactorIn = mod(tt, nint(run_cfg%tsRoutFactorIn))
513 if ((mod(tt, nint(run_cfg%tsRoutFactorIn)) .eq. 0_i4) .or. (tt .eq. run_cfg%domainDateTime%nTimeSteps)) then
514 ! Inflow discharge is given as flow-rate and has to be converted to [m3]
515 run_cfg%InflowDischarge = run_cfg%InflowDischarge / run_cfg%tsRoutFactorIn
516 run_cfg%timestep_rout = timestep * nint(run_cfg%tsRoutFactorIn, i4)
517 run_cfg%doRoute = .true.
518 end if
519 end if
520 end if
521 ! prepare temperature routing
522 if ( riv_temp_pcs%active ) then
523 ! init riv-temp from current air temp
524 if ( tt .eq. 1_i4 ) call riv_temp_pcs%init_riv_temp( &
525 temp_air = l1_temp_calc(s1 : e1), &
526 efecarea = level1(idomain)%CellArea * 1.e-6_dp, &
527 l1_l11_id = l1_l11_id(s1 : e1), &
528 l11_areacell = level11(idomain)%CellArea * 1.e-6_dp, &
529 l11_l1_id = l11_l1_id(run_cfg%s11 : run_cfg%e11), &
530 map_flag = ge(resolutionrouting(idomain), resolutionhydrology(idomain)) &
531 )
532 ! get riv-temp specific meteo arrays
533 call meteo_handler%get_ssrd(riv_temp_pcs%L1_ssrd_calc)
534 call meteo_handler%get_strd(riv_temp_pcs%L1_strd_calc)
535 call meteo_handler%get_tann(riv_temp_pcs%L1_tann_calc)
536 ! accumulate source Energy at L1 level
537 call riv_temp_pcs%acc_source_E( &
538 fsealed_area_fraction = l1_fsealed(s1 : e1, 1, run_cfg%domainDateTime%yId), &
539 fast_interflow = l1_fastrunoff(s1 : e1), &
540 slow_interflow = l1_slowrunoff(s1 : e1), &
541 baseflow = l1_baseflow(s1 : e1), &
542 direct_runoff = l1_runoffseal(s1 : e1), &
543 temp_air = l1_temp_calc(s1 : e1) &
544 )
545 ! if routing should be performed, scale source energy to L11 level
546 if ( run_cfg%doRoute ) call riv_temp_pcs%finalize_source_E( &
547 efecarea = level1(idomain)%CellArea * 1.e-6_dp, &
548 l1_l11_id = l1_l11_id(s1 : e1), &
549 l11_areacell = level11(idomain)%CellArea * 1.e-6_dp, &
550 l11_l1_id = l11_l1_id(run_cfg%s11 : run_cfg%e11), &
551 timestep = run_cfg%timestep_rout, &
552 map_flag = ge(resolutionrouting(idomain), resolutionhydrology(idomain)) &
553 )
554 end if
555 ! -------------------------------------------------------------------
556 ! execute routing
557 ! -------------------------------------------------------------------
558 if (run_cfg%doRoute) call mrm_routing(&
559 ! general INPUT variables
560 read_restart, &
561 processmatrix(8, 1), & ! parse process Case to be used
562 run_cfg%parameterset(processmatrix(8, 3) - processmatrix(8, 2) + 1 : processmatrix(8, 3)), & ! routing par.
563 run_cfg%RunToRout, & ! runoff [mm TS-1] mm per timestep old: L1_total_runoff_in(run_cfg%s1:run_cfg%e1, tt), &
564 level1(idomain)%CellArea * 1.e-6_dp, &
565 l1_l11_id(s1 : e1), &
566 level11(idomain)%CellArea * 1.e-6_dp, &
567 l11_l1_id(run_cfg%s11 : run_cfg%e11), &
568 l11_netperm(run_cfg%s11 : run_cfg%e11), & ! routing order at L11
569 l11_fromn(run_cfg%s11 : run_cfg%e11), & ! link source at L11
570 l11_ton(run_cfg%s11 : run_cfg%e11), & ! link target at L11
571 l11_noutlets(idomain), & ! number of outlets
572 run_cfg%timestep_rout, & ! timestep of runoff to rout [h]
573 run_cfg%tsRoutFactorIn, & ! simulate timestep in [h]
574 level11(idomain)%nCells, & ! number of Nodes
575 domain_mrm(idomain)%nInflowGauges, &
576 domain_mrm(idomain)%InflowGaugeIndexList(:), &
577 domain_mrm(idomain)%InflowGaugeHeadwater(:), &
578 domain_mrm(idomain)%InflowGaugeNodeList(:), &
579 run_cfg%InflowDischarge, &
580 domain_mrm(idomain)%nGauges, &
581 domain_mrm(idomain)%gaugeIndexList(:), &
582 domain_mrm(idomain)%gaugeNodeList(:), &
583 ge(resolutionrouting(idomain), resolutionhydrology(idomain)), &
584 ! original routing specific input variables
585 l11_length(run_cfg%s11 : run_cfg%e11 - 1), & ! link length
586 l11_slope(run_cfg%s11 : run_cfg%e11 - 1), &
587 l11_nlinkfracfpimp(run_cfg%s11 : run_cfg%e11, run_cfg%domainDateTime%yId), & ! fraction of impervious layer at L11 scale
588 sink_cells(idomain)%ids, &
589 ! general INPUT/OUTPUT variables
590 l11_c1(run_cfg%s11 : run_cfg%e11), & ! first muskingum parameter
591 l11_c2(run_cfg%s11 : run_cfg%e11), & ! second muskigum parameter
592 l11_qout(run_cfg%s11 : run_cfg%e11), & ! routed runoff flowing out of L11 cell
593 l11_qtin(run_cfg%s11 : run_cfg%e11, :), & ! inflow water into the reach at L11
594 l11_qtr(run_cfg%s11 : run_cfg%e11, :), & !
595 l11_qmod(run_cfg%s11 : run_cfg%e11), &
596 mrm_runoff(tt, :) &
597 )
598 ! -------------------------------------------------------------------
599 ! groundwater coupling
600 ! -------------------------------------------------------------------
601 if (gw_coupling) then
603 end if
604 ! -------------------------------------------------------------------
605 ! reset variables
606 ! -------------------------------------------------------------------
607 if (processmatrix(8, 1) .eq. 1) then
608 ! reset Input variables
609 run_cfg%InflowDischarge = 0._dp
610 run_cfg%RunToRout = 0._dp
611 else if ((processmatrix(8, 1) .eq. 2) .or. (processmatrix(8, 1) .eq. 3)) then
612 if ((.not. (run_cfg%tsRoutFactorIn .lt. 1._dp)) .and. run_cfg%doRoute) then
613 do jj = 1, nint(run_cfg%tsRoutFactorIn) ! BUG: this should start at 2
614 mrm_runoff(tt - jj + 1, :) = mrm_runoff(tt, :)
615 end do
616 ! reset Input variables
617 run_cfg%InflowDischarge = 0._dp
618 run_cfg%RunToRout = 0._dp
619 ! reset lateral fluxes and time-step counter if routing was done
620 if ( riv_temp_pcs%active ) call riv_temp_pcs%reset_timestep()
621 end if
622 ! if routing is done every time-step, reset river-temp time step
623 if (run_cfg%tsRoutFactor .lt. 1._dp .and. riv_temp_pcs%active ) call riv_temp_pcs%reset_timestep()
624 end if
625 end if
626
627 ! output only for evaluation period
628 run_cfg%domainDateTime%tIndex_out = (tt - warmingdays(idomain) * ntstepday) ! tt if write out of warming period
629
630 call run_cfg%domainDateTime%increment()
631
632 ! update the year-dependent domainDateTime%yId (land cover id)
633 if (run_cfg%domainDateTime%is_new_year .and. tt < run_cfg%domainDateTime%nTimeSteps) then
634 run_cfg%domainDateTime%yId = lcyearid(run_cfg%domainDateTime%year, idomain)
635 end if
636
637 ! calculate BFI releated after warming days if wanted
638 if ( run_cfg%output_BFI .and. (run_cfg%domainDateTime%tIndex_out > 0_i4) ) then
639 bfi_qbf_sum(idomain) = bfi_qbf_sum(idomain) &
640 + sum(l1_baseflow(s1 : e1) * level1(idomain)%CellArea) / level1(idomain)%nCells
641 bfi_qt_sum(idomain) = bfi_qt_sum(idomain) &
642 + sum(l1_total_runoff(s1 : e1) * level1(idomain)%CellArea) / level1(idomain)%nCells
643 end if
644
645 end subroutine mhm_interface_run_do_time_step
646
647 !> \brief write output after current time-step
649 implicit none
650 integer(i4) :: iDomain, tt, s0, e0
651
652 ! get time step
653 tt = run_cfg%time_step
654
655 ! get domain index
656 idomain = run_cfg%get_domain_index(run_cfg%selected_domain)
657
658 if ( (.not. optimize) .and. (run_cfg%domainDateTime%tIndex_out > 0_i4)) then
659 if (any(outputflxstate_mrm) .AND. (domainmeta%doRouting(idomain))) then
660
661 if (run_cfg%domainDateTime%tIndex_out == 1) then
662 run_cfg%nc_mrm = mrm_outputdataset(idomain, run_cfg%mask11)
663 end if
664
665 ! update Dataset (riv-temp as optional input)
666 if ( riv_temp_pcs%active ) then
667 call mrm_updatedataset(run_cfg%nc_mrm, &
668 l11_qmod(run_cfg%s11 : run_cfg%e11), riv_temp_pcs%river_temp(riv_temp_pcs%s11 : riv_temp_pcs%e11))
669 else
670 call mrm_updatedataset(run_cfg%nc_mrm, l11_qmod(run_cfg%s11 : run_cfg%e11))
671 end if
672
673 ! write data
674 if (run_cfg%domainDateTime%writeout(timestep_model_outputs_mrm, tt)) then
675 call run_cfg%nc_mrm%writeTimestep(run_cfg%domainDateTime%tIndex_out * timestep)
676 end if
677
678 if(tt == run_cfg%domainDateTime%nTimeSteps) then
679 call run_cfg%nc_mrm%close()
680 end if
681
682 if ( gw_coupling ) then
683 ! create
684 if (run_cfg%domainDateTime%tIndex_out == 1) then
685 run_cfg%nc_gw = gw_outputdataset(idomain, level0(idomain)%mask)
686 end if
687 ! add data
688 s0 = level0(idomain)%iStart
689 e0 = level0(idomain)%iEnd
691 ! write
692 if (run_cfg%domainDateTime%writeout(-2, tt)) then ! -2 for monthly
693 call run_cfg%nc_gw%writeTimestep(run_cfg%domainDateTime%tIndex_out * timestep)
694 end if
695 ! close
696 if(tt == run_cfg%domainDateTime%nTimeSteps) then
697 call run_cfg%nc_gw%close()
698 end if
699 end if
700
701 end if
702
703 if (any(outputflxstate)) then
704
705 if (run_cfg%domainDateTime%tIndex_out == 1) then
706 run_cfg%nc_mhm = mhm_outputdataset(idomain, run_cfg%mask1)
707 end if
708
709 call mhm_updatedataset(&
710 run_cfg%nc_mhm, &
711 run_cfg%s1, run_cfg%e1, &
712 l1_fsealed(:, 1, run_cfg%domainDateTime%yId), &
713 run_cfg%L1_fNotSealed(:, 1, run_cfg%domainDateTime%yId), &
714 l1_inter, &
715 l1_snowpack, &
716 l1_soilmoist, &
717 l1_soilmoistsat(:, :, run_cfg%domainDateTime%yId), &
718 l1_sealstw, &
719 l1_unsatstw, &
720 l1_satstw, &
721 l1_neutrons, &
722 l1_pet_calc, &
723 l1_aetsoil, &
724 l1_aetcanopy, &
725 l1_aetsealed, &
730 l1_baseflow, &
731 l1_percol, &
732 l1_infilsoil, &
733 l1_preeffect, &
734 l1_melt &
735 )
736
737 ! write data
738 if (run_cfg%domainDateTime%writeout(timestep_model_outputs, tt)) then
739 call run_cfg%nc_mhm%writeTimestep(run_cfg%domainDateTime%tIndex_out * timestep)
740 end if
741
742 if(tt == run_cfg%domainDateTime%nTimeSteps) then
743 call run_cfg%nc_mhm%close()
744 end if
745
746 end if
747 end if ! <-- if (.not. optimize)
748
749 end subroutine mhm_interface_run_write_output
750
751 !> \brief add simulation data to optimization data types
752 subroutine mhm_interface_run_update_optisim(etOptiSim, twsOptiSim, neutronsOptiSim, smOptiSim, sweOptiSim)
753 implicit none
754 !> returns soil moisture time series for all grid cells (of multiple Domains concatenated),DIMENSION [nCells, nTimeSteps]
755 type(optidata_sim), dimension(:), optional, intent(inout) :: smOptiSim
756 !> dim1=ncells, dim2=time
757 type(optidata_sim), dimension(:), optional, intent(inout) :: neutronsOptiSim
758 !> returns evapotranspiration time series for all grid cells (of multiple Domains concatenated),DIMENSION [nCells, nTimeSteps]
759 type(optidata_sim), dimension(:), optional, intent(inout) :: etOptiSim
760 !> returns tws time series for all grid cells (of multiple Domains concatenated),DIMENSION [nCells, nTimeSteps]
761 type(optidata_sim), dimension(:), optional, intent(inout) :: twsOptiSim
762 !> returns swe time series for all grid cells (of multiple Domains concatenated),DIMENSION [nCells, nTimeSteps]
763 type(optidata_sim), dimension(:), optional, intent(inout) :: sweOptiSim
764
765 integer(i4) :: gg, s1, e1, lcId
766
767 integer(i4) :: iDomain, tt
768
769 ! get time step
770 tt = run_cfg%time_step
771
772 ! get domain index
773 idomain = run_cfg%get_domain_index(run_cfg%selected_domain)
774
775 ! slice settings
776 s1 = run_cfg%s1
777 e1 = run_cfg%e1
778 lcid = run_cfg%domainDateTime%yId
779
780 !----------------------------------------------------------------------
781 ! FOR SOIL MOISTURE
782 ! NOTE:: modeled soil moisture is averaged according to input time step
783 ! soil moisture (timeStep_sm_input)
784 !----------------------------------------------------------------------
785 if (present(smoptisim)) then
786 ! only for evaluation period - ignore warming days
787 if ((tt - warmingdays(idomain) * ntstepday) .GT. 0) then
788 ! decide for daily, monthly or yearly aggregation
789 call smoptisim(idomain)%average_per_timestep(l1_smobs(idomain)%timeStepInput, &
790 run_cfg%domainDateTime%is_new_day, run_cfg%domainDateTime%is_new_month, run_cfg%domainDateTime%is_new_year)
791 ! last timestep is already done - write_counter exceeds size(smOptiSim(iDomain)%dataSim, dim=2)
792 if (tt /= run_cfg%domainDateTime%nTimeSteps) then
793 ! aggregate soil moisture to needed time step for optimization
794 call smoptisim(idomain)%average_add(sum(l1_soilmoist(:, 1 : nsoilhorizons_sm_input), dim = 2) / &
795 sum(l1_soilmoistsat(:, 1 : nsoilhorizons_sm_input, lcid), dim = 2))
796 end if
797 end if
798 end if
799
800 !----------------------------------------------------------------------
801 ! FOR NEUTRONS
802 ! NOTE:: modeled neutrons are averaged daily
803 !----------------------------------------------------------------------
804 if (present(neutronsoptisim)) then
805 ! only for evaluation period - ignore warming days
806 if ((tt - warmingdays(idomain) * ntstepday) .GT. 0) then
807 ! decide for daily, monthly or yearly aggregation
808 ! daily
809 if (run_cfg%domainDateTime%is_new_day) then
810 call neutronsoptisim(idomain)%average()
811 end if
812
813 ! last timestep is already done - write_counter exceeds size(sm_opti, dim=2)
814 if (tt /= run_cfg%domainDateTime%nTimeSteps) then
815 ! aggregate neutrons to needed time step for optimization
816 call neutronsoptisim(idomain)%average_add(l1_neutrons(s1 : e1))
817 end if
818 end if
819 end if
820
821 !----------------------------------------------------------------------
822 ! FOR EVAPOTRANSPIRATION
823 ! NOTE:: modeled evapotranspiration is averaged according to input time step
824 ! evapotranspiration (timeStep_et_input)
825 !----------------------------------------------------------------------
826 if (present(etoptisim)) then
827 ! only for evaluation period - ignore warming days
828 if ((tt - warmingdays(idomain) * ntstepday) .GT. 0) then
829 ! decide for daily, monthly or yearly aggregation
830 call etoptisim(idomain)%increment_counter(l1_etobs(idomain)%timeStepInput, &
831 run_cfg%domainDateTime%is_new_day, run_cfg%domainDateTime%is_new_month, run_cfg%domainDateTime%is_new_year)
832
833 ! last timestep is already done - write_counter exceeds size(etOptiSim(iDomain)%dataSim, dim=2)
834 if (tt /= run_cfg%domainDateTime%nTimeSteps) then
835 ! aggregate evapotranspiration to needed time step for optimization
836 call etoptisim(idomain)%add(sum(l1_aetsoil(s1 : e1, :), dim = 2) * &
837 run_cfg%L1_fNotSealed(s1 : e1, 1, lcid) + &
838 l1_aetcanopy(s1 : e1) + &
839 l1_aetsealed(s1 : e1) * l1_fsealed(s1 : e1, 1, lcid))
840 end if
841 end if
842 end if
843
844 !----------------------------------------------------------------------
845 ! FOR TWS
846 ! NOTE:: modeled tws is averaged according to input time step
847 ! (timeStepInput)
848 !----------------------------------------------------------------------
849 if (present(twsoptisim)) then
850 ! only for evaluation period - ignore warming days
851 if ((tt - warmingdays(idomain) * ntstepday) > 0) then
852 ! decide for daily, monthly or yearly aggregation
853 call twsoptisim(idomain)%average_per_timestep(l1_twsaobs(idomain)%timeStepInput, &
854 run_cfg%domainDateTime%is_new_day, run_cfg%domainDateTime%is_new_month, run_cfg%domainDateTime%is_new_year)
855
856 ! last timestep is already done - write_counter exceeds size(twsOptiSim(iDomain)%dataSim, dim=2)
857 if (tt /= run_cfg%domainDateTime%nTimeSteps) then
858 ! aggregate evapotranspiration to needed time step for optimization
859 call twsoptisim(idomain)%average_add(l1_inter(s1 : e1) + l1_snowpack(s1 : e1) + l1_sealstw(s1 : e1) + &
860 l1_unsatstw(s1 : e1) + l1_satstw(s1 : e1))
861 do gg = 1, nsoilhorizons_mhm
862 call twsoptisim(idomain)%add(l1_soilmoist(s1 : e1, gg))
863 end do
864 end if
865 end if
866 end if
867
868 !----------------------------------------------------------------------
869 ! FOR SWE
870 ! NOTE:: modeled snow water equivalent is averaged according to input time step
871 ! snow presence flag (timeStep_spf_input).
872 ! The modelled snow water equivalent is converted into snow presence flag
873 ! by convert_swe_to_spf in mo_objective_function.
874 !----------------------------------------------------------------------
875 if (present(sweoptisim)) then
876 ! only for evaluation period - ignore warming days
877 if ((tt - warmingdays(idomain) * ntstepday) .GT. 0) then
878 ! decide for daily, monthly or yearly aggregation
879 call sweoptisim(idomain)%average_per_timestep(l1_spfobs(idomain)%timeStepInput, &
880 run_cfg%domainDateTime%is_new_day, run_cfg%domainDateTime%is_new_month, run_cfg%domainDateTime%is_new_year)
881 ! last timestep is already done - write_counter exceeds size(sweOptiSim(iDomain)%dataSim, dim=2)
882 if (tt /= run_cfg%domainDateTime%nTimeSteps) then
883 ! aggregate snow water equivalent to needed time step for optimization
884 call sweoptisim(idomain)%add(l1_snowpack(s1 : e1))
885 end if
886 end if
887 end if
888
889 ! TODO-RIV-TEMP: add OptiSim for river temperature
890
892
893 !> \brief finalize current domain after running
895 implicit none
896
897 integer(i4) :: iDomain
898
899 ! get domain index
900 idomain = run_cfg%get_domain_index(run_cfg%selected_domain)
901
902 if (allocated(run_cfg%InflowDischarge)) deallocate(run_cfg%InflowDischarge)
903 if (domainmeta%doRouting(idomain)) then
904 ! clean runoff variable
905 deallocate(run_cfg%RunToRout)
906 if ( riv_temp_pcs%active ) call riv_temp_pcs%dealloc_lateral()
907 end if
908
910
911 !> \brief finalize run
912 subroutine mhm_interface_run_finalize(runoff, BFI)
913 implicit none
914 !> returns runoff time series, DIMENSION [nTimeSteps, nGaugesTotal]
915 real(dp), dimension(:, :), allocatable, optional, intent(out) :: runoff
916 !> baseflow index, dim1=domainID
917 real(dp), dimension(:), allocatable, optional, intent(out) :: BFI
918
919 if (present(runoff) .and. (processmatrix(8, 1) > 0)) runoff = mrm_runoff
920 if (present(bfi)) then
921 bfi = bfi_qbf_sum / bfi_qt_sum
922 deallocate(bfi_qbf_sum)
923 deallocate(bfi_qt_sum)
924 end if
925
926 if (allocated(run_cfg%parameterset)) deallocate(run_cfg%parameterset)
927 if (allocated(run_cfg%L1_fNotSealed)) deallocate(run_cfg%L1_fNotSealed)
928 if (allocated(run_cfg%domain_indices)) deallocate(run_cfg%domain_indices)
929
930 end subroutine mhm_interface_run_finalize
931
932end 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
type(optidata), dimension(:), allocatable, public l1_spfobs
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, sweoptisim)
prepare single domain to run mHM on
subroutine mhm_interface_run_update_optisim(etoptisim, twsoptisim, neutronsoptisim, smoptisim, sweoptisim)
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)
type(sink_cells_t), dimension(:), allocatable sink_cells
sink cell ids for each domain
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, sink_cells, 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.
Type definitions for optimization routines.
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.
type for simulated optional data