LCOV - code coverage report
Current view: top level - mHM - mo_mhm.f90 (source / functions) Hit Total Coverage
Test: mHM coverage Lines: 55 59 93.2 %
Date: 2024-02-27 14:40:25 Functions: 1 1 100.0 %

          Line data    Source code
       1             : !> \file mo_mhm.f90
       2             : !> \brief   \copybrief mo_mhm
       3             : !> \details \copydetails mo_mhm
       4             : 
       5             : !> \brief Call all main processes of mHM.
       6             : !> \details This module calls all processes of mHM for a given configuration.
       7             : !!       The configuration of the model is stored in the a process matrix.
       8             : !!       This configuration is specified in the namelist mhm.nml.
       9             : !!
      10             : !!       The processes are executed in ascending order. At the moment only
      11             : !!       process 5 and 8 have options.
      12             : !!
      13             : !!       Currently the following processes are implemented:
      14             : !!
      15             : !!       Process    | Name                      | Flag  | Description
      16             : !!       ---------- | ------------------------- | ----- | ------------------------------------------
      17             : !!       1          | interception              |   1   | Maximum interception
      18             : !!       2          | snow and melting          |   1   | Degree-day
      19             : !!       3          | soil moisture             |   1   | Feddes equation for ET reduction, Brooks-Corey like
      20             : !!       3          | soil moisture             |   2   | Jarvis equation for ET reduction, Brooks-Corey like
      21             : !!       3          | soil moisture             |   3   | Jarvis eq. for ET red. + FC dependency on root frac. coef.
      22             : !!       4          | direct runoff             |   1   | Linear reservoir exceedance
      23             : !!       5          | PET                       |  -1   | PET is input, LAI based correction, dynamic scaling func.
      24             : !!       5          | PET                       |   0   | PET is input, Aspect based correction
      25             : !!       5          | PET                       |   1   | Hargreaves-Samani
      26             : !!       5          | PET                       |   2   | Priestley-Taylor
      27             : !!       5          | PET                       |   3   | Penman-Monteith
      28             : !!       6          | interflow                 |   1   | Nonlinear reservoir with saturation excess
      29             : !!       7          | percolation and base flow |   1   | GW linear reservoir
      30             : !!       8          | routing                   |   0   | no routing
      31             : !!       8          | routing                   |   1   | use mRM i.e. Muskingum
      32             : !!       8          | routing                   |   2   | use mRM i.e. adaptive timestep
      33             : !> \changelog
      34             : !! - Luis Samaniego, Rohini Kumar    Dec 2012
      35             : !!   - modularization
      36             : !! - Luis Samaniego                  Feb 2013
      37             : !!   - call routine
      38             : !! - Rohini Kumar                    Feb 2013
      39             : !!   - MPR call and other pre-requisite variables for this call
      40             : !! - Rohini Kumar                    May 2013
      41             : !!   - Error checks
      42             : !! - Rohini Kumar                    Jun 2013
      43             : !!   - sealed area correction in total runoff
      44             : !!   - initalization of soil moist. at first timestep
      45             : !! - Rohini Kumar                    Aug 2013
      46             : !!   - dynamic LAI option included, and changed within the code made accordingly (e.g., canopy intecpt.)
      47             : !!   - max. canopy interception is estimated outside of MPR call
      48             : !! - Matthias Zink                   Feb 2014
      49             : !!   - added PET calculation: Hargreaves-Samani (Process 5)
      50             : !! - Matthias Zink                   Mar 2014
      51             : !!   - added inflow from upstream areas
      52             : !! - Matthias Zink                   Apr 2014
      53             : !!   - added PET calculation: Priestley-Taylor and Penman-Monteith and its parameterization (Process 5)
      54             : !! - Rohini Kumar                    Apr 2014
      55             : !!   - mHM run with a single L0 grid cell, also in the routing mode
      56             : !! - Stephan Thober                  Jun 2014
      57             : !!   - added flag for switching of MPR
      58             : !! - Matthias Cuntz & Juliane Mai    Nov 2014
      59             : !!   - LAI input from daily, monthly or yearly files
      60             : !! - Matthias Zink                   Dec 2014
      61             : !!   - adopted inflow gauges to ignore headwater cells
      62             : !! - Stephan Thober                  Aug 2015
      63             : !!   - moved routing to mRM
      64             : !! - Rohini Kumar                    Mar 2016
      65             : !!   - changes for handling multiple soil database options
      66             : !! - Rohini Kumar                    Dec 2016
      67             : !!   - changes for reading gridded mean monthly LAI fields
      68             : !! - Stephan Thober                  Jan 2017
      69             : !!   - added prescribed weights for tavg and pet
      70             : !! - Zink M. Demirel C.              Mar 2017
      71             : !!   - added Jarvis soil water stress function at SM process(3)
      72             : !! - M.Cuneyd Demirel & Simon Stisen May 2017
      73             : !!   - added FC dependency on root fraction coef. at SM process(3)
      74             : !! - M.Cuneyd Demirel & Simon Stisen Jun 2017
      75             : !!   - added PET correction based on LAI at PET process(5)
      76             : !! - Robert Schweppe, Stephan Thober Nov 2017
      77             : !!   - moved call to MPR to mhm_eval
      78             : !! - Robert Schweppe                 Jun 2018
      79             : !!   - refactoring and reformatting
      80             : !! - Robert Schweppe                 Nov 2018
      81             : !!   - added c2TSTu for unit conversion (moved here from MPR)
      82             : !! - Rohini Kumar                    Oct 2021
      83             : !!   - Neutron count module to mHM integrate into develop branch (5.11.2)
      84             : !! - Stephan Thober                  Jan 2022
      85             : !!   - added is_hourly_forcing
      86             : !! - Sebastian Mueller               May 2022
      87             : !!   - added temp_calc and prec_calc for coupling to other models
      88             : !> \authors Luis Samaniego
      89             : !> \date Dec 2012
      90             : !> \copyright Copyright 2005-\today, the mHM Developers, Luis Samaniego, Sabine Attinger: All rights reserved.
      91             : !! mHM is released under the LGPLv3+ license \license_note
      92             : !> \ingroup f_mhm
      93             : MODULE mo_mHM
      94             : 
      95             :   use mo_kind, only : i4, dp
      96             :   use mo_message, only : message
      97             :   !$ USE omp_lib
      98             : 
      99             :   IMPLICIT NONE
     100             : 
     101             :   PUBLIC :: mHM      ! initialization sequence
     102             : 
     103             :   PRIVATE
     104             : 
     105             : CONTAINS
     106             :   ! ------------------------------------------------------------------
     107             : 
     108             :   !    NAME
     109             :   !        mHM
     110             : 
     111             :   !    PURPOSE
     112             :   !>       \brief Pure mHM calculations.
     113             : 
     114             :   !>       \details Pure mHM calculations. All variables are allocated and initialized.
     115             :   !>       They will be local variables within this call.
     116             : 
     117             :   !    INTENT(IN)
     118             :   !>       \param[in] "logical :: read_states"                           indicated whether states have been read from
     119             :   !>       file
     120             :   !>       \param[in] "integer(i4) :: tt"                                simulation time step
     121             :   !>       \param[in] "real(dp) :: time"                                 current decimal Julian day
     122             :   !>       \param[in] "integer(i4), dimension(:, :) :: processMatrix"    mHM process configuration matrix
     123             :   !>       \param[in] "real(dp), dimension(:) :: horizon_depth"          Depth of each horizon in mHM
     124             :   !>       \param[in] "integer(i4) :: nCells1"                           number of cells in a given domain at level L1
     125             :   !>       \param[in] "integer(i4) :: nHorizons_mHM"                     Number of Horizons in mHM
     126             :   !>       \param[in] "real(dp) :: ntimesteps_day"                       number of time intervals per day, transformed
     127             :   !>       in dp
     128             :   !>       \param[in] "real(dp), dimension(:) :: neutron_integral_AFast" tabular for neutron flux approximation
     129             :   !>       \param[in] "real(dp), dimension(:) :: latitude"               latitude on level 1
     130             :   !>       \param[in] "real(dp), dimension(:) :: evap_coeff"             Evaporation coefficent for free-water surface
     131             :   !>       of that current month
     132             :   !>       \param[in] "real(dp), dimension(:) :: fday_prec"              [-] day ratio precipitation < 1
     133             :   !>       \param[in] "real(dp), dimension(:) :: fnight_prec"            [-] night ratio precipitation < 1
     134             :   !>       \param[in] "real(dp), dimension(:) :: fday_pet"               [-] day ratio PET  < 1
     135             :   !>       \param[in] "real(dp), dimension(:) :: fnight_pet"             [-] night ratio PET  < 1
     136             :   !>       \param[in] "real(dp), dimension(:) :: fday_temp"              [-] day factor mean temp
     137             :   !>       \param[in] "real(dp), dimension(:) :: fnight_temp"            [-] night factor mean temp
     138             :   !>       \param[in] "real(dp), dimension(:, :, :) :: temp_weights"     multiplicative weights for temperature (deg K)
     139             :   !>       \param[in] "real(dp), dimension(:, :, :) :: pet_weights"      multiplicative weights for potential
     140             :   !>       evapotranspiration
     141             :   !>       \param[in] "real(dp), dimension(:, :, :) :: pre_weights"      multiplicative weights for precipitation
     142             :   !>       \param[in] "logical :: read_meteo_weights"                    flag whether weights for tavg and pet have read
     143             :   !>       and should be used
     144             :   !>       \param[in] "real(dp), dimension(:) :: pet_in"                 [mm d-1] Daily potential evapotranspiration
     145             :   !>       (input)
     146             :   !>       \param[in] "real(dp), dimension(:) :: tmin_in"                [degc]   Daily minimum temperature
     147             :   !>       \param[in] "real(dp), dimension(:) :: tmax_in"                [degc]   Daily maxumum temperature
     148             :   !>       \param[in] "real(dp), dimension(:) :: netrad_in"              [w m2]   Daily average net radiation
     149             :   !>       \param[in] "real(dp), dimension(:) :: absvappres_in"          [Pa]     Daily average absolute vapour pressure
     150             :   !>       \param[in] "real(dp), dimension(:) :: windspeed_in"           [m s-1]  Daily average wind speed
     151             :   !>       \param[in] "real(dp), dimension(:) :: prec_in"                [mm d-1] Daily mean precipitation
     152             :   !>       \param[in] "real(dp), dimension(:) :: temp_in"                [degc]   Daily average temperature
     153             : 
     154             :   !    INTENT(INOUT)
     155             :   !>       \param[inout] "real(dp), dimension(:) :: fSealed1"              fraction of sealed area at scale L1
     156             :   !>       \param[inout] "real(dp), dimension(:) :: interc"                Interception
     157             :   !>       \param[inout] "real(dp), dimension(:) :: snowpack"              Snowpack
     158             :   !>       \param[inout] "real(dp), dimension(:) :: sealedStorage"         Retention storage of impervious areas
     159             :   !>       \param[inout] "real(dp), dimension(:, :) :: soilMoisture"       Soil moisture of each horizon
     160             :   !>       \param[inout] "real(dp), dimension(:) :: unsatStorage"          Upper soil storage
     161             :   !>       \param[inout] "real(dp), dimension(:) :: satStorage"            Groundwater storage
     162             :   !>       \param[inout] "real(dp), dimension(:) :: neutrons"              Ground albedo neutrons
     163             :   !>       \param[inout] "real(dp), dimension(:) :: pet_calc"              [mm TS-1] estimated PET (if PET is input =
     164             :   !>       corrected values (fAsp*PET))
     165             :   !>       \param[inout] "real(dp), dimension(:, :) :: aet_soil"           actual ET
     166             :   !>       \param[inout] "real(dp), dimension(:) :: aet_canopy"            Real evaporation intensity from canopy
     167             :   !>       \param[inout] "real(dp), dimension(:) :: aet_sealed"            Actual ET from free-water surfaces
     168             :   !>       \param[inout] "real(dp), dimension(:) :: baseflow"              Baseflow
     169             :   !>       \param[inout] "real(dp), dimension(:, :) :: infiltration"       Recharge, infiltration intensity or effective
     170             :   !>       precipitation of each horizon
     171             :   !>       \param[inout] "real(dp), dimension(:) :: fast_interflow"        Fast runoff component
     172             :   !>       \param[inout] "real(dp), dimension(:) :: melt"                  Melting snow depth
     173             :   !>       \param[inout] "real(dp), dimension(:) :: perc"                  Percolation
     174             :   !>       \param[inout] "real(dp), dimension(:) :: prec_effect"           Effective precipitation depth (snow melt +
     175             :   !>       rain)
     176             :   !>       \param[inout] "real(dp), dimension(:) :: rain"                  Rain precipitation depth
     177             :   !>       \param[inout] "real(dp), dimension(:) :: runoff_sealed"         Direct runoff from impervious areas
     178             :   !>       \param[inout] "real(dp), dimension(:) :: slow_interflow"        Slow runoff component
     179             :   !>       \param[inout] "real(dp), dimension(:) :: snow"                  Snow precipitation depth
     180             :   !>       \param[inout] "real(dp), dimension(:) :: throughfall"           Throughfall
     181             :   !>       \param[inout] "real(dp), dimension(:) :: total_runoff"          Generated runoff
     182             :   !>       \param[inout] "real(dp), dimension(:) :: alpha"                 Exponent for the upper reservoir
     183             :   !>       \param[inout] "real(dp), dimension(:) :: deg_day_incr"          Increase of the Degree-day factor per mm of
     184             :   !>       increase in precipitation
     185             :   !>       \param[inout] "real(dp), dimension(:) :: deg_day_max"           Maximum Degree-day factor
     186             :   !>       \param[inout] "real(dp), dimension(:) :: deg_day_noprec"        Degree-day factor with no precipitation
     187             :   !>       \param[inout] "real(dp), dimension(:) :: deg_day"               Degree-day factor
     188             :   !>       \param[inout] "real(dp), dimension(:) :: fAsp"                  [1]     PET correction for Aspect at level 1
     189             :   !>       \param[inout] "real(dp), dimension(:) :: petLAIcorFactorL1"     PET correction factor based on LAI at level 1
     190             :   !>       \param[inout] "real(dp), dimension(:) :: HarSamCoeff"           [1]     PET Hargreaves Samani coefficient at
     191             :   !>       level 1
     192             :   !>       \param[inout] "real(dp), dimension(:) :: PrieTayAlpha"          [1]     PET Priestley Taylor coefficient at
     193             :   !>       level 1
     194             :   !>       \param[inout] "real(dp), dimension(:) :: aeroResist"            [s m-1] PET aerodynamical resitance at level
     195             :   !>       1
     196             :   !>       \param[inout] "real(dp), dimension(:) :: surfResist"            [s m-1] PET bulk surface resitance at level 1
     197             :   !>       \param[inout] "real(dp), dimension(:, :) :: frac_roots"         Fraction of Roots in soil horizon
     198             :   !>       \param[inout] "real(dp), dimension(:) :: interc_max"            Maximum interception
     199             :   !>       \param[inout] "real(dp), dimension(:) :: karst_loss"            Karstic percolation loss
     200             :   !>       \param[inout] "real(dp), dimension(:) :: k0"                    Recession coefficient of the upper reservoir,
     201             :   !>       upper outlet
     202             :   !>       \param[inout] "real(dp), dimension(:) :: k1"                    Recession coefficient of the upper reservoir,
     203             :   !>       lower outlet
     204             :   !>       \param[inout] "real(dp), dimension(:) :: k2"                    Baseflow recession coefficient
     205             :   !>       \param[inout] "real(dp), dimension(:) :: kp"                    Percolation coefficient
     206             :   !>       \param[inout] "real(dp), dimension(:, :) :: soil_moist_FC"      Soil moisture below which actual ET is
     207             :   !>       reduced
     208             :   !>       \param[inout] "real(dp), dimension(:, :) :: soil_moist_sat"     Saturation soil moisture for each horizon
     209             :   !>       [mm]
     210             :   !>       \param[inout] "real(dp), dimension(:, :) :: soil_moist_exponen" Exponential parameter to how non-linear is
     211             :   !>       the soil water retention
     212             :   !>       \param[inout] "real(dp), dimension(:) :: jarvis_thresh_c1"      jarvis critical value for normalized soil
     213             :   !>       water content
     214             :   !>       \param[inout] "real(dp), dimension(:) :: temp_thresh"           Threshold temperature for snow/rain
     215             :   !>       \param[inout] "real(dp), dimension(:) :: unsat_thresh"          Threshold water depth in upper reservoir
     216             :   !>       \param[inout] "real(dp), dimension(:) :: water_thresh_sealed"   Threshold water depth in impervious areas
     217             :   !>       \param[inout] "real(dp), dimension(:, :) :: wilting_point"      Permanent wilting point for each horizon
     218             :   !
     219             :   !>       \param[inout] "real(dp), dimension(:) :: No_count"
     220             :   !>       \param[inout] "real(dp), dimension(:) :: bulkDens"
     221             :   !>       \param[inout] "real(dp), dimension(:) :: latticeWater"
     222             :   !>       \param[inout] "real(dp), dimension(:, :) :: COSMICL3"
     223             : 
     224             : 
     225             :   !    HISTORY
     226             :   !>       \authors Luis Samaniego & Rohini Kumar
     227             : 
     228             :   !>       \date Dec 2012
     229     2020272 :   subroutine mHM(read_states, tt, time, processMatrix, horizon_depth, nCells1, nHorizons_mHM, &
     230     4040544 :                 c2TSTu, neutron_integral_AFast, &
     231     4040544 :                 evap_coeff, &
     232     2020272 :                 fSealed1, interc, snowpack, &
     233     4040544 :                 sealedStorage, soilMoisture, unsatStorage, satStorage, neutrons, &
     234     2020272 :                 pet_calc, temp_calc, prec_calc, &
     235     2020272 :                 aet_soil, aet_canopy, &
     236     8081088 :                 aet_sealed, baseflow, infiltration, fast_interflow, melt, perc, prec_effect, rain, runoff_sealed, &
     237     8081088 :                 slow_interflow, snow, throughfall, total_runoff, &
     238     2020272 :                 alpha, deg_day_incr, deg_day_max, deg_day_noprec, &
     239     2020272 :                 deg_day, frac_roots, &
     240     8081088 :                 interc_max, karst_loss, k0, k1, k2, kp, soil_moist_FC, soil_moist_sat, soil_moist_exponen, &
     241     8081088 :                 jarvis_thresh_c1, temp_thresh, unsat_thresh, water_thresh_sealed, wilting_point, &
     242     4040544 :                 No_count, bulkDens, latticeWater, COSMICL3)
     243             : 
     244             :     use mo_julian, only : dec2date
     245             :     use mo_canopy_interc, only : canopy_interc
     246             :     use mo_neutrons, only : COSMIC, DesiletsN0
     247             :     use mo_runoff, only : L1_total_runoff, runoff_sat_zone, runoff_unsat_zone
     248             :     use mo_snow_accum_melt, only : snow_accum_melt
     249             :     use mo_soil_moisture, only : soil_moisture
     250             : 
     251             :     implicit none
     252             : 
     253             :     !> indicated whether states have been read from file
     254             :     logical, intent(in) :: read_states
     255             : 
     256             :     !> simulation time step
     257             :     integer(i4), intent(in) :: tt
     258             : 
     259             :     !> current decimal Julian day
     260             :     real(dp), intent(in) :: time
     261             : 
     262             :     !> mHM process configuration matrix
     263             :     integer(i4), dimension(:, :), intent(in) :: processMatrix
     264             : 
     265             :     !> Depth of each horizon in mHM
     266             :     real(dp), dimension(:), intent(in) :: horizon_depth
     267             : 
     268             :     !> number of cells in a given domain at level L1
     269             :     integer(i4), intent(in) :: nCells1
     270             : 
     271             :     !> Number of Horizons in mHM
     272             :     integer(i4), intent(in) :: nHorizons_mHM
     273             : 
     274             :     !> unit conversion
     275             :     real(dp), intent(in) :: c2TSTu
     276             : 
     277             :     !> tabular for neutron flux approximation
     278             :     real(dp), dimension(:), intent(in) :: neutron_integral_AFast
     279             : 
     280             :     !> Evaporation coefficent for free-water surface of that current month
     281             :     real(dp), dimension(:), intent(in) :: evap_coeff
     282             : 
     283             :     !> fraction of sealed area at scale L1
     284             :     real(dp), dimension(:), intent(in) :: fSealed1
     285             : 
     286             :     !> Interception
     287             :     real(dp), dimension(:), intent(inout) :: interc
     288             : 
     289             :     !> Snowpack
     290             :     real(dp), dimension(:), intent(inout) :: snowpack
     291             : 
     292             :     !> Retention storage of impervious areas
     293             :     real(dp), dimension(:), intent(inout) :: sealedStorage
     294             : 
     295             :     !> Soil moisture of each horizon
     296             :     real(dp), dimension(:, :), intent(inout) :: soilMoisture
     297             : 
     298             :     !> Upper soil storage
     299             :     real(dp), dimension(:), intent(inout) :: unsatStorage
     300             : 
     301             :     !> Groundwater storage
     302             :     real(dp), dimension(:), intent(inout) :: satStorage
     303             : 
     304             :     !> Ground albedo neutrons
     305             :     real(dp), dimension(:), intent(inout) :: neutrons
     306             : 
     307             :     !> [mm TS-1] estimated PET (if PET is input = corrected values (fAsp*PET))
     308             :     real(dp), dimension(:), intent(inout) :: pet_calc
     309             : 
     310             :     !> [degC] temperature for current time step
     311             :     real(dp), dimension(:), intent(inout) :: temp_calc
     312             : 
     313             :     !> [mm TS-1] precipitation for current time step
     314             :     real(dp), dimension(:), intent(inout) :: prec_calc
     315             : 
     316             :     !> actual ET
     317             :     real(dp), dimension(:, :), intent(inout) :: aet_soil
     318             : 
     319             :     !> Real evaporation intensity from canopy
     320             :     real(dp), dimension(:), intent(inout) :: aet_canopy
     321             : 
     322             :     !> Actual ET from free-water surfaces
     323             :     real(dp), dimension(:), intent(inout) :: aet_sealed
     324             : 
     325             :     !> Baseflow
     326             :     real(dp), dimension(:), intent(inout) :: baseflow
     327             : 
     328             :     !> Recharge, infiltration intensity or effective precipitation of each horizon
     329             :     real(dp), dimension(:, :), intent(inout) :: infiltration
     330             : 
     331             :     !> Fast runoff component
     332             :     real(dp), dimension(:), intent(inout) :: fast_interflow
     333             : 
     334             :     !> Melting snow depth
     335             :     real(dp), dimension(:), intent(inout) :: melt
     336             : 
     337             :     !> Percolation
     338             :     real(dp), dimension(:), intent(inout) :: perc
     339             : 
     340             :     !> Effective precipitation depth (snow melt + rain)
     341             :     real(dp), dimension(:), intent(inout) :: prec_effect
     342             : 
     343             :     !> Rain precipitation depth
     344             :     real(dp), dimension(:), intent(inout) :: rain
     345             : 
     346             :     !> Direct runoff from impervious areas
     347             :     real(dp), dimension(:), intent(inout) :: runoff_sealed
     348             : 
     349             :     !> Slow runoff component
     350             :     real(dp), dimension(:), intent(inout) :: slow_interflow
     351             : 
     352             :     !> Snow precipitation depth
     353             :     real(dp), dimension(:), intent(inout) :: snow
     354             : 
     355             :     !> Throughfall
     356             :     real(dp), dimension(:), intent(inout) :: throughfall
     357             : 
     358             :     !> Generated runoff
     359             :     real(dp), dimension(:), intent(inout) :: total_runoff
     360             : 
     361             :     !> Exponent for the upper reservoir
     362             :     real(dp), dimension(:), intent(inout) :: alpha
     363             : 
     364             :     !> Increase of the Degree-day factor per mm of increase in precipitation
     365             :     real(dp), dimension(:), intent(inout) :: deg_day_incr
     366             : 
     367             :     !> Maximum Degree-day factor
     368             :     real(dp), dimension(:), intent(inout) :: deg_day_max
     369             : 
     370             :     !> Degree-day factor with no precipitation
     371             :     real(dp), dimension(:), intent(inout) :: deg_day_noprec
     372             : 
     373             :     !> Degree-day factor
     374             :     real(dp), dimension(:), intent(inout) :: deg_day
     375             : 
     376             :     !> Fraction of Roots in soil horizon
     377             :     real(dp), dimension(:, :), intent(inout) :: frac_roots
     378             : 
     379             :     !> Maximum interception
     380             :     real(dp), dimension(:), intent(inout) :: interc_max
     381             : 
     382             :     !> Karstic percolation loss
     383             :     real(dp), dimension(:), intent(inout) :: karst_loss
     384             : 
     385             :     !> Recession coefficient of the upper reservoir, upper outlet
     386             :     real(dp), dimension(:), intent(inout) :: k0
     387             : 
     388             :     !> Recession coefficient of the upper reservoir, lower outlet
     389             :     real(dp), dimension(:), intent(inout) :: k1
     390             : 
     391             :     !> Baseflow recession coefficient
     392             :     real(dp), dimension(:), intent(inout) :: k2
     393             : 
     394             :     !> Percolation coefficient
     395             :     real(dp), dimension(:), intent(inout) :: kp
     396             : 
     397             :     !> Soil moisture below which actual ET is reduced
     398             :     real(dp), dimension(:, :), intent(inout) :: soil_moist_FC
     399             : 
     400             :     !> Saturation soil moisture for each horizon [mm]
     401             :     real(dp), dimension(:, :), intent(inout) :: soil_moist_sat
     402             : 
     403             :     !> Exponential parameter to how non-linear is the soil water retention
     404             :     real(dp), dimension(:, :), intent(inout) :: soil_moist_exponen
     405             : 
     406             :     !> jarvis critical value for normalized soil water content
     407             :     real(dp), dimension(:), intent(inout) :: jarvis_thresh_c1
     408             : 
     409             :     !> Threshold temperature for snow/rain
     410             :     real(dp), dimension(:), intent(inout) :: temp_thresh
     411             : 
     412             :     !> Threshold water depth in upper reservoir
     413             :     real(dp), dimension(:), intent(inout) :: unsat_thresh
     414             : 
     415             :     !> Threshold water depth in impervious areas
     416             :     real(dp), dimension(:), intent(inout) :: water_thresh_sealed
     417             : 
     418             :     !> Permanent wilting point for each horizon
     419             :     real(dp), dimension(:, :), intent(inout) :: wilting_point
     420             : 
     421             :     ! neutron count
     422             :     real(dp), dimension(:), intent(inout)   ::  No_count
     423             :     real(dp), dimension(:,:), intent(inout) ::  bulkDens
     424             :     real(dp), dimension(:,:), intent(inout) ::  latticeWater
     425             :     real(dp), dimension(:,:), intent(inout) ::  COSMICL3
     426             : 
     427             : 
     428             :     ! Month of current day [1-12]
     429             :     integer(i4) :: month
     430             :     ! cell index
     431             :     integer(i4) :: k
     432             : 
     433     6060816 :     real(dp), dimension(size(infiltration, 2)) :: tmp_infiltration
     434     8081088 :     real(dp), dimension(size(soilMoisture, 2)) :: tmp_soilMoisture
     435     8081088 :     real(dp), dimension(size(aet_soil, 2)) :: tmp_aet_soil
     436             : 
     437             :     !-------------------------------------------------------------------
     438             :     ! date and month of this timestep
     439             :     !-------------------------------------------------------------------
     440     2020272 :     call dec2date(time, mm = month)
     441             : 
     442             :     !-------------------------------------------------------------------
     443             :     ! Update the inital states of soil water content for the first time
     444             :     ! step and when perform_mpr = FALSE
     445             :     ! based on the half of the derived values of Field capacity
     446             :     ! other states are kept at their inital values
     447             :     !-------------------------------------------------------------------
     448     2020272 :     if((tt .EQ. 1) .AND. (.not. read_states)) then
     449        6972 :       soilMoisture(:, :) = 0.5_dp * soil_moist_FC(:, :)
     450             :     end if
     451             : 
     452             :     !-------------------------------------------------------------------
     453             :     ! HYDROLOGICAL PROCESSES at L1-LEVEL
     454             :     !-------------------------------------------------------------------
     455             :     !$OMP parallel default(shared) &
     456             :     !$OMP private(k, tmp_soilmoisture, tmp_infiltration, tmp_aet_soil)
     457             :     !$OMP do SCHEDULE(STATIC)
     458    78667320 :     do k = 1, nCells1
     459             : 
     460    76647048 :       call canopy_interc(pet_calc(k), interc_max(k), prec_calc(k), & ! Intent IN
     461    76647048 :               interc(k), & ! Intent INOUT
     462   153294096 :               throughfall(k), aet_canopy(k))                                                      ! Intent OUT
     463    76647048 :       call snow_accum_melt(deg_day_incr(k), deg_day_max(k) * c2TSTu, & ! Intent IN
     464    76647048 :               deg_day_noprec(k) * c2TSTu, prec_calc(k), temp_calc(k), temp_thresh(k), throughfall(k), & ! Intent IN
     465    76647048 :               snowpack(k), & ! Intent INOUT
     466    76647048 :               deg_day(k), & ! Intent OUT
     467   153294096 :               melt(k), prec_effect(k), rain(k), snow(k))                                          ! Intent OUT
     468             : 
     469   229941144 :       tmp_soilMoisture(:) = soilMoisture(k, :)
     470   229941144 :       tmp_infiltration(:) = infiltration(k, :)
     471             : 
     472    76647048 :       call soil_moisture(processMatrix(3, 1), & ! Intent IN
     473    76647048 :               fSealed1(k), water_thresh_sealed(k), & ! Intent IN
     474    76647048 :               pet_calc(k), evap_coeff(month), soil_moist_sat(k, :), frac_roots(k, :), & ! Intent IN
     475             :               soil_moist_FC(k, :), wilting_point(k, :), soil_moist_exponen(k, :), & ! Intent IN
     476           0 :               jarvis_thresh_c1(k), aet_canopy(k), & ! Intent IN
     477    76647048 :               prec_effect(k), runoff_sealed(k), sealedStorage(k), & ! Intent INOUT
     478             :               tmp_infiltration(:), tmp_soilMoisture(:), & ! Intent INOUT
     479   229941144 :               tmp_aet_soil(:), aet_sealed(k))                                                     ! Intent OUT
     480             : 
     481   229941144 :       infiltration(k, :) = tmp_infiltration(:)
     482   229941144 :       soilMoisture(k, :) = tmp_soilMoisture(:)
     483   229941144 :       aet_soil(k, :) = tmp_aet_soil(:)
     484   153294096 :       call runoff_unsat_zone(c2TSTu / k1(k), c2TSTu / kp(k), c2TSTu / k0(k), alpha(k), karst_loss(k), & ! Intent IN
     485    76647048 :               infiltration(k, nHorizons_mHM), unsat_thresh(k), & ! Intent IN
     486    76647048 :               satStorage(k), unsatStorage(k), & ! Intent INOUT
     487   229941144 :               slow_interflow(k), fast_interflow(k), perc(k))                                      ! Intent OUT
     488    76647048 :       call runoff_sat_zone(c2TSTu / k2(k), & ! Intent IN
     489             :               satStorage(k), & ! Intent INOUT
     490    76647048 :               baseflow(k))                                                                        ! Intent OUT
     491             :       call L1_total_runoff(fSealed1(k), fast_interflow(k), slow_interflow(k), baseflow(k), & ! Intent IN
     492             :               runoff_sealed(k), & ! Intent IN
     493    76647048 :               total_runoff(k))                                                                    ! Intent OUT
     494             : 
     495             :       !-------------------------------------------------------------------
     496             :       ! Nested model: Neutrons state variable, related to soil moisture
     497             :       ! >> NOTE THAT SINCE LAST mHM layer is variable iFlag_soilDB = 0
     498             :       !    the neuton count is estimated only upto nHorizons_mHM-1
     499             :       !    set your horizon depth accordingly
     500             :       !-------------------------------------------------------------------
     501             :       ! DESLET
     502    76647048 :       if ( processMatrix(10, 1) .EQ. 1 ) &
     503     8570016 :            call DesiletsN0( soilMoisture(k,1:nHorizons_mHM-1),& ! Intent IN
     504     8570016 :            horizon_depth(1:nHorizons_mHM-1),                  & ! Intent IN
     505     8570016 :            bulkDens(k,1:nHorizons_mHM-1),                     & ! Intent IN
     506     8570016 :            latticeWater(k,1:nHorizons_mHM-1), No_count(k),    & ! Intent IN
     507    42850080 :            neutrons(k) )                                        ! Intent INOUT
     508             : 
     509             :       ! COSMIC
     510    76647048 :       if ( processMatrix(10, 1) .EQ. 2 ) &
     511           0 :            call COSMIC( soilMoisture(k,1:nHorizons_mHM-1), horizon_depth(1:nHorizons_mHM-1),&
     512             :            neutron_integral_AFast(:),                                         &  ! Intent IN
     513             :            interc(k), snowpack(k),                                            &  ! Intent IN
     514           0 :            No_count(k), bulkDens(k,1:nHorizons_mHM-1),                        &  ! Intent IN
     515           0 :            latticeWater(k,1:nHorizons_mHM-1), COSMICL3(k,1:nHorizons_mHM-1),  &  ! Intent IN
     516   155314368 :            neutrons(k)  )                                                        ! Intent INOUT
     517             :    end do
     518             :    !$OMP end do
     519             :    !$OMP end parallel
     520             : 
     521     2020272 :   end subroutine mHM
     522             : 
     523             : END MODULE mo_mHM

Generated by: LCOV version 1.16