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