63 use mo_kind,
only : dp, i4
64 use mo_message,
only : message
67 use mo_netcdf,
only : ncdataset, ncdimension, ncvariable
68 use mo_string_utils,
only : num2str
72 character(256) :: fname
75 character(256),
dimension(:),
intent(in) :: outfile
77 integer(i4) :: idomain, domainid
88 logical,
dimension(:, :),
allocatable :: mask1
91 real(dp),
dimension(:, :, :),
allocatable :: dummy_3d
92 real(dp),
dimension(:),
allocatable :: dummy_1d
94 integer(i4) :: max_extent
98 type(ncdimension) :: rows1, cols1, soil1, lcscenes, lais
100 type(ncvariable) :: var
106 domain_loop :
do idomain = 1,
domainmeta%nDomains
110 fname = trim(outfile(idomain))
112 call message(
" Writing Restart-file: ", trim(adjustl(fname)),
" ...")
114 nc = ncdataset(fname,
"w")
119 rows1 = nc%getDimension(
"nrows1")
120 cols1 = nc%getDimension(
"ncols1")
140 allocate(dummy_3d(rows1%getLength(), cols1%getLength(), max_extent))
141 allocate(mask1(rows1%getLength(), cols1%getLength()))
142 s1 =
level1(idomain)%iStart
144 mask1 =
level1(idomain)%mask
146 var = nc%setVariable(
"L1_Inter",
"f64", (/rows1, cols1/))
149 call var%setAttribute(
"long_name",
"Interception storage at level 1")
151 var = nc%setVariable(
"L1_snowPack",
"f64", (/rows1, cols1/))
154 call var%setAttribute(
"long_name",
"Snowpack at level 1")
156 var = nc%setVariable(
"L1_sealSTW",
"f64", (/rows1, cols1/))
159 call var%setAttribute(
"long_name",
"Retention storage of impervious areas at level 1")
165 var = nc%setVariable(
"L1_soilMoist",
"f64", (/rows1, cols1, soil1/))
168 call var%setAttribute(
"long_name",
"soil moisture at level 1")
170 var = nc%setVariable(
"L1_unsatSTW",
"f64", (/rows1, cols1/))
173 call var%setAttribute(
"long_name",
"upper soil storage at level 1")
175 var = nc%setVariable(
"L1_satSTW",
"f64", (/rows1, cols1/))
178 call var%setAttribute(
"long_name",
"groundwater storage at level 1")
184 var = nc%setVariable(
"L1_aETSoil",
"f64", (/rows1, cols1, soil1/))
187 call var%setAttribute(
"long_name",
"soil actual ET at level 1")
189 var = nc%setVariable(
"L1_aETCanopy",
"f64", (/rows1, cols1/))
192 call var%setAttribute(
"long_name",
"canopy actual ET at level 1")
194 var = nc%setVariable(
"L1_aETSealed",
"f64", (/rows1, cols1/))
197 call var%setAttribute(
"long_name",
"sealed actual ET at level 1")
199 var = nc%setVariable(
"L1_baseflow",
"f64", (/rows1, cols1/))
202 call var%setAttribute(
"long_name",
"baseflow at level 1")
208 var = nc%setVariable(
"L1_infilSoil",
"f64", (/rows1, cols1, soil1/))
211 call var%setAttribute(
"long_name",
"soil in-exfiltration at level 1")
213 var = nc%setVariable(
"L1_fastRunoff",
"f64", (/rows1, cols1/))
216 call var%setAttribute(
"long_name",
"fast runoff")
218 var = nc%setVariable(
"L1_percol",
"f64", (/rows1, cols1/))
221 call var%setAttribute(
"long_name",
"percolation at level 1")
223 var = nc%setVariable(
"L1_melt",
"f64", (/rows1, cols1/))
226 call var%setAttribute(
"long_name",
"snow melt at level 1")
228 var = nc%setVariable(
"L1_preEffect",
"f64", (/rows1, cols1/))
231 call var%setAttribute(
"long_name",
"effective precip. depth (snow melt + rain) at level 1")
233 var = nc%setVariable(
"L1_rain",
"f64", (/rows1, cols1/))
236 call var%setAttribute(
"long_name",
"rain (liquid water) at level 1")
238 var = nc%setVariable(
"L1_runoffSeal",
"f64", (/rows1, cols1/))
241 call var%setAttribute(
"long_name",
"runoff from impervious area at level 1")
243 var = nc%setVariable(
"L1_slowRunoff",
"f64", (/rows1, cols1/))
246 call var%setAttribute(
"long_name",
"slow runoff at level 1")
248 var = nc%setVariable(
"L1_snow",
"f64", (/rows1, cols1/))
251 call var%setAttribute(
"long_name",
"snow (solid water) at level 1")
253 var = nc%setVariable(
"L1_Throughfall",
"f64", (/rows1, cols1/))
256 call var%setAttribute(
"long_name",
"throughfall at level 1")
258 var = nc%setVariable(
"L1_total_runoff",
"f64", (/rows1, cols1/))
261 call var%setAttribute(
"long_name",
"total runoff at level 1")
263 call write_eff_params(mask1, s1, e1, rows1, cols1, soil1, lcscenes, lais, nc)
267 deallocate(dummy_3d, mask1)
299 use mo_kind,
only : dp, i4
310 use mo_netcdf,
only : ncdataset, ncdimension, ncvariable
311 use mo_string_utils,
only : num2str
312 use mo_message,
only: message, error_message
317 integer(i4),
intent(in) :: idomain
319 integer(i4),
intent(in) :: domainid
321 character(256),
intent(in) :: infile
323 character(256) :: fname
325 integer(i4) :: var_rank
327 integer(i4) :: ii, jj
333 logical,
dimension(:, :),
allocatable :: mask1
335 real(dp),
dimension(:, :),
allocatable :: dummyd2
337 real(dp),
dimension(:, :, :),
allocatable :: dummyd3
339 real(dp),
dimension(:, :, :, :),
allocatable :: dummyd4
341 type(ncdataset) :: nc
342 type(ncvariable) :: var
346 call message(
' Reading states from ', trim(adjustl(fname)),
' ...')
349 allocate(mask1(
level1(idomain)%nrows,
level1(idomain)%ncols))
350 mask1 =
level1(idomain)%mask
351 s1 =
level1(idomain)%iStart
354 nc = ncdataset(fname,
"r")
356 if (nc%hasVariable(
'L1_Inter'))
then
362 var = nc%getVariable(
"L1_Inter")
363 call var%getData(dummyd2)
364 l1_inter(s1 : e1) = pack(dummyd2, mask1)
367 var = nc%getVariable(
"L1_snowPack")
368 call var%getData(dummyd2)
372 var = nc%getVariable(
"L1_sealSTW")
373 call var%getData(dummyd2)
377 var = nc%getVariable(
"L1_unsatSTW")
378 call var%getData(dummyd2)
382 var = nc%getVariable(
"L1_satSTW")
383 call var%getData(dummyd2)
384 l1_satstw(s1 : e1) = pack(dummyd2, mask1)
387 var = nc%getVariable(
"L1_soilMoist")
388 call var%getData(dummyd3)
390 l1_soilmoist(s1 : e1, ii) = pack(dummyd3(:, :, ii), mask1)
398 var = nc%getVariable(
"L1_aETSoil")
399 call var%getData(dummyd3)
401 l1_aetsoil(s1 : e1, ii) = pack(dummyd3(:, :, ii), mask1)
405 var = nc%getVariable(
"L1_aETCanopy")
406 call var%getData(dummyd2)
410 var = nc%getVariable(
"L1_aETSealed")
411 call var%getData(dummyd2)
415 var = nc%getVariable(
"L1_baseflow")
416 call var%getData(dummyd2)
420 var = nc%getVariable(
"L1_infilSoil")
421 call var%getData(dummyd3)
423 l1_infilsoil(s1 : e1, ii) = pack(dummyd3(:, :, ii), mask1)
427 var = nc%getVariable(
"L1_fastRunoff")
428 call var%getData(dummyd2)
432 var = nc%getVariable(
"L1_melt")
433 call var%getData(dummyd2)
434 l1_melt(s1 : e1) = pack(dummyd2, mask1)
437 var = nc%getVariable(
"L1_percol")
438 call var%getData(dummyd2)
439 l1_percol(s1 : e1) = pack(dummyd2, mask1)
442 var = nc%getVariable(
"L1_preEffect")
443 call var%getData(dummyd2)
447 var = nc%getVariable(
"L1_rain")
448 call var%getData(dummyd2)
449 l1_rain(s1 : e1) = pack(dummyd2, mask1)
452 var = nc%getVariable(
"L1_runoffSeal")
453 call var%getData(dummyd2)
457 var = nc%getVariable(
"L1_slowRunoff")
458 call var%getData(dummyd2)
462 var = nc%getVariable(
"L1_snow")
463 call var%getData(dummyd2)
464 l1_snow(s1 : e1) = pack(dummyd2, mask1)
467 var = nc%getVariable(
"L1_Throughfall")
468 call var%getData(dummyd2)
472 var = nc%getVariable(
"L1_total_runoff")
473 call var%getData(dummyd2)
480 var = nc%getVariable(
"L1_fSealed")
481 call var%getData(dummyd3)
483 l1_fsealed(s1 : e1, 1, ii) = pack(dummyd3(:, :, ii), mask1)
487 var = nc%getVariable(
"L1_alpha")
488 var_rank = var%getrank()
489 select case(var_rank)
492 call var%getData(dummyd2)
494 l1_alpha(s1 : e1, 1, ii) = pack(dummyd2, mask1)
497 call var%getData(dummyd3)
499 l1_alpha(s1 : e1, 1, ii) = pack(dummyd3(:, :, ii), mask1)
502 call error_message(
"Restart: L1_alpha rank needs to be 2 or 3")
506 var = nc%getVariable(
"L1_degDayInc")
507 call var%getData(dummyd3)
509 l1_degdayinc(s1 : e1, 1, ii) = pack(dummyd3(:, :, ii), mask1)
513 var = nc%getVariable(
"L1_degDayMax")
514 call var%getData(dummyd3)
516 l1_degdaymax(s1 : e1, 1, ii) = pack(dummyd3(:, :, ii), mask1)
520 var = nc%getVariable(
"L1_degDayNoPre")
521 call var%getData(dummyd3)
527 var = nc%getVariable(
"L1_degDay")
528 var_rank = var%getrank()
529 select case(var_rank)
532 call var%getData(dummyd2)
534 l1_degday(s1 : e1, 1, ii) = pack(dummyd2, mask1)
537 call var%getData(dummyd3)
539 l1_degday(s1 : e1, 1, ii) = pack(dummyd3(:, :, ii), mask1)
542 call error_message(
"Restart: L1_degDay rank needs to be 2 or 3")
546 var = nc%getVariable(
"L1_karstLoss")
547 call var%getData(dummyd2)
551 var = nc%getVariable(
"L1_fRoots")
552 call var%getData(dummyd4)
555 l1_froots(s1 : e1, ii, jj) = pack(dummyd4(:, :, ii, jj), mask1)
560 var = nc%getVariable(
"L1_maxInter")
561 call var%getData(dummyd3)
563 l1_maxinter(s1 : e1, ii, 1) = pack(dummyd3(:, :, ii), mask1)
567 if (nc%hasvariable(
"L1_kFastFlow"))
then
568 var = nc%getVariable(
"L1_kFastFlow")
570 var = nc%getVariable(
"L1_kfastFlow")
572 call var%getData(dummyd3)
574 l1_kfastflow(s1 : e1, 1, ii) = pack(dummyd3(:, :, ii), mask1)
578 var = nc%getVariable(
"L1_kSlowFlow")
579 var_rank = var%getrank()
580 select case(var_rank)
583 call var%getData(dummyd2)
588 call var%getData(dummyd3)
590 l1_kslowflow(s1 : e1, 1, ii) = pack(dummyd3(:, :, ii), mask1)
593 call error_message(
"Restart: L1_kSlowFlow rank needs to be 2 or 3")
597 var = nc%getVariable(
"L1_kBaseFlow")
598 var_rank = var%getrank()
599 select case(var_rank)
602 call var%getData(dummyd2)
607 call var%getData(dummyd3)
609 l1_kbaseflow(s1 : e1, 1, ii) = pack(dummyd3(:, :, ii), mask1)
612 call error_message(
"Restart: L1_kBaseFlow rank needs to be 2 or 3")
616 var = nc%getVariable(
"L1_kPerco")
617 var_rank = var%getrank()
618 select case(var_rank)
621 call var%getData(dummyd2)
623 l1_kperco(s1 : e1, 1, ii) = pack(dummyd2, mask1)
626 call var%getData(dummyd3)
628 l1_kperco(s1 : e1, 1, ii) = pack(dummyd3(:, :, ii), mask1)
631 call error_message(
"Restart: L1_kPerco rank needs to be 2 or 3")
636 var = nc%getVariable(
"L1_soilMoistFC")
637 call var%getData(dummyd4)
640 l1_soilmoistfc(s1 : e1, ii, jj) = pack(dummyd4(:, :, ii, jj), mask1)
645 var = nc%getVariable(
"L1_soilMoistSat")
646 call var%getData(dummyd4)
654 var = nc%getVariable(
"L1_soilMoistExp")
655 call var%getData(dummyd4)
664 var = nc%getVariable(
"L1_jarvis_thresh_c1")
665 call var%getData(dummyd2)
670 var = nc%getVariable(
"L1_tempThresh")
671 call var%getData(dummyd3)
673 l1_tempthresh(s1 : e1, 1, ii) = pack(dummyd3(:, :, ii), mask1)
677 var = nc%getVariable(
"L1_unsatThresh")
678 call var%getData(dummyd2)
682 var = nc%getVariable(
"L1_sealedThresh")
683 call var%getData(dummyd2)
687 var = nc%getVariable(
"L1_wiltingPoint")
688 call var%getData(dummyd4)
700 var = nc%getVariable(
"L1_petLAIcorFactor")
701 call var%getData(dummyd4)
711 var = nc%getVariable(
"L1_fAsp")
712 call var%getData(dummyd2)
713 l1_fasp(s1 : e1, 1, 1) = pack(dummyd2, mask1)
718 var = nc%getVariable(
"L1_fAsp")
719 call var%getData(dummyd2)
720 l1_fasp(s1 : e1, 1, 1) = pack(dummyd2, mask1)
723 var = nc%getVariable(
"L1_HarSamCoeff")
724 call var%getData(dummyd2)
730 var = nc%getVariable(
"L1_PrieTayAlpha")
731 call var%getData(dummyd3)
739 var = nc%getVariable(
"L1_aeroResist")
740 call var%getData(dummyd4)
743 l1_aeroresist(s1 : e1, ii, jj) = pack(dummyd4(:, :, ii, jj), mask1)
748 var = nc%getVariable(
"L1_surfResist")
749 call var%getData(dummyd3)
751 l1_surfresist(s1 : e1, ii, 1) = pack(dummyd3(:, :, ii), mask1)
761 var = nc%getVariable(
"L1_No_Count")
762 call var%getData(dummyd2)
766 var = nc%getVariable(
"L1_bulkDens")
767 call var%getData(dummyd4)
770 l1_bulkdens(s1:e1, ii, jj) = pack(dummyd4(:, :, ii, jj), mask1)
775 var = nc%getVariable(
"L1_latticeWater")
776 call var%getData(dummyd4)
785 var = nc%getVariable(
"L1_No_Count")
786 call var%getData(dummyd2)
790 var = nc%getVariable(
"L1_bulkDens")
791 call var%getData(dummyd4)
794 l1_bulkdens(s1:e1, ii, jj) = pack(dummyd4(:, :, ii, jj), mask1)
799 var = nc%getVariable(
"L1_latticeWater")
800 call var%getData(dummyd4)
808 var = nc%getVariable(
"L1_COSMICL3")
809 call var%getData(dummyd4)
812 l1_cosmicl3(s1:e1, ii, jj) = pack(dummyd4(:, :, ii, jj), mask1)
Provides constants commonly used by mHM, mRM and MPR.
character(64), parameter, public soilhorizonsvarname
character(64), parameter, public landcoverperiodsvarname
character(64), parameter, public laivarname
real(dp), parameter, public nodata_dp
subroutine, public write_grid_info(grid_in, level_name, nc)
write restart files for each domain
Provides structures needed by mHM, mRM and/or mpr.
type(domain_meta), public domainmeta
integer(i4), public nlcoverscene
integer(i4), dimension(:), allocatable, public lc_year_end
integer(i4), dimension(nprocesses, 3), public processmatrix
type(grid), dimension(:), allocatable, target, public level1
type(grid), dimension(:), allocatable, target, public level0
integer(i4), dimension(:), allocatable, public lc_year_start
Main global variables for mHM.
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
real(dp), dimension(:), allocatable, public l1_aetcanopy
[mm TS-1] Real evaporation intensity from canopy
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.
real(dp), dimension(:), allocatable, public l1_inter
[mm] Interception
real(dp), dimension(:), allocatable, public l1_sealstw
[mm] Retention storage of impervious areas
real(dp), dimension(:), allocatable, public l1_percol
[mm TS-1] Percolation.
real(dp), dimension(:, :), allocatable, public l1_soilmoist
[mm] Soil moisture of each horizon
real(dp), dimension(:), allocatable, public l1_unsatstw
[mm] upper soil storage
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_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_total_runoff
[m3 TS-1] Generated runoff
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 laiboundaries
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
reading and writing states, fluxes and configuration for restart of mHM.
subroutine, public write_eff_params(mask1, s1, e1, rows1, cols1, soil1, lcscenes, lais, nc)
write effective parameter fields to given restart file
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
subroutine, public write_restart_files(outfile)
write restart files for each domain